From aed26bf002ea776806f84b4b9d03a8d4f0b83d27 Mon Sep 17 00:00:00 2001 From: Date: Mon, 30 Jan 2006 08:56:40 +0100 Subject: [PATCH] Introduced CGI module --- src/protocol/file/cgi.c | 24 ++++++++++++++++++++++++ src/protocol/file/cgi.h | 2 ++ src/protocol/file/file.c | 14 -------------- src/protocol/protocol.c | 4 ++++ 4 files changed, 30 insertions(+), 14 deletions(-) diff --git a/src/protocol/file/cgi.c b/src/protocol/file/cgi.c index ddca7136..91ee73bf 100644 --- a/src/protocol/file/cgi.c +++ b/src/protocol/file/cgi.c @@ -35,6 +35,30 @@ #include "util/env.h" #include "util/string.h" +static struct option_info cgi_options[] = { + INIT_OPT_TREE("protocol.file", N_("Local CGI"), + "cgi", 0, + N_("Local CGI specific options.")), + + INIT_OPT_STRING("protocol.file.cgi", N_("Path"), + "path", 0, "", + N_("Colon separated list of directories, where CGI scripts are stored.")), + + INIT_OPT_BOOL("protocol.file.cgi", N_("Allow local CGI"), + "policy", 0, 0, + N_("Whether to execute local CGI scripts.")), + NULL_OPTION_INFO, +}; + +struct module cgi_protocol_module = struct_module( + /* name: */ N_("CGI"), + /* options: */ cgi_options, + /* hooks: */ NULL, + /* submodules: */ NULL, + /* data: */ NULL, + /* init: */ NULL, + /* done: */ NULL +); static void close_pipe_and_read(struct socket *data_socket) diff --git a/src/protocol/file/cgi.h b/src/protocol/file/cgi.h index bf844fa8..72cd6a02 100644 --- a/src/protocol/file/cgi.h +++ b/src/protocol/file/cgi.h @@ -3,7 +3,9 @@ #define EL__PROTOCOL_FILE_CGI_H struct connection; +struct module; +extern struct module cgi_protocol_module; int execute_cgi(struct connection *); #endif diff --git a/src/protocol/file/file.c b/src/protocol/file/file.c index b085a943..fe37eb18 100644 --- a/src/protocol/file/file.c +++ b/src/protocol/file/file.c @@ -39,20 +39,6 @@ static struct option_info file_options[] = { "file", 0, N_("Options specific to local browsing.")), -#ifdef CONFIG_CGI - INIT_OPT_TREE("protocol.file", N_("Local CGI"), - "cgi", 0, - N_("Local CGI specific options.")), - - INIT_OPT_STRING("protocol.file.cgi", N_("Path"), - "path", 0, "", - N_("Colon separated list of directories, where CGI scripts are stored.")), - - INIT_OPT_BOOL("protocol.file.cgi", N_("Allow local CGI"), - "policy", 0, 0, - N_("Whether to execute local CGI scripts.")), -#endif /* CONFIG_CGI */ - INIT_OPT_BOOL("protocol.file", N_("Allow reading special files"), "allow_special_files", 0, 0, N_("Whether to allow reading from non-regular files.\n" diff --git a/src/protocol/protocol.c b/src/protocol/protocol.c index 9ab10da8..75de4646 100644 --- a/src/protocol/protocol.c +++ b/src/protocol/protocol.c @@ -29,6 +29,7 @@ #include "protocol/bittorrent/bittorrent.h" #include "protocol/bittorrent/connection.h" #include "protocol/data.h" +#include "protocol/file/cgi.h" #include "protocol/file/file.h" #include "protocol/finger/finger.h" #include "protocol/fsp/fsp.h" @@ -275,6 +276,9 @@ static struct module *protocol_submodules[] = { &bittorrent_protocol_module, #endif &file_protocol_module, +#ifdef CONFIG_CGI + &cgi_protocol_module, +#endif #ifdef CONFIG_FINGER &finger_protocol_module, #endif