Changeset 1582
- Timestamp:
- 03/04/10 16:33:24 (6 months ago)
- Files:
-
- 1 modified
-
trunk/batctl/bat-hosts.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/batctl/bat-hosts.c
r1581 r1582 24 24 #include <stdio.h> 25 25 #include <stdint.h> 26 #include <limits.h> 26 27 #include <stdlib.h> 27 28 #include <errno.h> … … 145 146 void bat_hosts_init(void) 146 147 { 147 unsigned int i ;148 unsigned int i, j, parse; 148 149 char confdir[CONF_DIR_LEN]; 149 150 char *homedir; 151 size_t locations = sizeof(bat_hosts_path) / sizeof(char *); 152 char *normalized[locations]; 150 153 151 154 host_hash = hash_new(64, compare_mac, choose_mac); … … 158 161 homedir = getenv("HOME"); 159 162 160 for (i = 0; i < sizeof(bat_hosts_path) / sizeof(char *); i++) {163 for (i = 0; i < locations; i++) { 161 164 strcpy(confdir, ""); 162 165 … … 171 174 } 172 175 173 parse_hosts_file(&host_hash, confdir); 176 normalized[i] = realpath(confdir, NULL); 177 if (normalized[i] == NULL) 178 continue; 179 180 /* check for duplicates: don't parse the same file twice */ 181 parse = 1; 182 for (j = 0; j < i; j++) { 183 if (normalized[j] == NULL) 184 continue; 185 186 if (strncmp(normalized[i], normalized[j], CONF_DIR_LEN) == 0) { 187 parse = 0; 188 break; 189 } 190 } 191 192 if (parse && (normalized[i] != NULL)) 193 parse_hosts_file(&host_hash, normalized[i]); 194 } 195 196 for (i = 0; i < locations; i++) { 197 if (normalized[i]) 198 free(normalized[i]); 174 199 } 175 200 }
