1 /* This file is part of the GNU plotutils package. Copyright (C) 1995,
2 1996, 1997, 1998, 1999, 2000, 2005, 2008, Free Software Foundation, Inc.
3
4 The GNU plotutils package is free software. You may redistribute it
5 and/or modify it under the terms of the GNU General Public License as
6 published by the Free Software foundation; either version 2, or (at your
7 option) any later version.
8
9 The GNU plotutils package is distributed in the hope that it will be
10 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General Public License for more details.
13
14 You should have received a copy of the GNU General Public License along
15 with the GNU plotutils package; see the file COPYING. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin St., Fifth Floor,
17 Boston, MA 02110-1301, USA. */
18
19 /* This file is specific to libplot, rather than libplotter. It defines
20 the `old' (i.e. non-thread-safe) C API. The old C API consists of
21 wrappers around the methods that may be applied to any Plotter object.
22
23 The old API also contains pl_newpl/pl_selectpl/pl_deletepl, which
24 construct and destroy Plotter instances, and maintain the global
25 variable `_old_api_plotter'. This is a pointer to a `currently
26 selected' Plotter instance. It is positioned by calling pl_selectpl.
27
28 Because of this global variable, the old C API is not thread-safe. In
29 the new C API, which is thread-safe, each function in the API is passed
30 a pointer to a Plotter as first argument. Even in the absence of
31 multithreading, this is a cleaner approach.
32
33 By convention, _old_api_plotter is initialized to point to a Plotter
34 instance that sends output in metafile format to standard output.
35 Initialization takes place when the first function in the old API is
36 invoked. This convention is for compatibility with pre-GNU versions of
37 libplot, which did not support pl_newpl/pl_select/pl_deletepl.
38
39 The old C API also contains the pl_parampl function. This function is
40 held in common with the old (non-thread-safe) C++ API, in which it is
41 simply called parampl. It is defined in apioldcc.c.
42
43 pl_parampl sets parameters in a global PlotterParams struct, a pointer
44 to which is kept in the global variable
45 `_old_api_global_plotter_params'. (See its definition and
46 initialization in g_defplot.c.) This PlotterParams is used when any
47 Plotter is created by pl_newpl. The presence of this global state is
48 another reason why the old C API is not thread-safe. */
49
50 #include "sys-defines.h"
51 #include "extern.h"
52 #include "plot.h" /* header file for C API's */
53
54 /* Sparse array of pointers to the old API's Plotter instances, and the
55 array size; also a distinguished Plotter pointer, through which the old
56 API will act. */
57 static Plotter **_old_api_plotters = NULL;
58 static int _old_api_plotters_len = 0;
59 static Plotter *_old_api_plotter = NULL;
60
61 /* initial size of _old_api_plotters[] */
62 #define INITIAL_PLOTTERS_LEN 4
63
64 /* default Plotter type (see list of supported types in the file devoted to
65 the new C API) */
66 #ifndef DEFAULT_PLOTTER_TYPE
67 #define DEFAULT_PLOTTER_TYPE "meta"
68 #endif
69
70 /* forward references */
71 static void _api_warning (const char *msg);
72 static void _create_and_select_default_plotter (void);
73
74 /* Expand the local array of Plotters to include a single Plotter, of
75 default type; also, select that Plotter. When this is invoked, the
76 array has zero size. */
77 static void
_create_and_select_default_plotter(void)78 _create_and_select_default_plotter (void)
79 {
80 int i;
81 Plotter *default_plotter;
82
83 /* create the default Plotter by invoking function in new API (make sure
84 global PlotterParams struct, used by the old API, is set up first) */
85 if (_old_api_global_plotter_params == NULL)
86 _old_api_global_plotter_params = pl_newplparams();
87 default_plotter = pl_newpl_r (DEFAULT_PLOTTER_TYPE, stdin, stdout, stderr,
88 _old_api_global_plotter_params);
89
90 /* initialize local array of Plotters */
91 _old_api_plotters = (Plotter **)_pl_xmalloc (INITIAL_PLOTTERS_LEN * sizeof(Plotter *));
92 for (i = 0; i < INITIAL_PLOTTERS_LEN; i++)
93 _old_api_plotters[i] = (Plotter *)NULL;
94 _old_api_plotters_len = INITIAL_PLOTTERS_LEN;
95
96 /* place default Plotter in local array, and select it */
97 _old_api_plotters[0] = default_plotter;
98 _old_api_plotter = default_plotter;
99 }
100
101 /* These are the 3 user-callable functions that are specific to the old C
102 binding: newpl, selectpl, deletepl. */
103
104 /* user-callable */
105 int
pl_newpl(const char * type,FILE * infile,FILE * outfile,FILE * errfile)106 pl_newpl (const char *type, FILE *infile, FILE *outfile, FILE *errfile)
107 {
108 Plotter *new_plotter;
109 bool open_slot;
110 int i, j;
111
112 if (_old_api_plotters_len == 0)
113 /* initialize local array of Plotters, and install default Plotter as
114 Plotter #0 */
115 _create_and_select_default_plotter ();
116
117 /* create the default Plotter by invoking function in new API (make sure
118 global PlotterParams struct, used by the old API, is set up first) */
119 if (_old_api_global_plotter_params == NULL)
120 _old_api_global_plotter_params = pl_newplparams();
121 new_plotter = pl_newpl_r (type, infile, outfile, errfile,
122 _old_api_global_plotter_params);
123
124 /* ensure local array has an open slot (slot i) */
125 open_slot = false;
126 for (i = 0; i < _old_api_plotters_len; i++)
127 if (_old_api_plotters[i] == NULL)
128 {
129 open_slot = true;
130 break;
131 }
132
133 if (!open_slot)
134 /* expand array, clearing upper half */
135 {
136 i = _old_api_plotters_len;
137 _old_api_plotters =
138 (Plotter **)_pl_xrealloc (_old_api_plotters,
139 2 * _old_api_plotters_len * sizeof (Plotter *));
140 for (j = _old_api_plotters_len; j < 2 * _old_api_plotters_len; j++)
141 _old_api_plotters[j] = (Plotter *)NULL;
142 _old_api_plotters_len *= 2;
143 }
144
145 /* place newly created Plotter in open slot */
146 _old_api_plotters[i] = new_plotter;
147
148 /* return index of newly created Plotter */
149 return i;
150 }
151
152 /* user-callable, alters selected Plotter and returns index of the one that
153 was previously selected */
154 int
pl_selectpl(int handle)155 pl_selectpl (int handle)
156 {
157 int i;
158
159 if (handle < 0 || handle >= _old_api_plotters_len
160 || _old_api_plotters[handle] == NULL)
161 {
162 _api_warning ("ignoring request to select a nonexistent plotter");
163 return -1;
164 }
165
166 /* determine index of currently selected Plotter in _old_api_plotters[] */
167 for (i = 0; i < _old_api_plotters_len; i++)
168 if (_old_api_plotters[i] == _old_api_plotter)
169 break;
170
171 /* select specified Plotter: alter value of the _old_api_plotter pointer */
172 _old_api_plotter = _old_api_plotters[handle];
173
174 /* return index of previously selected Plotter */
175 return i;
176 }
177
178 /* user-callable */
179 int
pl_deletepl(int handle)180 pl_deletepl (int handle)
181 {
182 if (handle < 0 || handle >= _old_api_plotters_len
183 || _old_api_plotters[handle] == NULL)
184 {
185 _api_warning ("ignoring request to delete a nonexistent plotter");
186 return -1;
187 }
188
189 if (_old_api_plotters[handle] == _old_api_plotter)
190 {
191 _api_warning ("ignoring request to delete currently selected plotter");
192 return -1;
193 }
194
195 /* delete Plotter by invoking function in new API */
196 pl_deletepl_r (_old_api_plotters[handle]);
197
198 /* remove now-invalid pointer from local array */
199 _old_api_plotters[handle] = NULL;
200
201 return 0;
202 }
203
204
205 /* function used in this file to print warning messages */
206 static void
_api_warning(const char * msg)207 _api_warning (const char *msg)
208 {
209 if (pl_libplot_warning_handler != NULL)
210 (*pl_libplot_warning_handler)(msg);
211 else
212 fprintf (stderr, "libplot: %s\n", msg);
213 }
214
215
216 /* The following are the C wrappers around the public functions in the
217 Plotter class. Together with the three functions above (pl_newpl,
218 pl_selectpl, pl_deletepl), and pl_parampl, they make up the old
219 (non-thread-safe) libplot C API.
220
221 Each binding tests whether _old_api_plotter is non-NULL, which determines
222 whether the array of Plotter instances has been initialized. That is
223 because it makes no sense to call these functions before the
224 _old_api_plotter pointer points to a Plotter object.
225
226 In fact, of the below functions, it really only makes sense to call
227 openpl, havecap, or outfile [deprecated] before the Plotter array is
228 initialized. Calling any other of the below functions before the
229 Plotter array is initialized will generate an error message because even
230 though the call to _create_and_select_default_plotter will initialize
231 the Plotter array and select a default Plotter instance, the Plotter
232 will not be open. No operation in the Plotter class, with the exception
233 of the just-mentioned ones, may be invoked unless the Plotter that is
234 being acted on is open. */
235
236 int
pl_alabel(int x_justify,int y_justify,const char * s)237 pl_alabel (int x_justify, int y_justify, const char *s)
238 {
239 if (_old_api_plotters_len == 0)
240 _create_and_select_default_plotter ();
241 return _API_alabel (_old_api_plotter, x_justify, y_justify, s);
242 }
243
244 int
pl_arc(int xc,int yc,int x0,int y0,int x1,int y1)245 pl_arc (int xc, int yc, int x0, int y0, int x1, int y1)
246 {
247 if (_old_api_plotters_len == 0)
248 _create_and_select_default_plotter ();
249 return _API_arc (_old_api_plotter, xc, yc, x0, y0, x1, y1);
250 }
251
252 int
pl_arcrel(int xc,int yc,int x0,int y0,int x1,int y1)253 pl_arcrel (int xc, int yc, int x0, int y0, int x1, int y1)
254 {
255 if (_old_api_plotters_len == 0)
256 _create_and_select_default_plotter ();
257 return _API_arcrel (_old_api_plotter, xc, yc, x0, y0, x1, y1);
258 }
259
260 int
pl_bezier2(int xc,int yc,int x0,int y0,int x1,int y1)261 pl_bezier2 (int xc, int yc, int x0, int y0, int x1, int y1)
262 {
263 if (_old_api_plotters_len == 0)
264 _create_and_select_default_plotter ();
265 return _API_bezier2 (_old_api_plotter, xc, yc, x0, y0, x1, y1);
266 }
267
268 int
pl_bezier2rel(int xc,int yc,int x0,int y0,int x1,int y1)269 pl_bezier2rel (int xc, int yc, int x0, int y0, int x1, int y1)
270 {
271 if (_old_api_plotters_len == 0)
272 _create_and_select_default_plotter ();
273 return _API_bezier2rel (_old_api_plotter, xc, yc, x0, y0, x1, y1);
274 }
275
276 int
pl_bezier3(int x0,int y0,int x1,int y1,int x2,int y2,int x3,int y3)277 pl_bezier3 (int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3)
278 {
279 if (_old_api_plotters_len == 0)
280 _create_and_select_default_plotter ();
281 return _API_bezier3 (_old_api_plotter, x0, y0, x1, y1, x2, y2, x3, y3);
282 }
283
284 int
pl_bezier3rel(int x0,int y0,int x1,int y1,int x2,int y2,int x3,int y3)285 pl_bezier3rel (int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3)
286 {
287 if (_old_api_plotters_len == 0)
288 _create_and_select_default_plotter ();
289 return _API_bezier3rel (_old_api_plotter, x0, y0, x1, y1, x2, y2, x3, y3);
290 }
291
292 int
pl_bgcolor(int red,int green,int blue)293 pl_bgcolor (int red, int green, int blue)
294 {
295 if (_old_api_plotters_len == 0)
296 _create_and_select_default_plotter ();
297 return _API_bgcolor (_old_api_plotter, red, green, blue);
298 }
299
300 int
pl_bgcolorname(const char * s)301 pl_bgcolorname (const char *s)
302 {
303 if (_old_api_plotters_len == 0)
304 _create_and_select_default_plotter ();
305 return _API_bgcolorname (_old_api_plotter, s);
306 }
307
308 int
pl_box(int x0,int y0,int x1,int y1)309 pl_box (int x0, int y0, int x1, int y1)
310 {
311 if (_old_api_plotters_len == 0)
312 _create_and_select_default_plotter ();
313 return _API_box (_old_api_plotter, x0, y0, x1, y1);
314 }
315
316 int
pl_boxrel(int x0,int y0,int x1,int y1)317 pl_boxrel (int x0, int y0, int x1, int y1)
318 {
319 if (_old_api_plotters_len == 0)
320 _create_and_select_default_plotter ();
321 return _API_boxrel (_old_api_plotter, x0, y0, x1, y1);
322 }
323
324 int
pl_capmod(const char * s)325 pl_capmod (const char *s)
326 {
327 if (_old_api_plotters_len == 0)
328 _create_and_select_default_plotter ();
329 return _API_capmod (_old_api_plotter, s);
330 }
331
332 int
pl_circle(int x,int y,int r)333 pl_circle (int x, int y, int r)
334 {
335 if (_old_api_plotters_len == 0)
336 _create_and_select_default_plotter ();
337 return _API_circle (_old_api_plotter, x, y, r);
338 }
339
340 int
pl_circlerel(int x,int y,int r)341 pl_circlerel (int x, int y, int r)
342 {
343 if (_old_api_plotters_len == 0)
344 _create_and_select_default_plotter ();
345 return _API_circlerel (_old_api_plotter, x, y, r);
346 }
347
348 int
pl_closepath(void)349 pl_closepath (void)
350 {
351 if (_old_api_plotters_len == 0)
352 _create_and_select_default_plotter ();
353 return _API_closepath (_old_api_plotter);
354 }
355
356 int
pl_closepl(void)357 pl_closepl (void)
358 {
359 if (_old_api_plotters_len == 0)
360 _create_and_select_default_plotter ();
361 return _API_closepl (_old_api_plotter);
362 }
363
364 int
pl_color(int red,int green,int blue)365 pl_color (int red, int green, int blue)
366 {
367 if (_old_api_plotters_len == 0)
368 _create_and_select_default_plotter ();
369 return _API_color (_old_api_plotter, red, green, blue);
370 }
371
372 int
pl_colorname(const char * s)373 pl_colorname (const char *s)
374 {
375 if (_old_api_plotters_len == 0)
376 _create_and_select_default_plotter ();
377 return _API_colorname (_old_api_plotter, s);
378 }
379
380 int
pl_cont(int x,int y)381 pl_cont (int x, int y)
382 {
383 if (_old_api_plotters_len == 0)
384 _create_and_select_default_plotter ();
385 return _API_cont (_old_api_plotter, x, y);
386 }
387
388 int
pl_contrel(int x,int y)389 pl_contrel (int x, int y)
390 {
391 if (_old_api_plotters_len == 0)
392 _create_and_select_default_plotter ();
393 return _API_contrel (_old_api_plotter, x, y);
394 }
395
396 int
pl_ellarc(int xc,int yc,int x0,int y0,int x1,int y1)397 pl_ellarc (int xc, int yc, int x0, int y0, int x1, int y1)
398 {
399 if (_old_api_plotters_len == 0)
400 _create_and_select_default_plotter ();
401 return _API_ellarc (_old_api_plotter, xc, yc, x0, y0, x1, y1);
402 }
403
404 int
pl_ellarcrel(int xc,int yc,int x0,int y0,int x1,int y1)405 pl_ellarcrel (int xc, int yc, int x0, int y0, int x1, int y1)
406 {
407 if (_old_api_plotters_len == 0)
408 _create_and_select_default_plotter ();
409 return _API_ellarcrel (_old_api_plotter, xc, yc, x0, y0, x1, y1);
410 }
411
412 int
pl_ellipse(int x,int y,int rx,int ry,int angle)413 pl_ellipse (int x, int y, int rx, int ry, int angle)
414 {
415 if (_old_api_plotters_len == 0)
416 _create_and_select_default_plotter ();
417 return _API_ellipse (_old_api_plotter, x, y, rx, ry, angle);
418 }
419
420 int
pl_ellipserel(int x,int y,int rx,int ry,int angle)421 pl_ellipserel (int x, int y, int rx, int ry, int angle)
422 {
423 if (_old_api_plotters_len == 0)
424 _create_and_select_default_plotter ();
425 return _API_ellipserel (_old_api_plotter, x, y, rx, ry, angle);
426 }
427
428 int
pl_endpath(void)429 pl_endpath (void)
430 {
431 if (_old_api_plotters_len == 0)
432 _create_and_select_default_plotter ();
433 return _API_endpath (_old_api_plotter);
434 }
435
436 int
pl_endsubpath(void)437 pl_endsubpath (void)
438 {
439 if (_old_api_plotters_len == 0)
440 _create_and_select_default_plotter ();
441 return _API_endsubpath (_old_api_plotter);
442 }
443
444 int
pl_erase(void)445 pl_erase (void)
446 {
447 if (_old_api_plotters_len == 0)
448 _create_and_select_default_plotter ();
449 return _API_erase (_old_api_plotter);
450 }
451
452 int
pl_farc(double xc,double yc,double x0,double y0,double x1,double y1)453 pl_farc (double xc, double yc, double x0, double y0, double x1, double y1)
454 {
455 if (_old_api_plotters_len == 0)
456 _create_and_select_default_plotter ();
457 return _API_farc (_old_api_plotter, xc, yc, x0, y0, x1, y1);
458 }
459
460 int
pl_farcrel(double xc,double yc,double x0,double y0,double x1,double y1)461 pl_farcrel (double xc, double yc, double x0, double y0, double x1, double y1)
462 {
463 if (_old_api_plotters_len == 0)
464 _create_and_select_default_plotter ();
465 return _API_farcrel (_old_api_plotter, xc, yc, x0, y0, x1, y1);
466 }
467
468 int
pl_fbezier2(double xc,double yc,double x0,double y0,double x1,double y1)469 pl_fbezier2 (double xc, double yc, double x0, double y0, double x1, double y1)
470 {
471 if (_old_api_plotters_len == 0)
472 _create_and_select_default_plotter ();
473 return _API_fbezier2 (_old_api_plotter, xc, yc, x0, y0, x1, y1);
474 }
475
476 int
pl_fbezier2rel(double xc,double yc,double x0,double y0,double x1,double y1)477 pl_fbezier2rel (double xc, double yc, double x0, double y0, double x1, double y1)
478 {
479 if (_old_api_plotters_len == 0)
480 _create_and_select_default_plotter ();
481 return _API_fbezier2rel (_old_api_plotter, xc, yc, x0, y0, x1, y1);
482 }
483
484 int
pl_fbezier3(double x0,double y0,double x1,double y1,double x2,double y2,double x3,double y3)485 pl_fbezier3 (double x0, double y0, double x1, double y1, double x2, double y2, double x3, double y3)
486 {
487 if (_old_api_plotters_len == 0)
488 _create_and_select_default_plotter ();
489 return _API_fbezier3 (_old_api_plotter, x0, y0, x1, y1, x2, y2, x3, y3);
490 }
491
492 int
pl_fbezier3rel(double x0,double y0,double x1,double y1,double x2,double y2,double x3,double y3)493 pl_fbezier3rel (double x0, double y0, double x1, double y1, double x2, double y2, double x3, double y3)
494 {
495 if (_old_api_plotters_len == 0)
496 _create_and_select_default_plotter ();
497 return _API_fbezier3rel (_old_api_plotter, x0, y0, x1, y1, x2, y2, x3, y3);
498 }
499
500 int
pl_fbox(double x0,double y0,double x1,double y1)501 pl_fbox (double x0, double y0, double x1, double y1)
502 {
503 if (_old_api_plotters_len == 0)
504 _create_and_select_default_plotter ();
505 return _API_fbox (_old_api_plotter, x0, y0, x1, y1);
506 }
507
508 int
pl_fboxrel(double x0,double y0,double x1,double y1)509 pl_fboxrel (double x0, double y0, double x1, double y1)
510 {
511 if (_old_api_plotters_len == 0)
512 _create_and_select_default_plotter ();
513 return _API_fboxrel (_old_api_plotter, x0, y0, x1, y1);
514 }
515
516 int
pl_fcircle(double x,double y,double r)517 pl_fcircle (double x, double y, double r)
518 {
519 if (_old_api_plotters_len == 0)
520 _create_and_select_default_plotter ();
521 return _API_fcircle (_old_api_plotter, x, y, r);
522 }
523
524 int
pl_fcirclerel(double x,double y,double r)525 pl_fcirclerel (double x, double y, double r)
526 {
527 if (_old_api_plotters_len == 0)
528 _create_and_select_default_plotter ();
529 return _API_fcirclerel (_old_api_plotter, x, y, r);
530 }
531
532 int
pl_fconcat(double m0,double m1,double m2,double m3,double m4,double m5)533 pl_fconcat (double m0, double m1, double m2, double m3, double m4, double m5)
534 {
535 if (_old_api_plotters_len == 0)
536 _create_and_select_default_plotter ();
537 return _API_fconcat (_old_api_plotter, m0, m1, m2, m3, m4, m5);
538 }
539
540 int
pl_fcont(double x,double y)541 pl_fcont (double x, double y)
542 {
543 if (_old_api_plotters_len == 0)
544 _create_and_select_default_plotter ();
545 return _API_fcont (_old_api_plotter, x, y);
546 }
547
548 int
pl_fcontrel(double x,double y)549 pl_fcontrel (double x, double y)
550 {
551 if (_old_api_plotters_len == 0)
552 _create_and_select_default_plotter ();
553 return _API_fcontrel (_old_api_plotter, x, y);
554 }
555
556 int
pl_fellarc(double xc,double yc,double x0,double y0,double x1,double y1)557 pl_fellarc (double xc, double yc, double x0, double y0, double x1, double y1)
558 {
559 if (_old_api_plotters_len == 0)
560 _create_and_select_default_plotter ();
561 return _API_fellarc (_old_api_plotter, xc, yc, x0, y0, x1, y1);
562 }
563
564 int
pl_fellarcrel(double xc,double yc,double x0,double y0,double x1,double y1)565 pl_fellarcrel (double xc, double yc, double x0, double y0, double x1, double y1)
566 {
567 if (_old_api_plotters_len == 0)
568 _create_and_select_default_plotter ();
569 return _API_fellarcrel (_old_api_plotter, xc, yc, x0, y0, x1, y1);
570 }
571
572 int
pl_fellipse(double x,double y,double rx,double ry,double angle)573 pl_fellipse (double x, double y, double rx, double ry, double angle)
574 {
575 if (_old_api_plotters_len == 0)
576 _create_and_select_default_plotter ();
577 return _API_fellipse (_old_api_plotter, x, y, rx, ry, angle);
578 }
579
580 int
pl_fellipserel(double x,double y,double rx,double ry,double angle)581 pl_fellipserel (double x, double y, double rx, double ry, double angle)
582 {
583 if (_old_api_plotters_len == 0)
584 _create_and_select_default_plotter ();
585 return _API_fellipserel (_old_api_plotter, x, y, rx, ry, angle);
586 }
587
588 double
pl_ffontname(const char * s)589 pl_ffontname (const char *s)
590 {
591 if (_old_api_plotters_len == 0)
592 _create_and_select_default_plotter ();
593 return _API_ffontname (_old_api_plotter, s);
594 }
595
596 double
pl_ffontsize(double size)597 pl_ffontsize (double size)
598 {
599 if (_old_api_plotters_len == 0)
600 _create_and_select_default_plotter ();
601 return _API_ffontsize (_old_api_plotter, size);
602 }
603
604 int
pl_fillcolor(int red,int green,int blue)605 pl_fillcolor (int red, int green, int blue)
606 {
607 if (_old_api_plotters_len == 0)
608 _create_and_select_default_plotter ();
609 return _API_fillcolor (_old_api_plotter, red, green, blue);
610 }
611
612 int
pl_fillcolorname(const char * s)613 pl_fillcolorname (const char *s)
614 {
615 if (_old_api_plotters_len == 0)
616 _create_and_select_default_plotter ();
617 return _API_fillcolorname (_old_api_plotter, s);
618 }
619
620 int
pl_fillmod(const char * s)621 pl_fillmod (const char *s)
622 {
623 if (_old_api_plotters_len == 0)
624 _create_and_select_default_plotter ();
625 return _API_fillmod (_old_api_plotter, s);
626 }
627
628 int
pl_filltype(int level)629 pl_filltype (int level)
630 {
631 if (_old_api_plotters_len == 0)
632 _create_and_select_default_plotter ();
633 return _API_filltype (_old_api_plotter, level);
634 }
635
636 double
pl_flabelwidth(const char * s)637 pl_flabelwidth (const char *s)
638 {
639 if (_old_api_plotters_len == 0)
640 _create_and_select_default_plotter ();
641 return _API_flabelwidth (_old_api_plotter, s);
642 }
643
644 int
pl_fline(double x0,double y0,double x1,double y1)645 pl_fline (double x0, double y0, double x1, double y1)
646 {
647 if (_old_api_plotters_len == 0)
648 _create_and_select_default_plotter ();
649 return _API_fline (_old_api_plotter, x0, y0, x1, y1);
650 }
651
652 int
pl_flinedash(int n,const double * dashes,double offset)653 pl_flinedash (int n, const double *dashes, double offset)
654 {
655 if (_old_api_plotters_len == 0)
656 _create_and_select_default_plotter ();
657 return _API_flinedash (_old_api_plotter, n, dashes, offset);
658 }
659
660 int
pl_flinerel(double x0,double y0,double x1,double y1)661 pl_flinerel (double x0, double y0, double x1, double y1)
662 {
663 if (_old_api_plotters_len == 0)
664 _create_and_select_default_plotter ();
665 return _API_flinerel (_old_api_plotter, x0, y0, x1, y1);
666 }
667
668 int
pl_flinewidth(double size)669 pl_flinewidth (double size)
670 {
671 if (_old_api_plotters_len == 0)
672 _create_and_select_default_plotter ();
673 return _API_flinewidth (_old_api_plotter, size);
674 }
675
676 int
pl_flushpl(void)677 pl_flushpl (void)
678 {
679 if (_old_api_plotters_len == 0)
680 _create_and_select_default_plotter ();
681 return _API_flushpl (_old_api_plotter);
682 }
683
684 int
pl_fmarker(double x,double y,int type,double size)685 pl_fmarker (double x, double y, int type, double size)
686 {
687 if (_old_api_plotters_len == 0)
688 _create_and_select_default_plotter ();
689 return _API_fmarker (_old_api_plotter, x, y, type, size);
690 }
691
692 int
pl_fmarkerrel(double x,double y,int type,double size)693 pl_fmarkerrel (double x, double y, int type, double size)
694 {
695 if (_old_api_plotters_len == 0)
696 _create_and_select_default_plotter ();
697 return _API_fmarkerrel (_old_api_plotter, x, y, type, size);
698 }
699
700 int
pl_fmiterlimit(double limit)701 pl_fmiterlimit (double limit)
702 {
703 if (_old_api_plotters_len == 0)
704 _create_and_select_default_plotter ();
705 return _API_fmiterlimit (_old_api_plotter, limit);
706 }
707
708 int
pl_fmove(double x,double y)709 pl_fmove (double x, double y)
710 {
711 if (_old_api_plotters_len == 0)
712 _create_and_select_default_plotter ();
713 return _API_fmove (_old_api_plotter, x, y);
714 }
715
716 int
pl_fmoverel(double x,double y)717 pl_fmoverel (double x, double y)
718 {
719 if (_old_api_plotters_len == 0)
720 _create_and_select_default_plotter ();
721 return _API_fmoverel (_old_api_plotter, x, y);
722 }
723
724 int
pl_fontname(const char * s)725 pl_fontname (const char *s)
726 {
727 if (_old_api_plotters_len == 0)
728 _create_and_select_default_plotter ();
729 return _API_fontname (_old_api_plotter, s);
730 }
731
732 int
pl_fontsize(int size)733 pl_fontsize (int size)
734 {
735 if (_old_api_plotters_len == 0)
736 _create_and_select_default_plotter ();
737 return _API_fontsize (_old_api_plotter, size);
738 }
739
740 int
pl_fpoint(double x,double y)741 pl_fpoint (double x, double y)
742 {
743 if (_old_api_plotters_len == 0)
744 _create_and_select_default_plotter ();
745 return _API_fpoint (_old_api_plotter, x, y);
746 }
747
748 int
pl_fpointrel(double x,double y)749 pl_fpointrel (double x, double y)
750 {
751 if (_old_api_plotters_len == 0)
752 _create_and_select_default_plotter ();
753 return _API_fpointrel (_old_api_plotter, x, y);
754 }
755
756 int
pl_frotate(double theta)757 pl_frotate (double theta)
758 {
759 if (_old_api_plotters_len == 0)
760 _create_and_select_default_plotter ();
761 return _API_frotate (_old_api_plotter, theta);
762 }
763
764 int
pl_fscale(double x,double y)765 pl_fscale (double x, double y)
766 {
767 if (_old_api_plotters_len == 0)
768 _create_and_select_default_plotter ();
769 return _API_fscale (_old_api_plotter, x, y);
770 }
771
772 int
pl_fsetmatrix(double m0,double m1,double m2,double m3,double m4,double m5)773 pl_fsetmatrix (double m0, double m1, double m2, double m3, double m4, double m5)
774 {
775 if (_old_api_plotters_len == 0)
776 _create_and_select_default_plotter ();
777 return _API_fsetmatrix (_old_api_plotter, m0, m1, m2, m3, m4, m5);
778 }
779
780 int
pl_fspace(double x0,double y0,double x1,double y1)781 pl_fspace (double x0, double y0, double x1, double y1)
782 {
783 if (_old_api_plotters_len == 0)
784 _create_and_select_default_plotter ();
785 return _API_fspace (_old_api_plotter, x0, y0, x1, y1);
786 }
787
788 int
pl_fspace2(double x0,double y0,double x1,double y1,double x2,double y2)789 pl_fspace2 (double x0, double y0, double x1, double y1, double x2, double y2)
790 {
791 if (_old_api_plotters_len == 0)
792 _create_and_select_default_plotter ();
793 return _API_fspace2 (_old_api_plotter, x0, y0, x1, y1, x2, y2);
794 }
795
796 double
pl_ftextangle(double angle)797 pl_ftextangle (double angle)
798 {
799 if (_old_api_plotters_len == 0)
800 _create_and_select_default_plotter ();
801 return _API_ftextangle (_old_api_plotter, angle);
802 }
803
804 int
pl_ftranslate(double x,double y)805 pl_ftranslate (double x, double y)
806 {
807 if (_old_api_plotters_len == 0)
808 _create_and_select_default_plotter ();
809 return _API_ftranslate (_old_api_plotter, x, y);
810 }
811
812 int
pl_havecap(const char * s)813 pl_havecap (const char *s)
814 {
815 if (_old_api_plotters_len == 0)
816 _create_and_select_default_plotter ();
817 return _API_havecap (_old_api_plotter, s);
818 }
819
820 int
pl_joinmod(const char * s)821 pl_joinmod (const char *s)
822 {
823 if (_old_api_plotters_len == 0)
824 _create_and_select_default_plotter ();
825 return _API_joinmod (_old_api_plotter, s);
826 }
827
828 int
pl_label(const char * s)829 pl_label (const char *s)
830 {
831 if (_old_api_plotters_len == 0)
832 _create_and_select_default_plotter ();
833 return _API_label (_old_api_plotter, s);
834 }
835
836 int
pl_labelwidth(const char * s)837 pl_labelwidth (const char *s)
838 {
839 if (_old_api_plotters_len == 0)
840 _create_and_select_default_plotter ();
841 return _API_labelwidth (_old_api_plotter, s);
842 }
843
844 int
pl_line(int x0,int y0,int x1,int y1)845 pl_line (int x0, int y0, int x1, int y1)
846 {
847 if (_old_api_plotters_len == 0)
848 _create_and_select_default_plotter ();
849 return _API_line (_old_api_plotter, x0, y0, x1, y1);
850 }
851
852 int
pl_linerel(int x0,int y0,int x1,int y1)853 pl_linerel (int x0, int y0, int x1, int y1)
854 {
855 if (_old_api_plotters_len == 0)
856 _create_and_select_default_plotter ();
857 return _API_linerel (_old_api_plotter, x0, y0, x1, y1);
858 }
859
860 int
pl_linewidth(int size)861 pl_linewidth (int size)
862 {
863 if (_old_api_plotters_len == 0)
864 _create_and_select_default_plotter ();
865 return _API_linewidth (_old_api_plotter, size);
866 }
867
868 int
pl_linedash(int n,const int * dashes,int offset)869 pl_linedash (int n, const int *dashes, int offset)
870 {
871 if (_old_api_plotters_len == 0)
872 _create_and_select_default_plotter ();
873 return _API_linedash (_old_api_plotter, n, dashes, offset);
874 }
875
876 int
pl_linemod(const char * s)877 pl_linemod (const char *s)
878 {
879 if (_old_api_plotters_len == 0)
880 _create_and_select_default_plotter ();
881 return _API_linemod (_old_api_plotter, s);
882 }
883
884 int
pl_marker(int x,int y,int type,int size)885 pl_marker (int x, int y, int type, int size)
886 {
887 if (_old_api_plotters_len == 0)
888 _create_and_select_default_plotter ();
889 return _API_marker (_old_api_plotter, x, y, type, size);
890 }
891
892 int
pl_markerrel(int x,int y,int type,int size)893 pl_markerrel (int x, int y, int type, int size)
894 {
895 if (_old_api_plotters_len == 0)
896 _create_and_select_default_plotter ();
897 return _API_markerrel (_old_api_plotter, x, y, type, size);
898 }
899
900 int
pl_move(int x,int y)901 pl_move (int x, int y)
902 {
903 if (_old_api_plotters_len == 0)
904 _create_and_select_default_plotter ();
905 return _API_move (_old_api_plotter, x, y);
906 }
907
908 int
pl_moverel(int x,int y)909 pl_moverel (int x, int y)
910 {
911 if (_old_api_plotters_len == 0)
912 _create_and_select_default_plotter ();
913 return _API_moverel (_old_api_plotter, x, y);
914 }
915
916 int
pl_openpl(void)917 pl_openpl (void)
918 {
919 if (_old_api_plotters_len == 0)
920 _create_and_select_default_plotter ();
921 return _API_openpl (_old_api_plotter);
922 }
923
924 int
pl_orientation(int direction)925 pl_orientation (int direction)
926 {
927 if (_old_api_plotters_len == 0)
928 _create_and_select_default_plotter ();
929 return _API_orientation (_old_api_plotter, direction);
930 }
931
932 FILE *
pl_outfile(FILE * outfile)933 pl_outfile (FILE *outfile)
934 {
935 if (_old_api_plotters_len == 0)
936 _create_and_select_default_plotter ();
937 return _API_outfile (_old_api_plotter, outfile);
938 }
939
940 int
pl_pencolor(int red,int green,int blue)941 pl_pencolor (int red, int green, int blue)
942 {
943 if (_old_api_plotters_len == 0)
944 _create_and_select_default_plotter ();
945 return _API_pencolor (_old_api_plotter, red, green, blue);
946 }
947
948 int
pl_pencolorname(const char * s)949 pl_pencolorname (const char *s)
950 {
951 if (_old_api_plotters_len == 0)
952 _create_and_select_default_plotter ();
953 return _API_pencolorname (_old_api_plotter, s);
954 }
955
956 int
pl_pentype(int level)957 pl_pentype (int level)
958 {
959 if (_old_api_plotters_len == 0)
960 _create_and_select_default_plotter ();
961 return _API_pentype (_old_api_plotter, level);
962 }
963
964 int
pl_point(int x,int y)965 pl_point (int x, int y)
966 {
967 if (_old_api_plotters_len == 0)
968 _create_and_select_default_plotter ();
969 return _API_point (_old_api_plotter, x, y);
970 }
971
972 int
pl_pointrel(int x,int y)973 pl_pointrel (int x, int y)
974 {
975 if (_old_api_plotters_len == 0)
976 _create_and_select_default_plotter ();
977 return _API_pointrel (_old_api_plotter, x, y);
978 }
979
980 int
pl_restorestate(void)981 pl_restorestate (void)
982 {
983 if (_old_api_plotters_len == 0)
984 _create_and_select_default_plotter ();
985 return _API_restorestate (_old_api_plotter);
986 }
987
988 int
pl_savestate(void)989 pl_savestate (void)
990 {
991 if (_old_api_plotters_len == 0)
992 _create_and_select_default_plotter ();
993 return _API_savestate (_old_api_plotter);
994 }
995
996 int
pl_space(int x0,int y0,int x1,int y1)997 pl_space (int x0, int y0, int x1, int y1)
998 {
999 if (_old_api_plotters_len == 0)
1000 _create_and_select_default_plotter ();
1001 return _API_space (_old_api_plotter, x0, y0, x1, y1);
1002 }
1003
1004 int
pl_space2(int x0,int y0,int x1,int y1,int x2,int y2)1005 pl_space2 (int x0, int y0, int x1, int y1, int x2, int y2)
1006 {
1007 if (_old_api_plotters_len == 0)
1008 _create_and_select_default_plotter ();
1009 return _API_space2 (_old_api_plotter, x0, y0, x1, y1, x2, y2);
1010 }
1011
1012 int
pl_textangle(int angle)1013 pl_textangle (int angle)
1014 {
1015 if (_old_api_plotters_len == 0)
1016 _create_and_select_default_plotter ();
1017 return _API_textangle (_old_api_plotter, angle);
1018 }
1019
1020 /* END OF WRAPPERS */
1021