| 1 |
/* hdup header file |
| 2 |
* |
| 3 |
* $Id: hdup.h.in,v 1.41 2004/09/25 22:47:41 miekg Exp $ |
| 4 |
* Author: Miek Gieben |
| 5 |
* Creation date: Wed, 27 feb 2002 |
| 6 |
* Gone with autoconf: 16 apr 2003 |
| 7 |
*/ |
| 8 |
|
| 9 |
#define VERSION "@PACKAGE_VERSION@" |
| 10 |
#define PROGNAME "@PACKAGE_NAME@" |
| 11 |
|
| 12 |
#include "config.h" |
| 13 |
|
| 14 |
#define TAR "@tar@" |
| 15 |
#define MCRYPT "@mcrypt@" |
| 16 |
#define GPG "@gpg@" |
| 17 |
#define DEFAULT_PROTO "@ssh@" |
| 18 |
#define PROTO_OPT "" /* empty */ |
| 19 |
#define BZIP_PROG "@bzip@" |
| 20 |
#define GZIP_PROG "@gzip@" |
| 21 |
#define LZOP_PROG "@lzop@" |
| 22 |
#define SPLIT_PROG "@split@" |
| 23 |
#define UNSPLIT_PROG "@cat@" |
| 24 |
#define REMOTE_HDUP "@prefix@/sbin/hdup" |
| 25 |
#define REMOTE_HDUP_OPT "" /* default is empty */ |
| 26 |
#define FILELIST "/filelist" |
| 27 |
#define MUTE " 2>/dev/null" |
| 28 |
#define SPARSE " --sparse " |
| 29 |
#define ONEFILE " --one-file-system " |
| 30 |
#define TAR_CONF_OPT "" |
| 31 |
#define DATE_DEF 0 |
| 32 |
#define DATE_ISO 1 |
| 33 |
#define DATE_US 2 |
| 34 |
#define DEF_USER "operator" |
| 35 |
#define STATIC "static" /* no history = yes */ |
| 36 |
/* this is the special GPG string used as algorithm */ |
| 37 |
#define GPG_ALG "gpg" |
| 38 |
/* make gpg act like a filter */ |
| 39 |
#define GPG_CRYPT "--trust-model always -e -r %s --batch -o -" |
| 40 |
#define GPG_DECRYPT "--trust-model always -d -r %s -o -" |
| 41 |
|
| 42 |
/* hdup's protocol header for talking to another hdup program*/ |
| 43 |
#define PROT_VER "v2" /* advanced enough to have versioning, yeah! */ |
| 44 |
#define PROT_NAME "HDUP" |
| 45 |
#define PROT_SEP "\n" |
| 46 |
|
| 47 |
#define LOGDEBUG(FORMAT, EXP...) \ |
| 48 |
debug == 1 ? \ |
| 49 |
fprintf(stderr, "[DEBUG] " FORMAT "\n", EXP) \ |
| 50 |
: 1 |
| 51 |
|
| 52 |
/* simplifies logging inside hdup */ |
| 53 |
#define LOG(FORMAT, EXP...) \ |
| 54 |
quiet > 1 ? \ |
| 55 |
1 \ |
| 56 |
: fprintf(stderr, "%s: " FORMAT ".\n", progname, EXP) |
| 57 |
|
| 58 |
#define SYSLOG(FORMAT, EXP...) \ |
| 59 |
hdup_log == 1 ? \ |
| 60 |
syslog(LOG_WARNING, FORMAT, EXP) \ |
| 61 |
: 1 |
| 62 |
/* one for host (_H) and one for host[which] (_HW) */ |
| 63 |
#define SYSLOG_H(FORMAT, EXP...) \ |
| 64 |
SYSLOG("FAILURE, %s, " FORMAT , host->name, EXP) |
| 65 |
#define SYSLOG_HW(FORMAT, EXP...) \ |
| 66 |
SYSLOG("FAILURE, %s, " FORMAT , host[which]->name, EXP) |
| 67 |
|
| 68 |
#define FATAL(FORMAT, EXP...) \ |
| 69 |
do { \ |
| 70 |
fprintf(stderr, "%s: FATAL: " FORMAT ".\n", progname, EXP); \ |
| 71 |
hdup_cleanup(-1,NULL); \ |
| 72 |
} while (0) |
| 73 |
#define FATAL_HOST(HOST, FORMAT, EXP...) \ |
| 74 |
do { \ |
| 75 |
fprintf(stderr, "%s: FATAL: " FORMAT ".\n", progname, EXP); \ |
| 76 |
hdup_cleanup(-1,HOST); \ |
| 77 |
} while (0) |
| 78 |
|
| 79 |
#define VERBOSE(FORMAT, EXP...) \ |
| 80 |
verbose < 2 ? \ |
| 81 |
fprintf(stderr,"%s: " FORMAT ".\n", progname, EXP) \ |
| 82 |
: 1 |
| 83 |
|
| 84 |
#define VVERBOSE(FORMAT, EXP...) \ |
| 85 |
verbose < 1 ? \ |
| 86 |
fprintf(stderr,"%s: " FORMAT ".\n", progname, EXP) \ |
| 87 |
: 1 |
| 88 |
|
| 89 |
/* print a warning no matter what */ |
| 90 |
#define WARN(FORMAT, EXP...) \ |
| 91 |
fprintf(stderr,"%s: WARNING: " FORMAT "!\n", progname, EXP); |
| 92 |
|
| 93 |
/* fix warning on Cygwin */ |
| 94 |
#ifndef MAXPATHLEN |
| 95 |
#define MAXPATHLEN 2048 |
| 96 |
#endif /* not MAXPATHLEN*/ |
| 97 |
|
| 98 |
#define OVERVIEW 50 |
| 99 |
#define MAXDIR 255 |
| 100 |
#define MAXHOST 255 |
| 101 |
#define DOTEND 13 |
| 102 |
|
| 103 |
/* this is ugly and old. When tar did it's own compression |
| 104 |
* this was usefull. Nowadays hdup does the compression. These |
| 105 |
* values are used to determine what compression is used for |
| 106 |
* tar. Better was if this was named, none, gzip, bzip etc |
| 107 |
*/ |
| 108 |
#define TAR_NONE "cpf" |
| 109 |
#define TAR_GZIP "cpfz" |
| 110 |
#define TAR_BZIP "cpfj" |
| 111 |
#define TAR_LZOP "cpfl" /* fake tar commandline */ |
| 112 |
|
| 113 |
/* DEcompression is still handled insde tar - this has no influence |
| 114 |
* on the incremental stuff */ |
| 115 |
/* general unpack option */ |
| 116 |
#define UNTAR_OPT "xpfC" |
| 117 |
|
| 118 |
#define UNTAR_NONE "" |
| 119 |
#define UNTAR_GZIP "--use-compress-program @gzip@" |
| 120 |
#define UNTAR_BZIP "--use-compress-program @bzip@" |
| 121 |
#define UNTAR_LZOP "--use-compress-program @lzop@" |
| 122 |
|
| 123 |
#define DAILY 0 |
| 124 |
#define WEEKLY 1 |
| 125 |
#define MONTHLY 2 |
| 126 |
#define REMOTE 3 |
| 127 |
#define RESTORE 4 |
| 128 |
#define SCHEME_ILL 5 |
| 129 |
|
| 130 |
#define LOCK 0 |
| 131 |
#define UNLOCK 1 |
| 132 |
|
| 133 |
#define GIGABYTE 1073741824 |
| 134 |
#define MEGABYTE 1048576 |
| 135 |
#define KILOBYTE 1024 |
| 136 |
#define SECDAY 86400 |
| 137 |
#define SECHOUR 3600 |
| 138 |
#define SECMIN 60 |
| 139 |
|
| 140 |
#define PREV -1 |
| 141 |
#define NEXT 1 |
| 142 |
#define MAXRESTORE 100 |
| 143 |
#define NONE 0 |
| 144 |
#define NONE_EXT ".tar" |
| 145 |
#define GZIP 1 |
| 146 |
#define GZIP_EXT ".tar.gz" |
| 147 |
#define BZIP 2 |
| 148 |
#define BZIP_EXT ".tar.bz2" |
| 149 |
#define CRYPT 4 |
| 150 |
#define MCRYPT_EXT ".nc" |
| 151 |
#define SPLIT 5 |
| 152 |
#define SPLIT_EXT "__split__" |
| 153 |
#define LZOP 6 |
| 154 |
#define LZOP_EXT ".tar.lzo" |
| 155 |
#define SPLIT_WILDCARD_EXT "*__split__" |
| 156 |
/* these defines are used in hdup_comression_crypt */ |
| 157 |
#define MCRYPT_GZIP_EXT ".tar.gz.nc" |
| 158 |
#define MCRYPT_BZIP_EXT ".tar.bz2.nc" |
| 159 |
#define MCRYPT_LZOP_EXT ".tar.lzo.nc" |
| 160 |
#define MCRYPT_NONE_EXT ".tar.nc" |
| 161 |
|
| 162 |
#define BUFSIZE 2048 |
| 163 |
|
| 164 |
/* the number of keywords */ |
| 165 |
#define KEYWORDS 35 |
| 166 |
/* the keywords are defined in hdupconf.c */ |
| 167 |
#define KEY_BACKUP 0 |
| 168 |
#define KEY_EXCLUDE 1 |
| 169 |
#define KEY_PROTO_OPT 2 |
| 170 |
#define KEY_USER 3 |
| 171 |
#define KEY_COMP 4 |
| 172 |
#define KEY_PRE 5 |
| 173 |
#define KEY_POST 6 |
| 174 |
#define KEY_PROTO 7 |
| 175 |
#define KEY_INCLUDE 8 |
| 176 |
#define KEY_DATESPEC 9 |
| 177 |
#define KEY_ALG 10 |
| 178 |
#define KEY_KEYFILE 11 |
| 179 |
#define KEY_OVERWRITE 12 |
| 180 |
#define KEY_SKIP 13 |
| 181 |
#define KEY_FORCE 14 |
| 182 |
#define KEY_SPARSE 15 |
| 183 |
#define KEY_TAR 16 |
| 184 |
#define KEY_FIND 17 |
| 185 |
#define KEY_ALWAYS 18 |
| 186 |
#define KEY_ALLOW 19 |
| 187 |
#define KEY_REMOTE_HDUP 20 |
| 188 |
#define KEY_REMOTE_HDUP_OPT 21 |
| 189 |
#define KEY_ARCHIVE 22 |
| 190 |
#define KEY_MCRYPT 23 |
| 191 |
#define KEY_HISTORY 24 |
| 192 |
#define KEY_ONEFILE 25 |
| 193 |
#define KEY_CHUNKSIZE 26 |
| 194 |
#define KEY_FREE 27 |
| 195 |
#define KEY_LOG 28 |
| 196 |
#define KEY_INHERIT 29 |
| 197 |
#define KEY_COMPLEVEL 30 |
| 198 |
#define KEY_GPG 31 |
| 199 |
#define KEY_GROUP 32 |
| 200 |
#define KEY_TAR_OPT 33 |
| 201 |
#define KEY_NOBACKUP 34 |
| 202 |
|
| 203 |
/* holds the %-vars (%h,%a,%s,%e,%u,%c,%g) */ |
| 204 |
#define SUBS 7 |
| 205 |
|
| 206 |
#define ALGORITHMS { \ |
| 207 |
{1, "cast-128"}, \ |
| 208 |
{2, "gost"}, \ |
| 209 |
{3, "rijndael-128" }, \ |
| 210 |
{4, "twofish" }, \ |
| 211 |
{5, "arcfour" }, \ |
| 212 |
{6, "cast-256" }, \ |
| 213 |
{7, "loki97" }, \ |
| 214 |
{8, "rijndael-192" }, \ |
| 215 |
{9, "saferplus" }, \ |
| 216 |
{10, "wake" }, \ |
| 217 |
{11, "blowfish-compat" }, \ |
| 218 |
{12, "des" }, \ |
| 219 |
{13, "rijndael-256" }, \ |
| 220 |
{14, "serpent" }, \ |
| 221 |
{15, "xtea" }, \ |
| 222 |
{16, "blowfish" }, \ |
| 223 |
{17, "enigma" }, \ |
| 224 |
{18, "rc2" }, \ |
| 225 |
{19, "tripledes"}, \ |
| 226 |
{0, NULL} \ |
| 227 |
} |
| 228 |
|
| 229 |
struct tab { |
| 230 |
int sym; |
| 231 |
const char *name; |
| 232 |
}; |
| 233 |
|
| 234 |
struct argument_t { |
| 235 |
char *configpath; |
| 236 |
unsigned int scheme; |
| 237 |
char *host; |
| 238 |
char *date; |
| 239 |
char *extractdir; |
| 240 |
char *extractfile; |
| 241 |
}; |
| 242 |
|
| 243 |
/* hold all the info about a specific host */ |
| 244 |
struct host { |
| 245 |
char *name; |
| 246 |
char *tar; |
| 247 |
char *archive; |
| 248 |
char *path[MAXDIR]; |
| 249 |
char *exclude[MAXDIR]; /* holds the exclude globbing patterns */ |
| 250 |
char *include[MAXDIR]; /* holds the include globbing patterns */ |
| 251 |
char *user; |
| 252 |
char *group; |
| 253 |
char *mcrypt; |
| 254 |
char *gpg; |
| 255 |
char *keypath; |
| 256 |
char *alg; |
| 257 |
char *remote; |
| 258 |
char *compression; |
| 259 |
char *date; |
| 260 |
char *datespec; |
| 261 |
char *basename; |
| 262 |
char *dirname_date; |
| 263 |
char *dirname_etc; |
| 264 |
char *filelist; |
| 265 |
char *excludelist; |
| 266 |
char *inclist; |
| 267 |
char *archivename; |
| 268 |
char *prerun; |
| 269 |
char *postrun; |
| 270 |
char *chunksize; |
| 271 |
char *free; |
| 272 |
char *complevel; /* compression level */ |
| 273 |
/* keep an eye on time */ |
| 274 |
time_t elapsed; |
| 275 |
/* how many bytes are written */ |
| 276 |
unsigned long long int bytes; |
| 277 |
/* define own options for each proto */ |
| 278 |
char *proto; |
| 279 |
char *proto_opt; |
| 280 |
char *remote_hdup; |
| 281 |
char *remote_hdup_opt; |
| 282 |
char *tar_conf_opt; /* Patch from Haskins */ |
| 283 |
char *nobackup; /* look for .nobackup files */ |
| 284 |
/* folded in the options from hdup-1.5 */ |
| 285 |
int overwrite; |
| 286 |
int skip; |
| 287 |
int force; |
| 288 |
int sparse; |
| 289 |
int always; |
| 290 |
int onefile; |
| 291 |
int allow_remote; /* host allowed to write archive */ |
| 292 |
int history; /* store everything in one dir or not */ |
| 293 |
int log; /* do syslogging */ |
| 294 |
}; |
| 295 |
|
| 296 |
struct header { |
| 297 |
char *prot_name; |
| 298 |
char *prot_ver; |
| 299 |
char *hostname; |
| 300 |
char *scheme; |
| 301 |
char *date; |
| 302 |
char *compression; |
| 303 |
char *encryption; |
| 304 |
char *extractdir; |
| 305 |
}; |
| 306 |
|
| 307 |
extern unsigned int quiet; |
| 308 |
extern unsigned int debug; |
| 309 |
extern unsigned int patched_tar; |
| 310 |
extern int verbose; |
| 311 |
extern unsigned int hdup_log; |
| 312 |
extern sig_atomic_t hdup_pipe; |
| 313 |
extern sig_atomic_t hdup_sig; |
| 314 |
extern sig_atomic_t hdup_alrm; |
| 315 |
extern char *progname; |
| 316 |
extern char *scheme[]; |
| 317 |
extern char *keyword[]; |
| 318 |
extern char *subvar[]; |
| 319 |
extern char *dots; |
| 320 |
extern char *spaces; |
| 321 |
extern const char ok_chars[]; |
| 322 |
typedef struct host host_t; |
| 323 |
typedef struct host * phost_t; |
| 324 |
typedef struct header header_t; |
| 325 |
typedef struct header * pheader_t; |