/* Pro134E.c */ /* "3Eraser.Exe" */ /* Word Capture in the middle of 'inline' by Memory Location '&inline[]'. */ /* This is Portable version of 'Pro134D.exe' (DATE-TIME Stamp Eraser) * to share. */ /* 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]; char name2 [64]; /* About user's input 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); /* Pro998-2.c */ 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 MgDrive[16], UpperLetterMgDrive[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("Now we need a little adjustment about Path differences in files.\n"); printf("For example, your files in \\SDW\\ and \\ZIP\\ looks like this.\n\n"); printf("Directory of C:\\TO-CD\\CORP.02\\001-DIRC.TRY (SDW in Hard disk)\n"); printf("Directory of E:\\001-DIRC.TRY (From ZIP disk)\n"); printf("1...5....0....5....0....5....0....5\n"); printf("1 10 20 30 \n\n"); printf("In this case, if we erase 29 charaters for SDW and 15 for ZIP, \n"); printf("then, they become the same \\001-DIRC.TRY. Thus, erase the path \n"); printf("difference by setting,\n"); printf(" MgPathSDW is 29,\n"); printf(" MgPathZIP is 15.\n"); printf("Count carefully by using a cursor. And come back here to go to \n"); printf("the next step below. To exit now, as always [Ctrl]-key + [C]-key.\n\n"); printf("Type 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", MgPathZIP); printf("Type Drive Name of Your ZIP Disk: "); scanf("%s", &MgDrive); UpperLetterMgDrive[0]=toupper(MgDrive[0]); UpperLetterMgDrive[1]='\0'; /* Without this, the Drive name was unstable. */ printf("Drive name for ZIP is set to %s.\n\n", UpperLetterMgDrive ); clrscr(); /* ======================================================= */ printf("Since 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\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("One moment. Then, go to see if DATE-TIME stamps erased\n"); printf("files are there at \\SDW\\ERASED and \\ZIP\\ERASED.\n"); printf("If there, we can go to the final step '4Diff.exe'.\n"); printf("In case directory Path difference are not erased, count \n"); printf("Magic Path (SDW and ZIP) again, and run this Program again.\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"); i++; /* Maximum i is the MgFileNo in Array version */ while(fgets(inline, 256, infp1)!=NULL){ if (strncmp(inline, " Volume in drive C", 18)==0) fprintf (outfp1, "C\:\n"); else if(strncmp(inline, " Volume Serial", 14)==0) ; else if(strncmp(inline, "Directory of C", 14)==0){ /* Win95/98 */ shiftedLine(jumpThere, &inline[MgPathSDW]); fprintf (outfp1, "%s", jumpThere); }else if(strncmp(inline, " Directory of C", 15)==0){ /* WinXP */ 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 ========================*/ /* ============ ========================*/ /* ========================================================*/ while( (fgets(openingFile, 64, infpZIP))!=NULL ) { FILE *infp2, *outfp2; firstwd (openedFN, &openingFile[2]); sprintf(openedFNP, "ZIP\\%s.Txt", openedFN); infp2=fopen ( openedFNP, "r"); sprintf(writingFile, "ZIP\\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, UpperLetterMgDrive); 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", UpperLetterMgDrive); /* 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); }