1 /* 2 * SPDX-License-Identifier: ISC 3 * 4 * Copyright (c) 2020 Todd C. Miller <Todd.Miller@sudo.ws> 5 * 6 * Permission to use, copy, modify, and distribute this software for any 7 * purpose with or without fee is hereby granted, provided that the above 8 * copyright notice and this permission notice appear in all copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 */ 18 19 #ifndef IOLOG_JSON_H 20 #define IOLOG_JSON_H 21 22 #include "sudo_json.h" 23 #include "sudo_queue.h" 24 25 TAILQ_HEAD(json_item_list, json_item); 26 27 struct json_object { 28 struct json_item *parent; 29 struct json_item_list items; 30 }; 31 32 struct json_item { 33 TAILQ_ENTRY(json_item) entries; 34 char *name; /* may be NULL for first brace */ 35 unsigned int lineno; 36 enum json_value_type type; 37 union { 38 struct json_object child; 39 char *string; 40 long long number; 41 id_t id; 42 bool boolean; 43 } u; 44 }; 45 46 void free_json_items(struct json_item_list *items); 47 bool iolog_parse_json(FILE *fp, const char *filename, struct json_object *root); 48 char **json_array_to_strvec(struct json_object *array); 49 50 #endif /* IOLOG_JSON_H */ 51