* mail/util.c (util_expand_msglist): Implement expansion of
:d All deleted messages :n All new messages :o All old messages :r All messages that have already been read :u All unread messages /string All messages with string in the subject line (the case of characters in string is ignored)
Showing
3 changed files
with
57 additions
and
23 deletions
1 | 2001-06-29 Alain Magloire | ||
2 | |||
3 | * mail/util.c (util_expand_msglist): Implement expansion of | ||
4 | :d All deleted messages | ||
5 | :n All new messages | ||
6 | :o All old messages | ||
7 | :r All messages that have already been read | ||
8 | :u All unread messages | ||
9 | /string All messages with string in the subject line | ||
10 | (the case of characters in string is ignored) | ||
11 | |||
1 | 2001-06-27 Alain Magloire | 12 | 2001-06-27 Alain Magloire |
2 | 13 | ||
3 | * configure.in: We were not checking for thread support | 14 | * configure.in: We were not checking for thread support | ... | ... |
... | @@ -152,41 +152,69 @@ util_expand_msglist (const int argc, char **argv, int **list) | ... | @@ -152,41 +152,69 @@ util_expand_msglist (const int argc, char **argv, int **list) |
152 | } | 152 | } |
153 | else if (argv[i][0] == '/') | 153 | else if (argv[i][0] == '/') |
154 | { | 154 | { |
155 | /* FIXME: all messages with pattern following / in | 155 | /* All messages with pattern following / in |
156 | the subject line, case insensitive */ | 156 | the subject line, case insensitive */ |
157 | /* This currently appears to be quit b0rked */ | 157 | int j; |
158 | message_t msg; | ||
159 | header_t hdr; | ||
160 | char subj[128]; | ||
161 | int j = 1, k = 0, l2 = 0; | ||
162 | int len = strlen (&argv[i][1]); | ||
163 | for (j = 1; j <= total; j++) | 158 | for (j = 1; j <= total; j++) |
164 | { | 159 | { |
160 | message_t msg = NULL; | ||
161 | header_t hdr = NULL; | ||
162 | char *subject = NULL; | ||
163 | size_t subjlen; | ||
164 | char *pattern; | ||
165 | size_t patlen; | ||
166 | int k; | ||
167 | |||
165 | mailbox_get_message (mbox, j, &msg); | 168 | mailbox_get_message (mbox, j, &msg); |
166 | message_get_header (msg, &hdr); | 169 | message_get_header (msg, &hdr); |
167 | header_get_value (hdr, MU_HEADER_SUBJECT, subj, 128, NULL); | 170 | |
168 | l2 = strlen (subj); | 171 | header_aget_value (hdr, MU_HEADER_SUBJECT, &subject); |
169 | for (k = 0; i < strlen (subj); k++) | 172 | subjlen = (subject) ? strlen (subject) : 0; |
170 | { | 173 | for (k = 0; k < subjlen; k++) |
171 | if (l2-k >= len && !strncasecmp (&argv[i][1], &subj[k], len)) | 174 | subject[k] = toupper ((int)subject[k]); |
175 | |||
176 | pattern = strdup (&argv[i][1]); | ||
177 | patlen = (pattern) ? strlen (pattern) : 0; | ||
178 | for (k = 0; k < patlen; k++) | ||
179 | pattern[k] = toupper ((int)pattern[k]); | ||
180 | |||
181 | if (pattern && subject && strstr (subject, pattern)) | ||
172 | { | 182 | { |
173 | current = util_ll_add (current, j); | 183 | current = util_ll_add (current, j); |
174 | k = 128; | ||
175 | } | ||
176 | } | 184 | } |
185 | |||
186 | free (pattern); | ||
187 | free (subject); | ||
177 | } | 188 | } |
178 | } | 189 | } |
179 | else if (argv[i][0] == ':') | 190 | else if (argv[i][0] == ':') |
180 | { | 191 | { |
181 | /* FIXME: all messages of type argv[i][1] */ | 192 | /* All messages of type argv[i][1] */ |
193 | int j; | ||
194 | for (j = 1; j <= total; j++) | ||
195 | { | ||
196 | message_t msg = NULL; | ||
197 | attribute_t attr= NULL; | ||
198 | |||
199 | mailbox_get_message (mbox, j, &msg); | ||
200 | message_get_attribute (msg, &attr); | ||
201 | if ((argv[i][1] == 'd' && attribute_is_deleted (attr)) | ||
202 | || (argv[i][1] == 'n' && attribute_is_recent (attr)) | ||
203 | || (argv[i][1] == 'o' && attribute_is_seen (attr)) | ||
204 | || (argv[i][1] == 'r' && attribute_is_read (attr)) | ||
205 | || (argv[i][1] == 'u' && !attribute_is_read (attr))) | ||
206 | current = util_ll_add (current, j); | ||
207 | } | ||
182 | } | 208 | } |
183 | else if (isalpha(argv[i][0])) | 209 | else if (isalpha(argv[i][0])) |
184 | { | 210 | { |
185 | /* FIXME: all messages from sender argv[i] */ | 211 | /* FIXME: all messages from sender argv[i] */ |
212 | /* Annoying we can use address_create() for that | ||
213 | but to compare against what? The email ? */ | ||
186 | } | 214 | } |
187 | else if (strchr (argv[i], '-') != NULL) | 215 | else if (strchr (argv[i], '-') != NULL) |
188 | { | 216 | { |
189 | /* message range */ | 217 | /* Message range. */ |
190 | int j, x, y; | 218 | int j, x, y; |
191 | char *arg = strdup (argv[i]); | 219 | char *arg = strdup (argv[i]); |
192 | for (j=0; j < strlen (arg); j++) | 220 | for (j=0; j < strlen (arg); j++) |
... | @@ -201,7 +229,7 @@ util_expand_msglist (const int argc, char **argv, int **list) | ... | @@ -201,7 +229,7 @@ util_expand_msglist (const int argc, char **argv, int **list) |
201 | } | 229 | } |
202 | else | 230 | else |
203 | { | 231 | { |
204 | /* single message */ | 232 | /* Single message. */ |
205 | current = util_ll_add (current, strtol (argv[i], NULL, 10)); | 233 | current = util_ll_add (current, strtol (argv[i], NULL, 10)); |
206 | } | 234 | } |
207 | } | 235 | } |
... | @@ -920,8 +948,3 @@ util_save_outgoing (message_t msg, char *savefile) | ... | @@ -920,8 +948,3 @@ util_save_outgoing (message_t msg, char *savefile) |
920 | free (filename); | 948 | free (filename); |
921 | } | 949 | } |
922 | } | 950 | } |
923 | |||
924 | |||
925 | |||
926 | |||
927 | ... | ... |
... | @@ -85,7 +85,7 @@ main(int argc, char **argv) | ... | @@ -85,7 +85,7 @@ main(int argc, char **argv) |
85 | msgset (argc - 1, &argv[1], &set, &n); | 85 | msgset (argc - 1, &argv[1], &set, &n); |
86 | else | 86 | else |
87 | { | 87 | { |
88 | char *av[] = { "*" }; | 88 | const char *av[] = { "*" }; |
89 | msgset (1, av, &set, &n); | 89 | msgset (1, av, &set, &n); |
90 | } | 90 | } |
91 | 91 | ... | ... |
-
Please register or sign in to post a comment