Changeset 212 for trunk/src/sh_portcheck.c
- Timestamp:
- Feb 17, 2009, 10:37:42 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/sh_portcheck.c
r210 r212 1218 1218 /* Subroutine to add an interface 1219 1219 */ 1220 static void * sh_dummy_str = NULL; /* fix clobbered by.. warning */ 1221 1220 1222 static int sh_portchk_add_interface (const char * str) 1221 1223 { 1222 1224 struct in_addr haddr; 1223 1225 char errbuf[256]; 1226 char buf[64]; 1227 1228 sh_dummy_str = (void*) &str; 1224 1229 1225 1230 if (iface_initialized == 0) … … 1229 1234 } 1230 1235 1231 if (0 == inet_aton(str, &haddr)) 1232 return -1; 1233 1234 if (iface_list.used == SH_IFACE_MAX) 1235 return -1; 1236 1237 sl_snprintf(errbuf, sizeof(errbuf), _("interface: %s"), inet_ntoa(haddr)); 1238 SH_MUTEX_LOCK(mutex_thread_nolog); 1239 sh_error_handle(SH_ERR_INFO, FIL__, __LINE__, 0, MSG_E_SUBGEN, 1240 errbuf, _("sh_portchk_add_interface")); 1241 SH_MUTEX_UNLOCK(mutex_thread_nolog); 1242 1243 memcpy (&(iface_list.iface[iface_list.used].s_addr), &(haddr.s_addr), sizeof(in_addr_t)); 1244 ++iface_list.used; 1236 do { 1237 1238 while (*str == ',' || *str == ' ' || *str == '\t') ++str; 1239 1240 if (*str) 1241 { 1242 unsigned int i = 0; 1243 while (*str && i < (sizeof(buf)-1) && *str != ',' && *str != ' ' && *str != '\t') 1244 { 1245 buf[i] = *str; ++str; ++i; 1246 } 1247 buf[i] = '\0'; 1248 1249 if (0 == inet_aton(buf, &haddr)) 1250 return -1; 1251 1252 if (iface_list.used == SH_IFACE_MAX) 1253 return -1; 1254 1255 sl_snprintf(errbuf, sizeof(errbuf), _("interface: %s"), inet_ntoa(haddr)); 1256 SH_MUTEX_LOCK(mutex_thread_nolog); 1257 sh_error_handle(SH_ERR_INFO, FIL__, __LINE__, 0, MSG_E_SUBGEN, 1258 errbuf, _("sh_portchk_add_interface")); 1259 SH_MUTEX_UNLOCK(mutex_thread_nolog); 1260 1261 memcpy (&(iface_list.iface[iface_list.used].s_addr), &(haddr.s_addr), sizeof(in_addr_t)); 1262 ++iface_list.used; 1263 } 1264 } while (*str); 1245 1265 1246 1266 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.