Changeset 1210 for pjproject/branches/split-3rd-party/pjlib/src/pj/string.c
- Timestamp:
- Apr 22, 2007 12:48:30 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/split-3rd-party/pjlib/src/pj/string.c
r1125 r1210 18 18 */ 19 19 #include <pj/string.h> 20 #include <pj/assert.h> 20 21 #include <pj/pool.h> 21 22 #include <pj/ctype.h> … … 84 85 } 85 86 87 PJ_DEF(unsigned long) pj_strtoul2(const pj_str_t *str, pj_str_t *endptr, 88 unsigned base) 89 { 90 unsigned long value; 91 unsigned i; 92 93 PJ_CHECK_STACK(); 94 95 value = 0; 96 if (base <= 10) { 97 for (i=0; i<(unsigned)str->slen; ++i) { 98 unsigned c = (str->ptr[i] - '0'); 99 if (c >= base) 100 break; 101 value = value * base + c; 102 } 103 } else if (base == 16) { 104 for (i=0; i<(unsigned)str->slen; ++i) { 105 if (!pj_isxdigit(str->ptr[i])) 106 break; 107 value = value * 16 + pj_hex_digit_to_val(str->ptr[i]); 108 } 109 } else { 110 pj_assert(!"Unsupported base"); 111 i = 0; 112 value = 0xFFFFFFFFUL; 113 } 114 115 if (endptr) { 116 endptr->ptr = str->ptr + i; 117 endptr->slen = str->slen - i; 118 } 119 120 return value; 121 } 122 86 123 PJ_DEF(int) pj_utoa(unsigned long val, char *buf) 87 124 {
Note: See TracChangeset
for help on using the changeset viewer.