1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
|
'\"macro stdmacro
.\"
.\" Copyright (c) 2007 Aconex, Inc. All Rights Reserved.
.\"
.\" This program is free software; you can redistribute it and/or modify it
.\" under the terms of the GNU General Public License as published by the
.\" Free Software Foundation; either version 2 of the License, or (at your
.\" option) any later version.
.\"
.\" This program is distributed in the hope that it will be useful, but
.\" WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
.\" or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
.\" for more details.
.\"
.\"
.TH PMPARSEHOSTSPEC 3 "Aconex" "Performance Co-Pilot"
.SH NAME
\f3__pmParseHostSpec\f1,
\f3__pmFreeHostSpec\f1 \- uniform host specification parser
.SH "C SYNOPSIS"
.ft 3
#include <pcp/pmapi.h>
.sp
int __pmParseHostSpec(const char *string, pmHostSpec **rsltp, int *count, char **errmsg)
.sp
void __pmFreeHostSpec(pmHostSpec *rslt, int count)
.sp
cc ... \-lpcp
.ft 1
.SH DESCRIPTION
.B __pmParseHostSpec
accepts a
.B string
specifying the location of a PCP performance metric collector daemon.
The syntax of the various formats of this
.B string
is described in
.BR PCPIntro (1)
where several examples are also presented.
.PP
The syntax allows the initial
.BR pmcd (1)
hostname to be optionally followed by a list of port numbers,
which will be tried in order when connecting to
.B pmcd
on that host.
The portlist is separated from the hostname using a colon, and
each port in the list is comma-separated.
.PP
In addition, one or more optional
.BR 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
.B pmcd
component using the @ character.
These may also be followed by an optional port list, using the
same comma-separated syntax as before.
.PP
.B __pmParseHostSpec
takes a null-terminated host specification
.B string
and returns an array of
.B pmHostSpec
structures, where the array has
.B count
entries.
.PP
These
.B pmHostSpec
structures that are returned via
.B rsltp
represent each individual host in the specification
.B string
and has the following
declaration:
.PP
.nf
.ft CW
typedef struct {
char *name; /* hostname (always valid) */
int *ports; /* array of host port numbers */
int nports; /* number of ports in host port array */
} pmHostSpec;
.fi
.PP
.B __pmParseHostSpec
returns 0 if the given
.B string
was successfully parsed. In this case all the storage allocated by
.B __pmParseHostSpec
can be released by calling
.B __pmFreeHostSpec
using the address returned from
.B __pmParseHostSpec
via
.BR rsltp .
.P
.B __pmParseHostSpec
returns
.B PM_ERR_GENERIC
and a dynamically allocated error message string in
.BR errmsg ,
if the given
.B string
does not parse, and the user-supplied
.B errmsg
pointer is non-null.
Be sure to
.BR free (3C)
the error message string in this situation.
.PP
In the case of an error,
.B rsltp
is undefined.
In the case of success,
.B errmsg
is undefined.
.SH SEE ALSO
.BR pmcd (1),
.BR pmproxy (1),
.BR pmchart (1),
.BR PMAPI (3)
and
.BR pmNewContext (3).
|