printf("%s left.\n", node->name);
}
+static meshlink_node_t **nodes;
+static size_t nnodes;
+
static void parse_command(meshlink_handle_t *mesh, char *buf) {
char *arg = strchr(buf, ' ');
if(arg)
printf("Node '%s' blacklisted.\n", arg);
} else if(!strcasecmp(buf, "who")) {
if(!arg) {
- meshlink_node_t *nodes[100];
- size_t n = meshlink_get_all_nodes(mesh, nodes, 100);
- if(!n) {
+ nodes = meshlink_get_all_nodes(mesh, nodes, &nnodes);
+ if(!nnodes) {
fprintf(stderr, "No nodes known!\n");
} else {
printf("Known nodes:");
- for(int i = 0; i < n && i < 100; i++)
+ for(int i = 0; i < nnodes; i++)
printf(" %s", nodes[i]->name);
- if(n > 100)
- printf(" (and %zu more)", n - 100);
printf("\n");
}
} else {
printf("%s left.\n", node->name);
}
+static meshlink::node **nodes;
+static size_t nnodes;
+
static void parse_command(meshlink::mesh *mesh, char *buf) {
char *arg = strchr(buf, ' ');
if(arg)
printf("Node '%s' blacklisted.\n", arg);
} else if(!strcasecmp(buf, "who")) {
if(!arg) {
- meshlink::node *nodes[100];
- size_t n = mesh->get_all_nodes(nodes, 100);
- if(!n) {
+ nodes = mesh->get_all_nodes(nodes, &nnodes);
+ if(!nnodes) {
fprintf(stderr, "No nodes known!\n");
} else {
printf("Known nodes:");
- for(size_t i = 0; i < n && i < 100; i++)
+ for(size_t i = 0; i < nnodes; i++)
printf(" %s", nodes[i]->name);
- if(n > 100)
- printf(" (and %zu more)", n - 100);
printf("\n");
}
} else {
* @return The number of known nodes, or -1 in case of an error.
* This can be larger than nmemb, in which case not all nodes were stored in the nodes array.
*/
- ssize_t get_all_nodes(node **nodes, size_t nmemb) {
- return meshlink_get_all_nodes(this, (meshlink_node_t **)nodes, nmemb);
+ node **get_all_nodes(node **nodes, size_t *nmemb) {
+ return (node **)meshlink_get_all_nodes(this, (meshlink_node_t **)nodes, nmemb);
}
/// Sign data using the local node's MeshLink key.