Previous Contents Index Next |
Sun Java System Application Server Standard and Enterprise Edition 7 2004Q2 Developer's Guide to NSAPI

> ## Appendix A
> Data Structure Reference

> NSAPI uses many data structures which are defined in the nsapi.h header file, which is in the directory install_dir/include.

> The NSAPI functions described in Chapter 6, “NSAPI Function Reference,” provide access to most of the data structures and data fields. Before directly accessing a data structure in naspi.h, check if an accessor function exists for it.

> For information about the privatization of some data structures in iPlanet Web Server 4.x, see Privatization of Some Data Structures.

> The rest of this chapter describes some of the frequently used public data structures in nsapi.h for your convenience. Note that only the most commonly used fields are documented here for each data structure; for complete details look in nsapi.h.

> - session
> - pblock
> - pb_entry
> - pb_param
> - Session->client
> - request
> - stat
> - shmem_s
> - cinfo

> ##

> Privatization of Some Data Structures

> In iPlanet Web Server 4.x, some data structures were moved from nsapi.h to nsapi_pvt.h. The data structures in nsapi_pvt.h are now considered to be private data structures, and you should not write code that accesses them directly. Instead, use accessor functions. We expect that very few people have written plug-ins that access these data structures directly, so this change should have very little impact on customer-defined plug-ins. Look in nsapi_pvt.h to see which data structures have been removed from the public domain and to see the accessor functions you can use to access them from now on.

> Plug-ins written for Enterprise Server 3.x that access contents of data structures defined in nsapi_pvt.h will not be source compatible with In iPlanet Web Server 4.x and 6.x, that is, it will be necessary to #include "nsapi_pvt.h" in order to build such plug-ins from source. There is also a small chance that these programs will not be binary compatible with iPlanet Web Server 4.x and 6.x, because some of the data structures in nsapi_pvt.h have changed size. In particular, the directive structure is larger, which means that a plug-in that indexes through the directives in a dtable will not work without being rebuilt (with nsapi_pvt.h included).

> We hope that the majority of plug-ins do not reference the internal data structures in nsapi_pvt.h, and therefore that most existing NSAPI plug-ins will be both binary and source compatible with Sun Java System Application Server 7.

> ##

> session

> A session is the time between the opening and closing of the connection between the client and the server. The Session data structure holds variables that apply session wide, regardless of the requests being sent, as shown here:

> typedef struct {
> /* Information about the remote client */
> pblock *client;
> /* The socket descriptor to the remote client */
> SYS_NETFD csd;
> /* The input buffer for that socket descriptor */
> netbuf *inbuf;
> /* Raw socket information about the remote */
> /* client (for internal use) */
> struct in_addr iaddr;
> } Session;

> ##

> pblock

> The parameter block is the hash table that holds pb_entry structures. Its contents are transparent to most code. This data structure is frequently used in NSAPI; it provides the basic mechanism for packaging up parameters and values. There are many functions for creating and managing parameter blocks, and for extracting, adding, and deleting entries. See the functions whose names start with pblock_ in Chapter 6, “NSAPI Function Reference.” You should not need to write code that access pblock data fields directly.

> typedef struct {
> int hsize;
> struct pb_entry **ht;
> } pblock;

> ##

> pb_entry

> The pb_entry is a single element in the parameter block.

> struct pb_entry {
> pb_param *param;
> struct pb_entry *next;
> };

> ##

> pb_param

> The pb_param represents a name-value pair, as stored in a pb_entry.

> typedef struct {
> char *name,*value;
> } pb_param;

> ##

> Session->client

> The Session->client parameter block structure contains two entries:

> - The ip entry is the IP address of the client machine.
> - The dns entry is the DNS name of the remote machine. This member must be accessed through the session_dns function call:

> /*
> * session_dns returns the DNS host name of the client for this
> * session and inserts it into the client pblock. Returns NULL if
> * unavailable.
> */
> char *session_dns(Session *sn);

> ##

> request

> Under HTTP protocol, there is only one request per session. The Request structure contains the variables that apply to the request in that session (for example, the variables include the client’s HTTP headers).

> typedef struct {
> /* Server working variables */
> pblock *vars;
> /* The method, URI, and protocol revision of this request */
> block *reqpb;
> /* Protocol specific headers */
> int loadhdrs;
> pblock *headers;
> /* Server’s response headers */
> pblock *srvhdrs;
> /* The object set constructed to fulfill this request */
> httpd_objset *os;
> /* The stat last returned by request_stat_path */
> char *statpath;
> struct stat *finfo;
> } Request;

> ##

> stat

> When a program calls the stat( ) function for a given file, the system returns a structure that provides information about the file. The specific details of the structure should be obtained from your platform’s implementation, but the basic outline of the structure is as follows:

> struct stat {
> dev_t st_dev; /* device of inode */
> inot_t st_ino; /* inode number */
> short st_mode; /* mode bits */
> short st_nlink; /* number of links to file /*
> short st_uid; /* owner’s user id */
> short st_gid; /* owner’s group id */
> dev_t st_rdev; /* for special files */
> off_t st_size; /* file size in characters */
> time_t st_atime; /* time last accessed */
> time_t st_mtime; /* time last modified */
> time_t st_ctime; /* time inode last changed*/
> }

> The elements that are most significant for server plug-in API activities are st_size, st_atime, st_mtime, and st_ctime.

> ##

> shmem_s

> typedef struct {
> void *data; /* the data */
> HANDLE fdmap;
> int size; /* the maximum length of the data */
> char *name; /* internal use: filename to unlink if
> exposed */
> SYS_FILE fd; /* internal use: file descriptor for
> region */
> } shmem_s;

> ##

> cinfo

> The cinfo data structure records the content information for a file.

> typedef struct {
> char *type;
> /* Identifies what kind of data is in the file */
> char *encoding;
> /* encoding identifies any compression or other /*
> /* content-independent transformation that’s been /*
> /* applied to the file, such as uuencode) */
> char *language;
> /* Identifies the language a text document is in. */
> } cinfo;

> Previous Contents Index Next

> Copyright 2004 Sun Microsystems, Inc. All rights reserved.