invitation = meshlink_invite(mesh, arg);
if(!invitation) {
- fprintf(stderr, "Could not invite '%s': %s\n", arg, meshlink_errstr);
+ fprintf(stderr, "Could not invite '%s': %s\n", arg, mesh->errstr);
return;
}
}
if(!meshlink_join(mesh, arg))
- fprintf(stderr, "Could not join using invitation: %s\n", meshlink_errstr);
+ fprintf(stderr, "Could not join using invitation: %s\n", mesh->errstr);
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, meshlink_errstr);
+ fprintf(stderr, "Could not send message to '%s': %s\n", destination->name, mesh->errstr);
return;
}
meshlink_handle_t *mesh = meshlink_open(confbase, nick);
if(!mesh) {
- fprintf(stderr, "Could not open MeshLink: %s\n", meshlink_errstr);
+ fprintf(stderr, "Could not open MeshLink: %s\n", mesh->errstr);
return 1;
}
meshlink_set_log_cb(mesh, MESHLINK_INFO, log);
if(!meshlink_start(mesh)) {
- fprintf(stderr, "Could not start MeshLink: %s\n", meshlink_errstr);
+ fprintf(stderr, "Could not start MeshLink: %s\n", mesh->errstr);
return 1;
}
/// A handle for an instance of MeshLink.
typedef struct meshlink_handle meshlink_handle_t;
-typedef struct meshlink_node meshlink_node_t;
-
-#ifndef MESHLINK_INTERNAL_H
-
/// A handle for a MeshLink node.
-typedef struct meshlink_node {
- const char *name; // Textual name of this node.
- void *priv; // Private pointer which the application can set at will.
-} meshlink_node_t;
-
-#endif // MESHLINK_INTERNAL_H
+typedef struct meshlink_node meshlink_node_t;
/// Code of most recent error encountered.
typedef enum {
MESHLINK_ENOENT, // Node is not known
} meshlink_errno_t;
-extern meshlink_errno_t meshlink_errno;
+#ifndef MESHLINK_INTERNAL_H
+
+struct meshlink_handle {
+ meshlink_errno_t errno; /// Code of the last encountered error.
+ const char *errstr; /// Textual representation of most recent error encountered.
+};
-/// Textual representation of most recent error encountered.
-const char *meshlink_errstr;
+struct meshlink_node {
+ const char *name; // Textual name of this node.
+ void *priv; // Private pointer which the application can set at will.
+};
+
+#endif // MESHLINK_INTERNAL_H
/// Get the text for the given MeshLink error code.
/** This function returns a pointer to the string containing the description of the given error code.