mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-20 23:51:29 -07:00
Move fgetline out into misc.c.
I'm about to want to use it outside the GTK front end.
This commit is contained in:
19
misc.c
19
misc.c
@ -169,6 +169,25 @@ unsigned char *hex2bin(const char *in, int outlen)
|
||||
return ret;
|
||||
}
|
||||
|
||||
char *fgetline(FILE *fp)
|
||||
{
|
||||
char *ret = snewn(512, char);
|
||||
int size = 512, len = 0;
|
||||
while (fgets(ret + len, size - len, fp)) {
|
||||
len += strlen(ret + len);
|
||||
if (ret[len-1] == '\n')
|
||||
break; /* got a newline, we're done */
|
||||
size = len + 512;
|
||||
ret = sresize(ret, size, char);
|
||||
}
|
||||
if (len == 0) { /* first fgets returned NULL */
|
||||
sfree(ret);
|
||||
return NULL;
|
||||
}
|
||||
ret[len] = '\0';
|
||||
return ret;
|
||||
}
|
||||
|
||||
void game_mkhighlight_specific(frontend *fe, float *ret,
|
||||
int background, int highlight, int lowlight)
|
||||
{
|
||||
|
Reference in New Issue
Block a user