Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 64 / 4d4abe19301bf26d23fc4f516db48cd160138f
1 Return-Path: <bremner@tethera.net>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 41B1941439B\r
6         for <notmuch@notmuchmail.org>; Sat, 14 Jan 2012 17:41:02 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -2.3\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id VSQifmqQRE8b for <notmuch@notmuchmail.org>;\r
16         Sat, 14 Jan 2012 17:41:00 -0800 (PST)\r
17 Received: from tempo.its.unb.ca (tempo.its.unb.ca [131.202.1.21])\r
18         (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
19         (No client certificate requested)\r
20         by olra.theworths.org (Postfix) with ESMTPS id 5330B41439D\r
21         for <notmuch@notmuchmail.org>; Sat, 14 Jan 2012 17:40:52 -0800 (PST)\r
22 Received: from zancas.localnet\r
23         (fctnnbsc36w-156034076032.pppoe-dynamic.High-Speed.nb.bellaliant.net\r
24         [156.34.76.32]) (authenticated bits=0)\r
25         by tempo.its.unb.ca (8.13.8/8.13.8) with ESMTP id q0F1efaI008568\r
26         (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO);\r
27         Sat, 14 Jan 2012 21:40:44 -0400\r
28 Received: from bremner by zancas.localnet with local (Exim 4.77)\r
29         (envelope-from <bremner@tethera.net>)\r
30         id 1RmF5M-00042j-ST; Sat, 14 Jan 2012 21:40:40 -0400\r
31 From: David Bremner <david@tethera.net>\r
32 To: notmuch@notmuchmail.org\r
33 Subject: [PATCH v3 02/10] test/hex-xcode: new test binary\r
34 Date: Sat, 14 Jan 2012 21:40:16 -0400\r
35 Message-Id: <1326591624-15493-3-git-send-email-david@tethera.net>\r
36 X-Mailer: git-send-email 1.7.7.3\r
37 In-Reply-To: <1326591624-15493-1-git-send-email-david@tethera.net>\r
38 References: <874nwxbkhr.fsf@zancas.localnet>\r
39         <1326591624-15493-1-git-send-email-david@tethera.net>\r
40 Cc: David Bremner <bremner@debian.org>\r
41 X-BeenThere: notmuch@notmuchmail.org\r
42 X-Mailman-Version: 2.1.13\r
43 Precedence: list\r
44 List-Id: "Use and development of the notmuch mail system."\r
45         <notmuch.notmuchmail.org>\r
46 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
47         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
48 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
49 List-Post: <mailto:notmuch@notmuchmail.org>\r
50 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
51 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
52         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
53 X-List-Received-Date: Sun, 15 Jan 2012 01:41:02 -0000\r
54 \r
55 From: David Bremner <bremner@debian.org>\r
56 \r
57 This program is used both as a test-bed/unit-tester for\r
58 ../util/hex-escape.c, and also as a utility in future tests of dump\r
59 and restore.\r
60 ---\r
61  test/.gitignore     |    1 +\r
62  test/Makefile.local |    6 ++-\r
63  test/basic          |    2 +-\r
64  test/hex-xcode.c    |  103 +++++++++++++++++++++++++++++++++++++++++++++++++++\r
65  4 files changed, 110 insertions(+), 2 deletions(-)\r
66  create mode 100644 test/hex-xcode.c\r
67 \r
68 diff --git a/test/.gitignore b/test/.gitignore\r
69 index e63c689..be7ab5e 100644\r
70 --- a/test/.gitignore\r
71 +++ b/test/.gitignore\r
72 @@ -3,4 +3,5 @@ corpus.mail\r
73  smtp-dummy\r
74  symbol-test\r
75  arg-test\r
76 +hex-xcode\r
77  tmp.*\r
78 diff --git a/test/Makefile.local b/test/Makefile.local\r
79 index fa2df73..ba697f4 100644\r
80 --- a/test/Makefile.local\r
81 +++ b/test/Makefile.local\r
82 @@ -13,6 +13,9 @@ smtp_dummy_modules = $(smtp_dummy_srcs:.c=.o)\r
83  $(dir)/arg-test: $(dir)/arg-test.o command-line-arguments.o util/libutil.a\r
84         $(call quiet,CC) -I. $^ -o $@\r
85  \r
86 +$(dir)/hex-xcode: $(dir)/hex-xcode.o command-line-arguments.o util/libutil.a\r
87 +       $(call quiet,CC) -I. $^ -o $@ -ltalloc\r
88 +\r
89  $(dir)/smtp-dummy: $(smtp_dummy_modules)\r
90         $(call quiet,CC) $^ -o $@\r
91  \r
92 @@ -21,7 +24,8 @@ $(dir)/symbol-test: $(dir)/symbol-test.o\r
93  \r
94  .PHONY: test check\r
95  \r
96 -test-binaries: $(dir)/arg-test $(dir)/smtp-dummy $(dir)/symbol-test\r
97 +test-binaries: $(dir)/arg-test $(dir)/hex-xcode \\r
98 +        $(dir)/smtp-dummy $(dir)/symbol-test\r
99  \r
100  test:  all test-binaries\r
101         @${dir}/notmuch-test $(OPTIONS)\r
102 diff --git a/test/basic b/test/basic\r
103 index d6aed24..af57026 100755\r
104 --- a/test/basic\r
105 +++ b/test/basic\r
106 @@ -54,7 +54,7 @@ test_begin_subtest 'Ensure that all available tests will be run by notmuch-test'\r
107  eval $(sed -n -e '/^TESTS="$/,/^"$/p' $TEST_DIRECTORY/notmuch-test)\r
108  tests_in_suite=$(for i in $TESTS; do echo $i; done | sort)\r
109  available=$(find "$TEST_DIRECTORY" -maxdepth 1 -type f -executable -printf '%f\n' | \\r
110 -    sed -r -e "/^(aggregate-results.sh|notmuch-test|smtp-dummy|test-verbose|symbol-test|arg-test)$/d" | \\r
111 +    sed -r -e "/^(aggregate-results.sh|notmuch-test|smtp-dummy|test-verbose|symbol-test|arg-test|hex-xcode)$/d" | \\r
112      sort)\r
113  test_expect_equal "$tests_in_suite" "$available"\r
114  \r
115 diff --git a/test/hex-xcode.c b/test/hex-xcode.c\r
116 new file mode 100644\r
117 index 0000000..eec6541\r
118 --- /dev/null\r
119 +++ b/test/hex-xcode.c\r
120 @@ -0,0 +1,103 @@\r
121 +/* No, nothing to to with IDE from Apple Inc.\r
122 +   testbed for ../util/hex-escape.c.\r
123 +\r
124 +   usage:\r
125 +   hex-xcode [--direction=(encode|decode)] [--omit-newline] < file\r
126 +   hex-xcode [--direction=(encode|decode)] [--omit-newline] arg1 arg2 arg3 ...\r
127 +\r
128 + */\r
129 +\r
130 +#include "notmuch-client.h"\r
131 +#include "hex-escape.h"\r
132 +#include <assert.h>\r
133 +\r
134 +\r
135 +enum direction {\r
136 +    ENCODE,\r
137 +    DECODE\r
138 +};\r
139 +\r
140 +static int\r
141 +xcode (void *ctx, enum direction dir, char *in, char **buf_p, size_t *size_p)\r
142 +{\r
143 +    hex_status_t status;\r
144 +\r
145 +    if (dir == ENCODE)\r
146 +       status = hex_encode (ctx, in, buf_p, size_p);\r
147 +    else\r
148 +       status = hex_decode (ctx, in, buf_p, size_p);\r
149 +\r
150 +    if (status == HEX_SUCCESS)\r
151 +       fputs (*buf_p, stdout);\r
152 +\r
153 +    return status;\r
154 +}\r
155 +\r
156 +\r
157 +int\r
158 +main (int argc, char **argv)\r
159 +{\r
160 +\r
161 +\r
162 +    enum direction dir = DECODE;\r
163 +    int omit_newline = FALSE;\r
164 +\r
165 +    notmuch_opt_desc_t options[] = {\r
166 +       { NOTMUCH_OPT_KEYWORD, &dir, "direction", 'd',\r
167 +         (notmuch_keyword_t []){ { "encode", ENCODE },\r
168 +                                 { "decode", DECODE },\r
169 +                                 { 0, 0 } } },\r
170 +       { NOTMUCH_OPT_BOOLEAN, &omit_newline, "omit-newline", 'n', 0 },\r
171 +       { 0, 0, 0, 0, 0 }\r
172 +    };\r
173 +\r
174 +    int opt_index = parse_arguments (argc, argv, options, 1);\r
175 +\r
176 +    if (opt_index < 0)\r
177 +       exit (1);\r
178 +\r
179 +    void *ctx = talloc_new (NULL);\r
180 +\r
181 +    char *line = NULL;\r
182 +    size_t line_size;\r
183 +    ssize_t line_len;\r
184 +\r
185 +    char *buffer = NULL;\r
186 +    size_t buf_size = 0;\r
187 +\r
188 +    notmuch_bool_t read_stdin = TRUE;\r
189 +\r
190 +    for (; opt_index < argc; opt_index++) {\r
191 +\r
192 +       if (xcode (ctx, dir, argv[opt_index],\r
193 +                  &buffer, &buf_size) != HEX_SUCCESS)\r
194 +           return 1;\r
195 +\r
196 +       if (!omit_newline)\r
197 +           putchar ('\n');\r
198 +\r
199 +       read_stdin = FALSE;\r
200 +    }\r
201 +\r
202 +    if (!read_stdin)\r
203 +       return 0;\r
204 +\r
205 +    while ((line_len = getline (&line, &line_size, stdin)) != -1) {\r
206 +\r
207 +       chomp_newline (line);\r
208 +\r
209 +       if (xcode (ctx, dir, line, &buffer, &buf_size) != HEX_SUCCESS)\r
210 +           return 1;\r
211 +\r
212 +       if (!omit_newline)\r
213 +           putchar ('\n');\r
214 +\r
215 +    }\r
216 +\r
217 +    if (line)\r
218 +       free (line);\r
219 +\r
220 +    talloc_free (ctx);\r
221 +\r
222 +    return 0;\r
223 +}\r
224 -- \r
225 1.7.7.3\r
226 \r