In XDR, introduce a new type 'string_big_int'.
[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_BIG_INT_LENGTH = 64; /* when encoded as a string */
28
29 typedef string variable_name<MAX_VARIABLE_NAME_LENGTH>;
30 typedef string string_value<MAX_VARIABLE_VALUE_LENGTH>;
31 typedef string string_big_int<MAX_BIG_INT_LENGTH>;
32
33 typedef variable_name variable_name_list<>;
34
35 /* Status code (OK or error) returned by most calls. */
36 enum status_code {
37   OK = 1,
38   ERROR = 2
39 };
40
41 union status switch (status_code s) {
42  case OK:
43    void;
44  case ERROR:
45    string error<>;
46 };
47
48 enum variable_type {
49   UNIT_T = 0,
50   BOOL_T = 1,
51   STRING_T = 2,
52   INT_T = 3,
53   FLOAT_T = 4
54 };
55
56 union variable switch (variable_type t) {
57  case UNIT_T:
58    void;
59  case BOOL_T:
60    bool b;
61  case STRING_T:
62    string_value s;
63  case INT_T:
64    string_big_int i;            /* OCaml [big_int], as a string. */
65  case FLOAT_T:
66    double f;                 /* C 'double' maps to an OCaml 'float' */
67 };
68
69 /* The API of the daemon. */
70 program When {
71   version V1 {
72     status reload_file (void) = 1;
73     status set_variable (variable_name, variable) = 2;
74     variable get_variable (variable_name) = 3;
75     variable_name_list get_variable_names (void) = 4;
76     status exit_daemon (void) = 5;
77   } = 1;
78 } = 0x20008081;