TIP: Click on subject to list as thread! ANSI
echo: aust_c_here
to: All
from: Frank Adam
date: 1996-10-26 14:37:14
subject: fatread.c 2/6

>>> Part 2 of 6...

 BYTE  AccessB; /*  00h if disk accessed, FFh if not */
 DWORD NextDbp; /*  pointer to next DPB */
 WORD  NextClus; /* cluster at which to start search for free space */
          /*  when writing, usually the last cluster allocated */
 WORD  FreeClus; /* number of free clusters on drive, FFFFh = unknown */
};

struct DiskReadPacket   /* for DOS INT 25 absread */
{
 DWORD   sector;
 WORD    numsectors;
 DWORD   transferto;
 }drp;

struct BackupData  /* this holds the "where to put it back" info */
{
 BYTE drive;
 WORD fss; /* fat start sector. Always 1 but who knows.. */
 WORD bps; /* bytes per sector 512 on my drives but may vary */
 WORD spf; /* sectors per fat 251-2 on my drives again may vary */
 BYTE fats;  /* number of fats  (normally 2, a 0 here is not really good.
       /* the two fats are contiguous and the same, so one is enough
       /* to save, Norton's image.exe does the same.
       /* perhaps i should compare before saving, may do in future
       */
 }bupdat;     /* for test purposes at this stage */

struct DriveParamBlock FAR dpb;
unsigned linecount = 0;
FILE *stream;int PrintFlag;
char fname[80] = "";

void ShowMedia(void);
int GetDpb(int);
int GetFat(int,int,int);
int GetBoot(int,int);
void ShowSector(int,UCHAR*);
int ParseArg(char*[], int*,int*);
void SeekBackupPos(FILE *,int);
void FatShow( int );
void FatSave( int );

int GetKey(void);
int AbsRead(int,DWORD,WORD,UCHAR*);
int AbsWrite(int,DWORD,WORD,UCHAR*);


int main (int argc, char* argv[])
{
 int drive,swich,key;

 if(argc <= 2) { printf("Missing argument(s) !");return 0; }
 if(!ParseArg(argv, &drive,&swich)) return 0;

 if(GetDpb(drive)) printf("DPB Operation OK..");
  else {
 printf("DPB Operation Failed ! Probably CD-ROM or invalid drive.");
 return 0;
 }

  ShowMedia(); /* looking good if we got here */
  printf("\n\nAre the above correct ? Proceed (Y/n)");
  while(!(key = GetKey()));
  if(toupper(key) == 'N') return 0;
  key = 0;

switch(swich)
{
 case FATSHOW : FatShow(drive); break;
 case FATSAVE : FatSave(drive); break;
 case RESTORE : printf("\nNot yet implemented, waiting on feedback..");
 }

 return 0;
 }

void FatShow( int drive )
{
 int key;
 char printoname[64];
 char *p;

 printf("\nPrint to what ? ('p'rinter, 'f'ile, 'S'creen)");
  while(!(key = GetKey()));
  switch(toupper(key))
  {
   case 'P' : stream = stdprn;PrintFlag = 2;break;
   case 'F' : printf("\nEnter Filename:");
       fgets(printoname,63,stdin);
       p = printoname;
       if(*p == '\n') {printf("Wise guy !"); exit(0);}
       while(*p != '\n') p++;
       *p = '\0';
       if(NULL == (stream = fopen(printoname,"wt")))
       {
        printf("Bad filename !"); exit(0);

 >>> Continued to next message...

___ Blue Wave/DOS v2.21

---
* Origin: Melbourne PC User Group BBS (3:632/309)
SEEN-BY: 633/267 270
@PATH: 632/309 107 635/503 50/99 635/728 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.