#include "../src/meshlink.h"
static void log_message(meshlink_handle_t *mesh, meshlink_log_level_t level, const char *text) {
- const char *levelstr[] = {
+ (void)mesh;
+
+ static const char *levelstr[] = {
[MESHLINK_DEBUG] = "\x1b[34mDEBUG",
[MESHLINK_INFO] = "\x1b[32mINFO",
[MESHLINK_WARNING] = "\x1b[33mWARNING",
[MESHLINK_ERROR] = "\x1b[31mERROR",
[MESHLINK_CRITICAL] = "\x1b[31mCRITICAL",
};
+
fprintf(stderr, "%s:\x1b[0m %s\n", levelstr[level], text);
}
static void receive(meshlink_handle_t *mesh, meshlink_node_t *source, const void *data, size_t len) {
+ (void)mesh;
+
const char *msg = data;
if(!len || msg[len - 1]) {
}
static void node_status(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) {
+ (void)mesh;
+
if(reachable) {
printf("%s joined.\n", node->name);
} else {
return;
}
- invitation = meshlink_invite(mesh, arg);
+ invitation = meshlink_invite(mesh, NULL, arg);
if(!invitation) {
fprintf(stderr, "Could not invite '%s': %s\n", arg, meshlink_strerror(meshlink_errno));
} else {
printf("%zu known nodes:", nnodes);
- for(int i = 0; i < nnodes; i++) {
+ for(size_t i = 0; i < nnodes; i++) {
printf(" %s", nodes[i]->name);
}
// Commands start with '/'
if(*buf == '/') {
- return parse_command(mesh, buf + 1);
+ parse_command(mesh, buf + 1);
+ return;
}
// Lines in the form "name: message..." set the destination node.