diff options
Diffstat (limited to 'shared.h')
-rw-r--r-- | shared.h | 23 |
1 files changed, 22 insertions, 1 deletions
@@ -1 +1,22 @@ -char *site = "https://kaa.neocities.org/"; +static char * +storeline(FILE *in, int *end, int *len, int guess) +{ + static char *line; + line = calloc(guess, sizeof(char)); + int i = 0, buflen = guess; + char ch; + while ((ch = fgetc(in)) != EOF && ch != '\n') { + if (i == buflen - 1) { + buflen += guess; + line = realloc(line, buflen * sizeof(char)); + } + line[i] = ch; + ++i; + } + line[i] = '\0'; + *len = i; + if (ch == EOF) + *end = 1; + + return line; +} |