xref: /titanic_44/usr/src/cmd/filesync/filesync.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright (c) 1996 Sun Microsystems, Inc.  All Rights Reserved
24  *
25  * module:
26  *	filesync.h
27  *
28  * purpose:
29  *	general defines for use throughout the program
30  */
31 
32 #ifndef	_FILESYNC_H
33 #define	_FILESYNC_H
34 
35 #pragma ident	"%W%	%E% SMI"
36 
37 #ifdef	__cplusplus
38 extern "C" {
39 #endif
40 
41 #include <sys/types.h>
42 
43 /*
44  * arbitrary limits
45  */
46 #define	MAX_NAME	256		/* longest path component	*/
47 #define	MAX_PATH	1024		/* longest total path length	*/
48 #define	MAX_RLIST	32		/* max number of -r arguments	*/
49 #define	MAX_LINE	1024		/* longest input line		*/
50 #define	MAX_DEPTH	20		/* how deep to recurse		*/
51 #define	COPY_BSIZE	8192		/* block size for file copies	*/
52 #define	MIN_HOLE	1024		/* minimum hole in sparse file	*/
53 #define	HASH_SIZE	99		/* ignore list hash table	*/
54 
55 /*
56  * sanity check limits
57  */
58 #define	CONFIRM_MIN	4		/* min # deletetes to confirm	*/
59 #define	CONFIRM_PCT	25		/* min pctg of files to confirm	*/
60 
61 /*
62  * special types used in the program
63  */
64 typedef enum {
65 	FALSE = 0,
66 	TRUE  = 1,
67 	MAYBE = 2			/* only partially true		*/
68 } bool_t;
69 
70 typedef enum {
71 	OPT_BASE = 0,			/* use the baseline data	*/
72 	OPT_SRC = 1,			/* use the source side		*/
73 	OPT_DST = 2,			/* use the destination side	*/
74 	OPT_OLD = 3,			/* use the old one		*/
75 	OPT_NEW = 4			/* use the new one		*/
76 } side_t;
77 
78 /*
79  * values for debug mask
80  */
81 typedef	long dbgmask_t;			/* type for debug masks		*/
82 #define	DBG_BASE	0x0001		/* baseline changes		*/
83 #define	DBG_RULE	0x0002		/* rule base changes		*/
84 #define	DBG_STAT	0x0004		/* file stats			*/
85 #define	DBG_ANAL	0x0008		/* analysis tracing		*/
86 #define	DBG_RECON	0x0010		/* reconciliation tracing	*/
87 #define	DBG_VARS	0x0020		/* variable tracing		*/
88 #define	DBG_FILES	0x0040		/* file reading/writing		*/
89 #define	DBG_LIST	0x0080		/* include list building	*/
90 #define	DBG_EVAL	0x0100		/* evaluation tracing		*/
91 #define	DBG_IGNORE	0x0200		/* ignore tracing		*/
92 #define	DBG_MISC	0x0400		/* catch-all everything else	*/
93 
94 /*
95  * values for error codes
96  */
97 typedef int errmask_t;			/* type for error masks		*/
98 #define	ERR_OK		0		/* everything is fine		*/
99 #define	ERR_RESOLVABLE	1		/* resolvable conflicts		*/
100 #define	ERR_UNRESOLVED	2		/* unresolvable conflicts	*/
101 #define	ERR_MISSING	4		/* some files missing		*/
102 #define	ERR_PERM	8		/* insufficient access		*/
103 #define	ERR_FILES	16		/* file format or I/O errors	*/
104 #define	ERR_INVAL	32		/* invalid arguments		*/
105 #define	ERR_NOBASE	64		/* inaccessable base directory	*/
106 #define	ERR_OTHER	128		/* anything else		*/
107 
108 /* errors that will prevent reconciliation from taking place		*/
109 #define	ERR_FATAL	(ERR_FILES|ERR_INVAL|ERR_NOBASE|ERR_OTHER)
110 
111 /* errors that will cause reconciliation to stop with -h specified	*/
112 #define	ERR_ABORT	(ERR_FILES|ERR_PERM)
113 
114 /*
115  * program defaults
116  */
117 #define	DFLT_PRFX	"$HOME/"		/* default location/pfx	*/
118 #define	SUFX_RULES	".packingrules"		/* rules v1.1 location	*/
119 #define	SUFX_BASE	".filesync-base"	/* baseline location	*/
120 #define	SUFX_OLD	".filesync-rules"	/* rules v1.0 location	*/
121 
122 /*
123  * global variables for command line options
124  */
125 extern bool_t  opt_acls;	/* enable acl checking/preservation	*/
126 extern bool_t  opt_mtime;	/* preserve modification times		*/
127 extern bool_t  opt_notouch;	/* don't actually make any changes	*/
128 extern side_t  opt_force;	/* designated winner for conflicts	*/
129 extern side_t  opt_oneway;	/* one way only propagation		*/
130 extern side_t  opt_onesided;	/* permit one sided analysis		*/
131 extern bool_t  opt_everything;	/* everything must agree (modes/uid/gid) */
132 extern bool_t  opt_quiet;	/* stiffle reconciliaton descriptions	*/
133 extern bool_t  opt_verbose;	/* generate analysis commentary		*/
134 extern bool_t  opt_errors;	/* simulate errors on specified files	*/
135 extern bool_t  opt_halt;	/* halt on any propagation error	*/
136 extern dbgmask_t opt_debug;	/* debugging options			*/
137 
138 /*
139  * information gained during startup that other people may need
140  */
141 extern uid_t my_uid;	/* User ID for files I create			*/
142 extern gid_t my_gid;	/* Group ID for files I create			*/
143 
144 /* error and warning routines						*/
145 void confirm(char *);		/* ask user if he's sure		*/
146 void nomem(char *);		/* die from malloc failure		*/
147 
148 /* routines for dealing with strings and file names			*/
149 const char *prefix(const char *, const char *); /* does s1 begin with s2 */
150 char *qualify(char *);		/* validate and fully qualify		*/
151 char *expand(char *);		/* expand variables in name		*/
152 char *lex(FILE *);		/* lex off one token			*/
153 extern int lex_linenum;		/* current input file line number	*/
154 const char *noblanks(const char *);	/* escape strings for embedded blanks */
155 bool_t wildcards(const char *);	/* does name contain wildcards		*/
156 bool_t suffix(const char *, const char *);	/* does s1 end with s2	*/
157 bool_t contains(const char *, const char *);	/* does s1 contain s2	*/
158 
159 #ifdef	__cplusplus
160 }
161 #endif
162 
163 #endif	/* _FILESYNC_H */
164