apioldcc.c 2.3 KB

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