xref: /dragonfly/bin/cpdup/cpdup.h (revision 2b7dbe20)
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 <strings.h>
18 #include <errno.h>
19 #include <unistd.h>
20 #include <utime.h>
21 #include <dirent.h>
22 #include <signal.h>
23 #include <pwd.h>
24 #include <fnmatch.h>
25 #include <assert.h>
26 
27 /*
28  * See ./mklinux script
29  *
30  * This is a horrible hack.  lchmod also seems to be missing
31  * on the Debian system I am testing compatibility on (which will
32  * break the symlink handling code), so not sure what to do about
33  * that.
34  *
35  * XXX TODO
36  */
37 #ifdef __linux
38 
39 #define __printflike(a, b)
40 #define __printf0like(a, b)
41 #define __aligned(n)
42 #define __dead2
43 #define __unused
44 
45 #define lchmod	chmod	/* horrible hack */
46 
47 size_t strlcpy(char *dst, const char *src, size_t size);
48 
49 #endif
50 
51 #define VERSION	"1.21"
52 #define AUTHORS	"Matt Dillon, Dima Ruban, & Oliver Fromme"
53 
54 void logstd(const char *ctl, ...) __printflike(1, 2);
55 void logerr(const char *ctl, ...) __printflike(1, 2);
56 char *mprintf(const char *ctl, ...) __printflike(1, 2);
57 void fatal(const char *ctl, ...) __dead2 __printf0like(1, 2);
58 char *fextract(FILE *fi, int n, int *pc, int skip);
59 
60 int16_t hc_bswap16(int16_t var);
61 int32_t hc_bswap32(int32_t var);
62 int64_t hc_bswap64(int64_t var);
63 
64 int fsmid_check(int64_t fsmid, const char *dpath);
65 void fsmid_flush(void);
66 #ifndef NOMD5
67 int md5_check(const char *spath, const char *dpath);
68 void md5_flush(void);
69 #endif
70 
71 extern const char *UseCpFile;
72 extern const char *MD5CacheFile;
73 extern const char *FSMIDCacheFile;
74 extern const char *UseHLPath;
75 
76 extern int AskConfirmation;
77 extern int SafetyOpt;
78 extern int ForceOpt;
79 extern int DeviceOpt;
80 extern int VerboseOpt;
81 extern int DirShowOpt;
82 extern int QuietOpt;
83 extern int NotForRealOpt;
84 extern int NoRemoveOpt;
85 extern int UseMD5Opt;
86 extern int UseFSMIDOpt;
87 extern int SlaveOpt;
88 extern int SummaryOpt;
89 extern int CompressOpt;
90 extern int ReadOnlyOpt;
91 extern int DstRootPrivs;
92 extern int ValidateOpt;
93 
94 extern int ssh_argc;
95 extern const char *ssh_argv[];
96 
97 extern int64_t CountSourceBytes;
98 extern int64_t CountSourceItems;
99 extern int64_t CountCopiedItems;
100 extern int64_t CountSourceReadBytes;
101 extern int64_t CountTargetReadBytes;
102 extern int64_t CountWriteBytes;
103 extern int64_t CountRemovedItems;
104 extern int64_t CountLinkedItems;
105 
106 #ifdef DEBUG_MALLOC
107 void *debug_malloc(size_t bytes, const char *file, int line);
108 void debug_free(void *ptr);
109 
110 #define malloc(bytes)	debug_malloc(bytes, __FILE__, __LINE__)
111 #define free(ptr)	debug_free(ptr)
112 #endif
113