validate JSON before loading
This commit also introduces slurp() which reads a file in its entirety. Using this function instead of doing IO in the functions in load_layout.c again and again makes the code cleaner (fixing at least two memory leaks) and avoids re-reading the same file 3 times. related to #2755
This commit is contained in:
@ -31,6 +31,12 @@ typedef enum {
|
||||
* determine whether the file contains workspaces or regular containers, which
|
||||
* is important to know when deciding where (and how) to append the contents.
|
||||
* */
|
||||
json_content_t json_determine_content(const char *filename);
|
||||
json_content_t json_determine_content(const char *buf, const size_t len);
|
||||
|
||||
void tree_append_json(Con *con, const char *filename, char **errormsg);
|
||||
/**
|
||||
* Returns true if the provided JSON could be parsed by yajl.
|
||||
*
|
||||
*/
|
||||
bool json_validate(const char *buf, const size_t len);
|
||||
|
||||
void tree_append_json(Con *con, const char *buf, const size_t len, char **errormsg);
|
||||
|
Reference in New Issue
Block a user