2 /*------------------------------
3 /* SOURCE FILE NAME: RTNEW.C
4 /*------------------------------
10 #include "restpars.h" /*;AN000;4*/
12 #include "dos.h" /*;AN000;2*/
13 #include "comsub.h" /* common subroutine def'n */
17 extern BYTE control_flag;
18 extern BYTE control_flag2;
19 extern unsigned far *control_buf_pointer;
20 extern unsigned control_file_handle; /* !wrw */
21 extern unsigned src_file_handle;
22 unsigned int done_searching; /* !wrw */
23 unsigned int numentry;
24 extern struct subst_list sublist; /*;AN000;6 Message substitution list */
26 /***************** START OF SPECIFICATION ********************************
28 /* SUBROUTINE NAME : search_src_disk_new
30 /* DESCRIPTIVE NAME : For new format only, search the entire disk for
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.
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
44 /* If the file matches all the specification, subroutine
45 /* restore_a_file is called to actually restore the file.
48 /********************* END OF SPECIFICATIONS ********************************/
49 void search_src_disk_new(dinfo,finfo,dheadold,dheadnew,fheadnew, /* wrw! */
50 srcd,destd,dnumwant,buf_size,
51 inpath,infname,infspec,control_buf_size,td)
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;
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;
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];
79 BYTE dir_path[MAXPATH];
80 unsigned int my_own_little_dirhandle = 0; /* !wrw */
81 union REGS qregs; /*;AN000;8*/
84 done_searching = FALSE; /* !wrw */
86 /***********************************************************************/
87 /*search the file control.xxx and try to find the file with match file */
88 /*name and file path */
89 /***********************************************************************/
91 retcode = findfirst_new(finfo,&found,&done_searching,inpath,
92 infspec,&dirptr,&flptr,&numentry,dir_path);
97 /***********************************************************************/
98 /*open file backup.xxx */
99 /***********************************************************************/
100 /*the current disk is one less than the disk num wanted*/
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');
109 file_tobe_opened[10] = (char)((dnum / 10) + '0');
111 file_tobe_opened[11] = (char)(dnum + '0');
112 file_tobe_opened[12] = NULLC;
116 ((char far *)&file_tobe_opened[0],
117 (unsigned far *)&src_file_handle,
118 (unsigned far *)&action,
127 if (retcode != NOERROR)
129 display_it(NOT_ABLE_TO_RESTORE_FILE,STND_ERR_DEV,0,NO_RESPTYPE,(BYTE)UTIL_MSG); /*;AN000;6*/
133 /***********************************************************************/
134 /*start loop to find next until no more file found */
135 /***********************************************************************/
138 /******************************************/
139 /* if it is system file, find next one */
140 /******************************************/
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
148 && strcmp(finfo->path,"\\")==0 /*;AN003;*/
150 { /* Do not RESTORE the file */
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) ))
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)
174 if (finfo->dnum != file_seq_num)
176 display_it(FILE_SEQUENCE_ERROR,STND_ERR_DEV,0,NO_RESPTYPE,(BYTE)UTIL_MSG); /*;AN000;6*/
177 unexperror(FILESEQERROR);
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,"\\");
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*/
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! */
206 first_file_on_diskette = FALSE;
208 if (set_reset_test_flag(&control_flag,SPLITFILE,TEST)==TRUE)
210 set_reset_test_flag(&control_flag,SPLITFILE,RESET);
211 /*do findfirst, the file found should be the splitted file*/
213 /* retcode= findfirst_new( finfo, &found, &done_searching, inpath, */
214 /* infspec, &dirptr, &flptr,&numentry,dir_path ); */
217 } /*end of if disk and file out of sequence*/
219 } /*end of if switch match is ok */
221 } /*end of if root directory and DOS system files */
223 /***********************************************************************/
224 /* if has not search to the end of the diskette, find next file */
225 /***********************************************************************/
226 if (done_searching == FALSE)
229 retcode= findnext_new(finfo,&found,&done_searching,inpath,infspec,
230 &dirptr,&flptr,&numentry,dir_path );
236 } /* end do while loop */
237 while( retcode == TRUE);
239 DOSCLOSE(src_file_handle);
243 } /*end of subroutine*/