/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/* Copyright (c) 1988 AT&T */
/* All Rights Reserved */
/*
 * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
 * Use is subject to license terms.
 */
/*
 * This file contains modifications Copyright 2009-2011 J. Schilling
 *
 * @(#)filehand.h	1.5 11/04/20 J. Schilling
 */
#ifndef	_HDR_FILEHAND_H
#define	_HDR_FILEHAND_H

#if defined(sun)
#pragma ident "@(#)filehand.h 1.5 11/04/20 J. Schilling"
#endif
/*
 * @(#)filehand.h 1.3 06/12/12
 */

#if defined(sun)
#pragma ident	"@(#)filehand.h"
#pragma ident	"@(#)sccs:hdr/filehand.h"
#endif

/* EMACS_MODES: c !fill tabstop=4 */

/* define EMPTY is used as an indicator for an empty string or as a last
 * argument.  It should always be used for such purposes when calling
 * filehand.  Because we only compare to this address, and do not
 * actually use it, it is safe to do this on all machines.  No pointer
 * problems can occur because we are concerned only with a constant
 * address, not its contents. */

# define EMPTY (char*) 0

            /* Operation codes for routine ftrans. */

/* These opcodes will cause an error if file2 exists. */

# define CPY 1			/* Copy file1 to file2. */
# define RENAME 2		/* Give file1 the new name file2. */
# define APPEND 4		/* Append file1 to file2. */

/* These opcodes will destroy file2 (if it exists) and then execute the
 * command. */

# define COPYOVER 8		/* Copy file1 to file2. */
# define MOVE 16		/* Replace file2 with file1. */

           /* Operation codes for routine sweep. */

# define VERIFY 4		/* See if something is in file1. */
# define INSERT 8		/* Insert a new record. */
# define DELETE 16		/* Delete an old record. */
# define REPLACE 32		/* Change an old record. */
# define PUTNOW 128		/* Put immediately into file2. */

# define SEQUENTIAL 64	/* Records are sequential flag. */
# define SEQVERIFY 68	/* These are just the regular operations with */
# define SEQINSERT 72	/* SEQUENTIAL logically anded with them. */
# define SEQDELETE 80	/* As before, EXIT is automatic. */
# define SEQREPLACE 96

						/* fldsep codes. */

/* WHITE is a code used to specify that spaces and tabs separate
 * fields in records.  It takes the value of NULL, because NULL
 * cannot be used to separate fields. */

# define WHITE 0

/* Normal return codes.  These codes are returned on normal filehand
 * and ftrans operations. */

# define FOUND 8		/* A record was found. */
# define DONE 10		/* Request was done successfully. */
# define NOTFOUND 13	/* Record was not there. */
# define OK DONE		/* For readrec. */

                        /* Error codes. */

/* Those that are followed by "NK" will cause the KEEP option of opcode
 * to be ignored. */

# define DESTEXISTS 1	/* File2 exists and it shouldn't. */
# define NOSOURCE 2		/* Can't read/find file1. (NK) */
# define NODEST 3		/* Failed to open file2. (NK) */
# define BADSIZE 4		/* Bad maximum record size. (NK) */
# define NOSPACE 6		/* Couldn't allocate enough core. (NK) */
# define BIGREC 7		/* A record bigger than maxlen was encountered. */
# define NOTNEW 9		/* An attempt to overwrite with INSERT. */
# define LIVEDEST 11	/* Couldn't kill destination file. (NK) */
# define ABEND 12		/* Should never happen. */
# define LIVESRC 14		/* File1 was not deleted. */
# define NOTPUT 18		/* Message could not be PUTNOW. */
# define FILE1EOF 19	/* End of file on file1. */
# define COPYERROR 20	/* Error in copying the rest of the file. */
# define SHORTREC 21	/* An incorrect size FIXED record was read. */
# define BADTYPE 22		/* Record type was not FIXED or VARIED. */
# define RESETERR 23	/* NOTFOUND, and could not remove file2. */
# define NOCLOSE 24		/* Could not close a file near end of run. */
# define RECURSE 1024	/* Error occured in ftrans.  Lower bits give error. */

						/* Record type codes */

# define FIXED 1		/* Records are of a fixed size. */
# define VARIED 2		/* Records are of a varied size. */

#endif	/* _HDR_FILEHAND_H */
