1 | /* bubbles.h - definitions for bubbles screensaver */ |
---|
2 | |
---|
3 | /* $Id: bubbles.h,v 1.1.1.3 2004-02-23 18:07:59 ghudson Exp $ */ |
---|
4 | |
---|
5 | #ifndef _BUBBLES_H_ |
---|
6 | #define _BUBBLES_H_ |
---|
7 | |
---|
8 | /*************************************************************************** |
---|
9 | * Options you might like to change to affect the program's behaviour * |
---|
10 | ***************************************************************************/ |
---|
11 | |
---|
12 | /* |
---|
13 | * Uncommenting the following will enable support for reading bubbles from |
---|
14 | * files (using the -file and -directory options to bubbles). This is |
---|
15 | * disabled by default since such operations are inherently non-portable |
---|
16 | * and we want the program to compile on as many systems as possible. |
---|
17 | * |
---|
18 | * If you uncomment this and you figure out how to get it working, please |
---|
19 | * let me (J.Macnicol@student.anu.edu.au) know. Diffs against the standard |
---|
20 | * distribution would be appreciated. Possible sources of problems are |
---|
21 | * dirent and possibly the use of tmpnam(). |
---|
22 | */ |
---|
23 | |
---|
24 | /* #define BUBBLES_IO */ |
---|
25 | |
---|
26 | /* |
---|
27 | * The following only makes sense if BUBBLES_IO above is defined. |
---|
28 | * |
---|
29 | * Uncomment the following if you always want to use the -file or |
---|
30 | * -directory options on the command line and never to use a default bubble |
---|
31 | * compiled into the program. This way you would save memory and disk space |
---|
32 | * since if you do use -file or -directory only one bubble will be loaded |
---|
33 | * into memory at any one time (and remember the default bubble is really |
---|
34 | * uncompressed, unlike bubbles in files which can be compressed). This |
---|
35 | * is disabled by default only so people running the program for the first |
---|
36 | * time with no knowldege of the command line options don't get error |
---|
37 | * messages ;) |
---|
38 | * |
---|
39 | * NOTE: You will still need to have a bubbles_default.c file, else the |
---|
40 | * build sequence will fail. Well constructed bubbles_default.c files |
---|
41 | * have #ifdef's which simply exclude everything else in the file at |
---|
42 | * compile time. The bubblestodefault script does this. |
---|
43 | */ |
---|
44 | |
---|
45 | /* #define NO_DEFAULT_BUBBLE */ |
---|
46 | |
---|
47 | /* |
---|
48 | * This turns on any debugging messages and sanity checks. Hopefully you |
---|
49 | * won't need this :) It slows things down a bit, too. |
---|
50 | * |
---|
51 | * NOTE: If you uncomment this you will get some messages about unused |
---|
52 | * functions when you compile. You can ignore these - they refer to |
---|
53 | * convenient checking routines which simply aren't called but are left |
---|
54 | * in case someone wants to use them. |
---|
55 | */ |
---|
56 | |
---|
57 | /* #define DEBUG */ |
---|
58 | |
---|
59 | /*************************************************************************** |
---|
60 | * Things you might need to change to get things working right * |
---|
61 | ***************************************************************************/ |
---|
62 | |
---|
63 | /* |
---|
64 | * Name of the gzip binary. You shouldn't need to change this unless it's |
---|
65 | * not in your PATH when the program is run, in which case you will need to |
---|
66 | * substitute the full path here. Keep the double quotes else things won't |
---|
67 | * compile! |
---|
68 | */ |
---|
69 | |
---|
70 | #define GZIP "gzip" |
---|
71 | |
---|
72 | /* |
---|
73 | * Likewise for the Bourne shell. |
---|
74 | */ |
---|
75 | |
---|
76 | #define BOURNESH "sh" |
---|
77 | |
---|
78 | /* |
---|
79 | * The name of the directory entry structure is different under Linux |
---|
80 | * (under which this code is being developed) than other systems. The case |
---|
81 | * alternate form here is that given in Kernighan & Ritchie's C book (which |
---|
82 | * must be authoratitive, no?) |
---|
83 | * |
---|
84 | * 04/07/96 : People will have to hack this to get it working on some |
---|
85 | * systems. I believe it doesn't work on SGI, for example. |
---|
86 | */ |
---|
87 | |
---|
88 | #ifdef _POSIX_SOURCE |
---|
89 | #define STRUCT_DIRENT struct dirent |
---|
90 | #else |
---|
91 | #define STRUCT_DIRENT Dirent |
---|
92 | #endif |
---|
93 | |
---|
94 | /* |
---|
95 | * The naming of fields in struct dirent also seems to differ from system to |
---|
96 | * system. This may have to be extended to make things truly portable. |
---|
97 | * What we want here is the name field from a dirent struct pointed to |
---|
98 | * by "dp". |
---|
99 | * |
---|
100 | * 04/07/96 : See above. This may need to be changed too. |
---|
101 | */ |
---|
102 | |
---|
103 | #ifdef _POSIX_SOURCE |
---|
104 | #define DIRENT_NAME dp->d_name |
---|
105 | #else |
---|
106 | #define DIRENT_NAME dp->name |
---|
107 | #endif |
---|
108 | |
---|
109 | /* I don't know why this isn't defined. */ |
---|
110 | #ifdef linux |
---|
111 | /* apparently it is defined in recent linuxes. who knows. */ |
---|
112 | /*extern char *tempnam(char *, char *);*/ |
---|
113 | #endif |
---|
114 | |
---|
115 | /**************************************************************************** |
---|
116 | * Buffer lengths and things you probably won't need to touch * |
---|
117 | ****************************************************************************/ |
---|
118 | |
---|
119 | /* Maximum length of a full path name we can deal with */ |
---|
120 | #define PATH_BUF_SIZE 1024 |
---|
121 | |
---|
122 | /* Size of string passed to shell as command */ |
---|
123 | #define COMMAND_BUF_SIZE 2500 |
---|
124 | |
---|
125 | /* Size increments for read_line() buffers */ |
---|
126 | #define READ_LINE_BUF_SIZE 24 |
---|
127 | |
---|
128 | /* Maximum amount to drop a bubble */ |
---|
129 | #define MAX_DROPPAGE 20 |
---|
130 | |
---|
131 | /**************************************************************************** |
---|
132 | * End of options * |
---|
133 | ****************************************************************************/ |
---|
134 | |
---|
135 | /* Some machines define M_PI and not PI. If they don't define either, use |
---|
136 | own own. Really, the accuracy of this is _not_ very important. */ |
---|
137 | #ifndef PI |
---|
138 | # define PI M_PI |
---|
139 | # ifndef M_PI |
---|
140 | # define M_PI 3.1415926535 |
---|
141 | # endif |
---|
142 | #endif |
---|
143 | |
---|
144 | /* for delete_bubble_in_mesh() */ |
---|
145 | #define DELETE_BUBBLE 0 |
---|
146 | #define KEEP_BUBBLE 1 |
---|
147 | |
---|
148 | /* Status codes for read_line */ |
---|
149 | #define LINE_READ 0 |
---|
150 | #define EOF_REACHED 1 |
---|
151 | #define IO_ERROR 2 |
---|
152 | |
---|
153 | /* |
---|
154 | * Magic number for Bubble struct, in case it's trashed when debugging code |
---|
155 | * (which happened to me often.... :( |
---|
156 | */ |
---|
157 | |
---|
158 | #define BUBBLE_MAGIC 5674 |
---|
159 | |
---|
160 | /* Useful macros */ |
---|
161 | #define MAX(A, B) ((A) > (B) ? (A) : (B)) |
---|
162 | #define MIN(A, B) ((A) < (B) ? (A) : (B)) |
---|
163 | |
---|
164 | /* How we represent bubbles */ |
---|
165 | struct bub { |
---|
166 | int radius; |
---|
167 | int step; /* for rendered bubbles */ |
---|
168 | long area; |
---|
169 | int x; |
---|
170 | int y; |
---|
171 | int magic; |
---|
172 | int cell_index; |
---|
173 | int visible; |
---|
174 | struct bub *next; |
---|
175 | struct bub *prev; |
---|
176 | }; |
---|
177 | |
---|
178 | typedef struct bub Bubble; |
---|
179 | |
---|
180 | /* |
---|
181 | * How we represent pixmaps of rendered bubbles. Because the range of radii |
---|
182 | * available may not be continuous, we call each a step (for the lack of a |
---|
183 | * better name...) |
---|
184 | */ |
---|
185 | |
---|
186 | #if defined(HAVE_GDK_PIXBUF) || defined(HAVE_XPM) |
---|
187 | struct bub_step { |
---|
188 | int radius; |
---|
189 | long area; |
---|
190 | int droppage; |
---|
191 | Pixmap ball, shape_mask; |
---|
192 | GC draw_gc, erase_gc; |
---|
193 | struct bub_step *next; |
---|
194 | }; |
---|
195 | |
---|
196 | typedef struct bub_step Bubble_Step; |
---|
197 | #endif /* HAVE_XPM || HAVE_GDK_PIXBUF */ |
---|
198 | |
---|
199 | /* Make sure default bubble isn't compiled when we don't have XPM |
---|
200 | Disable file I/O code too. */ |
---|
201 | #if !defined(HAVE_XPM) && !defined(HAVE_GDK_PIXBUF) |
---|
202 | # define NO_DEFAULT_BUBBLE |
---|
203 | # undef BUBBLES_IO |
---|
204 | #endif /* !HAVE_XPM && !HAVE_GDK_PIXBUF */ |
---|
205 | |
---|
206 | /* Make sure default bubble is compiled in when we have XPM and no file I/O */ |
---|
207 | #if defined(HAVE_XPM) || defined(HAVE_GDK_PIXBUF) |
---|
208 | # ifndef BUBBLES_IO |
---|
209 | # undef NO_DEFAULT_BUBBLE |
---|
210 | # endif /* BUBBLES_IO */ |
---|
211 | #endif /* HAVE_XPM || HAVE_GDK_PIXBUF */ |
---|
212 | |
---|
213 | #endif /* _BUBBLES_H_ */ |
---|