dbstrbuild

Description

Build a printable string from text containing placeholders for variables.

Syntax

int dbstrbuild(dbproc, charbuf, bufsize,
             text [, formats [, arg] ... ])
 
DBPROCESS     *dbproc;
char                    *charbuf;
int                         bufsize;
char                    *text;
char                    *formats;
???                    args...;

Parameters

dbproc

A pointer to the DBPROCESS that provides the connection for a particular front-end/server process. It contains all the information that DB-Library uses to manage communications and data between the front end and the server. dbstrbuild uses it only as a parameter to the programmer-installed error handler (if one exists) when an error occurs.

charbuf

A pointer to the destination buffer that will contain the message built by dbstrbuild.

bufsize

The size of the destination buffer, in bytes. This size must include a single byte for the results string’s null terminator.

text

A pointer to a null-terminated character string that contains message text and placeholders for variables. Placeholders consist of a percent sign, an integer, and an exclamation point. The integer indicates which argument to substitute for a particular placeholder. Arguments and format strings are numbered from left to right. Argument 1 is substituted for placeholder “%1!”, and so on.

formats

A pointer to a null-terminated string containing one sprintf-style format specifier for each place holder in the text string.

args

The values that will be converted according to the contents of the formats string. There must be one argument for each format in the formats string. The first value will correspond to the “%1!” parameter, the second the “%2!”, and so forth. The results are undefined if there are insufficient arguments for the format. If the format is exhausted while arguments remain, the excess arguments are simply ignored.

Returns

On success, the length of the resulting message string, not including the null terminator; on failure, a negative integer.

Usage

See also

dbconvert, dbdatename, dbdatepart