diff options
Diffstat (limited to 'v4.0/src/CMD/RESTORE/RESTORE.C')
| -rw-r--r-- | v4.0/src/CMD/RESTORE/RESTORE.C | 240 |
1 files changed, 240 insertions, 0 deletions
diff --git a/v4.0/src/CMD/RESTORE/RESTORE.C b/v4.0/src/CMD/RESTORE/RESTORE.C new file mode 100644 index 0000000..e60288f --- /dev/null +++ b/v4.0/src/CMD/RESTORE/RESTORE.C | |||
| @@ -0,0 +1,240 @@ | |||
| 1 | |||
| 2 | /* 0 */ | ||
| 3 | |||
| 4 | /**************************************************************************/ | ||
| 5 | /* | ||
| 6 | /* MODULE NAME : RESTORE utility | ||
| 7 | /* | ||
| 8 | /* SOURCE FILE NAME: RESTORE.C | ||
| 9 | /* | ||
| 10 | /* DESCRIPTIVE NAME : Restore one or more backed-up files from a | ||
| 11 | /* disk to another disk | ||
| 12 | /* | ||
| 13 | /* FUNCTION: Restore files saved by BACKUP utility to their | ||
| 14 | /* destination disk. This utility will be able to identify | ||
| 15 | /* which of the two backup formats was used and to do the | ||
| 16 | /* restore accordingly. | ||
| 17 | /* | ||
| 18 | /* NOTES: This RESTORE utility recognize two data formats: | ||
| 19 | /* 1. The data format used by BACKUP utility of 3.2 and before. | ||
| 20 | /* 2. The data format used by BACKUP utility of 3.3 and above, | ||
| 21 | /* and also used by CP/DOS 1.0 and above. | ||
| 22 | /* | ||
| 23 | /* DEPENDENCY: | ||
| 24 | /* This utility has a dependency on the BACKUP utility to | ||
| 25 | /* perform file backup correctly using the data structure | ||
| 26 | /* agreed on. | ||
| 27 | /* | ||
| 28 | /* RESTRICTION: | ||
| 29 | /* This utility is able to restore the files which are previously | ||
| 30 | /* backup by the BACKUP utility only. | ||
| 31 | /* | ||
| 32 | /* ENTRY POINT: Main | ||
| 33 | /* | ||
| 34 | /* INPUT: (PARAMETERS) | ||
| 35 | /* | ||
| 36 | /* COMMAND SYNTAX: | ||
| 37 | /* [d:][path]Restore d: [d:][path][filename][.ext] | ||
| 38 | /* [/S] [/P] [/B:date] [/A:date] [/E:time][/L:time][/M] [/N] | ||
| 39 | /* | ||
| 40 | /* Parameters: | ||
| 41 | /* The first parameter you specify is the drive designator of | ||
| 42 | /* the disk containing the backed up files. The second | ||
| 43 | /* parameter is the a filespec indicating which files you want | ||
| 44 | /* to restore. | ||
| 45 | /* Switches: | ||
| 46 | /* /S - Restore subdirectories too. | ||
| 47 | /* /P - If any hidden or read-only files match the filespec, | ||
| 48 | /* prompt the user for permission to restore them. | ||
| 49 | /* /B - Only restore those files which were last Revised on or | ||
| 50 | /* before the given date. | ||
| 51 | /* /A - Only restore those files which were last Revised on or | ||
| 52 | /* after the given date. | ||
| 53 | /* /E - Only restore those files which were last Revised at or | ||
| 54 | /* earlier then the given time. | ||
| 55 | /* /L - Only restore those files which were last Revised at or | ||
| 56 | /* later then the given time. | ||
| 57 | /* /M - Only restore those files which have been Revised since | ||
| 58 | /* the last backup. | ||
| 59 | /* /N - Only restore those files which no longer exist on the | ||
| 60 | /* destination disk. | ||
| 61 | /* | ||
| 62 | /* EXIT-ERROR: | ||
| 63 | /* The restore program sets the ERRORLEVEL in the following manner: | ||
| 64 | /* | ||
| 65 | /* 0 Normal completion | ||
| 66 | /* 1 No files were found to backup | ||
| 67 | /* 2 Some files not restored due to sharing conflict | ||
| 68 | /* 3 Terminated by user | ||
| 69 | /* 4 Terminated due to error | ||
| 70 | /* | ||
| 71 | /* | ||
| 72 | /* SOURCE HISTORY: | ||
| 73 | /* | ||
| 74 | /* Modification History: | ||
| 75 | /* | ||
| 76 | /* Code added in DOS 3.3 to allow control file > 64k commented as: | ||
| 77 | /* /* !wrw */ | ||
| 78 | /* | ||
| 79 | /* ;AN000; Code added in DOS 4.0 | ||
| 80 | /* ;AN000;2 Support for APPEND /X deactivation | ||
| 81 | /* ;AN000;3 Support for Extended Attributes | ||
| 82 | /* ;AN000;4 Support for PARSE service routines | ||
| 83 | /* ;AN000;5 Support for code page file tags | ||
| 84 | /* ;AN000;6 Support for MESSAGE retriever | ||
| 85 | /* ;AN000;8 Eliminate double prompting on single drive systems | ||
| 86 | /* ;AN000;9 Fix for termination on "Unable to MKDIR" | ||
| 87 | /* ;AN000;10 Fix for p1620 | ||
| 88 | /* ;AN001; Add CR, LF to end of command line | ||
| 89 | /* ;AN002; Make parser errors display the offending parameter | ||
| 90 | /* ;AN003; Only disallow restore of system files in ROOT !! | ||
| 91 | /* ;AN004; Fix parser | ||
| 92 | /* ;AN005; Replace COM_STRRCHR dbcs routine, fixes p5029 | ||
| 93 | /***************** END OF SPECIFICATION *********************************/ | ||
| 94 | |||
| 95 | #include "rt.h" | ||
| 96 | #include "rt1.h" | ||
| 97 | #include "rt2.h" | ||
| 98 | #include "restpars.h" /*;AN000;4*/ | ||
| 99 | #include "dos.h" /*;AN000;2*/ | ||
| 100 | #include "comsub.h" /* common subroutine def'n */ | ||
| 101 | #include "doscalls.h" | ||
| 102 | #include "error.h" | ||
| 103 | |||
| 104 | |||
| 105 | BYTE destddir[MAXPATH+3] = {'\0'}; | ||
| 106 | BYTE srcddir[MAXPATH+3] = {'\0'}; | ||
| 107 | BYTE rtswitch=0; | ||
| 108 | BYTE control_flag=0; | ||
| 109 | BYTE control_flag2=0; | ||
| 110 | BYTE *buf_pointer; | ||
| 111 | |||
| 112 | /*=============================*/ | ||
| 113 | BYTE srcd; /*;AN000;4*/ | ||
| 114 | BYTE destd; /*;AN000;4*/ | ||
| 115 | BYTE inpath [MAXPATH]; /*;AN000;*/ | ||
| 116 | BYTE infname [MAXFNAME]; /*;AN000;*/ | ||
| 117 | BYTE infext [MAXFEXT]; /*;AN000;*/ | ||
| 118 | BYTE infspec [MAXFSPEC]; /*;AN000;*/ | ||
| 119 | /*=============================*/ | ||
| 120 | /*---------------------------------------*/ | ||
| 121 | /*- */ | ||
| 122 | /*- Data structures for the PARSER */ | ||
| 123 | /*- */ | ||
| 124 | /*---------------------------------------*/ | ||
| 125 | |||
| 126 | struct subst_list sublist; /*;AN000;6 Message substitution list */ | ||
| 127 | char response_buff[5]; /*;AN000;6 User response buffer *//*;AN000;6*/ | ||
| 128 | |||
| 129 | BYTE append_indicator = 0xff; /*;AN000;2 Indicates the support for APPEND /X is active */ | ||
| 130 | WORD original_append_func; /*;AN000;2 APPEND functions on program entry*/ | ||
| 131 | struct timedate td; | ||
| 132 | |||
| 133 | /***************** START OF SPECIFICATION *********************************/ | ||
| 134 | /* | ||
| 135 | /* SUBROUTINE NAME : Main | ||
| 136 | /* | ||
| 137 | /* DESCRIPTIVE NAME : Main routine for RESTORE utility | ||
| 138 | /* | ||
| 139 | /* FUNCTION: Main routine does the following: | ||
| 140 | /* 1. Verifies the DOS version | ||
| 141 | /* 2. Validate the input command line | ||
| 142 | /* 3. Calls dorestore to do the file restore. | ||
| 143 | /* | ||
| 144 | /* NOTES: | ||
| 145 | /* | ||
| 146 | /* ENTRY POINT: Main | ||
| 147 | /* Linkage: main((argc,argv) | ||
| 148 | /* | ||
| 149 | /* INPUT: (PARAMETERS) | ||
| 150 | /* argc - number of arguments | ||
| 151 | /* argv - array of pointers to arguments | ||
| 152 | /* | ||
| 153 | /* EFFECTS: rtswitch is changed to reflect the switches passed. | ||
| 154 | /* | ||
| 155 | /********************** END OF SPECIFICATIONS *******************************/ | ||
| 156 | void main(argc,argv) /* wrw! */ | ||
| 157 | int argc; | ||
| 158 | char *argv[]; | ||
| 159 | { | ||
| 160 | WORD retcode; | ||
| 161 | union REGS inregs,outregs; /*AN000*/ | ||
| 162 | WORD i; /*loop counter */ | ||
| 163 | WORD j; /*arrary subcript */ | ||
| 164 | BYTE *c; | ||
| 165 | DWORD drive_map; | ||
| 166 | DWORD prev_address; | ||
| 167 | WORD prev_action; | ||
| 168 | |||
| 169 | /**********************************/ | ||
| 170 | /** PRELOAD MESSAGES **/ | ||
| 171 | /**********************************/ | ||
| 172 | sysloadmsg(&inregs,&outregs); /*;AN000;6 Preload messages */ | ||
| 173 | if (outregs.x.cflag & CARRY) /*;AN000;6 If there was an error */ | ||
| 174 | { /*;AN000;6*/ | ||
| 175 | sysdispmsg(&outregs,&outregs); /*;AN000;6 Display the error message */ | ||
| 176 | exit_routine(UNEXPECTED); /*;AN000;6 and terminate */ | ||
| 177 | } /*;AN000;6*/ | ||
| 178 | |||
| 179 | |||
| 180 | /*********************************************/ | ||
| 181 | /* Parse the drive and file name entered */ | ||
| 182 | /*********************************************/ | ||
| 183 | parse_command_line /*;AN000;4*/ | ||
| 184 | ( /*;AN000;4*/ | ||
| 185 | argc, /*;AN000;4*/ | ||
| 186 | argv /*;AN000;4*/ | ||
| 187 | ); /*;AN000;4*/ | ||
| 188 | |||
| 189 | /*********************************************/ | ||
| 190 | /* Make sure APPEND /X is not active */ | ||
| 191 | /*********************************************/ | ||
| 192 | check_appendX(); /*;AN000;2 */ | ||
| 193 | |||
| 194 | |||
| 195 | /*********************************************/ | ||
| 196 | /* Take control of Control Break Interrupt */ | ||
| 197 | /*********************************************/ | ||
| 198 | retcode = DOSSETSIGHANDLER | ||
| 199 | ( | ||
| 200 | (void far *)signal_handler_routine, /* Signal handler address */ | ||
| 201 | (DWORD far *)&prev_address, /* Address of previous handler */ | ||
| 202 | (unsigned far *)&prev_action, /* Address of previous action */ | ||
| 203 | (unsigned)INSTALL_SIGNAL, /* Indicate request type */ | ||
| 204 | (unsigned)CTRL_C /* Signal number */ | ||
| 205 | ); | ||
| 206 | |||
| 207 | retcode = DOSSETSIGHANDLER | ||
| 208 | ( | ||
| 209 | (void far *)signal_handler_routine, /* Signal handler address */ | ||
| 210 | (DWORD far *)&prev_address, /* Address of previous handler */ | ||
| 211 | (unsigned far *)&prev_action, /* Address of previous action */ | ||
| 212 | (unsigned)INSTALL_SIGNAL, /* Indicate request type */ | ||
| 213 | (unsigned)CTRL_BREAK /* Signal number */ | ||
| 214 | ); | ||
| 215 | |||
| 216 | /*********************************/ | ||
| 217 | /* Take control of Hard Errors */ | ||
| 218 | /*********************************/ | ||
| 219 | set_int24_vector(); /*;AN000; Set Critical error vector (int 24h) */ | ||
| 220 | |||
| 221 | |||
| 222 | /************************************************************/ | ||
| 223 | /* call dorestore (RTDO.C) to actually do the restoring */ | ||
| 224 | /************************************************************/ | ||
| 225 | dorestore(srcd,destd,inpath,infname,infext,infspec,&td); | ||
| 226 | |||
| 227 | /************************************************************/ | ||
| 228 | /* output a msg in the following situations: */ | ||
| 229 | /* if flag indicates no file found */ | ||
| 230 | /************************************************************/ | ||
| 231 | if (set_reset_test_flag(&control_flag,FOUND,TEST)==FALSE) | ||
| 232 | { | ||
| 233 | /*warning! No files were found to restore*/ | ||
| 234 | display_it(NO_FILE_TO_RESTORE,STND_ERR_DEV,0,NO_RESPTYPE,(BYTE)UTIL_MSG); /*;AN000;6*/ | ||
| 235 | exit_routine(NOFILES); | ||
| 236 | } | ||
| 237 | |||
| 238 | exit_routine(NORMAL); | ||
| 239 | |||
| 240 | } /* end of main*/ | ||