typedef void *Ns_OpContext; typedef int (Ns_OpProc) (void *context, Ns_Conn *conn); typedef void (Ns_OpDeleteProc) (void *context); void Ns_RegisterRequest( char *hServer, char *method, char *URL, Ns_OpProc *proc, Ns_OpDeleteProc *deleteProc, Ns_OpContext context, int flags );
The Ns_RegisterRequest function registers function proc to handle HTTP requests. When the specified server receives an HTTP request, it finds the most specific registered operation. The default operation for a GET (i.e., the one registered with URL \Q/') serves up a page out of the file system.
The server passes your procedure the context you specify here and the Ns_Conn structure associated with the new HTTP connection.
When a procedure is unregistered with either Ns_UnRegisterRequest or by registering another procedure with the same method and URL, the server calls the deleteProc with the same context. You can use this to do any cleanup you might require (e.g., close an index file or free something from the heap). If the value of deleteProc is NULL, the server does nothing.
The flags parameter specifies one or more constants that can be OR'ed together. The available flags are NS_OP_NOINHERIT and NS_OP_NODELETE.
NS_OP_NOINHERIT tells AOLserver to only call your procedure if the URL matches exactly (the default behavior is to look for the closest match). You can register two procedures for the same method/URL combination by calling Ns_RegisterRequest once with NS_OP_NOINHERIT specified and once without NS_OP_NOINHERIT specified. The first procedure will be called if there is an exact match with the specified URL. The second procedure will be called if the requested URL is below the specified URL, provided there is not already another procedure registered with a closer match.
NS_OP_NODELETE specifies that the previous procedure's deleteproc should not be called. NS_OP_NODELETE can be used in conjunction with Ns_GetRequest to implement wrappers.