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