struct slist *build_manifest_with_data_files(const char *path, const char *datapath, int entries, int data_files) { struct blk *b=NULL; struct slist *slist=NULL; struct manio *manio=NULL; struct fzp *fzp=NULL; char spath[256]=""; char cpath[256]=""; fail_unless((manio=manio_open_phase3(path, "wb", PROTO_2, RMANIFEST_RELATIVE))!=NULL); slist=do_build_manifest(manio, PROTO_2, entries, data_files); fail_unless(!manio_close(&manio)); for(b=slist->blist->head; b; b=b->next) { snprintf(spath, sizeof(spath), "%s/%s", datapath, uint64_to_savepathstr(b->savepath)); if(strcmp(spath, cpath)) { snprintf(cpath, sizeof(cpath), "%s", spath); fzp_close(&fzp); } if(!fzp) { fail_unless(!build_path_w(cpath)); fail_unless((fzp=fzp_open(cpath, "wb"))!=NULL); } fzp_printf(fzp, "%c%04X%s", CMD_DATA, strlen("data"), "data"); } fzp_close(&fzp); return slist; }
static int parse_cmd(struct iobuf *rbuf, struct blk *blk) { int ret=-1; printf("%c%04X", rbuf->cmd, (unsigned int)rbuf->len); switch(rbuf->cmd) { case CMD_SIG: if(blk_set_from_iobuf_sig_and_savepath(blk, rbuf)) goto end; printf("%016" PRIX64 "%s%s\n", blk->fingerprint, bytes_to_md5str(blk->md5sum), uint64_to_savepathstr_with_sig(blk->savepath)); break; case CMD_FINGERPRINT: if(blk_set_from_iobuf_fingerprint(blk, rbuf)) goto end; printf("%016" PRIX64 "\n", blk->fingerprint); break; case CMD_SAVE_PATH: if(blk_set_from_iobuf_savepath(blk, rbuf)) goto end; printf("%s\n", uint64_to_savepathstr(blk->savepath)); break; case CMD_DATA: logp("\n%s looks like a data file\n", path); goto end; /* FIX THIS - give a flag to tell it to decode attributes. case CMD_ATTRIBS: memcpy(&sb->attr, rbuf, sizeof(struct iobuf)); attribs_decode(sb); printf("compression: %d\n", sb->compression); break; */ default: printf("%s\n", rbuf->buf); break; } ret=0; end: return ret; }
static int parse_cmd(struct iobuf *rbuf, struct blk *blk) { int ret=-1; printf("%c%04lX", rbuf->cmd, rbuf->len); switch(rbuf->cmd) { case CMD_SIG: if(blk_set_from_iobuf_sig_and_savepath(blk, rbuf)) goto end; printf("%016"PRIX64"%s%s\n", blk->fingerprint, bytes_to_md5str(blk->md5sum), uint64_to_savepathstr_with_sig(blk->savepath)); break; case CMD_FINGERPRINT: if(blk_set_from_iobuf_fingerprint(blk, rbuf)) goto end; printf("%016"PRIX64"\n", blk->fingerprint); break; case CMD_SAVE_PATH: if(blk_set_from_iobuf_savepath(blk, rbuf)) goto end; printf("%s\n", uint64_to_savepathstr(blk->savepath)); break; case CMD_DATA: logp("\n%s looks like a data file\n", path); goto end; default: printf("%s\n", rbuf->buf); break; } ret=0; end: return ret;; }