Revision: | 1.1 |
Committed: | Tue Mar 4 18:07:42 2003 UTC (21 years, 2 months ago) by pajs |
Content type: | text/plain |
Branch: | MAIN |
Log Message: | Useful tools, currently only one function. Function takes a file pointer and will read threw it until it hits a passed string. It will return that line. |
# | User | Rev | Content |
---|---|---|---|
1 | pajs | 1.1 | #include <stdio.h> |
2 | #include <string.h> | ||
3 | |||
4 | char *f_read_line(FILE *f, const char *string){ | ||
5 | /* Max line length. 8k should be more than enough */ | ||
6 | static char line[8192]; | ||
7 | |||
8 | while((fgets(line, sizeof(line), f))==NULL){ | ||
9 | |||
10 | if(strncmp(string, line, strlen(string))==0){ | ||
11 | return line; | ||
12 | } | ||
13 | } | ||
14 | |||
15 | return NULL; | ||
16 | } |