bug 336837: convert from popt to goption
This commit is contained in:
@@ -109,14 +109,6 @@ PKG_CHECK_MODULES(GLIB, glib-2.0 >= $GLIB_REQUIRED)
|
|||||||
AC_SUBST(GLIB_CFLAGS)
|
AC_SUBST(GLIB_CFLAGS)
|
||||||
AC_SUBST(GLIB_LIBS)
|
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])
|
AC_CHECK_HEADER(ifaddrs.h, [HAVE_IFADDRS_H=yes], [HAVE_IFADDRS_H=no])
|
||||||
if test x$HAVE_IFADDRS_H = xyes ; then
|
if test x$HAVE_IFADDRS_H = xyes ; then
|
||||||
AC_DEFINE(HAVE_IFADDRS_H, 1, [defined if you have ifaddrs.h])
|
AC_DEFINE(HAVE_IFADDRS_H, 1, [defined if you have ifaddrs.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_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);
|
void syslog_io_message (int priority, const char *format, ...) G_GNUC_INTERNAL G_GNUC_PRINTF(2, 3);
|
||||||
|
|
||||||
extern int enable_debug;
|
extern gboolean enable_debug;
|
||||||
extern int verbose_output;
|
extern gboolean verbose_output;
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
@@ -46,7 +46,6 @@
|
|||||||
#include <glibtop/gnuserv.h>
|
#include <glibtop/gnuserv.h>
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <popt.h>
|
|
||||||
|
|
||||||
#include "daemon.h"
|
#include "daemon.h"
|
||||||
|
|
||||||
@@ -79,10 +78,10 @@ static Xauth *server_xauth = NULL;
|
|||||||
|
|
||||||
#endif /* AUTH_MAGIC_COOKIE */
|
#endif /* AUTH_MAGIC_COOKIE */
|
||||||
|
|
||||||
int enable_debug = 0;
|
gboolean enable_debug = FALSE;
|
||||||
int verbose_output = 0;
|
gboolean verbose_output = FALSE;
|
||||||
static int no_daemon = 0;
|
static gboolean no_daemon = FALSE;
|
||||||
static int invoked_from_inetd = 0;
|
static gboolean invoked_from_inetd = FALSE;
|
||||||
static int changed_uid = 0;
|
static int changed_uid = 0;
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -454,27 +453,26 @@ handle_signal (int sig)
|
|||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct poptOption popt_options [] = {
|
static const GOptionEntry options [] = {
|
||||||
POPT_AUTOHELP
|
{ "debug", 'd', 0, G_OPTION_ARG_NONE, &enable_debug,
|
||||||
{ "debug", 'd', POPT_ARG_NONE, &enable_debug, 0,
|
N_("Enable debugging"), NULL },
|
||||||
N_("Enable debugging"), N_("DEBUG") },
|
{ "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose_output,
|
||||||
{ "verbose", 'v', POPT_ARG_NONE, &verbose_output, 0,
|
N_("Enable verbose output"), NULL },
|
||||||
N_("Enable verbose output"), N_("VERBOSE") },
|
{ "no-daemon", 'f', 0, G_OPTION_ARG_NONE, &no_daemon,
|
||||||
{ "no-daemon", 'f', POPT_ARG_NONE, &no_daemon, 0,
|
N_("Don't fork into background"), NULL },
|
||||||
N_("Don't fork into background"), N_("NO-DAEMON") },
|
{ "inetd", 'i', 0, G_OPTION_ARG_NONE, &invoked_from_inetd,
|
||||||
{ "inetd", 'i', POPT_ARG_NONE, &invoked_from_inetd, 0,
|
N_("Invoked from inetd"), NULL },
|
||||||
N_("Invoked from inetd"), N_("INETD") },
|
{ NULL }
|
||||||
{ NULL, '\0', 0, NULL, 0, NULL, NULL }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, const char **argv)
|
main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
const unsigned method = GLIBTOP_METHOD_PIPE;
|
const unsigned method = GLIBTOP_METHOD_PIPE;
|
||||||
const unsigned long features = GLIBTOP_SYSDEPS_ALL;
|
const unsigned long features = GLIBTOP_SYSDEPS_ALL;
|
||||||
glibtop *server = glibtop_global_server;
|
glibtop *server = glibtop_global_server;
|
||||||
poptContext context;
|
GOptionContext *goption_context;
|
||||||
int nextopt;
|
GError *error = NULL;
|
||||||
|
|
||||||
int ils = -1; /* internet domain listen socket */
|
int ils = -1; /* internet domain listen socket */
|
||||||
|
|
||||||
@@ -488,21 +486,18 @@ main (int argc, const char **argv)
|
|||||||
arg ? (arg + 1) : program_invocation_name;
|
arg ? (arg + 1) : program_invocation_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
context = poptGetContext ("libgtop-daemon", argc, argv,
|
g_set_prgname (program_invocation_short_name);
|
||||||
popt_options, 0);
|
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);
|
||||||
|
|
||||||
poptReadDefaultConfig (context, TRUE);
|
if (error != NULL) {
|
||||||
|
g_printerr ("%s\n", error->message);
|
||||||
while ((nextopt = poptGetNextOpt (context)) > 0)
|
g_error_free (error);
|
||||||
/* do nothing */ ;
|
g_printerr (_("Run '%s --help' to see a full list of "
|
||||||
|
|
||||||
if(nextopt != -1) {
|
|
||||||
printf (_("Error on option %s: %s.\n"
|
|
||||||
"Run '%s --help' to see a full list of "
|
|
||||||
"available command line options.\n"),
|
"available command line options.\n"),
|
||||||
poptBadOption (context, 0),
|
program_invocation_name);
|
||||||
poptStrerror (nextopt),
|
|
||||||
argv[0]);
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user