File: main.c

package info (click to toggle)
borgbackup 1.4.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 15,732 kB
  • sloc: python: 26,637; pascal: 3,245; ansic: 2,597; sh: 151; makefile: 137; tcl: 94
file content (33 lines) | stat: -rw-r--r-- 705 bytes parent folder | download | duplicates (7)
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

#define BORG_NO_PYTHON

#include "../../src/borg/_hashindex.c"
#include "../../src/borg/cache_sync/cache_sync.c"

#define BUFSZ 32768

int main() {
    char buf[BUFSZ];
    int len, ret;
    CacheSyncCtx *ctx;
    HashIndex *idx;

    /* capacity, key size, value size */
    idx = hashindex_init(0, 32, 12);
    ctx = cache_sync_init(idx);

    while (1) {
        len = read(0, buf, BUFSZ);
        if (!len) {
            break;
        }
        ret = cache_sync_feed(ctx, buf, len);
        if(!ret && cache_sync_error(ctx)) {
            fprintf(stderr, "error: %s\n", cache_sync_error(ctx));
            return 1;
        }
    }
    hashindex_free(idx);
    cache_sync_free(ctx);
    return 0;
}