diff options
author | Antony Kellermann | 2018-09-26 19:15:52 -0400 |
---|---|---|
committer | Antony Kellermann | 2018-09-26 19:15:52 -0400 |
commit | b993c86812d9ea718354d49713f870f06c015181 (patch) | |
tree | c1e07c46a0f2db4a6ec03a8ddea1a45504e38a53 | |
parent | 52c072060efc55b7ba43d780dbce95b871db9d5d (diff) | |
download | aur-b993c86812d9ea718354d49713f870f06c015181.tar.gz |
Added cache path init
-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(); |