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 belongs to both libplot and libplotter. It contains a
20 function that appears in both the old (non-thread-safe) C and C++
21 bindings. It is named pl_parampl() and parampl(), respectively.
22
23 pl_parampl/parampl sets parameters in a global PlotterParams object,
24 which is used as a source of parameters when any Plotter is created.
25 The presence of this global state is one reason why the old API's are
26 not thread-safe.
27
28 In libplotter, parampl is a static function member of the Plotter class,
29 as is the global PlotterParams. This is arranged by #ifdef's in
30 extern.h.
31
32 In both libplot and libplotter, the pointer to the global PlotterParams,
33 which is called _old_api_global_plotter_params, is defined in
34 g_defplot.c. */
35
36 #include "sys-defines.h"
37 #include "extern.h"
38 #ifndef LIBPLOTTER
39 #include "plot.h" /* header file for C API's */
40 #endif
41
42 int
43 #ifdef LIBPLOTTER
parampl(const char * parameter,void * value)44 parampl (const char *parameter, void *value)
45 #else /* not LIBPLOTTER */
46 pl_parampl (const char *parameter, void *value)
47 #endif
48 {
49 /* create global object if necessary (via different routes for libplotter
50 and libplot; for latter, call a function in new C API) */
51 if (_old_api_global_plotter_params == NULL)
52 #ifdef LIBPLOTTER
53 _old_api_global_plotter_params = new PlotterParams;
54 #else
55 _old_api_global_plotter_params = pl_newplparams ();
56 #endif
57
58 return _old_api_global_plotter_params->setplparam (R___(_old_api_global_plotter_params)
59 parameter, value);
60 }
61