From 7f7868303567fd4a774bef614fac3e865702243a Mon Sep 17 00:00:00 2001 From: Jacob Date: Mon, 16 Dec 2019 14:45:02 -0500 Subject: [PATCH] Remove JSON library dependency. --- CMakeLists.txt | 6 +----- main.c | 11 +---------- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 324334f..619ee79 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,3 @@ project(HostBlocker) find_package(PkgConfig REQUIRED) -pkg_check_modules(JSONC REQUIRED json-c) - -add_executable(hb main.c) -target_link_libraries(hb ${JSONC_LIBS}) -target_include_directories(hb PUBLIC ${JSONC_INCLUDE_DIRS}) \ No newline at end of file +add_executable(hb main.c) \ No newline at end of file diff --git a/main.c b/main.c index 889585d..db7902e 100644 --- a/main.c +++ b/main.c @@ -6,8 +6,6 @@ #include #include -#include - // Macro for status checks. #define ONFAILED(status, fn) if(status > fn) @@ -25,7 +23,6 @@ const char *CONFIG; // The current hardcoded location of the hosts file. static const char *HOSTFILE = "/etc/hosts"; // Our configuration -struct json_object *config; /** * SIGINT handler, cleans up resources on Ctrl-C @@ -36,7 +33,6 @@ void int_handler(int signal) { fprintf(stderr, "SIGINT received, cleaning up...\n"); // This should be the final decrement to the config object. - json_object_put(config); } void replacehost(char *oldhost, char *newhost); @@ -101,11 +97,7 @@ void showHosts() */ int read_config_file() { // increment the refcount for tmp. - struct json_object *tmp = json_object_get(config); - /** Utilize the JSON parsing library json-c to parse configuration */ - json_object_object_foreach(tmp, key, val) { - fprintf(stderr,"Key: %s\nValue:%s\n\n", key, val); - } + } /** @@ -184,7 +176,6 @@ int main(int argc, char **argv) showHosts(); } else if (strcmp(argv[i], "-config") == 0) { - config = json_tokener_parse(argv[++i]); CONFIG = argv[i]; }