/*
* Utility functions for memory management. Very primitive.
* ema@csn.es
*/
static char *pos;
static int maxsize;
#define NULL (void *)0
void memgets_init(memarea, size)
char *memarea;
int size;
{
pos = memarea;
maxsize = size;
}
char *memgets(output, maxitems)
char *output;
int maxitems;
{
char *retval = output;
while (maxitems-- && maxsize-- >=0 && (*output++=*pos++) != '\n' )
;
*output = '\0';
if (maxsize >= 0)
return retval;
else
return NULL;
}
|