Changeset 50418 in vbox for trunk/src/VBox/Runtime/common/net/netaddrstr2.cpp
- Timestamp:
- Feb 11, 2014 6:50:58 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/net/netaddrstr2.cpp
r48935 r50418 36 36 #include "internal/string.h" 37 37 38 RTDECL(int) RTNetStrToIPv4Addr(const char *pszAddr, PRTNETADDRIPV4 pAddr) 38 39 DECLHIDDEN(int) rtNetStrToIPv4AddrEx(const char *pcszAddr, PRTNETADDRIPV4 pAddr, 40 char **ppszNext) 39 41 { 40 42 char *pszNext; 41 AssertPtrReturn(pszAddr, VERR_INVALID_PARAMETER); 43 int rc; 44 45 AssertPtrReturn(pcszAddr, VERR_INVALID_PARAMETER); 42 46 AssertPtrReturn(pAddr, VERR_INVALID_PARAMETER); 43 47 44 int rc = RTStrToUInt8Ex(RTStrStripL(pszAddr), &pszNext, 10, &pAddr->au8[0]);48 rc = RTStrToUInt8Ex(pcszAddr, &pszNext, 10, &pAddr->au8[0]); 45 49 if (rc != VINF_SUCCESS && rc != VWRN_TRAILING_CHARS) 46 50 return VERR_INVALID_PARAMETER; … … 61 65 62 66 rc = RTStrToUInt8Ex(pszNext, &pszNext, 10, &pAddr->au8[3]); 63 if (rc != VINF_SUCCESS && rc != VWRN_TRAILING_SPACES )67 if (rc != VINF_SUCCESS && rc != VWRN_TRAILING_SPACES && rc != VWRN_TRAILING_CHARS) 64 68 return VERR_INVALID_PARAMETER; 69 70 if (ppszNext != NULL) 71 *ppszNext = pszNext; 72 return VINF_SUCCESS; 73 } 74 75 76 RTDECL(int) RTNetStrToIPv4AddrEx(const char *pcszAddr, PRTNETADDRIPV4 pAddr, 77 char **ppszNext) 78 { 79 return rtNetStrToIPv4AddrEx(pcszAddr, pAddr, ppszNext); 80 } 81 RT_EXPORT_SYMBOL(RTNetStrToIPv4AddrEx); 82 83 84 RTDECL(int) RTNetStrToIPv4Addr(const char *pcszAddr, PRTNETADDRIPV4 pAddr) 85 { 86 char *pszNext; 87 int rc; 88 89 AssertPtrReturn(pcszAddr, VERR_INVALID_PARAMETER); 90 AssertPtrReturn(pAddr, VERR_INVALID_PARAMETER); 91 92 pcszAddr = RTStrStripL(pcszAddr); 93 rc = rtNetStrToIPv4AddrEx(pcszAddr, pAddr, &pszNext); 94 if (rc != VINF_SUCCESS) 95 return VERR_INVALID_PARAMETER; 96 65 97 pszNext = RTStrStripL(pszNext); 66 if (*pszNext )98 if (*pszNext != '\0') 67 99 return VERR_INVALID_PARAMETER; 68 100 … … 71 103 RT_EXPORT_SYMBOL(RTNetStrToIPv4Addr); 72 104 105 106 RTDECL(bool) RTNetIsIPv4AddrStr(const char *pcszAddr) 107 { 108 RTNETADDRIPV4 addrIPv4; 109 char *pszNext; 110 int rc; 111 112 if (pcszAddr == NULL) 113 return false; 114 115 rc = rtNetStrToIPv4AddrEx(pcszAddr, &addrIPv4, &pszNext); 116 if (rc != VINF_SUCCESS) 117 return false; 118 119 if (*pszNext != '\0') 120 return false; 121 122 return true; 123 } 124 RT_EXPORT_SYMBOL(RTNetIsIPv4AddrStr);
Note:
See TracChangeset
for help on using the changeset viewer.