Well, these CGI variables are only set when you execute a CGI. Perhaps the easiest thing to do is look at the nscgi code and of these values that are set, mirror the way that they are set in nscgi.
There are some better/worse ways to get them, such as using Ns_ConnGetQuery() instead of conn->request->query. It is probably best, IMHO, to call these functions instead of fetching them directly from the conn structure. The functions are unlikely to change, you never know about structures.
AOLserver doesn't set all of these variables either (like SERVER_ADMIN). Others like SERVER_PORT have Ns_Conn* functions.
I echo Dossy's suggestion, look at aolserver/nsd/conn.c. It shouldn't be too hard to figure out which functions to call to get what you need. The documention is woefully out of date, so that may not be too much help, the code is definitive.
rob
Dave Kuhlman wrote:
I'm writing a function to handle certain requests. I've registered this function with Ns_RegisterRequest(). My module loads and my function is called to process requests. So I'm doing good so far.
But there is some information I can't get my hands on. I've looked lots of the AOLserver C API documentation, but have not found much about this.
I need to be able, from my registered function, to retrieve things like the script name/path, the remote (client) address, etc.
So, is there some documentation somewhere on how to get the value corresponding to the following CGI variables? I've put a note next to the ones that I've figured out:
SERVER_SOFTWARE SERVER_PROTOCOL SERVER_NAME -- Ns_ConnServer() SERVER_ADMIN SERVER_ADDR SERVER_PORT REMOTE_ADDR REMOTE_PORT -- Ns_ConnPort() REMOTE_USER -- Ns_ConnAuthUser() ? REQUEST_METHOD REQUEST_URI -- Ns_ConnLocation() returns the base URL, but not the whole URI. QUERY_STRING -- Ns_ConnGetQuery() SCRIPT_NAME PATH_INFO HTTP_USER_AGENT HTTP_COOKIE HTTPS CONTENT_TYPE DOCUMENT_ROOT HTTP_ACCEPT HTTP_REFERER
In particular, I need the SCRIPT_NAME. For example, if the request is:
http://www.myhost.com/xxx/yyy/zzz
then I need to be able to retrieve "/xxx/yyy/zzz". And, since I did *not* use flag NS_OP_NOINHERIT when I called Ns_RegisterRequest(), I don't know what that is.
I did a test, and found that these are *not* available as environment variables when my registered C function is called.
Is there a struct somewhere that contains some of these items?
I've read the C examples (at http://aolserver.com/docs/devel/c/c-examples.html). But, none of them seem to show any awareness of the client, the request, etc.
I've been able to find a few, but can't find the rest. Is there a document somewhere about this. It'd be great if there were a document on how to convert a CGI application written in C into an AOLserver loadable module with a registered function.
One additional question -- Many functions return a char *. Am I correct that these return a pointer to a const char *? So I do not need to free these, right?
Thanks for help and pointers.
Dave
-- Dave Kuhlman [EMAIL PROTECTED] http://www.rexx.com/~dkuhlman
-- AOLserver - http://www.aolserver.com/
To Remove yourself from this list, simply send an email to <[EMAIL PROTECTED]> with the body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: field of your email blank.
-- AOLserver - http://www.aolserver.com/
To Remove yourself from this list, simply send an email to <[EMAIL PROTECTED]> with the body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: field of your email blank.
