예제 #1
0
void ajv_state_mark_seen(ajv_state s, const ajv_node *node) {
  ajv_node_state ns;
  ns = (ajv_node_state)orderly_ps_current(s->node_state);
  if (node->parent && node->parent->node->t == orderly_node_union) {
    orderly_ps_push(s->AF, ns->seen, (void *)(node->parent));
  } else {
    orderly_ps_push(s->AF, ns->seen, (void *)(node));
  }
  /* advance the current pointer if we're checking a tuple typed array */
  if (node->parent &&
      node->parent->node->t == orderly_node_array &&
      node->parent->node->tuple_typed) {
    if (node->sibling) {
      s->node = s->node->sibling;
    } else {
      /* otherwise, put us into schemaless mode */
      ((orderly_node *)(s->any.node))->t = 
        ajv_state_parent(s)->node->additional_properties; 
      s->any.sibling = &(s->any);
      s->depth = 0;
      s->any.parent = ajv_state_parent(s);
      s->node = &(s->any);
    }
  }
}
예제 #2
0
int o_json_parse_start_map(void * ctx)
{
    o_json_parse_context * pc = (o_json_parse_context *) ctx;
    orderly_json * n = orderly_alloc_json(pc->alloc, orderly_json_object);
    orderly_ps_push(pc->alloc, pc->nodeStack, n);
    return 1;
}
예제 #3
0
int o_json_parse_map_key(void * ctx, const unsigned char * v,
                         unsigned int l)
{
    o_json_parse_context * pc = (o_json_parse_context *) ctx;
    char * k = NULL;
    BUF_STRDUP(k, pc->alloc, v, l);
    orderly_ps_push(pc->alloc, pc->keyStack, k);
    return 1;
}
예제 #4
0
void ajv_state_push(ajv_state state, const ajv_node *n) {
  ajv_node_state s = ajv_alloc_node_state(state->AF, n);
  /* only maps and array have children */
  assert(n->node->t == orderly_node_object
         || n->node->t == orderly_node_array);
  s->node = state->node;
  orderly_ps_push(state->AF, state->node_state, s);

  state->node = state->node->child;
}
예제 #5
0
yajl_status ajv_validate(ajv_handle hand,
                        ajv_schema schema,
                        orderly_json *json) {
  yajl_status ret =  yajl_status_ok;
  int cancelled;
  ajv_clear_error(hand);
  hand->s = schema;
  hand->node = schema->root;
  ajv_node_state s = ajv_alloc_node_state(hand->AF, schema->root);
  orderly_ps_push(hand->AF, hand->node_state, s);


  cancelled = orderly_synthesize_callbacks(&ajv_callbacks,hand,json);
  if (cancelled == 1) {
    if (hand->error.code == ajv_e_no_error) {
      ret = yajl_status_client_canceled;
    } else {
      ret = yajl_status_error;
    }
  }
  
  return ret;
}
예제 #6
0
yajl_status ajv_parse_and_validate(ajv_handle hand,
                                   const unsigned char * jsonText,
                                   unsigned int jsonTextLength,
                                   ajv_schema schema) {
  yajl_status stat;
  yajl_handle yh = hand->yajl;
  if (schema) {
    ajv_node_state s = ajv_alloc_node_state(hand->AF, schema->root);
    ajv_clear_error(hand);
    hand->s = schema;
    hand->node = schema->root;
    orderly_ps_push(hand->AF, hand->node_state, s);
    memcpy(&hand->ourcb, &ajv_callbacks,sizeof(yajl_callbacks));
  } else {
    memcpy(&hand->ourcb, &ajv_passthrough,sizeof(yajl_callbacks));
  }
  stat = yajl_parse(yh, jsonText, jsonTextLength);
  if (hand->error.code != ajv_e_no_error) {
    assert(stat == yajl_status_client_canceled);
    stat = yajl_status_error;
  } 

  return stat;
}
예제 #7
0
void ajv_state_require(ajv_state state, ajv_node *req) {
 ajv_node_state s = state->node_state.stack[state->node_state.used - 1];  
 orderly_ps_push(state->AF, s->required, req);
}