+ amfree(datestamp);
+ amfree(current_label);
+
+ return found_something;
+}
+
+
+/*
+ * Return the set of dumps that match *all* of the given patterns (we consider
+ * an empty pattern to match .*, though). If 'ok' is true, will only match
+ * dumps with SUCCESS status.
+ *
+ * Returns a newly allocated list of results, where all strings are also newly
+ * allocated. Apparently some part of Amanda leaks under this condition.
+ */
+find_result_t *
+dumps_match(
+ find_result_t *output_find,
+ char *hostname,
+ char *diskname,
+ char *datestamp,
+ char *level,
+ int ok)
+{
+ find_result_t *cur_result;
+ find_result_t *matches = NULL;
+
+ for(cur_result=output_find;
+ cur_result;
+ cur_result=cur_result->next) {
+ char level_str[NUM_STR_SIZE];
+ g_snprintf(level_str, SIZEOF(level_str), "%d", cur_result->level);
+ if((!hostname || *hostname == '\0' || match_host(hostname, cur_result->hostname)) &&
+ (!diskname || *diskname == '\0' || match_disk(diskname, cur_result->diskname)) &&
+ (!datestamp || *datestamp== '\0' || match_datestamp(datestamp, cur_result->timestamp)) &&
+ (!level || *level== '\0' || match_level(level, level_str)) &&
+ (!ok || !strcmp(cur_result->status, "OK"))){
+
+ find_result_t *curmatch = alloc(SIZEOF(find_result_t));
+ memcpy(curmatch, cur_result, SIZEOF(find_result_t));
+
+ curmatch->timestamp = stralloc(cur_result->timestamp);
+ curmatch->hostname = stralloc(cur_result->hostname);
+ curmatch->diskname = stralloc(cur_result->diskname);
+ curmatch->level = cur_result->level;
+ curmatch->label = stralloc(cur_result->label);
+ curmatch->filenum = cur_result->filenum;
+ curmatch->status = stralloc(cur_result->status);
+ curmatch->partnum = stralloc(cur_result->partnum);
+
+ curmatch->next = matches;
+ matches = curmatch;
+ }
+ }
+
+ return(matches);