1 /*
2  * This software is copyrighted as noted below.  It may be freely copied,
3  * modified, and redistributed, provided that the copyright notice is
4  * preserved on all copies.
5  *
6  * There is no warranty or other guarantee of fitness for this software,
7  * it is provided solely "as is".  Bug reports or fixes may be sent
8  * to the author, who may or may not act on them as he desires.
9  *
10  * You may not include this software in a program or other software product
11  * without supplying the source, or without informing the end-user that the
12  * source is available for no extra charge.
13  *
14  * If you modify this software, you should include a notice giving the
15  * name of the person performing the modification, the date of modification,
16  * and the reason for such modification.
17  */
18 /*
19  * rle_put.h - Definitions and a few global variables for rle_putrow/putraw.
20  *
21  * Author:	Spencer W. Thomas
22  * 		Computer Science Dept.
23  * 		University of Utah
24  * Date:	Mon Aug  9 1982
25  * Copyright (c) 1982 Spencer W. Thomas
26  *
27  * $Id: rle_put.h,v 3.0.1.2 1992/02/27 21:14:35 spencer Exp $
28  */
29 
30 #include "rle.h"
31 #include "rle_config.h"
32 
33 /* ****************************************************************
34  * Dispatch table for different output types.
35  */
36 #ifdef __cplusplus        /* Cfront 2.0  or g++ */
37 #ifndef c_plusplus
38 #define c_plusplus
39 #endif
40 extern "C" {
41 #endif
42 
43 
44 #ifdef c_plusplus
45 #define ARB_ARGS ...
46 #else
47 #define ARB_ARGS
48 #endif
49 
50 typedef int rle_fn( ARB_ARGS );
51 
52 struct rle_dispatch_tab {
53     CONST_DECL char   *magic;   /* magic type flags */
54     void (*setup)(rle_hdr * the_hdr);          /* startup function */
55     void (*skipBlankLines)(int nblank, rle_hdr * the_hdr);
56     void(*setColor)(int c, rle_hdr * the_hdr);
57     void(*skipPixels)(int nskip, int last, int wasrun, rle_hdr * the_hdr);
58     void(*newScanLine)(int flag, rle_hdr * the_hdr);
59     void(*putdat)(rle_pixel * buf, int n, rle_hdr * the_hdr);
60         /* put a set of differing pixels */
61     void(*putrn)(int color, int n, int last, rle_hdr * the_hdr);
62         /* put a run all the same */
63     void (*blockHook)(rle_hdr * the_hdr);
64         /* hook called at start of new output block */
65     void(*putEof)(rle_hdr * the_hdr);     /* write EOF marker (if possible) */
66 };
67 
68 extern struct rle_dispatch_tab rle_DTable[];
69 
70 /*
71  * These definitions presume the existence of a variable called
72  * "fileptr", declared "long * fileptr".  *fileptr should be
73  * initialized to 0 before calling Setup().
74  * A pointer "the_hdr" declared "rle_hdr * the_hdr" is also
75  * presumed to exist.
76  */
77 #define	    rle_magic		(rle_DTable[(int)the_hdr->dispatch].magic)
78 #define	    Setup()		(*rle_DTable[(int)the_hdr->dispatch].setup)(the_hdr)
79 #define	    SkipBlankLines(n)	(*rle_DTable[(int)the_hdr->dispatch].skipBlankLines)(n, the_hdr)
80 #define	    SetColor(c)		(*rle_DTable[(int)the_hdr->dispatch].setColor)(c, the_hdr)
81 #define	    SkipPixels(n, l, r)	(*rle_DTable[(int)the_hdr->dispatch].skipPixels)(n,l,r, the_hdr)
82 #define	    NewScanLine(flag)	(*rle_DTable[(int)the_hdr->dispatch].newScanLine)(flag, the_hdr)
83 #define	    putdata(buf, len)	(*rle_DTable[(int)the_hdr->dispatch].putdat)(buf, len, the_hdr)
84 #define	    putrun(val, len, f)	(*rle_DTable[(int)the_hdr->dispatch].putrn)(val,len,f, the_hdr)
85 #define	    BlockHook()		(*rle_DTable[(int)the_hdr->dispatch].blockHook)(the_hdr)
86 #define	    PutEof()		(*rle_DTable[(int)the_hdr->dispatch].putEof)(the_hdr)
87 
88 void
89 DefaultBlockHook(rle_hdr * the_hdr);
90 /*
91  * States for run detection
92  */
93 #define	DATA	0
94 #define	RUN1	1
95 #define RUN2	2
96 #define	RUN3	3
97 #define RUN4	4
98 #define RUN5	5
99 #define RUN6	6
100 #define RUN7	7
101 #define	INRUN	-1
102 
103 #ifdef __cplusplus
104 }
105 #endif
106