setlabel(3C) 04 Jun 1992 (C Programming Language Utilities) setlabel(3C)
NAME
setlabel - define the label for pfmt() and lfmt().
SYNOPSIS
#include <pfmt.h>
int setlabel(const char *label);
DESCRIPTION
The routine setlabel() defines the label for messages produced in
standard format by subsequent calls to pfmt() and lfmt().
label is a character string no more than 25 characters in length.
No label is defined before setlabel() is called. A NULL pointer or an
empty string passed as the argument will reset the definition of the
label.
The value of the environment variable LC_ALL_LABELS affects the way
the parameter label is interpreted by setlabel(). If LC_ALL_LABELS has
a value of `1', the value of label is copied verbatim for use as the
new message label. If LC_ALL_LABELS is not defined or has a value
other than `1', the value of label is copied, but any leading string
followed by a colon `:' is removed from the message label.
LC_ALL_LABELS also affects the printing of the message severity by
pfmt() and lfmt().
RETURN VALUE
setlabel() returns 0 in case of success, non-zero otherwise.
EXAMPLE
The following code (without a previous call to setlabel()):
pfmt(stderr, MM_ERROR, "test:2:Cannot open file\n");
setlabel("UX:test");
pfmt(stderr, MM_ERROR, "test:2:Cannot open file\n");
will produce the following output if LC_ALL_LABELS is set to 1:
ERROR: Cannot open file
UX:test: ERROR: Cannot open file
or the following output if LC_ALL_LABELS is not set to 1:
Cannot open file
test: Cannot open file
USAGE
The label should be set once at the beginning of a utility and remain
constant.
getopt() has been modified to report errors using the standard message
format. if setlabel() is called before getopt(), getopt() will use
that label. Otherwise, getopt() will use the name of the utility.
Page 1 Reliant UNIX 5.44 6, 194
setlabel(3C) 04 Jun 1992 (C Programming Language Utilities) setlabel(3C)
SEE ALSO
getopt(3C), lfmt(3C), pfmt(3C).
Page 2 Reliant UNIX 5.44 6, 194