dav/config.c

changeset 215
781aee172901
parent 205
bf756f6c3581
child 222
7b73058d782e
equal deleted inserted replaced
214:7961460e0d9e 215:781aee172901
49 static UcxMap *repos; 49 static UcxMap *repos;
50 static UcxMap *keys; 50 static UcxMap *keys;
51 static Proxy *http_proxy; 51 static Proxy *http_proxy;
52 static Proxy *https_proxy; 52 static Proxy *https_proxy;
53 53
54 int check_config_dir() { 54 int check_config_dir(void) {
55 char *file = util_concat_path(ENV_HOME, ".dav"); 55 char *file = util_concat_path(ENV_HOME, ".dav");
56 int ret = 0; 56 int ret = 0;
57 if(util_mkdir(file, S_IRWXU)) { 57 if(util_mkdir(file, S_IRWXU)) {
58 if(errno != EEXIST) { 58 if(errno != EEXIST) {
59 ret = 1; 59 ret = 1;
125 } 125 }
126 126
127 xmlFreeDoc(doc); 127 xmlFreeDoc(doc);
128 } 128 }
129 129
130 void free_config() { 130 void free_config(void) {
131 UcxMapIterator i = ucx_map_iterator(repos); 131 UcxMapIterator i = ucx_map_iterator(repos);
132 UcxKey k; 132 UcxKey k;
133 Repository *repo; 133 Repository *repo;
134 UCX_MAP_FOREACH(k, repo, i) { 134 UCX_MAP_FOREACH(k, repo, i) {
135 if(repo->default_key) { 135 if(repo->default_key) {
152 ucx_map_free(repos); 152 ucx_map_free(repos);
153 153
154 ucx_map_free(keys); 154 ucx_map_free(keys);
155 } 155 }
156 156
157 Repository* repository_new() { 157 Repository* repository_new(void) {
158 Repository *repo = calloc(1, sizeof(Repository)); 158 Repository *repo = calloc(1, sizeof(Repository));
159 repo->encrypt_name = false; 159 repo->encrypt_name = false;
160 repo->encrypt_content = false; 160 repo->encrypt_content = false;
161 repo->decrypt_name = false; 161 repo->decrypt_name = false;
162 repo->decrypt_content = true; 162 repo->decrypt_content = true;
475 return NULL; 475 return NULL;
476 } 476 }
477 return ucx_map_cstr_get(keys, name); 477 return ucx_map_cstr_get(keys, name);
478 } 478 }
479 479
480 Proxy* get_http_proxy() { 480 Proxy* get_http_proxy(void) {
481 return http_proxy; 481 return http_proxy;
482 } 482 }
483 483
484 Proxy* get_https_proxy() { 484 Proxy* get_https_proxy(void) {
485 return https_proxy; 485 return https_proxy;
486 } 486 }
487 487
488 488
489 int add_repository(Repository *repo) { 489 int add_repository(Repository *repo) {
539 UCX_MAP_FOREACH(key, repo, i) { 539 UCX_MAP_FOREACH(key, repo, i) {
540 printf("%s\n", repo->name); 540 printf("%s\n", repo->name);
541 } 541 }
542 return 0; 542 return 0;
543 } 543 }
544
545 UcxList* get_repositories(void) {
546 UcxList *list = NULL;
547 UcxMapIterator i = ucx_map_iterator(repos);
548 Repository *repo;
549 UCX_MAP_FOREACH(key, repo, i) {
550 list = ucx_list_append(list, repo);
551 }
552 return list;
553 }

mercurial