/* BU.H FILE FOR BU.C - VERSION 2.0 * A File Backup Utility for cp/m 80 * BDS-C version ONLY . Requires v1.50a * * Copyright Ian Ashdown * byHeart Software * 2 - 2016 West First Avenue * Vancouver, B.C. V6J 1G8 * CANADA * * Originally published in 'Dr Dobb's Journal' Jan 1985 vol 10 No 1 * Program improvement suggestions by Anthony Skjellum, DDJ * Contrib Ed. * Modifications for BDS-C v1.50a by Peter Martin May '85 - May '86 * * THE STORY SO FAR.... BEGINNING FROM THE END : * * VERSION * 2.0 Reorganised for different query system and mapping of * active user areas into a map to be searched when * files are accessed, drops necessity for user area * to be given with a specified-filename (ambig or other) * Includes option to set attribute bits of files etc. * Also corrects corrections and new bugs in 1.4 * * Using L2.COM, COMPILE COMMANDS ARE: * cc bu -e 4700 * cc bu2 -e 4700 * cc bu3 -e 4700 * cc bu4 -e 4700 * l2 bu bu2 bu3 bu4 * 7 May 1986 -- p.g.m. * * 1.5 -- 1.9 unreleased bug-ridden developments April-May 86 * * 1.4 incorporates option to change file attributes by entering * same-drive copy command -- accepts wild-card filenames and * generic attribute 'pattern', but query option also active * to permit changing attributes file-by-file. Code * reorganised into 4 files, extended list of globals, and * simplified some badly-structured code of my own making to * try to make a bit more sense. * Made few main segments subroutines. 2 April 1986 * -- p.g.m. * * 1.3 assayed a fix on the (documented) problem occuring * when the back-up for a hard disk accepts a directory * entry, but has no space for file data. 25 March 1986 * -- p.g.m. * * 1.2 dropped AZTEC/DESMET options. BDS-C ONLY. * 12 June 1985 -- inserted new -C option for the command * line to allow disk swapping after program loaded -- pause * for disk-swap in relevant drives. * CONFINED CHANGES TO BDS-C Version * -- p.g.m. * * 1.1b as for 1.1a +further mods to new_disk routines etc.. * 7 June 1985 -- fixed bug in full disk routines; gave 2 * prompts : one to abort/continue, other for drive change. * fixed own BDS 'hacking' call after file renaming; fixed * own bug in offset updating to make count of sectors * actually written; changed problem with routine to * reloop for file that didn't fit if not hard_disk * -- p.g.m. * * 1.1a (cp/m 80) with BDS-C v1.50a compile options as well * 31 May 1985 -- changes to sequences for attribute * setting, to avert bdos File R/O error on abort with full * disk -- Peter G. Martin * * 1.1 originally for Aztec CII v1.06b (cp/m 80) and DeSmet C88 * v2.2 (cp/m 86) -- September 7, 1984 * -- published in Dr Dobbs' jan 1985 * * 1.0 December 31, 1983 -- Ian Ashdown only knows ! * * * BU utilizes the undocumented 'archive' file attribute feature of * cp/m. 80 versions 2.x and cpm-86 to detect MANY (not all) files * that were changed after the disk was 'backed up' and copy them * (with optional verification) to a backup disk. This program * was designed to perform the same action as the 'A' option of PIP * under DRI's MPM 2, for which the Archive attribute is * documented. * From Version 1.4, the entry of a 'same drive' command also permits * the simple setting of attribute bits WITHOUT file copying on the * target drive. The latter option allows -Q option (to permit * file-by-file attribute setting) but normally will work to an * established attribute setting 'pattern'. Change instructions * include a 'leave alone' command (---) for a given attribute or * attributes. * * Usage -- BU x[:afn] y [-AFHQCSn] (for back-up operations) * OR BU x[:afn] x [-AQCn] (for attribute-setting) * * where x = drive name of disk to be backed up * y = drive name of backup disk * * and the optional arguments are: * * -A All files, regardless of status * -F Fast copy -- without verification * -H Hard disk (files may be split) * -Q Query each file before backup * -C Change disk in copy drive after BU loaded * -S System attribute copied to backup * -n Specific USER of files to be backed up * afn Any legal ambiguous fileref * * * H option renames files by changing chars in filename to segment * nos. A copies files whether they are 'marked' as backed-up or not * * The second command form, BU x[:afn] x [-] * permits setting and resetting of file attribute bits, EITHER * according to a general pattern (eg R/O DIR NRC) OR (with -Q * option) for each file * * * DEFINES AND GLOBALS ETC FOLLOW */ #include #include /* * * * * * * * * * * * * * * Definitions * * * * * * * * * * * */ #define ERROR -1 #define DEL 0xff /* Deleted fileref flag */ #define ALL -1 /* All user numbers flag */ #define TRUE -1 #define FALSE 0 #define SUCCESS 0 #define O_RDONLY 0 #define USER_ERR 0 /* Specified fileref used with -n option */ /* * * * * * * * * * Error codes * * * * * * * * * * * * */ #define BAD_FREF 1 /* Illegal file reference */ #define BAD_ARGS 2 /* Illegal command line */ #define BAD_OPT 3 /* Illegal option */ #define BAD_USER 4 /* Illegal user number */ #define BAD_DRV 5 /* Illegal drive name(s) */ #define SAME_DRV 6 /* Same drive for output & input */ #define SET_FAIL 7 /* att bit set error, NOT USED in 2.0 */ #define OPN_ERR 8 /* File open error */ #define READ_ERR 9 /* File read error */ #define CLS_ERR 10 /* File close error */ #define BAD_VFY 11 /* File verify error */ /* * * * * * * * * * * * BDOS services * * * * * * * * * * * * * * */ #define DIR_IO 6 /* Direct I/O */ #define RESET_DRV 13 /* Reset all drives */ #define SEL_DRV 14 /* Select drive */ #define SRCH_F 17 /* Search first */ #define SRCH_N 18 /* Search Next */ #define GET_DRV 25 /* Get Default Drive */ #define SET_DMA 26 /* Set DMA Address */ #define SET_ATT 30 /* Set File Attributes */ #define USER_CODE 32 /* Get/Set User Code */ #define MAX_USER 16 /* user codes under cpm */ /* * * * * * * * * * * GLOBAL VARIABLES * * * * * * * * * * */ char ent_drv, /* Entry drive code */ ent_user, /* Entry user code */ cur_user, /* Current user code */ user_map[MAX_USER/8], /* bit map of user areas */ sf_cur[32], /* buffer for files found */ attpat[3], /* pattern of changes to attribs*/ *alloc(); /* Structure for linked list of filerefs */ struct file_ref { char name[12]; /* File reference */ struct file_ref *next; /* pointer to next structure */ }; struct file_ref root, /* Start of linked list */ *fref_1, /* Scratch struct pointers to */ *fref_2; /* linked list instances */ /* Flags used throughout program */ int dup_flag, /* duplicate fileref flag */ all_files, /* all files flag (cmd line option) */ fast_copy, /* fast copy flag */ hard_disk, /* hard disk flag */ query, /* query flag */ system, /* system flag */ user_no, /* user number */ swap_flag, /* flag for -C option */ next_flag, /* flag to switch srch-f to srch_n */ att_flag; /* flag for attribute-setting function */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* End BU.H 7 May 1986 */