]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/findlib/find.h
1408f17a2b78994f2e8a7abb424a56247746ad22
[bacula/bacula] / bacula / src / findlib / find.h
1 /*
2  * File types as returned by find_files()
3  *
4  *     Kern Sibbald MIM
5  */
6 /*
7    Copyright (C) 2000, 2001 Kern Sibbald and John Walker
8
9    This program is free software; you can redistribute it and/or
10    modify it under the terms of the GNU General Public License
11    as published by the Free Software Foundation; either version 2
12    of the License, or (at your option) any later version.
13
14    This program is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17    GNU General Public License for more details.
18
19    You should have received a copy of the GNU General Public License
20    along with this program; if not, write to the Free Software
21    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22  */
23
24 #ifndef __FILES_H
25 #define __FILES_H
26
27 #ifdef HAVE_FNMATCH
28 #include <fnmatch.h>
29 #else
30 #include "lib/fnmatch.h"
31 #endif
32
33
34 /* 
35  *  NOTE!!! These go on the tape, so don't change them. If 
36  *  need be, add to them.
37  */
38 #define FT_LNKSAVED   1               /* hard link to file already saved */  
39 #define FT_REGE       2               /* Regular file but empty */
40 #define FT_REG        3               /* Regular file */
41 #define FT_LNK        4               /* Soft Link */
42 #define FT_DIR        5               /* Directory */
43 #define FT_SPEC       6               /* Special file -- chr, blk, fifo, sock */
44 #define FT_NOACCESS   7               /* Not able to access */
45 #define FT_NOFOLLOW   8               /* Could not follow link */
46 #define FT_NOSTAT     9               /* Could not stat file */
47 #define FT_NOCHG     10               /* Incremental option, file not changed */
48 #define FT_DIRNOCHG  11               /* Incremental option, directory not changed */
49 #define FT_ISARCH    12               /* Trying to save archive file */
50 #define FT_NORECURSE 13               /* No recursion into directory */
51 #define FT_NOFSCHG   14               /* Different file system, prohibited */
52 #define FT_NOOPEN    15               /* Could not open directory */
53
54 /* FileSet options */     
55 #define FO_MD5      0x1               /* Do MD5 checksum */
56 #define FO_GZIP     0x2               /* Do Zlib compression */
57
58
59 #define OPT_compute_MD5       0x01
60 #define OPT_GZIP_compression  0x02
61 #define OPT_no_recursion      0x04
62
63
64 struct s_included_file {
65    struct s_included_file *next;
66    int options;                       /* backup options */
67    int level;                         /* compression level */
68    int len;                           /* length of fname */
69    int pattern;                       /* set if pattern */
70    char VerifyOpts[20];               /* Options for verify */
71    char fname[1];
72 };
73
74 struct s_excluded_file {
75    struct s_excluded_file *next;
76    int len;
77    char fname[1];
78 };
79
80
81 /*
82  * Definition of the find_files packet passed as the
83  * first argument to the find_files callback subroutine.
84  */
85 typedef struct ff {
86    char *fname;                       /* filename */
87    char *link;                        /* link if file linked */
88    struct stat statp;                 /* stat packet */
89    int type;                          /* FT_ type from above */
90    int flags;                         /* control flags */
91    int ff_errno;                      /* errno */
92    int incremental;                   /* do incremental save */
93    time_t save_time;                  /* start of incremental time */
94    int no_recursion;                  /* do not recurse into sub directories */
95    int mtime_only;                    /* incremental on mtime_only */
96    int dereference;                   /* follow links */
97    int compute_MD5;                   /* compute MD5 checksum */
98    int GZIP_compression;              /* compress the file */
99    int GZIP_level;                    /* compression level */
100    int one_file_system;               /* do not traverse file systems */
101    int atime_preserve;                /* preserve access times */
102    int null_output_device;            /* using null output device */
103    char VerifyOpts[20];
104    struct s_included_file *included_files_list;
105    struct s_excluded_file *excluded_files_list;
106    struct s_excluded_file *excluded_paths_list;
107
108    struct f_link *linklist;           /* hard linked files */
109 } FF_PKT;
110
111 /* From find.c */
112 FF_PKT *init_find_files();
113 void set_find_options(FF_PKT *ff, int incremental, time_t mtime);
114 int find_files(FF_PKT *ff, int sub(FF_PKT *ff_pkt, void *hpkt), void *pkt);
115 void term_find_files(FF_PKT *ff);
116
117 /* From match.c */
118 void init_include_exclude_files(FF_PKT *ff);
119 void term_include_exclude_files(FF_PKT *ff);
120 void add_fname_to_include_list(FF_PKT *ff, int prefixed, char *fname);
121 void add_fname_to_exclude_list(FF_PKT *ff, char *fname);
122 struct s_included_file *get_next_included_file(
123     FF_PKT *ff, struct s_included_file *inc);
124 int file_is_excluded(FF_PKT *ff, char *file);
125 int file_is_included(FF_PKT *ff, char *file);
126
127 #endif /* __FILES_H */