4 /**************************************************************************/
6 /* MODULE NAME : RESTORE utility
8 /* SOURCE FILE NAME: RESTORE.C
10 /* DESCRIPTIVE NAME : Restore one or more backed-up files from a
11 /* disk to another disk
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.
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.
24 /* This utility has a dependency on the BACKUP utility to
25 /* perform file backup correctly using the data structure
29 /* This utility is able to restore the files which are previously
30 /* backup by the BACKUP utility only.
34 /* INPUT: (PARAMETERS)
37 /* [d:][path]Restore d: [d:][path][filename][.ext]
38 /* [/S] [/P] [/B:date] [/A:date] [/E:time][/L:time][/M] [/N]
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
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
59 /* /N - Only restore those files which no longer exist on the
63 /* The restore program sets the ERRORLEVEL in the following manner:
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
74 /* Modification History:
76 /* Code added in DOS 3.3 to allow control file > 64k commented as:
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 !!
92 /* ;AN005; Replace COM_STRRCHR dbcs routine, fixes p5029
93 /***************** END OF SPECIFICATION *********************************/
98 #include "restpars.h" /*;AN000;4*/
99 #include "dos.h" /*;AN000;2*/
100 #include "comsub.h" /* common subroutine def'n */
101 #include "doscalls.h"
105 BYTE destddir[MAXPATH+3] = {'\0'};
106 BYTE srcddir[MAXPATH+3] = {'\0'};
109 BYTE control_flag2=0;
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 /*---------------------------------------*/
122 /*- Data structures for the PARSER */
124 /*---------------------------------------*/
126 struct subst_list sublist; /*;AN000;6 Message substitution list */
127 char response_buff[5]; /*;AN000;6 User response buffer *//*;AN000;6*/
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*/
133 /***************** START OF SPECIFICATION *********************************/
135 /* SUBROUTINE NAME : Main
137 /* DESCRIPTIVE NAME : Main routine for RESTORE utility
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.
147 /* Linkage: main((argc,argv)
149 /* INPUT: (PARAMETERS)
150 /* argc - number of arguments
151 /* argv - array of pointers to arguments
153 /* EFFECTS: rtswitch is changed to reflect the switches passed.
155 /********************** END OF SPECIFICATIONS *******************************/
156 void main(argc,argv) /* wrw! */
161 union REGS inregs,outregs; /*AN000*/
162 WORD i; /*loop counter */
163 WORD j; /*arrary subcript */
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 */
175 sysdispmsg(&outregs,&outregs); /*;AN000;6 Display the error message */
176 exit_routine(UNEXPECTED); /*;AN000;6 and terminate */
180 /*********************************************/
181 /* Parse the drive and file name entered */
182 /*********************************************/
183 parse_command_line /*;AN000;4*/
189 /*********************************************/
190 /* Make sure APPEND /X is not active */
191 /*********************************************/
192 check_appendX(); /*;AN000;2 */
195 /*********************************************/
196 /* Take control of Control Break Interrupt */
197 /*********************************************/
198 retcode = DOSSETSIGHANDLER
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 */
207 retcode = DOSSETSIGHANDLER
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 */
216 /*********************************/
217 /* Take control of Hard Errors */
218 /*********************************/
219 set_int24_vector(); /*;AN000; Set Critical error vector (int 24h) */
222 /************************************************************/
223 /* call dorestore (RTDO.C) to actually do the restoring */
224 /************************************************************/
225 dorestore(srcd,destd,inpath,infname,infext,infspec,&td);
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)
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);
238 exit_routine(NORMAL);