/var/lib/pcp/testsuite/src/parsehostspec.c is in pcp-testsuite 4.0.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | #include <stdio.h>
#include <pcp/pmapi.h>
#include "libpcp.h"
int
main(int argc, char **argv)
{
char *msg, buffer[512];
pmHostSpec *hosts;
int count, sts, i, j;
if (argc != 2) {
fprintf(stderr, "Usage: parsehostspec spec\n");
exit(1);
}
printf("pmParseHostSpec(\"%s\", ...)\n", argv[1]);
sts = __pmParseHostSpec(argv[1], &hosts, &count, &msg);
if (sts < 0) {
if (sts == PM_ERR_GENERIC)
printf("pmParseHostSpec error:\n%s\n", msg);
else
printf("Error: %s\n", pmErrStr(sts));
exit(1);
}
for (i = 0; i < count; i++) {
printf("host[%d]: \"%s\"", i, hosts[i].name);
if (hosts[i].nports == 1)
printf(" port:");
else if (hosts[i].nports > 1)
printf(" ports:");
for (j = 0; j < hosts[i].nports; j++)
printf(" %d", hosts[i].ports[j]);
putchar('\n');
}
sts = __pmUnparseHostSpec(hosts, count, buffer, sizeof(buffer));
if (sts < 0) {
printf("pmUnparseHostSpec: %s\n", pmErrStr(sts));
exit(1);
}
printf("pmUnparseHostSpec(\"%s\") -> \"%s\"\n", argv[1], buffer);
__pmFreeHostSpec(hosts, count);
exit(0);
}
|