MCPcopy Create free account
hub / github.com/F-Stack/f-stack / StatusCmd

Function StatusCmd

tools/ngctl/status.c:59–100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57};
58
59static int
60StatusCmd(int ac, char **av)
61{
62 u_char sbuf[sizeof(struct ng_mesg) + NG_TEXTRESPONSE];
63 struct ng_mesg *const resp = (struct ng_mesg *) sbuf;
64 char *const status = (char *) resp->data;
65 char *path;
66 int nostat = 0;
67
68 /* Get arguments */
69 switch (ac) {
70 case 2:
71 path = av[1];
72 break;
73 default:
74 return (CMDRTN_USAGE);
75 }
76
77 /* Get node status summary */
78 if (NgSendMsg(csock, path, NGM_GENERIC_COOKIE,
79 NGM_TEXT_STATUS, NULL, 0) < 0) {
80 switch (errno) {
81 case EINVAL:
82 nostat = 1;
83 break;
84 default:
85 warn("send msg");
86 return (CMDRTN_ERROR);
87 }
88 } else {
89 if (NgRecvMsg(csock, resp, sizeof(sbuf), NULL) < 0
90 || (resp->header.flags & NGF_RESP) == 0)
91 nostat = 1;
92 }
93
94 /* Show it */
95 if (nostat)
96 printf("No status available for \"%s\"\n", path);
97 else
98 printf("Status for \"%s\":\n%s\n", path, status);
99 return (CMDRTN_OK);
100}
101

Callers

nothing calls this directly

Calls 3

NgSendMsgFunction · 0.85
NgRecvMsgFunction · 0.85
printfFunction · 0.50

Tested by

no test coverage detected