Commit c8abc2b1 c8abc2b1adfcddccf0e85caf44f3376aad11552c by Sergey Poznyakoff

For alpha version, include git tag info in the version output.

* include/mailutils/libargp.h (mu_program_version_hook): New proto.
* libmu_argp/Makefile.am (libmu_argp_a_SOURCES): Remove mu_argp.h.
* libmu_argp/mu_argp.h: Remove.
* libmu_argp/muinit.c [MU_ALPHA_RELEASE]: Include git-describe.h
(mu_program_version_hook): New function.
(mu_argp_init): Set mu_program_version_hook, unless vers is given.

* comsat/comsat.c (main): Call mu_argp_init with NULL arguments.
* config/mailutils-config.c: Likewise.
* dotlock/dotlock.c: Likewise.
* examples/muauth.c: Likewise.
* frm/frm.c: Likewise.
* frm/from.c: Likewise.
* guimb/main.c: Likewise.
* imap4d/imap4d.c: Likewise.
* maidag/maidag.c: Likewise.
* mail/mail.c: Likewise.
* messages/messages.c: Likewise.
* mimeview/mimeview.c: Likewise.
* movemail/movemail.c: Likewise.
* pop3d/pop3d.c: Likewise.
* pop3d/popauth.c: Likewise.
* readmsg/readmsg.c: Likewise.
* sieve/sieve.c: Likewise.
1 parent fa54cb19
......@@ -570,7 +570,7 @@ main (int argc, char **argv)
/* Native Language Support */
MU_APP_INIT_NLS ();
mu_argp_init (program_version, NULL);
mu_argp_init (NULL, NULL);
comsat_init ();
mu_acl_cfg_init ();
mu_m_server_cfg_init ();
......
......@@ -25,7 +25,6 @@
#include <mu_asprintf.h>
#include "mailutils/libargp.h"
const char *program_version = "mailutils-config (" PACKAGE_STRING ")";
static char doc[] = N_("GNU mailutils-config -- display compiler and loader options needed for building a program with mailutils.");
static char args_doc[] = N_("[arg...]");
......@@ -188,7 +187,7 @@ main (int argc, char **argv)
mu_stream_t stream;
int fmtflags = 0;
mu_argp_init (program_version, NULL);
mu_argp_init (NULL, NULL);
mu_set_program_name (argv[0]);
mu_libargp_init ();
......
......@@ -33,7 +33,6 @@
#include "mailutils/libargp.h"
const char *program_version = "GNU dotlock (" PACKAGE_STRING ")";
static char doc[] =
N_("GNU dotlock -- lock mail spool files.")
"\v"
......@@ -161,7 +160,7 @@ main (int argc, char *argv[])
argp_err_exit_status = MU_DL_EX_ERROR;
mu_argp_init (program_version, NULL);
mu_argp_init (NULL, NULL);
if (mu_app_init (&argp, dotlock_capa, dotlock_cfg_param,
argc, argv, 0, NULL, NULL))
exit (1);
......
......@@ -27,7 +27,6 @@
#include <mailutils/mailutils.h>
#include "mailutils/libargp.h"
const char *program_version = "muauth (" PACKAGE_STRING ")";
static char doc[] =
"muauth -- test mailutils authentication and authorization schemes";
static char args_doc[] = "key";
......@@ -91,7 +90,7 @@ main (int argc, char * argv [])
uid_t uid;
MU_AUTH_REGISTER_ALL_MODULES ();
mu_argp_init (program_version, NULL);
mu_argp_init (NULL, NULL);
if (mu_app_init (&argp, capa, NULL, argc, argv, 0, &index, NULL))
exit (1);
......
......@@ -31,7 +31,6 @@ static int align = 0; /* Tidy mode. -t option. */
#define IS_NEW 0x100
static int select_attribute;
const char *program_version = "frm (" PACKAGE_STRING ")";
static char doc[] = N_("GNU frm -- display From: lines.");
static struct attr_tab {
......@@ -358,7 +357,7 @@ main (int argc, char **argv)
mu_gocs_register ("tls", mu_tls_module_init);
#endif
mu_argp_init (program_version, NULL);
mu_argp_init (NULL, NULL);
if (mu_app_init (&argp, frm_argp_capa, NULL, argc, argv, 0, &c, NULL))
exit (1);
......
......@@ -23,7 +23,6 @@ int count_only;
char *sender_option;
char *mailbox_name;
const char *program_version = "from (" PACKAGE_STRING ")";
static char doc[] = N_("GNU from -- display from and subject.");
static struct argp_option options[] = {
......@@ -120,7 +119,7 @@ main (int argc, char **argv)
mu_gocs_register ("tls", mu_tls_module_init);
#endif
mu_argp_init (program_version, NULL);
mu_argp_init (NULL, NULL);
if (mu_app_init (&argp, capa, NULL, argc, argv, 0, &c, NULL))
exit (1);
......
......@@ -122,7 +122,6 @@ parse_opt (int key, char *arg, struct argp_state *state)
return 0;
}
const char *program_version = "guimb (" PACKAGE_STRING ")";
static char doc[] =
N_("GNU guimb -- process contents of the specified mailboxes "
"using a Scheme program or expression.");
......@@ -161,7 +160,7 @@ main (int argc, char *argv[])
/* Register the desired formats. */
mu_register_all_formats ();
mu_argp_init (program_version, NULL);
mu_argp_init (NULL, NULL);
if (mu_app_init (&argp, guimb_argp_capa, NULL, argc, argv, 0, &index, &c))
exit (1);
......
......@@ -507,7 +507,7 @@ main (int argc, char **argv)
mu_acl_cfg_init ();
mu_m_server_cfg_init ();
mu_argp_init (program_version, NULL);
mu_argp_init (NULL, NULL);
mu_m_server_create (&server, program_version);
mu_m_server_set_conn (server, imap4d_connection);
......
......@@ -75,6 +75,7 @@ void mu_argp_init (const char *vers, const char *bugaddr);
int mu_app_init (struct argp *myargp, const char **capa,
struct mu_cfg_param *cfg_param,
int argc, char **argv, int flags, int *pindex, void *data);
extern void mu_program_version_hook (FILE *stream, struct argp_state *state);
error_t mu_argp_parse (const struct argp *myargp,
int *pargc, char **pargv[],
......
......@@ -32,7 +32,6 @@ libmu_argp_a_SOURCES =\
cmdline.h\
common.c\
compat.c\
mu_argp.h\
mu_argp.c\
muinit.c\
sieve.c\
......
......@@ -25,13 +25,48 @@
#include <mailutils/stream.h>
#include "xalloc.h"
#include <string.h>
#ifdef MU_ALPHA_RELEASE
# include <git-describe.h>
#endif
struct mu_cfg_tree *mu_argp_tree;
const char version_etc_copyright[] =
/* Do *not* mark this string for translation. %s is a copyright
symbol suitable for this locale, and %d is the copyright
year. */
"Copyright %s 2010 Free Software Foundation, inc.";
void
mu_program_version_hook (FILE *stream, struct argp_state *state)
{
#ifdef GIT_DESCRIBE
fprintf (stream, "%s (%s) %s [%s]\n",
mu_program_name, PACKAGE_NAME, PACKAGE_VERSION, GIT_DESCRIBE);
#else
fprintf (stream, "%s (%s) %s\n", mu_program_name,
PACKAGE_NAME, PACKAGE_VERSION);
#endif
/* TRANSLATORS: Translate "(C)" to the copyright symbol
(C-in-a-circle), if this symbol is available in the user's
locale. Otherwise, do not translate "(C)"; leave it as-is. */
fprintf (stream, version_etc_copyright, _("(C)"));
fputs (_("\
\n\
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\nThis is free software: you are free to change and redistribute it.\n\
There is NO WARRANTY, to the extent permitted by law.\n\
\n\
"),
stream);
}
void
mu_argp_init (const char *vers, const char *bugaddr)
{
argp_program_version = vers ? vers : PACKAGE_STRING;
if (vers)
argp_program_version = vers;
else
argp_program_version_hook = mu_program_version_hook;
argp_program_bug_address = bugaddr ? bugaddr : "<" PACKAGE_BUGREPORT ">";
}
......
......@@ -518,7 +518,7 @@ main (int argc, char *argv[])
maidag_cfg_init ();
/* Parse command line */
mu_argp_init (program_version, NULL);
mu_argp_init (NULL, NULL);
mu_m_server_create (&server, program_version);
mu_m_server_set_conn (server, lmtp_connection);
......
......@@ -394,7 +394,7 @@ main (int argc, char **argv)
#ifdef WITH_TLS
mu_gocs_register ("tls", mu_tls_module_init);
#endif
mu_argp_init (program_version, NULL);
mu_argp_init (NULL, NULL);
if (mu_app_init (&argp, mail_capa, NULL, argc, argv, 0, NULL, &args))
exit (1);
......
......@@ -31,7 +31,6 @@
static int messages_count (const char *);
const char *program_version = "messages (" PACKAGE_STRING ")";
static char doc[] = N_("GNU messages -- count the number of messages in a mailbox");
static char args_doc[] = N_("[mailbox...]");
......@@ -112,7 +111,7 @@ main (int argc, char **argv)
#ifdef WITH_TLS
mu_gocs_register ("tls", mu_tls_module_init);
#endif
mu_argp_init (program_version, NULL);
mu_argp_init (NULL, NULL);
if (mu_app_init (&argp, argp_capa, NULL, argc, argv, 0, NULL, &args))
exit (1);
......
......@@ -33,7 +33,6 @@
#include "mailcap.h"
const char *program_version = "mimeview (" PACKAGE_STRING ")";
static char doc[] = N_("GNU mimeview -- display files, using mailcap mechanism.")
"\v"
N_("Default mime.types file is ") DEFAULT_CUPS_CONFDIR "/mime.types"
......@@ -281,7 +280,7 @@ main (int argc, char **argv)
int index;
MU_APP_INIT_NLS ();
mu_argp_init (program_version, NULL);
mu_argp_init (NULL, NULL);
if (mu_app_init (&argp, capa, mimeview_cfg_param,
argc, argv, 0, &index, NULL))
exit (1);
......
......@@ -33,7 +33,6 @@
#include "mailutils/libargp.h"
#include <muaux.h>
const char *program_version = "movemail (" PACKAGE_STRING ")";
static char doc[] = N_("GNU movemail -- move messages across mailboxes.");
static char args_doc[] = N_("inbox-url destfile [POP-password]");
......@@ -744,7 +743,7 @@ main (int argc, char **argv)
#ifdef WITH_TLS
mu_gocs_register ("tls", mu_tls_module_init);
#endif
mu_argp_init (program_version, NULL);
mu_argp_init (NULL, NULL);
if (mu_app_init (&argp, movemail_capa, movemail_cfg_param,
argc, argv, 0, &index, NULL))
exit (1);
......
......@@ -338,7 +338,7 @@ main (int argc, char **argv)
mu_acl_cfg_init ();
mu_m_server_cfg_init ();
mu_argp_init (program_version, NULL);
mu_argp_init (NULL, NULL);
mu_m_server_create (&server, program_version);
mu_m_server_set_conn (server, pop3d_connection);
......
......@@ -56,14 +56,11 @@ int (*ftab[]) (struct action_data *) = {
action_chpass
};
const char *program_version = "popauth (" PACKAGE_STRING ")";
static char doc[] = N_("GNU popauth -- manage pop3 authentication database");
static error_t popauth_parse_opt (int key, char *arg,
struct argp_state *astate);
void popauth_version (FILE *stream, struct argp_state *state);
void (*argp_program_version_hook) (FILE *stream, struct argp_state *state) =
popauth_version;
static struct argp_option options[] =
{
......@@ -202,7 +199,8 @@ main(int argc, char **argv)
/* Native Language Support */
MU_APP_INIT_NLS ();
mu_argp_init (program_version, NULL);
mu_argp_init (NULL, NULL);
argp_program_version_hook = popauth_version;
if (mu_app_init (&argp, popauth_argp_capa, NULL,
argc, argv, 0, NULL, &adata))
exit (EX_USAGE);
......@@ -600,7 +598,7 @@ popauth_version (FILE *stream, struct argp_state *state)
#elif defined(WITH_TOKYOCABINET)
# define FORMAT "Tokyo Cabinet"
#endif
printf ("%s\n", argp_program_version);
mu_program_version_hook (stream, state);
printf (_("Database format: %s\n"), FORMAT);
printf (_("Database location: %s\n"), APOP_PASSFILE);
exit (EX_OK);
......
......@@ -33,7 +33,6 @@ static void print_header (mu_message_t, int, int, char **);
static void print_body (mu_message_t);
static int string_starts_with (const char * s1, const char *s2);
const char *program_version = "readmsg (" PACKAGE_STRING ")";
static char doc[] = N_("GNU readmsg -- print messages.");
static error_t readmsg_parse_opt (int key, char *arg, struct argp_state *astate);
......@@ -301,7 +300,7 @@ main (int argc, char **argv)
#ifdef WITH_TLS
mu_gocs_register ("tls", mu_tls_module_init);
#endif
mu_argp_init (program_version, NULL);
mu_argp_init (NULL, NULL);
if (mu_app_init (&argp, readmsg_argp_capa, readmsg_cfg_param,
argc, argv, 0, &index, NULL))
exit (1);
......
......@@ -48,8 +48,6 @@
#include "mailutils/libargp.h"
const char *program_version = "sieve (" PACKAGE_STRING ")";
static char doc[] =
N_("GNU sieve -- a mail filtering tool.")
"\v"
......@@ -480,7 +478,7 @@ main (int argc, char *argv[])
/* Native Language Support */
MU_APP_INIT_NLS ();
mu_argp_init (program_version, NULL);
mu_argp_init (NULL, NULL);
#ifdef WITH_TLS
mu_gocs_register ("tls", mu_tls_module_init);
#endif
......