Mercurial > hg > forks > pwpunix
annotate pwplib/pwplib-unix.c @ 17:c60e531d19cd
Some misc. cleanups and minor warning removals.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 22 May 2010 20:32:49 +0300 |
parents | fa87f8897f21 |
children | 2c72092554fa |
rev | line source |
---|---|
0 | 1 #define __PWPLIB_C |
2 | |
3 #include "config.h" | |
4 | |
5 #include <stdio.h> | |
6 #include <stdlib.h> | |
7 | |
15
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
8 #ifdef DRIVE_SDL |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
9 #include <SDL.h> |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
10 #endif |
0 | 11 #include <signal.h> |
12 #include <time.h> | |
13 #include <sys/time.h> | |
14 | |
15 #include "pwplib.h" | |
16 #include "tty.h" | |
17 | |
18 | |
19 /******************** random stuff *************************/ | |
20 | |
15
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
21 static int sdl_init = 0; |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
22 |
0 | 23 extern void pwplib_dummy(); |
24 #define pwp_dummy pwplib_dummy | |
25 | |
17
c60e531d19cd
Some misc. cleanups and minor warning removals.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
26 void pwpwrite(const char *fmt, ...) |
0 | 27 { |
28 if(!pwplib.setup[SETUP_SHUTUP]) | |
29 { | |
17
c60e531d19cd
Some misc. cleanups and minor warning removals.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
30 va_list ap; |
c60e531d19cd
Some misc. cleanups and minor warning removals.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
31 va_start(ap, fmt); |
c60e531d19cd
Some misc. cleanups and minor warning removals.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
32 vfprintf(stderr, fmt, ap); |
c60e531d19cd
Some misc. cleanups and minor warning removals.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
33 va_end(ap); |
c60e531d19cd
Some misc. cleanups and minor warning removals.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
34 |
0 | 35 usleep(1000*pwplib.set.infodelay); |
36 } | |
37 } | |
38 | |
39 /********************* timer ******************************/ | |
40 | |
41 #define TIMERHZ 72 | |
42 int pwp_unix_tod() | |
43 { | |
15
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
44 #ifdef DRIVE_SDL |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
45 if (sdl_init) { |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
46 int quit = 0; |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
47 SDL_Event event; |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
48 if (SDL_PollEvent(&event) >= 0) { |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
49 switch (event.type) { |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
50 case SDL_KEYDOWN: |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
51 if (event.key.keysym.sym == SDLK_ESCAPE) |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
52 quit = 1; |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
53 break; |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
54 case SDL_QUIT: |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
55 quit = 1; |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
56 break; |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
57 } |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
58 } |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
59 if (quit) { |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
60 SDL_Quit(); |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
61 pwplib_shutdown(); |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
62 exit(1); |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
63 } |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
64 return (SDL_GetTicks() * TIMERHZ) / 1000; |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
65 } else |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
66 #endif |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
67 { |
0 | 68 struct timeval tod; |
69 gettimeofday(&tod,NULL); | |
70 return (tod.tv_sec*TIMERHZ)+(tod.tv_usec*TIMERHZ/1000000); | |
15
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
71 } |
0 | 72 } |
73 | |
74 /********************* destructors, signals etc **********/ | |
75 | |
76 void pwp_fatalsignal(int n) | |
77 { | |
78 char buf[40]; | |
79 | |
15
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
80 pwpwrite("* pwplib shutting down\n"); |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
81 |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
82 #ifdef DRIVE_SDL |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
83 if (sdl_init) { |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
84 sdl_init = 0; |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
85 SDL_Quit(); |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
86 } |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
87 #endif |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
88 |
0 | 89 pwplib_shutdown(); |
90 | |
91 sprintf(buf,"* died to signal %d\n",n); | |
92 pwpwrite(buf); | |
93 | |
94 exit(1); | |
95 } | |
96 | |
97 /******************** initialization *********************/ | |
98 | |
99 int pwplib_initcore() | |
100 { | |
15
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
101 int sdl_flags = 0; |
0 | 102 pwplib_init_common(); |
103 | |
104 /*** set signals ***/ | |
105 | |
15
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
106 #ifdef DRIVE_SDL |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
107 #ifdef DRIVE_VIDEO |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
108 sdl_flags |= SDL_INIT_VIDEO; |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
109 #endif |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
110 #ifdef DRIVE_AUDIO |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
111 sdl_flags |= SDL_INIT_AUDIO; |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
112 #endif |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
113 /* With SDL, we let it handle the signals */ |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
114 if (SDL_Init(SDL_INIT_TIMER | SDL_INIT_EVENTTHREAD | /* SDL_INIT_NOPARACHUTE | */ sdl_flags) != 0) |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
115 { |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
116 pwpwrite("* SDL could not be initialized.\n"); |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
117 sdl_init = 0; |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
118 } else |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
119 sdl_init = 1; |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
120 #endif |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
121 |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
122 if (!sdl_init) { |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
123 signal(SIGTERM,pwp_fatalsignal); |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
124 signal(SIGINT,pwp_fatalsignal); |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
125 signal(SIGQUIT,pwp_fatalsignal); |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
126 signal(SIGKILL,pwp_fatalsignal); |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
127 signal(SIGSEGV,pwp_fatalsignal); |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
128 } |
0 | 129 |
130 /*** video ***/ | |
131 | |
132 # ifdef DRIVE_VIDEO | |
133 | |
134 # ifdef DRIVE_SDL | |
15
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
135 if(sdl_init && pwp_SDL_init()) |
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
136 { |
0 | 137 } |
138 else | |
139 # endif | |
140 # ifdef DRIVE_PVP | |
141 if(pwplib.setup[SETUP_PVP]) | |
142 pvp_init(); | |
143 else | |
144 # endif | |
145 if(!pwplib.setup[SETUP_NOVIDEO]) | |
146 { | |
147 tty_init(); | |
148 } | |
149 # endif | |
150 | |
151 /*** audio ***/ | |
152 # ifdef DRIVE_AUDIO | |
153 if(!pwplib.setup[SETUP_NOSOUND]) | |
154 { | |
155 int snd=0; | |
156 #ifdef DRIVE_SDL | |
15
fa87f8897f21
Implement hacky and crummy SDL event handling in timer value fetching function; moved SDL general initialization into pwplib-unix.c.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
157 if(!snd) { if(sdl_init && pwp_sdlaudio_init())snd++; } |
0 | 158 #endif |
159 | |
160 #ifdef DRIVE_OSS | |
161 if(!snd) { if(oss_init())snd++; } | |
162 #endif | |
163 | |
164 #ifdef DRIVE_HPUX | |
165 if(!snd) { if(hpuxsnd_init())snd++; } | |
166 #endif | |
167 | |
168 if(!snd) | |
169 pwpwrite("* couldn't init sound. going silent.\n"); | |
170 | |
171 } | |
172 else | |
173 pwpwrite("* no sound, as requested\n"); | |
174 # endif | |
175 | |
176 /*** fallbacks - remove? ***/ | |
177 | |
178 if(pwplib.dump_rast==pwplib_dummy && pwplib.dump_attr!=pwplib_dummy) | |
179 pwplib.dump_rast=pwplib_dump_rast_plain; | |
180 | |
181 /*** timer ***/ | |
182 | |
183 if(pwplib.setup[SETUP_BPS]|pwplib.setup[SETUP_FPS]) | |
184 { | |
185 char tmp[100]; | |
186 sprintf(tmp,"non-realtime output (bps=%d fps=%d)\n", | |
187 pwplib.setup[SETUP_BPS],pwplib.setup[SETUP_FPS]); | |
188 pwpwrite(tmp); | |
189 | |
190 pwplib.timerfunc=pwp_timer_nrt; | |
191 pwplib.timer_counter=0; | |
192 } | |
193 else | |
194 pwplib.timerfunc=pwp_unix_tod; | |
195 | |
196 /*** hmmm ***/ | |
197 | |
198 if(pwplib.setup[SETUP_HALVE]) | |
199 pwplib.videobuf.height<<=1; | |
200 | |
201 /* only allow if smaller than original? */ | |
202 | |
203 if(pwplib.setup[SETUP_USERHEIGHT]) | |
204 pwplib.videobuf.height=pwplib.setup[SETUP_USERHEIGHT]; | |
205 if(pwplib.setup[SETUP_USERWIDTH]) | |
206 pwplib.videobuf.width=pwplib.setup[SETUP_USERWIDTH]; | |
207 | |
208 /*** done ***/ | |
209 | |
210 # ifdef DRIVE_VIDEO | |
211 if(!pwplib.setup[SETUP_NOVIDEO]) | |
212 {char tmp[100]; | |
213 sprintf(tmp,"* pwplib now controls a %d x %d framebuffer\n", | |
214 pwplib.videobuf.width,pwplib.videobuf.height); | |
215 pwpwrite(tmp); | |
216 } | |
217 # endif | |
218 | |
219 return 1; | |
220 } | |
221 | |
222 /************************************/ | |
223 | |
224 const char*pwplogo= | |
225 "\033[2J\033[H\n" | |
226 " \033[36;46mMMmmmmmmMM\033[0m\n" | |
227 " \033[36;46mMM\033[0m\n" | |
228 " \033[31;41mxxxxxxxxxxxx\033[0m\n" | |
229 " \033[31;41mxxxxxxxxxxxxxxxxxxx\033[0m\n" | |
230 " \033[31;41mxxxxxxxxx\033[0m\n" | |
231 " \033[33;43mZZZZZ\033[34;44m....\033[0m %%%%%%%%% %%% %%% %%%%%%%%%\n" | |
232 " \033[37;47m@@@@\033[34;44m......\033[0m %%%%%%%%%. %%%....... %%%. %%%%%%%%%....\n" | |
233 " \033[37;47m@@@@\033[34;44m....\033[37mo\033[34m.\033[0m .....%%% %%% %%% %%% %%% %%% %%%\n" | |
234 " \033[37;47m@@@@@@@\033[34;44m....\033[0m %%% %%% %%% %%% %%% %%% %%%\n" | |
235 " \033[37;47m@@@@@@@@@@@\033[0m %%%% %%% %%% %%% %%% %%%% %%%\n" | |
236 " \033[37;47m@@@@@@@@@@@@@\033[0m %%%% %%% %%% %%% %%% %%%% %%%\n" | |
237 " \033[37;47m@@@@@@@@@@@@@@@\033[0m %%%%%%%%% %%% %%% %%% %%%%%%%%%\n" | |
238 " \033[37;47m@@@@\033[0m %%%%%%%%% %%% %%% %%% %%%%%%%%%\n" | |
239 " \033[37;47m@@@@@@\033[0m %%% %%%%% %%% %%% %%%\n" | |
240 " \033[37;47m@@@@@@@@@@\033[0m \033[31;41mxx\033[0m %%% %%%%% %%% %%% %%%\n" | |
241 " \033[37;47m@@@@@@@@@@@@@@\033[0m %%% %%%%% %%%% %%% %%%\n" | |
242 " \033[37;47m@@@@@@@@@@@\033[0m %%% %%%%% %%%% %%% %%%\n" | |
243 " \033[37;47m@@@@@@@@@\033[0m .....%%%....... %%%%%%%%%%%%%%. %%%..........\n" | |
244 " \033[37;47m@@@@@\033[0m %%% %%%%%%%%%%%%%% %%%\n" | |
245 " \033[37;47m@@@@\033[0m\n\n"; | |
246 | |
247 | |
248 void pwplib_startup() | |
249 { | |
250 if(!pwplib.setup[SETUP_SHUTUP]) | |
251 { | |
252 pwpwrite("starting up.... 2sec delay for ^C"); | |
253 sleep(2); | |
254 } | |
255 | |
256 /* send initstuff? */ | |
257 } | |
258 | |
259 void pwplib_end() | |
260 { | |
261 if(pwplib.setup[SETUP_SHUTUP])return; | |
262 | |
263 pwplib_shutdown(); | |
264 sleep(2); | |
265 | |
266 fputs(pwplogo,stderr); | |
267 pwpwrite("shutting down multimedia subsystems\n" | |
268 "operation finished - support pwp\n\n\n"); | |
269 } | |
270 | |
271 /***************************************************************/ | |
272 | |
273 int pwplib_init(int argc,char**argv) | |
274 { | |
275 int i=0,quit=0; | |
276 | |
277 pwplib.argc=argc; | |
278 pwplib.argv=argv; | |
279 | |
280 pwplib_getopts(); | |
281 | |
282 if(pwplib.setup[SETUP_WANTHELP]) | |
283 { | |
284 printhelp(); | |
285 exit(0); | |
286 pwplib.setup[SETUP_SHUTUP]++; | |
287 } | |
288 | |
289 if(!pwplib.setup[SETUP_SHUTUP]) | |
290 { | |
291 fputs(pwplogo,stderr); | |
292 pwpwrite("pwplib " PWPLIB_VERSION " initializing..\n\nrun with --help for some options\n\n"); | |
293 } | |
294 | |
295 {char buf[40]; | |
296 sprintf(buf,"* using locale '%s'\n",pwplib.set.lang); | |
297 pwpwrite(buf); | |
298 } | |
299 | |
300 if(!pwplib_initcore()) | |
301 { | |
302 pwpwrite("initialization failed!\n"); | |
303 return 0; | |
304 } | |
305 | |
306 if(pwplib.setup[SETUP_WANTHELP]) | |
307 return 0; | |
308 | |
309 return 1; | |
310 } |