| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
#include "config.h" |
| 30 |
|
| 31 |
#include "log.h" |
| 32 |
#include "util.h" |
| 33 |
#include <stddef.h> |
| 34 |
#include <stdlib.h> |
| 35 |
|
| 36 |
|
| 37 |
ConfigStruct CONFIG; |
| 38 |
|
| 39 |
void Config_init(void) |
| 40 |
{ |
| 41 |
CONFIG.mode = NORMAL; |
| 42 |
|
| 43 |
CONFIG.log_type = log_level_init(); |
| 44 |
|
| 45 |
|
| 46 |
CONFIG.http_username = NULL; |
| 47 |
|
| 48 |
CONFIG.http_password = NULL; |
| 49 |
|
| 50 |
CONFIG.proxy = NULL; |
| 51 |
|
| 52 |
CONFIG.proxy_username = NULL; |
| 53 |
|
| 54 |
CONFIG.proxy_password = NULL; |
| 55 |
|
| 56 |
CONFIG.proxy_cafile = NULL; |
| 57 |
|
| 58 |
CONFIG.proxy_capath = NULL; |
| 59 |
|
| 60 |
CONFIG.max_conns = DEFAULT_NETWORK_MAX_CONNS; |
| 61 |
|
| 62 |
CONFIG.user_agent = DEFAULT_USER_AGENT; |
| 63 |
|
| 64 |
CONFIG.http_wait_sec = DEFAULT_HTTP_WAIT_SEC; |
| 65 |
|
| 66 |
CONFIG.http_headers = NULL; |
| 67 |
|
| 68 |
CONFIG.no_range_check = 0; |
| 69 |
|
| 70 |
CONFIG.zero_len_is_dir = 0; |
| 71 |
|
| 72 |
CONFIG.insecure_tls = 0; |
| 73 |
|
| 74 |
CONFIG.cafile = NULL; |
| 75 |
|
| 76 |
CONFIG.capath = NULL; |
| 77 |
|
| 78 |
CONFIG.refresh_timeout = DEFAULT_REFRESH_TIMEOUT; |
| 79 |
|
| 80 |
CONFIG.invalid_refresh = 0; |
| 81 |
|
| 82 |
|
| 83 |
CONFIG.cache_enabled = 0; |
| 84 |
|
| 85 |
CONFIG.cache_dir = NULL; |
| 86 |
|
| 87 |
CONFIG.data_blksz = DEFAULT_DATA_BLKSZ; |
| 88 |
|
| 89 |
CONFIG.cache_min_size = -1; |
| 90 |
CONFIG.cache_max_size = -1; |
| 91 |
|
| 92 |
|
| 93 |
CONFIG.sonic_username = NULL; |
| 94 |
|
| 95 |
CONFIG.sonic_password = NULL; |
| 96 |
|
| 97 |
CONFIG.sonic_id3 = 0; |
| 98 |
|
| 99 |
CONFIG.sonic_insecure = 0; |
| 100 |
atexit(mem_cleanup); |
| 101 |
} |
| 102 |
|
| 103 |
void Config_cleanup(void) |
| 104 |
{ |
| 105 |
FREE(CONFIG.http_username); |
| 106 |
FREE(CONFIG.http_password); |
| 107 |
FREE(CONFIG.proxy); |
| 108 |
FREE(CONFIG.proxy_username); |
| 109 |
FREE(CONFIG.proxy_password); |
| 110 |
FREE(CONFIG.proxy_cafile); |
| 111 |
FREE(CONFIG.proxy_capath); |
| 112 |
if (CONFIG.user_agent |
| 113 |
&& strcmp(CONFIG.user_agent, DEFAULT_USER_AGENT) != 0) { |
| 114 |
FREE(CONFIG.user_agent); |
| 115 |
} |
| 116 |
FREE(CONFIG.cafile); |
| 117 |
FREE(CONFIG.capath); |
| 118 |
FREE(CONFIG.cache_dir); |
| 119 |
FREE(CONFIG.sonic_username); |
| 120 |
FREE(CONFIG.sonic_password); |
| 121 |
} |