01c18a28f89deb4157e65ba504739e2a5bf0fa13
[debian/amanda] / server-src / find.h
1 #ifndef FIND_H
2 #define FIND_H
3
4 #include "diskfile.h"
5
6 #define DEFAULT_SORT_ORDER      "hkdlpbfw"
7
8 typedef struct find_result_s {
9     struct find_result_s *next;
10     char *timestamp;
11     char *hostname;
12     char *diskname;
13     int level;
14     char *label;        /* holding filename for holding files */
15     off_t filenum;
16     char *status;       /* status of the part */
17     char *dump_status;  /* status of the dump; should be identical for all parts in dump */
18     char *message;      /* reason for dump_status; should be identical for all parts in dump */
19     int partnum;        /* -1 for holding files */
20     int totalparts;     /* -1 for holding files */
21     double sec;         /* may be 0.0 for older log files or holding files */
22     off_t kb;           /* may be 0 for older log files, can be compressed */
23     off_t orig_kb;      /* native size */
24     void *user_ptr;
25 } find_result_t;
26
27 /* Finds /all/ dumps still on a volume. If diskqp is not NULL, then dumps
28  * not matching any existing disklist entry will be added to diskqp and to
29  * the global disklist. If diskqp is NULL, disks not matching existing
30  * disklist entries will be skipped. See search_logfile below, which does
31  * the dirty work for find_dump. */
32 find_result_t *find_dump(disklist_t* diskqp);
33
34 /* Return a list of unqualified filenames of logfiles for active
35  * tapes.  Filenames are relative to the logdir.
36  *
37  * @returns: dynamically allocated, null-terminated strv
38  */
39 char **find_log(void);
40
41 void sort_find_result(char *sort_order, find_result_t **output_find);
42 void print_find_result(find_result_t *output_find);
43 void free_find_result(find_result_t **output_find);
44 find_result_t *dump_exist(find_result_t *output_find, char *hostname,
45                           char *diskname, char *datestamp, int level);
46 find_result_t *dumps_match(find_result_t *output_find, char *hostname,
47                            char *diskname, char *datestamp, char *level,
48                            int ok);
49 find_result_t *dumps_match_dumpspecs(find_result_t *output_find,
50                                      GSList *dumpspecs,
51                                      int ok);
52
53 /* This function looks in a particular log.xxx file for dumps. Returns TRUE
54  * if something was found. This function also skips dumps whose disklist
55  * entries are not marked 'todo'.
56  * * output_find      : Put found dumps here.
57  * * volume_label     : If not NULL, restrict the search to
58  *                      dumps matching the given volume details.
59  * * log_datestamp    : If not NULL, checks that this logfile is from this time.
60  * * logfile          : Name of logfile in config dir.
61  * * dynamic_disklist : If not NULL, adds disks not already in the global
62  *                      disklist to the given disklist (and the global one).
63  *                      If dynamic_disklist is NULL, skips disks not in the
64  *                      global disklist.
65  */
66 gboolean search_logfile(find_result_t **output_find, const char *volume_label,
67                         const char *log_datestamp, const char *logfile,
68                         disklist_t * dynamic_disklist);
69
70 /* return all dumps on holding disk; not really a search at all.
71  *
72  * * output_find      : Put found dumps here.
73  * * dynamic_disklist : If not NULL, adds disks not already in the global
74  *                      disklist to the given disklist (and the global one).
75  *                      If dynamic_disklist is NULL, skips disks not in the
76  *                      global disklist.
77  */
78 void search_holding_disk(
79         find_result_t **output_find,
80         disklist_t * dynamic_disklist);
81
82 #endif  /* !FIND_H */