@CHIP-RTOS - Data Structures used in CGI API
IPC@CHIP® Documentation Index
Data Structures
Here are the data structures used by the CGI API.
All constants and data structures are defined in the header file cgi.h
Notes:
- Byte alignment is required
for all data structures used within the API.
Contents
:
typedef CGI_Entry
| typedef struct tag_cgi_table
{
char *PathPtr; // Name of the page, URL
int method; // http method: Get, Head or Post
RpCgiFuncPtr CgiFuncPtr; // ptr to callback function for this page
} CGI_Entry; |
Comments
- The members of the CGI_Entry structure should be filled as follows.
PathPtr
This is a far pointer to a zero terminated URL address of the page.
method
This int is an enumerator
used to specify what HTTP method this CGI function supports.
CgiFuncPtr
This is a far vector to the CGI function for this Web page.
For Borland C compilers the RpCgiFuncPtr type is:
typedef void (huge _pascal *RpCgiFuncPtr)
(rpCgi far *CgiRequestPtr);
... and therefore the CGI function itself is declared as ...
void huge _pascal CGI_Func(rpCgi far *CgiRequest);
For Microsoft Visual C compilers the RpCgiFuncPtr type is:
typedef void far _saveregs _loadds _pascal
(*RpCgiFuncPtr)(rpCgi far *CgiRequestPtr);
... and the CGI function declared as ...
void far _saveregs _loadds _pascal
CGI_Func(rpCgi far *CgiRequest);
Related Topics
-
- API function CGI_INSTALL - Install a CGI function
-
- rpCgi structure type
Top of list Index page
define CGI HTTP Request
| #define CgiHttpGet 1 // Cgi request is HTTP GET
#define CgiHttpHead 2 // Cgi request is HTTP HEAD
#define CgiHttpPost 3 // Cgi request is HTTP POST
#define CgiHttpAll 255 // Cgi request handler for all methods |
Comments
- These defines are used as enumeration names for request methods.
Related Topics
-
- method member of CGI_Entry type
Top of list Index page
typedef FormItem
| typedef struct tag_form_item
{
char *NamePtr;
char *ValuePtr;
} FormItem; |
Comments
- Both strings referenced here are null terminated.
Related Topics
-
- API function CGI_GETFORMITEM - Split a form item
into name and value
Top of list Index page
typedef rpCgi
| typedef struct {
//******************************************************
// Request fields (Read Only!!!!)
//******************************************************
unsigned char fConnectionId; // SC1x3/SC2x: 0=HTTP/1=HTTPS (SSL) server
// SC1x: -- internal use only --
int fHttpRequest; // get, post, head
char *fPathPtr; // URL
char *fHostPtr; // Host
char *fRefererPtr; // Referer (SC1x3/SC2x only)
char *fAgentPtr; // Agent (SC1x3/SC2x only)
char *fLanguagePtr; // Accept-Language (SC1x3/SC2x only)
unsigned long fBrowserDate; // Date: (internal)
char *fArgumentBufferPtr; // Pointer to argument buf
long fArgumentBufferLength; // Length of argument buf
char *fUserNamePtr; // Username from Authorization
char *fPasswordPtr; // Password from Authorization
long *fRemoteIPPtr; // points to the remoteIP,
// you must split the octets
// For using the IP to etsablish TCP/IP
// connections, you have to exchange
// lowbyte and highbyte!
//******************************************************
// Response fields (Set by CGI function)
//******************************************************
int fResponseState; // -- internal, do not modify --
int fHttpResponse; // Response httpmsg e.g. CgiHttpOk
int fDataType; // Content type, e.g. text/HTML, text/plain
char *fResponseBufferPtr; // Pointer to the created page
long fResponseBufferLength; // Length of the page
// (on SC1x: max. length is 65519 chars)
unsigned long fObjectDate; // -- internal, do not modify --
unsigned int fHostIndex; // -- internal, do not modify --
} rpCgi, *rpCgiPtr; |
Comments
- fHttpResponse
fDataType
fRemoteIPPtr
This is an unsigned long value that represents the IPv4 address of the
remote host. To get the string representation of the IP address use the
following code:
On SC1x:
sprintf( ipString, "%d.%d.%d.%d",
(int)( ( *( CgiRequest->fRemoteIPPtr ) & 0xFF000000l ) >> 24 ),
(int)( ( *( CgiRequest->fRemoteIPPtr ) & 0x00FF0000l ) >> 16 ),
(int)( ( *( CgiRequest->fRemoteIPPtr ) & 0x0000FF00l ) >> 8 ),
(int)( *( CgiRequest->fRemoteIPPtr ) & 0x000000FFl ) );
On SC1x3/SC2x:
InetToAscii((const unsigned long far *)CgiRequest->fRemoteIPPtr, ipString);
Related Topics
-
- CGI Callback Function
Top of list Index page
typedef CUSTOM_MIMETYPES_TABLE
| typedef struct
{
unsigned int mimeId; // enum value, >= 100 for new types
char far* mimeExt; // file extension, e.g. "gif"
char far* mimeType; // mime type, e.g. "image/gif"
} CUSTOM_MIMETYPES_TABLE; |
Comments
- mimeId
This is an enumeration type. If the value is equal to the
internal used fDatatype value,
the MIME type value is overwritten for this ID. For new custom MIME types,
values greater 100 should be used.
mimeExt
On Sc1x only three letter extensions are allowed.
Related Topics
-
- API function CGI_MIME_INSTALL - Install custom MIME table
Top of list Index page
typedef CUSTOM_CONTENTENCODING_TABLE
| typedef char far *CUSTOM_CONTENTENCODING_TABLE; |
Comments
- Contains the null terminated string which will be send to the browser. A
Null pointer or an empty string will be identified as no encoding type. In
that case the http content-encoding header will not created.
Related Topics
-
- API function CGI_CONTENT_ENCODING_INSTALL - Install custom content encoding table
Top of list Index page
typedef SSI_Params
| typedef struct
{
unsigned char structVersion; // Version of this struct, for future extenstions of this struct.
// Set to zero for current version V0.
unsigned char serverHandle; // V0 member, Server handle
// 0 = HTTP / 1 = HTTPS (SSL) server
struct sockaddr_storage * peerSockAddr; // V0 member, Peer socket address
struct sockaddr_storage * localSockAddr; // V0 member, Local socket address
char * pathPtr; // V0 member, URL path name
char * hostPtr; // V0 member, Host name
char * userNamePtr; // V0 member, User name from authorization
char * passwordPtr; // V0 member, Password from authorization
} SSI_Params; |
Related Topics
-
- See sockaddr_storage data structure definition
Top of list Index page
End of document
|