static int deal_with_read_from_chfd(struct asfd *asfd, struct asfd *chfd, struct blist *blist, uint64_t *wrap_up, struct dpth *dpth) { int ret=-1; uint64_t file_no; char *save_path; // Deal with champ chooser read here. //printf("read from cc: %s\n", chfd->rbuf->buf); switch(chfd->rbuf->cmd) { case CMD_SIG: // Get these for blks that the champ chooser has found. file_no=decode_file_no_and_save_path(chfd->rbuf, &save_path); // printf("got save_path: %d %s\n", file_no, save_path); if(mark_up_to_index(blist, file_no, dpth)) goto end; mark_got(blist->blk_from_champ_chooser, save_path); // printf("after mark_got: %d\n", // blist->blk_from_champ_chooser->index); break; case CMD_WRAP_UP: file_no=decode_file_no(chfd->rbuf); // printf("mark up to: %d\n", file_no); if(mark_up_to_index(blist, file_no, dpth)) goto end; mark_not_got(blist->blk_from_champ_chooser, dpth); //printf("after mark_up: %d\n", // blist->blk_from_champ_chooser->index); break; default: iobuf_log_unexpected(chfd->rbuf, __func__); goto end; } ret=0; end: iobuf_free_content(chfd->rbuf); return ret; }
static int deal_with_read(struct iobuf *rbuf, struct slist *slist, struct cntr *cntr, uint8_t *end_flags, struct dpth *dpth) { int ret=0; switch(rbuf->cmd) { /* Incoming block data. */ case CMD_DATA: if(add_data_to_store(cntr, slist, rbuf, dpth)) goto error; goto end; /* Incoming block signatures. */ case CMD_ATTRIBS_SIGS: static struct iobuf attr; static uint64_t index; iobuf_init(&attr); iobuf_move(&attr, rbuf); index=decode_file_no(&attr); // Need to go through slist to find the matching // entry. if(set_up_for_sig_info(slist, &attr, index)) goto error; return 0; case CMD_SIG: if(add_to_sig_list(slist, rbuf)) goto error; goto end; /* Incoming control/message stuff. */ case CMD_MESSAGE: case CMD_WARNING: { struct cntr *cntr=NULL; log_recvd(rbuf, cntr, 0); goto end; } case CMD_GEN: if(!strcmp(rbuf->buf, "sigs_end")) { (*end_flags)|=END_SIGS; goto end; } else if(!strcmp(rbuf->buf, "backup_end")) { (*end_flags)|=END_BACKUP; goto end; } break; case CMD_INTERRUPT: { uint64_t file_no; file_no=base64_to_uint64(rbuf->buf); if(slist_del_sbuf_by_index(slist, file_no)) goto error; goto end; } default: break; } iobuf_log_unexpected(rbuf, __func__); error: ret=-1; end: iobuf_free_content(rbuf); return ret; }
static int deal_with_read(struct iobuf *rbuf, struct slist *slist, struct blist *blist, struct conf *conf, int *sigs_end, int *backup_end, struct dpth *dpth) { int ret=0; static struct sbuf *inew=NULL; if(!inew && !(inew=sbuf_alloc(conf))) goto error; switch(rbuf->cmd) { /* Incoming block data. */ case CMD_DATA: if(add_data_to_store(conf, blist, rbuf, dpth)) goto error; goto end; /* Incoming block signatures. */ case CMD_ATTRIBS_SIGS: // New set of stuff incoming. Clean up. if(inew->attr.buf) free(inew->attr.buf); iobuf_copy(&inew->attr, rbuf); inew->burp2->index=decode_file_no(&inew->attr); rbuf->buf=NULL; // Need to go through slist to find the matching // entry. if(set_up_for_sig_info(slist, blist, inew)) goto error; return 0; case CMD_SIG: if(add_to_sig_list(slist, blist, rbuf, dpth, conf)) goto error; goto end; /* Incoming control/message stuff. */ case CMD_WARNING: logp("WARNING: %s\n", rbuf); cntr_add(conf->cntr, rbuf->cmd, 0); goto end; case CMD_GEN: if(!strcmp(rbuf->buf, "sigs_end")) { *sigs_end=1; goto end; } else if(!strcmp(rbuf->buf, "backup_end")) { *backup_end=1; goto end; } break; } iobuf_log_unexpected(rbuf, __func__); error: ret=-1; sbuf_free(&inew); end: if(rbuf->buf) { free(rbuf->buf); rbuf->buf=NULL; } return ret; }
static int deal_with_read(struct iobuf *rbuf, struct slist *slist, struct cntr *cntr, uint8_t *end_flags, struct dpth *dpth) { int ret=0; static struct sbuf *inew=NULL; if(!inew && !(inew=sbuf_alloc(PROTO_2))) goto error; switch(rbuf->cmd) { /* Incoming block data. */ case CMD_DATA: if(add_data_to_store(cntr, slist, rbuf, dpth)) goto error; goto end; /* Incoming block signatures. */ case CMD_ATTRIBS_SIGS: // New set of stuff incoming. Clean up. iobuf_free_content(&inew->attr); iobuf_move(&inew->attr, rbuf); inew->protocol2->index=decode_file_no(&inew->attr); // Need to go through slist to find the matching // entry. if(set_up_for_sig_info(slist, inew)) goto error; return 0; case CMD_SIG: if(add_to_sig_list(slist, rbuf)) goto error; goto end; /* Incoming control/message stuff. */ case CMD_MESSAGE: case CMD_WARNING: { struct cntr *cntr=NULL; log_recvd(rbuf, cntr, 0); goto end; } case CMD_GEN: if(!strcmp(rbuf->buf, "sigs_end")) { (*end_flags)|=END_SIGS; goto end; } else if(!strcmp(rbuf->buf, "backup_end")) { (*end_flags)|=END_BACKUP; goto end; } break; default: break; } iobuf_log_unexpected(rbuf, __func__); error: ret=-1; sbuf_free(&inew); end: iobuf_free_content(rbuf); return ret; }