diff options
-rw-r--r-- | api.c | 10 | ||||
-rw-r--r-- | api.h | 4 | ||||
-rw-r--r-- | main.c | 4 |
3 files changed, 17 insertions, 1 deletions
@@ -1,5 +1,15 @@ #include "api.h" +char* ref_cache_file_path; + +void ref_cache_file_path_init(void) { + char* home = getenv("HOME"); + char* path = malloc(strlen(home) + 32); + pointer_alloc_check(path); + sprintf(path, "%s/.tick_ref_cache.json", home); + ref_cache_file_path = path; +} + Ref_Data* ref_data_init_length(size_t length) { Ref_Data* pRef_Data = malloc(sizeof(Ref_Data)); pointer_alloc_check(pRef_Data); @@ -150,6 +150,10 @@ struct info_array { Info* totals; }; +extern char* ref_cache_file_path; + +void ref_cache_file_path_init(void); + /** * Allocates a Ref_Data struct with length and returns a pointer to it. * @param length @@ -17,8 +17,9 @@ int main(int argc, char* argv[]) { strtoupper(sym); } - // Init portfolio path + // Init file paths portfolio_file_path_init(); + ref_cache_file_path_init(); // Init cURL curl_global_init(CURL_GLOBAL_ALL); @@ -105,6 +106,7 @@ int main(int argc, char* argv[]) { } } free(portfolio_file_path); + free(ref_cache_file_path); free(sym); free(cmd); curl_global_cleanup(); |