| |
| <h1><a name="toc">Table of contents</a></h1> |
| 0 |
| <a href="#over">overview</a><br> |
| - |
| <a href="#gene">general remarks</a><br> |
| 1 |
| <a href="#reqdatamgt">request data management</a><br> |
| - |
| <a href="#webp">web::param </a><br> |
| - |
| <a href="#webf">web::formvar </a><br> |
| 2 |
| <a href="#dispatch">command dispatching</a><br> |
| - |
| <a href="#webd">web::dispatch</a><br> |
| - |
| <a href="#webc">web::command</a><br> |
| - |
| <a href="#webg">web::getcommand</a><br> |
| - |
| <a href="#webcm">web::cmdurl</a><br> |
| - |
| <a href="#webcmd">web::cmdurlcfg</a><br> |
| 3 |
| <a href="#resp">response data management</a><br> |
| - |
| <a href="#webpu">web::put</a><br> |
| - |
| <a href="#webput">web::putx</a><br> |
| - |
| <a href="#webputx">web::putxfile</a><br> |
| - |
| <a href="#webr">web::response</a><br> |
| - |
| <a href="#Exam">Examples</a><br> |
| 4 |
| <a href="#cont">context management</a><br> |
| 5 |
| <a href="#file">file-based context</a><br> |
| 6 |
| <a href="#cook">cookie-based sessions</a><br> |
| 7 |
| <a href="#== conversion">uri-/html- en-/decoding</a><br> |
| 8 |
| <a href="#msg">inter-process/-system communication</a><br> |
| - |
| <a href="#webs">web::send</a><br> |
| - |
| <a href="#webre">web::recv</a><br> |
| - |
| <a href="#webm">web::msgflag</a><br> |
| 9 |
| <a href="#crypt">data encryption</a><br> |
| - |
| <a href="#webe">web::encrypt</a><br> |
| - |
| <a href="#webde">web::decrypt</a><br> |
| - |
| <a href="#encr">encryption plugIn D</a><br> |
| - |
| <a href="#weben">web::encryptd</a><br> |
| - |
| <a href="#webdec">web::decryptd</a><br> |
| - |
| <a href="#webcr">web::cryptdkey</a><br> |
| - |
| <a href="#encry">encryption plugIn interface </a><br> |
| 10 |
| <a href="#log">logging</a><br> |
| - |
| <a href="#webl">web::log</a><br> |
| - |
| <a href="#weblo">web::logfilter</a><br> |
| - |
| <a href="#weblog">web::logdest</a><br> |
| 11 |
| <a href="#logp">log plugins</a><br> |
| - |
| <a href="#file7">file</a><br> |
| - |
| <a href="#sysl">syslog</a><br> |
| - |
| <a href="#comm">command</a><br> |
| - |
| <a href="#chan">channel</a><br> |
| - |
| <a href="#aplo">aplog</a><br> |
| 12 |
| <a href="#cfg">configuration</a><br> |
| 13 |
| <a href="#misc">misc commands</a><br> |
| - |
| <a href="#webt">web::tempfile</a><br> |
| - |
| <a href="#webi">web::include</a><br> |
| - |
| <a href="#webrea">web::readfile</a><br> |
| - |
| <a href="#webfi">web::filecounter</a><br> |
| - |
| <a href="#webco">web::copyright</a><br> |
| - |
| <a href="#webge">web::getcgivar</a><br> |
| - |
| <a href="#webma">web::match</a><br> |
| - |
| <a href="#webloc">web::lockfile and web::unlockfile</a><br> |
| 14 |
| <a href="#Copy">Copyright</a><br> |
| |
| <h1><a name="over">overview</a></h1> |
| |
| The webshell Command Reference gives a brief description of all webshell |
| 3.0 commands. It is not intended to replace a technical reference of |
| webshell. It is organized along webshell 3 topics, in the following |
| order: |
| |
| <ul> |
| <li>request data management |
| <li>command dispatching |
| <li>response data management |
| <li>context management |
| <li>persistent contexts |
| <li>session management |
| <li>uri-/html- en-/decoding |
| <li>interprocess-/system-communication |
| <li>data encryption |
| <li>logging |
| </ul> |
| |
| webshell 3.0 embeds a Tcl 8.3 interpreter, and all Tcl 8.3 commands |
| are available, too. |
| |
| <h2><a name="gene">general remarks</a></h2> |
| |
| Typically, webshell commands have the following syntax: |
| <i>web::acommand ?options? ?subcommands ? ?arguments?</i>. |
| Options start with a dash ("-"). As usual, dash-dash ("--") indicates |
| the "end-of-options". Thus, <i>web::acommand -o1 a1 -- -o2</i> |
| takes "-o2" as the first argument. |
| |
| <br><br> |
| In difference to the normal "set" behaviour of tcl and webshell, |
| configuration commands of webshell normally return the previously |
| used value when a new value is set. |
| |
| <h1><a name="reqdatamgt">request data management</a></h1> |
| |
| <h2><a name="webp">web::param </a></h2> |
| |
| <dl> |
| <dt><b>syntax</b> |
| <dd> |
| <b>web::param</b> ?options? ?<key>? ?<value>?<br> |
| Options are: <tt>-count</tt>, <tt>-set</tt>, <tt>-lappend</tt>, and <tt>-unset</tt> |
| </dl> |
| |
| web::param is an accessor to state information from the querystring. |
| Suppose the querystring is "lang=EN". After web::dispatch has parsed the |
| querystring, <tt>web::param lang</tt> will report <tt>EN</tt>. Additionaly, |
| web::param can manage this data and add, append, and delete parameters as |
| needed. |
| |
| <dl> |
| <dt><b>web::param</b> |
| <dd> |
| returns a list of all known keys |
| <dt><b>web::param <key> ?<default>?</b> |
| <dd> |
| returns the value for <key>. Can be a list. In case |
| that <key> does not exist, return <default>, if it is |
| given, or an empty string. |
| <dt><b>web::param -count <key></b> |
| <dd> |
| returns number of items in list |
| <dt><b>web::param -set <key> <value></b> |
| <dd> |
| add the parameter <key> to the web::param data. |
| Any existing parameters with <key> are overwritten |
| <dt><b>web::param -lappend <key> <value></b> |
| <dd> |
| append parameters with the same <key> to the web::param data. In |
| this case the existing <value> is not overwritten |
| <dt><b>web::param -unset <key></b> |
| <dd> |
| delete a parameter from the web::param data |
| <dt><b>web::param -unset</b> |
| <dd> |
| delete all web::param data |
| </dl> |
| |
| <h2><a name="webf">web::formvar </a></h2> |
| |
| <dl> |
| <dt><b>syntax</b> |
| <dd> |
| <b>web::formvar</b> ?options? ?<key>? ?<value>?<br> |
| Exactly like <tt>web::param</tt> |
| </dl> |
| |
| web::formvar is an accessor to HTML <FORM> data. After web::dispatch has |
| parsed the POST data, you can access all form fields using web::formvar. |
| |
| <h1><a name="dispatch">command dispatching</a></h1> |
| |
| webshell provides a command dispatching mechanism to produce, for example, |
| different HTML pages within one application. The name of the command to be |
| used is encoded in the querystring (see <tt>web::cmdurl</tt> for details on how |
| to produce such querystrings). Command dispatching is initiated with the |
| command <tt>web::dispatch</tt>. Commands are defined with <tt>web::command</tt>. |
| |
| <h2><a name="webd">web::dispatch</a></h2> |
| |
| <dl> |
| <dt><b>syntax</b> |
| <dd> |
| <b>web::dispatch</b> ?options?<br> |
| Options are: <tt>-cmd</tt>, =%-querystring=%, <tt>-postdata</tt>, |
| <tt>-track</tt> and <tt>-hook</tt> |
| </dl> |
| |
| Parse information and call a command. |
| |
| <br><br> |
| <dl> |
| <dt><b>web::dispatch -cmd <cmdName></b> |
| <dd> |
| switch into command <cmdName>. If <cmdName> is an empty string, |
| no command is called. By default, <cmdName> is taken from |
| the querystring. |
| <dt><b>web::dispatch -querystring <string></b> |
| <dd> |
| parse <string> as querystring. If <string> is an empty string, |
| querystring parsing is turned off. By default, querystring is |
| taken from the request data (CGI environment or apache module |
| request object). |
| <dt><b>web::dispatch -postdata <string> ?<content_type>?</b> |
| <dd> |
| parse <string> as POST data input with type <content_type>. |
| <content_type> can be <tt>application/x-www-form-urlencoded</tt> or |
| <tt>multipart/form-data; boundary=xxx</tt>. In the second case, |
| <content-type> must specify the boundary as well. By default, |
| POST data is taken from the request data.<br> |
| If <string> is an empty string, postdata parsing is turned off. |
| <dt><b>web::dispatch -postdata <channelName> <content_type> <content_length></b> |
| <dd> |
| As above, but reads the POST data from channel <channelName>. |
| <dt><b>web::dispatch -track <paramKeyList></b> |
| <dd> |
| Track a parameter: register it as "static" for the generation of |
| URLs with web::cmdurl. Thus, each parameter with the key in |
| <paramKeyList> will be repeated in every URL generated with |
| web::cmdurl. See the documentation of web::cmdurl for details. |
| <dt><b>web::dispatch -hook <code></b> |
| <dd> |
| Causes web::dispatch to eval <code> just before the command (from |
| any source) is evaluated. When <code> is evaluated, the full |
| request information has been parsed. That is, web::param, |
| web::formvar etc. will have up-to-date information when |
| <code> is evaluated. |
| </dl> |
| |
| <b>Note</b> that, if no command is passed to web::dispatch either in the |
| querystring or with the -cmd option, web::dispatch will call the |
| command "default". |
| |
| Examples: |
| <pre> |
| --------------------------------------------------------------------------- |
| set tst {puts "On the hook"} |
| web::command acmd { puts "this is acmd" } |
| web::dispatch -cmd acmd -querystring "" -postdata "" |
| ==> this is acmd |
| web::dispatch -cmd acmd -querystring "" -postdata "" -hook $tst |
| ==> On the hook |
| ==> this is acmd |
| --------------------------------------------------------------------------- |
| </pre> |
| |
| <h2><a name="webc">web::command</a></h2> |
| |
| <dl> |
| <dt><b>Syntax:</b> |
| <dd> |
| <b>web::command</b> ?<cmdName>? <cmdBody> |
| </dl> |
| |
| Registers <cmdBody> as <cmdName>. If <cmdName> is |
| omitted, "default" is used. |
| |
| <h2><a name="webg">web::getcommand</a></h2> |
| |
| <dl> |
| <dt><b>Syntax:</b> |
| <dd> |
| <b>web::getcommand</b> ?<cmdName>? |
| </dl> |
| |
| Retrieves the body of the command <commandName> or of the command "default" |
| if <cmdName> is omitted. |
| |
| <br><br> |
| <h2><a name="webcm">web::cmdurl</a></h2> |
| |
| <dl> |
| <dt><b>syntax</b> |
| <dd> |
| <b>web::cmdurl</b> ?options? <cmdName> ?<key-value-list>?<br> |
| <b>web::cmdurl</b> ?options? <cmdName> <k1> <v1> ... <kN> <vN><br> |
| Options are: <tt>-notimestamp</tt>, and %=urlformat%= |
| </dl> |
| |
| Generate URLs including querystring. By default, URLs are |
| self-referencing, but the exact output is subject to configuration. The |
| querystring is encrypted, using the encryption method specified by |
| configuration (see <tt>web::config</tt>). |
| |
| <dl> |
| <dt><b>-notimestamp</b> |
| <dd> |
| do not add a timestamp to the URL |
| <dt><b>-urlformat <list></b> |
| <dd> |
| specify what items will be used to format just this URL. |
| Default is: <tt>{scriptname querystring}</tt><br> |
| Use <tt>web::cmdurlcfg</tt> to define the url format for all |
| URLs produced by <tt>web::cmdurl</tt> in one request.<br> |
| ==D protocol |
| use the protocol, like "http" |
| ==D servername |
| use the servername, like "websh.com" |
| ==D serverport |
| use the port like "80" |
| Trying to set this item, without servername, will throw |
| an error |
| ==D scriptname |
| use scriptname, like "websh3" |
| ==D pathinfo |
| use pathinfo, like "home" |
| ==D querystring |
| use the querystring, like "select=download" |
| </dl> |
| |
| Examples: |
| <pre> |
| --------------------------------------------------------------------------- |
| web::cmdurl -notimestamp -urlformat [list protocol querystring] "test" |
| ==> http://?XDZuRD2rnsfHjFH |
| --------------------------------------------------------------------------- |
| </pre> |
| |
| Note that there are two more commands that control the output of |
| <tt>web::cmdurl</tt>: <tt>web::config cmdparam</tt> and <tt>web::config timeparam</tt>. |
| |
| <h2><a name="webcmd">web::cmdurlcfg</a></h2> |
| |
| <dl> |
| <dt><b>syntax</b> |
| <dd> |
| <b>web::cmdurlcfg</b> ?options? ?<key>? ?<value>?<br> |
| Exactly like <tt>web::param</tt><br> |
| <b>web::cmdurlcfg</b> option ?<value>?<br> |
| Options are <b>-protocol</b>, <b>-servername</b>, <b>-port</b>, |
| <b>-pathinfo</b>, <b>-urlformat</b><br> |
| If <value> is omitted, the current value is returned. |
| Otherwise, the <value> is stored. |
| </dl> |
| |
| Configuration for web::cmdurl. This command serves two purposes: |
| <ol> |
| <li>management of static parameters |
| <li>configuration for <tt>web::cmdurl</tt> |
| </ol> |
| |
| <h2>management of static parameters</h2> |
| |
| In order to set, retrieve, append or unset static parameters, |
| use the syntax of the <tt>web::param</tt> command, for example: |
| <dl> |
| <dt><b>web::cmdurlcfg -set <key> <value></b> |
| <dd> |
| add the static parameter <key> |
| <dt><b>web::cmdurlcfg</b> |
| <dd> |
| returns a list of all known static parameters |
| </dl> |
| |
| <br><br> |
| <b>Important</b>: <tt>web::cmdurl</tt> compares every key from the static |
| parameters (see <tt>web::cmdurlcfg</tt>) against the keys from the command |
| line. The static parameter is only used if there is no parameter given |
| on the command line. |
| |
| <h2>configuration for <tt>web::cmdurl</tt></h2> |
| |
| <dl> |
| <dt><b>web::cmdurlcfg -protocol ?<value>?</b> |
| <dd> |
| protocol to be used. Default: http. |
| <dt><b>web::cmdurlcfg -servername ?<value>?</b> |
| <dd> |
| server name to be used. Default: taken from request. |
| <dt><b>web::cmdurlcgf -port </b> |
| <dd> |
| port number to be used. Default: 80. |
| <dt><b>-scriptname</b> |
| <dd> |
| name of CGI executable. Default: taken from request. |
| <dt><b>-pathinfo</b> |
| <dd> |
| path info (path after scriptname). Default: taken from request. |
| <dt><b>-urlformat <list></b> |
| <dd> |
| changes the urlformat permanently. See web::cmdurl for the |
| description of this option |
| </dl> |
| |
| In all cases, "web::cmdurlcfg -option <value>" sets the value of |
| the given option and returns the value that was used before the change, |
| while "web::cmdurlcfg -option" returns the current value. If no value |
| has been set using web::cmdurlcfg, but is requested for the URL |
| generation, the value from the request will be used. This value, |
| however, can not be retrieved using web::cmdurlcfg. |
| |
| <br><br> |
| Note that setting a value to an empty string amounts to "unset". |
| |
| Examples: |
| <pre> |
| --------------------------------------------------------------------------- |
| % web::cmdurl |
| ==> ?XD8Fseb6tjYQsBUWZ9 |
| % web::cmdurlcfg -scriptname bin/test_script |
| % web::cmdurl |
| ==> bin/test_script?XD8Fseb6tjYRl1M9Fl |
| % web::cmdurlcfg -scriptname "" |
| % web::cmdurl |
| ==> ?XD8Fseb6tjYQsBUWZ9 |
| --------------------------------------------------------------------------- |
| </pre> |
| |
| <b>Important</b>: web::cmdurl compares every key from the static |
| parameters see -->(web::cmdurlcfg) against the keys from the command |
| line. The static parameter is only used if there is no parameter on |
| the command line. |
| |
| <h1><a name="resp">response data management</a></h1> |
| |
| webshell can send output to any Tcl channel and to global |
| variables (=%web::put=%). Optionally, data is scanned for Tcl code before it is |
| output to a channel (<tt>web::putx</tt>). |
| webshell manages <i>response objects</i> that are |
| related to Tcl channels and are identified using the name of the |
| corresponding Tcl channel. Configuration with <tt>web::response</tt>. |
| |
| <h2><a name="webpu">web::put</a></h2> |
| |
| <dl> |
| <dt><b>Syntax:</b> |
| <dd> |
| <b>web::put</b> ??#?<channel>? <text> |
| </dl> |
| |
| Send output to a Tcl channel. |
| No newline is added to output. |
| |
| <h2><a name="webput">web::putx</a></h2> |
| |
| <dl> |
| <dt><b>Syntax:</b> |
| <dd> |
| <b>web::putx</b> ?options? ??#?<channel>? <text> |
| Options are: <tt>-tag</tt> and <tt>-tagisdefault</tt> |
| </dl> |
| |
| Writes <text> to the specified channel. Code in curly brackets is |
| executed, unless the brackets are escaped by "\". |
| |
| <dl> |
| <dt><b>web::putx -tag ??#?<channel>? <text></b> |
| <dd> |
| for this call, use =%<%%= and =%%>%= instead of |
| <tt>{</tt> and <tt>{</tt> as marker for code |
| <dt><b>web::putx -tagisdefault ?<boolean>?</b> |
| <dd> |
| for all subsequent calls, use the =%<%%= and =%%>%= |
| as marker for code (default is 0). |
| If <boolean> is omitted, the current setting is returned. |
| </dl> |
| |
| <h2><a name="webputx">web::putxfile</a></h2> |
| |
| <dl> |
| <dt><b>Syntax:</b> |
| <dd> |
| <b>web::putxfile</b> ??#?<channel>? <file> ?<msg>? |
| </dl> |
| |
| As web::putx, but takes input from a file. |
| |
| Returns 0 on success, 1 otherwise. If an error occurs, an error |
| message is written to <msg>. If only two arguments are passed, then |
| <channel> takes precedence. |
| |
| <h2><a name="webr">web::response</a></h2> |
| |
| <dl> |
| <dt><b>Syntax</b> |
| <dd> |
| <b>web::response</b><br> |
| <b>web::response</b> ?option?<br> |
| <b>web::response</b> ??#?<channel>? ?subcommand? args<br> |
| Subcommands are <b>-select</b>, <b>-set</b>, <b>-lappend</b>, |
| <b>-names</b>, <b>-exists</b>, <b>-unset</b>, and <b>-reset</b>, |
| Options are <b>-sendheader</b>, and <b>-bytessent</b>.<br> |
| If <channel> is omitted, the command operates on the |
| currently selected channel. If <channel> is prepended |
| by a #, it refers too a global variable. |
| </dl> |
| |
| Selects the default response object, sets and accesses properties |
| of the response object, and returns the name of the response |
| object. |
| |
| <dl> |
| <dt><b>web::response</b> |
| <dd> |
| returns the name of the currently selected response object |
| <dt><b>web::response ??#?<channel>? -select</b> |
| <dd> |
| makes <channel> the new default response object |
| <dt><b>web::response ??#?<channel>? -set <key> ?<value>?</b> |
| <dd> |
| sets property <key> to <value>, or returns current |
| value if <value> is omitted.<br> |
| Two property names are reseved: <b>httpresonse</b> and |
| <b>header</b>. httpresonse is the status message to be sent |
| back to the client. It is not set by default. |
| header is a key-value list consisting of HTTP Headers |
| (like Content-Type) and their values (like text/html). |
| <dt><b>web::response ??#?<channel>? -names</b> |
| <dd> |
| returns the list of known keys |
| <dt><b>web::response ??#?<channel>? -exists <key></b> |
| <dd> |
| true if <key> exists in list |
| <dt><b>web::response -unset ?<key>?</b> |
| <dd> |
| delete the value of <key>, if <key> is given, or |
| all keys. |
| <dt><b>web::response ??#?<channel>? -sendheader ?<boolean>?</b> |
| <dd> |
| Sets the sendheader flag which indicates and controls |
| whether the HTTP headers have been or should be sent. |
| It is initially set to 1 and set to 0 after the first |
| call of <tt>web::put</tt> or <tt>web::putx</tt>. If <boolean> is |
| omitted, returns the current value. |
| <dt><b>web::response ??#?<channel>? -bytessent</b> |
| <dd> |
| returns the number of bytes that have already been sent to this |
| channel. |
| </dl> |
| |
| <h2><a name="Exam">Examples</a></h2> |
| <pre> |
| --------------------------------------------------------------------------- |
| web::response |
| ==> stdout |
| web::response stderr -select |
| ==> stdout |
| web::response -sendheader |
| ==> 1 |
| web::response -set header |
| ==> Content-Type text/html Generator {websh 3.0} |
| web::response -bytessent |
| ==> 0 |
| web::response -lappend header "Set-Cookie" "mycookie" |
| web::put "Hello, world" |
| ==>Content-Type: text/html |
| |
| --------------------------------------------------------------------------- |
| </pre> |
| |
| <h1><a name="cont">context management</a></h1> |
| |
| <dl> |
| <dt><b>Creation </b> |
| <dd> |
| <b>web::context</b> <name> |
| </dl> |
| |
| Creates a namespace <name> with the following commands: |
| |
| <dl> |
| <dt><b>Syntax</b> |
| <dd> |
| <b><name></b>::<subcommand> <args><br> |
| Subcommands are: <tt>cset</tt>, <tt>cappend</tt>, <tt>clappend</tt>, |
| <tt>cget</tt>, <tt>cexists</tt>, <tt>cunset</tt>, <tt>carray</tt>, |
| <tt>cnames</tt>, and <tt>dump</tt>. |
| </dl> |
| |
| Manages data of the context. The subcommands have their |
| familiar behaviour of the Tcl commands with similar |
| names. |
| |
| <dl> |
| <dt><b><name>::cset <key> <value></b> |
| <dd> |
| store <value> |
| <dt><b><name>::cappend <key> <value></b> |
| <dd> |
| append <value> to existing value for <key> |
| <dt><b><name>::clappend <key> <value></b> |
| <dd> |
| append <value> to existing list of values for <key> |
| <dt><b><name>::cget <key> ?<default>?</b> |
| <dd> |
| access the value for key <key>, or return <default> |
| if <key> does not exist in the context. If <default> |
| is omitted, an empty string is returned if <key> |
| is unknown. |
| <dt><b><name>::cexists <key></b> |
| <dd> |
| returns true (1) if <key> exists in context, false (0) |
| otherwise. |
| <dt><b><name>::cunset <key></b> |
| <dd> |
| remove <key> from context |
| <dt><b><name>::carray <option> <key> <arg></b> |
| <dd> |
| array manipulation as known from the Tcl command |
| <i>array</i> |
| <dt><b><name>::cnames ?<pattern>?</b> |
| <dd> |
| lists existing keys of context matching <pattern> |
| <dt><b><name>::dump</b> |
| <dd> |
| serialize context |
| </dl> |
| |
| Example: |
| <pre> |
| --------------------------------------------------------------------------- |
| % web::context sc |
| % sc::cset lang FR |
| ... some code ... |
| set lang [sc::cget lang EN] |
| ==> FR |
| --------------------------------------------------------------------------- |
| </pre> |
| |
| <h1><a name="file">file-based context</a></h1> |
| |
| <dl> |
| <dt><b>Creation:</b> |
| <dd> |
| <b>web::filecontext</b> <name> ?options?<br> |
| Options are: <tt>-perm</tt>, <tt>-path</tt>, <tt>-crypt</tt>, |
| <tt>-idgen</tt>, and <tt>-attachto</tt>. |
| </dl> |
| |
| Creates a namespace <name> to manage file-based context data: |
| |
| <dl> |
| <dt><b>Syntax</b> |
| <dd> |
| <b><name></b>::<subcommand> <args><br> |
| Subcommands are: <tt>cset</tt>, <tt>cappend</tt>, <tt>clappend</tt>, |
| <tt>cget</tt>, <tt>cexists</tt>, <tt>cunset</tt>, <tt>carray</tt>, |
| <tt>cnames</tt>, <tt>init</tt>, <tt>new</tt>, <tt>commit</tt>, and <tt>id</tt>. |
| </dl> |
| |
| Manages file-based context data. The subcommands have their familiar |
| behaviour of the Tcl commands with similar names. Please refer to the |
| section <tt>context management</tt> for a description of the commands |
| <tt>cset</tt>, <tt>cappend</tt>, <tt>clappend</tt>, <tt>cget</tt>, <tt>cexists</tt>, |
| <tt>cunset</tt>, <tt>carray</tt>, and <tt>cnames</tt>. |
| |
| <dl> |
| <dt><b><name>::init ?<id>?</b> |
| <dd> |
| load an existing session context with id <id>, or create a new one, |
| possible. Automation depends on the settings of the actual |
| context manager settings, see below. |
| <dt><b><name>::new ?<id>?</b> |
| <dd> |
| create a new session context. Automation depends on the settings of the |
| actual context manager settings, see below. |
| <dt><b><name>::commit</b> |
| <dd> |
| make session context persistent |
| <dt><b><name>::id</b> |
| <dd> |
| return id of session |
| </dl> |
| |
| Options: |
| |
| <dl> |
| <dt><b>web::filecontext <name> -perm <perm></b> |
| <dd> |
| set the file permissions of the session context files |
| <perm> is an unix-like octal value like 0644. |
| <dt><b>web::filecontext <name> -path <path></b> |
| <dd> |
| specify where to store session context files and |
| how to name them. Suppose that the session id is 99. |
| <i>-path [file join .. data s%d.dat]</i> would then |
| cause filecontext to save the session context |
| as <tt>../data/s99.dat</tt> |
| <dt><b>web::filecontext <name> -crypt <boolean></b> |
| <dd> |
| Flag to turn crypting of session context on and off. |
| Default is on. |
| <dt><b>web::filecontext <name> -idgen <idgen></b> |
| <dd> |
| Use <idgen> to find a new session id. See doc of |
| <i>web::filecounter</i> below for an implementation |
| provided with webshell.<br> |
| <idgen> is used in case that now <id> argument |
| has been passed to <i>init</i> or <i>new</i>. |
| <dt><b>web::filecontext <name> -attachto <idparam></b> |
| <dd> |
| Use <tt>web::param <idparam></tt> to access current session id. |
| This option is only used if <i>init</i> has been called |
| without <id> argument.<br> |
| webshell passes session Ids from one HTML request to |
| the next using the querystring (this is one reason why |
| the querystring is encrypted). After web::dispatch |
| has parsed the querystring, web::param will report the |
| current session id, if any. <i>Note</i> that you can |
| maintain several sessions in parallel, and attach every |
| session to its own <idparam>.<br> |
| Using <i>web::dispatch -track</i> further automates the |
| passing of session Ids from request to request. |
| </dl> |
| |
| <b>Note:</b> Whenever you create a new file-based context, the context is |
| initialized and you loose whatever information that you might have |
| stored in the context before you initialized it as a file-based |
| session context. |
| |
| <h1><a name="cook">cookie-based sessions</a></h1> |
| |
| <dl> |
| <dt><b>Creation:</b> |
| <dd> |
| <b>web::cookiecontext</b> <name> ?options?<br> |
| Options are: <tt>-expires</tt>, <tt>-path</tt>, <tt>-domain</tt>, |
| <tt>-secure</tt>, and <tt>-channel</tt>. |
| </dl> |
| |
| Creates a namespace <name> to manage cookie-based context data: |
| |
| <dl> |
| <dt><b><name>::init ?<id>?</b> |
| <dd> |
| load an existing session context (cookie must have been sent by the |
| client). |
| <dt><b><name>::new ?<id>?</b> |
| <dd> |
| create a new session context. |
| <dt><b><name>::commit</b> |
| <dd> |
| send a cookie |
| <dt><b><name>::id</b> |
| <dd> |
| return id of session |
| </dl> |
| |
| Options: |
| |
| <dl> |
| <dt><b>web::cookiecontext <name> -expires <time></b> |
| <dd> |
| set the expiration date of the cookie. Possible values for <time> |
| are <i>day</i> (lifetime: one day), <i>week</i>, <i>today</i>, <i>seconds</i> |
| (time in seconds since 1-1-1970) or <i>date-string</i>. |
| <dt><b>web::cookiecontext <name> -path <path></b> |
| <dd> |
| set the <i>path</i> property of the cookie |
| <dt><b>web::cookiecontext <name> -domain <domain></b> |
| <dd> |
| set the <i>domain</i> property of the cookie |
| <dt><b>web::cookiecontext <name> -secure <boolean></b> |
| <dd> |
| set the <i>secure</i> property of the cookie |
| <dt><b>web::cookiecontext <name> -channel <channelName></b> |
| <dd> |
| The response object to send the cookie to (see also |
| <tt>web::response</tt>). |
| </dl> |
| |
| Because cookies are client-based, in principle no id is |
| needed. webshell uses <id> to name the cookie, however, and the |
| <tt>new</tt>, <tt>init</tt>, and <tt>load</tt> commands still require the <id> |
| argument. |
| |
| <br><br> |
| <h1><a name="== conversion">uri-/html- en-/decoding</a></h1> |
| |
| <ul> |
| <li><b>web::htmlify</b> ?-options? <text><br> |
| Options is: <tt>-numeric</tt>.<br> |
| Return HTML-compliant <text> |
| <li><b>web::dehtmlify</b> <text><br> |
| Remove all HTML-specifics of <text> |
| <li><b>web::uriencode</b> <text><br> |
| Return URI-compliant <text>. |
| <li><b>web::uridecode</b> <text><br> |
| Decode URI-compliant <text>. |
| </ul> |
| |
| Examples: |
| <pre> |
| --------------------------------------------------------------------------- |
| % web::htmlify ä |
| ==> &auml; |
| % web::htmlify -numeric ä |
| ==> &#228; |
| % web::dehtmlify &auml; |
| ==> ä |
| % web::uriencode "Hello, world!" |
| ==> Hello,+world%21 |
| % web::uridecode %21 |
| ==> ! |
| --------------------------------------------------------------------------- |
| </pre> |
| |
| <h1><a name="msg">inter-process/-system communication</a></h1> |
| |
| Send to and receive from sockets. |
| |
| <h2><a name="webs">web::send</a></h2> |
| |
| <dl> |
| <dt><b>Syntax:</b> |
| <dd> |
| <b>web::send</b> <channel> <cmdNr> <message> ??#?<flags>? |
| </dl> |
| |
| Send the command <cmdNr> and the message <message> to channel |
| <channelName> using the flags <flags>. The command numbers are |
| application specific. If #<flags> is used, flags is the numeric |
| (integer) representation of the flags is to be set. If the # is |
| omitted, <flags> is a list of symbolic flags. Currently, there is only |
| one flag: "multiple", indicating that there is more to follow. |
| |
| <h2><a name="webre">web::recv</a></h2> |
| |
| <dl> |
| <dt><b>Syntax:</b> |
| <dd> |
| <b>web::recv</b> <channel> <cmdVarName> <msgVarName> <flagVarName> |
| </dl> |
| |
| Receives a message from <channelName>. The other arguments are the |
| names of the corresponding variables which will contain the message. |
| The flags are returned numeric. (To handle these flags, use the |
| web::msgflag function). |
| |
| <h2><a name="webm">web::msgflag</a></h2> |
| |
| <dl> |
| <dt><b>Syntax:</b> |
| <dd> |
| <b>web::msgflag</b> ?<flags>? ?<testflags>? |
| </dl> |
| |
| Set or test flags. |
| |
| <dl> |
| <dt><b>web::msgflag</b> |
| <dd> |
| returns a list of all known message flags |
| <dt><b>web::msgflag <flags></b> |
| <dd> |
| returns the integer representation of the flags listed in <flags> |
| <dt><b>web::msgflag <flags> <testflags></b> |
| <dd> |
| returns 1, if the flags in <testflags> are set in <flags> |
| </dl> |
| |
| <h1><a name="crypt">data encryption</a></h1> |
| |
| Encrypt (<tt>web::encrypt</tt>) and decrypt (<tt>web::decrypt</tt>) data. By |
| default, the built-in, weak encryption is used. encryption is |
| extensible by plug-Ins. The encryption module tries all plug-Ins from |
| a list until the first plug-In was able to en-/decrypt the input. See |
| <tt>web::config</tt> for the configuration of the plug-Ins to be used. |
| |
| <h2><a name="webe">web::encrypt</a></h2> |
| |
| <dl> |
| <dt><b>Syntax:</b> |
| <dd> |
| <b>web::encrypt</b> <data> |
| </dl> |
| |
| Returns encrypted data. |
| |
| <h2><a name="webde">web::decrypt</a></h2> |
| |
| <dl> |
| <dt><b>Syntax:</b> |
| <dd> |
| <b>web::decrypt</b> <data> |
| </dl> |
| |
| Returns decrypted data. |
| |
| Examples: |
| <pre> |
| --------------------------------------------------------------------------- |
| % web::encrypt "Hello, world!" |
| ==> XDaL9T6OqaqUXVJVKDAKQU |
| % web::decrypt [web::encrypt "Hello, world!"] |
| ==> Hello, world! |
| --------------------------------------------------------------------------- |
| </pre> |
| |
| <h2><a name="encr">encryption plugIn D</a></h2> |
| |
| By default, webshell uses this plug-In for weak data encryption for |
| encryption (<tt>web::encryptd</tt>) and decryption (<tt>web::decryptd</tt>). |
| The encryption key is managed with <tt>web::crpytdkey</tt>. |
| |
| <h2><a name="weben">web::encryptd</a></h2> |
| |
| <dl> |
| <dt><b>Syntax:</b> |
| <dd> |
| <b>web::encryptd</b> <data> |
| </dl> |
| |
| Returns encrypted data. |
| |
| <h2><a name="webdec">web::decryptd</a></h2> |
| |
| <dl> |
| <dt><b>Syntax:</b> |
| <dd> |
| <b>web::decryptd</b> <data> |
| </dl> |
| |
| Decryption. |
| |
| <h2><a name="webcr">web::cryptdkey</a></h2> |
| |
| <dl> |
| <dt><b>Syntax:</b> |
| <dd> |
| <b>web::cryptdkey</b> ?<key>? |
| </dl> |
| |
| Sets the new key for encryption. If no argument is given, resets to |
| the default key. This command does not return the currently active |
| key, in difference to other configuration commands of webshell 3. |
| |
| Commands: |
| |
| <dl> |
| <dt><b>web::encryptd <message></b> |
| <dd> |
| encrypts list |
| <dt><b>web::decryptd <message></b> |
| <dd> |
| decryption |
| <dt><b>web::cryptdkey ?<key>?</b> |
| <dd> |
| </dl> |
| |
| <h2><a name="encry">encryption plugIn interface </a></h2> |
| |
| <i>For plug-In developers only</i><br> |
| |
| The encryption plug-In is required to implement the interface |
| described below: |
| |
| <ul> |
| <li>web::yourencrypt accepts one argument |
| web::yourencrypt takes a string as input and generates a string which |
| must be URI compliant |
| <li>web::yourdecrypt accepts one argument |
| web::yourdecrypt takes a string as input and returns a string |
| <li>symmetry: <i>$in == [web::yourdecrypt [web::yourencrypt $in]]</i> |
| <li>error messaging: |
| <i>TCL_OK</i> for success<br> |
| <i>TCL_ERROR</i> for any error during en-/decryption<br> |
| <i>TCL_CONTINUE</i> for unknown encryption type (pass on to next method) |
| </ul> |
| |
| <h1><a name="log">logging</a></h1> |
| |
| Logging consists of two parts. <tt>web::log</tt> issues a logging message, |
| while <tt>web::logfilter</tt> and <tt>web::logdest</tt> determine where to send |
| a message. webshell uses a two-step filtering. First, webshell |
| determines whether it should handle a message, or not, using |
| the filters configured with "web::logfilter". Then, webshell |
| determines which message is to be sent where, using the filters |
| configured with <tt>web::logdest</tt>. |
| |
| A filter consists of a tag and a level, separated |
| by a ".". The tag is free text. Typically, it is the name of the application, |
| say "foo". Example: "ws3.debug". Levels are, in order: |
| |
| <ul> |
| <li>alert |
| <li>error |
| <li>warning |
| <li>info |
| <li>debug |
| </ul> |
| |
| <h2><a name="webl">web::log</a></h2> |
| |
| <dl> |
| <dt><b>Syntax:</b> |
| <dd> |
| <b>web::log</b> ?options? <level> <msg> |
| Option is: <tt>-nosubst</tt>. |
| </dl> |
| |
| Issue a log message. <i>Note</i> that, for performance reasons, |
| variables and command names <msg> will be substituted by the log |
| module and you should put <msg> in curly braces to prevent Tcl from |
| substituting the string as well. This ensures that webshell only |
| spends time on messages which actually pass all filters, and debug |
| messages that contain variable names and commands will not slow down |
| the productive system, where no debug messages pass the filters. |
| |
| Options: |
| |
| <dl> |
| <dt><b><b>web::log</b> -nosubst <level> <msg></b> |
| <dd> |
| prevent the log module from substituting <msg> |
| </dl> |
| |
| <br><br> |
| <h2><a name="weblo">web::logfilter</a></h2> |
| |
| <dl> |
| <dt><b>Syntax:</b> |
| <dd> |
| <b>web::logfilter</b> subcommand args<br> |
| Subcommands are: <tt>add</tt>, <tt>delete</tt>, and <tt>names</tt>. |
| </dl> |
| |
| Add a filter to the list. |
| |
| <dl> |
| <dt><b>web::logfilter add <level></b> |
| <dd> |
| add a <level> to the list |
| <dt><b>web::logfilter delete ?<name>?</b> |
| <dd> |
| remove a <name> from list, or remove all filters if <name> is omitted. |
| <dt><b>web::logfilter names</b> |
| <dd> |
| list all filters that have been set |
| </dl> |
| |
| <h2><a name="weblog">web::logdest</a></h2> |
| |
| web::logdest add -maxchar 25 -format "%x %X \$l \$m" *.-debug command logTest |
| |
| <dl> |
| <dt><b>Syntax:</b> |
| <dd> |
| <b>web::logdest</b> subcommand ?options? <level> <plugin><br> |
| Subcommands are: <tt>add</tt>, <tt>delete</tt>, and <tt>names</tt>.<br> |
| Options are: <tt>-maxchar</tt>, and <tt>-format</tt>.<br> |
| Known plugins are: <tt>file</tt>, <tt>syslog</tt>, <tt>command</tt>, |
| <tt>channel</tt>, and <tt>aplog</tt>. |
| </dl> |
| |
| The format string consits of format specifications for <tt>fprintf()</tt> |
| plus: <tt>p</tt> (process id), <tt>t</tt> (thread id), <tt>n</tt> (log level), |
| <tt>f</tt> (log type), and <tt>m</tt> (the message). |
| |
| <h1><a name="logp">log plugins</a></h1> |
| |
| <h2><a name="file7">file</a></h2> |
| |
| <dl> |
| <dt><b>Syntax:</b> |
| <dd> |
| web::logdest add *.-debug <b>file</b> ?options? <file><br> |
| Option is: <tt>-unbuffered</tt> |
| </dl> |
| |
| <h2><a name="sysl">syslog</a></h2> |
| |
| <dl> |
| <dt><b>Syntax:</b> |
| <dd> |
| web::logdest add *.-debug <b>syslog</b> <level><br> |
| </dl> |
| |
| See the man page for syslog for levels on your system. Typical: 10. |
| |
| <h2><a name="comm">command</a></h2> |
| |
| <dl> |
| <dt><b>Syntax:</b> |
| <dd> |
| web::logdest add *.-debug <b>command</b> <cmdName> |
| </dl> |
| |
| <h2><a name="chan">channel</a></h2> |
| |
| <dl> |
| <dt><b>Syntax:</b> |
| <dd> |
| web::logdest add *.-debug <b>channel</b> ?options? <channe> |
| Option is: <tt>-unbuffered</tt> |
| </dl> |
| |
| <h2><a name="aplo">aplog</a></h2> |
| |
| Available in mod_websh only. |
| |
| Examples: |
| <pre> |
| --------------------------------------------------------------------------- |
| web::logfilter add *.-debug |
| web::logdest add *.-debug channel stdout |
| web::log info {websh is cool} |
| ==> 03/01/00 00:00:00 [111] user.info: websh is cool |
| web::logdest add -format "--> \$m\n" *.-debug channel stdout |
| web::log info {websh is cool} |
| ==> --> websh is cool |
| web::logdest add -maxchar 5 *.-debug channel stdout |
| web::log info {websh is cool} |
| ==> 03/01/00 00:00:00 [111] user.info: websh |
| --------------------------------------------------------------------------- |
| </pre> |
| |
| <h1><a name="cfg">configuration</a></h1> |
| |
| The are a few configuration options for websh. Use web::config <tag> |
| to access the current value of <tag>, and web::config <tag> <value> to |
| set it. Possible tags are: |
| |
| <dl> |
| <dt><b>uploadfilesize</b> |
| <dd> |
| Sets the maximum number of bytes allowed to be uploaded. |
| Default: 0. |
| <dt><b>cmdparam</b> |
| <dd> |
| Name of the parameter to store reference to a web::command command |
| in the URL. Default: "cmd". |
| <dt><b>timeparam</b> |
| <dd> |
| Name of the parameter to store reference to the timestamp |
| in the URL. Default: "t". |
| <dt><b>encryptchain <list></b> |
| <dd> |
| defines which commands should be tried, in sequence, to encrypt |
| a message. Default: "web::encryptd" |
| <dt><b>decryptchain <list></b> |
| <dd> |
| defines which commands should be tried, in sequence, to decrypt |
| a message. Default: [list web::decryptd web::nullencrypt] |
| </dl> |
| |
| <h1><a name="misc">misc commands</a></h1> |
| |
| <h2><a name="webt">web::tempfile</a></h2> |
| |
| Returns a unique name of a temporary file. The maximum of guaranteed |
| unique names per application is system dependent. This command just |
| returns the name of a file. It is the programmers job to handle the |
| file, for example to open it. Note that webshell keeps an internal |
| list of all file names generated with web::tempfile and will attempt |
| to delete all files when the interpreter dies. |
| |
| <h2><a name="webi">web::include</a></h2> |
| |
| <dl> |
| <dt><b>Syntax:</b> |
| <dd> |
| web_include <fileName> ?<msg>? |
| </dl> |
| |
| If the file <fileName> exists, it is sourced (must be a |
| script). Otherwise if the library fileName+"shared lib extension" |
| exists, it is loaded (must be a shared library). Returns 0 on success, |
| 1 otherwise. If an error occurs, an error message is written to <msg>. |
| |
| <h2><a name="webrea">web::readfile</a></h2> |
| |
| <dl> |
| <dt><b>Syntax:</b> |
| <dd> |
| web::readfile <file> <varName> <msg> |
| </dl> |
| |
| <file> is read and written to <varName>. Returns 0 on success, 1 |
| otherwise. If an error occurs, an error message is written to the |
| variable <msg>. |
| |
| <h2><a name="webfi">web::filecounter</a></h2> |
| |
| This is a sequence-number generator which stores its state |
| in a file. Basic usage: |
| |
| <dl> |
| <dt><b>nextval</b> |
| <dd> |
| return the next value |
| <dt><b>curval</b> |
| <dd> |
| return the current value, that is, the value that |
| the last call to "nextval" reported (as opposed |
| to the current value in the file) |
| </dl> |
| |
| Options: |
| |
| <ul> |
| <li>-seed <seed> |
| <li>-min <min> |
| <li>-max <max> |
| <li>-incr <increment> |
| <li>-wrap <1|0> |
| </ul> |
| |
| Examples: |
| <pre> |
| --------------------------------------------------------------------------- |
| web::filecounter handleName -filename "test.dat" |
| ==> from now on, use handleName <curval|nextval> |
| web::filecounter handleName -filename "test.dat" \ |
| -min 1 -max 10 -seed 1 -incr 2 -wrap 1 |
| --------------------------------------------------------------------------- |
| </pre> |
| |
| <h2><a name="webco">web::copyright</a></h2> |
| |
| returns copyright and version/build information |
| |
| <h2><a name="webge">web::getcgivar</a></h2> |
| |
| Data-source independent accessor to CGI variables. In the CGI mode, |
| webshell will return environment variables, and in the Apache module |
| mode, web::getcgivar will return data from the Apache request object. |
| |
| <h2><a name="webma">web::match</a></h2> |
| |
| <dl> |
| <dt><b>Syntax:</b> |
| <dd> |
| web::match <result> <listToBeSearched> <searchFor> |
| </dl> |
| |
| In case <searchFor> exists in <listToBeSearched>, web::match returns |
| <result>, otherwise an empty string. |
| |
| <br><br> |
| For websh2 wizards:<br> |
| |
| wpp_isselected v1 v2 would now be: |
| web::match "selected" v1 v2 |
| |
| <br><br> |
| web::match treats v1 as a list. Thus, <i>web::match "ok" {tv dvd vcr} dvd</i> |
| will return <i>ok</i>. |
| |
| <h2><a name="webloc">web::lockfile and web::unlockfile</a></h2> |
| |
| Interface to lockf(). lockf() works best on local filesystems. Please |
| read the documentation of lockf on your system to learn about the |
| problems and limitations of file locking. Note that web::lockfile also |
| performs a seek() and resets the file cursor to the beginning of the |
| file. |
| |
| <i>Note</i> that the file needs to be open for writing. |
| |
| <h1><a name="Copy">Copyright</a></h1> |
| |
| Copyright (C) 2000 by Netcetera AG.<br> |
| All rights reserved. |
| |
| <br><br> |
| <b>Note</b>: We try to keep this quick reference up-to-date and hope that |
| it will be useful. We do not guarantee that it is suitable for any |
| particular purpose whatsoever. The authors accept no liability in |
| respect to this information or its use. |
| |
| <br><br> |
| The original version of this document can always be found |
| at <a href="http://websh.com">http://websh.com</a>. |
| |
| <pre> |
| |
| $Id$ |
| |
| </pre> |