From a7cf016d67ac43099ed674fd287bac629d724715 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Dejean?= Date: Sun, 2 Apr 2006 09:09:41 +0000 Subject: Reverted. See #336837 * configure.in: * src/daemon/daemon.h: * src/daemon/gnuserv.c: (main): Reverted. See #336837 --- ChangeLog | 8 +++++++ configure.in | 8 +++++++ src/daemon/daemon.h | 4 ++-- src/daemon/gnuserv.c | 65 ++++++++++++++++++++++++++++------------------------ 4 files changed, 53 insertions(+), 32 deletions(-) diff --git a/ChangeLog b/ChangeLog index f6fce345..849ceb6c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2006-04-02 BenoƮt Dejean + + * configure.in: + * src/daemon/daemon.h: + * src/daemon/gnuserv.c: (main): + + Reverted. See #336837 + 2006-03-18 Vladimer Sichinava * configure.in: Added "ka" (Georgian) to ALL_LINGUAS diff --git a/configure.in b/configure.in index 8a9085f7..92c3de20 100644 --- a/configure.in +++ b/configure.in @@ -109,6 +109,14 @@ PKG_CHECK_MODULES(GLIB, glib-2.0 >= $GLIB_REQUIRED) AC_SUBST(GLIB_CFLAGS) AC_SUBST(GLIB_LIBS) +AC_CHECK_HEADER(popt.h,[POPT=yes],[POPT=no]) +AC_MSG_CHECKING(for popt.h) +if test x$POPT = xyes ; then + AC_MSG_RESULT(yes) +else + AC_MSG_ERROR([libgtop requires the popt development libraries]) +fi + AC_CHECK_HEADER(ifaddrs.h, [HAVE_IFADDRS_H=yes], [HAVE_IFADDRS_H=no]) if test x$HAVE_IFADDRS_H = xyes ; then AC_DEFINE(HAVE_IFADDRS_H, 1, [defined if you have ifaddrs.h]) diff --git a/src/daemon/daemon.h b/src/daemon/daemon.h index 21badd0f..a585b32c 100644 --- a/src/daemon/daemon.h +++ b/src/daemon/daemon.h @@ -71,8 +71,8 @@ int do_read (int s, void *ptr, size_t total_size) G_GNUC_INTERNAL; void syslog_message (int priority, const char *format, ...) G_GNUC_INTERNAL G_GNUC_PRINTF(2, 3); void syslog_io_message (int priority, const char *format, ...) G_GNUC_INTERNAL G_GNUC_PRINTF(2, 3); -extern gboolean enable_debug; -extern gboolean verbose_output; +extern int enable_debug; +extern int verbose_output; G_END_DECLS diff --git a/src/daemon/gnuserv.c b/src/daemon/gnuserv.c index 8243b871..ea61ded1 100644 --- a/src/daemon/gnuserv.c +++ b/src/daemon/gnuserv.c @@ -46,6 +46,7 @@ #include #include +#include #include "daemon.h" @@ -78,10 +79,10 @@ static Xauth *server_xauth = NULL; #endif /* AUTH_MAGIC_COOKIE */ -gboolean enable_debug = FALSE; -gboolean verbose_output = FALSE; -static gboolean no_daemon = FALSE; -static gboolean invoked_from_inetd = FALSE; +int enable_debug = 0; +int verbose_output = 0; +static int no_daemon = 0; +static int invoked_from_inetd = 0; static int changed_uid = 0; void @@ -453,26 +454,27 @@ handle_signal (int sig) exit (1); } -static const GOptionEntry options [] = { - { "debug", 'd', 0, G_OPTION_ARG_NONE, &enable_debug, - N_("Enable debugging"), NULL }, - { "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose_output, - N_("Enable verbose output"), NULL }, - { "no-daemon", 'f', 0, G_OPTION_ARG_NONE, &no_daemon, - N_("Don't fork into background"), NULL }, - { "inetd", 'i', 0, G_OPTION_ARG_NONE, &invoked_from_inetd, - N_("Invoked from inetd"), NULL }, - { NULL } +const struct poptOption popt_options [] = { + POPT_AUTOHELP + { "debug", 'd', POPT_ARG_NONE, &enable_debug, 0, + N_("Enable debugging"), N_("DEBUG") }, + { "verbose", 'v', POPT_ARG_NONE, &verbose_output, 0, + N_("Enable verbose output"), N_("VERBOSE") }, + { "no-daemon", 'f', POPT_ARG_NONE, &no_daemon, 0, + N_("Don't fork into background"), N_("NO-DAEMON") }, + { "inetd", 'i', POPT_ARG_NONE, &invoked_from_inetd, 0, + N_("Invoked from inetd"), N_("INETD") }, + { NULL, '\0', 0, NULL, 0, NULL, NULL } }; int -main (int argc, char **argv) +main (int argc, const char **argv) { const unsigned method = GLIBTOP_METHOD_PIPE; const unsigned long features = GLIBTOP_SYSDEPS_ALL; glibtop *server = glibtop_global_server; - GOptionContext *goption_context; - GError *error = NULL; + poptContext context; + int nextopt; int ils = -1; /* internet domain listen socket */ @@ -486,19 +488,22 @@ main (int argc, char **argv) arg ? (arg + 1) : program_invocation_name; } - g_set_prgname (program_invocation_short_name); - goption_context = g_option_context_new (NULL); - g_option_context_add_main_entries (goption_context, options, NULL); - g_option_context_parse (goption_context, &argc, &argv, &error); - g_option_context_free (goption_context); - - if (error != NULL) { - g_printerr ("%s\n", error->message); - g_error_free (error); - g_printerr (_("Run '%s --help' to see a full list of " - "available command line options.\n"), - program_invocation_name); - exit(1); + context = poptGetContext ("libgtop-daemon", argc, argv, + popt_options, 0); + + poptReadDefaultConfig (context, TRUE); + + while ((nextopt = poptGetNextOpt (context)) > 0) + /* do nothing */ ; + + if(nextopt != -1) { + printf (_("Error on option %s: %s.\n" + "Run '%s --help' to see a full list of " + "available command line options.\n"), + poptBadOption (context, 0), + poptStrerror (nextopt), + argv[0]); + exit(1); } if (enable_debug) -- cgit v1.2.1