/[mailutils]/mailutils/mailbox/mu_argp.c
ViewVC logotype

Diff of /mailutils/mailbox/mu_argp.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.17 by gray, Tue Dec 24 10:19:15 2002 UTC revision 1.18 by polak, Wed Dec 25 22:30:55 2002 UTC
# Line 1  Line 1 
1  /* GNU mailutils - a suite of utilities for electronic mail  /* GNU Mailutils -- a suite of utilities for electronic mail
2     Copyright (C) 1999, 2001 Free Software Foundation, Inc.     Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc.
3    
4     This program is free software; you can redistribute it and/or modify     GNU Mailutils is free software; you can redistribute it and/or modify
5     it under the terms of the GNU Lesser General Public License as published by     it under the terms of the GNU Lesser General Public License as published by
6     the Free Software Foundation; either version 2, or (at your option)     the Free Software Foundation; either version 2, or (at your option)
7     any later version.     any later version.
8    
9     This program is distributed in the hope that it will be useful,     GNU Mailutils is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU Lesser General Public License for more details.     GNU Lesser General Public License for more details.
13    
14     You should have received a copy of the GNU Lesser General Public License     You should have received a copy of the GNU Lesser General Public License
15     along with this program; if not, write to the Free Software     along with GNU Mailutils; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
17    
18  #ifdef HAVE_CONFIG_H  #ifdef HAVE_CONFIG_H
# Line 41  Line 41 
41  #include <mailutils/locker.h>  #include <mailutils/locker.h>
42  #include <mailutils/mailer.h>  #include <mailutils/mailer.h>
43  #include <mailutils/mailbox.h>  #include <mailutils/mailbox.h>
44    #include <mailutils/nls.h>
45  #include <mailutils/argcv.h>  #include <mailutils/argcv.h>
46    
47  #define ARG_LOG_FACILITY 1  #define ARG_LOG_FACILITY 1
# Line 53  const char *argp_program_bug_address = " Line 53  const char *argp_program_bug_address = "
53    
54  static struct argp_option mu_common_argp_options[] =  static struct argp_option mu_common_argp_options[] =
55  {  {
56    { NULL, 0, NULL, 0, "Common options", 0},    { NULL, 0, NULL, 0, N_("Common options"), 0},
57    { "show-config-options", ARG_SHOW_OPTIONS, NULL, OPTION_HIDDEN,    { "show-config-options", ARG_SHOW_OPTIONS, NULL, OPTION_HIDDEN,
58      "Show compilation options", 0 },      N_("Show compilation options"), 0 },
59    { NULL, 0, NULL, 0, NULL, 0 }    { NULL, 0, NULL, 0, NULL, 0 }
60  };  };
61    
62  /* Option to print the license. */  /* Option to print the license. */
63  static struct argp_option mu_license_argp_option[] = {  static struct argp_option mu_license_argp_option[] = {
64    { "license", ARG_LICENSE, NULL, 0, "Print license and exit", -2 },    { "license", ARG_LICENSE, NULL, 0, N_("Print license and exit"), -2 },
65    { NULL,      0, NULL, 0, NULL, 0 }    { NULL,      0, NULL, 0, NULL, 0 }
66  };  };
67    
68  /* Options used by programs that access mailboxes. */  /* Options used by programs that access mailboxes. */
69  static struct argp_option mu_mailbox_argp_option[] = {  static struct argp_option mu_mailbox_argp_option[] = {
70    {"mail-spool", 'm', "URL", 0,    {"mail-spool", 'm', "URL", 0,
71     "Use specified URL as a mailspool directory", 0},     N_("Use specified URL as a mailspool directory"), 0},
72    {"lock-flags", ARG_LOCK_FLAGS, "FLAGS", 0,    {"lock-flags", ARG_LOCK_FLAGS, "FLAGS", 0,
73     "Default locker flags (E=external, R=retry, T=time, P=pid)", 0},     N_("Default locker flags (E=external, R=retry, T=time, P=pid)"), 0},
74    { NULL,      0, NULL, 0, NULL, 0 }    { NULL,      0, NULL, 0, NULL, 0 }
75  };  };
76    
77  /* Options used by programs that do address mapping. */  /* Options used by programs that do address mapping. */
78  static struct argp_option mu_address_argp_option[] = {  static struct argp_option mu_address_argp_option[] = {
79    {"email-addr", 'E', "EMAIL", 0,    {"email-addr", 'E', "EMAIL", 0,
80     "Set current user's email address (default is loginname@defaultdomain)", 0},     N_("Set current user's email address (default is loginname@defaultdomain)"), 0},
81    {"email-domain", 'D', "DOMAIN", 0,    {"email-domain", 'D', "DOMAIN", 0,
82     "Set domain for unqualified user names (default is this host)", 0},     N_("Set domain for unqualified user names (default is this host)"), 0},
83    { NULL,      0, NULL, 0, NULL, 0 }    { NULL,      0, NULL, 0, NULL, 0 }
84  };  };
85    
86  /* Options used by programs that send mail. */  /* Options used by programs that send mail. */
87  static struct argp_option mu_mailer_argp_option[] = {  static struct argp_option mu_mailer_argp_option[] = {
88    {"mailer", 'M', "MAILER", 0,    {"mailer", 'M', "MAILER", 0,
89     "Use specified URL as the default mailer", 0},     N_("Use specified URL as the default mailer"), 0},
90    { NULL,      0, NULL, 0, NULL, 0 }    { NULL,      0, NULL, 0, NULL, 0 }
91  };  };
92    
93  /* Options used by programs that log to syslog. */  /* Options used by programs that log to syslog. */
94  static struct argp_option mu_logging_argp_option[] = {  static struct argp_option mu_logging_argp_option[] = {
95    {"log-facility", ARG_LOG_FACILITY, "FACILITY", 0,    {"log-facility", ARG_LOG_FACILITY, "FACILITY", 0,
96     "Output logs to syslog FACILITY", 0},     N_("Output logs to syslog FACILITY"), 0},
97    { NULL,      0, NULL, 0, NULL, 0 }    { NULL,      0, NULL, 0, NULL, 0 }
98  };  };
99    
# Line 101  static struct argp_option mu_logging_arg Line 101  static struct argp_option mu_logging_arg
101  /* Options used by programs that become daemons. */  /* Options used by programs that become daemons. */
102  static struct argp_option mu_daemon_argp_option[] = {  static struct argp_option mu_daemon_argp_option[] = {
103    {"daemon", 'd', "NUMBER", OPTION_ARG_OPTIONAL,    {"daemon", 'd', "NUMBER", OPTION_ARG_OPTIONAL,
104     "Runs in daemon mode with a maximum of NUMBER children"},     N_("Runs in daemon mode with a maximum of NUMBER children")},
105    {"inetd",  'i', 0, 0,    {"inetd",  'i', 0, 0,
106     "Run in inetd mode", 0},     N_("Run in inetd mode"), 0},
107    {"port", 'p', "PORT", 0,    {"port", 'p', "PORT", 0,
108     "Listen on specified port number", 0},     N_("Listen on specified port number"), 0},
109    {"timeout", 't', "NUMBER", 0,    {"timeout", 't', "NUMBER", 0,
110     "Set idle timeout value to NUMBER seconds", 0},     N_("Set idle timeout value to NUMBER seconds"), 0},
111    {"transcript", 'x', NULL, 0,    {"transcript", 'x', NULL, 0,
112     "output session transcript via syslog", 0},     N_("output session transcript via syslog"), 0},
113    { NULL,      0, NULL, 0, NULL, 0 }    { NULL,      0, NULL, 0, NULL, 0 }
114  };    };  
115    
# Line 198  struct argp mu_daemon_argp = { Line 198  struct argp mu_daemon_argp = {
198  struct argp_child mu_daemon_argp_child = {  struct argp_child mu_daemon_argp_child = {
199    &mu_daemon_argp,    &mu_daemon_argp,
200    0,    0,
201    "Daemon configuration options",    N_("Daemon configuration options"),
202    0    0
203  };  };
204    
# Line 233  parse_log_facility (const char *str) Line 233  parse_log_facility (const char *str)
233    for (i = 0; i < sizeof (syslog_kw) / sizeof (syslog_kw[0]); i++)    for (i = 0; i < sizeof (syslog_kw) / sizeof (syslog_kw[0]); i++)
234      if (strcasecmp (syslog_kw[i].name, str) == 0)      if (strcasecmp (syslog_kw[i].name, str) == 0)
235        return syslog_kw[i].facility;        return syslog_kw[i].facility;
236    fprintf (stderr, "unknown facility `%s'\n", str);    fprintf (stderr, _("unknown facility `%s'\n"), str);
237    return LOG_FACILITY;    return LOG_FACILITY;
238  }  }
239    
240  char *mu_license_text =  char *mu_license_text =
241      "   This program is free software; you can redistribute it and/or modify\n"   N_("   GNU Mailutils is free software; you can redistribute it and/or modify\n"
242      "   it under the terms of the GNU General Public License as published by\n"      "   it under the terms of the GNU General Public License as published by\n"
243      "   the Free Software Foundation; either version 2, or (at your option)\n"      "   the Free Software Foundation; either version 2, or (at your option)\n"
244      "   any later version.\n"      "   any later version.\n"
245      "\n"      "\n"
246      "   This program is distributed in the hope that it will be useful,\n"      "   GNU Mailutils is distributed in the hope that it will be useful,\n"
247      "   but WITHOUT ANY WARRANTY; without even the implied warranty of\n"      "   but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
248      "   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n"      "   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n"
249      "   GNU General Public License for more details.\n"      "   GNU General Public License for more details.\n"
250      "\n"      "\n"
251      "   You should have received a copy of the GNU General Public License\n"      "   You should have received a copy of the GNU General Public License\n"
252      "   along with this program; if not, write to the Free Software\n"      "   along with GNU Mailutils; if not, write to the Free Software\n"
253      "   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\n";      "   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\n\n");
254    
255  static char *mu_conf_option[] = {  static char *mu_conf_option[] = {
256    "VERSION=" VERSION,    "VERSION=" VERSION,
# Line 353  mu_common_argp_parser (int key, char *ar Line 353  mu_common_argp_parser (int key, char *ar
353      {      {
354        /* common */        /* common */
355      case ARG_LICENSE:      case ARG_LICENSE:
356        printf ("License for %s:\n\n", argp_program_version);        printf (_("License for %s:\n\n"), argp_program_version);
357        printf ("%s", mu_license_text);        printf ("%s", mu_license_text);
358        exit (0);        exit (0);
359    
# Line 390  mu_common_argp_parser (int key, char *ar Line 390  mu_common_argp_parser (int key, char *ar
390                  break;                  break;
391                                    
392                default:                default:
393                  argp_error (state, "invalid lock flag '%c'", *arg);                  argp_error (state, _("invalid lock flag '%c'"), *arg);
394                }                }
395            }            }
396          locker_set_default_flags(flags);          locker_set_default_flags(flags);
# Line 401  mu_common_argp_parser (int key, char *ar Line 401  mu_common_argp_parser (int key, char *ar
401      case 'E':      case 'E':
402        if ((err = mu_set_user_email(arg)) != 0)        if ((err = mu_set_user_email(arg)) != 0)
403            {            {
404              argp_error (state, "invalid email-addr '%s': %s",              argp_error (state, _("invalid email-addr '%s': %s"),
405                  arg, mu_errstring(err));                  arg, mu_errstring(err));
406            }            }
407        break;        break;
# Line 409  mu_common_argp_parser (int key, char *ar Line 409  mu_common_argp_parser (int key, char *ar
409      case 'D':      case 'D':
410        if ((err = mu_set_user_email_domain(arg)) != 0)        if ((err = mu_set_user_email_domain(arg)) != 0)
411            {            {
412              argp_error (state, "invalid email-domain '%s': %s",              argp_error (state, _("invalid email-domain '%s': %s"),
413                  arg, mu_errstring(err));                  arg, mu_errstring(err));
414            }            }
415        break;        break;
# Line 418  mu_common_argp_parser (int key, char *ar Line 418  mu_common_argp_parser (int key, char *ar
418      case 'M':      case 'M':
419        if ((err = mailer_set_url_default (arg)) != 0)        if ((err = mailer_set_url_default (arg)) != 0)
420            {            {
421              argp_error (state, "invalid mailer url '%s': %s",              argp_error (state, _("invalid mailer url '%s': %s"),
422                          arg, mu_errstring(err));                          arg, mu_errstring(err));
423            }            }
424        break;        break;
# Line 432  mu_common_argp_parser (int key, char *ar Line 432  mu_common_argp_parser (int key, char *ar
432        p = mu_normalize_maildir (mu_path_maildir);        p = mu_normalize_maildir (mu_path_maildir);
433        if (!p)        if (!p)
434          {          {
435            argp_error (state, "badly formed maildir: %s", mu_path_maildir);            argp_error (state, _("badly formed maildir: %s"), mu_path_maildir);
436          }          }
437        mu_path_maildir = p;        mu_path_maildir = p;
438        break;        break;
# Line 522  read_rc (const char *progname, const cha Line 522  read_rc (const char *progname, const cha
522    
523    if (!rcfile)    if (!rcfile)
524      {      {
525        fprintf (stderr, "%s: not enough memory\n", progname);        fprintf (stderr, _("%s: not enough memory\n"), progname);
526        exit (1);        exit (1);
527      }      }
528    
# Line 567  read_rc (const char *progname, const cha Line 567  read_rc (const char *progname, const cha
567                        
568            if (!linebuf)            if (!linebuf)
569              {              {
570                fprintf (stderr, "%s: not enough memory\n", progname);                fprintf (stderr, _("%s: not enough memory\n"), progname);
571                exit (1);                exit (1);
572              }              }
573                        
# Line 606  read_rc (const char *progname, const cha Line 606  read_rc (const char *progname, const cha
606                              (x_argc + n_argc) * sizeof (x_argv[0]));                              (x_argc + n_argc) * sizeof (x_argv[0]));
607            if (!x_argv)            if (!x_argv)
608              {              {
609                fprintf (stderr, "%s: not enough memory\n", progname);                fprintf (stderr, _("%s: not enough memory\n"), progname);
610                exit (1);                exit (1);
611              }              }
612                        
# Line 646  mu_create_argcv (const char *capa[], Line 646  mu_create_argcv (const char *capa[],
646    x_argv = malloc (sizeof (x_argv[0]));    x_argv = malloc (sizeof (x_argv[0]));
647    if (!x_argv)    if (!x_argv)
648      {      {
649        fprintf (stderr, "%s: not enough memory\n", progname);        fprintf (stderr, _("%s: not enough memory\n"), progname);
650        exit (1);        exit (1);
651      }      }
652    
# Line 668  mu_create_argcv (const char *capa[], Line 668  mu_create_argcv (const char *capa[],
668    
669      if (!rcdirname)      if (!rcdirname)
670        {        {
671          fprintf (stderr, "%s: not enough memory\n", progname);          fprintf (stderr, _("%s: not enough memory\n"), progname);
672          exit (1);          exit (1);
673        }        }
674      if(stat(rcdirname, &s) == 0 && S_ISDIR(s.st_mode))      if(stat(rcdirname, &s) == 0 && S_ISDIR(s.st_mode))
# Line 693  mu_create_argcv (const char *capa[], Line 693  mu_create_argcv (const char *capa[],
693    
694        if (!userrc)        if (!userrc)
695          {          {
696            fprintf (stderr, "%s: not enough memory\n", progname);            fprintf (stderr, _("%s: not enough memory\n"), progname);
697            exit (1);            exit (1);
698          }          }
699                
# Line 722  mu_create_argcv (const char *capa[], Line 722  mu_create_argcv (const char *capa[],
722    
723      if (!progrc)      if (!progrc)
724        {        {
725          fprintf (stderr, "%s: not enough memory\n", progname);          fprintf (stderr, _("%s: not enough memory\n"), progname);
726          exit (1);          exit (1);
727        }        }
728    
# Line 808  mu_build_argp (const struct argp *templa Line 808  mu_build_argp (const struct argp *templa
808    ap = calloc (n + 1, sizeof (*ap));    ap = calloc (n + 1, sizeof (*ap));
809    if (!ap)    if (!ap)
810      {      {
811        mu_error ("out of memory");        mu_error (_("out of memory"));
812        abort ();        abort ();
813      }      }
814    
# Line 832  mu_build_argp (const struct argp *templa Line 832  mu_build_argp (const struct argp *templa
832        struct argp_child *child = find_argp_child (capa[n]);        struct argp_child *child = find_argp_child (capa[n]);
833        if (!child)        if (!child)
834          {          {
835            mu_error ("INTERNAL ERROR: requested unknown argp capability %s",            mu_error (_("INTERNAL ERROR: requested unknown argp capability %s"),
836                      capa[n]);                      capa[n]);
837            abort ();            abort ();
838          }          }
# Line 846  mu_build_argp (const struct argp *templa Line 846  mu_build_argp (const struct argp *templa
846    argp = malloc (sizeof (*argp));    argp = malloc (sizeof (*argp));
847    if (!argp)    if (!argp)
848      {      {
849        mu_error ("out of memory");        mu_error (_("out of memory"));
850        abort ();        abort ();
851      }      }
852    
# Line 885  mu_auth_init () Line 885  mu_auth_init ()
885    extern struct argp_child mu_auth_argp_child;    extern struct argp_child mu_auth_argp_child;
886    if (mu_register_capa ("auth", &mu_auth_argp_child))    if (mu_register_capa ("auth", &mu_auth_argp_child))
887      {      {
888        mu_error ("INTERNAL ERROR: cannot register argp capability auth");        mu_error (_("INTERNAL ERROR: cannot register argp capability auth"));
889        abort ();        abort ();
890      }      }
891  }  }

Legend:
Removed from v.1.17  
changed lines
  Added in v.1.18

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26