aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/run_queue.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/run_queue.c')
-rw-r--r--src/run_queue.c35
1 files changed, 28 insertions, 7 deletions
diff --git a/src/run_queue.c b/src/run_queue.c
index cb000e0..e1fdf84 100644
--- a/src/run_queue.c
+++ b/src/run_queue.c
@@ -8,6 +8,7 @@
#include "run_queue.h"
#include "log.h"
#include "msg.h"
+#include "string.h"
#include <stdlib.h>
#include <string.h>
@@ -57,26 +58,46 @@ fail:
return -1;
}
+void run_destroy(struct run *entry)
+{
+ free(entry->rev);
+ free(entry->url);
+ free(entry);
+}
+
int run_from_msg(struct run **run, const struct msg *msg)
{
size_t msg_len = msg_get_length(msg);
- if (msg_len != 3) {
+ if (msg_len != 4) {
log_err("Invalid number of arguments for a message: %zu\n", msg_len);
msg_dump(msg);
return -1;
}
const char **argv = msg_get_strings(msg);
- /* We don't know the ID yet. */
- return run_create(run, 0, argv[1], argv[2]);
+
+ int id = 0;
+ int ret = string_to_int(argv[1], &id);
+ if (ret < 0)
+ return ret;
+
+ return run_create(run, id, argv[2], argv[3]);
}
-void run_destroy(struct run *entry)
+int run_from_msg_unknown_id(struct run **run, const struct msg *msg)
{
- free(entry->rev);
- free(entry->url);
- free(entry);
+ size_t msg_len = msg_get_length(msg);
+
+ if (msg_len != 3) {
+ log_err("Invalid number of arguments for a message: %zu\n", msg_len);
+ msg_dump(msg);
+ return -1;
+ }
+
+ const char **argv = msg_get_strings(msg);
+ /* We don't know the ID yet. */
+ return run_create(run, 0, argv[1], argv[2]);
}
int run_get_id(const struct run *entry)