Changeset 53972 in vbox
- Timestamp:
- Jan 27, 2015 10:50:42 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibRuntimeXF86.cpp
r52210 r53972 34 34 #include <iprt/log.h> 35 35 #include <iprt/mem.h> 36 #include <iprt/string.h>37 36 #if defined(VBOX_VBGLR3_XFREE86) 38 37 extern "C" { 39 38 # define XFree86LOADER 40 39 # include <xf86_ansic.h> 41 # include <errno.h>42 40 # undef size_t 43 41 } 44 42 #else 45 # include <ctype.h>46 # include <errno.h>47 43 # include <stdarg.h> 48 # include <stdio.h>49 44 # include <stdlib.h> 50 45 # define xalloc malloc 51 # define xf86vsnprintf vsnprintf52 # define xf86errno errno53 # define xf86strtoul strtoul54 # define xf86isspace isspace55 46 # define xfree free 56 47 extern "C" void ErrorF(const char *f, ...); 57 extern "C" void VErrorF(const char *f, va_list args);58 48 #endif 59 60 /* This is risky as it restricts call to the ANSI format type specifiers. */61 RTDECL(size_t) RTStrPrintf(char *pszBuffer, size_t cchBuffer, const char *pszFormat, ...)62 {63 va_list args;64 int cbRet;65 va_start(args, pszFormat);66 cbRet = xf86vsnprintf(pszBuffer, cchBuffer, pszFormat, args);67 va_end(args);68 return cbRet >= 0 ? cbRet : 0;69 }70 71 RTDECL(int) RTStrToUInt32Ex(const char *pszValue, char **ppszNext, unsigned uBase, uint32_t *pu32)72 {73 char *pszNext = NULL;74 xf86errno = 0;75 unsigned long ul = xf86strtoul(pszValue, &pszNext, uBase);76 if (ppszNext)77 *ppszNext = pszNext;78 if (RT_UNLIKELY(pszValue == pszNext))79 return VERR_NO_DIGITS;80 if (RT_UNLIKELY(ul > UINT32_MAX))81 ul = UINT32_MAX;82 if (pu32)83 *pu32 = (uint32_t) ul;84 if (RT_UNLIKELY(xf86errno == EINVAL))85 return VERR_INVALID_PARAMETER;86 if (RT_UNLIKELY(xf86errno == ERANGE))87 return VWRN_NUMBER_TOO_BIG;88 if (RT_UNLIKELY(xf86errno))89 /* RTErrConvertFromErrno() is not available */90 return VERR_UNRESOLVED_ERROR;91 if (RT_UNLIKELY(*pszValue == '-'))92 return VWRN_NEGATIVE_UNSIGNED;93 if (RT_UNLIKELY(*pszNext))94 {95 while (*pszNext)96 if (!xf86isspace(*pszNext))97 return VWRN_TRAILING_CHARS;98 return VWRN_TRAILING_SPACES;99 }100 return VINF_SUCCESS;101 }102 103 RTDECL(int) RTStrToUInt32Full(const char *pszValue, unsigned uBase, uint32_t *pu32)104 {105 char *psz;106 int rc = RTStrToUInt32Ex(pszValue, &psz, uBase, pu32);107 if (RT_SUCCESS(rc) && *psz)108 if (rc == VWRN_TRAILING_CHARS || rc == VWRN_TRAILING_SPACES)109 rc = -rc;110 return rc;111 }112 49 113 50 RTDECL(void) RTAssertMsg1Weak(const char *pszExpr, unsigned uLine, const char *pszFile, const char *pszFunction) … … 120 57 RTDECL(void) RTAssertMsg2Weak(const char *pszFormat, ...) 121 58 { 122 va_list args; 123 va_start(args, pszFormat); 124 VErrorF(pszFormat, args); 125 va_end(args); 59 NOREF(pszFormat); 126 60 } 127 61 … … 138 72 RTDECL(void) RTLogLoggerEx(PRTLOGGER, unsigned, unsigned, const char *pszFormat, ...) 139 73 { 140 va_list args; 141 va_start(args, pszFormat); 142 VErrorF(pszFormat, args); 143 va_end(args); 74 NOREF(pszFormat); 144 75 } 145 76 … … 154 85 xfree(pv); 155 86 } 156
Note:
See TracChangeset
for help on using the changeset viewer.

