daemon: Implement ping command.
[whenjobs.git] / lib / whenproto.x
1 /* whenjobs -*- c -*-
2  * (C) Copyright 2012 Red Hat Inc.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17  */
18
19 /* This is the protocol used to talk between the client (whenjobs) and
20  * the daemon (whenjobsd).  Communication happens over a Unix domain
21  * socket '$HOME/.whenjobs/socket'.  The wire protocol is SunRPC.
22  */
23
24 /* Maximum lengths and some useful typedefs. */
25 const MAX_VARIABLE_NAME_LENGTH = 256;
26 const MAX_VARIABLE_VALUE_LENGTH = 65536;
27 const MAX_JOB_NAME_LENGTH = 256;
28 const MAX_BIG_INT_LENGTH = 64; /* when encoded as a string */
29 const MAX_PATH_LENGTH = 4096;
30
31 typedef string variable_name<MAX_VARIABLE_NAME_LENGTH>;
32 typedef string string_value<MAX_VARIABLE_VALUE_LENGTH>;
33 typedef string job_name<MAX_JOB_NAME_LENGTH>;
34 typedef string string_big_int<MAX_BIG_INT_LENGTH>;
35 typedef string path<MAX_PATH_LENGTH>;
36
37 typedef variable_name variable_name_list<>;
38
39 /* Status code (OK or error) returned by most calls. */
40 enum status_code {
41   OK = 1,
42   ERROR = 2
43 };
44
45 union status switch (status_code s) {
46  case OK:
47    void;
48  case ERROR:
49    string error<>;
50 };
51
52 enum variable_type {
53   UNIT_T = 0,
54   BOOL_T = 1,
55   STRING_T = 2,
56   INT_T = 3,
57   FLOAT_T = 4
58 };
59
60 union variable switch (variable_type t) {
61  case UNIT_T:
62    void;
63  case BOOL_T:
64    bool b;
65  case STRING_T:
66    string_value s;
67  case INT_T:
68    string_big_int i;            /* OCaml [big_int], as a string. */
69  case FLOAT_T:
70    double f;                    /* C 'double' maps to an OCaml 'float' */
71 };
72
73 struct set_variable {
74   variable_name sv_name;
75   variable sv_value;
76 };
77 typedef set_variable set_variable_list<>;
78
79 struct job {
80   job_name job_name;
81   string_big_int job_serial;
82   path job_tmpdir;
83   hyper job_start_time;
84 };
85
86 typedef job job_list<>;
87
88 typedef job_name job_name_list<>;
89
90 /* The API of the daemon. */
91 program When {
92   version V1 {
93     status reload_file (void) = 1;
94     status set_variable (variable_name, variable) = 2; /* obsolete */
95     variable get_variable (variable_name) = 3;
96     variable_name_list get_variable_names (void) = 4;
97     status exit_daemon (void) = 5;
98     job_list get_jobs (void) = 6;
99     status cancel_job (string_big_int) = 7;
100     status start_job (job_name) = 8;
101     job get_job (string_big_int) = 9;
102     status set_variables (set_variable_list) = 10;
103     job_name_list get_job_names (void) = 11;
104     job_name_list test_variables (set_variable_list) = 12;
105     status ping_daemon (void) = 13;
106   } = 1;
107 } = 0x20008081;