summaryrefslogtreecommitdiff
path: root/v4.0/src/CMD/RESTORE/RTNEW.C
diff options
context:
space:
mode:
Diffstat (limited to 'v4.0/src/CMD/RESTORE/RTNEW.C')
-rw-r--r--v4.0/src/CMD/RESTORE/RTNEW.C244
1 files changed, 244 insertions, 0 deletions
diff --git a/v4.0/src/CMD/RESTORE/RTNEW.C b/v4.0/src/CMD/RESTORE/RTNEW.C
new file mode 100644
index 0000000..c4c9cb6
--- /dev/null
+++ b/v4.0/src/CMD/RESTORE/RTNEW.C
@@ -0,0 +1,244 @@
1
2/*------------------------------
3/* SOURCE FILE NAME: RTNEW.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 control_flag;
18extern BYTE control_flag2;
19extern unsigned far *control_buf_pointer;
20extern unsigned control_file_handle; /* !wrw */
21extern unsigned src_file_handle;
22unsigned int done_searching; /* !wrw */
23unsigned int numentry;
24extern struct subst_list sublist; /*;AN000;6 Message substitution list */
25
26/***************** START OF SPECIFICATION ********************************
27/*
28/* SUBROUTINE NAME : search_src_disk_new
29/*
30/* DESCRIPTIVE NAME : For new format only, search the entire disk for
31/* matching files.
32/*
33/* FUNCTION: Call subroutine findfirst_new and fnext_new to find all the
34/* files which match the filename and file extension specified
35/* in the command line.
36/*
37/* Whenever there is a file found, subroutine filematch
38/* is called to match the file path, and file extension.
39/* If file path and file extension match the specification,
40/* subroutine switchmatch is called to match the file
41/* attributes, file modes, time, and date, then file sequence
42/* is checked.
43/*
44/* If the file matches all the specification, subroutine
45/* restore_a_file is called to actually restore the file.
46/*
47/*
48/********************* END OF SPECIFICATIONS ********************************/
49void search_src_disk_new(dinfo,finfo,dheadold,dheadnew,fheadnew, /* wrw! */
50 srcd,destd,dnumwant,buf_size,
51 inpath,infname,infspec,control_buf_size,td)
52
53 struct disk_info *dinfo;
54 struct file_info *finfo;
55 struct disk_header_new far *dheadnew;
56 struct file_header_new far *fheadnew;
57 struct disk_header_old *dheadold;
58 BYTE srcd;
59 BYTE destd;
60 unsigned int *dnumwant; /*num of next disk*/
61 unsigned long buf_size;
62 unsigned *control_buf_size;
63 unsigned char *inpath;
64 unsigned char *infname;
65 unsigned char *infspec;
66 struct timedate *td;
67
68{
69 BYTE outstring[MAXPATH+MAXFSPEC];
70 WORD file_seq_num = 1;
71 WORD first_file_on_diskette = TRUE;
72 BYTE file_tobe_opened[MAXFSPEC+2];
73 WORD dnum;
74 WORD found = FALSE;
75 WORD far *dirptr;
76 WORD far *flptr;
77 WORD retcode;
78 WORD action;
79 BYTE dir_path[MAXPATH];
80 unsigned int my_own_little_dirhandle = 0; /* !wrw */
81 union REGS qregs; /*;AN000;8*/
82 int x; /*;AN000;8*/
83
84 done_searching = FALSE; /* !wrw */
85
86 /***********************************************************************/
87 /*search the file control.xxx and try to find the file with match file */
88 /*name and file path */
89 /***********************************************************************/
90
91 retcode = findfirst_new(finfo,&found,&done_searching,inpath,
92 infspec,&dirptr,&flptr,&numentry,dir_path);
93
94 if (retcode != TRUE)
95 return;
96
97 /***********************************************************************/
98 /*open file backup.xxx */
99 /***********************************************************************/
100 /*the current disk is one less than the disk num wanted*/
101 dnum = *dnumwant -1;
102 /*make the file name to be opened*/
103 file_tobe_opened[0] = srcd;
104 file_tobe_opened[1] = ':';
105 file_tobe_opened[2] = NULLC;
106 strcat(file_tobe_opened,"BACKUP.");
107 file_tobe_opened[9] = (char)((dnum / 100) + '0');
108 dnum = dnum % 100;
109 file_tobe_opened[10] = (char)((dnum / 10) + '0');
110 dnum = dnum % 10;
111 file_tobe_opened[11] = (char)(dnum + '0');
112 file_tobe_opened[12] = NULLC;
113
114 retcode =
115 DOSOPEN
116 ((char far *)&file_tobe_opened[0],
117 (unsigned far *)&src_file_handle,
118 (unsigned far *)&action,
119 (DWORD)0,
120 0,
121 0x01,
122 0x00c0,
123 (DWORD)0
124 );
125
126
127 if (retcode != NOERROR)
128 {
129 display_it(NOT_ABLE_TO_RESTORE_FILE,STND_ERR_DEV,0,NO_RESPTYPE,(BYTE)UTIL_MSG); /*;AN000;6*/
130 unexperror(retcode);
131 }
132
133 /***********************************************************************/
134 /*start loop to find next until no more file found */
135 /***********************************************************************/
136 do
137 {
138 /******************************************/
139 /* if it is system file, find next one */
140 /******************************************/
141 if
142 (
143 (strcmp(finfo->fname,"IBMBIO.COM")==0 ||
144 strcmp(finfo->fname,"IBMDOS.COM")==0 ||
145 strcmp(finfo->fname,"CMD.EXE")==0 ||
146 strcmp(finfo->fname,"COMMAND.COM")==0
147 ) /*;AN003;*/
148 && strcmp(finfo->path,"\\")==0 /*;AN003;*/
149 )
150 { /* Do not RESTORE the file */
151 }
152 else
153 {
154
155 /***********************************************************************/
156 /*if there are any switches set in the input line, call switch match. */
157 /* if switchmatch returns FALSE, then find next file */
158 /***********************************************************************/
159 if ((set_reset_test_flag(&control_flag,SWITCHES,TEST) == FALSE) ||
160 (set_reset_test_flag(&control_flag,SWITCHES,TEST) == TRUE &&
161 ((retcode = switchmatch(finfo, srcd, destd, td)) == TRUE) ))
162 {
163
164 /***********************************************************************/
165 /* if the diskette is out of sequence, then do not check the sequence */
166 /* number of the 1st file. Otherwise, check sequence number */
167 /***********************************************************************/
168 if (set_reset_test_flag(&control_flag2,OUTOF_SEQ,TEST) == TRUE &&
169 first_file_on_diskette == TRUE && finfo->dnum != file_seq_num)
170 {
171 }
172 else
173 {
174 if (finfo->dnum != file_seq_num)
175 {
176 display_it(FILE_SEQUENCE_ERROR,STND_ERR_DEV,0,NO_RESPTYPE,(BYTE)UTIL_MSG); /*;AN000;6*/
177 unexperror(FILESEQERROR);
178 }
179
180 /***********************************************************************/
181 /* msg: output one line of outstring on the screen */
182 /* to confirm that a file has been restored sucessfully */
183 /***********************************************************************/
184 strcpy(outstring,finfo->path);
185 if (strlen(finfo->path) != 1 )
186 strcat(outstring,"\\");
187
188 strcat(outstring,finfo->fname);
189 x = strlen(outstring);
190 outstring[x] = CR; /*;AN000;6*/
191 outstring[x+1] = LF; /*;AN000;6*/
192 outstring[x+2] = NUL; /*;AN000;6*/
193 qregs.x.ax = 0x4000; /*;AN000;6*/
194 qregs.x.bx = 0x0001; /*;AN000;6*/
195 qregs.x.cx = (WORD)strlen(outstring); /*;AN000;6*/
196 qregs.x.dx = (unsigned int)&outstring[0]; /*;AN000;6*/
197 intdos(&qregs,&qregs); /*;AN000;6*/
198
199 /***********************************************************************/
200 /* restore the file */
201 /***********************************************************************/
202 restore_a_file(finfo,dinfo,buf_size,control_buf_size,
203 fheadnew,dheadold,dheadnew,
204 srcd,destd,inpath,infname,infspec,dnumwant,&my_own_little_dirhandle); /* wrw! */
205
206 first_file_on_diskette = FALSE;
207
208 if (set_reset_test_flag(&control_flag,SPLITFILE,TEST)==TRUE)
209 {
210 set_reset_test_flag(&control_flag,SPLITFILE,RESET);
211 /*do findfirst, the file found should be the splitted file*/
212
213 /* retcode= findfirst_new( finfo, &found, &done_searching, inpath, */
214 /* infspec, &dirptr, &flptr,&numentry,dir_path ); */
215 }
216
217 } /*end of if disk and file out of sequence*/
218
219 } /*end of if switch match is ok */
220
221 } /*end of if root directory and DOS system files */
222
223 /***********************************************************************/
224 /* if has not search to the end of the diskette, find next file */
225 /***********************************************************************/
226 if (done_searching == FALSE)
227 {
228 found = FALSE;
229 retcode= findnext_new(finfo,&found,&done_searching,inpath,infspec,
230 &dirptr,&flptr,&numentry,dir_path );
231
232 }
233 else
234 break;
235
236 } /* end do while loop */
237 while( retcode == TRUE);
238
239 DOSCLOSE(src_file_handle);
240
241return; /* !wrw */
242
243} /*end of subroutine*/
244