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.33 2000/11/29 21:31:04 hubbe Exp $"); + RCSID("$Id: xcf.c,v 1.34 2000/12/01 08:10:08 hubbe 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"   #include "threads.h"   #include "array.h"   #include "interpret.h"   #include "svalue.h"   #include "mapping.h" - #include "error.h" + #include "pike_error.h"   #include "stralloc.h"   #include "builtin_functions.h"   #include "operators.h"   #include "dynamic_buffer.h"   #include "signal_handler.h"   #include "bignum.h"      #include "image.h"   #include "colortable.h"   
pike.git/src/modules/Image/encodings/xcf.c:76:   }      static void f_substring_index( INT32 args )   {    int i = sp[-1].u.integer;    struct substring *s = SS(fp->current_object);    pop_n_elems( args );       if( i < 0 ) i = s->len + i;    if( i >= s->len ) { -  error("Index out of bounds, %d > %ld\n", i, +  Pike_error("Index out of bounds, %d > %ld\n", i,    DO_NOT_WARN((long)s->len-1) );    }    push_int( ((unsigned char *)s->s->str)[s->offset+i] );   }      static void f_substring__sprintf( INT32 args )   {    int x;    struct substring *s = SS(fp->current_object);   
pike.git/src/modules/Image/encodings/xcf.c:122:    }   }      static void f_substring_get_int( INT32 args )   {    struct substring *s = SS(fp->current_object);    int res;    unsigned char *p;    int x = sp[-1].u.integer;    if( x > s->len>>2 ) -  error("Index %d out of range", x ); +  Pike_error("Index %d out of range", x );       p = s->s->str + s->offset + x*4;    res = (p[0]<<24) | (p[1]<<16) | (p[2]<<8) | p[3];    push_int( res );   }         static void f_substring_get_uint( INT32 args )   {    struct substring *s = SS(fp->current_object);    unsigned int res;    unsigned char *p;    int x = sp[-1].u.integer;    if( x > s->len>>2 ) -  error("Index %d out of range", x ); +  Pike_error("Index %d out of range", x );       p = s->s->str + s->offset + x*4;    res = (p[0]<<24) | (p[1]<<16) | (p[2]<<8) | p[3];    push_int64( res );   }      static void f_substring_get_ushort( INT32 args )   {    struct substring *s = SS(fp->current_object);    unsigned short res;    unsigned char *p;    int x = sp[-1].u.integer;    if( x > s->len>>1 ) -  error("Index %d out of range", x ); +  Pike_error("Index %d out of range", x );       p = s->s->str + s->offset + x*2;    res = (p[2]<<8) | p[3];    push_int( res );   }      static void f_substring_get_short( INT32 args )   {    struct substring *s = SS(fp->current_object);    short res;    unsigned char *p;    int x = sp[-1].u.integer;    if( x > s->len>>1 ) -  error("Index %d out of range", x ); +  Pike_error("Index %d out of range", x );       p = s->s->str + s->offset + x*2;    res = (p[2]<<8) | p[3];    push_int( res );   }      static void push_substring( struct pike_string *s,    ptrdiff_t offset,    ptrdiff_t len )   {
pike.git/src/modules/Image/encodings/xcf.c:294:   {    int type;    struct buffer data;    struct property *next;   };      static unsigned int read_uint( struct buffer *from )   {    unsigned int res;    if(from->len < 4) -  error("Not enough space for 4 bytes (uint32)\n"); +  Pike_error("Not enough space for 4 bytes (uint32)\n");    res = (from->str[0]<<24)|(from->str[1]<<16)|(from->str[2]<<8)|from->str[3];    from->str += 4;    from->len -= 4;    return res;   }      static int xcf_read_int( struct buffer *from )   {    return (int)read_uint( from );   }      static char *read_data( struct buffer *from, size_t len )   {    char *res;    if( from->len < len ) -  error("Not enough space for %lu bytes\n", +  Pike_error("Not enough space for %lu bytes\n",    DO_NOT_WARN((unsigned long)len));    res = (char *)from->str;    from->str += len;    from->len -= len;    return res;   }      static struct buffer read_string( struct buffer *data )   {    struct buffer res = *data;    res.len = xcf_read_int( data );    res.base_offset = (data->base_offset+(data->base_len-data->len));    res.str = (unsigned char *)read_data( data, res.len );    if(res.len > 0) res.len--; /* len includes ending \0 */    res.base_len = res.len;    if(!res.str) -  error("String read failed\n"); +  Pike_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)    {
pike.git/src/modules/Image/encodings/xcf.c:692:   {    struct gimp_image res;    struct property tmp;    struct buffer initial;    unsigned int offset;    ONERROR err;       MEMSET(&res, 0, sizeof(res));    initial = *data;    if(data->len < 34) -  error("This is not an xcf file (to little data)\n"); +  Pike_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((char *)data->str) == 13) -  error("This is not an xcf file (%s)\n", data->str); +  Pike_error("This is not an xcf file (%s)\n", data->str);    else -  error("This is not an xcf file\n"); +  Pike_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 = xcf_read_int( data );       SET_ONERROR( err, free_image, &res );       do
pike.git/src/modules/Image/encodings/xcf.c:787:   {    push_buffer( &t->data );   }      static void push_hierarchy( struct hierarchy * h )   {    struct tile *t = h->level.first_tile;    struct svalue *osp = sp, *tsp;    if(h->level.width != h->width ||    h->level.height != h->height) -  error("Illegal hierarchy level sizes!\n"); +  Pike_error("Illegal hierarchy level sizes!\n");       ref_push_string( s_width ); push_int( h->width );    ref_push_string( s_height ); push_int( h->height );    ref_push_string( s_bpp ); push_int( h->bpp );       ref_push_string( s_tiles );    tsp = sp;    while(t)    {    push_tile( t );
pike.git/src/modules/Image/encodings/xcf.c:893:         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"); +  Pike_error("Too many arguments to Image.XCF.___decode()\n");       b.s = s;    b.base_offset = 0;    b.base_len = s->len;    b.len = s->len;    b.str = (unsigned char *)s->str;       res = read_image( &b );    SET_ONERROR( err, free_image, &res );    push_image( &res );
pike.git/src/modules/Image/encodings/xcf.c:939:   **!   **! image_xres, image_yres, image_colormap, image_guides, image_parasites,   **! name, parasites, visible, active   */      /*   **! 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 + **! Throws upon Pike_error in data, you will loose quite a lot of   **! information by doing this. See Image.XCF._decode and Image.XCF.__decode   */         /*   **! method mapping _decode(string|object data,mapping|void options)   **! Decodes a XCF image to a mapping, with at least an   **! 'image' and possibly an 'alpha' object. Data is either a XCF image, or   **! a XCF.GimpImage object structure (as received from __decode)   **!
pike.git/src/modules/Image/encodings/xcf.c:976:   **! Draw an outline around all (drawn) layers   **!   **! "mark_layer_names":Image.Font object,   **! Write the name of all layers using the font object,   **!   **! "mark_active_layer":1,   **! Draw an outline around the active layer   **! ])</pre>   **!   **! note - **! Throws upon error in data. For more information, see Image.XCF.__decode + **! Throws upon Pike_error in data. For more information, see Image.XCF.__decode   */      /*   **! method object __decode(string|mapping data, mapping|void options)   **! Decodes a XCF image to a Image.XCF.GimpImage object.   **!   **! <pre>Returned structure reference   **!   **! !class GimpImage   **! {
pike.git/src/modules/Image/encodings/xcf.c:1187:    rgb_group pix = {0,0,0};    rgb_group apix= {255,255,255}; /* avoid may use uninitialized warnings */       INT_TYPE rle, bpp, span, shrink;    unsigned int l, x=0, y=0, cx, cy;    get_all_args( "_decode_tiles", args, "%o%O%a%i%i%O%d%d%d",    &io, &ao, &tiles, &rle, &bpp, &cmapo, &shrink, &rxs, &rys);          if( !(i = (struct image *)get_storage( io, image_program ))) -  error("Wrong type object argument 1 (image)\n"); +  Pike_error("Wrong type object argument 1 (image)\n");       if(ao && !(a = (struct image *)get_storage( ao, image_program ))) -  error("Wrong type object argument 2 (image)\n"); +  Pike_error("Wrong type object argument 2 (image)\n");       if( cmapo &&    !(cmap=(struct neo_colortable *)get_storage(cmapo,    image_colortable_program))) -  error("Wrong type object argument 4 (colortable)\n"); +  Pike_error("Wrong type object argument 4 (colortable)\n");       for(l=0; l<(unsigned int)tiles->size; l++)    if(tiles->item[l].type != T_OBJECT) -  error("Wrong type array argument 3 (tiles)\n"); +  Pike_error("Wrong type array argument 3 (tiles)\n");       if(a && ((i->xsize != a->xsize) || (i->ysize != a->ysize))) -  error("Image and alpha objects are not identically sized.\n"); +  Pike_error("Image and alpha objects are not identically sized.\n");       if(cmap)    {    colortable = malloc(sizeof(rgb_group)*image_colortable_size( cmap ));    image_colortable_write_rgb( cmap, (unsigned char *)colortable );    }       x=y=0;       THREADS_ALLOW();