jrb@wdl1.UUCP (John R Blaker) (02/17/84)
/*===========================================================================* * == R T 1 1 . H == * *===========================================================================* * John R Blaker -- Ford Aerospace & Communications Corporation -- Oct. 1982 * *===========================================================================* * This file contains a number of global definitions * *===========================================================================* */ /* * Include file */ #include <stdio.h> /* Standard I/O headers */ /* * Values for boolean flags */ #define TRUE 1 #define FALSE 0 #define ZERO 0 /* For DRIVE flag */ #define ONE 1 /* For DRIVE flag */ /* * Boolean flags */ int TRACE; /* Tracing turned on if TRUE */ int VERBOSE; /* Verbose mode turned on if TRUE */ int EXTRACT; /* Extract files from disc if TRUE */ int WRITE; /* Write files on disc if TRUE */ int CREATE; /* Create a new disc if TRUE */ int LIST; /* List disc directory if TRUE */ int DRIVE; /* Select drive 0 if ZERO and 1 if ONE */ /* * Holds list of filenames * The size is large and arbitrary */ char *FILES[512]; /* * Number of files on command line */ int COUNT; /* * Structures for directories and * directory entries */ typedef struct dir_header { unsigned dh_segs; /* Total segments in directory */ unsigned dh_next; /* Segment number of next segment */ unsigned dh_highest; /* Segment number of last segment */ unsigned dh_extra; /* Extra bytes per entry (zero) */ unsigned dh_addr; /* Start of data referred to */ } DIR_HEADER; typedef struct dir_entry { unsigned de_status; /* Status word */ unsigned de_fln1; /* Chars 1-3 of filename */ unsigned de_fln2; /* Chars 4-6 of filename */ unsigned de_type; /* File type */ unsigned de_length; /* Total file length */ unsigned de_unused; /* Unused */ unsigned de_date; /* File creation date */ } DIR_ENTRY; /* * Valid statuses for de_status field */ #define ST_TENT 0000400 /* File is tentative */ #define ST_EMPT 0001000 /* Empty area defined */ #define ST_PERM 0002000 /* File is permanent */ #define ST_PROT 0102000 /* File is protected from being overwritten */ #define ST_EOSG 0004000 /* End of segment */ /* * Structure for a directory segment */ typedef struct dir_segmnt { DIR_HEADER ds_header; /* Segment header */ DIR_ENTRY ds_direct[72]; /* Entries (larger than max used) */ } DIR_SEGMNT; /* * Structure of an entry in the in-memory directory. The in-memory * directory is implemented as a linked list with nodes as * follows: */ typedef struct mem_dir { char md_name[15]; /* Name of file */ unsigned md_addr; /* Block number of start of file */ unsigned md_size; /* Size of file (in bytes) */ unsigned md_date; /* File creation date */ struct mem_dir *md_next; /* Pointer to next node */ } MEM_DIR; MEM_DIR *dir_header; /* Pointer to the head of the directory */ /* * Useful definitions */ #define BLOCKSIZE 512 /* Size of a block */ #define SEGSIZE (2 * BLOCKSIZE) /* Size of a segment */ #define IO_RD 0 /* Read only open() mode */ #define IO_WT 1 /* Write only open() mode */ #define IO_RW 2 /* Read/write open() mode */