Changed invocation of mh_argp_parse and updated the definition of opt_handler.
Showing
16 changed files
with
58 additions
and
187 deletions
... | @@ -56,7 +56,7 @@ static char *component; /* header field */ | ... | @@ -56,7 +56,7 @@ static char *component; /* header field */ |
56 | static char *anno_text; /* header field value */ | 56 | static char *anno_text; /* header field value */ |
57 | 57 | ||
58 | static int | 58 | static int |
59 | opt_handler (int key, char *arg, void *unused) | 59 | opt_handler (int key, char *arg, void *unused, struct argp_state *state) |
60 | { | 60 | { |
61 | switch (key) | 61 | switch (key) |
62 | { | 62 | { |
... | @@ -111,7 +111,7 @@ main (int argc, char **argv) | ... | @@ -111,7 +111,7 @@ main (int argc, char **argv) |
111 | 111 | ||
112 | mu_init_nls (); | 112 | mu_init_nls (); |
113 | 113 | ||
114 | mh_argp_parse (argc, argv, options, mh_option, args_doc, doc, | 114 | mh_argp_parse (argc, argv, 0, options, mh_option, args_doc, doc, |
115 | opt_handler, NULL, &index); | 115 | opt_handler, NULL, &index); |
116 | 116 | ||
117 | mbox = mh_open_folder (current_folder, 0); | 117 | mbox = mh_open_folder (current_folder, 0); | ... | ... |
... | @@ -85,7 +85,7 @@ static int query_mode = 0; /* --query flag */ | ... | @@ -85,7 +85,7 @@ static int query_mode = 0; /* --query flag */ |
85 | static int use_draft = 0; /* --use flag */ | 85 | static int use_draft = 0; /* --use flag */ |
86 | 86 | ||
87 | static int | 87 | static int |
88 | opt_handler (int key, char *arg, void *unused) | 88 | opt_handler (int key, char *arg, void *unused, struct argp_state *state) |
89 | { | 89 | { |
90 | switch (key) | 90 | switch (key) |
91 | { | 91 | { |
... | @@ -132,7 +132,7 @@ opt_handler (int key, char *arg, void *unused) | ... | @@ -132,7 +132,7 @@ opt_handler (int key, char *arg, void *unused) |
132 | 132 | ||
133 | case ARG_WHATNOWPROC: | 133 | case ARG_WHATNOWPROC: |
134 | case ARG_NOWHATNOWPROC: | 134 | case ARG_NOWHATNOWPROC: |
135 | mh_error (_("option is not yet implemented")); | 135 | argp_error (state, _("option is not yet implemented")); |
136 | exit (1); | 136 | exit (1); |
137 | 137 | ||
138 | default: | 138 | default: |
... | @@ -223,7 +223,7 @@ main (int argc, char **argv) | ... | @@ -223,7 +223,7 @@ main (int argc, char **argv) |
223 | /* Native Language Support */ | 223 | /* Native Language Support */ |
224 | mu_init_nls (); | 224 | mu_init_nls (); |
225 | 225 | ||
226 | mh_argp_parse (argc, argv, options, mh_option, args_doc, doc, | 226 | mh_argp_parse (argc, argv, 0, options, mh_option, args_doc, doc, |
227 | opt_handler, NULL, &index); | 227 | opt_handler, NULL, &index); |
228 | 228 | ||
229 | if (!wh_env.draftfolder) | 229 | if (!wh_env.draftfolder) | ... | ... |
... | @@ -64,7 +64,7 @@ action_dump () | ... | @@ -64,7 +64,7 @@ action_dump () |
64 | static action_fp action = action_dump; | 64 | static action_fp action = action_dump; |
65 | 65 | ||
66 | static int | 66 | static int |
67 | opt_handler (int key, char *arg, void *unused) | 67 | opt_handler (int key, char *arg, void *unused, struct argp_state *state) |
68 | { | 68 | { |
69 | switch (key) | 69 | switch (key) |
70 | { | 70 | { |
... | @@ -96,7 +96,7 @@ main (int argc, char **argv) | ... | @@ -96,7 +96,7 @@ main (int argc, char **argv) |
96 | /* Native Language Support */ | 96 | /* Native Language Support */ |
97 | mu_init_nls (); | 97 | mu_init_nls (); |
98 | 98 | ||
99 | mh_argp_parse (argc, argv, options, mh_option, args_doc, doc, | 99 | mh_argp_parse (argc, argv, 0, options, mh_option, args_doc, doc, |
100 | opt_handler, NULL, NULL); | 100 | opt_handler, NULL, NULL); |
101 | 101 | ||
102 | if (format_str && mh_format_parse (format_str, &format)) | 102 | if (format_str && mh_format_parse (format_str, &format)) | ... | ... |
... | @@ -108,7 +108,7 @@ char *mh_seq_name; /* Name of the mh sequence file (defaults to | ... | @@ -108,7 +108,7 @@ char *mh_seq_name; /* Name of the mh sequence file (defaults to |
108 | .mh_sequences) */ | 108 | .mh_sequences) */ |
109 | 109 | ||
110 | static int | 110 | static int |
111 | opt_handler (int key, char *arg, void *unused) | 111 | opt_handler (int key, char *arg, void *unused, struct argp_state *state) |
112 | { | 112 | { |
113 | switch (key) | 113 | switch (key) |
114 | { | 114 | { |
... | @@ -503,7 +503,7 @@ main (int argc, char **argv) | ... | @@ -503,7 +503,7 @@ main (int argc, char **argv) |
503 | /* Native Language Support */ | 503 | /* Native Language Support */ |
504 | mu_init_nls (); | 504 | mu_init_nls (); |
505 | 505 | ||
506 | mh_argp_parse (argc, argv, options, mh_option, args_doc, doc, | 506 | mh_argp_parse (argc, argv, 0, options, mh_option, args_doc, doc, |
507 | opt_handler, NULL, &index); | 507 | opt_handler, NULL, &index); |
508 | 508 | ||
509 | /* If folder is invoked by a name ending with "s" (e.g., folders), | 509 | /* If folder is invoked by a name ending with "s" (e.g., folders), | ... | ... |
... | @@ -76,7 +76,7 @@ static int quiet = 0; | ... | @@ -76,7 +76,7 @@ static int quiet = 0; |
76 | static char *append_folder; | 76 | static char *append_folder; |
77 | 77 | ||
78 | static int | 78 | static int |
79 | opt_handler (int key, char *arg, void *unused) | 79 | opt_handler (int key, char *arg, void *unused, struct argp_state *state) |
80 | { | 80 | { |
81 | switch (key) | 81 | switch (key) |
82 | { | 82 | { |
... | @@ -118,7 +118,7 @@ opt_handler (int key, char *arg, void *unused) | ... | @@ -118,7 +118,7 @@ opt_handler (int key, char *arg, void *unused) |
118 | width = strtoul (arg, NULL, 0); | 118 | width = strtoul (arg, NULL, 0); |
119 | if (!width) | 119 | if (!width) |
120 | { | 120 | { |
121 | mh_error (_("Invalid width")); | 121 | argp_error (state, _("Invalid width")); |
122 | exit (1); | 122 | exit (1); |
123 | } | 123 | } |
124 | break; | 124 | break; |
... | @@ -166,7 +166,7 @@ main (int argc, char **argv) | ... | @@ -166,7 +166,7 @@ main (int argc, char **argv) |
166 | /* Native Language Support */ | 166 | /* Native Language Support */ |
167 | mu_init_nls (); | 167 | mu_init_nls (); |
168 | 168 | ||
169 | mh_argp_parse (argc, argv, options, mh_option, args_doc, doc, | 169 | mh_argp_parse (argc, argv, 0, options, mh_option, args_doc, doc, |
170 | opt_handler, NULL, NULL); | 170 | opt_handler, NULL, NULL); |
171 | 171 | ||
172 | if (!quiet && mh_format_parse (format_str, &format)) | 172 | if (!quiet && mh_format_parse (format_str, &format)) | ... | ... |
... | @@ -38,7 +38,7 @@ struct mh_option mh_option[] = { | ... | @@ -38,7 +38,7 @@ struct mh_option mh_option[] = { |
38 | int automode; | 38 | int automode; |
39 | 39 | ||
40 | static int | 40 | static int |
41 | opt_handler (int key, char *arg, void *unused) | 41 | opt_handler (int key, char *arg, void *unused, struct argp_state *state) |
42 | { | 42 | { |
43 | switch (key) | 43 | switch (key) |
44 | { | 44 | { |
... | @@ -64,7 +64,7 @@ main (int argc, char **argv) | ... | @@ -64,7 +64,7 @@ main (int argc, char **argv) |
64 | mu_init_nls (); | 64 | mu_init_nls (); |
65 | 65 | ||
66 | mh_auto_install = 0; | 66 | mh_auto_install = 0; |
67 | mh_argp_parse (argc, argv, options, mh_option, args_doc, doc, | 67 | mh_argp_parse (argc, argv, 0, options, mh_option, args_doc, doc, |
68 | opt_handler, NULL, NULL); | 68 | opt_handler, NULL, NULL); |
69 | 69 | ||
70 | home = mu_get_homedir (); | 70 | home = mu_get_homedir (); | ... | ... |
... | @@ -54,8 +54,8 @@ struct mh_option mh_option[] = { | ... | @@ -54,8 +54,8 @@ struct mh_option mh_option[] = { |
54 | }; | 54 | }; |
55 | 55 | ||
56 | static int action; /* Action to perform */ | 56 | static int action; /* Action to perform */ |
57 | static int mode_public = 1; /* Create public sequences */ | 57 | static int seq_flags = 0; /* Create public sequences; |
58 | static int mode_zero = 1; /* Zero the sequence before addition */ | 58 | Do not zero the sequence before addition */ |
59 | static list_t seq_list; /* List of sequence names to operate upon */ | 59 | static list_t seq_list; /* List of sequence names to operate upon */ |
60 | 60 | ||
61 | static char *mbox_dir; | 61 | static char *mbox_dir; |
... | @@ -72,7 +72,7 @@ add_sequence (char *name) | ... | @@ -72,7 +72,7 @@ add_sequence (char *name) |
72 | } | 72 | } |
73 | 73 | ||
74 | static int | 74 | static int |
75 | opt_handler (int key, char *arg, void *unused) | 75 | opt_handler (int key, char *arg, void *unused, struct argp_state *state) |
76 | { | 76 | { |
77 | switch (key) | 77 | switch (key) |
78 | { | 78 | { |
... | @@ -92,19 +92,25 @@ opt_handler (int key, char *arg, void *unused) | ... | @@ -92,19 +92,25 @@ opt_handler (int key, char *arg, void *unused) |
92 | break; | 92 | break; |
93 | 93 | ||
94 | case ARG_PUBLIC: | 94 | case ARG_PUBLIC: |
95 | mode_public = is_true (arg); | 95 | if (is_true (arg)) |
96 | seq_flags &= ~SEQ_PRIVATE; | ||
97 | else | ||
98 | seq_flags |= SEQ_PRIVATE; | ||
96 | break; | 99 | break; |
97 | 100 | ||
98 | case ARG_NOPUBLIC: | 101 | case ARG_NOPUBLIC: |
99 | mode_public = 0; | 102 | seq_flags |= SEQ_PRIVATE; |
100 | break; | 103 | break; |
101 | 104 | ||
102 | case ARG_ZERO: | 105 | case ARG_ZERO: |
103 | mode_zero = is_true (arg); | 106 | if (is_true (arg)) |
107 | seq_flags |= SEQ_ZERO; | ||
108 | else | ||
109 | seq_flags &= ~SEQ_ZERO; | ||
104 | break; | 110 | break; |
105 | 111 | ||
106 | case ARG_NOZERO: | 112 | case ARG_NOZERO: |
107 | mode_zero = 0; | 113 | seq_flags &= ~SEQ_ZERO; |
108 | break; | 114 | break; |
109 | 115 | ||
110 | default: | 116 | default: |
... | @@ -113,152 +119,17 @@ opt_handler (int key, char *arg, void *unused) | ... | @@ -113,152 +119,17 @@ opt_handler (int key, char *arg, void *unused) |
113 | return 0; | 119 | return 0; |
114 | } | 120 | } |
115 | 121 | ||
116 | static char * | ||
117 | private_sequence_name (char *name) | ||
118 | { | ||
119 | char *p; | ||
120 | |||
121 | asprintf (&p, "atr-%s-%s", name, mbox_dir); | ||
122 | return p; | ||
123 | } | ||
124 | |||
125 | static char * | ||
126 | read_sequence (char *name, int public) | ||
127 | { | ||
128 | char *value; | ||
129 | |||
130 | if (public) | ||
131 | value = mh_global_sequences_get (name, NULL); | ||
132 | else | ||
133 | { | ||
134 | char *p = private_sequence_name (name); | ||
135 | value = mh_global_context_get (p, NULL); | ||
136 | free (p); | ||
137 | } | ||
138 | return value; | ||
139 | } | ||
140 | |||
141 | static void | ||
142 | write_sequence (char *name, char *value, int public) | ||
143 | { | ||
144 | if (public) | ||
145 | mh_global_sequences_set (name, value); | ||
146 | else | ||
147 | { | ||
148 | char *p = private_sequence_name (name); | ||
149 | mh_global_context_set (p, value); | ||
150 | free (p); | ||
151 | } | ||
152 | } | ||
153 | |||
154 | static void | ||
155 | delete_sequence (char *name, int public) | ||
156 | { | ||
157 | write_sequence (name, NULL, public); | ||
158 | } | ||
159 | |||
160 | static int | 122 | static int |
161 | action_add (void *item, void *data) | 123 | action_add (void *item, void *data) |
162 | { | 124 | { |
163 | char *name = item; | 125 | mh_seq_add ((char *)item, (mh_msgset_t *)data, seq_flags); |
164 | mh_msgset_t *mset = data; | ||
165 | char *value = read_sequence (name, mode_public); | ||
166 | char *new_value, *p; | ||
167 | char buf[64]; | ||
168 | size_t i, len; | ||
169 | |||
170 | delete_sequence (name, !mode_public); | ||
171 | |||
172 | if (mode_zero) | ||
173 | value = NULL; | ||
174 | |||
175 | if (value) | ||
176 | len = strlen (value); | ||
177 | else | ||
178 | len = 0; | ||
179 | len++; | ||
180 | for (i = 0; i < mset->count; i++) | ||
181 | { | ||
182 | snprintf (buf, sizeof buf, "%lu", (unsigned long) mset->list[i]); | ||
183 | len += strlen (buf) + 1; | ||
184 | } | ||
185 | |||
186 | new_value = xmalloc (len + 1); | ||
187 | if (value) | ||
188 | strcpy (new_value, value); | ||
189 | else | ||
190 | new_value[0] = 0; | ||
191 | p = new_value + strlen (new_value); | ||
192 | *p++ = ' '; | ||
193 | for (i = 0; i < mset->count; i++) | ||
194 | { | ||
195 | p += sprintf (p, "%lu", (unsigned long) mset->list[i]); | ||
196 | *p++ = ' '; | ||
197 | } | ||
198 | *p = 0; | ||
199 | write_sequence (name, new_value, mode_public); | ||
200 | return 0; | ||
201 | } | ||
202 | |||
203 | static int | ||
204 | cmp_msgnum (const void *a, const void *b) | ||
205 | { | ||
206 | const size_t *as = a; | ||
207 | const size_t *bs = b; | ||
208 | |||
209 | if (*as < *bs) | ||
210 | return -1; | ||
211 | if (*as > *bs) | ||
212 | return 1; | ||
213 | return 0; | 126 | return 0; |
214 | } | 127 | } |
215 | 128 | ||
216 | static int | 129 | static int |
217 | action_delete (void *item, void *data) | 130 | action_delete (void *item, void *data) |
218 | { | 131 | { |
219 | char *name = item; | 132 | mh_seq_delete ((char *)item, (mh_msgset_t *)data, seq_flags); |
220 | mh_msgset_t *mset = data; | ||
221 | char *value = read_sequence (name, mode_public); | ||
222 | char *p; | ||
223 | int argc, i; | ||
224 | char **argv; | ||
225 | |||
226 | if (!value) | ||
227 | return 0; | ||
228 | |||
229 | if (argcv_get (value, "", NULL, &argc, &argv)) | ||
230 | return 0; | ||
231 | |||
232 | for (i = 0; i < argc; i++) | ||
233 | { | ||
234 | char *p; | ||
235 | size_t num = strtoul (argv[i], &p, 10); | ||
236 | |||
237 | if (*p) | ||
238 | continue; | ||
239 | |||
240 | if (bsearch (&num, mset->list, mset->count, sizeof (mset->list[0]), | ||
241 | cmp_msgnum)) | ||
242 | { | ||
243 | free (argv[i]); | ||
244 | argv[i] = NULL; | ||
245 | } | ||
246 | } | ||
247 | |||
248 | p = value; | ||
249 | for (i = 0; i < argc; i++) | ||
250 | { | ||
251 | if (argv[i]) | ||
252 | { | ||
253 | strcpy (p, argv[i]); | ||
254 | p += strlen (p); | ||
255 | *p++ = ' '; | ||
256 | } | ||
257 | } | ||
258 | *p = 0; | ||
259 | write_sequence (name, value, mode_public); | ||
260 | argcv_free (argc, argv); | ||
261 | |||
262 | return 0; | 133 | return 0; |
263 | } | 134 | } |
264 | 135 | ||
... | @@ -268,10 +139,10 @@ action_list (void *item, void *data) | ... | @@ -268,10 +139,10 @@ action_list (void *item, void *data) |
268 | char *name = item; | 139 | char *name = item; |
269 | char *val; | 140 | char *val; |
270 | 141 | ||
271 | val = read_sequence (name, 1); | 142 | val = mh_seq_read (name, 0); |
272 | if (val) | 143 | if (val) |
273 | printf ("%s: %s\n", name, val); | 144 | printf ("%s: %s\n", name, val); |
274 | else if ((val = read_sequence (name, 0))) | 145 | else if ((val = mh_seq_read (name, SEQ_PRIVATE))) |
275 | printf ("%s (%s): %s\n", name, _("private"), val); | 146 | printf ("%s (%s): %s\n", name, _("private"), val); |
276 | return 0; | 147 | return 0; |
277 | } | 148 | } |
... | @@ -317,7 +188,7 @@ main (int argc, char **argv) | ... | @@ -317,7 +188,7 @@ main (int argc, char **argv) |
317 | url_t url; | 188 | url_t url; |
318 | 189 | ||
319 | mu_init_nls (); | 190 | mu_init_nls (); |
320 | mh_argp_parse (argc, argv, options, mh_option, args_doc, doc, | 191 | mh_argp_parse (argc, argv, 0, options, mh_option, args_doc, doc, |
321 | opt_handler, NULL, &index); | 192 | opt_handler, NULL, &index); |
322 | 193 | ||
323 | mbox = mh_open_folder (current_folder, 0); | 194 | mbox = mh_open_folder (current_folder, 0); | ... | ... |
... | @@ -73,7 +73,7 @@ static int nomoreproc; | ... | @@ -73,7 +73,7 @@ static int nomoreproc; |
73 | static list_t format; | 73 | static list_t format; |
74 | 74 | ||
75 | static int | 75 | static int |
76 | opt_handler (int key, char *arg, void *unused) | 76 | opt_handler (int key, char *arg, void *unused, struct argp_state *state) |
77 | { | 77 | { |
78 | switch (key) | 78 | switch (key) |
79 | { | 79 | { |
... | @@ -106,7 +106,7 @@ opt_handler (int key, char *arg, void *unused) | ... | @@ -106,7 +106,7 @@ opt_handler (int key, char *arg, void *unused) |
106 | width = strtoul (arg, NULL, 0); | 106 | width = strtoul (arg, NULL, 0); |
107 | if (!width) | 107 | if (!width) |
108 | { | 108 | { |
109 | mh_error (_("Invalid width")); | 109 | argp_error (state, _("Invalid width")); |
110 | exit (1); | 110 | exit (1); |
111 | } | 111 | } |
112 | break; | 112 | break; |
... | @@ -115,7 +115,7 @@ opt_handler (int key, char *arg, void *unused) | ... | @@ -115,7 +115,7 @@ opt_handler (int key, char *arg, void *unused) |
115 | length = strtoul (arg, NULL, 0); | 115 | length = strtoul (arg, NULL, 0); |
116 | if (!length) | 116 | if (!length) |
117 | { | 117 | { |
118 | mh_error (_("Invalid length")); | 118 | argp_error (state, _("Invalid length")); |
119 | exit (1); | 119 | exit (1); |
120 | } | 120 | } |
121 | break; | 121 | break; |
... | @@ -212,7 +212,7 @@ main (int argc, char **argv) | ... | @@ -212,7 +212,7 @@ main (int argc, char **argv) |
212 | interactive = isatty (1) && isatty (0); | 212 | interactive = isatty (1) && isatty (0); |
213 | 213 | ||
214 | mu_init_nls (); | 214 | mu_init_nls (); |
215 | mh_argp_parse (argc, argv, options, mh_option, args_doc, doc, | 215 | mh_argp_parse (argc, argv, 0, options, mh_option, args_doc, doc, |
216 | opt_handler, NULL, &index); | 216 | opt_handler, NULL, &index); |
217 | 217 | ||
218 | format = mhl_format_compile (formfile); | 218 | format = mhl_format_compile (formfile); | ... | ... |
... | @@ -37,7 +37,7 @@ struct mh_option mh_option[] = { | ... | @@ -37,7 +37,7 @@ struct mh_option mh_option[] = { |
37 | }; | 37 | }; |
38 | 38 | ||
39 | static int | 39 | static int |
40 | opt_handler (int key, char *arg, void *unused) | 40 | opt_handler (int key, char *arg, void *unused, struct argp_state *state) |
41 | { | 41 | { |
42 | switch (key) | 42 | switch (key) |
43 | { | 43 | { |
... | @@ -75,7 +75,7 @@ main (int argc, char **argv) | ... | @@ -75,7 +75,7 @@ main (int argc, char **argv) |
75 | /* Native Language Support */ | 75 | /* Native Language Support */ |
76 | mu_init_nls (); | 76 | mu_init_nls (); |
77 | 77 | ||
78 | mh_argp_parse (argc, argv, options, mh_option, args_doc, doc, | 78 | mh_argp_parse (argc, argv, 0, options, mh_option, args_doc, doc, |
79 | opt_handler, NULL, &index); | 79 | opt_handler, NULL, &index); |
80 | 80 | ||
81 | /* If the only argument is `+', your MH Path is output; this | 81 | /* If the only argument is `+', your MH Path is output; this | ... | ... |
... | @@ -145,7 +145,7 @@ close_folders () | ... | @@ -145,7 +145,7 @@ close_folders () |
145 | } | 145 | } |
146 | 146 | ||
147 | static int | 147 | static int |
148 | opt_handler (int key, char *arg, void *unused) | 148 | opt_handler (int key, char *arg, void *unused, struct argp_state *state) |
149 | { | 149 | { |
150 | switch (key) | 150 | switch (key) |
151 | { | 151 | { |
... | @@ -223,7 +223,7 @@ main (int argc, char **argv) | ... | @@ -223,7 +223,7 @@ main (int argc, char **argv) |
223 | /* Native Language Support */ | 223 | /* Native Language Support */ |
224 | mu_init_nls (); | 224 | mu_init_nls (); |
225 | 225 | ||
226 | mh_argp_parse (argc, argv, options, mh_option, args_doc, doc, | 226 | mh_argp_parse (argc, argv, 0, options, mh_option, args_doc, doc, |
227 | opt_handler, NULL, &index); | 227 | opt_handler, NULL, &index); |
228 | 228 | ||
229 | open_folders (); | 229 | open_folders (); | ... | ... |
... | @@ -123,7 +123,7 @@ decode_cc_flag (const char *opt, const char *arg) | ... | @@ -123,7 +123,7 @@ decode_cc_flag (const char *opt, const char *arg) |
123 | } | 123 | } |
124 | 124 | ||
125 | static int | 125 | static int |
126 | opt_handler (int key, char *arg, void *unused) | 126 | opt_handler (int key, char *arg, void *unused, struct argp_state *state) |
127 | { | 127 | { |
128 | char *s; | 128 | char *s; |
129 | 129 | ||
... | @@ -172,7 +172,7 @@ opt_handler (int key, char *arg, void *unused) | ... | @@ -172,7 +172,7 @@ opt_handler (int key, char *arg, void *unused) |
172 | width = strtoul (arg, NULL, 0); | 172 | width = strtoul (arg, NULL, 0); |
173 | if (!width) | 173 | if (!width) |
174 | { | 174 | { |
175 | mh_error (_("Invalid width")); | 175 | argp_error (state, _("Invalid width")); |
176 | exit (1); | 176 | exit (1); |
177 | } | 177 | } |
178 | break; | 178 | break; |
... | @@ -198,7 +198,7 @@ opt_handler (int key, char *arg, void *unused) | ... | @@ -198,7 +198,7 @@ opt_handler (int key, char *arg, void *unused) |
198 | case ARG_INPLACE: | 198 | case ARG_INPLACE: |
199 | case ARG_WHATNOWPROC: | 199 | case ARG_WHATNOWPROC: |
200 | case ARG_NOWHATNOWPROC: | 200 | case ARG_NOWHATNOWPROC: |
201 | mh_error (_("option is not yet implemented")); | 201 | argp_error (state, _("option is not yet implemented")); |
202 | exit (1); | 202 | exit (1); |
203 | 203 | ||
204 | default: | 204 | default: |
... | @@ -318,7 +318,7 @@ main (int argc, char **argv) | ... | @@ -318,7 +318,7 @@ main (int argc, char **argv) |
318 | /* Native Language Support */ | 318 | /* Native Language Support */ |
319 | mu_init_nls (); | 319 | mu_init_nls (); |
320 | 320 | ||
321 | mh_argp_parse (argc, argv, options, mh_option, args_doc, doc, | 321 | mh_argp_parse (argc, argv, 0, options, mh_option, args_doc, doc, |
322 | opt_handler, NULL, &index); | 322 | opt_handler, NULL, &index); |
323 | if (mh_format_parse (format_str, &format)) | 323 | if (mh_format_parse (format_str, &format)) |
324 | { | 324 | { | ... | ... |
... | @@ -55,7 +55,7 @@ int interactive; /* Ask for confirmation before deleting */ | ... | @@ -55,7 +55,7 @@ int interactive; /* Ask for confirmation before deleting */ |
55 | int recurse; /* Recursively process all the sub-directories */ | 55 | int recurse; /* Recursively process all the sub-directories */ |
56 | 56 | ||
57 | static int | 57 | static int |
58 | opt_handler (int key, char *arg, void *unused) | 58 | opt_handler (int key, char *arg, void *unused, struct argp_state *state) |
59 | { | 59 | { |
60 | switch (key) | 60 | switch (key) |
61 | { | 61 | { |
... | @@ -134,7 +134,7 @@ main (int argc, char **argv) | ... | @@ -134,7 +134,7 @@ main (int argc, char **argv) |
134 | /* Native Language Support */ | 134 | /* Native Language Support */ |
135 | mu_init_nls (); | 135 | mu_init_nls (); |
136 | 136 | ||
137 | mh_argp_parse (argc, argv, options, mh_option, args_doc, doc, | 137 | mh_argp_parse (argc, argv, 0, options, mh_option, args_doc, doc, |
138 | opt_handler, NULL, NULL); | 138 | opt_handler, NULL, NULL); |
139 | if (!explicit_folder) | 139 | if (!explicit_folder) |
140 | interactive = 1; | 140 | interactive = 1; | ... | ... |
... | @@ -37,7 +37,7 @@ struct mh_option mh_option[] = { | ... | @@ -37,7 +37,7 @@ struct mh_option mh_option[] = { |
37 | }; | 37 | }; |
38 | 38 | ||
39 | static int | 39 | static int |
40 | opt_handler (int key, char *arg, void *unused) | 40 | opt_handler (int key, char *arg, void *unused, struct argp_state *state) |
41 | { | 41 | { |
42 | switch (key) | 42 | switch (key) |
43 | { | 43 | { |
... | @@ -71,7 +71,7 @@ main (int argc, char **argv) | ... | @@ -71,7 +71,7 @@ main (int argc, char **argv) |
71 | /* Native Language Support */ | 71 | /* Native Language Support */ |
72 | mu_init_nls (); | 72 | mu_init_nls (); |
73 | 73 | ||
74 | mh_argp_parse (argc, argv, options, mh_option, args_doc, doc, | 74 | mh_argp_parse (argc, argv, 0, options, mh_option, args_doc, doc, |
75 | opt_handler, NULL, &index); | 75 | opt_handler, NULL, &index); |
76 | 76 | ||
77 | mbox = mh_open_folder (current_folder, 0); | 77 | mbox = mh_open_folder (current_folder, 0); | ... | ... |
... | @@ -84,7 +84,7 @@ void print_header __P((mailbox_t mbox)); | ... | @@ -84,7 +84,7 @@ void print_header __P((mailbox_t mbox)); |
84 | void clear_screen __P((void)); | 84 | void clear_screen __P((void)); |
85 | 85 | ||
86 | static int | 86 | static int |
87 | opt_handler (int key, char *arg, void *unused) | 87 | opt_handler (int key, char *arg, void *unused, struct argp_state *state) |
88 | { | 88 | { |
89 | switch (key) | 89 | switch (key) |
90 | { | 90 | { |
... | @@ -113,7 +113,7 @@ opt_handler (int key, char *arg, void *unused) | ... | @@ -113,7 +113,7 @@ opt_handler (int key, char *arg, void *unused) |
113 | width = strtoul (arg, NULL, 0); | 113 | width = strtoul (arg, NULL, 0); |
114 | if (!width) | 114 | if (!width) |
115 | { | 115 | { |
116 | mh_error (_("Invalid width")); | 116 | argp_error (state, _("Invalid width")); |
117 | exit (1); | 117 | exit (1); |
118 | } | 118 | } |
119 | break; | 119 | break; |
... | @@ -123,7 +123,7 @@ opt_handler (int key, char *arg, void *unused) | ... | @@ -123,7 +123,7 @@ opt_handler (int key, char *arg, void *unused) |
123 | break; | 123 | break; |
124 | 124 | ||
125 | case ARG_FILE: | 125 | case ARG_FILE: |
126 | mh_error (_("option is not yet implemented")); | 126 | argp_error (state, _("option is not yet implemented")); |
127 | break; | 127 | break; |
128 | 128 | ||
129 | case ARG_LICENSE: | 129 | case ARG_LICENSE: |
... | @@ -166,7 +166,7 @@ main (int argc, char **argv) | ... | @@ -166,7 +166,7 @@ main (int argc, char **argv) |
166 | /* Native Language Support */ | 166 | /* Native Language Support */ |
167 | mu_init_nls (); | 167 | mu_init_nls (); |
168 | 168 | ||
169 | mh_argp_parse (argc, argv, options, mh_option, args_doc, doc, | 169 | mh_argp_parse (argc, argv, 0, options, mh_option, args_doc, doc, |
170 | opt_handler, NULL, &index); | 170 | opt_handler, NULL, &index); |
171 | 171 | ||
172 | if (mh_format_parse (format_str, &format)) | 172 | if (mh_format_parse (format_str, &format)) | ... | ... |
... | @@ -118,7 +118,7 @@ static unsigned width = 76; /* Maximum width of header fields */ | ... | @@ -118,7 +118,7 @@ static unsigned width = 76; /* Maximum width of header fields */ |
118 | } while (0) | 118 | } while (0) |
119 | 119 | ||
120 | static int | 120 | static int |
121 | opt_handler (int key, char *arg, void *unused) | 121 | opt_handler (int key, char *arg, void *unused, struct argp_state *state) |
122 | { | 122 | { |
123 | char *p; | 123 | char *p; |
124 | 124 | ||
... | @@ -194,7 +194,7 @@ opt_handler (int key, char *arg, void *unused) | ... | @@ -194,7 +194,7 @@ opt_handler (int key, char *arg, void *unused) |
194 | split_interval = strtoul(arg, &p, 10); | 194 | split_interval = strtoul(arg, &p, 10); |
195 | if (*p) | 195 | if (*p) |
196 | { | 196 | { |
197 | mh_error (_("Invalid number")); | 197 | argp_error (state, _("Invalid number")); |
198 | exit (1); | 198 | exit (1); |
199 | } | 199 | } |
200 | break; | 200 | break; |
... | @@ -219,7 +219,7 @@ opt_handler (int key, char *arg, void *unused) | ... | @@ -219,7 +219,7 @@ opt_handler (int key, char *arg, void *unused) |
219 | width = strtoul(arg, &p, 10); | 219 | width = strtoul(arg, &p, 10); |
220 | if (*p) | 220 | if (*p) |
221 | { | 221 | { |
222 | mh_error (_("Invalid number")); | 222 | argp_error (state, _("Invalid number")); |
223 | exit (1); | 223 | exit (1); |
224 | } | 224 | } |
225 | break; | 225 | break; |
... | @@ -447,7 +447,7 @@ main (int argc, char **argv) | ... | @@ -447,7 +447,7 @@ main (int argc, char **argv) |
447 | 447 | ||
448 | mu_init_nls (); | 448 | mu_init_nls (); |
449 | 449 | ||
450 | mh_argp_parse (argc, argv, options, mh_option, args_doc, doc, | 450 | mh_argp_parse (argc, argv, 0, options, mh_option, args_doc, doc, |
451 | opt_handler, NULL, &index); | 451 | opt_handler, NULL, &index); |
452 | 452 | ||
453 | argc -= index; | 453 | argc -= index; | ... | ... |
... | @@ -52,7 +52,7 @@ struct mh_whatnow_env wh_env = { 0 }; | ... | @@ -52,7 +52,7 @@ struct mh_whatnow_env wh_env = { 0 }; |
52 | static int initial_edit = 1; | 52 | static int initial_edit = 1; |
53 | 53 | ||
54 | static int | 54 | static int |
55 | opt_handler (int key, char *arg, void *unused) | 55 | opt_handler (int key, char *arg, void *unused, struct argp_state *state) |
56 | { | 56 | { |
57 | switch (key) | 57 | switch (key) |
58 | { | 58 | { |
... | @@ -93,7 +93,7 @@ main (int argc, char **argv) | ... | @@ -93,7 +93,7 @@ main (int argc, char **argv) |
93 | 93 | ||
94 | mu_init_nls (); | 94 | mu_init_nls (); |
95 | 95 | ||
96 | mh_argp_parse (argc, argv, options, mh_option, args_doc, doc, | 96 | mh_argp_parse (argc, argv, 0, options, mh_option, args_doc, doc, |
97 | opt_handler, NULL, &index); | 97 | opt_handler, NULL, &index); |
98 | 98 | ||
99 | wh_env.msg = getenv ("mhaltmsg"); | 99 | wh_env.msg = getenv ("mhaltmsg"); | ... | ... |
-
Please register or sign in to post a comment