Changeset 4795
- Timestamp:
- 05/27/07 19:21:59 (2 years ago)
- Files:
-
- libwired/trunk/libwired/net/wi-host.c (modified) (6 diffs)
- libwired/trunk/libwired/net/wi-wired.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
libwired/trunk/libwired/net/wi-host.c
r4679 r4795 66 66 static wi_hash_code_t _wi_host_hash(wi_runtime_instance_t *); 67 67 68 static wi_array_t * _wi_host_a ll_interface_addresses(void);69 static wi_array_t * _wi_host_addresses_for_ string(wi_string_t *string);68 static wi_array_t * _wi_host_addresses_for_interface_string(wi_string_t *string); 69 static wi_array_t * _wi_host_addresses_for_host_string(wi_string_t *); 70 70 71 71 … … 209 209 #pragma mark - 210 210 211 static wi_array_t * _wi_host_a ll_interface_addresses(void) {212 #if defined(HAVE_GETIFADDRS) && !defined(HAVE_GLIBC)211 static wi_array_t * _wi_host_addresses_for_interface_string(wi_string_t *string) { 212 #ifdef HAVE_GETIFADDRS 213 213 wi_array_t *array; 214 214 wi_address_t *address; 215 215 struct ifaddrs *ifap, *ifp; 216 const char *name; 216 217 217 218 if(getifaddrs(&ifap) < 0) { … … 222 223 223 224 array = wi_array_init(wi_array_alloc()); 225 name = string ? wi_string_cstring(string) : NULL; 224 226 225 227 for(ifp = ifap; ifp; ifp = ifp->ifa_next) { … … 228 230 229 231 if(!(ifp->ifa_flags & IFF_UP)) 232 continue; 233 234 if(name && strcasecmp(ifp->ifa_name, name) != 0) 230 235 continue; 231 236 … … 258 263 259 264 260 static wi_array_t * _wi_host_addresses_for_ string(wi_string_t *string) {265 static wi_array_t * _wi_host_addresses_for_host_string(wi_string_t *string) { 261 266 wi_array_t *array; 262 267 wi_address_t *address; … … 319 324 320 325 wi_array_t * wi_host_addresses(wi_host_t *host) { 321 return host->string 322 ? _wi_host_addresses_for_string(host->string) 323 : _wi_host_all_interface_addresses(); 324 } 326 wi_array_t *addresses; 327 328 if(!host->string) { 329 addresses = _wi_host_addresses_for_interface_string(NULL); 330 } else { 331 addresses = _wi_host_addresses_for_host_string(host->string); 332 333 if(!addresses && wi_error_domain() == WI_ERROR_DOMAIN_GAI) 334 addresses = _wi_host_addresses_for_interface_string(host->string); 335 } 336 337 return addresses; 338 } libwired/trunk/libwired/net/wi-wired.c
r4767 r4795 77 77 *out_arguments = wi_autorelease(wi_array_init_with_string(wi_array_alloc(), substring, WI_STR(_WI_WIRED_FIELD_SEPARATOR))); 78 78 } else { 79 *out_command = wi_autorelease(wi_retain(string));79 *out_command = string; 80 80 *out_arguments = wi_array(); 81 81 }
