1 /* No, nothing to to with IDE from Apple Inc.
2 * testbed for ../util/hex-escape.c.
5 * hex-xcode [--direction=(encode|decode)] [--omit-newline] < file
6 * hex-xcode [--direction=(encode|decode)] [--omit-newline] [--in-place] arg1 arg2 arg3 ...
10 #include "notmuch-client.h"
11 #include "hex-escape.h"
19 static int inplace = FALSE;
22 xcode (void *ctx, enum direction dir, char *in, char **buf_p, size_t *size_p)
27 status = hex_encode (ctx, in, buf_p, size_p);
30 status = hex_decode_inplace (in);
34 status = hex_decode (ctx, in, buf_p, size_p);
37 if (status == HEX_SUCCESS)
38 fputs (*buf_p, stdout);
44 main (int argc, char **argv)
47 enum direction dir = DECODE;
48 int omit_newline = FALSE;
50 notmuch_opt_desc_t options[] = {
51 { NOTMUCH_OPT_KEYWORD, &dir, "direction", 'd',
52 (notmuch_keyword_t []){ { "encode", ENCODE },
55 { NOTMUCH_OPT_BOOLEAN, &omit_newline, "omit-newline", 'n', 0 },
56 { NOTMUCH_OPT_BOOLEAN, &inplace, "in-place", 'i', 0 },
60 int opt_index = parse_arguments (argc, argv, options, 1);
65 void *ctx = talloc_new (NULL);
74 notmuch_bool_t read_stdin = TRUE;
76 for (; opt_index < argc; opt_index++) {
78 if (xcode (ctx, dir, argv[opt_index],
79 &buffer, &buf_size) != HEX_SUCCESS)
91 while ((line_len = getline (&line, &line_size, stdin)) != -1) {
95 if (xcode (ctx, dir, line, &buffer, &buf_size) != HEX_SUCCESS)