From bc25e14b448edb9f41260a23cf6567e6632db267 Mon Sep 17 00:00:00 2001 From: gramanas Date: Sun, 15 Apr 2018 00:43:08 +0300 Subject: dummy init done action parser conf parser db layer --- src/checks.c | 133 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 src/checks.c (limited to 'src/checks.c') diff --git a/src/checks.c b/src/checks.c new file mode 100644 index 0000000..80b1954 --- /dev/null +++ b/src/checks.c @@ -0,0 +1,133 @@ +#include +#include +#include +#include +#include + +#include "checks.h" + + + +/* const char* const matchVCDirName = " version_control_dir = %s"; */ +/* const char* const matchSCRTDirName = " secret_dir = %s"; */ +/* const char* const matchDBDirName = " database_dir = %s"; */ + +/* ConfigParserResult parseConfigFile(FILE *f, Conf *c) { */ +/* char *vc_dir, *scrt_dir, *db_dir; */ +/* DIR *dir; */ + +/* char * buffer = 0; */ +/* long length; */ +/* if (f) { */ +/* fseek(f, 0, SEEK_END); */ +/* length = ftell (f); */ +/* fseek(f, 0, SEEK_SET); */ +/* buffer = malloc (length); */ +/* if (buffer) { */ +/* fread (buffer, 1, length, f); */ +/* for (int i = 0; i < length; i++) { */ +/* if (buffer[i] == '\n') { */ +/* buffer[i] = ' '; */ +/* } */ +/* } */ +/* } */ +/* fclose (f); */ +/* } */ + + /* if (buffer) { */ + /* // VC dir */ + /* vc_dir = malloc(sizeof(char)*100); */ + /* if (sscanf(buffer, matchVCDirName, vc_dir) != 1) { */ + /* return CPR_NO_VC_DIR; */ + /* } */ + /* dir = opendir(vc_dir); */ + /* if (!dir) { */ + /* return CPR_WRONG_VC_DIR; */ + /* } */ + /* closedir(dir); */ + /* c->VC_dir = vc_dir; */ + +/* /\* printf("%s", buffer); *\/ */ + +/* // SCRT_dir */ +/* scrt_dir = malloc(sizeof(char)*100); */ +/* if(sscanf(buffer, matchSCRTDirName, scrt_dir) != 1) { */ +/* return CPR_NO_SCRT_DIR; */ +/* } */ +/* dir = opendir(scrt_dir); */ +/* if (!dir) { */ +/* return CPR_WRONG_SCRT_DIR; */ +/* } */ +/* c->SCRT_dir = scrt_dir; */ + +/* // DB_dir */ +/* db_dir = malloc(sizeof(char)*100); */ +/* if (sscanf(buffer, matchDBDirName, db_dir) != 1) { */ +/* return CPR_NO_DB_DIR; */ +/* } */ +/* dir = opendir(db_dir); */ +/* if (!dir) { */ +/* return CPR_WRONG_DB_DIR; */ +/* } */ +/* c->DB_dir = db_dir; */ +/* } */ +/* return CPR_OK; */ +/* } */ + + +/* char *getConfigPath() { */ +/* char *home = getenv("HOME"); */ +/* char *path; */ +/* if (home == NULL) { */ +/* printf("HOME variable is not set. Can't find config."); */ + +/* } */ +/* if ((path = malloc(strlen(home)+strlen(configFilename)+1 /\* for the slash *\/))) { */ +/* strcat(path, home); */ +/* strcat(path, "/"); */ +/* strcat(path, configFilename); */ +/* } */ +/* return path; */ +/* } */ + +// -1 config file problem +// 0 config content problem +// 1 all good +/* int doConfigCheck(Conf *conf) { */ +/* char* ckConfigPath = getConfigPath(); */ +/* if (ckConfigPath == NULL) { */ +/* return -1; */ +/* } */ +/* FILE *confPtr; */ +/* if ((confPtr = fopen(ckConfigPath, "r")) == NULL){ */ +/* return -1; */ +/* } */ +/* return 2; */ +/* } */ + +/* /\* CheckResult doInitCheck(Conf *conf) { */ + /* switch (doConfigCheck(conf)) { */ + /* case CPR_NO_VC_DIR: */ + /* printf("There is no VersionControl directory defined in the configuration file.\n"); */ + /* return CR_NO_CONFIG; */ + /* case CPR_WRONG_VC_DIR: */ + /* printf("The VersionControl directory defined in the configuration file is wrong.\n"); */ + /* return CR_WRONG_CONFIG; */ + /* case CPR_NO_SCRT_DIR: */ + /* printf("There is no Secret directory defined in the configuration file.\n"); */ + /* return CR_NO_CONFIG; */ + /* case CPR_WRONG_SCRT_DIR: */ + /* printf("The Secret directory defined in the configuration file is wrong.\n"); */ + /* return CR_WRONG_CONFIG; */ + /* case CPR_NO_DB_DIR: */ + /* printf("There is no Database directory defined in the configuration file.\n"); */ + /* return CR_NO_CONFIG; */ + /* case CPR_WRONG_DB_DIR: */ + /* printf("The Database directory defined in the configuration file is wrong.\n"); */ + /* return CR_WRONG_CONFIG; */ + /* case CPR_OK: */ + /* break; */ + /* } */ +// return 0; + //doDbCheck(); +//} -- cgit v1.2.3