TUX(2)              TUX Programmer's Manual             TUX(2)

NAME
       tux - interact with the TUX kernel subsystem

SYNOPSIS
       #include <sys/tux.h>

       int tux (unsigned int action, user_req_t * req);

DESCRIPTION
       tux() calls the kernel to perform an 'action' on behalf of the
       currently executing user-space TUX module.

       'action' can be one of:

	enum tux_actions {
	        TUX_ACTION_STARTUP = 1,
	        TUX_ACTION_SHUTDOWN = 2,
	        TUX_ACTION_STARTTHREAD = 3,
	        TUX_ACTION_STOPTHREAD = 4,
	        TUX_ACTION_EVENTLOOP = 5,
	        TUX_ACTION_GET_OBJECT = 6,
	        TUX_ACTION_SEND_OBJECT = 7,
	        TUX_ACTION_READ_OBJECT = 8,
	        TUX_ACTION_FINISH_REQ = 9,
	        MAX_TUX_ACTION
	};

        TUX_ACTION_EVENTLOOP invokes the TUX event loop - the TUX
	subsystem will either immediately return with a new request, or
	will wait for new requests to arrive.

	TUX_ACTION_GET_OBJECT issues a request for the URL object named in
	req->objectname. If the object is not immediately available then
	the currently handled request is suspended, and a new request is
	returned, or the TUX subsystem waits for new requests.

	TUX_ACTION_SEND_OBJECT sends the current URL object to the client.

	TUX_ACTION_READ_OBJECT reads the current URL object into the
	address specified by req->object_addr.

	TUX_ACTION_FINISH_REQ finishes and logs the request.

	user_req_t is the request returned by the TUX subsystem.
	Defined fields are:

	typedef struct user_req_s {
	        int http_version;
	        int http_method;
	        int sock;
	        int bytes_sent;
	        int http_status;
	        unsigned int client_host;
	        unsigned int objectlen;
	        char query[MAX_URI_LEN];
	        char *object_addr;
	        char objectname[MAX_URI_LEN];
	        char modulename[MAX_MODULENAME_LEN];
	        char post_data[MAX_POST_DATA];
	
	        int cookies_len;
	        char cookies[MAX_COOKIE_LEN];
	
	        int phase;
	        int thread_nr;
	        void *id;
	        void *private;
	} user_req_t;

RETURN VALUE
	tux() returns the following values:

	enum tux_reactions {
	        TUX_RETURN_USERSPACE_REQUEST = 0,
	        TUX_RETURN_EXIT = 1,
	        TUX_RETURN_SIGNAL = 2,
	};

	TUX_RETURN_USERSPACE_REQUEST means that the kernel has put a
	new request into 'req'.

	TUX_RETURN_EXIT means that TUX has been stopped.

	TUX_RETURN_SIGNAL means that a signal has occured.

ERRORS
	any negative value (such as -EFAULT, -EINVAL) are an indication of
	an error.
