The server utility library,
ZSERVER.LIB, contains the structures, functions, and constants to allow HTTP (Hypertext Transfer Protocol) and FTP (File Transfer Protocol) servers to share data and user authentication information while running concurrently.HTML form functionality is included in
ZSERVER.LIB.3.1 Data Structures for Zserver.lib
There are several data structures in this library of interest to developers of HTTP or FTP servers.
3.1.1 ServerSpec Structure
A file transfer server has access to a list of objects: files, functions and variables. This list is defined as a global array in
ZSERVER.LIB.ServerSpec server_spec[SSPEC_MAXSPEC];Throughout this manual, this array will be called the TCP/IP servers' object list or sometimes the server spec list.
3.1.2 ServerAuth Structure
ZSERVER.LIBalso defines a global array that is a list of user name/password pairs.ServerAuth server_auth[SAUTH_MAXUSERS];Throughout this manual, this array will be called the TCP/IP users list or sometimes just users list.
3.1.3 FormVar Structure
An array of
FormVarstructures represent the variables in an HTML form. The developer will declare an array of these structures, with the size needed to hold all variables for a particular form. TheFormVarstructure contains:
- A
server_specindex that references the variable to be modified. This is the location of the form variable in the TCP/IP servers' object list.- An integrity-checking function pointer that ensures that the variables are set to valid values.
- High and low values (for numerical types).
- Length (for the string type, and for the maximum length of the string representations of values).
- A Pointer to an array of values (for when the value must be one of a specific, and probably short, list).
The developer can specify whether she wants the variable to be set through a text entry field or a pull-down menu, and if the variable should be considered read-only.
This
FormVararray is placed in aServerSpecstructure using the functionsspec_addform.ServerSpecentries that represent variables will be added to theFormVararray usingsspec_addfv. Properties (e.g., the integrity-checking properties) for theseFormVarentries can be set with various other functions. Hence, there is a level of indirection between the variables in the forms and the actual variables themselves. This allows the same variable to be included in multiple forms with different ranges for each form, and perhaps be read-only in one form and modifiable in another.3.2 Constants Used in Zserver.lib
The constants in this section are values assigned to the fields of the structures
ServerSpecandServerAuth. They are used in the functions described in Section 3.4, some as function parameters and some as return values.3.2.1 ServerSpec Type Field
This field describes the objects in the TCP/IP servers' object list.
SSPEC_ERROR //Error conditionSSPEC_FILE //Data resides in a fileSSPEC_FSFILE //The data resides in a file system fileSSPEC_FORM//Set of modifiable variablesSSPEC_FUNCTION //Data is a functionSSPEC_ROOTFILE //Data resides in root memorySSPEC_UNUSED //Indicates an unused entrySSPEC_VARIABLE //Data is a variable (for HTTP)SSPEC_XMEMFILE //Data resides in extended memorySSPEC_ROOTVAR//Data is a variable in root memorySSPEC_XMEMVAR//Data is a variable in xmem3.2.2 ServerSpec Vartype Field
If the object is a variable, then this field will tell you what type of variable it is:
INT8,INT16,INT32,PTR16,FLOAT323.2.3 Servermask field
The type of server (HTTP and/or FTP) that has access to a particular data structure is determined by the servermask field. Both
ServerSpecandServerAuthhave this field. It must be set when adding the structure to its array. The default is that no server has access.servermaskcan be one of the following, or any bitwise inclusive OR of these values:
SERVER_FTPfor use with the flash file system.
SERVER_HTTP
SERVER_USER //SERVER_WRITABLE //server will allow client(s) to write to its files.3.2.4 Configuration Macros
These constants define system limits on various data lengths and array sizes.
SSPEC_MAXNAME
Maximum length of strings in a
ServerSpecstructure entry. Default is 20.SSPEC_MAXSPEC
Sets the maximum number of entries in the global array,
server_spec.HTTP_MAXRAMSPEC(fromHTTP.LIB) should overrideSSPEC_MAXSPEC. If you attempt to use both you may not get the desired results, therefore, the use ofHTTP_MAXRAMSPECshould be deprecated. If bothHTTP_MAXRAMSPECandSSPEC_MAXSPECare not defined,SSPEC_MAXSPECdefaults to 10.SSPEC_XMEMVARLEN
Defines the size of the stack-allocated buffer used by
sspec_readvariable()when reading a variable in xmem. It defaults to 20.SAUTH_MAXNAME
Maximum length of strings in
ServerAuthstructure. Default is 20. Strings must include a null character, so with its default value of 20, strings in this structure may be at most 19 characters longSAUTH_MAXUSERS
Maximum number of users for a TCP/IP users list. Default is 10.
3.3 HTML Forms
Defining
FORM_ERROR_BUFis required to use the HTML form functionality inZserver.lib. The value assigned to this macro is the number of bytes to reserve in root memory for the buffer used for form processing. This buffer must be large enough to hold the name and value for each variable, plus four bytes for each variable.An array of type
FormVarmust be declared to hold information about the form variables. Be sure to allocate enough entries in the array to hold all of the variables that will go in the form. If more forms are needed, then more of these arrays can be allocated. Please see Section 4.3.4 on page 192 for an example program.3.4 Function Reference
The server utility API functions are described in this section. The functions give servers a consistent interface to files, variables and client information.
sauth_adduser
int sauth_adduser(char* username, char* password, word servermask);Description
Adds a user to the TCP/IP users list.
Parameters
username
password
servermask
Bitmask representing valid servers (e.g.
SERVER_HTTP,SERVER_FTP).Return value
-1: Failure.
≥0: Success; index in TCP/IP users list (id passed tosauth_getusername()).Library
See also
sauth_authenticate, sauth_getwriteaccess, sauth_setwriteaccess, sauth_removeuser
sauth_authenticate
int sauth_authenticate(char* username, char* password, word server);Description
Parameters
username
password
server
The server for which this function is authenticating (e.g.
SERVER_HTTP,SERVER_FTP).Return value
-1: Failure, user not valid.
≥0: Success, array index of theServerAuthstructure for authenticated user.Library
See also
sauth_getuserid
int sauth_getuserid(char* username, word server);Description
Gets the user index for a user.
Parameters
username
server
Server for which we are looking up.
Return value
≥
0: Success, index of user in the TCP/IP users list.-1: Failure.Library
sauth_getusername
char* sauth_getusername(int uid);Description
Gets a pointer to
usernamefrom theServerAuthstructure.Parameters
uid
The user's id, i.e., the array index in the TCP/IP users list.
Return value
NULL: Failure.!NULL: Success, pointer to theusernamestring.Library
See also
sauth_getwriteaccess
int sauth_getwriteaccess(int sauth);Description
Checks whether or not a user has write access.
Parameters
sauth
Index of the user in the TCP/IP users list.
Return value
0: User does not have write access.1: User has write access.-1: Failure.Library
See also
sauth_removeuser
int sauth_removeuser(int userid);Description
Remove the given user from the user list. IMPORTANT: Any associations of the given user with web pages should be changed. Otherwise, no one will have access to the unchanged web pages. Authentication can be turned off for a page with
sspec_setrealm(sspec, "").Parameters
userid
Return value
Library
See also
sauth_setpassword
int sauth_setpassword(int userid, char* password);Description
Parameters
userid
Index of user in TCP/IP users list.
password
Return value
Library
sauth_setwriteaccess
int sauth_setwriteaccess(int sauth, int writeaccess);Description
Sets the write accessibility of a user.
Parameters
sauth
Index of the user in the TCP/IP users list.
writeaccess
Set to
1to give write access,0to deny write access.Return value
Library
See also
sspec_addform
int sspec_addform(char* name, FormVar* form, int formsize, word servermask);Description
Adds a form (set of modifiable variables) to the TCP/IP servers' object list. Make sure that
SSPEC_MAXSPECis large enough to hold this new entry.This function is currently only useful for the HTTP server.Parameters
name
form
Pointer to the form array. This is a user-defined array to hold information about form variables.
formsize
servermask
Bitmask representing valid servers (currently only useful with
SERVER_HTTP)Return value
≥
0: Success; location of form in TCP/IP servers' object list.-1: Failed to add form.Library
SEE ALSO
sspec_addfsfile, sspec_addfunction, sspec_addrootfile, sspec_addvariable, sspec_addxmemvar, sspec_addxmemfile sspec_aliasspec, sspec_addfv
sspec_addfsfile
int sspec_addfsfile(char* name, byte filenum, word servermask);Description
Adds a file located in the file system to the TCP/IP servers' object list. Make sure that
SSPEC_MAXSPECis large enough to hold this new entry.Parameters
name
filenum
Number of the file in the file system.
servermask
Bitmask representing valid servers.
Return value
-1: Failure.
≥0: Success; location of file in TCP/IP servers' object list.Library
See also
sspec_addrootfile, sspec_addfunction, sspec_addvariable, sspec_addxmemfile, sspec_addform, sspec_aliasspec
sspec_addfunction
int sspec_addfunction(char* name, void (*fptr)(), word servermask);Description
Adds a function to the list of objects recognized by the server. Make sure that
SSPEC_MAXSPECis large enough to hold this new entry.This function is currently only useful for HTTP servers.Parameters
name
(*ftpr)()
servermask
Bitmask representing servers for which this function will be valid (currently only useful with
SERVER_HTTP).Return value
-1: Failure.
≥0: Success, location of the function in the TCP/IP servers' object list.Library
See also
sspec_addform, sspec_addfsfile, sspec_addrootfile, sspec_addvariable, sspec_addxmemfile, sspec_aliasspec
sspec_addfv
int sspec_addfv(int form, int var);Description
Parameters
form
Index of the form in the TCP/IP servers' object list.
var
Index of the variable in the TCP/IP servers' object list.
Return value
-1: Failure.
≥0: Success; next available index into theFormVararray.Library
sspec_addrootfile
int sspec_addrootfile(char* name, char* fileloc, int len, word servermask);Description
Adds a file that is located in root memory to the TCP/IP servers' object list. Make sure that
SSPEC_MAXSPECis large enough to hold this new entry.Parameters
name
fileloc
Pointer to the beginning of the file.
len
servermask
Bitmask representing servers for which this entry will be valid (e.g.
SERVER_HTTP,SERVER_FTP).Return value
-1: Failure.
≥0: Success, location of the file in the TCP/IP servers' object list.Library
See also
sspec_addfsfile, sspec_addxmemfile, sspec_addvariable, sspec_addfunction sspec_addform, sspec_aliasspec
sspec_addvariable
int sspec_addvariable(char* name, void* variable, word type, char* format, word servermask);Description
Adds a variable to the TCP/IP servers' object list. Make sure that
SSPEC_MAXSPECis large enough to hold this new entry.This function is currently only useful for the HTTP server.Parameters
name
variable
type
Type of the variable (e.g.,
INT8,INT16,PTR16, etc.).format
Output format of the variable.
servermask
Bitmask representing servers for which this function will be valid (currently only useful with
SERVER_HTTP).Return value
-1: Failure.
≥0: Success, the location of the variable in the TCP/IP servers' object list.Library
See also
sspec_addfsfile, sspec_addrootfile, sspec_addxmemfile, sspec_addfunction sspec_addform, sspec_aliasspec
sspec_addxmemfile
int sspec_addxmemfile(char* name, long fileloc, word servermask);Description
Adds a file, located in extended memory, to the TCP/IP servers' object list. Make sure that
SSPEC_MAXSPECis large enough to hold this new entry.Parameters
name
fileloc
Location of the beginning of the file. The first 4 bytes of the file must represent the length of the file (
#ximportdoes this automatically).servermask
Bitmask representing servers for which this entry will be valid (e.g.
SERVER_HTTP,SERVER_FTP).Return value
-1: Failure.
≥0: Success, the location of the file in the TCP/IP servers' object list.Library
See also
sspec_addfsfile, sspec_addrootfile, sspec_addvariable, sspec_addxmemvar, sspec_addfunction, sspec_addform, sspec_aliasspec
sspec_addxmemvar
int sspec_addxmemvar(char* name, long variable, word type, char* format, word servermask);Description
Add a variable located in extended memory to the TCP/IP servers' object list. Make sure that
SSPEC_MAXSPECis large enough to hold this new entry.Currently, this function is useful only for the HTTP server.Parameters
name
variable
Address of the variable in extended memory.
type
Variable type (e.g.,
INT8,INT16,PTR16, etc.).format
Output format of the variable.
servermask
Bitmask representing valid servers (currently only useful with
SERVER_HTTP).Return value
-1: Failure.
≥0: Success, the location of the variable in the TCP/IP servers' object list.Library
See also
sspec_addfsfile, sspec_addrootfile, sspec_addvariable, sspec_addfunction, sspec_addform, sspec_addxmemfile, sspec_aliasspec
sspec_aliasspec
int sspec_aliasspec(int sspec, char* name);Description
Creates an alias to an existing object in the TCP/IP servers' object list. Make sure that
SSPEC_MAXSPECis large enough to hold this new entry.Please note, this is NOT a deep copy. That is, any file, variable, or form that the alias references will be the same copy of the file, variable, or form that already exists in the TCP/IP servers' object list. This should be called only when the original entry has been completely set up.Parameters
sspec
Location of the object in the TCP/IP servers' object list that will be aliased.
name
Name field of the
ServerSpecstructure that will be aliased.Return value
-1: Failure.
≥0: Success; return location of alias, i.e., new indexLibrary
See also
sspec_addform, sspec_addfsfile, sspec_addfunction, sspec_addrootfile, sspec_addvariable, sspec_addxmemfile
sspec_checkaccess
int sspec_checkaccess(int sspec, int uid);Description
This function checks whether or not the specified user has permission to access the specified object in the TCP/IP servers' object list.
Parameters
sspec
Location of object in TCP/IP servers' object list.
uid
Location of the user in the TCP/IP users list.
Return value
0: User does not have access.1: User has access.-1: Failure.Library
See also
sspec_findfv
int sspec_findfv(int form, char* varname);Description
Finds the index in the array of type
FormVarof a form variable in a given form.Parameters
form
Location of the form in the TCP/IP servers' object list.
varname
Return value
-1: Failure.
≥0: Success; the index of the form variable in the array of typeFormVar.Library
sspec_findname
int sspec_findname(char* name, word server);Description
Finds the location of the object associated with
nameand returns the location (index into theserver_specarray) of the object if the server is allowed access to it. (Access is determined by theservermaskfield in theServerSpecstructure for the object.)Parameters
name
Name to search for in the TCP/IP servers' object list.
server
The server making the request (e.g.
SERVER_HTTP).Return value
-1: Failure.
≥0: Success, location of the object in the TCP/IP servers' object list.Library
See also
sspec_findnextfile
int sspec_findnextfile(int start, word server);Description
Finds the first
ServerSpecstructure in the array, at or following the structure indexed bystart,that is associated with a file and that is accessible by the server.Parameters
start
The array index at which to begin the search.
server
The server making the request (e.g.
SERVER_HTTP).Return value
-1: Failure.
≥0: Success, index of requestedServerSpecstructure.Library
See also
sspec_getfileloc
long sspec_getfileloc(int sspec);Description
Gets the location in memory or in the file system of a file represented by a
ServerSpecstructure. Note that the location of the file is returned as a long; the return value should be cast to the appropriate type (char*for a root file,FileNumfor the file system) by the user.sspec_getfiletype()can be used to find the file type.Parameters
sspec
Index into the array of
ServerSpecstructures.Return value
≥
0: Success, location of the file.-1: Failure.Library
See also
sspec_getfiletype, sspec_getlength
sspec_getfiletype
word sspec_getfiletype(int sspec);Description
Gets the type of a file represented by a
ServerSpecstructure.Parameters
sspec
Index into the array of
ServerSpecstructures.Return value
SSPEC_ERROR: Failure.!=SSPEC_ERROR: Success, the type of file.Library
See also
sspec_getfileloc, sspec_gettype
sspec_getformtitle
char* sspec_getformtitle(int form);Description
Gets the title for an automatically generated form.
Parameters
form
server_specindex of the form.Return value
NULL: Failure.!NULL: Success, title string.Library
sspec_getfunction
void* sspec_getfunction(int sspec);Description
Accesses the array of
ServerSpecstructures to get a pointer to the requested function.Parameters
sspec
Index into the array of
ServerSpecstructures.Return value
NULL: Failure.!NULL: Success, pointer to requested function.Library
See also
sspec_getfvdesc
char* sspec_getfvdesc(int form, int var);Description
Gets the description of a variable that is displayed in the HTML form table.
Parameters
form
server_specindex of the form.var
Index (into the
FormVararray) of the variable.Return value
NULL: Failure.!NULL: Success, description string.Library
sspec_getfventrytype
int sspec_getfventrytype(int form, int var);Description
Gets the type of form entry element that should be used for the given variable.
Parameters
form
server_specindex of the form.var
Index (into the
FormVararray) of the variable.Return value
-1: Failure;
Type of form entry element on success:HTML_FORM_TEXTis a text box.HTML_FORM_PULLDOWNis a pull-down menu.Library
sspec_getfvlen
int sspec_getfvlen(int form, int var);Description
Gets the length of a form variable (the maximum length of the string representation of the variable).
Parameters
form
server_specindex of the form.var
Index (into the
FormVararray) of the variable.Return value
-1: Failure.>0: Success, length of the variable.Library
sspec_getfvname
char* sspec_getfvname(int form, int var);Description
Gets the name of a variable that is displayed in the HTML form table.
Parameters
form
server_specindex of the form.var
Index into the array of
FormVarstructures of the variable.Return value
NULL: Failure.!NULL, name of the form variable.Library
sspec_getfvnum
int sspec_getfvnum(int form);Description
Gets the number of variables in a form.
Parameters
form
server_specindex of the form.Return value
-1: Failure.
≥0: Success, number of form variables.Library
sspec_getfvopt
char* sspec_getfvopt(int form, int var, int option);Description
Gets the numbered option (starting from 0) of the form variable. This function is only valid if the form variable has the option list set.
Parameters
form
server_specindex of the form.var
Index into the array of
FormVarstructures of the variable.option
Index of the form variable option.
Return value
NULL: Failure.!NULL: Success, form variable option.Library
sspec_getfvoptlistlen
int sspec_getfvoptlistlen(int form, int var);Description
Gets the length of the options list of the form variable. This function is only valid if the form variable has the option list set.
Parameters
form
server_specindex of the form.var
Index (into the
FormVararray) of the variable.Return value
-1: Failure.>0: Success, length of the options list.Library
sspec_getfvreadonly
int sspec_getfvreadonly(int form, int var);Description
Checks if a form variable is read-only.
Parameters
form
server_specindex of the form.var
Index (into the
FormVararray) of the variable.Return value
0: Read-only.1: Not read-only.-1: Failure.Library
sspec_getfvspec
int sspec_getfvspec(int form, int var);Description
Gets the
server_specindex of a variable in a form.Parameters
form
server_specindex of the form.var
Index into the array of
FormVarstructures of the variable.Return value
-1: Failure.
≥0: Success, location of the form variable in the TCP/IP servers' object list.Library
sspec_getlength
long sspec_getlength(int sspec);Description
Gets the length of the file associated with the specified
ServerSpecstructure.Parameters
sspec
Location of file in TCP/IP servers' object list.
Return value
-1: Failure.
≥0: Success, length of the file in bytes.Library
See also
sspec_readfile, sspec_getfileloc
sspec_getname
char* sspec_getname(int sspec);Description
Accesses the array of
ServerSpecstructures and returns a pointer to the object's name.Parameters
sspec
Location of object in TCP/IP servers' object list.
Return value
NULL: Failure.
!NULL: Success, pointer to name string.Library
sspec_getpreformfunction
void* sspec_getpreformfunction(int form);Description
Gets the user function that will be called just before HTML form generation. This function is useful mainly for custom form generation functions.
Parameters
form
Return value
NULL: No user function.!NULL: Pointer to user function.Library
See also
sspec_setpreformfunction, sspec_setformfunction
sspec_getrealm
char* sspec_getrealm(int sspec);Description
Returns the realm for the object.
Parameters
sspec
Location of the object in the TCP/IP servers' object list.
Return value
NULL: Failure.!NULL: Success, pointer to the realm string.Library
See also
sspec_gettype
word sspec_gettype(int sspec);Description
Gets the
typefield of aServerSpecstructure.Parameters
sspec
Location of the object in the TCP/IP servers' object list.
Return value
SSPEC_ERROR: Failure.typefield: Success (See Constants Used in Zserver.lib). For files and variables, it returns the generic typeSSPEC_FILEorSSPEC_VARIABLE, respectively.Library
See also
sspec_getfiletype, sspec_getvartype
sspec_getusername
char* sspec_getusername(int sspec);Description
Gets the username field of a
ServerAuthstructure.Parameters
sspec
Location of user in TCP/IP users list.
Return value
NULL: Failure.!NULL: Success, pointer tousername.Library
See also
sspec_getvaraddr
void* sspec_getvaraddr(int sspec);Description
Returns a pointer to the requested variable in the TCP/IP servers' object list.
Parameters
sspec
Location of the variable in the TCP/IP servers' object list.
Return value
NULL: Failure.!NULL: Success, pointer to variable.Library
See also
sspec_getvarkind
word sspec_getvarkind(int sspec);Description
Returns the kind of variable represented by
sspec(INT8,INT16,INT32,FLOAT32, orPTR16).Parameters
sspec
Location of the variable in the TCP/IP servers' object list.
Return value
0: Failure.INT8|INT16|INT32|FLOAT32|PTR16: Success.Library
See also
sspec_getvaraddr, sspec_getvartype, sspec_gettype
sspec_getvartype
word sspec_getvartype(int sspec);Description
Gets the type of the variable in the TCP/IP servers' object list.
Parameters
sspec
Location of the variable in the TCP/IP servers' object list.
Return value
SSPEC_ERROR: Failure.SSPEC_ROOTVARorSSPEC_XMEMVAR: Success.Library
See also
sspec_getvaraddr, sspec_getvarkind, sspec_gettype
sspec_needsauthentication
int sspec_needsauthentication(int sspec);Description
Checks if an object in the TCP/IP servers' object list needs user authentication to permit access. There is a field in the
ServerSpecstructure that is an index into the array ofServerAuthstructures (list of valid users). If this field has a value, access to the object is limited to the one user specified.Parameters
sspec
Index into the array of
ServerSpecstructures.Return value
0: Does not need authentication.1: Does need authentication.-1: Failure.Library
See also
sspec_readfile
int sspec_readfile(int sspec, char* buffer, long offset, int len);Description
Read a file represented by the
sspecindex intobuffer, starting atoffset, and only copyinglenbytes. For xmem files, this function automatically skips the first 4 bytes. Hence, an offset of 0 marks the beginning of the file contents, not the file length.Parameters
sspec
Index into the array of
ServerSpecstructures.buffer
The buffer to put the file contents into.
offset
The offset from the start of the file, in bytes, at which copying should begin.
len
Return value
-1: Failure.
≥0: Success, number of bytes copied.Library
See also
sspec_getlength, sspec_getfileloc
sspec_readvariable
int sspec_readvariable(int sspec, char* buffer);Description
Formats the variable associated with the specified
ServerSpecstructure, and puts aNULL-terminated string representation of it inbuffer. The macroSSPEC_XMEMVARLEN(default is 20) defines the size of the stack-allocated buffer when reading a variable in xmem.Parameters
sspec
Index into the array of
ServerSpecstructures.buffer
The buffer in which to put the variable.
Return value
Library
See also
sspec_remove
int sspec_remove(int sspec);Description
Removes an object from the TCP/IP servers' object list.
Parameters
sspec
Index into the array of
ServerSpecstructures.Return value
0: Success.-1: Failure (i.e. the index is already unused).Library
sspec_restore
int sspec_restore(void);Description
Restores the TCP/IP servers' object list and the TCP/IP users list (and some user-specified data if set up with
sspec_setsavedata()) from the file system. This does not restore the actual files and variables, but only the structures that reference them. If the files are stored in flash, then the references will still be valid. Files in volatile RAM and variables must be rebuilt through other means.Return value
Library
See also
sspec_save
int sspec_save(void);Description
Saves the servers' object list and server authorization list (along with some user-specified data if set up with
sspec_setsavedata()) to the file system. This does not save the actual files and variables, but only the structures that reference them. If the files are stored in flash, then the references will still be valid. Files in volatile RAM and variables must be rebuilt through other means.Return value
Library
See also
sspec_restore, sspec_setsavedata
sspec_setformepilog
int sspec_setformepilog(int form, int function);Description
Sets the user-specified function that will be called when the form has been successfully submitted. This function can, for example, execute a
cgi_redirecttoto redirect to a specific page. It should accept "HttpState* state" as an argument, return 0 when it is not finished, and 1 when it is finished (i.e., behave like a normal CGI function).Parameters
form
Index into the array of
ServerSpecstructures.function
Index into the array of
ServerSpecstructures. This is the return value of the functionsspec_addfunction().Return value
Library
See also
sspec_setformfunction
int sspec_setformfunction(int form, void (*fptr)());Description
Sets the function that will generate the form.
Parameters
form
server_specindex of the form.fptr
Form generation function (
NULLfor the default function).Return value
Library
sspec_setformprolog
int sspec_setformprolog(int form, int function);Description
Allows a user-specified function to be called just before form variables are updated. This is useful for implementing locking on the form variables (which can then be unlocked in the epilog function), so that other code will not update the variables during form processing. The user-specified function
should accept "HttpState* state" as an argument, return 0 when it is not finished, and 1 when it is finished (i.e., behave like a normal CGI function).Parameters
form
Index into the array of
ServerSpecstructures.function
Index into the array of
ServerSpecstructures. This is the return value ofsspec_addfunction().Return value
Library
See also
sspec_setformtitle
int sspec_setformtitle(int form, char* title);Description
Sets the title for an automatically generated form.
Parameters
form
server_specindex of the form.title
Return value
Library
sspec_setfvcheck
int sspec_setfvcheck(int form, int var, int (*varcheck)());Description
Sets a function that can be used to check the integrity of a variable. The function should return 0 if there is no error, or !0 if there is an error.
Parameters
form
server_specindex of the form.var
Index (into the
FormVararray) of the variable.varcheck
Pointer to integrity-checking function.
Return value
Library
sspec_setfvdesc
int sspec_setfvdesc(int form, int var, char* desc);Description
Sets the description of a variable that is displayed in the HTML form table.
Parameters
form
server_specindex of the form.var
Index (into the
FormVararray) of the variable.desc
Description of the variable. This text will display on the html page.
Return value
Library
sspec_setfventrytype
int sspec_setfventrytype(int form, int var, int entrytype);Description
Sets the type of form entry element that should be used for the given variable.
Parameters
form
server_specindex of the form.var
Index (into the
FormVararray) of the variable.entrytype
HTML_FORM_TEXTfor a text box,HTML_FORM_PULLDOWNfor a pull-down menu. The default isHTML_FORM_TEXT.Return value
Library
sspec_setfvfloatrange
int sspec_setfvfloatrange(int form, int var, float low, float high);Description
Parameters
form
server_specindex of the form.var
Index (into the
FormVararray) of the variable.low
Minimum value of the variable.
high
Maximum value of the variable.
Return value
Library
sspec_setfvlen
int sspec_setfvlen(int form, int var, int len);Description
Sets the length of a form variable (the maximum length of the string representation of the variable).
Parameters
form
server_specindex of the form.var
Index (into the
FormVararray) of the variable.len
Return value
Library
sspec_setfvname
int sspec_setfvname(int form, int var, char* name);Description
Sets the name of a variable that is displayed in the HTML form table.
Parameters
form
server_specindex of the form.var
Index (into the
FormVararray) of the variable.name
Return value
Library
sspec_setfvoptlist
int sspec_setfvoptlist(int form, int var, char* list[], int listlen);Description
Sets an enumerated list of possible values for a string variable.
Parameters
form
server_specindex of the form.var
Index (into the
FormVararray) of the variable.list[]
Array of string values that the variable can assume.
listlen
Return value
Library
sspec_setfvrange
int sspec_setfvrange(int form, int var, long low, long high);Description
Parameters
form
server_specindex of the form.var
Index (into the
FormVararray) of the variable.low
Minimum value of the variable.
high
Maximum value of the variable.
Return value
Library
sspec_setfvreadonly
int sspec_setfvreadonly(int form, int var, int readonly);Description
Sets the form variable to be read-only.
Parameters
form
server_specindex of the form.var
Index (into the
FormVararray) of the variable.readonly
0for read/write (this is the default);1for read-only.Return value
Library
sspec_setpreformfunction
int sspec_setpreformfunction(int form, void (*fptr)());Description
Sets a user function that will be called just before form generation. The user function is not called when the form is being generated because of errors in the form input. The user function must have the following prototype:
void userfunction(int form);The function may not use the parameter, but it is useful if the same user function is used for multiple forms.
Parameters
form
fptr
Pointer to user function to be called just before form generation
Return value
Library
See also
sspec_setrealm
int sspec_setrealm(int sspec, char* realm);Description
Sets the realm field of a
ServerSpecstructure for HTTP authentication purposes. Setting this field enables authentication for the given entry in the TCP/IP servers' object list. Authentication can be turned off again by passing "" as the realm parameter to this function.Parameters
sspec
Index into the array of
ServerSpecstructures.realm
Return value
Library
See also
sspec_setsavedata
int sspec_setsavedata(char* data, unsigned long len, void* fptr);Description
Sets user-supplied data that will be saved in addition to the spec and user authentication tables when
sspec_save()is called.Parameters
data
Pointer to location of user-supplied data.
len
Length of the user-supplied data in bytes.
fptr
Pointer to a function that will be called when the user-supplied data has been restored
Return value
Library
See also
sspec_setuser
int sspec_setuser(int sspec, int uid);Description
Sets the user (owner) of a
ServerSpecstructure.Parameters
sspec
Index into the array of
ServerSpecstructures.uid
Index into the array of
ServerAuthstructures (identifies user).Return value
Library
See also
sauth_adduser, sspec_getusername
| Z-World http://www.zworld.com Voice: 530.757.3737 Fax: 530.757.3792 or 530.753.5141 sales@zworld.com |