summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2003-02-16 11:35:44 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2003-02-16 11:35:44 +0000
commit1eeba80dccd45eef3662054a2fd1c6152903e249 (patch)
tree120b8071acbaac1718f2032f85ef1c4031d5ddce
parent9d4495871468cad1d6fb19e9b8728bd343cd0be3 (diff)
downloadmailutils-1eeba80dccd45eef3662054a2fd1c6152903e249.tar.gz
mailutils-1eeba80dccd45eef3662054a2fd1c6152903e249.tar.bz2
Changed invocation of mh_argp_parse and updated the definition of opt_handler.
-rw-r--r--mh/anno.c4
-rw-r--r--mh/comp.c6
-rw-r--r--mh/fmtcheck.c4
-rw-r--r--mh/folder.c4
-rw-r--r--mh/inc.c6
-rw-r--r--mh/install-mh.c4
-rw-r--r--mh/mark.c165
-rw-r--r--mh/mhl.c8
-rw-r--r--mh/mhpath.c4
-rw-r--r--mh/refile.c4
-rw-r--r--mh/repl.c8
-rw-r--r--mh/rmf.c4
-rw-r--r--mh/rmm.c4
-rw-r--r--mh/scan.c8
-rw-r--r--mh/send.c8
-rw-r--r--mh/whatnow.c4
16 files changed, 58 insertions, 187 deletions
diff --git a/mh/anno.c b/mh/anno.c
index e36059d17..4eb5033f4 100644
--- a/mh/anno.c
+++ b/mh/anno.c
@@ -56,7 +56,7 @@ static char *component; /* header field */
static char *anno_text; /* header field value */
static int
-opt_handler (int key, char *arg, void *unused)
+opt_handler (int key, char *arg, void *unused, struct argp_state *state)
{
switch (key)
{
@@ -111,7 +111,7 @@ main (int argc, char **argv)
mu_init_nls ();
- mh_argp_parse (argc, argv, options, mh_option, args_doc, doc,
+ mh_argp_parse (argc, argv, 0, options, mh_option, args_doc, doc,
opt_handler, NULL, &index);
mbox = mh_open_folder (current_folder, 0);
diff --git a/mh/comp.c b/mh/comp.c
index 18233a06f..75d1b31c4 100644
--- a/mh/comp.c
+++ b/mh/comp.c
@@ -85,7 +85,7 @@ static int query_mode = 0; /* --query flag */
static int use_draft = 0; /* --use flag */
static int
-opt_handler (int key, char *arg, void *unused)
+opt_handler (int key, char *arg, void *unused, struct argp_state *state)
{
switch (key)
{
@@ -132,7 +132,7 @@ opt_handler (int key, char *arg, void *unused)
case ARG_WHATNOWPROC:
case ARG_NOWHATNOWPROC:
- mh_error (_("option is not yet implemented"));
+ argp_error (state, _("option is not yet implemented"));
exit (1);
default:
@@ -223,7 +223,7 @@ main (int argc, char **argv)
/* Native Language Support */
mu_init_nls ();
- mh_argp_parse (argc, argv, options, mh_option, args_doc, doc,
+ mh_argp_parse (argc, argv, 0, options, mh_option, args_doc, doc,
opt_handler, NULL, &index);
if (!wh_env.draftfolder)
diff --git a/mh/fmtcheck.c b/mh/fmtcheck.c
index 4ffbd0a6b..b52ff06b3 100644
--- a/mh/fmtcheck.c
+++ b/mh/fmtcheck.c
@@ -64,7 +64,7 @@ action_dump ()
static action_fp action = action_dump;
static int
-opt_handler (int key, char *arg, void *unused)
+opt_handler (int key, char *arg, void *unused, struct argp_state *state)
{
switch (key)
{
@@ -96,7 +96,7 @@ main (int argc, char **argv)
/* Native Language Support */
mu_init_nls ();
- mh_argp_parse (argc, argv, options, mh_option, args_doc, doc,
+ mh_argp_parse (argc, argv, 0, options, mh_option, args_doc, doc,
opt_handler, NULL, NULL);
if (format_str && mh_format_parse (format_str, &format))
diff --git a/mh/folder.c b/mh/folder.c
index a7b3aaa5c..4ae8172e2 100644
--- a/mh/folder.c
+++ b/mh/folder.c
@@ -108,7 +108,7 @@ char *mh_seq_name; /* Name of the mh sequence file (defaults to
.mh_sequences) */
static int
-opt_handler (int key, char *arg, void *unused)
+opt_handler (int key, char *arg, void *unused, struct argp_state *state)
{
switch (key)
{
@@ -503,7 +503,7 @@ main (int argc, char **argv)
/* Native Language Support */
mu_init_nls ();
- mh_argp_parse (argc, argv, options, mh_option, args_doc, doc,
+ mh_argp_parse (argc, argv, 0, options, mh_option, args_doc, doc,
opt_handler, NULL, &index);
/* If folder is invoked by a name ending with "s" (e.g., folders),
diff --git a/mh/inc.c b/mh/inc.c
index d0bcce80c..bf286a485 100644
--- a/mh/inc.c
+++ b/mh/inc.c
@@ -76,7 +76,7 @@ static int quiet = 0;
static char *append_folder;
static int
-opt_handler (int key, char *arg, void *unused)
+opt_handler (int key, char *arg, void *unused, struct argp_state *state)
{
switch (key)
{
@@ -118,7 +118,7 @@ opt_handler (int key, char *arg, void *unused)
width = strtoul (arg, NULL, 0);
if (!width)
{
- mh_error (_("Invalid width"));
+ argp_error (state, _("Invalid width"));
exit (1);
}
break;
@@ -166,7 +166,7 @@ main (int argc, char **argv)
/* Native Language Support */
mu_init_nls ();
- mh_argp_parse (argc, argv, options, mh_option, args_doc, doc,
+ mh_argp_parse (argc, argv, 0, options, mh_option, args_doc, doc,
opt_handler, NULL, NULL);
if (!quiet && mh_format_parse (format_str, &format))
diff --git a/mh/install-mh.c b/mh/install-mh.c
index 52491d6dd..f0cb1340a 100644
--- a/mh/install-mh.c
+++ b/mh/install-mh.c
@@ -38,7 +38,7 @@ struct mh_option mh_option[] = {
int automode;
static int
-opt_handler (int key, char *arg, void *unused)
+opt_handler (int key, char *arg, void *unused, struct argp_state *state)
{
switch (key)
{
@@ -64,7 +64,7 @@ main (int argc, char **argv)
mu_init_nls ();
mh_auto_install = 0;
- mh_argp_parse (argc, argv, options, mh_option, args_doc, doc,
+ mh_argp_parse (argc, argv, 0, options, mh_option, args_doc, doc,
opt_handler, NULL, NULL);
home = mu_get_homedir ();
diff --git a/mh/mark.c b/mh/mark.c
index aa09f3ed8..753a27f7f 100644
--- a/mh/mark.c
+++ b/mh/mark.c
@@ -54,8 +54,8 @@ struct mh_option mh_option[] = {
};
static int action; /* Action to perform */
-static int mode_public = 1; /* Create public sequences */
-static int mode_zero = 1; /* Zero the sequence before addition */
+static int seq_flags = 0; /* Create public sequences;
+ Do not zero the sequence before addition */
static list_t seq_list; /* List of sequence names to operate upon */
static char *mbox_dir;
@@ -72,7 +72,7 @@ add_sequence (char *name)
}
static int
-opt_handler (int key, char *arg, void *unused)
+opt_handler (int key, char *arg, void *unused, struct argp_state *state)
{
switch (key)
{
@@ -92,19 +92,25 @@ opt_handler (int key, char *arg, void *unused)
break;
case ARG_PUBLIC:
- mode_public = is_true (arg);
+ if (is_true (arg))
+ seq_flags &= ~SEQ_PRIVATE;
+ else
+ seq_flags |= SEQ_PRIVATE;
break;
case ARG_NOPUBLIC:
- mode_public = 0;
+ seq_flags |= SEQ_PRIVATE;
break;
case ARG_ZERO:
- mode_zero = is_true (arg);
+ if (is_true (arg))
+ seq_flags |= SEQ_ZERO;
+ else
+ seq_flags &= ~SEQ_ZERO;
break;
case ARG_NOZERO:
- mode_zero = 0;
+ seq_flags &= ~SEQ_ZERO;
break;
default:
@@ -113,152 +119,17 @@ opt_handler (int key, char *arg, void *unused)
return 0;
}
-static char *
-private_sequence_name (char *name)
-{
- char *p;
-
- asprintf (&p, "atr-%s-%s", name, mbox_dir);
- return p;
-}
-
-static char *
-read_sequence (char *name, int public)
-{
- char *value;
-
- if (public)
- value = mh_global_sequences_get (name, NULL);
- else
- {
- char *p = private_sequence_name (name);
- value = mh_global_context_get (p, NULL);
- free (p);
- }
- return value;
-}
-
-static void
-write_sequence (char *name, char *value, int public)
-{
- if (public)
- mh_global_sequences_set (name, value);
- else
- {
- char *p = private_sequence_name (name);
- mh_global_context_set (p, value);
- free (p);
- }
-}
-
-static void
-delete_sequence (char *name, int public)
-{
- write_sequence (name, NULL, public);
-}
-
static int
action_add (void *item, void *data)
{
- char *name = item;
- mh_msgset_t *mset = data;
- char *value = read_sequence (name, mode_public);
- char *new_value, *p;
- char buf[64];
- size_t i, len;
-
- delete_sequence (name, !mode_public);
-
- if (mode_zero)
- value = NULL;
-
- if (value)
- len = strlen (value);
- else
- len = 0;
- len++;
- for (i = 0; i < mset->count; i++)
- {
- snprintf (buf, sizeof buf, "%lu", (unsigned long) mset->list[i]);
- len += strlen (buf) + 1;
- }
-
- new_value = xmalloc (len + 1);
- if (value)
- strcpy (new_value, value);
- else
- new_value[0] = 0;
- p = new_value + strlen (new_value);
- *p++ = ' ';
- for (i = 0; i < mset->count; i++)
- {
- p += sprintf (p, "%lu", (unsigned long) mset->list[i]);
- *p++ = ' ';
- }
- *p = 0;
- write_sequence (name, new_value, mode_public);
- return 0;
-}
-
-static int
-cmp_msgnum (const void *a, const void *b)
-{
- const size_t *as = a;
- const size_t *bs = b;
-
- if (*as < *bs)
- return -1;
- if (*as > *bs)
- return 1;
+ mh_seq_add ((char *)item, (mh_msgset_t *)data, seq_flags);
return 0;
}
static int
action_delete (void *item, void *data)
{
- char *name = item;
- mh_msgset_t *mset = data;
- char *value = read_sequence (name, mode_public);
- char *p;
- int argc, i;
- char **argv;
-
- if (!value)
- return 0;
-
- if (argcv_get (value, "", NULL, &argc, &argv))
- return 0;
-
- for (i = 0; i < argc; i++)
- {
- char *p;
- size_t num = strtoul (argv[i], &p, 10);
-
- if (*p)
- continue;
-
- if (bsearch (&num, mset->list, mset->count, sizeof (mset->list[0]),
- cmp_msgnum))
- {
- free (argv[i]);
- argv[i] = NULL;
- }
- }
-
- p = value;
- for (i = 0; i < argc; i++)
- {
- if (argv[i])
- {
- strcpy (p, argv[i]);
- p += strlen (p);
- *p++ = ' ';
- }
- }
- *p = 0;
- write_sequence (name, value, mode_public);
- argcv_free (argc, argv);
-
+ mh_seq_delete ((char *)item, (mh_msgset_t *)data, seq_flags);
return 0;
}
@@ -268,10 +139,10 @@ action_list (void *item, void *data)
char *name = item;
char *val;
- val = read_sequence (name, 1);
+ val = mh_seq_read (name, 0);
if (val)
printf ("%s: %s\n", name, val);
- else if ((val = read_sequence (name, 0)))
+ else if ((val = mh_seq_read (name, SEQ_PRIVATE)))
printf ("%s (%s): %s\n", name, _("private"), val);
return 0;
}
@@ -317,7 +188,7 @@ main (int argc, char **argv)
url_t url;
mu_init_nls ();
- mh_argp_parse (argc, argv, options, mh_option, args_doc, doc,
+ mh_argp_parse (argc, argv, 0, options, mh_option, args_doc, doc,
opt_handler, NULL, &index);
mbox = mh_open_folder (current_folder, 0);
diff --git a/mh/mhl.c b/mh/mhl.c
index bc5c935c1..6f9349eca 100644
--- a/mh/mhl.c
+++ b/mh/mhl.c
@@ -73,7 +73,7 @@ static int nomoreproc;
static list_t format;
static int
-opt_handler (int key, char *arg, void *unused)
+opt_handler (int key, char *arg, void *unused, struct argp_state *state)
{
switch (key)
{
@@ -106,7 +106,7 @@ opt_handler (int key, char *arg, void *unused)
width = strtoul (arg, NULL, 0);
if (!width)
{
- mh_error (_("Invalid width"));
+ argp_error (state, _("Invalid width"));
exit (1);
}
break;
@@ -115,7 +115,7 @@ opt_handler (int key, char *arg, void *unused)
length = strtoul (arg, NULL, 0);
if (!length)
{
- mh_error (_("Invalid length"));
+ argp_error (state, _("Invalid length"));
exit (1);
}
break;
@@ -212,7 +212,7 @@ main (int argc, char **argv)
interactive = isatty (1) && isatty (0);
mu_init_nls ();
- mh_argp_parse (argc, argv, options, mh_option, args_doc, doc,
+ mh_argp_parse (argc, argv, 0, options, mh_option, args_doc, doc,
opt_handler, NULL, &index);
format = mhl_format_compile (formfile);
diff --git a/mh/mhpath.c b/mh/mhpath.c
index c84c3973c..70e1d2cad 100644
--- a/mh/mhpath.c
+++ b/mh/mhpath.c
@@ -37,7 +37,7 @@ struct mh_option mh_option[] = {
};
static int
-opt_handler (int key, char *arg, void *unused)
+opt_handler (int key, char *arg, void *unused, struct argp_state *state)
{
switch (key)
{
@@ -75,7 +75,7 @@ main (int argc, char **argv)
/* Native Language Support */
mu_init_nls ();
- mh_argp_parse (argc, argv, options, mh_option, args_doc, doc,
+ mh_argp_parse (argc, argv, 0, options, mh_option, args_doc, doc,
opt_handler, NULL, &index);
/* If the only argument is `+', your MH Path is output; this
diff --git a/mh/refile.c b/mh/refile.c
index 78740d7da..2c109515a 100644
--- a/mh/refile.c
+++ b/mh/refile.c
@@ -145,7 +145,7 @@ close_folders ()
}
static int
-opt_handler (int key, char *arg, void *unused)
+opt_handler (int key, char *arg, void *unused, struct argp_state *state)
{
switch (key)
{
@@ -223,7 +223,7 @@ main (int argc, char **argv)
/* Native Language Support */
mu_init_nls ();
- mh_argp_parse (argc, argv, options, mh_option, args_doc, doc,
+ mh_argp_parse (argc, argv, 0, options, mh_option, args_doc, doc,
opt_handler, NULL, &index);
open_folders ();
diff --git a/mh/repl.c b/mh/repl.c
index 7c4365714..e9e050aeb 100644
--- a/mh/repl.c
+++ b/mh/repl.c
@@ -123,7 +123,7 @@ decode_cc_flag (const char *opt, const char *arg)
}
static int
-opt_handler (int key, char *arg, void *unused)
+opt_handler (int key, char *arg, void *unused, struct argp_state *state)
{
char *s;
@@ -172,7 +172,7 @@ opt_handler (int key, char *arg, void *unused)
width = strtoul (arg, NULL, 0);
if (!width)
{
- mh_error (_("Invalid width"));
+ argp_error (state, _("Invalid width"));
exit (1);
}
break;
@@ -198,7 +198,7 @@ opt_handler (int key, char *arg, void *unused)
case ARG_INPLACE:
case ARG_WHATNOWPROC:
case ARG_NOWHATNOWPROC:
- mh_error (_("option is not yet implemented"));
+ argp_error (state, _("option is not yet implemented"));
exit (1);
default:
@@ -318,7 +318,7 @@ main (int argc, char **argv)
/* Native Language Support */
mu_init_nls ();
- mh_argp_parse (argc, argv, options, mh_option, args_doc, doc,
+ mh_argp_parse (argc, argv, 0, options, mh_option, args_doc, doc,
opt_handler, NULL, &index);
if (mh_format_parse (format_str, &format))
{
diff --git a/mh/rmf.c b/mh/rmf.c
index 8b329c310..ef4c0e356 100644
--- a/mh/rmf.c
+++ b/mh/rmf.c
@@ -55,7 +55,7 @@ int interactive; /* Ask for confirmation before deleting */
int recurse; /* Recursively process all the sub-directories */
static int
-opt_handler (int key, char *arg, void *unused)
+opt_handler (int key, char *arg, void *unused, struct argp_state *state)
{
switch (key)
{
@@ -134,7 +134,7 @@ main (int argc, char **argv)
/* Native Language Support */
mu_init_nls ();
- mh_argp_parse (argc, argv, options, mh_option, args_doc, doc,
+ mh_argp_parse (argc, argv, 0, options, mh_option, args_doc, doc,
opt_handler, NULL, NULL);
if (!explicit_folder)
interactive = 1;
diff --git a/mh/rmm.c b/mh/rmm.c
index 035731ea5..dfe8c931f 100644
--- a/mh/rmm.c
+++ b/mh/rmm.c
@@ -37,7 +37,7 @@ struct mh_option mh_option[] = {
};
static int
-opt_handler (int key, char *arg, void *unused)
+opt_handler (int key, char *arg, void *unused, struct argp_state *state)
{
switch (key)
{
@@ -71,7 +71,7 @@ main (int argc, char **argv)
/* Native Language Support */
mu_init_nls ();
- mh_argp_parse (argc, argv, options, mh_option, args_doc, doc,
+ mh_argp_parse (argc, argv, 0, options, mh_option, args_doc, doc,
opt_handler, NULL, &index);
mbox = mh_open_folder (current_folder, 0);
diff --git a/mh/scan.c b/mh/scan.c
index 3ceb326dd..6539f3a78 100644
--- a/mh/scan.c
+++ b/mh/scan.c
@@ -84,7 +84,7 @@ void print_header __P((mailbox_t mbox));
void clear_screen __P((void));
static int
-opt_handler (int key, char *arg, void *unused)
+opt_handler (int key, char *arg, void *unused, struct argp_state *state)
{
switch (key)
{
@@ -113,7 +113,7 @@ opt_handler (int key, char *arg, void *unused)
width = strtoul (arg, NULL, 0);
if (!width)
{
- mh_error (_("Invalid width"));
+ argp_error (state, _("Invalid width"));
exit (1);
}
break;
@@ -123,7 +123,7 @@ opt_handler (int key, char *arg, void *unused)
break;
case ARG_FILE:
- mh_error (_("option is not yet implemented"));
+ argp_error (state, _("option is not yet implemented"));
break;
case ARG_LICENSE:
@@ -166,7 +166,7 @@ main (int argc, char **argv)
/* Native Language Support */
mu_init_nls ();
- mh_argp_parse (argc, argv, options, mh_option, args_doc, doc,
+ mh_argp_parse (argc, argv, 0, options, mh_option, args_doc, doc,
opt_handler, NULL, &index);
if (mh_format_parse (format_str, &format))
diff --git a/mh/send.c b/mh/send.c
index f352a086d..0b51c2487 100644
--- a/mh/send.c
+++ b/mh/send.c
@@ -118,7 +118,7 @@ static unsigned width = 76; /* Maximum width of header fields */
} while (0)
static int
-opt_handler (int key, char *arg, void *unused)
+opt_handler (int key, char *arg, void *unused, struct argp_state *state)
{
char *p;
@@ -194,7 +194,7 @@ opt_handler (int key, char *arg, void *unused)
split_interval = strtoul(arg, &p, 10);
if (*p)
{
- mh_error (_("Invalid number"));
+ argp_error (state, _("Invalid number"));
exit (1);
}
break;
@@ -219,7 +219,7 @@ opt_handler (int key, char *arg, void *unused)
width = strtoul(arg, &p, 10);
if (*p)
{
- mh_error (_("Invalid number"));
+ argp_error (state, _("Invalid number"));
exit (1);
}
break;
@@ -447,7 +447,7 @@ main (int argc, char **argv)
mu_init_nls ();
- mh_argp_parse (argc, argv, options, mh_option, args_doc, doc,
+ mh_argp_parse (argc, argv, 0, options, mh_option, args_doc, doc,
opt_handler, NULL, &index);
argc -= index;
diff --git a/mh/whatnow.c b/mh/whatnow.c
index 9dd9ccb69..84f645a3a 100644
--- a/mh/whatnow.c
+++ b/mh/whatnow.c
@@ -52,7 +52,7 @@ struct mh_whatnow_env wh_env = { 0 };
static int initial_edit = 1;
static int
-opt_handler (int key, char *arg, void *unused)
+opt_handler (int key, char *arg, void *unused, struct argp_state *state)
{
switch (key)
{
@@ -93,7 +93,7 @@ main (int argc, char **argv)
mu_init_nls ();
- mh_argp_parse (argc, argv, options, mh_option, args_doc, doc,
+ mh_argp_parse (argc, argv, 0, options, mh_option, args_doc, doc,
opt_handler, NULL, &index);
wh_env.msg = getenv ("mhaltmsg");

Return to:

Send suggestions and report system problems to the System administrator.