#ifndef PUBLIC_NSAPI_H
#define PUBLIC_NSAPI_H
#ifdef __cplusplus
extern "C" {
#endif
#define NSAPI_VERSION 303
#ifdef USE_NSAPI_VERSION
#if USE_NSAPI_VERSION < 300 || USE_NSAPI_VERSION > NSAPI_VERSION
#error This header file does not support the requested NSAPI version
#else
#undef NSAPI_VERSION
#define NSAPI_VERSION USE_NSAPI_VERSION
#endif
#endif
#if !defined(XP_WIN32) && !defined(XP_UNIX)
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
#define XP_WIN32
#else
#define XP_UNIX
#endif
#endif
#ifdef XP_UNIX
#define NSAPI_PUBLIC
#define ZERO(ptr, len) memset(ptr, 0, len)
#ifdef AIX
#define TCPLEN_T size_t
#endif
#ifdef HPUX
#define TCPLEN_T int
#endif
#ifndef TCPLEN_T
#define TCPLEN_T socklen_t
#endif
#endif
#ifdef XP_WIN32
#define NSAPI_PUBLIC __declspec(dllexport)
struct iovec {
char *iov_base;
unsigned iov_len;
};
#ifndef S_ISDIR
#define S_ISDIR(mode) ((mode & S_IFMT) == S_IFDIR)
#endif
#ifndef S_ISREG
#define S_ISREG(mode) ((mode & S_IFMT) == S_IFREG)
#endif
#ifndef S_ISLNK
#define S_ISLNK(x) (0)
#endif
#define caddr_t PCHAR
#define NEED_STRCASECMP
#define NEED_STRNCASECMP
#define ZERO(ptr, len) ZeroMemory(ptr, len)
#define TCPLEN_T int
#endif
#define WS_TRUE 1
#define WS_FALSE 0
#define MAGNUS_ERROR_LEN 1024
#define CR 13
#define LF 10
#ifdef XP_WIN32
#define ENDLINE "\r\n"
#else
#define ENDLINE "\n"
#endif
#define NCC_MT_MAGIC "#--Netscape Communications Corporation MIME Information"
#define NCC_MT_MAGIC_LEN 55
#define CINFO_SEPARATOR '.'
#define CINFO_MAX_LEN 1024
#define MAX_ERROR_LEN 4096
#define LOG_WARN 0
#define LOG_MISCONFIG 1
#define LOG_SECURITY 2
#define LOG_FAILURE 3
#define LOG_CATASTROPHE 4
#define LOG_INFORM 5
#define LOG_VERBOSE 6
#define LOG_DEBUG 7
#define ERR_TIMEFMT "[%d/%b/%Y:%H:%M:%S]"
#define ERRORS_TO_SYSLOG NULL
#define IO_OKAY 1
#define IO_ERROR -1
#define IO_EOF 0
#define NETBUF_EOF -1
#define NETBUF_ERROR -2
#define NETBUF_FULL -3
#define FILE_BUFFERSIZE 4096
#ifdef XP_UNIX
#define FILE_PATHSEP '/'
#define FILE_PARENT "../"
#elif defined(XP_WIN32)
#define FILE_PATHSEP '/'
#define FILE_PARENT "..\\"
#endif
#define NET_INFINITE_TIMEOUT 0
#define NET_ZERO_TIMEOUT -1
#ifdef USE_REGEX
#define WILDPAT_VALID(exp) regexp_valid(exp)
#define WILDPAT_MATCH(str, exp) regexp_match(str, exp)
#define WILDPAT_CMP(str, exp) regexp_cmp(str, exp)
#define WILDPAT_CASECMP(str, exp) regexp_casecmp(str, exp)
#define WILDPAT_USES_REGEXP 1
#else
#define WILDPAT_VALID(exp) shexp_valid(exp)
#define WILDPAT_MATCH(str, exp) shexp_match(str, exp)
#define WILDPAT_CMP(str, exp) shexp_cmp(str, exp)
#define WILDPAT_CASECMP(str, exp) shexp_casecmp(str, exp)
#define WILDPAT_USES_SHEXP 1
#endif
#define NON_WILDPAT -1
#define INVALID_WILDPAT -2
#define VALID_WILDPAT 1
#define NON_SXP NON_WILDPAT
#define INVALID_SXP INVALID_WILDPAT
#define VALID_SXP VALID_WILDPAT
#define NON_REGEXP NON_SXP
#define INVALID_REGEXP INVALID_SXP
#define VALID_REGEXP VALID_SXP
#define SYSTHREAD_DEFAULT_PRIORITY 16
#define CONF_MAXLEN 16384
#define HTTP_DATE_LEN 30
#define HTTP_DATE_FMT "%a, %d %b %Y %T GMT"
#define PROTOCOL_CONTINUE 100
#define PROTOCOL_SWITCHING 101
#define PROTOCOL_OK 200
#define PROTOCOL_CREATED 201
#define PROTOCOL_ACCEPTED 202
#define PROTOCOL_NONAUTHORITATIVE 203
#define PROTOCOL_NO_RESPONSE 204
#define PROTOCOL_NO_CONTENT 204
#define PROTOCOL_RESET_CONTENT 205
#define PROTOCOL_PARTIAL_CONTENT 206
#define PROTOCOL_MULTI_STATUS 207
#define PROTOCOL_MULTIPLE_CHOICES 300
#define PROTOCOL_MOVED_PERMANENTLY 301
#define PROTOCOL_REDIRECT 302
#define PROTOCOL_SEE_OTHER 303
#define PROTOCOL_NOT_MODIFIED 304
#define PROTOCOL_USE_PROXY 305
#define PROTOCOL_TEMPORARY_REDIRECT 307
#define PROTOCOL_BAD_REQUEST 400
#define PROTOCOL_UNAUTHORIZED 401
#define PROTOCOL_PAYMENT_REQUIRED 402
#define PROTOCOL_FORBIDDEN 403
#define PROTOCOL_NOT_FOUND 404
#define PROTOCOL_METHOD_NOT_ALLOWED 405
#define PROTOCOL_NOT_ACCEPTABLE 406
#define PROTOCOL_PROXY_UNAUTHORIZED 407
#define PROTOCOL_REQUEST_TIMEOUT 408
#define PROTOCOL_CONFLICT 409
#define PROTOCOL_GONE 410
#define PROTOCOL_LENGTH_REQUIRED 411
#define PROTOCOL_PRECONDITION_FAIL 412
#define PROTOCOL_ENTITY_TOO_LARGE 413
#define PROTOCOL_URI_TOO_LARGE 414
#define PROTOCOL_UNSUPPORTED_MEDIA_TYPE 415
#define PROTOCOL_REQUESTED_RANGE_NOT_SATISFIABLE 416
#define PROTOCOL_EXPECTATION_FAILED 417
#define PROTOCOL_LOCKED 423
#define PROTOCOL_FAILED_DEPENDENCY 424
#define PROTOCOL_SERVER_ERROR 500
#define PROTOCOL_NOT_IMPLEMENTED 501
#define PROTOCOL_BAD_GATEWAY 502
#define PROTOCOL_SERVICE_UNAVAILABLE 503
#define PROTOCOL_GATEWAY_TIMEOUT 504
#define PROTOCOL_VERSION_NOT_SUPPORTED 505
#define PROTOCOL_INSUFFICIENT_STORAGE 507
#define PROTOCOL_VERSION_HTTP09 9
#define PROTOCOL_VERSION_HTTP10 100
#define PROTOCOL_VERSION_HTTP11 101
#define CURRENT_PROTOCOL_VERSION PROTOCOL_VERSION_HTTP11
#define HTTPS_PORT 443
#define HTTPS_URL "https"
#define HTTP_PORT 80
#define HTTP_URL "http"
#define REQ_MAX_LINE 4096
#define REQ_PROCEED 0
#define REQ_ABORTED -1
#define REQ_NOACTION -2
#define REQ_EXIT -3
#define REQ_RESTART -4
#define REQ_TOOBUSY -5
#define REQ_PROCESSING -8
#ifdef XP_UNIX
#include <unistd.h>
#include <sys/file.h>
#include <pthread.h>
#ifndef HPUX
#include <sys/select.h>
#endif
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/uio.h>
#include <fcntl.h>
#include <dirent.h>
#include <pwd.h>
#include <netinet/in.h>
#endif
#ifdef XP_WIN32
#include <wtypes.h>
#include <winbase.h>
#include <direct.h>
#include <dirent.h>
#include <winsock.h>
#endif
#include <sys/stat.h>
#include <ctype.h>
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <time.h>
#include <inttypes.h>
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
typedef int WSBool;
#ifndef SYS_FILE_T
typedef struct VFSFile *SYS_FILE;
#define SYS_FILE_T void *
#endif
#define SYS_ERROR_FD ((SYS_FILE)-1)
#ifndef SYS_NETFD_T
typedef void *SYS_NETFD;
#define SYS_NETFD_T void *
#endif
#ifndef SYS_NET_ERRORFD
#define SYS_NET_ERRORFD ((SYS_NETFD)-1)
#endif
typedef struct directive directive;
typedef struct dtable dtable;
typedef struct httpd_object httpd_object;
typedef struct httpd_objset httpd_objset;
typedef struct filebuffer filebuffer;
struct filebuffer {
SYS_FILE fd;
#ifdef XP_WIN32
HANDLE fdmap;
#endif
caddr_t fp;
int len;
unsigned char *inbuf;
int cursize;
int pos;
const char *errmsg;
};
#define filebuf_getc(b) ((b)->pos == (b)->len ? IO_EOF : (int)((b)->fp)[(b)->pos++])
#define filebuf_iseof(b) ((b)->pos == (b)->len)
typedef filebuffer filebuf_t;
#ifdef XP_WIN32
#define pipebuf_getc(b) \
((b)->pos != (b)->cursize ? (int)((b)->inbuf[(b)->pos++]) : pipebuf_next(b,1))
#endif
typedef struct netbuf netbuf;
struct netbuf {
SYS_NETFD sd;
int pos, cursize, maxsize, rdtimeout;
#ifdef XP_WIN32
CHAR address[64];
#endif
unsigned char *inbuf;
char *errmsg;
#ifndef XP_WIN32
char address[64];
#endif
};
#define netbuf_getc(b) \
((b)->pos != (b)->cursize ? (int)((b)->inbuf[(b)->pos++]) : netbuf_next(b,1))
#define buffer_error(b) ((b)->errmsg)
typedef struct sendfiledata sendfiledata;
struct sendfiledata {
SYS_FILE fd;
off_t offset;
size_t len;
const void *header;
int hlen;
const void *trailer;
int tlen;
};
typedef struct iovec NSAPIIOVec;
typedef struct cinfo cinfo;
struct cinfo {
char *type;
char *encoding;
char *language;
};
#define EVENT_POLLIN 0x1
#define EVENT_POLLOUT 0x2
typedef struct EventHandler EventHandler;
typedef struct Event Event;
typedef int(*eventfunc)(EventHandler*, Event*);
struct Event {
eventfunc fn;
eventfunc finish;
void *cookie;
intptr_t object;
int events;
int error;
};
typedef void* CONDVAR;
typedef void *COUNTING_SEMAPHORE;
typedef void* CRITICAL;
#ifdef XP_UNIX
typedef DIR* SYS_DIR;
typedef struct dirent SYS_DIRENT;
#endif
#ifdef XP_WIN32
typedef struct dirent_s dirent_s;
struct dirent_s {
char *d_name;
};
typedef struct dir_s dir_s;
struct dir_s {
HANDLE dp;
WIN32_FIND_DATA fdata;
dirent_s de;
};
typedef dir_s* SYS_DIR;
typedef dirent_s SYS_DIRENT;
#endif
typedef struct pb_param pb_param;
struct pb_param {
char *name,*value;
};
typedef struct pb_entry pb_entry;
struct pb_entry {
pb_param *param;
struct pb_entry *next;
};
typedef struct pblock pblock;
struct pblock {
int hsize;
struct pb_entry **ht;
};
#ifndef POOL_HANDLE_T
#define POOL_HANDLE_T
typedef void *pool_handle_t;
#endif
#ifndef SEMAPHORE_T
#endif
#define SESSION_HASHSIZE 5
typedef struct PListStruct_s PListStruct_s;
typedef struct ACLListHandle ACLListHandle;
typedef struct VFS VFS;
typedef struct VFSContext VFSContext;
enum WSConfigNodeType {
WS_CONFIG_NODE_OBJECT = 0,
WS_CONFIG_NODE_DIRECTIVE
};
typedef struct ServerConfiguration ServerConfiguration;
typedef struct ConfigNode WSConfigNode;
typedef enum WSConfigNodeType WSConfigNodeType;
typedef struct HttpResponseWriter HttpResponseWriter;
#ifndef PR_AF_INET
typedef union PRNetAddr PRNetAddr;
#endif
typedef struct Session Session;
typedef struct Request Request;
struct Session {
pblock *client;
SYS_NETFD csd;
netbuf *inbuf;
int csd_open;
struct in_addr iaddr;
pool_handle_t *pool;
EventHandler *ev;
void *clauth;
struct Session *next;
int fill;
struct sockaddr_in local_addr;
PListStruct_s *subject;
int ssl;
int clientauth;
PRNetAddr *pr_client_addr;
PRNetAddr *pr_local_addr;
};
typedef struct FuncStruct FuncStruct;
#ifdef XP_UNIX
typedef int Func(pblock *, Session *, Request *);
typedef int FuncExec(FuncStruct *, pblock *, Session *, Request *);
#else
typedef int _cdecl Func(pblock *, Session *, Request *);
typedef int _cdecl FuncExec(FuncStruct *, pblock *, Session *, Request *);
#endif
typedef Func *FuncPtr;
typedef FuncExec *FuncExecPtr;
struct FuncStruct {
const char *name;
FuncPtr func;
FuncExecPtr func_exec;
void *exec_data;
unsigned flags;
unsigned poolID;
unsigned pool_resolved;
};
typedef struct _http_listener HttpListener;
typedef struct ResourcePool ResourcePool;
typedef struct ResourceType ResourceType;
typedef struct ResourceData ResourceData;
typedef void * (*resource_pool_init_func)(pool_handle_t *, const char *, pblock *);
typedef void (*resource_pool_destroy_func)(void *);
typedef void * (*resource_pool_createresource_func)(void *);
typedef void (*resource_pool_freeresource_func)(void *, void *);
typedef int (*resource_pool_prepare_func)(void *, void *);
typedef int (*resource_pool_finish_func)(void *, void *);
typedef void * (*resource_pool_getresourcedata_func)(void *);
struct ResourceType {
void * (*init)(pool_handle_t *, const char *, pblock *);
void (*destroy)(void *);
void * (*createresource)(void *);
void (*freeresource)(void *, void *);
int (*prepare)(void *, void *);
int (*finish)(void *, void *);
void * (*getresourcedata)(void *);
};
struct ResourceData {
ResourcePool *resourcepool;
void *data;
};
int resourcepool_register_type(const char *type_name, ResourceType *type_info);
typedef struct VirtualServer VirtualServer;
typedef int VSInitFunc(VirtualServer *incoming, const VirtualServer *current);
typedef void VSDestroyFunc(VirtualServer *outgoing);
typedef VSInitFunc *VSInitFuncPtr;
typedef VSDestroyFunc *VSDestroyFuncPtr;
typedef int VSDirectiveInitFunc(const directive *dir, VirtualServer *incoming, const VirtualServer *current);
typedef void VSDirectiveDestroyFunc(const directive *dir, VirtualServer *outgoing);
typedef VSDirectiveInitFunc *VSDirectiveInitFuncPtr;
typedef VSDirectiveDestroyFunc *VSDirectiveDestroyFuncPtr;
typedef struct Filter Filter;
typedef struct FilterContext FilterContext;
struct FilterContext {
pool_handle_t *pool;
Session *sn;
Request *rq;
void *data;
};
typedef struct FilterLayer FilterLayer;
struct FilterLayer {
Filter *filter;
FilterContext *context;
SYS_NETFD lower;
};
typedef int (*FilterInsertFunc)(FilterLayer *layer, pblock *pb);
typedef void (*FilterRemoveFunc)(FilterLayer *layer);
typedef int (*FilterFlushFunc)(FilterLayer *layer);
typedef int (*FilterReadFunc)(FilterLayer *layer, void *buf, int amount, int timeout);
typedef int (*FilterWriteFunc)(FilterLayer *layer, const void *buf, int amount);
typedef int (*FilterWritevFunc)(FilterLayer *layer, const NSAPIIOVec *iov, int iov_size);
typedef int (*FilterSendfileFunc)(FilterLayer *layer, sendfiledata *sfd);
typedef struct FilterMethods FilterMethods;
struct FilterMethods {
size_t size;
#if NSAPI_VERSION >= 302
FilterInsertFunc *insert;
FilterRemoveFunc *remove;
FilterFlushFunc *flush;
FilterReadFunc *read;
FilterWriteFunc *write;
FilterWritevFunc *writev;
FilterSendfileFunc *sendfile;
#else
void *reserved1;
void *reserved2;
void *reserved3;
void *reserved4;
void *reserved5;
void *reserved6;
void *reserved7;
#endif
};
#define FILTER_METHODS_INITIALIZER \
{ \
sizeof(FilterMethods), \
NULL, \
NULL, \
NULL, \
NULL, \
NULL, \
NULL, \
NULL \
}
#define FILTER_CONTENT_GENERATION 0xf0000
#define FILTER_CONTENT_TRANSLATION_HIGH 0xa0000
#define FILTER_CONTENT_TRANSLATION 0x90000
#define FILTER_CONTENT_TRANSLATION_LOW 0x80000
#define FILTER_CONTENT_CODING 0x50000
#define FILTER_TRANSFER_CODING 0x40000
#define FILTER_MESSAGE_CODING 0x30000
#define FILTER_TRANSPORT_CODING 0x20000
#define FILTER_NETWORK 0x10000
typedef struct shmem_s shmem_s;
struct shmem_s {
void *data;
#ifdef XP_WIN32
HANDLE fdmap;
#endif
int size;
char *name;
SYS_FILE fd;
};
#ifdef XP_UNIX
typedef pthread_t SYS_THREAD;
#else
typedef void* SYS_THREAD;
#endif
#define SYS_THREAD_ERROR NULL
typedef struct conf_global_vars_s conf_global_vars_s;
struct conf_global_vars_s {
int Vport;
#define server_portnum 80
char *Vaddr;
struct passwd *Vuserpw;
char *Vchr;
char *Vpidfn;
#define pool_max conf_getglobals()->Vpool_max
int Vpool_max;
#define pool_min conf_getglobals()->Vpool_min
int Vpool_min;
#define pool_life conf_getglobals()->Vpool_life
int Vpool_life;
#define pool_maxthreads conf_getglobals()->Vpool_maxthreads
int Vpool_maxthreads;
#define pool_minthreads conf_getglobals()->Vpool_minthreads
int Vpool_minthreads;
char *Vsecure_keyfn;
char *Vsecure_certfn;
#define security_active 0
int Vsecurity_active;
int Vssl3_active;
int Vssl2_active;
int Vsecure_auth;
int Vsecurity_session_timeout;
long Vssl3_session_timeout;
#define server_hostname "x4"
char *Vserver_hostname;
#define root_object conf_getglobals()->Vroot_object
char *Vroot_object;
#define std_os conf_getglobals()->Vstd_os
httpd_objset *Vstd_os;
void *Vacl_root;
char *Vmaster_error_log;
#define server_root conf_getglobals()->Vserver_root
char *Vserver_root;
#define server_id conf_getglobals()->Vserver_id
char *Vserver_id;
char *Vadmin_users;
char *Vnetsite_root;
int digest_stale_timeout;
int single_accept;
int num_keep_alives;
int log_verbose;
int mmap_flags;
int mmap_prots;
int unused1;
int unused2;
int accept_language;
char *mtahost;
char *nntphost;
void *Vacl_root_30;
char *agentFilePath;
int Allowed;
pblock *genericGlobals;
char *agentsACLFile;
int wait_for_cgi;
int cgiwatch_timeout;
int started_by_watchdog;
int restarted_by_watchdog;
int old_accel_cache_enabled;
int Vssl_cache_entries;
int blocking_listen_socket;
pblock **initfns;
char *vs_config_file;
};
#ifdef AIX
#define RQATTR unsigned
#else
#define RQATTR unsigned long
#endif
struct Request {
pblock *vars;
pblock *reqpb;
int loadhdrs;
pblock *headers;
int senthdrs;
pblock *srvhdrs;
httpd_objset *os;
httpd_objset *tmpos;
char *statpath;
char *staterr;
struct stat *finfo;
int aclstate;
int acldirno;
char *aclname;
pblock *aclpb;
ACLListHandle *acllist;
uint32_t aclreqaccess;
VFS *vfs;
void *davCollection;
int request_is_cacheable;
int directive_is_cacheable;
char *cached_headers;
int cached_headers_len;
char *unused;
#define REQ_TIME(x) (x)->req_start
time_t req_start;
short protv_num;
short method_num;
struct rq_attr {
RQATTR abs_uri:1;
RQATTR chunked:1;
RQATTR keep_alive:1;
RQATTR pipelined:1;
RQATTR internal_req:1;
RQATTR perm_req:1;
RQATTR header_file_present:1;
RQATTR footer_file_present:1;
RQATTR jvm_attached:1;
RQATTR req_restarted:1;
RQATTR jvm_request_locked:1;
RQATTR default_type_set:1;
RQATTR is_web_app:1;
RQATTR ssl_unclean_shutdown:1;
RQATTR vary_accept_language:1;
RQATTR reserved:17;
} rq_attr;
char *hostname;
int allowed;
int byterange;
short status_num;
int staterrno;
Request *orig_rq;
};
#define ABS_URI(x) (x)->rq_attr.abs_uri
#define CHUNKED(x) (x)->rq_attr.chunked
#define KEEP_ALIVE(x) (x)->rq_attr.keep_alive
#define PIPELINED(x) (x)->rq_attr.pipelined
#define INTERNAL_REQUEST(x) (x)->rq_attr.internal_req
#define RESTARTED_REQUEST(x) (x)->rq_attr.req_restarted
#define PERM_REQUEST(x) (x)->rq_attr.perm_req
#define JVM_REQUEST_LOCKED(x) (x)->rq_attr.jvm_request_locked
#define SSL_UNCLEAN_SHUTDOWN(x) (x)->rq_attr.ssl_unclean_shutdown
#define VARY_ACCEPT_LANGUAGE(x) (x)->rq_attr.vary_accept_language
#define METHOD_HEAD 0
#define METHOD_GET 1
#define METHOD_PUT 2
#define METHOD_POST 3
#define METHOD_DELETE 4
#define METHOD_TRACE 5
#define METHOD_OPTIONS 6
#define METHOD_MOVE 7
#define METHOD_INDEX 8
#define METHOD_MKDIR 9
#define METHOD_RMDIR 10
#define METHOD_COPY 11
#define METHOD_MAX 12
#define ISMGET(r) ((r)->method_num == METHOD_GET)
#define ISMHEAD(r) ((r)->method_num == METHOD_HEAD)
#define ISMPUT(r) ((r)->method_num == METHOD_PUT)
#define ISMPOST(r) ((r)->method_num == METHOD_POST)
#define ISMDELETE(r) ((r)->method_num == METHOD_DELETE)
#define ISMMOVE(r) ((r)->method_num == METHOD_MOVE)
#define ISMINDEX(r) ((r)->method_num == METHOD_INDEX)
#define ISMMKDIR(r) ((r)->method_num == METHOD_MKDIR)
#define ISMRMDIR(r) ((r)->method_num == METHOD_RMDIR)
#define ISMCOPY(r) ((r)->method_num == METHOD_COPY)
#define ISMTRACE(r) ((r)->method_num == METHOD_TRACE)
#define ISMOPTIONS(r) ((r)->method_num == METHOD_OPTIONS)
typedef struct aiocb_s {
SYS_FILE filedes;
void *buf;
size_t nbytes;
off_t offset;
ssize_t result;
int result_errno;
Event *event;
EventHandler *evhandler;
} aiocb_s;
typedef struct _thread_pool threadpool_t;
typedef struct _threadpool_job threadpool_job;
typedef void*(*job_callback_f)(void *data);
typedef struct WebSocket WebSocket;
typedef struct WSMessage WSMessage;
struct WebSocket {
int (*on_open)(WebSocket *);
int (*on_error)(WebSocket *);
int (*on_message)(WebSocket *, WSMessage *msg);
int (*on_close)(WebSocket *);
void *userdata;
};
struct WSMessage {
char *data;
size_t length;
int type;
WSMessage *next;
};
#ifndef INTNSAPI
#if NSAPI_VERSION >= 301
#define __NSAPI_RUNTIME_VERSION nsapi_runtime_version()
#define NSAPI_RUNTIME_VERSION nsapi_runtime_version()
#endif
NSAPI_PUBLIC char* system_version();
#endif
#ifdef XP_UNIX
#define dir_open opendir
#define dir_read readdir
#define dir_close closedir
#define dir_create(path) mkdir(path, 0755)
#define dir_remove rmdir
#define system_chdir chdir
#define file_unix2local(path,p2) strcpy(p2,path)
#endif
#ifdef XP_WIN32
#define dir_create _mkdir
#define dir_remove _rmdir
#define system_chdir SetCurrentDirectory
#endif
#define system_localtime(curtime, ret) util_localtime(curtime, ret)
#define system_gmtime(curtime, ret) util_gmtime(curtime, ret)
#define pblock_find(name, pb) (pblock_fr(name,pb,0))
#define pblock_remove(name, pb) (pblock_fr(name,pb,1))
#define session_dns(sn) session_dns_lookup(sn, 0)
#define session_maxdns(sn) session_dns_lookup(sn, 1)
NSAPI_PUBLIC conf_global_vars_s* conf_getglobals();
const VirtualServer* request_get_vs(Request *rq);
#define request_get_vs request_get_vs
struct stat* request_stat_path(const char *path, Request *rq);
#define request_stat_path request_stat_path
void request_free(Request *rq);
#define request_free request_free
Request* request_restart_internal(const char *uri, Request *rq);
#define request_restart_internal request_restart_internal
char* vs_translate_uri(const VirtualServer *vs, const char *uri);
#define vs_translate_uri vs_translate_uri
char* servact_translate_uri(char *uri, Session *sn);
#define servact_translate_uri servact_translate_uri
#define request_translate_uri servact_translate_uri
ssize_t net_write(SYS_NETFD fd, const void *buf, size_t nbytes);
ssize_t net_writev(SYS_NETFD fd, struct iovec *iovec, int iovcnt);
ssize_t net_sendfile(SYS_NETFD fd, sendfiledata *sfd);
ssize_t net_read(SYS_NETFD fd, void *buf, size_t nbytes);
int net_flush(SYS_NETFD sd);
void net_close(SYS_NETFD fd);
ssize_t net_printf(SYS_NETFD fd, char *format, ...);
int net_setnonblock(SYS_NETFD fd, int nonblock);
int net_errno(SYS_NETFD fd);
NSAPI_PUBLIC pb_param *INTparam_create(const char *name, const char *value);
NSAPI_PUBLIC int INTparam_free(pb_param *pp);
NSAPI_PUBLIC pblock *INTpblock_create(int n);
NSAPI_PUBLIC void INTpblock_free(pblock *pb);
NSAPI_PUBLIC char *INTpblock_findval(const char *name, const pblock *pb);
NSAPI_PUBLIC pb_param *INTpblock_nvinsert(const char *name, const char *value, pblock *pb);
NSAPI_PUBLIC pb_param *pblock_nvlinsert(const char *name, int namelen, const char *value, int valuelen, pblock *pb);
NSAPI_PUBLIC pb_param *INTpblock_nninsert(const char *name, int value, pblock *pb);
NSAPI_PUBLIC void INTpblock_pinsert(pb_param *pp, pblock *pb);
NSAPI_PUBLIC int INTpblock_str2pblock(const char *str, pblock *pb);
NSAPI_PUBLIC char *INTpblock_pblock2str(const pblock *pb, char *str);
NSAPI_PUBLIC int INTpblock_copy(const pblock *src, pblock *dst);
NSAPI_PUBLIC pblock *INTpblock_dup(const pblock *src);
NSAPI_PUBLIC char **INTpblock_pb2env(const pblock *pb, char **env);
NSAPI_PUBLIC void pblock_nvreplace (const char *name, const char *value, pblock *pb);
NSAPI_PUBLIC pb_param *pblock_param_create(pblock *pb, const char *name, const char *value);
NSAPI_PUBLIC pblock *pblock_create_pool(pool_handle_t *pool_handle, int n);
NSAPI_PUBLIC pb_param *INTpblock_fr(const char *name, pblock *pb, int remove);
NSAPI_PUBLIC char *INTpblock_replace(const char *name,char * new_value,pblock *pb);
NSAPI_PUBLIC int INTpblock_str2pblock_lowercasename(const char *str, pblock *pb);
#define pblock_remove(name, pb) (pblock_fr(name,pb,1))
#define param_create INTparam_create
#define param_free INTparam_free
#define pblock_create INTpblock_create
#define pblock_free INTpblock_free
#define pblock_findval INTpblock_findval
#define pblock_nvinsert INTpblock_nvinsert
#define pblock_nninsert INTpblock_nninsert
#define pblock_pinsert INTpblock_pinsert
#define pblock_str2pblock INTpblock_str2pblock
#define pblock_pblock2str INTpblock_pblock2str
#define pblock_copy INTpblock_copy
#define pblock_dup INTpblock_dup
#define pblock_pb2env INTpblock_pb2env
#define pblock_fr INTpblock_fr
#define pblock_replace INTpblock_replace
NSAPI_PUBLIC pool_handle_t *INTpool_create(void);
NSAPI_PUBLIC void *INTpool_mark(pool_handle_t *pool_handle);
NSAPI_PUBLIC void INTpool_recycle(pool_handle_t *pool_handle, void *mark);
NSAPI_PUBLIC void INTpool_destroy(pool_handle_t *pool_handle);
NSAPI_PUBLIC int INTpool_enabled(void);
NSAPI_PUBLIC void *INTpool_malloc(pool_handle_t *pool_handle, size_t size );
NSAPI_PUBLIC void INTpool_free(pool_handle_t *pool_handle, void *ptr );
NSAPI_PUBLIC
void *INTpool_calloc(pool_handle_t *pool_handle, size_t nelem, size_t elsize);
NSAPI_PUBLIC
void *INTpool_realloc(pool_handle_t *pool_handle, void *ptr, size_t size );
NSAPI_PUBLIC
char *INTpool_strdup(pool_handle_t *pool_handle, const char *orig_str );
#define pool_create INTpool_create
#define pool_mark INTpool_mark
#define pool_recycle INTpool_recycle
#define pool_destroy INTpool_destroy
#define pool_enabled INTpool_enabled
#define pool_malloc INTpool_malloc
#define pool_free INTpool_free
#define pool_calloc INTpool_calloc
#define pool_realloc INTpool_realloc
#define pool_strdup INTpool_strdup
#define MALLOC malloc
#define CALLOC(size) calloc(1, size)
#define REALLOC realloc
#define FREE free
#define STRDUP strdup
FuncStruct* func_resolve(pblock *pb, Session *sn, Request *rq);
int func_exec(pblock *pb, Session *sn, Request *rq);
struct FuncStruct func_insert(char *name, FuncPtr fn);
#define func_insert func_insert
void protocol_status(Session *sn, Request *rq, int n, const char *m);
int http_start_response(Session *sn, Request *rq);
#define protocol_start_response http_start_response
HttpResponseWriter *http_create_response(Session *sn, Request *rq);
int http_send_response(HttpResponseWriter *writer);
int request_header(char *name, char **value, Session *sn, Request *rq);
char *http_uri2url(const char *prefix, const char *suffix);
char *http_uri2url_dynamic(const char *prefix, const char *suffix,
Session *sn, Request *rq);
#define protocol_uri2url http_uri2url
#define protocol_uri2url_dynamic http_uri2url_dynamic
NSAPI_PUBLIC void http_format_etag(Session *sn, Request *rq, char *etagp, int etaglen, off_t size, time_t mtime);
NSAPI_PUBLIC int http_check_preconditions(Session *sn, Request *rq, struct tm *mtm, const char *etag);
NSAPI_PUBLIC int http_set_finfo(Session *sn, Request *rq, struct stat *finfo);
NSAPI_PUBLIC int http_set_finfo_etag(Session *sn, Request *rq, struct stat *finfo, const char *etag);
NSAPI_PUBLIC char **http_hdrs2env(pblock *pb);
NSAPI_PUBLIC int http_handle_websocket(Session *sn, Request *rq, WebSocket *websocket);
NSAPI_PUBLIC int websocket_send_text(SYS_NETFD csd, char *msg, size_t len);
typedef void (*thrstartfunc)(void *);
SYS_THREAD INTsysthread_start(int prio, int stksz, thrstartfunc fn, void *arg);
NSAPI_PUBLIC void INTsysthread_sleep(int milliseconds);
#define systhread_start INTsysthread_start
#define systhread_sleep INTsysthread_sleep
void webserver_atrestart(void (*fn)(void *), void *data);
#define magnus_atrestart webserver_atrestart
#define daemon_atrestart webserver_atrestart
NSAPI_PUBLIC int INTshexp_match(const char *str, const char *exp);
#define shexp_match INTshexp_match
NSAPI_PUBLIC char *session_dns_lookup(Session *s, int verify);
NSAPI_PUBLIC netbuf *netbuf_open(SYS_NETFD sd, int sz);
NSAPI_PUBLIC void netbuf_close(netbuf *buf);
NSAPI_PUBLIC unsigned char * netbuf_replace(netbuf *buf,
unsigned char *inbuf, int pos, int cursize, int maxsize);
NSAPI_PUBLIC int netbuf_next(netbuf *buf, int advance);
NSAPI_PUBLIC int netbuf_getbytes(netbuf *buf, char *buffer, int size);
NSAPI_PUBLIC int netbuf_grab(netbuf *buf, int sz);
#define netbuf_open netbuf_open
#define netbuf_close netbuf_close
#define netbuf_replace netbuf_replace
#define netbuf_next netbuf_next
#define netbuf_getbytes netbuf_getbytes
#define netbuf_grab netbuf_grab
NSAPI_PUBLIC int system_fread(SYS_FILE fd, void *buf, int nbyte);
NSAPI_PUBLIC int system_fwrite(SYS_FILE fd, const void *buf, int nbyte);
NSAPI_PUBLIC int system_pread(SYS_FILE fd, void *buf, int nbyte, off_t offset);
NSAPI_PUBLIC int system_pwrite(SYS_FILE fd, const void *buf, int nbyte, off_t offset);
NSAPI_PUBLIC off_t system_lseek(SYS_FILE fd, off_t offset, int whence);
NSAPI_PUBLIC int system_fclose(SYS_FILE fd);
NSAPI_PUBLIC int system_aio_read(aiocb_s *aiocb);
NSAPI_PUBLIC int system_aio_write(aiocb_s *aiocb);
int log_ereport(int degree, const char *format, ...);
int log_ereport_v(int degree, const char *format, va_list args);
int log_error(int degree, const char *func, Session *sn, Request *rq,
const char *format, ...);
int log_error_v(int degree, const char *func, Session *sn, Request *rq,
const char *format, va_list args);
int log_message(const char *degree, const char *format, ...);
int log_message_v(const char *degree, const char *format, va_list args);
NSAPI_PUBLIC int util_errno2status(int errno_value);
#define util_errno2status util_errno2status
NSAPI_PUBLIC pblock* util_parse_param(pool_handle_t *pool, char *query);
#define util_parse_param util_parse_param
void nsapi_function_return(Session *sn, Request *rq, int ret);
threadpool_t* threadpool_new(int min, int max);
int threadpool_start(threadpool_t *pool);
void* threadpool_func(void *data);
threadpool_job* threadpool_get_job(threadpool_t *pool);
void threadpool_run(threadpool_t *pool, job_callback_f func, void *data);
int event_pollin(EventHandler *ev, SYS_NETFD fd, Event *event);
int event_pollout(EventHandler *ev, SYS_NETFD fd, Event *event);
int event_removepoll(EventHandler *ev, SYS_NETFD fd);
int event_send(EventHandler *ev, Event *event);
ResourceData* resourcepool_lookup(Session *sn, Request *rq, const char *name, int flags);
ResourceData* resourcepool_cfg_lookup(ServerConfiguration *cfg, const char *name, int flags);
void resourcepool_free(Session *sn, Request *rq, ResourceData *resource);
NSAPI_PUBLIC char *util_html_escape(const char *s);
void ws_log_assert(const char *file, const char *func, int line);
#ifdef _DEBUG
#ifndef __FUNCTION__
#define __FUNCTION__ __func__
#endif
#define WS_ASSERT(c) if(!c) ws_log_assert(__FILE__, __FUNCTION__, __LINE__)
#else
#define WS_ASSERT(c)
#endif
#define SYS_STDERR STDERR_FILENO
#ifdef XP_WIN32
#define ERROR_PIPE \
(ERROR_BROKEN_PIPE | ERROR_BAD_PIPE | \
ERROR_PIPE_BUSY | ERROR_PIPE_LISTENING | ERROR_PIPE_NOT_CONNECTED)
#define CONVERT_TO_PRINTABLE_FORMAT(Filename) \
{ \
register char *s; \
if (Filename) \
for (s = Filename; *s; s++) \
if ( *s == '\\') \
*s = '/'; \
}
#define CONVERT_TO_NATIVE_FS(Filename) \
{ \
register char *s; \
if (Filename) \
for (s = Filename; *s; s++) \
if ( *s == '/') \
*s = '\\'; \
}
#ifdef INTNSAPI
#if NSAPI_VERSION >= 302
#endif
#if NSAPI_VERSION >= 303
#endif
#else
#if NSAPI_VERSION >= 302
#endif
#if NSAPI_VERSION >= 303
#endif
#endif
#else
#endif
#ifdef __cplusplus
}
#endif
#endif