| 63 | }; |
| 64 | |
| 65 | static int |
| 66 | DotCmd(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 { |
nothing calls this directly
no test coverage detected