Changeset 13858
- Timestamp:
- Jan 24, 2013, 12:53:37 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/variant-json.c
r13687 r13858 153 153 decode_hex_string (const char * in, unsigned int * setme) 154 154 { 155 bool success; 156 char buf[5]; 157 char * end; 155 unsigned int val = 0; 156 const char * const end = in + 6; 158 157 159 158 assert (in != NULL); 160 159 assert (in[0] == '\\'); 161 160 assert (in[1] == 'u'); 162 163 memcpy (buf, in+2, 4); 164 buf[4] = '\0'; 165 *setme = strtoul (buf, &end, 16); 166 success = end == buf+4; 167 168 return success; 161 in += 2; 162 163 do 164 { 165 val <<= 4; 166 if (('0'<=*in) && (*in<='9')) 167 val += (*in-'0'); 168 else if (('a'<=*in) && (*in<='f')) 169 val += (*in-'a') + 10u; 170 else if (('A'<=*in) && (*in<='F')) 171 val += (*in-'A') + 10u; 172 else 173 return false; 174 } 175 while (++in != end); 176 177 *setme = val; 178 return true; 169 179 } 170 180
Note: See TracChangeset
for help on using the changeset viewer.