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