diff --git a/src/journal/format.h b/src/journal/format.h deleted file mode 100644 index e69de29..0000000 diff --git a/src/journal/journal.c b/src/journal/journal.c deleted file mode 100644 index fa8137f..0000000 --- a/src/journal/journal.c +++ /dev/null @@ -1,57 +0,0 @@ -#include -#include -#include -#include -#include - -// functions to deal with the journal file - - -FILE *journal_open(char *topic) -{ - char *home_path = getenv("HOME"); - - // combine w/ home path - char *journal_dir = (char*)malloc(1024); - snprintf(journal_dir, 1024, "%s/.lunabot", home_path); - - // construct a 744 - mkdir(journal_dir, S_IRWXU | S_IRGRP | S_IROTH); - - char *journal_path = (char*)malloc(1024); - snprintf(journal_path, 1024, "%s/%s", journal_dir, topic); - - FILE* res = fopen(journal_path, "a"); - - free(journal_path); - free(journal_dir); - - return res; -} - -void journal_write(FILE* journal_fd, char* message) -{ - // TODO: strlen()? - fwrite(message, strlen(message), 1, journal_fd); -} - -void journal_close(FILE* journal_fd) -{ - fclose(journal_fd); -} - -void journal_write_topic(FILE *journal_fd, char *topic, char *message) -{ - char *tstamp = malloc(128 * sizeof(char)); - char fmt_msg[512]; - - time_t rawtime; - time(&rawtime); - const struct tm *cur_time = gmtime(&rawtime); - strftime(tstamp, 128, "%c", cur_time); - - sprintf(fmt_msg, "[%s] [%s]: %s\n", tstamp, topic, message); - free(tstamp); - - journal_write(journal_fd, fmt_msg); -}