strtonum.cpp revision f0b204548770be4884950650a101d87e35adc215
667f741ffdced56a2059511ce99372ebdd62a115vboxsync 255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync 255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255, 0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
255,
255,
255,
255,
255,
255,
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync 255,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
255,
255,
255,
255,
255,
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync 255,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
255,
255,
255,
255,
255,
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync 255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync 255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync 255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
18470279db8a9fdd714617adbe1aa8b63cc80aeevboxsync 255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255,
255 10330aa61b0abd8a82e3dd9fb2ad064ec64ac900vboxsync 64,
64,
63,
63,
62,
62,
62,
62,
61,
61,
61,
61,
61,
61,
61,
61,
60,
60,
60,
60,
60,
60,
60,
60,
60,
60,
60,
60,
60,
60,
60,
60,
59,
59,
59,
59 for (i = 0; i < 256; i++) if (i >= '0' && i <= '9') else if (i >= 'a' && i <= 'z') else if (i >= 'A' && i <= 'Z') * Converts a string representation of a number to a 64-bit unsigned number. * @returns iprt status code. * Warnings are used to indicate convertion problems. * @retval VWRN_NUMBER_TOO_BIG * @retval VWRN_NEGATIVE_UNSIGNED * @retval VWRN_TRAILING_CHARS * @retval VWRN_TRAILING_SPACES * @param pszValue Pointer to the string value. * @param ppszNext Where to store the pointer to the first char following the number. (Optional) * @param uBase The base of the representation used. * If the function will look for known prefixes before defaulting to 10. * @param pu64 Where to store the converted number. (optional) && (
psz[
1] ==
'x' ||
psz[
1] ==
'X')
&& (
psz[
1] ==
'x' ||
psz[
1] ==
'X')
* Note: We only support ascii digits at this time... :-) pszValue =
psz;
/* (Prefix and sign doesn't count in the digit counting.) */ while ((
uch = (
unsigned char)*
psz) != 0)
while (*
psz ==
' ' || *
psz ==
'\t')
* Converts a string representation of a number to a 64-bit unsigned number, * making sure the full string is converted. * @returns iprt status code. * Warnings are used to indicate convertion problems. * @retval VWRN_NUMBER_TOO_BIG * @retval VWRN_NEGATIVE_UNSIGNED * @retval VERR_TRAILING_SPACES * @retval VERR_TRAILING_CHARS * @param pszValue Pointer to the string value. * @param uBase The base of the representation used. * If the function will look for known prefixes before defaulting to 10. * @param pu64 Where to store the converted number. (optional) while (*
psz ==
' ' || *
psz ==
'\t')
* Converts a string representation of a number to a 64-bit unsigned number. * @returns 64-bit unsigned number on success. * @param pszValue Pointer to the string value. * Converts a string representation of a number to a 32-bit unsigned number. * @returns iprt status code. * Warnings are used to indicate convertion problems. * @retval VWRN_NUMBER_TOO_BIG * @retval VWRN_NEGATIVE_UNSIGNED * @retval VWRN_TRAILING_CHARS * @retval VWRN_TRAILING_SPACES * @param pszValue Pointer to the string value. * @param ppszNext Where to store the pointer to the first char following the number. (Optional) * @param uBase The base of the representation used. * If the function will look for known prefixes before defaulting to 10. * @param pu32 Where to store the converted number. (optional) if (
u64 & ~
0xffffffffULL)
* Converts a string representation of a number to a 32-bit unsigned number, * making sure the full string is converted. * @returns iprt status code. * Warnings are used to indicate convertion problems. * @retval VWRN_NUMBER_TOO_BIG * @retval VWRN_NEGATIVE_UNSIGNED * @retval VERR_TRAILING_SPACES * @retval VERR_TRAILING_CHARS * @param pszValue Pointer to the string value. * @param uBase The base of the representation used. * If the function will look for known prefixes before defaulting to 10. * @param pu32 Where to store the converted number. (optional) if (
u64 & ~
0xffffffffULL)
* Converts a string representation of a number to a 64-bit unsigned number. * @returns 32-bit unsigned number on success. * @param pszValue Pointer to the string value. * Converts a string representation of a number to a 16-bit unsigned number. * @returns iprt status code. * Warnings are used to indicate convertion problems. * @retval VWRN_NUMBER_TOO_BIG * @retval VWRN_NEGATIVE_UNSIGNED * @retval VWRN_TRAILING_CHARS * @retval VWRN_TRAILING_SPACES * @param pszValue Pointer to the string value. * @param ppszNext Where to store the pointer to the first char following the number. (Optional) * @param uBase The base of the representation used. * If the function will look for known prefixes before defaulting to 10. * @param pu16 Where to store the converted number. (optional) * Converts a string representation of a number to a 16-bit unsigned number, * making sure the full string is converted. * @returns iprt status code. * Warnings are used to indicate convertion problems. * @retval VWRN_NUMBER_TOO_BIG * @retval VWRN_NEGATIVE_UNSIGNED * @retval VERR_TRAILING_SPACES * @retval VERR_TRAILING_CHARS * @param pszValue Pointer to the string value. * @param uBase The base of the representation used. * If the function will look for known prefixes before defaulting to 10. * @param pu16 Where to store the converted number. (optional) * Converts a string representation of a number to a 16-bit unsigned number. * @returns 16-bit unsigned number on success. * @param pszValue Pointer to the string value. * Converts a string representation of a number to a 8-bit unsigned number. * @returns iprt status code. * Warnings are used to indicate convertion problems. * @retval VWRN_NUMBER_TOO_BIG * @retval VWRN_NEGATIVE_UNSIGNED * @retval VWRN_TRAILING_CHARS * @retval VWRN_TRAILING_SPACES * @param pszValue Pointer to the string value. * @param ppszNext Where to store the pointer to the first char following the number. (Optional) * @param uBase The base of the representation used. * If the function will look for known prefixes before defaulting to 10. * @param pu8 Where to store the converted number. (optional) * Converts a string representation of a number to a 8-bit unsigned number, * making sure the full string is converted. * @returns iprt status code. * Warnings are used to indicate convertion problems. * @retval VWRN_NUMBER_TOO_BIG * @retval VWRN_NEGATIVE_UNSIGNED * @retval VERR_TRAILING_SPACES * @retval VERR_TRAILING_CHARS * @param pszValue Pointer to the string value. * @param uBase The base of the representation used. * If the function will look for known prefixes before defaulting to 10. * @param pu8 Where to store the converted number. (optional) * Converts a string representation of a number to a 8-bit unsigned number. * @returns 8-bit unsigned number on success. * @param pszValue Pointer to the string value. * Converts a string representation of a number to a 64-bit signed number. * @returns iprt status code. * Warnings are used to indicate convertion problems. * @retval VWRN_NUMBER_TOO_BIG * @retval VWRN_TRAILING_CHARS * @retval VWRN_TRAILING_SPACES * @param pszValue Pointer to the string value. * @param ppszNext Where to store the pointer to the first char following the number. (Optional) * @param uBase The base of the representation used. * If the function will look for known prefixes before defaulting to 10. * @param pi64 Where to store the converted number. (optional) && (
psz[
1] ==
'x' ||
psz[
1] ==
'X')
&& (
psz[
1] ==
'x' ||
psz[
1] ==
'X')
* Note: We only support ascii digits at this time... :-) pszValue =
psz;
/* (Prefix and sign doesn't count in the digit counting.) */ while ((
uch = (
unsigned char)*
psz) != 0)
while (*
psz ==
' ' || *
psz ==
'\t')
* Converts a string representation of a number to a 64-bit signed number, * making sure the full string is converted. * @returns iprt status code. * Warnings are used to indicate convertion problems. * @retval VWRN_NUMBER_TOO_BIG * @retval VERR_TRAILING_CHARS * @retval VERR_TRAILING_SPACES * @param pszValue Pointer to the string value. * @param uBase The base of the representation used. * If the function will look for known prefixes before defaulting to 10. * @param pi64 Where to store the converted number. (optional) while (*
psz ==
' ' || *
psz ==
'\t')
* Converts a string representation of a number to a 64-bit signed number. * @returns 64-bit signed number on success. * @param pszValue Pointer to the string value. * Converts a string representation of a number to a 32-bit signed number. * @returns iprt status code. * Warnings are used to indicate convertion problems. * @retval VWRN_NUMBER_TOO_BIG * @retval VWRN_TRAILING_CHARS * @retval VWRN_TRAILING_SPACES * @param pszValue Pointer to the string value. * @param ppszNext Where to store the pointer to the first char following the number. (Optional) * @param uBase The base of the representation used. * If the function will look for known prefixes before defaulting to 10. * @param pi32 Where to store the converted number. (optional) * Converts a string representation of a number to a 32-bit signed number, * making sure the full string is converted. * @returns iprt status code. * Warnings are used to indicate convertion problems. * @retval VWRN_NUMBER_TOO_BIG * @retval VERR_TRAILING_CHARS * @retval VERR_TRAILING_SPACES * @param pszValue Pointer to the string value. * @param uBase The base of the representation used. * If the function will look for known prefixes before defaulting to 10. * @param pi32 Where to store the converted number. (optional) * Converts a string representation of a number to a 32-bit signed number. * @returns 32-bit signed number on success. * @param pszValue Pointer to the string value. * Converts a string representation of a number to a 16-bit signed number. * @returns iprt status code. * Warnings are used to indicate convertion problems. * @retval VWRN_NUMBER_TOO_BIG * @retval VWRN_TRAILING_CHARS * @retval VWRN_TRAILING_SPACES * @param pszValue Pointer to the string value. * @param ppszNext Where to store the pointer to the first char following the number. (Optional) * @param uBase The base of the representation used. * If the function will look for known prefixes before defaulting to 10. * @param pi16 Where to store the converted number. (optional) * Converts a string representation of a number to a 16-bit signed number, * making sure the full string is converted. * @returns iprt status code. * Warnings are used to indicate convertion problems. * @retval VWRN_NUMBER_TOO_BIG * @retval VERR_TRAILING_CHARS * @retval VERR_TRAILING_SPACES * @param pszValue Pointer to the string value. * @param uBase The base of the representation used. * If the function will look for known prefixes before defaulting to 10. * @param pi16 Where to store the converted number. (optional) * Converts a string representation of a number to a 16-bit signed number. * @returns 16-bit signed number on success. * @param pszValue Pointer to the string value. * Converts a string representation of a number to a 8-bit signed number. * @returns iprt status code. * Warnings are used to indicate convertion problems. * @retval VWRN_NUMBER_TOO_BIG * @retval VWRN_TRAILING_CHARS * @retval VWRN_TRAILING_SPACES * @param pszValue Pointer to the string value. * @param ppszNext Where to store the pointer to the first char following the number. (Optional) * @param uBase The base of the representation used. * If the function will look for known prefixes before defaulting to 10. * @param pi8 Where to store the converted number. (optional) * Converts a string representation of a number to a 8-bit signed number, * making sure the full string is converted. * @returns iprt status code. * Warnings are used to indicate convertion problems. * @retval VWRN_NUMBER_TOO_BIG * @retval VERR_TRAILING_CHARS * @retval VERR_TRAILING_SPACES * @param pszValue Pointer to the string value. * @param uBase The base of the representation used. * If the function will look for known prefixes before defaulting to 10. * @param pi8 Where to store the converted number. (optional) * Converts a string representation of a number to a 8-bit signed number. * @returns 8-bit signed number on success. * @param pszValue Pointer to the string value.