summaryrefslogtreecommitdiff
path: root/rcon.c
diff options
context:
space:
mode:
Diffstat (limited to 'rcon.c')
-rw-r--r--rcon.c50
1 files changed, 25 insertions, 25 deletions
diff --git a/rcon.c b/rcon.c
index e7c37ce..1a57b89 100644
--- a/rcon.c
+++ b/rcon.c
@@ -27,7 +27,7 @@ rcon_free(struct uring_task *task)
{
struct rcon *rcon = container_of(task, struct rcon, task);
- debug(DBG_RCON, "task %p, idle %p\n", task, rcon);
+ debug(DBG_RCON, "task %p, idle %p", task, rcon);
rcon->server->rcon = NULL;
xfree(rcon);
}
@@ -49,7 +49,7 @@ rcon_delete(struct cfg *cfg, struct server *server)
if (!rcon)
return;
- debug(DBG_RCON, "closing fd %i\n", rcon->task.fd);
+ debug(DBG_RCON, "closing fd %i", rcon->task.fd);
uring_task_destroy(cfg, &rcon->task);
server->rcon = NULL;
}
@@ -141,7 +141,7 @@ create_packet(struct cfg *cfg, struct rcon *rcon, int32_t reqid,
write_int(&pos, NULL, rcon->tbuf.len - 4);
debug(DBG_RCON, "created packet (reqid: %" PRIi32 ", type %" PRIi32
- ", len %zu, payload: %s)\n",
+ ", len %zu, payload: %s)",
reqid, type, rcon->tbuf.len, msg);
}
@@ -158,7 +158,7 @@ packet_complete(struct cfg *cfg, struct uring_task *task, int res)
return 0;
plen = read_int(&pos, &len);
- debug(DBG_RCON, "reply size: %zu bytes, packet size %" PRIi32 "\n",
+ debug(DBG_RCON, "reply size: %zu bytes, packet size %" PRIi32,
task->tbuf->len, plen + 4);
if (task->tbuf->len < plen + 4)
@@ -181,7 +181,7 @@ rcon_read_packet(struct cfg *cfg, struct rcon *rcon, int32_t *id,
*rmsg = NULL;
if (plen < 10) {
- error("invalid packet length: %" PRIi32 "\n", plen);
+ error("invalid packet length: %" PRIi32, plen);
return false;
}
@@ -192,17 +192,17 @@ rcon_read_packet(struct cfg *cfg, struct rcon *rcon, int32_t *id,
}
if (len < 2) {
- error("short message\n");
+ error("short message");
return false;
}
if (pos[0] != '\0' || pos[1] != '\0') {
- error("invalid trailer\n");
+ error("invalid trailer");
return false;
}
debug(DBG_RCON, "response - len: %" PRIi32 ", id: %" PRIi32
- ", type: %" PRIi32 ", msg: %s\n",
+ ", type: %" PRIi32 ", msg: %s",
plen, *id, *type, *rmsg);
return true;
@@ -219,22 +219,22 @@ rcon_stop_reply(struct cfg *cfg, struct uring_task *task, int res)
assert_task_alive(DBG_RCON, task);
if (res < 0) {
- debug(DBG_RCON, "res: %i\n", res);
+ debug(DBG_RCON, "res: %i", res);
goto out;
}
- debug(DBG_RCON, "packet complete\n");
+ debug(DBG_RCON, "packet complete");
rcon_read_packet(cfg, rcon, &id, &type, &msg);
if (id != 2) {
- error("rcon stop cmd failed - unexpected reply id (%" PRIi32 ")\n", id);
+ error("rcon stop failed - reply id (%" PRIi32 ")", id);
goto out;
} else if (type != RCON_PACKET_RESPONSE) {
- error("rcon stop cmd failed - unexpected reply type (%" PRIi32 ")\n", type);
+ error("rcon stop failed - reply type (%" PRIi32 ")", type);
goto out;
}
- verbose("rcon stop cmd successful (%s)\n", msg);
+ verbose("rcon stop successful (%s)", msg);
out:
uring_task_put(cfg, &rcon->task);
@@ -248,12 +248,12 @@ rcon_stop_sent(struct cfg *cfg, struct uring_task *task, int res)
assert_task_alive(DBG_RCON, task);
if (res < 0) {
- debug(DBG_RCON, "res: %i\n", res);
+ debug(DBG_RCON, "res: %i", res);
uring_task_put(cfg, &rcon->task);
return;
}
- debug(DBG_RCON, "stop cmd sent\n");
+ debug(DBG_RCON, "stop cmd sent");
uring_tbuf_read_until(cfg, &rcon->task, packet_complete, rcon_stop_reply);
}
@@ -268,25 +268,25 @@ rcon_login_reply(struct cfg *cfg, struct uring_task *task, int res)
assert_task_alive(DBG_RCON, task);
if (res < 0) {
- debug(DBG_RCON, "res: %i\n", res);
+ debug(DBG_RCON, "res: %i", res);
goto error;
}
- debug(DBG_RCON, "packet complete\n");
+ debug(DBG_RCON, "packet complete");
rcon_read_packet(cfg, rcon, &id, &type, &msg);
if (id != 1) {
- error("rcon login failed - unexpected reply id (%" PRIi32 ")\n", id);
+ error("rcon login failed - unexpected reply id (%" PRIi32 ")", id);
goto error;
} else if (type == RCON_PACKET_LOGIN_FAIL) {
- error("rcon login failed - incorrect password\n");
+ error("rcon login failed - incorrect password");
goto error;
} else if (type != RCON_PACKET_LOGIN_OK) {
- error("rcon login failed - unexpected reply type (%" PRIi32 ")\n", type);
+ error("rcon login failed - unexpected reply type (%" PRIi32 ")", type);
goto error;
}
- debug(DBG_RCON, "rcon login successful\n");
+ debug(DBG_RCON, "rcon login successful");
create_packet(cfg, rcon, 2, RCON_PACKET_COMMAND, "stop");
uring_tbuf_write(cfg, &rcon->task, rcon_stop_sent);
return;
@@ -303,12 +303,12 @@ rcon_login_sent(struct cfg *cfg, struct uring_task *task, int res)
assert_task_alive(DBG_RCON, task);
if (res < 0) {
- debug(DBG_RCON, "res: %i\n", res);
+ debug(DBG_RCON, "res: %i", res);
uring_task_put(cfg, &rcon->task);
return;
}
- debug(DBG_RCON, "login sent\n");
+ debug(DBG_RCON, "login sent");
uring_tbuf_read_until(cfg, &rcon->task, packet_complete, rcon_login_reply);
}
@@ -320,7 +320,7 @@ rcon_connected_cb(struct cfg *cfg, struct connection *conn, bool connected)
assert_task_alive(DBG_RCON, &rcon->task);
if (!connected) {
- error("rcon connection to remote server (%s) failed\n",
+ error("rcon connection to remote server (%s) failed",
rcon->server->name);
uring_task_put(cfg, &rcon->task);
return;
@@ -343,7 +343,7 @@ rcon_init(struct cfg *cfg, struct server *server)
rcon = zmalloc(sizeof(*rcon));
if (!rcon)
- perrordie("malloc");
+ die("malloc: %m");
uring_task_init(&rcon->task, "rcon", &server->task, rcon_free);
uring_task_set_buf(&rcon->task, &rcon->tbuf);