Service Example
Chapter
6
Examples of Custom SAFs
231
/* Write the output using net_write*/
return_value = net_write(sn->csd, simple_msg,
strlen(simple_msg));
if (return_value == IO_ERROR) {
return REQ_EXIT;
}
return REQ_PROCEED;
}
More Complex Service Example
The
send-images
function is a custom SAF which replaces the
doit.cgi
demonstration available on the Netscape home pages. When a file is accessed as
/dir1/dir2/something.picgroup
, the
send-images
function checks if the file is
being accessed by a
Mozilla/1.1
browser. If not, it sends a short error message.
The file
something.picgroup
contains a list of lines, each of which specifies a
filename followed by a content-type (for example,
one.gif image/gif
).
To load the shared object containing your function, add the following line at the
beginning of the
magnus.conf
file:
Init fn=load-modules shlib=
yourlibrary
funcs=send-images
Also, add the following line to the
mime.types
file:
type=magnus-internal/picgroup exts=picgroup
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 (
send-images
takes an
optional parameter,
delay
, which is not used for this example):
The source code is in
service.c
in the
nsapi/examples/
or
plugins/nsapi/examples
subdirectory within the server root directory.
Service method=(GET|HEAD) type=magnus-internal/picgroup
fn=send-images
Summary of Contents for ENTERPRISE SERVER 6.1
Page 1: ...NSAPI Programmer s Guide Netscape Enterprise Server Version6 1 April 2002 Draft...
Page 290: ...Miscellaneous 290 Netscape Enterprise Server NSAPI Programmer s Guide April 2002 Draft...
Page 318: ...cinfo 318 Netscape Enterprise Server NSAPI Programmer s Guide April 2002 Draft...
Page 336: ...Buffered Streams 336 Netscape Enterprise Server NSAPI Programmer s Guide April 2002 Draft...
Page 344: ...344 Netscape Enterprise Server NSAPI Programmer s Guide April 2002 Draft...
Page 350: ...350 Netscape Enterprise Server NSAPI Programmer s Guide April 2002 Draft...
Page 356: ...356 Netscape Enterprise Server NSAPI Programmer s Guide April 2002 Draft...