1 /***********************************************************************/
2 /* Open Visualization Data Explorer                                    */
3 /* (C) Copyright IBM Corp. 1989,1999                                   */
4 /* ALL RIGHTS RESERVED                                                 */
5 /* This code licensed under the                                        */
6 /*    "IBM PUBLIC LICENSE - Open Visualization Data Explorer"          */
7 /***********************************************************************/
8 
9 #include <dxconfig.h>
10 #include <dx/dx.h>
11 #include <dx/arch.h>
12 #include <stdio.h>
13 #include <stdlib.h>
14 #include <string.h>
15 
16 
17 #if defined(HAVE_WINDOWS_H)
18 #include <windows.h>
19 #endif
20 
21 #if defined(HAVE_UNISTD_H)
22 #include <unistd.h>
23 #endif
24 
25 #if defined(HAVE_ERRNO_H)
26 #include <errno.h>
27 #endif
28 
29 #if defined(HAVE_PROCESS_H)
30 #include <process.h>
31 #endif
32 
33 #if defined(HAVE__SPAWNVP) && !defined(HAVE_SPAWNVP)
34 #define spawnvp _spawnvp
35 #define HAVE_SPAWNVP 1
36 #endif
37 
38 #define EXE_EXT ".exe"
39 #define DIRSEP "\\"
40 #define PATHSEP ";"
41 
42 #define SCRIPTVERSION DXD_VERSION_STRING
43 
44 #ifndef MAX_PATH
45 #define MAX_PATH 256
46 #endif
47 
48 #define SMALLSTR 50
49 #define MAXARGS 200
50 #define MAXNAME MAX_PATH
51 #define MAXENV  24576
52 #define MAXPARMS 200
53 
54 /* String Types ----------------------------*/
55 typedef char smallstr[SMALLSTR];
56 typedef char envstr[MAXENV];
57 typedef char namestr[MAXNAME];
58 typedef char valuestr[MAXNAME];
59 
60 /* Enum types ----------------------------*/
61 enum regCo {
62   OPENDX_ID = 1,
63   HUMMBIRD_ID = 2,
64   HUMMBIRD_ID2 = 3,
65   STARNET_ID = 4,
66   LABF_ID = 5
67 };
68 
69 enum regGet {
70   GET = 1,
71   CHECK = 2
72 };
73 
74 enum xServer { UNKNOWN, EXCEED6, EXCEED7, XWIN32, WINAXE };
75 
76 
77 /* Macros ---------------------------- */
78 #define IfError(s)		\
79     if (rc != ERROR_SUCCESS) {	\
80 	strcpy(errstr, s);	\
81 	goto error;		\
82     }
83 
84 #define IfError2(s, t, u) {			\
85     if (rc != ERROR_SUCCESS) {			\
86 	sprintf(errstr, "%s %s %s", s, t, u);	\
87 	goto error;				\
88     }						\
89 }
90 
91 #define ErrorGoto(s) {		\
92 	strcpy(errstr, s);	\
93 	goto error;		\
94     }
95 
96 #define ErrorGoto2(s, t, u) {			\
97 	sprintf(errstr, "%s %s %s", s, t, u);	\
98 	goto error;				\
99     }
100 
101 #define KILLSEMI(s) {							\
102 	int kk;								\
103 	while ((kk = strlen(s)) && ((s[kk-1] == ';') || (s[kk-1] == ' ')))	\
104 	    s[kk-1] = '\0';						\
105     }
106 
107 #define setenvpair(s, v)	\
108     if (s && *s && v && *v)	\
109 	if(!putenvstr(s, v, echo)) {	\
110     printf("\nCannot set env var: %s\n", s); 	\
111 }
112