PasHyPer is a Pascal Hypertext Preprocessor.
The preprocessor works reading a HTML page and finding for pascal programs into this page.
On found a pascal program, the preprocessor compiles and run the script. All this is made in side server.
Pascal is a very popular programming language because it´s clean, easy and readable. Why pascal is out of web as script language? I don´t know! If you like pascal, join us. Help us to build a Pascal Hypertext Preprocessor.
PasHyPer was compiled with FPC - FreePascal Compiler.
PasHyPer supports a subset of standard pascal and is missing several wanted improvements.
Reserved Words are the same of standard pascal, but not yet supports set, downto, array, record, type and
signs as [].
PasHyPer supports the types integer, real, string, boolean and char.
The string type
is a pointer to bytes managed by itself PasHyPer. The size of string is 1024 bytes for now. May be the max size of a
WORD.
PasHyPer can run a enough set of functions and procedures of standard pascal and some functions to connection with
MySQL database.
PasHyPer have a unique cgi function (cgi_getenv) that retrieves all the values of pages server.
PasHyPer manage uploads files, but need the programmer to pointer the directory of uploaded files with chdir procedure.
The size of uploaded files is limited to space in disk or space quote.
PasHyPer not yet with work typed files. Only text files is available for read/write.
PasHyPer not writes to files. This is a decision not a limitation (except downloaded files).
PasHyPer just supports comments in Borland way ({comment...}) and slashes (//comment).
PasHyPer supports just two directive (for now): $INCLUDE and $DEFINE.
PasHyPer file include is limited to 36KB for now. Because this limit, you must write small libraries. This turns PasHyPer faster and usefull with economic memory.
PasHyPer chdir procedure is virtual. It changes to a directory into directory root declared into pashyper.ini (see config file bellow). If you declare as directory root in pashyper.ini the string /home/carlos/pashyper/site01 and changes the directory with chdir to /home/carlos/pashyper/anotherdirectory will generate a error. The same with assign a file. So, if you must refere to file or directory into think root directory as "/". An alias can override the path to directory root.
PasHyPer handle date like FPC and Delphi/Kylix: it's a real value. The time part of datetime type is not implemented. This is the fractional part of a real. The date values may be different of FPC/Delphi values.
PasHyPer, for now, don't have a module to Apache. But some integration may be using the file httpd.conf. To do this, you need put into file httpd.conf four lines:
ScriptAlias /pas/ "<pashyper directory>" (ex: "c:/pashyper/")
If you not yet setup the CGI directory, then put the following lines into httpd.conf:
AddType application/x-httpd-pas .pas .pp
AddHandler application/x-httpd-pas .pas .pp
Action application/x-httpd-pas "/pas/pashyper[.exe]"
<Directory "pashyperdirectory">
AllowOverride All
Options ExecCGI FollowSymlinks Includes
Order allow,deny
Allow from all
Require All Granted
</Directory>
You need find CGI directory in httpd.conf file and replace it with lines below.
PasHyPer, for now, don't have module to IIS. To integrate PasHyPer with IIS, take the steps in IIS manager interface:
appcmd set config /section:handlers /+[name='pascal_script',path='*.pp',verb='GET,HEAD,POST',scriptProcessor='"C:\path\pashyper.exe"', modules='CgiModule', resourceType='Either'];
appcmd set config /section:handlers /accessPolicy:Read,Script,Execute
The pashyper.ini file must be placed into PasHyPer directory. If you use MySQL, you must write the config file.
The pashyper.ini is a plain text file, with sections, keys and values, in format:
[section]
key=value
# Line commented is started by a "#" or a ";"
The sections possible for now are root, aliases and mysql. The keys are: directory, in root section
to indicate a directory as "/" directory; path in mysql section to indicate mysql client library path (without file name);
lib in mysql section to pointer to mysql client library file (just the file name).
In aliases section you can put aliases that will be replaced by the indicated value. For example, if you put into file healthplan01=/home/mydocs/health/plans/01/page.htm, when PasHyPer found healthplan01 as parameter to filename* it will replace by the indicated value. For now, just full string is translated (i.e., no compare is made with substring). The aliases, for now, overrides the root directory declared into root section. To disable the aliases (global processor), write in root section ignorealiases=yes (1, si, sim, true)
Example:
[root]
directory=/home/carlos/programming/pashyper/
charset=iso8859-1
uploaded=/home/carlos/programming/pashyper/uploaded
sessions=/home/carlos/programming/pashyper/sessions
tempdir=/home/carlos/programming/pashyper/temp
;logfile=/home/carlos/programming/pashyper/temp/logs.txt
[mysql]
path=/usr/lib/
lib=libmysqlclient.so
[aliases]
#overrides path
readme=/home/carlos/programming/HTML/pashyper/readme.htm*
* The parameter filename is used in following way:
http://www.mydom.com/cgi-bin/pashyper?filename=name_of_myfile&anotherparam=...
to indicate to pashyper how file it process. The extension assumed as default is .htm, but the file may be a image, a video, a
text, etc. In this case you must indicate the file extension (pashyper selects media type based on file extension). PasHyPer
accept wildcards in aliases section. If you write kc*=c:\pashyper\site01\index.htm, all word that start with kc in filename parameter will translated to
c:\pashyper\site01\index.htm.
PasHyPer need debugging all internal functions, procedures and operators. This is made with little codes for each case.
PasHyPer need little libraries that provides facilities to programmer. This is made using the $include clause.
a) utf-8 routines to writes output and read input.
b) url encode and decode routines don't works properly in linux. AllocMem may be crashes when running under linux. Trying don't use ansistring but pchar.
c) md5 and base64 encrypt routines to work natively.
d) images and other binary files can be served by PasHyPer. But if you use pashyper to output very images per page, the performance is down. For now, references as http://.../pashyper?filename=<a_image_file> must be not used or skippep.
d) ssl security is not implemented.
e) implement support to arrays and pointers.
f) case not supports construction as case myfunc(parameters) of. The construction for now is case variable of.
A script is a program. So, as in pascal standard, you need write a program to PasHyPer recognize it as a script. Into html files, PasHyPer will recognize just code fragment placed into tags <pas> and </pas>. Example:
<pas>
writeln(anything);
</pas>
But, if you need use variables, you will write this fragments as a procedure, declaring variables and a code block, as in:
<pas>
var i:integer;
begin
for i:=1 to 1000 do write('XX ');
end;
</pas>
For now, you cannot write pascal tags into html tags as in:
<input ... <pas> ... </pas> ... />.
You can write several procedures and functions into script section:
<script type="text/pascal">
procedure abba;
begin
...
end;
procedure baab;
begin
...
end;
function faaf:integer;
begin
...
end;
function affa:boolean;
begin
...
end;
{$include somefilepascal.inc}
//you can call this functions and procedures into body of html.
</script>
For build calling of functions and procedure, PasHyPer work only as a script, it not work as code peace into html file. So, the logical structure of a program is the logical structure of a program:
program dosomething;
var i:integer;
{$include someincludefile}
function foo_bar(s:string):boolean;
begin
foo_bar:=length(s) > 0;
end;
procedure baboo(i:integer);
begin
writeln('<tr><td>', i, '</td></tr>');
end;
begin {program}
if foo_bar('***********') then
baboo(length('***********'));
writeln('<tr><td>', some thing, '</td></tr>');
end.
You can help this project if you like Pascal Language and know Pascal Language. You can debug it, write examples code, write documentation, translating text, coding short libraries, etc. Just if you know and like Pascal Language.
Pashyper presents the set of types, functions and procedures below, for now:
Type | Description |
---|---|
integer | Numeric type that receive a integer number. |
char | Character type that receive only a character. |
boolean | Logical type that receive special values TRUE or FALSE |
real | Numeric type that receive a point floating value. |
string | A chain of characters. You cannot access strings as an array of char. |
file | Handle a text file, for now. You cannot access typed file (see directives). |
array | Array declaration of any basic type, except file |
Procedure | Description |
---|---|
write | writes one or more values in output stream (without CRLF). |
writeln | writes one or more values in output stream (within CRLF). |
read | reads a value from input stream not staying CRLF. |
readln | reads a value from input stream staying CRLF. |
assign | assigns a name to a file handle. |
reset | open a file for read only. |
rewrite | creates a file for write. If file exists, it will be override. |
close | closes a opened file. |
delete | deletes a specified peace of a string. |
insert | inserts a specified string into another string. |
val | computes a value numeric that a string presents. |
exit | exits of a specified point of a procedure or function. |
inc | increments a integer number of a specified increment. If not specified the increment, it will 1. |
dec | decrements a integer number of a specified decrement. If not specified the decrement, it will 1. |
randomize | initializes the random number generator. |
str | puts in a variable of type string the representation of numeric value. |
chdir | changes the current directory to another specified. Work just into root directory of pashyper. |
runerror | simulates an error specified. NOT IMPLEMENTED. |
swap | swaps two values of two variables. NOT IMPLEMENTED. |
move | move a value of a variable to another variable. NOT IMPLEMENTED. |
getdate | returns current date into four variables: year, month, day and day of week. |
gettime | returns current time into three variables: hour, minutes, seconds. |
packtime | packs date and time into a variable real. TIME NOT IMPLEMENTED. |
unpacktime | unpacks a real value into six variables: year, month, day, hour, minutes and seconds. |
halt | stops the program at point where is called. |
cgi_header | writes a value in output stream (as writeln). Checks the presence of "content-type". |
sql_connect | connects mysql database server. |
sql_query | executes a query into mysql server and return the result. |
sql_free | releases the query result returned by sql_open. |
sql_close | closes the connection with mysql server. |
sql_next | move data pointer of a query result to next record. |
sql_exec | executes a query into mysql server that not return result. |
unloadlib | not util, yet. Unloads a dynamic library. |
cgi_session_set | assign a value to a field of current session. |
cgi_session_clear | clear current session. |
cgi_session_sql | save all current record of mysql into current session. |
gph_barcode | creates a bitmap file with a bar code determined. Supports 16 bar code types. |
Function | Description |
---|---|
eof | returns True if end of file was founded. |
ord | returns the ordinal value numeric of parameter. |
odd | returns True if the parameter is odd. |
trunc | returns a integer truncated value of parameter. |
pred | returns the predecessor of parameter. |
succ | returns the successor of parameter. |
chr | returns a character correspondent to parameter. |
copy | returns a substring of string parameter. |
length | returns the length of a string. |
pos | returns the position of a string into another. |
upcase | returns up case value of parameter. |
locase | returns low case value of parameter. |
abs | returns the absolute value of parameter. |
arctan | returns the arch witch tangent is the parameter. |
cos | returns the cosine of parameter. |
exp | returns the exponential of parameter. |
frac | returns the fractional part of a number. |
int | returns the integer part of a number. |
ln | returns the logarithm of parameter. |
power | returns the power of a number by another. |
random | returns a random number between 0 and parameter. |
round | returns the parameter rounded. |
sin | returns the sine of parameter. |
sqr | returns the square of a number. |
sqrt | returns the square root of a number. |
addr | returns the address of a variable. NOT IMPLEMENTED. |
offs | returns the offset of a variable. NOT IMPLEMENTED. |
sizeof | returns the size of a variable (type). NOT IMPLEMENTED |
getdir | returns the current directory. |
pi | returns pi (π) value. |
ioresult | returns last input/output error value. |
formatdate | returns a string that represents a date in a human comprehensive format. |
cgi_getenv | returns a value of environment variable. |
cgi_query | returns a value of a field of query_string |
cgi_cookie | returns a value of a cookie. |
cgi_md5_string | returns a value of md5 encrypt algorithm of a string |
cgi_md5_file | returns a value of md5 encrypt algorithm of a file |
cgi_sha1_string | returns a value of sha1 encrypt algorithm of a string |
cgi_sha1_buffer | returns a value of sha1 encrypt algorithm of a string |
cgi_sha1_file | returns a value of sha1 encrypt algorithm of a file |
sql_eof | returns True if the pointer to result of mysql reached end. |
sql_asint | returns the integer value of a field in data set of mysql. |
sql_asstr | returns the string value of a field in data set of mysql. |
sql_asbool | returns the boolean value of a field in data set of mysql. |
sql_asreal | returns the floating value of a field in data set of mysql. |
sql_astext | returns the long text value of a field in data set of mysql. |
sql_asdate | returns the date value of a field in data set of mysql. |
sql_datest | returns the date field value as a string value of a field in data set of mysql. |
sql_rows | returns the number of records into a data set of mysql. |
sql_escape | returns a string ready to be saved into mysql database. |
loadlib | Load a DLL - not implemented. |
cgi_session_get | returns the value of field session specified. |
cgi_temp_name | returns a temporary filename. The directory is the parameter. |
For now, PasHyPer supports just two directives:
When compiling and linking the PasHyPer preprocessor, you can turn on or off the following directives:
Directive | Affects |
---|---|
{$DEFINE PASCAL64} | if ON then the code must compiled and linked with Free Pascal 64 bits. |
{$DEFINE DTEQFPC} | if ON, the date values are equal fpc date values else it's Pashyper values. |
{$DEFINE USEMYSQL} | if ON, Pashyper load mysql library. |
{$DEFINE MYSQLOBJ} | if ON then will be used the unit mysql as object pascal (not procedural). |
{$DEFINE STRING256} | if ON, Pashyper will use strings with 256 characters of length. |
{$DEFINE TYPEDFILE} | if ON, typed file will be accessible. |
{$DEFINE FILEHANDLEW32} | if ON, pashyper modifies free pascal output handle. Works only on MS-Windows(1). |
{$DEFINE NOIOREDIRECT} | if ON, pashyper output not will be into a temporary file but directly to console(2). |
{$DEFINE USELOGS} | if ON, pashyper will produce log file about url accesses. |
{$DEFINE PT_DATENAMES} | if ON then names of date and double numbers will be converted to Portuguese of Brazil. |
{$DEFINE BIGWRITE} | if ON then pashyper will process all text HTML making a unique program. Very fast. |
{$DEFINE ADDRESSNOROT} | if ON then address manager routines will be ignored. |
{$DEFINE LISTLINKEDLIST} | if ON then will be used a linked list as TLIST; else will be used a TLIST KOL based. |
{$DEFINE USESMD5} | if ON then will be used MD5 algorithm of cryptography. |
{$DEFINE USESSHA1} | if ON then will be used SHA1 algorithm of cryptography. |
{$DEFINE CFG_OBJ} | if ON then will be used the unit of configuration files as object pascal (not procedural). |
{$DEFINE BARCODE} | if ON then will be used bar code module to creation of. |
For PASHYPER Internal Debug | |
{$DEFINE DBG_HP} | if ON, an internal debug is executed over preprocessor unit, writing a log file. |
{$DEFINE DBG_INT} | if ON then the compiler and interpreter will be debugged. |
{$DEFINE DBG_SCR} | if ON then the script manager will be debugged. |
{$DEFINE DBG_MAC} | if ON then the virtual machine will be debugged. |
{$DEFINE DBG_CMP} | if ON then the compiler will be debugged. |
{$DEFINE DBG_SES} | if ON, an internal debug is executed over session unit, writing a log file. |
{$DEFINE DBG_LIT} | if ON then the literal memory manager will be debugged. |
{$DEFINE DBG_URL} | if ON then the url converter will be debugged. |
{$DEFINE DBG_DTT} | if ON then the datetime manager will be debugged. |
{$DEFINE DBG_PIO} | if ON, an internal debug is executed over input/output unit, writing a log file. |
{$DEFINE DBG_SLF} | if ON, Pashyper starts GDB debug when running. Compile with -g option. |
{$DEFINE DBG_BWT} | if ON then the unit bigwriter will be debugged. |
{$DEFINE DBG_MD5} | if ON then the unit MD5 of cryptography will be debugged. |
{$DEFINE DBG_SHA} | if ON then unit SHA1 of cryptography will be debugged. |
{$DEFINE DBG_SEC} | if ON then unit of security will be debugged. |
{$DEFINE DBG_BAR} | if ON then unit of bar code will be debugged. |
{$DEFINE DBG_CNF} | if ON then unit of configuration file will be debugged. |
{$DEFINE DBG_SQL} | if ON then unit of database sql will be debugged. |
{$DEFINE DBG_HDR} | if ON then unit of cgi header will be debugged. |
{$DEFINE SIMULATEGET} | if ON, an execution of pashyper simulates a GET method. Parameters settings is in envar unit. |
© 2008 Carlos Alberto de Oliveira - carlosnatal@yahoo.com.br