1 | |
---|
2 | /* file globalparams.c |
---|
3 | * ============== |
---|
4 | * |
---|
5 | * $Revision: 42 $, $Date: 2008-10-13 22:51:21 +0200 (Mo, 13 Okt 2008) $ |
---|
6 | * |
---|
7 | * Management of global parameters |
---|
8 | * K. Stammler, 9-May-2006 |
---|
9 | */ |
---|
10 | |
---|
11 | |
---|
12 | /* |
---|
13 | * |
---|
14 | * SeismicHandler, seismic analysis software |
---|
15 | * Copyright (C) 1992, Klaus Stammler, Federal Institute for Geosciences |
---|
16 | * and Natural Resources (BGR), Germany |
---|
17 | * |
---|
18 | * This program is free software; you can redistribute it and/or modify |
---|
19 | * it under the terms of the GNU General Public License as published by |
---|
20 | * the Free Software Foundation; either version 2 of the License, or |
---|
21 | * (at your option) any later version. |
---|
22 | * |
---|
23 | * This program is distributed in the hope that it will be useful, |
---|
24 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
26 | * GNU General Public License for more details. |
---|
27 | * |
---|
28 | * You should have received a copy of the GNU General Public License |
---|
29 | * along with this program; if not, write to the Free Software |
---|
30 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
---|
31 | * |
---|
32 | */ |
---|
33 | |
---|
34 | |
---|
35 | #include <stdio.h> |
---|
36 | #include <string.h> |
---|
37 | #include "basecnst.h" |
---|
38 | #ifdef BC_INC_STDLIB |
---|
39 | #include BC_INC_STDLIB |
---|
40 | #endif |
---|
41 | #include "utusrdef.h" |
---|
42 | #include "globalparams.h" |
---|
43 | |
---|
44 | |
---|
45 | /* local types */ |
---|
46 | typedef struct _string_elem { |
---|
47 | struct _string_elem *next; /* pointer to next string element */ |
---|
48 | char *string; /* string values */ |
---|
49 | int strlth; /* string length excl. term null */ |
---|
50 | } TGpStringElem; |
---|
51 | |
---|
52 | |
---|
53 | |
---|
54 | /* integer variables |
---|
55 | * ----------------- |
---|
56 | */ |
---|
57 | |
---|
58 | static char *gpv_i_name[] = { |
---|
59 | "debug_level", |
---|
60 | "parfile_version", |
---|
61 | "parfile_subversion", |
---|
62 | "min_drag_box_width", |
---|
63 | "double_click_time", |
---|
64 | "x_max_drawlth", |
---|
65 | "drag_box_rubber_val", |
---|
66 | "default_quality", |
---|
67 | "default_event_type", |
---|
68 | "default_phase_flags", |
---|
69 | "default_depth_type", |
---|
70 | "default_loc_quality", |
---|
71 | "max_cursor_form", |
---|
72 | "top_margin", |
---|
73 | "parameter_box_x", |
---|
74 | "parameter_box_y", |
---|
75 | "parameter_box_w", |
---|
76 | "parameter_box_h", |
---|
77 | "phase_box_x", |
---|
78 | "phase_box_y", |
---|
79 | "phase_box_w", |
---|
80 | "phase_box_h", |
---|
81 | "window_main_x", |
---|
82 | "window_main_y", |
---|
83 | "window_main_w", |
---|
84 | "window_main_h", |
---|
85 | "single_trace_box_x", |
---|
86 | "single_trace_box_y", |
---|
87 | "single_trace_box_w", |
---|
88 | "single_trace_box_h", |
---|
89 | "window_border", |
---|
90 | "draw_area_width", |
---|
91 | "draw_area_height", |
---|
92 | "trace_normalisation", |
---|
93 | "spectrogram_width", |
---|
94 | "spectrogram_step", |
---|
95 | "keysym_arrow_up", |
---|
96 | "keysym_arrow_down", |
---|
97 | "keysym_arrow_left", |
---|
98 | "keysym_arrow_right", |
---|
99 | "i_last_parameter" |
---|
100 | }; |
---|
101 | |
---|
102 | /* default values if no parameter file is found */ |
---|
103 | static int gpv_i_glob[cGpI_last+1] = { |
---|
104 | 0, /* debug_level */ |
---|
105 | 0, /* parfile_version */ |
---|
106 | 0, /* parfile_subversion */ |
---|
107 | 7, /* min_drag_box_width */ |
---|
108 | 200, /* double_click_time */ |
---|
109 | 4096, /* x_max_drawlth */ |
---|
110 | 10, /* drag_box_rubber_val */ |
---|
111 | 2, /* default_quality */ |
---|
112 | 0, /* default_phase_type */ |
---|
113 | 0, /* default_phase_flags */ |
---|
114 | 0, /* default_depth_type */ |
---|
115 | 0, /* default_loc_quality */ |
---|
116 | 5, /* max_cursor_form */ |
---|
117 | 20, /* top margin */ |
---|
118 | 93, /* parameter_box_x */ |
---|
119 | 0, /* parameter_box_y */ |
---|
120 | 125, /* parameter_box_w */ |
---|
121 | 700, /* parameter_box_h */ |
---|
122 | -38, /* phase_box_x */ |
---|
123 | 0, /* phase_box_y */ |
---|
124 | 155, /* phase_box_w */ |
---|
125 | 720, /* phase_box_h */ |
---|
126 | 224, /* window_main_x */ |
---|
127 | 220, /* window_main_y */ |
---|
128 | 1039, /* window_main_w */ |
---|
129 | 516, /* window_main_h */ |
---|
130 | 224, /* single_trace_box_x */ |
---|
131 | 0, /* single_trace_box_y */ |
---|
132 | 1039, /* single_trace_box_w */ |
---|
133 | 203, /* single_trace_box_h */ |
---|
134 | 3, /* window_border */ |
---|
135 | 1035, /* draw_area_width */ |
---|
136 | 485, /* draw_area_height */ |
---|
137 | 0, /* trace_normalisation */ |
---|
138 | 1024, /* spectrogram_width */ |
---|
139 | 4, /* spectrogram_step */ |
---|
140 | 268762962, /* keysym_arrow_up */ |
---|
141 | 268762964, /* keysym_arrow_down */ |
---|
142 | 268762961, /* keysym_arrow_left */ |
---|
143 | 268762963, /* keysym_arrow_right */ |
---|
144 | 0 /* last parameter */ |
---|
145 | }; |
---|
146 | |
---|
147 | |
---|
148 | /* float variables |
---|
149 | * ----------------- |
---|
150 | */ |
---|
151 | |
---|
152 | static char *gpv_f_name[] = { |
---|
153 | "close_phase_resol", |
---|
154 | "phase_ampl_diff", |
---|
155 | "trace_zoom_base", |
---|
156 | "trace_zoom_exp", |
---|
157 | "area_zoom_base", |
---|
158 | "area_zoom_exp", |
---|
159 | "move_wdw_step", |
---|
160 | "default_depth", |
---|
161 | "colour_fg_red", |
---|
162 | "colour_fg_green", |
---|
163 | "colour_fg_blue", |
---|
164 | "colour_bg_red", |
---|
165 | "colour_bg_green", |
---|
166 | "colour_bg_blue", |
---|
167 | "colour_dialog_fg_red", |
---|
168 | "colour_dialog_fg_green", |
---|
169 | "colour_dialog_fg_blue", |
---|
170 | "colour_dialog_bg0_red", |
---|
171 | "colour_dialog_bg0_green", |
---|
172 | "colour_dialog_bg0_blue", |
---|
173 | "colour_dialog_bg1_red", |
---|
174 | "colour_dialog_bg1_green", |
---|
175 | "colour_dialog_bg1_blue", |
---|
176 | "colour_dialog_bg2_red", |
---|
177 | "colour_dialog_bg2_green", |
---|
178 | "colour_dialog_bg2_blue", |
---|
179 | "colour_mark_red", |
---|
180 | "colour_mark_green", |
---|
181 | "colour_mark_blue", |
---|
182 | "colour_mark0_red", |
---|
183 | "colour_mark0_green", |
---|
184 | "colour_mark0_blue", |
---|
185 | "colour_theo_red", |
---|
186 | "colour_theo_green", |
---|
187 | "colour_theo_blue", |
---|
188 | "colour_auto_red", |
---|
189 | "colour_auto_green", |
---|
190 | "colour_auto_blue", |
---|
191 | "colour_crsr_red", |
---|
192 | "colour_crsr_green", |
---|
193 | "colour_crsr_blue", |
---|
194 | "colour_alert_red", |
---|
195 | "colour_alert_green", |
---|
196 | "colour_alert_blue", |
---|
197 | "colour_addfil_red", |
---|
198 | "colour_addfil_green", |
---|
199 | "colour_addfil_blue", |
---|
200 | "calib_wdw_width", |
---|
201 | "calib_wdw_height", |
---|
202 | "calib_azimuth_grid", |
---|
203 | "calib_slowness_grid", |
---|
204 | "sn_noise_start", |
---|
205 | "sn_noise_end", |
---|
206 | "sn_signal_start", |
---|
207 | "sn_signal_end", |
---|
208 | "idphases_tol_trav", |
---|
209 | "idphases_tol_travsurf", |
---|
210 | "idphases_tol_slow", |
---|
211 | "idphases_tol_azim", |
---|
212 | "axis_label_rounding", |
---|
213 | "f_last_parameter" |
---|
214 | }; |
---|
215 | |
---|
216 | static float gpv_f_glob[cGpF_last+1] = { |
---|
217 | 8.0, /* close_phase_resol */ |
---|
218 | 60.0, /* phase_ampl_diff */ |
---|
219 | 10.0, /* trace_zoom_base */ |
---|
220 | 3.3333333, /* trace_zoom_exp */ |
---|
221 | 10.0, /* area_zoom_base */ |
---|
222 | 25.0, /* area_zoom_exp */ |
---|
223 | 1.0, /* move_wdw_step */ |
---|
224 | 33.0, /* default_depth */ |
---|
225 | 0.0, /* colour_fg_red */ |
---|
226 | 0.0, /* colour_fg_green */ |
---|
227 | 0.0, /* colour_fg_blue */ |
---|
228 | 1.0, /* colour_bg_red */ |
---|
229 | 1.0, /* colour_bg_green */ |
---|
230 | 1.0, /* colour_bg_blue */ |
---|
231 | 0.3882, /* colour_dialog_fg_red */ |
---|
232 | 0.1569, /* colour_dialog_fg_green */ |
---|
233 | 0.1647, /* colour_dialog_fg_blue */ |
---|
234 | 0.9686, /* colour_dialog_bg0_red */ |
---|
235 | 0.8706, /* colour_dialog_bg0_green */ |
---|
236 | 0.7412, /* colour_dialog_bg0_blue */ |
---|
237 | 0.9490, /* colour_dialog_bg1_red */ |
---|
238 | 0.6941, /* colour_dialog_bg1_green */ |
---|
239 | 0.4314, /* colour_dialog_bg1_blue */ |
---|
240 | 0.3882, /* colour_dialog_bg2_red */ |
---|
241 | 0.1569, /* colour_dialog_bg2_green */ |
---|
242 | 0.1647, /* colour_dialog_bg2_blue */ |
---|
243 | 1.0, /* colour_mark_red */ |
---|
244 | 0.0, /* colour_mark_green */ |
---|
245 | 0.0, /* colour_mark_blue */ |
---|
246 | 1.0, /* colour_mark0_red */ |
---|
247 | 0.7, /* colour_mark0_green */ |
---|
248 | 0.7, /* colour_mark0_blue */ |
---|
249 | 0.0, /* colour_theo_red */ |
---|
250 | 1.0, /* colour_theo_green */ |
---|
251 | 0.0, /* colour_theo_blue */ |
---|
252 | 1.0, /* colour_auto_red */ |
---|
253 | 0.5, /* colour_auto_green */ |
---|
254 | 0.5, /* colour_auto_blue */ |
---|
255 | 0.0, /* colour_crsr_red */ |
---|
256 | 0.0, /* colour_crsr_green */ |
---|
257 | 1.0, /* colour_crsr_blue */ |
---|
258 | 0.9, /* colour_alert_red */ |
---|
259 | 0.0, /* colour_alert_green */ |
---|
260 | 0.0, /* colour_alert_blue */ |
---|
261 | 0.6, /* colour_addfil_red */ |
---|
262 | 0.0, /* colour_addfil_green */ |
---|
263 | 0.25, /* colour_addfil_blue */ |
---|
264 | 2.5, /* calib_wdw_width */ |
---|
265 | 2.5, /* calib_wdw_height */ |
---|
266 | 10.0, /* calib_azimuth_grid */ |
---|
267 | 0.5, /* calib_slowness_grid */ |
---|
268 | -13.0, /* sn_noise_start */ |
---|
269 | -3.0, /* sn_noise_end */ |
---|
270 | -1.0, /* sn_signal_start */ |
---|
271 | 9.0, /* sn_signal_end */ |
---|
272 | 20.0, /* idphases_tol_trav */ |
---|
273 | 1200.0, /* idphases_tol_travsurf */ |
---|
274 | 1.5, /* idphases_tol_slow */ |
---|
275 | 20.0, /* idphases_tol_azim */ |
---|
276 | 0.01, /* axis_label_rounding */ |
---|
277 | 0.0 /* last parameter */ |
---|
278 | }; |
---|
279 | |
---|
280 | |
---|
281 | /* char variables |
---|
282 | * ----------------- |
---|
283 | */ |
---|
284 | |
---|
285 | static char *gpv_c_name[] = { |
---|
286 | "filter_type", |
---|
287 | "c_last_parameter" |
---|
288 | }; |
---|
289 | |
---|
290 | static char gpv_c_glob[cGpC_last+1] = { |
---|
291 | ' ', /* filter_type */ |
---|
292 | ' ' /* last parameter */ |
---|
293 | }; |
---|
294 | |
---|
295 | |
---|
296 | /* string variables |
---|
297 | * ----------------- |
---|
298 | */ |
---|
299 | |
---|
300 | static char *gpv_s_name[] = { |
---|
301 | "defpath_events", |
---|
302 | "defpath_gse", |
---|
303 | "defpath_ah", |
---|
304 | "defpath_q", |
---|
305 | "defpath_evid", |
---|
306 | "defpath_evtout", |
---|
307 | "defpath_data", |
---|
308 | "defpath_help", |
---|
309 | "defpath_errors", |
---|
310 | "defpath_userdir", |
---|
311 | "defpath_extprog", |
---|
312 | "analyst", |
---|
313 | "list_of_analysts", |
---|
314 | "texteditor", |
---|
315 | "refstation", |
---|
316 | "list_of_refstations", |
---|
317 | "default_filter", |
---|
318 | "minmax_format", |
---|
319 | "default_source", |
---|
320 | "auto_phase", |
---|
321 | "depth_phase_list", |
---|
322 | "theo_phase_list", |
---|
323 | "diff_phase_list", |
---|
324 | "event_check_proc", |
---|
325 | "screendump_proc", |
---|
326 | "evtview_proc", |
---|
327 | "reformat_proc", |
---|
328 | "final_proc", |
---|
329 | "motif_log", |
---|
330 | "ftp_address", |
---|
331 | "ftp_path", |
---|
332 | "exclusive_agency", |
---|
333 | "sfdb_command", |
---|
334 | "sfdb_exec_qual", |
---|
335 | "sfdb_trailer", |
---|
336 | "s_last_parameter" |
---|
337 | }; |
---|
338 | |
---|
339 | static char gpv_s_glob[cGpS_last+1][cGp_TEXTVARLTH+1] = { |
---|
340 | "default", /* defpath_events */ |
---|
341 | "default", /* defpath_gse */ |
---|
342 | "default", /* defpath_ah */ |
---|
343 | "default", /* defpath_q */ |
---|
344 | "default", /* defpath_evid */ |
---|
345 | "default", /* defpath_evtout */ |
---|
346 | "default", /* defpath_data */ |
---|
347 | "default", /* defpath_help */ |
---|
348 | "default", /* defpath_errors */ |
---|
349 | "default", /* defpath_userdir */ |
---|
350 | "default", /* defpath_extprog */ |
---|
351 | "", /* analyst */ |
---|
352 | "", /* list_of_analysts */ |
---|
353 | "xedit", /* texteditor */ |
---|
354 | "CENTRE", /* refstation */ |
---|
355 | "GRA1,MOX,GRFO,GEC2,CENTRE,---", /* list_of_refstations */ |
---|
356 | "", /* default_filter*/ |
---|
357 | "", /* minmax_format */ |
---|
358 | "UNDEF", /* default_source */ |
---|
359 | "beam", /* auto_phase */ |
---|
360 | "pP,sP,pS,sS", /* depth_phase_list */ |
---|
361 | "P,S,pP,pS,sP,sS,ScS,PcP,PP,SS", /* theo_phase_list */ |
---|
362 | "S-P,PP-P,Pg-Pn", /* diff_phase_list */ |
---|
363 | "", /* event_check_proc */ |
---|
364 | "screendump.csh", /* screendump_proc */ |
---|
365 | "ev2view", /* evtview_proc */ |
---|
366 | "undefined", /* reformat_proc */ |
---|
367 | "", /* final_proc */ |
---|
368 | "", /* motif_log */ |
---|
369 | "ftp.szgrf.bgr.de", /* ftp_address */ |
---|
370 | "pub/software/shm", /* ftp_path */ |
---|
371 | "", /* exclusive_agency */ |
---|
372 | "mysql sfdb", /* sfdb_command */ |
---|
373 | "-B -e", /* sfdb_exec_qual */ |
---|
374 | "", /* sfdb_trailer */ |
---|
375 | "s_last_parameter" /* last parameter */ |
---|
376 | }; |
---|
377 | |
---|
378 | |
---|
379 | /* boolean variables |
---|
380 | * ----------------- |
---|
381 | */ |
---|
382 | |
---|
383 | static char *gpv_b_name[] = { |
---|
384 | "top_down_order", |
---|
385 | "auto_pick_first", |
---|
386 | "auto_scaling", |
---|
387 | "prompt_analyst", |
---|
388 | "reverse_xors", |
---|
389 | "full_phase_names", |
---|
390 | "own_accelerators", |
---|
391 | "small_menu_font", |
---|
392 | "recover_evid", |
---|
393 | "overwrite_string_lists", |
---|
394 | "ignore_data_lock", |
---|
395 | "reads_swap", |
---|
396 | "reads_invhdr", |
---|
397 | "autosort_by_distance", |
---|
398 | "b_last_parameter" |
---|
399 | }; |
---|
400 | |
---|
401 | static long gpv_b_glob = |
---|
402 | (1 << cGpB_autopick_first) | |
---|
403 | (1 << cGpB_auto_scaling) | |
---|
404 | (1 << cGpB_overwrite_string_lists) | |
---|
405 | (1 << cGpB_own_accelerators) | |
---|
406 | (1 << cGpB_autosort_by_distance) | |
---|
407 | (1 << cGpB_reads_swap) |
---|
408 | ; |
---|
409 | |
---|
410 | |
---|
411 | /* string list variables |
---|
412 | * --------------------- |
---|
413 | */ |
---|
414 | |
---|
415 | static char *gpv_l_name[] = { |
---|
416 | "station_info_file", |
---|
417 | "filter_lookup_table", |
---|
418 | "sensitivity_file", |
---|
419 | "defpath_filter", |
---|
420 | "defpath_command", |
---|
421 | "defpath_globals", |
---|
422 | "l_last_parameter" |
---|
423 | }; |
---|
424 | |
---|
425 | static TGpStringElem gpv_l_glob[cGpL_last+1] = { |
---|
426 | {NULL,"default",7}, /* station_info_file */ |
---|
427 | {NULL,"default",7}, /* filter_lookup_table */ |
---|
428 | {NULL,"default",7}, /* sensitivity_file */ |
---|
429 | {NULL,"default",7}, /* defpath_filter */ |
---|
430 | {NULL,"default",7}, /* defpath_command */ |
---|
431 | {NULL,"default",7}, /* defpath_globals */ |
---|
432 | {NULL,"",0} /* last parameter */ |
---|
433 | }; |
---|
434 | |
---|
435 | |
---|
436 | /* prototypes of local routines */ |
---|
437 | static void GpReadParametersFromFile( char fname[] ); |
---|
438 | static void GpEvaluateVar( char val[] ); |
---|
439 | |
---|
440 | |
---|
441 | /*----------------------------------------------------------------------------*/ |
---|
442 | |
---|
443 | |
---|
444 | |
---|
445 | void GpReadParfile( void ) |
---|
446 | |
---|
447 | /* Reads parameters from file |
---|
448 | * |
---|
449 | * no parameters passed |
---|
450 | */ |
---|
451 | { |
---|
452 | /* local variables */ |
---|
453 | char *env; /* pointer to environment */ |
---|
454 | char parfile[cBcFileLth+1]; /* name of parameter file */ |
---|
455 | char *cptr; /* char pointer */ |
---|
456 | int i; /* counter */ |
---|
457 | |
---|
458 | /* executable code */ |
---|
459 | |
---|
460 | /* get parameter file */ |
---|
461 | env = (char *)getenv( "SH_USER_PARAM" ); |
---|
462 | if (env == NULL) { |
---|
463 | env = (char *)getenv( "SH_INPUTS" ); |
---|
464 | if (strlen(env) < cBcFileLth-15) { |
---|
465 | strcpy( parfile, env ); |
---|
466 | strcat( parfile, "/shm-config.txt" ); |
---|
467 | } else { |
---|
468 | fprintf( stderr, "configuration filename too long. Abort.\n" ); |
---|
469 | exit( 1 ); |
---|
470 | } /*endif*/ |
---|
471 | } else { |
---|
472 | if (strlen(env) < cBcFileLth) { |
---|
473 | strcpy( parfile, env ); |
---|
474 | } else { |
---|
475 | fprintf( stderr, "environment SH_USER_PARAM too long. Abort.\n" ); |
---|
476 | exit( 1 ); |
---|
477 | } /*endif*/ |
---|
478 | } /*endif*/ |
---|
479 | |
---|
480 | GpReadParametersFromFile( parfile ); |
---|
481 | |
---|
482 | /* set 'default' strings */ |
---|
483 | if (strcmp(gpv_s_glob[cGpS_defpath_events],"default") == 0) { |
---|
484 | cptr = (char *)getenv( "HOME" ); |
---|
485 | if (cptr == NULL) {printf("HOME not defined\n"); exit(1);} |
---|
486 | if (strlen(cptr) < cGp_TEXTVARLTH) |
---|
487 | strcpy( gpv_s_glob[cGpS_defpath_events], cptr ); |
---|
488 | } /*endif*/ |
---|
489 | if (strcmp(gpv_s_glob[cGpS_defpath_gse],"default") == 0) { |
---|
490 | cptr = (char *)getenv( "SH_ROOT" ); |
---|
491 | if (cptr == NULL) {printf("SH_ROOT not defined\n"); exit(1);} |
---|
492 | if (strlen(cptr) < cGp_TEXTVARLTH-21) { |
---|
493 | strcpy( gpv_s_glob[cGpS_defpath_gse], cptr ); |
---|
494 | strcat( gpv_s_glob[cGpS_defpath_gse], "/data-examples/gse" ); |
---|
495 | } /*endif*/ |
---|
496 | } /*endif*/ |
---|
497 | if (strcmp(gpv_s_glob[cGpS_defpath_ah],"default") == 0) { |
---|
498 | cptr = (char *)getenv( "HOME" ); |
---|
499 | if (cptr == NULL) {printf("HOME not defined\n"); exit(1);} |
---|
500 | if (strlen(cptr) < cGp_TEXTVARLTH) |
---|
501 | strcpy( gpv_s_glob[cGpS_defpath_ah], cptr ); |
---|
502 | } /*endif*/ |
---|
503 | if (strcmp(gpv_s_glob[cGpS_defpath_q],"default") == 0) { |
---|
504 | cptr = (char *)getenv( "HOME" ); |
---|
505 | if (cptr == NULL) {printf("HOME not defined\n"); exit(1);} |
---|
506 | if (strlen(cptr) < cGp_TEXTVARLTH) |
---|
507 | strcpy( gpv_s_glob[cGpS_defpath_q], cptr ); |
---|
508 | } /*endif*/ |
---|
509 | if (strcmp(gpv_s_glob[cGpS_defpath_evid],"default") == 0) { |
---|
510 | cptr = (char *)getenv( "SH_PRIVATE" ); |
---|
511 | if (cptr == NULL) cptr = (char *)getenv( "HOME" ); |
---|
512 | if (cptr == NULL) {printf("HOME not defined\n"); exit(1);} |
---|
513 | if (strlen(cptr) < cGp_TEXTVARLTH-6) { |
---|
514 | strcpy( gpv_s_glob[cGpS_defpath_evid], cptr ); |
---|
515 | strcat( gpv_s_glob[cGpS_defpath_evid], "/evid/" ); |
---|
516 | } /*endif*/ |
---|
517 | } /*endif*/ |
---|
518 | if (strcmp(gpv_s_glob[cGpS_defpath_evtout],"default") == 0) { |
---|
519 | cptr = (char *)getenv( "SH_PRIVATE" ); |
---|
520 | if (cptr == NULL) cptr = (char *)getenv( "HOME" ); |
---|
521 | if (cptr == NULL) {printf("HOME not defined\n"); exit(1);} |
---|
522 | if (strlen(cptr) < cGp_TEXTVARLTH-8) { |
---|
523 | strcpy( gpv_s_glob[cGpS_defpath_evtout], cptr ); |
---|
524 | strcat( gpv_s_glob[cGpS_defpath_evtout], "/evtout/" ); |
---|
525 | } /*endif*/ |
---|
526 | } /*endif*/ |
---|
527 | if (strcmp(gpv_s_glob[cGpS_defpath_help],"default") == 0) { |
---|
528 | cptr = (char *)getenv( "SH_ROOT" ); |
---|
529 | if (cptr == NULL) cptr = (char *)getenv( "HOME" ); |
---|
530 | if (cptr == NULL) {printf("HOME not defined\n"); exit(1);} |
---|
531 | if (strlen(cptr) < cGp_TEXTVARLTH-6) { |
---|
532 | strcpy( gpv_s_glob[cGpS_defpath_help], cptr ); |
---|
533 | strcat( gpv_s_glob[cGpS_defpath_help], "/help/" ); |
---|
534 | } /*endif*/ |
---|
535 | } /*endif*/ |
---|
536 | if (strcmp(gpv_s_glob[cGpS_defpath_errors],"default") == 0) { |
---|
537 | cptr = (char *)getenv( "SH_ROOT" ); |
---|
538 | if (cptr == NULL) cptr = (char *)getenv( "HOME" ); |
---|
539 | if (cptr == NULL) {printf("HOME not defined\n"); exit(1);} |
---|
540 | if (strlen(cptr) < cGp_TEXTVARLTH-8) { |
---|
541 | strcpy( gpv_s_glob[cGpS_defpath_errors], cptr ); |
---|
542 | strcat( gpv_s_glob[cGpS_defpath_errors], "/errors/" ); |
---|
543 | } /*endif*/ |
---|
544 | } /*endif*/ |
---|
545 | if (strcmp(gpv_s_glob[cGpS_defpath_userdir],"default") == 0) { |
---|
546 | /* the usage of SH_USERDIR is for backward compatibility */ |
---|
547 | cptr = (char *)getenv( "SH_USERDIR" ); |
---|
548 | if (cptr == NULL) { |
---|
549 | cptr = (char *)getenv( "HOME" ); |
---|
550 | if (cptr == NULL) {printf("HOME not defined\n"); exit(1);} |
---|
551 | if (strlen(cptr) < cGp_TEXTVARLTH-17) { |
---|
552 | strcpy( gpv_s_glob[cGpS_defpath_userdir], cptr ); |
---|
553 | strcat( gpv_s_glob[cGpS_defpath_userdir], "/shfiles/private/" ); |
---|
554 | } /*endif*/ |
---|
555 | } else { |
---|
556 | if (strlen(cptr) < cGp_TEXTVARLTH) |
---|
557 | strcpy( gpv_s_glob[cGpS_defpath_userdir], cptr ); |
---|
558 | } /*endif*/ |
---|
559 | } /*endif*/ |
---|
560 | if (strcmp(gpv_s_glob[cGpS_defpath_extprog],"default") == 0) { |
---|
561 | /* the usage of SH_UTIL is for backward compatibility */ |
---|
562 | cptr = (char *)getenv( "SH_UTIL" ); |
---|
563 | if (cptr == NULL) { |
---|
564 | cptr = (char *)getenv( "HOME" ); |
---|
565 | if (cptr == NULL) {printf("HOME not defined\n"); exit(1);} |
---|
566 | if (strlen(cptr) < cGp_TEXTVARLTH-17) { |
---|
567 | strcpy( gpv_s_glob[cGpS_defpath_extprog], cptr ); |
---|
568 | strcat( gpv_s_glob[cGpS_defpath_extprog], "/util/" ); |
---|
569 | } /*endif*/ |
---|
570 | } else { |
---|
571 | if (strlen(cptr) < cGp_TEXTVARLTH) |
---|
572 | strcpy( gpv_s_glob[cGpS_defpath_extprog], cptr ); |
---|
573 | } /*endif*/ |
---|
574 | } /*endif*/ |
---|
575 | |
---|
576 | /* 'default' in string lists */ |
---|
577 | if (strcmp(gpv_l_glob[cGpL_station_info_file].string,"default") == 0) { |
---|
578 | cptr = (char *)getenv( "SH_INPUTS" ); |
---|
579 | if (cptr != NULL) { |
---|
580 | i = strlen( cptr ); |
---|
581 | /* "default" value is set by variable initialisation, can't free it */ |
---|
582 | /*free( gpv_l_glob[cGpL_station_info_file].string );*/ |
---|
583 | gpv_l_glob[cGpL_station_info_file].string = |
---|
584 | (char *)malloc( (int)sizeof(char)*(i+12) ); |
---|
585 | strcpy( gpv_l_glob[cGpL_station_info_file].string, cptr ); |
---|
586 | strcat( gpv_l_glob[cGpL_station_info_file].string, "STATINF.DAT" ); |
---|
587 | gpv_l_glob[cGpL_station_info_file].strlth = i+11; |
---|
588 | } /*endif*/ |
---|
589 | } /*endif*/ |
---|
590 | if (strcmp(gpv_l_glob[cGpL_filter_lookup_table].string,"default") == 0) { |
---|
591 | cptr = (char *)getenv( "SH_INPUTS" ); |
---|
592 | if (cptr != NULL) { |
---|
593 | i = strlen( cptr ); |
---|
594 | /*free( gpv_l_glob[cGpL_filter_lookup_table].string );*/ |
---|
595 | gpv_l_glob[cGpL_filter_lookup_table].string = |
---|
596 | (char *)malloc( (int)sizeof(char)*(i+18) ); |
---|
597 | strcpy( gpv_l_glob[cGpL_filter_lookup_table].string, cptr ); |
---|
598 | strcat( gpv_l_glob[cGpL_filter_lookup_table].string, "filter_lookup.txt" ); |
---|
599 | gpv_l_glob[cGpL_filter_lookup_table].strlth = i+17; |
---|
600 | } /*endif*/ |
---|
601 | } /*endif*/ |
---|
602 | if (strcmp(gpv_l_glob[cGpL_sensitivity_file].string,"default") == 0) { |
---|
603 | cptr = (char *)getenv( "SH_INPUTS" ); |
---|
604 | if (cptr != NULL) { |
---|
605 | i = strlen( cptr ); |
---|
606 | /*free( gpv_l_glob[cGpL_sensitivity_file].string );*/ |
---|
607 | gpv_l_glob[cGpL_sensitivity_file].string = |
---|
608 | (char *)malloc( (int)sizeof(char)*(i+18) ); |
---|
609 | strcpy( gpv_l_glob[cGpL_sensitivity_file].string, cptr ); |
---|
610 | strcat( gpv_l_glob[cGpL_sensitivity_file].string, "sensitivities.txt" ); |
---|
611 | gpv_l_glob[cGpL_sensitivity_file].strlth = i+17; |
---|
612 | } /*endif*/ |
---|
613 | } /*endif*/ |
---|
614 | if (strcmp(gpv_l_glob[cGpL_defpath_filter].string,"default") == 0) |
---|
615 | GpParseStringList( cGpL_defpath_filter, ".,$SH_ROOT/filter" ); |
---|
616 | if (strcmp(gpv_l_glob[cGpL_defpath_command].string,"default") == 0) |
---|
617 | GpParseStringList( cGpL_defpath_command, ".,$SH_ROOT/command" ); |
---|
618 | if (strcmp(gpv_l_glob[cGpL_defpath_globals].string,"default") == 0) |
---|
619 | GpParseStringList( cGpL_defpath_globals, ".,$SH_ROOT/globals/" ); |
---|
620 | |
---|
621 | /* make some strings uppercase */ |
---|
622 | ut_cap( gpv_s_glob[cGpS_refstation] ); |
---|
623 | ut_cap( gpv_s_glob[cGpS_list_of_refstations] ); |
---|
624 | |
---|
625 | /* check for setting of normalisation */ |
---|
626 | if (gpv_i_glob[cGpI_trace_normalisation] == cGp_NORM_UNDEF) { |
---|
627 | /* trace_normalisation not set take it from 'old' auto_scaling */ |
---|
628 | printf( "--globalparams: warning: auto_scaling obsolete, please set trace_normalisation\n" ); |
---|
629 | gpv_i_glob[cGpI_trace_normalisation] = |
---|
630 | (gpv_b_glob & cGpB_auto_scaling) ? cGp_NORM_SW : cGp_NORM_AW; |
---|
631 | } else { |
---|
632 | switch (gpv_i_glob[cGpI_trace_normalisation]) { |
---|
633 | case cGp_NORM_CONST: GpSetBoolean( cGpB_auto_scaling, 0 ); break; |
---|
634 | case cGp_NORM_AW: GpSetBoolean( cGpB_auto_scaling, 0 ); break; |
---|
635 | case cGp_NORM_SW: GpSetBoolean( cGpB_auto_scaling, 1 ); break; |
---|
636 | default: |
---|
637 | printf( "--globalparams: illegal value of trace_normalisation, please correct\n" ); |
---|
638 | GpSetBoolean( cGpB_auto_scaling, 0 ); |
---|
639 | gpv_i_glob[cGpI_trace_normalisation] = cGp_NORM_AW; |
---|
640 | } /*endswitch*/ |
---|
641 | } /*endif*/ |
---|
642 | |
---|
643 | if (gpv_i_glob[cGpI_parfile_version] == 0) |
---|
644 | printf( "--globalparams: warning: no version of parameter file found\n" ); |
---|
645 | |
---|
646 | } /* end of GpReadParfile */ |
---|
647 | |
---|
648 | |
---|
649 | |
---|
650 | /*----------------------------------------------------------------------------*/ |
---|
651 | |
---|
652 | |
---|
653 | |
---|
654 | static void GpReadParametersFromFile( char fname[] ) |
---|
655 | |
---|
656 | /* reads parametes from file, calls itself on 'include' statement |
---|
657 | * |
---|
658 | * parameters of routine |
---|
659 | * char fname[]; input; name of file to read |
---|
660 | */ |
---|
661 | { |
---|
662 | /* local variables */ |
---|
663 | FILE *fp; /* pointer to input file */ |
---|
664 | char line[cBcVeryLongStrLth+1]; /* current line of file */ |
---|
665 | char name[cBcLineLth+1]; /* variable name */ |
---|
666 | int namelth; /* length of name */ |
---|
667 | int itmp; /* integer scratch */ |
---|
668 | float ftmp; /* float scratch */ |
---|
669 | char ctmp; /* char scratch */ |
---|
670 | char stmp[cBcVeryLongStrLth+1]; /* string scratch */ |
---|
671 | TGpIntIndex icnt; /* integer counter */ |
---|
672 | TGpFloatIndex fcnt; /* float counter */ |
---|
673 | TGpCharIndex ccnt; /* char counter */ |
---|
674 | TGpStringIndex scnt; /* string counter */ |
---|
675 | TGpBooleanIndex bcnt; /* boolean counter */ |
---|
676 | TGpStringListIndex lcnt; /* string list counter */ |
---|
677 | int found; /* (boolean) parameter found */ |
---|
678 | char *cptr; /* char pointer */ |
---|
679 | char *env; /* pointer to environment */ |
---|
680 | |
---|
681 | /* executable code */ |
---|
682 | |
---|
683 | if (GpGetInt(cGpI_debug_level) > 3) |
---|
684 | printf( "SHM-dbg3: reading parameters from parfile %s\n", fname ); |
---|
685 | |
---|
686 | fp = fopen( fname, "r" ); |
---|
687 | if (fp == NULL) { |
---|
688 | if (GpGetInt(cGpI_debug_level) > 2) |
---|
689 | printf( "SHM-dbg3: parfile %s not found\n", fname ); |
---|
690 | return; |
---|
691 | } /*endif*/ |
---|
692 | |
---|
693 | while (fgets(line,cBcVeryLongStrLth,fp) != NULL) { |
---|
694 | |
---|
695 | if (*line == '!' || *line == '#' || *line == '\n') continue; |
---|
696 | if (line[1] == '$') continue; |
---|
697 | if (sscanf(line,"%s",name) != 1) continue; |
---|
698 | namelth = strlen( name ); |
---|
699 | if (strlen(line) < namelth) { |
---|
700 | printf( "--globalparams: empty entry %s, ignore\n", name ); |
---|
701 | continue; |
---|
702 | } /*endif*/ |
---|
703 | found = 0; |
---|
704 | |
---|
705 | /* check for include statement */ |
---|
706 | if (strcmp(name,"include") == 0) { |
---|
707 | if (GpGetInt(cGpI_debug_level) > 3) |
---|
708 | printf( "SHM-dbg4: include statement found\n", fname ); |
---|
709 | if (sscanf(line+namelth,"%s",stmp) != 1) { |
---|
710 | printf( "--globalparams: error reading include in parameter file %s\n", |
---|
711 | fname ); |
---|
712 | } else { |
---|
713 | if (strlen(stmp) > cGp_TEXTVARLTH) { |
---|
714 | printf( "--globalparams: include filename %s too long\n", name ); |
---|
715 | } else { |
---|
716 | /* reentrant call, read from $SH_INPUTS if not absolute */ |
---|
717 | if (*stmp == '/') { |
---|
718 | /* absolute name, dont't change */ |
---|
719 | strcpy( line, stmp ); |
---|
720 | } else { |
---|
721 | env = (char *)getenv( "SH_INPUTS" ); |
---|
722 | if (strlen(env)+strlen(stmp)+1 > cBcVeryLongStrLth) { |
---|
723 | printf( "--globalparams: string overflow in include statement\n" ); |
---|
724 | continue; |
---|
725 | } /*endif*/ |
---|
726 | sprintf( line, "%s/%s", env, stmp ); |
---|
727 | } /*endif*/ |
---|
728 | GpReadParametersFromFile( line ); |
---|
729 | } /*endif*/ |
---|
730 | } /*endif*/ |
---|
731 | continue; |
---|
732 | } /*endif*/ |
---|
733 | |
---|
734 | /* check for version number */ |
---|
735 | if (strcmp(name,"file_version") == 0) { |
---|
736 | if (sscanf(line+namelth,"%s",stmp) != 1) { |
---|
737 | printf( "--globalparams: error reading version in parameter file %s\n", |
---|
738 | fname ); |
---|
739 | } else { |
---|
740 | if (strlen(stmp) > cGp_TEXTVARLTH) { |
---|
741 | printf( "--globalparams: include filename %s too long\n", name ); |
---|
742 | } else { |
---|
743 | if (sscanf(stmp,"%d.%d",&itmp,&icnt) == 2) { |
---|
744 | gpv_i_glob[cGpI_parfile_version] = itmp; |
---|
745 | gpv_i_glob[cGpI_parfile_subversion] = icnt; |
---|
746 | if (gpv_i_glob[cGpI_parfile_version] > cGp_VERSION |
---|
747 | || gpv_i_glob[cGpI_parfile_subversion] > cGp_SUBVERSION) { |
---|
748 | printf( "--globalparams: warning: file version too new; "); |
---|
749 | printf( "expect problems while reading\n" ); |
---|
750 | printf( "--globalparams: version %d.%d is expected here\n", |
---|
751 | cGp_VERSION, cGp_SUBVERSION ); |
---|
752 | } else if (gpv_i_glob[cGpI_parfile_version] < cGp_VERSION) { |
---|
753 | printf( "--globalparams: warning: old parameter file version; "); |
---|
754 | printf( "consider creating a new one\n" ); |
---|
755 | printf( "--globalparams: version %d.%d is expected here\n", |
---|
756 | cGp_VERSION, cGp_SUBVERSION ); |
---|
757 | } /*endif*/ |
---|
758 | } else { |
---|
759 | printf( "--globalparams: error reading parameter version\n" ); |
---|
760 | } /*endif*/ |
---|
761 | } /*endif*/ |
---|
762 | } /*endif*/ |
---|
763 | continue; |
---|
764 | } /*endif*/ |
---|
765 | |
---|
766 | /* integer variables */ |
---|
767 | for (icnt=0; icnt<cGpI_last; icnt++) |
---|
768 | if (strcmp(gpv_i_name[icnt],name) == 0) { |
---|
769 | if (sscanf(line+namelth,"%d",&itmp) != 1) { |
---|
770 | printf( "--globalparams: error reading parameter %s\n", name ); |
---|
771 | } else { |
---|
772 | gpv_i_glob[icnt] = itmp; |
---|
773 | found = 1; |
---|
774 | } /*endif*/ |
---|
775 | break; |
---|
776 | } /*endif*/ |
---|
777 | if (found) continue; |
---|
778 | |
---|
779 | /* float variables */ |
---|
780 | for (fcnt=0; fcnt<cGpF_last; fcnt++) |
---|
781 | if (strcmp(gpv_f_name[fcnt],name) == 0) { |
---|
782 | if (sscanf(line+namelth,"%f",&ftmp) != 1) { |
---|
783 | printf( "--globalparams: error reading parameter %s\n", name ); |
---|
784 | } else { |
---|
785 | gpv_f_glob[fcnt] = ftmp; |
---|
786 | found = 1; |
---|
787 | } /*endif*/ |
---|
788 | break; |
---|
789 | } /*endif*/ |
---|
790 | if (found) continue; |
---|
791 | |
---|
792 | /* char variables */ |
---|
793 | for (ccnt=0; ccnt<cGpC_last; ccnt++) |
---|
794 | if (strcmp(gpv_c_name[ccnt],name) == 0) { |
---|
795 | /* read first character after blanks and tabs */ |
---|
796 | cptr = line + namelth; |
---|
797 | while (*cptr == ' ' || *cptr == '\t') cptr++; |
---|
798 | if (*cptr != '\n' && *cptr != '\0') { |
---|
799 | gpv_c_glob[ccnt] = *cptr; |
---|
800 | found = 1; |
---|
801 | } /*endif*/ |
---|
802 | break; |
---|
803 | } /*endif*/ |
---|
804 | if (found) continue; |
---|
805 | |
---|
806 | /* string variables */ |
---|
807 | for (scnt=0; scnt<cGpS_last; scnt++) |
---|
808 | if (strcmp(gpv_s_name[scnt],name) == 0) { |
---|
809 | /* skip blanks after keyword and take remaining line as value */ |
---|
810 | cptr = line + namelth; |
---|
811 | while (*cptr == ' ' || *cptr == '\t') cptr++; |
---|
812 | strcpy( stmp, cptr ); |
---|
813 | /* drop the linefeed */ |
---|
814 | itmp = strlen( stmp ); |
---|
815 | if (itmp > 0 && stmp[itmp-1] == '\n') stmp[itmp-1] = '\0'; |
---|
816 | if (*stmp == '\0') { |
---|
817 | printf( "--globalparams: error reading parameter %s\n", name ); |
---|
818 | } else { |
---|
819 | if (strlen(stmp) > cGp_TEXTVARLTH) { |
---|
820 | printf( "--globalparams: string parameter %s too long\n", name ); |
---|
821 | } else { |
---|
822 | if (strcmp(stmp,"<NULL>") == 0 || strcmp(stmp,"NULL") == 0 |
---|
823 | || strcmp(stmp,"<null>") == 0 || strcmp(stmp,"null") == 0) { |
---|
824 | gpv_s_glob[scnt][0] = '\0'; |
---|
825 | } else { |
---|
826 | while (stmp[0] == '$') |
---|
827 | GpEvaluateVar( stmp ); |
---|
828 | strcpy( gpv_s_glob[scnt], stmp ); |
---|
829 | } /*endif*/ |
---|
830 | found = 1; |
---|
831 | } /*endif*/ |
---|
832 | } /*endif*/ |
---|
833 | break; |
---|
834 | } /*endif*/ |
---|
835 | |
---|
836 | /* boolean variables */ |
---|
837 | for (bcnt=0; bcnt<cGpB_last; bcnt++) |
---|
838 | if (strcmp(gpv_b_name[bcnt],name) == 0) { |
---|
839 | if (sscanf(line+namelth,"%s",&stmp) != 1) { |
---|
840 | printf( "--globalparams: error reading parameter %s\n", name ); |
---|
841 | } else { |
---|
842 | if (strcmp(stmp,"TRUE") == 0 || strcmp(stmp,"true") == 0 |
---|
843 | || strcmp(stmp,"True") == 0 || strcmp(stmp,"1") == 0) { |
---|
844 | gpv_b_glob |= (1 << bcnt); |
---|
845 | found = 1; |
---|
846 | } else if (strcmp(stmp,"FALSE") == 0 || strcmp(stmp,"false") == 0 |
---|
847 | || strcmp(stmp,"False") == 0 || strcmp(stmp,"0") == 0) { |
---|
848 | gpv_b_glob &= ~(1 << bcnt); |
---|
849 | found = 1; |
---|
850 | } else { |
---|
851 | printf( "--globalparams: illegal boolean value at %s\n", name ); |
---|
852 | } /*endif*/ |
---|
853 | } /*endif*/ |
---|
854 | break; |
---|
855 | } /*endif*/ |
---|
856 | if (found) continue; |
---|
857 | |
---|
858 | /* string list variables */ |
---|
859 | for (lcnt=0; lcnt<cGpL_last; lcnt++) |
---|
860 | if (strcmp(gpv_l_name[lcnt],name) == 0) { |
---|
861 | GpParseStringList( lcnt, line+namelth ); |
---|
862 | found = 1; |
---|
863 | } /*endif*/ |
---|
864 | |
---|
865 | if (!found) |
---|
866 | printf( "--globalparams: illegal parameter %s in parameter file\n", name ); |
---|
867 | |
---|
868 | } /*endwhile*/ |
---|
869 | |
---|
870 | fclose( fp ); |
---|
871 | |
---|
872 | } /* end of GpReadParametersFromFile */ |
---|
873 | |
---|
874 | |
---|
875 | |
---|
876 | /*----------------------------------------------------------------------------*/ |
---|
877 | |
---|
878 | |
---|
879 | |
---|
880 | int GpGetInt( TGpIntIndex idx ) |
---|
881 | |
---|
882 | /* Returns integer valued global |
---|
883 | * |
---|
884 | * parameters of routine |
---|
885 | * TGpIntIndex idx; input; index of variable |
---|
886 | * returns value of variable |
---|
887 | */ |
---|
888 | { |
---|
889 | /* executable code */ |
---|
890 | |
---|
891 | if (idx >= 0 && idx < cGpI_last) { |
---|
892 | return gpv_i_glob[idx]; |
---|
893 | } else { |
---|
894 | printf( "--globalparams: illegal index %d in GpGetInt\n", idx ); |
---|
895 | return 0; |
---|
896 | } /*endif*/ |
---|
897 | |
---|
898 | } /* end of GpGetInt */ |
---|
899 | |
---|
900 | |
---|
901 | |
---|
902 | /*----------------------------------------------------------------------------*/ |
---|
903 | |
---|
904 | |
---|
905 | |
---|
906 | float GpGetFloat( TGpFloatIndex idx ) |
---|
907 | |
---|
908 | /* Returns float valued global |
---|
909 | * |
---|
910 | * parameters of routine |
---|
911 | * TGpFloatIndex idx; input; index of variable |
---|
912 | * returns value of variable |
---|
913 | */ |
---|
914 | { |
---|
915 | /* executable code */ |
---|
916 | |
---|
917 | if (idx >= 0 && idx < cGpF_last) { |
---|
918 | return gpv_f_glob[idx]; |
---|
919 | } else { |
---|
920 | printf( "--globalparams: illegal index %d in GpGetFloat\n", idx ); |
---|
921 | return 0; |
---|
922 | } /*endif*/ |
---|
923 | |
---|
924 | } /* end of GpGetFloat */ |
---|
925 | |
---|
926 | |
---|
927 | |
---|
928 | /*----------------------------------------------------------------------------*/ |
---|
929 | |
---|
930 | |
---|
931 | |
---|
932 | char GpGetChar( TGpCharIndex idx ) |
---|
933 | |
---|
934 | /* Returns char valued global |
---|
935 | * |
---|
936 | * parameters of routine |
---|
937 | * TGpCharIndex idx; input; index of variable |
---|
938 | * returns value of variable |
---|
939 | */ |
---|
940 | { |
---|
941 | /* executable code */ |
---|
942 | |
---|
943 | if (idx >= 0 && idx < cGpC_last) { |
---|
944 | return gpv_c_glob[idx]; |
---|
945 | } else { |
---|
946 | printf( "globalparams: illegal index %d in GpGetChar\n", idx ); |
---|
947 | return 0; |
---|
948 | } /*endif*/ |
---|
949 | |
---|
950 | } /* end of GpGetChar */ |
---|
951 | |
---|
952 | |
---|
953 | |
---|
954 | /*----------------------------------------------------------------------------*/ |
---|
955 | |
---|
956 | |
---|
957 | |
---|
958 | char *GpGetString( TGpStringIndex idx ) |
---|
959 | |
---|
960 | /* Returns pointer to string valued global |
---|
961 | * |
---|
962 | * parameters of routine |
---|
963 | * TGpStringIndex idx; input; index of variable |
---|
964 | * returns value of variable |
---|
965 | */ |
---|
966 | { |
---|
967 | /* executable code */ |
---|
968 | |
---|
969 | if (idx >= 0 && idx < cGpS_last) { |
---|
970 | return gpv_s_glob[idx]; |
---|
971 | } else { |
---|
972 | printf( "--globalparams: illegal index %d in GpGetString\n", idx ); |
---|
973 | return 0; |
---|
974 | } /*endif*/ |
---|
975 | |
---|
976 | } /* end of GpGetString */ |
---|
977 | |
---|
978 | |
---|
979 | |
---|
980 | /*----------------------------------------------------------------------------*/ |
---|
981 | |
---|
982 | |
---|
983 | |
---|
984 | int GpGetBoolean( TGpBooleanIndex idx ) |
---|
985 | |
---|
986 | /* Returns boolean valued global |
---|
987 | * |
---|
988 | * parameters of routine |
---|
989 | * TGpBooleanIndex idx; input; index of variable |
---|
990 | * returns value of variable |
---|
991 | */ |
---|
992 | { |
---|
993 | /* executable code */ |
---|
994 | |
---|
995 | if (idx >= 0 && idx < cGpB_last) { |
---|
996 | if ((gpv_b_glob & (1 << idx)) == 0) { |
---|
997 | return 0; |
---|
998 | } else { |
---|
999 | return 1; |
---|
1000 | } /*endif*/ |
---|
1001 | } else { |
---|
1002 | printf( "--globalparams: illegal index %d in GpGetBoolean\n", idx ); |
---|
1003 | return 0; |
---|
1004 | } /*endif*/ |
---|
1005 | |
---|
1006 | } /* end of GpGetBoolean */ |
---|
1007 | |
---|
1008 | |
---|
1009 | |
---|
1010 | /*----------------------------------------------------------------------------*/ |
---|
1011 | |
---|
1012 | |
---|
1013 | |
---|
1014 | char *GpGetStringElem( TGpStringListIndex idx, int elemnum ) |
---|
1015 | |
---|
1016 | /* returns string element number elemnum from string list idx |
---|
1017 | * |
---|
1018 | * parameters of routine |
---|
1019 | * TGpStringListIndex idx; input; index numer of string list |
---|
1020 | * int elemnum; input; number of string in list (start with 0) |
---|
1021 | * returns string address or NULL |
---|
1022 | */ |
---|
1023 | { |
---|
1024 | /* local variables */ |
---|
1025 | TGpStringElem *sel; /* pointer to string element */ |
---|
1026 | |
---|
1027 | /* executable code */ |
---|
1028 | |
---|
1029 | if (idx < 0 || idx >= cGpL_last) return NULL; |
---|
1030 | |
---|
1031 | sel = gpv_l_glob+idx; |
---|
1032 | |
---|
1033 | while (elemnum-- > 0) { |
---|
1034 | if (sel->next == NULL) return NULL; |
---|
1035 | sel = sel->next; |
---|
1036 | } /*endwhile*/ |
---|
1037 | |
---|
1038 | return sel->string; |
---|
1039 | |
---|
1040 | } /* end of GpGetStringElem */ |
---|
1041 | |
---|
1042 | |
---|
1043 | |
---|
1044 | /*----------------------------------------------------------------------------*/ |
---|
1045 | |
---|
1046 | |
---|
1047 | |
---|
1048 | void GpSetInt( TGpIntIndex idx, int value ) |
---|
1049 | |
---|
1050 | /* Sets integer valued global |
---|
1051 | * |
---|
1052 | * parameters of routine |
---|
1053 | * TGpIntIndex idx; input; index of variable |
---|
1054 | * int value; input; new value of variable |
---|
1055 | */ |
---|
1056 | { |
---|
1057 | /* executable code */ |
---|
1058 | |
---|
1059 | if (idx >= 0 && idx < cGpI_last) { |
---|
1060 | gpv_i_glob[idx] = value; |
---|
1061 | } else { |
---|
1062 | printf( "--globalparams: illegal index %d in GpSetInt\n", idx ); |
---|
1063 | } /*endif*/ |
---|
1064 | |
---|
1065 | } /* end of GpSetInt */ |
---|
1066 | |
---|
1067 | |
---|
1068 | |
---|
1069 | /*----------------------------------------------------------------------------*/ |
---|
1070 | |
---|
1071 | |
---|
1072 | |
---|
1073 | void GpSetFloat( TGpFloatIndex idx, float value ) |
---|
1074 | |
---|
1075 | /* Sets float valued global |
---|
1076 | * |
---|
1077 | * parameters of routine |
---|
1078 | * TGpFloatIndex idx; input; index of variable |
---|
1079 | * float value; input; new value of variable |
---|
1080 | */ |
---|
1081 | { |
---|
1082 | /* executable code */ |
---|
1083 | |
---|
1084 | if (idx >= 0 && idx < cGpF_last) { |
---|
1085 | gpv_f_glob[idx] = value; |
---|
1086 | } else { |
---|
1087 | printf( "--globalparams: illegal index %d in GpSetFloat\n", idx ); |
---|
1088 | } /*endif*/ |
---|
1089 | |
---|
1090 | } /* end of GpSetFloat */ |
---|
1091 | |
---|
1092 | |
---|
1093 | |
---|
1094 | /*----------------------------------------------------------------------------*/ |
---|
1095 | |
---|
1096 | |
---|
1097 | |
---|
1098 | void GpSetChar( TGpCharIndex idx, char value ) |
---|
1099 | |
---|
1100 | /* Sets char valued global |
---|
1101 | * |
---|
1102 | * parameters of routine |
---|
1103 | * TGpCharIndex idx; input; index of variable |
---|
1104 | * char value; input; new value of variable |
---|
1105 | */ |
---|
1106 | { |
---|
1107 | /* executable code */ |
---|
1108 | |
---|
1109 | if (idx >= 0 && idx < cGpC_last) { |
---|
1110 | gpv_c_glob[idx] = value; |
---|
1111 | } else { |
---|
1112 | printf( "--globalparams: illegal index %d in GpSetChar\n", idx ); |
---|
1113 | } /*endif*/ |
---|
1114 | |
---|
1115 | } /* end of GpSetChar */ |
---|
1116 | |
---|
1117 | |
---|
1118 | |
---|
1119 | /*----------------------------------------------------------------------------*/ |
---|
1120 | |
---|
1121 | |
---|
1122 | |
---|
1123 | void GpSetString( TGpStringIndex idx, char str[], int *ok ) |
---|
1124 | |
---|
1125 | /* Sets value of string valued global variable |
---|
1126 | * |
---|
1127 | * parameters of routine |
---|
1128 | * TGpStringIndex idx; input; index of variable |
---|
1129 | * char str[]; input; new value of variable |
---|
1130 | * int *ok; output (if not NULL); 1 = ok, 0 = failure |
---|
1131 | */ |
---|
1132 | { |
---|
1133 | /* executable code */ |
---|
1134 | |
---|
1135 | if (strlen(str) > cGp_TEXTVARLTH) { |
---|
1136 | if (ok != NULL) *ok = 0; |
---|
1137 | return; |
---|
1138 | } /*endif*/ |
---|
1139 | |
---|
1140 | if (idx >= 0 && idx < cGpS_last) { |
---|
1141 | strcpy( gpv_s_glob[idx], str ); |
---|
1142 | if (ok != NULL) *ok = 1; |
---|
1143 | } else { |
---|
1144 | if (ok != NULL) *ok = 0; |
---|
1145 | } /*endif*/ |
---|
1146 | |
---|
1147 | } /* end of GpSetString */ |
---|
1148 | |
---|
1149 | |
---|
1150 | |
---|
1151 | /*----------------------------------------------------------------------------*/ |
---|
1152 | |
---|
1153 | |
---|
1154 | |
---|
1155 | void GpSetBoolean( TGpBooleanIndex idx, int value ) |
---|
1156 | |
---|
1157 | /* Sets boolean valued global |
---|
1158 | * |
---|
1159 | * parameters of routine |
---|
1160 | * TGpBooleanIndex idx; input; index of variable |
---|
1161 | * int value; input; new value of variable |
---|
1162 | */ |
---|
1163 | { |
---|
1164 | /* executable code */ |
---|
1165 | |
---|
1166 | if (idx >= 0 && idx < cGpB_last) { |
---|
1167 | if (value) { |
---|
1168 | gpv_b_glob |= (1 << idx); |
---|
1169 | } else { |
---|
1170 | gpv_b_glob &= ~(1 << idx); |
---|
1171 | } /*endif*/ |
---|
1172 | } else { |
---|
1173 | printf( "--globalparams: illegal index %d in GpSetBoolean\n", idx ); |
---|
1174 | } /*endif*/ |
---|
1175 | |
---|
1176 | } /* end of GpSetBoolean */ |
---|
1177 | |
---|
1178 | |
---|
1179 | |
---|
1180 | /*----------------------------------------------------------------------------*/ |
---|
1181 | |
---|
1182 | |
---|
1183 | |
---|
1184 | void GpReadParameter( char parname[], int maxlth, char value[], int *ok ) |
---|
1185 | |
---|
1186 | /* Reads parameter of name parname from parameter file. |
---|
1187 | * |
---|
1188 | * parameters of routine |
---|
1189 | * char parname[]; input, name of parameter |
---|
1190 | * int maxlth; input; maximum length of output string |
---|
1191 | * char value[]; output; value of parameter |
---|
1192 | * int *ok; output; 1=ok, 0=not found or string too short |
---|
1193 | */ |
---|
1194 | { |
---|
1195 | /* local variables */ |
---|
1196 | char *env; /* pointer to environment */ |
---|
1197 | char parfile[cBcFileLth+1]; /* name of parameter file */ |
---|
1198 | FILE *fp; /* pointer to parameter file */ |
---|
1199 | char line[cBcVeryLongStrLth+1]; /* current line of file */ |
---|
1200 | int namelth; /* length of parameter name */ |
---|
1201 | char *vptr; /* pointer to parameter value */ |
---|
1202 | int slth; /* string length */ |
---|
1203 | |
---|
1204 | /* executable code */ |
---|
1205 | |
---|
1206 | /* get parameter file */ |
---|
1207 | env = (char *)getenv( "SH_USER_PARAM" ); |
---|
1208 | if (env == NULL) { |
---|
1209 | env = (char *)getenv( "SH_INPUTS" ); |
---|
1210 | if (strlen(env) < cBcFileLth-15) { |
---|
1211 | strcpy( parfile, env ); |
---|
1212 | strcat( parfile, "/shm-config.txt" ); |
---|
1213 | } else { |
---|
1214 | fprintf( stderr, "configuration filename too long. Abort.\n" ); |
---|
1215 | exit( 1 ); |
---|
1216 | } /*endif*/ |
---|
1217 | } else { |
---|
1218 | if (strlen(env) < cBcFileLth) { |
---|
1219 | strcpy( parfile, env ); |
---|
1220 | } else { |
---|
1221 | fprintf( stderr, "environment SH_USER_PARAM too long. Abort.\n" ); |
---|
1222 | exit( 1 ); |
---|
1223 | } /*endif*/ |
---|
1224 | } /*endif*/ |
---|
1225 | |
---|
1226 | namelth = strlen( parname ); |
---|
1227 | |
---|
1228 | *ok = 0; |
---|
1229 | fp = fopen( parfile, "r" ); |
---|
1230 | if (fp == NULL) return; |
---|
1231 | |
---|
1232 | while (fgets(line,cBcVeryLongStrLth,fp) != NULL) { |
---|
1233 | |
---|
1234 | if (*line == '!' || *line == '#' || *line == '\n') continue; |
---|
1235 | if (strncasecmp(line,parname,namelth) == 0 |
---|
1236 | && (line[namelth] == ' ' || line[namelth] == '\t')) { |
---|
1237 | vptr = line + namelth; |
---|
1238 | while (*vptr == ' ') vptr++; |
---|
1239 | slth = strlen( vptr ); |
---|
1240 | if (vptr[slth-1] == '\n') vptr[--slth] = '\0'; |
---|
1241 | *ok = (strlen(vptr) < maxlth); |
---|
1242 | if (*ok) strcpy( value, vptr ); |
---|
1243 | break; |
---|
1244 | } /*endif*/ |
---|
1245 | |
---|
1246 | } /*endwhile*/ |
---|
1247 | |
---|
1248 | fclose( fp ); |
---|
1249 | |
---|
1250 | } /* end of GpReadParameter */ |
---|
1251 | |
---|
1252 | |
---|
1253 | |
---|
1254 | /*----------------------------------------------------------------------------*/ |
---|
1255 | |
---|
1256 | |
---|
1257 | |
---|
1258 | void GpParseTextList( char str[], TGpTextList *tl ) |
---|
1259 | |
---|
1260 | /* Parses comma separated text string and returns pointers to elements of list. |
---|
1261 | * Data structure returned must be freed after use (GpFreeTextList). |
---|
1262 | * |
---|
1263 | * parameters of routine |
---|
1264 | * char str[]; input; input string to be parsed |
---|
1265 | * GpTextList *tl; output; elements of list |
---|
1266 | */ |
---|
1267 | { |
---|
1268 | /* local variables */ |
---|
1269 | int strlth; /* length of input string */ |
---|
1270 | int i, j; /* counters */ |
---|
1271 | |
---|
1272 | /* executable code */ |
---|
1273 | |
---|
1274 | strlth = strlen( str ); |
---|
1275 | if (strlth == 0) { |
---|
1276 | tl->numelem = 0; |
---|
1277 | tl->elem = NULL; |
---|
1278 | tl->mem = NULL; |
---|
1279 | return; |
---|
1280 | } /*endif*/ |
---|
1281 | |
---|
1282 | tl->mem = (char *)malloc( strlth+1 ); |
---|
1283 | if (tl->mem == NULL) { |
---|
1284 | fprintf( stderr, "GpParseTextList: error allocating memory. Abort.\n" ); |
---|
1285 | exit( 1 ); |
---|
1286 | } /*endif*/ |
---|
1287 | strcpy( tl->mem, str ); |
---|
1288 | |
---|
1289 | /* count elements */ |
---|
1290 | tl->numelem = (*str == '\0') ? 0 : 1; |
---|
1291 | for (i=0; i<strlth; i++) |
---|
1292 | if (str[i] == ',') (tl->numelem)++; |
---|
1293 | |
---|
1294 | tl->elem = (char **)malloc( (int)sizeof(char *)*(tl->numelem) ); |
---|
1295 | if (tl->elem == NULL) { |
---|
1296 | fprintf( stderr, "GpParseTextList: error allocating memory. Abort.\n" ); |
---|
1297 | exit( 1 ); |
---|
1298 | } /*endif*/ |
---|
1299 | |
---|
1300 | j = 1; |
---|
1301 | tl->elem[0] = tl->mem; |
---|
1302 | for (i=0; i<strlth; i++) { |
---|
1303 | if (tl->mem[i] == ',') { |
---|
1304 | tl->mem[i] = '\0'; |
---|
1305 | tl->elem[j++] = tl->mem+i+1; |
---|
1306 | } /*endif*/ |
---|
1307 | } /*endfor*/ |
---|
1308 | |
---|
1309 | /* debug output */ |
---|
1310 | /* |
---|
1311 | for (j=0; j<tl->numelem; j++) |
---|
1312 | printf( "debug-textlist: %2d >%s<\n", j+1, tl->elem[j] ); |
---|
1313 | */ |
---|
1314 | |
---|
1315 | } /* end of GpParseTextList */ |
---|
1316 | |
---|
1317 | |
---|
1318 | |
---|
1319 | /*----------------------------------------------------------------------------*/ |
---|
1320 | |
---|
1321 | |
---|
1322 | |
---|
1323 | void GpFreeTextList( TGpTextList *tl ) |
---|
1324 | |
---|
1325 | /* Frees memory of textlist |
---|
1326 | * |
---|
1327 | * parameters of routine |
---|
1328 | * TGpTextList modify; text list to be freed |
---|
1329 | */ |
---|
1330 | { |
---|
1331 | /* executable code */ |
---|
1332 | |
---|
1333 | if (tl->numelem == 0) return; |
---|
1334 | |
---|
1335 | if (tl->elem != NULL) free( tl->elem ); |
---|
1336 | if (tl->mem != NULL) free( tl->mem ); |
---|
1337 | |
---|
1338 | } /* end of GpFreeTextList */ |
---|
1339 | |
---|
1340 | |
---|
1341 | |
---|
1342 | /*----------------------------------------------------------------------------*/ |
---|
1343 | |
---|
1344 | |
---|
1345 | |
---|
1346 | void GpDumpParams( void ) |
---|
1347 | |
---|
1348 | /* write all parameters out to stdout |
---|
1349 | * |
---|
1350 | * no parameters passed |
---|
1351 | * |
---|
1352 | */ |
---|
1353 | { |
---|
1354 | /* local variables */ |
---|
1355 | int i; /* counter */ |
---|
1356 | int j; /* string counter */ |
---|
1357 | char *s; /* string pointer */ |
---|
1358 | |
---|
1359 | /* executable code */ |
---|
1360 | |
---|
1361 | for (i=0; i<cGpI_last; i++) |
---|
1362 | printf( "%s: %d\n", gpv_i_name[i], gpv_i_glob[i] ); |
---|
1363 | for (i=0; i<cGpF_last; i++) |
---|
1364 | printf( "%s: %g\n", gpv_f_name[i], gpv_f_glob[i] ); |
---|
1365 | for (i=0; i<cGpC_last; i++) |
---|
1366 | printf( "%s: %c\n", gpv_c_name[i], gpv_c_glob[i] ); |
---|
1367 | for (i=0; i<cGpS_last; i++) |
---|
1368 | printf( "%s: %s\n", gpv_s_name[i], gpv_s_glob[i] ); |
---|
1369 | for (i=0; i<cGpB_last; i++) |
---|
1370 | printf( "%s: %d\n", gpv_b_name[i], ((1<<i) & gpv_b_glob) ); |
---|
1371 | for (i=0; i<cGpL_last; i++) { |
---|
1372 | for (j=0;;j++) { |
---|
1373 | s = GpGetStringElem( i, j ); |
---|
1374 | if (s == NULL) break; |
---|
1375 | printf( "%s (%d): %s\n", gpv_l_name[i], j, s ); |
---|
1376 | } /*endfor*/ |
---|
1377 | } /*endfor*/ |
---|
1378 | |
---|
1379 | } /* end of GpDumpParams */ |
---|
1380 | |
---|
1381 | |
---|
1382 | |
---|
1383 | /*----------------------------------------------------------------------------*/ |
---|
1384 | |
---|
1385 | |
---|
1386 | |
---|
1387 | void GpParseStringList( TGpStringListIndex idx, char line[] ) |
---|
1388 | |
---|
1389 | /* parses string list and puts result to list number idx |
---|
1390 | * |
---|
1391 | * parameters of routine |
---|
1392 | * TGpStringListIndex idx; input; string list variable index |
---|
1393 | * char line[]; input; line to be parsed |
---|
1394 | */ |
---|
1395 | { |
---|
1396 | /* local variables */ |
---|
1397 | int i, j; /* counters */ |
---|
1398 | TGpStringElem *sel; /* pointer to string element */ |
---|
1399 | char val[cBcLineLth+1]; /* string value */ |
---|
1400 | |
---|
1401 | /* excutable code */ |
---|
1402 | |
---|
1403 | sel = gpv_l_glob+idx; |
---|
1404 | |
---|
1405 | /* !!! should free list before (if not "default") */ |
---|
1406 | |
---|
1407 | sel->next = NULL; |
---|
1408 | sel->string = '\0'; |
---|
1409 | sel->strlth = 0; |
---|
1410 | |
---|
1411 | while (*line != '\0') { |
---|
1412 | |
---|
1413 | /* skip blanks */ |
---|
1414 | while (*line == ' ' || *line == '\t') line++; |
---|
1415 | if (*line == '\0' || *line == '\n') break; |
---|
1416 | |
---|
1417 | /* allocate next StringElem if necessary */ |
---|
1418 | if (sel->string != '\0') { |
---|
1419 | sel->next = (TGpStringElem *)malloc( (int)sizeof(TGpStringElem) ); |
---|
1420 | if (sel->next == NULL) { |
---|
1421 | printf( "--globalparams: error allocating memory (1). Abort\n" ); |
---|
1422 | exit( 1 ); |
---|
1423 | } /*endif*/ |
---|
1424 | sel = sel->next; |
---|
1425 | sel->next = NULL; |
---|
1426 | sel->string = '\0'; |
---|
1427 | sel->strlth = 0; |
---|
1428 | } /*endif*/ |
---|
1429 | |
---|
1430 | /* get next string length */ |
---|
1431 | i = 0; |
---|
1432 | while (line[i] != '\0' && line[i] != ' ' && line[i] != '\n' |
---|
1433 | && line[i] != '\t' && line[i] != ',' && line[i] != ';') |
---|
1434 | i++; |
---|
1435 | if (i >= cBcLineLth-1) { |
---|
1436 | printf( "--globalparams: string element (idx: %d) too long\n", idx ); |
---|
1437 | return; |
---|
1438 | } /*endif*/ |
---|
1439 | |
---|
1440 | /* copy string to StringElem structure */ |
---|
1441 | if (i > 0) { |
---|
1442 | |
---|
1443 | /* copy string and translate if necessary */ |
---|
1444 | strncpy( val, line, i ); |
---|
1445 | val[i] = '\0'; |
---|
1446 | |
---|
1447 | while (*val == '$') |
---|
1448 | GpEvaluateVar( val ); |
---|
1449 | |
---|
1450 | j = strlen( val ); |
---|
1451 | sel->string = (char *)malloc( (int)sizeof(char)*(j+1) ); |
---|
1452 | if (sel->string == NULL) { |
---|
1453 | printf( "--globalparams: error allocating memory (2). Abort\n" ); |
---|
1454 | exit( 1 ); |
---|
1455 | } /*endif*/ |
---|
1456 | strcpy( sel->string, val ); |
---|
1457 | sel->strlth = j; |
---|
1458 | |
---|
1459 | } /*endif*/ |
---|
1460 | |
---|
1461 | if (line[i] == '\0' || *line == '\n') break; |
---|
1462 | line += i+1; |
---|
1463 | |
---|
1464 | } /*endwhile*/ |
---|
1465 | |
---|
1466 | } /* end of GpParseStringList */ |
---|
1467 | |
---|
1468 | |
---|
1469 | |
---|
1470 | /*----------------------------------------------------------------------------*/ |
---|
1471 | |
---|
1472 | |
---|
1473 | |
---|
1474 | static void GpEvaluateVar( char val[] ) |
---|
1475 | |
---|
1476 | /* Evaluates value of variable |
---|
1477 | * |
---|
1478 | * parameters of routine |
---|
1479 | * char val[]; modify; input: variable name, output: value |
---|
1480 | */ |
---|
1481 | { |
---|
1482 | /* local variable */ |
---|
1483 | char vname[cBcLineLth+1]; /* variable name */ |
---|
1484 | char appdx[cBcLineLth+1]; /* appendix (after '/') */ |
---|
1485 | int j; /* counter */ |
---|
1486 | int ok; /* string value found */ |
---|
1487 | char *env; /* pointer to environment */ |
---|
1488 | |
---|
1489 | /* executable code */ |
---|
1490 | |
---|
1491 | if (*val != '$') return; /* leave unchanged */ |
---|
1492 | |
---|
1493 | /* try 'v$'-variable in configuration file */ |
---|
1494 | vname[0] = 'v'; |
---|
1495 | j = 0; |
---|
1496 | while (val[j] != '/' && val[j] != '\0') { |
---|
1497 | vname[j+1] = val[j]; |
---|
1498 | j++; |
---|
1499 | } /*endwhile*/ |
---|
1500 | vname[j+1] = '\0'; |
---|
1501 | *appdx = '\0'; |
---|
1502 | if (val[j] == '/') strcpy( appdx, val+j ); |
---|
1503 | GpReadParameter( vname, cBcLineLth, val, &ok ); |
---|
1504 | |
---|
1505 | if (!ok) { |
---|
1506 | /* try to find environment variable */ |
---|
1507 | env = (char *)getenv( vname+2 ); /* skip v$ */ |
---|
1508 | if (env == NULL) { |
---|
1509 | strcpy( val, vname+2 ); /* take away '$', results in an error later */ |
---|
1510 | } else if (strlen(env) < cBcLineLth) { |
---|
1511 | strcpy( val, env ); |
---|
1512 | } else { |
---|
1513 | strcpy( val, vname+2 ); /* results in an error later */ |
---|
1514 | } /*endif*/ |
---|
1515 | } /*endif*/ |
---|
1516 | |
---|
1517 | if (*appdx != '\0') |
---|
1518 | if (strlen(val)+strlen(appdx) < cBcLineLth) |
---|
1519 | strcat( val, appdx ); |
---|
1520 | |
---|
1521 | } /* end of GpEvaluateVar */ |
---|
1522 | |
---|
1523 | |
---|
1524 | |
---|
1525 | /*----------------------------------------------------------------------------*/ |
---|