/* 通过关键字,从文件中提取有用的信息 */
int FindInfoFromFile(char *keyword, char *FilePath, char *OutString){
char *pattern;
int x, z, lno = 0, cflags = 0;
char ebuf[128], lbuf[256];
FILE *fp = NULL;
regex_t reg;
regmatch_t pm[10];
const size_t nmatch = 10;
pattern = keyword;
fp = fopen(FilePath, "r" );
if(fp == NULL)
{
fprintf(stderr,"%s[%d]:Cannot open %s\n", __FILE__, __LINE__, FilePath);
return -1;
};
z = regcomp(®, pattern, cflags);
if (z != 0)
{
regerror(z, ®, ebuf, sizeof(ebuf));
fprintf(stderr, "%s: pattern '%s' \n", ebuf, pattern);
fclose(fp);
fp = NULL;
return -1;