libexplain  1.4.D001
Data Structures | Defines | Typedefs | Functions
libexplain/printf_format.h File Reference
#include <libexplain/ac/stddef.h>
#include <libexplain/string_buffer.h>
#include <libexplain/ac/stdarg.h>

Go to the source code of this file.

Data Structures

struct  explain_printf_format_t
struct  explain_printf_format_list_t

Defines

#define FLAG_ZERO   (1 << 0)
#define FLAG_SPACE   (1 << 1)
#define FLAG_HASH   (1 << 2)
#define FLAG_PLUS   (1 << 3)
#define FLAG_MINUS   (1 << 4)
#define FLAG_THOUSANDS   (1 << 5)
#define FLAG_I18N   (1 << 6)

Typedefs

typedef struct
explain_printf_format_t 
explain_printf_format_t
typedef struct
explain_printf_format_list_t 
explain_printf_format_list_t

Functions

void explain_printf_format_list_constructor (explain_printf_format_list_t *lp)
void explain_printf_format_list_destructor (explain_printf_format_list_t *lp)
void explain_printf_format_list_clear (explain_printf_format_list_t *lp)
int explain_printf_format_list_append (explain_printf_format_list_t *lp, const explain_printf_format_t *datum)
void explain_printf_format_list_sort (explain_printf_format_list_t *lp)
size_t explain_printf_format (const char *text, explain_printf_format_list_t *result)
void explain_printf_format_representation (explain_string_buffer_t *sb, const char *format, va_list ap)

Define Documentation

#define FLAG_HASH   (1 << 2)

Definition at line 27 of file printf_format.h.

#define FLAG_I18N   (1 << 6)

Definition at line 31 of file printf_format.h.

#define FLAG_MINUS   (1 << 4)

Definition at line 29 of file printf_format.h.

#define FLAG_PLUS   (1 << 3)

Definition at line 28 of file printf_format.h.

#define FLAG_SPACE   (1 << 1)

Definition at line 26 of file printf_format.h.

#define FLAG_THOUSANDS   (1 << 5)

Definition at line 30 of file printf_format.h.

#define FLAG_ZERO   (1 << 0)

Definition at line 25 of file printf_format.h.


Typedef Documentation

Definition at line 44 of file printf_format.h.

Definition at line 33 of file printf_format.h.


Function Documentation

size_t explain_printf_format ( const char *  text,
explain_printf_format_list_t result 
)

The explain_printf_format function may be used to parse an argument format, and store the types of the arguments. It understands positional arguments, too.

Parameters:
textThe text (format specification) to be parsed.
resultWhere to place the discovered format specifiers. (Will be cleared first, and cleared again if there are errors.)
Returns:
0 if there were no errors, >0 if something was odd (number indicates position in string).

The explain_printf_format_list_append function is used to add another formaat specifier to the list.

Parameters:
lpThe list to operate on.
datumThe additional format spec.
Returns:
0 on success, -1 if malloc() fails.

Definition at line 51 of file list.c.

The explain_printf_format_list_clear function is used to discard the contents of a list.

Parameters:
lpThe list to operate on.

Definition at line 44 of file list.c.

The explain_printf_format_list_constructor function is used to prepare a list for use. Failure to call it will cause segfaults.

Parameters:
lpThe list to operate on.

Definition at line 26 of file list.c.

The explain_printf_format_list_destructor function is used to release resources held by the list. Failure to call it will cause memory leaks.

Parameters:
lpThe list to operate on.

Definition at line 34 of file list.c.

The explain_printf_format_list_sort function is used to sort the format specifiers in the list, into ascending order of indexes. This is how you figure out the order and types of the remaining arguments.

Parameters:
lpThe list to operate on.

Definition at line 88 of file list.c.

void explain_printf_format_representation ( explain_string_buffer_t sb,
const char *  format,
va_list  ap 
)

The explain_print_format_representation function is used to parse a format string, and the print representations of all the arguments. This is used to print system call representations. The format string has already been printed.

Parameters:
sbWhen to print the representation
formatThe format string describing the rest of the arguments.
apthe rest of the arguments.

Definition at line 40 of file representation.c.