File: gif_lib.html

package info (click to toggle)
giflib 3.0-11
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,052 kB
  • ctags: 967
  • sloc: ansic: 11,668; sh: 223; makefile: 212; perl: 54
file content (682 lines) | stat: -rw-r--r-- 22,834 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
<!doctype HTML public "-//W3O//DTD W3 HTML 2.0//EN">
<HTML>
<HEAD>
<TITLE>gif_lib</TITLE>
<link rev=made href=mailto:esr@snark.thyrsus.com>
</HEAD>
<BODY>
Go to <a href="index.html">index page</a>.

<CENTER><H1>The GIFLIB Library</H1></CENTER>

<CENTER><BLOCKQUOTE>
Gershon Elber, May 1991<BR>
Eric S. Raymond, Sep 1992<BR>
</BLOCKQUOTE></CENTER>

The Graphics Interchange Format(c) is the Copyright property of
CompuServe Incorporated.  GIF(sm) is a Service Mark property of CompuServe
Incorporated.<P>

Gershon wrote: "This library was written because I couldn't find
anything similar and I wanted one.  I was inspired by the RLE Utah tool kit,
which I hoped to port to an IBM PC, but found it to be too machine specific,
and its compression ratio too low.  I compromised on the GIF format, but I am
not sure how long 8 bits per pixel will be enough."<P>

This document explains the GIF library code in directory `lib'.  The
code is collected into libgif.a which is used in all the utilities in
`util'.  It can be used in any application needs to read/write the GIF
file format.  This document does </em>not</em> explain the GIF file
format and assumes you know it, at least to the level of the GIF file
structure.<P>

When a GIF file is opened, a GIF file descriptor is created which
is a pointer to GifFileType structure as follows:<P>

<pre><code>
typedef struct GifFileType {
    int SWidth, SHeight,			       /* Screen dimensions. */
	SColorResolution, 		 /* How many colors can we generate? */
	SBackGroundColor;		/* I hope you understand this one... */
    ColorMapObject *SColorMap;			      /* NULL if not exists. */
    int ImageCount;				  /* Number of current image */
    GifImageDesc Image;			   /* Block describing current image */
    struct SavedImage *SavedImages;	/* Use this to accumulate file state */
    VoidPtr Private;	  /* The regular user should not mess with this one! */
} GifFileType;
</code></pre>

This structure was copied from gif_lib.h - the header file for the GIF
library.  Any application program that uses the libgif.a library should
include it.  Members beginning with S refer to GIF Screen; others hold
properties of the current image (a GIF file may have more than one image)
or point to allocated store used by various routines.<P>

The user almost never writes into this structure (exception: it may
occasionally useful to alter things in the SavedImages array), but can read
any of these items at any time it is valid (image information is invalid
until first image was read/write).<P>

As the library needs to keep its own internal data, a Private pointer
to hidden data is included. Applications should ignore this item.<P>

The library has no static data. This means that it is fully reentrant
and any number of GIF files (up to memory limits) can be opened for
read/write. Instead of the static data, internal structure pointed by the
Private pointer is used.<P>

The library allocates its own memory dynamically, on opening of files,
and releases that once closed.  The user is never required to allocate
any memory for any of the functions of this library nor to free them
directly.<P>

In order to reduce disk access, the file buffer is increased to
FILE_BUFFER_SIZE (defined in gif_lib.h).  The library was compiled in large
model on the PC as the memory allocated per file is quite big: about 17k for
decoding (DGIF_LIB.C), and 32k for encoding (EGIF_LIB.C), excluding the
FILE_BUFFER_SIZE.<P>

Here is a module summary:<P>

<DL>
<DT>egif_lib.c <DD> Encoding routines, all prefixed with E.<P>

<DT>dgif_lib.c <DD> Decoding routines, all prefixed with D.<P>

<DT>dev2gif.c  <DD> Routines to convert specific device buffers into GIF files.<P>

<DT>gifalloc.c <DD> Routines for colormap handling and GIF record allocation.<P>

<DT>gif_font.c <DD> The 8x8 font table for the GIF utility font.<P>

<DT>gif_err.c <DD> Error handler for the library.<P>
</DL>

The library includes a sixth file of hash-function code which is accessed
internally only.<P>

<P>Most of the routines return GIF_ERROR (see gif_lib.h) if something
went wrong, GIF_OK otherwise.  After an error return, the code in the
gif_err.c module can be used to do something about it.<P>

In addition, a module to parse command line arguments is supplied.
This module is called getarg.c and its headers are in gagetarg.h.  See the header
of getarg.c for details on its usage.<P>

<H1>Decoding (dgif_lib.c)</H1>

The following functions are used to set up input from a GIF:<P>

<pre><code>
GifFileType *DGifOpenFileName(char *GifFileName)
</code></pre>

Open a new GIF file using the given GifFileName, and read its Screen
information.
</code></pre>

If any error occurs, NULL is returned and the error handler can be
used to get the exact error (see gif_err.c).
</code></pre>

The file is opened in binary mode, and its buffer size is set to
FILE_BUFFER_SIZE bytes.
</code></pre>

<pre><code>
GifFileType *DGifOpenFileHandle(int GifFileHandle)
</code></pre>

Open a new GIF file using the given GifFileHandle, and read its Screen
information.<P>

If any error occurs, NULL is returned and the error handler can be 
used to get the exact error (see gif_err.c).<P>

The file is opened in binary mode, and its buffer size is set to
FILE_BUFFER_SIZE bytes.<P>

Once you have acquired a handle on a GIF, there are two ways to read it in.
The high-level function

<pre><code>
int DGifSlurp(GifFileType)
</code></pre>

reads the rest of a complete (possibly multi-image) GIF file from the
indicated file handle into in-core allocated structures.  It returns
GIF_OK on success, GIF_ERROR on failure.<P>

Once you have done this, all image, raster, and extension-block data in the
GIF is accessable in the SavedImages member (see the structures in fif_lib.h).
When you have modified the image to taste, write it out with EGifSpew().<P>

If you are handling large images on a memory-limited machine, you may need
to use the following functions for sequential read.<P>

<pre><code>
int DGifGetScreenDesc(GifFileType *GifFile)
</code></pre>

Reads the screen information into the GifFile structure. Note this
routine is automatically called once a file is opened, and therefore
usually need not be called explicitly.<P>

Returns GIF_ERROR if something went wrong, GIF_OK otherwise.<P>

<pre><code>
int DGifGetRecordType(GifFileType *GifFile, GifRecordType *GifType)
</code></pre>

As the GIF file can have different records in arbitrary order, this
routine should be called once the file was open to detect the next
record type, and act upon it.  It can return these types in GifType:<P>

<DL>
<DT>	1. UndefinedRecordType <DD> something is wrong!<P>

<DT>	2. ScreenDescRecordType <DD> screen information.  As the screen info
	   is automatically read in when the file is open, this should
	   not happen.<P>

<DT>	3. ImageDescRecordType <DD> next record is an image descriptor.<P>

<DT>	4. ExtensionRecordType <DD> next record is extension block.<P>

<DT>	5. TerminateRecordType <DD> last record reached, can close the file.<P>
</DL>
The first two types can usually be ignored. The function
returns GIF_ERROR if something went wrong, GIF_OK otherwise.

<pre><code>
int DGifGetImageDesc(GifFileType *GifFile)
</code></pre>

Reads image information into the GifFile structure.
Returns GIF_ERROR if something went wrong, GIF_OK otherwise.<P>

<pre><code><A NAME="DGifGetLine">
int DGifGetLine(GifFileType *GifFile, PixelType *GifLine, int GifLineLen)
</A></code></pre>

Load a block of pixels from the GIF file.  The line can be
of any length.  More than that, this routine may be interleaved with
DGifGetPixel until all pixels have been read.<P>

Returns GIF_ERROR if something went wrong, GIF_OK otherwise.</P>

<pre><code>
int DGifGetPixel(GifFileType *GifFile, PixelType GifPixel)
</code></pre>

Loads one pixel from the GIF file.  This routine may be interleaved
with <a href="#DGifGetLine">DGifGetLine</a>, until all pixels are
read.  Because of the overhead per each call, use of this routine is
not recommended.<P>

Returns GIF_ERROR if something went wrong, GIF_OK otherwise.<P>

<pre><code>
int DGifGetComment(GifFileType *GifFile, char *GifComment)
</code></pre>

Load a comment from the GIF file.  Because DGifGetRecordType will
only tell if the record is of type extension, this routine should be
called iff it is known %100 that is must be a comment.<P>

For the definition of a comment, see <a
href="#EGifPutComment">EGifPutComment</a>.  Returns GIF_ERROR if
something went wrong, GIF_OK otherwise.<P>

<pre><code>
int DGifGetExtension(
        GifFileType *GifFile,
        int *GifExtCode,
        ByteType **GifExtension)
</code></pre>

Loads an extension block from the GIF file.  Extension blocks
are optional in GIF files.  This routine should be followed by
<a href="#DGifGetExtensionNext">DGifGetExtensionNext</a>.<P>

Returns GIF_ERROR if something went wrong, GIF_OK otherwise.<P>

<pre><code><A NAME="DGifGetExtensionNext">
int DGifGetExtensionNext(GifFileType *GifFile, ByteType **GifExtension)
</A> </code></pre>

As extensions may contain more than one block, use this routine to
continue after DGifGetExtension, until *GifExtension is NULL.<P>

Returns GIF_ERROR if something went wrong, GIF_OK otherwise.<P>


<pre><code>
int DGifGetCode(
        GifFileType *GifFile, 
        int *GifCodeSize, ByteType **GifCodeBlock)
</code></pre>

It sometimes may be desired to read the compressed code as is
without decoding it.  This routine does exactly that (with
DGifGetCodeNext), and can be used instead of DGifGetLine.<P>

This compressed code information can be written out using the
EGifPutCode/EGifPutCodeNext sequence (see gifpos.c for example).
Returns GIF_ERROR if something went wrong, GIF_OK otherwise.<P>

<pre><code>
int DGifGetCodeNext(GifFileType *GifFile, ByteType **GifCodeBlock)
</code></pre>

See DGifGetCode above.<P>
	  
<pre><code>
int DGifGetLZCodes(GifFileType *GifFile, int *GifCode)
</code></pre>

This routine can be called instead of DGifGetLine/DGifGetPixel or
DGifGetCode/DGifGetCodeNext to get the 12 bits LZ codes of the images.
It will be used mainly for debugging purposes (see GifText.c for
example).<P>

Returns GIF_ERROR if something went wrong, GIF_OK otherwise.<P>

<pre><code>
int DGifCloseFile(GifFileType *GifFile)
</code></pre>

Close GIF file and free all memory allocated for it. GifFile should
not be used after this routine has been called.<P>

Returns GIF_ERROR if something went wrong, GIF_OK otherwise.<P>

<H1>Encoding (egif_lib.c)</H1>

There are two ways to write out a GIF.  The high-level function<P>

<pre>
int EGifSpew(GifFileType *GifFile, int GifFileHandle)
</pre>

Writes a complete (possibly multi-image) GIF file to the indicated file
handle from in-core allocated structures created by a previous DGifSlurp()
or equivalent operations.  Its arguments are a GIF file descriptor (as
above) and an ordinary output file descriptor.<P>

The file is written with a GIF87 stamp unless it contains one of the four
special extension blocks defined in GIF89, in which case it is written
with a GIF89 stamp.<P>

If you are handling large images on a memory-limited machine, you may need
to use the following functions for sequential write.<P>

<pre><code>
GifFileType *EGifOpenFileName(char *GifFileName, int GifTestExistance)
</code></pre>

Open a new GIF file using the given GifFileName.  If GifTestExistance
is TRUE, and file exists, the file is not destroyed, and NULL
returned.<P>

If any error occurs, NULL is returned and the error handler can be
used to get the exact error (see gif_err.c).<P>

The file is opened in binary mode, and its buffer size is set to
FILE_BUFFER_SIZE bytes.<P>

<pre><code>
GifFileType *EGifOpenFileHandle(int GifFileHandle)
</code></pre>

Open a new GIF file using the given GifFileHandle.<P>

If any error occurs, NULL is returned and the error handler can be
used to get the exact error (see gif_err.c).<P>

The file is opened in binary mode, and its buffer size is set to
FILE_BUFFER_SIZE bytes.<P>

<pre><code>
void EGifSetGifVersion(char *Version)
</code></pre>

Sets the GIF version of all files opened, until another call to this
routine is made.  Version is a 3 characters string of the form "87a"
or "89a".  No test is made to validate this string.<P>

<pre><code>
int EGifPutScreenDesc(GifFileType *GifFile,
        int GifWidth, int GifHeight,
        int GifColorRes, int GifBackGround,
        ColorMapObject *GifColorMap)
</code></pre>

Update the GifFile Screen parameters, in GifFile structure and in
the real file.  If error occurs, returns GIF_ERROR (see gif_lib.h),
otherwise GIF_OK.<P>

This routine should be called immediately after the GIF file was
opened.<P>

<pre><code>
int EGifPutImageDesc(GifFileType *GifFile,
        int GifLeft, int GifTop,
        int Width, int GifHeight,
        int GifInterlace,
        ColorMapObject *GifColorMap)
</code></pre>

Update GifFile Image parameters, in GifFile structure and in the real
file. if error occurs returns GIF_ERROR (see gif_lib.h), otherwise
GIF_OK.<P>

This routine should be called each time a new image must be
dumped to the file.<P>

<pre><code><A NAME="EGifPutLine">
int EGifPutLine(GifFileType *GifFile, PixelType *GifLine, int GifLineLen)
</A> </code></pre>

Dumps a block of pixels out to the GIF file.  The slab can be
of any length.  More than that, this routine may be interleaved with
<a href="#EGifPutPixel"></a>, until all pixels have been sent.<P>

Returns GIF_ERROR if something went wrong, GIF_OK otherwise.<P>

<pre><code><A NAME="EGifPutPixel">
int EGifPutPixel(GifFileType *GifFile, PixelType GifPixel)
</A></code></pre>

Dumps one pixel to the GIF file.  This routine may be interleaved with
<a href="#EGifPutLine">EGifPutLine</a>, until all pixels were sent.
Because of the overhead for each call, use of this routine is not
recommended.<P>

Returns GIF_ERROR if something went wrong, GIF_OK otherwise.<P>

<pre><code><A NAME="EGifPutComment">
int EGifPutComment(GifFileType *GifFile, char *GifComment)
</A></code></pre>

Uses extension GIF records to save a string as a comment is the file.
The extension code is 'C' (for Comment).<P>

Returns GIF_ERROR if something went wrong, GIF_OK otherwise.<P>

<pre><code>
int EGifPutExtension(
        GifFileType *GifFile,
        int GifExtCode,
        int GifExtLen,
        void *GifExtension)
</code></pre>

Dumps the given extension block into the GIF file. Extension blocks
are optional in GIF file. Extension blocks of more than 255 bytes or
more than one block are not supported.<P>

Returns GIF_ERROR if something went wrong, GIF_OK otherwise.<P>

<pre><code>
int EGifPutExtensionHeader(
        GifFileType *GifFile,
        int GifExtCode)
</code></pre>

Dumps the given extension block header to the GIF file. This must be
used in combination with EGifPutExtensionBlock to create a valid
Extension.  Using these two functions it is possible to create an
extension with any number of sub-blocks.<P>

Returns GIF_ERROR if something went wrong, GIF_OK otherwise.<P>

<pre><code>
int EGifPutExtensionBlock(
        GifFileType *GifFile,
        int GifExtLen,
        void *GifExtension)
</code></pre>

Dumps the given extension sub-block into the GIF file. Extension 
sub-blocks are limited to 255 bytes in length, but extensions which
allow multiple sub-blocks are not limited in their total length.
Extension blocks created this way must be terminated with a 0 length
sub-block.<P>

Returns GIF_ERROR if something went wrong, GIF_OK otherwise.<P>

<pre><code>
int EGifPutCode(
        GifFileType *GifFile,
        int *GifCodeSize,
        ByteType **GifCodeBlock)
</code></pre>

It sometimes may be desired to write the compressed code as is
without decoding it.  For example a filter for a GIF file that change
only screen size (GifPos), does not need the exact pixel values.
Piping out the compressed image as is makes this process much
faster.<P>

This routine does exactly that (with EGifPutCodeNext), and can be
used instead of EGifPutLine.  You'll usually use this with the
DGifGetCode/DgifGetCodeNext routines, which reads the compressed
code, while EGifPutCode/EGifPutCodeNext write it out.  See gifpos.c
for example.<P>

Returns GIF_ERROR if something went wrong, GIF_OK otherwise.<P>

<pre><code>
int EGifPutCodeNext(GifFileType *GifFile, ByteType **GifCodeBlock)
</code></pre>

See EGifPutCode above.<P>

<pre><code>
int EGifCloseFile(GifFileType *GifFile)
</code></pre>

Close a GIF file and free all memory allocated for it.  gif-file$
should not be used, once this routine was called.<P>

Returns GIF_ERROR if something went wrong, GIF_OK otherwise.<P>

<H1>Color map handling and allocation routines</H1>

<pre><code>
ColorMapObject *MakeMapObject(int ColorCount, GifColorType *ColorMap)
</code></pre>

Allocate storage for a color map object with the given number of
RGB triplet slots.  If the second argument is non-NULL, initialize
the color table portion of the new map from it.  Returns NULL if
memory is exhausted or if the size is not a power of 2 <= 256.<P>

<pre><code>
void FreeMapObject(ColorMapObject *Object)
</code></pre>

Free the storage occupied by a ColorMapObject that is no longer needed.<P>

<pre><code>
ColorMapObject *UnionColorMap(
        ColorMapObject *ColorIn1, ColorMapObject *ColorIn2,
        GifPixelType ColorTransIn2[])
</code></pre>

Create the union of two given color maps and return it.  If the result
won't fit into 256 colors, NULL is returned, the allocated union
otherwise.  ColorIn1 is copied as it to ColorUnion, while colors from
ColorIn2 are copied iff they didn't exist before.  ColorTransIn2 maps
the old ColorIn2 into ColorUnion color map table.<P>

<pre><code>
SavedImage *GifAttachImage(GifFileType *GifFile)
</code></pre>

Add an image block to the SavedImages array.  The image block is
initially zeroed out.  This image block will be seen by any following
EGifSpew() calls.
</code></pre>

<H1>The GIF Utility Font</H1>

The 8x8 utility font used in text2gif and gifcolor lives in the library
module gif_font.c, in a table called AsciiTable.  The library header file
includes suitable externs and defines.<P>

The GIF utility font support includes entry points for drawing legends
on in-core images, drawing boxes and rectangles, and boxing text.
These entry points are as follows:<P>

<pre><code>
void DrawText(
        SavedImage *Image,
        const int x, const int y,
        const char *legend,
        const int color)
</code></pre>

Draw text using the 8x8 utility font on the saved image.  Upper left
corner of the text is at image pixel (x, y).  Use the specified
color index.<P>

<pre><code>
void DrawBox(SavedImage *Image,
        const int x, const int y,
        const int w, const int h,
        const int color)
</code></pre>

Draw a box on the saved image.  Upper left corner of the box is at
image pixels (x, y), width is w, height is h.  Use the specified color
index.<P>

<pre><code>
void DrawRectangle(SavedImage *Image,
        const int x, const int y,
        const int w, const int h,
        const int color)
</code></pre>

Draw a (filled) rectangle on the saved image.  Upper left corner of
the box is at image pixels (x, y), width is w, height is h.  Use the
specified color index.<P>

<pre><code>
void DrawBoxedText(SavedImage *Image,
        const int x, const int y,
        const char *legend,
        const int border,
        const int bg, const int fg)
</code></pre>

Draw text on a filled rectangle.  The rectangle will be sized to fit
the text, with upper left hand corner at (x, y) on the saved image.
The `border' argument specifies a pixel margin around the text.  The
`bg' argument is the color table index to fill the rectangle with;
`fg' is the color table index to draw the text with.<P>

This function interprets some characters in the legend string
specially.  A tab (\t) is interpreted as a command to center the
following text in the box.  A carriage return (\r) is interpreted
as a request for a line break.<P>

<H1>Error Handling (egif_lib.c)</H1>

<pre><code>
void PrintGifError(void)
</code></pre>

Print a one-line diagnostic on the last giflib error to stderr.<P>

<pre><code>
int GifLastError(void)
</code></pre>

Return the number of the last giflib error, and clear the error.
The error types are defined in gif_lib.h.<P>

Note it is the user's responsibility to call the file closing
routine, so the file will be closed (if was opened), and allocated
memory will be released.<P>

<H1>Device Specific (XXX2gif.c)</H1>

<pre><code>
int DumpScreen2Gif(char *FileName, int ReqGraphDriver, int ReqGraphMode1,
						       int ReqGraphMode2)
</code></pre>

Dumps the whole device buffer as specified by GraphDriver and
GraphMode (as defined in TC 2.0 graphics.h) into FileName as GIF file.
Current devices supported:<P>

<pre>
	1. Hercules.

	2. EGA, EGA64, EGAMONO (all modes - see TC graphics.h).

	3. VGA (all modes - see TC graphics.h).

	4. SVGA_SPECIAL. This mode is special and not supported by Borland
	   graphics.h. ReqGraphDriver must be equal to 999, and ReqGraphMode
	   is ignored. This modes assumes 800 by 600 in 16 colors.
	  Returns GIF_ERROR if something went wrong, GIF_OK otherwise.

	5. SGI 4D using gl graphic library - window dump.

	6. X11 window dump.
</pre>


<H1>Command Line Parsing</H1>

<pre><code>
int GAGetArgs(int argc, char **argv, char *CtrlStr, ...)
</code></pre>

Main routine of this module.  Given argc & argv as received by
the main procedure, the command line CtrlStr, and the addresses of
all parameters, parse the command line, and update the parameters.<P>

The CtrlStr defines what types of variables should follow. Look at the
beginning of getarg.c for exact usage.<P>

Returns 0 if successful, error number (as defined by gagetarg.h) otherwise.<P>

<pre><code>
void GAPrintErrMsg(int Error)
</code></pre>

If an error occurred in GAGetARgs, this routine may be used to print
one line diagnostic to stderr.<P>

<pre><code>
void GAPrintHowTo(char *CtrlStr)
</code></pre>

Given the same CtrlStr as for GAGetArgs, can be used to print a one line
'how to use'. <P>

<H1>Skeletons of GIF filters</H1>

If you are developing on a virtual-memory OS such as most flavors of
UNIX, or are otherwise sure of having enough memory to keep all of GIFs you
need to operate in core, writing a filter is trivial.   See the file
gifspnge.c in util.<P>

A sequential filter skeleton will usually look like the example file
giffiltr.c in util.<P>

<P>Please look at the utilities in the util directory for more ideas once
you feel comfortable with these skeletons.  Also try to follow the coding
standards of this package if you want the maintainer to officially add your new
utility to it.<P>

<HR>
<ADDRESS>Eric S. Raymond <A HREF="mailto:esr@thyrsus.com">&lt;esr@snark.thyrsus.com&gt;</A></ADDRESS>
</BODY>
</HTML>