Category : Recently Uploaded Files
Archive   : DOSUIT07.ZIP
Filename : FORM.C

 
Output of file : FORM.C contained in archive : DOSUIT07.ZIP

/* form.c - This is a re-written version for those who don't have
* the Zortech one.
*/
#include
#include
#include
#include

/*
* Re-usable buffer to contain the output
*/
#define FORMBUFSIZE 1024 /* size of buffer */
#define FORMMIN 256 /* minimum size needed */
static char formbuf[FORMBUFSIZE];
static char *formptr = formbuf;

char *form(const char *format,...)
{
char *start;
int len;
va_list args;

start = formptr;
if(start >= formbuf + FORMBUFSIZE - FORMMIN) /* ensure enough chars */
start = formbuf;
va_start(args,format);
len = vsprintf(start,format,args);
va_end(args);
assert(start + len < formbuf + FORMBUFSIZE); /* wrote past end of buffer */
formptr = start + len + 1;
return start;
}