static int list_all_backups(void) { int found=0; struct bu *bu=NULL; for(bu=bu_list; bu; bu=bu->next) { found=1; if(send_backup_name_to_client(bu)) return -1; } return found; }
static int list_contents_many( int list_server_callback(const char *fullpath)) { int found=0; struct bu *bu=NULL; for(bu=bu_list; bu; bu=bu->next) { found=1; if(send_backup_name_to_client(bu) || list_server_callback(bu->path)) return -1; } return found; }
static int list_contents_one( int list_server_callback(const char *fullpath)) { struct bu *bu=NULL; for(bu=bu_list; bu; bu=bu->next) { if(!strcmp(bu->timestamp, backup) || bu->bno==bno || (*backup=='c' && (bu->flags & BU_CURRENT))) { if(send_backup_name_to_client(bu) || list_server_callback(bu->path)) return -1; return 1; } } return 0; }
int do_list_server(struct asfd *asfd, struct sdirs *sdirs, struct conf *conf, const char *backup, const char *listregex, const char *browsedir) { int ret=-1; uint8_t found=0; unsigned long bno=0; regex_t *regex=NULL; struct bu *bu=NULL; struct bu *bu_list=NULL; printf("in do_list_server\n"); if(compile_regex(®ex, listregex) || bu_list_get(sdirs, &bu_list) || write_status(STATUS_LISTING, NULL, conf)) goto end; if(backup && *backup) bno=strtoul(backup, NULL, 10); for(bu=bu_list; bu; bu=bu->next) { // Search all backups for things matching the regex. if(listregex && backup && *backup=='a') { found=1; if(write_wrapper_str(asfd, CMD_TIMESTAMP, bu->timestamp) || list_manifest(asfd, bu->path, regex, browsedir, conf)) goto end; } // Search or list a particular backup. else if(backup && *backup) { if(!found && (!strcmp(bu->timestamp, backup) || bu->bno==bno)) { found=1; if(send_backup_name_to_client(asfd, bu, conf) || list_manifest(asfd, bu->path, regex, browsedir, conf)) goto end; } } // List the backups. else { found=1; if(send_backup_name_to_client(asfd, bu, conf)) goto end; } } if(backup && *backup && !found) { write_wrapper_str(asfd, CMD_ERROR, "backup not found"); goto end; } if(flush_asio(asfd)) goto end; ret=0; end: if(regex) { regfree(regex); free(regex); } bu_list_free(&bu); return ret; }