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) ...@@ -570,7 +570,7 @@ main (int argc, char **argv)
570 /* Native Language Support */ 570 /* Native Language Support */
571 MU_APP_INIT_NLS (); 571 MU_APP_INIT_NLS ();
572 572
573 mu_argp_init (program_version, NULL); 573 mu_argp_init (NULL, NULL);
574 comsat_init (); 574 comsat_init ();
575 mu_acl_cfg_init (); 575 mu_acl_cfg_init ();
576 mu_m_server_cfg_init (); 576 mu_m_server_cfg_init ();
......
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
25 #include <mu_asprintf.h> 25 #include <mu_asprintf.h>
26 #include "mailutils/libargp.h" 26 #include "mailutils/libargp.h"
27 27
28 const char *program_version = "mailutils-config (" PACKAGE_STRING ")";
29 static char doc[] = N_("GNU mailutils-config -- display compiler and loader options needed for building a program with mailutils."); 28 static char doc[] = N_("GNU mailutils-config -- display compiler and loader options needed for building a program with mailutils.");
30 static char args_doc[] = N_("[arg...]"); 29 static char args_doc[] = N_("[arg...]");
31 30
...@@ -188,7 +187,7 @@ main (int argc, char **argv) ...@@ -188,7 +187,7 @@ main (int argc, char **argv)
188 mu_stream_t stream; 187 mu_stream_t stream;
189 int fmtflags = 0; 188 int fmtflags = 0;
190 189
191 mu_argp_init (program_version, NULL); 190 mu_argp_init (NULL, NULL);
192 191
193 mu_set_program_name (argv[0]); 192 mu_set_program_name (argv[0]);
194 mu_libargp_init (); 193 mu_libargp_init ();
......
...@@ -33,7 +33,6 @@ ...@@ -33,7 +33,6 @@
33 33
34 #include "mailutils/libargp.h" 34 #include "mailutils/libargp.h"
35 35
36 const char *program_version = "GNU dotlock (" PACKAGE_STRING ")";
37 static char doc[] = 36 static char doc[] =
38 N_("GNU dotlock -- lock mail spool files.") 37 N_("GNU dotlock -- lock mail spool files.")
39 "\v" 38 "\v"
...@@ -161,7 +160,7 @@ main (int argc, char *argv[]) ...@@ -161,7 +160,7 @@ main (int argc, char *argv[])
161 160
162 argp_err_exit_status = MU_DL_EX_ERROR; 161 argp_err_exit_status = MU_DL_EX_ERROR;
163 162
164 mu_argp_init (program_version, NULL); 163 mu_argp_init (NULL, NULL);
165 if (mu_app_init (&argp, dotlock_capa, dotlock_cfg_param, 164 if (mu_app_init (&argp, dotlock_capa, dotlock_cfg_param,
166 argc, argv, 0, NULL, NULL)) 165 argc, argv, 0, NULL, NULL))
167 exit (1); 166 exit (1);
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
27 #include <mailutils/mailutils.h> 27 #include <mailutils/mailutils.h>
28 #include "mailutils/libargp.h" 28 #include "mailutils/libargp.h"
29 29
30 const char *program_version = "muauth (" PACKAGE_STRING ")";
31 static char doc[] = 30 static char doc[] =
32 "muauth -- test mailutils authentication and authorization schemes"; 31 "muauth -- test mailutils authentication and authorization schemes";
33 static char args_doc[] = "key"; 32 static char args_doc[] = "key";
...@@ -91,7 +90,7 @@ main (int argc, char * argv []) ...@@ -91,7 +90,7 @@ main (int argc, char * argv [])
91 uid_t uid; 90 uid_t uid;
92 91
93 MU_AUTH_REGISTER_ALL_MODULES (); 92 MU_AUTH_REGISTER_ALL_MODULES ();
94 mu_argp_init (program_version, NULL); 93 mu_argp_init (NULL, NULL);
95 if (mu_app_init (&argp, capa, NULL, argc, argv, 0, &index, NULL)) 94 if (mu_app_init (&argp, capa, NULL, argc, argv, 0, &index, NULL))
96 exit (1); 95 exit (1);
97 96
......
...@@ -31,7 +31,6 @@ static int align = 0; /* Tidy mode. -t option. */ ...@@ -31,7 +31,6 @@ static int align = 0; /* Tidy mode. -t option. */
31 #define IS_NEW 0x100 31 #define IS_NEW 0x100
32 static int select_attribute; 32 static int select_attribute;
33 33
34 const char *program_version = "frm (" PACKAGE_STRING ")";
35 static char doc[] = N_("GNU frm -- display From: lines."); 34 static char doc[] = N_("GNU frm -- display From: lines.");
36 35
37 static struct attr_tab { 36 static struct attr_tab {
...@@ -358,7 +357,7 @@ main (int argc, char **argv) ...@@ -358,7 +357,7 @@ main (int argc, char **argv)
358 mu_gocs_register ("tls", mu_tls_module_init); 357 mu_gocs_register ("tls", mu_tls_module_init);
359 #endif 358 #endif
360 359
361 mu_argp_init (program_version, NULL); 360 mu_argp_init (NULL, NULL);
362 if (mu_app_init (&argp, frm_argp_capa, NULL, argc, argv, 0, &c, NULL)) 361 if (mu_app_init (&argp, frm_argp_capa, NULL, argc, argv, 0, &c, NULL))
363 exit (1); 362 exit (1);
364 363
......
...@@ -23,7 +23,6 @@ int count_only; ...@@ -23,7 +23,6 @@ int count_only;
23 char *sender_option; 23 char *sender_option;
24 char *mailbox_name; 24 char *mailbox_name;
25 25
26 const char *program_version = "from (" PACKAGE_STRING ")";
27 static char doc[] = N_("GNU from -- display from and subject."); 26 static char doc[] = N_("GNU from -- display from and subject.");
28 27
29 static struct argp_option options[] = { 28 static struct argp_option options[] = {
...@@ -120,7 +119,7 @@ main (int argc, char **argv) ...@@ -120,7 +119,7 @@ main (int argc, char **argv)
120 mu_gocs_register ("tls", mu_tls_module_init); 119 mu_gocs_register ("tls", mu_tls_module_init);
121 #endif 120 #endif
122 121
123 mu_argp_init (program_version, NULL); 122 mu_argp_init (NULL, NULL);
124 if (mu_app_init (&argp, capa, NULL, argc, argv, 0, &c, NULL)) 123 if (mu_app_init (&argp, capa, NULL, argc, argv, 0, &c, NULL))
125 exit (1); 124 exit (1);
126 125
......
...@@ -122,7 +122,6 @@ parse_opt (int key, char *arg, struct argp_state *state) ...@@ -122,7 +122,6 @@ parse_opt (int key, char *arg, struct argp_state *state)
122 return 0; 122 return 0;
123 } 123 }
124 124
125 const char *program_version = "guimb (" PACKAGE_STRING ")";
126 static char doc[] = 125 static char doc[] =
127 N_("GNU guimb -- process contents of the specified mailboxes " 126 N_("GNU guimb -- process contents of the specified mailboxes "
128 "using a Scheme program or expression."); 127 "using a Scheme program or expression.");
...@@ -161,7 +160,7 @@ main (int argc, char *argv[]) ...@@ -161,7 +160,7 @@ main (int argc, char *argv[])
161 /* Register the desired formats. */ 160 /* Register the desired formats. */
162 mu_register_all_formats (); 161 mu_register_all_formats ();
163 162
164 mu_argp_init (program_version, NULL); 163 mu_argp_init (NULL, NULL);
165 if (mu_app_init (&argp, guimb_argp_capa, NULL, argc, argv, 0, &index, &c)) 164 if (mu_app_init (&argp, guimb_argp_capa, NULL, argc, argv, 0, &index, &c))
166 exit (1); 165 exit (1);
167 166
......
...@@ -507,7 +507,7 @@ main (int argc, char **argv) ...@@ -507,7 +507,7 @@ main (int argc, char **argv)
507 mu_acl_cfg_init (); 507 mu_acl_cfg_init ();
508 mu_m_server_cfg_init (); 508 mu_m_server_cfg_init ();
509 509
510 mu_argp_init (program_version, NULL); 510 mu_argp_init (NULL, NULL);
511 511
512 mu_m_server_create (&server, program_version); 512 mu_m_server_create (&server, program_version);
513 mu_m_server_set_conn (server, imap4d_connection); 513 mu_m_server_set_conn (server, imap4d_connection);
......
...@@ -75,6 +75,7 @@ void mu_argp_init (const char *vers, const char *bugaddr); ...@@ -75,6 +75,7 @@ void mu_argp_init (const char *vers, const char *bugaddr);
75 int mu_app_init (struct argp *myargp, const char **capa, 75 int mu_app_init (struct argp *myargp, const char **capa,
76 struct mu_cfg_param *cfg_param, 76 struct mu_cfg_param *cfg_param,
77 int argc, char **argv, int flags, int *pindex, void *data); 77 int argc, char **argv, int flags, int *pindex, void *data);
78 extern void mu_program_version_hook (FILE *stream, struct argp_state *state);
78 79
79 error_t mu_argp_parse (const struct argp *myargp, 80 error_t mu_argp_parse (const struct argp *myargp,
80 int *pargc, char **pargv[], 81 int *pargc, char **pargv[],
......
...@@ -32,7 +32,6 @@ libmu_argp_a_SOURCES =\ ...@@ -32,7 +32,6 @@ libmu_argp_a_SOURCES =\
32 cmdline.h\ 32 cmdline.h\
33 common.c\ 33 common.c\
34 compat.c\ 34 compat.c\
35 mu_argp.h\
36 mu_argp.c\ 35 mu_argp.c\
37 muinit.c\ 36 muinit.c\
38 sieve.c\ 37 sieve.c\
......
...@@ -25,13 +25,48 @@ ...@@ -25,13 +25,48 @@
25 #include <mailutils/stream.h> 25 #include <mailutils/stream.h>
26 #include "xalloc.h" 26 #include "xalloc.h"
27 #include <string.h> 27 #include <string.h>
28 28 #ifdef MU_ALPHA_RELEASE
29 # include <git-describe.h>
30 #endif
29 struct mu_cfg_tree *mu_argp_tree; 31 struct mu_cfg_tree *mu_argp_tree;
30 32
33 const char version_etc_copyright[] =
34 /* Do *not* mark this string for translation. %s is a copyright
35 symbol suitable for this locale, and %d is the copyright
36 year. */
37 "Copyright %s 2010 Free Software Foundation, inc.";
38
39 void
40 mu_program_version_hook (FILE *stream, struct argp_state *state)
41 {
42 #ifdef GIT_DESCRIBE
43 fprintf (stream, "%s (%s) %s [%s]\n",
44 mu_program_name, PACKAGE_NAME, PACKAGE_VERSION, GIT_DESCRIBE);
45 #else
46 fprintf (stream, "%s (%s) %s\n", mu_program_name,
47 PACKAGE_NAME, PACKAGE_VERSION);
48 #endif
49 /* TRANSLATORS: Translate "(C)" to the copyright symbol
50 (C-in-a-circle), if this symbol is available in the user's
51 locale. Otherwise, do not translate "(C)"; leave it as-is. */
52 fprintf (stream, version_etc_copyright, _("(C)"));
53
54 fputs (_("\
55 \n\
56 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\
57 There is NO WARRANTY, to the extent permitted by law.\n\
58 \n\
59 "),
60 stream);
61 }
62
31 void 63 void
32 mu_argp_init (const char *vers, const char *bugaddr) 64 mu_argp_init (const char *vers, const char *bugaddr)
33 { 65 {
34 argp_program_version = vers ? vers : PACKAGE_STRING; 66 if (vers)
67 argp_program_version = vers;
68 else
69 argp_program_version_hook = mu_program_version_hook;
35 argp_program_bug_address = bugaddr ? bugaddr : "<" PACKAGE_BUGREPORT ">"; 70 argp_program_bug_address = bugaddr ? bugaddr : "<" PACKAGE_BUGREPORT ">";
36 } 71 }
37 72
......
...@@ -518,7 +518,7 @@ main (int argc, char *argv[]) ...@@ -518,7 +518,7 @@ main (int argc, char *argv[])
518 maidag_cfg_init (); 518 maidag_cfg_init ();
519 519
520 /* Parse command line */ 520 /* Parse command line */
521 mu_argp_init (program_version, NULL); 521 mu_argp_init (NULL, NULL);
522 522
523 mu_m_server_create (&server, program_version); 523 mu_m_server_create (&server, program_version);
524 mu_m_server_set_conn (server, lmtp_connection); 524 mu_m_server_set_conn (server, lmtp_connection);
......
...@@ -394,7 +394,7 @@ main (int argc, char **argv) ...@@ -394,7 +394,7 @@ main (int argc, char **argv)
394 #ifdef WITH_TLS 394 #ifdef WITH_TLS
395 mu_gocs_register ("tls", mu_tls_module_init); 395 mu_gocs_register ("tls", mu_tls_module_init);
396 #endif 396 #endif
397 mu_argp_init (program_version, NULL); 397 mu_argp_init (NULL, NULL);
398 if (mu_app_init (&argp, mail_capa, NULL, argc, argv, 0, NULL, &args)) 398 if (mu_app_init (&argp, mail_capa, NULL, argc, argv, 0, NULL, &args))
399 exit (1); 399 exit (1);
400 400
......
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
31 31
32 static int messages_count (const char *); 32 static int messages_count (const char *);
33 33
34 const char *program_version = "messages (" PACKAGE_STRING ")";
35 static char doc[] = N_("GNU messages -- count the number of messages in a mailbox"); 34 static char doc[] = N_("GNU messages -- count the number of messages in a mailbox");
36 static char args_doc[] = N_("[mailbox...]"); 35 static char args_doc[] = N_("[mailbox...]");
37 36
...@@ -112,7 +111,7 @@ main (int argc, char **argv) ...@@ -112,7 +111,7 @@ main (int argc, char **argv)
112 #ifdef WITH_TLS 111 #ifdef WITH_TLS
113 mu_gocs_register ("tls", mu_tls_module_init); 112 mu_gocs_register ("tls", mu_tls_module_init);
114 #endif 113 #endif
115 mu_argp_init (program_version, NULL); 114 mu_argp_init (NULL, NULL);
116 if (mu_app_init (&argp, argp_capa, NULL, argc, argv, 0, NULL, &args)) 115 if (mu_app_init (&argp, argp_capa, NULL, argc, argv, 0, NULL, &args))
117 exit (1); 116 exit (1);
118 117
......
...@@ -33,7 +33,6 @@ ...@@ -33,7 +33,6 @@
33 33
34 #include "mailcap.h" 34 #include "mailcap.h"
35 35
36 const char *program_version = "mimeview (" PACKAGE_STRING ")";
37 static char doc[] = N_("GNU mimeview -- display files, using mailcap mechanism.") 36 static char doc[] = N_("GNU mimeview -- display files, using mailcap mechanism.")
38 "\v" 37 "\v"
39 N_("Default mime.types file is ") DEFAULT_CUPS_CONFDIR "/mime.types" 38 N_("Default mime.types file is ") DEFAULT_CUPS_CONFDIR "/mime.types"
...@@ -281,7 +280,7 @@ main (int argc, char **argv) ...@@ -281,7 +280,7 @@ main (int argc, char **argv)
281 int index; 280 int index;
282 281
283 MU_APP_INIT_NLS (); 282 MU_APP_INIT_NLS ();
284 mu_argp_init (program_version, NULL); 283 mu_argp_init (NULL, NULL);
285 if (mu_app_init (&argp, capa, mimeview_cfg_param, 284 if (mu_app_init (&argp, capa, mimeview_cfg_param,
286 argc, argv, 0, &index, NULL)) 285 argc, argv, 0, &index, NULL))
287 exit (1); 286 exit (1);
......
...@@ -33,7 +33,6 @@ ...@@ -33,7 +33,6 @@
33 #include "mailutils/libargp.h" 33 #include "mailutils/libargp.h"
34 #include <muaux.h> 34 #include <muaux.h>
35 35
36 const char *program_version = "movemail (" PACKAGE_STRING ")";
37 static char doc[] = N_("GNU movemail -- move messages across mailboxes."); 36 static char doc[] = N_("GNU movemail -- move messages across mailboxes.");
38 static char args_doc[] = N_("inbox-url destfile [POP-password]"); 37 static char args_doc[] = N_("inbox-url destfile [POP-password]");
39 38
...@@ -744,7 +743,7 @@ main (int argc, char **argv) ...@@ -744,7 +743,7 @@ main (int argc, char **argv)
744 #ifdef WITH_TLS 743 #ifdef WITH_TLS
745 mu_gocs_register ("tls", mu_tls_module_init); 744 mu_gocs_register ("tls", mu_tls_module_init);
746 #endif 745 #endif
747 mu_argp_init (program_version, NULL); 746 mu_argp_init (NULL, NULL);
748 if (mu_app_init (&argp, movemail_capa, movemail_cfg_param, 747 if (mu_app_init (&argp, movemail_capa, movemail_cfg_param,
749 argc, argv, 0, &index, NULL)) 748 argc, argv, 0, &index, NULL))
750 exit (1); 749 exit (1);
......
...@@ -338,7 +338,7 @@ main (int argc, char **argv) ...@@ -338,7 +338,7 @@ main (int argc, char **argv)
338 mu_acl_cfg_init (); 338 mu_acl_cfg_init ();
339 mu_m_server_cfg_init (); 339 mu_m_server_cfg_init ();
340 340
341 mu_argp_init (program_version, NULL); 341 mu_argp_init (NULL, NULL);
342 342
343 mu_m_server_create (&server, program_version); 343 mu_m_server_create (&server, program_version);
344 mu_m_server_set_conn (server, pop3d_connection); 344 mu_m_server_set_conn (server, pop3d_connection);
......
...@@ -56,14 +56,11 @@ int (*ftab[]) (struct action_data *) = { ...@@ -56,14 +56,11 @@ int (*ftab[]) (struct action_data *) = {
56 action_chpass 56 action_chpass
57 }; 57 };
58 58
59 const char *program_version = "popauth (" PACKAGE_STRING ")";
60 static char doc[] = N_("GNU popauth -- manage pop3 authentication database"); 59 static char doc[] = N_("GNU popauth -- manage pop3 authentication database");
61 static error_t popauth_parse_opt (int key, char *arg, 60 static error_t popauth_parse_opt (int key, char *arg,
62 struct argp_state *astate); 61 struct argp_state *astate);
63 62
64 void popauth_version (FILE *stream, struct argp_state *state); 63 void popauth_version (FILE *stream, struct argp_state *state);
65 void (*argp_program_version_hook) (FILE *stream, struct argp_state *state) =
66 popauth_version;
67 64
68 static struct argp_option options[] = 65 static struct argp_option options[] =
69 { 66 {
...@@ -202,7 +199,8 @@ main(int argc, char **argv) ...@@ -202,7 +199,8 @@ main(int argc, char **argv)
202 /* Native Language Support */ 199 /* Native Language Support */
203 MU_APP_INIT_NLS (); 200 MU_APP_INIT_NLS ();
204 201
205 mu_argp_init (program_version, NULL); 202 mu_argp_init (NULL, NULL);
203 argp_program_version_hook = popauth_version;
206 if (mu_app_init (&argp, popauth_argp_capa, NULL, 204 if (mu_app_init (&argp, popauth_argp_capa, NULL,
207 argc, argv, 0, NULL, &adata)) 205 argc, argv, 0, NULL, &adata))
208 exit (EX_USAGE); 206 exit (EX_USAGE);
...@@ -600,7 +598,7 @@ popauth_version (FILE *stream, struct argp_state *state) ...@@ -600,7 +598,7 @@ popauth_version (FILE *stream, struct argp_state *state)
600 #elif defined(WITH_TOKYOCABINET) 598 #elif defined(WITH_TOKYOCABINET)
601 # define FORMAT "Tokyo Cabinet" 599 # define FORMAT "Tokyo Cabinet"
602 #endif 600 #endif
603 printf ("%s\n", argp_program_version); 601 mu_program_version_hook (stream, state);
604 printf (_("Database format: %s\n"), FORMAT); 602 printf (_("Database format: %s\n"), FORMAT);
605 printf (_("Database location: %s\n"), APOP_PASSFILE); 603 printf (_("Database location: %s\n"), APOP_PASSFILE);
606 exit (EX_OK); 604 exit (EX_OK);
......
...@@ -33,7 +33,6 @@ static void print_header (mu_message_t, int, int, char **); ...@@ -33,7 +33,6 @@ static void print_header (mu_message_t, int, int, char **);
33 static void print_body (mu_message_t); 33 static void print_body (mu_message_t);
34 static int string_starts_with (const char * s1, const char *s2); 34 static int string_starts_with (const char * s1, const char *s2);
35 35
36 const char *program_version = "readmsg (" PACKAGE_STRING ")";
37 static char doc[] = N_("GNU readmsg -- print messages."); 36 static char doc[] = N_("GNU readmsg -- print messages.");
38 static error_t readmsg_parse_opt (int key, char *arg, struct argp_state *astate); 37 static error_t readmsg_parse_opt (int key, char *arg, struct argp_state *astate);
39 38
...@@ -301,7 +300,7 @@ main (int argc, char **argv) ...@@ -301,7 +300,7 @@ main (int argc, char **argv)
301 #ifdef WITH_TLS 300 #ifdef WITH_TLS
302 mu_gocs_register ("tls", mu_tls_module_init); 301 mu_gocs_register ("tls", mu_tls_module_init);
303 #endif 302 #endif
304 mu_argp_init (program_version, NULL); 303 mu_argp_init (NULL, NULL);
305 if (mu_app_init (&argp, readmsg_argp_capa, readmsg_cfg_param, 304 if (mu_app_init (&argp, readmsg_argp_capa, readmsg_cfg_param,
306 argc, argv, 0, &index, NULL)) 305 argc, argv, 0, &index, NULL))
307 exit (1); 306 exit (1);
......
...@@ -48,8 +48,6 @@ ...@@ -48,8 +48,6 @@
48 48
49 #include "mailutils/libargp.h" 49 #include "mailutils/libargp.h"
50 50
51 const char *program_version = "sieve (" PACKAGE_STRING ")";
52
53 static char doc[] = 51 static char doc[] =
54 N_("GNU sieve -- a mail filtering tool.") 52 N_("GNU sieve -- a mail filtering tool.")
55 "\v" 53 "\v"
...@@ -480,7 +478,7 @@ main (int argc, char *argv[]) ...@@ -480,7 +478,7 @@ main (int argc, char *argv[])
480 /* Native Language Support */ 478 /* Native Language Support */
481 MU_APP_INIT_NLS (); 479 MU_APP_INIT_NLS ();
482 480
483 mu_argp_init (program_version, NULL); 481 mu_argp_init (NULL, NULL);
484 #ifdef WITH_TLS 482 #ifdef WITH_TLS
485 mu_gocs_register ("tls", mu_tls_module_init); 483 mu_gocs_register ("tls", mu_tls_module_init);
486 #endif 484 #endif
......