From adaf8af1ff273c61f84de7d51960165676d6eaaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BChler?= Date: Fri, 7 May 2010 22:50:48 +0200 Subject: [PATCH] Add option handling, bump version number to 0.1.5, add man-page --- CMakeLists.txt | 10 +++++++++- Makefile.am | 5 ++--- configure.ac | 2 +- fcgi-cgi.1 | 33 +++++++++++++++++++++++++++++++++ fcgi-cgi.c | 21 +++++++++++++++++++-- 5 files changed, 64 insertions(+), 7 deletions(-) create mode 100644 fcgi-cgi.1 diff --git a/CMakeLists.txt b/CMakeLists.txt index d3f4f3a..08e15ee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,7 @@ MACRO(ADD_TARGET_PROPERTIES _target _name _properties) ENDMACRO(ADD_TARGET_PROPERTIES) PROJECT(fcgi-cgi) -SET(PACKAGE_VERSION 0.1.0) +SET(PACKAGE_VERSION 0.1.5) IF("${CMAKE_BUILD_TYPE}" STREQUAL "") SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel." FORCE) ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "") @@ -71,3 +71,11 @@ ADD_TARGET_PROPERTIES(fcgi-cgi LINK_FLAGS "${GLIB2_LDFLAGS}") ADD_TARGET_PROPERTIES(fcgi-cgi COMPILE_FLAGS "${GLIB2_CFLAGS_OTHER}") INSTALL(TARGETS fcgi-cgi DESTINATION bin) + +# man page + +SET(CMAKE_MAN_DIR "share/man" CACHE STRING + "Install location for man pages (relative to prefix).") +MARK_AS_ADVANCED(CMAKE_MAN_DIR) + +INSTALL(FILES fcgi-cgi.1 DESTINATION ${CMAKE_MAN_DIR}/man1) diff --git a/Makefile.am b/Makefile.am index 8048763..20fac47 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,6 +1,5 @@ -# fcgi-cgi.1 -EXTRA_DIST=autogen.sh CMakeLists.txt config.h.cmake -#man1_MANS=fcgi-cgi.1 +EXTRA_DIST=autogen.sh CMakeLists.txt config.h.cmake fcgi-cgi.1 +man1_MANS=fcgi-cgi.1 AM_CFLAGS=$(GLIB_CFLAGS) fcgi_cgi_LDADD=$(GLIB_LIBS) diff --git a/configure.ac b/configure.ac index 2e9c37b..c57a23a 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ([2.63]) -AC_INIT([fcgi-cgi], [0.1.0], [lighttpd@stbuehler.de]) +AC_INIT([fcgi-cgi], [0.1.5], [lighttpd@stbuehler.de]) AC_CONFIG_SRCDIR([fcgi-cgi.c]) AC_CONFIG_HEADERS([config.h]) diff --git a/fcgi-cgi.1 b/fcgi-cgi.1 new file mode 100644 index 0000000..3b8d392 --- /dev/null +++ b/fcgi-cgi.1 @@ -0,0 +1,33 @@ +.TH fcgi-cgi 1 "May 7, 2010" +. +.SH NAME +. +fcgi-cgi \- a FastCGI application to run cgi applications +. +.SH OPTIONS +. +.TP 8 +.B \-c +Maximum number of connections (default 16) +.TP 8 +.B \-v +Shows version information and exits +. +.SH DESCRIPTION +fcgi-cgi is a FastCGI application to run normal cgi applications. It doesn't +make CGI applications faster, but it allows you to run them on a different +host and with different user permissions (without the need for suexec). +.P +lighttpd2 won't have a mod_cgi, so you need this FastCGI wrapper to be +able to execute standard cgi applications like mailman and cgit. +.P +nginx recommends something similar, they implemented the wrapper in Perl: +http://wiki.nginx.org/NginxSimpleCGI +.P +For running you probably want spawn-fcgi (http://redmine.lighttpd.net/projects/spawn-fcgi) +.SH EXAMPLE +Example usage: + +spawn-fcgi -n -s /tmp/fastcgi-cgi.sock -u www-default -U www-data -- /usr/bin/fcgi-cgi +.SH AUTHOR +fcgi-cgi was written by Stefan Bühler. diff --git a/fcgi-cgi.c b/fcgi-cgi.c index fc44a7f..f946028 100644 --- a/fcgi-cgi.c +++ b/fcgi-cgi.c @@ -23,6 +23,8 @@ #define __STR(x) #x #define ERROR(...) g_printerr("fcgi-cgi.c:" G_STRINGIFY(__LINE__) ": " __VA_ARGS__) +#define PACKAGE_DESC (PACKAGE_NAME " v" PACKAGE_VERSION " - forks and watches multiple instances of a program in the same environment") + struct fcgi_cgi_server; typedef struct fcgi_cgi_server fcgi_cgi_server; @@ -557,10 +559,25 @@ static const GOptionEntry entries[] = { }; int main(int argc, char **argv) { + GOptionContext *context; + GError *error = NULL; struct ev_loop *loop; fcgi_cgi_server* srv; - UNUSED(argc); - UNUSED(argv); + + context = g_option_context_new(" [app arguments]"); + g_option_context_add_main_entries(context, entries, NULL); + g_option_context_set_summary(context, PACKAGE_DESC); + + if (!g_option_context_parse (context, &argc, &argv, &error)) { + g_printerr("Option parsing failed: %s\n", error->message); + return -1; + } + + if (opts.show_version) { + g_printerr(PACKAGE_DESC); + g_printerr("\nBuild-Date: " __DATE__ " " __TIME__ "\n"); + return 0; + } loop = ev_default_loop(0); srv = fcgi_cgi_server_create(loop, 0, opts.maxconns);