1.1.2
by Martin Pitt
Import upstream version 1.5.11+cvs20060403 |
1 |
/*
|
2 |
* Copyright (C) 1996-2002 Michael R. Elkins <me@mutt.org>
|
|
3 |
* Copyright (C) 1999-2002 Thomas Roessler <roessler@does-not-exist.org>
|
|
4 |
* Copyright (C) 2004 g10 Code GmbH
|
|
5 |
*
|
|
6 |
* This program is free software; you can redistribute it and/or modify
|
|
7 |
* it under the terms of the GNU General Public License as published by
|
|
8 |
* the Free Software Foundation; either version 2 of the License, or
|
|
9 |
* (at your option) any later version.
|
|
10 |
*
|
|
11 |
* This program is distributed in the hope that it will be useful,
|
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14 |
* GNU General Public License for more details.
|
|
15 |
*
|
|
16 |
* You should have received a copy of the GNU General Public License
|
|
17 |
* along with this program; if not, write to the Free Software
|
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
19 |
*/
|
|
20 |
||
21 |
#define MAIN_C 1
|
|
22 |
||
23 |
#if HAVE_CONFIG_H
|
|
24 |
# include "config.h"
|
|
25 |
#endif
|
|
26 |
||
27 |
#include "mutt.h" |
|
28 |
#include "mutt_curses.h" |
|
29 |
#include "keymap.h" |
|
30 |
#include "mailbox.h" |
|
31 |
#include "url.h" |
|
32 |
#include "mutt_crypt.h" |
|
33 |
#include "mutt_idna.h" |
|
34 |
||
35 |
#ifdef USE_SASL
|
|
36 |
#include "mutt_sasl.h" |
|
37 |
#endif
|
|
38 |
||
39 |
#ifdef USE_IMAP
|
|
40 |
#include "imap/imap.h" |
|
41 |
#endif
|
|
42 |
||
43 |
#include <string.h> |
|
44 |
#include <stdlib.h> |
|
45 |
#include <locale.h> |
|
46 |
#include <unistd.h> |
|
47 |
#include <errno.h> |
|
48 |
#include <sys/stat.h> |
|
49 |
#include <sys/utsname.h> |
|
50 |
||
51 |
#ifdef HAVE_GETOPT_H
|
|
52 |
#include <getopt.h> |
|
53 |
#endif
|
|
54 |
||
55 |
#ifdef HAVE_LIBIDN
|
|
56 |
#include <stringprep.h> |
|
57 |
#endif
|
|
58 |
||
59 |
static const char *ReachingUs = N_("\ |
|
60 |
To contact the developers, please mail to <mutt-dev@mutt.org>.\n\ |
|
61 |
To report a bug, please visit http://bugs.mutt.org/.\n"); |
|
62 |
||
63 |
static const char *Notice = N_("\ |
|
1.1.5
by Christoph Berg
Import upstream version 1.5.15+20070412 |
64 |
Copyright (C) 1996-2007 Michael R. Elkins and others.\n\ |
1.1.2
by Martin Pitt
Import upstream version 1.5.11+cvs20060403 |
65 |
Mutt comes with ABSOLUTELY NO WARRANTY; for details type `mutt -vv'.\n\ |
66 |
Mutt is free software, and you are welcome to redistribute it\n\ |
|
67 |
under certain conditions; type `mutt -vv' for details.\n"); |
|
68 |
||
69 |
static const char *Copyright = N_("\ |
|
70 |
Copyright (C) 1996-2004 Michael R. Elkins <me@mutt.org>\n\ |
|
71 |
Copyright (C) 1996-2002 Brandon Long <blong@fiction.net>\n\ |
|
1.1.5
by Christoph Berg
Import upstream version 1.5.15+20070412 |
72 |
Copyright (C) 1997-2007 Thomas Roessler <roessler@does-not-exist.org>\n\ |
1.1.2
by Martin Pitt
Import upstream version 1.5.11+cvs20060403 |
73 |
Copyright (C) 1998-2005 Werner Koch <wk@isil.d.shuttle.de>\n\ |
1.1.5
by Christoph Berg
Import upstream version 1.5.15+20070412 |
74 |
Copyright (C) 1999-2007 Brendan Cully <brendan@kublai.com>\n\ |
1.1.2
by Martin Pitt
Import upstream version 1.5.11+cvs20060403 |
75 |
Copyright (C) 1999-2002 Tommi Komulainen <Tommi.Komulainen@iki.fi>\n\ |
76 |
Copyright (C) 2000-2002 Edmund Grimley Evans <edmundo@rano.org>\n\ |
|
77 |
\n\ |
|
78 |
Many others not mentioned here contributed code, fixes,\n\ |
|
79 |
and suggestions.\n"); |
|
80 |
||
81 |
static const char *Licence = N_("\ |
|
82 |
This program is free software; you can redistribute it and/or modify\n\ |
|
83 |
it under the terms of the GNU General Public License as published by\n\ |
|
84 |
the Free Software Foundation; either version 2 of the License, or\n\ |
|
85 |
(at your option) any later version.\n\ |
|
86 |
\n\ |
|
87 |
This program is distributed in the hope that it will be useful,\n\ |
|
88 |
but WITHOUT ANY WARRANTY; without even the implied warranty of\n\ |
|
89 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\ |
|
90 |
GNU General Public License for more details.\n"); |
|
91 |
static const char *Obtaining = N_("\ |
|
92 |
You should have received a copy of the GNU General Public License\n\ |
|
93 |
along with this program; if not, write to the Free Software\n\ |
|
94 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\n\ |
|
95 |
"); |
|
96 |
||
97 |
void mutt_exit (int code) |
|
98 |
{
|
|
99 |
mutt_endwin (NULL); |
|
100 |
exit (code); |
|
101 |
}
|
|
102 |
||
103 |
static void mutt_usage (void) |
|
104 |
{
|
|
105 |
puts (mutt_make_version ()); |
|
106 |
||
107 |
puts _( |
|
1.1.5
by Christoph Berg
Import upstream version 1.5.15+20070412 |
108 |
"usage: mutt [<options>] [-z] [-f <file> | -yZ]\n\ |
109 |
mutt [<options>] [-x] [-Hi <file>] [-s <subj>] [-bc <addr>] [-a <file> [...]] [--] <addr> [...]\n\ |
|
110 |
mutt [<options>] -p\n\ |
|
111 |
mutt [<options>] -A <alias> [...]\n\ |
|
112 |
mutt [<options>] -Q <query> [...]\n\ |
|
113 |
mutt [<options>] -D\n\ |
|
1.1.2
by Martin Pitt
Import upstream version 1.5.11+cvs20060403 |
114 |
mutt -v[v]\n"); |
115 |
||
116 |
puts _("\ |
|
117 |
options:\n\ |
|
118 |
-A <alias>\texpand the given alias\n\ |
|
119 |
-a <file>\tattach a file to the message\n\ |
|
120 |
-b <address>\tspecify a blind carbon-copy (BCC) address\n\ |
|
121 |
-c <address>\tspecify a carbon-copy (CC) address\n\ |
|
122 |
-D\t\tprint the value of all variables to stdout"); |
|
123 |
#if DEBUG
|
|
124 |
puts _(" -d <level>\tlog debugging output to ~/.muttdebug0"); |
|
125 |
#endif
|
|
126 |
puts _( |
|
127 |
" -e <command>\tspecify a command to be executed after initialization\n\ |
|
128 |
-f <file>\tspecify which mailbox to read\n\ |
|
129 |
-F <file>\tspecify an alternate muttrc file\n\ |
|
130 |
-H <file>\tspecify a draft file to read header and body from\n\ |
|
131 |
-i <file>\tspecify a file which Mutt should include in the body\n\ |
|
132 |
-m <type>\tspecify a default mailbox type\n\ |
|
133 |
-n\t\tcauses Mutt not to read the system Muttrc\n\ |
|
134 |
-p\t\trecall a postponed message"); |
|
135 |
||
136 |
puts _("\ |
|
137 |
-Q <variable>\tquery a configuration variable\n\ |
|
138 |
-R\t\topen mailbox in read-only mode\n\ |
|
139 |
-s <subj>\tspecify a subject (must be in quotes if it has spaces)\n\ |
|
140 |
-v\t\tshow version and compile-time definitions\n\ |
|
141 |
-x\t\tsimulate the mailx send mode\n\ |
|
142 |
-y\t\tselect a mailbox specified in your `mailboxes' list\n\ |
|
143 |
-z\t\texit immediately if there are no messages in the mailbox\n\ |
|
144 |
-Z\t\topen the first folder with new message, exit immediately if none\n\ |
|
145 |
-h\t\tthis help message"); |
|
1.1.5
by Christoph Berg
Import upstream version 1.5.15+20070412 |
146 |
puts _(" --\t\ttreat remaining arguments as addr even if starting with a dash\n\ |
147 |
\t\twhen using -a with multiple filenames using -- is mandatory"); |
|
1.1.2
by Martin Pitt
Import upstream version 1.5.11+cvs20060403 |
148 |
|
149 |
exit (0); |
|
150 |
}
|
|
151 |
||
152 |
static void show_version (void) |
|
153 |
{
|
|
154 |
struct utsname uts; |
|
155 |
||
156 |
puts (mutt_make_version()); |
|
157 |
puts (_(Notice)); |
|
158 |
||
159 |
uname (&uts); |
|
160 |
||
161 |
#ifdef _AIX
|
|
162 |
printf ("System: %s %s.%s", uts.sysname, uts.version, uts.release); |
|
163 |
#elif defined (SCO)
|
|
164 |
printf ("System: SCO %s", uts.release); |
|
165 |
#else
|
|
166 |
printf ("System: %s %s", uts.sysname, uts.release); |
|
167 |
#endif
|
|
168 |
||
169 |
printf (" (%s)", uts.machine); |
|
170 |
||
171 |
#ifdef NCURSES_VERSION
|
|
1.1.5
by Christoph Berg
Import upstream version 1.5.15+20070412 |
172 |
printf ("\nncurses: %s (compiled with %s)", curses_version(), NCURSES_VERSION); |
1.1.2
by Martin Pitt
Import upstream version 1.5.11+cvs20060403 |
173 |
#elif defined(USE_SLANG_CURSES)
|
1.1.5
by Christoph Berg
Import upstream version 1.5.15+20070412 |
174 |
printf ("\nslang: %d", SLANG_VERSION); |
1.1.2
by Martin Pitt
Import upstream version 1.5.11+cvs20060403 |
175 |
#endif
|
176 |
||
177 |
#ifdef _LIBICONV_VERSION
|
|
1.1.5
by Christoph Berg
Import upstream version 1.5.15+20070412 |
178 |
printf ("\nlibiconv: %d.%d", _LIBICONV_VERSION >> 8, |
1.1.2
by Martin Pitt
Import upstream version 1.5.11+cvs20060403 |
179 |
_LIBICONV_VERSION & 0xff); |
180 |
#endif
|
|
181 |
||
182 |
#ifdef HAVE_LIBIDN
|
|
1.1.5
by Christoph Berg
Import upstream version 1.5.15+20070412 |
183 |
printf ("\nlibidn: %s (compiled with %s)", stringprep_check_version (NULL), |
1.1.2
by Martin Pitt
Import upstream version 1.5.11+cvs20060403 |
184 |
STRINGPREP_VERSION); |
185 |
#endif
|
|
186 |
||
187 |
puts (_("\nCompile options:")); |
|
188 |
||
189 |
#ifdef DOMAIN
|
|
190 |
printf ("DOMAIN=\"%s\"\n", DOMAIN); |
|
191 |
#else
|
|
192 |
puts ("-DOMAIN"); |
|
193 |
#endif
|
|
194 |
||
195 |
#ifdef DEBUG
|
|
196 |
puts ("+DEBUG"); |
|
197 |
#else
|
|
198 |
puts ("-DEBUG"); |
|
199 |
#endif
|
|
200 |
||
201 |
||
202 |
||
203 |
puts ( |
|
204 |
||
205 |
#ifdef HOMESPOOL
|
|
206 |
"+HOMESPOOL "
|
|
207 |
#else
|
|
208 |
"-HOMESPOOL "
|
|
209 |
#endif
|
|
210 |
||
211 |
#ifdef USE_SETGID
|
|
212 |
"+USE_SETGID "
|
|
213 |
#else
|
|
214 |
"-USE_SETGID "
|
|
215 |
#endif
|
|
216 |
||
217 |
#ifdef USE_DOTLOCK
|
|
218 |
"+USE_DOTLOCK "
|
|
219 |
#else
|
|
220 |
"-USE_DOTLOCK "
|
|
221 |
#endif
|
|
222 |
||
223 |
#ifdef DL_STANDALONE
|
|
224 |
"+DL_STANDALONE "
|
|
225 |
#else
|
|
226 |
"-DL_STANDALONE "
|
|
227 |
#endif
|
|
228 |
||
229 |
"\n" |
|
230 |
||
231 |
#ifdef USE_FCNTL
|
|
232 |
"+USE_FCNTL "
|
|
233 |
#else
|
|
234 |
"-USE_FCNTL "
|
|
235 |
#endif
|
|
236 |
||
237 |
#ifdef USE_FLOCK
|
|
238 |
"+USE_FLOCK "
|
|
239 |
#else
|
|
240 |
"-USE_FLOCK "
|
|
241 |
#endif
|
|
242 |
||
243 |
#ifdef USE_INODESORT
|
|
244 |
"+USE_INODESORT "
|
|
245 |
#else
|
|
246 |
"-USE_INODESORT "
|
|
247 |
#endif
|
|
248 |
);
|
|
249 |
puts ( |
|
250 |
#ifdef USE_POP
|
|
251 |
"+USE_POP "
|
|
252 |
#else
|
|
253 |
"-USE_POP "
|
|
254 |
#endif
|
|
255 |
||
256 |
#ifdef USE_IMAP
|
|
257 |
"+USE_IMAP "
|
|
258 |
#else
|
|
259 |
"-USE_IMAP "
|
|
260 |
#endif
|
|
261 |
||
1.1.5
by Christoph Berg
Import upstream version 1.5.15+20070412 |
262 |
#ifdef USE_SMTP
|
263 |
"+USE_SMTP "
|
|
264 |
#else
|
|
265 |
"-USE_SMTP "
|
|
266 |
#endif
|
|
267 |
||
1.1.2
by Martin Pitt
Import upstream version 1.5.11+cvs20060403 |
268 |
#ifdef USE_GSS
|
269 |
"+USE_GSS "
|
|
270 |
#else
|
|
271 |
"-USE_GSS "
|
|
272 |
#endif
|
|
273 |
||
274 |
||
1.1.3
by Martin Pitt
Import upstream version 1.5.12 |
275 |
#ifdef USE_SSL_OPENSSL
|
276 |
"+USE_SSL_OPENSSL "
|
|
1.1.2
by Martin Pitt
Import upstream version 1.5.11+cvs20060403 |
277 |
#else
|
1.1.3
by Martin Pitt
Import upstream version 1.5.12 |
278 |
"-USE_SSL_OPENSSL "
|
1.1.2
by Martin Pitt
Import upstream version 1.5.11+cvs20060403 |
279 |
#endif
|
280 |
||
1.1.3
by Martin Pitt
Import upstream version 1.5.12 |
281 |
#ifdef USE_SSL_GNUTLS
|
282 |
"+USE_SSL_GNUTLS "
|
|
1.1.2
by Martin Pitt
Import upstream version 1.5.11+cvs20060403 |
283 |
#else
|
1.1.3
by Martin Pitt
Import upstream version 1.5.12 |
284 |
"-USE_SSL_GNUTLS "
|
1.1.2
by Martin Pitt
Import upstream version 1.5.11+cvs20060403 |
285 |
#endif
|
286 |
||
287 |
#ifdef USE_SASL
|
|
288 |
"+USE_SASL "
|
|
289 |
#else
|
|
290 |
"-USE_SASL "
|
|
291 |
#endif
|
|
292 |
||
293 |
#if HAVE_GETADDRINFO
|
|
294 |
"+HAVE_GETADDRINFO "
|
|
295 |
#else
|
|
296 |
"-HAVE_GETADDRINFO "
|
|
297 |
#endif
|
|
298 |
);
|
|
299 |
||
300 |
puts ( |
|
301 |
#ifdef HAVE_REGCOMP
|
|
302 |
"+HAVE_REGCOMP "
|
|
303 |
#else
|
|
304 |
"-HAVE_REGCOMP "
|
|
305 |
#endif
|
|
306 |
||
307 |
#ifdef USE_GNU_REGEX
|
|
308 |
"+USE_GNU_REGEX "
|
|
309 |
#else
|
|
310 |
"-USE_GNU_REGEX "
|
|
311 |
#endif
|
|
312 |
||
313 |
"\n" |
|
314 |
||
315 |
#ifdef HAVE_COLOR
|
|
316 |
"+HAVE_COLOR "
|
|
317 |
#else
|
|
318 |
"-HAVE_COLOR "
|
|
319 |
#endif
|
|
320 |
||
321 |
#ifdef HAVE_START_COLOR
|
|
322 |
"+HAVE_START_COLOR "
|
|
323 |
#else
|
|
324 |
"-HAVE_START_COLOR "
|
|
325 |
#endif
|
|
326 |
||
327 |
#ifdef HAVE_TYPEAHEAD
|
|
328 |
"+HAVE_TYPEAHEAD "
|
|
329 |
#else
|
|
330 |
"-HAVE_TYPEAHEAD "
|
|
331 |
#endif
|
|
332 |
||
333 |
#ifdef HAVE_BKGDSET
|
|
334 |
"+HAVE_BKGDSET "
|
|
335 |
#else
|
|
336 |
"-HAVE_BKGDSET "
|
|
337 |
#endif
|
|
338 |
||
339 |
"\n" |
|
340 |
||
341 |
#ifdef HAVE_CURS_SET
|
|
342 |
"+HAVE_CURS_SET "
|
|
343 |
#else
|
|
344 |
"-HAVE_CURS_SET "
|
|
345 |
#endif
|
|
346 |
||
347 |
#ifdef HAVE_META
|
|
348 |
"+HAVE_META "
|
|
349 |
#else
|
|
350 |
"-HAVE_META "
|
|
351 |
#endif
|
|
352 |
||
353 |
#ifdef HAVE_RESIZETERM
|
|
354 |
"+HAVE_RESIZETERM "
|
|
355 |
#else
|
|
356 |
"-HAVE_RESIZETERM "
|
|
357 |
#endif
|
|
358 |
);
|
|
359 |
||
360 |
puts ( |
|
361 |
#ifdef CRYPT_BACKEND_CLASSIC_PGP
|
|
362 |
"+CRYPT_BACKEND_CLASSIC_PGP "
|
|
363 |
#else
|
|
364 |
"-CRYPT_BACKEND_CLASSIC_PGP "
|
|
365 |
#endif
|
|
366 |
#ifdef CRYPT_BACKEND_CLASSIC_SMIME
|
|
367 |
"+CRYPT_BACKEND_CLASSIC_SMIME "
|
|
368 |
#else
|
|
369 |
"-CRYPT_BACKEND_CLASSIC_SMIME "
|
|
370 |
#endif
|
|
371 |
#ifdef CRYPT_BACKEND_GPGME
|
|
372 |
"+CRYPT_BACKEND_GPGME "
|
|
373 |
#else
|
|
374 |
"-CRYPT_BACKEND_GPGME "
|
|
375 |
#endif
|
|
376 |
);
|
|
377 |
||
378 |
puts ( |
|
379 |
#ifdef EXACT_ADDRESS
|
|
380 |
"+EXACT_ADDRESS "
|
|
381 |
#else
|
|
382 |
"-EXACT_ADDRESS "
|
|
383 |
#endif
|
|
384 |
||
385 |
#ifdef SUN_ATTACHMENT
|
|
386 |
"+SUN_ATTACHMENT "
|
|
387 |
#else
|
|
388 |
"-SUN_ATTACHMENT "
|
|
389 |
#endif
|
|
390 |
||
391 |
"\n" |
|
392 |
||
393 |
#ifdef ENABLE_NLS
|
|
394 |
"+ENABLE_NLS "
|
|
395 |
#else
|
|
396 |
"-ENABLE_NLS "
|
|
397 |
#endif
|
|
398 |
||
399 |
#ifdef LOCALES_HACK
|
|
400 |
"+LOCALES_HACK "
|
|
401 |
#else
|
|
402 |
"-LOCALES_HACK "
|
|
403 |
#endif
|
|
404 |
||
405 |
#ifdef HAVE_WC_FUNCS
|
|
406 |
"+HAVE_WC_FUNCS "
|
|
407 |
#else
|
|
408 |
"-HAVE_WC_FUNCS "
|
|
409 |
#endif
|
|
410 |
||
411 |
#ifdef HAVE_LANGINFO_CODESET
|
|
412 |
"+HAVE_LANGINFO_CODESET "
|
|
413 |
#else
|
|
414 |
"-HAVE_LANGINFO_CODESET "
|
|
415 |
#endif
|
|
416 |
||
417 |
||
418 |
#ifdef HAVE_LANGINFO_YESEXPR
|
|
419 |
"+HAVE_LANGINFO_YESEXPR "
|
|
420 |
#else
|
|
421 |
"-HAVE_LANGINFO_YESEXPR "
|
|
422 |
#endif
|
|
423 |
||
424 |
"\n" |
|
425 |
||
426 |
#if HAVE_ICONV
|
|
427 |
"+HAVE_ICONV "
|
|
428 |
#else
|
|
429 |
"-HAVE_ICONV "
|
|
430 |
#endif
|
|
431 |
||
432 |
#if ICONV_NONTRANS
|
|
433 |
"+ICONV_NONTRANS "
|
|
434 |
#else
|
|
435 |
"-ICONV_NONTRANS "
|
|
436 |
#endif
|
|
437 |
||
438 |
#if HAVE_LIBIDN
|
|
439 |
"+HAVE_LIBIDN "
|
|
440 |
#else
|
|
441 |
"-HAVE_LIBIDN "
|
|
442 |
#endif
|
|
443 |
||
444 |
#if HAVE_GETSID
|
|
445 |
"+HAVE_GETSID "
|
|
446 |
#else
|
|
447 |
"-HAVE_GETSID "
|
|
448 |
#endif
|
|
449 |
||
450 |
#if USE_HCACHE
|
|
451 |
"+USE_HCACHE "
|
|
452 |
#else
|
|
453 |
"-USE_HCACHE "
|
|
454 |
#endif
|
|
455 |
||
456 |
);
|
|
457 |
||
458 |
#ifdef ISPELL
|
|
459 |
printf ("ISPELL=\"%s\"\n", ISPELL); |
|
460 |
#else
|
|
461 |
puts ("-ISPELL"); |
|
462 |
#endif
|
|
463 |
||
464 |
printf ("SENDMAIL=\"%s\"\n", SENDMAIL); |
|
465 |
printf ("MAILPATH=\"%s\"\n", MAILPATH); |
|
466 |
printf ("PKGDATADIR=\"%s\"\n", PKGDATADIR); |
|
467 |
printf ("SYSCONFDIR=\"%s\"\n", SYSCONFDIR); |
|
468 |
printf ("EXECSHELL=\"%s\"\n", EXECSHELL); |
|
469 |
#ifdef MIXMASTER
|
|
470 |
printf ("MIXMASTER=\"%s\"\n", MIXMASTER); |
|
471 |
#else
|
|
472 |
puts ("-MIXMASTER"); |
|
473 |
#endif
|
|
474 |
||
475 |
puts(_(ReachingUs)); |
|
476 |
||
477 |
mutt_print_patchlist(); |
|
478 |
||
479 |
exit (0); |
|
480 |
}
|
|
481 |
||
482 |
static void start_curses (void) |
|
483 |
{
|
|
484 |
km_init (); /* must come before mutt_init */ |
|
485 |
||
486 |
#ifdef USE_SLANG_CURSES
|
|
487 |
SLtt_Ignore_Beep = 1; /* don't do that #*$@^! annoying visual beep! */ |
|
488 |
SLsmg_Display_Eight_Bit = 128; /* characters above this are printable */ |
|
489 |
SLtt_set_color(0, NULL, "default", "default"); |
|
1.1.3
by Martin Pitt
Import upstream version 1.5.12 |
490 |
#if SLANG_VERSION >= 20000
|
491 |
SLutf8_enable(-1); |
|
492 |
#endif
|
|
1.1.2
by Martin Pitt
Import upstream version 1.5.11+cvs20060403 |
493 |
#else
|
494 |
/* should come before initscr() so that ncurses 4.2 doesn't try to install
|
|
495 |
its own SIGWINCH handler */
|
|
496 |
mutt_signal_init (); |
|
497 |
#endif
|
|
498 |
if (initscr () == NULL) |
|
499 |
{
|
|
500 |
puts _("Error initializing terminal."); |
|
501 |
exit (1); |
|
502 |
}
|
|
503 |
#if 1 /* USE_SLANG_CURSES - commenting out suggested in #455. */ |
|
504 |
/* slang requires the signal handlers to be set after initializing */
|
|
505 |
mutt_signal_init (); |
|
506 |
#endif
|
|
507 |
ci_start_color (); |
|
508 |
keypad (stdscr, TRUE); |
|
509 |
cbreak (); |
|
510 |
noecho (); |
|
511 |
#if HAVE_TYPEAHEAD
|
|
512 |
typeahead (-1); /* simulate smooth scrolling */ |
|
513 |
#endif
|
|
514 |
#if HAVE_META
|
|
515 |
meta (stdscr, TRUE); |
|
516 |
#endif
|
|
517 |
}
|
|
518 |
||
519 |
#define M_IGNORE (1<<0) /* -z */ |
|
520 |
#define M_BUFFY (1<<1) /* -Z */ |
|
521 |
#define M_NOSYSRC (1<<2) /* -n */ |
|
522 |
#define M_RO (1<<3) /* -R */ |
|
523 |
#define M_SELECT (1<<4) /* -y */ |
|
524 |
||
525 |
int main (int argc, char **argv) |
|
526 |
{
|
|
527 |
char folder[_POSIX_PATH_MAX] = ""; |
|
528 |
char *subject = NULL; |
|
529 |
char *includeFile = NULL; |
|
530 |
char *draftFile = NULL; |
|
531 |
char *newMagic = NULL; |
|
532 |
HEADER *msg = NULL; |
|
533 |
LIST *attach = NULL; |
|
534 |
LIST *commands = NULL; |
|
535 |
LIST *queries = NULL; |
|
536 |
LIST *alias_queries = NULL; |
|
537 |
int sendflags = 0; |
|
538 |
int flags = 0; |
|
539 |
int version = 0; |
|
540 |
int i; |
|
541 |
int explicit_folder = 0; |
|
542 |
int dump_variables = 0; |
|
543 |
extern char *optarg; |
|
544 |
extern int optind; |
|
1.1.5
by Christoph Berg
Import upstream version 1.5.15+20070412 |
545 |
int attach_sep = 0; |
1.1.2
by Martin Pitt
Import upstream version 1.5.11+cvs20060403 |
546 |
|
547 |
/* sanity check against stupid administrators */
|
|
548 |
||
549 |
if(getegid() != getgid()) |
|
550 |
{
|
|
551 |
fprintf(stderr, "%s: I don't want to run with privileges!\n", |
|
552 |
argv[0]); |
|
553 |
exit(1); |
|
554 |
}
|
|
555 |
||
556 |
#ifdef ENABLE_NLS
|
|
557 |
/* FIXME what about init.c:1439 ? */
|
|
558 |
setlocale (LC_ALL, ""); |
|
559 |
bindtextdomain (PACKAGE, MUTTLOCALEDIR); |
|
560 |
textdomain (PACKAGE); |
|
561 |
#endif
|
|
562 |
||
563 |
setlocale (LC_CTYPE, ""); |
|
564 |
||
565 |
mutt_error = mutt_nocurses_error; |
|
566 |
mutt_message = mutt_nocurses_error; |
|
567 |
SRAND (time (NULL)); |
|
568 |
umask (077); |
|
569 |
||
570 |
memset (Options, 0, sizeof (Options)); |
|
571 |
memset (QuadOptions, 0, sizeof (QuadOptions)); |
|
1.1.5
by Christoph Berg
Import upstream version 1.5.15+20070412 |
572 |
|
573 |
for (i = 1; i < argc; i++) |
|
574 |
if (!strcmp(argv[i], "--")) |
|
575 |
{
|
|
576 |
attach_sep = i; |
|
577 |
break; |
|
578 |
}
|
|
579 |
||
1.1.2
by Martin Pitt
Import upstream version 1.5.11+cvs20060403 |
580 |
while ((i = getopt (argc, argv, "A:a:b:F:f:c:Dd:e:H:s:i:hm:npQ:RvxyzZ")) != EOF) |
581 |
switch (i) |
|
582 |
{
|
|
583 |
case 'A': |
|
584 |
alias_queries = mutt_add_list (alias_queries, optarg); |
|
585 |
break; |
|
586 |
case 'a': |
|
587 |
attach = mutt_add_list (attach, optarg); |
|
588 |
break; |
|
589 |
||
590 |
case 'F': |
|
591 |
mutt_str_replace (&Muttrc, optarg); |
|
592 |
break; |
|
593 |
||
594 |
case 'f': |
|
595 |
strfcpy (folder, optarg, sizeof (folder)); |
|
596 |
explicit_folder = 1; |
|
597 |
break; |
|
598 |
||
599 |
case 'b': |
|
600 |
case 'c': |
|
601 |
if (!msg) |
|
602 |
msg = mutt_new_header (); |
|
603 |
if (!msg->env) |
|
604 |
msg->env = mutt_new_envelope (); |
|
605 |
if (i == 'b') |
|
606 |
msg->env->bcc = rfc822_parse_adrlist (msg->env->bcc, optarg); |
|
607 |
else
|
|
608 |
msg->env->cc = rfc822_parse_adrlist (msg->env->cc, optarg); |
|
609 |
break; |
|
610 |
||
611 |
case 'D': |
|
612 |
dump_variables = 1; |
|
613 |
break; |
|
614 |
||
615 |
case 'd': |
|
616 |
#ifdef DEBUG
|
|
617 |
debuglevel = atoi (optarg); |
|
618 |
printf (_("Debugging at level %d.\n"), debuglevel); |
|
619 |
#else
|
|
620 |
printf _("DEBUG was not defined during compilation. Ignored.\n"); |
|
621 |
#endif
|
|
622 |
break; |
|
623 |
||
624 |
case 'e': |
|
625 |
commands = mutt_add_list (commands, optarg); |
|
626 |
break; |
|
627 |
||
628 |
case 'H': |
|
629 |
draftFile = optarg; |
|
630 |
break; |
|
631 |
||
632 |
case 'i': |
|
633 |
includeFile = optarg; |
|
634 |
break; |
|
635 |
||
636 |
case 'm': |
|
637 |
/* should take precedence over .muttrc setting, so save it for later */
|
|
638 |
newMagic = optarg; |
|
639 |
break; |
|
640 |
||
641 |
case 'n': |
|
642 |
flags |= M_NOSYSRC; |
|
643 |
break; |
|
644 |
||
645 |
case 'p': |
|
646 |
sendflags |= SENDPOSTPONED; |
|
647 |
break; |
|
648 |
||
649 |
case 'Q': |
|
650 |
queries = mutt_add_list (queries, optarg); |
|
651 |
break; |
|
652 |
||
653 |
case 'R': |
|
654 |
flags |= M_RO; /* read-only mode */ |
|
655 |
break; |
|
656 |
||
657 |
case 's': |
|
658 |
subject = optarg; |
|
659 |
break; |
|
660 |
||
661 |
case 'v': |
|
662 |
version++; |
|
663 |
break; |
|
664 |
||
665 |
case 'x': /* mailx compatible send mode */ |
|
666 |
sendflags |= SENDMAILX; |
|
667 |
break; |
|
668 |
||
669 |
case 'y': /* My special hack mode */ |
|
670 |
flags |= M_SELECT; |
|
671 |
break; |
|
672 |
||
673 |
case 'z': |
|
674 |
flags |= M_IGNORE; |
|
675 |
break; |
|
676 |
||
677 |
case 'Z': |
|
678 |
flags |= M_BUFFY | M_IGNORE; |
|
679 |
break; |
|
680 |
||
681 |
default: |
|
682 |
mutt_usage (); |
|
683 |
}
|
|
684 |
||
685 |
switch (version) |
|
686 |
{
|
|
687 |
case 0: |
|
688 |
break; |
|
689 |
case 1: |
|
690 |
show_version (); |
|
691 |
break; |
|
692 |
default: |
|
693 |
puts (mutt_make_version ()); |
|
694 |
puts (_(Copyright)); |
|
695 |
puts (_(Licence)); |
|
696 |
puts (_(Obtaining)); |
|
697 |
puts (_(ReachingUs)); |
|
698 |
exit (0); |
|
699 |
}
|
|
700 |
||
701 |
/* Check for a batch send. */
|
|
702 |
if (!isatty (0) || queries || alias_queries || dump_variables) |
|
703 |
{
|
|
704 |
set_option (OPTNOCURSES); |
|
705 |
sendflags = SENDBATCH; |
|
706 |
}
|
|
707 |
||
708 |
/* This must come before mutt_init() because curses needs to be started
|
|
709 |
before calling the init_pair() function to set the color scheme. */
|
|
710 |
if (!option (OPTNOCURSES)) |
|
711 |
start_curses (); |
|
712 |
||
713 |
/* set defaults and read init files */
|
|
714 |
mutt_init (flags & M_NOSYSRC, commands); |
|
715 |
mutt_free_list (&commands); |
|
716 |
||
717 |
/* Initialize crypto backends. */
|
|
718 |
crypt_init (); |
|
719 |
||
720 |
if (queries) |
|
1.1.5
by Christoph Berg
Import upstream version 1.5.15+20070412 |
721 |
{
|
722 |
for (; optind < argc; optind++) |
|
723 |
queries = mutt_add_list (queries, argv[optind]); |
|
1.1.2
by Martin Pitt
Import upstream version 1.5.11+cvs20060403 |
724 |
return mutt_query_variables (queries); |
1.1.5
by Christoph Berg
Import upstream version 1.5.15+20070412 |
725 |
}
|
1.1.2
by Martin Pitt
Import upstream version 1.5.11+cvs20060403 |
726 |
if (dump_variables) |
727 |
return mutt_dump_variables(); |
|
728 |
||
729 |
if (alias_queries) |
|
730 |
{
|
|
731 |
int rv = 0; |
|
732 |
ADDRESS *a; |
|
1.1.5
by Christoph Berg
Import upstream version 1.5.15+20070412 |
733 |
for (; optind < argc; optind++) |
734 |
alias_queries = mutt_add_list (alias_queries, argv[optind]); |
|
1.1.2
by Martin Pitt
Import upstream version 1.5.11+cvs20060403 |
735 |
for (; alias_queries; alias_queries = alias_queries->next) |
736 |
{
|
|
737 |
if ((a = mutt_lookup_alias (alias_queries->data))) |
|
738 |
{
|
|
739 |
/* output in machine-readable form */
|
|
740 |
mutt_addrlist_to_idna (a, NULL); |
|
741 |
mutt_write_address_list (a, stdout, 0, 0); |
|
742 |
}
|
|
743 |
else
|
|
744 |
{
|
|
745 |
rv = 1; |
|
746 |
printf ("%s\n", alias_queries->data); |
|
747 |
}
|
|
748 |
}
|
|
749 |
return rv; |
|
750 |
}
|
|
1.1.5
by Christoph Berg
Import upstream version 1.5.15+20070412 |
751 |
|
752 |
/* if an -a option is present, all non-option arguments before -- are considered attachments */
|
|
753 |
if (attach) |
|
754 |
for (; optind <= attach_sep; optind++) |
|
755 |
attach = mutt_add_list (attach, argv[optind]); |
|
756 |
||
1.1.2
by Martin Pitt
Import upstream version 1.5.11+cvs20060403 |
757 |
if (newMagic) |
758 |
mx_set_magic (newMagic); |
|
759 |
||
760 |
if (!option (OPTNOCURSES)) |
|
761 |
{
|
|
762 |
SETCOLOR (MT_COLOR_NORMAL); |
|
763 |
clear (); |
|
764 |
mutt_error = mutt_curses_error; |
|
765 |
mutt_message = mutt_curses_message; |
|
766 |
}
|
|
767 |
||
768 |
/* Create the Maildir directory if it doesn't exist. */
|
|
769 |
if (!option (OPTNOCURSES) && Maildir) |
|
770 |
{
|
|
771 |
struct stat sb; |
|
772 |
char fpath[_POSIX_PATH_MAX]; |
|
773 |
char msg[STRING]; |
|
774 |
||
775 |
strfcpy (fpath, Maildir, sizeof (fpath)); |
|
776 |
mutt_expand_path (fpath, sizeof (fpath)); |
|
777 |
#ifdef USE_IMAP
|
|
778 |
/* we're not connected yet - skip mail folder creation */
|
|
779 |
if (!mx_is_imap (fpath)) |
|
780 |
#endif
|
|
781 |
if (stat (fpath, &sb) == -1 && errno == ENOENT) |
|
782 |
{
|
|
783 |
snprintf (msg, sizeof (msg), _("%s does not exist. Create it?"), Maildir); |
|
784 |
if (mutt_yesorno (msg, M_YES) == M_YES) |
|
785 |
{
|
|
786 |
if (mkdir (fpath, 0700) == -1 && errno != EEXIST) |
|
787 |
mutt_error ( _("Can't create %s: %s."), Maildir, strerror (errno)); |
|
788 |
}
|
|
789 |
}
|
|
790 |
}
|
|
791 |
||
792 |
if (sendflags & SENDPOSTPONED) |
|
793 |
{
|
|
794 |
if (!option (OPTNOCURSES)) |
|
795 |
mutt_flushinp (); |
|
796 |
ci_send_message (SENDPOSTPONED, NULL, NULL, NULL, NULL); |
|
797 |
mutt_endwin (NULL); |
|
798 |
}
|
|
799 |
else if (subject || msg || sendflags || draftFile || includeFile || attach || |
|
800 |
optind < argc) |
|
801 |
{
|
|
802 |
FILE *fin = NULL; |
|
803 |
char buf[LONG_STRING]; |
|
804 |
char *tempfile = NULL, *infile = NULL; |
|
805 |
char *bodytext = NULL; |
|
1.1.5
by Christoph Berg
Import upstream version 1.5.15+20070412 |
806 |
int rv = 0; |
1.1.2
by Martin Pitt
Import upstream version 1.5.11+cvs20060403 |
807 |
|
808 |
if (!option (OPTNOCURSES)) |
|
809 |
mutt_flushinp (); |
|
810 |
||
811 |
if (!msg) |
|
812 |
msg = mutt_new_header (); |
|
813 |
||
814 |
if (draftFile) |
|
815 |
infile = draftFile; |
|
816 |
else
|
|
817 |
{
|
|
818 |
if (!msg->env) |
|
819 |
msg->env = mutt_new_envelope (); |
|
820 |
||
821 |
for (i = optind; i < argc; i++) |
|
822 |
{
|
|
823 |
if (url_check_scheme (argv[i]) == U_MAILTO) |
|
824 |
url_parse_mailto (msg->env, &bodytext, argv[i]); |
|
825 |
else
|
|
826 |
msg->env->to = rfc822_parse_adrlist (msg->env->to, argv[i]); |
|
827 |
}
|
|
828 |
||
829 |
if (option (OPTAUTOEDIT) && !msg->env->to && !msg->env->cc) |
|
830 |
{
|
|
831 |
if (!option (OPTNOCURSES)) |
|
832 |
mutt_endwin (NULL); |
|
833 |
fputs (_("No recipients specified.\n"), stderr); |
|
834 |
exit (1); |
|
835 |
}
|
|
836 |
||
837 |
if (subject) |
|
838 |
msg->env->subject = safe_strdup (subject); |
|
839 |
||
840 |
if (includeFile) |
|
841 |
infile = includeFile; |
|
842 |
}
|
|
843 |
||
844 |
if (infile || bodytext) |
|
845 |
{
|
|
846 |
if (infile) |
|
847 |
{
|
|
848 |
if (mutt_strcmp ("-", infile) == 0) |
|
849 |
fin = stdin; |
|
850 |
else
|
|
851 |
{
|
|
852 |
char path[_POSIX_PATH_MAX]; |
|
853 |
||
854 |
strfcpy (path, infile, sizeof (path)); |
|
855 |
mutt_expand_path (path, sizeof (path)); |
|
856 |
if ((fin = fopen (path, "r")) == NULL) |
|
857 |
{
|
|
858 |
if (!option (OPTNOCURSES)) |
|
859 |
mutt_endwin (NULL); |
|
860 |
perror (path); |
|
861 |
exit (1); |
|
862 |
}
|
|
863 |
}
|
|
864 |
}
|
|
865 |
else
|
|
866 |
fin = NULL; |
|
867 |
||
868 |
mutt_mktemp (buf); |
|
869 |
tempfile = safe_strdup (buf); |
|
870 |
||
871 |
if (draftFile) |
|
872 |
msg->env = mutt_read_rfc822_header (fin, NULL, 1, 0); |
|
873 |
||
874 |
/* is the following if still needed? */
|
|
875 |
||
876 |
if (tempfile) |
|
877 |
{
|
|
878 |
FILE *fout; |
|
879 |
||
880 |
if ((fout = safe_fopen (tempfile, "w")) == NULL) |
|
881 |
{
|
|
882 |
if (!option (OPTNOCURSES)) |
|
883 |
mutt_endwin (NULL); |
|
884 |
perror (tempfile); |
|
885 |
fclose (fin); |
|
886 |
FREE (&tempfile); |
|
887 |
exit (1); |
|
888 |
}
|
|
889 |
if (fin) |
|
890 |
mutt_copy_stream (fin, fout); |
|
891 |
else if (bodytext) |
|
892 |
fputs (bodytext, fout); |
|
893 |
fclose (fout); |
|
894 |
if (fin && fin != stdin) |
|
895 |
fclose (fin); |
|
896 |
}
|
|
897 |
}
|
|
898 |
||
899 |
FREE (&bodytext); |
|
900 |
||
901 |
if (attach) |
|
902 |
{
|
|
903 |
LIST *t = attach; |
|
904 |
BODY *a = NULL; |
|
905 |
||
906 |
while (t) |
|
907 |
{
|
|
908 |
if (a) |
|
909 |
{
|
|
910 |
a->next = mutt_make_file_attach (t->data); |
|
911 |
a = a->next; |
|
912 |
}
|
|
913 |
else
|
|
914 |
msg->content = a = mutt_make_file_attach (t->data); |
|
915 |
if (!a) |
|
916 |
{
|
|
917 |
if (!option (OPTNOCURSES)) |
|
918 |
mutt_endwin (NULL); |
|
919 |
fprintf (stderr, _("%s: unable to attach file.\n"), t->data); |
|
920 |
mutt_free_list (&attach); |
|
921 |
exit (1); |
|
922 |
}
|
|
923 |
t = t->next; |
|
924 |
}
|
|
925 |
mutt_free_list (&attach); |
|
926 |
}
|
|
927 |
||
1.1.5
by Christoph Berg
Import upstream version 1.5.15+20070412 |
928 |
rv = ci_send_message (sendflags, msg, tempfile, NULL, NULL); |
1.1.2
by Martin Pitt
Import upstream version 1.5.11+cvs20060403 |
929 |
|
930 |
if (!option (OPTNOCURSES)) |
|
931 |
mutt_endwin (NULL); |
|
1.1.5
by Christoph Berg
Import upstream version 1.5.15+20070412 |
932 |
|
933 |
if (rv) |
|
934 |
exit(1); |
|
1.1.2
by Martin Pitt
Import upstream version 1.5.11+cvs20060403 |
935 |
}
|
936 |
else
|
|
937 |
{
|
|
938 |
if (flags & M_BUFFY) |
|
939 |
{
|
|
940 |
if (!mutt_buffy_check (0)) |
|
941 |
{
|
|
942 |
mutt_endwin _("No mailbox with new mail."); |
|
943 |
exit (1); |
|
944 |
}
|
|
945 |
folder[0] = 0; |
|
946 |
mutt_buffy (folder, sizeof (folder)); |
|
947 |
}
|
|
948 |
else if (flags & M_SELECT) |
|
949 |
{
|
|
950 |
if (!Incoming) { |
|
951 |
mutt_endwin _("No incoming mailboxes defined."); |
|
952 |
exit (1); |
|
953 |
}
|
|
954 |
folder[0] = 0; |
|
955 |
mutt_select_file (folder, sizeof (folder), M_SEL_FOLDER | M_SEL_BUFFY); |
|
956 |
if (!folder[0]) |
|
957 |
{
|
|
958 |
mutt_endwin (NULL); |
|
959 |
exit (0); |
|
960 |
}
|
|
961 |
}
|
|
962 |
||
963 |
if (!folder[0]) |
|
964 |
strfcpy (folder, NONULL(Spoolfile), sizeof (folder)); |
|
965 |
mutt_expand_path (folder, sizeof (folder)); |
|
966 |
||
967 |
mutt_str_replace (&CurrentFolder, folder); |
|
968 |
mutt_str_replace (&LastFolder, folder); |
|
969 |
||
970 |
if (flags & M_IGNORE) |
|
971 |
{
|
|
972 |
/* check to see if there are any messages in the folder */
|
|
973 |
switch (mx_check_empty (folder)) |
|
974 |
{
|
|
975 |
case -1: |
|
976 |
mutt_endwin (strerror (errno)); |
|
977 |
exit (1); |
|
978 |
case 1: |
|
979 |
mutt_endwin _("Mailbox is empty."); |
|
980 |
exit (1); |
|
981 |
}
|
|
982 |
}
|
|
983 |
||
984 |
mutt_folder_hook (folder); |
|
985 |
||
986 |
if((Context = mx_open_mailbox (folder, ((flags & M_RO) || option (OPTREADONLY)) ? M_READONLY : 0, NULL)) |
|
987 |
|| !explicit_folder) |
|
988 |
{
|
|
989 |
mutt_index_menu (); |
|
990 |
if (Context) |
|
991 |
FREE (&Context); |
|
992 |
}
|
|
993 |
#ifdef USE_IMAP
|
|
994 |
imap_logout_all (); |
|
995 |
#endif
|
|
996 |
#ifdef USE_SASL
|
|
997 |
mutt_sasl_done (); |
|
998 |
#endif
|
|
999 |
mutt_free_opts (); |
|
1000 |
mutt_endwin (Errorbuf); |
|
1001 |
}
|
|
1002 |
||
1003 |
exit (0); |
|
1004 |
}
|