Example #1
0
ast_err
Msgtest_read(ast_runtime* rt, Msgtest** msgtest_vp)
{
    ast_err status = AST_NOERR;
    uint32_t wiretype, fieldno;
    Msgtest* msgtest_v;

    msgtest_v = (Msgtest*)ast_alloc(rt,sizeof(Msgtest));
    if(msgtest_v == NULL) return AST_ENOMEM;

    while(status == AST_NOERR) {
        status = ast_read_tag(rt,&wiretype,&fieldno);
        if(status == AST_EOF) {status = AST_NOERR; break;}
        if(status != AST_NOERR) break;
        switch (fieldno) {
        case 1: {
            size_t size;
            if(wiretype != ast_counted) {status=AST_EFAIL; goto done;}
            status = ast_read_size(rt,&size);
            if(status != AST_NOERR) {ACATCH(status); goto done;}
            ast_mark(rt,size);
            status = Submsg_read(rt,&msgtest_v->rmsg);
            if(status != AST_NOERR) {ACATCH(status); goto done;}
            ast_unmark(rt);
            } break;
        case 2: {
            size_t size;
            if(wiretype != ast_counted) {status=AST_EFAIL; goto done;}
            status = ast_read_size(rt,&size);
            if(status != AST_NOERR) {ACATCH(status); goto done;}
            ast_mark(rt,size);
            msgtest_v->omsg.defined = 1;
            msgtest_v->omsg.value = NULL;
            status = Submsg_read(rt,&msgtest_v->omsg.value);
            if(status != AST_NOERR) {ACATCH(status); goto done;}
            ast_unmark(rt);
            } break;
        case 3: {
            size_t size;
            Submsg* tmp;
            if(wiretype != ast_counted) {status=AST_EFAIL; goto done;}
            status = ast_read_size(rt,&size);
            if(status != AST_NOERR) {ACATCH(status); goto done;}
            ast_mark(rt,size);
            status = Submsg_read(rt,&tmp);
            if(status != AST_NOERR) {ACATCH(status); goto done;}
            status = ast_repeat_append(rt,ast_message,&msgtest_v->pmsg,&tmp);
            if(status != AST_NOERR) {ACATCH(status); goto done;}
            ast_unmark(rt);
            } break;
        default:
            status = ast_skip_field(rt,wiretype,fieldno);
            if(status != AST_NOERR) {ACATCH(status); goto done;}
        }; /*switch*/
    };/*while*/
    if(status != AST_NOERR) {ACATCH(status); goto done;}
    if(msgtest_vp) *msgtest_vp = msgtest_v;
done:
    return status;
} /*Msgtest_read*/
Example #2
0
ast_err
BytesRepeated_read(ast_runtime* rt, BytesRepeated** bytesrepeated_vp)
{
    ast_err status = AST_NOERR;
    uint32_t wiretype, fieldno;
    BytesRepeated* bytesrepeated_v;

    bytesrepeated_v = (BytesRepeated*)ast_alloc(rt,sizeof(BytesRepeated));
    if(bytesrepeated_v == NULL) return AST_ENOMEM;

    while(status == AST_NOERR) {
        status = ast_read_tag(rt,&wiretype,&fieldno);
        if(status == AST_EOF) {status = AST_NOERR; break;}
        if(status != AST_NOERR) break;
        switch (fieldno) {
        case 1: {
            char* tmp;
            status = ast_read_primitive(rt,ast_string,1,&tmp);
            if(status != AST_NOERR) {goto done;}
            status = ast_repeat_append(rt,ast_string,&bytesrepeated_v->f_string,&tmp);
            if(status != AST_NOERR) {goto done;}
            } break;
        case 2: {
            bytes_t tmp;
            status = ast_read_primitive(rt,ast_bytes,2,&tmp);
            if(status != AST_NOERR) {goto done;}
            status = ast_repeat_append(rt,ast_bytes,&bytesrepeated_v->f_bytes,&tmp);
            if(status != AST_NOERR) {goto done;}
            } break;
        default:
            status = ast_skip_field(rt,wiretype,fieldno);
            if(status != AST_NOERR) {goto done;}
        }; /*switch*/
    };/*while*/
    if(status != AST_NOERR) {goto done;}
    if(bytesrepeated_vp) *bytesrepeated_vp = bytesrepeated_v;
done:
    return status;
} /*BytesRepeated_read*/