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)
invitation = mesh->invite(arg);
if(!invitation) {
- fprintf(stderr, "Could not invite '%s': %s\n", arg, mesh->errstr);
+ fprintf(stderr, "Could not invite '%s': %s\n", arg, meshlink::strerror());
return;
}
}
if(!mesh->join(arg))
- fprintf(stderr, "Could not join using invitation: %s\n", mesh->errstr);
+ fprintf(stderr, "Could not join using invitation: %s\n", meshlink::strerror());
else
fprintf(stderr, "Invitation accepted!\n");
} else if(!strcasecmp(buf, "kick")) {
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(int 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 {
}
if(!mesh->send(destination, msg, strlen(msg) + 1)) {
- fprintf(stderr, "Could not send message to '%s': %s\n", destination->name, mesh->errstr);
+ fprintf(stderr, "Could not send message to '%s': %s\n", destination->name, meshlink::strerror());
return;
}
mesh->set_log_cb(MESHLINK_INFO, log_message);
if(!mesh->start()) {
- fprintf(stderr, "Could not start MeshLink: %s\n", mesh->errstr);
+ fprintf(stderr, "Could not start MeshLink: %s\n", meshlink::strerror());
return 1;
}