+
+
+/*********************************************************************
+ *
+ * Function : gif_deanimate_response
+ *
+ * Description : Deanimate the GIF image that has been accumulated in
+ * csp->iob->buf and set csp->content_length to the modified
+ * size.
+ *
+ * Parameters :
+ * 1 : csp = Current client state (buffers, headers, etc...)
+ *
+ * Returns : a pointer to the (newly allocated) modified buffer.
+ * or NULL in case something went wrong.
+ *
+ *********************************************************************/
+char *gif_deanimate_response(struct client_state *csp)
+{
+ struct binbuffer *in, *out;
+ char *p;
+ int size = csp->iob->eod - csp->iob->cur;
+
+ if ( (NULL == (in = (struct binbuffer *)zalloc(sizeof *in )))
+ || (NULL == (out = (struct binbuffer *)zalloc(sizeof *out))) )
+ {
+ log_error(LOG_LEVEL_DEANIMATE, "failed! (No Mem!)");
+ return NULL;
+ }
+
+ in->buffer = csp->iob->cur;
+ in->size = size;
+
+ if (gif_deanimate(in, out))
+ {
+ log_error(LOG_LEVEL_DEANIMATE, "failed! (size %d)", size);
+ free(in);
+ buf_free(out);
+ return(NULL);
+ }
+ else
+ {
+ log_error(LOG_LEVEL_DEANIMATE, "Success! GIF shrunk from %d bytes to %d.", size, out->offset);
+ csp->content_length = out->offset;
+ p = out->buffer;
+ free(in);
+ free(out);
+ return(p);
+ }
+
+}