skip to content
==> include/mesh/jobs/req.h <==
1/* @ajax/mesh-jobs-req: a change of the job table as the control port's words (jobs.rs `Submit`,
2 * `Req`, `SUBMIT_USAGE`): `job submit <program> items <..> [op ..] [priority ..] [attempts ..]
3 * [deadline <secs>] [results collect|nonzero|none] [setup <op>:<arg>,..] [members <k>,..]`,
4 * `job cancel <id>`, `job forget <id>`, `job tone <id> aces|reinhard` (the words after `job`). */
5#ifndef MESH_JOBS_REQ_H
6#define MESH_JOBS_REQ_H
7
8#include "mesh/jobs/id.h"
9#include "mesh/jobs/ranges.h"
10#include "mesh/jobs/spec.h"
11
12#include <stdbool.h>
13#include <stddef.h>
14#include <stdint.h>
15
16#define MESH_JOBS_SUBMIT_USAGE                                                                                                   \
17    "usage: job submit <program> items <n | a-b | a- | a,b-c,..> [op <o>] [priority <p>] [attempts <a>] [deadline <secs>] " \
18    "[results collect|nonzero|none] [setup <op>:<arg>,..] [members <k>,..]"
19
20typedef struct {
21    uint32_t members;
22    char *program;
23    uint32_t op;
24    mj_ranges items;
25    int32_t priority;
26    uint32_t attempts;
27    uint64_t deadline_s;
28    mj_mode mode;
29    mj_setup *setup;
30    size_t nsetup;
31} mj_submit;
32
33typedef enum { MJ_REQ_SUBMIT, MJ_REQ_CANCEL, MJ_REQ_FORGET, MJ_REQ_TONE } mj_req_kind;
34
35typedef struct {
36    mj_req_kind kind;
37    mj_submit submit; /* SUBMIT */
38    mj_job_id job;    /* CANCEL, FORGET, TONE */
39    uint32_t tone;    /* TONE: 0 ACES, 1 Reinhard */
40} mj_req;
41
42void mj_submit_free(mj_submit *s);
43mj_submit mj_submit_clone(const mj_submit *s);
44void mj_req_free(mj_req *r);
45mj_req mj_req_clone(const mj_req *r);
46
47/* The words after `submit`. False with *err (the Rust's message; the caller frees it). */
48bool mj_submit_parse(const char *const *words, size_t n, mj_submit *out, char **err);
49/* The words after `job`. */
50bool mj_req_parse(const char *const *words, size_t n, mj_req *out, char **err);
51
52#endif