Common Lisp Package: COM.INFORMATIMAGO.COMMON-LISP.HTTP.HTRANS

A simple "transaction" manager for CGI. html-client transac-manager cgi | | | | | / |--------(initial-request)------->| / | |-----initialrequest(sessid)----->| | | | | |<------reply(sessid,trid)--------| |<-------(html-form)--------------| / | / | | / |----------(action.get)---------->| / | |----request(sesid,trid,data)---->| | | | | |<------reply(sessid,trid+1)------| |<-------(html-form)--------------| / | / | | | | V V V In this implementation transac-manager and cgi are linked together in the CGI process and this CGI process lives from the HTML request to the response. License: AGPL3 Copyright Pascal J. Bourguignon 2003 - 2012 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>

README:

FUNCTION

Public

GETCMDS (TRANS-DATA)

RETURN: A list of commands appearing in TRANS-DATA. NOTE: Normaly, only one command is present. But if the GET url is hacked, zero or multiple commands may be present.

Private

ADDRESS-IN-SUBNETS-P (ADDRESS SUBNETS)

ADDRESS: A string containing an IP address. SUBNETS: A list of (''address'' ''mask'') identifying the subnets. RETURN: Whether ADDRESS is on some of the SUBNETS.

PREFIXP (PREFIX STRING &KEY (START 0) (END NIL) (TEST #'CHAR=))

PREFIX: A sequence. STRING: A sequence. START: The start of the substring of STRING to consider. Default: 0. END: The end of the substring of STRING to consider. Default: NIL. TEST: A function to compare the elements of the strings. RETURN: Whether PREFIX is a prefix of the (substring STRING START END).

SPLIT-STRING (STRING &OPTIONAL (SEPARATORS ) (REMOVE-EMPTY NIL))

STRING: A sequence. SEPARATOR: A sequence. RETURN: A list of subsequence of STRING, split upon any element of SEPARATORS. Separators are compared to elements of the STRING with EQL. NOTE: It's actually a simple split-sequence now. EXAMPLES: (split-string '(1 2 0 3 4 5 0 6 7 8 0 9) '(0)) --> ((1 2) (3 4 5) (6 7 8) (9)) (split-string #(1 2 0 3 4 5 0 6 7 8 0 9) #(0)) --> (#(1 2) #(3 4 5) #(6 7 8) #(9)) (split-string "1 2 0 3 4 5 0 6 7 8" '(#space #0)) --> ("1" "2" "" "" "3" "4" "5" "" "" "6" "7" "8")

UNIX-ENVIRONMENT-GET (ENVIRONMENT NAME)

RETURN: The value of the unix environment variable named NAME.

Undocumented

ADDRESS-IN-LAN-P (IP-STRING LAN-ADDRESS LAN-MASK)

BYTEP (THING)

GENERATE-COMMAND-BUTTONS (COMMANDS)

GENERATE-MENU (NAME ITEMS)

GENERATE-MENU-ITEMS (ITEMS)

IP-STRING-TO-ADDRESS (IP-ADDRESS)

KMAXLENGTH (TYPE)

KSIZE (TYPE)

KTYPE (TYPE)

GENERIC-FUNCTION

Public

GENERATE-HTML-HEADER (SELF SESSION-ID)

A hook allowing the hprogram to display a header. It should not generate a form with the same action!

PROCESS-REQUEST (SELF SESSION-ID TRANS-ID TRANS-DATA)

A call-back function (hprogram session-id trans-id data) that will be called with the decoded request.

PROCESS-TRANSACTION (HTP)

DO: Parses the CGI request and calls the REQUEST function passing it the session-id, transaction-id and request data. For the initial request, transaction-id and request data will be NIL. NOTE: Begins by outputing the HTML header and ends with the HTML footer.

REFUSE-REMOTE (SELF SESSION-ID REMOTE-IP)

A call-back function called to display a message indicating that the remote was refused access for it's IP address.

REFUSE-SESSION (SELF SESSION-ID)

A call-back function called to display a message indicating that the session-id is bad.

SEND-REPLY (HTP SESSION-ID TRANSAC-ID TITLE DATA COMMANDS)

DO: Sends a reply page.

SEND-TABLE (HTP SESSION-ID TRANSAC-ID TITLE ROW-DESC DATA COMMANDS)

DO: Sends a table.

Private

Undocumented

CHECK-SESSION-ID (PROGRAM SESSION-ID IP-STRING)

MAKE-SESSION-ID (PROGRAM IP-STRING)

SLOT-ACCESSOR

Public

ACTION (PROGRAM)

The A string naming the action used in the HTML forms.

SETFACTION (NEW-VALUE OBJECT)

Set the A string naming the action used in the HTML forms.

ALLOWED-NETS (PROGRAM)

The A list of (ip-address ip-mask).

SETFALLOWED-NETS (NEW-VALUE OBJECT)

Set the A list of (ip-address ip-mask).

ARGUMENTS (PROGRAM)

The A list of command-line arguments.

SETFARGUMENTS (NEW-VALUE OBJECT)

Set the A list of command-line arguments.

BODY-ATTRIBUTES (PROGRAM)

The A list containing the HTML:BODY attributes.

SETFBODY-ATTRIBUTES (NEW-VALUE OBJECT)

Set the A list containing the HTML:BODY attributes.

ENVIRONMENT (PROGRAM)

The An a-list of unix environment variables: (var . value)*

SETFENVIRONMENT (NEW-VALUE OBJECT)

Set the An a-list of unix environment variables: (var . value)*

REFUSED-NETS (PROGRAM)

The A list of (ip-address ip-mask).

SETFREFUSED-NETS (NEW-VALUE OBJECT)

Set the A list of (ip-address ip-mask).

TITLE (PROGRAM)

The A string used as page title.

SETFTITLE (NEW-VALUE OBJECT)

Set the A string used as page title.

VARIABLE

Private

+COMMAND-PREFIX+

A prefix used for the INPUT names.

Undocumented

*SESSION-COUNTER*

+CRLF+

CLASS

Public

HPROGRAM

An abstract class of a HTML Transaction Program. This is the interface used by the HTRANS package to communicate with it.