-
-/* In memory list of JobIds */
-struct s_file_del_ctx {
- JobId_t *JobId;
- int num_ids; /* ids stored */
- int max_ids; /* size of array */
- int num_del; /* number deleted */
- int tot_ids; /* total to process */
-};
-
-struct s_job_del_ctx {
- JobId_t *JobId; /* array of JobIds */
- char *PurgedFiles; /* Array of PurgedFile flags */
- int num_ids; /* ids stored */
- int max_ids; /* size of array */
- int num_del; /* number deleted */
- int tot_ids; /* total to process */
-};
-
-struct s_count_ctx {
- int count;
-};
-
-/*
- * Called here to count entries to be deleted
- */
-static int count_handler(void *ctx, int num_fields, char **row)
-{
- struct s_count_ctx *cnt = (struct s_count_ctx *)ctx;
-
- if (row[0]) {
- cnt->count = str_to_int64(row[0]);
- } else {
- cnt->count = 0;
- }
- return 0;
-}
-
-/*
- * Called here to count entries to be deleted
- */
-static int file_count_handler(void *ctx, int num_fields, char **row)
-{
- struct s_file_del_ctx *del = (struct s_file_del_ctx *)ctx;
- del->tot_ids++;
- return 0;
-}
-
-
-static int job_count_handler(void *ctx, int num_fields, char **row)
-{
- struct s_job_del_ctx *del = (struct s_job_del_ctx *)ctx;
- del->tot_ids++;
- return 0;
-}
-
-
-/*
- * Called here to make in memory list of JobIds to be
- * deleted and the associated PurgedFiles flag.
- * The in memory list will then be transversed
- * to issue the SQL DELETE commands. Note, the list
- * is allowed to get to MAX_DEL_LIST_LEN to limit the
- * maximum malloc'ed memory.
- */
-static int job_delete_handler(void *ctx, int num_fields, char **row)
-{
- struct s_job_del_ctx *del = (struct s_job_del_ctx *)ctx;
-
- if (del->num_ids == MAX_DEL_LIST_LEN) {
- return 1;
- }
- if (del->num_ids == del->max_ids) {
- del->max_ids = (del->max_ids * 3) / 2;
- del->JobId = (JobId_t *)brealloc(del->JobId, sizeof(JobId_t) * del->max_ids);
- del->PurgedFiles = (char *)brealloc(del->PurgedFiles, del->max_ids);
- }
- del->JobId[del->num_ids] = (JobId_t)str_to_int64(row[0]);
- del->PurgedFiles[del->num_ids++] = (char)str_to_int64(row[1]);
- return 0;
-}
-
-static int file_delete_handler(void *ctx, int num_fields, char **row)
-{
- struct s_file_del_ctx *del = (struct s_file_del_ctx *)ctx;
-
- if (del->num_ids == MAX_DEL_LIST_LEN) {
- return 1;
- }
- if (del->num_ids == del->max_ids) {
- del->max_ids = (del->max_ids * 3) / 2;
- del->JobId = (JobId_t *)brealloc(del->JobId, sizeof(JobId_t) *
- del->max_ids);
- }
- del->JobId[del->num_ids++] = (JobId_t)str_to_int64(row[0]);
- return 0;
-}
-