home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Simtel MSDOS 1992 June
/
SIMTEL_0692.cdr
/
msdos
/
txtutl
/
bakzap.arc
/
BAKZAP.C
< prev
next >
Wrap
C/C++ Source or Header
|
1988-12-08
|
3KB
|
139 lines
/*
Backspace zapper by Mat*Rat
Ever have CAPTURE on while you're entering messages on line?
Ever get those stupid backspace characters in your capture
file? Pain, isn't it? BAKZAP will read any input text file
you specify and ZAP all the backspace characters. In other
words, it acts just like the bulletin board, zapping characters
from the file that would have been replaced by backspace
keypresses. If no backspaces are found, the file is left
unmodified. If backspaces are found, the output goes to a
file called TEMP. When all done, the original file is deleted,
and TEMP is renamed to the original filename.
*/
#include <stdio.h>
#include <string.h>
#define DEBUG 0
main(argc, argv)
int argc;
char *argv[];
{
char filename[40];
char works[120], *wPtr;
char oworks[120];
char temp[80];
int i, j;
long bakzaps;
FILE *fPtr, *oPtr;
bakzaps = 0;
if (argc == 1)
{
printf("\nInput filename to zap backspaces from? ");
gets(filename);
}
else
strcpy(filename, argv[1]);
strupr(filename);
strcpy(temp, filename);
wPtr = strrchr(temp, 92); /* Path specifier? */
if (wPtr == NULL)
wPtr = strchr(temp, ':'); /* drive specifier? */
if (wPtr != NULL)
{
wPtr++;
*wPtr = 0;
}
else
temp[0] = 0;
strcat(temp, "TEMP.TXT");
fPtr = fopen(filename, "r");
if (fPtr == NULL)
{
printf("\nBAKZAP can't open file: %s\n", filename);
return;
}
oPtr = fopen(temp, "w");
if (oPtr == NULL)
{
fclose(fPtr);
return;
}
do
{
wPtr = fgets(works,119,fPtr);
if (wPtr != NULL)
{
if (strlen(works) != 0)
{
j = 0;
i = 0;
do
{
oworks[j] = works[i];
if ( (works[i] == 8) && (j>0) )
{
bakzaps = bakzaps + (long)1;
j--;
}
else
j++;
i++;
}
while (works[i-1] != 0);
}
fputs(oworks, oPtr);
}
}
while (wPtr != NULL);
fclose( fPtr );
fclose( oPtr );
if (bakzaps == (long)0)
{
unlink(temp);
printf("\nNo backspace characters found in %s\n", filename);
}
else
{
unlink(filename);
strcpy(works, "rename ");
strcat(works, temp);
strcat(works, " ");
wPtr = strrchr(filename, 92);
if (wPtr == NULL)
wPtr = strrchr(filename, ':');
if (wPtr == NULL)
wPtr = filename;
else
wPtr++;
strcat(works, wPtr);
#if DEBUG
printf("System call: %s\n", works);
#else
system(works);
#endif
printf("\n%lu backspace characters zapped from file %s\n",bakzaps,filename);
}
puts("Thanks for using BAKZAP by Mat*Rat");
printf("From Ratware Softworks, (c) 1988");
}