/[3dldf]/3dldf/Group/ANIMATNS/animctrl.web
ViewVC logotype

Contents of /3dldf/Group/ANIMATNS/animctrl.web

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.7 - (show annotations) (download)
Wed Dec 29 13:32:06 2010 UTC (13 years, 10 months ago) by lfinsto1
Branch: MAIN
CVS Tags: HEAD
Changes since 1.6: +2 -1 lines
Added "2011" to copyright notice.

1 @q animctrl.web @>
2 @q Created by Laurence D. Finston (LDF) 2005.05.08.@>
3
4 @q * (1) Copyright and License.@>
5
6 @q This file is part of GNU 3DLDF, a package for three-dimensional drawing. @>
7 @q Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, @>
8 @q 2011 The Free Software Foundation @>
9
10 @q GNU 3DLDF is free software; you can redistribute it and/or modify @>
11 @q it under the terms of the GNU General Public License as published by @>
12 @q the Free Software Foundation; either version 3 of the License, or @>
13 @q (at your option) any later version. @>
14
15 @q GNU 3DLDF is distributed in the hope that it will be useful, @>
16 @q but WITHOUT ANY WARRANTY; without even the implied warranty of @>
17 @q MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @>
18 @q GNU General Public License for more details. @>
19
20 @q You should have received a copy of the GNU General Public License @>
21 @q along with GNU 3DLDF; if not, write to the Free Software @>
22 @q Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA@>
23
24 @q GNU 3DLDF is a GNU package. @>
25 @q It is part of the GNU Project of the @>
26 @q Free Software Foundation @>
27 @q and is published under the GNU General Public License. @>
28 @q See the website http://www.gnu.org @>
29 @q for more information. @>
30 @q GNU 3DLDF is available for downloading from @>
31 @q http://www.gnu.org/software/3dldf/LDF.html.@>
32
33 @q ("@@" stands for a single at-sign in the following paragraph.) @>
34
35 @q Please send bug reports to Laurence.Finston@@gmx.de@>
36 @q The mailing list help-3dldf@@gnu.org is available for people to @>
37 @q ask other users for help. @>
38 @q The mailing list info-3dldf@@gnu.org is for sending @>
39 @q announcements to users. To subscribe to these mailing lists, send an @>
40 @q email with ``subscribe <email-address>'' as the subject. @>
41
42 @q The author can be contacted at: @>
43
44 @q Laurence D. Finston @>
45 @q c/o Free Software Foundation, Inc. @>
46 @q 51 Franklin St, Fifth Floor @>
47 @q Boston, MA 02110-1301 @>
48 @q USA @>
49
50 @q Laurence.Finston@@gmx.de (@@ stands for a single "at" sign.)@>
51
52
53 @q * (0) animctrl.@>
54 @** animctrl\quad ({\tt animctrl\PERIOD web}).\hfil
55
56 \LOG
57 \initials{LDF 2005.05.08.}
58 Created this file.
59 \ENDLOG
60
61 @<Version control identifier@>=
62 static string rcs_id
63 = "$Id: animctrl.web,v 1.7 2008/01/05 17:57:15 lfinsto1 Exp $";
64
65 @q * (1) Include files.@>
66 @ Include files.
67
68 \LOG
69 \initials{LDF 2005.05.11.}
70 Added code to this section. Previously, it was empty.
71 \ENDLOG
72
73 @<Include files@>=
74 #include "../CWEB/config.h"
75
76 #ifndef DEBUG_COMPILE
77 #define DEBUG_COMPILE 1
78 #endif
79
80 #include <errno.h>
81 #include <exception>
82
83 #ifdef __GNUC__
84 #if HAVE_FLOAT_H
85 #include <float.h> /* \initials{LDF 2002.12.13.} Needed for |FLT_MAX|. */
86 #endif
87 #endif
88
89 #include <fstream>
90 #include <iomanip>
91
92 #include <ios>
93
94 #include <iostream>
95 #include <iterator>
96
97 #include <math.h>
98 #include <new>
99
100 #include <pthread.h>
101
102 #include <sstream>
103
104 #include <stdarg.h>
105 #include <stdexcept>
106
107 #include <stdio.h>
108
109 #if HAVE_STDLIB_H
110 #include <stdlib.h>
111 #endif
112
113 #include <string>
114 #include <sys/types.h>
115 #include <sys/wait.h>
116 #include <unistd.h>
117
118 using namespace std;
119
120 #include "thrdutls.h"
121
122
123 @q * (1) Scanning and parsing input.@>
124 @* Scanning and parsing input.
125
126 @q ** (2) yyparse. @>
127
128 @*1 {\bf yyparse()}.
129
130
131 @<Declare scanning and parsing functions@>=
132 int
133 yyparse (void*);
134
135 @q ** (2) yywrap. @>
136 @*1 {\bf yywrap()}.
137
138 @<Declare scanning and parsing functions@>=
139
140 #if 0
141 int
142 yywrap(void);
143 #endif
144
145 @
146 @<Define scanning and parsing functions@>=
147 #if 0
148 int
149 yywrap(void)
150 {
151 return 1;
152 }
153 #endif
154
155 @q * (1) Global variables.@>
156 @* Global variables.
157 \initials{LDF 2005.05.11.}
158
159 \LOG
160 \initials{LDF 2005.05.11.}
161 Added this section.
162
163 \initials{LDF 2005.05.11.}
164 |THREADS_MAX_LDF| and |PROCESSES_MAX_LDF| will normally be set
165 to |PTHREAD_THREADS_MAX| and |CHILD_MAX|, respectively.
166 On the system I'm using, |PTHREAD_THREADS_MAX == 16384| and
167 |CHILD_MAX == 999|. However, |THREADS_MAX_LDF| and |PROCESSES_MAX_LDF|
168 can be set to lower values for debugging. On the system I'm using,
169 |USHRT_MAX == 65535|, so it's large enough to be used for
170 |THREADS_MAX_LDF| and |PROCESSES_MAX_LDF|.
171 \ENDLOG
172
173 @<Global variables@>=
174
175 Cond_Var_Type <unsigned short> thread_ctr;
176 Cond_Var_Type <unsigned short> process_ctr;
177
178 const unsigned short THREADS_MAX_LDF = PTHREAD_THREADS_MAX;
179 const unsigned short PROCESSES_MAX_LDF = CHILD_MAX;
180
181
182 @q * (1) Main.@>
183 @* Main.
184 \initials{LDF 2005.05.08.}
185
186 @<Main@>=
187
188 int
189 main(int argc, char** argv)
190 {
191
192 bool DEBUG = true; /* |false| */
193
194 stringstream cerr_strm;
195
196 int status;
197
198 #if DEBUG_COMPILE
199 if (DEBUG)
200 {
201
202 cerr_strm << "Entering 'animctrl' ('main()').";
203
204 log_message(cerr_strm);
205 cerr_message(cerr_strm);
206 cerr_strm.str("");
207
208 #if 0
209 cerr_strm << "In 'main()': 'CHILD_MAX' == " << CHILD_MAX
210 << endl
211 << "'PTHREAD_THREADS_MAX' == " << PTHREAD_THREADS_MAX
212 << endl
213 << "'USHRT_MAX' == " << USHRT_MAX;
214 log_message(cerr_strm);
215 cerr_message(cerr_strm);
216 cerr_strm.str("");
217 #endif
218
219 }
220 #endif /* |DEBUG_COMPILE| */@;
221
222 thread_ctr.lock();
223 thread_ctr.value_0 = 1;
224 thread_ctr.unlock();
225
226 process_ctr.lock();
227 process_ctr.value_0 = 1;
228 process_ctr.unlock();
229
230 pthread_t thread_id;
231
232 thread_ctr.lock();
233 status = pthread_create(&thread_id, 0, thread_func, 0);
234 thread_ctr.value_0 += 1;
235 thread_ctr.unlock();
236
237 status = pthread_join(thread_id, 0);
238
239 thread_ctr.lock();
240 thread_ctr.value_0 -= 1;
241 thread_ctr.unlock();
242
243 cerr_strm << "In 'main()': Joined with the sub-thread.";
244
245 cerr_message(cerr_strm);
246 cerr_strm.str("");
247
248 pthread_exit(0);
249
250 } /* End of |main()| definition. */
251
252 @q * (1) |thread_func()|.@>
253 @* {\bf thread\_func()}.
254
255 \LOG
256 \initials{LDF 2005.05.11.}
257 Added this function.
258 \ENDLOG
259
260 @q ** (2) Declaration.@>
261
262
263 @<Declare |thread_func()|@>=
264 void*
265 thread_func(void* arg);
266
267 @q ** (2) Definition.@>
268
269 @
270 @<Define |thread_func()|@>=
271 void*
272 thread_func(void* arg)
273 {
274 stringstream cerr_strm;
275
276 cerr_strm << "Entering 'thread_func()'.";
277
278 log_message(cerr_strm);
279 cerr_message(cerr_strm);
280 cerr_strm.str("");
281
282
283 process_ctr.lock();
284
285 pid_t pid = fork();
286 process_ctr.value_0 += 1;
287
288 process_ctr.unlock();
289
290 if (pid == 0)
291 {
292 cerr_strm << "In the child process." << endl;
293
294 log_message(cerr_strm);
295 cerr_message(cerr_strm);
296 cerr_strm.str("");
297
298 execl("a.out", "./a.out", 0);
299 }
300
301 else
302 {
303
304 int status;
305
306 cerr_strm << "In the parent process: "
307 << "Waiting for child process to terminate."
308 << endl;
309
310 log_message(cerr_strm);
311 cerr_message(cerr_strm);
312 cerr_strm.str("");
313
314 waitpid(pid, &status, 0);
315
316
317 process_ctr.lock();
318 process_ctr.value_0 -= 1;
319 process_ctr.unlock();
320
321 cerr_strm << "In the parent process: "
322 << "Child process terminated."
323 << endl
324 << "Exiting 'thread_func()'.";
325
326 log_message(cerr_strm);
327 cerr_message(cerr_strm);
328 cerr_strm.str("");
329
330 pthread_exit(0);
331
332 }
333
334
335 } /* End of |thread_func()| definition. */
336
337
338 @q * (1) |log_message()|.@>
339 @* {\bf log\_message()}.
340 \initials{LDF 2005.05.11.}
341
342 \LOG
343 \initials{LDF 2005.05.11.}
344 Added this function.
345 It currently returns 0 immediately.
346 \ENDLOG
347
348 @q ** (2) Declaration.@>
349
350 @<Declare |log_message()|@>=
351 int
352 log_message(stringstream& s);
353
354 @q ** (2) Definition.@>
355
356 @
357 @<Define |log_message()|@>=
358 int
359 log_message(stringstream& s)
360 {
361 return 0;
362 }
363
364 @q * (1) Putting animctrl together.@>
365 @* Putting animctrl together.
366
367 @q ** (2) Compilation. @>
368 @ This is what's compiled.
369 @c
370 @<Include files@>@;
371 @<Version control identifier@>@;
372 @<Global variables@>@;
373 @<Declare scanning and parsing functions@>@;
374 @<Declare |log_message()|@>@;
375 @<Declare |thread_func()|@>@;
376 @<Main@>@;
377 @<Define scanning and parsing functions@>@;
378 @<Define |log_message()|@>@;
379 @<Define |thread_func()|@>@;
380
381 @q * (1)@>
382
383 @q * (1) Emacs-Lisp code for use in indirect buffers when using the @>
384 @q GNU Emacs editor. The local variable list is not evaluated when an @>
385 @q indirect buffer is visited, so it's necessary to evaluate the @>
386 @q following s-expression in order to use the facilities normally @>
387 @q accessed via the local variables list. @>
388 @q \initials{LDF 2004.02.12}. @>
389 @q (progn (cweb-mode) (outline-minor-mode t)) @>
390
391
392 @q * Local variables for Emacs.@>
393 @q Local Variables: @>
394 @q mode:CWEB @>
395 @q eval:(display-time) @>
396 @q run-cweave-on-file:"3DLDFprg.web" @>
397 @q eval:(read-abbrev-file) @>
398 @q indent-tabs-mode:nil @>
399 @q eval:(outline-minor-mode) @>
400 @q fill-column:80 @>
401 @q End: @>
402

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26