| 17 | } |
| 18 | |
| 19 | int main(int argc, char* argv[]) { |
| 20 | acl::string file; |
| 21 | acl::string names; |
| 22 | bool use_remove = false; |
| 23 | int ch; |
| 24 | |
| 25 | while ((ch = getopt(argc, argv, "hf:n:D")) > 0) { |
| 26 | switch (ch) { |
| 27 | case 'h': |
| 28 | usage(argv[0]); |
| 29 | return 0; |
| 30 | case 'f': |
| 31 | file = optarg; |
| 32 | break; |
| 33 | case 'n': |
| 34 | names = optarg; |
| 35 | break; |
| 36 | case 'D': |
| 37 | use_remove = true; |
| 38 | break; |
| 39 | default: |
| 40 | break; |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | if (file.empty() || names.empty()) { |
| 45 | usage(argv[0]); |
| 46 | return 1; |
| 47 | } |
| 48 | |
| 49 | acl::string buf; |
| 50 | if (!acl::ifstream::load(file, &buf)) { |
| 51 | printf("load %s error %s\r\n", file.c_str(), acl::last_serror()); |
| 52 | return 1; |
| 53 | } |
| 54 | |
| 55 | std::vector<std::string> tokens; |
| 56 | acl::split(names.c_str(), ",; \t", tokens); |
| 57 | |
| 58 | acl::json json(buf); |
| 59 | if (!json.finish()) { |
| 60 | printf("invalid json: %s\r\n", buf.c_str()); |
| 61 | return 1; |
| 62 | } |
| 63 | |
| 64 | acl::json_node* node = json.first_node(); |
| 65 | while (node) { |
| 66 | const char* tag = node->tag_name(); |
| 67 | if (tag == NULL || *tag == 0) { |
| 68 | node = json.next_node(); |
| 69 | continue; |
| 70 | } |
| 71 | |
| 72 | if (matched(tokens, tag)) { |
| 73 | if (use_remove) { |
| 74 | node = json.free_node(node); |
| 75 | } else { |
| 76 | node->disable(true); |
nothing calls this directly
no test coverage detected
searching dependent graphs…