NAME
__pmParseHostSpec, __pmFreeHostSpec - uniform host specification parser
C SYNOPSIS
#include <pcp/pmapi.h>
int __pmParseHostSpec(const char *string, pmHostSpec **rsltp, int
*count, char **errmsg)
void __pmFreeHostSpec(pmHostSpec *rslt, int count)
cc ... -lpcp
DESCRIPTION
__pmParseHostSpec accepts a string specifying the location of a PCP
performance metric collector daemon. The syntax of the various formats
of this string is described in PCPIntro(1) where several examples are
also presented.
The syntax allows the initial pmcd(1) hostname to be optionally
followed by a list of port numbers, which will be tried in order when
connecting to pmcd on that host. The portlist is separated from the
hostname using a colon, and each port in the list is comma-separated.
In addition, one or more optional pmproxy(1) hosts can be specified
(currently, only one proxy host is supported by the PCP protocols).
These are separated from each other and from the pmcd component using
the @ character. These may also be followed by an optional port list,
using the same comma-separated syntax as before.
__pmParseHostSpec takes a null-terminated host specification string and
returns an array of pmHostSpec structures, where the array has count
entries.
These pmHostSpec structures that are returned via rsltp represent each
individual host in the specification string and has the following
declaration:
typedef struct {
char *name; /* hostname (always valid) */
int *ports; /* array of host port numbers */
int nports; /* number of ports in host port array */
} pmHostSpec;
__pmParseHostSpec returns 0 if the given string was successfully
parsed. In this case all the storage allocated by __pmParseHostSpec
can be released by calling __pmFreeHostSpec using the address returned
from __pmParseHostSpec via rsltp.
__pmParseHostSpec returns PM_ERR_GENERIC and a dynamically allocated
error message string in errmsg, if the given string does not parse, and
the user-supplied errmsg pointer is non-null. Be sure to free(3C) the
error message string in this situation.
In the case of an error, rsltp is undefined. In the case of success,
errmsg is undefined.
SEE ALSO
pmcd(1), pmproxy(1), pmchart(1), PMAPI(3) and pmNewContext(3).