Thread: I've gone mad
View Single Post
Old 08-04-2005, 05:53 PM  
darkone
Disabled
 
darkone's Avatar
 
Join Date: Dec 2001
Posts: 2,230
Default I've gone mad

Seriously... I think I can not be considered to be sane anymore after writing single HEADER file for 4hours straight. Now I just need to write code to fill (and free) all those headers... uhh-huh Hopefully I have decent http service, that can handle PHPs, running within few days

Code:
typedef enum
{
	HTTP_VER_UNKNOWN	= 0,
    HTTP_VER_1_0,
	HTTP_VER_1_1

} HTTP_VER;

typedef enum
{
    HTTP_RC_CMD	= 0,
	HTTP_RC_FILENAME,
	HTTP_RC_ARGUMENTS,
	HTTP_RC_VERSION,
	HTTP_RC_END,
	HTTP_RC_CNT
};

typedef enum
{
	HTTP_CMD_UNKNOWN	= 0,
	HTTP_CMD_GET,
	HTTP_CMD_PUT,
	HTTP_CMD_POST,
	HTTP_CMD_HEAD,

} HTTP_CMD;

typedef enum
{
	HTTP_CONN_CLOSE			= 0,
	HTTP_CONN_KEEP_ALIVE
} HTTP_CONN;

typedef enum
{
	HTTP_CS_MEMORY	= 0,
	HTTP_CS_FILE

} HTTP_CONTENT_STORE;


typedef struct _HTTP_REQUEST_COMMAND
{
	LPSTR			szCommandLine;						/* original command line */
	PCHAR			pToken[HTTP_RC_CNT];				/* pointers to command line */
	LPWSTR			wszFilename;						/* filename on filesystem */
	HTTP_CMD		Command;							/* command in binary */
	HTTP_VER		Version;							/* version */

} HTTP_REQUEST_COMMAND, * LPHTTP_REQUEST_COMMAND;

typedef struct _HTTP_HEADER_LINE
{
	LPSTR						szVariable;		/* ???: variable of header*/
	LPSTR						szValue;		/* value of variable */
	struct _HTTP_HEADER_LINE	*lpNext;		/* pointer to next variable */
    
} HTTP_HEADER_LINE, *LPHTTP_HEADER_LINE;

typedef struct _HTTP_REQUEST_HEADER
{
	LPCSTR				szHostname;			/* hostname: */
	LPCSTR				szCookies;			/* cookies: */
	LPCSTR				szModified;			/* last-modified: */
	LPCSTR				szETag;				/* etag: */
	LPCSTR				szPragma;			/* pragma: */
	HTTP_CONN			ConnectionType;		/* connection: */
	UINT64				iContentLength;		/* content-length: */
	LPHTTP_HEADER_LINE	lpHeaderLineList;	/* all headers are stored here, do not free() any of above vars directly! */

} HTTP_REQUEST_HEADER, * LPHTTP_REQUEST_HEADER;

typedef struct _HTTP_REQUEST_CONTENT
{
	HTTP_CONTENT_STORE	StoreType;				/* memory/file */
	union {
		struct {
			PBYTE		pBuffer;				/* buffer */
		};
		struct {
			LPWSTR				wszFilename;	/* filename */
			LPUNIFIED_HANDLE	lpHandle;		/* file handle */
		};
	};

} HTTP_REQUEST_CONTENT, * LPHTTP_REQUEST_CONTENT;


typedef struct _HTTP_REPLY_COMMAND_RESPONSE
{
	HTTP_VER			Version;		/* http version */
	ULONG				lReplyCode;		/* http reply code */
	LPSTR				szReplyMessage;	/* http reply message */
    
} HTTP_REPLY_COMMAND_RESPONSE, * LPHTTP_REPLY_COMMAND_RESPONSE;

typedef struct _HTTP_REPLY_HEADER
{
	BUFFER				HeaderContent;	/* http reply header contents */

} HTTP_REPLY_HEADER;

typedef struct _HTTP_REPLY_CONTENT_DATA
{
	HTTP_CONTENT_STORE		StoreType;	/* memory/file */
	UINT64					iLength;	/* length of content */
	union {
		PBYTE				pBuffer;	/* source buffer */
		LPUNIFIED_HANDLE	lpHandle;	/* source stream handle */
	};

} HTTP_REPLY_CONTENT_DATA, * LPHTTP_REPLY_CONTENT_DATA;

typedef struct _HTTP_REPLY_CONTENT
{
	LPHTTP_REPLY_CONTENT_DATA	lpData;	/* http reply content */

} HTTP_REPLY_CONTENT, * LPHTTP_REPLY_CONTENT;

typedef struct _HTTP_REQUEST
{
	HTTP_REQUEST_COMMAND	Command;	/* Http request command */
	HTTP_REQUEST_HEADER		Header;		/* Http request header */
	HTTP_REQUEST_CONTENT	Content;	/* Http request content */

} HTTP_REQUEST, * LPHTTP_REQUEST;


typedef struct _HTTP_REPLY
{
	HTTP_REPLY_COMMAND_RESPONSE	Response;	/* Http command response */
	HTTP_REPLY_HEADER			Header;		/* Http reply header */
	HTTP_REPLY_CONTENT			Content;	/* Http reply content */

} HTTP_REPLY, * LPHTTP_REPLY;


typedef struct _HTTP_CONTEXT
{
	HTTP_REQUEST	Request;			/* Http-request content */
	HTTP_REPLY		Reply;				/* Http-reply content */

} HTTP_CONTEXT, * LPHTTP_CONTEXT;
darkone is offline