static int update_packetheader(NUTContext *nut, ByteIOContext *bc, int additional_size){

    int64_t start= nut->packet_start;

    int64_t cur= url_ftell(bc);

    int size= cur - start + additional_size;

    

    if(size != nut->written_packet_size){

        int i;



        assert( size <= nut->written_packet_size );

    

        url_fseek(bc, nut->packet_size_pos, SEEK_SET);

        for(i=get_length(size); i < get_length(nut->written_packet_size); i+=7)

            put_byte(bc, 0x80);

        put_v(bc, size);



        url_fseek(bc, cur, SEEK_SET);

        nut->written_packet_size= size; //FIXME may fail if multiple updates with differing sizes, as get_length may differ

    }

    

    return 0;

}

static int update_packetheader(NUTContext *nut, ByteIOContext *bc, int additional_size){

    int64_t start= nut->packet_start;

    int64_t cur= url_ftell(bc);

    int size= cur - start + additional_size;

    

    if(size != nut->written_packet_size){

        int i;



        assert( size <= nut->written_packet_size );

    

        url_fseek(bc, nut->packet_size_pos, SEEK_SET);

        for(i=get_length(size); i < get_length(nut->written_packet_size); i+=7)

            put_byte(bc, 0x80);

        put_v(bc, size);



        url_fseek(bc, cur, SEEK_SET);

        nut->written_packet_size= size; 

    }

    

    return 0;

}

static int FUNC_0(NUTContext *VAR_0, ByteIOContext *VAR_1, int VAR_2){

    int64_t start= VAR_0->packet_start;

    int64_t cur= url_ftell(VAR_1);

    int VAR_3= cur - start + VAR_2;

    

    if(VAR_3 != VAR_0->written_packet_size){

        int VAR_4;



        assert( VAR_3 <= VAR_0->written_packet_size );

    

        url_fseek(VAR_1, VAR_0->packet_size_pos, SEEK_SET);

        for(VAR_4=get_length(VAR_3); VAR_4 < get_length(VAR_0->written_packet_size); VAR_4+=7)

            put_byte(VAR_1, 0x80);

        put_v(VAR_1, VAR_3);



        url_fseek(VAR_1, cur, SEEK_SET);

        VAR_0->written_packet_size= VAR_3; 

    }

    

    return 0;

}

static int FUNC_0(NUTContext *VAR_0, ByteIOContext *VAR_1, int VAR_2){ int64_t start= VAR_0->packet_start; int64_t cur= url_ftell(VAR_1); int VAR_3= cur - start + VAR_2; if(VAR_3 != VAR_0->written_packet_size){ int VAR_4; assert( VAR_3 <= VAR_0->written_packet_size ); url_fseek(VAR_1, VAR_0->packet_size_pos, SEEK_SET); for(VAR_4=get_length(VAR_3); VAR_4 < get_length(VAR_0->written_packet_size); VAR_4+=7) put_byte(VAR_1, 0x80); put_v(VAR_1, VAR_3); url_fseek(VAR_1, cur, SEEK_SET); VAR_0->written_packet_size= VAR_3; } return 0; }