Download Dynamic C TCP/IP Users Manual

Transcript
The following structures are documented for historical reasons:
• FormVar
• SSpecFileHandle
3.1.1 MIMETypeMap Structure
This structure, organized into a table, associates a file extension with a MIME type (Multipurpose Internet
Mail Extension) and a function that handles the MIME type. Users can override HTTP_MAXNAME
(defaults to 20 characters) in their source file. If the function pointer given is NULL, then the default handler (which sends the content verbatim) is used.
typedef struct {
char extension[10];
char type[HTTP_MAXNAME];
int (*fptr)(/* HttpState* */);
} MIMETypeMap;
For example, to create an HTTP server that can serve files with html or gif extensions, the following declaration is required in the application code:
SSPEC_MIMETABLE_START
SSPEC_MIME(".html", "text/html"),
SSPEC_MIME(".gif", "image/gif"),
SSPEC_MIMETABLE_END
Use of the above macros is the recommended method for maintaining forward compatibility. For more
information, see Section 3.2.5.2 "Static MIME Type Table." All these macros are doing is generating the
correct C syntax for a static constant initializer.
Note that servers that do not implement MIME, such as FTP, do not require a MIME table to be defined.
Currently, this table is required only for HTTP.
32
rabbit.com
Server Utility Library