5 void printErrCode (int err)
9 str = ngadmin_errorStr(err);
12 printf("unknown status code (%i)\n", err);
13 else if (err != ERR_OK)
18 void displaySwitchTab (const struct swi_attr *sa, int nb)
23 printf("no switch found\n");
27 printf("Num\tMac\t\t\tProduct\t\t\tName\t\t\t\t\tIP\t\tPorts\tFirmware\n");
29 for (i = 0; i < nb; i++)
30 printf("% 3d\t%-17s\t%-16.16s\t%-32.32s\t%-15s\t% 5d\t%s\n", i, ether_ntoa(&sa[i].mac), sa[i].product, sa[i].name, inet_ntoa(sa[i].nc.ip), sa[i].ports, sa[i].firmware);
32 printf("\nfound %i switch(es)\n", nb);
36 int explode (const char *commande, char** tab, int maximum)
38 const char *start, *end;
42 for (end = commande; ; n++) {
43 for (start = end; *start == ' ' && *start != 0; start++);
44 for (end = start; (*end != ' ' || n >= maximum - 1 ) && *end != 0; end++);
50 tab[n] = malloc(sizeof(char) * (len + 1));
51 memcpy(tab[n], start, len);