2 /*----------------------------
3 /* SOURCE FILE NAME: RTOLD.C
4 /*----------------------------
10 #include "restpars.h" /*;AN000;4*/
12 #include "dos.h" /*;AN000;2*/
13 #include "comsub.h" /* common subroutine def'n */
18 extern BYTE control_flag;
19 extern BYTE control_flag2;
20 extern BYTE far *buf_pointer;
21 extern unsigned src_file_handle;
22 extern struct FileFindBuf filefindbuf;
23 extern struct subst_list sublist; /*;AN000;6 Message substitution list */
25 /***************** START OF SPECIFICATION *********************************/
27 /* SUBROUTINE NAME : search_src_disk_old */
29 /* DESCRIPTIVE NAME : For old format only, search the entire disk for */
32 /* FUNCTION: Using find first and find next to find all the files */
33 /* which match the filename specified in the input */
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. */
43 /* If the file matches all the specification, subroutine */
44 /* restore_a_file is called to actually restore the file. */
47 /********************** END OF SPECIFICATIONS *******************************/
48 void search_src_disk_old(dinfo,finfo,dheadold,dheadnew,fheadnew, /* wrw! */
49 srcd,destd,buf_size,dnumwant,
50 inpath,infname,infext,infspec,td)
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;
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;
68 BYTE outstring[MAXPATH+MAXFSPEC];
70 WORD first_file_on_diskette = TRUE;
71 WORD first_time_in_loop = TRUE;
74 unsigned int control_bufsize;
75 BYTE temp_fname[MAXFNAME];
76 BYTE temp_path[MAXPATH];
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];
86 /*end decleration for ffirst and fnext*/
87 union REGS qregs; /*;AN000;8*/
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, ".*");
99 retcode = /* 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 */
111 /*************************************************************************/
112 /* IF CANNOT FIND ANY FILES ON SOURCE, RETURN */
113 /*************************************************************************/
120 /*************************************************************************/
121 /* start DO loop to find next until no more file found */
122 /*************************************************************************/
125 /*if the directory found is a subdirectory, find next one*/
126 if((retcode = filefindbuf.attributes & 0x0010) != 0x0010)
129 if (strcmp(filefindbuf.file_name,BACKUPID) != 0)
131 if (first_time_in_loop == FALSE)
132 DOSCLOSE(src_file_handle);
134 first_time_in_loop = FALSE;
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);
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 ))
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) )) {
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)
172 if (finfo->dnum != 1 || finfo->dnum != file_seq_num)
174 display_it(FILE_SEQUENCE_ERROR,STND_ERR_DEV,0,NO_RESPTYPE,(BYTE)UTIL_MSG); /*;AN000;6*/
175 unexperror(FILESEQERROR);
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,"\\");
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*/
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);
205 first_file_on_diskette = FALSE;
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)
212 set_reset_test_flag(&control_flag,SPLITFILE,RESET);
214 if (dirhandle == 0xffff)
221 } /*end of if file splitted*/
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*/
236 (struct FileFindBuf far *)&filefindbuf,
238 (unsigned far *)&search_cnt
242 while(retcode == 0); /* END MAIN DO LOOP */
244 DOSCLOSE(src_file_handle);
245 /*************************************************************************/
246 /* if error during findnext, error exit */
247 /*************************************************************************/
248 if (retcode != ERROR_NO_MORE_FILES && retcode != 0)
255 if (dirhandle != 0xffff)
257 if ((retcode = DOSFINDCLOSE(dirhandle)) != 0)
266 } /*end of subroutine*/