Untabified. Needed for proper conversion to *.texi
Showing
6 changed files
with
175 additions
and
175 deletions
... | @@ -58,46 +58,46 @@ parse (const char *str) | ... | @@ -58,46 +58,46 @@ parse (const char *str) |
58 | printf ("%d ", no); | 58 | printf ("%d ", no); |
59 | 59 | ||
60 | if (isgroup) | 60 | if (isgroup) |
61 | { | 61 | { |
62 | address_get_personal (address, no, buf, sizeof (buf), &got); | 62 | address_get_personal (address, no, buf, sizeof (buf), &got); |
63 | 63 | ||
64 | printf ("group <%s>\n", buf); | 64 | printf ("group <%s>\n", buf); |
65 | } | 65 | } |
66 | else | 66 | else |
67 | { | 67 | { |
68 | address_get_email (address, no, buf, sizeof (buf), 0); | 68 | address_get_email (address, no, buf, sizeof (buf), 0); |
69 | 69 | ||
70 | printf ("email <%s>\n", buf); | 70 | printf ("email <%s>\n", buf); |
71 | } | 71 | } |
72 | 72 | ||
73 | address_get_personal (address, no, buf, sizeof (buf), &got); | 73 | address_get_personal (address, no, buf, sizeof (buf), &got); |
74 | 74 | ||
75 | if (got && !isgroup) | 75 | if (got && !isgroup) |
76 | printf (" personal <%s>\n", buf); | 76 | printf (" personal <%s>\n", buf); |
77 | 77 | ||
78 | address_get_comments (address, no, buf, sizeof (buf), &got); | 78 | address_get_comments (address, no, buf, sizeof (buf), &got); |
79 | 79 | ||
80 | if (got) | 80 | if (got) |
81 | printf (" comments <%s>\n", buf); | 81 | printf (" comments <%s>\n", buf); |
82 | 82 | ||
83 | address_get_local_part (address, no, buf, sizeof (buf), &got); | 83 | address_get_local_part (address, no, buf, sizeof (buf), &got); |
84 | 84 | ||
85 | if (got) | 85 | if (got) |
86 | { | 86 | { |
87 | printf (" local-part <%s>", buf); | 87 | printf (" local-part <%s>", buf); |
88 | 88 | ||
89 | address_get_domain (address, no, buf, sizeof (buf), &got); | 89 | address_get_domain (address, no, buf, sizeof (buf), &got); |
90 | 90 | ||
91 | if (got) | 91 | if (got) |
92 | printf (" domain <%s>", buf); | 92 | printf (" domain <%s>", buf); |
93 | 93 | ||
94 | printf ("\n"); | 94 | printf ("\n"); |
95 | } | 95 | } |
96 | 96 | ||
97 | address_get_route (address, no, buf, sizeof (buf), &got); | 97 | address_get_route (address, no, buf, sizeof (buf), &got); |
98 | 98 | ||
99 | if (got) | 99 | if (got) |
100 | printf (" route <%s>\n", buf); | 100 | printf (" route <%s>\n", buf); |
101 | } | 101 | } |
102 | address_destroy (&address); | 102 | address_destroy (&address); |
103 | 103 | ||
... | @@ -132,13 +132,13 @@ main (int argc, const char *argv[]) | ... | @@ -132,13 +132,13 @@ main (int argc, const char *argv[]) |
132 | for (; argv[argc]; argc++) | 132 | for (; argv[argc]; argc++) |
133 | { | 133 | { |
134 | if (strcmp (argv[argc], "-") == 0) | 134 | if (strcmp (argv[argc], "-") == 0) |
135 | { | 135 | { |
136 | parseinput (); | 136 | parseinput (); |
137 | } | 137 | } |
138 | else | 138 | else |
139 | { | 139 | { |
140 | parse (argv[argc]); | 140 | parse (argv[argc]); |
141 | } | 141 | } |
142 | } | 142 | } |
143 | 143 | ||
144 | return 0; | 144 | return 0; | ... | ... |
... | @@ -68,13 +68,13 @@ main (int argc, char **argv) | ... | @@ -68,13 +68,13 @@ main (int argc, char **argv) |
68 | for (i = 1; i < argc; i++) | 68 | for (i = 1; i < argc; i++) |
69 | { | 69 | { |
70 | if (strcmp (argv[i], "-d") == 0) | 70 | if (strcmp (argv[i], "-d") == 0) |
71 | debug = 1; | 71 | debug = 1; |
72 | else if (strcmp (argv[i], "-p") == 0) | 72 | else if (strcmp (argv[i], "-p") == 0) |
73 | print_attachments = 1; | 73 | print_attachments = 1; |
74 | else if (strcmp (argv[i], "-i") == 0) | 74 | else if (strcmp (argv[i], "-i") == 0) |
75 | indent_level = strtoul (argv[++i], NULL, 0); | 75 | indent_level = strtoul (argv[++i], NULL, 0); |
76 | else | 76 | else |
77 | break; | 77 | break; |
78 | } | 78 | } |
79 | 79 | ||
80 | mailbox_name = argv[i]; | 80 | mailbox_name = argv[i]; |
... | @@ -122,32 +122,32 @@ main (int argc, char **argv) | ... | @@ -122,32 +122,32 @@ main (int argc, char **argv) |
122 | size_t msize; | 122 | size_t msize; |
123 | 123 | ||
124 | if ((ret = mailbox_get_message (mbox, i, &msg)) != 0) | 124 | if ((ret = mailbox_get_message (mbox, i, &msg)) != 0) |
125 | { | 125 | { |
126 | fprintf (stderr, "mailbox_get_message - %s\n", mu_errstring (ret)); | 126 | fprintf (stderr, "mailbox_get_message - %s\n", mu_errstring (ret)); |
127 | exit (2); | 127 | exit (2); |
128 | } | 128 | } |
129 | if ((ret = message_size (msg, &msize)) != 0) | 129 | if ((ret = message_size (msg, &msize)) != 0) |
130 | { | 130 | { |
131 | fprintf (stderr, "message_size - %s\n", mu_errstring (ret)); | 131 | fprintf (stderr, "message_size - %s\n", mu_errstring (ret)); |
132 | exit (2); | 132 | exit (2); |
133 | } | 133 | } |
134 | if ((ret = message_get_header (msg, &hdr)) != 0) | 134 | if ((ret = message_get_header (msg, &hdr)) != 0) |
135 | { | 135 | { |
136 | fprintf (stderr, "message_get_header - %s\n", mu_errstring (ret)); | 136 | fprintf (stderr, "message_get_header - %s\n", mu_errstring (ret)); |
137 | exit (2); | 137 | exit (2); |
138 | } | 138 | } |
139 | header_get_value (hdr, MU_HEADER_FROM, from, sizeof (from), NULL); | 139 | header_get_value (hdr, MU_HEADER_FROM, from, sizeof (from), NULL); |
140 | header_get_value (hdr, MU_HEADER_SUBJECT, subject, sizeof (subject), | 140 | header_get_value (hdr, MU_HEADER_SUBJECT, subject, sizeof (subject), |
141 | NULL); | 141 | NULL); |
142 | printf ("Message: %d\n", i); | 142 | printf ("Message: %d\n", i); |
143 | printf ("From: %s\n", from); | 143 | printf ("From: %s\n", from); |
144 | printf ("Subject: %s\n", subject); | 144 | printf ("Subject: %s\n", subject); |
145 | 145 | ||
146 | if ((ret = message_get_num_parts (msg, &nparts)) != 0) | 146 | if ((ret = message_get_num_parts (msg, &nparts)) != 0) |
147 | { | 147 | { |
148 | fprintf (stderr, "message_get_num_parts - %s\n", mu_errstring (ret)); | 148 | fprintf (stderr, "message_get_num_parts - %s\n", mu_errstring (ret)); |
149 | exit (2); | 149 | exit (2); |
150 | } | 150 | } |
151 | printf ("Number of parts in message - %d\n", nparts); | 151 | printf ("Number of parts in message - %d\n", nparts); |
152 | printf ("Total message size - %d\n", msize); | 152 | printf ("Total message size - %d\n", msize); |
153 | message_display_parts (msg, 0); | 153 | message_display_parts (msg, 0); |
... | @@ -186,98 +186,98 @@ message_display_parts (message_t msg, int indent) | ... | @@ -186,98 +186,98 @@ message_display_parts (message_t msg, int indent) |
186 | for (j = 1; j <= nparts; j++) | 186 | for (j = 1; j <= nparts; j++) |
187 | { | 187 | { |
188 | if ((ret = message_get_part (msg, j, &part)) != 0) | 188 | if ((ret = message_get_part (msg, j, &part)) != 0) |
189 | { | 189 | { |
190 | fprintf (stderr, "mime_get_part - %s\n", mu_errstring (ret)); | 190 | fprintf (stderr, "mime_get_part - %s\n", mu_errstring (ret)); |
191 | exit (2); | 191 | exit (2); |
192 | } | 192 | } |
193 | if ((ret = message_size (part, &msize)) != 0) | 193 | if ((ret = message_size (part, &msize)) != 0) |
194 | { | 194 | { |
195 | fprintf (stderr, "message_size - %s\n", mu_errstring (ret)); | 195 | fprintf (stderr, "message_size - %s\n", mu_errstring (ret)); |
196 | exit (2); | 196 | exit (2); |
197 | } | 197 | } |
198 | if ((ret = message_get_header (part, &hdr)) != 0) | 198 | if ((ret = message_get_header (part, &hdr)) != 0) |
199 | { | 199 | { |
200 | fprintf (stderr, "message_get_header - %s\n", mu_errstring (ret)); | 200 | fprintf (stderr, "message_get_header - %s\n", mu_errstring (ret)); |
201 | exit (2); | 201 | exit (2); |
202 | } | 202 | } |
203 | header_get_value (hdr, MU_HEADER_CONTENT_TYPE, type, sizeof (type), | 203 | header_get_value (hdr, MU_HEADER_CONTENT_TYPE, type, sizeof (type), |
204 | NULL); | 204 | NULL); |
205 | printf ("%*.*sType of part %d = %s\n", indent, indent, "", j, type); | 205 | printf ("%*.*sType of part %d = %s\n", indent, indent, "", j, type); |
206 | printf ("%*.*sMessage part size - %d\n", indent, indent, "", msize); | 206 | printf ("%*.*sMessage part size - %d\n", indent, indent, "", msize); |
207 | encoding[0] = '\0'; | 207 | encoding[0] = '\0'; |
208 | header_get_value (hdr, MU_HEADER_CONTENT_TRANSFER_ENCODING, encoding, | 208 | header_get_value (hdr, MU_HEADER_CONTENT_TRANSFER_ENCODING, encoding, |
209 | sizeof (encoding), NULL); | 209 | sizeof (encoding), NULL); |
210 | ismulti = 0; | 210 | ismulti = 0; |
211 | if ((type[0] | 211 | if ((type[0] |
212 | && strncasecmp (type, "message/rfc822", strlen (type)) == 0) | 212 | && strncasecmp (type, "message/rfc822", strlen (type)) == 0) |
213 | || (message_is_multipart (part, &ismulti) == 0 && ismulti)) | 213 | || (message_is_multipart (part, &ismulti) == 0 && ismulti)) |
214 | { | 214 | { |
215 | if (!ismulti) | 215 | if (!ismulti) |
216 | { | 216 | { |
217 | ret = message_unencapsulate (part, &part, NULL); | 217 | ret = message_unencapsulate (part, &part, NULL); |
218 | if (ret != 0) | 218 | if (ret != 0) |
219 | fprintf (stderr, "message_unencapsulate - %s\n", | 219 | fprintf (stderr, "message_unencapsulate - %s\n", |
220 | mu_errstring (ret)); | 220 | mu_errstring (ret)); |
221 | break; | 221 | break; |
222 | } | 222 | } |
223 | if ((ret = message_get_header (part, &hdr)) != 0) | 223 | if ((ret = message_get_header (part, &hdr)) != 0) |
224 | { | 224 | { |
225 | fprintf (stderr, "message_get_header - %s\n", | 225 | fprintf (stderr, "message_get_header - %s\n", |
226 | mu_errstring (ret)); | 226 | mu_errstring (ret)); |
227 | exit (2); | 227 | exit (2); |
228 | } | 228 | } |
229 | header_get_value (hdr, MU_HEADER_FROM, from, sizeof (from), NULL); | 229 | header_get_value (hdr, MU_HEADER_FROM, from, sizeof (from), NULL); |
230 | header_get_value (hdr, MU_HEADER_SUBJECT, subject, sizeof (subject), | 230 | header_get_value (hdr, MU_HEADER_SUBJECT, subject, sizeof (subject), |
231 | NULL); | 231 | NULL); |
232 | printf ("%*.*sEncapsulated message : %s\t%s\n", | 232 | printf ("%*.*sEncapsulated message : %s\t%s\n", |
233 | indent, indent, "", from, subject); | 233 | indent, indent, "", from, subject); |
234 | printf ("%*.*sBegin\n", indent, indent, ""); | 234 | printf ("%*.*sBegin\n", indent, indent, ""); |
235 | if ((ret = message_get_num_parts (part, &nsubparts)) != 0) | 235 | if ((ret = message_get_num_parts (part, &nsubparts)) != 0) |
236 | { | 236 | { |
237 | fprintf (stderr, "mime_get_num_parts - %s\n", | 237 | fprintf (stderr, "mime_get_num_parts - %s\n", |
238 | mu_errstring (ret)); | 238 | mu_errstring (ret)); |
239 | exit (2); | 239 | exit (2); |
240 | } | 240 | } |
241 | message_display_parts (part, indent+indent_level); | 241 | message_display_parts (part, indent+indent_level); |
242 | message_destroy (&part, NULL); | 242 | message_destroy (&part, NULL); |
243 | } | 243 | } |
244 | else if (type[0] == '\0' | 244 | else if (type[0] == '\0' |
245 | || (strncasecmp (type, "text/plain", strlen ("text/plain")) == | 245 | || (strncasecmp (type, "text/plain", strlen ("text/plain")) == |
246 | 0) | 246 | 0) |
247 | || (strncasecmp (type, "text/html", strlen ("text/html")) == | 247 | || (strncasecmp (type, "text/html", strlen ("text/html")) == |
248 | 0)) | 248 | 0)) |
249 | { | 249 | { |
250 | printf ("%*.*sText Message\n", indent, indent, ""); | 250 | printf ("%*.*sText Message\n", indent, indent, ""); |
251 | printf ("%*.*sBegin\n", indent, indent, ""); | 251 | printf ("%*.*sBegin\n", indent, indent, ""); |
252 | message_get_body (part, &body); | 252 | message_get_body (part, &body); |
253 | body_get_stream (body, &str); | 253 | body_get_stream (body, &str); |
254 | filter_create (&str, str, encoding, 0, 0); | 254 | filter_create (&str, str, encoding, 0, 0); |
255 | offset = 0; | 255 | offset = 0; |
256 | while (stream_readline (str, buf, sizeof (buf), offset, &nbytes) == | 256 | while (stream_readline (str, buf, sizeof (buf), offset, &nbytes) == |
257 | 0 && nbytes) | 257 | 0 && nbytes) |
258 | { | 258 | { |
259 | printf ("%*.*s%s", indent, indent, "", buf); | 259 | printf ("%*.*s%s", indent, indent, "", buf); |
260 | offset += nbytes; | 260 | offset += nbytes; |
261 | } | 261 | } |
262 | stream_destroy (&str, NULL); | 262 | stream_destroy (&str, NULL); |
263 | } | 263 | } |
264 | else | 264 | else |
265 | { | 265 | { |
266 | /* Save the attachements. */ | 266 | /* Save the attachements. */ |
267 | char *fname = NULL; | 267 | char *fname = NULL; |
268 | message_aget_attachment_name (part, &fname); | 268 | message_aget_attachment_name (part, &fname); |
269 | if (fname == NULL) | 269 | if (fname == NULL) |
270 | fname = mu_tempname (NULL); | 270 | fname = mu_tempname (NULL); |
271 | 271 | ||
272 | printf ("%*.*sAttachment - saving [%s]\n", indent, indent, "", | 272 | printf ("%*.*sAttachment - saving [%s]\n", indent, indent, "", |
273 | fname); | 273 | fname); |
274 | printf ("%*.*sBegin\n", indent, indent, ""); | 274 | printf ("%*.*sBegin\n", indent, indent, ""); |
275 | /*FIXME: What is the 'data' argument for? */ | 275 | /*FIXME: What is the 'data' argument for? */ |
276 | message_save_attachment (part, NULL, NULL); | 276 | message_save_attachment (part, NULL, NULL); |
277 | if (print_attachments) | 277 | if (print_attachments) |
278 | print_file (fname, indent); | 278 | print_file (fname, indent); |
279 | free (fname); | 279 | free (fname); |
280 | } | 280 | } |
281 | printf ("\n%*.*sEnd\n", indent, indent, ""); | 281 | printf ("\n%*.*sEnd\n", indent, indent, ""); |
282 | } | 282 | } |
283 | } | 283 | } | ... | ... |
... | @@ -71,27 +71,27 @@ main (int argc, char *argv[]) | ... | @@ -71,27 +71,27 @@ main (int argc, char *argv[]) |
71 | while ((opt = getopt (argc, argv, "hdm:f:")) != -1) | 71 | while ((opt = getopt (argc, argv, "hdm:f:")) != -1) |
72 | { | 72 | { |
73 | switch (opt) | 73 | switch (opt) |
74 | { | 74 | { |
75 | case 'h': | 75 | case 'h': |
76 | printf ("%s\n%s", USAGE, HELP); | 76 | printf ("%s\n%s", USAGE, HELP); |
77 | return 0; | 77 | return 0; |
78 | 78 | ||
79 | case 'd': | 79 | case 'd': |
80 | optdebug++; | 80 | optdebug++; |
81 | break; | 81 | break; |
82 | 82 | ||
83 | case 'm': | 83 | case 'm': |
84 | optmailer = optarg; | 84 | optmailer = optarg; |
85 | break; | 85 | break; |
86 | 86 | ||
87 | case 'f': | 87 | case 'f': |
88 | optfrom = optarg; | 88 | optfrom = optarg; |
89 | break; | 89 | break; |
90 | 90 | ||
91 | default: | 91 | default: |
92 | fprintf (stderr, "%s\n", USAGE); | 92 | fprintf (stderr, "%s\n", USAGE); |
93 | exit (1); | 93 | exit (1); |
94 | } | 94 | } |
95 | } | 95 | } |
96 | 96 | ||
97 | /* Register mailers. */ | 97 | /* Register mailers. */ | ... | ... |
... | @@ -38,7 +38,7 @@ main (int argc, char *argv[]) | ... | @@ -38,7 +38,7 @@ main (int argc, char *argv[]) |
38 | else | 38 | else |
39 | { | 39 | { |
40 | for (; argv[arg]; arg++) | 40 | for (; argv[arg]; arg++) |
41 | printf ("%s -> %s\n", argv[arg], mu_get_user_email (argv[arg])); | 41 | printf ("%s -> %s\n", argv[arg], mu_get_user_email (argv[arg])); |
42 | } | 42 | } |
43 | 43 | ||
44 | return 0; | 44 | return 0; | ... | ... |
... | @@ -64,18 +64,18 @@ main (int argc, const char **argv) | ... | @@ -64,18 +64,18 @@ main (int argc, const char **argv) |
64 | header_t hdr; | 64 | header_t hdr; |
65 | 65 | ||
66 | if ((status = mailbox_get_message (mbox, msgno, &msg)) != 0 | 66 | if ((status = mailbox_get_message (mbox, msgno, &msg)) != 0 |
67 | || (status = message_get_header (msg, &hdr)) != 0) | 67 | || (status = message_get_header (msg, &hdr)) != 0) |
68 | { | 68 | { |
69 | fprintf (stderr, "Error message: %s\n", | 69 | fprintf (stderr, "Error message: %s\n", |
70 | mu_errstring (status)); | 70 | mu_errstring (status)); |
71 | exit (EXIT_FAILURE); | 71 | exit (EXIT_FAILURE); |
72 | } | 72 | } |
73 | 73 | ||
74 | if (header_aget_value (hdr, MU_HEADER_FROM, &from)) | 74 | if (header_aget_value (hdr, MU_HEADER_FROM, &from)) |
75 | from = strdup ("(NO FROM)"); | 75 | from = strdup ("(NO FROM)"); |
76 | 76 | ||
77 | if (header_aget_value (hdr, MU_HEADER_SUBJECT, &subject)) | 77 | if (header_aget_value (hdr, MU_HEADER_SUBJECT, &subject)) |
78 | subject = strdup("(NO SUBJECT)"); | 78 | subject = strdup("(NO SUBJECT)"); |
79 | 79 | ||
80 | printf ("%s\t%s\n", from, subject); | 80 | printf ("%s\t%s\n", from, subject); |
81 | free (from); | 81 | free (from); | ... | ... |
... | @@ -33,46 +33,46 @@ main () | ... | @@ -33,46 +33,46 @@ main () |
33 | { | 33 | { |
34 | int rc; | 34 | int rc; |
35 | 35 | ||
36 | str[strlen (str) - 1] = '\0'; /* chop newline */ | 36 | str[strlen (str) - 1] = '\0'; /* chop newline */ |
37 | if (strspn (str, " \t") == strlen (str)) | 37 | if (strspn (str, " \t") == strlen (str)) |
38 | continue; /* skip empty lines */ | 38 | continue; /* skip empty lines */ |
39 | if ((rc = url_create (&u, str)) != 0) | 39 | if ((rc = url_create (&u, str)) != 0) |
40 | { | 40 | { |
41 | fprintf (stderr, "url_create %s ERROR: [%d] %s", | 41 | fprintf (stderr, "url_create %s ERROR: [%d] %s", |
42 | str, rc, mu_errstring (rc)); | 42 | str, rc, mu_errstring (rc)); |
43 | exit (1); | 43 | exit (1); |
44 | } | 44 | } |
45 | if ((rc = url_parse (u)) != 0) | 45 | if ((rc = url_parse (u)) != 0) |
46 | { | 46 | { |
47 | printf ("%s => FAILED: [%d] %s\n", | 47 | printf ("%s => FAILED: [%d] %s\n", |
48 | str, rc, mu_errstring (rc)); | 48 | str, rc, mu_errstring (rc)); |
49 | continue; | 49 | continue; |
50 | } | 50 | } |
51 | printf ("%s => SUCCESS\n", str); | 51 | printf ("%s => SUCCESS\n", str); |
52 | 52 | ||
53 | url_get_scheme (u, buffer, len, NULL); | 53 | url_get_scheme (u, buffer, len, NULL); |
54 | printf (" scheme <%s>\n", buffer); | 54 | printf (" scheme <%s>\n", buffer); |
55 | 55 | ||
56 | url_get_user (u, buffer, len, NULL); | 56 | url_get_user (u, buffer, len, NULL); |
57 | printf (" user <%s>\n", buffer); | 57 | printf (" user <%s>\n", buffer); |
58 | 58 | ||
59 | url_get_passwd (u, buffer, len, NULL); | 59 | url_get_passwd (u, buffer, len, NULL); |
60 | printf (" passwd <%s>\n", buffer); | 60 | printf (" passwd <%s>\n", buffer); |
61 | 61 | ||
62 | url_get_auth (u, buffer, len, NULL); | 62 | url_get_auth (u, buffer, len, NULL); |
63 | printf (" auth <%s>\n", buffer); | 63 | printf (" auth <%s>\n", buffer); |
64 | 64 | ||
65 | url_get_host (u, buffer, len, NULL); | 65 | url_get_host (u, buffer, len, NULL); |
66 | printf (" host <%s>\n", buffer); | 66 | printf (" host <%s>\n", buffer); |
67 | 67 | ||
68 | url_get_port (u, &port); | 68 | url_get_port (u, &port); |
69 | printf (" port %ld\n", port); | 69 | printf (" port %ld\n", port); |
70 | 70 | ||
71 | url_get_path (u, buffer, len, NULL); | 71 | url_get_path (u, buffer, len, NULL); |
72 | printf (" path <%s>\n", buffer); | 72 | printf (" path <%s>\n", buffer); |
73 | 73 | ||
74 | url_get_query (u, buffer, len, NULL); | 74 | url_get_query (u, buffer, len, NULL); |
75 | printf (" query <%s>\n", buffer); | 75 | printf (" query <%s>\n", buffer); |
76 | 76 | ||
77 | url_destroy (&u); | 77 | url_destroy (&u); |
78 | 78 | ... | ... |
-
Please register or sign in to post a comment