Category : C Source Code
Archive   : FASTGREP.ZIP
Filename : GETPATFI.C

 
Output of file : GETPATFI.C contained in archive : FASTGREP.ZIP
#include
#include
#include
#include
#include
#include "bm.h"
int
GetPatFile(PatFile, DescVec)
char *PatFile;
struct PattDesc *DescVec[];
/* read patterns from a file and set up a pattern descriptor vector */
{
extern char *malloc();
int PFile;
struct stat StatBuff;
int PatSize; /* the number of chars in all the patterns */
char *PatBuff; /* hold the patterns */
int file_size;

if ((PFile = open(PatFile,O_TEXT)) < 0)
{
fprintf(stderr,"bm: can't open pattern file %s\n",PatFile);
exit(2);
} /* if */
/* find out how big the patterns are */
if (fstat(PFile,&StatBuff) == -1)
{
fprintf(stderr,"bm: can't fstat %s\n",PatFile);
exit(2);
} /* if */
PatSize = StatBuff.st_size;
if (!PatSize)
{
fprintf(stderr,"bm: pattern file is empty\n");
exit(2);
} /* if */
if (!(PatBuff = malloc(PatSize)))
{
fprintf(stderr,"bm: insufficient memory to store patterns\n");
exit(2);
} /* if */
file_size = read(PFile,PatBuff,PatSize); /* get the patterns */
close(PFile);
/* make sure the patterns are null-terminated. We can't have
* nulls in the patterns */
if (PatBuff[file_size-1] == '\n')
{
PatBuff[file_size-1] = NULL;
}
else
{
PatBuff[file_size] = NULL;
}
return(MkDescVec(DescVec,PatBuff));
} /* GetPatFile */


  3 Responses to “Category : C Source Code
Archive   : FASTGREP.ZIP
Filename : GETPATFI.C

  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/