Parse and print formatted strings specifying modes

Name

ggiParseMode, ggiPrintMode, ggiSNPrintMode, ggiFPrintMode : Parse and print formatted strings specifying modes

Synopsis

#include <ggi/ggi.h>


int ggiParseMode(const char *s, ggi_mode *m);

#define ggiPrintMode(m) ggiFPrintMode(stdout,(m))

int ggiSNPrintMode(char *s, size_t n, const ggi_mode *m);

int ggiFPrintMode(FILE *s, const ggi_mode *m);

Description

ggiParseMode parses a string into a ggi_mode(3).

The ggi*PrintMode functions print all the members of ggi_mode(3) in a human-readable form. ggiSNPrintMode outputs to a preallocated string buffer, ggiFPrintMode outputs to a stdio FILE, and ggiPrintMode outputs to standard output. ggiSNPrintMode makes sure that no more than n chars are written, including the trailing 0. These functions correspond to snprintf(3), fprintf(3), printf(3).

The format of the string used by these functions is exactly the same as the one used in the GGI_DEFMODE environment variable described in libggi(7).

The string returned by both ggiSNPrintMode and ggiFPrintMode does not contain a trailing newline.

Return value

ggiParseMode returns:

0

on success, i.e. the string was correct. However, errors involving GT_*, position information, or mismatched brackets do not make it fail; these errors are simply ignored.

<0

if there is text that can not be parsed. This text is printed to stderr. All parameters parsed so far are written into m.

So m contains all parameters that have been successfully parsed. For most applications there will be no need for testing ggiParseMode for failure.

ggiSNPrintMode returns the total number of chars that would have been written (excluding the trailing 0) if the buffer was large enough.

See Also