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

Function DotCmd

tools/ngctl/dot.c:65–222  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

63};
64
65static int
66DotCmd(int ac, char **av)
67{
68 struct ng_mesg *nlresp;
69 struct namelist *nlist;
70 FILE *f = stdout;
71 int ch;
72 int compact = 0;
73 u_int i;
74
75 /* Get options */
76 optind = 1;
77 while ((ch = getopt(ac, av, "c")) != -1) {
78 switch (ch) {
79 case 'c':
80 compact = 1;
81 break;
82 case '?':
83 default:
84 return (CMDRTN_USAGE);
85 break;
86 }
87 }
88 ac -= optind;
89 av += optind;
90
91 /* Get arguments */
92 switch (ac) {
93 case 1:
94 f = fopen(av[0], "w");
95 if (f == NULL) {
96 warn("Could not open %s for writing", av[0]);
97 return (CMDRTN_ERROR);
98 }
99 case 0:
100 break;
101 default:
102 if (f != stdout)
103 (void)fclose(f);
104 return (CMDRTN_USAGE);
105 }
106
107 /* Get list of nodes */
108 if (NgSendMsg(csock, ".", NGM_GENERIC_COOKIE, NGM_LISTNODES, NULL,
109 0) < 0) {
110 warn("send listnodes msg");
111 goto error;
112 }
113 if (NgAllocRecvMsg(csock, &nlresp, NULL) < 0) {
114 warn("recv listnodes msg");
115 goto error;
116 }
117
118 nlist = (struct namelist *)nlresp->data;
119 if (compact) {
120 fprintf(f, "digraph netgraph {\n");
121 fprintf(f, "\tedge [ dir = \"none\", fontsize = 10 ];\n");
122 } else {

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected