main.c 705 B

123456789101112131415161718192021222324252627282930313233
  1. #define BORG_NO_PYTHON
  2. #include "../../src/borg/_hashindex.c"
  3. #include "../../src/borg/cache_sync/cache_sync.c"
  4. #define BUFSZ 32768
  5. int main() {
  6. char buf[BUFSZ];
  7. int len, ret;
  8. CacheSyncCtx *ctx;
  9. HashIndex *idx;
  10. /* capacity, key size, value size */
  11. idx = hashindex_init(0, 32, 12);
  12. ctx = cache_sync_init(idx);
  13. while (1) {
  14. len = read(0, buf, BUFSZ);
  15. if (!len) {
  16. break;
  17. }
  18. ret = cache_sync_feed(ctx, buf, len);
  19. if(!ret && cache_sync_error(ctx)) {
  20. fprintf(stderr, "error: %s\n", cache_sync_error(ctx));
  21. return 1;
  22. }
  23. }
  24. hashindex_free(idx);
  25. cache_sync_free(ctx);
  26. return 0;
  27. }