197 unsigned long *ULongPtr;
200 if(!buffer)
return(EOF);
203 if((value=(
char *)malloc((1+MaxValLength)*
sizeof(
char)))==
NULL)
207 va_start(ap, format);
221 while(*FormStart && *FormStart !=
'%') FormStart++;
222 if(!(*FormStart))
break;
226 while(*stop && *stop !=
'%') stop++;
229 for(i=0; FormStart != stop; i++)
230 form[i] = *(FormStart++);
235 while(*ptr ==
'\0' || *ptr ==
' ' || *ptr ==
'\t') ptr--;
236 type = toupper(*ptr);
239 if((*(ptr-1) ==
'l') || (*(ptr-1) ==
'L'))
250 for(ptr = form+1; *ptr && isdigit(*ptr); ptr++)
253 width += (*ptr) -
'0';
260 if(width > MaxValLength)
262 if((value = (
char *)realloc(value, (width+1) *
sizeof(
char)))
269 MaxValLength = width;
276 stop = BuffStart + width;
277 for(i=0; *BuffStart && *BuffStart !=
'\n' && BuffStart != stop; i++)
278 value[i] = *(BuffStart++);
287 DblPtr = va_arg(ap,
double *);
288 if(sscanf(value,
"%lf", DblPtr) == (-1))
289 *DblPtr = (double)0.0;
293 FloatPtr = va_arg(ap,
float *);
294 if(sscanf(value,
"%f", FloatPtr) == (-1))
295 *FloatPtr = (float)0.0;
302 LongPtr = va_arg(ap,
long *);
303 if(sscanf(value,
"%ld", LongPtr) == (-1))
308 IntPtr = va_arg(ap,
int *);
309 if(sscanf(value,
"%d", IntPtr) == (-1))
316 ULongPtr = va_arg(ap,
unsigned long *);
317 if(sscanf(value,
"%lu", ULongPtr) == (-1))
322 UPtr = va_arg(ap,
unsigned *);
323 if(sscanf(value,
"%u", UPtr) == (-1))
328 ptr = va_arg(ap,
char *);
331 *(value + width) =
'\0';
332 strncpy(ptr, value, width+1);
337 if(strlen(ptr) < width)
blPadterm(ptr, width);
341 for(i=0; i<width; i++)
343 *(ptr + width) =
'\0';
347 *(va_arg(ap,
char *)) = (value[0] ? value[0]:
' ');
357 if(type !=
'X') NArg++;
368 if(buffer[0] ==
'\0' || buffer[0] ==
'\n')
return(EOF);
void blPadterm(char *string, int length)
int fsscanf(char *buffer, char *format,...)
Header file for general purpose routines.
System-type variable type definitions.