BRL-CAD
sscanf.c File Reference
#include "common.h"
#include <ctype.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include "bu/log.h"
Include dependency graph for sscanf.c:

Go to the source code of this file.

Macros

#define LONG   0x00001 /* l: long or double */
 
#define LONGDBL   0x00002 /* L: long double */
 
#define SHORT   0x00004 /* h: short */
 
#define SUPPRESS   0x00008 /* *: suppress assignment */
 
#define POINTER   0x00010 /* p: void * (as hex) */
 
#define NOSKIP   0x00020 /* [ or c: do not skip blanks */
 
#define LONGLONG   0x00400 /* ll: long long (+ deprecated q: quad) */
 
#define INTMAXT   0x00800 /* j: intmax_t */
 
#define PTRDIFFT   0x01000 /* t: ptrdiff_t */
 
#define SIZET   0x02000 /* z: size_t */
 
#define SHORTSHORT   0x04000 /* hh: char */
 
#define UNSIGNED   0x08000 /* %[oupxX] conversions */
 
#define ALTERNATE   0x40000 /* # flag for alternate behavior */
 
#define SIGNOK   0x00040 /* +/- is (still) legal */
 
#define NDIGITS   0x00080 /* no digits detected */
 
#define PFXOK   0x00100 /* 0x prefix is (still) legal */
 
#define NZDIGITS   0x00200 /* no zero digits detected */
 
#define HAVESIGN   0x10000 /* sign detected */
 
#define HAVEWIDTH   0x20000
 
#define CT_CHAR   0 /* %c conversion */
 
#define CT_CCL   1 /* %[...] conversion */
 
#define CT_STRING   2 /* %s conversion */
 
#define CT_INT   3 /* %[dioupxX] conversion */
 
#define CT_FLOAT   4 /* %[efgEFG] conversion */
 
#define CT_VLS   5 /* %V and %#V conversion */
 
#define UPDATE_COUNTS
 
#define FREE_FORMAT_PART   bu_vls_free(&partFmt);
 
#define GET_FORMAT_PART   bu_vls_strcat(&partFmt, "%n");
 
#define EXIT_DUE_TO_INPUT_FAILURE
 
#define EXIT_DUE_TO_MATCH_FAILURE
 
#define EXIT_DUE_TO_MISC_ERROR
 
#define NUMERIC_CHAR_TO_INT(c)   (c - '0')
 
#define SSCANF_TYPE(type)
 
#define SSCANF_SIGNED_UNSIGNED(type)
 

Functions

int bu_vsscanf (const char *src, const char *fmt0, va_list ap)
 
int bu_sscanf (const char *src, const char *fmt,...)
 

Detailed Description

libbu implementations of vsscanf/sscanf() with extra format specifiers.

Custom sscanf and vsscanf.

Definition in file sscanf.c.

Macro Definition Documentation

#define LONG   0x00001 /* l: long or double */

Definition at line 56 of file sscanf.c.

Referenced by bu_vsscanf().

#define LONGDBL   0x00002 /* L: long double */

Definition at line 57 of file sscanf.c.

Referenced by bu_vsscanf().

#define SHORT   0x00004 /* h: short */

Definition at line 58 of file sscanf.c.

Referenced by bu_vsscanf().

#define SUPPRESS   0x00008 /* *: suppress assignment */

Definition at line 59 of file sscanf.c.

Referenced by bu_vsscanf().

#define POINTER   0x00010 /* p: void * (as hex) */

Definition at line 60 of file sscanf.c.

Referenced by bu_vsscanf().

#define NOSKIP   0x00020 /* [ or c: do not skip blanks */

Definition at line 61 of file sscanf.c.

Referenced by bu_vsscanf().

#define LONGLONG   0x00400 /* ll: long long (+ deprecated q: quad) */

Definition at line 62 of file sscanf.c.

Referenced by bu_vsscanf().

#define INTMAXT   0x00800 /* j: intmax_t */

Definition at line 63 of file sscanf.c.

Referenced by bu_vsscanf().

#define PTRDIFFT   0x01000 /* t: ptrdiff_t */

Definition at line 64 of file sscanf.c.

Referenced by bu_vls_vprintf(), bu_vsscanf(), and handle_format_part().

#define SIZET   0x02000 /* z: size_t */

Definition at line 65 of file sscanf.c.

Referenced by bu_vsscanf().

#define SHORTSHORT   0x04000 /* hh: char */

Definition at line 66 of file sscanf.c.

Referenced by bu_vsscanf().

#define UNSIGNED   0x08000 /* %[oupxX] conversions */

Definition at line 67 of file sscanf.c.

Referenced by bu_vsscanf().

#define ALTERNATE   0x40000 /* # flag for alternate behavior */

Definition at line 68 of file sscanf.c.

Referenced by bu_vsscanf().

#define SIGNOK   0x00040 /* +/- is (still) legal */

Definition at line 74 of file sscanf.c.

#define NDIGITS   0x00080 /* no digits detected */

Definition at line 75 of file sscanf.c.

#define PFXOK   0x00100 /* 0x prefix is (still) legal */

Definition at line 76 of file sscanf.c.

Referenced by bu_vsscanf().

#define NZDIGITS   0x00200 /* no zero digits detected */

Definition at line 77 of file sscanf.c.

#define HAVESIGN   0x10000 /* sign detected */

Definition at line 78 of file sscanf.c.

#define HAVEWIDTH   0x20000

Definition at line 79 of file sscanf.c.

Referenced by bu_vsscanf().

#define CT_CHAR   0 /* %c conversion */

Definition at line 84 of file sscanf.c.

Referenced by bu_vsscanf().

#define CT_CCL   1 /* %[...] conversion */

Definition at line 85 of file sscanf.c.

Referenced by bu_vsscanf().

#define CT_STRING   2 /* %s conversion */

Definition at line 86 of file sscanf.c.

Referenced by bu_vsscanf().

#define CT_INT   3 /* %[dioupxX] conversion */

Definition at line 87 of file sscanf.c.

Referenced by bu_vsscanf().

#define CT_FLOAT   4 /* %[efgEFG] conversion */

Definition at line 88 of file sscanf.c.

Referenced by bu_vsscanf().

#define CT_VLS   5 /* %V and %#V conversion */

Definition at line 89 of file sscanf.c.

Referenced by bu_vsscanf().

#define UPDATE_COUNTS
Value:
numCharsConsumed += partConsumed; \
numFieldsAssigned += partAssigned;

Referenced by bu_vsscanf().

#define FREE_FORMAT_PART   bu_vls_free(&partFmt);

Referenced by bu_vsscanf().

#define GET_FORMAT_PART   bu_vls_strcat(&partFmt, "%n");

Referenced by bu_vsscanf().

#define EXIT_DUE_TO_INPUT_FAILURE
Value:
if (numFieldsAssigned == 0) { \
return EOF; \
} \
return numFieldsAssigned;
if(share_geom)
Definition: nmg_mod.c:3829
#define FREE_FORMAT_PART

Referenced by bu_vsscanf().

#define EXIT_DUE_TO_MATCH_FAILURE
Value:
return numFieldsAssigned;
#define FREE_FORMAT_PART

Referenced by bu_vsscanf().

#define EXIT_DUE_TO_MISC_ERROR
Value:
return EOF;
#define FREE_FORMAT_PART

Referenced by bu_vsscanf().

#define NUMERIC_CHAR_TO_INT (   c)    (c - '0')

Referenced by bu_vsscanf().

#define SSCANF_TYPE (   type)
Value:
if (flags & SUPPRESS) { \
partAssigned = sscanf(&src[numCharsConsumed], bu_vls_addr(&partFmt), \
&partConsumed); \
} else { \
partAssigned = sscanf(&src[numCharsConsumed], bu_vls_addr(&partFmt), \
va_arg(ap, type), &partConsumed); \
}
#define SUPPRESS
Definition: sscanf.c:59
char * bu_vls_addr(const struct bu_vls *vp)
Definition: vls.c:111

Referenced by bu_vsscanf().

#define SSCANF_SIGNED_UNSIGNED (   type)
Value:
if (flags & UNSIGNED) { \
SSCANF_TYPE(unsigned type); \
} else { \
SSCANF_TYPE(type); \
}
#define UNSIGNED
Definition: sscanf.c:67
#define SSCANF_TYPE(type)

Referenced by bu_vsscanf().