Finish conversion of MH utilities to mh_parseopt
This finishes work started at commit bc73fc65. * include/mailutils/opt.h (mu_option_cache) <cache_arg>: Made const. * libmailutils/opt/opt.c (mu_option_cache_destroy): Don't free cache_arg. * doc/texinfo/mu-mh.texi: Update. * po/POTFILES.in: Remove obsolete files. * mh/tests/refile.at: Don't use double-dash options. * mh/mh_getopt.c (mh_opt_set_folder): New function. * mh/mh_getopt.h: Likewise. * mh/mhn.c: Convert to mh_getopt. * mh/mhparam.c: Likewise. * mh/mhpath.c: Likewise. * mh/mhseq.c: Likewise. * mh/msgchk.c: Likewise. * mh/pick.c: Likewise. * mh/pick.h: Likewise. * mh/pick.y: Likewise. * mh/prompter.c: Likewise. * mh/refile.c: Likewise. * mh/repl.c: Likewise. * mh/rmf.c: Likewise. * mh/rmm.c: Likewise. * mh/scan.c: Likewise. * mh/send.c: Likewise. * mh/show.c: Likewise. * mh/sortm.c: Likewise. * mh/whatnow.c: Likewise. * mh/whom.c: Likewise.
Showing
26 changed files
with
547 additions
and
937 deletions
... | @@ -27,9 +27,6 @@ distribution directory. | ... | @@ -27,9 +27,6 @@ distribution directory. |
27 | @subsection Major differences between Mailutils MH and other MH implementations | 27 | @subsection Major differences between Mailutils MH and other MH implementations |
28 | 28 | ||
29 | @enumerate 1 | 29 | @enumerate 1 |
30 | @item All programs use usual GNU long options. The support for MH single-dash | ||
31 | options is provided for backward compatibility; | ||
32 | |||
33 | @item UUCP addresses are not supported; | 30 | @item UUCP addresses are not supported; |
34 | 31 | ||
35 | @item Mailutils supports a set of new format specifications | 32 | @item Mailutils supports a set of new format specifications |
... | @@ -38,6 +35,12 @@ options is provided for backward compatibility; | ... | @@ -38,6 +35,12 @@ options is provided for backward compatibility; |
38 | @item Mailutils provides a set of new profile variables | 35 | @item Mailutils provides a set of new profile variables |
39 | (@pxref{Profile Variable Diffs}); | 36 | (@pxref{Profile Variable Diffs}); |
40 | 37 | ||
38 | @item All programs recognize @option{--help} and @option{--version} options | ||
39 | |||
40 | These options are recognized only if no other arguments are present in | ||
41 | the command line. Abbreviations are not recognized. This makes Mailutils | ||
42 | MH implementation compatible with the standard usage for GNU tools. | ||
43 | |||
41 | @item Several programs behave differently (@pxref{Program | 44 | @item Several programs behave differently (@pxref{Program |
42 | Diffs}); | 45 | Diffs}); |
43 | 46 | ||
... | @@ -150,7 +153,7 @@ This expression is used in default @file{replcomps} and | ... | @@ -150,7 +153,7 @@ This expression is used in default @file{replcomps} and |
150 | @deftypefn {MH Format} boolean rcpt (@samp{to} | @samp{cc} | @samp{me} | @samp{all}) | 153 | @deftypefn {MH Format} boolean rcpt (@samp{to} | @samp{cc} | @samp{me} | @samp{all}) |
151 | 154 | ||
152 | This function returns true if the given element is present in the | 155 | This function returns true if the given element is present in the |
153 | recipient mask (as modified by @option{--cc} or @option{--nocc} options) and | 156 | recipient mask (as modified by @option{-cc} or @option{-nocc} options) and |
154 | false otherwise. It is used in default formats for @command{repl} and | 157 | false otherwise. It is used in default formats for @command{repl} and |
155 | @command{comp}, e.g.: | 158 | @command{comp}, e.g.: |
156 | 159 | ||
... | @@ -159,7 +162,7 @@ false otherwise. It is used in default formats for @command{repl} and | ... | @@ -159,7 +162,7 @@ false otherwise. It is used in default formats for @command{repl} and |
159 | @end smallexample | 162 | @end smallexample |
160 | 163 | ||
161 | Notice that this means that usual @file{replcomps} file will be ignoring | 164 | Notice that this means that usual @file{replcomps} file will be ignoring |
162 | @option{--cc} and @option{--nocc} options, unless it has been modified | 165 | @option{-cc} and @option{-nocc} options, unless it has been modified |
163 | as shown above. | 166 | as shown above. |
164 | @end deftypefn | 167 | @end deftypefn |
165 | 168 | ||
... | @@ -226,12 +229,12 @@ RAND @command{anno} displays the prompt anyway. | ... | @@ -226,12 +229,12 @@ RAND @command{anno} displays the prompt anyway. |
226 | 229 | ||
227 | The utility is able to burst both RFC 934 digest messages and MIME | 230 | The utility is able to burst both RFC 934 digest messages and MIME |
228 | multipart messages. It provides two additional command line options: | 231 | multipart messages. It provides two additional command line options: |
229 | @option{--recurse} and @option{--length}. | 232 | @option{-recurse} and @option{-length}. |
230 | 233 | ||
231 | The @option{--recurse} option instructs the utility to recursively | 234 | The @option{-recurse} option instructs the utility to recursively |
232 | expand the digest. | 235 | expand the digest. |
233 | 236 | ||
234 | The @option{--length} option can be used to set the minimal encapsulation | 237 | The @option{-length} option can be used to set the minimal encapsulation |
235 | boundary length for RFC 934 digests. Default length is 1, | 238 | boundary length for RFC 934 digests. Default length is 1, |
236 | i.e. encountering one dash immediately following a newline triggers | 239 | i.e. encountering one dash immediately following a newline triggers |
237 | digest decoding. It is OK for messages that follow RFC 934 | 240 | digest decoding. It is OK for messages that follow RFC 934 |
... | @@ -239,12 +242,12 @@ specification. However, many user agents do not precisely follow it, | ... | @@ -239,12 +242,12 @@ specification. However, many user agents do not precisely follow it, |
239 | in particular, they often do not escape lines starting with a dash by | 242 | in particular, they often do not escape lines starting with a dash by |
240 | @samp{- } sequence. @command{Mailman} is one of such agents. To cope | 243 | @samp{- } sequence. @command{Mailman} is one of such agents. To cope |
241 | with such digests you can set encapsulation boundary length to a higher | 244 | with such digests you can set encapsulation boundary length to a higher |
242 | value. For example, @command{bounce --length=8} has been found to be | 245 | value. For example, @command{bounce -length 8} has been found to be |
243 | sufficient for most Mailman-generated digests. | 246 | sufficient for most Mailman-generated digests. |
244 | 247 | ||
245 | @item comp | 248 | @item comp |
246 | 249 | ||
247 | Understands @option{--build} option. | 250 | Understands @option{-build} option. |
248 | 251 | ||
249 | @item fmtdump | 252 | @item fmtdump |
250 | 253 | ||
... | @@ -252,24 +255,24 @@ This command is not provided. Use @option{fmtcheck} instead. | ... | @@ -252,24 +255,24 @@ This command is not provided. Use @option{fmtcheck} instead. |
252 | 255 | ||
253 | @item inc | 256 | @item inc |
254 | @itemize @bullet | 257 | @itemize @bullet |
255 | @item The @option{--moveto} option. | 258 | @item The @option{-moveto} option. |
256 | The @option{--moveto} option instructs @command{inc} to move | 259 | The @option{-moveto} option instructs @command{inc} to move |
257 | messages into another folder after incorporating them. This option | 260 | messages into another folder after incorporating them. This option |
258 | has effect only if the @option{--truncate} option has also been | 261 | has effect only if the @option{-truncate} option has also been |
259 | specified and the underlying mailbox supports the @samp{move} | 262 | specified and the underlying mailbox supports the @samp{move} |
260 | operation. Currently only @samp{imap} and @samp{imaps} mailboxes | 263 | operation. Currently only @samp{imap} and @samp{imaps} mailboxes |
261 | support it. For example, the following command moves incorporated | 264 | support it. For example, the following command moves incorporated |
262 | messages into the @samp{archive} folder: | 265 | messages into the @samp{archive} folder: |
263 | 266 | ||
264 | @example | 267 | @example |
265 | inc --file imaps://imap.gmail.com --moveto=archive | 268 | inc -file imaps://imap.gmail.com -moveto=archive |
266 | @end example | 269 | @end example |
267 | 270 | ||
268 | The @samp{moveto} URL parameter can be used instead of this option, | 271 | The @samp{moveto} URL parameter can be used instead of this option, |
269 | e.g.: | 272 | e.g.: |
270 | 273 | ||
271 | @example | 274 | @example |
272 | inc --file 'imaps://imap.gmail.com;moveto=archive' | 275 | inc -file 'imaps://imap.gmail.com;moveto=archive' |
273 | @end example | 276 | @end example |
274 | 277 | ||
275 | @item Multiple sources | 278 | @item Multiple sources |
... | @@ -294,7 +297,7 @@ Moves incorporated messages into another folder. This was discussed | ... | @@ -294,7 +297,7 @@ Moves incorporated messages into another folder. This was discussed |
294 | above. | 297 | above. |
295 | 298 | ||
296 | @item nomoveto | 299 | @item nomoveto |
297 | Disables the previous @option{--moveto} option. | 300 | Disables the previous @option{-moveto} option. |
298 | 301 | ||
299 | @item truncate[=@var{bool}] | 302 | @item truncate[=@var{bool}] |
300 | Controls source mailbox truncation. If @var{bool} is not given or it is | 303 | Controls source mailbox truncation. If @var{bool} is not given or it is |
... | @@ -333,13 +336,13 @@ The following format variables are silently ignored: @samp{center}, | ... | @@ -333,13 +336,13 @@ The following format variables are silently ignored: @samp{center}, |
333 | @itemize @bullet | 336 | @itemize @bullet |
334 | 337 | ||
335 | @item New option | 338 | @item New option |
336 | New option @option{--compose} forces @command{mhn} editing mode. This | 339 | New option @option{-compose} forces @command{mhn} editing mode. This |
337 | is also the default mode. This differs from the standard | 340 | is also the default mode. This differs from the standard |
338 | @command{mhn}, which switches to the editing mode only if no other | 341 | @command{mhn}, which switches to the editing mode only if no other |
339 | options were given and the input file name coincides with the value of | 342 | options were given and the input file name coincides with the value of |
340 | @env{mhdraft} environment variable. | 343 | @env{mhdraft} environment variable. |
341 | 344 | ||
342 | @item Show mode (@option{--show}) | 345 | @item Show mode (@option{-show}) |
343 | If an appropriate mhn-show-type[/subtype] was not found, GNU @command{mhn} | 346 | If an appropriate mhn-show-type[/subtype] was not found, GNU @command{mhn} |
344 | prints the decoded message content using @code{moreproc} | 347 | prints the decoded message content using @code{moreproc} |
345 | variable. Standard @command{mhn} in this case used to print @samp{don't | 348 | variable. Standard @command{mhn} in this case used to print @samp{don't |
... | @@ -349,47 +352,28 @@ The default behaviour is to pipe the content to the standard input | ... | @@ -349,47 +352,28 @@ The default behaviour is to pipe the content to the standard input |
349 | of the mhn-show-type[/subtype] command. This is altered to using a | 352 | of the mhn-show-type[/subtype] command. This is altered to using a |
350 | temporary file if the command contains @code{%f} or @code{%F} escapes. | 353 | temporary file if the command contains @code{%f} or @code{%F} escapes. |
351 | 354 | ||
352 | @item Store mode (@option{--store}) | 355 | @item Store mode (@option{-store}) |
353 | If the @code{Content-Disposition} header contains @samp{filename=}, | 356 | If the @code{Content-Disposition} header contains @samp{filename=}, |
354 | and @command{mhn} is invoked with @option{--auto} switch, it | 357 | and @command{mhn} is invoked with @option{-auto} switch, it |
355 | transforms the file name into the absolute notation and uses it only | 358 | transforms the file name into the absolute notation and uses it only |
356 | if it lies below the current mhn-storage directory. Standard | 359 | if it lies below the current mhn-storage directory. Standard |
357 | @command{mhn} only requires that the file name do not begin with @samp{/}. | 360 | @command{mhn} only requires that the file name do not begin with @samp{/}. |
358 | 361 | ||
359 | Before saving a message part, GNU @command{mhn} checks if the file already | 362 | Before saving a message part, GNU @command{mhn} checks if the file already |
360 | exists. If so, it asks whether the user wishes to rewrite it. This | 363 | exists. If so, it asks whether the user wishes to rewrite it. This |
361 | behaviour is disabled when @option{--quiet} option was given. | 364 | behaviour is disabled when @option{-quiet} option was given. |
362 | @end itemize | 365 | @end itemize |
363 | 366 | ||
364 | @item mhparam | 367 | @item mhparam |
365 | 368 | ||
366 | The @option{--all} mode does not display commented out entries. | 369 | The @option{-all} mode does not display commented out entries. |
367 | 370 | ||
368 | @item pick | 371 | @item pick |
369 | 372 | ||
370 | The command line syntax @option{--@var{component} @var{string}}) is | 373 | New command line option @option{-cflags} allows to control the type of |
371 | recognized only if at least one of the following conditions is met: | ||
372 | |||
373 | @itemize @bullet | ||
374 | @item The word @var{component} contains at least one capital letter. | ||
375 | E.g. @option{--User-Agent Mailutils}. | ||
376 | |||
377 | @item The word @var{component} ends with a colon, as in | ||
378 | @option{user-agent: Mailutils}. | ||
379 | |||
380 | @item Standard input is not connected to a terminal. | ||
381 | @end itemize | ||
382 | |||
383 | The GNU syntax for component matching is: | ||
384 | |||
385 | @smallexample | ||
386 | pick --component @var{field} --pattern @var{string} | ||
387 | @end smallexample | ||
388 | |||
389 | New command line option @option{--cflags} allows to control the type of | ||
390 | regular expressions used. The option must occur right before | 374 | regular expressions used. The option must occur right before |
391 | @option{--pattern} or @option{--component} option (or one of its | 375 | @option{--@var{component} @var{pattern}} or equivalent construct (like |
392 | aliases, like @option{--cc}, @option{--from}, etc.) | 376 | @option{-cc}, @option{-from}, etc.) |
393 | 377 | ||
394 | The argument to this option is a string of type specifications: | 378 | The argument to this option is a string of type specifications: |
395 | 379 | ||
... | @@ -402,24 +386,24 @@ The argument to this option is a string of type specifications: | ... | @@ -402,24 +386,24 @@ The argument to this option is a string of type specifications: |
402 | 386 | ||
403 | Default is @samp{EI}. | 387 | Default is @samp{EI}. |
404 | 388 | ||
405 | The flags remain in effect until the next occurrence of @option{--cflags} | 389 | The flags remain in effect until the next occurrence of @option{-cflags} |
406 | option. | 390 | option. |
407 | 391 | ||
408 | Sample usage: | 392 | Sample usage: |
409 | 393 | ||
410 | @smallexample | 394 | @smallexample |
411 | pick --cflag BC --subject '*a string' | 395 | pick -cflag BC -subject '*a string' |
412 | @end smallexample | 396 | @end smallexample |
413 | 397 | ||
414 | The date comparison options (@option{--before} and @option{--after} | 398 | The date comparison options (@option{-before} and @option{-after} |
415 | accept date specifications in a wide variety of formats, e.g.: | 399 | accept date specifications in a wide variety of formats, e.g.: |
416 | 400 | ||
417 | @smallexample | 401 | @smallexample |
418 | pick --after 20030301 | 402 | pick -after 20030301 |
419 | pick --after 2003-03-01 | 403 | pick -after 2003-03-01 |
420 | pick --after 01-mar-2003 | 404 | pick -after 01-mar-2003 |
421 | pick --after 2003-mar-01 | 405 | pick -after 2003-mar-01 |
422 | pick --before '1 year ago' | 406 | pick -before '1 year ago' |
423 | etc... | 407 | etc... |
424 | @end smallexample | 408 | @end smallexample |
425 | 409 | ||
... | @@ -454,11 +438,11 @@ will add it automatically. | ... | @@ -454,11 +438,11 @@ will add it automatically. |
454 | @item | 438 | @item |
455 | Linking messages between folders goes against the logic of Mailutils, | 439 | Linking messages between folders goes against the logic of Mailutils, |
456 | so @command{refile} never makes links even if called with | 440 | so @command{refile} never makes links even if called with |
457 | @option{--link} option. The latter is actually a synonym for @option{--copy}, | 441 | @option{-link} option. The latter is actually a synonym for @option{-copy}, |
458 | which preserves the original message. | 442 | which preserves the original message. |
459 | 443 | ||
460 | @item | 444 | @item |
461 | The @option{--preserve} option is not implemented. It is retained for backward | 445 | The @option{-preserve} option is not implemented. It is retained for backward |
462 | compatibility only. | 446 | compatibility only. |
463 | 447 | ||
464 | @item | 448 | @item |
... | @@ -467,7 +451,7 @@ Message specs and folder names may be interspersed. | ... | @@ -467,7 +451,7 @@ Message specs and folder names may be interspersed. |
467 | 451 | ||
468 | @item repl | 452 | @item repl |
469 | 453 | ||
470 | Understands @option{--use} option. Disposition shell provides | 454 | Understands @option{-use} option. Disposition shell provides |
471 | @code{use} command. | 455 | @code{use} command. |
472 | 456 | ||
473 | @item rmm | 457 | @item rmm |
... | @@ -491,14 +475,14 @@ rmmproc: | ... | @@ -491,14 +475,14 @@ rmmproc: |
491 | 475 | ||
492 | @item sortm | 476 | @item sortm |
493 | 477 | ||
494 | New option @option{--numfield} specifies numeric comparison for the | 478 | New option @option{-numfield} specifies numeric comparison for the |
495 | given field. | 479 | given field. |
496 | 480 | ||
497 | Any number of @option{--datefield}, @option{--textfield} and | 481 | Any number of @option{-datefield}, @option{-textfield} and |
498 | @option{--numfield} options may be given, thus allowing to build sort | 482 | @option{-numfield} options may be given, thus allowing to build sort |
499 | criteria of arbitrary complexity. | 483 | criteria of arbitrary complexity. |
500 | 484 | ||
501 | The order of @option{--.*field} options sets the ordering priority. This | 485 | The order of @option{-.*field} options sets the ordering priority. This |
502 | differs from the behaviour of the standard @command{sortm}, which | 486 | differs from the behaviour of the standard @command{sortm}, which |
503 | always orders datefield-major, textfield-minor. | 487 | always orders datefield-major, textfield-minor. |
504 | 488 | ||
... | @@ -506,11 +490,11 @@ Apart from sorting the mailfolder the following actions may be | ... | @@ -506,11 +490,11 @@ Apart from sorting the mailfolder the following actions may be |
506 | specified: | 490 | specified: |
507 | 491 | ||
508 | @table @option | 492 | @table @option |
509 | @item --list | 493 | @item -list |
510 | List the ordered messages using a format string given by | 494 | List the ordered messages using a format string given by |
511 | @option{--form} or @option{--format} option. | 495 | @option{-form} or @option{-format} option. |
512 | 496 | ||
513 | @item --dry-run | 497 | @item -dry-run |
514 | Do not actually sort messages, rather print what would have been | 498 | Do not actually sort messages, rather print what would have been |
515 | done. This is useful for debugging purposes. | 499 | done. This is useful for debugging purposes. |
516 | @end table | 500 | @end table | ... | ... |
... | @@ -71,7 +71,7 @@ typedef struct mu_option_cache *mu_option_cache_ptr_t; | ... | @@ -71,7 +71,7 @@ typedef struct mu_option_cache *mu_option_cache_ptr_t; |
71 | struct mu_option_cache | 71 | struct mu_option_cache |
72 | { | 72 | { |
73 | struct mu_option *cache_opt; | 73 | struct mu_option *cache_opt; |
74 | char *cache_arg; | 74 | char const *cache_arg; |
75 | }; | 75 | }; |
76 | 76 | ||
77 | #define MU_PARSEOPT_DEFAULT 0 | 77 | #define MU_PARSEOPT_DEFAULT 0 | ... | ... |
... | @@ -136,7 +136,6 @@ static void | ... | @@ -136,7 +136,6 @@ static void |
136 | mu_option_cache_destroy (void *ptr) | 136 | mu_option_cache_destroy (void *ptr) |
137 | { | 137 | { |
138 | struct mu_option_cache *cache = ptr; | 138 | struct mu_option_cache *cache = ptr; |
139 | free (cache->cache_arg); | ||
140 | free (cache); | 139 | free (cache); |
141 | } | 140 | } |
142 | 141 | ||
... | @@ -150,7 +149,7 @@ add_option_cache (struct mu_parseopt *po, struct mu_option *opt, | ... | @@ -150,7 +149,7 @@ add_option_cache (struct mu_parseopt *po, struct mu_option *opt, |
150 | { | 149 | { |
151 | struct mu_option_cache *cache = mu_alloc (sizeof (*cache)); | 150 | struct mu_option_cache *cache = mu_alloc (sizeof (*cache)); |
152 | cache->cache_opt = opt; | 151 | cache->cache_opt = opt; |
153 | cache->cache_arg = arg ? mu_strdup (arg) : NULL; | 152 | cache->cache_arg = arg; |
154 | 153 | ||
155 | if ((po->po_flags & MU_PARSEOPT_IMMEDIATE) | 154 | if ((po->po_flags & MU_PARSEOPT_IMMEDIATE) |
156 | || (opt->opt_flags & MU_OPTION_IMMEDIATE)) | 155 | || (opt->opt_flags & MU_OPTION_IMMEDIATE)) |
... | @@ -774,7 +773,7 @@ mu_option_set_value (struct mu_parseopt *po, struct mu_option *opt, | ... | @@ -774,7 +773,7 @@ mu_option_set_value (struct mu_parseopt *po, struct mu_option *opt, |
774 | free (errmsg); | 773 | free (errmsg); |
775 | 774 | ||
776 | if (!(po->po_flags & MU_PARSEOPT_NO_ERREXIT)) | 775 | if (!(po->po_flags & MU_PARSEOPT_NO_ERREXIT)) |
777 | exit (EXIT_ERROR); | 776 | exit (po->po_exit_error); |
778 | } | 777 | } |
779 | } | 778 | } |
780 | } | 779 | } | ... | ... |
... | @@ -79,6 +79,23 @@ augment_argv (int *pargc, char ***pargv) | ... | @@ -79,6 +79,23 @@ augment_argv (int *pargc, char ***pargv) |
79 | } | 79 | } |
80 | 80 | ||
81 | static void | 81 | static void |
82 | process_std_options (int argc, char **argv, struct mu_parseopt *po) | ||
83 | { | ||
84 | if (argc != 1) | ||
85 | return; | ||
86 | if (strcmp (argv[0], "--help") == 0) | ||
87 | { | ||
88 | mu_program_help (po, mu_strout); | ||
89 | exit (0); | ||
90 | } | ||
91 | if (strcmp (argv[0], "--version") == 0) | ||
92 | { | ||
93 | mu_program_version (po, mu_strout); | ||
94 | exit (0); | ||
95 | } | ||
96 | } | ||
97 | |||
98 | static void | ||
82 | process_folder_arg (int *pargc, char **argv, struct mu_parseopt *po) | 99 | process_folder_arg (int *pargc, char **argv, struct mu_parseopt *po) |
83 | { | 100 | { |
84 | int i, j; | 101 | int i, j; |
... | @@ -109,8 +126,9 @@ process_folder_arg (int *pargc, char **argv, struct mu_parseopt *po) | ... | @@ -109,8 +126,9 @@ process_folder_arg (int *pargc, char **argv, struct mu_parseopt *po) |
109 | *pargc = j; | 126 | *pargc = j; |
110 | } | 127 | } |
111 | 128 | ||
112 | static void | 129 | void |
113 | set_folder (struct mu_parseopt *po, struct mu_option *opt, char const *arg) | 130 | mh_opt_set_folder (struct mu_parseopt *po, struct mu_option *opt, |
131 | char const *arg) | ||
114 | { | 132 | { |
115 | mh_set_current_folder (arg); | 133 | mh_set_current_folder (arg); |
116 | } | 134 | } |
... | @@ -118,7 +136,45 @@ set_folder (struct mu_parseopt *po, struct mu_option *opt, char const *arg) | ... | @@ -118,7 +136,45 @@ set_folder (struct mu_parseopt *po, struct mu_option *opt, char const *arg) |
118 | static struct mu_option folder_option[] = { | 136 | static struct mu_option folder_option[] = { |
119 | { "folder", 0, NULL, MU_OPTION_DEFAULT, | 137 | { "folder", 0, NULL, MU_OPTION_DEFAULT, |
120 | N_("set current folder"), | 138 | N_("set current folder"), |
121 | mu_c_string, NULL, set_folder }, | 139 | mu_c_string, NULL, mh_opt_set_folder }, |
140 | MU_OPTION_END | ||
141 | }; | ||
142 | |||
143 | void | ||
144 | mh_version_hook (struct mu_parseopt *po, mu_stream_t stream) | ||
145 | { | ||
146 | extern const char mu_version_copyright[]; | ||
147 | #ifdef GIT_DESCRIBE | ||
148 | mu_stream_printf (stream, "%s (GNU MH, %s) %s [%s]\n", | ||
149 | mu_program_name, PACKAGE_NAME, PACKAGE_VERSION, | ||
150 | GIT_DESCRIBE); | ||
151 | #else | ||
152 | mu_stream_printf (stream, "%s (GNU MH, %s) %s\n", mu_program_name, | ||
153 | PACKAGE_NAME, PACKAGE_VERSION); | ||
154 | #endif | ||
155 | /* TRANSLATORS: Translate "(C)" to the copyright symbol | ||
156 | (C-in-a-circle), if this symbol is available in the user's | ||
157 | locale. Otherwise, do not translate "(C)"; leave it as-is. */ | ||
158 | mu_stream_printf (stream, mu_version_copyright, _("(C)")); | ||
159 | mu_stream_printf (stream, _("\ | ||
160 | \n\ | ||
161 | 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\ | ||
162 | There is NO WARRANTY, to the extent permitted by law.\n\ | ||
163 | \n\ | ||
164 | ")); | ||
165 | } | ||
166 | |||
167 | static void | ||
168 | fn_version (struct mu_parseopt *po, struct mu_option *opt, char const *unused) | ||
169 | { | ||
170 | mu_program_version (po, mu_strout); | ||
171 | exit (0); | ||
172 | } | ||
173 | |||
174 | static struct mu_option version_option[] = { | ||
175 | { "version", 0, NULL, MU_OPTION_DEFAULT, | ||
176 | N_("print program version"), | ||
177 | mu_c_string, NULL, fn_version }, | ||
122 | MU_OPTION_END | 178 | MU_OPTION_END |
123 | }; | 179 | }; |
124 | 180 | ||
... | @@ -132,7 +188,7 @@ mh_getopt (int *pargc, char ***pargv, struct mu_option *options, | ... | @@ -132,7 +188,7 @@ mh_getopt (int *pargc, char ***pargv, struct mu_option *options, |
132 | struct mu_parseopt po; | 188 | struct mu_parseopt po; |
133 | struct mu_option *optv[3]; | 189 | struct mu_option *optv[3]; |
134 | struct getopt_data getopt_data; | 190 | struct getopt_data getopt_data; |
135 | char const *args[2]; | 191 | char const *args[3]; |
136 | int flags = MU_PARSEOPT_SINGLE_DASH | MU_PARSEOPT_IMMEDIATE; | 192 | int flags = MU_PARSEOPT_SINGLE_DASH | MU_PARSEOPT_IMMEDIATE; |
137 | int i; | 193 | int i; |
138 | 194 | ||
... | @@ -177,6 +233,9 @@ mh_getopt (int *pargc, char ***pargv, struct mu_option *options, | ... | @@ -177,6 +233,9 @@ mh_getopt (int *pargc, char ***pargv, struct mu_option *options, |
177 | //po.po_extra_info = gnu_general_help_url; | 233 | //po.po_extra_info = gnu_general_help_url; |
178 | //flags |= MU_PARSEOPT_EXTRA_INFO; | 234 | //flags |= MU_PARSEOPT_EXTRA_INFO; |
179 | 235 | ||
236 | po.po_version_hook = mh_version_hook; | ||
237 | flags |= MU_PARSEOPT_VERSION_HOOK; | ||
238 | |||
180 | mu_set_program_name (argv[0]); | 239 | mu_set_program_name (argv[0]); |
181 | mh_init (); | 240 | mh_init (); |
182 | augment_argv (&argc, &argv); | 241 | augment_argv (&argc, &argv); |
... | @@ -184,7 +243,9 @@ mh_getopt (int *pargc, char ***pargv, struct mu_option *options, | ... | @@ -184,7 +243,9 @@ mh_getopt (int *pargc, char ***pargv, struct mu_option *options, |
184 | i = 0; | 243 | i = 0; |
185 | if (mhflags & MH_GETOPT_DEFAULT_FOLDER) | 244 | if (mhflags & MH_GETOPT_DEFAULT_FOLDER) |
186 | optv[i++] = folder_option; | 245 | optv[i++] = folder_option; |
246 | if (options) | ||
187 | optv[i++] = options; | 247 | optv[i++] = options; |
248 | optv[i++] = version_option; | ||
188 | optv[i] = NULL; | 249 | optv[i] = NULL; |
189 | 250 | ||
190 | if (mu_parseopt (&po, argc, argv, optv, flags)) | 251 | if (mu_parseopt (&po, argc, argv, optv, flags)) |
... | @@ -193,6 +254,8 @@ mh_getopt (int *pargc, char ***pargv, struct mu_option *options, | ... | @@ -193,6 +254,8 @@ mh_getopt (int *pargc, char ***pargv, struct mu_option *options, |
193 | argc -= po.po_arg_start; | 254 | argc -= po.po_arg_start; |
194 | argv += po.po_arg_start; | 255 | argv += po.po_arg_start; |
195 | 256 | ||
257 | process_std_options (argc, argv, &po); | ||
258 | |||
196 | process_folder_arg (&argc, argv, &po); | 259 | process_folder_arg (&argc, argv, &po); |
197 | 260 | ||
198 | if (!argdoc && argc) | 261 | if (!argdoc && argc) | ... | ... |
... | @@ -35,5 +35,7 @@ void mh_opt_find_file (struct mu_parseopt *po, struct mu_option *opt, | ... | @@ -35,5 +35,7 @@ void mh_opt_find_file (struct mu_parseopt *po, struct mu_option *opt, |
35 | char const *arg); | 35 | char const *arg); |
36 | void mh_opt_read_formfile (struct mu_parseopt *po, struct mu_option *opt, | 36 | void mh_opt_read_formfile (struct mu_parseopt *po, struct mu_option *opt, |
37 | char const *arg); | 37 | char const *arg); |
38 | void mh_opt_set_folder (struct mu_parseopt *po, struct mu_option *opt, | ||
39 | char const *arg); | ||
38 | 40 | ||
39 | 41 | ... | ... |
This diff is collapsed.
Click to expand it.
... | @@ -19,47 +19,21 @@ | ... | @@ -19,47 +19,21 @@ |
19 | 19 | ||
20 | #include <mh.h> | 20 | #include <mh.h> |
21 | 21 | ||
22 | static char doc[] = N_("GNU MH mhparam")"\v" | 22 | static char prog_doc[] = N_("GNU MH mhparam"); |
23 | N_("Use -help to obtain the list of traditional MH options."); | ||
24 | static char args_doc[] = N_("[COMPONENT [COMPONENT...]]"); | 23 | static char args_doc[] = N_("[COMPONENT [COMPONENT...]]"); |
25 | 24 | ||
26 | /* GNU options */ | ||
27 | static struct argp_option options[] = { | ||
28 | {"all", ARG_ALL, NULL, 0, | ||
29 | N_("display all components from the MH profile. All other arguments are ignored")}, | ||
30 | {"component", ARG_COMPONENT, N_("BOOL"), OPTION_ARG_OPTIONAL, | ||
31 | N_("always display the component name") }, | ||
32 | { 0 } | ||
33 | }; | ||
34 | |||
35 | /* Traditional MH options */ | ||
36 | struct mh_option mh_option[] = { | ||
37 | { "all" }, | ||
38 | { "component", MH_OPT_BOOL }, | ||
39 | { NULL } | ||
40 | }; | ||
41 | |||
42 | static int display_all; | 25 | static int display_all; |
43 | static int display_comp_name = -1; | 26 | static int display_comp_name = -1; |
44 | 27 | ||
45 | static error_t | 28 | static struct mu_option options[] = { |
46 | opt_handler (int key, char *arg, struct argp_state *state) | 29 | { "all", 0, NULL, MU_OPTION_DEFAULT, |
47 | { | 30 | N_("display all components from the MH profile. All other arguments are ignored"), |
48 | switch (key) | 31 | mu_c_bool, &display_all }, |
49 | { | 32 | { "component", 0, NULL, MU_OPTION_DEFAULT, |
50 | case ARG_ALL: | 33 | N_("always display the component name"), |
51 | display_all = 1; | 34 | mu_c_bool, &display_comp_name }, |
52 | break; | 35 | MU_OPTION_END |
53 | 36 | }; | |
54 | case ARG_COMPONENT: | ||
55 | display_comp_name = is_true (arg); | ||
56 | break; | ||
57 | |||
58 | default: | ||
59 | return ARGP_ERR_UNKNOWN; | ||
60 | } | ||
61 | return 0; | ||
62 | } | ||
63 | 37 | ||
64 | static struct { | 38 | static struct { |
65 | char *comp; | 39 | char *comp; |
... | @@ -81,7 +55,8 @@ mhparam_defval (char *comp) | ... | @@ -81,7 +55,8 @@ mhparam_defval (char *comp) |
81 | } | 55 | } |
82 | 56 | ||
83 | int | 57 | int |
84 | mhparam_iterator (const char *comp, const char *value, void *data MU_ARG_UNUSED) | 58 | mhparam_iterator (const char *comp, const char *value, |
59 | void *data MU_ARG_UNUSED) | ||
85 | { | 60 | { |
86 | if (display_comp_name) | 61 | if (display_comp_name) |
87 | printf("%s:\t", comp); | 62 | printf("%s:\t", comp); |
... | @@ -112,14 +87,10 @@ mhparam (char *comp) | ... | @@ -112,14 +87,10 @@ mhparam (char *comp) |
112 | int | 87 | int |
113 | main (int argc, char **argv) | 88 | main (int argc, char **argv) |
114 | { | 89 | { |
115 | int index; | ||
116 | |||
117 | /* Native Language Support */ | 90 | /* Native Language Support */ |
118 | MU_APP_INIT_NLS (); | 91 | MU_APP_INIT_NLS (); |
119 | 92 | ||
120 | mh_argp_init (); | 93 | mh_getopt (&argc, &argv, options, 0, args_doc, prog_doc, NULL); |
121 | mh_argp_parse (&argc, &argv, 0, options, mh_option, args_doc, doc, | ||
122 | opt_handler, NULL, &index); | ||
123 | 94 | ||
124 | if (display_all) | 95 | if (display_all) |
125 | { | 96 | { |
... | @@ -129,11 +100,13 @@ main (int argc, char **argv) | ... | @@ -129,11 +100,13 @@ main (int argc, char **argv) |
129 | } | 100 | } |
130 | else | 101 | else |
131 | { | 102 | { |
103 | int i; | ||
104 | |||
132 | if (display_comp_name == -1) | 105 | if (display_comp_name == -1) |
133 | display_comp_name = argc - index > 1; | 106 | display_comp_name = argc > 1; |
134 | 107 | ||
135 | for (; index < argc; index++) | 108 | for (i = 0; i < argc; i++) |
136 | mhparam (argv[index]); | 109 | mhparam (argv[i]); |
137 | } | 110 | } |
138 | return 0; | 111 | return 0; |
139 | } | 112 | } | ... | ... |
... | @@ -19,37 +19,9 @@ | ... | @@ -19,37 +19,9 @@ |
19 | 19 | ||
20 | #include <mh.h> | 20 | #include <mh.h> |
21 | 21 | ||
22 | static char doc[] = N_("GNU MH mhpath")"\v" | 22 | static char prog_doc[] = N_("GNU MH mhpath"); |
23 | N_("Use -help to obtain the list of traditional MH options."); | ||
24 | static char args_doc[] = N_("[+FOLDER] [MSGLIST]"); | 23 | static char args_doc[] = N_("[+FOLDER] [MSGLIST]"); |
25 | 24 | ||
26 | /* GNU options */ | ||
27 | static struct argp_option options[] = { | ||
28 | {"folder", ARG_FOLDER, N_("FOLDER"), 0, | ||
29 | N_("specify folder to operate upon")}, | ||
30 | { 0 } | ||
31 | }; | ||
32 | |||
33 | /* Traditional MH options */ | ||
34 | struct mh_option mh_option[] = { | ||
35 | { NULL } | ||
36 | }; | ||
37 | |||
38 | static error_t | ||
39 | opt_handler (int key, char *arg, struct argp_state *state) | ||
40 | { | ||
41 | switch (key) | ||
42 | { | ||
43 | case ARG_FOLDER: | ||
44 | mh_set_current_folder (arg); | ||
45 | break; | ||
46 | |||
47 | default: | ||
48 | return ARGP_ERR_UNKNOWN; | ||
49 | } | ||
50 | return 0; | ||
51 | } | ||
52 | |||
53 | static int | 25 | static int |
54 | mhpath (size_t num, mu_message_t msg, void *data) | 26 | mhpath (size_t num, mu_message_t msg, void *data) |
55 | { | 27 | { |
... | @@ -63,7 +35,6 @@ mhpath (size_t num, mu_message_t msg, void *data) | ... | @@ -63,7 +35,6 @@ mhpath (size_t num, mu_message_t msg, void *data) |
63 | int | 35 | int |
64 | main (int argc, char **argv) | 36 | main (int argc, char **argv) |
65 | { | 37 | { |
66 | int index = 0; | ||
67 | mu_mailbox_t mbox = NULL; | 38 | mu_mailbox_t mbox = NULL; |
68 | mu_url_t url = NULL; | 39 | mu_url_t url = NULL; |
69 | char *mhdir; | 40 | char *mhdir; |
... | @@ -75,9 +46,8 @@ main (int argc, char **argv) | ... | @@ -75,9 +46,8 @@ main (int argc, char **argv) |
75 | /* Native Language Support */ | 46 | /* Native Language Support */ |
76 | MU_APP_INIT_NLS (); | 47 | MU_APP_INIT_NLS (); |
77 | 48 | ||
78 | mh_argp_init (); | 49 | mh_getopt (&argc, &argv, NULL, MH_GETOPT_DEFAULT_FOLDER, |
79 | mh_argp_parse (&argc, &argv, 0, options, mh_option, args_doc, doc, | 50 | args_doc, prog_doc, NULL); |
80 | opt_handler, NULL, &index); | ||
81 | 51 | ||
82 | current_folder = mh_current_folder (); | 52 | current_folder = mh_current_folder (); |
83 | /* If the only argument is `+', your MH Path is output; this | 53 | /* If the only argument is `+', your MH Path is output; this |
... | @@ -98,7 +68,7 @@ main (int argc, char **argv) | ... | @@ -98,7 +68,7 @@ main (int argc, char **argv) |
98 | 68 | ||
99 | /* If no `msgs' are specified, mhpath outputs the folder pathname | 69 | /* If no `msgs' are specified, mhpath outputs the folder pathname |
100 | instead. */ | 70 | instead. */ |
101 | if (index == argc) | 71 | if (argc == 0) |
102 | { | 72 | { |
103 | printf ("%s\n", mhdir); | 73 | printf ("%s\n", mhdir); |
104 | exit (0); | 74 | exit (0); |
... | @@ -112,7 +82,7 @@ main (int argc, char **argv) | ... | @@ -112,7 +82,7 @@ main (int argc, char **argv) |
112 | The "new" message may not be used as part of a message | 82 | The "new" message may not be used as part of a message |
113 | range. */ | 83 | range. */ |
114 | 84 | ||
115 | if (argc - index == 1 && strcmp (argv[index], "new") == 0) | 85 | if (argc == 1 && strcmp (argv[0], "new") == 0) |
116 | { | 86 | { |
117 | mu_message_t msg = NULL; | 87 | mu_message_t msg = NULL; |
118 | size_t num; | 88 | size_t num; |
... | @@ -126,7 +96,7 @@ main (int argc, char **argv) | ... | @@ -126,7 +96,7 @@ main (int argc, char **argv) |
126 | /* Mhpath expands and sorts the message list `msgs' and | 96 | /* Mhpath expands and sorts the message list `msgs' and |
127 | writes the full pathnames of the messages to the standard | 97 | writes the full pathnames of the messages to the standard |
128 | output separated by newlines. */ | 98 | output separated by newlines. */ |
129 | mh_msgset_parse (&msgset, mbox, argc - index, argv + index, "cur"); | 99 | mh_msgset_parse (&msgset, mbox, argc, argv, "cur"); |
130 | status = mu_msgset_foreach_message (msgset, mhpath, mhdir); | 100 | status = mu_msgset_foreach_message (msgset, mhpath, mhdir); |
131 | mu_mailbox_close (mbox); | 101 | mu_mailbox_close (mbox); |
132 | mu_mailbox_destroy (&mbox); | 102 | mu_mailbox_destroy (&mbox); | ... | ... |
... | @@ -18,50 +18,20 @@ | ... | @@ -18,50 +18,20 @@ |
18 | 18 | ||
19 | #include <mh.h> | 19 | #include <mh.h> |
20 | 20 | ||
21 | static char doc[] = N_("GNU MH mhseq")"\v" | 21 | static char prog_doc[] = N_("GNU MH mhseq"); |
22 | N_("Use -help to obtain the list of traditional MH options."); | ||
23 | static char args_doc[] = N_("[SEQUENCE]"); | 22 | static char args_doc[] = N_("[SEQUENCE]"); |
24 | 23 | ||
25 | static struct argp_option options[] = { | ||
26 | {"folder", ARG_FOLDER, N_("FOLDER"), 0, | ||
27 | N_("specify the folder to use")}, | ||
28 | { "uids", 'u', NULL, 0, | ||
29 | N_("show message UIDs (default)")}, | ||
30 | { "numbers", 'n', NULL, 0, | ||
31 | N_("show message numbers") }, | ||
32 | { NULL } | ||
33 | }; | ||
34 | |||
35 | /* Traditional MH options */ | ||
36 | struct mh_option mh_option[] = { | ||
37 | { "uid" }, | ||
38 | { NULL } | ||
39 | }; | ||
40 | |||
41 | static int uid_option = 1; | 24 | static int uid_option = 1; |
42 | 25 | ||
43 | static error_t | 26 | static struct mu_option options[] = { |
44 | opt_handler (int key, char *arg, struct argp_state *state) | 27 | { "uids", 0, NULL, MU_OPTION_DEFAULT, |
45 | { | 28 | N_("show message UIDs (default)"), |
46 | switch (key) | 29 | mu_c_int, &uid_option, NULL, "1" }, |
47 | { | 30 | { "numbers", 0, NULL, MU_OPTION_DEFAULT, |
48 | case ARG_FOLDER: | 31 | N_("show message numbers"), |
49 | mh_set_current_folder (arg); | 32 | mu_c_int, &uid_option, NULL, "0" }, |
50 | break; | 33 | MU_OPTION_END |
51 | 34 | }; | |
52 | case 'n': | ||
53 | uid_option = 0; | ||
54 | break; | ||
55 | |||
56 | case 'u': | ||
57 | uid_option = 1; | ||
58 | break; | ||
59 | |||
60 | default: | ||
61 | return ARGP_ERR_UNKNOWN; | ||
62 | } | ||
63 | return 0; | ||
64 | } | ||
65 | 35 | ||
66 | static int | 36 | static int |
67 | _print_number (size_t n, void *data) | 37 | _print_number (size_t n, void *data) |
... | @@ -73,19 +43,15 @@ _print_number (size_t n, void *data) | ... | @@ -73,19 +43,15 @@ _print_number (size_t n, void *data) |
73 | int | 43 | int |
74 | main (int argc, char **argv) | 44 | main (int argc, char **argv) |
75 | { | 45 | { |
76 | int index; | ||
77 | mu_mailbox_t mbox; | 46 | mu_mailbox_t mbox; |
78 | mu_msgset_t msgset; | 47 | mu_msgset_t msgset; |
79 | 48 | ||
80 | /* Native Language Support */ | 49 | /* Native Language Support */ |
81 | MU_APP_INIT_NLS (); | 50 | MU_APP_INIT_NLS (); |
82 | 51 | ||
83 | mh_argp_init (); | 52 | mh_getopt (&argc, &argv, options, MH_GETOPT_DEFAULT_FOLDER, |
84 | mh_argp_parse (&argc, &argv, 0, options, mh_option, args_doc, doc, | 53 | args_doc, prog_doc, NULL); |
85 | opt_handler, NULL, &index); | ||
86 | 54 | ||
87 | argc -= index; | ||
88 | argv += index; | ||
89 | mbox = mh_open_folder (mh_current_folder (), MU_STREAM_READ); | 55 | mbox = mh_open_folder (mh_current_folder (), MU_STREAM_READ); |
90 | 56 | ||
91 | mh_msgset_parse (&msgset, mbox, argc, argv, "cur"); | 57 | mh_msgset_parse (&msgset, mbox, argc, argv, "cur"); | ... | ... |
... | @@ -21,42 +21,9 @@ | ... | @@ -21,42 +21,9 @@ |
21 | #include "mailutils/datetime.h" | 21 | #include "mailutils/datetime.h" |
22 | #include <pwd.h> | 22 | #include <pwd.h> |
23 | 23 | ||
24 | static char doc[] = N_("GNU MH msgchk")"\v" | 24 | static char prog_doc[] = N_("GNU MH msgchk"); |
25 | N_("Use -help to obtain the list of traditional MH options."); | ||
26 | static char args_doc[] = N_("USER [USER...]"); | 25 | static char args_doc[] = N_("USER [USER...]"); |
27 | 26 | ||
28 | /* GNU options */ | ||
29 | static struct argp_option options[] = { | ||
30 | {"date", ARG_DATE, N_("BOOL"), OPTION_ARG_OPTIONAL, | ||
31 | N_("print out the last date mail was read") }, | ||
32 | {"nodate", ARG_NODATE, NULL, OPTION_HIDDEN, | ||
33 | N_("don't print out the last date mail was read") }, | ||
34 | {"notify", ARG_NOTIFY, "all|mail|nomail", 0, | ||
35 | N_("produce a message upon these events") }, | ||
36 | {"nonotify", ARG_NONOTIFY, "all|mail|nomail", 0, | ||
37 | N_("disable notification") }, | ||
38 | {"host", ARG_HOST, N_("URL"), 0, | ||
39 | N_("check mail on this host or URL") }, | ||
40 | {"user", ARG_USER, N_("NAME"), 0, | ||
41 | N_("set user name for remote mailbox access") }, | ||
42 | {"apop", ARG_APOP, N_("BOOL"), OPTION_ARG_OPTIONAL, | ||
43 | N_("enable APOP") }, | ||
44 | {"noapop", ARG_NOAPOP, NULL, OPTION_HIDDEN, | ||
45 | N_("disable APOP") }, | ||
46 | {NULL} | ||
47 | }; | ||
48 | |||
49 | /* Traditional MH options */ | ||
50 | struct mh_option mh_option[] = { | ||
51 | { "date", MH_OPT_BOOL }, | ||
52 | { "notify", MH_OPT_ARG, "all|mail|nomail" }, | ||
53 | { "nonotify", MH_OPT_ARG, "all|mail|nomail" }, | ||
54 | { "host", MH_OPT_ARG, "host-or-url" }, | ||
55 | { "user", MH_OPT_ARG, "name" }, | ||
56 | { "apop", MH_OPT_BOOL }, | ||
57 | { NULL } | ||
58 | }; | ||
59 | |||
60 | int date_option = 1; | 27 | int date_option = 1; |
61 | int apop_option; | 28 | int apop_option; |
62 | char *remote_host; | 29 | char *remote_host; |
... | @@ -75,55 +42,53 @@ static struct mu_kwd notifytab[] = { | ... | @@ -75,55 +42,53 @@ static struct mu_kwd notifytab[] = { |
75 | { NULL } | 42 | { NULL } |
76 | }; | 43 | }; |
77 | 44 | ||
78 | static error_t | 45 | static void |
79 | opt_handler (int key, char *arg, struct argp_state *state) | 46 | set_notify (struct mu_parseopt *po, struct mu_option *opt, char const *arg) |
80 | { | 47 | { |
81 | int n; | 48 | int n; |
82 | |||
83 | switch (key) | ||
84 | { | ||
85 | case ARG_DATE: | ||
86 | date_option = is_true (arg); | ||
87 | break; | ||
88 | |||
89 | case ARG_NODATE: | ||
90 | date_option = 0; | ||
91 | break; | ||
92 | |||
93 | case ARG_APOP: | ||
94 | apop_option = is_true (arg); | ||
95 | break; | ||
96 | |||
97 | case ARG_NOAPOP: | ||
98 | apop_option = 0; | ||
99 | break; | ||
100 | |||
101 | case ARG_NOTIFY: | ||
102 | if (mu_kwd_xlat_name (notifytab, arg, &n)) | 49 | if (mu_kwd_xlat_name (notifytab, arg, &n)) |
103 | argp_error (state, "unknown notify argument: %s", arg); | 50 | { |
51 | mu_parseopt_error (po, "unknown notify argument: %s", arg); | ||
52 | exit (po->po_exit_error); | ||
53 | } | ||
104 | notify |= n; | 54 | notify |= n; |
105 | break; | 55 | } |
106 | 56 | ||
107 | case ARG_NONOTIFY: | 57 | static void |
58 | clr_notify (struct mu_parseopt *po, struct mu_option *opt, char const *arg) | ||
59 | { | ||
60 | int n; | ||
108 | if (mu_kwd_xlat_name (notifytab, arg, &n)) | 61 | if (mu_kwd_xlat_name (notifytab, arg, &n)) |
109 | argp_error (state, "unknown notify argument: %s", arg); | 62 | { |
110 | notify &= ~n; | 63 | mu_parseopt_error (po, "unknown notify argument: %s", arg); |
111 | break; | 64 | exit (po->po_exit_error); |
112 | |||
113 | case ARG_USER: | ||
114 | remote_user = arg; | ||
115 | break; | ||
116 | |||
117 | case ARG_HOST: | ||
118 | remote_host = arg; | ||
119 | break; | ||
120 | |||
121 | default: | ||
122 | return ARGP_ERR_UNKNOWN; | ||
123 | } | 65 | } |
124 | return 0; | 66 | notify &= ~n; |
125 | } | 67 | } |
126 | 68 | ||
69 | static struct mu_option options[] = { | ||
70 | { "date", 0, NULL, MU_OPTION_DEFAULT, | ||
71 | N_("print out the last date mail was read"), | ||
72 | mu_c_bool, &date_option }, | ||
73 | { "notify", 0, "all|mail|nomail", MU_OPTION_DEFAULT, | ||
74 | N_("produce a message upon these events"), | ||
75 | mu_c_string, NULL, set_notify }, | ||
76 | { "nonotify", 0, "all|mail|nomail", MU_OPTION_DEFAULT, | ||
77 | N_("disable notification"), | ||
78 | mu_c_string, NULL, clr_notify }, | ||
79 | { "host", 0, N_("URL"), MU_OPTION_DEFAULT, | ||
80 | N_("check mail on this host or URL"), | ||
81 | mu_c_string, &remote_host }, | ||
82 | { "user", 0, N_("NAME"), MU_OPTION_DEFAULT, | ||
83 | N_("set user name for remote mailbox access"), | ||
84 | mu_c_string, &remote_user }, | ||
85 | { "apop", 0, NULL, MU_OPTION_DEFAULT, | ||
86 | N_("enable APOP"), | ||
87 | mu_c_bool, &apop_option }, | ||
88 | |||
89 | MU_OPTION_END | ||
90 | }; | ||
91 | |||
127 | static char * | 92 | static char * |
128 | attach_auth_ticket (mu_mailbox_t mbox) | 93 | attach_auth_ticket (mu_mailbox_t mbox) |
129 | { | 94 | { |
... | @@ -185,7 +150,7 @@ checkmail (const char *username, int personal) | ... | @@ -185,7 +150,7 @@ checkmail (const char *username, int personal) |
185 | { | 150 | { |
186 | static mu_url_t pop_hint; | 151 | static mu_url_t pop_hint; |
187 | 152 | ||
188 | if (pop_hint) | 153 | if (!pop_hint) |
189 | { | 154 | { |
190 | rc = mu_url_create (&pop_hint, "pop://"); | 155 | rc = mu_url_create (&pop_hint, "pop://"); |
191 | if (rc) | 156 | if (rc) |
... | @@ -382,17 +347,11 @@ checkmail (const char *username, int personal) | ... | @@ -382,17 +347,11 @@ checkmail (const char *username, int personal) |
382 | int | 347 | int |
383 | main (int argc, char **argv) | 348 | main (int argc, char **argv) |
384 | { | 349 | { |
385 | int index; | ||
386 | int rc = 0; | 350 | int rc = 0; |
387 | 351 | ||
388 | MU_APP_INIT_NLS (); | 352 | MU_APP_INIT_NLS (); |
389 | 353 | ||
390 | mh_argp_init (); | 354 | mh_getopt (&argc, &argv, options, 0, args_doc, prog_doc, NULL); |
391 | mh_argp_parse (&argc, &argv, 0, options, mh_option, args_doc, doc, | ||
392 | opt_handler, NULL, &index); | ||
393 | |||
394 | argc -= index; | ||
395 | argv += index; | ||
396 | 355 | ||
397 | if (argc == 0) | 356 | if (argc == 0) |
398 | { | 357 | { | ... | ... |
This diff is collapsed.
Click to expand it.
... | @@ -56,6 +56,6 @@ struct node | ... | @@ -56,6 +56,6 @@ struct node |
56 | } v; | 56 | } v; |
57 | }; | 57 | }; |
58 | 58 | ||
59 | void pick_add_token (mu_list_t *list, int tok, char *val); | 59 | void pick_add_token (mu_list_t *list, int tok, char const *val); |
60 | int pick_parse (mu_list_t toklist); | 60 | int pick_parse (mu_list_t toklist); |
61 | int pick_eval (mu_message_t msg); | 61 | int pick_eval (mu_message_t msg); | ... | ... |
... | @@ -189,28 +189,28 @@ tokname (int tok) | ... | @@ -189,28 +189,28 @@ tokname (int tok) |
189 | switch (tok) | 189 | switch (tok) |
190 | { | 190 | { |
191 | case T_DATEFIELD: | 191 | case T_DATEFIELD: |
192 | return "--datefield"; | 192 | return "-datefield"; |
193 | 193 | ||
194 | case T_BEFORE: | 194 | case T_BEFORE: |
195 | return "--before"; | 195 | return "-before"; |
196 | 196 | ||
197 | case T_AFTER: | 197 | case T_AFTER: |
198 | return "--after"; | 198 | return "-after"; |
199 | 199 | ||
200 | case T_LBRACE: | 200 | case T_LBRACE: |
201 | return "--lbrace"; | 201 | return "-lbrace"; |
202 | 202 | ||
203 | case T_RBRACE: | 203 | case T_RBRACE: |
204 | return "--rbrace"; | 204 | return "-rbrace"; |
205 | 205 | ||
206 | case T_OR: | 206 | case T_OR: |
207 | return "--or"; | 207 | return "-or"; |
208 | 208 | ||
209 | case T_AND: | 209 | case T_AND: |
210 | return "--and"; | 210 | return "-and"; |
211 | 211 | ||
212 | case T_NOT: | 212 | case T_NOT: |
213 | return "--not"; | 213 | return "-not"; |
214 | } | 214 | } |
215 | return NULL; | 215 | return NULL; |
216 | } | 216 | } |
... | @@ -236,7 +236,7 @@ yyerror (const char *s) | ... | @@ -236,7 +236,7 @@ yyerror (const char *s) |
236 | } | 236 | } |
237 | 237 | ||
238 | void | 238 | void |
239 | pick_add_token (mu_list_t *list, int tok, char *val) | 239 | pick_add_token (mu_list_t *list, int tok, char const *val) |
240 | { | 240 | { |
241 | struct token *tp; | 241 | struct token *tp; |
242 | int rc; | 242 | int rc; | ... | ... |
... | @@ -19,98 +19,33 @@ | ... | @@ -19,98 +19,33 @@ |
19 | #include <mh.h> | 19 | #include <mh.h> |
20 | #include "prompter.h" | 20 | #include "prompter.h" |
21 | 21 | ||
22 | static char doc[] = N_("GNU MH prompter")"\v" | 22 | static char prog_doc[] = N_("GNU MH prompter"); |
23 | N_("Use -help to obtain the list of traditional MH options."); | ||
24 | static char args_doc[] = N_("FILE"); | 23 | static char args_doc[] = N_("FILE"); |
25 | 24 | ||
26 | enum { | ||
27 | ARG_ERASE=256, | ||
28 | ARG_KILL, | ||
29 | ARG_PREPEND, | ||
30 | ARG_NOPREPEND, | ||
31 | ARG_RAPID, | ||
32 | ARG_NORAPID, | ||
33 | ARG_DOTEOF, | ||
34 | ARG_NODOTEOF | ||
35 | }; | ||
36 | |||
37 | static struct argp_option options[] = { | ||
38 | { "erase", ARG_ERASE, N_("CHAR"), 0, | ||
39 | N_("set erase character") }, | ||
40 | { "kill", ARG_KILL, N_("CHAR"), 0, | ||
41 | N_("set kill character") }, | ||
42 | { "prepend", ARG_PREPEND, N_("BOOL"), 0, | ||
43 | N_("prepend user input to the message body") }, | ||
44 | { "noprepend", ARG_NOPREPEND, NULL, OPTION_HIDDEN, | ||
45 | NULL }, | ||
46 | { "rapid", ARG_RAPID, N_("BOOL"), 0, | ||
47 | N_("do not display message body") }, | ||
48 | { "norapid", ARG_NORAPID, NULL, OPTION_HIDDEN, | ||
49 | NULL }, | ||
50 | { "doteof", ARG_DOTEOF, N_("BOOL"), 0, | ||
51 | N_("a period on a line marks end-of-file") }, | ||
52 | { "nodoteof", ARG_NODOTEOF, NULL, OPTION_HIDDEN, | ||
53 | NULL }, | ||
54 | { NULL } | ||
55 | }; | ||
56 | |||
57 | struct mh_option mh_option[] = { | ||
58 | { "erase", MH_OPT_ARG, "chr" }, | ||
59 | { "kill", MH_OPT_ARG, "chr" }, | ||
60 | { "prepend", MH_OPT_BOOL }, | ||
61 | { "rapid", MH_OPT_BOOL }, | ||
62 | { "doteof", MH_OPT_BOOL }, | ||
63 | { NULL } | ||
64 | }; | ||
65 | |||
66 | char *erase_seq; | 25 | char *erase_seq; |
67 | char *kill_seq; | 26 | char *kill_seq; |
68 | int prepend_option; | 27 | int prepend_option; |
69 | int rapid_option; | 28 | int rapid_option; |
70 | int doteof_option; | 29 | int doteof_option; |
71 | 30 | ||
72 | static error_t | 31 | static struct mu_option options[] = { |
73 | opt_handler (int key, char *arg, struct argp_state *state) | 32 | { "erase", 0, N_("CHAR"), MU_OPTION_DEFAULT, |
74 | { | 33 | N_("set erase character"), |
75 | switch (key) | 34 | mu_c_string, &erase_seq }, |
76 | { | 35 | { "kill", 0, N_("CHAR"), MU_OPTION_DEFAULT, |
77 | case ARG_ERASE: | 36 | N_("set kill character"), |
78 | erase_seq = arg; | 37 | mu_c_string, &kill_seq }, |
79 | break; | 38 | { "prepend", 0, NULL, MU_OPTION_DEFAULT, |
80 | 39 | N_("prepend user input to the message body"), | |
81 | case ARG_KILL: | 40 | mu_c_bool, &prepend_option }, |
82 | kill_seq = arg; | 41 | { "rapid", 0, NULL, MU_OPTION_DEFAULT, |
83 | break; | 42 | N_("do not display message body"), |
84 | 43 | mu_c_bool, &rapid_option }, | |
85 | case ARG_PREPEND: | 44 | { "doteof", 0, NULL, MU_OPTION_DEFAULT, |
86 | prepend_option = is_true (arg); | 45 | N_("a period on a line marks end-of-file"), |
87 | break; | 46 | mu_c_bool, &doteof_option }, |
88 | 47 | MU_OPTION_END | |
89 | case ARG_NOPREPEND: | 48 | }; |
90 | prepend_option = 0; | ||
91 | break; | ||
92 | |||
93 | case ARG_RAPID: | ||
94 | rapid_option = is_true (arg); | ||
95 | break; | ||
96 | |||
97 | case ARG_NORAPID: | ||
98 | rapid_option = 0; | ||
99 | break; | ||
100 | |||
101 | case ARG_DOTEOF: | ||
102 | doteof_option = is_true (arg); | ||
103 | break; | ||
104 | |||
105 | case ARG_NODOTEOF: | ||
106 | doteof_option = 0; | ||
107 | break; | ||
108 | |||
109 | default: | ||
110 | return ARGP_ERR_UNKNOWN; | ||
111 | } | ||
112 | return 0; | ||
113 | } | ||
114 | 49 | ||
115 | static int | 50 | static int |
116 | is_empty_string (const char *str) | 51 | is_empty_string (const char *str) |
... | @@ -142,7 +77,6 @@ mu_stream_t strout; | ... | @@ -142,7 +77,6 @@ mu_stream_t strout; |
142 | int | 77 | int |
143 | main (int argc, char **argv) | 78 | main (int argc, char **argv) |
144 | { | 79 | { |
145 | int index; | ||
146 | int rc; | 80 | int rc; |
147 | mu_stream_t in, tmp; | 81 | mu_stream_t in, tmp; |
148 | mu_message_t msg; | 82 | mu_message_t msg; |
... | @@ -156,16 +90,20 @@ main (int argc, char **argv) | ... | @@ -156,16 +90,20 @@ main (int argc, char **argv) |
156 | 90 | ||
157 | MU_APP_INIT_NLS (); | 91 | MU_APP_INIT_NLS (); |
158 | 92 | ||
159 | mh_argp_init (); | 93 | mh_getopt (&argc, &argv, options, 0, args_doc, prog_doc, NULL); |
160 | mh_argp_parse (&argc, &argv, 0, options, mh_option, args_doc, doc, | ||
161 | opt_handler, NULL, &index); | ||
162 | 94 | ||
163 | if (index == argc) | 95 | if (argc == 0) |
164 | { | 96 | { |
165 | mu_error (_("file name not given")); | 97 | mu_error (_("file name not given")); |
166 | exit (1); | 98 | exit (1); |
167 | } | 99 | } |
168 | file = argv[index]; | 100 | else if (argc > 1) |
101 | { | ||
102 | mu_error (_("too many arguments")); | ||
103 | exit (1); | ||
104 | } | ||
105 | |||
106 | file = argv[0]; | ||
169 | 107 | ||
170 | prompter_init (); | 108 | prompter_init (); |
171 | if (erase_seq) | 109 | if (erase_seq) |
... | @@ -186,7 +124,6 @@ main (int argc, char **argv) | ... | @@ -186,7 +124,6 @@ main (int argc, char **argv) |
186 | return 1; | 124 | return 1; |
187 | } | 125 | } |
188 | rc = mu_stream_to_message (in, &msg); | 126 | rc = mu_stream_to_message (in, &msg); |
189 | mu_stream_unref (in); | ||
190 | if (rc) | 127 | if (rc) |
191 | { | 128 | { |
192 | mu_error (_("input stream %s is not a message (%s)"), | 129 | mu_error (_("input stream %s is not a message (%s)"), | ... | ... |
... | @@ -23,39 +23,9 @@ | ... | @@ -23,39 +23,9 @@ |
23 | #include <errno.h> | 23 | #include <errno.h> |
24 | #include <fcntl.h> | 24 | #include <fcntl.h> |
25 | 25 | ||
26 | static char doc[] = N_("GNU MH refile")"\v" | 26 | static char prog_doc[] = N_("GNU MH refile"); |
27 | N_("Options marked with `*' are not yet implemented.\n\ | ||
28 | Use -help to obtain the list of traditional MH options."); | ||
29 | static char args_doc[] = N_("MSGLIST FOLDER [FOLDER...]"); | 27 | static char args_doc[] = N_("MSGLIST FOLDER [FOLDER...]"); |
30 | 28 | ||
31 | /* GNU options */ | ||
32 | static struct argp_option options[] = { | ||
33 | {"folder", ARG_FOLDER, N_("FOLDER"), 0, | ||
34 | N_("specify folder to operate upon")}, | ||
35 | {"draft", ARG_DRAFT, NULL, 0, | ||
36 | N_("use <mh-dir>/draft as the source message")}, | ||
37 | {"copy", ARG_LINK, N_("BOOL"), OPTION_ARG_OPTIONAL, | ||
38 | N_("preserve the source folder copy")}, | ||
39 | {"link", 0, NULL, OPTION_ALIAS, NULL}, | ||
40 | {"preserve", ARG_PRESERVE, N_("BOOL"), OPTION_ARG_OPTIONAL, | ||
41 | N_("* try to preserve message sequence numbers")}, | ||
42 | {"source", ARG_SOURCE, N_("FOLDER"), 0, | ||
43 | N_("specify source folder; it will become the current folder after the program exits")}, | ||
44 | {"src", 0, NULL, OPTION_ALIAS, NULL}, | ||
45 | {"file", ARG_FILE, N_("FILE"), 0, N_("use FILE as the source message")}, | ||
46 | { 0 } | ||
47 | }; | ||
48 | |||
49 | /* Traditional MH options */ | ||
50 | struct mh_option mh_option[] = { | ||
51 | { "file", MH_OPT_ARG, "input-file"}, | ||
52 | { "draft" }, | ||
53 | { "link", MH_OPT_BOOL }, | ||
54 | { "preserve", MH_OPT_BOOL }, | ||
55 | { "src", MH_OPT_ARG, "folder" }, | ||
56 | { NULL } | ||
57 | }; | ||
58 | |||
59 | int link_flag = 0; | 29 | int link_flag = 0; |
60 | int preserve_flag = 0; | 30 | int preserve_flag = 0; |
61 | char *source_file = NULL; | 31 | char *source_file = NULL; |
... | @@ -73,8 +43,39 @@ add_folder (const char *folder) | ... | @@ -73,8 +43,39 @@ add_folder (const char *folder) |
73 | mu_list_append (folder_name_list, mu_strdup (folder)); | 43 | mu_list_append (folder_name_list, mu_strdup (folder)); |
74 | } | 44 | } |
75 | 45 | ||
46 | static void | ||
47 | add_folder_option (struct mu_parseopt *po, struct mu_option *opt, | ||
48 | const char *arg) | ||
49 | { | ||
50 | add_folder (arg); | ||
51 | } | ||
52 | |||
53 | static struct mu_option options[] = { | ||
54 | { "folder", 0, N_("FOLDER"), MU_OPTION_DEFAULT, | ||
55 | N_("specify folder to operate upon"), | ||
56 | mu_c_string, NULL, add_folder_option }, | ||
57 | { "draft", 0, NULL, MU_OPTION_DEFAULT, | ||
58 | N_("use <mh-dir>/draft as the source message"), | ||
59 | mu_c_string, &source_file, NULL, "draft" }, | ||
60 | { "copy", 0, NULL, MU_OPTION_DEFAULT, | ||
61 | N_("preserve the source folder copy"), | ||
62 | mu_c_bool, &link_flag }, | ||
63 | { "link", 0, NULL, MU_OPTION_ALIAS }, | ||
64 | { "preserve", 0, NULL, MU_OPTION_HIDDEN, | ||
65 | N_("try to preserve message sequence numbers"), | ||
66 | mu_c_string, NULL, mh_opt_notimpl_warning }, | ||
67 | { "source", 0, N_("FOLDER"), MU_OPTION_DEFAULT, | ||
68 | N_("specify source folder; it will become the current folder after the program exits"), | ||
69 | mu_c_string, NULL, mh_opt_set_folder }, | ||
70 | { "src", 0, NULL, MU_OPTION_ALIAS }, | ||
71 | { "file", 0, N_("FILE"), MU_OPTION_DEFAULT, | ||
72 | N_("use FILE as the source message"), | ||
73 | mu_c_string, &source_file }, | ||
74 | MU_OPTION_END | ||
75 | }; | ||
76 | |||
76 | void | 77 | void |
77 | open_folders () | 78 | open_folders (void) |
78 | { | 79 | { |
79 | int rc; | 80 | int rc; |
80 | mu_iterator_t itr; | 81 | mu_iterator_t itr; |
... | @@ -139,47 +140,11 @@ _close_folder (void *unused, mu_mailbox_t mbox) | ... | @@ -139,47 +140,11 @@ _close_folder (void *unused, mu_mailbox_t mbox) |
139 | } | 140 | } |
140 | 141 | ||
141 | void | 142 | void |
142 | close_folders () | 143 | close_folders (void) |
143 | { | 144 | { |
144 | enumerate_folders (_close_folder, NULL); | 145 | enumerate_folders (_close_folder, NULL); |
145 | } | 146 | } |
146 | 147 | ||
147 | static int | ||
148 | opt_handler (int key, char *arg, struct argp_state *state) | ||
149 | { | ||
150 | switch (key) | ||
151 | { | ||
152 | case ARG_FOLDER: | ||
153 | add_folder (arg); | ||
154 | break; | ||
155 | |||
156 | case ARG_DRAFT: | ||
157 | source_file = "draft"; | ||
158 | break; | ||
159 | |||
160 | case ARG_LINK: | ||
161 | link_flag = is_true(arg); | ||
162 | break; | ||
163 | |||
164 | case ARG_PRESERVE: | ||
165 | mh_opt_notimpl_warning ("-preserve"); | ||
166 | preserve_flag = is_true(arg); | ||
167 | break; | ||
168 | |||
169 | case ARG_SOURCE: | ||
170 | mh_set_current_folder (arg); | ||
171 | break; | ||
172 | |||
173 | case ARG_FILE: | ||
174 | source_file = arg; | ||
175 | break; | ||
176 | |||
177 | default: | ||
178 | return ARGP_ERR_UNKNOWN; | ||
179 | } | ||
180 | return 0; | ||
181 | } | ||
182 | |||
183 | void | 148 | void |
184 | refile_folder (void *data, mu_mailbox_t mbox) | 149 | refile_folder (void *data, mu_mailbox_t mbox) |
185 | { | 150 | { |
... | @@ -216,7 +181,6 @@ refile_iterator (size_t num, mu_message_t msg, void *data) | ... | @@ -216,7 +181,6 @@ refile_iterator (size_t num, mu_message_t msg, void *data) |
216 | int | 181 | int |
217 | main (int argc, char **argv) | 182 | main (int argc, char **argv) |
218 | { | 183 | { |
219 | int index; | ||
220 | mu_msgset_t msgset; | 184 | mu_msgset_t msgset; |
221 | mu_mailbox_t mbox; | 185 | mu_mailbox_t mbox; |
222 | int status, i, j; | 186 | int status, i, j; |
... | @@ -224,13 +188,7 @@ main (int argc, char **argv) | ... | @@ -224,13 +188,7 @@ main (int argc, char **argv) |
224 | /* Native Language Support */ | 188 | /* Native Language Support */ |
225 | MU_APP_INIT_NLS (); | 189 | MU_APP_INIT_NLS (); |
226 | 190 | ||
227 | mh_argp_init (); | 191 | mh_getopt (&argc, &argv, options, 0, args_doc, prog_doc, NULL); |
228 | mh_argp_parse (&argc, &argv, 0, options, mh_option, args_doc, doc, | ||
229 | opt_handler, NULL, &index); | ||
230 | |||
231 | argc -= index; | ||
232 | argv += index; | ||
233 | |||
234 | /* Collect any surplus folders */ | 192 | /* Collect any surplus folders */ |
235 | for (i = j = 0; i < argc; i++) | 193 | for (i = j = 0; i < argc; i++) |
236 | { | 194 | { | ... | ... |
This diff is collapsed.
Click to expand it.
... | @@ -28,29 +28,9 @@ | ... | @@ -28,29 +28,9 @@ |
28 | 28 | ||
29 | #include <dirent.h> | 29 | #include <dirent.h> |
30 | 30 | ||
31 | static char doc[] = N_("GNU MH rmf")"\v" | 31 | static char prog_doc[] = N_("GNU MH rmf"); |
32 | N_("Use -help to obtain the list of traditional MH options."); | ||
33 | static char args_doc[] = N_("[+FOLDER]"); | 32 | static char args_doc[] = N_("[+FOLDER]"); |
34 | 33 | ||
35 | /* GNU options */ | ||
36 | static struct argp_option options[] = { | ||
37 | {"folder", ARG_FOLDER, N_("FOLDER"), 0, | ||
38 | N_("specify the folder to delete")}, | ||
39 | {"interactive", ARG_INTERACTIVE, N_("BOOL"), OPTION_ARG_OPTIONAL, | ||
40 | N_("interactive mode: ask for confirmation before removing each folder")}, | ||
41 | {"nointeractive", ARG_NOINTERACTIVE, NULL, OPTION_HIDDEN, ""}, | ||
42 | {"recursive", ARG_RECURSIVE, NULL, 0, | ||
43 | N_("recursively delete all subfolders")}, | ||
44 | {"norecursive", ARG_NORECURSIVE, NULL, OPTION_HIDDEN, ""}, | ||
45 | { 0 } | ||
46 | }; | ||
47 | |||
48 | /* Traditional MH options */ | ||
49 | struct mh_option mh_option[] = { | ||
50 | { "interactive", MH_OPT_BOOL }, | ||
51 | { 0 } | ||
52 | }; | ||
53 | |||
54 | int explicit_folder; /* Was the folder explicitly given */ | 34 | int explicit_folder; /* Was the folder explicitly given */ |
55 | int interactive; /* Ask for confirmation before deleting */ | 35 | int interactive; /* Ask for confirmation before deleting */ |
56 | int recursive; /* Recursively process all the sub-directories */ | 36 | int recursive; /* Recursively process all the sub-directories */ |
... | @@ -59,38 +39,26 @@ static char *cur_folder_path; /* Full pathname of the current folder */ | ... | @@ -59,38 +39,26 @@ static char *cur_folder_path; /* Full pathname of the current folder */ |
59 | static char *folder_name; /* Name of the (topmost) folder to be | 39 | static char *folder_name; /* Name of the (topmost) folder to be |
60 | deleted */ | 40 | deleted */ |
61 | 41 | ||
62 | static error_t | 42 | static void |
63 | opt_handler (int key, char *arg, struct argp_state *state) | 43 | set_folder (struct mu_parseopt *po, struct mu_option *opt, char const *arg) |
64 | { | 44 | { |
65 | switch (key) | ||
66 | { | ||
67 | case ARG_FOLDER: | ||
68 | explicit_folder = 1; | 45 | explicit_folder = 1; |
69 | folder_name = arg; | 46 | folder_name = mu_strdup (arg); |
70 | break; | ||
71 | |||
72 | case ARG_INTERACTIVE: | ||
73 | interactive = is_true (arg); | ||
74 | break; | ||
75 | |||
76 | case ARG_NOINTERACTIVE: | ||
77 | interactive = 0; | ||
78 | break; | ||
79 | |||
80 | case ARG_RECURSIVE: | ||
81 | recursive = is_true (arg); | ||
82 | break; | ||
83 | |||
84 | case ARG_NORECURSIVE: | ||
85 | recursive = 0; | ||
86 | break; | ||
87 | |||
88 | default: | ||
89 | return ARGP_ERR_UNKNOWN; | ||
90 | } | ||
91 | return 0; | ||
92 | } | 47 | } |
93 | 48 | ||
49 | static struct mu_option options[] = { | ||
50 | { "folder", 0, N_("FOLDER"), MU_OPTION_DEFAULT, | ||
51 | N_("specify the folder to delete"), | ||
52 | mu_c_string, NULL, set_folder }, | ||
53 | { "interactive", 0, NULL, MU_OPTION_DEFAULT, | ||
54 | N_("interactive mode: ask for confirmation before removing each folder"), | ||
55 | mu_c_bool, &interactive }, | ||
56 | { "recursive", 0, NULL, MU_OPTION_DEFAULT, | ||
57 | N_("recursively delete all subfolders"), | ||
58 | mu_c_bool, &recursive }, | ||
59 | MU_OPTION_END | ||
60 | }; | ||
61 | |||
94 | static char * | 62 | static char * |
95 | current_folder_path (void) | 63 | current_folder_path (void) |
96 | { | 64 | { |
... | @@ -185,9 +153,7 @@ main (int argc, char **argv) | ... | @@ -185,9 +153,7 @@ main (int argc, char **argv) |
185 | /* Native Language Support */ | 153 | /* Native Language Support */ |
186 | MU_APP_INIT_NLS (); | 154 | MU_APP_INIT_NLS (); |
187 | 155 | ||
188 | mh_argp_init (); | 156 | mh_getopt (&argc, &argv, options, 0, args_doc, prog_doc, NULL); |
189 | mh_argp_parse (&argc, &argv, 0, options, mh_option, args_doc, doc, | ||
190 | opt_handler, NULL, NULL); | ||
191 | 157 | ||
192 | cur_folder_path = current_folder_path (); | 158 | cur_folder_path = current_folder_path (); |
193 | 159 | ... | ... |
... | @@ -19,37 +19,9 @@ | ... | @@ -19,37 +19,9 @@ |
19 | 19 | ||
20 | #include <mh.h> | 20 | #include <mh.h> |
21 | 21 | ||
22 | static char doc[] = N_("GNU MH rmm")"\v" | 22 | static char prog_doc[] = N_("GNU MH rmm"); |
23 | N_("Use -help to obtain the list of traditional MH options."); | ||
24 | static char args_doc[] = N_("[+FOLDER] [MSGLIST]"); | 23 | static char args_doc[] = N_("[+FOLDER] [MSGLIST]"); |
25 | 24 | ||
26 | /* GNU options */ | ||
27 | static struct argp_option options[] = { | ||
28 | {"folder", ARG_FOLDER, N_("FOLDER"), 0, | ||
29 | N_("specify folder to operate upon")}, | ||
30 | { 0 } | ||
31 | }; | ||
32 | |||
33 | /* Traditional MH options */ | ||
34 | struct mh_option mh_option[] = { | ||
35 | { NULL } | ||
36 | }; | ||
37 | |||
38 | static error_t | ||
39 | opt_handler (int key, char *arg, struct argp_state *state) | ||
40 | { | ||
41 | switch (key) | ||
42 | { | ||
43 | case ARG_FOLDER: | ||
44 | mh_set_current_folder (arg); | ||
45 | break; | ||
46 | |||
47 | default: | ||
48 | return ARGP_ERR_UNKNOWN; | ||
49 | } | ||
50 | return 0; | ||
51 | } | ||
52 | |||
53 | static int | 25 | static int |
54 | rmm (size_t num, mu_message_t msg, void *data) | 26 | rmm (size_t num, mu_message_t msg, void *data) |
55 | { | 27 | { |
... | @@ -79,7 +51,6 @@ rmseq (const char *name, const char *value, void *data) | ... | @@ -79,7 +51,6 @@ rmseq (const char *name, const char *value, void *data) |
79 | int | 51 | int |
80 | main (int argc, char **argv) | 52 | main (int argc, char **argv) |
81 | { | 53 | { |
82 | int index = 0; | ||
83 | mu_mailbox_t mbox; | 54 | mu_mailbox_t mbox; |
84 | mu_msgset_t msgset; | 55 | mu_msgset_t msgset; |
85 | int status; | 56 | int status; |
... | @@ -88,13 +59,12 @@ main (int argc, char **argv) | ... | @@ -88,13 +59,12 @@ main (int argc, char **argv) |
88 | /* Native Language Support */ | 59 | /* Native Language Support */ |
89 | MU_APP_INIT_NLS (); | 60 | MU_APP_INIT_NLS (); |
90 | 61 | ||
91 | mh_argp_init (); | 62 | mh_getopt (&argc, &argv, NULL, MH_GETOPT_DEFAULT_FOLDER, |
92 | mh_argp_parse (&argc, &argv, 0, options, mh_option, args_doc, doc, | 63 | args_doc, prog_doc, NULL); |
93 | opt_handler, NULL, &index); | ||
94 | 64 | ||
95 | mbox = mh_open_folder (mh_current_folder (), MU_STREAM_RDWR); | 65 | mbox = mh_open_folder (mh_current_folder (), MU_STREAM_RDWR); |
96 | 66 | ||
97 | mh_msgset_parse (&msgset, mbox, argc - index, argv + index, "cur"); | 67 | mh_msgset_parse (&msgset, mbox, argc, argv, "cur"); |
98 | 68 | ||
99 | status = mu_msgset_foreach_message (msgset, rmm, NULL); | 69 | status = mu_msgset_foreach_message (msgset, rmm, NULL); |
100 | 70 | ... | ... |
... | @@ -26,7 +26,7 @@ | ... | @@ -26,7 +26,7 @@ |
26 | #include <time.h> | 26 | #include <time.h> |
27 | #include <mailutils/observer.h> | 27 | #include <mailutils/observer.h> |
28 | 28 | ||
29 | static char progdoc[] = N_("GNU MH scan"); | 29 | static char prog_doc[] = N_("GNU MH scan"); |
30 | static char args_doc[] = N_("[+FOLDER] [MSGLIST]"); | 30 | static char args_doc[] = N_("[+FOLDER] [MSGLIST]"); |
31 | 31 | ||
32 | static int clear; | 32 | static int clear; |
... | @@ -107,7 +107,7 @@ main (int argc, char **argv) | ... | @@ -107,7 +107,7 @@ main (int argc, char **argv) |
107 | MU_APP_INIT_NLS (); | 107 | MU_APP_INIT_NLS (); |
108 | 108 | ||
109 | mh_getopt (&argc, &argv, options, MH_GETOPT_DEFAULT_FOLDER, | 109 | mh_getopt (&argc, &argv, options, MH_GETOPT_DEFAULT_FOLDER, |
110 | args_doc, progdoc, NULL); | 110 | args_doc, prog_doc, NULL); |
111 | 111 | ||
112 | if (mh_format_parse (format_str, &format)) | 112 | if (mh_format_parse (format_str, &format)) |
113 | { | 113 | { | ... | ... |
This diff is collapsed.
Click to expand it.
... | @@ -19,55 +19,9 @@ | ... | @@ -19,55 +19,9 @@ |
19 | 19 | ||
20 | #include <mh.h> | 20 | #include <mh.h> |
21 | 21 | ||
22 | static char doc[] = N_("GNU MH show")"\v" | 22 | static char prog_doc[] = N_("GNU MH show"); |
23 | N_("Use -help to obtain the list of traditional MH options."); | ||
24 | static char args_doc[] = N_("[+FOLDER] [MSGLIST]"); | 23 | static char args_doc[] = N_("[+FOLDER] [MSGLIST]"); |
25 | 24 | ||
26 | #define ARG_PASS ARG_MAX | ||
27 | |||
28 | static struct argp_option options[] = { | ||
29 | {"draft", ARG_DRAFT, NULL, 0, | ||
30 | N_("show the draft file") }, | ||
31 | {"file", ARG_FILE, N_("FILE"), 0, | ||
32 | N_("show this file") }, | ||
33 | {"header", ARG_HEADER, N_("BOOL"), OPTION_ARG_OPTIONAL, | ||
34 | N_("display a description of the message before the message itself") }, | ||
35 | {"noheader", ARG_HEADER, NULL, OPTION_HIDDEN, "" }, | ||
36 | {"showproc", ARG_SHOWPROC, N_("PROGRAM"), 0, | ||
37 | N_("use PROGRAM to show messages")}, | ||
38 | {"noshowproc", ARG_NOSHOWPROC, NULL, 0, | ||
39 | N_("disable the use of the \"showproc:\" profile component") }, | ||
40 | |||
41 | {"form", ARG_FORM, N_("FILE"), 0, | ||
42 | N_("read format from given file")}, | ||
43 | {"moreproc", ARG_MOREPROC, N_("PROG"), 0, | ||
44 | N_("use this PROG as pager"), }, | ||
45 | {"nomoreproc", ARG_NOMOREPROC, NULL, 0, | ||
46 | N_("disable the use of moreproc") }, | ||
47 | {"length", ARG_LENGTH, N_("NUMBER"), 0, | ||
48 | N_("set output screen length")}, | ||
49 | {"width", ARG_WIDTH, N_("NUMBER"), 0, | ||
50 | N_("set output width")}, | ||
51 | |||
52 | {NULL} | ||
53 | }; | ||
54 | |||
55 | /* Traditional MH options */ | ||
56 | struct mh_option mh_option[] = { | ||
57 | { "draft" }, | ||
58 | { "file", MH_OPT_ARG, "file" }, | ||
59 | { "header", MH_OPT_BOOL }, | ||
60 | { "showproc", MH_OPT_ARG, "program" }, | ||
61 | { "noshowproc" }, | ||
62 | { "form", MH_OPT_ARG, "formatfile"}, | ||
63 | { "width", MH_OPT_ARG, "number"}, | ||
64 | { "length", MH_OPT_ARG, "number"}, | ||
65 | { "moreproc", MH_OPT_ARG, "program"}, | ||
66 | { "nomoreproc" }, | ||
67 | |||
68 | { NULL } | ||
69 | }; | ||
70 | |||
71 | int use_draft; | 25 | int use_draft; |
72 | int use_showproc = 1; | 26 | int use_showproc = 1; |
73 | int header_option = 1; | 27 | int header_option = 1; |
... | @@ -101,70 +55,74 @@ insarg (char *arg) | ... | @@ -101,70 +55,74 @@ insarg (char *arg) |
101 | } | 55 | } |
102 | } | 56 | } |
103 | 57 | ||
104 | static const char * | 58 | static void |
105 | findopt (int key) | 59 | set_draft (struct mu_parseopt *po, struct mu_option *opt, char const *arg) |
106 | { | ||
107 | struct argp_option *p; | ||
108 | |||
109 | for (p = options; p->name; p++) | ||
110 | if (p->key == key) | ||
111 | return p->name; | ||
112 | abort (); | ||
113 | } | ||
114 | |||
115 | static error_t | ||
116 | opt_handler (int key, char *arg, struct argp_state *state) | ||
117 | { | 60 | { |
118 | switch (key) | ||
119 | { | ||
120 | case ARG_FOLDER: | ||
121 | mh_set_current_folder (arg); | ||
122 | break; | ||
123 | |||
124 | case ARG_DRAFT: | ||
125 | if (use_draft || file) | 61 | if (use_draft || file) |
126 | argp_error (state, _("only one file at a time!")); | 62 | { |
63 | mu_parseopt_error (po, _("only one file at a time!")); | ||
64 | exit (po->po_exit_error); | ||
65 | } | ||
127 | use_draft = 1; | 66 | use_draft = 1; |
128 | break; | 67 | } |
129 | 68 | ||
130 | case ARG_FILE: | 69 | static void |
70 | set_file (struct mu_parseopt *po, struct mu_option *opt, char const *arg) | ||
71 | { | ||
131 | if (use_draft || file) | 72 | if (use_draft || file) |
132 | argp_error (state, _("only one file at a time!")); | 73 | { |
74 | mu_parseopt_error (po, _("only one file at a time!")); | ||
75 | exit (po->po_exit_error); | ||
76 | } | ||
133 | file = mh_expand_name (NULL, arg, NAME_FILE); | 77 | file = mh_expand_name (NULL, arg, NAME_FILE); |
134 | break; | 78 | } |
135 | 79 | ||
136 | case ARG_HEADER: | 80 | static void |
137 | header_option = is_true (arg); | 81 | add_show_arg (struct mu_parseopt *po, struct mu_option *opt, char const *arg) |
138 | break; | 82 | { |
139 | 83 | char *name = mu_alloc (strlen (opt->opt_long) + 2); | |
140 | case ARG_NOHEADER: | 84 | name[0] = '-'; |
141 | header_option = 0; | 85 | strcpy (name + 1, opt->opt_long); |
142 | break; | 86 | addarg (name); |
143 | |||
144 | case ARG_SHOWPROC: | ||
145 | showproc = arg; | ||
146 | break; | ||
147 | |||
148 | case ARG_NOSHOWPROC: | ||
149 | use_showproc = 0; | ||
150 | break; | ||
151 | |||
152 | case ARG_NOMOREPROC: | ||
153 | case ARG_FORM: | ||
154 | case ARG_MOREPROC: | ||
155 | case ARG_LENGTH: | ||
156 | case ARG_WIDTH: | ||
157 | addarg (findopt (key)); | ||
158 | if (arg) | 87 | if (arg) |
159 | addarg (arg); | 88 | addarg (arg); |
160 | break; | ||
161 | |||
162 | default: | ||
163 | return ARGP_ERR_UNKNOWN; | ||
164 | } | ||
165 | return 0; | ||
166 | } | 89 | } |
167 | 90 | ||
91 | static struct mu_option options[] = { | ||
92 | { "draft", 0, NULL, MU_OPTION_DEFAULT, | ||
93 | N_("show the draft file"), | ||
94 | mu_c_string, NULL, set_draft }, | ||
95 | { "file", 0, N_("FILE"), MU_OPTION_DEFAULT, | ||
96 | N_("show this file"), | ||
97 | mu_c_string, NULL, set_file }, | ||
98 | { "header", 0, NULL, MU_OPTION_DEFAULT, | ||
99 | N_("display a description of the message before the message itself"), | ||
100 | mu_c_bool, &header_option }, | ||
101 | { "showproc", 0, N_("PROGRAM"), MU_OPTION_DEFAULT, | ||
102 | N_("use PROGRAM to show messages"), | ||
103 | mu_c_string, &showproc }, | ||
104 | { "noshowproc", 0, NULL, MU_OPTION_DEFAULT, | ||
105 | N_("disable the use of the \"showproc:\" profile component"), | ||
106 | mu_c_int, &use_showproc, NULL, "0" }, | ||
107 | { "form", 0, N_("FILE"), MU_OPTION_DEFAULT, | ||
108 | N_("read format from given file"), | ||
109 | mu_c_string, NULL, add_show_arg }, | ||
110 | { "moreproc", 0, N_("PROG"), MU_OPTION_DEFAULT, | ||
111 | N_("use this PROG as pager"), | ||
112 | mu_c_string, NULL, add_show_arg }, | ||
113 | { "nomoreproc", 0, NULL, MU_OPTION_DEFAULT, | ||
114 | N_("disable the use of moreproc"), | ||
115 | mu_c_string, NULL, add_show_arg }, | ||
116 | { "length", 0, N_("NUMBER"), MU_OPTION_DEFAULT, | ||
117 | N_("set output screen length"), | ||
118 | mu_c_string, NULL, add_show_arg }, | ||
119 | { "width", 0, N_("NUMBER"), MU_OPTION_DEFAULT, | ||
120 | N_("set output width"), | ||
121 | mu_c_string, NULL, add_show_arg }, | ||
122 | |||
123 | MU_OPTION_END | ||
124 | }; | ||
125 | |||
168 | static int | 126 | static int |
169 | resolve_mime (size_t num, mu_message_t msg, void *data) | 127 | resolve_mime (size_t num, mu_message_t msg, void *data) |
170 | { | 128 | { |
... | @@ -222,7 +180,6 @@ checkfile (char *file) | ... | @@ -222,7 +180,6 @@ checkfile (char *file) |
222 | int | 180 | int |
223 | main (int argc, char **argv) | 181 | main (int argc, char **argv) |
224 | { | 182 | { |
225 | int index = 0; | ||
226 | mu_mailbox_t mbox; | 183 | mu_mailbox_t mbox; |
227 | mu_msgset_t msgset; | 184 | mu_msgset_t msgset; |
228 | const char *p; | 185 | const char *p; |
... | @@ -234,13 +191,11 @@ main (int argc, char **argv) | ... | @@ -234,13 +191,11 @@ main (int argc, char **argv) |
234 | showargc = 1; | 191 | showargc = 1; |
235 | showargv = mu_calloc (showargmax, sizeof showargv[0]); | 192 | showargv = mu_calloc (showargmax, sizeof showargv[0]); |
236 | 193 | ||
237 | mh_argp_init (); | 194 | mh_getopt (&argc, &argv, options, MH_GETOPT_DEFAULT_FOLDER, |
238 | mh_argp_parse (&argc, &argv, 0, options, mh_option, args_doc, doc, | 195 | args_doc, prog_doc, NULL); |
239 | opt_handler, NULL, &index); | 196 | |
240 | mbox = mh_open_folder (mh_current_folder (), MU_STREAM_RDWR); | ||
241 | 197 | ||
242 | argc -= index; | 198 | mbox = mh_open_folder (mh_current_folder (), MU_STREAM_RDWR); |
243 | argv += index; | ||
244 | 199 | ||
245 | if (use_draft || file) | 200 | if (use_draft || file) |
246 | { | 201 | { | ... | ... |
... | @@ -22,72 +22,10 @@ | ... | @@ -22,72 +22,10 @@ |
22 | #include <unistd.h> | 22 | #include <unistd.h> |
23 | #include <signal.h> | 23 | #include <signal.h> |
24 | 24 | ||
25 | static char doc[] = N_("GNU MH sortm")"\v" | 25 | static char prog_doc[] = N_("GNU MH sortm")"\v" |
26 | N_("Use -help to obtain the list of traditional MH options."); | 26 | N_("Use -help to obtain the list of traditional MH options."); |
27 | static char args_doc[] = N_("[MSGLIST]"); | 27 | static char args_doc[] = N_("[MSGLIST]"); |
28 | 28 | ||
29 | #define ARG_QUICKSORT 1024 | ||
30 | #define ARG_SHELL 1025 | ||
31 | |||
32 | /* GNU options */ | ||
33 | static struct argp_option options[] = { | ||
34 | {"folder", ARG_FOLDER, N_("FOLDER"), 0, | ||
35 | N_("specify folder to operate upon")}, | ||
36 | |||
37 | {N_("Setting sort keys:"), 0, NULL, OPTION_DOC, NULL, 0}, | ||
38 | {"datefield", ARG_DATEFIELD, N_("STRING"), 0, | ||
39 | N_("sort on the date field (default `Date:')"), 10}, | ||
40 | {"nodatefield", ARG_NODATEFIELD, NULL, 0, | ||
41 | N_("undo the effect of the last --datefield option"), 10}, | ||
42 | {"limit", ARG_LIMIT, N_("DAYS"), 0, | ||
43 | N_("consider two datefields equal if their difference lies within the given nuber of DAYS."), 11}, | ||
44 | {"nolimit", ARG_NOLIMIT, NULL, 0, | ||
45 | N_("undo the effect of the last --limit option"), 11}, | ||
46 | {"textfield", ARG_TEXTFIELD, N_("STRING"), 0, | ||
47 | N_("sort on the text field"), 15}, | ||
48 | {"notextfield", ARG_NOTEXTFIELD, NULL, 0, | ||
49 | N_("undo the effect of the last --textfield option"), 15}, | ||
50 | {"numfield", ARG_NUMFIELD, N_("STRING"), 0, | ||
51 | N_("sort on the numeric field"), 16}, | ||
52 | |||
53 | {N_("Actions:"), 0, NULL, OPTION_DOC, NULL, 16}, | ||
54 | {"reorder", ARG_REORDER, 0, 0, | ||
55 | N_("reorder the messages (default)"), 20 }, | ||
56 | {"dry-run", ARG_DRY_RUN, 0, 0, | ||
57 | N_("do not do anything, only show what would have been done"), 20 }, | ||
58 | {"list", ARG_LIST, 0, 0, | ||
59 | N_("list the sorted messages"), 20 }, | ||
60 | {"form", ARG_FORM, N_("FILE"), 0, | ||
61 | N_("read format from given file"), 23}, | ||
62 | {"format", ARG_FORMAT, N_("FORMAT"), 0, | ||
63 | N_("use this format string"), 23}, | ||
64 | |||
65 | {"verbose", ARG_VERBOSE, N_("BOOL"), OPTION_ARG_OPTIONAL, | ||
66 | N_("verbosely list executed actions"), 30 }, | ||
67 | {"noverbose", ARG_NOVERBOSE, NULL, OPTION_HIDDEN, "" }, | ||
68 | |||
69 | {N_("Select sort algorithm:"), 0, NULL, OPTION_DOC, NULL, 30}, | ||
70 | |||
71 | {"shell", ARG_SHELL, 0, 0, | ||
72 | N_("use shell algorithm"), 40 }, | ||
73 | {"quicksort", ARG_QUICKSORT, 0, 0, | ||
74 | N_("use quicksort algorithm (default)"), 40 }, | ||
75 | |||
76 | { NULL }, | ||
77 | }; | ||
78 | |||
79 | /* Traditional MH options */ | ||
80 | struct mh_option mh_option[] = { | ||
81 | { "datefield", MH_OPT_ARG, "field" }, | ||
82 | { "nodatefield" }, | ||
83 | { "textfield", MH_OPT_ARG, "field" }, | ||
84 | { "notextfield" }, | ||
85 | { "limit", MH_OPT_ARG, "days" }, | ||
86 | { "nolimit" }, | ||
87 | { "verbose", MH_OPT_BOOL }, | ||
88 | { NULL }, | ||
89 | }; | ||
90 | |||
91 | static int limit; | 29 | static int limit; |
92 | static int verbose; | 30 | static int verbose; |
93 | static mu_mailbox_t mbox; | 31 | static mu_mailbox_t mbox; |
... | @@ -98,115 +36,175 @@ static size_t msgcount; | ... | @@ -98,115 +36,175 @@ static size_t msgcount; |
98 | 36 | ||
99 | static size_t current_num; | 37 | static size_t current_num; |
100 | 38 | ||
101 | #define ACTION_REORDER 0 | 39 | enum |
102 | #define ACTION_DRY_RUN 1 | 40 | { |
103 | #define ACTION_LIST 2 | 41 | ACTION_REORDER, |
42 | ACTION_DRY_RUN, | ||
43 | ACTION_LIST | ||
44 | }; | ||
104 | 45 | ||
105 | static int algorithm = ARG_QUICKSORT; | 46 | enum |
47 | { | ||
48 | algo_quicksort, | ||
49 | algo_shell | ||
50 | }; | ||
51 | static int algorithm = algo_quicksort; | ||
106 | static int action = ACTION_REORDER; | 52 | static int action = ACTION_REORDER; |
107 | static char *format_str = mh_list_format; | 53 | static char *format_str = mh_list_format; |
108 | static mh_format_t format; | 54 | static mh_format_t format; |
109 | 55 | ||
110 | typedef int (*compfun) (void *, void *); | 56 | typedef int (*compfun) (void *, void *); |
111 | static void addop (char *field, compfun comp); | 57 | static void addop (char const *field, compfun comp); |
112 | static void remop (compfun comp); | 58 | static void remop (compfun comp); |
113 | static int comp_text (void *a, void *b); | 59 | static int comp_text (void *a, void *b); |
114 | static int comp_date (void *a, void *b); | 60 | static int comp_date (void *a, void *b); |
115 | static int comp_number (void *a, void *b); | 61 | static int comp_number (void *a, void *b); |
116 | 62 | ||
117 | static error_t | 63 | static void |
118 | opt_handler (int key, char *arg, struct argp_state *state) | 64 | add_datefield (struct mu_parseopt *po, struct mu_option *opt, char const *arg) |
119 | { | 65 | { |
120 | switch (key) | ||
121 | { | ||
122 | case ARG_FOLDER: | ||
123 | mh_set_current_folder (arg); | ||
124 | break; | ||
125 | |||
126 | case ARG_DATEFIELD: | ||
127 | addop (arg, comp_date); | 66 | addop (arg, comp_date); |
128 | break; | 67 | } |
129 | 68 | ||
130 | case ARG_NUMFIELD: | 69 | static void |
70 | add_numfield (struct mu_parseopt *po, struct mu_option *opt, char const *arg) | ||
71 | { | ||
131 | addop (arg, comp_number); | 72 | addop (arg, comp_number); |
132 | break; | 73 | } |
133 | |||
134 | case ARG_NODATEFIELD: | ||
135 | remop (comp_date); | ||
136 | break; | ||
137 | 74 | ||
138 | case ARG_TEXTFIELD: | 75 | static void |
76 | add_textfield (struct mu_parseopt *po, struct mu_option *opt, char const *arg) | ||
77 | { | ||
139 | addop (arg, comp_text); | 78 | addop (arg, comp_text); |
140 | break; | 79 | } |
141 | |||
142 | case ARG_NOTEXTFIELD: | ||
143 | remop (comp_text); | ||
144 | break; | ||
145 | |||
146 | case ARG_LIMIT: | ||
147 | limit = strtoul (arg, NULL, 0); | ||
148 | break; | ||
149 | |||
150 | case ARG_NOLIMIT: | ||
151 | limit = -1; | ||
152 | break; | ||
153 | |||
154 | case ARG_VERBOSE: | ||
155 | if (!arg || mu_isalpha (arg[0])) | ||
156 | verbose = is_true (arg); | ||
157 | else | ||
158 | verbose = arg[0] - '0'; | ||
159 | break; | ||
160 | 80 | ||
161 | case ARG_NOVERBOSE: | 81 | static void |
162 | verbose = 0; | 82 | rem_datefield (struct mu_parseopt *po, struct mu_option *opt, char const *arg) |
163 | break; | 83 | { |
84 | remop (comp_date); | ||
85 | } | ||
164 | 86 | ||
165 | case ARG_FORM: | 87 | static void |
166 | mh_read_formfile (arg, &format_str); | 88 | rem_numfield (struct mu_parseopt *po, struct mu_option *opt, char const *arg) |
167 | break; | 89 | { |
90 | remop (comp_number); | ||
91 | } | ||
168 | 92 | ||
169 | case ARG_FORMAT: | 93 | static void |
170 | format_str = arg; | 94 | rem_textfield (struct mu_parseopt *po, struct mu_option *opt, char const *arg) |
171 | break; | 95 | { |
96 | remop (comp_text); | ||
97 | } | ||
172 | 98 | ||
173 | case ARG_REORDER: | 99 | static void |
100 | set_action_reorder (struct mu_parseopt *po, struct mu_option *opt, | ||
101 | char const *arg) | ||
102 | { | ||
174 | action = ACTION_REORDER; | 103 | action = ACTION_REORDER; |
175 | break; | 104 | } |
176 | 105 | ||
177 | case ARG_LIST: | 106 | static void |
107 | set_action_list (struct mu_parseopt *po, struct mu_option *opt, | ||
108 | char const *arg) | ||
109 | { | ||
178 | action = ACTION_LIST; | 110 | action = ACTION_LIST; |
179 | break; | 111 | } |
180 | 112 | ||
181 | case ARG_DRY_RUN: | 113 | static void |
114 | set_action_dry_run (struct mu_parseopt *po, struct mu_option *opt, | ||
115 | char const *arg) | ||
116 | { | ||
182 | action = ACTION_DRY_RUN; | 117 | action = ACTION_DRY_RUN; |
183 | if (!verbose) | 118 | if (!verbose) |
184 | verbose = 1; | 119 | verbose = 1; |
185 | break; | 120 | } |
186 | 121 | ||
187 | case ARG_SHELL: | 122 | static void |
188 | case ARG_QUICKSORT: | 123 | set_algo_shell (struct mu_parseopt *po, struct mu_option *opt, |
189 | algorithm = key; | 124 | char const *arg) |
190 | break; | 125 | { |
126 | algorithm = algo_shell; | ||
127 | } | ||
191 | 128 | ||
192 | default: | 129 | static void |
193 | return ARGP_ERR_UNKNOWN; | 130 | set_algo_quicksort (struct mu_parseopt *po, struct mu_option *opt, |
194 | } | 131 | char const *arg) |
195 | return 0; | 132 | { |
133 | algorithm = algo_quicksort; | ||
196 | } | 134 | } |
197 | 135 | ||
136 | static struct mu_option options[] = { | ||
137 | MU_OPTION_GROUP (N_("Setting sort keys:")), | ||
138 | { "datefield", 0, N_("STRING"), MU_OPTION_DEFAULT, | ||
139 | N_("sort on the date field (default `Date:')"), | ||
140 | mu_c_string, NULL, add_datefield }, | ||
141 | { "nodatefield", 0, NULL, MU_OPTION_DEFAULT, | ||
142 | N_("don't sort on the date field"), | ||
143 | mu_c_string, NULL, rem_datefield }, | ||
144 | { "limit", 0, N_("DAYS"), MU_OPTION_DEFAULT, | ||
145 | N_("consider two datefields equal if their difference lies within the given nuber of DAYS."), | ||
146 | mu_c_int, &limit }, | ||
147 | { "nolimit", 0, NULL, MU_OPTION_DEFAULT, | ||
148 | N_("undo the effect of the last -limit option"), | ||
149 | mu_c_int, &limit, NULL, "-1" }, | ||
150 | { "textfield", 0, N_("STRING"), MU_OPTION_DEFAULT, | ||
151 | N_("sort on the text field"), | ||
152 | mu_c_string, NULL, add_textfield }, | ||
153 | { "notextfield", 0, NULL, MU_OPTION_DEFAULT, | ||
154 | N_("don't sort on the text field"), | ||
155 | mu_c_string, NULL, rem_textfield }, | ||
156 | { "numfield", 0, N_("STRING"), MU_OPTION_DEFAULT, | ||
157 | N_("sort on the numeric field"), | ||
158 | mu_c_string, NULL, add_numfield }, | ||
159 | { "nonumfield", 0, NULL, MU_OPTION_DEFAULT, | ||
160 | N_("don't sort on the numeric field"), | ||
161 | mu_c_string, NULL, rem_numfield }, | ||
162 | |||
163 | MU_OPTION_GROUP (N_("Actions:")), | ||
164 | { "reorder", 0, NULL, MU_OPTION_DEFAULT, | ||
165 | N_("reorder the messages (default)"), | ||
166 | mu_c_string, NULL, set_action_reorder }, | ||
167 | { "dry-run", 0, NULL, MU_OPTION_DEFAULT, | ||
168 | N_("do not do anything, only show what would have been done"), | ||
169 | mu_c_string, NULL, set_action_dry_run }, | ||
170 | { "list", 0, NULL, MU_OPTION_DEFAULT, | ||
171 | N_("list the sorted messages"), | ||
172 | mu_c_string, NULL, set_action_list }, | ||
173 | |||
174 | { "form", 0, N_("FILE"), MU_OPTION_DEFAULT, | ||
175 | N_("read format from given file"), | ||
176 | mu_c_string, &format_str, mh_opt_read_formfile }, | ||
177 | { "format", 0, N_("FORMAT"), MU_OPTION_DEFAULT, | ||
178 | N_("use this format string"), | ||
179 | mu_c_string, &format_str }, | ||
180 | |||
181 | { "verbose", 0, NULL, MU_OPTION_DEFAULT, | ||
182 | N_("verbosely list executed actions"), | ||
183 | mu_c_bool, &verbose }, | ||
184 | |||
185 | MU_OPTION_GROUP (N_("Select sort algorithm:")), | ||
186 | { "shell", 0, NULL, MU_OPTION_DEFAULT, | ||
187 | N_("use shell algorithm"), | ||
188 | mu_c_string, NULL, set_algo_shell }, | ||
189 | |||
190 | { "quicksort", 0, NULL, MU_OPTION_DEFAULT, | ||
191 | N_("use quicksort algorithm (default)"), | ||
192 | mu_c_string, NULL, set_algo_quicksort }, | ||
193 | |||
194 | MU_OPTION_END | ||
195 | }; | ||
198 | 196 | ||
199 | /* *********************** Comparison functions **************************** */ | 197 | /* *********************** Comparison functions **************************** */ |
200 | struct comp_op | 198 | struct comp_op |
201 | { | 199 | { |
202 | char *field; | 200 | char const *field; |
203 | compfun comp; | 201 | compfun comp; |
204 | }; | 202 | }; |
205 | 203 | ||
206 | static mu_list_t oplist; | 204 | static mu_list_t oplist; |
207 | 205 | ||
208 | static void | 206 | static void |
209 | addop (char *field, compfun comp) | 207 | addop (char const *field, compfun comp) |
210 | { | 208 | { |
211 | struct comp_op *op = mu_alloc (sizeof (*op)); | 209 | struct comp_op *op = mu_alloc (sizeof (*op)); |
212 | 210 | ||
... | @@ -497,11 +495,11 @@ sort () | ... | @@ -497,11 +495,11 @@ sort () |
497 | 495 | ||
498 | switch (algorithm) | 496 | switch (algorithm) |
499 | { | 497 | { |
500 | case ARG_QUICKSORT: | 498 | case algo_quicksort: |
501 | qsort (msgarr, msgcount, sizeof (msgarr[0]), comp); | 499 | qsort (msgarr, msgcount, sizeof (msgarr[0]), comp); |
502 | break; | 500 | break; |
503 | 501 | ||
504 | case ARG_SHELL: | 502 | case algo_shell: |
505 | shell_sort (); | 503 | shell_sort (); |
506 | break; | 504 | break; |
507 | } | 505 | } |
... | @@ -599,19 +597,17 @@ fill_msgarr (mu_msgset_t msgset) | ... | @@ -599,19 +597,17 @@ fill_msgarr (mu_msgset_t msgset) |
599 | } | 597 | } |
600 | 598 | ||
601 | 599 | ||
602 | /* Main */ | ||
603 | |||
604 | int | 600 | int |
605 | main (int argc, char **argv) | 601 | main (int argc, char **argv) |
606 | { | 602 | { |
607 | int index; | ||
608 | mu_url_t url; | 603 | mu_url_t url; |
609 | mu_msgset_t msgset; | 604 | mu_msgset_t msgset; |
610 | 605 | ||
611 | MU_APP_INIT_NLS (); | 606 | MU_APP_INIT_NLS (); |
612 | mh_argp_init (); | 607 | |
613 | mh_argp_parse (&argc, &argv, 0, options, mh_option, | 608 | mh_getopt (&argc, &argv, options, MH_GETOPT_DEFAULT_FOLDER, |
614 | args_doc, doc, opt_handler, NULL, &index); | 609 | args_doc, prog_doc, NULL); |
610 | |||
615 | if (!oplist) | 611 | if (!oplist) |
616 | addop ("date", comp_date); | 612 | addop ("date", comp_date); |
617 | 613 | ||
... | @@ -627,9 +623,6 @@ main (int argc, char **argv) | ... | @@ -627,9 +623,6 @@ main (int argc, char **argv) |
627 | if (memcmp (mbox_path, "mh:", 3) == 0) | 623 | if (memcmp (mbox_path, "mh:", 3) == 0) |
628 | mbox_path += 3; | 624 | mbox_path += 3; |
629 | 625 | ||
630 | argc -= index; | ||
631 | argv += index; | ||
632 | |||
633 | mh_mailbox_get_cur (mbox, ¤t_num); | 626 | mh_mailbox_get_cur (mbox, ¤t_num); |
634 | 627 | ||
635 | mh_msgset_parse (&msgset, mbox, argc, argv, "all"); | 628 | mh_msgset_parse (&msgset, mbox, argc, argv, "all"); | ... | ... |
... | @@ -53,11 +53,11 @@ Mail/inbox/5 | ... | @@ -53,11 +53,11 @@ Mail/inbox/5 |
53 | Mail/inbox/6 | 53 | Mail/inbox/6 |
54 | ]) | 54 | ]) |
55 | 55 | ||
56 | MH_CHECK([refile --copy],[refile02 refile--copy],[ | 56 | MH_CHECK([refile -copy],[refile02 refile-copy],[ |
57 | MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox]) | 57 | MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox]) |
58 | MUT_MBCOPY($abs_top_srcdir/testsuite/mh/teaparty,[Mail/teaparty]) | 58 | MUT_MBCOPY($abs_top_srcdir/testsuite/mh/teaparty,[Mail/teaparty]) |
59 | echo 'Current-Folder: teaparty' > Mail/context | 59 | echo 'Current-Folder: teaparty' > Mail/context |
60 | refile --copy 3 4 +inbox || exit $? | 60 | refile -copy 3 4 +inbox || exit $? |
61 | find Mail/inbox -name '[[0-9]]' | sort | 61 | find Mail/inbox -name '[[0-9]]' | sort |
62 | cmp Mail/inbox/6 Mail/teaparty/3 >/dev/null || echo "Message 3 differs" | 62 | cmp Mail/inbox/6 Mail/teaparty/3 >/dev/null || echo "Message 3 differs" |
63 | cmp Mail/inbox/7 Mail/teaparty/4 >/dev/null || echo "Message 4 differs" | 63 | cmp Mail/inbox/7 Mail/teaparty/4 >/dev/null || echo "Message 4 differs" | ... | ... |
... | @@ -19,88 +19,45 @@ | ... | @@ -19,88 +19,45 @@ |
19 | 19 | ||
20 | #include <mh.h> | 20 | #include <mh.h> |
21 | 21 | ||
22 | static char doc[] = "GNU MH whatnow"; | 22 | static char prog_doc[] = "GNU MH whatnow"; |
23 | static char args_doc[] = N_("[FILE]"); | 23 | static char args_doc[] = N_("[FILE]"); |
24 | 24 | ||
25 | /* GNU options */ | ||
26 | static struct argp_option options[] = { | ||
27 | {"draftfolder", ARG_DRAFTFOLDER, N_("FOLDER"), 0, | ||
28 | N_("specify the folder for message drafts")}, | ||
29 | {"nodraftfolder", ARG_NODRAFTFOLDER, 0, 0, | ||
30 | N_("undo the effect of the last --draftfolder option")}, | ||
31 | {"draftmessage" , ARG_DRAFTMESSAGE, N_("MSG"), 0, | ||
32 | N_("invoke the draftmessage facility")}, | ||
33 | {"editor", ARG_EDITOR, N_("PROG"), 0, N_("set the editor program to use")}, | ||
34 | {"noedit", ARG_NOEDIT, 0, 0, N_("suppress the initial edit")}, | ||
35 | {"prompt", ARG_PROMPT, N_("STRING"), 0, N_("set the prompt")}, | ||
36 | |||
37 | { NULL } | ||
38 | }; | ||
39 | |||
40 | /* Traditional MH options */ | ||
41 | struct mh_option mh_option[] = { | ||
42 | { "draftfolder", MH_OPT_ARG, "folder" }, | ||
43 | { "nodraftfolder" }, | ||
44 | { "draftmessage" }, | ||
45 | { "editor", MH_OPT_ARG, "program" }, | ||
46 | { "noedit" }, | ||
47 | { "prompt" }, | ||
48 | { NULL } | ||
49 | }; | ||
50 | |||
51 | struct mh_whatnow_env wh_env = { 0 }; | 25 | struct mh_whatnow_env wh_env = { 0 }; |
52 | static int initial_edit = 1; | 26 | static int initial_edit = 1; |
53 | static char *draftmessage = "cur"; | 27 | static char *draftmessage = "cur"; |
54 | static const char *draftfolder = NULL; | 28 | static const char *draftfolder = NULL; |
55 | 29 | ||
56 | static error_t | 30 | static struct mu_option options[] = { |
57 | opt_handler (int key, char *arg, struct argp_state *state) | 31 | { "draftfolder", 0, N_("FOLDER"), MU_OPTION_DEFAULT, |
58 | { | 32 | N_("specify the folder for message drafts"), |
59 | switch (key) | 33 | mu_c_string, &draftfolder }, |
60 | { | 34 | { "nodraftfolder", 0, NULL, MU_OPTION_DEFAULT, |
61 | case ARG_DRAFTFOLDER: | 35 | N_("undo the effect of the last -draftfolder option"), |
62 | draftfolder = arg; | 36 | mu_c_string, &draftfolder, mh_opt_clear_string }, |
63 | break; | 37 | { "draftmessage" , 0, N_("MSG"), MU_OPTION_DEFAULT, |
64 | 38 | N_("invoke the draftmessage facility"), | |
65 | case ARG_EDITOR: | 39 | mu_c_string, &draftmessage }, |
66 | wh_env.editor = arg; | 40 | { "editor", 0, N_("PROG"), MU_OPTION_DEFAULT, |
67 | break; | 41 | N_("set the editor program to use"), |
68 | 42 | mu_c_string, &wh_env.editor }, | |
69 | case ARG_NODRAFTFOLDER: | 43 | { "noedit", 0, NULL, MU_OPTION_DEFAULT, |
70 | draftfolder = NULL; | 44 | N_("suppress the initial edit"), |
71 | break; | 45 | mu_c_int, &initial_edit, NULL, "0" }, |
72 | 46 | { "prompt", 0, N_("STRING"), MU_OPTION_DEFAULT, | |
73 | case ARG_NOEDIT: | 47 | N_("set the prompt"), |
74 | initial_edit = 0; | 48 | mu_c_string, &wh_env.prompt }, |
75 | break; | 49 | MU_OPTION_END |
76 | 50 | }; | |
77 | case ARG_DRAFTMESSAGE: | ||
78 | draftmessage = arg; | ||
79 | break; | ||
80 | |||
81 | case ARG_PROMPT: | ||
82 | wh_env.prompt = arg; | ||
83 | break; | ||
84 | |||
85 | default: | ||
86 | return ARGP_ERR_UNKNOWN; | ||
87 | } | ||
88 | return 0; | ||
89 | } | ||
90 | 51 | ||
91 | int | 52 | int |
92 | main (int argc, char **argv) | 53 | main (int argc, char **argv) |
93 | { | 54 | { |
94 | int index; | ||
95 | |||
96 | MU_APP_INIT_NLS (); | 55 | MU_APP_INIT_NLS (); |
97 | 56 | ||
98 | mh_argp_init (); | ||
99 | mh_whatnow_env_from_environ (&wh_env); | 57 | mh_whatnow_env_from_environ (&wh_env); |
100 | mh_argp_parse (&argc, &argv, 0, options, mh_option, args_doc, doc, | 58 | |
101 | opt_handler, NULL, &index); | 59 | mh_getopt (&argc, &argv, options, 0, args_doc, prog_doc, NULL); |
102 | argc -= index; | 60 | |
103 | argv += index; | ||
104 | if (argc) | 61 | if (argc) |
105 | wh_env.draftfile = argv[0]; | 62 | wh_env.draftfile = argv[0]; |
106 | else if (draftfolder) | 63 | else if (draftfolder) | ... | ... |
... | @@ -17,99 +17,58 @@ | ... | @@ -17,99 +17,58 @@ |
17 | 17 | ||
18 | #include <mh.h> | 18 | #include <mh.h> |
19 | 19 | ||
20 | static char doc[] = N_("GNU MH whom")"\v" | 20 | static char prog_doc[] = N_("GNU MH whom"); |
21 | N_("Use -help to obtain the list of traditional MH options."); | ||
22 | static char args_doc[] = "[FILE]"; | 21 | static char args_doc[] = "[FILE]"; |
23 | 22 | ||
24 | /* GNU options */ | ||
25 | static struct argp_option options[] = { | ||
26 | {"alias", ARG_ALIAS, N_("FILE"), 0, | ||
27 | N_("specify additional alias file") }, | ||
28 | {"draft", ARG_DRAFT, NULL, 0, | ||
29 | N_("use prepared draft") }, | ||
30 | {"draftfolder", ARG_DRAFTFOLDER, N_("FOLDER"), 0, | ||
31 | N_("specify the folder for message drafts") }, | ||
32 | {"draftmessage", ARG_DRAFTMESSAGE, NULL, 0, | ||
33 | N_("treat the arguments as a list of messages from the draftfolder") }, | ||
34 | {"nodraftfolder", ARG_NODRAFTFOLDER, NULL, 0, | ||
35 | N_("undo the effect of the last --draftfolder option") }, | ||
36 | {"check", ARG_CHECK, N_("BOOL"), OPTION_ARG_OPTIONAL, | ||
37 | N_("check if addresses are deliverable") }, | ||
38 | {"nocheck", ARG_NOCHECK, NULL, OPTION_HIDDEN, "" }, | ||
39 | |||
40 | {NULL} | ||
41 | }; | ||
42 | |||
43 | /* Traditional MH options */ | ||
44 | struct mh_option mh_option[] = { | ||
45 | { "alias", MH_OPT_ARG, "aliasfile" }, | ||
46 | { "draft" }, | ||
47 | { "draftfolder", MH_OPT_ARG, "folder" }, | ||
48 | { "draftmessage", MH_OPT_ARG, "message" }, | ||
49 | { "nodraftfolder" }, | ||
50 | { "check", MH_OPT_BOOL }, | ||
51 | {NULL} | ||
52 | }; | ||
53 | |||
54 | static int check_recipients; | 23 | static int check_recipients; |
55 | static int use_draft; /* Use the prepared draft */ | 24 | static int use_draft; /* Use the prepared draft */ |
56 | static const char *draft_folder; /* Use this draft folder */ | 25 | static const char *draft_folder; /* Use this draft folder */ |
57 | 26 | ||
58 | static error_t | 27 | static void |
59 | opt_handler (int key, char *arg, struct argp_state *state) | 28 | add_alias (struct mu_parseopt *po, struct mu_option *opt, char const *arg) |
60 | { | 29 | { |
61 | switch (key) | ||
62 | { | ||
63 | case ARG_ALIAS: | ||
64 | mh_alias_read (arg, 1); | 30 | mh_alias_read (arg, 1); |
65 | break; | 31 | } |
66 | |||
67 | case ARG_DRAFT: | ||
68 | use_draft = 1; | ||
69 | break; | ||
70 | |||
71 | case ARG_DRAFTFOLDER: | ||
72 | draft_folder = arg; | ||
73 | break; | ||
74 | |||
75 | case ARG_NODRAFTFOLDER: | ||
76 | draft_folder = NULL; | ||
77 | break; | ||
78 | 32 | ||
79 | case ARG_DRAFTMESSAGE: | 33 | static void |
34 | set_draftmessage (struct mu_parseopt *po, struct mu_option *opt, | ||
35 | char const *arg) | ||
36 | { | ||
80 | if (!draft_folder) | 37 | if (!draft_folder) |
81 | draft_folder = mh_global_profile_get ("Draft-Folder", | 38 | draft_folder = mh_global_profile_get ("Draft-Folder", |
82 | mu_folder_directory ()); | 39 | mu_folder_directory ()); |
83 | break; | ||
84 | |||
85 | case ARG_CHECK: | ||
86 | check_recipients = is_true (arg); | ||
87 | break; | ||
88 | |||
89 | case ARG_NOCHECK: | ||
90 | check_recipients = 0; | ||
91 | break; | ||
92 | |||
93 | default: | ||
94 | return ARGP_ERR_UNKNOWN; | ||
95 | } | ||
96 | return 0; | ||
97 | } | 40 | } |
98 | 41 | ||
42 | static struct mu_option options[] = { | ||
43 | { "alias", 0, N_("FILE"), MU_OPTION_DEFAULT, | ||
44 | N_("specify additional alias file"), | ||
45 | mu_c_string, NULL, add_alias }, | ||
46 | { "draft", 0, NULL, MU_OPTION_DEFAULT, | ||
47 | N_("use prepared draft"), | ||
48 | mu_c_bool, &use_draft }, | ||
49 | { "draftfolder", 0, N_("FOLDER"), MU_OPTION_DEFAULT, | ||
50 | N_("specify the folder for message drafts"), | ||
51 | mu_c_string, &draft_folder }, | ||
52 | { "nodraftfolder", 0, NULL, MU_OPTION_DEFAULT, | ||
53 | N_("undo the effect of the last -draftfolder option"), | ||
54 | mu_c_string, &draft_folder, mh_opt_clear_string }, | ||
55 | { "draftmessage", 0, NULL, MU_OPTION_DEFAULT, | ||
56 | N_("treat the arguments as a list of messages from the draftfolder"), | ||
57 | mu_c_string, NULL, set_draftmessage }, | ||
58 | { "check", 0, NULL, MU_OPTION_DEFAULT, | ||
59 | N_("check if addresses are deliverable"), | ||
60 | mu_c_bool, &check_recipients }, | ||
61 | MU_OPTION_END | ||
62 | }; | ||
63 | |||
99 | int | 64 | int |
100 | main (int argc, char **argv) | 65 | main (int argc, char **argv) |
101 | { | 66 | { |
102 | int index; | ||
103 | char *name = "draft"; | 67 | char *name = "draft"; |
104 | 68 | ||
105 | MU_APP_INIT_NLS (); | 69 | MU_APP_INIT_NLS (); |
106 | 70 | ||
107 | mh_argp_init (); | 71 | mh_getopt (&argc, &argv, options, 0, args_doc, prog_doc, NULL); |
108 | mh_argp_parse (&argc, &argv, 0, options, mh_option, args_doc, doc, | ||
109 | opt_handler, NULL, &index); | ||
110 | |||
111 | argc -= index; | ||
112 | argv += index; | ||
113 | 72 | ||
114 | if (!use_draft && argc > 0) | 73 | if (!use_draft && argc > 0) |
115 | name = argv[0]; | 74 | name = argv[0]; | ... | ... |
... | @@ -144,7 +144,6 @@ mh/inc.c | ... | @@ -144,7 +144,6 @@ mh/inc.c |
144 | mh/install-mh.c | 144 | mh/install-mh.c |
145 | mh/mark.c | 145 | mh/mark.c |
146 | mh/mboxprop.c | 146 | mh/mboxprop.c |
147 | mh/mh_argp.c | ||
148 | mh/mh_fmtgram.y | 147 | mh/mh_fmtgram.y |
149 | mh/mh_format.c | 148 | mh/mh_format.c |
150 | mh/mh_getopt.c | 149 | mh/mh_getopt.c | ... | ... |
-
Please register or sign in to post a comment