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

Function ConfigCmd

tools/ngctl/config.c:60–110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 4

strcatFunction · 0.85
NgSendMsgFunction · 0.85
NgRecvMsgFunction · 0.85
printfFunction · 0.50

Tested by

no test coverage detected