Server data structures

he server plug-in API uses many data structures. All their definitions are gathered here for your convenience.

The Session data structure

A session is the time between the opening and the 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 in the following code. It is defined in the base/session.h file.

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;

The parameter block (pblock) data structure

The parameter block is the hash table that holds pb_entry structures. Its contents are transparent to most code. It is defined in the base/pblock.h file.

#include "base/pblock.h"
typedef struct { 
	int hsize; 
	struct pb_entry **ht; 
} pblock;

The pb_entry data structure

The pb_entry is a single element in the parameter block. It is defined in the base/pblock.h file.

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

The pb_param data structure

The pb_param represents a name-value pair, as stored in a pb_entry. It is defined in the base/pblock.h file.

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

The Client parameter block

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

It is defined in the base/session.h file.

/* 
* 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);

The Request data structure

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). It is declared in the frame/req.h file.

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;

The stat data structure

When the 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 must be obtained from your own 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.

The shared memory structure shmem_s

typedef struct { 
void *data;   /* the data */ 
	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;

The netbuf data structure

The netbuf is a platform-independent network-buffering structure that maintains such members as buffer address, position within buffer, current file size, maximum file size, and so on. Details of its structure vary between implementations. It is defined in buffer.h.

The filebuffer data structure

The filebuffer is a platform-independent file-buffering structure that maintains such members as buffer address, file position, current file size, and so on. Details of its structure vary between implementations. It is defined in buffer.h.

The cinfo data structure

The cinfo data structure records the content info for a file. It is defined in cinfo.h.

typedef struct { 
	char *type;		/* Identifies what kind of data is in the file*/ 
	char *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;

The SYS_NETFD data structure

The SYS_NETFD data structure is a platform-independent socket descriptor. Details of its structure vary between implementations.

The SYS_FILE data structure

The SYS_FILE data structure is a platform-independent file descriptor. Details of its structure vary between implementations.

The SEMAPHORE data structure

The SEMAPHORE data structure is a platform-independent implementation of semaphores. Details of its structure vary between implementations. It is defined in sem.h.

The sockaddr_in data structure

The socaddr_in data structure is a platform-dependent socket address. You can find more information in netinet/in.h.

The CONDVAR data structure

The CONDVAR data structure is a platform-independent implementation of a condition variable. Details of its structure may vary between implementations. It is defined in crit.h.

The CRITICAL data structure

The CRITICAL data structure is a platform-independent implementation of a critical-section variable. Details of its structure may vary between implementations. It is defined in crit.h.

The SYS_THREAD data structure

The SYS_THREAD data structure is a platform-independent implementation of a system-thread variable. Details of its structure may vary between implementations. It is defined in systhr.h.