Changeset 8e3b7ac for lib


Ignore:
Timestamp:
2012-11-08T22:38:20Z (11 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
fb351ce
Parents:
0688e99
Message:

It logs in and fetches statuses! \o/ But, some corruption..

Location:
lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • lib/json_util.c

    r0688e99 r8e3b7ac  
    2727#include "json_util.h"
    2828
    29 json_value *json_o_get( json_value *obj, json_char *name )
     29json_value *json_o_get( const json_value *obj, const json_char *name )
    3030{
    3131        int i;
     
    4141}
    4242
    43 const char *json_o_str( json_value *obj, json_char *name )
     43const char *json_o_str( const json_value *obj, const json_char *name )
    4444{
    4545        json_value *ret = json_o_get( obj, name );
    4646       
    47         if( ret )
     47        if( ret && ret->type == json_string )
    4848                return ret->u.string.ptr;
    4949        else
    5050                return NULL;
    5151}
     52
     53char *json_o_strdup( const json_value *obj, const json_char *name )
     54{
     55        json_value *ret = json_o_get( obj, name );
     56       
     57        if( ret && ret->type == json_string && ret->u.string.ptr )
     58                return g_memdup( ret->u.string.ptr, ret->u.string.length + 1 );
     59        else
     60                return NULL;
     61}
  • lib/json_util.h

    r0688e99 r8e3b7ac  
    2424#include "json.h"
    2525
    26 json_value *json_o_get( json_value *obj, json_char *name );
    27 const char *json_o_str( json_value *obj, json_char *name );
     26#define JSON_O_FOREACH(o, k, v) \
     27        char *k; json_value *v; int __i; \
     28        for( __i = 0; k = (o)->u.object.values[__i].name, \
     29                      v = (o)->u.object.values[__i].value, \
     30                      __i < (o)->u.object.length; __i ++ )
     31
     32json_value *json_o_get( const json_value *obj, const json_char *name );
     33const char *json_o_str( const json_value *obj, const json_char *name );
     34char *json_o_strdup( const json_value *obj, const json_char *name );
Note: See TracChangeset for help on using the changeset viewer.