Changeset 13819
- Timestamp:
- Jan 21, 2013, 1:26:59 AM (8 years ago)
- Location:
- trunk/libtransmission
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/jsonsl.c
r13615 r13819 148 148 149 149 JSONSL_API 150 jsonsl_t jsonsl_new( size_t nlevels)150 jsonsl_t jsonsl_new(int nlevels) 151 151 { 152 152 struct jsonsl_st *jsn = … … 164 164 void jsonsl_reset(jsonsl_t jsn) 165 165 { 166 size_t ii;166 unsigned int ii; 167 167 jsn->tok_last = 0; 168 168 jsn->can_insert = 1; … … 682 682 *(c+3) = origc; 683 683 684 *outp = pctval;684 *outp = (char) pctval; 685 685 c += 2; 686 686 continue; … … 793 793 jsonsl_jpr_match(jsonsl_jpr_t jpr, 794 794 jsonsl_type_t parent_type, 795 size_t parent_level,795 unsigned int parent_level, 796 796 const char *key, 797 797 size_t nkey) … … 940 940 941 941 if (parent_state->type == JSONSL_T_LIST) { 942 nkey = parent_state->nelem;942 nkey = (size_t) parent_state->nelem; 943 943 } 944 944 … … 1014 1014 *err = JSONSL_ERROR_##e; \ 1015 1015 if (errat) { \ 1016 *errat = (const char*)(c+ ( ssize_t)(offset)); \1016 *errat = (const char*)(c+ (ptrdiff_t)(offset)); \ 1017 1017 } \ 1018 1018 return 0; -
trunk/libtransmission/jsonsl.h
r13614 r13819 38 38 #include <stdio.h> 39 39 #include <stdlib.h> 40 #include <stddef.h> 40 41 #include <string.h> 41 42 #include <sys/types.h> … … 55 56 56 57 /* Stolen from http-parser.h, and possibly others */ 57 #if defined(_WIN32) && !defined(__MINGW32__) && (!defined(_MSC_VER) || _MSC_VER<1600)58 #if defined(_WIN32) && !defined(__MINGW32__) 58 59 typedef __int8 int8_t; 59 60 typedef unsigned __int8 uint8_t; … … 64 65 typedef __int64 int64_t; 65 66 typedef unsigned __int64 uint64_t; 66 67 #if !defined(_MSC_VER) || _MSC_VER<1400 67 68 typedef unsigned int size_t; 68 69 typedef int ssize_t; 70 #endif 69 71 #else 70 72 #include <stdint.h> … … 237 239 238 240 /** 239 * A state is a single level of the stack 241 * A state is a single level of the stack. 242 * Non-private data (i.e. the 'data' field, see the STATE_GENERIC section) 243 * will remain in tact until the item is popped. 244 * 245 * As a result, it means a parent state object may be accessed from a child 246 * object, (the parents fields will all be valid). This allows a user to create 247 * an ad-hoc hierarchy on top of the JSON one. 248 * 240 249 */ 241 250 struct jsonsl_state_st { … … 261 270 262 271 /** 263 * The position at which any immediate child was last POPped 272 * The position at which any immediate child was last POPped. 273 * Note that this field is only set when the item is popped. 264 274 */ 265 275 size_t pos_cur; … … 271 281 * level parameter (though the logic is not that simple) 272 282 */ 273 size_t level;283 unsigned int level; 274 284 275 285 … … 305 315 /** 306 316 * Put anything you want here. if JSONSL_STATE_USER_FIELDS is here, then 307 * the macro expansion happens here 317 * the macro expansion happens here. 318 * 319 * You can use these fields to store hierarchical or 'tagging' information 320 * for specific objects. 321 * 322 * See the documentation above for the lifetime of the state object (i.e. 323 * if the private data points to allocated memory, it should be freed 324 * when the object is popped, as the state object will be re-used) 308 325 */ 309 326 #ifndef JSONSL_STATE_GENERIC … … 392 409 393 410 /** This is the current level of the stack */ 394 size_t level;411 unsigned int level; 395 412 396 413 /** … … 472 489 char tok_last; 473 490 int can_insert; 474 size_t levels_max;491 unsigned int levels_max; 475 492 476 493 #ifndef JSONSL_NO_JPR 477 unsigned int jpr_count;494 size_t jpr_count; 478 495 jsonsl_jpr_t *jprs; 479 496 … … 498 515 */ 499 516 JSONSL_API 500 jsonsl_t jsonsl_new( size_t nlevels);517 jsonsl_t jsonsl_new(int nlevels); 501 518 502 519 /** … … 698 715 * this should be the current index. 699 716 * 717 * NOTE: The key of the child means any kind of associative data related to the 718 * element. Thus: <<< { "foo" : [ >>, 719 * the opening array's key is "foo". 720 * 700 721 * @return a status constant. This indicates whether a match was excluded, possible, 701 722 * or successful. … … 704 725 jsonsl_jpr_match_t jsonsl_jpr_match(jsonsl_jpr_t jpr, 705 726 jsonsl_type_t parent_type, 706 size_t parent_level,727 unsigned int parent_level, 707 728 const char *key, size_t nkey); 708 729
Note: See TracChangeset
for help on using the changeset viewer.