summaryrefslogtreecommitdiff
path: root/v4.0/src/CMD/RESTORE/RTOLD.C
diff options
context:
space:
mode:
Diffstat (limited to 'v4.0/src/CMD/RESTORE/RTOLD.C')
-rw-r--r--v4.0/src/CMD/RESTORE/RTOLD.C266
1 files changed, 266 insertions, 0 deletions
diff --git a/v4.0/src/CMD/RESTORE/RTOLD.C b/v4.0/src/CMD/RESTORE/RTOLD.C
new file mode 100644
index 0000000..a345d76
--- /dev/null
+++ b/v4.0/src/CMD/RESTORE/RTOLD.C
@@ -0,0 +1,266 @@
1
2/*----------------------------
3/* SOURCE FILE NAME: RTOLD.C
4/*----------------------------
5/*  0 */
6
7#include "rt.h"
8#include "rt1.h"
9#include "rt2.h"
10#include "restpars.h" /*;AN000;4*/
11#include "string.h"
12#include "dos.h" /*;AN000;2*/
13#include "comsub.h" /* common subroutine def'n */
14#include "doscalls.h"
15#include "error.h"
16
17extern BYTE rtswitch;
18extern BYTE control_flag;
19extern BYTE control_flag2;
20extern BYTE far *buf_pointer;
21extern unsigned src_file_handle;
22extern struct FileFindBuf filefindbuf;
23extern struct subst_list sublist; /*;AN000;6 Message substitution list */
24
25/***************** START OF SPECIFICATION *********************************/
26/* */
27/* SUBROUTINE NAME : search_src_disk_old */
28/* */
29/* DESCRIPTIVE NAME : For old format only, search the entire disk for */
30/* matching files. */
31/* */
32/* FUNCTION: Using find first and find next to find all the files */
33/* which match the filename specified in the input */
34/* cammand line. */
35/* */
36/* Whenever there is a file found, subroutine filespecmatch */
37/* is called to match the file path, and file extension. */
38/* If file path and file extension match the specification, */
39/* subroutine switchmatch is called to match the file */
40/* attributes, file modes, time, and date, then file sequence */
41/* number is checked. */
42/* */
43/* If the file matches all the specification, subroutine */
44/* restore_a_file is called to actually restore the file. */
45/* */
46/* */
47/********************** END OF SPECIFICATIONS *******************************/
48void search_src_disk_old(dinfo,finfo,dheadold,dheadnew,fheadnew, /* wrw! */
49 srcd,destd,buf_size,dnumwant,
50 inpath,infname,infext,infspec,td)
51
52 struct disk_info *dinfo;
53 struct file_info *finfo;
54 struct disk_header_old *dheadold;
55 struct file_header_new far *fheadnew;
56 struct disk_header_new far *dheadnew;
57 BYTE srcd;
58 BYTE destd;
59 unsigned long buf_size;
60 unsigned int *dnumwant;
61 unsigned char *inpath;
62 unsigned char *infname;
63 unsigned char *infext;
64 unsigned char *infspec;
65 struct timedate *td;
66
67{
68 BYTE outstring[MAXPATH+MAXFSPEC];
69 WORD file_seq_num=1;
70 WORD first_file_on_diskette = TRUE;
71 WORD first_time_in_loop = TRUE;
72 WORD return_code;
73 DWORD partsize;
74 unsigned int control_bufsize;
75 BYTE temp_fname[MAXFNAME];
76 BYTE temp_path[MAXPATH];
77 WORD temp_dirhandle;
78
79
80 /*declaration for dosfindfirst */
81 unsigned dirhandle = 0xffff; /* directory handle */
82 unsigned search_cnt = 1; /* # of entries to find */
83 unsigned buf_len = sizeof(struct FileFindBuf);
84 BYTE search_string[MAXPATHF+2];
85 WORD retcode;
86 /*end decleration for ffirst and fnext*/
87 union REGS qregs; /*;AN000;8*/
88 int x; /*;AN000;8*/
89
90/*************************************************************************/
91/* FIND THE FIRST FILE ON SOURCE */
92/*************************************************************************/
93 search_string[0] = srcd;
94 search_string[1] = ':';
95 search_string[2] = NULLC;
96 strcat(search_string, infname);
97 strcat(search_string, ".*");
98
99retcode = /* Find the 1st filename that */
100 DOSFINDFIRST( /* matches specified file spec*/
101 ( char far * ) search_string, /* File path name */
102 ( unsigned far * ) &dirhandle, /* Directory search handle */
103 (unsigned) NOTV, /* Search attribute */
104 (struct FileFindBuf far *) &filefindbuf,
105 buf_len, /* Result buffer length */
106 ( unsigned far * ) &search_cnt, /* Number of entries to find */
107 ( DWORD) 0
108 );
109
110
111/*************************************************************************/
112/* IF CANNOT FIND ANY FILES ON SOURCE, RETURN */
113/*************************************************************************/
114 if (retcode != 0)
115 return;
116
117
118
119
120/*************************************************************************/
121/* start DO loop to find next until no more file found */
122/*************************************************************************/
123do
124{
125 /*if the directory found is a subdirectory, find next one*/
126 if((retcode = filefindbuf.attributes & 0x0010) != 0x0010)
127 {
128 /* SKIP BACKUPID */
129 if (strcmp(filefindbuf.file_name,BACKUPID) != 0)
130 {
131 if (first_time_in_loop == FALSE)
132 DOSCLOSE(src_file_handle);
133 else
134 first_time_in_loop = FALSE;
135
136 /*************************************************************************/
137 /*check_flheader_old: open and read file header, */
138 /*************************************************************************/
139 strcpy(temp_fname,filefindbuf.file_name);
140 retcode = check_flheader_old( finfo, temp_fname,
141 filefindbuf.write_date, filefindbuf.write_time,
142 filefindbuf.attributes, filefindbuf.file_size,
143 file_seq_num, srcd, destd, infspec, inpath, dnumwant);
144
145 if (retcode == 0) {
146
147 /*************************/
148 /* SKIP SYSTEM FILES */
149 if ((set_reset_test_flag(&control_flag2,CPPC,TEST) == FALSE) &&
150 (strcmp(finfo->fname,"IBMBIO.COM")==0 ||
151 strcmp(finfo->fname,"IBMDOS.COM")==0 ||
152 strcmp(finfo->fname,"COMMAND.COM")==0 ))
153 {}
154 else {
155
156 /*************************************************************************/
157 /*if there is any switches set in the input line */
158 /*switchmatch (this subroutine search the hard disk for the dest */
159 /*************************************************************************/
160 if ((set_reset_test_flag(&control_flag,SWITCHES,TEST) == FALSE) ||
161 (set_reset_test_flag(&control_flag,SWITCHES,TEST) == TRUE &&
162 ((retcode = switchmatch(finfo, srcd, destd, td)) == TRUE) )) {
163
164 /*************************************************************************/
165 /*if dnum in fheadold.disknum is not 1 and is not in sequence, error */
166 /*************************************************************************/
167 if (set_reset_test_flag(&control_flag2,OUTOF_SEQ,TEST) == TRUE &&
168 first_file_on_diskette == TRUE && finfo->dnum != 1)
169 {}
170 else
171 {
172 if (finfo->dnum != 1 || finfo->dnum != file_seq_num)
173 {
174 display_it(FILE_SEQUENCE_ERROR,STND_ERR_DEV,0,NO_RESPTYPE,(BYTE)UTIL_MSG); /*;AN000;6*/
175 unexperror(FILESEQERROR);
176 }
177 /*endif*/
178 /*************************************************************************/
179 /* output msg to indicate which file is to be restored */
180 /*************************************************************************/
181 /*outstring = inpath\infspec*/
182 strcpy(outstring,finfo->path);
183 if (strlen(finfo->path) != 1 )
184 strcat(outstring,"\\");
185
186 strcat(outstring,finfo->fname);
187 x = strlen(outstring);
188 outstring[x] = CR; /*;AN000;6*/
189 outstring[x+1] = LF; /*;AN000;6*/
190 outstring[x+2] = NUL; /*;AN000;6*/
191 qregs.x.ax = 0x4000; /*;AN000;6*/
192 qregs.x.bx = 0x0001; /*;AN000;6*/
193 qregs.x.cx = (WORD)strlen(outstring); /*;AN000;6*/
194 qregs.x.dx = (unsigned int)&outstring[0]; /*;AN000;6*/
195 intdos(&qregs,&qregs); /*;AN000;6*/
196
197
198 /*************************************************************************/
199 /* call restore_a_file to restore the file */
200 /*************************************************************************/
201 restore_a_file(finfo,dinfo,buf_size,&control_bufsize,
202 fheadnew,dheadold,dheadnew,
203 srcd,destd,inpath,infname,infspec,dnumwant,&dirhandle);
204
205 first_file_on_diskette = FALSE;
206
207 /*************************************************************************/
208 /* if the file just restored is a split file, and last file, exit loop */
209 /*************************************************************************/
210 if (set_reset_test_flag(&control_flag,SPLITFILE,TEST)==TRUE)
211 {
212 set_reset_test_flag(&control_flag,SPLITFILE,RESET);
213
214 if (dirhandle == 0xffff)
215 break;
216 else
217 {
218 retcode = 0;
219 continue;
220 }
221 } /*end of if file splitted*/
222
223
224 } /*end of if disk and file out of sequence*/
225 } /*end of switch match fail*/
226 } /*end of PC/DOS and it is system files*/
227 } /*end of if check file header is ok */
228 } /*end of if file name is not BACKUPID*/
229 } /*end of if the directory found is a subdirectory*/
230
231 search_cnt = 1;
232
233 retcode =
234 DOSFINDNEXT
235 (dirhandle,
236 (struct FileFindBuf far *)&filefindbuf,
237 buf_len,
238 (unsigned far *)&search_cnt
239 );
240
241}
242while(retcode == 0); /* END MAIN DO LOOP */
243
244DOSCLOSE(src_file_handle);
245/*************************************************************************/
246/* if error during findnext, error exit */
247/*************************************************************************/
248 if (retcode != ERROR_NO_MORE_FILES && retcode != 0)
249 {
250 com_msg(retcode);
251 unexperror(retcode);
252 }
253
254
255 if (dirhandle != 0xffff)
256 {
257 if ((retcode = DOSFINDCLOSE(dirhandle)) != 0)
258 {
259 com_msg(retcode);
260 unexperror(retcode);
261 }
262 }
263
264
265return;
266} /*end of subroutine*/