.PHONY: all clean
.SUFFIXES: .c .o .so
-all: mod_example.so
+all: mod_example.so mod_cgi.so
.o.so:
$(CC) $(LDFLAGS) -shared -o $@ $< ../Common/common.a $(LIBS)
--- /dev/null
+/* $Id$ */
+
+#include "../Server/tw_module.h"
+
+int mod_init(struct tw_config* config, struct tw_tool* tools) {
+ tools->log("CGI", "Initializing CGI module");
+ tools->add_version("CGI/1.1");
+ return 0;
+}
+
+int mod_config(struct tw_tool* tools, char** argv, int argc) {
+ printf("args %d\n", argc);
+ return TW_CONFIG_ERROR;
+}
+
+int mod_request(struct tw_tool* tools, struct tw_http_request* req, struct tw_http_response* res) { return TW_MODULE_PASS; }
current->readmes[current->readme_count++] = cm_strdup(r[i]);
}
} else {
+ stop = 1;
if(r[0] != NULL) {
- cm_log("Config", "Unknown directive `%s' at line %d", r[0], ln);
+ int argc;
+ for(argc = 0; r[argc] != NULL; argc++)
+ ;
+ stop = 0;
+ int i;
+ bool called = false;
+ struct tw_tool tools;
+ tw_init_tools(&tools);
+ for(i = 0; i < config.module_count; i++) {
+ tw_mod_config_t mod_config = (tw_mod_config_t)tw_module_symbol(config.modules[i], "mod_config");
+ int resp;
+ if(mod_config != NULL && (resp = mod_config(&tools, r, argc)) == TW_CONFIG_PARSED) {
+ called = true;
+ break;
+ }
+ if(resp == TW_CONFIG_ERROR) {
+ stop = 1;
+ called = true;
+ break;
+ }
+ }
+ if(!called) {
+ cm_log("Config", "Unknown directive `%s' at line %d", r[0], ln);
+ stop = 1;
+ }
}
- stop = 1;
}
for(i = 0; r[i] != NULL; i++) free(r[i]);
free(r);
enum TW_MODULE_RETURN {
_TW_MODULE_PASS = 0, /* Pass to the next module. */
_TW_MODULE_STOP, /* Do not pass to the next module. */
- _TW_MODULE_ERROR /* Error, and do not pass to the next module. */
+ _TW_MODULE_ERROR, /* Error, and do not pass to the next module. */
+
+ _TW_CONFIG_PARSED, /* Got parsed */
+ _TW_CONFIG_NOTME, /* Did not parse */
+ _TW_CONFIG_ERROR /* Error */
};
#define TW_MODULE_PASS _TW_MODULE_PASS
#define TW_MODULE_STOP _TW_MODULE_STOP
#define TW_MODULE_ERROR(x) (_TW_MODULE_ERROR | ((x) << 8))
+#define TW_CONFIG_PARSED _TW_CONFIG_PARSED
+#define TW_CONFIG_NOTME _TW_CONFIG_NOTME
+#define TW_CONFIG_ERROR _TW_CONFIG_ERROR
+
typedef int (*tw_mod_init_t)(struct tw_config* config, struct tw_tool* tools);
typedef int (*tw_mod_request_t)(struct tw_tool* tools, struct tw_http_request* req, struct tw_http_response* res);
+typedef int (*tw_mod_config_t)(struct tw_tool* tools, char** argv, int argc);
void* tw_module_load(const char* path);
void* tw_module_symbol(void* mod, const char* sym);
# $Id$
# This is an example config
-#LoadModule /home/nishi/SVN/tewi/trunk/Module/mod_example.so
+LoadModule /home/nishi/SVN/tewi/trunk/Module/mod_cgi.so
Listen 80
ListenSSL 443