src/server/public/nsapi.h

changeset 193
aa8393527b1e
parent 166
c07122f66676
parent 189
a2438f6d1e73
child 211
2160585200ac
--- a/src/server/public/nsapi.h	Thu Aug 31 16:29:49 2017 +0200
+++ b/src/server/public/nsapi.h	Sat Jan 13 19:01:00 2018 +0100
@@ -605,6 +605,28 @@
 };
 
 
+// nsapi ext begin
+
+#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;
+};
+
+// nsapi ext end
+
+
 typedef void* CONDVAR;
 typedef void *COUNTING_SEMAPHORE;
 typedef void* CRITICAL;
@@ -684,6 +706,8 @@
     struct in_addr iaddr;
 
     pool_handle_t *pool;
+    
+    EventHandler *ev; /* event handler instance (new) */
 
     void *clauth;       /* v2 ACL client authentication information */
     struct Session *next;
@@ -1117,7 +1141,19 @@
 #define ISMOPTIONS(r)   ((r)->method_num == METHOD_OPTIONS)
 
 
-// new type
+// new types
+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);
@@ -1298,6 +1334,8 @@
 // NSAPI extension
 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);
 
@@ -1503,9 +1541,14 @@
 /* file */
 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);
@@ -1521,6 +1564,7 @@
 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
 threadpool_t* threadpool_new(int min, int max);
@@ -1528,6 +1572,10 @@
 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);
 
 // assert
 void ws_log_assert(const char *file, const char *func, int line);

mercurial