2 * ----------------------------------------------------------------------------
3 * "THE BEER-WARE LICENSE" (Revision 42):
4 * <phk@login.dknet.dk> wrote this file. As long as you retain this notice you
5 * can do whatever you want with this stuff. If we meet some day, and you think
6 * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
7 * ----------------------------------------------------------------------------
9 * $FreeBSD: src/usr.sbin/ctm/ctm/ctm.h,v 1.14.2.2 2001/07/05 02:30:52 kris Exp $
10 * $DragonFly: src/usr.sbin/ctm/ctm/Attic/ctm.h,v 1.2 2003/06/17 04:29:53 dillon Exp $
24 #include <sys/types.h>
30 #define MAXSIZE (1024*1024*40)
32 #define SUBSUFF ".ctm"
33 #define TMPSUFF ".ctmtmp"
34 #define TARCMD "tar -rf %s -T -"
37 #define CTM_F_MASK 0xff
38 #define CTM_F_Name 0x01
39 #define CTM_F_Uid 0x02
40 #define CTM_F_Gid 0x03
41 #define CTM_F_Mode 0x04
42 #define CTM_F_MD5 0x05
43 #define CTM_F_Count 0x06
44 #define CTM_F_Bytes 0x07
46 /* The qualifiers... */
47 #define CTM_Q_MASK 0xff00
48 #define CTM_Q_Name_File 0x0100
49 #define CTM_Q_Name_Dir 0x0200
50 #define CTM_Q_Name_New 0x0400
51 #define CTM_Q_Name_Subst 0x0800
52 #define CTM_Q_MD5_After 0x0100
53 #define CTM_Q_MD5_Before 0x0200
54 #define CTM_Q_MD5_Chunk 0x0400
55 #define CTM_Q_MD5_Force 0x0800
58 char *Key; /* CTM key for operation */
59 int *List; /* List of operations */
62 extern struct CTM_Syntax Syntax[];
65 struct CTM_Filter *Next; /* next filter in the list */
66 int Action; /* enable or disable */
67 regex_t CompiledRegex; /* compiled regex */
70 #define CTM_FILTER_DISABLE 0
71 #define CTM_FILTER_ENABLE 1
75 #define Delete(foo) if (!foo) ; else {Free(foo); foo = 0; }
76 #define String(foo) strdup(foo)
79 # define EXTERN extern
81 EXTERN u_char *Version;
84 EXTERN u_char *TimeStamp;
85 EXTERN u_char *Prefix;
86 EXTERN u_char *FileName;
87 EXTERN u_char *TmpDir;
88 EXTERN u_char *CatPtr;
89 EXTERN u_char *Buffer;
90 EXTERN u_char *BackupFile;
91 EXTERN u_char *TarCmd;
94 * Paranoid -- Just in case they should be after us...
100 * Verbose -- What to tell mom...
101 * 0 Nothing which wouldn't surprise.
103 * 2 Show progress '.'.
104 * 3 Show progress names, and actions.
108 * ExitCode -- our Epitaph
109 * 0 Perfect, all input digested, no problems
110 * 1 Bad input, no point in retrying.
111 * 2 Pilot error, commandline problem &c
112 * 4 Out of resources.
113 * 8 Destination-tree not correct.
114 * 16 Destination-tree not correct, can force.
115 * 32 Internal problems.
127 EXTERN struct timeval Times[2];
128 EXTERN struct CTM_Filter *FilterList;
129 EXTERN struct CTM_Filter *LastFilter;
132 #define Exit_Garbage 1
136 #define Exit_Forcible 16
139 #define Exit_Version 128
140 #define Exit_NoMatch 256
142 void Fatal_(int ln, char *fn, char *kind);
143 #define Fatal(foo) Fatal_(__LINE__,__FILE__,foo)
144 #define Assert() Fatal_(__LINE__,__FILE__,"Assert failed.")
145 #define WRONG {Assert(); return Exit_Mess;}
147 u_char * Ffield(FILE *fd, MD5_CTX *ctx,u_char term);
148 u_char * Fname(FILE *fd, MD5_CTX *ctx,u_char term,int qual, int verbose);
150 int Fbytecnt(FILE *fd, MD5_CTX *ctx, u_char term);
152 u_char * Fdata(FILE *fd, int u_chars, MD5_CTX *ctx);
154 #define GETFIELD(p,q) if(!((p)=Ffield(fd,&ctx,(q)))) return BADREAD
155 #define GETFIELDCOPY(p,q) if(!((p)=Ffield(fd,&ctx,(q)))) return BADREAD; else p=String(p)
156 #define GETBYTECNT(p,q) if(0 >((p)= Fbytecnt(fd,&ctx,(q)))) return BADREAD
157 #define GETDATA(p,q) if(!((p) = Fdata(fd,(q),&ctx))) return BADREAD
158 #define GETNAMECOPY(p,q,r,v) if(!((p)=Fname(fd,&ctx,(q),(r),(v)))) return BADREAD; else p=String(p)
160 int Pass1(FILE *fd, unsigned applied);
165 int ctm_edit(u_char *script, int length, char *filein, char *fileout);