Mercurial > emacs
comparison src/xfns.c @ 27153:31b7a2a8ea20
(current_gif_memory_src): New variable.
(gif_load): Record the address of the current memory source
in current_gif_memory_src.
(gif_read_from_memory): Use current_gif_memory_src.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Tue, 04 Jan 2000 21:22:24 +0000 |
parents | d647366b1464 |
children | 3dafddaefc2c |
comparison
equal
deleted
inserted
replaced
27152:56ea89168dba | 27153:31b7a2a8ea20 |
---|---|
9153 gif_load, | 9153 gif_load, |
9154 x_clear_image, | 9154 x_clear_image, |
9155 NULL | 9155 NULL |
9156 }; | 9156 }; |
9157 | 9157 |
9158 | |
9159 /* Return non-zero if OBJECT is a valid GIF image specification. */ | 9158 /* Return non-zero if OBJECT is a valid GIF image specification. */ |
9160 | 9159 |
9161 static int | 9160 static int |
9162 gif_image_p (object) | 9161 gif_image_p (object) |
9163 Lisp_Object object; | 9162 Lisp_Object object; |
9183 size_t len; | 9182 size_t len; |
9184 int index; | 9183 int index; |
9185 } | 9184 } |
9186 gif_memory_source; | 9185 gif_memory_source; |
9187 | 9186 |
9187 /* Make the current memory source available to gif_read_from_memory. | |
9188 It's done this way because not all versions of libungif support | |
9189 a UserData field in the GifFileType structure. */ | |
9190 static gif_memory_source *current_gif_memory_src; | |
9191 | |
9188 static int | 9192 static int |
9189 gif_read_from_memory (file, buf, len) | 9193 gif_read_from_memory (file, buf, len) |
9190 GifFileType *file; | 9194 GifFileType *file; |
9191 GifByteType *buf; | 9195 GifByteType *buf; |
9192 int len; | 9196 int len; |
9193 { | 9197 { |
9194 gif_memory_source *src = (gif_memory_source *) file->UserData; | 9198 gif_memory_source *src = current_gif_memory_src; |
9195 | 9199 |
9196 if (len > src->len - src->index) | 9200 if (len > src->len - src->index) |
9197 return -1; | 9201 return -1; |
9198 | 9202 |
9199 bcopy (src->bytes + src->index, buf, len); | 9203 bcopy (src->bytes + src->index, buf, len); |
9248 } | 9252 } |
9249 } | 9253 } |
9250 else | 9254 else |
9251 { | 9255 { |
9252 /* Read from memory! */ | 9256 /* Read from memory! */ |
9257 current_gif_memory_src = &memsrc; | |
9253 memsrc.bytes = XSTRING (specified_data)->data; | 9258 memsrc.bytes = XSTRING (specified_data)->data; |
9254 memsrc.len = STRING_BYTES (XSTRING (specified_data)); | 9259 memsrc.len = STRING_BYTES (XSTRING (specified_data)); |
9255 memsrc.index = 0; | 9260 memsrc.index = 0; |
9256 | 9261 |
9257 gif = DGifOpen(&memsrc, gif_read_from_memory); | 9262 gif = DGifOpen(&memsrc, gif_read_from_memory); |