603 char *encoding; |
603 char *encoding; |
604 char *language; |
604 char *language; |
605 }; |
605 }; |
606 |
606 |
607 |
607 |
|
608 // nsapi ext begin |
|
609 |
|
610 #define EVENT_POLLIN 0x1 |
|
611 #define EVENT_POLLOUT 0x2 |
|
612 |
|
613 typedef struct EventHandler EventHandler; |
|
614 typedef struct Event Event; |
|
615 |
|
616 typedef int(*eventfunc)(EventHandler*, Event*); |
|
617 |
|
618 struct Event { |
|
619 eventfunc fn; |
|
620 eventfunc finish; |
|
621 void *cookie; |
|
622 intptr_t object; |
|
623 int events; |
|
624 int error; |
|
625 }; |
|
626 |
|
627 // nsapi ext end |
|
628 |
|
629 |
608 typedef void* CONDVAR; |
630 typedef void* CONDVAR; |
609 typedef void *COUNTING_SEMAPHORE; |
631 typedef void *COUNTING_SEMAPHORE; |
610 typedef void* CRITICAL; |
632 typedef void* CRITICAL; |
611 |
633 |
612 #ifdef XP_UNIX |
634 #ifdef XP_UNIX |
1115 #define ISMCOPY(r) ((r)->method_num == METHOD_COPY) |
1139 #define ISMCOPY(r) ((r)->method_num == METHOD_COPY) |
1116 #define ISMTRACE(r) ((r)->method_num == METHOD_TRACE) |
1140 #define ISMTRACE(r) ((r)->method_num == METHOD_TRACE) |
1117 #define ISMOPTIONS(r) ((r)->method_num == METHOD_OPTIONS) |
1141 #define ISMOPTIONS(r) ((r)->method_num == METHOD_OPTIONS) |
1118 |
1142 |
1119 |
1143 |
1120 // new type |
1144 // new types |
|
1145 typedef struct aiocb_s { |
|
1146 SYS_FILE filedes; |
|
1147 void *buf; |
|
1148 size_t nbytes; |
|
1149 off_t offset; |
|
1150 ssize_t result; |
|
1151 int result_errno; |
|
1152 Event *event; |
|
1153 EventHandler *evhandler; |
|
1154 } aiocb_s; |
|
1155 |
|
1156 |
1121 typedef struct _thread_pool threadpool_t; |
1157 typedef struct _thread_pool threadpool_t; |
1122 typedef struct _threadpool_job threadpool_job; |
1158 typedef struct _threadpool_job threadpool_job; |
1123 typedef void*(*job_callback_f)(void *data); |
1159 typedef void*(*job_callback_f)(void *data); |
1124 |
1160 |
1125 |
1161 |
1296 void net_close(SYS_NETFD fd); |
1332 void net_close(SYS_NETFD fd); |
1297 |
1333 |
1298 // NSAPI extension |
1334 // NSAPI extension |
1299 ssize_t net_printf(SYS_NETFD fd, char *format, ...); |
1335 ssize_t net_printf(SYS_NETFD fd, char *format, ...); |
1300 |
1336 |
|
1337 int net_setnonblock(SYS_NETFD fd, int nonblock); |
|
1338 int net_errno(SYS_NETFD fd); |
1301 |
1339 |
1302 NSAPI_PUBLIC pb_param *INTparam_create(const char *name, const char *value); |
1340 NSAPI_PUBLIC pb_param *INTparam_create(const char *name, const char *value); |
1303 |
1341 |
1304 NSAPI_PUBLIC int INTparam_free(pb_param *pp); |
1342 NSAPI_PUBLIC int INTparam_free(pb_param *pp); |
1305 |
1343 |
1501 #define netbuf_grab netbuf_grab |
1539 #define netbuf_grab netbuf_grab |
1502 |
1540 |
1503 /* file */ |
1541 /* file */ |
1504 NSAPI_PUBLIC int system_fread(SYS_FILE fd, void *buf, int nbyte); |
1542 NSAPI_PUBLIC int system_fread(SYS_FILE fd, void *buf, int nbyte); |
1505 NSAPI_PUBLIC int system_fwrite(SYS_FILE fd, const void *buf, int nbyte); |
1543 NSAPI_PUBLIC int system_fwrite(SYS_FILE fd, const void *buf, int nbyte); |
|
1544 NSAPI_PUBLIC int system_pread(SYS_FILE fd, void *buf, int nbyte, off_t offset); |
|
1545 NSAPI_PUBLIC int system_pwrite(SYS_FILE fd, const void *buf, int nbyte, off_t offset); |
1506 NSAPI_PUBLIC off_t system_lseek(SYS_FILE fd, off_t offset, int whence); |
1546 NSAPI_PUBLIC off_t system_lseek(SYS_FILE fd, off_t offset, int whence); |
1507 NSAPI_PUBLIC int system_fclose(SYS_FILE fd); |
1547 NSAPI_PUBLIC int system_fclose(SYS_FILE fd); |
|
1548 |
|
1549 NSAPI_PUBLIC int system_aio_read(aiocb_s *aiocb); |
|
1550 NSAPI_PUBLIC int system_aio_write(aiocb_s *aiocb); |
1508 |
1551 |
1509 |
1552 |
1510 int log_ereport(int degree, const char *format, ...); |
1553 int log_ereport(int degree, const char *format, ...); |
1511 int log_ereport_v(int degree, const char *format, va_list args); |
1554 int log_ereport_v(int degree, const char *format, va_list args); |
1512 int log_error(int degree, const char *func, Session *sn, Request *rq, |
1555 int log_error(int degree, const char *func, Session *sn, Request *rq, |
1519 NSAPI_PUBLIC int util_errno2status(int errno_value); // new |
1562 NSAPI_PUBLIC int util_errno2status(int errno_value); // new |
1520 #define util_errno2status util_errno2status |
1563 #define util_errno2status util_errno2status |
1521 NSAPI_PUBLIC pblock* util_parse_param(pool_handle_t *pool, char *query); |
1564 NSAPI_PUBLIC pblock* util_parse_param(pool_handle_t *pool, char *query); |
1522 #define util_parse_param util_parse_param |
1565 #define util_parse_param util_parse_param |
1523 |
1566 |
|
1567 void nsapi_function_return(Session *sn, Request *rq, int ret); |
1524 |
1568 |
1525 // threadpool |
1569 // threadpool |
1526 threadpool_t* threadpool_new(int min, int max); |
1570 threadpool_t* threadpool_new(int min, int max); |
1527 void* threadpool_func(void *data); |
1571 void* threadpool_func(void *data); |
1528 threadpool_job* threadpool_get_job(threadpool_t *pool); |
1572 threadpool_job* threadpool_get_job(threadpool_t *pool); |
1529 void threadpool_run(threadpool_t *pool, job_callback_f func, void *data); |
1573 void threadpool_run(threadpool_t *pool, job_callback_f func, void *data); |
1530 |
1574 |
|
1575 int event_pollin(EventHandler *ev, SYS_NETFD fd, Event *event); |
|
1576 int event_pollout(EventHandler *ev, SYS_NETFD fd, Event *event); |
|
1577 int event_removepoll(EventHandler *ev, SYS_NETFD fd); |
|
1578 int event_send(EventHandler *ev, Event *event); |
1531 |
1579 |
1532 // assert |
1580 // assert |
1533 void ws_log_assert(const char *file, const char *func, int line); |
1581 void ws_log_assert(const char *file, const char *func, int line); |
1534 #ifdef _DEBUG |
1582 #ifdef _DEBUG |
1535 #ifndef __FUNCTION__ |
1583 #ifndef __FUNCTION__ |