Category : Files from Magazines
Archive   : WDJAN92.ZIP
Filename : 3N01062A

 
Output of file : 3N01062A contained in archive : WDJAN92.ZIP
/*
* WINEXT.C - DOS program to fix up bextstr output for Windows.
*/

#include
#include

/* Biggest line we can handle */
#define MAX_LINE (1024*1)

typedef unsigned long ULONG;

FILE *OpenFile(char *FileName, char *OpenMode)
{
FILE *File = fopen(FileName, OpenMode);
if(File == NULL)
{
fprintf(stderr, "Can't open file '%s' for '%s'\n",
FileName, OpenMode);
exit(EXIT_FAILURE);
}
else
return File;
}

ULONG GetLineCount(FILE *InputFile, char *InputLine)
{
if(fgets(InputLine, MAX_LINE, InputFile))
return atol(InputLine);
else
{
fprintf(stderr, "Input file is empty\n");
exit(EXIT_FAILURE);
}
}

size_t ConvertLine(FILE *OutputFile, char *InputLine)
{
size_t LineLength = 0;
char C;

for(; (C=*InputLine++); ++LineLength)
if(C == '\\')
switch(C = *InputLine++)
{
/* RC chokes on "\"" */
case '"' :
fputs("\\042", OutputFile);
break;
default :
fputc('\\', OutputFile);
fputc(C, OutputFile);
}
else
fputc(C, OutputFile);

return LineLength + 1; /* add one for end-of-string */
}


ULONG Convert(FILE *InputFile, FILE *OutputFile,
char *InputLine, ULONG TotalLines)
{
ULONG CharCount = 0;
ULONG LineCount = 0;

while((TotalLines>0) && fgets(InputLine, MAX_LINE, InputFile))
{
--TotalLines;
if(strlen(InputLine))
InputLine[strlen(InputLine)-1] = '\0';

/* LineCount+1 because bexstr starts numbering
* at 2 for some reason. */
fprintf(OutputFile, "\t%lu\t\"", ++LineCount+1);
CharCount += ConvertLine(OutputFile, InputLine);
fputs("\"\n", OutputFile);
}
if(TotalLines != 0)
{
fprintf(stderr, "Error: string file delivered %lu less lines than delivered\n", TotalLines);
exit(EXIT_FAILURE);
}
return CharCount;
}


int main(int argc, char **argv)
{
FILE *InputFile, *OutputFile, *CountFile;
char *InputLine = (char *)malloc(MAX_LINE);
ULONG TotalLines, TotalChars;

if(InputLine == NULL)
{
fprintf(stderr, "Can't allocate %ul bytes\n", MAX_LINE);
exit(EXIT_FAILURE);
}
InputFile = OpenFile("ext.str", "r");
OutputFile = OpenFile("ext.rc", "w");
CountFile = OpenFile("extcnt.h", "w");
TotalLines = GetLineCount(InputFile, InputLine);
fprintf(stdout, "Processing %lu lines\n", TotalLines);
TotalChars = Convert(InputFile, OutputFile,
InputLine, TotalLines);
fprintf(CountFile, "#define WINEXT_LINES (%lu)\n", TotalLines);
fprintf(CountFile, "#define WINEXT_CHARS (%lu)\n", TotalChars);
fclose(InputFile);
fclose(OutputFile);
fclose(CountFile);
exit(EXIT_SUCCESS);
}


  3 Responses to “Category : Files from Magazines
Archive   : WDJAN92.ZIP
Filename : 3N01062A

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/