Main Page | Data Structures | File List | Globals

libgu/gu_sscanf.c File Reference

safe sscanf() More...

#include "before_system.h"
#include <ctype.h>
#include <string.h>
#include "gu.h"

Defines

#define MAX_ROLLBACK   10

Functions

void gu_sscanf_checkpoint (void)
void gu_sscanf_rollback (void)
int gu_sscanf (const char *input, const char *format,...)
 safe sscanf()


Detailed Description

safe sscanf()

This module constains a limited version of sscanf() which allows the maximum width of string arguments to be specified as an additional argument. It also defines additional formats such as z which reads a string which extends to the end of the input string, and S which reads a word and allocates storage for it.


Function Documentation

int gu_sscanf const char *  input,
const char *  format,
... 
 

safe sscanf()

This function is similiar to sscanf(). It has additional format specifiers which allocate memory and read quoted strings. Since it is meant to read PPR configuration files and queue files, it does out of its way not to heed the current locale.

It implements the following formats:

d
read an int. The argument should be a pointer to an int.

ld
read a long int. The argument should be a pointer to a long int.

hd
read a short int. The argument should be a pointer to a short int.

u
read an unsigned int

f
read a floating point number

s
Read characters up to the next whitespace. The argument should be a pointer to a char array with enough space to hold the string and the terminating NULL. To prevent overruns, the size of the array may be specified by a decimal number between the and the s or by a #. If the length of the array is specified with a # then the actuall length is read from gu_sscanf()'s next argument (the one before the pointer to the char array).

S
Read characters up to the next whitespace, allocate memory, and store them in the allocated memory. The argument should be a pointer to a char pointer which will be set to the address of the allocated memory.

z
Read characters up to the end of the string. The argument should be a char array. To prevent overruns, the size of the char array may be specified in the same manner as for the s format.

Z
Read characters up to the end of the string, allocate storeage for them, and copy them into that storage. The argument should be a pointer to a pointer to a char array.

Q
Read a quoted string and allocate storate for it.

A
If there is a quoted string, read to the closing quote. Otherwise, read to the end of the line. This is used for reading values which must be quoted if they have leading or trailing spaces but needn't if they just have internal spaces.

t
Get a time_t.

n
Store the number of characters read so far.


Generated on Fri Feb 20 15:17:52 2004 for PPR Libraries by doxygen 1.3.5