static struct slist *build_slist(enum protocol protocol, int entries, int with_data_files) { struct sbuf *sb; struct slist *slist; slist=build_slist_phase1(NULL /* prefix */, protocol, entries); for(sb=slist->head; sb; sb=sb->next) set_sbuf(slist, sb, with_data_files); return slist; }
static void run_test(int expected_ret, int slist_entries, enum protocol protocol, void setup_callback(struct asfd *asfd, struct slist *slist)) { int result; struct slist *slist=NULL; const char *conffile=BASE "/burp.conf"; struct asfd *asfd; struct conf **confs; const char *buf; if(protocol==PROTO_1) buf=MIN_CLIENT_CONF "protocol=1\n"; else buf=MIN_CLIENT_CONF "protocol=2\n"; base64_init(); asfd=asfd_mock_setup(&reads, &writes); confs=setup_conf(); fail_unless(recursive_delete(BASE)==0); build_file(conffile, buf); fail_unless(!conf_load_global_only(conffile, confs)); if(slist_entries) slist=build_slist_phase1(BASE, protocol, slist_entries); setup_callback(asfd, slist); result=do_restore_client(asfd, confs, ACTION_RESTORE, 0 /* vss_restore */); fail_unless(result==expected_ret); slist_free(&slist); tear_down(&asfd, &confs); }
static struct slist *build_manifest_phase1(const char *path, enum protocol protocol, int entries) { struct sbuf *sb; struct slist *slist=NULL; struct manio *manio=NULL; slist=build_slist_phase1(NULL /*prefix*/, protocol, entries); fail_unless((manio=manio_open_phase1(path, "wb", protocol))!=NULL); for(sb=slist->head; sb; sb=sb->next) { fail_unless(!manio_write_sbuf(manio, sb)); if(protocol==PROTO_2) hack_protocol2_attr(&sb->attr); } fail_unless(!send_msg_fzp(manio->fzp, CMD_GEN, "phase1end", strlen("phase1end"))); fail_unless(!manio_close(&manio)); return slist; }