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 bool 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)
48 bool omit_newline = false;
50 notmuch_opt_desc_t options[] = {
51 { .opt_keyword = &dir, .name = "direction", .keywords =
52 (notmuch_keyword_t []){ { "encode", ENCODE },
55 { .opt_bool = &omit_newline, .name = "omit-newline" },
56 { .opt_bool = &inplace, .name = "in-place" },
60 int opt_index = parse_arguments (argc, argv, options, 1);
65 void *ctx = talloc_new (NULL);
74 bool 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)