| 4 | #include "lib_acl.h" |
| 5 | |
| 6 | static void test_json(const char *data, ACL_ARGV *names) |
| 7 | { |
| 8 | ACL_JSON *json = acl_json_alloc(); |
| 9 | ACL_VSTRING *buf = acl_vstring_alloc(1024); |
| 10 | ACL_ITER iter, iter2; |
| 11 | |
| 12 | acl_json_update(json, data); |
| 13 | |
| 14 | if (!acl_json_finish(json)) { |
| 15 | printf("Invalid json!\r\n"); |
| 16 | return; |
| 17 | } |
| 18 | |
| 19 | #define STR acl_vstring_str |
| 20 | #define LEN ACL_VSTRING_LEN |
| 21 | #define EQ !strcmp |
| 22 | |
| 23 | acl_foreach(iter, json) { |
| 24 | ACL_JSON_NODE* node = (ACL_JSON_NODE*) iter.data; |
| 25 | if (LEN(node->ltag) == 0) { |
| 26 | continue; |
| 27 | } |
| 28 | |
| 29 | acl_foreach(iter2, names) { |
| 30 | const char *name = (const char*) iter2.data; |
| 31 | if (EQ(STR(node->ltag), name)) { |
| 32 | acl_json_node_disable(node, 1); |
| 33 | } |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | acl_json_build(json, buf); |
| 38 | printf("%s\r\n", STR(buf)); |
| 39 | acl_json_free(json); |
| 40 | acl_vstring_free(buf); |
| 41 | } |
| 42 | |
| 43 | static void usage(const char *procname) |
| 44 | { |
no test coverage detected
searching dependent graphs…