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

version» Context lines:

pike.git/src/modules/Image/encodings/xcf.c:1:   #include "global.h" - RCSID("$Id: xcf.c,v 1.11 1999/08/16 18:10:23 grubba Exp $"); + RCSID("$Id: xcf.c,v 1.12 2000/02/03 19:01:29 grubba Exp $");      #include "image_machine.h"      #include "pike_macros.h"   #include "object.h"   #include "constants.h"   #include "module_support.h"   #include "interpret.h"   #include "object.h"   #include "svalue.h"
pike.git/src/modules/Image/encodings/xcf.c:29:      /*   **! module Image   **! submodule XCF   **!   */      #define TILE_WIDTH 64   #define TILE_HEIGHT 64    - #define STRING(X) static struct pike_string *s_##X; + #define STRING(X) static struct pike_string *s_##X   #include "xcf_constant_strings.h"   #undef STRING         struct buffer   {    unsigned int len;    unsigned char *str;   };   
pike.git/src/modules/Image/encodings/xcf.c:157:   static int read_int( struct buffer *from )   {    return (int)read_uint( from );   }      static char *read_data( struct buffer * from, unsigned int len )   {    char *res;    if( from->len < len )    error("Not enough space for %ud bytes\n", len); -  res = from->str; +  res = (char *)from->str;    from->str += len;    from->len -= len;    return res;   }      static struct buffer read_string( struct buffer *data )   {    struct buffer res;    res.len = read_int( data ); -  res.str = read_data( data, res.len ); +  res.str = (unsigned char *)read_data( data, res.len );    if(res.len > 0) res.len--; /* len includes ending \0 */    if(!res.str)    error("String read failed\n");    return res;   }      static struct property read_property( struct buffer * data )   {    int i;    struct property res;    res.type = read_uint( data );    if(res.type == PROP_COLORMAP)    {    unsigned int foo;    read_uint(data); /* bogus 'len'... */    foo = read_uint( data );    res.data.len = foo*3; -  res.data.str = read_data( data,foo*3 ); +  res.data.str = (unsigned char *)read_data( data,foo*3 );    } else {    res.data.len = read_uint( data ); -  res.data.str = read_data( data,res.data.len ); +  res.data.str = (unsigned char *)read_data( data,res.data.len );    }    res.next = NULL;    return res;   }         struct tile   {    struct tile *next;    struct buffer data;
pike.git/src/modules/Image/encodings/xcf.c:554:    MEMSET(&res, 0, sizeof(res));    initial = *data;    if(data->len < 34)    error("This is not an xcf file (to little data)\n");    if(!(data->str[0] == 'g' &&    data->str[1] == 'i' &&    data->str[2] == 'm' &&    data->str[3] == 'p' &&    data->str[4] == ' '))    { -  if(strlen(data->str) == 13) +  if(strlen((char *)data->str) == 13)    error("This is not an xcf file (%s)\n", data->str);    else    error("This is not an xcf file\n");    }    data->str+=14; data->len-=14;       res.width = read_uint( data );    res.height = read_uint( data );    res.type = read_int( data );   
pike.git/src/modules/Image/encodings/xcf.c:614:    s->next = res.first_channel;    res.first_channel = s;    }    }    UNSET_ONERROR( err );    return res;   }      static void push_buffer( struct buffer *b )   { -  push_string( make_shared_binary_string( b->str, b->len ) ); +  push_string( make_shared_binary_string( (char *)b->str, b->len ) );   }      static void push_properties( struct property *p )   {    struct svalue *osp = sp;    while(p)    {    ref_push_string( s_type ); push_int( p->type );    ref_push_string( s_data ); push_buffer( &p->data );    f_aggregate_mapping( 4 );
pike.git/src/modules/Image/encodings/xcf.c:749:   static void image_xcf____decode( INT32 args )   {    struct pike_string *s;    struct buffer b;    struct gimp_image res;    ONERROR err;    get_all_args( "___decode", args, "%S", &s );    if(args > 1)    error("Too many arguments to Image.XCF.___decode()\n");    -  b.str = s->str; b.len = s->len; +  b.str = (unsigned char *)s->str; b.len = s->len;    res = read_image( &b );    SET_ONERROR( err, free_image, &res );    push_image( &res );    UNSET_ONERROR( err );    free_image( &res );    stack_swap();    pop_stack();   }      
pike.git/src/modules/Image/encodings/xcf.c:782:      void image_xcf_f__rle_decode( INT32 args )   {    struct pike_string *t;    struct buffer s;    struct buffer od, d;    int bpp, xsize, ysize, i;    get_all_args( "_rle_decode", args, "%S%d%d%d", &t, &bpp, &xsize, &ysize);       s.len = t->len; -  s.str = t->str; -  od.len = xsize*ysize*bpp; -  od.str = xalloc( xsize*ysize*bpp ); /* Max and only size, really */ +  s.str = (unsigned char *)t->str; +  od.len = xsize*ysize*bpp; /* Max and only size, really */ +  od.str = (unsigned char *)xalloc( xsize*ysize*bpp );    d = od;    for(i=0; i<bpp; i++)    {    int nelems = xsize*ysize;    int length;    while(nelems)    {    unsigned char val = read_char( &s );    if(!s.len)    {
pike.git/src/modules/Image/encodings/xcf.c:834:    d.len--;    }    }    }    }       pop_n_elems(args);    /* fprintf(stderr, "%d bytes of source data used out of %d bytes\n" */    /* "%d bytes decoded data generated\n", */    /* t->len-s.len,t->len,od.len); */ -  push_string(make_shared_binary_string(od.str,od.len)); +  push_string(make_shared_binary_string((char *)od.str,od.len));    free(od.str);   }         /*   **! method object decode(string data)   **! Decodes a XCF image to a single image object.   **!   **! note   **! Throws upon error in data, you will loose quite a lot of
pike.git/src/modules/Image/encodings/xcf.c:1150:    tile = (struct pike_string *)debug_malloc_pass(sp[-1].u.string);    if(sp[-1].type != T_STRING)    fatal("Internal disaster in XCF module\n");    sp--;    }       if( (unsigned)(tile->len) < (unsigned)(eheight * ewidth * bpp ))    error("Too small tile, was %d bytes, I really need %d\n",    tile->len, eheight*ewidth * bpp);    -  s = tile->str; +  s = (unsigned char *)tile->str;       check_signals(); /* Allow ^C */       for(cy=0; cy<eheight; cy++)    {    for(cx=0; cx<ewidth; cx++)    {    rgb_group pix;    rgb_group apix;    int ind = (cx+cy*ewidth);
pike.git/src/modules/Image/encodings/xcf.c:1301:    add_integer_constant( "Indexed", Indexed, 0 );    add_integer_constant( "Auxillary", Auxillary, 0 );       add_integer_constant( "RGB_GIMAGE", RGB_GIMAGE, 0 );    add_integer_constant( "RGBA_GIMAGE", RGBA_GIMAGE, 0 );    add_integer_constant( "GRAY_GIMAGE", GRAY_GIMAGE, 0 );    add_integer_constant( "GRAYA_GIMAGE", GRAYA_GIMAGE, 0 );    add_integer_constant( "INDEXED_GIMAGE", INDEXED_GIMAGE, 0 );    add_integer_constant( "INDEXEDA_GIMAGE", INDEXEDA_GIMAGE, 0 );    - #define STRING(X) s_##X = make_shared_binary_string(#X,sizeof( #X )-sizeof("")); + #define STRING(X) s_##X = make_shared_binary_string(#X,sizeof( #X )-sizeof(""))   #include "xcf_constant_strings.h"   #undef STRING   }         void exit_image_xcf()   {   #define STRING(X) free_string(s_##X)   #include "xcf_constant_strings.h"   #undef STRING   }