main.c 680 B

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