2 * Exercise __pmSetClientId()
4 * Copyright (c) 2009 Ken McDonell. All Rights Reserved.
11 #define TAG "QA-clientid "
14 main(int argc
, char *argv
[])
22 static char *usage
= "[-l] [-D debugopts]";
24 __pmSetProgname(argv
[0]);
26 while ((c
= getopt(argc
, argv
, "D:l")) != EOF
) {
30 case 'D': /* debug flag */
31 sts
= __pmParseDebug(optarg
);
33 fprintf(stderr
, "%s: unrecognized debug flag specification (%s)\n",
42 case 'l': /* linger when done */
54 printf("Usage: %s %s\n", pmProgname
, usage
);
58 fprintf(stderr
, "Error expected ...\n");
59 if ((sts
= __pmSetClientId("no context yet, bozo")) < 0) {
60 fprintf(stderr
, "__pmSetClientId(...): %s\n",
64 if ((ctx
= pmNewContext(PM_CONTEXT_HOST
, "localhost")) < 0) {
65 fprintf(stderr
, "pmNewContext(..., \"localhost\"): %s\n",
70 for (a
= optind
; a
< argc
; a
++) {
72 cp
= (char *)malloc(strlen(argv
[a
])+strlen(TAG
)+1);
75 if ((sts
= __pmSetClientId(cp
)) < 0) {
76 fprintf(stderr
, "__pmSetClientId(%s): %s\n",
80 sts
= system("pminfo -f pmcd.client.whoami");
82 fprintf(stderr
, "Warning: pminfo command: exit status %d\n", sts
);