diff options
author | mrb0nk500 <b0nk@b0nk.xyz> | 2021-06-18 10:00:36 -0400 |
---|---|---|
committer | mrb0nk500 <b0nk@b0nk.xyz> | 2021-06-18 10:00:36 -0400 |
commit | 6f73ce79a253f59a7fa590b5abebd757afaa0ec5 (patch) | |
tree | c7ac724cc7528eae3f37c261863216b3fad8dd77 | |
parent | c70cf68a59dd94789b700d48c2389468ed6d4383 (diff) |
Removed the code that's now in `misc.c` from
`config.c`.
Forgot to remove it. lol
-rw-r--r-- | config.c | 71 |
1 files changed, 0 insertions, 71 deletions
@@ -7,77 +7,6 @@ #include "macros.h" #include "misc.h" -char *read_file(const char *filename, long *size) { - /* Open the file. */ - FILE *fp = fopen(filename, "r"); - /* Size of the file, in bytes. */ - long filesize = 0; - /* Buffer of the file contents. */ - char *buf; - - /* Return NULL, if we couldn't open the file. */ - if (fp == NULL) { - return NULL; - } - - /* Return NULL, if we couldn't seek to the end of the file. */ - if (fseek(fp, 0L, SEEK_END)) { - fclose(fp); - return NULL; - } - - /* Get the size of the file, in bytes. */ - filesize = ftell(fp); - - /* Return NULL, if the returned size is negative. */ - if (filesize < 0) { - fclose(fp); - return NULL; - } - - /* Allocate enough space for the entire file, plus one. */ - buf = calloc(filesize+1, sizeof(char)); - - /* Return NULL, if the buffer wasn't allocated. */ - if (buf == NULL) { - fclose(fp); - return NULL; - } - - /* Seek back to the start of the file. */ - rewind(fp); - /* Read the entire file contents into the buffer. */ - fread(buf, sizeof(char), filesize, fp); - /* Close the file. */ - fclose(fp); - - /* Return the filesize, in bytes. */ - *size = filesize; - /* Return the buffer. */ - return buf; -} - -char *get_line(char **str) { - char *s; - size_t i; - char *tmp = *str; - - for (i = 0; tmp[i] != '\n' && tmp[i] != '\0'; i++); - - s = calloc(i+1, sizeof(char)); - memcpy(s, *str, i); - - *str += (i+1); - return s; -} - -char *make_str(const char *str) { - const size_t length = strlen(str); - char *s = calloc(length+1, sizeof(char)); - memcpy(s, str, length+1); - return s; -} - config_val parse_option_value(const config_opt *opt, char *value) { config_val val = {0}; |