/* Pro134F.c */ /* "3Eraser.Exe" */ /* Read 'LOOKUP.TXT' file. * Two Magic Numbers, MgPath[SDW,ZIP], became a user's input. * MgDrive was added as a user's Drive name. * OS was added as an user's Catalogs' Creator OS version. */ /* User's input Drive name is introduced, and bypassed in one way, * and strictly recognized in another way. See deails in comment. */ /* (2005-02-09) */ /* I simplified the codes before Switch (Win3.1; Win95/98; WinXP). * Now is to try Global Variable to pass to Object, ColAdvPt * Column Advancing Pointer. Before do that, I test the OS * version switch, intermediate step just for OS1-Win95/98. * OS1-Win95/98 works. Now is the time to try Global. * Global variable passing to Recycle Object is working, * at lest OS1(Win95/98). Let me try to consolidate the * ColAdPt1 and ColAdPt2, because the matter is only * Advancing Column Numbers. * During the development, I used two different Column_Advancing_Pointer * with fixed ADV_NO1 and ADV_NO2. * ColAdvPt1 (wordColumnBegin, &inline[iBegin], ADV_NO1); * ColAdvPt2 (wordColumnErase, &inline[iErase], ADV_NO2); * Now, I simplified to only one. * ColAdvPtr (wordColumnBegin, &inline[iBegin], ADV_NO1); * ColAdvPtr (wordColumnErase, &inline[iErase], ADV_NO2); * so that Recycle Object is taking any ADV_NO which is assinged in * the main.c Codes. The compiler claimed a warning about * "int *adv_no" * but it is working as a whole. So I keep. * One more test in Win95/98, then test in WinXP. */ #include <stdio.h> #include <string.h> #include <ctype.h> #include <conio.h> char inline [256]; char jumpThere [128]; char wordColumnBegin [128]; char wordColumnErase [128]; char wordColumnFinish [128]; char openingFile [64]; char openedFN [64]; /* openedFN = openedFilename */ char openedFNP [128]; /* openedFNP = openedFileNameWithPath */ char writingFile [64]; char name1 [64]; /* About user's input HD Drive name + alpha */ char name2 [64]; /* About user's input ZIP Drive name + alpha */ static int ADV_NO1, ADV_NO2; /* For Eraser, "ColAdvPtr.o", Global Fixed Numbers for Pointer Advancing */ extern char *firstwd (char *to, char *from); extern char *shiftedLine (char *to, char *from); extern char *ColAdvPt (char *to, char *from, int ADV_NO1); /* Column_Advancing_Pointer */ extern char *ColAdvPt (char *to, char *from, int ADV_NO2); /* Column_Advancing_Pointer */ //extern char *ColAdvPt2 (char *to, char *from, int *position); /* Column_Advancing_Pointer */ extern char *ColFinPt (char *to, char *from); /* Column_Finishing_Pointer */ //extern char *ColFinPt (char *to, char *from, int *position); /* Column_Finishing_Pointer */ void main(void){ char MgHDrive[16], UpperLetterMgHDrive[16]; char MgZIPDrive[16], UpperLetterMgZIPDrive[16]; char strPause[16]; int i, MgPathSDW, MgPathZIP; int OS; int iBegin, iErase, iFinish; FILE *infpSDW, *infpZIP; infpSDW=fopen ("LOOKUP.TXT", "r"); infpZIP=fopen ("LOOKUP.TXT", "r"); /* Right now, both 'SDW(ZIP)-head.TXT' are the same, so this doesn't make sense. But for convenience of opening another set of file listing. */ i=MgPathSDW=MgPathZIP=0; iBegin=iErase=iFinish=0; /* This is local variables */ printf("[Sample]\n"); printf("1........10........20........30........40...\n\n"); printf("Directory of C:\\1TO-CD\\CORP.02\\001-DIRC.TRY (SDW in Hard disk)\n"); printf("Directory of E:\\001-DIRC.TRY (ZIP disk or Flash drive)\n"); printf("\n\nFor example above, 30 char deletion at SDW catalogs, and 15 char \n"); printf("deletion at ZIP_Flash catalogs become the same \\001-DIRC.TRY. \n"); printf("Please type those numbers as MagicPath to erase the difference. \n"); printf("\nType Number of MgPathSDW : "); scanf("%d", &MgPathSDW); printf("Magic Path for SDW is set to %d.\n\n", MgPathSDW); printf("Type Number of MgPathZIP : "); scanf("%d", &MgPathZIP); printf("Magic Path for ZIP is set to %d.\n\n\n", MgPathZIP); printf("Type any character key and [ENTER] to continue : "); scanf("%s", &strPause); clrscr(); printf("\n"); printf("Type Dual's Working Hard Drive [C, D, ..] : "); scanf("%s", &MgHDrive); UpperLetterMgHDrive[0]=toupper(MgHDrive[0]); UpperLetterMgHDrive[1]='\0'; /* Without this, the Drive name was unstable. */ printf("Dual's working hard disk is set to ------- %s.\n\n", UpperLetterMgHDrive ); printf("Type Drive Name of ZIP_FLASH Drive [D, E, ..] : "); scanf("%s", &MgZIPDrive); UpperLetterMgZIPDrive[0]=toupper(MgZIPDrive[0]); UpperLetterMgZIPDrive[1]='\0'; /* Without this, the Drive name was unstable. */ printf("Drive name for ZIP or Flash is set to ----- %s.\n\n\n\n", UpperLetterMgZIPDrive ); printf("Type any character key and [ENTER] to continue : "); scanf("%s", &strPause); clrscr(); // clrscr(); /* ======================================================= */ printf("\nSince different OS makes slightly different Catalog.Txt, \n"); printf("please select the OS version where you are running here now. \n\n"); printf(" 1. Win95\/Win98\n"); printf(" 2. WinXP\/Win2000\n\n"); printf("Select Your OS verions by Number [1 or 2] : "); scanf("%d", &OS); clrscr(); if (OS==1) { ADV_NO1=28; ADV_NO2=15; } /* I can recycle this to be Global variable to Objects */ if (OS==2) { ADV_NO2=20; } // printf("ADV_NO1 and ADV_NO2 are set to %d and %d respectively.\n\n", ADV_NO1, ADV_NO2 ); /* ======================================================= */ printf("\nDATE-TIME stamps are erased from catalogs for comparison.\n"); printf("The final step is '4Diff.exe'.\n\n\n"); printf("Type any character key and [ENTER] to close this message : "); scanf("%s", &strPause); while( (fgets(openingFile, 64, infpSDW))!=NULL ) { FILE *infp1, *outfp1; firstwd (openedFN, &openingFile[2]); /* This firstwd() is important to capture the filename */ /* without extra blanks and a carrige return. */ sprintf(openedFNP, "SDW\\%s.Txt", openedFN); infp1=fopen ( openedFNP, "r"); sprintf(writingFile, "SDW\\ERASED\\%s.Txt", openedFN); outfp1=fopen( writingFile, "w"); /* Appending user's input Drive name to strings */ if (OS==1) strcat(name1, "Directory of "); /* Win95/98 */ if (OS==2) strcat(name1, " Directory of "); /* WinXP */ strcat(name1, UpperLetterMgHDrive); i++; /* Maximum i is the MgFileNo in Array version */ while(fgets(inline, 256, infp1)!=NULL){ if (strncmp(inline, " Volume in drive", 16)==0) fprintf (outfp1, "%s\:\n", UpperLetterMgHDrive); /* Bypassing strict recognition of Drive name */ else if(strncmp(inline, " Volume Serial", 14)==0) ; else if(strncmp(inline, name1, 14)==0){ shiftedLine(jumpThere, &inline[MgPathSDW]); fprintf (outfp1, "%s", jumpThere); }else if(strncmp(inline, "\n", 1)==0) fprintf (outfp1, "\n"); else if(strncmp(inline, " ", 6)==0) fprintf (outfp1, "%s", inline); else if(strncmp(inline, "Total", 5)==0) fprintf (outfp1, "%s", inline); /* For this moment, I do ELSE, assuming Win95/98, if getting work, else if for Others */ // else if (OS=2) /* At here, I need to apply DATE-TIME Stamp Erasing */ else /* At here, I need to apply DATE-TIME Stamp Erasing */ { if(OS==1) { iBegin=0; iErase=29; iFinish=44; } if(OS==2) { iErase=0; iFinish=21; } if(OS==1) ColAdvPt (wordColumnBegin, &inline[iBegin], ADV_NO1); ColAdvPt (wordColumnErase, &inline[iErase], ADV_NO2); ColFinPt (wordColumnFinish, &inline[iFinish]); fprintf (outfp1, "%s", wordColumnBegin); if(OS==1){ fprintf (outfp1, " "); } if(OS==2){ fprintf (outfp1, " "); } fprintf (outfp1, "%s", wordColumnFinish); *wordColumnBegin =0; /* Reset */ *wordColumnErase =0; *wordColumnFinish =0; iBegin=iErase=iFinish=0; /* reset, in case */ } } *openedFN=0; /* Reset, in case */ *openedFNP=0; fclose (infp1); fclose (outfp1); } /* Close the first Filename changing WHILE-LOOP for SDW */ MgPathSDW=0; /* Reset */ fclose (infpSDW); /* ============ SECOND SET FOR ZIP_FLASH =================*/ /* ============ =================*/ /* ========================================================*/ while( (fgets(openingFile, 64, infpZIP))!=NULL ) { FILE *infp2, *outfp2; firstwd (openedFN, &openingFile[2]); sprintf(openedFNP, "ZIP_FL\\%s.Txt", openedFN); infp2=fopen ( openedFNP, "r"); sprintf(writingFile, "ZIP_FL\\ERASED\\%s.Txt", openedFN); outfp2=fopen( writingFile, "w"); /* Appending user's input Drive name to strings */ // strcat(name1, " Volume in drive "); // strcat(name1, UpperLetterMgDrive); if (OS==1) strcat(name2, "Directory of "); if (OS==2) strcat(name2, " Directory of "); strcat(name2, UpperLetterMgZIPDrive); i++; /* Maximum i is the MgFileNo in Array version */ while(fgets(inline, 256, infp2)!=NULL){ if(strncmp(inline, " Volume in drive", 16)==0){ fprintf (outfp2, "%s\:\n", UpperLetterMgZIPDrive); /* Bypassing strict recognition of Drive name */ // else if(strncmp(inline, name1, 18)==0) // fprintf (outfp2, "%s\:\n", UpperLetterMgDrive); /* This recognition worked only partially, see comment. */ }else if(strncmp(inline, " Volume Serial", 14)==0) ; else if(strncmp(inline, name2, 14)==0){ shiftedLine(jumpThere, &inline[MgPathZIP]); fprintf (outfp2, "%s", jumpThere); /* Keeping strict recognition of Drive name */ }else if(strncmp(inline, "\n", 1)==0) fprintf (outfp2, "\n"); else if(strncmp(inline, " ", 6)==0) fprintf (outfp2, "%s", inline); else if(strncmp(inline, "Total", 5)==0) fprintf (outfp2, "%s", inline); /* For this moment, I do ELSE, assuming Win95/98, if getting work, else if for Others */ // else if (OS=2) /* At here, I need to apply DATE-TIME Stamp Erasing */ else /* At here, I need to apply DATE-TIME Stamp Erasing */ { if(OS==1) { iBegin=0; iErase=29; iFinish=44; } if(OS==2) { iErase=0; iFinish=21; } if(OS==1) ColAdvPt (wordColumnBegin, &inline[iBegin], ADV_NO1); ColAdvPt (wordColumnErase, &inline[iErase], ADV_NO2); ColFinPt (wordColumnFinish, &inline[iFinish]); fprintf (outfp2, "%s", wordColumnBegin); if(OS==1){ fprintf (outfp2, " "); } if(OS==2){ fprintf (outfp2, " "); } // fprintf (outfp2, " "); fprintf (outfp2, "%s", wordColumnFinish); *wordColumnBegin =0; /* Reset */ *wordColumnErase =0; *wordColumnFinish =0; iBegin=iErase=iFinish=0; /* reset, in case */ } } fclose (infp2); fclose (outfp2); } /* Close the second Filename changing WHILE-LOOP for ZIP */ MgPathZIP=0; /* Reset */ // *name1=0; *name2=0; fclose (infpZIP); }