SFDISC(3)

NAME
sfdisc - some common sfio disciplines

SYNOPSIS
    #include <sfdisc.h>
    typedef int (*Sf_key_lookup_t)(void* handle, const char* name, const char* op, int cc, char** str_ptr, long* num_ptr);
    typedef char* (*Sf_key_convert_t)(void* handle, const char* name, const char* op, int cc, char* str_value, long num_value);
    int    sfkeyprintf(Sfio_t* sp, void* handle, const char* format, Sf_key_lookup_t lookup, Sf_key_convert_t convert);
    int    sflowio(Sfio_t* sp);

DESCRIPTION
provides support for sfio(3) printf formatting. Rather than getting format values from the next argument, the style gets the format value by doing a lookup on Output is written to the sfio(3) stream sp under control of the format string format. handle is a user supplied pointer that is passed untouched to the user supplied routines lookup and convert.

lookup determines the value for name with optional information op and places the value either in *str_ptr or *num_ptr. cc is the conversion character (e.g., etc.) and may provide a hint to the name lookup.

convert is called when an format unknown conversion character cc is encountered. name is the keyword name from the format specification, op is the optional operation string, if not specified, str_value is its string value, if it is not a string, and num_value is the numeric value if str_value == 0. convert returns a pointer to the converted string, on error.

supplies two operations:

:case:pattern1:format1:...:patternn:formatn
    matches the string value of against pattern1 through patternn. using strmatch(3). formati corresponding to the first matching pattern patterni from the left is pushed back on to the format input. If nothing matches then nothing is output to sp. Any delimiter may appear after

:edit:old:new:flags[:...]
    Performs an ed(1)-style substitution on the string value of keyword. Multiple sets of old,new,flags may be specified; they are applied in order from left to right. In addition to the flags supported by ed(3) are that converts the substituted value to lower case and that converts the substituted value to upper case. Any delimiter may appear after

pushes an sfio(3) discipline onto the stream sp that makes the stream interruptable. Read or write operations on sp fail with errno set to when interrupted.

SEE ALSO
sfio(3)