src/server/public/nsapi.h

changeset 385
a1f4cb076d2f
parent 371
ea836c4f7341
child 432
7c9137f9e7f9
--- a/src/server/public/nsapi.h	Tue Aug 13 22:14:32 2019 +0200
+++ b/src/server/public/nsapi.h	Sat Sep 24 16:26:10 2022 +0200
@@ -110,6 +110,9 @@
 
 /* --- Begin miscellaneous definitions --- */
 
+#define WS_TRUE 1
+#define WS_FALSE 0
+
 /* Used in some places as a length limit on error messages */
 #define MAGNUS_ERROR_LEN 1024
 
@@ -355,9 +358,6 @@
 #ifndef HPUX
 #include <sys/select.h>
 #endif
-#ifndef BSD
-#include <alloca.h> /* new */
-#endif
 #include <sys/socket.h>
 #include <sys/time.h>
 #include <sys/types.h>
@@ -404,6 +404,7 @@
 //          they are VFSFile*
 // TODO: fix NOTE
 
+typedef int WSBool;
 
 #ifndef SYS_FILE_T
 typedef struct VFSFile *SYS_FILE;
@@ -690,6 +691,15 @@
 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;
+
 #ifndef PR_AF_INET
 typedef union PRNetAddr PRNetAddr;
 #endif
@@ -763,6 +773,36 @@
 
 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);
+
 //////
 /*
  * VSInitFunc, VSDestroyFunc, VSDirectiveInitFunc and VSDirectiveDestroyFunc
@@ -1483,6 +1523,7 @@
 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);
 
@@ -1568,6 +1609,7 @@
 
 // threadpool
 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);
@@ -1577,6 +1619,14 @@
 int event_removepoll(EventHandler *ev, SYS_NETFD fd);
 int event_send(EventHandler *ev, Event *event);
 
+// resource pool
+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);
+
+// utils
+NSAPI_PUBLIC char *util_html_escape(const char *s);
+
 // assert
 void ws_log_assert(const char *file, const char *func, int line);
 #ifdef _DEBUG

mercurial