38 |
#include <argp.h> |
#include <argp.h> |
39 |
|
|
40 |
#include "sieve.h" |
#include "sieve.h" |
41 |
|
#include "sieve_interface.h" |
42 |
|
|
43 |
#include <mailutils/argp.h> |
#include <mailutils/argp.h> |
44 |
#include <mailutils/auth.h> |
#include <mailutils/auth.h> |
58 |
"GNU sieve -- a mail filtering tool\n" |
"GNU sieve -- a mail filtering tool\n" |
59 |
"\v" |
"\v" |
60 |
"Debug flags:\n" |
"Debug flags:\n" |
61 |
|
" a - address parser traces\n" |
62 |
|
" g - main parser traces\n" |
63 |
" T - mailutil traces (MU_DEBUG_TRACE)\n" |
" T - mailutil traces (MU_DEBUG_TRACE)\n" |
64 |
" P - network protocols (MU_DEBUG_PROT)\n" |
" P - network protocols (MU_DEBUG_PROT)\n" |
65 |
" t - sieve trace (SV_DEBUG_TRACE)\n" |
" t - sieve trace (SV_DEBUG_TRACE)\n" |
153 |
case 'T': |
case 'T': |
154 |
opts->debug_level |= MU_DEBUG_TRACE; |
opts->debug_level |= MU_DEBUG_TRACE; |
155 |
break; |
break; |
156 |
|
|
157 |
case 'P': |
case 'P': |
158 |
opts->debug_level |= MU_DEBUG_PROT; |
opts->debug_level |= MU_DEBUG_PROT; |
159 |
break; |
break; |
160 |
|
|
161 |
case 't': |
case 't': |
162 |
opts->debug_level |= SV_DEBUG_TRACE; |
opts->debug_level |= SV_DEBUG_TRACE; |
163 |
break; |
break; |
164 |
|
|
165 |
case 'h': |
case 'h': |
166 |
opts->debug_level |= SV_DEBUG_HDR_FILL; |
opts->debug_level |= SV_DEBUG_HDR_FILL; |
167 |
break; |
break; |
168 |
|
|
169 |
case 'q': |
case 'q': |
170 |
opts->debug_level |= SV_DEBUG_MSG_QUERY; |
opts->debug_level |= SV_DEBUG_MSG_QUERY; |
171 |
break; |
break; |
172 |
|
|
173 |
|
case 'g': |
174 |
|
yydebug = 1; |
175 |
|
break; |
176 |
|
|
177 |
|
case 'a': |
178 |
|
addrdebug = 1; |
179 |
|
break; |
180 |
|
|
181 |
default: |
default: |
182 |
argp_error (state, "%c is not a valid debug flag", *arg); |
argp_error (state, "%c is not a valid debug flag", *arg); |
183 |
break; |
break; |
208 |
doc |
doc |
209 |
}; |
}; |
210 |
|
|
211 |
|
static const char *sieve_argp_capa[] = { |
212 |
|
"common", |
213 |
|
"mailbox", |
214 |
|
"license", |
215 |
|
NULL |
216 |
|
}; |
217 |
|
|
218 |
|
char *sieve_license_text = |
219 |
|
" Copyright 1999 by Carnegie Mellon University\n" |
220 |
|
" Copyright 1999,2001,2002 by Free Software Foundation\n" |
221 |
|
"\n" |
222 |
|
" Permission to use, copy, modify, and distribute this software and its\n" |
223 |
|
" documentation for any purpose and without fee is hereby granted,\n" |
224 |
|
" provided that the above copyright notice appear in all copies and that\n" |
225 |
|
" both that copyright notice and this permission notice appear in\n" |
226 |
|
" supporting documentation, and that the name of Carnegie Mellon\n" |
227 |
|
" University not be used in advertising or publicity pertaining to\n" |
228 |
|
" distribution of the software without specific, written prior\n" |
229 |
|
" permission.\n"; |
230 |
|
|
231 |
|
|
232 |
static void |
static void |
233 |
parse_error (const char *script, int lineno, const char *errmsg) |
parse_error (const char *script, int lineno, const char *errmsg) |
234 |
{ |
{ |
285 |
mailbox_t mbox = 0; |
mailbox_t mbox = 0; |
286 |
|
|
287 |
struct options opts = { 0 }; |
struct options opts = { 0 }; |
|
/*const char* capa[] = { 0 };*/ |
|
288 |
|
|
289 |
size_t count = 0; |
size_t count = 0; |
290 |
int msgno = 0; |
int msgno = 0; |
291 |
|
|
292 |
int rc = 0; |
int rc = 0; |
293 |
|
|
294 |
rc = mu_argp_parse(&argp, &argc, &argv, ARGP_IN_ORDER, 0, 0, &opts); |
/* Override license text: */ |
295 |
|
mu_license_text = sieve_license_text; |
296 |
|
rc = mu_argp_parse(&argp, &argc, &argv, ARGP_IN_ORDER, sieve_argp_capa, |
297 |
|
0, &opts); |
298 |
|
|
299 |
if(rc) { |
if (rc) { |
300 |
fprintf (stderr, "arg parsing failed: %s\n", sv_strerror (rc)); |
fprintf (stderr, "arg parsing failed: %s\n", sv_strerror (rc)); |
301 |
return 1; |
return 1; |
302 |
} |
} |