Пример #1
0
int sub_parsestream(void* stream, ot_queue* msg) {
    int status;

    switch (sub_parse_header(stream)) {
    case DATA_EOF:
        return -1;
    case DATA_error:
        return -2;
    case DATA_lineterm:
        return -3;
    case DATA_comment:
        return sub_passcomment(stream);
    case DATA_ascii:
        return sub_getascii(stream, msg);
    case DATA_binnum:
        return sub_getbinnum(&status, stream, msg);
    case DATA_hexnum:
        return sub_gethexnum(&status, stream, msg);
    case DATA_hexblock:
        return sub_gethexblock(stream, msg);
    case DATA_decnum:
        return sub_getdecnum(&status, stream, msg);
    case DATA_decblock:
        return sub_getdecblock(stream, msg);
    }

    return -2;
}
Пример #2
0
int sub_getdecblock(void* stream, ot_queue* msg) {
    int status = 0;
    int bytes_written = q_length(msg);

    while (status == 0) {
        sub_getdecnum(&status, stream, msg);
    }

    bytes_written = q_length(msg) - bytes_written;
    return bytes_written;
}
Пример #3
0
int sub_getdecblock(FILE* stream, Queue* msg) {
    int status = 0;
    int bytes_written = msg->length;

    while (status == 0) {
        sub_getdecnum(&status, stream, msg);
    }

    bytes_written = msg->length - bytes_written;
    return bytes_written;
}