Ejemplo n.º 1
0
static enum RPC_Error _parse_pair(uchar **str, struct RPC_Node *node)
{
  enum RPC_Error status;

  if( (node->children = calloc(2, sizeof *node)) == NULL )
    return RPC_FAIL;

  if( (status=_parse_key(str,&node->children[0])) != RPC_OK )
  {
    free(node->children);
    return status;
  }

  if( (status=_parse_value(str, &node->children[1])) != RPC_OK )
  {
    _free_rpc_node(&node->children[0]);
    free(node->children);
    return status;
  }

  node->numChildren = 2;
  node->type = RPC_PAIR;

  return RPC_OK;
}
Ejemplo n.º 2
0
int Configure::_parse_item(char*& src, ConfNode* item) {
	ConfNode* node = new ConfNode(ITEM);
	char token[CONF_LINE_NUM];
	_parse_key(src, token);
	node->set_key(token);
	expect(src, ":");
	node->set_father(item);
	node->add_to_tree();
	_parse_value(src, token);
	node->set_value(token);
	return CONF_SUCC;
};
Ejemplo n.º 3
0
int Configure::_parse_array_root(char*& src, ConfNode* item) {
	ConfNode* node = new ConfNode(ARRAY_ROOT);
	char token[CONF_LINE_NUM];
	_parse_key(src, token);
	node->set_key(token);
	expect(src, ":");
	expect(src, "[");
	node->set_father(item);
	node->add_to_tree();
	if (CONF_ERROR == _parse_array(src, node)) {
		throw exception(MISSING, "parse array error");
	}
	if (0 == get_token(src, token, CONF_LINE_NUM)) {
		return CONF_SUCC;
	}	
	return CONF_ERROR;
};