diff options
Diffstat (limited to 'v4.0/src/CMD/RESTORE/RTNEW1.C')
| -rw-r--r-- | v4.0/src/CMD/RESTORE/RTNEW1.C | 627 |
1 files changed, 627 insertions, 0 deletions
diff --git a/v4.0/src/CMD/RESTORE/RTNEW1.C b/v4.0/src/CMD/RESTORE/RTNEW1.C new file mode 100644 index 0000000..c449192 --- /dev/null +++ b/v4.0/src/CMD/RESTORE/RTNEW1.C | |||
| @@ -0,0 +1,627 @@ | |||
| 1 | |||
| 2 | /*------------------------------ | ||
| 3 | /* SOURCE FILE NAME: RTNEW1.C | ||
| 4 | /*------------------------------ | ||
| 5 | /* 0 */ | ||
| 6 | #include "rt.h" | ||
| 7 | #include "rt1.h" | ||
| 8 | #include "rt2.h" | ||
| 9 | #include "restpars.h" /*;AN000;4*/ | ||
| 10 | #include "string.h" | ||
| 11 | #include "dos.h" /*;AN000;2*/ | ||
| 12 | #include "comsub.h" /* common subroutine def'n */ | ||
| 13 | #include "doscalls.h" | ||
| 14 | #include "error.h" | ||
| 15 | |||
| 16 | |||
| 17 | #define LAST_DIRBLOCK 0xffffffff /* !wrw */ | ||
| 18 | BYTE got_first_fh; /* !wrw */ | ||
| 19 | |||
| 20 | struct dir_block russ_dir_block; /* Current directory block /* !wrw */ | ||
| 21 | extern BYTE backup_level; /* Tells which DOS version made the BACKUP*/ /*;AN000;3*/ | ||
| 22 | |||
| 23 | struct file_header_new russ_file_header;/* Current file_header /* !wrw */ | ||
| 24 | unsigned short tot_num_fh_read_in; /* Num FH read in so far /* !wrw */ | ||
| 25 | unsigned short num_fh_in_buffer; /* Num FH currently in buff /* !wrw */ | ||
| 26 | unsigned short num_fh_in_buf_processed; /* Number of FH in the buffer that have been processed /* !wrw */ | ||
| 27 | struct file_header_new far *fheadnew; /* Global pointer to FH /* !wrw */ | ||
| 28 | |||
| 29 | |||
| 30 | BYTE fileheader_length; /*;AN000;3 Length of a file header */ | ||
| 31 | |||
| 32 | extern BYTE rtswitch; | ||
| 33 | extern BYTE control_flag; | ||
| 34 | extern BYTE control_flag2; | ||
| 35 | extern char far *control_buf_pointer; | ||
| 36 | extern unsigned control_file_handle; | ||
| 37 | extern WORD control_bufsize; /* !wrw */ | ||
| 38 | |||
| 39 | |||
| 40 | /* 0 */ | ||
| 41 | /***************** START OF SPECIFICATION ******************************** | ||
| 42 | /* | ||
| 43 | /* SUBROUTINE NAME : findfile_new | ||
| 44 | /* | ||
| 45 | /* DESCRIPTIVE NAME : Find a file with matching file name from | ||
| 46 | /* the file CONTROL.xxx. | ||
| 47 | /* | ||
| 48 | /* FUNCTION: For new format only, search through all directory blocks | ||
| 49 | /* and all file headers until a file header with matched file | ||
| 50 | /* path, name and extension is found. also store information | ||
| 51 | /* into fhead and finfo if file is found which match the | ||
| 52 | /* filename and file extension specified in the command line. | ||
| 53 | /* | ||
| 54 | /* NOTES: Path name for comparison has to started with \ and end with \. | ||
| 55 | /* | ||
| 56 | /********************** END OF SPECIFICATIONS *******************************/ | ||
| 57 | int findfile_new( finfo, found, done_searching, inpath, | ||
| 58 | infspec, dirptr, flptr, numentry, dir_path) | ||
| 59 | |||
| 60 | struct file_info *finfo; | ||
| 61 | WORD *found; | ||
| 62 | unsigned int *done_searching; | ||
| 63 | BYTE *inpath; | ||
| 64 | BYTE *infspec; | ||
| 65 | WORD far **dirptr; | ||
| 66 | WORD far **flptr; | ||
| 67 | unsigned int *numentry; | ||
| 68 | BYTE *dir_path; | ||
| 69 | { | ||
| 70 | struct dir_block far *dirblk; | ||
| 71 | char temp_path[MAXPATH]; | ||
| 72 | char temp_fname[MAXFSPEC]; | ||
| 73 | WORD i; | ||
| 74 | WORD rc; | ||
| 75 | |||
| 76 | |||
| 77 | dirblk = (struct dir_block far *)&russ_dir_block; /* !wrw */ | ||
| 78 | fheadnew = (struct file_header_new far *)&russ_file_header; /* !wrw */ | ||
| 79 | |||
| 80 | /******************************************************************/ | ||
| 81 | /* search the directory block for the one that has the right path */ | ||
| 82 | /*******************************************************************/ | ||
| 83 | while ((*done_searching == FALSE) && (*found == FALSE)) | ||
| 84 | { | ||
| 85 | temp_path[0] = '\\'; | ||
| 86 | for (i = 0; i <= (MAXPATH-2); ++i) | ||
| 87 | temp_path[i+1] = dirblk->path[i]; | ||
| 88 | |||
| 89 | temp_path[MAXPATH-1] = NULLC; | ||
| 90 | |||
| 91 | /*****************************/ | ||
| 92 | /* While path does not match */ | ||
| 93 | /*****************************/ | ||
| 94 | |||
| 95 | while (pathmatch(inpath,temp_path) == FALSE) | ||
| 96 | { | ||
| 97 | if (dirblk->nextdb == LAST_DIRBLOCK) /* !wrw */ | ||
| 98 | { | ||
| 99 | *found = FALSE; | ||
| 100 | *done_searching = TRUE; | ||
| 101 | break; | ||
| 102 | } | ||
| 103 | else | ||
| 104 | { | ||
| 105 | read_in_next_dirblock(); /* !wrw */ | ||
| 106 | temp_path[0] = '\\'; | ||
| 107 | for (i = 0; i <= (MAXPATH-2); ++i) | ||
| 108 | temp_path[i+1] = dirblk->path[i]; | ||
| 109 | temp_path[MAXPATH-1] = NULLC; | ||
| 110 | continue; | ||
| 111 | } | ||
| 112 | /*end of if not last dirblk*/ | ||
| 113 | |||
| 114 | } /*end while loop, searching for the right path in directory block*/ | ||
| 115 | /*if done searching, break out of the big loop to exit*/ | ||
| 116 | |||
| 117 | if (*done_searching == TRUE) | ||
| 118 | break; | ||
| 119 | |||
| 120 | /***************************************************/ | ||
| 121 | /* directory block with correct path has been found*/ | ||
| 122 | /***************************************************/ | ||
| 123 | |||
| 124 | /*get the total number of file headers in the directory block*/ | ||
| 125 | *numentry = (unsigned int)russ_dir_block.numentry; /* !wrw */ | ||
| 126 | |||
| 127 | if (got_first_fh == FALSE) /* !wrw */ | ||
| 128 | read_in_a_fileheader(); /*#### /* !wrw */ | ||
| 129 | |||
| 130 | /****************************************************/ | ||
| 131 | /* search all the file headers under this directory */ | ||
| 132 | /* block to find the one with right file name */ | ||
| 133 | /****************************************************/ | ||
| 134 | for (;;) | ||
| 135 | { | ||
| 136 | |||
| 137 | if ((rc = fheadnew->flag & COMPLETE_BIT) != COMPLETE_BIT) | ||
| 138 | { | ||
| 139 | if (*numentry) | ||
| 140 | --(*numentry); | ||
| 141 | if (*numentry==0) | ||
| 142 | { | ||
| 143 | if (dirblk->nextdb == LAST_DIRBLOCK) /* !wrw */ | ||
| 144 | { | ||
| 145 | *found = FALSE; | ||
| 146 | *done_searching = TRUE; | ||
| 147 | break; /*exit FOR loop, go back to WHILE loop*/ | ||
| 148 | } | ||
| 149 | else | ||
| 150 | { | ||
| 151 | read_in_next_dirblock(); /* !wrw */ | ||
| 152 | break; /*exit FOR loop, go back to WHILE loop*/ | ||
| 153 | } | ||
| 154 | } | ||
| 155 | else | ||
| 156 | { | ||
| 157 | read_in_a_fileheader(); /* !wrw */ | ||
| 158 | continue; | ||
| 159 | } | ||
| 160 | } | ||
| 161 | |||
| 162 | for (i = 0; i <= (MAXFSPEC-2); ++i) | ||
| 163 | temp_fname[i] = fheadnew->fname[i]; | ||
| 164 | temp_fname[MAXFSPEC-1] = NULLC; | ||
| 165 | |||
| 166 | if (fspecmatch(infspec,temp_fname)==TRUE) | ||
| 167 | { | ||
| 168 | *found = TRUE; | ||
| 169 | break; | ||
| 170 | } | ||
| 171 | else /* This file header is not the right one*/ | ||
| 172 | { | ||
| 173 | if (*numentry) | ||
| 174 | --(*numentry); | ||
| 175 | if (*numentry == 0) | ||
| 176 | { | ||
| 177 | if (dirblk->nextdb == LAST_DIRBLOCK) | ||
| 178 | { | ||
| 179 | *found = FALSE; | ||
| 180 | *done_searching = TRUE; | ||
| 181 | break; /*exit FOR loop, go back to WHILE loop*/ | ||
| 182 | } | ||
| 183 | else | ||
| 184 | { | ||
| 185 | read_in_next_dirblock(); /* !wrw */ | ||
| 186 | break; | ||
| 187 | } /*end of if not last dir block */ | ||
| 188 | } | ||
| 189 | else /*point to the next file header and loop again*/ | ||
| 190 | read_in_a_fileheader(); /* !wrw */ | ||
| 191 | |||
| 192 | } | ||
| 193 | |||
| 194 | } /* end for (;;) loop to search all file headers in a directory block */ | ||
| 195 | |||
| 196 | } /*end of while loop*/ | ||
| 197 | |||
| 198 | |||
| 199 | |||
| 200 | /*******************************************************************/ | ||
| 201 | /* if a file is found, save the information in the disk header and */ | ||
| 202 | /* file header */ | ||
| 203 | /*******************************************************************/ | ||
| 204 | if (*found == TRUE) | ||
| 205 | { | ||
| 206 | /* Store information from dir blk into finfo */ | ||
| 207 | if (strcmp(dir_path,"no path from fnext") == 0) | ||
| 208 | strcpy(finfo->path,temp_path); | ||
| 209 | else | ||
| 210 | { | ||
| 211 | finfo->path[0] = '\\'; | ||
| 212 | finfo->path[1] = NULLC; | ||
| 213 | strcat(finfo->path,dir_path); | ||
| 214 | } | ||
| 215 | |||
| 216 | /*store information from file header into finfo*/ | ||
| 217 | for (i = 0; i <= (MAXFSPEC-2); ++i) | ||
| 218 | finfo->fname[i] = fheadnew->fname[i]; | ||
| 219 | finfo->fname[MAXFSPEC-1] = NULLC; | ||
| 220 | finfo->fflag = fheadnew->flag; | ||
| 221 | finfo->dnum = fheadnew->fsequenc; | ||
| 222 | finfo->ftime = fheadnew->ftime; | ||
| 223 | finfo->fdate = fheadnew->fdate; | ||
| 224 | finfo->attrib = fheadnew->attrib; | ||
| 225 | finfo->partsize = fheadnew->partsize; | ||
| 226 | finfo->offset = fheadnew->offset; | ||
| 227 | |||
| 228 | if ((fheadnew->flag & EXT_ATTR_FLAG) == EXT_ATTR_FLAG) /*;AN000;3*/ | ||
| 229 | finfo->ea_offset = fheadnew->FH_EA_offset; /*;AN000;3*/ | ||
| 230 | |||
| 231 | if (*numentry) | ||
| 232 | --(*numentry); | ||
| 233 | |||
| 234 | if (*numentry == 0) | ||
| 235 | { | ||
| 236 | if (dirblk->nextdb == LAST_DIRBLOCK) | ||
| 237 | *done_searching = TRUE; | ||
| 238 | else | ||
| 239 | { | ||
| 240 | read_in_next_dirblock(); /* !wrw */ | ||
| 241 | read_in_a_fileheader(); /* !wrw */ | ||
| 242 | *numentry = dirblk->numentry; | ||
| 243 | } | ||
| 244 | } | ||
| 245 | else | ||
| 246 | read_in_a_fileheader(); /* !wrw */ | ||
| 247 | |||
| 248 | *dirptr=(WORD far *)dirblk; | ||
| 249 | *flptr=(WORD far *)fheadnew; | ||
| 250 | |||
| 251 | return (TRUE); | ||
| 252 | } /*end of if found */ | ||
| 253 | else | ||
| 254 | return (FALSE); | ||
| 255 | |||
| 256 | return(TRUE); /*;AN000;*/ | ||
| 257 | } /*end of subroutine */ | ||
| 258 | |||
| 259 | /* 0 */ | ||
| 260 | /***************** START OF SPECIFICATION ******************************** | ||
| 261 | /* | ||
| 262 | /* SUBROUTINE NAME : findnext_new | ||
| 263 | /* | ||
| 264 | /* DESCRIPTIVE NAME : For new format only, continue at the point | ||
| 265 | /* findfirst_new or previous findnext_new exit, search | ||
| 266 | /* the entire file of CONTROL.xxx to find matching file | ||
| 267 | /* names. | ||
| 268 | /* | ||
| 269 | /* FUNCTION: Continue at where findfirst_new or previous findnext_new | ||
| 270 | /* stop, search the current directory blocks for the matching | ||
| 271 | /* file path, if fail to find a file, then call findfile to | ||
| 272 | /* search all directory block. | ||
| 273 | /* | ||
| 274 | /* | ||
| 275 | /********************** END OF SPECIFICATIONS *******************************/ | ||
| 276 | int findnext_new(finfo, found, done_searching, in_path, | ||
| 277 | infspec, dirptr, flptr, numentry, dir_path) | ||
| 278 | |||
| 279 | struct file_info *finfo; | ||
| 280 | WORD *found; | ||
| 281 | unsigned int *done_searching; | ||
| 282 | BYTE *in_path; | ||
| 283 | BYTE *infspec; | ||
| 284 | WORD far **dirptr; | ||
| 285 | WORD far **flptr; | ||
| 286 | unsigned int *numentry; | ||
| 287 | BYTE *dir_path; | ||
| 288 | { | ||
| 289 | struct dir_block far *dirblk; | ||
| 290 | WORD retcode; | ||
| 291 | WORD i; | ||
| 292 | BYTE temp_fname[MAXFSPEC]; | ||
| 293 | WORD rc; | ||
| 294 | char temp_path[MAXPATH]; | ||
| 295 | |||
| 296 | dirblk=(struct dir_block far *)*dirptr; | ||
| 297 | fheadnew=(struct file_header_new far *)*flptr; | ||
| 298 | strcpy(dir_path,"no path from fnext"); | ||
| 299 | |||
| 300 | temp_path[0] = '\\'; | ||
| 301 | for (i = 0; i <= (MAXPATH-2); ++i) | ||
| 302 | temp_path[i+1] = dirblk->path[i]; | ||
| 303 | |||
| 304 | temp_path[MAXPATH-1] = NULLC; | ||
| 305 | |||
| 306 | /****************************************/ | ||
| 307 | /* Should we process this subdirectory ?*/ | ||
| 308 | /****************************************/ | ||
| 309 | if (pathmatch(in_path,temp_path) == TRUE) | ||
| 310 | { | ||
| 311 | |||
| 312 | /*************************************************/ | ||
| 313 | /*complete the scanning current db to find a file*/ | ||
| 314 | /*************************************************/ | ||
| 315 | for (;;) | ||
| 316 | { | ||
| 317 | if ((rc = fheadnew->flag & COMPLETE_BIT) != COMPLETE_BIT) | ||
| 318 | { | ||
| 319 | if (*numentry) | ||
| 320 | --(*numentry); | ||
| 321 | |||
| 322 | if (*numentry==0) | ||
| 323 | { | ||
| 324 | if (dirblk->nextdb == LAST_DIRBLOCK) | ||
| 325 | { | ||
| 326 | *found = FALSE; | ||
| 327 | *done_searching = TRUE; | ||
| 328 | break; | ||
| 329 | } | ||
| 330 | else | ||
| 331 | { | ||
| 332 | read_in_next_dirblock(); /* !wrw */ | ||
| 333 | break; /* !wrw */ | ||
| 334 | } | ||
| 335 | } /* !wrw */ | ||
| 336 | else /* There are more files from current dirblock. Get them */ | ||
| 337 | { /* !wrw */ | ||
| 338 | read_in_a_fileheader(); /* !wrw */ | ||
| 339 | continue; /* !wrw */ | ||
| 340 | } | ||
| 341 | } | ||
| 342 | /*endif*/ | ||
| 343 | |||
| 344 | /* If this file header is the right one)*/ | ||
| 345 | for (i = 0; i <= (MAXFSPEC-2); ++i) | ||
| 346 | temp_fname[i] = fheadnew->fname[i]; | ||
| 347 | |||
| 348 | temp_fname[MAXFSPEC-1] = NULLC; | ||
| 349 | |||
| 350 | if (fspecmatch(infspec,temp_fname)==TRUE) | ||
| 351 | { | ||
| 352 | *found = TRUE; | ||
| 353 | for (i = 0; i <= (MAXPATH-2); ++i) | ||
| 354 | dir_path[i] = dirblk->path[i]; | ||
| 355 | break; | ||
| 356 | } | ||
| 357 | else /*if this file header is not the right one*/ | ||
| 358 | { | ||
| 359 | if (*numentry) | ||
| 360 | --(*numentry); | ||
| 361 | if (*numentry == 0) /* If no more files in this directory block */ | ||
| 362 | { | ||
| 363 | if (dirblk->nextdb == LAST_DIRBLOCK) /* If this is the last dirblock on current source disk */ | ||
| 364 | { | ||
| 365 | *found = FALSE; | ||
| 366 | *done_searching = TRUE; | ||
| 367 | break; | ||
| 368 | } | ||
| 369 | else | ||
| 370 | { | ||
| 371 | read_in_next_dirblock(); /* !wrw */ | ||
| 372 | break; /* !wrw */ | ||
| 373 | } /*end of if not last dir block */ /* !wrw */ | ||
| 374 | } /* !wrw */ | ||
| 375 | else /* !wrw */ | ||
| 376 | read_in_a_fileheader(); /* !wrw */ | ||
| 377 | } | ||
| 378 | } /*end loop searching all file headers in dir block */ | ||
| 379 | } /*end of if the path match inpath*/ | ||
| 380 | |||
| 381 | else | ||
| 382 | *found = FALSE; | ||
| 383 | |||
| 384 | |||
| 385 | /********************************************************************/ | ||
| 386 | /* If fail to find a file in the current directory block, call */ | ||
| 387 | /* filefind_new to find next. */ | ||
| 388 | /* If already found or done searching, call findfile_new to store */ | ||
| 389 | /* information in finfo and dinfo */ | ||
| 390 | /********************************************************************/ | ||
| 391 | |||
| 392 | *dirptr=(WORD far *)dirblk; | ||
| 393 | *flptr=(WORD far *)fheadnew; | ||
| 394 | |||
| 395 | retcode = findfile_new(finfo,found,done_searching,in_path,infspec,dirptr, | ||
| 396 | flptr,numentry, dir_path); | ||
| 397 | |||
| 398 | return(retcode); | ||
| 399 | } | ||
| 400 | |||
| 401 | /* 0 */ | ||
| 402 | /***************** START OF SPECIFICATION ******************************** | ||
| 403 | /* | ||
| 404 | /* SUBROUTINE NAME : findfirst_new | ||
| 405 | /* | ||
| 406 | /* DESCRIPTIVE NAME : For new format only, search the entire file | ||
| 407 | /* of CONTROL.xxx to find matching file names. | ||
| 408 | /* | ||
| 409 | /* FUNCTION: search directory blocks one after the other to find the | ||
| 410 | /* directory block with the matching file path, then search | ||
| 411 | /* the entire directory block to find the file with matching | ||
| 412 | /* file name. | ||
| 413 | /* | ||
| 414 | /* | ||
| 415 | /********************** END OF SPECIFICATIONS *******************************/ | ||
| 416 | int findfirst_new(finfo,found,done_searching,in_path,infspec,dirptr,flptr,numentry,dir_path) | ||
| 417 | |||
| 418 | struct file_info *finfo; | ||
| 419 | WORD *found; | ||
| 420 | unsigned int *done_searching; | ||
| 421 | BYTE *in_path; | ||
| 422 | BYTE *infspec; | ||
| 423 | WORD far **dirptr; | ||
| 424 | WORD far **flptr; | ||
| 425 | unsigned int *numentry; | ||
| 426 | BYTE *dir_path; | ||
| 427 | { | ||
| 428 | struct dir_block far *dirblk; | ||
| 429 | WORD retcode; | ||
| 430 | |||
| 431 | strcpy(dir_path,"no path from fnext"); | ||
| 432 | dirblk = (struct dir_block far *)&russ_dir_block; /* !wrw */ | ||
| 433 | read_in_first_dirblock(); /* !wrw */ | ||
| 434 | |||
| 435 | if (got_first_fh == FALSE) /* !wrw */ | ||
| 436 | read_in_a_fileheader(); /*### /* !wrw */ | ||
| 437 | |||
| 438 | *found = FALSE; | ||
| 439 | *done_searching = FALSE; | ||
| 440 | *dirptr=(WORD far *)dirblk; | ||
| 441 | *flptr=(WORD far *)fheadnew; | ||
| 442 | |||
| 443 | retcode = findfile_new(finfo,found,done_searching,in_path, | ||
| 444 | infspec,dirptr,flptr,numentry,dir_path); | ||
| 445 | |||
| 446 | return(retcode); | ||
| 447 | } /*end of findfirst_new */ | ||
| 448 | |||
| 449 | |||
| 450 | |||
| 451 | |||
| 452 | /* 0 */ | ||
| 453 | /*********************************************************************/ | ||
| 454 | /* | ||
| 455 | /* SUBROUTINE NAME: read_in_next_dirblock | ||
| 456 | /* | ||
| 457 | /* FUNCTION: | ||
| 458 | /* Reads in a directory block | ||
| 459 | /* Figures out if it was put there by DOS 3.3 or 4.0 | ||
| 460 | /*********************************************************************/ | ||
| 461 | void read_in_next_dirblock() /* !wrw */ | ||
| 462 | { | ||
| 463 | |||
| 464 | WORD retcode; /* return code save area */ /* !wrw */ | ||
| 465 | WORD read_count; /* num bytes read in */ /* !wrw */ | ||
| 466 | DWORD file_pointer; /* current file pointer, returned by lseek !wrw */ | ||
| 467 | |||
| 468 | retcode = /* !wrw */ | ||
| 469 | DOSCHGFILEPTR /* !wrw */ | ||
| 470 | ( /* !wrw */ | ||
| 471 | control_file_handle, /* Handle */ /* !wrw */ | ||
| 472 | russ_dir_block.nextdb, /* New location */ /* !wrw */ | ||
| 473 | (BYTE)0, /* MOVE METHOD */ /* !wrw */ | ||
| 474 | (DWORD far *)&file_pointer /* !wrw */ | ||
| 475 | ); /* !wrw */ | ||
| 476 | |||
| 477 | retcode = | ||
| 478 | DOSREAD | ||
| 479 | ( /* !wrw */ | ||
| 480 | control_file_handle, /* !wrw */ | ||
| 481 | (char far *)&russ_dir_block, /* !wrw */ | ||
| 482 | (unsigned short)DIRBLKLEN, /* !wrw */ | ||
| 483 | (unsigned far *)&read_count /* !wrw */ | ||
| 484 | ); /* !wrw */ | ||
| 485 | /* !wrw */ | ||
| 486 | if (retcode != NOERROR) /* !wrw */ | ||
| 487 | { /* !wrw */ | ||
| 488 | display_it(SOURCE_NO_BACKUP_FILE,STND_ERR_DEV,0,NO_RESPTYPE,(BYTE)UTIL_MSG); /*;AN000;6*/ | ||
| 489 | unexperror(NOBACKUPFILE); /* !wrw */ | ||
| 490 | } | ||
| 491 | |||
| 492 | got_first_fh = FALSE; /* !wrw */ | ||
| 493 | get_fileheader_length(); /*;AN000;3*/ | ||
| 494 | |||
| 495 | return; /* !wrw */ | ||
| 496 | } /* !wrw */ | ||
| 497 | |||
| 498 | |||
| 499 | /*********************************************************************/ | ||
| 500 | /* | ||
| 501 | /* SUBROUTINE NAME: read_in_first_dirblock | ||
| 502 | /* | ||
| 503 | /* FUNCTION: | ||
| 504 | /* Reads in the first directory block | ||
| 505 | /* Figures out if it was put there by DOS 3.3 or 4.0 | ||
| 506 | /*********************************************************************/ | ||
| 507 | |||
| 508 | void read_in_first_dirblock() /* !wrw */ | ||
| 509 | { | ||
| 510 | |||
| 511 | WORD retcode; /* return code save area */ /* !wrw */ | ||
| 512 | WORD read_count; /* num bytes read in */ /* !wrw */ | ||
| 513 | |||
| 514 | /********************************************************************/ | ||
| 515 | /* READ DIRECTORY_BLOCK INTO STATIC DATA AREA */ | ||
| 516 | /********************************************************************/ | ||
| 517 | |||
| 518 | retcode = DOSREAD( /* !wrw */ | ||
| 519 | control_file_handle, /* !wrw */ | ||
| 520 | (char far *)&russ_dir_block, /* !wrw */ | ||
| 521 | (unsigned short)DIRBLKLEN, /* !wrw */ | ||
| 522 | (unsigned far *)&read_count /* !wrw */ | ||
| 523 | ); /* !wrw */ | ||
| 524 | |||
| 525 | if (retcode != 0) /* !wrw */ | ||
| 526 | { /* !wrw */ | ||
| 527 | display_it(SOURCE_NO_BACKUP_FILE,STND_ERR_DEV,0,NO_RESPTYPE,(BYTE)UTIL_MSG); /*;AN000;6*/ | ||
| 528 | unexperror(NOBACKUPFILE); /* !wrw */ | ||
| 529 | } | ||
| 530 | |||
| 531 | got_first_fh = FALSE; /* !wrw */ | ||
| 532 | get_fileheader_length(); /*;AN000;3*/ | ||
| 533 | |||
| 534 | return; /* end subroutine */ /* !wrw */ | ||
| 535 | } /* !wrw */ | ||
| 536 | |||
| 537 | /**************************************************************/ | ||
| 538 | /* | ||
| 539 | /* SUBROUTINE: get_fileheader_length | ||
| 540 | /* | ||
| 541 | /* FUNCTION: Gets the length of a file header | ||
| 542 | /* Sets BACKUP_LEVEL to indicate which | ||
| 543 | /**************************************************************/ | ||
| 544 | void get_fileheader_length() | ||
| 545 | { | ||
| 546 | WORD retcode; /*;AN000;3*/ | ||
| 547 | WORD read_count; /*;AN000;3*/ | ||
| 548 | DWORD file_position; /*;AN000;3*/ | ||
| 549 | |||
| 550 | /* Save current file pointer */ | ||
| 551 | retcode = /*;AN000;3*/ | ||
| 552 | DOSCHGFILEPTR /*;AN000;3*/ | ||
| 553 | ( /*;AN000;3*/ | ||
| 554 | control_file_handle, /* Handle */ /*;AN000;3*/ | ||
| 555 | (DWORD)0, /* New location *//*;AN000;3*/ | ||
| 556 | (BYTE)1, /* MOVE METHOD *//*;AN000;3*/ | ||
| 557 | (DWORD far *)&file_position /*;AN000;3*/ | ||
| 558 | ); /*;AN000;3*/ | ||
| 559 | |||
| 560 | if (retcode != 0) /*;AN000;3*/ | ||
| 561 | { /*;AN000;3*/ | ||
| 562 | display_it(SOURCE_NO_BACKUP_FILE,STND_ERR_DEV,0,NO_RESPTYPE,(BYTE)UTIL_MSG); /*;AN000;6*/ | ||
| 563 | unexperror(NOBACKUPFILE); /*;AN000;3*/ | ||
| 564 | } | ||
| 565 | |||
| 566 | /* Read in file header length*/ | ||
| 567 | retcode = /*;AN000;3*/ | ||
| 568 | DOSREAD /*;AN000;3*/ | ||
| 569 | ( /*;AN000;3*/ | ||
| 570 | control_file_handle, /*;AN000;3*/ | ||
| 571 | (char far *)&fileheader_length, /*;AN000;3*/ | ||
| 572 | (unsigned short)2, /*;AN000;3*/ | ||
| 573 | (unsigned far *)&read_count /*;AN000;3*/ | ||
| 574 | ); /*;AN000;3*/ | ||
| 575 | |||
| 576 | if (retcode != 0 || read_count != 2) /*;AN000;3*/ | ||
| 577 | { /*;AN000;3*/ | ||
| 578 | display_it(SOURCE_NO_BACKUP_FILE,STND_ERR_DEV,0,NO_RESPTYPE,(BYTE)UTIL_MSG); /*;AN000;6*/ | ||
| 579 | unexperror(NOBACKUPFILE); /*;AN000;3*/ | ||
| 580 | } | ||
| 581 | |||
| 582 | /* Reset file pointer */ | ||
| 583 | retcode = /*;AN000;3*/ | ||
| 584 | DOSCHGFILEPTR /*;AN000;3*/ | ||
| 585 | ( /*;AN000;3*/ | ||
| 586 | control_file_handle, /* Handle */ /*;AN000;3*/ | ||
| 587 | file_position, /* New location *//*;AN000;3*/ | ||
| 588 | (BYTE)0, /* MOVE METHOD *//*;AN000;3*/ | ||
| 589 | (DWORD far *)&file_position /*;AN000;3*/ | ||
| 590 | ); /*;AN000;3*/ | ||
| 591 | |||
| 592 | return; | ||
| 593 | } /* end get_fileheader_length() */ | ||
| 594 | |||
| 595 | |||
| 596 | /* 0 */ | ||
| 597 | /**************************************************************/ | ||
| 598 | /* | ||
| 599 | /* SUBROUTINE: read_in_a_fileheader | ||
| 600 | /* | ||
| 601 | /* FUNCTION: Reads in a file header | ||
| 602 | /* | ||
| 603 | /**************************************************************/ | ||
| 604 | void read_in_a_fileheader() /* !wrw */ | ||
| 605 | { /* !wrw */ | ||
| 606 | WORD retcode; /* return code save area */ /* !wrw */ | ||
| 607 | WORD read_count; /* num bytes read in */ /* !wrw */ | ||
| 608 | |||
| 609 | retcode = DOSREAD /* !wrw */ | ||
| 610 | ( /* !wrw */ | ||
| 611 | control_file_handle, /* !wrw */ | ||
| 612 | (char far *)&russ_file_header, /* !wrw */ | ||
| 613 | fileheader_length, /* !wrw */ | ||
| 614 | (unsigned far *)&read_count /* !wrw */ | ||
| 615 | ); /* !wrw */ | ||
| 616 | |||
| 617 | if (retcode != NOERROR) /* !wrw */ | ||
| 618 | { /* !wrw */ | ||
| 619 | display_it(SOURCE_NO_BACKUP_FILE,STND_ERR_DEV,0,NO_RESPTYPE,(BYTE)UTIL_MSG); /*;AN000;6*/ | ||
| 620 | unexperror(NOBACKUPFILE); /* !wrw */ | ||
| 621 | } /* !wrw */ | ||
| 622 | |||
| 623 | got_first_fh = TRUE; /* !wrw */ | ||
| 624 | fheadnew = (struct file_header_new far *)&russ_file_header; /* !wrw */ | ||
| 625 | |||
| 626 | return; /* !wrw */ | ||
| 627 | } /* !wrw */ | ||