/*static char *SCCSID = "@(#)file.h	6.2 91/01/14";*/
/*	SCCSID = "@(#)file.h	6.2 91/01/14"
 *
 *	IBM/Microsoft Confidential
 *
 *	Copyright (c) IBM Corporation 1987, 1989
 *	Copyright (c) Microsoft Corporation 1987, 1989
 *
 *	All Rights Reserved
 *
 */

/*
 *  FILE.H
 *
 *    DESCRIPTION
 *
 *      Header file for constants/macros associated with files
 *
 *
 *    FUNCTIONS DEFINED
 *
 *      None
 *
 *
 *  REVISION HISTORY (in reverse chronological order)
 *  -----------------------------------------------------------------------
 *  5/21/90     Brian Andrew    Added constants for 'must_have' file
 *                              attributes (dcr 853)
 *
 *  4/49/90     Brian Andrew    Added define for MAX_FILE_SIZE.
 *
 *  12/7/89     Brian Andrew    ATTR_MATCH_ALL looks for all files.
 *
 *  9/20/89     Brian Andrew    Structures for file info.
 *
 *  8/23/89     Brian Andrew    File attribute bits.
 *
 *  8/4/89      Brian Andrew    Initial Blank Template.
 *
 *
 *  TO DO
 *  -------------------------------------------------------------------------
 */

#define ROOT_DIR_NUM        1

#define NO_PREV_DIR         -1  /* Indicates don't use current directory */

#define NO_VERSION          -1  /* value used to indicate that file had no
								 * version number
								 */

#define MAX_DIGITS          5   /* Maximum digits in file version */

#define MAX_VERSION         32767   /* Maximum legal version number */

#define MAX_FILE_SIZE       0xFFFFFFFF  /* Max size is 2^32         */

/* these came from infoseg.inc in Gordon's assy code */
#define DOS_ATTR_READ_ONLY  0x0001
#define DOS_ATTR_HIDDEN     0x0002
#define DOS_ATTR_SYSTEM     0x0004
#define DOS_ATTR_DIRECTORY  0x0010
#define DOS_ATTR_ARCHIVE    0x0020

#define DOS_ATTR_NEWNAME    0x0040
#define DOS_ATTR_SEARCH     (DOS_ATTR_HIDDEN | DOS_ATTR_SYSTEM | \
							 DOS_ATTR_DIRECTORY | DOS_ATTR_NEWNAME)

#define DOS_ATTR_CHANGEABLE (DOS_ATTR_READ_ONLY | DOS_ATTR_HIDDEN | \
							 DOS_ATTR_SYSTEM | DOS_ATTR_ARCHIVE)

/* ATTR_MATCH_ALL   removed DOS_ATTR_SYSTEM as this allows interleave records */
#define ATTR_MATCH_ALL      (DOS_ATTR_READ_ONLY | DOS_ATTR_HIDDEN | \
							 DOS_ATTR_ARCHIVE | \
							 DOS_ATTR_DIRECTORY | DOS_ATTR_NEWNAME)

/* Constants for 'Must Have' file attributes */
#define MUST_HAVE_SHIFT     8
#define MUST_HAVE_MASK      0x3700

/* File attribute ISO/HSG */

#define ISO_ATTR_HIDDEN     0x0001
#define ISO_ATTR_DIRECTORY  0x0002
#define ISO_ATTR_ASSOC      0x0004

/*
 *  We need a bit to determine if this is the last extent of the multi-extent.
 *  We will use bit 7, since this is not used by us for file searches.
 *
 *  If this bit is set, then there are more extents for the file
 */

#define ISO_ATTR_MULTI      0x0080

/*      HSG time format (ASCII values in volume descriptors)
** Byte position        Field           Range
** 1-4                  Year            1 - 9999
** 5-6                  Month           1 - 12
** 7-8                  Day             1 - 31
** 9-10                 Hour            0 - 23
** 11-12                Minute          0 - 59
** 13-14                Second          0 - 59
** 15-16                Hundredths      0 - 99
**      Internal time
**              4 bytes
**      year     month    day       hour     minute   second
**      7 bits | 4 bits | 5 bits || 5 bits | 6 bits | 5 bits
*/

#define MASK_YEAR       0xfe00
#define MASK_MONTH      0x01e0
#define MASK_DAY        0x001f
#define MASK_HOUR       0xf800
#define MASK_MINUTE     0x07e0
#define MASK_SECOND     0x001f

#define GET_YEAR(s)     ((s & MASK_YEAR) >> 9)
#define GET_MONTH(s)    ((s & MASK_MONTH) >> 5)
#define GET_DAY(s)       (s & MASK_DAY)
#define GET_HOUR(s)     ((s & MASK_HOUR) >> 11)
#define GET_MINUTE(s)   ((s & MASK_MINUTE) >> 5)
#define GET_SECOND(s)   ((s & MASK_SECOND) << 1)

#define SET_YEAR(s,v)   (s |= (((USHORT) v) << 9))
#define SET_MONTH(s,v)  (s |= (((USHORT) v) << 5))
#define SET_DAY(s,v)    (s |= v)
#define SET_HOUR(s,v)   (s |= (((USHORT) v) << 11))
#define SET_MINUTE(s,v) (s |= (((USHORT) v) << 5))
#define SET_SECOND(s,v) (s |= (v >> 1))

/* The following constants are used for FS_OPENCREATE */
#define OPEN_DIR_ACC    0x8000
#define OPEN_ACCESS     0x0007
#define OPEN_ACC_READ   0
#define OPEN_ACC_RW     1
#define OPEN_ACC_WRITE  2
#define OPEN_ACC_EXE    3
#define OPEN_TYPE_FILE  0xFFFC
#define OPEN_TYPE_DEV   0xFFFD
#define OPEN_FLAG       0x000F
#define OPEN_FLAG_FAIL  0x0000
#define OPEN_FLAG_OPEN  0x0001
#define OPEN_FLAG_RPL   0x0002
#define OPEN_FLAGD      0x00F0
#define OPEN_FLAGD_FAIL 0x0000
#define OPEN_FLAGD_CR   0x0010
#define FILE_EXISTED    0x0001

