Re: [feature request] emacs: use `notmuch insert` for FCC
[notmuch-archives.git] / 77 / 4a6eac040e80ee3c60fb58b3eda496cbbb4fc2
1 Return-Path: <jani@nikula.org>\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 BC35F431FAF\r
6         for <notmuch@notmuchmail.org>; Sun, 15 Jan 2012 00:05:18 -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: -0.699\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.699 tagged_above=-999 required=5\r
12         tests=[HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-0.7] 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 m9UHXtLjTjfT for <notmuch@notmuchmail.org>;\r
16         Sun, 15 Jan 2012 00:05:17 -0800 (PST)\r
17 Received: from mail-pz0-f53.google.com (mail-pz0-f53.google.com\r
18         [209.85.210.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
19         (No client certificate requested)\r
20         by olra.theworths.org (Postfix) with ESMTPS id 49D2A431FAE\r
21         for <notmuch@notmuchmail.org>; Sun, 15 Jan 2012 00:05:17 -0800 (PST)\r
22 Received: by dalz17 with SMTP id z17so2743369dal.26\r
23         for <notmuch@notmuchmail.org>; Sun, 15 Jan 2012 00:05:15 -0800 (PST)\r
24 MIME-Version: 1.0\r
25 Received: by 10.68.213.38 with SMTP id np6mr16285599pbc.37.1326614715150; Sun,\r
26         15 Jan 2012 00:05:15 -0800 (PST)\r
27 Received: by 10.68.58.234 with HTTP; Sun, 15 Jan 2012 00:05:15 -0800 (PST)\r
28 Received: by 10.68.58.234 with HTTP; Sun, 15 Jan 2012 00:05:15 -0800 (PST)\r
29 In-Reply-To: <1326591624-15493-10-git-send-email-david@tethera.net>\r
30 References: <874nwxbkhr.fsf@zancas.localnet>\r
31         <1326591624-15493-1-git-send-email-david@tethera.net>\r
32         <1326591624-15493-10-git-send-email-david@tethera.net>\r
33 Date: Sun, 15 Jan 2012 10:05:15 +0200\r
34 Message-ID:\r
35  <CAB+hUn9Eas_4DRc8FDk+S88JiWhcOipHc_ePn4pHe89B72=JiA@mail.gmail.com>\r
36 Subject: Re: [PATCH v3 09/10] random-dump.c: new test-binary to generate dump\r
37         files\r
38 From: Jani Nikula <jani@nikula.org>\r
39 To: David Bremner <david@tethera.net>\r
40 Content-Type: multipart/alternative; boundary=e89a8ff1c322d9b16904b68c8ec8\r
41 Cc: notmuch@notmuchmail.org, David Bremner <bremner@debian.org>\r
42 X-BeenThere: notmuch@notmuchmail.org\r
43 X-Mailman-Version: 2.1.13\r
44 Precedence: list\r
45 List-Id: "Use and development of the notmuch mail system."\r
46         <notmuch.notmuchmail.org>\r
47 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
48         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
49 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
50 List-Post: <mailto:notmuch@notmuchmail.org>\r
51 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
52 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
53         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
54 X-List-Received-Date: Sun, 15 Jan 2012 08:05:18 -0000\r
55 \r
56 --e89a8ff1c322d9b16904b68c8ec8\r
57 Content-Type: text/plain; charset=UTF-8\r
58 \r
59 On Jan 15, 2012 3:41 AM, "David Bremner" <david@tethera.net> wrote:\r
60 >\r
61 > From: David Bremner <bremner@debian.org>\r
62 >\r
63 > This binary creates a "torture test" dump file for the new dump\r
64 > format.\r
65 > ---\r
66 >  test/Makefile.local |    4 ++\r
67 >  test/basic          |    2 +-\r
68 >  test/random-dump.c  |  144\r
69 +++++++++++++++++++++++++++++++++++++++++++++++++++\r
70 >  3 files changed, 149 insertions(+), 1 deletions(-)\r
71 >  create mode 100644 test/random-dump.c\r
72 >\r
73 > diff --git a/test/Makefile.local b/test/Makefile.local\r
74 > index ba697f4..b59f837 100644\r
75 > --- a/test/Makefile.local\r
76 > +++ b/test/Makefile.local\r
77 > @@ -16,6 +16,9 @@ $(dir)/arg-test: $(dir)/arg-test.o\r
78 command-line-arguments.o util/libutil.a\r
79 >  $(dir)/hex-xcode: $(dir)/hex-xcode.o command-line-arguments.o\r
80 util/libutil.a\r
81 >        $(call quiet,CC) -I. $^ -o $@ -ltalloc\r
82 >\r
83 > +$(dir)/random-dump:  $(dir)/random-dump.o command-line-arguments.o\r
84 util/libutil.a\r
85 > +       $(call quiet,CC) -I. $^ -o $@ -ltalloc -lm\r
86 > +\r
87 >  $(dir)/smtp-dummy: $(smtp_dummy_modules)\r
88 >        $(call quiet,CC) $^ -o $@\r
89 >\r
90 > @@ -25,6 +28,7 @@ $(dir)/symbol-test: $(dir)/symbol-test.o\r
91 >  .PHONY: test check\r
92 >\r
93 >  test-binaries: $(dir)/arg-test $(dir)/hex-xcode \\r
94 > +       $(dir)/random-dump \\r
95 >         $(dir)/smtp-dummy $(dir)/symbol-test\r
96 >\r
97 >  test:  all test-binaries\r
98 > diff --git a/test/basic b/test/basic\r
99 > index af57026..e3a6cef 100755\r
100 > --- a/test/basic\r
101 > +++ b/test/basic\r
102 > @@ -54,7 +54,7 @@ test_begin_subtest 'Ensure that all available tests\r
103 will be run by notmuch-test'\r
104 >  eval $(sed -n -e '/^TESTS="$/,/^"$/p' $TEST_DIRECTORY/notmuch-test)\r
105 >  tests_in_suite=$(for i in $TESTS; do echo $i; done | sort)\r
106 >  available=$(find "$TEST_DIRECTORY" -maxdepth 1 -type f -executable\r
107 -printf '%f\n' | \\r
108 > -    sed -r -e\r
109 "/^(aggregate-results.sh|notmuch-test|smtp-dummy|test-verbose|symbol-test|arg-test|hex-xcode)$/d"\r
110 | \\r
111 > +    sed -r -e\r
112 "/^(aggregate-results.sh|notmuch-test|smtp-dummy|test-verbose|symbol-test|arg-test|hex-xcode|random-dump)$/d"\r
113 | \\r
114 >     sort)\r
115 >  test_expect_equal "$tests_in_suite" "$available"\r
116 >\r
117 > diff --git a/test/random-dump.c b/test/random-dump.c\r
118 > new file mode 100644\r
119 > index 0000000..1949425\r
120 > --- /dev/null\r
121 > +++ b/test/random-dump.c\r
122 > @@ -0,0 +1,144 @@\r
123 > +/*\r
124 > +   Generate a random dump file in 'notmuch' format.\r
125 > +   Generated message-id's and tags are intentionally nasty.\r
126 > +\r
127 > +   We restrict ourselves to 7 bit message-ids, because generating\r
128 > +   random valid UTF-8 seems like work. And invalid UTF-8 can't be\r
129 > +   round-tripped via Xapian.\r
130 > +\r
131 > + */\r
132 > +\r
133 > +#include <stdlib.h>\r
134 > +#include <assert.h>\r
135 > +#include <talloc.h>\r
136 > +#include <string.h>\r
137 > +#include "math.h"\r
138 > +#include "hex-escape.h"\r
139 > +#include "command-line-arguments.h"\r
140 > +\r
141 > +static void\r
142 > +hex_out (void *ctx, char *buf)\r
143 > +{\r
144 > +    static char *encoded_buf = NULL;\r
145 > +    static size_t encoded_buf_size = 0;\r
146 > +\r
147 > +    if (hex_encode (ctx, buf, &encoded_buf, &encoded_buf_size) !=\r
148 HEX_SUCCESS) {\r
149 > +       fprintf (stderr, "Hex encoding failed");\r
150 > +       exit (1);\r
151 > +    }\r
152 > +\r
153 > +    fputs (encoded_buf, stdout);\r
154 > +}\r
155 > +\r
156 > +static void\r
157 > +random_chars (char *buf, int from, int stop, int max_char,\r
158 > +             const char *blacklist)\r
159 > +{\r
160 > +    int i;\r
161 > +\r
162 > +    for (i = from; i < stop; i++) {\r
163 > +       do {\r
164 > +           buf[i] = ' ' + (random () % (max_char - ' '));\r
165 > +       } while (blacklist && strchr (blacklist, buf[i]));\r
166 > +    }\r
167 > +}\r
168 > +\r
169 > +static void\r
170 > +random_tag (void *ctx, size_t len)\r
171 > +{\r
172 > +    static char *buf = NULL;\r
173 > +    static size_t buf_len = 0;\r
174 > +\r
175 > +    int use = (random () % (len - 1)) + 1;\r
176 > +\r
177 > +    if (len > buf_len) {\r
178 > +       buf = talloc_realloc (ctx, buf, char, len);\r
179 > +       buf_len = len;\r
180 > +    }\r
181 > +\r
182 > +    random_chars (buf, 0, use, 255, NULL);\r
183 > +\r
184 > +    buf[use] = '\0';\r
185 > +\r
186 > +    hex_out (ctx, buf);\r
187 > +}\r
188 > +\r
189 > +static void\r
190 > +random_message_id (void *ctx, size_t len)\r
191 > +{\r
192 > +    static char *buf = NULL;\r
193 > +    static size_t buf_len = 0;\r
194 > +\r
195 > +    int lhs_len = (random () % (len / 2 - 1)) + 1;\r
196 > +\r
197 > +    int rhs_len = (random () % len / 2) + 1;\r
198 > +\r
199 > +    const char *blacklist = "\n\r@<>[]()";\r
200 > +\r
201 > +    if (len > buf_len) {\r
202 > +       buf = talloc_realloc (ctx, buf, char, len);\r
203 > +       buf_len = len;\r
204 > +    }\r
205 > +\r
206 > +    random_chars (buf, 0, lhs_len, 127, blacklist);\r
207 > +\r
208 > +    buf[lhs_len] = '@';\r
209 > +\r
210 > +    random_chars (buf, lhs_len + 1, lhs_len + rhs_len + 1, 127,\r
211 blacklist);\r
212 > +\r
213 > +    hex_out (ctx, buf);\r
214 > +}\r
215 > +\r
216 > +int\r
217 > +main (int argc, char **argv)\r
218 > +{\r
219 > +\r
220 > +    void *ctx = talloc_new (NULL);\r
221 > +    int num_lines = 500;\r
222 > +    int max_tags = 10;\r
223 > +    int message_id_len = 100;\r
224 > +    int tag_len = 50;\r
225 > +    int seed = 734569;\r
226 > +\r
227 > +    int pad_tag = 0, pad_mid = 0;\r
228 > +\r
229 > +    notmuch_opt_desc_t options[] = {\r
230 > +       { NOTMUCH_OPT_INT, &num_lines, "num-lines", 'n', 0 },\r
231 > +       { NOTMUCH_OPT_INT, &max_tags, "max-tags", 'm', 0 },\r
232 > +       { NOTMUCH_OPT_INT, &message_id_len, "message-id-len", 'M', 0 },\r
233 > +       { NOTMUCH_OPT_INT, &tag_len, "tag-len", 't', 0 },\r
234 > +       { NOTMUCH_OPT_INT, &seed, "tag-len", 't', 0 },\r
235 \r
236 s/tag-len/seed/\r
237 \r
238 > +       { 0, 0, 0, 0, 0 }\r
239 > +    };\r
240 > +\r
241 > +    int opt_index = parse_arguments (argc, argv, options, 1);\r
242 > +\r
243 > +    if (opt_index < 0)\r
244 > +       exit (1);\r
245 > +\r
246 > +    pad_mid = ((int) log10 (num_lines) + 1);\r
247 > +    pad_tag = ((int) log10 (max_tags)) + 1;\r
248 > +\r
249 > +    srandom (seed);\r
250 > +\r
251 > +    int line;\r
252 > +    for (line = 0; line < num_lines; line++) {\r
253 > +\r
254 > +       printf ("%0*d-", pad_mid, line);\r
255 > +\r
256 > +       random_message_id (ctx, message_id_len);\r
257 > +\r
258 > +       int num_tags = random () % (max_tags + 1);\r
259 > +\r
260 > +       int j;\r
261 > +       for (j = 0; j < num_tags; j++) {\r
262 > +           printf (" %0*d-", pad_tag, j);\r
263 > +           random_tag (ctx, tag_len);\r
264 > +       }\r
265 > +       putchar ('\n');\r
266 > +    }\r
267 > +\r
268 > +    talloc_free (ctx);\r
269 > +\r
270 > +    return 0;\r
271 > +}\r
272 > --\r
273 > 1.7.7.3\r
274 >\r
275 > _______________________________________________\r
276 > notmuch mailing list\r
277 > notmuch@notmuchmail.org\r
278 > http://notmuchmail.org/mailman/listinfo/notmuch\r
279 \r
280 --e89a8ff1c322d9b16904b68c8ec8\r
281 Content-Type: text/html; charset=UTF-8\r
282 Content-Transfer-Encoding: quoted-printable\r
283 \r
284 <p><br>\r
285 On Jan 15, 2012 3:41 AM, &quot;David Bremner&quot; &lt;<a href=3D"mailto:da=\r
286 vid@tethera.net">david@tethera.net</a>&gt; wrote:<br>\r
287 &gt;<br>\r
288 &gt; From: David Bremner &lt;<a href=3D"mailto:bremner@debian.org">bremner@=\r
289 debian.org</a>&gt;<br>\r
290 &gt;<br>\r
291 &gt; This binary creates a &quot;torture test&quot; dump file for the new d=\r
292 ump<br>\r
293 &gt; format.<br>\r
294 &gt; ---<br>\r
295 &gt; =C2=A0test/Makefile.local | =C2=A0 =C2=A04 ++<br>\r
296 &gt; =C2=A0test/basic =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| =C2=A0 =C2=A02 +-=\r
297 <br>\r
298 &gt; =C2=A0test/random-dump.c =C2=A0| =C2=A0144 +++++++++++++++++++++++++++=\r
299 ++++++++++++++++++++++++<br>\r
300 &gt; =C2=A03 files changed, 149 insertions(+), 1 deletions(-)<br>\r
301 &gt; =C2=A0create mode 100644 test/random-dump.c<br>\r
302 &gt;<br>\r
303 &gt; diff --git a/test/Makefile.local b/test/Makefile.local<br>\r
304 &gt; index ba697f4..b59f837 100644<br>\r
305 &gt; --- a/test/Makefile.local<br>\r
306 &gt; +++ b/test/Makefile.local<br>\r
307 &gt; @@ -16,6 +16,9 @@ $(dir)/arg-test: $(dir)/arg-test.o command-line-argu=\r
308 ments.o util/libutil.a<br>\r
309 &gt; =C2=A0$(dir)/hex-xcode: $(dir)/hex-xcode.o command-line-arguments.o ut=\r
310 il/libutil.a<br>\r
311 &gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0$(call quiet,CC) -I. $^ -o $@ -ltalloc<br>\r
312 &gt;<br>\r
313 &gt; +$(dir)/random-dump: =C2=A0$(dir)/random-dump.o command-line-arguments=\r
314 .o util/libutil.a<br>\r
315 &gt; + =C2=A0 =C2=A0 =C2=A0 $(call quiet,CC) -I. $^ -o $@ -ltalloc -lm<br>\r
316 &gt; +<br>\r
317 &gt; =C2=A0$(dir)/smtp-dummy: $(smtp_dummy_modules)<br>\r
318 &gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0$(call quiet,CC) $^ -o $@<br>\r
319 &gt;<br>\r
320 &gt; @@ -25,6 +28,7 @@ $(dir)/symbol-test: $(dir)/symbol-test.o<br>\r
321 &gt; =C2=A0.PHONY: test check<br>\r
322 &gt;<br>\r
323 &gt; =C2=A0test-binaries: $(dir)/arg-test $(dir)/hex-xcode \<br>\r
324 &gt; + =C2=A0 =C2=A0 =C2=A0 $(dir)/random-dump \<br>\r
325 &gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 $(dir)/smtp-dummy $(dir)/symbol-test<br>\r
326 &gt;<br>\r
327 &gt; =C2=A0test: =C2=A0all test-binaries<br>\r
328 &gt; diff --git a/test/basic b/test/basic<br>\r
329 &gt; index af57026..e3a6cef 100755<br>\r
330 &gt; --- a/test/basic<br>\r
331 &gt; +++ b/test/basic<br>\r
332 &gt; @@ -54,7 +54,7 @@ test_begin_subtest &#39;Ensure that all available te=\r
333 sts will be run by notmuch-test&#39;<br>\r
334 &gt; =C2=A0eval $(sed -n -e &#39;/^TESTS=3D&quot;$/,/^&quot;$/p&#39; $TEST_=\r
335 DIRECTORY/notmuch-test)<br>\r
336 &gt; =C2=A0tests_in_suite=3D$(for i in $TESTS; do echo $i; done | sort)<br>\r
337 &gt; =C2=A0available=3D$(find &quot;$TEST_DIRECTORY&quot; -maxdepth 1 -type=\r
338  f -executable -printf &#39;%f\n&#39; | \<br>\r
339 &gt; - =C2=A0 =C2=A0sed -r -e &quot;/^(aggregate-results.sh|notmuch-test|sm=\r
340 tp-dummy|test-verbose|symbol-test|arg-test|hex-xcode)$/d&quot; | \<br>\r
341 &gt; + =C2=A0 =C2=A0sed -r -e &quot;/^(aggregate-results.sh|notmuch-test|sm=\r
342 tp-dummy|test-verbose|symbol-test|arg-test|hex-xcode|random-dump)$/d&quot; =\r
343 | \<br>\r
344 &gt; =C2=A0 =C2=A0 sort)<br>\r
345 &gt; =C2=A0test_expect_equal &quot;$tests_in_suite&quot; &quot;$available&q=\r
346 uot;<br>\r
347 &gt;<br>\r
348 &gt; diff --git a/test/random-dump.c b/test/random-dump.c<br>\r
349 &gt; new file mode 100644<br>\r
350 &gt; index 0000000..1949425<br>\r
351 &gt; --- /dev/null<br>\r
352 &gt; +++ b/test/random-dump.c<br>\r
353 &gt; @@ -0,0 +1,144 @@<br>\r
354 &gt; +/*<br>\r
355 &gt; + =C2=A0 Generate a random dump file in &#39;notmuch&#39; format.<br>\r
356 &gt; + =C2=A0 Generated message-id&#39;s and tags are intentionally nasty.<=\r
357 br>\r
358 &gt; +<br>\r
359 &gt; + =C2=A0 We restrict ourselves to 7 bit message-ids, because generatin=\r
360 g<br>\r
361 &gt; + =C2=A0 random valid UTF-8 seems like work. And invalid UTF-8 can&#39=\r
362 ;t be<br>\r
363 &gt; + =C2=A0 round-tripped via Xapian.<br>\r
364 &gt; +<br>\r
365 &gt; + */<br>\r
366 &gt; +<br>\r
367 &gt; +#include &lt;stdlib.h&gt;<br>\r
368 &gt; +#include &lt;assert.h&gt;<br>\r
369 &gt; +#include &lt;talloc.h&gt;<br>\r
370 &gt; +#include &lt;string.h&gt;<br>\r
371 &gt; +#include &quot;math.h&quot;<br>\r
372 &gt; +#include &quot;hex-escape.h&quot;<br>\r
373 &gt; +#include &quot;command-line-arguments.h&quot;<br>\r
374 &gt; +<br>\r
375 &gt; +static void<br>\r
376 &gt; +hex_out (void *ctx, char *buf)<br>\r
377 &gt; +{<br>\r
378 &gt; + =C2=A0 =C2=A0static char *encoded_buf =3D NULL;<br>\r
379 &gt; + =C2=A0 =C2=A0static size_t encoded_buf_size =3D 0;<br>\r
380 &gt; +<br>\r
381 &gt; + =C2=A0 =C2=A0if (hex_encode (ctx, buf, &amp;encoded_buf, &amp;encode=\r
382 d_buf_size) !=3D HEX_SUCCESS) {<br>\r
383 &gt; + =C2=A0 =C2=A0 =C2=A0 fprintf (stderr, &quot;Hex encoding failed&quot=\r
384 ;);<br>\r
385 &gt; + =C2=A0 =C2=A0 =C2=A0 exit (1);<br>\r
386 &gt; + =C2=A0 =C2=A0}<br>\r
387 &gt; +<br>\r
388 &gt; + =C2=A0 =C2=A0fputs (encoded_buf, stdout);<br>\r
389 &gt; +}<br>\r
390 &gt; +<br>\r
391 &gt; +static void<br>\r
392 &gt; +random_chars (char *buf, int from, int stop, int max_char,<br>\r
393 &gt; + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 const char *blacklist)<br>\r
394 &gt; +{<br>\r
395 &gt; + =C2=A0 =C2=A0int i;<br>\r
396 &gt; +<br>\r
397 &gt; + =C2=A0 =C2=A0for (i =3D from; i &lt; stop; i++) {<br>\r
398 &gt; + =C2=A0 =C2=A0 =C2=A0 do {<br>\r
399 &gt; + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 buf[i] =3D &#39; &#39; + (random =\r
400 () % (max_char - &#39; &#39;));<br>\r
401 &gt; + =C2=A0 =C2=A0 =C2=A0 } while (blacklist &amp;&amp; strchr (blacklist=\r
402 , buf[i]));<br>\r
403 &gt; + =C2=A0 =C2=A0}<br>\r
404 &gt; +}<br>\r
405 &gt; +<br>\r
406 &gt; +static void<br>\r
407 &gt; +random_tag (void *ctx, size_t len)<br>\r
408 &gt; +{<br>\r
409 &gt; + =C2=A0 =C2=A0static char *buf =3D NULL;<br>\r
410 &gt; + =C2=A0 =C2=A0static size_t buf_len =3D 0;<br>\r
411 &gt; +<br>\r
412 &gt; + =C2=A0 =C2=A0int use =3D (random () % (len - 1)) + 1;<br>\r
413 &gt; +<br>\r
414 &gt; + =C2=A0 =C2=A0if (len &gt; buf_len) {<br>\r
415 &gt; + =C2=A0 =C2=A0 =C2=A0 buf =3D talloc_realloc (ctx, buf, char, len);<b=\r
416 r>\r
417 &gt; + =C2=A0 =C2=A0 =C2=A0 buf_len =3D len;<br>\r
418 &gt; + =C2=A0 =C2=A0}<br>\r
419 &gt; +<br>\r
420 &gt; + =C2=A0 =C2=A0random_chars (buf, 0, use, 255, NULL);<br>\r
421 &gt; +<br>\r
422 &gt; + =C2=A0 =C2=A0buf[use] =3D &#39;\0&#39;;<br>\r
423 &gt; +<br>\r
424 &gt; + =C2=A0 =C2=A0hex_out (ctx, buf);<br>\r
425 &gt; +}<br>\r
426 &gt; +<br>\r
427 &gt; +static void<br>\r
428 &gt; +random_message_id (void *ctx, size_t len)<br>\r
429 &gt; +{<br>\r
430 &gt; + =C2=A0 =C2=A0static char *buf =3D NULL;<br>\r
431 &gt; + =C2=A0 =C2=A0static size_t buf_len =3D 0;<br>\r
432 &gt; +<br>\r
433 &gt; + =C2=A0 =C2=A0int lhs_len =3D (random () % (len / 2 - 1)) + 1;<br>\r
434 &gt; +<br>\r
435 &gt; + =C2=A0 =C2=A0int rhs_len =3D (random () % len / 2) + 1;<br>\r
436 &gt; +<br>\r
437 &gt; + =C2=A0 =C2=A0const char *blacklist =3D &quot;\n\r@&lt;&gt;[]()&quot;=\r
438 ;<br>\r
439 &gt; +<br>\r
440 &gt; + =C2=A0 =C2=A0if (len &gt; buf_len) {<br>\r
441 &gt; + =C2=A0 =C2=A0 =C2=A0 buf =3D talloc_realloc (ctx, buf, char, len);<b=\r
442 r>\r
443 &gt; + =C2=A0 =C2=A0 =C2=A0 buf_len =3D len;<br>\r
444 &gt; + =C2=A0 =C2=A0}<br>\r
445 &gt; +<br>\r
446 &gt; + =C2=A0 =C2=A0random_chars (buf, 0, lhs_len, 127, blacklist);<br>\r
447 &gt; +<br>\r
448 &gt; + =C2=A0 =C2=A0buf[lhs_len] =3D &#39;@&#39;;<br>\r
449 &gt; +<br>\r
450 &gt; + =C2=A0 =C2=A0random_chars (buf, lhs_len + 1, lhs_len + rhs_len + 1, =\r
451 127, blacklist);<br>\r
452 &gt; +<br>\r
453 &gt; + =C2=A0 =C2=A0hex_out (ctx, buf);<br>\r
454 &gt; +}<br>\r
455 &gt; +<br>\r
456 &gt; +int<br>\r
457 &gt; +main (int argc, char **argv)<br>\r
458 &gt; +{<br>\r
459 &gt; +<br>\r
460 &gt; + =C2=A0 =C2=A0void *ctx =3D talloc_new (NULL);<br>\r
461 &gt; + =C2=A0 =C2=A0int num_lines =3D 500;<br>\r
462 &gt; + =C2=A0 =C2=A0int max_tags =3D 10;<br>\r
463 &gt; + =C2=A0 =C2=A0int message_id_len =3D 100;<br>\r
464 &gt; + =C2=A0 =C2=A0int tag_len =3D 50;<br>\r
465 &gt; + =C2=A0 =C2=A0int seed =3D 734569;<br>\r
466 &gt; +<br>\r
467 &gt; + =C2=A0 =C2=A0int pad_tag =3D 0, pad_mid =3D 0;<br>\r
468 &gt; +<br>\r
469 &gt; + =C2=A0 =C2=A0notmuch_opt_desc_t options[] =3D {<br>\r
470 &gt; + =C2=A0 =C2=A0 =C2=A0 { NOTMUCH_OPT_INT, &amp;num_lines, &quot;num-li=\r
471 nes&quot;, &#39;n&#39;, 0 },<br>\r
472 &gt; + =C2=A0 =C2=A0 =C2=A0 { NOTMUCH_OPT_INT, &amp;max_tags, &quot;max-tag=\r
473 s&quot;, &#39;m&#39;, 0 },<br>\r
474 &gt; + =C2=A0 =C2=A0 =C2=A0 { NOTMUCH_OPT_INT, &amp;message_id_len, &quot;m=\r
475 essage-id-len&quot;, &#39;M&#39;, 0 },<br>\r
476 &gt; + =C2=A0 =C2=A0 =C2=A0 { NOTMUCH_OPT_INT, &amp;tag_len, &quot;tag-len&=\r
477 quot;, &#39;t&#39;, 0 },<br>\r
478 &gt; + =C2=A0 =C2=A0 =C2=A0 { NOTMUCH_OPT_INT, &amp;seed, &quot;tag-len&quo=\r
479 t;, &#39;t&#39;, 0 },</p>\r
480 <p>s/tag-len/seed/</p>\r
481 <p>&gt; + =C2=A0 =C2=A0 =C2=A0 { 0, 0, 0, 0, 0 }<br>\r
482 &gt; + =C2=A0 =C2=A0};<br>\r
483 &gt; +<br>\r
484 &gt; + =C2=A0 =C2=A0int opt_index =3D parse_arguments (argc, argv, options,=\r
485  1);<br>\r
486 &gt; +<br>\r
487 &gt; + =C2=A0 =C2=A0if (opt_index &lt; 0)<br>\r
488 &gt; + =C2=A0 =C2=A0 =C2=A0 exit (1);<br>\r
489 &gt; +<br>\r
490 &gt; + =C2=A0 =C2=A0pad_mid =3D ((int) log10 (num_lines) + 1);<br>\r
491 &gt; + =C2=A0 =C2=A0pad_tag =3D ((int) log10 (max_tags)) + 1;<br>\r
492 &gt; +<br>\r
493 &gt; + =C2=A0 =C2=A0srandom (seed);<br>\r
494 &gt; +<br>\r
495 &gt; + =C2=A0 =C2=A0int line;<br>\r
496 &gt; + =C2=A0 =C2=A0for (line =3D 0; line &lt; num_lines; line++) {<br>\r
497 &gt; +<br>\r
498 &gt; + =C2=A0 =C2=A0 =C2=A0 printf (&quot;%0*d-&quot;, pad_mid, line);<br>\r
499 &gt; +<br>\r
500 &gt; + =C2=A0 =C2=A0 =C2=A0 random_message_id (ctx, message_id_len);<br>\r
501 &gt; +<br>\r
502 &gt; + =C2=A0 =C2=A0 =C2=A0 int num_tags =3D random () % (max_tags + 1);<br=\r
503 >\r
504 &gt; +<br>\r
505 &gt; + =C2=A0 =C2=A0 =C2=A0 int j;<br>\r
506 &gt; + =C2=A0 =C2=A0 =C2=A0 for (j =3D 0; j &lt; num_tags; j++) {<br>\r
507 &gt; + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 printf (&quot; %0*d-&quot;, pad_t=\r
508 ag, j);<br>\r
509 &gt; + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 random_tag (ctx, tag_len);<br>\r
510 &gt; + =C2=A0 =C2=A0 =C2=A0 }<br>\r
511 &gt; + =C2=A0 =C2=A0 =C2=A0 putchar (&#39;\n&#39;);<br>\r
512 &gt; + =C2=A0 =C2=A0}<br>\r
513 &gt; +<br>\r
514 &gt; + =C2=A0 =C2=A0talloc_free (ctx);<br>\r
515 &gt; +<br>\r
516 &gt; + =C2=A0 =C2=A0return 0;<br>\r
517 &gt; +}<br>\r
518 &gt; --<br>\r
519 &gt; 1.7.7.3<br>\r
520 &gt;<br>\r
521 &gt; _______________________________________________<br>\r
522 &gt; notmuch mailing list<br>\r
523 &gt; <a href=3D"mailto:notmuch@notmuchmail.org">notmuch@notmuchmail.org</a>=\r
524 <br>\r
525 &gt; <a href=3D"http://notmuchmail.org/mailman/listinfo/notmuch">http://not=\r
526 muchmail.org/mailman/listinfo/notmuch</a><br>\r
527 </p>\r
528 \r
529 --e89a8ff1c322d9b16904b68c8ec8--\r