⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hdefs.h

📁 《Web编程专家指南》
💻 H
字号:
/*
 * hdefs.h - common preprocessor definitions, types, etc.
 *
 * John Calcote 5/10/95
 * internet: jcalcote@novell.com
 */

#ifndef _HDEFS_H
#define _HDEFS_H

#include <stdio.h>

#define MAX_RSP_THREADS    15             /* maximum response threads      */
#define MIN_RSP_THREADS    5              /* minimum response threads      */
#define REQ_LOW_WATER      2              /* request queue low water mark  */
#define REQ_HIGH_WATER     6              /* request queue high water mark */
#define TLI_QLEN           10             /* max concurrent connect rqsts  */

#define MAX_PATH           FILENAME_MAX   /* max netware file path         */
#define MAX_STRING         512            /* buffered line input, etc      */
#define MAX_IOBUF          1024           /* i/o buf size                  */
#define MAX_ALIASES        20             /* max aliases                   */
#define HUGE_BUFFER        8192           /* header unwrap buffer          */

#define MONITOR_TIMEOUT		1000				/* max 10 seconds to terminate monitors */
#define RESPONDER_TIMEOUT	6000			  	/* max 60 seconds to terminate responders */

#define SHUTDOWN_TIMEOUT   6000          	/* max 60 seconds to shutdown - obsolete??? */

#define SERVER_VERSION     "NWWebServer/0.90"
#define SERVER_PROTOCOL    "HTTP/1.0"
#define SERVER_SUPPORT     "jcalcote@novell.com"

/* Configuration value definitions */
#define OFF                0
#define ON                 1
#define SELECTIVE          2
#define TOP                3
#define BOTTOM             4

/* HTTP Request methods -- DON'T change this ordering */
#define GET                0
#define HEAD               1
#define POST               2
#define PUT                3
#define DELETE             4
#define LINK               5
#define UNLINK             6
#define NUM_METHODS        7

/* HTTP URL Translation rule types */
#define R_MAP              0
#define R_PASS             1
#define R_FAIL             2
#define R_REDIRECT         3
#define R_EXEC             4

/* Special CGI MIME content-types */
#define CGI_MAGIC_TYPE      "application/x-httpd-cgi"
#define INCLUDES_MAGIC_TYPE "text/x-server-parsed-html"

/* Default configuration values */
#define DEFAULT_ADMIN            "[no address given]"
#define DEFAULT_SERVER_ROOT      "Sys:Webserv"
#define DEFAULT_SERVER_TCPPORT   80
#define DEFAULT_SERVER_SPXPORT   0x3280
#define DEFAULT_INPUT_TIMEOUT    (2 * 60 * 100)       /* 2 minutes   */
#define DEFAULT_OUTPUT_TIMEOUT   (20 * 60 * 100)      /* 20 minutes  */
#define DEFAULT_SCRIPT_TIMEOUT   (5 * 60 * 100)       /* 5 minutes   */
#define DEFAULT_DOCUMENT_ROOT    "Sys:Webserv/Webdocs"
#define BROWSABLE_FILENAME       "Brwsable.www"
#define DEFAULT_INDEX1           "Welcome.htm"
#define DEFAULT_INDEX2           "Index.htm"
#define DEFAULT_TYPE             "text/plain"
#define DEFAULT_ICON             ""

/* Transport provider types */
#define TCP_CONN           		0
#define SPX_CONN           		1


/* Type definitions */
typedef unsigned char   uchar;
typedef unsigned short  ushort;
typedef unsigned int    uint;
typedef unsigned long   ulong;
typedef unsigned short  uint16;
typedef unsigned long   uint32;
typedef int             bool;

typedef struct req {       /* Request context block                     */
	struct req *pNext;		/* Pointer to next request (when in list)		*/
	struct req *pPrev;		/* Pointer to prev request (when in list)		*/
   FILE  *strm;            /* FILE Stream buffer pointer                */
	int    fd;					/* Connection file descriptor (TLI)			 	*/
	int    connType;			/* Connection type flag (TCP or SPX)			*/
	int    nStatus;         /* Request Status (for logging)				  	*/
	int    nMethod;			/* HTTP method requested							*/
	int    nMajor;          /* HTTP major version number						*/
	int    nMinor;		      /* HTTP minor version number						*/
	int    fSent;				/* Request sent? (for logging)               */
	int    fFullReq;        /* new full- or old partial-request?         */
   int    fExternal;       /* External process, or internal file?       */
	char  *szHost;          /* Connection host name (from TLI)           */
	char  *szAddr;          /* Connectoin host address (from TLI)        */
	char  *szRequest;       /* Copy of full request text						*/
   char  *szURL;           /* Copy of full URL text                     */
	char	*szPath;			   /* Path to file or external request          */
   char  *szExtra;         /* Extra path information                    */
	char	*szQuery;         /* Request query text							  	*/
} REQUEST;

typedef struct resource {              /* Generic Linked List           */
   struct resource   *pNext;           /* Next node                     */
   int                iType;           /* Generic node type field       */
   char              *pszName;         /* Generic node name (key) field */
   char              *pszValue1;       /* Primary node value            */
   char              *pszValue2;       /* Secondary node value          */
} RESOURCE;

typedef struct ws_config {                /* Server configuration struct   */
   char     *pszServerRoot;               /* Server root directory         */
   char     *pszHostName;                 /* Server nost name              */
   char     *pszServerAdmin;              /* EMail address of webmaster    */
   uint16    usTCPPort;                   /* TCP port number               */
   uint16    usSPXPort;                   /* SPX socket number             */
   uint32    ulEnabled;                   /* Bitmap of enabled methods     */
   RESOURCE *pWelcomeHead;                /* Head of welcome list          */
   RESOURCE *pWelcomeTail;                /* Tail of welcome list, append  */
   bool      fAlwaysWelcome;              /* If no wecome, generate error  */
   RESOURCE *pMapHead;                    /* Head of rule list             */
   RESOURCE *pMapTail;                    /* Tail of rule list, add to end */
   RESOURCE *pCTypeHead[27];              /* MIME content-type hash table  */
   RESOURCE *pCEncodingHead;              /* MIME content-encoding list    */
   bool      fDirAccess;                  /* Type of directory access      */
   bool      fDirReadme;                  /* Position of directory readme  */
   bool      fDirShowIcons;               /* Show icons?                   */
   bool      fDirShowDate;                /* Show date?                    */
   bool      fDirShowSize;                /* Show size?                    */
   bool      fDirShowBytes;               /* Show size < 1K ?              */
   bool      fDirShowDescription;         /* Show description, HTML title? */
   uint32    ulDirShowMaxDescrLength;     /* Description length            */
   bool      fDirShowBrackets;            /* Brackets around ALT text?     */
   bool      fDirShowHidden;              /* Show Hidden/System files?     */
   bool      fDirShowOwner;               /* Show NetWare owner?           */
   bool      fDirShowFlags;               /* Show file attributes?         */
   RESOURCE *pIconHead;                   /* Head of directory icon list   */
   RESOURCE *pIconTail;                   /* Tail of directory icon list   */
   RESOURCE *pBlankIcon;                  /* Blank icon                    */
   RESOURCE *pUnknownIcon;                /* Unknown icon                  */
   RESOURCE *pDirIcon;                    /* Sub-directory icon            */
   RESOURCE *pParentIcon;                 /* Parent directory icon         */
   char     *pszAccessLog;                /* Pathname of access log        */
   char     *pszErrorLog;                 /* Pathname of error log         */
   bool      fLogGMT;                     /* GMT or Local time?            */
   RESOURCE *pNoLogHead;                  /* Head of no log pattern list   */
   uint32    ulInputTimeout;              /* Client->Server in ticks       */
   uint32    ulOutputTimeout;             /* Server->Client in ticks       */
   uint32    ulScriptTimeout;             /* Script timeout in ticks       */
} WS_CONFIG;

typedef struct _mlist {
	char  *szMethod;
	void (*fpProcess)(REQUEST*);
} MLIST;

typedef int (*FPREQ)(IOSTR *, int, char **, char **);

/* needed to access hash table outside of configuration module */
#define hash(i) (isalpha(i) ? (tolower(i)) - 'a' : 26)

#endif   /* _HDEFS_H */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -