Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / programs / dtappbuilder / src / ab / cgen_env_stubs.c
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these librararies and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /*** DTB_USER_CODE_START vvv Add file header below vvv ***/
24 /*
25  *      $XConsortium: cgen_env_stubs.c /main/4 1996/04/18 13:17:55 drk $
26  *
27  * @(#)cgen_env_stubs.c 1.15 16 Feb 1995 cde_app_builder/src/ab
28  *
29  *      RESTRICTED CONFIDENTIAL INFORMATION:
30  *
31  *      The information in this document is subject to special
32  *      restrictions in a confidential disclosure agreement between
33  *      HP, IBM, Sun, USL, SCO and Univel.  Do not distribute this
34  *      document outside HP, IBM, Sun, USL, SCO, or Univel without
35  *      Sun's specific written approval.  This document and all copies
36  *      and derivative works thereof must be returned or destroyed at
37  *      Sun's request.
38  *
39  *      Copyright 1993 Sun Microsystems, Inc.  All rights reserved.
40  *
41  */
42
43 /*** DTB_USER_CODE_END   ^^^ Add file header above ^^^ ***/
44
45 /*
46  * File: cgen_env_stubs.c
47  * Contains: Module callbacks and connection functions
48  *
49  * This file was generated by dtcodegen, from module cgen_env
50  *
51  * Any text may be added between the DTB_USER_CODE_START and
52  * DTB_USER_CODE_END comments (even non-C code). Descriptive comments
53  * are provided only as an aid.
54  *
55  *  ** EDIT ONLY WITHIN SECTIONS MARKED WITH DTB_USER_CODE COMMENTS.  **
56  *  ** ALL OTHER MODIFICATIONS WILL BE OVERWRITTEN. DO NOT MODIFY OR  **
57  *  ** DELETE THE GENERATED COMMENTS!                                 **
58  */
59
60 #include <stdio.h>
61 #include <Xm/Xm.h>
62 #include "dtb_utils.h"
63 #include "dtbuilder.h"
64 #include "cgen_env_ui.h"
65
66
67 /**************************************************************************
68  *** DTB_USER_CODE_START
69  ***
70  *** All necessary header files have been included.
71  ***
72  *** Add include files, types, macros, externs, and user functions here.
73  ***/
74
75 #include <Xm/TextF.h>
76 #include <Xm/Text.h>
77
78 #include "dtbuilder.h"
79 #include "cgen_env_ui.h"
80 #include <ab_private/strlist.h>
81 #include "palette_ui.h"
82 #include "cgen.h"
83 #include "dtb_utils.h"
84
85 /*** DTB_USER_CODE_END
86  ***
87  *** End of user code section
88  ***
89  **************************************************************************/
90
91
92
93 void 
94 cgenP_get_envCB(
95     Widget widget,
96     XtPointer clientData,
97     XtPointer callData
98 )
99 {
100     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
101
102     DtbCgenEnvDialogInfo        env_dlg = (DtbCgenEnvDialogInfo)clientData;
103     STRING                      var_name = NULL;
104     STRING                      var_value = NULL;
105     int                         index = 0;
106
107     var_name = XmTextFieldGetString(env_dlg->name_textf);
108     if (util_strempty(var_name))
109     {
110         /* clean out the value textpane */
111         XmTextSetString(env_dlg->textpane, NULL);
112     }
113     else
114     {
115         if (strlist_str_exists(user_env_vars, var_name))
116         {
117             var_value = (STRING) strlist_get_str_data(user_env_vars, var_name);
118         }
119         else
120         {
121             /* not in list */
122             var_value = getenv(var_name);
123         }
124         if (var_value == NULL)
125         {
126             XmTextSetString(env_dlg->textpane, catgets(Dtb_project_catd, 100, 58, "*** Not Set ***"));
127         }
128         else
129         {
130             XmTextSetString(env_dlg->textpane, var_value);
131         }
132         
133     }
134
135     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
136     
137     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
138     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
139 }
140
141
142 void 
143 cgenP_set_envCB(
144     Widget widget,
145     XtPointer clientData,
146     XtPointer callData
147 )
148 {
149     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
150
151     DtbCgenEnvDialogInfo        env_dlg = (DtbCgenEnvDialogInfo)clientData;
152     STRING                      var_name = NULL;
153     STRING                      var_value = NULL;
154     STRING                      old_var_value = NULL;
155
156     var_name = XmTextFieldGetString(env_dlg->name_textf);
157
158     if (util_strempty(var_name))
159         return;
160
161     var_value = XmTextGetString(env_dlg->textpane);
162
163     if (strlist_str_exists(user_env_vars, var_name))
164     {
165         /* the user has set this before - we need to deallocate
166          * the string we allocated
167          */
168         old_var_value = (STRING) strlist_get_str_data(user_env_vars, var_name);
169         util_free(old_var_value);
170         strlist_remove_str(user_env_vars, var_name);
171     }
172     if (!util_strempty(var_value))
173         strlist_add_str(user_env_vars, var_name, (void *)strdup(var_value));
174     else
175         strlist_add_str(user_env_vars, var_name, (void *)NULL);
176
177     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
178     
179     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
180     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
181 }
182
183
184 void 
185 cgenP_reset_envCB(
186     Widget widget,
187     XtPointer clientData,
188     XtPointer callData
189 )
190 {
191     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
192     DtbCgenEnvDialogInfo        env_dlg = (DtbCgenEnvDialogInfo)clientData;
193     STRING                      var_name = NULL;
194     STRING                      var_value = NULL;
195
196     var_name = XmTextFieldGetString(env_dlg->name_textf);
197
198     if (util_strempty(var_name))
199         return;
200
201     if (strlist_str_exists(user_env_vars, var_name))
202     {
203         /* the user has set this before - we need to deallocate
204          * the string we allocated
205          */
206         var_value = (STRING) strlist_get_str_data(user_env_vars, var_name);
207         util_free(var_value);
208         strlist_remove_str(user_env_vars, var_name);
209     }
210     var_value = getenv(var_name);
211
212     if (var_value == NULL)
213     {
214         XmTextSetString(env_dlg->textpane, catgets(Dtb_project_catd, 100, 58, "*** Not Set ***"));
215     }
216     else
217     {
218         XmTextSetString(env_dlg->textpane, var_value);
219     }
220
221     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
222     
223     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
224     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
225 }
226
227
228 void 
229 cgenP_init_env_list(
230     Widget widget,
231     XtPointer clientData,
232     XtPointer callData
233 )
234 {
235     DtbCgenEnvDialogInfo        dtbSource = (DtbCgenEnvDialogInfo)callData;
236     
237     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
238
239     if (user_env_vars == NULL)
240     {
241         user_env_vars = strlist_create();
242     }
243
244     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
245     
246     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
247     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
248 }
249
250
251 void 
252 cgenP_cancel_envCB(
253     Widget widget,
254     XtPointer clientData,
255     XtPointer callData
256 )
257 {
258     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
259     DtbCgenEnvDialogInfo        env_dlg = (DtbCgenEnvDialogInfo)clientData;
260     char buf[10];
261
262     sprintf(buf, "");
263     XmTextFieldSetString(env_dlg->name_textf, buf);
264     XmTextSetString(env_dlg->textpane, buf);
265     
266     XtPopdown(env_dlg->dialog);
267
268     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
269     
270     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
271     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
272 }
273
274
275
276 /**************************************************************************
277  *** DTB_USER_CODE_START
278  ***
279  *** All automatically-generated data and functions have been defined.
280  ***
281  *** Add new functions here, or at the top of the file.
282  ***/
283 /*** DTB_USER_CODE_END
284  ***
285  *** End of user code section
286  ***
287  **************************************************************************/
288
289