pike.git / src / modules / Image / encodings / wbf.c

version» Context lines:

pike.git/src/modules/Image/encodings/wbf.c:1:   #include "global.h"      #include <math.h>   #include <stdio.h>   #include <ctype.h>      #include "stralloc.h" - RCSID("$Id: wbf.c,v 1.1 1999/10/21 22:18:44 per Exp $"); + RCSID("$Id: wbf.c,v 1.2 1999/10/21 23:20:11 per Exp $");   #include "pike_macros.h"   #include "object.h"   #include "mapping.h"   #include "constants.h"   #include "interpret.h"   #include "operators.h"   #include "svalue.h"   #include "threads.h"   #include "array.h"   #include "error.h"
pike.git/src/modules/Image/encodings/wbf.c:78:    error("Invalid data format\n");    return res;   }      static int read_int( struct buffer *from )   {    int res = 0;    while( 1 )    {    int i = read_uchar( from ); -  res <<= 8; +  res <<= 7;    res |= i&0x7f; -  if( !(res & 0x80 ) ) +  if( !(i & 0x80 ) )    break;    }    return res;   }      static void push_ext_header( struct ext_header *eh )   {    push_constant_text( "identifier" );    push_string( make_shared_binary_string( eh->name, eh->name_len ) );    push_constant_text( "value" );
pike.git/src/modules/Image/encodings/wbf.c:176:    {    unsigned char q = 0; /* avoid warning */    unsigned char *data = buff->str + y * rowsize;    if( buff->len < (rowsize+1)*y )    break;    for( x = 0; x<wh->width; x++ )    {    if( !(x % 8) )    q = data[x/8];    else -  q = (q<<1) | (q>>7); +  q <<= 1;    if( q & 128 )    *id = white;    id++;    }    }    push_object( io );   }      static void low_image_f_wbf_decode( int args, int mode )   {
pike.git/src/modules/Image/encodings/wbf.c:294:   static void image_f_wbf__decode( int args )   {    low_image_f_wbf_decode( args, 1 );   }      static void image_f_wbf_decode_header( int args )   {    low_image_f_wbf_decode( args, 0 );   }    - void push_wap_integer( int i ) + void push_wap_integer( unsigned int i )   { -  char data[6]; +  char data[10]; /* More than big enough... */    int pos = 0; -  while( i > 0x7f ) +  +  if( !i )    { -  data[5-pos] = i&0x7f; -  i>>=8; pos++; +  data[0] = 0; +  pos=1;    } -  data[5-pos] = i; -  push_string( make_shared_binary_string( data+5-pos, pos+1 ) ); +  +  while( i ) +  { +  data[pos] = (i&0x7f) | 0x80; +  i>>=7; +  pos++;    } -  +  data[0] &= 0x7f; +  push_string( make_shared_binary_string( data, pos ) ); +  f_reverse(1); + }      static void push_wap_type0_image_data( struct image *i )   {    int x, y;    unsigned char *data, *p;    rgb_group *is;    data = malloc( i->ysize * (i->xsize+7)/8 );    MEMSET( data, 0, i->ysize * (i->xsize+7)/8 );    is = i->img;    for( y = 0; y<i->ysize; y++ )