*** empty log message ***
Showing
7 changed files
with
0 additions
and
427 deletions
from/Makefile.am
deleted
100644 → 0
1 | ## Process this file with GNU Automake to create Makefile.in | ||
2 | |||
3 | ## Copyright (C) 2000, 2001, 2002, 2005 Free Software Foundation, Inc. | ||
4 | ## | ||
5 | ## GNU Mailutils is free software; you can redistribute it and/or | ||
6 | ## modify it under the terms of the GNU General Public License as | ||
7 | ## published by the Free Software Foundation; either version 2, or (at | ||
8 | ## your option) any later version. | ||
9 | ## | ||
10 | ## This program is distributed in the hope that it will be useful, but | ||
11 | ## WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | ## General Public License for more details. | ||
14 | ## | ||
15 | ## You should have received a copy of the GNU General Public License | ||
16 | ## along with this program; if not, write to the Free Software | ||
17 | ## Foundation, Inc. | ||
18 | ## 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
19 | |||
20 | INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/lib -I${top_builddir}/include/mailutils/gnu @INTLINCS@ | ||
21 | SUBDIRS = testsuite | ||
22 | |||
23 | noinst_PROGRAMS = from | ||
24 | |||
25 | from_LDADD = \ | ||
26 | ../mailbox/mbox/libmu_mbox.la\ | ||
27 | ../mailbox/imap/libmu_imap.la\ | ||
28 | ../mailbox/pop/libmu_pop.la\ | ||
29 | ../mailbox/nntp/libmu_nntp.la\ | ||
30 | ../mailbox/mh/libmu_mh.la\ | ||
31 | ../mailbox/maildir/libmu_maildir.la\ | ||
32 | ../mailbox/libmailbox.la\ | ||
33 | ../lib/libmailutils.la\ | ||
34 | @AUTHLIBS@ @MU_COMMON_LIBRARIES@ |
from/from.c
deleted
100644 → 0
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | Copyright (C) 1999, 2000, 2002, 2003, | ||
3 | 2004 Free Software Foundation, Inc. | ||
4 | |||
5 | GNU Mailutils is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published by | ||
7 | the Free Software Foundation; either version 2, or (at your option) | ||
8 | any later version. | ||
9 | |||
10 | GNU Mailutils is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNU Mailutils; if not, write to the Free Software | ||
17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ | ||
18 | |||
19 | /** | ||
20 | * | ||
21 | * Created as an example for using mailutils API | ||
22 | * Sean 'Shaleh' Perry <shaleh@debian.org>, 1999 | ||
23 | * Alain Magloire alainm@gnu.org | ||
24 | * | ||
25 | **/ | ||
26 | |||
27 | #ifdef HAVE_CONFIG_H | ||
28 | # include <config.h> | ||
29 | #endif | ||
30 | |||
31 | #include <sys/types.h> | ||
32 | #include <stdio.h> | ||
33 | #include <stdlib.h> | ||
34 | #include <string.h> | ||
35 | #include <unistd.h> | ||
36 | |||
37 | #include <mailutils/address.h> | ||
38 | #include <mailutils/argp.h> | ||
39 | #include <mailutils/debug.h> | ||
40 | #include <mailutils/errno.h> | ||
41 | #include <mailutils/header.h> | ||
42 | #include <mailutils/list.h> | ||
43 | #include <mailutils/mailbox.h> | ||
44 | #include <mailutils/message.h> | ||
45 | #include <mailutils/registrar.h> | ||
46 | #include <mailutils/stream.h> | ||
47 | #include <mailutils/nls.h> | ||
48 | #include <mailutils/tls.h> | ||
49 | #include <mailutils/mutil.h> | ||
50 | #include <mailutils/error.h> | ||
51 | #include <mailutils/mime.h> | ||
52 | |||
53 | const char *program_version = "from (" PACKAGE_STRING ")"; | ||
54 | static char doc[] = N_("GNU from -- display from and subject"); | ||
55 | |||
56 | static struct argp_option options[] = { | ||
57 | {"debug", 'd', NULL, 0, N_("Enable debugging output"), 0}, | ||
58 | {0, 0, 0, 0} | ||
59 | }; | ||
60 | |||
61 | static int debug; | ||
62 | |||
63 | static error_t | ||
64 | parse_opt (int key, char *arg, struct argp_state *state) | ||
65 | { | ||
66 | switch (key) | ||
67 | { | ||
68 | case 'd': | ||
69 | debug++; | ||
70 | break; | ||
71 | |||
72 | default: | ||
73 | return ARGP_ERR_UNKNOWN; | ||
74 | } | ||
75 | return 0; | ||
76 | } | ||
77 | |||
78 | static struct argp argp = { | ||
79 | options, | ||
80 | parse_opt, | ||
81 | N_("[URL]"), | ||
82 | doc, | ||
83 | }; | ||
84 | |||
85 | static const char *capa[] = { | ||
86 | "common", | ||
87 | "license", | ||
88 | "mailbox", | ||
89 | #ifdef WITH_TLS | ||
90 | "tls", | ||
91 | #endif | ||
92 | NULL | ||
93 | }; | ||
94 | |||
95 | static char * | ||
96 | rfc2047_decode_wrapper (char *buf, size_t buflen) | ||
97 | { | ||
98 | char locale[32]; | ||
99 | char *charset = NULL; | ||
100 | char *tmp; | ||
101 | int rc; | ||
102 | |||
103 | memset (locale, 0, sizeof (locale)); | ||
104 | |||
105 | /* Try to deduce the charset from LC_ALL or LANG variables */ | ||
106 | |||
107 | tmp = getenv ("LC_ALL"); | ||
108 | if (!tmp) | ||
109 | tmp = getenv ("LANG"); | ||
110 | |||
111 | if (tmp) | ||
112 | { | ||
113 | char *sp = NULL; | ||
114 | char *lang; | ||
115 | char *terr; | ||
116 | |||
117 | strncpy (locale, tmp, sizeof (locale) - 1); | ||
118 | |||
119 | lang = strtok_r (locale, "_", &sp); | ||
120 | terr = strtok_r (NULL, ".", &sp); | ||
121 | charset = strtok_r (NULL, "@", &sp); | ||
122 | |||
123 | if (!charset) | ||
124 | charset = mu_charset_lookup (lang, terr); | ||
125 | } | ||
126 | |||
127 | if (!charset) | ||
128 | return strdup (buf); | ||
129 | |||
130 | rc = rfc2047_decode (charset, buf, &tmp); | ||
131 | if (rc) | ||
132 | { | ||
133 | if (debug) | ||
134 | mu_error (_("Cannot decode line `%s': %s"), | ||
135 | buf, mu_strerror (rc)); | ||
136 | return strdup (buf); | ||
137 | } | ||
138 | |||
139 | return tmp; | ||
140 | } | ||
141 | |||
142 | int | ||
143 | main (int argc, char **argv) | ||
144 | { | ||
145 | mailbox_t mbox; | ||
146 | size_t i; | ||
147 | size_t count = 0; | ||
148 | char *mailbox_name = NULL; | ||
149 | char *buf; | ||
150 | char personal[128]; | ||
151 | int status; | ||
152 | |||
153 | /* Native Language Support */ | ||
154 | mu_init_nls (); | ||
155 | |||
156 | { | ||
157 | int opt; | ||
158 | mu_argp_init (program_version, NULL); | ||
159 | #ifdef WITH_TLS | ||
160 | mu_tls_init_client_argp (); | ||
161 | #endif | ||
162 | mu_argp_parse (&argp, &argc, &argv, 0, capa, &opt, NULL); | ||
163 | mailbox_name = argv[opt]; | ||
164 | } | ||
165 | |||
166 | /* Register the desire formats. */ | ||
167 | mu_register_all_mbox_formats (); | ||
168 | |||
169 | status = mailbox_create_default (&mbox, mailbox_name); | ||
170 | if (status != 0) | ||
171 | { | ||
172 | mu_error (_("Could not create mailbox <%s>: %s."), | ||
173 | mailbox_name ? mailbox_name : _("default"), | ||
174 | mu_strerror (status)); | ||
175 | exit (1); | ||
176 | } | ||
177 | |||
178 | /* Debuging Trace. */ | ||
179 | if (debug) | ||
180 | { | ||
181 | mu_debug_t debug; | ||
182 | mailbox_get_debug (mbox, &debug); | ||
183 | mu_debug_set_level (debug, MU_DEBUG_TRACE|MU_DEBUG_PROT); | ||
184 | } | ||
185 | |||
186 | status = mailbox_open (mbox, MU_STREAM_READ); | ||
187 | if (status != 0) | ||
188 | { | ||
189 | mu_error (_("Could not open mailbox <%s>: %s."), | ||
190 | mailbox_name, mu_strerror (status)); | ||
191 | exit (1); | ||
192 | } | ||
193 | |||
194 | mailbox_messages_count (mbox, &count); | ||
195 | for (i = 1; i <= count; ++i) | ||
196 | { | ||
197 | message_t msg; | ||
198 | header_t hdr; | ||
199 | size_t len = 0; | ||
200 | |||
201 | if ((status = mailbox_get_message (mbox, i, &msg)) != 0 | ||
202 | || (status = message_get_header (msg, &hdr)) != 0) | ||
203 | { | ||
204 | mu_error (_("msg %d : %s"), i, mu_strerror (status)); | ||
205 | exit (2); | ||
206 | } | ||
207 | |||
208 | status = header_aget_value (hdr, MU_HEADER_FROM, &buf); | ||
209 | if (status == 0) | ||
210 | { | ||
211 | address_t address = NULL; | ||
212 | |||
213 | char *s = rfc2047_decode_wrapper (buf, strlen (buf)); | ||
214 | address_create (&address, s); | ||
215 | free (s); | ||
216 | |||
217 | len = 0; | ||
218 | address_get_personal (address, 1, personal, sizeof (personal), &len); | ||
219 | printf ("%s\t", (len != 0) ? personal : buf); | ||
220 | address_destroy (&address); | ||
221 | } | ||
222 | else | ||
223 | { | ||
224 | status = header_aget_value (hdr, MU_HEADER_TO, &buf); | ||
225 | if (status == 0) | ||
226 | { | ||
227 | char *s = rfc2047_decode_wrapper (buf, strlen (buf)); | ||
228 | printf ("%s\t", s); | ||
229 | free (s); | ||
230 | } | ||
231 | } | ||
232 | free (buf); | ||
233 | |||
234 | status = header_aget_value_unfold (hdr, MU_HEADER_SUBJECT, &buf); | ||
235 | if (status == 0) | ||
236 | { | ||
237 | char *s = rfc2047_decode_wrapper (buf, strlen (buf)); | ||
238 | printf ("%s\n", s); | ||
239 | free (s); | ||
240 | free (buf); | ||
241 | } | ||
242 | } | ||
243 | |||
244 | status = mailbox_close (mbox); | ||
245 | if (status != 0) | ||
246 | { | ||
247 | mu_error (_("Could not close <%s>: %s."), | ||
248 | mailbox_name, mu_strerror (status)); | ||
249 | } | ||
250 | |||
251 | mailbox_destroy (&mbox); | ||
252 | return 0; | ||
253 | } |
from/testsuite/.cvsignore
deleted
100644 → 0
from/testsuite/Makefile.am
deleted
100644 → 0
1 | ## Process this file with GNU Automake to create Makefile.in | ||
2 | |||
3 | ## Copyright (C) 2002 Free Software Foundation, Inc. | ||
4 | ## | ||
5 | ## GNU Mailutils is free software; you can redistribute it and/or | ||
6 | ## modify it under the terms of the GNU General Public License as | ||
7 | ## published by the Free Software Foundation; either version 2, or (at | ||
8 | ## your option) any later version. | ||
9 | ## | ||
10 | ## This program is distributed in the hope that it will be useful, but | ||
11 | ## WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | ## General Public License for more details. | ||
14 | ## | ||
15 | ## You should have received a copy of the GNU General Public License | ||
16 | ## along with this program; if not, write to the Free Software | ||
17 | ## Foundation, Inc. | ||
18 | ## 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
19 | |||
20 | AUTOMAKE_OPTIONS = dejagnu | ||
21 | DEJATOOL = from | ||
22 | RUNTESTFLAGS = | ||
23 | CLEANFILES = *.log | ||
24 | test_dirs = from | ||
25 | |||
26 | dist-hook: | ||
27 | here=`cd $(top_builddir)/$(subdir) && pwd`; \ | ||
28 | srcdir=`cd $(srcdir) && pwd`; \ | ||
29 | distdir=`cd $(distdir) && pwd`; \ | ||
30 | for dir in $(test_dirs); \ | ||
31 | do \ | ||
32 | cd $$srcdir;\ | ||
33 | mkdir $$distdir/$$dir;\ | ||
34 | cd $$dir;\ | ||
35 | for file in DISTFILES `cat DISTFILES`; do \ | ||
36 | d=$$srcdir/$$dir; \ | ||
37 | if test -d $$d/$$file; then \ | ||
38 | cp -pr $$d/$$file $$distdir/$$dir/$$file; \ | ||
39 | else \ | ||
40 | test -f $$distdir/$$dir/$$file \ | ||
41 | || cp -p $$d/$$file $$distdir/$$dir/$$file || exit; \ | ||
42 | fi; \ | ||
43 | done;\ | ||
44 | done;\ | ||
45 | cd $$here | ||
46 | |||
47 | site.exp: Makefile remote.exp | ||
48 | @echo 'Making a new site.exp file...' | ||
49 | @test ! -f site.bak || rm -f site.bak | ||
50 | @echo '## these variables are automatically generated by make ##' > $@-t | ||
51 | @echo '# Do not edit here. If you wish to override these values' >> $@-t | ||
52 | @echo '# edit the last section' >> $@-t | ||
53 | @echo 'set tool $(DEJATOOL)' >> $@-t | ||
54 | @echo "set top_srcdir `cd $(top_srcdir); pwd`" >> $@-t | ||
55 | @echo "set srcdir `cd $(srcdir); pwd`" >> $@-t | ||
56 | @echo 'set objdir' `pwd` >> $@-t | ||
57 | @echo 'set host_alias "$(host_alias)"' >> $@-t | ||
58 | @echo 'set host_triplet $(host_triplet)' >> $@-t | ||
59 | @echo 'set target_alias "$(target_alias)"' >> $@-t | ||
60 | @echo 'set target_triplet $(target_triplet)' >> $@-t | ||
61 | @echo 'set build_alias "$(build_alias)"' >> $@-t | ||
62 | @echo 'set build_triplet $(build_triplet)' >> $@-t | ||
63 | @echo '## All variables above are generated by configure. Do Not Edit ##' >> $@-t | ||
64 | @test ! -f site.exp || sed '1,/^## All variables above are.*##/ d' site.exp >> $@-t | ||
65 | @test ! -f site.exp || mv site.exp site.bak | ||
66 | @mv $@-t site.exp | ||
67 | |||
68 | remote.exp:; | ||
69 | @echo 'Making a new remote.exp file...' | ||
70 | @test ! -f remote.bak || rm -f remote.bak | ||
71 | @echo '## These variables are used to set up for the remote testing.' >> $@-t | ||
72 | @echo '## Please, read file README in this directory for instructions' >> $@-t | ||
73 | @echo '## on how to use this file' >> $@-t | ||
74 | @echo "set host_board `hostname`" >> $@-t | ||
75 | @echo 'set board_info($$host_board,connect) rlogin' >> $@-t | ||
76 | @echo 'set board_info($$host_board,shell_prompt) "\\$$ "' >> $@-t | ||
77 | @echo "set board_info(\$$host_board,top_srcdir) `cd $(top_srcdir); pwd`" >> $@-t | ||
78 | @echo "set board_info(\$$host_board,srcdir) `cd $(srcdir); pwd`" >> $@-t | ||
79 | @echo "set board_info(\$$host_board,objdir) `pwd`" >> $@-t | ||
80 | @echo "set board_info(\$$host_board,top_srcdir) `cd $(top_srcdir); pwd`" >> $@-t | ||
81 | @echo "set board_info(\$$host_board,top_builddir) `cd $(top_builddir); pwd`" >> $@-t | ||
82 | @test ! -f remote.exp || mv remote.exp remote.bak | ||
83 | @mv $@-t remote.exp | ||
84 | |||
85 | |||
86 | DISTCLEANFILES=*.exp *.log *.sum | ||
87 | |||
88 | distclean-local: | ||
89 | -rm -rf data |
from/testsuite/from/DISTFILES
deleted
100644 → 0
1 | test.exp |
from/testsuite/from/test.exp
deleted
100644 → 0
1 | # -*- tcl -*- | ||
2 | # This file is part of Mailutils testsuite. | ||
3 | # Copyright (C) 2002, Free Software Foundation | ||
4 | # | ||
5 | # This program is free software; you can redistribute it and/or modify | ||
6 | # it under the terms of the GNU General Public License as published by | ||
7 | # the Free Software Foundation; either version 2 of the License, or | ||
8 | # (at your option) any later version. | ||
9 | # | ||
10 | # This program is distributed in the hope that it will be useful, | ||
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | # GNU General Public License for more details. | ||
14 | # | ||
15 | # You should have received a copy of the GNU General Public License | ||
16 | # along with this program; if not, write to the Free Software Foundation, | ||
17 | # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
18 | |||
19 | source $top_srcdir/testsuite/lib/mailutils.exp | ||
20 | |||
21 | mu_init | ||
22 | set env(MAIL) $MU_SPOOL_DIR/mbox1 | ||
23 | set env(FOLDER) $env(MAIL) | ||
24 | |||
25 | mu_prepare_spools | ||
26 | |||
27 | mu_exec -message "from" \ | ||
28 | "Foo Bar\tJabberwocky"\ | ||
29 | "Bar\tRe: Jabberwocky"\ | ||
30 | "Sergey Poznyakoff\tSimple MIME"\ | ||
31 | "Sergey Poznyakoff\tNested MIME"\ | ||
32 | "Sergey Poznyakoff\tEmpty MIME Parts" | ||
33 | |||
34 | mu_exec -message "from mbox" -arg %mbox \ | ||
35 | "Sergey Poznyakoff\tMBOX" | ||
36 | |||
37 | #end of test.exp |
-
Please register or sign in to post a comment