123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223 |
- #include "sys-defines.h"
- #include "extern.h"
- #ifndef LIBPLOTTER
- const PlotterParams _default_plotter_params =
- {
-
- _setplparam
- };
- #endif
- #ifdef LIBPLOTTER
- PlotterParams::PlotterParams ()
- {
- int i;
-
- for (i = 0; i < NUM_PLOTTER_PARAMETERS; i++)
- plparams[i] = (void *)NULL;
- }
- PlotterParams::~PlotterParams ()
- {
- int i;
-
- for (i = 0; i < NUM_PLOTTER_PARAMETERS; i++)
- if (_known_params[i].is_string && plparams[i] != NULL)
- free (plparams[i]);
- }
- PlotterParams::PlotterParams (const PlotterParams& oldPlotterParams)
- {
- int i;
-
- for (i = 0; i < NUM_PLOTTER_PARAMETERS; i++)
- plparams[i] = oldPlotterParams.plparams[i];
- }
- PlotterParams& PlotterParams::operator= (const PlotterParams& oldPlotterParams)
- {
- int i;
-
- for (i = 0; i < NUM_PLOTTER_PARAMETERS; i++)
- plparams[i] = oldPlotterParams.plparams[i];
- return (*this);
- }
- #endif
- int
- _setplparam (R___(PlotterParams *_plotter_params) const char *parameter, void * value)
- {
- int j;
- for (j = 0; j < NUM_PLOTTER_PARAMETERS; j++)
- {
- if (strcmp (_known_params[j].parameter, parameter) == 0)
- {
- if (_known_params[j].is_string)
-
- {
- if (_plotter_params->plparams[j])
- free (_plotter_params->plparams[j]);
- if (value != NULL)
- {
- _plotter_params->plparams[j] =
- (char *)_pl_xmalloc (strlen ((char *)value) + 1);
- strcpy ((char *)_plotter_params->plparams[j], (char *)value);
- }
- else
- _plotter_params->plparams[j] = NULL;
- }
- else
-
- _plotter_params->plparams[j] = value;
-
-
- return 0;
- }
- }
-
- return 0;
- }
-
- void
- _pl_g_copy_params_to_plotter (R___(Plotter *_plotter) const PlotterParams *plotter_params)
- {
- int j;
- char *envs;
- for (j = 0; j < NUM_PLOTTER_PARAMETERS; j++)
- {
- if (!_known_params[j].is_string)
-
- _plotter->data->params[j] = plotter_params->plparams[j];
- else
-
- {
- if (plotter_params->plparams[j])
-
- {
- _plotter->data->params[j] =
- (char *)_pl_xmalloc (strlen ((char *)plotter_params->plparams[j]) + 1);
- strcpy ((char *)_plotter->data->params[j],
- (char *)plotter_params->plparams[j]);
- }
- else if ((envs = getenv (_known_params[j].parameter)) != NULL)
-
- {
- _plotter->data->params[j] =
- (char *)_pl_xmalloc (strlen (envs) + 1);
- strcpy ((char *)_plotter->data->params[j], envs);
- }
- else if (_known_params[j].default_value)
-
- {
- _plotter->data->params[j] =
- (char *)_pl_xmalloc (strlen ((char *)_known_params[j].default_value) + 1);
- strcpy ((char *)_plotter->data->params[j],
- (char *)_known_params[j].default_value);
- }
- else
- _plotter->data->params[j] = NULL;
- }
- }
- }
- void *
- _get_plot_param (const plPlotterData *data, const char *parameter_name)
- {
- int j;
- for (j = 0; j < NUM_PLOTTER_PARAMETERS; j++)
- if (strcmp (_known_params[j].parameter, parameter_name) == 0)
- return data->params[j];
- return (void *)NULL;
- }
- void
- _pl_g_free_params_in_plotter (S___(Plotter *_plotter))
- {
- int j;
-
- for (j = 0; j < NUM_PLOTTER_PARAMETERS; j++)
- if (_known_params[j].is_string && _plotter->data->params[j] != NULL)
-
- free (_plotter->data->params[j]);
- }
- void *
- _get_default_plot_param (const char *parameter_name)
- {
- int j;
- for (j = 0; j < NUM_PLOTTER_PARAMETERS; j++)
- if (strcmp (_known_params[j].parameter, parameter_name) == 0)
- return _known_params[j].default_value;
- return (void *)NULL;
- }
|