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

Function ShowCmd

tools/ngctl/show.c:62–137  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

60};
61
62static int
63ShowCmd(int ac, char **av)
64{
65 char *path;
66 struct ng_mesg *resp;
67 struct hooklist *hlist;
68 struct nodeinfo *ninfo;
69 int ch, no_hooks = 0;
70
71 /* Get options */
72 optind = 1;
73 while ((ch = getopt(ac, av, "n")) != -1) {
74 switch (ch) {
75 case 'n':
76 no_hooks = 1;
77 break;
78 case '?':
79 default:
80 return (CMDRTN_USAGE);
81 break;
82 }
83 }
84 ac -= optind;
85 av += optind;
86
87 /* Get arguments */
88 switch (ac) {
89 case 1:
90 path = av[0];
91 break;
92 default:
93 return (CMDRTN_USAGE);
94 }
95
96 /* Get node info and hook list */
97 if (NgSendMsg(csock, path, NGM_GENERIC_COOKIE,
98 NGM_LISTHOOKS, NULL, 0) < 0) {
99 warn("send msg");
100 return (CMDRTN_ERROR);
101 }
102 if (NgAllocRecvMsg(csock, &resp, NULL) < 0) {
103 warn("recv msg");
104 return (CMDRTN_ERROR);
105 }
106
107 /* Show node information */
108 hlist = (struct hooklist *) resp->data;
109 ninfo = &hlist->nodeinfo;
110 if (!*ninfo->name)
111 snprintf(ninfo->name, sizeof(ninfo->name), "%s", UNNAMED);
112 printf(" Name: %-15s Type: %-15s ID: %08x Num hooks: %d\n",
113 ninfo->name, ninfo->type, ninfo->id, ninfo->hooks);
114 if (!no_hooks && ninfo->hooks > 0) {
115 u_int k;
116
117 printf(FMT, "Local hook", "Peer name",
118 "Peer type", "Peer ID", "Peer hook");
119 printf(FMT, "----------", "---------",

Callers

nothing calls this directly

Calls 6

NgSendMsgFunction · 0.85
NgAllocRecvMsgFunction · 0.85
snprintfFunction · 0.85
getoptFunction · 0.50
printfFunction · 0.50
freeFunction · 0.50

Tested by

no test coverage detected