1 /* Blerg is (C) 2011 The Dominion of Awesome, and is distributed under a
2 * BSD-style license. Please see the COPYING file for details.
10 printf("Usage: blergtool <store|fetch> <storename> [record]\n");
13 int main(int argc, char *argv[]) {
19 if (strncmp(argv[1], "store", 5) == 0) {
20 char *store = argv[2];
21 struct blerg *f = blerg_open(store);
23 printf("Blerg open failed\n");
27 size_t bytes_read = 0;
28 char *data = malloc(65536);
30 bytes_read += fread(data + bytes_read, 1, 65536 - bytes_read, stdin);
31 } while (bytes_read < 65536 && !feof(stdin));
32 int record = blerg_store(f, data, bytes_read);
37 fprintf(stderr, "Could not store\n");
40 fprintf(stderr, "Stored record %d\n", record);
42 } else if (strncmp(argv[1], "fetch", 5) == 0) {
43 char *store = argv[2];
44 int record = atoi(argv[3]);
45 struct blerg *f = blerg_open(store);
47 printf("Blerg open failed\n");
53 if (blerg_fetch(f, record, &data, &size)) {
54 fwrite(data, 1, size, stdout);
58 } else if (strncmp(argv[1], "list", 4) == 0) {
61 struct blergref *list = tag_list(tag, 0, &count, -1);
66 for (i = 0; i < count; i++) {
67 printf("%s %d\n", list[i].author, list[i].record);
71 } else if (strncmp(argv[1], "mute", 4) == 0) {
72 char *store = argv[2];
73 struct blerg *f = blerg_open(store);
75 printf("Blerg open failed\n");
81 } else if (strncmp(argv[1], "unmute", 6) == 0) {
82 char *store = argv[2];
83 struct blerg *f = blerg_open(store);
85 printf("Blerg open failed\n");