unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
blob 20c16036d26f29cb3f5cf54cc7a9491fbfb3bedb 1315 bytes (raw)
name: test/hex-xcode.c 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
 
/* No, nothing to to with IDE from Apple Inc.
   testbed for ../util/hex-escape.c.

   usage: hex-xcode (e|d) < foo

   e is for encode
   d is for decode
 */

#include "notmuch-client.h"
#include "hex-escape.h"
#include <assert.h>

static int
xcode (void *ctx, char dir, char *in, char **buf_p, size_t *size_p)
{
    hex_status_t status;

    if (dir == 'e')
	status = hex_encode (ctx, in, buf_p, size_p);
    else
	status = hex_decode (ctx, in, buf_p, size_p);

    if (status == HEX_SUCCESS)
	puts (*buf_p);

    return status;
}


int
main (int argc, char **argv)
{

    assert (argc > 1 && argv[1]);

    char dir = argv[1][0];

    void *ctx = talloc_new (NULL);

    char *line = NULL;
    size_t line_size;
    ssize_t line_len;

    char *buffer = NULL;
    size_t buf_size = 0;

    int arg_index = 2;
    notmuch_bool_t read_stdin = TRUE;

    for (arg_index = 2; arg_index < argc; arg_index++) {

	if (xcode (ctx, dir, argv[arg_index],
		   &buffer, &buf_size) != HEX_SUCCESS)
	    return 1;

	read_stdin = FALSE;
    }

    if (!read_stdin)
	return 0;

    while ((line_len = getline (&line, &line_size, stdin)) != -1) {

	chomp_newline (line);

	if (xcode (ctx, dir, line, &buffer, &buf_size) != HEX_SUCCESS)
	    return 1;

    }

    if (line)
	free (line);

    talloc_free (ctx);

    return 0;
}

debug log:

solving 20c1603 ...
found 20c1603 in https://yhetil.org/notmuch/1324214111-32079-3-git-send-email-david@tethera.net/

applying [1/1] https://yhetil.org/notmuch/1324214111-32079-3-git-send-email-david@tethera.net/
diff --git a/test/hex-xcode.c b/test/hex-xcode.c
new file mode 100644
index 0000000..20c1603

Checking patch test/hex-xcode.c...
Applied patch test/hex-xcode.c cleanly.

index at:
100644 20c16036d26f29cb3f5cf54cc7a9491fbfb3bedb	test/hex-xcode.c

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).