-const char deanimate_rcs[] = "$Id: deanimate.c,v 1.19 2008/05/21 15:29:35 fabiankeil Exp $";
+const char deanimate_rcs[] = "$Id: deanimate.c,v 1.23 2012/03/09 16:24:36 fabiankeil Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/deanimate.c,v $
* Purpose : Declares functions to manipulate binary images on the
* fly. High-level functions include:
* - Deanimation of GIF images
- *
- * Functions declared include: gif_deanimate, buf_free,
- * buf_copy, buf_getbyte, gif_skip_data_block
- * and gif_extract_image
*
* Copyright : Written by and Copyright (C) 2001 - 2004, 2006 by the
* SourceForge Privoxy team. http://www.privoxy.org/
* and ideas from the Image::DeAnim Perl module by
* Ken MacFarlane, <ksm+cpan@universal.dca.net>
*
- * This program is free software; you can redistribute it
+ * This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at
const char deanimate_h_rcs[] = DEANIMATE_H_VERSION;
/*********************************************************************
- *
+ *
* Function : buf_free
*
* Description : Safely frees a struct binbuffer
/*********************************************************************
- *
+ *
* Function : buf_extend
*
* Description : Ensure that a given binbuffer can hold a given amount
* Parameters :
* 1 : buf = Pointer to the binbuffer
* 2 : length = Desired minimum size
- *
+ *
*
* Returns : 0 on success, 1 on failure.
*
/*********************************************************************
- *
+ *
* Function : buf_copy
*
* Description : Safely copies a given amount of bytes from one
/*
* Sanity check: Can't copy more data than we have
*/
- if (src->offset + length > src->size)
+ if (src->offset + length > src->size)
{
return 1;
}
/*
* Ensure that dst can hold the new data
*/
- if (buf_extend(dst, length))
+ if (buf_extend(dst, length))
{
return 1;
}
/*********************************************************************
- *
+ *
* Function : buf_getbyte
*
* Description : Safely gets a byte from a given binbuffer at a
/*********************************************************************
- *
+ *
* Function : gif_skip_data_block
*
* Description : Safely advances the offset of a given struct binbuffer
{
unsigned char c;
- /*
+ /*
* Data blocks are sequences of chunks, which are headed
* by a one-byte length field, with the last chunk having
* zero length.
/*********************************************************************
- *
+ *
* Function : gif_extract_image
*
* Description : Safely extracts an image data block from a given
* struct binbuffer that contains a GIF image and whose
- * offset is positioned at the start of a data block
+ * offset is positioned at the start of a data block
* into a given destination binbuffer.
*
* Parameters :
if (buf_copy(src, dst, (size_t)map_length))
{
return 1;
- }
+ }
}
if (buf_copy(src, dst, 1)) return 1;
}
/*********************************************************************
- *
+ *
* Function : gif_deanimate
*
* Description : Deanimate a given GIF image, i.e. given a GIF with
c = buf_getbyte(src, 10);
/*
- * Check & copy GIF header
+ * Check & copy GIF header
*/
- if (strncmp(src->buffer, "GIF89a", 6) && strncmp(src->buffer, "GIF87a", 6))
+ if (strncmp(src->buffer, "GIF89a", 6) && strncmp(src->buffer, "GIF87a", 6))
{
return 1;
}
/*
* Look for global colormap and copy if found.
*/
- if(c & 0x80)
+ if (c & 0x80)
{
int map_length = 3 * (1 << ((c & 0x07) + 1));
if (map_length <= 0)
/*
* Reserve a buffer for the current image block
*/
- if (NULL == (image = (struct binbuffer *)zalloc(sizeof(*image))))
- {
- return 1;
- }
+ image = zalloc_or_die(sizeof(*image));
/*
* Parse the GIF block by block and copy the relevant
case 0x3b:
goto write;
- /*
+ /*
* Image block: Extract to current image buffer.
*/
case 0x2c:
*/
default:
goto failed;
-
+
}
} /* -END- while src */
/*
* Either we got here by goto, or because the GIF is
- * bogus and EOF was reached before an end-of-gif marker
+ * bogus and EOF was reached before an end-of-gif marker
* was found.
*/