Changeset 45115 in vbox for trunk/src/VBox
- Timestamp:
- Mar 21, 2013 8:01:54 AM (12 years ago)
- Location:
- trunk/src/VBox/Runtime/common
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/misc/getopt.cpp
r44528 r45115 93 93 * Converts an stringified IPv4 address into the RTNETADDRIPV4 representation. 94 94 * 95 * @todo This should be move to some generic part of the runtime.96 *97 95 * @returns VINF_SUCCESS on success, VERR_GETOPT_INVALID_ARGUMENT_FORMAT on 98 96 * failure. … … 103 101 static int rtgetoptConvertIPv4Addr(const char *pszValue, PRTNETADDRIPV4 pAddr) 104 102 { 105 char *pszNext; 106 int rc = RTStrToUInt8Ex(RTStrStripL(pszValue), &pszNext, 10, &pAddr->au8[0]); 107 if (rc != VINF_SUCCESS && rc != VWRN_TRAILING_CHARS) 108 return VERR_GETOPT_INVALID_ARGUMENT_FORMAT; 109 if (*pszNext++ != '.') 110 return VERR_GETOPT_INVALID_ARGUMENT_FORMAT; 111 112 rc = RTStrToUInt8Ex(pszNext, &pszNext, 10, &pAddr->au8[1]); 113 if (rc != VINF_SUCCESS && rc != VWRN_TRAILING_CHARS) 114 return VERR_GETOPT_INVALID_ARGUMENT_FORMAT; 115 if (*pszNext++ != '.') 116 return VERR_GETOPT_INVALID_ARGUMENT_FORMAT; 117 118 rc = RTStrToUInt8Ex(pszNext, &pszNext, 10, &pAddr->au8[2]); 119 if (rc != VINF_SUCCESS && rc != VWRN_TRAILING_CHARS) 120 return VERR_GETOPT_INVALID_ARGUMENT_FORMAT; 121 if (*pszNext++ != '.') 122 return VERR_GETOPT_INVALID_ARGUMENT_FORMAT; 123 124 rc = RTStrToUInt8Ex(pszNext, &pszNext, 10, &pAddr->au8[3]); 125 if (rc != VINF_SUCCESS && rc != VWRN_TRAILING_SPACES) 126 return VERR_GETOPT_INVALID_ARGUMENT_FORMAT; 127 pszNext = RTStrStripL(pszNext); 128 if (*pszNext) 129 return VERR_GETOPT_INVALID_ARGUMENT_FORMAT; 130 103 if (RT_FAILURE(RTNetStrToIPv4Addr(pszValue, pAddr))) 104 return VERR_GETOPT_INVALID_ARGUMENT_FORMAT; 131 105 return VINF_SUCCESS; 132 106 } -
trunk/src/VBox/Runtime/common/net/netaddrstr.cpp
r43221 r45115 1285 1285 RT_EXPORT_SYMBOL(RTNetIsIPv4AddrStr); 1286 1286 1287 RTDECL(int) RTNetStrToIPv4Addr(const char *pszAddr, PRTNETADDRIPV4 pAddr) 1288 { 1289 char *pszNext; 1290 AssertPtrReturn(pszAddr, VERR_INVALID_PARAMETER); 1291 AssertPtrReturn(pAddr, VERR_INVALID_PARAMETER); 1292 1293 int rc = RTStrToUInt8Ex(RTStrStripL(pszAddr), &pszNext, 10, &pAddr->au8[0]); 1294 if (rc != VINF_SUCCESS && rc != VWRN_TRAILING_CHARS) 1295 return VERR_INVALID_PARAMETER; 1296 if (*pszNext++ != '.') 1297 return VERR_INVALID_PARAMETER; 1298 1299 rc = RTStrToUInt8Ex(pszNext, &pszNext, 10, &pAddr->au8[1]); 1300 if (rc != VINF_SUCCESS && rc != VWRN_TRAILING_CHARS) 1301 return VERR_INVALID_PARAMETER; 1302 if (*pszNext++ != '.') 1303 return VERR_INVALID_PARAMETER; 1304 1305 rc = RTStrToUInt8Ex(pszNext, &pszNext, 10, &pAddr->au8[2]); 1306 if (rc != VINF_SUCCESS && rc != VWRN_TRAILING_CHARS) 1307 return VERR_INVALID_PARAMETER; 1308 if (*pszNext++ != '.') 1309 return VERR_INVALID_PARAMETER; 1310 1311 rc = RTStrToUInt8Ex(pszNext, &pszNext, 10, &pAddr->au8[3]); 1312 if (rc != VINF_SUCCESS && rc != VWRN_TRAILING_SPACES) 1313 return VERR_INVALID_PARAMETER; 1314 pszNext = RTStrStripL(pszNext); 1315 if (*pszNext) 1316 return VERR_INVALID_PARAMETER; 1317 1318 return VINF_SUCCESS; 1319 } 1320 RT_EXPORT_SYMBOL(RTNetStrToIPv4Addr);
Note:
See TracChangeset
for help on using the changeset viewer.