ObjectType Example
Chapter
6
Examples of Custom SAFs
227
The
html2shtml
function looks at the requested file name. If it ends with
.html
,
the function looks for a file with the same base name, but with the extension
.shtml
instead. If it finds one, it uses that path and informs the server that the file
is parsed HTML instead of regular HTML. Note that this requires an extra
stat
call
for every HTML file accessed.
Installing the Example
To load the shared object containing your function, add the following line in the
Init
section of the
magnus.conf
file:
Init fn=load-modules shlib=
yourlibrary
funcs=html2shtml
To execute the custom SAF during the request-response process for some object,
add the following line to that object in the
obj.conf
file:
ObjectType fn=html2shtml
Source Code
The source code for this example is in
otype.c
in the
nsapi/examples/
or
plugins/nsapi/examples
subdirectory within the server root directory.
#include "nsapi.h"
#include <string.h>
/* strncpy */
#include "base/util.h"
#ifdef __cplusplus
extern "C"
#endif
NSAPI_PUBLIC int html2shtml(pblock *pb, Session *sn, Request *rq)
{
/* No parameters */
/* Set the content-type to magnus-internal/parsed-html */
pblock_nvinsert("content-type", "magnus-internal/parsed-html",
rq->srvhdrs);
Содержание ENTERPRISE SERVER 6.1
Страница 1: ...NSAPI Programmer s Guide Netscape Enterprise Server Version6 1 April 2002 Draft...
Страница 18: ...Where to Find Related Information 18 Netscape Enterprise Server NSAPI Programmer s Guide April 2002 Draft...
Страница 138: ...CGI to NSAPI Conversion 138 Netscape Enterprise Server NSAPI Programmer s Guide April 2002 Draft...
Страница 214: ...NSAPI Functions in Alphabetical Order 214 Netscape Enterprise Server NSAPI Programmer s Guide April 2002 Draft...
Страница 290: ...Miscellaneous 290 Netscape Enterprise Server NSAPI Programmer s Guide April 2002 Draft...
Страница 310: ...The Netscape LDAP Schema 310 Netscape Enterprise Server NSAPI Programmer s Guide April 2002 Draft...
Страница 318: ...cinfo 318 Netscape Enterprise Server NSAPI Programmer s Guide April 2002 Draft...
Страница 324: ...Sample MIME Types File 324 Netscape Enterprise Server NSAPI Programmer s Guide April 2002 Draft...
Страница 336: ...Buffered Streams 336 Netscape Enterprise Server NSAPI Programmer s Guide April 2002 Draft...
Страница 344: ...344 Netscape Enterprise Server NSAPI Programmer s Guide April 2002 Draft...
Страница 350: ...350 Netscape Enterprise Server NSAPI Programmer s Guide April 2002 Draft...
Страница 356: ...356 Netscape Enterprise Server NSAPI Programmer s Guide April 2002 Draft...