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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /* Copyright (c) 1988 AT&T */
22 /* All Rights Reserved */
23 /*
24  * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
25  * Use is subject to license terms.
26  */
27 /*
28  * This file contains modifications Copyright 2009-2011 J. Schilling
29  *
30  * @(#)filehand.h	1.5 11/04/20 J. Schilling
31  */
32 #ifndef	_HDR_FILEHAND_H
33 #define	_HDR_FILEHAND_H
34 
35 #if defined(sun)
36 #pragma ident "@(#)filehand.h 1.5 11/04/20 J. Schilling"
37 #endif
38 /*
39  * @(#)filehand.h 1.3 06/12/12
40  */
41 
42 #if defined(sun)
43 #pragma ident	"@(#)filehand.h"
44 #pragma ident	"@(#)sccs:hdr/filehand.h"
45 #endif
46 
47 /* EMACS_MODES: c !fill tabstop=4 */
48 
49 /* define EMPTY is used as an indicator for an empty string or as a last
50  * argument.  It should always be used for such purposes when calling
51  * filehand.  Because we only compare to this address, and do not
52  * actually use it, it is safe to do this on all machines.  No pointer
53  * problems can occur because we are concerned only with a constant
54  * address, not its contents. */
55 
56 # define EMPTY (char*) 0
57 
58             /* Operation codes for routine ftrans. */
59 
60 /* These opcodes will cause an error if file2 exists. */
61 
62 # define CPY 1			/* Copy file1 to file2. */
63 # define RENAME 2		/* Give file1 the new name file2. */
64 # define APPEND 4		/* Append file1 to file2. */
65 
66 /* These opcodes will destroy file2 (if it exists) and then execute the
67  * command. */
68 
69 # define COPYOVER 8		/* Copy file1 to file2. */
70 # define MOVE 16		/* Replace file2 with file1. */
71 
72            /* Operation codes for routine sweep. */
73 
74 # define VERIFY 4		/* See if something is in file1. */
75 # define INSERT 8		/* Insert a new record. */
76 # define DELETE 16		/* Delete an old record. */
77 # define REPLACE 32		/* Change an old record. */
78 # define PUTNOW 128		/* Put immediately into file2. */
79 
80 # define SEQUENTIAL 64	/* Records are sequential flag. */
81 # define SEQVERIFY 68	/* These are just the regular operations with */
82 # define SEQINSERT 72	/* SEQUENTIAL logically anded with them. */
83 # define SEQDELETE 80	/* As before, EXIT is automatic. */
84 # define SEQREPLACE 96
85 
86 						/* fldsep codes. */
87 
88 /* WHITE is a code used to specify that spaces and tabs separate
89  * fields in records.  It takes the value of NULL, because NULL
90  * cannot be used to separate fields. */
91 
92 # define WHITE 0
93 
94 /* Normal return codes.  These codes are returned on normal filehand
95  * and ftrans operations. */
96 
97 # define FOUND 8		/* A record was found. */
98 # define DONE 10		/* Request was done successfully. */
99 # define NOTFOUND 13	/* Record was not there. */
100 # define OK DONE		/* For readrec. */
101 
102                         /* Error codes. */
103 
104 /* Those that are followed by "NK" will cause the KEEP option of opcode
105  * to be ignored. */
106 
107 # define DESTEXISTS 1	/* File2 exists and it shouldn't. */
108 # define NOSOURCE 2		/* Can't read/find file1. (NK) */
109 # define NODEST 3		/* Failed to open file2. (NK) */
110 # define BADSIZE 4		/* Bad maximum record size. (NK) */
111 # define NOSPACE 6		/* Couldn't allocate enough core. (NK) */
112 # define BIGREC 7		/* A record bigger than maxlen was encountered. */
113 # define NOTNEW 9		/* An attempt to overwrite with INSERT. */
114 # define LIVEDEST 11	/* Couldn't kill destination file. (NK) */
115 # define ABEND 12		/* Should never happen. */
116 # define LIVESRC 14		/* File1 was not deleted. */
117 # define NOTPUT 18		/* Message could not be PUTNOW. */
118 # define FILE1EOF 19	/* End of file on file1. */
119 # define COPYERROR 20	/* Error in copying the rest of the file. */
120 # define SHORTREC 21	/* An incorrect size FIXED record was read. */
121 # define BADTYPE 22		/* Record type was not FIXED or VARIED. */
122 # define RESETERR 23	/* NOTFOUND, and could not remove file2. */
123 # define NOCLOSE 24		/* Could not close a file near end of run. */
124 # define RECURSE 1024	/* Error occured in ftrans.  Lower bits give error. */
125 
126 						/* Record type codes */
127 
128 # define FIXED 1		/* Records are of a fixed size. */
129 # define VARIED 2		/* Records are of a varied size. */
130 
131 #endif	/* _HDR_FILEHAND_H */
132