1 /****************************************************************************
2  *
3  *  Copyright (C) 2005-2006 "Stuart R. Anderson" <anderson@netsweng.com>
4  *
5  *  This program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2 of the License, or
8  *  (at your option) any later version.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with this program; if not, write to the Free Software
17  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  *
19  ****************************************************************************/
20 
21 #ifndef SWF_OUTPUT_H_INCLUDED
22 #define SWF_OUTPUT_H_INCLUDED
23 
24 #include "libswf.h"
25 
26 #define max(x,y)	(((x)>(y))?(x):(y))
27 
28 #define BUFFER_INCREMENT 1024
29 
30 struct _output
31 {
32   struct _output *next;
33   byte *buffer;
34   byte *pos;
35   int buffersize;
36   int free;
37   int bitpos;
38 };
39 typedef struct _output *Output;
40 
41 #define OUTPUT_SIZE sizeof(struct _output)
42 
43 /* create/destroy output object */
44 Output newOutput();
45 Output newSizedOutput(int size);
46 void destroyOutput(Output out);
47 
48 /* write output's buffer to stream */
49 void outputWriteToStream(Output out, FILE *f);
50 
51 /* utilities for writing */
52 void outputGrow(Output out);
53 void outputCheckSize(Output out, int bytes);
54 void outputByteAlign(Output out);
55 
56 int outputLength(Output out);
57 
58 /* write data to output */
59 void outputWriteBits(Output out, int data, int bits);
60 void outputWriteSBits(Output out, int data, int bits);
61 void outputWriteUInt8(Output out, int data);
62 void outputWriteSInt8(Output out, int data);
63 void outputWriteUInt16(Output out, int data);
64 void outputWriteSInt16(Output out, int data);
65 void outputWriteUInt32(Output out, long data);
66 void outputWriteSInt32(Output out, long data);
67 void outputWriteBuffer(Output out, char *buffer, int bytes);
68 
69 /* number of bits required to store num */
70 int numBits(int num);
71 int numSBits(int num);
72 
73 void outputWriteRect(Output out, int xmin, int xmax, int ymin, int ymax);
74 void outputWriteString(Output out, byte *string);
75 
76 #endif /* SWF_OUTPUT_H_INCLUDED */
77