1 /* Goom Project
2 * Copyright (C) <2003> Jean-Christophe Hoelt <jeko@free.fr>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20 #include "goom_config_param.h"
21 #include <string.h>
22
23 static void
empty_fct(PluginParam * dummy)24 empty_fct (PluginParam * dummy)
25 {
26 }
27
28 void
goom_secure_param(PluginParam * p)29 goom_secure_param (PluginParam * p)
30 {
31 p->changed = empty_fct;
32 p->change_listener = empty_fct;
33 p->user_data = 0;
34 p->name = p->desc = 0;
35 p->rw = 1;
36 }
37
38 void
goom_secure_f_param(PluginParam * p,const char * name)39 goom_secure_f_param (PluginParam * p, const char *name)
40 {
41 secure_param (p);
42
43 p->name = name;
44 p->type = PARAM_FLOATVAL;
45 FVAL (*p) = 0.5f;
46 FMIN (*p) = 0.0f;
47 FMAX (*p) = 1.0f;
48 FSTEP (*p) = 0.01f;
49 }
50
51 void
goom_secure_f_feedback(PluginParam * p,const char * name)52 goom_secure_f_feedback (PluginParam * p, const char *name)
53 {
54 secure_f_param (p, name);
55
56 p->rw = 0;
57 }
58
59 void
goom_secure_s_param(PluginParam * p,const char * name)60 goom_secure_s_param (PluginParam * p, const char *name)
61 {
62 secure_param (p);
63
64 p->name = name;
65 p->type = PARAM_STRVAL;
66 SVAL (*p) = 0;
67 }
68
69 void
goom_secure_b_param(PluginParam * p,const char * name,int value)70 goom_secure_b_param (PluginParam * p, const char *name, int value)
71 {
72 secure_param (p);
73
74 p->name = name;
75 p->type = PARAM_BOOLVAL;
76 BVAL (*p) = value;
77 }
78
79 void
goom_secure_i_param(PluginParam * p,const char * name)80 goom_secure_i_param (PluginParam * p, const char *name)
81 {
82 secure_param (p);
83
84 p->name = name;
85 p->type = PARAM_INTVAL;
86 IVAL (*p) = 50;
87 IMIN (*p) = 0;
88 IMAX (*p) = 100;
89 ISTEP (*p) = 1;
90 }
91
92 void
goom_secure_i_feedback(PluginParam * p,const char * name)93 goom_secure_i_feedback (PluginParam * p, const char *name)
94 {
95 secure_i_param (p, name);
96
97 p->rw = 0;
98 }
99
100 void
goom_plugin_parameters(PluginParameters * p,const char * name,int nb)101 goom_plugin_parameters (PluginParameters * p, const char *name, int nb)
102 {
103 p->name = name;
104 p->desc = "";
105 p->nbParams = nb;
106 p->params = malloc (nb * sizeof (PluginParam *));
107 }
108
109 void
goom_plugin_parameters_free(PluginParameters * p)110 goom_plugin_parameters_free (PluginParameters * p)
111 {
112 free (p->params);
113 }
114
115 /*---------------------------------------------------------------------------*/
116
117 void
goom_set_str_param_value(PluginParam * p,const char * str)118 goom_set_str_param_value (PluginParam * p, const char *str)
119 {
120 int len = strlen (str);
121
122 if (SVAL (*p))
123 SVAL (*p) = (char *) realloc (SVAL (*p), len + 1);
124 else
125 SVAL (*p) = (char *) malloc (len + 1);
126 memcpy (SVAL (*p), str, len + 1);
127 }
128
129 void
goom_set_list_param_value(PluginParam * p,const char * str)130 goom_set_list_param_value (PluginParam * p, const char *str)
131 {
132 int len = strlen (str);
133
134 #ifdef VERBOSE
135 printf ("%s: %d\n", str, len);
136 #endif
137 if (LVAL (*p))
138 LVAL (*p) = (char *) realloc (LVAL (*p), len + 1);
139 else
140 LVAL (*p) = (char *) malloc (len + 1);
141 memcpy (LVAL (*p), str, len + 1);
142 }
143