commit-mailutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SCM] GNU Mailutils branch, master, updated. release-2.2-778-gf2279f2


From: Sergey Poznyakoff
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-778-gf2279f2
Date: Sun, 16 Oct 2016 08:02:29 +0000 (UTC)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Mailutils".

http://git.savannah.gnu.org/cgit/mailutils.git/commit/?id=f2279f27831f79d036ceab51e093250546f8b9d1

The branch, master has been updated
       via  f2279f27831f79d036ceab51e093250546f8b9d1 (commit)
      from  e3840467baf287cc14177d224dddc282674f1609 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit f2279f27831f79d036ceab51e093250546f8b9d1
Author: Sergey Poznyakoff <address@hidden>
Date:   Sun Oct 16 10:52:21 2016 +0300

    Convert comsat to mu_cli

-----------------------------------------------------------------------

Summary of changes:
 comsat/Makefile.am                    |    2 +-
 comsat/comsat.c                       |  165 +++++++++++++++------------------
 libmailutils/cli/Makefile.am          |    1 +
 {libmu_cfg => libmailutils/cli}/acl.c |    6 +-
 4 files changed, 81 insertions(+), 93 deletions(-)
 copy {libmu_cfg => libmailutils/cli}/acl.c (98%)

diff --git a/comsat/Makefile.am b/comsat/Makefile.am
index e67b218..a661ffe 100644
--- a/comsat/Makefile.am
+++ b/comsat/Makefile.am
@@ -31,7 +31,7 @@ biff.rc.h: $(top_srcdir)/comsat/biff.rc
          $(top_srcdir)/comsat/biff.rc > biff.rc.h
 
 comsatd_LDADD = \
- ${MU_APP_LIBRARIES}\
+ ${MU_APP_NEW_LIBRARIES}\
  ${MU_LIB_MBOX}\
  ${MU_LIB_IMAP}\
  ${MU_LIB_POP}\
diff --git a/comsat/comsat.c b/comsat/comsat.c
index 0911a37..c12ed20 100644
--- a/comsat/comsat.c
+++ b/comsat/comsat.c
@@ -18,7 +18,7 @@
 #include "comsat.h"
 #define MU_CFG_COMPATIBILITY /* This source uses deprecated cfg interfaces */
 #include "mailutils/libcfg.h"
-#include "mailutils/libargp.h"
+#include "mailutils/cli.h"
 
 #ifndef PATH_DEV
 # define PATH_DEV "/dev"
@@ -59,44 +59,62 @@ typedef struct utmp UTMP;
 #define MAX_TTY_SIZE (sizeof (PATH_TTY_PFX) + sizeof (((UTMP*)0)->ut_line))
 
 const char *program_version = "comsatd (" PACKAGE_STRING ")";
-static char doc[] = N_("GNU comsatd -- notify users about incoming mail");
-static char args_doc[] = N_("\n--test MBOX-URL MSG-QID");
 
-#define OPT_FOREGROUND 256
+int test_mode;
+char *biffrc = BIFF_RC;
+mu_m_server_t server;
 
-static struct argp_option options[] = 
+static void
+set_inetd_mode (struct mu_parseopt *po, struct mu_option *opt,
+               char const *arg)
 {
-  { "test", 't', NULL, 0, N_("run in test mode"), 0 },
-  { "foreground", OPT_FOREGROUND, 0, 0, N_("remain in foreground"), 0},
-  { "inetd",  'i', 0, 0, N_("run in inetd mode"), 0 },
-  { "daemon", 'd', N_("NUMBER"), OPTION_ARG_OPTIONAL,
-    N_("runs in daemon mode with a maximum of NUMBER children"), 0 },
-  { "file", 'f', N_("FILE"), 0,
-    N_("read FILE instead of .biffrc"), 0 },
-  { NULL, 0, NULL, 0, NULL, 0 }
-};
-
-static error_t comsatd_parse_opt (int key, char *arg,
-                                 struct argp_state *state);
+  mu_m_server_set_mode (server, MODE_INTERACTIVE);
+}
+  
+static void
+set_daemon_mode (struct mu_parseopt *po, struct mu_option *opt,
+                char const *arg)
+{
+  mu_m_server_set_mode (server, MODE_DAEMON);
+  if (arg)
+    {
+      size_t max_children;
+      char *errmsg;
+      int rc = mu_str_to_c (arg, mu_c_size, &max_children, &errmsg);
+      if (rc)
+       {
+         mu_parseopt_error (po, _("%s: bad argument"), arg);
+         exit (po->po_exit_error);
+       }
+      mu_m_server_set_max_children (server, max_children);
+    }
+}
 
-static struct argp argp = {
-  options,
-  comsatd_parse_opt,
-  args_doc, 
-  doc,
-  NULL,
-  NULL, NULL
-};
+static void
+set_foreground (struct mu_parseopt *po, struct mu_option *opt,
+               char const *arg)
+{
+  mu_m_server_set_foreground (server, 1);
+}
 
-static const char *comsat_argp_capa[] = {
-  "mailutils",
-  "common",
-  "debug",
-  "logging",
-  "mailbox",
-  "locking",
-  NULL
-};
+static struct mu_option comsat_options[] = {
+  { "test", 't', NULL, MU_OPTION_DEFAULT,
+    N_("run in test mode"),
+    mu_c_bool, &test_mode },
+  { "foreground",  0, NULL, MU_OPTION_DEFAULT,
+    N_("remain in foreground"),
+    mu_c_bool, NULL, set_foreground },
+  { "inetd",  'i', NULL, MU_OPTION_DEFAULT,
+    N_("run in inetd mode"),
+    mu_c_bool, NULL, set_inetd_mode },
+  { "daemon", 'd', N_("NUMBER"), MU_OPTION_ARG_OPTIONAL,
+    N_("runs in daemon mode with a maximum of NUMBER children"),
+    mu_c_string, NULL, set_daemon_mode },
+  { "file", 'f', N_("FILE"), MU_OPTION_DEFAULT,
+    N_("read FILE instead of .biffrc"),
+    mu_c_string, &biffrc },
+  MU_OPTION_END
+}, *options[] = { comsat_options, NULL };
 
 #define SUCCESS 0
 #define NOT_HERE 1
@@ -107,7 +125,6 @@ char *hostname;
 const char *username;
 int require_tty;
 int biffrc_errors = BIFFRC_ERRORS_TO_TTY | BIFFRC_ERRORS_TO_ERR;
-mu_m_server_t server;
 
 static void comsat_init (void);
 static int comsat_main (int fd);
@@ -118,9 +135,6 @@ static char *mailbox_path (const char *user);
 static int change_user (const char *user);
 
 static int reload = 0;
-int test_mode;
-char *biffrc = BIFF_RC;
-
 static int
 biffrc_error_ctl (mu_config_value_t *val, int flag)
 {
@@ -171,55 +185,30 @@ struct mu_cfg_param comsat_cfg_param[] = {
     0, NULL,
     N_("Set overflow control interval.") },
   { "overflow-delay-time", mu_c_time, &overflow_delay_time,
-    0, NULL,
+   0, NULL,
     N_("Time to sleep after the first overflow occurs.") },
   { ".server", mu_cfg_section, NULL, 0, NULL,
     N_("Server configuration.") },
   { NULL }
 };
 
-static error_t
-comsatd_parse_opt (int key, char *arg, struct argp_state *state)
-{
-  static mu_list_t lst;
-
-  switch (key)
-    {
-    case 'd':
-      mu_argp_node_list_new (lst, "mode", "daemon");
-      if (arg)
-       mu_argp_node_list_new (lst, "max-children", arg);
-      break;
-
-    case 'f':
-      biffrc = arg;
-      break;
-      
-    case 'i':
-      mu_argp_node_list_new (lst, "mode", "inetd");
-      break;
+static char const *alt_args[] = { N_("--test MBOX-URL MSG-QID"), NULL };
 
-    case OPT_FOREGROUND:
-      mu_argp_node_list_new (lst, "foreground", "yes");
-      break;
-
-    case 't':
-      test_mode = 1;
-      break;
-      
-    case ARGP_KEY_INIT:
-      mu_argp_node_list_init (&lst);
-      break;
-      
-    case ARGP_KEY_FINI:
-      mu_argp_node_list_finish (lst, NULL, NULL);
-      break;
+static struct mu_cli_setup cli = {
+  options,
+  comsat_cfg_param,
+  N_("GNU comsatd -- notify users about incoming mail"),
+  "",
+  alt_args,
+};
 
-    default:
-      return ARGP_ERR_UNKNOWN;
-    }
-  return 0;
-}
+static char *capa[] = {
+  "debug",
+  "logging",
+  "mailbox",
+  "locking",
+  NULL
+};
 
 static RETSIGTYPE
 sig_hup (int sig)
@@ -558,12 +547,11 @@ int
 main (int argc, char **argv)
 {
   int c;
-  int ind;
-
+  char **save_argv;
+  
   /* Native Language Support */
   MU_APP_INIT_NLS ();
 
-  mu_argp_init (NULL, NULL);
   comsat_init ();
   mu_acl_cfg_init ();
   mu_m_server_create (&server, program_version);
@@ -578,19 +566,16 @@ main (int argc, char **argv)
   
   /* FIXME: timeout is not needed. How to disable it? */
   mu_log_syslog = 1;
+
+  save_argv = argv;
   
-  if (mu_app_init (&argp, comsat_argp_capa, comsat_cfg_param, argc, argv, 0,
-                  &ind, server))
-    exit (EXIT_FAILURE);
+  mu_cli (argc, argv, &cli, capa, NULL, &argc, &argv);
 
   if (test_mode)
     {
       struct passwd *pw;
       char *user;
       
-      argc -= ind;
-      argv += ind;
-  
       mu_stdstream_strerr_setup (MU_STRERR_STDERR);
       biffrc_errors = BIFFRC_ERRORS_TO_ERR;
       if (argc < 2 || argc > 2)
@@ -630,7 +615,7 @@ main (int argc, char **argv)
 
   if (mu_m_server_mode (server) == MODE_DAEMON)
     {
-      if (argv[0][0] != '/')
+      if (save_argv[0][0] != '/')
        mu_diag_output (MU_DIAG_NOTICE,
                        _("program name is not absolute; reloading will not "
                          "be possible"));
@@ -651,7 +636,7 @@ main (int argc, char **argv)
       if (reload)
        {
          mu_diag_output (MU_DIAG_NOTICE, _("restarting"));
-         execvp (argv[0], argv);
+         execvp (save_argv[0], save_argv);
        }
     }
   else
diff --git a/libmailutils/cli/Makefile.am b/libmailutils/cli/Makefile.am
index 48770e8..e506b91 100644
--- a/libmailutils/cli/Makefile.am
+++ b/libmailutils/cli/Makefile.am
@@ -18,6 +18,7 @@
 noinst_LTLIBRARIES = libcli.la
 
 libcli_la_SOURCES = \
+ acl.c\
  capa.c\
  cli.c\
  stdcapa.c
diff --git a/libmu_cfg/acl.c b/libmailutils/cli/acl.c
similarity index 98%
copy from libmu_cfg/acl.c
copy to libmailutils/cli/acl.c
index b4bfded..778c3f5 100644
--- a/libmu_cfg/acl.c
+++ b/libmailutils/cli/acl.c
@@ -18,10 +18,12 @@
 #ifdef HAVE_CONFIG_H
 # include <config.h>
 #endif
-#include "mailutils/libcfg.h"
 #include "mailutils/acl.h"
 #include "mailutils/argcv.h"
 #include "mailutils/cidr.h"
+#include "mailutils/cfg.h"
+#include "mailutils/errno.h"
+#include "mailutils/nls.h"
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -254,7 +256,7 @@ acl_section_parser (enum mu_cfg_section_stage stage,
 }
 
 void
-mu_acl_cfg_init ()
+mu_acl_cfg_init (void)
 {
   struct mu_cfg_section *section;
   if (mu_create_canned_section ("acl", &section) == 0)


hooks/post-receive
-- 
GNU Mailutils



reply via email to

[Prev in Thread] Current Thread [Next in Thread]