# When running Aubit programs as CGI in web server, use A4GL_UI=CONSOLE
# $Id: libahtmllib.4gl,v 1.9 2009/08/19 18:00:46 fortiz Exp $
########################################################################
#ANSI C libraryes for CGI programing:
#
#own main()!!!!
#http://www.boutell.com/cgic/
#
#C, not free
#http://www.iexp.com/products/cgi-lib/
#
#cpp, free
#
#
#C, free
#http://www.newbreedsoftware.com/cgi-util/
#
#C, free
#http://www.eekim.com/software/cgihtml/
#
#c(?) simple, free
#http://www.csclub.uwaterloo.ca/~yhchan/download/qcgidoc.html
#
#W3C protocol library
#http://www.w3.org/Library/
#
#no main()
#http://www.geocities.com/SiliconValley/Bay/1927/yacgi.html
#
#http://kitsumi.xware.cx/xcgi/
#
#
#http://www.global-owl.de/ecgi/
#
#nice...
#http://catchen.org/gcgi/
########################################################################
###########
globals
###########
define
do_debug,
showpage
smallint,
item,
form_method
char(20),
HTTP_POST_VAR,
HTTP_GET_VAR
char(1000),
www record
GATEWAY_INTERFACE char (20),
SERVER_NAME char (60),
SERVER_SOFTWARE char (100),
SERVER_PROTOCOL char (20),
REQUEST_METHOD char (10),
QUERY_STRING char (300),
DOCUMENT_ROOT char (200),
HTTP_ACCEPT char (200),
HTTP_ACCEPT_CHARSET char (40),
HTTP_ACCEPT_ENCODING char (20),
HTTP_ACCEPT_LANGUAGE char (10),
HTTP_CONNECTION char (20),
HTTP_HOST char (200),
HTTP_REFERER char (600),
HTTP_USER_AGENT char (300),
REMOTE_ADDR char (20),
REMOTE_PORT char (10),
SCRIPT_FILENAME char (300),
SERVER_ADMIN char (100),
SERVER_PORT char (10),
SERVER_SIGNATURE char (100),
PATH_TRANSLATED char (300),
SCRIPT_NAME char (300),
REQUEST_URI char (600)
end record,
HTTPvar array [100] of record
vname char(20),
value char(60)
end record,
g_css char (40)
end globals
#==================== HTML Library ==========================
#######################
function html_init(cssfilename)
#######################
define
cssfilename char (40),
lv_debug, lv_do_debug varchar(3)
call html_headers()
display ""
let form_method="POST"
call get_webserver_vars()
if www.REQUEST_METHOD = "POST"
then
call getstdin()
end if
if www.REQUEST_METHOD = "POST"
then
call html_params(HTTP_POST_VAR)
else
call html_params(HTTP_GET_VAR)
end if
let lv_do_debug = vread("do_debug") clipped
if lv_do_debug = "on" then
let do_debug = true
end if
if lv_do_debug = "off" then
let do_debug = false
end if
let lv_debug = vread("debug") clipped
if lv_debug = "on" then
let do_debug = true
end if
if lv_debug = "off" then
let do_debug = false
end if
if do_debug
then
display "HTTP_POST_VAR=[",HTTP_POST_VAR clipped, "]"
display " HTTP_GET_VAR=[",HTTP_GET_VAR clipped,"]"
display " "
end if
if vread("g_css") <> "0" then
let g_css = vread("g_css")
let cssfilename = g_css
end if
if do_debug
then
call vreadall()
end if
call html_css(cssfilename)
end function
################################
function html_css(cssfilename)
################################
define
cssfilename, tmp_cssfilename char (40)
let tmp_cssfilename = vread("css")
{
display "xxx",tmp_cssfilename clipped,"xxx"
if vread("css") <> false
then
display "not false"
end if
if vread("css") <> "0"
then
display "not '0'"
end if
if vread("css") <> 0
then
display "not 0"
end if
}
if tmp_cssfilename <> '0'
# if vread("css") <> '0'
then
# let tmp_cssfilename = vread("css")
# display "xxx",tmp_cssfilename clipped,"xxx"
let cssfilename = tmp_cssfilename
let g_css = tmp_cssfilename
end if
if cssfilename <> "none" then
display " "
end if
end function
############################
function html_headers()
############################
#We cannot use DISPLAY for first line, because of bug (?) in Aubit that
#prints newline BEFORE it prints string, creating one empty line after program
#starts, so we heve to use this:
code
//printf("HTTP/1.1 200 OK");
//Pragma: no-cache
printf("Content-type: text/html\n\n");
endcode
return
{
if [ "$REQUEST_METHOD" = "HEAD" ]; then
echo HTTP/1.1 200 OK
echo Date: `date`
echo Server: $SERVER_SOFTWARE
echo Connection: close
echo Content-type: multipart/x-mixed-replace
echo
elif [ "$REQUEST_METHOD" = "GET" ]; then
echo HTTP/1.1 200 OK
echo Date: `date`
echo Server: $SERVER_SOFTWARE
echo Connection: close
exec $PATH_TO_WEBCAM $WEBCAM_OPTIONS
else
cat <405 Method Not Allowed
Method Not Allowed
The requested method $REQUEST_METHOD is not allowed for the URL $REQUEST_URI.
EOF
fi
print "Content-type: text/html\n\n";
}
{
display "HTTP/1.1 200 OK"
display "Date: Tue Oct 16 12:16:03 NZDT 2001"
display "Server: ",www.SERVER_SOFTWARE clipped
display "Connection: close"
#display "Content-type: multipart/x-mixed-replace"
}
#echo Content-type: text/plain
#HTTP/1.1 405 Method Not Allowed
#Allow: GET, HEAD
end function
###################################
function html_start_body()
###################################
#black falout.com scheme:
#display "
"
#light blue scheme fro Maximise "add user"
#display ""
#
display ""
end function
###################################
function html_end_body()
###################################
display ""
end function
###################################
function html_start_para()
###################################
display "
"
end function
###################################
function html_end_para()
###################################
display "
"
end function
###################################
function html_display_para(mytext)
###################################
#FIXME: why is "text" reserved word?
define mytext char (10000)
call html_start_para()
display mytext clipped
call html_end_para()
end function
###################################
function html_meta()
###################################
display ""
display ""
display ""
display ""
end function
###################################
function html_link(URL,target,mytext)
###################################
define
URL,mytext char (300),
target char(10)
display "",mytext clipped,""
end function
###################################
function html_head(page_title)
###################################
define page_title char (300)
display ""
display " "
call html_title(page_title)
call html_meta()
display ""
display " "
end function
###################################
function html_title(p_string)
###################################
define p_string char(512)
display "",p_string clipped,""
end function
###################################
function html_heading(p_string,p_level)
###################################
define p_string char(512)
define p_level integer
display "",p_string clipped,
""
end function
###################################
function html_hline()
###################################
display ""
end function
###################################
function html_image(URL,W,H)
###################################
define
URL char (200),
W,H integer
display ""
end function
###################################
function html_start_center()
###################################
display "
"
end function
###################################
function html_end_center()
###################################
display "
"
end function
###############################
function HTMLF_form_header()
###############################
# display ""
end function
###############################
function HTMLF_tableFrameStart()
###############################
display "
"
display "
"
display "
"
display "
"
display "
"
display "
"
display "
"
end function
###############################
function HTMLF_TableFrameEnd()
###############################
display "
"
display "
"
display "
"
display "
"
display "
"
display "
"
display "
"
end function
###################################
function HTMLF_countrylist()
###################################
display "
"
end function
#################################
function HTMLF_SubmitButton()
#################################
define
s1,s2,s3,s4,s5,s6,s7,s8,s9 char (200)
#4glc dums core on this one:
# display ""
#------------------------------------------------------------
#must be on one line?
display "
"
let s1 = ""
end function
function HTMLF_transferValue()
display ""
end function
#--------------------------- EOF --------------------------------