1 |
nishi |
1.1 |
/* $Id: tw_module.h 369 2024-10-17 04:28:13Z nishi $ */ |
2 |
|
|
|
3 |
|
|
#ifndef __TW_MODULE_H__ |
4 |
|
|
#define __TW_MODULE_H__ |
5 |
|
|
|
6 |
|
|
#ifdef __cplusplus |
7 |
|
|
extern "C" { |
8 |
|
|
#endif |
9 |
|
|
|
10 |
|
|
#include "tw_config.h" |
11 |
|
|
#include "tw_http.h" |
12 |
|
|
|
13 |
|
|
#ifdef __NETWARE__ |
14 |
|
|
#include <nwconio.h> |
15 |
|
|
#include <nwthread.h> |
16 |
|
|
#include <stddef.h> |
17 |
|
|
#define END_MODULE void _thread(void* arg){ \ |
18 |
|
|
SuspendThread(GetThreadID()); \ |
19 |
|
|
} \ |
20 |
|
|
int main(){ \ |
21 |
|
|
DestroyScreen(GetCurrentScreen()); \ |
22 |
|
|
BeginThread(_thread, NULL, 0, NULL); \ |
23 |
|
|
ThreadSwitch(); \ |
24 |
|
|
return 0; \ |
25 |
|
|
} |
26 |
|
|
#else |
27 |
|
|
#define END_MODULE |
28 |
|
|
#endif |
29 |
|
|
|
30 |
|
|
#if defined(__OS2__) |
31 |
|
|
#define INCL_DOSMODULEMGR |
32 |
|
|
#define INCL_DOSERRORS |
33 |
|
|
#include <os2.h> |
34 |
|
|
#define MODULE_DECL __export APIENTRY |
35 |
|
|
#elif defined(__WATCOMC__) |
36 |
|
|
#define MODULE_DECL __export |
37 |
|
|
#else |
38 |
|
|
#define MODULE_DECL |
39 |
|
|
#endif |
40 |
|
|
|
41 |
|
|
struct tw_tool { |
42 |
|
|
void (*log)(const char* name, const char* log, ...); |
43 |
|
|
void (*add_version)(const char* string); |
44 |
|
|
void (*add_define)(const char* string); |
45 |
|
|
void (*delete_define)(const char* string); |
46 |
|
|
}; |
47 |
|
|
|
48 |
|
|
enum TW_MODULE_RETURN { |
49 |
|
|
_TW_MODULE_PASS = 0, /* Pass to the next module. */ |
50 |
|
|
_TW_MODULE_STOP, /* Do not pass to the next module. */ |
51 |
|
|
_TW_MODULE_STOP2, /* Do not pass to the next module, and do not handle response. */ |
52 |
|
|
_TW_MODULE_ERROR, /* Error, and do not pass to the next module. */ |
53 |
|
|
|
54 |
|
|
_TW_CONFIG_PARSED, /* Got parsed */ |
55 |
|
|
_TW_CONFIG_NOTME, /* Did not parse */ |
56 |
|
|
_TW_CONFIG_ERROR /* Error */ |
57 |
|
|
}; |
58 |
|
|
|
59 |
|
|
#define TW_MODULE_PASS _TW_MODULE_PASS |
60 |
|
|
#define TW_MODULE_STOP _TW_MODULE_STOP |
61 |
|
|
#define TW_MODULE_STOP2 _TW_MODULE_STOP2 |
62 |
|
|
#define TW_MODULE_ERROR(x) (_TW_MODULE_ERROR | ((x) << 8)) |
63 |
|
|
|
64 |
|
|
#define TW_CONFIG_PARSED _TW_CONFIG_PARSED |
65 |
|
|
#define TW_CONFIG_NOTME _TW_CONFIG_NOTME |
66 |
|
|
#define TW_CONFIG_ERROR _TW_CONFIG_ERROR |
67 |
|
|
|
68 |
|
|
typedef int(MODULE_DECL* tw_mod_init_t)(struct tw_config* config, struct tw_tool* tools); |
69 |
|
|
typedef int(MODULE_DECL* tw_mod_request_t)(struct tw_tool* tools, struct tw_http_request* req, struct tw_http_response* res); |
70 |
|
|
typedef int(MODULE_DECL* tw_mod_config_t)(struct tw_tool* tools, char** argv, int argc); |
71 |
|
|
|
72 |
|
|
#ifdef SOURCE |
73 |
|
|
void* tw_module_load(const char* path); |
74 |
|
|
void* tw_module_symbol(void* mod, const char* sym); |
75 |
|
|
void tw_init_tools(struct tw_tool* tools); |
76 |
|
|
int tw_module_init(void* mod); |
77 |
|
|
|
78 |
|
|
void tw_add_version(const char* string); |
79 |
|
|
void tw_add_define(const char* string); |
80 |
|
|
void tw_delete_define(const char* string); |
81 |
|
|
#endif |
82 |
|
|
|
83 |
|
|
#ifdef __cplusplus |
84 |
|
|
} |
85 |
|
|
#endif |
86 |
|
|
|
87 |
|
|
#endif |