apioldc.c 26 KB

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