invitation = meshlink_invite(mesh, 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(meshlink_errno));
return;
}
}
if(!meshlink_join(mesh, arg))
- fprintf(stderr, "Could not join using invitation: %s\n", mesh->errstr);
+ fprintf(stderr, "Could not join using invitation: %s\n", meshlink_strerror(meshlink_errno));
else
fprintf(stderr, "Invitation accepted!\n");
} else if(!strcasecmp(buf, "kick")) {
}
if(!meshlink_send(mesh, 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(meshlink_errno));
return;
}
meshlink_set_log_cb(mesh, MESHLINK_INFO, log_message);
if(!meshlink_start(mesh)) {
- fprintf(stderr, "Could not start MeshLink: %s\n", mesh->errstr);
+ fprintf(stderr, "Could not start MeshLink: %s\n", meshlink_strerror(meshlink_errno));
return 1;
}
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")) {
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 < n && i < 100; i++)
printf(" %s", nodes[i]->name);
if(n > 100)
printf(" (and %zu more)", n - 100);
}
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;
}
static void close(mesh *mesh) {
meshlink_close(mesh);
}
+
+ static const char *strerror(errno_t err = meshlink_errno) {
+ return meshlink_strerror(err);
+ }
};
#endif // MESHLINKPP_H
#define MSG_NOSIGNAL 0
#endif
+__thread meshlink_errno_t meshlink_errno;
+
//TODO: this can go away completely
const var_t variables[] = {
/* Server configuration */
MESHLINK_ENOENT, ///< Node is not known
} meshlink_errno_t;
+/// A variable holding the last encountered error from MeshLink.
+extern __thread meshlink_errno_t meshlink_errno;
+
#ifndef MESHLINK_INTERNAL_H
struct meshlink_handle {
- meshlink_errno_t meshlink_errno; ///< Code of the last encountered error.
- const char *errstr; ///< Textual representation of most recent error encountered.
};
struct meshlink_node {