source: ogServer-Git/src/json.h @ 24c8b94

Last change on this file since 24c8b94 was 27fbc65, checked in by OpenGnSys Support Team <soporte-og@…>, 4 years ago

#941 Add og_json_parse_string_copy(...) function

This function provides an easy way to copy the content of a json string
into a regular C string.

  • Property mode set to 100644
File size: 2.2 KB
Line 
1#ifndef _OG_JSON_H
2#define _OG_JSON_H
3
4#include <jansson.h>
5#include "schedule.h"
6
7int og_json_parse_string(json_t *element, const char **str);
8int og_json_parse_string_copy(json_t *element, char *str, size_t size);
9int og_json_parse_uint64(json_t *element, uint64_t *integer);
10int og_json_parse_uint(json_t *element, uint32_t *integer);
11int og_json_parse_bool(json_t *element, bool *value);
12
13#define OG_PARAM_PART_NUMBER                    (1UL << 0)
14#define OG_PARAM_PART_CODE                      (1UL << 1)
15#define OG_PARAM_PART_FILESYSTEM                (1UL << 2)
16#define OG_PARAM_PART_SIZE                      (1UL << 3)
17#define OG_PARAM_PART_FORMAT                    (1UL << 4)
18#define OG_PARAM_PART_DISK                      (1UL << 5)
19#define OG_PARAM_PART_OS                        (1UL << 6)
20#define OG_PARAM_PART_USED_SIZE                 (1UL << 7)
21
22struct og_partition {
23        const char      *disk;
24        const char      *number;
25        const char      *code;
26        const char      *size;
27        const char      *filesystem;
28        const char      *format;
29        const char      *os;
30        const char      *used_size;
31};
32
33#define OG_PARTITION_MAX        4
34
35int og_json_parse_partition(json_t *element, struct og_partition *part,
36                            uint64_t required_flags);
37
38#define OG_CLIENTS_MAX  4096
39
40struct og_sync_params {
41        const char      *sync;
42        const char      *diff;
43        const char      *remove;
44        const char      *compress;
45        const char      *cleanup;
46        const char      *cache;
47        const char      *cleanup_cache;
48        const char      *remove_dst;
49        const char      *diff_id;
50        const char      *diff_name;
51        const char      *path;
52        const char      *method;
53};
54
55#define OG_PARAM_SCOPE_ID       (1UL << 0)
56#define OG_PARAM_SCOPE_TYPE     (1UL << 1)
57
58struct og_scope {
59        uint32_t        id;
60        const char      *type;
61};
62
63int og_json_parse_scope(json_t *element, struct og_scope *scope,
64                        const uint64_t required_flags);
65
66struct og_msg_params {
67        const char      *ips_array[OG_CLIENTS_MAX];
68        const char      *mac_array[OG_CLIENTS_MAX];
69        const char      *netmask_array[OG_CLIENTS_MAX];
70        unsigned int    ips_array_len;
71        const char      *wol_type;
72        char            run_cmd[4096];
73        const char      *disk;
74        const char      *partition;
75        const char      *repository;
76        const char      *name;
77        const char      *id;
78        const char      *code;
79        const char      *type;
80        const char      *profile;
81        const char      *cache;
82        const char      *cache_size;
83        bool            echo;
84        struct og_partition     partition_setup[OG_PARTITION_MAX];
85        struct og_sync_params sync_setup;
86        struct og_schedule_time time;
87        const char      *task_id;
88        uint64_t        flags;
89};
90
91#endif
Note: See TracBrowser for help on using the repository browser.