47 |
{"subject", 's', "SUBJ", 0, "Send a message with a Subject of SUBJ", 0}, |
{"subject", 's', "SUBJ", 0, "Send a message with a Subject of SUBJ", 0}, |
48 |
{"to", 't', 0, 0, "Precede message by a list of addresses", 0}, |
{"to", 't', 0, 0, "Precede message by a list of addresses", 0}, |
49 |
{"user", 'u', "USER", 0, "Operate on USER's mailbox", 0}, |
{"user", 'u', "USER", 0, "Operate on USER's mailbox", 0}, |
50 |
|
{NULL, 0, NULL, OPTION_DOC, |
51 |
|
"Note: Argument to --file (-f) option is optional. If it is present, " |
52 |
|
"it must follow the short option immediately, without any intervening " |
53 |
|
"whitespace. If it is used with the long option, it must be separated " |
54 |
|
"from it by an equal sign, with no intervening whitespace.", 0}, |
55 |
{ NULL, 0, NULL, 0, NULL, 0 } |
{ NULL, 0, NULL, 0, NULL, 0 } |
56 |
}; |
}; |
57 |
|
|
58 |
|
|
59 |
struct arguments |
struct arguments |
60 |
{ |
{ |
61 |
char **args; |
char **args; |
73 |
case 'e': |
case 'e': |
74 |
util_do_command ("set mode=exist"); |
util_do_command ("set mode=exist"); |
75 |
break; |
break; |
76 |
|
|
77 |
case 'f': |
case 'f': |
78 |
if (arg != NULL) |
if (arg != NULL) |
79 |
args->file = arg; |
args->file = arg; |
87 |
strcat (args->file, "/mbox"); |
strcat (args->file, "/mbox"); |
88 |
} |
} |
89 |
break; |
break; |
90 |
|
|
91 |
case 'p': |
case 'p': |
92 |
case 'r': |
case 'r': |
93 |
util_do_command ("set mode=print"); |
util_do_command ("set mode=print"); |
94 |
break; |
break; |
95 |
|
|
96 |
case 'q': |
case 'q': |
97 |
util_do_command ("set quit"); |
util_do_command ("set quiet"); |
98 |
break; |
break; |
99 |
|
|
100 |
case 't': |
case 't': |
101 |
util_do_command ("set mode=send"); |
util_do_command ("set mode=send"); |
102 |
break; |
break; |
103 |
|
|
104 |
case 'H': |
case 'H': |
105 |
util_do_command ("set mode=headers"); |
util_do_command ("set mode=headers"); |
106 |
break; |
break; |
107 |
|
|
108 |
case 'i': |
case 'i': |
109 |
util_do_command ("set ignore"); |
util_do_command ("set ignore"); |
110 |
break; |
break; |
111 |
|
|
112 |
case 'n': |
case 'n': |
113 |
util_do_command ("set norc"); |
util_do_command ("set norc"); |
114 |
break; |
break; |
115 |
|
|
116 |
case 'N': |
case 'N': |
117 |
util_do_command ("set noheader"); |
util_do_command ("set noheader"); |
118 |
break; |
break; |
119 |
|
|
120 |
case 's': |
case 's': |
121 |
util_do_command ("set mode=send"); |
util_do_command ("set mode=send"); |
122 |
util_do_command ("set noasksub"); |
util_do_command ("set noasksub"); |
123 |
util_do_command ("set subject=\"%s\"", arg); |
util_do_command ("set subject=\"%s\"", arg); |
124 |
break; |
break; |
125 |
|
|
126 |
case 'u': |
case 'u': |
127 |
args->user = arg; |
args->user = arg; |
128 |
break; |
break; |
129 |
|
|
130 |
case 'F': |
case 'F': |
131 |
util_do_command ("set byname"); |
util_do_command ("set byname"); |
132 |
break; |
break; |
133 |
|
|
134 |
case ARGP_KEY_ARG: |
case ARGP_KEY_ARG: |
135 |
args->args = realloc (args->args, |
/* People often tend to separate -f option from its argument |
136 |
sizeof (char *) * (state->arg_num + 2)); |
with a whitespace. This heuristics tries to catch the |
137 |
args->args[state->arg_num] = arg; |
error: */ |
138 |
args->args[state->arg_num + 1] = NULL; |
|
139 |
util_do_command ("set mode=send"); |
if (args->file) |
140 |
|
{ |
141 |
|
util_error ("Usage error: --file takes an optional argument, it must follow the option\n" |
142 |
|
"without any intervening whitespace."); |
143 |
|
util_error ("Run mail --help for more info."); |
144 |
|
util_do_command ("set quiet"); |
145 |
|
args->file = arg; |
146 |
|
} |
147 |
|
else |
148 |
|
{ |
149 |
|
args->args = realloc (args->args, |
150 |
|
sizeof (char *) * (state->arg_num + 2)); |
151 |
|
args->args[state->arg_num] = arg; |
152 |
|
args->args[state->arg_num + 1] = NULL; |
153 |
|
util_do_command ("set mode=send"); |
154 |
|
} |
155 |
break; |
break; |
156 |
|
|
157 |
default: |
default: |
158 |
return ARGP_ERR_UNKNOWN; |
return ARGP_ERR_UNKNOWN; |
159 |
} |
} |
398 |
else if ((rc = mailbox_create_default (&mbox, args.file)) != 0) |
else if ((rc = mailbox_create_default (&mbox, args.file)) != 0) |
399 |
{ |
{ |
400 |
util_error ("Can not create mailbox %s: %s", args.file, |
util_error ("Can not create mailbox %s: %s", args.file, |
401 |
mu_errstring (errno)); |
mu_errstring (rc)); |
402 |
exit (EXIT_FAILURE); |
exit (EXIT_FAILURE); |
403 |
} |
} |
404 |
|
|
423 |
total = 0; |
total = 0; |
424 |
else |
else |
425 |
{ |
{ |
426 |
if (mailbox_scan (mbox, 1, &total) != 0) |
if ((rc = mailbox_scan (mbox, 1, &total)) != 0) |
427 |
{ |
{ |
428 |
util_error ("Can not read mailbox"); |
url_t url = NULL; |
429 |
|
mailbox_get_url (mbox, &url); |
430 |
|
util_error ("Can not read mailbox %s: %s", |
431 |
|
url_to_string (url), mu_errstring (rc)); |
432 |
exit (EXIT_FAILURE); |
exit (EXIT_FAILURE); |
433 |
} |
} |
434 |
|
|