/*
* 从文件里得到url地址 2003-2-8 17:15
*/
#include <stdlib.h>
#include <stdio.h>
#define mailMaxLen 20
long filesize(FILE *stream)
{
long curpos, length;
curpos = ftell(stream);
fseek(stream, 0L, SEEK_END);
length = ftell(stream);
fseek(stream, curpos, SEEK_SET);
return length;
}
int main(void)
{
FILE *fp;
int i,temp_len;
int bool_find=0,bool_finished=0;
long file_len=0;
char *buf;
char *fileName="test.txt";
char *p,*mail_begin,*temp_p;
if((fp=fopen(fileName,"r"))==NULL)/*test256*/
{
printf("/nCan't open The file for %s ! /n",fileName);
printf("Press any key to halt!");
return(0);
}
file_len=filesize(fp);
buf=(char *)malloc(file_len);
fread(buf,file_len,1, fp);
for(p=buf;*p!='/0';p++)
{
//<a href="../template/membercenter/index.php">
if(*p=='<')
{ p++;
while(*p==' ' && *p!='/0')p++;//路过空格
if(*p=='a' || *p=='A')
{ p++;
while(*p==' ' && *p!='/0')p++;//路过空格
if(*p=='h' || *p=='H' ){p++;}
if(*p=='r' || *p=='R' ){p++;}
if(*p=='e' || *p=='E' ){p++;}
if(*p=='f' || *p=='F' )
{ p++;
while(*p==' ' && *p!='/0')p++;//路过空格
if(*p=='=')
{ p++;
while(*p==' ' && *p!='/0')p++;//路过空格
//printf("%c ",*p);
if(*p=='/"') //如果地址里有引号 " 那应该以下一个引号为结束
{ p++;
while(*p!='/"' && *p!='>' && *p!='/0')//得到路径
{ printf("%c",*p);
p++;
}
}
else //没有引号,以空格与>表示结束
{
while(*p!=' ' && *p!='>' && *p!='/0')//得到路径
{ printf("%c",*p);
p++;
}
}
printf("/n",*p);
}
}
}
}// if(*p=='@')
// printf("%c",*p);
}//for
fclose(fp);
return(0);
}