diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2010-10-28 23:20:22 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2010-10-28 23:20:22 +0300 |
commit | 4a49f5341ae9005c9ffbd7620efaecffcdfda79f (patch) | |
tree | 53ba2d6a638bd9b83747ebd6899931ab89d13ca0 /comsat | |
parent | 697384c64dadb0a4db97136a6cbcf2166c48897b (diff) | |
download | mailutils-4a49f5341ae9005c9ffbd7620efaecffcdfda79f.tar.gz mailutils-4a49f5341ae9005c9ffbd7620efaecffcdfda79f.tar.bz2 |
Add wordsplit module.
The wordsplit module (borrowed from another project of mine, called 'grecs')
provides a flexible and powerful mechanism for parsing input in a way
similar to posix-shell. In particular, the POSIX function wordexp is
a subset of the wordsplit functionality.
The argcv module is now deprecated.
* include/mailutils/wordsplit.h: New file.
* include/mailutils/Makefile.am (pkginclude_HEADERS): Add wordsplit.h
* libmailutils/string/wordsplit.c: New file.
* libmailutils/string/Makefile.am (libstring_la_SOURCES): Add wordsplit.c.
* include/mailutils/argcv.h (mu_argcv_join): New proto.
(mu_argcv_get, mu_argcv_get_n, mu_argcv_get_np)
(mu_argcv_unquote_char, mu_argcv_quote_char)
(mu_argcv_quoted_length, mu_argcv_unquote_copy)
(mu_argcv_quote_copy): Mark as deprecated.
* include/mailutils/mailutils.h: Include wordsplit.h.
* libmailutils/tests/wsp.c: New file.
* libmailutils/tests/.gitignore: List wsp.
* libmailutils/tests/wordsplit.at: New file.
* libmailutils/tests/Makefile.am (noinst_PROGRAMS): Add wsp
(TESTSUITE_AT): Add wordsplit.at.
* libmailutils/tests/argcv.c: Define MU_ARCGV_DEPRECATED to
avoid deprecation warnings.
* libmailutils/tests/testsuite.at: Include wordsplit.at.
* libmailutils/base/argcvfree.c: New file.
* libmailutils/base/argcvjoin.c: New file.
* libmailutils/base/argcvrem.c: New file.
* libmailutils/base/Makefile.am (libbase_la_SOURCES): Add new files.
* libmailutils/base/argcv.c: Define MU_ARCGV_DEPRECATED to
avoid deprecation warnings.
(argcv_string, argcv_free, argv_free)
(mu_argcv_remove): Rewrite in separate modules.
* comsat/comsat.h: Include wordsplit.h.
* imap4d/imap4d.h: Likewise.
* mail/mail.h: Likewise.
* mh/mh.h: Likewise.
* readmsg/readmsg.h: Likewise.
* comsat/action.c: Use wordsplit.
* imap4d/fetch.c: Likewise.
* lib/mailcap.c: Likewise.
* libmailutils/auth/mu_auth.c: Likewise.
* libmailutils/base/mutil.c: Likewise.
* libmailutils/cfg/format.c: Likewise.
* libmailutils/cfg/lexer.l: Likewise.
* libmailutils/cfg/parser.y: Likewise.
* libmailutils/diag/gdebug.c: Likewise.
* libmailutils/mailer/mailer.c: Likewise.
* libmailutils/server/acl.c: Likewise.
* libmailutils/stream/prog_stream.c: Likewise.
* libmailutils/tests/listop.c: Likewise.
* libmailutils/url/create.c: Likewise.
* libmu_auth/ldap.c: Likewise.
* libmu_auth/radius.c: Likewise.
* libmu_sieve/sieve.l: Likewise.
* libproto/mailer/mbox.c: Likewise.
* libproto/mailer/smtp.c: Likewise.
* libproto/mailer/smtp_gsasl.c: Likewise.
* mail/mailline.c: Likewise.
* mail/mailvar.c: Likewise.
* mail/send.c: Likewise.
* mail/util.c: Likewise.
* mh/folder.c: Likewise.
* mh/mh_alias.y: Likewise.
* mh/mh_argp.c: Likewise.
* mh/mh_init.c: Likewise.
* mh/mh_list.c: Likewise.
* mh/mh_msgset.c: Likewise.
* mh/mh_sequence.c: Likewise.
* mh/mh_whatnow.c: Likewise.
* mh/mh_sequence.c: Likewise.
* mh/mh_whatnow.c: Likewise.
* mh/mhn.c: Likewise.
* mh/send.c: Likewise.
* movemail/movemail.c: Likewise.
* mu/shell.c: Likewise.
* readmsg/readmsg.c: Likewise.
* testsuite/smtpsend.c: Likewise.
* pop3d/popauth.c: Use wordsplit.
Use simplified input format (username and password delimited
by any amount of whitespace).
Read/produce old format if invoked with the --compatibility option.
* examples/aclck.c: Use wordsplit instead of argcv.
* examples/header.c: Likewise.
* examples/mta.c: Likewise.
* examples/.gitignore: Remove pop3client.
* examples/Makefile.am: Remove pop3client.
* po/POTFILES.in: Add new files.
Diffstat (limited to 'comsat')
-rw-r--r-- | comsat/action.c | 40 | ||||
-rw-r--r-- | comsat/comsat.h | 2 |
2 files changed, 22 insertions, 20 deletions
diff --git a/comsat/action.c b/comsat/action.c index 0e1e679cd..4a8701348 100644 --- a/comsat/action.c +++ b/comsat/action.c @@ -204,7 +204,7 @@ expand_line (const char *str, mu_message_t msg) p++; if (*p) { - c = mu_argcv_unquote_char (*p); + c = mu_wordsplit_c_unquote_char (*p); obstack_1grow (&stk, c); } break; @@ -300,7 +300,8 @@ action_exec (FILE *tty, int argc, char **argv) if (argv[0][0] != '/') { - mu_diag_output (MU_DIAG_ERROR, _("not an absolute pathname: %s"), argv[0]); + mu_diag_output (MU_DIAG_ERROR, _("not an absolute pathname: %s"), + argv[0]); return; } @@ -388,15 +389,14 @@ run_user_action (FILE *tty, const char *cr, mu_message_t msg) while ((n = act_getline (fp, &stmt, &size))) { - int argc; - char **argv; + struct mu_wordsplit ws; - if (mu_argcv_get (stmt, "", NULL, &argc, &argv) == 0 - && argc - && argv[0][0] != '#') + ws.ws_comment = "#"; + if (mu_wordsplit (stmt, &ws, MU_WRDSF_DEFFLAGS | MU_WRDSF_COMMENT) + && ws.ws_wordc) { mu_debug_set_locus (debug, rcname, line); - if (strcmp (argv[0], "beep") == 0) + if (strcmp (ws.ws_wordv[0], "beep") == 0) { /* FIXME: excess arguments are ignored */ action_beep (tty); @@ -406,25 +406,27 @@ run_user_action (FILE *tty, const char *cr, mu_message_t msg) { /* Rest of actions require keyword expansion */ int i; - int n_option = argc > 1 && strcmp (argv[1], "-n") == 0; + int n_option = ws.ws_wordc > 1 && + strcmp (ws.ws_wordv[1], "-n") == 0; - for (i = 1; i < argc; i++) + for (i = 1; i < ws.ws_wordc; i++) { - char *oldarg = argv[i]; - argv[i] = expand_line (argv[i], msg); + char *oldarg = ws.ws_wordv[i]; + ws.ws_wordv[i] = expand_line (ws.ws_wordv[i], msg); free (oldarg); - if (!argv[i]) + if (!ws.ws_wordv[i]) break; } - if (strcmp (argv[0], "echo") == 0) + if (strcmp (ws.ws_wordv[0], "echo") == 0) { - action_echo (tty, cr, n_option, argc - 1, argv + 1); + action_echo (tty, cr, n_option, + ws.ws_wordc - 1, ws.ws_wordv + 1); nact++; } - else if (strcmp (argv[0], "exec") == 0) + else if (strcmp (ws.ws_wordv[0], "exec") == 0) { - action_exec (tty, argc - 1, argv + 1); + action_exec (tty, ws.ws_wordc - 1, ws.ws_wordv + 1); nact++; } else @@ -432,12 +434,12 @@ run_user_action (FILE *tty, const char *cr, mu_message_t msg) fprintf (tty, _(".biffrc:%d: unknown keyword"), line); fprintf (tty, "\r\n"); mu_diag_output (MU_DIAG_ERROR, _("unknown keyword %s"), - argv[0]); + ws.ws_wordv[0]); break; } } } - mu_argcv_free (argc, argv); + mu_wordsplit_free (&ws); line += n; } fclose (fp); diff --git a/comsat/comsat.h b/comsat/comsat.h index 5148fa809..1c1381abf 100644 --- a/comsat/comsat.h +++ b/comsat/comsat.h @@ -53,7 +53,7 @@ #include <mailutils/registrar.h> #include <mailutils/stream.h> #include <mailutils/mu_auth.h> -#include <mailutils/argcv.h> +#include <mailutils/wordsplit.h> #include <mailutils/nls.h> #include <mailutils/daemon.h> #include <mailutils/acl.h> |