#include #include #include #include "db.h" #include "parse.h" #include "config.h" CONFIG config; int wu_delete_files(WORKUNIT& wu) { char* p; char filename[256], pathname[256], buf[MAX_BLOB_SIZE]; bool no_delete; strcpy(buf,wu.xml_doc); p = strtok(buf, "\n"); strcpy(filename, ""); while (p) { if (parse_str(p, "", filename, sizeof(filename))) { } else if (match_tag(p, "")) { no_delete = false; strcpy(filename, ""); } else if (match_tag(p, "")) { no_delete = true; } else if (match_tag(p, "")) { if (!no_delete) { sprintf(pathname, "%s/%s", config.download_dir, filename); printf("deleting %s\n", pathname); unlink(pathname); } } p = strtok(0, "\n"); } return 0; } int result_delete_files(RESULT& result) { char* p; char filename[256], pathname[256], buf[MAX_BLOB_SIZE]; bool no_delete; strcpy(buf,result.xml_doc_in); p = strtok(buf,"\n"); while (p) { if (parse_str(p, "", filename, sizeof(filename))) { } else if (match_tag(p, "")) { no_delete = false; strcpy(filename, ""); } else if (match_tag(p, "")) { no_delete = true; } else if (match_tag(p, "")) { if (!no_delete) { sprintf(pathname, "%s/%s", config.upload_dir, filename); printf("deleting %s\n", pathname); unlink(pathname); } } p = strtok(0, "\n"); } return 0; } // return nonzero if did anything // bool do_pass() { WORKUNIT wu; RESULT result; bool did_something = false; wu.file_delete_state = FILE_DELETE_READY; while (!db_workunit_enum_file_delete_state(wu)) { did_something = true; wu_delete_files(wu); wu.file_delete_state = FILE_DELETE_DONE; db_workunit_update(wu); } result.file_delete_state = FILE_DELETE_READY; while (!db_result_enum_file_delete_state(result)) { did_something = true; result_delete_files(result); result.file_delete_state = FILE_DELETE_DONE; db_result_update(result); } return did_something; } int main(int argc, char** argv) { int retval; bool asynch = false, one_pass = false; int i; for (i=1; i