Exemple #1
0
ast_err
BytesRequired_read(ast_runtime* rt, BytesRequired** bytesrequired_vp)
{
    ast_err status = AST_NOERR;
    uint32_t wiretype, fieldno;
    BytesRequired* bytesrequired_v;

    bytesrequired_v = (BytesRequired*)ast_alloc(rt,sizeof(BytesRequired));
    if(bytesrequired_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: {
            status = ast_read_primitive(rt,ast_string,1,&bytesrequired_v->f_string);
            } break;
        case 2: {
            status = ast_read_primitive(rt,ast_bytes,2,&bytesrequired_v->f_bytes);
            } break;
        default:
            status = ast_skip_field(rt,wiretype,fieldno);
            if(status != AST_NOERR) {goto done;}
        }; /*switch*/
    };/*while*/
    if(status != AST_NOERR) {goto done;}
    if(bytesrequired_vp) *bytesrequired_vp = bytesrequired_v;
done:
    return status;
} /*BytesRequired_read*/
Exemple #2
0
ast_err
Submsg_read(ast_runtime* rt, Submsg** submsg_vp)
{
    ast_err status = AST_NOERR;
    uint32_t wiretype, fieldno;
    Submsg* submsg_v;

    submsg_v = (Submsg*)ast_alloc(rt,sizeof(Submsg));
    if(submsg_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: {
            status = ast_read_primitive(rt,ast_int32,1,&submsg_v->f_int32);
            } 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(submsg_vp) *submsg_vp = submsg_v;
done:
    return status;
} /*Submsg_read*/
Exemple #3
0
ast_err
BytesOptional_read(ast_runtime* rt, BytesOptional** bytesoptional_vp)
{
    ast_err status = AST_NOERR;
    uint32_t wiretype, fieldno;
    BytesOptional* bytesoptional_v;

    bytesoptional_v = (BytesOptional*)ast_alloc(rt,sizeof(BytesOptional));
    if(bytesoptional_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: {
            bytesoptional_v->f_string.defined = 1;
            bytesoptional_v->f_string.value = NULL;
            status = ast_read_primitive(rt,ast_string,1,&bytesoptional_v->f_string.value);
            } break;
        case 2: {
            bytesoptional_v->f_bytes.defined = 1;
            bytesoptional_v->f_bytes.value.nbytes = 0;
            bytesoptional_v->f_bytes.value.bytes = NULL;
            status = ast_read_primitive(rt,ast_bytes,2,&bytesoptional_v->f_bytes.value);
            } break;
        default:
            status = ast_skip_field(rt,wiretype,fieldno);
            if(status != AST_NOERR) {goto done;}
        }; /*switch*/
    };/*while*/
    if(!bytesoptional_v->f_string.defined) {
        bytesoptional_v->f_string.value = "hello";
    }
    if(!bytesoptional_v->f_bytes.defined) {
        bytesoptional_v->f_bytes.value.nbytes = 0;
        bytesoptional_v->f_bytes.value.bytes = NULL;
    }
    if(status != AST_NOERR) {goto done;}
    if(bytesoptional_vp) *bytesoptional_vp = bytesoptional_v;
done:
    return status;
} /*BytesOptional_read*/