xref: /dragonfly/bin/cpdup/cpdup.h (revision 7b1120e5)
1 /*
2  * CPDUP.H
3  */
4 
5 #include <sys/param.h>
6 #include <sys/time.h>
7 #include <sys/stat.h>
8 #include <sys/file.h>
9 
10 #include <fcntl.h>
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <stdarg.h>
14 #include <stddef.h>
15 #include <stdint.h>
16 #include <string.h>
17 #include <errno.h>
18 #include <unistd.h>
19 #include <utime.h>
20 #include <dirent.h>
21 #include <signal.h>
22 #include <pwd.h>
23 #include <fnmatch.h>
24 #include <assert.h>
25 #ifndef NOMD5
26 #include <md5.h>
27 #endif
28 
29 /* Solaris needs <strings.h> for bzero(), bcopy() and bcmp(). */
30 #include <strings.h>
31 
32 #ifdef __sun
33 #include "compat_sun.h"
34 #endif
35 
36 #ifdef __linux
37 #define __printflike(a,b)
38 #define __printf0like(a,b)
39 #define __aligned(x)
40 #define __unused
41 #endif
42 
43 void logstd(const char *ctl, ...) __printflike(1, 2);
44 void logerr(const char *ctl, ...) __printflike(1, 2);
45 char *mprintf(const char *ctl, ...) __printflike(1, 2);
46 void fatal(const char *ctl, ...) __dead2 __printf0like(1, 2);
47 char *fextract(FILE *fi, int n, int *pc, int skip);
48 
49 int16_t hc_bswap16(int16_t var);
50 int32_t hc_bswap32(int32_t var);
51 int64_t hc_bswap64(int64_t var);
52 
53 int fsmid_check(int64_t fsmid, const char *dpath);
54 void fsmid_flush(void);
55 #ifndef NOMD5
56 int md5_check(const char *spath, const char *dpath);
57 void md5_flush(void);
58 #endif
59 
60 extern const char *UseCpFile;
61 extern const char *MD5CacheFile;
62 extern const char *FSMIDCacheFile;
63 extern const char *UseHLPath;
64 
65 extern int AskConfirmation;
66 extern int SafetyOpt;
67 extern int ForceOpt;
68 extern int DeviceOpt;
69 extern int VerboseOpt;
70 extern int DirShowOpt;
71 extern int QuietOpt;
72 extern int NotForRealOpt;
73 extern int NoRemoveOpt;
74 extern int UseMD5Opt;
75 extern int UseFSMIDOpt;
76 extern int SlaveOpt;
77 extern int SummaryOpt;
78 extern int CompressOpt;
79 extern int ReadOnlyOpt;
80 extern int DstRootPrivs;
81 extern int ValidateOpt;
82 
83 extern int ssh_argc;
84 extern const char *ssh_argv[];
85 
86 extern int64_t CountSourceBytes;
87 extern int64_t CountSourceItems;
88 extern int64_t CountCopiedItems;
89 extern int64_t CountSourceReadBytes;
90 extern int64_t CountTargetReadBytes;
91 extern int64_t CountWriteBytes;
92 extern int64_t CountRemovedItems;
93 extern int64_t CountLinkedItems;
94 
95 #ifdef DEBUG_MALLOC
96 void *debug_malloc(size_t bytes, const char *file, int line);
97 void debug_free(void *ptr);
98 
99 #define malloc(bytes)	debug_malloc(bytes, __FILE__, __LINE__)
100 #define free(ptr)	debug_free(ptr)
101 #endif
102