/var/lib/pcp/testsuite/src/mergelabels.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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | /*
* Copyright (c) 2016-2017 Red Hat.
*
* Test helper program for exercising pmMergeLabels(3).
*/
#include <ctype.h>
#include <assert.h>
#include <pcp/pmapi.h>
int
main(int argc, char **argv)
{
int c;
int sts;
int nsets;
int errflag = 0;
char **sets, result[PM_MAXLABELJSONLEN];
static char *usage = "labels [[labels] ...]";
pmSetProgname(argv[0]);
while ((c = getopt(argc, argv, "D:?")) != EOF) {
switch (c) {
case 'D': /* debug flag */
if ((sts = pmSetDebug(optarg)) < 0) {
fprintf(stderr, "%s: unrecognized debug flag specification (%s)\n",
pmGetProgname(), optarg);
errflag++;
}
break;
case '?':
default:
errflag++;
break;
}
}
nsets = argc - optind;
if (errflag || nsets < 1) {
printf("Usage: %s %s\n", pmGetProgname(), usage);
exit(1);
}
if ((sets = calloc(nsets, sizeof(char *))) == NULL) {
perror("calloc");
exit(1);
}
for (c = 0; c < nsets; c++)
sets[c] = argv[optind++];
/* iterate over remaining arguments (labels) and build merge set */
if ((sts = pmMergeLabels(sets, nsets, result, sizeof(result))) < 0) {
fprintf(stderr, "pmMergeLabels: %s\n", pmErrStr(sts));
exit(1);
}
puts(result);
exit(0);
}
|