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 /* DX script - C-Windows version */
9
10 #include "dx.h"
11
12 #if !defined(intelnt) && !defined(WIN32)
13 #include <stdio.h>
main()14 int main(){fprintf(stderr, "misc/dx is only needed on Windows (non-cygwin) based systems.\n"); return 1;}
15 #else /* Windows system compile application */
16
17 #include "utils.h"
18
19 #define USE_REGISTRY 1
20
21 #if defined(cygwin)
22 void
GetShortPathName(char * src,char * dst,int max)23 GetShortPathName(char *src, char *dst, int max)
24 {
25 strncpy(dst, src, strlen(src)+1);
26 }
27 #endif
28
29 #define ConvertShortPathName(s1) { \
30 envstr sPath = ""; \
31 GetShortPathName(s1, sPath, MAXENV); \
32 strncpy(s1, sPath, strlen(s1)); \
33 }
34
35 /* Global Variables */
36
37 enum xServer whichX = UNKNOWN;
38
39 int numparms = 0;
40 int exonly = 0;
41 int native = 0;
42 int uionly = 0;
43 int startup = 0;
44 int seecomline = 0;
45 int echo = 0;
46 int showversion = 0;
47 int prompter = 0;
48 int tutor = 0;
49 int builder = 0;
50 int wizard = 0;
51 int portset = 0;
52 int javaserver = 0;
53 int needShortPath = 0;
54
55 namestr parm[MAXPARMS];
56 envstr cmd = "";
57 envstr path = "";
58
59 envstr dxargs = "";
60 smallstr uimode = "";
61 smallstr exmode = "";
62 namestr exhost = "";
63 namestr cdto = "";
64 namestr exmem = "";
65 namestr uimem = "";
66 namestr exprocs = "";
67 namestr uiflags = "";
68 namestr errmsg = "";
69 namestr display = "";
70 smallstr uilog = "";
71 smallstr exlog = "";
72 smallstr uicache = "";
73 smallstr excache = "";
74 smallstr uitrace = "";
75 smallstr extrace = "";
76 smallstr uiread = "";
77 smallstr exread = "";
78 smallstr uitime = "";
79 smallstr extime = "";
80 smallstr uihilite = "";
81 smallstr exhilite = "-B"; /* Default is on */
82 namestr FileName = "";
83 namestr dxroot = "";
84 namestr dxexroot = "";
85 namestr dxuiroot = "";
86 namestr exceeddir = "";
87 namestr exceeduserdir = "";
88 namestr starnetdir = "";
89 namestr winaxedir = "";
90 namestr xservername = "";
91 namestr xserverversion= "";
92 namestr xnlspath = "";
93 namestr xapplresdir = "";
94 namestr xkeysymdb = "";
95 namestr dxexec = "";
96 namestr dxmdf = "";
97 namestr exmdf = "";
98 namestr uimdf = "";
99 namestr dxui = "";
100 envstr dxdata = "";
101 envstr dxmacros = "";
102 envstr dxmodules = "";
103 namestr uirestrict = "";
104 namestr prompterflags = "";
105 namestr dxhwmod = "";
106 smallstr port = "";
107 smallstr host = "";
108 smallstr dx8bitcmap = "";
109 namestr dxinclude = "";
110 smallstr dxcolors = "";
111 smallstr uiarch = "";
112 smallstr exarch = "";
113 namestr curdir = "";
114 namestr motifbind = "DX*officialmascot: fred";
115 namestr xparms = "";
116 namestr thishost = "localhost";
117 smallstr uidebug = "";
118
119 namestr classpath = "";
120
121 namestr msgstr = "";
122 namestr errstr = "";
123 envstr argstr = "";
124 envstr magickhome = "";
125
126
127 /* Function Prototypes */
128
129 int regval(enum regGet get, char *name, enum regCo co, char *value, int size, int *word);
130 int initrun();
131 int getparms(int argc, char **argv);
132 int fillparms(char *str, int *n);
133 int parseparms();
134 void configure();
135 void dxjsconfig(); /* Add more env variables for JavaDX Server */
136 int buildcmd();
137 int launchit();
138 int launchjs(); /* Launch the JavaDX Server */
139 int shorthelp();
140 int longhelp();
141
main(int argc,char ** argv)142 int main(int argc, char **argv)
143 {
144 initrun();
145 getparms(argc, argv);
146 parseparms();
147 if (javaserver) {
148 dxjsconfig();
149 } else {
150 configure();
151 }
152 buildcmd();
153 if (!echo)
154 launchit();
155 exit(0);
156 }
157
158 #if defined(USE_REGISTRY)
159
160 /* The following queries the registry for various paths that, */
161 /* among other things, allow dx and Xserver to start without */
162 /* either being in the path. But they must be added to the */
163 /* beginning of the path in order for them to run, and all */
164 /* children must convey this down. */
regval(enum regGet get,char * name,enum regCo co,char * value,int size,int * word)165 int regval(enum regGet get, char *name, enum regCo co, char *value, int size, int *word)
166 {
167 char key[500];
168 char key2[500];
169 int valtype;
170 int sizegot = size;
171 HKEY hkey_m;
172 HKEY hkey_u;
173 long rc, rc_m, rc_u;
174 int i;
175 DWORD options;
176 DWORD dwDisp;
177 REGSAM access = KEY_READ;
178 const char **regpath;
179 const char *dxpath[] = {"SOFTWARE\\OpenDX\\DX\\CurrentVersion", NULL };
180 const char *snpath[] = { "SOFTWARE\\Starnet\\X-Win32 LX\\7.3",
181 "SOFTWARE\\Starnet\\X-Win32 LX\\7.2",
182 "SOFTWARE\\Starnet\\X-Win32 LX\\7.1",
183 "SOFTWARE\\Starnet\\X-Win32 LX\\7.0",
184 "SOFTWARE\\Starnet\\X-Win32 LX\\6.1",
185 "SOFTWARE\\Starnet\\X-Win32 LX\\6.0",
186 "SOFTWARE\\Starnet\\X-Win32\\7.1",
187 "SOFTWARE\\Starnet\\X-Win32\\7.0",
188 "SOFTWARE\\Starnet\\X-Win32\\6.2",
189 "SOFTWARE\\Starnet\\X-Win32\\6.1",
190 "SOFTWARE\\Starnet\\X-Win32\\6.0",
191 "SOFTWARE\\Starnet\\X-Win32\\5.5",
192 "SOFTWARE\\Starnet\\X-Win32\\5.4",
193 "SOFTWARE\\Starnet\\X-Win32\\5.3",
194 "SOFTWARE\\Starnet\\X-Win32\\5.2",
195 "SOFTWARE\\Starnet\\X-Win32\\5.1", NULL };
196 const char *wapath[] = { "SOFTWARE\\LabF.com\\WinaXe\\7.4",
197 "SOFTWARE\\LabF.com\\WinaXe\\7.3",
198 "SOFTWARE\\LabF.com\\WinaXe\\7.2",
199 "SOFTWARE\\LabF.com\\WinaXe\\7.1",
200 "SOFTWARE\\LabF.com\\WinaXe\\7.0",
201 "SOFTWARE\\LabF.com\\WinaXe\\6.9",
202 "SOFTWARE\\LabF.com\\WinaXe\\6.8",
203 "SOFTWARE\\LabF.com\\WinaXe\\6.7",
204 "SOFTWARE\\LabF.com\\WinaXe\\6.6",
205 "SOFTWARE\\LabF.com\\WinaXe\\6.5",
206 "SOFTWARE\\LabF.com\\WinaXe\\6.4",
207 "SOFTWARE\\LabF.com\\WinaXe\\6.3",
208 "SOFTWARE\\LabF.com\\WinaXe\\6.2",
209 "SOFTWARE\\LabF.com\\WinaXe\\6.1", NULL };
210 const char *hbpath[] = { "SOFTWARE\\Hummingbird\\Connectivity\\12.00\\Exceed",
211 "SOFTWARE\\Hummingbird\\Connectivity\\11.10\\Exceed",
212 "SOFTWARE\\Hummingbird\\Connectivity\\11.00\\Exceed",
213 "SOFTWARE\\Hummingbird\\Connectivity\\10.10\\Exceed",
214 "SOFTWARE\\Hummingbird\\Connectivity\\10.00\\Exceed",
215 "SOFTWARE\\Hummingbird\\Connectivity\\9.10\\Exceed",
216 "SOFTWARE\\Hummingbird\\Connectivity\\9.00\\Exceed",
217 "SOFTWARE\\Hummingbird\\Connectivity\\8.10\\Exceed",
218 "SOFTWARE\\Hummingbird\\Connectivity\\8.00\\Exceed",
219 "SOFTWARE\\Hummingbird\\Connectivity\\7.10\\Exceed",
220 "SOFTWARE\\Hummingbird\\Connectivity\\7.00\\Exceed", NULL };
221 const char *h6path[] = { "SOFTWARE\\Hummingbird\\Exceed\\CurrentVersion", NULL };
222
223 /* First determine which system we're looking up. */
224
225 if(co == OPENDX_ID)
226 regpath = dxpath;
227 else if (co == STARNET_ID)
228 regpath = snpath;
229 else if (co == LABF_ID)
230 regpath = wapath;
231 else if (co == HUMMBIRD_ID)
232 regpath = hbpath;
233 else /* Old Exceed 6 */
234 regpath = h6path;
235
236
237 /* What a pain--some systems store some info in HKEY_LOCAL_MACHINE */
238 /* whereas others store it in HKEY_CURRENT_USER. It also depends */
239 /* on the type of info and how it was installed. Thus we'll have */
240 /* to always look at both to make sure we do this right and then */
241 /* return the result if in either. */
242
243 i = 0;
244 while(regpath[i]) {
245 #ifdef DEBUGREG
246 printf("Checking: %s\n", regpath[i]);
247 #endif
248 rc_m = RegOpenKeyEx(HKEY_LOCAL_MACHINE, __TEXT(regpath[i]), 0, access, &hkey_m);
249 rc_u = RegOpenKeyEx(HKEY_CURRENT_USER, __TEXT(regpath[i]), 0, access, &hkey_u);
250
251 if((rc_m == ERROR_SUCCESS || rc_u == ERROR_SUCCESS) && get == CHECK) {
252 RegCloseKey(hkey_m);
253 RegCloseKey(hkey_u);
254 return 1;
255 }
256 else if (rc_m == ERROR_SUCCESS || rc_u == ERROR_SUCCESS) {
257 break;
258 }
259 i++;
260 }
261 if(rc_m != ERROR_SUCCESS && rc_u != ERROR_SUCCESS) return 0;
262
263 /* hkey now pointing in the proper reg entry area */
264
265 if (get == GET) {
266 rc_u = RegQueryValueEx(hkey_u, __TEXT(name), (LPDWORD) 0,
267 (LPDWORD) &valtype, (LPBYTE) value, &sizegot);
268
269 if(rc_u != ERROR_SUCCESS)
270 rc_m = RegQueryValueEx(hkey_m, __TEXT(name), (LPDWORD) 0,
271 (LPDWORD) &valtype, (LPBYTE) value, &sizegot);
272
273 if( rc_u != ERROR_SUCCESS && rc_m != ERROR_SUCCESS) {
274 rc = rc_u;
275 sprintf(errstr, "%s %s %s",
276 "Query value failed on registry value", name, "");
277 goto error;
278 }
279
280 RegCloseKey(hkey_u);
281 RegCloseKey(hkey_m);
282
283 /* Now check to see if it is a DWORD entry if so, pass it back through word
284 not as a string through name. */
285 switch(valtype) {
286 case REG_DWORD:
287 *word = *((int *)value);
288 strcpy(value, "");
289 break;
290 case REG_SZ:
291 break;
292 default:
293 return 0;
294 }
295 return 1;
296 }
297
298 error:
299 printf("%s: rc = %d\n", errstr, rc);
300 return 0;
301 }
302 #endif
303
304
initrun()305 int initrun()
306 {
307 #if defined(intelnt) || defined(WIN32)
308 OSVERSIONINFO osvi;
309 #endif
310 #if defined(USE_REGISTRY)
311 int keydata;
312
313 namestr xenvvar = "";
314 namestr dxrootreg = "";
315 namestr dxdatareg = "";
316 namestr dxmacroreg = "";
317 namestr magickhomereg = "";
318
319 if(!(regval(CHECK, "Default", OPENDX_ID, dxrootreg, sizeof(dxrootreg), &keydata) &&
320 (regval(GET, "DXROOT", OPENDX_ID, dxrootreg, sizeof(dxrootreg), &keydata) +
321 regval(GET, "DXDATA", OPENDX_ID, dxdatareg, sizeof(dxdatareg), &keydata) +
322 regval(GET, "DXMACROS", OPENDX_ID, dxmacroreg, sizeof(dxmacroreg), &keydata) +
323 regval(GET, "IMHOME", OPENDX_ID, magickhomereg, sizeof(magickhomereg), &keydata)) > 3) )
324 printf("This version of OpenDX does not appear to be correctly installed on this\n"
325 "machine. Execution will be attempted anyway, and if it fails, please try\n"
326 "reinstalling the software.\n");
327
328 getenvstr("XSRVR", xenvvar);
329 if(strlen(xenvvar)==0 || strcmp(xenvvar, "exceed")==0) {
330 if(regval(CHECK, "Default", HUMMBIRD_ID, exceeddir, sizeof(exceeddir), &keydata)) {
331 strcpy(xservername, "Exceed 7"); whichX = EXCEED7;
332 if(!(regval(GET, "HomeDir", HUMMBIRD_ID, exceeddir, sizeof(exceeddir), &keydata) &&
333 regval(GET, "UserDir", HUMMBIRD_ID, exceeduserdir, sizeof(exceeduserdir), &keydata))) {
334 printf("If Exceed is installed on this machine, please make sure it is available\n"
335 "to you as a user. Otherwise, make sure another X server is installed and running.\n");
336 whichX = UNKNOWN;
337 }
338 }
339 if(regval(CHECK, "Default", HUMMBIRD_ID2, exceeddir, sizeof(exceeddir), &keydata)) {
340 strcpy(xservername, "Exceed 6"); whichX = EXCEED6;
341 if(!(regval(GET, "PathName", HUMMBIRD_ID2, exceeddir, sizeof(exceeddir), &keydata) &&
342 regval(GET, "UserDir", HUMMBIRD_ID2, exceeduserdir, sizeof(exceeduserdir), &keydata))) {
343 printf("If Exceed is installed on this machine, please make sure it is available\n"
344 "to you as a user. Otherwise, make sure another X server is installed and running.\n");
345 whichX = UNKNOWN;
346 }
347 }
348
349 }
350 if((strlen(xenvvar)==0 || strcmp(xenvvar, "xwin32")==0) && whichX == UNKNOWN) {
351 if (regval(CHECK, "Default", STARNET_ID, starnetdir, sizeof(starnetdir), &keydata)) {
352 strcpy(xservername, "X-Win32"); whichX = XWIN32;
353 if(!regval(GET, "Pathname", STARNET_ID, starnetdir, sizeof(starnetdir), &keydata)) {
354 printf("If X-Win32 is installed on this machine, please make sure it is available\n"
355 "to you as a user. Otherwise, make sure another X server is installed and running.\n");
356 whichX = UNKNOWN;
357 }
358 }
359 }
360 if((strlen(xenvvar)==0 || strcmp(xenvvar, "winaxe")==0) && whichX == UNKNOWN) {
361 if(regval(CHECK, "Default", LABF_ID, winaxedir, sizeof(winaxedir), &keydata)) {
362 strcpy(xservername, "WinaXe"); whichX = WINAXE;
363 if(!regval(GET, "App Path", LABF_ID, winaxedir, sizeof(winaxedir), &keydata))
364 printf("If WinaXe is installed on this machine, please make sure it is available\n"
365 "to you as a user. Otherwise, make sure another X server is installed and running.\n");
366 }
367 }
368 #endif /*(USE_REGISTRY)*/
369
370 #if defined(intelnt) || defined(WIN32)
371 osvi.dwOSVersionInfoSize = sizeof(osvi);
372 GetVersionEx(&osvi);
373
374 if(osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)
375 needShortPath = 1;
376 else
377 #endif
378 needShortPath = 0;
379
380 strcpy(exhost, thishost);
381 strcpy(exarch, DXD_ARCHNAME);
382 strcpy(uiarch, DXD_ARCHNAME);
383 putenvstr("ARCH", DXD_ARCHNAME, echo);
384 startup = 1;
385
386 /* Currently everything is correct, except that on NT/2000 we need to
387 not convert to short pathnames. Only do this on Windows ME and below.
388 Thus we need to query the system get the revision number and then
389 make the decision based on this fact. */
390
391 getenvstr("DXARGS", dxargs);
392 getcwd(curdir, sizeof(curdir));
393 getenvstr("DXROOT", dxroot);
394 getenvstr("DXDATA", dxdata);
395 getenvstr("DXMACROS", dxmacros);
396 getenvstr("DXMODULES", dxmodules);
397 getenvstr("DXMDF", dxmdf);
398 getenvstr("DXINCLUDE", dxinclude);
399 getenvstr("DXCOLORS", dxcolors);
400 getenvstr("DXEXEC", dxexec);
401 getenvstr("DXUI", dxui);
402 getenvstr("DISPLAY", display);
403 getenvstr("MAGICK_HOME", magickhome);
404
405 #if defined(USE_REGISTRY)
406 /* If env vars not set then try using the Registry vars */
407 if (!*dxroot)
408 strcpy(dxroot, dxrootreg);
409 if(!*dxdata)
410 strcpy(dxdata, dxdatareg);
411 if(!*dxmacros)
412 strcpy(dxmacros, dxmacroreg);
413 if(!*magickhome)
414 strcpy(magickhome, magickhomereg);
415 #endif
416
417 /* If all else fails, set some defaults for OpenSource Unix layout */
418 if (!*dxroot) {
419 #if defined(cygwin)
420 strcpy(dxroot, "/usr/local/dx/");
421 #else
422 strcpy(dxroot, "\\usr\\local\\dx\\");
423 #endif
424 }
425
426 /* Now strip off any garbage that may have been set on dxroot */
427 removeQuotes(dxroot);
428 u2d(dxroot);
429 if(needShortPath)
430 ConvertShortPathName(dxroot);
431
432 #if defined(cygwin)
433 if (dxdata && *dxdata)
434 strcat(dxdata, ":");
435 strcat(dxdata, dxroot);
436 if(dxroot[strlen(dxroot)-1] !='/')
437 strcat(dxdata, "/");
438 strcat(dxdata,"samples/data");
439 #else
440 if (dxdata && *dxdata)
441 strcat(dxdata, ";");
442 strcat(dxdata, dxroot);
443 if(dxroot[strlen(dxroot)-1] !='\\')
444 strcat(dxdata, "\\");
445 strcat(dxdata,"samples\\data");
446 #endif
447
448 /* Append the default dxroot/samples/macros to current macros if it doesn't exist */
449
450 #if defined(cygwin)
451 if(dxmacros && *dxmacros)
452 strcat(dxmacros, ":");
453 strcat(dxmacros, dxroot);
454 if(dxroot[strlen(dxroot)-1] !='/')
455 strcat(dxmacros, "/");
456 strcat(dxmacros,"samples/macros");
457 #else
458 {
459 namestr buf;
460 strcpy(buf, dxroot);
461 if(dxroot[strlen(dxroot)-1] !='\\')
462 strcat(buf, "\\");
463 strcat(buf,"samples\\macros");
464 if(strstr(dxmacros, buf) == 0) {
465 if(dxmacros && *dxmacros)
466 strcat(dxmacros, ";");
467 strcat(dxmacros, buf);
468 }
469 }
470 #endif
471
472 /* fill envargs */
473
474 return 1;
475 }
476
477 #define notset(s) (s && !*s)
478
479 #define setifnot(s, v) \
480 if notset(s) { \
481 strcpy(s, v); \
482 }
483
484
configure()485 void configure()
486 {
487 int result=0;
488 namestr temp, xs;
489
490 if(dxroot[strlen(dxroot)-1] == '\\') dxroot[strlen(dxroot)-1] = '\0';
491
492 getenvstr("Path", path);
493
494 getenvstr("XSERVER_LAUNCHED", xs);
495
496 #if defined(USE_REGISTRY)
497 /* If using registry, then installer installs this file
498 appropriately.
499 */
500
501 sprintf(xkeysymdb, "%s\\lib\\keysyms.dx", dxroot);
502 if(needShortPath)
503 ConvertShortPathName(xkeysymdb);
504 setenvpair("XKEYSYMDB", xkeysymdb);
505 #endif
506
507 if(strcmp(xs, "yes") != 0) {
508 if (whichX == EXCEED6) {
509 /* Set Exceed 6 env variables */
510 if(needShortPath)
511 ConvertShortPathName(exceeddir);
512 if(exceeddir[strlen(exceeddir)-1] == '\\')
513 exceeddir[strlen(exceeddir)-1] = '\0';
514 strcat(path, ";");
515 strcat(path, exceeddir);
516 setenvpair("Path", path);
517 result = _spawnlp(_P_NOWAIT, "Exceed", "Exceed", NULL);
518 if(result == -1)
519 printf( "Error spawning Exceed: %s\n", strerror( errno ) );
520 setenvpair("XSERVER_LAUNCHED", "yes");
521 }
522
523 if (whichX == XWIN32) {
524 /* Need to define X-Win32 env variables */
525 /* set DISPLAY to COMPUTERNAME:0 */
526 /* Start XWIN32 */
527 if(needShortPath)
528 ConvertShortPathName(starnetdir);
529 if(starnetdir[strlen(starnetdir)-1] == '\\')
530 starnetdir[strlen(starnetdir)-1] = '\0';
531 strcat(path,";");
532 strcat(path, starnetdir);
533 setenvpair("Path", path);
534 result = _spawnlp(_P_NOWAIT, "xwin32", "xwin32", NULL);
535 if(result == -1)
536 printf( "Error spawning xwin32: %s\n", strerror( errno ) );
537
538 setenvpair("XSERVER_LAUNCHED", "yes");
539 }
540 if (whichX == WINAXE) {
541 if(needShortPath)
542 ConvertShortPathName(winaxedir);
543 if(winaxedir[strlen(winaxedir)-1] == '\\')
544 winaxedir[strlen(winaxedir)-1] = '\0';
545 strcat(path,";");
546 strcat(path, winaxedir);
547 setenvpair("Path", path);
548 result = _spawnlp(_P_NOWAIT, "xserver", "xserver", NULL);
549 if(result == -1)
550 printf( "Error spawning winaxe: %s\n", strerror( errno ) );
551
552 setenvpair("XSERVER_LAUNCHED", "yes");
553 }
554 }
555
556 if (whichX == EXCEED7) {
557 /* Need to define Exceed Env Variables */
558 if(needShortPath)
559 ConvertShortPathName(exceeddir);
560 if(exceeddir[strlen(exceeddir)-1] == '\\')
561 exceeddir[strlen(exceeddir)-1] = '\0';
562 strcat(path, ";");
563 strcat(path, exceeddir);
564 }
565
566 sprintf(temp, "%s\\bin_%s", dxroot, DXD_ARCHNAME);
567 if(needShortPath)
568 ConvertShortPathName(temp);
569 strcat(path, ";");
570 strcat(path, temp);
571
572 u2d(magickhome);
573 if(needShortPath)
574 ConvertShortPathName(magickhome);
575 strcat(path, ";");
576 strcat(path, magickhome);
577
578 setenvpair("Path", path);
579
580 /* The following logic is specific to the PC, where the */
581 /* the sample data and macro paths are automatically set */
582 /* if neither is specified. This allows the samples not */
583 /* to have hardcoded paths in the pc environment (they */
584 /* are sed'd out). Unix needs different logic. */
585
586
587 setenvpair("DXDATA", dxdata);
588 setenvpair("DXMACROS", dxmacros);
589 setenvpair("DXMODULES", dxmodules);
590 setenvpair("DXINCLUDE", dxinclude);
591 setenvpair("DXMDF", dxmdf);
592 setenvpair("DXCOLORS", dxcolors);
593 setenvpair("DX8BITCMAP", dx8bitcmap);
594 setenvpair("MAGICK_HOME", magickhome);
595
596
597 if (!*display || !strcasecmp(display, "localpc:0"))
598 {
599 if(whichX == EXCEED7)
600 strcpy(display, "localpc:0");
601 else
602 strcpy(display, "localhost:0");
603 }
604 setenvpair("DISPLAY", display);
605 setenvpair("DXNO_BACKING_STORE", "1");
606 setenvpair("DXFLING", "1");
607 //Solve problem with queuing in DXLink within Windows.
608 setenvpair("DX_STALL", "1");
609
610 /* Due to the way XrmParseCommand works, it cannot accept
611 spaces when launching other processes from dxui, etc.
612 Therefore, must store root in the short version without
613 spaces. */
614 if(strstr(dxroot, " "))
615 ConvertShortPathName(dxroot);
616
617 setenvpair("DXROOT", dxroot);
618 if (strcasecmp(dxroot, dxexroot))
619 setenvpair("DXEXECROOT", dxexroot);
620 if (strcasecmp(dxroot, dxuiroot))
621 setenvpair("DXUIROOT", dxuiroot);
622 if (strcmp(exhost, thishost))
623 setenvpair("DXHOST", exhost);
624 }
625
626
dxjsconfig()627 void dxjsconfig() {
628 namestr jdxsrvPath, temp;
629
630 /* Don't need X Server for Java Explorer server */
631 setenvpair("XSERVER_LAUNCHED", "yes");
632
633 if(dxroot[strlen(dxroot)-1] == '\\') dxroot[strlen(dxroot)-1] = '\0';
634 sprintf(jdxsrvPath, "%s\\java\\server", dxroot);
635 ConvertShortPathName(jdxsrvPath);
636
637 sprintf(classpath, "%s\\class", jdxsrvPath);
638 ConvertShortPathName(classpath);
639
640 getenvstr("Path", path);
641
642 /* Add dxroot\bin */
643 sprintf(temp, "%s\\bin", dxroot);
644 ConvertShortPathName(temp);
645 strcat(path, ";"); strcat(path, temp);
646
647 /* Add dxroot\bin_arch */
648 sprintf(temp, "%s\\bin_%s", dxroot, DXD_ARCHNAME);
649 ConvertShortPathName(temp);
650 strcat(path, ";"); strcat(path, temp);
651
652 /* Add dxroot\lib_arch */
653 sprintf(temp, "%s\\lib_%s", dxroot, DXD_ARCHNAME);
654 ConvertShortPathName(temp);
655 strcat(path, ";"); strcat(path, temp);
656
657 /* Add jdxsrvPath\lib_arch */
658 sprintf(temp, "%s\\lib_%s", jdxsrvPath, DXD_ARCHNAME);
659 ConvertShortPathName(temp);
660 strcat(path, ";"); strcat(path, temp);
661
662 u2d(magickhome);
663 ConvertShortPathName(magickhome);
664 strcat(path, ";"); strcat(path, magickhome);
665
666 setenvpair("Path", path);
667
668 /* The following logic is specific to the PC, where the */
669 /* the sample data and macro paths are automatically set */
670 /* if neither is specified. This allows the samples not */
671 /* to have hardcoded paths in the pc environment (they */
672 /* are sed'd out). Unix needs different logic. */
673
674 sprintf(temp, "%s\\dxmacros", jdxsrvPath);
675 ConvertShortPathName(temp);
676 if(*dxmacros)
677 strcat(dxmacros, ";"); strcat(dxmacros, temp);
678 sprintf(temp, "%s\\usermacros", jdxsrvPath);
679 ConvertShortPathName(temp);
680 strcat(dxmacros, ";"); strcat(dxmacros, temp);
681 setenvpair("DXMACROS", dxmacros);
682
683 strcpy(dxinclude, dxmacros);
684 setenvpair("DXINCLUDE", dxinclude);
685
686 sprintf(temp, "%s\\userdata", jdxsrvPath);
687 ConvertShortPathName(temp);
688 if(*dxdata)
689 strcat(dxdata, ";"); strcat(dxdata, temp);
690 setenvpair("DXDATA", dxdata);
691
692 setenvpair("DXMODULES", dxmodules);
693 setenvpair("DXMDF", dxmdf);
694 setenvpair("DXCOLORS", dxcolors);
695 setenvpair("DX8BITCMAP", dx8bitcmap);
696 setenvpair("MAGICK_HOME", magickhome);
697
698 setenvpair("DXROOT", dxroot);
699 if (strcasecmp(dxroot, dxexroot))
700 setenvpair("DXEXECROOT", dxexroot);
701 if (strcasecmp(dxroot, dxuiroot))
702 setenvpair("DXUIROOT", dxuiroot);
703 if (strcmp(exhost, thishost))
704 setenvpair("DXHOST", exhost);
705
706 setenvpair("DXARGS", "-execonly -highlight off -optimize memory");
707 }
708
buildcmd()709 int buildcmd()
710 {
711 envstr tmp;
712 namestr outdir;
713 namestr dxexecdef = "";
714 envstr exflags = "";
715
716
717 if(javaserver) {
718 sprintf(outdir, "%s\\java\\output", dxroot);
719 ConvertShortPathName(outdir);
720
721 u2d(classpath);
722 d2u(outdir);
723
724 sprintf(cmd, "java -classpath %s\\server.jar -DDXServer.pathsFile=%s\\dxserver.paths -DDXServer.hostsFile=%s\\dxserver.hosts -DDXServer.outUrl=output -DDXServer.outDir=%s DXServer",
725 classpath, classpath, classpath, outdir);
726 }
727 else
728 {
729
730 setifnot(dxexroot, dxroot);
731 u2d(dxexroot);
732 setifnot(dxuiroot, dxroot);
733
734 if(native)
735 sprintf(dxexecdef, "%s\\bin_%s\\dxexec-native%s", dxexroot, exarch, EXE_EXT);
736 else
737 sprintf(dxexecdef, "%s\\bin_%s\\dxexec%s", dxexroot, exarch, EXE_EXT);
738 setifnot(dxexec, dxexecdef);
739 setifnot(exmode, "-r");
740
741 setifnot(dxuiroot, dxroot);
742 if (notset(dxui))
743 sprintf(dxui, "%s\\bin_%s\\dxui%s", dxuiroot, uiarch, EXE_EXT);
744
745 setifnot(uimode, "-edit");
746 setifnot(cdto, curdir);
747
748 u2d(dxroot);
749 u2d(dxexec);
750 u2d(dxui);
751 u2d(cdto);
752 d2u(prompterflags);
753 d2u(argstr);
754 d2u(uimdf);
755 d2u(uiflags);
756 d2u(exmdf);
757 if (*FileName) {
758 d2u(FileName);
759 #if defined(intelnt) || defined(WIN32)
760 addQuotes(FileName);
761 #endif
762 }
763
764 if (uionly && exonly)
765 ErrorGoto("-uionly and -execonly are mutually exclusive");
766
767 if (!strcmp(uimode, "-java") && !*FileName)
768 ErrorGoto("-program name required with -java flag");
769
770 if (showversion) {
771 if (*xservername) {
772 printf("X server found: %s\n", xservername);
773 }
774 printf("Open Visualization Data Explorer, version %s (%s, %s)\n", SCRIPTVERSION, __TIME__, __DATE__);
775 sprintf(cmd, "%s -v", dxexec);
776 launchit();
777 sprintf(cmd, "%s -version", dxui);
778 launchit();
779 exit(0);
780 }
781
782 if (tutor) {
783 sprintf(cmd, "%s%sbin_%s%stutor%s", dxexroot, DIRSEP, uiarch, DIRSEP, EXE_EXT);
784 u2d(cmd);
785 }
786 else if (prompter) {
787 if (*FileName) {
788 strcat(prompterflags, " -file ");
789 strcat(prompterflags, FileName);
790 }
791 sprintf(cmd, "%s%sbin_%s%sprompter%s %s", dxuiroot, DIRSEP, uiarch, DIRSEP, EXE_EXT, prompterflags);
792 u2d(cmd);
793 }
794 else if (startup) {
795 sprintf(cmd, "%s%sbin_%s%sstartupui%s %s", dxuiroot, DIRSEP, uiarch, DIRSEP, EXE_EXT, argstr);
796 u2d(cmd);
797 }
798 else if (builder) {
799 sprintf(cmd, "%s%sbin_%s%sbuilder%s %s", dxuiroot, DIRSEP, uiarch, DIRSEP, EXE_EXT, FileName);
800 /* sprintf(cmd, "%s%sbin_%s%sbuilder -xrm %s %s", dxroot, DIRSEP, uiarch, DIRSEP, motifbind, FileName); */
801 u2d(cmd);
802 }
803 else if (exonly) {
804 printf("Starting DX executive\n");
805 sprintf(exflags, "%s %s %s %s %s %s %s %s %s %s",
806 exmode, excache, exlog, exread, exmem, exprocs,
807 extrace, exhilite, extime,
808 exmdf);
809 sprintf(cmd, "%s %s ", dxexec, exflags);
810 if (*FileName) {
811 u2d(FileName);
812 }
813
814 }
815 else {
816 printf("Starting DX user interface\n");
817 sprintf(tmp, " %s %s %s %s %s %s %s %s %s %s %s %s",
818 uimode, uidebug, uimem, uilog, uicache,
819 uiread, uitrace, uitime, uihilite, uimdf, xparms,
820 uirestrict);
821 strcat(uiflags, tmp);
822 if (portset) {
823 strcat(uiflags, " -port ");
824 strcat(uiflags, port);
825 }
826 if (*FileName) {
827 strcat(uiflags, " -program ");
828 strcat(uiflags, FileName);
829 }
830 if (uionly)
831 strcat(uiflags, " -uionly");
832 if (wizard)
833 strcat(uiflags, " -wizard");
834 #ifndef DXD_WIN
835 if (*cdto) {
836 strcat(uiflags, " -directory ");
837 strcat(uiflags, cdto);
838 }
839 #endif
840 if (strcmp(dxexec, dxexecdef)) {
841 strcat(uiflags, " -exec ");
842 d2u(dxexec);
843 strcat(uiflags, dxexec);
844 }
845
846 sprintf(cmd, "%s %s", dxui, uiflags);
847 /* sprintf(cmd, "%s %s -xrm %s", dxui, uiflags, motifbind); */
848
849 }
850 }
851
852 if (seecomline || echo)
853 printf("%s\n", cmd);
854
855
856 return 1;
857
858 error:
859 printf("%s\n", errstr);
860 return 1;
861 }
862
863
launchit()864 int launchit()
865 {
866 #define BUFFSIZE 2048
867 int rc;
868 char *args[100];
869 char *s, *lastSep;
870 int i;
871 FILE *f, *p;
872
873 char buf[BUFFSIZE];
874
875 u2d(cdto);
876 chdir(cdto);
877 if (exonly && *FileName) {
878 removeQuotes(FileName);
879 f = fopen(FileName, "r");
880 if (!f)
881 ErrorGoto2("File", FileName, "not found");
882 p = popen(cmd, "wt");
883 if (!p)
884 ErrorGoto2("Error spawning exec using", cmd, "");
885 while (fgets(buf, BUFFSIZE, f))
886 fputs(buf, p);
887 pclose(p);
888 fclose(f);
889 }
890 else
891 {
892 lastSep = strstr(cmd, " -") -1;
893
894 for (i=0, s=cmd; *s; s++) {
895 for ( ; *s && *s == ' '; s++)
896 ;
897 if (!*s)
898 break;
899 for (args[i++]=s; *s && (*s != ' ' || s < lastSep); s++)
900 ;
901 if (!*s)
902 break;
903 *s = '\0';
904 }
905 args[i] = NULL;
906
907 #if defined(DEBUG)
908 printf("DEBUG: %d\n", DEBUG);
909 for (i=0; args[i] != NULL; i++)
910 printf("arg[%d]: %s\n", i, args[i]);
911 #endif
912
913 #if defined(HAVE_SPAWNVP)
914 if (strcmp(exmode, "-r") || showversion)
915 rc = spawnvp(_P_WAIT, cmd, &args[0]);
916 else
917 rc = spawnvp(_P_OVERLAY, cmd, &args[0]);
918 if (rc < 0)
919 {
920 rc = errno;
921 perror("error");
922 }
923 #else
924 rc = execvp(args[0], args);
925 #endif
926 }
927 return 1;
928 error:
929 printf("%s\n", errstr);
930 return 0;
931 }
932
933
934
getparms(int argc,char ** argv)935 int getparms(int argc, char **argv)
936 {
937 int i;
938 int n = 0;
939 int readpipe = 0;
940 char c;
941 envstr pipestr = "";
942
943
944 /* fill parms array, first with DXARGS values */
945 /* then with command line options */
946 /* then with pipe args */
947 /* so they will have priority given to last ones in */
948
949 /* -pipeargs is necessary evil since I couldn't get */
950 /* Windows to do a non-blocking peek at stdin to */
951 /* see if anything is there. -pipeargs makes it */
952 /* explicit, anyway. */
953
954 fillparms(dxargs, &n);
955
956 for (i=1; i<argc; i++) {
957 strcpy(parm[n], argv[i]);
958 if (!strcmp(parm[n], "-pipeargs"))
959 readpipe = 1;
960 else
961 {
962 strcat(argstr, parm[n]);
963 strcat(argstr, " ");
964 n++;
965 }
966 }
967
968 if (readpipe) {
969 for (i=0; (c=getchar()) != EOF; i++)
970 pipestr[i] = c;
971 pipestr[i] = '\0';
972 fillparms(pipestr, &n);
973 }
974
975 numparms = n;
976
977 return 1;
978 }
979
980 /* This fills the parm array with tokens that have their */
981 /* leading and trailing blanks removed. In Windows, filepaths */
982 /* may contain spaces if they were passed in as quoted strings */
983 /* and the shell may have removed the quotes, leaving interior */
984 /* blanks. */
fillparms(char * s,int * n)985 int fillparms(char *s, int *n)
986 {
987 char *p, *q, *dest;
988
989 for (p = s; *p; p++)
990 if (*p == '\t' || *p == '\n' || *p == '\f')
991 *p = ' ';
992
993 for (p = s; *p; p = q) { /* start next */
994 dest = parm[*n];
995 for ( ; *p == ' '; p++) /* skip to nonblank */
996 ;
997 for (q = p; *q && *q != ' '; q++) /* find token end */
998 ;
999 if (p == q) /* no more tokens */
1000 return 1;
1001 strncpy(dest, p, (int)(q-p)); /* load it */
1002 dest[(int)(q-p)] = '\0';
1003 (*n)++;
1004 }
1005
1006 return 1;
1007 }
1008
1009
1010
1011
1012
1013 /* Below is a slew of macros. Note that some would be very */
1014 /* unhappy if a c-style semicolon were used after them, while */
1015 /* others wouldn't mind. */
1016
1017 /* Note also that a few automatically advance the pointer, */
1018 /* while others do not. */
1019
1020 /* The leading - is implicit in the conditionals, but must be */
1021 /* explicit in the startswith() query. */
1022
1023 #define advance \
1024 p++; \
1025 s = parm[p];
1026
1027 #define is(str) \
1028 if (!strcmp(s, "-" #str)) {
1029
1030 #define startswith(str) \
1031 if (!strncmp(s, #str, strlen(#str))) {
1032
1033 #define isregexpr \
1034 (s[strlen(s)-1] == '*')
1035
1036 #define isor(str) \
1037 if (!strcmp(s, "-" #str) ||
1038
1039 #define or(str) \
1040 !strcmp(s, "-" #str) ||
1041
1042 #define rosi(str) \
1043 !strcmp(s, "-" #str)) {
1044
1045 #define next \
1046 } else
1047
1048 #define islast \
1049 (p >= numparms)
1050
1051 #define last(str) \
1052 if islast { \
1053 strcpy(errmsg, str); \
1054 goto error; \
1055 } \
1056 advance;
1057
1058 #define lastoff(str) \
1059 last("-" #str ": missing parameter, must be on or off");
1060
1061 #define check(str) \
1062 if ((p >= numparms-1) || (*parm[p+1] == '-')) { \
1063 strcpy(errmsg, str); \
1064 goto error; \
1065 } \
1066 advance;
1067
1068 #define set(val) \
1069 strcpy(val, s);
1070
1071 #define add(val) \
1072 strcat(val, " "); \
1073 strcat(val, s);
1074
1075 #define add2(val1, val2) \
1076 add(val1) \
1077 add(val2)
1078
1079 #define argadd(what, val) \
1080 is(what) \
1081 strcat(val, " -" #what); \
1082 next
1083
1084 #define eq(val) \
1085 if (!strcmp(s, #val)) {
1086
1087 #define eqon \
1088 if (!strcmp(s, "on")) {
1089
1090 #define eqoff \
1091 if (!strcmp(s, "off")) {
1092
1093 #define neither(str) \
1094 } else { \
1095 strcpy(errmsg, str); \
1096 goto error; \
1097 }
1098
1099 #define neitheroff(str) \
1100 neither("-" #str ": bad parameter, must be on or off")
1101
1102 #define nextisswitch \
1103 (*parm[p+1] == '-')
1104
1105 #define skipwarn(val) \
1106 is(val) \
1107 strcpy(msgstr, "ignoring option -" #val " and its value, "); \
1108 advance; \
1109 strcat(msgstr, s); \
1110 printf("%s\n", msgstr); \
1111 next
1112
1113 #define skipwarn0(val) \
1114 is(val) \
1115 strcpy(msgstr, "ignoring option -" #val); \
1116 printf("%s\n", msgstr); \
1117 next
1118
1119 #define skip0(val) \
1120 is(val) \
1121 next
1122
1123 #define skipnowarn(val) \
1124 is(val) \
1125 advance; \
1126 next
1127
1128 /* Here's the script, which amounts to a long chain of if-else's */
parseparms()1129 int parseparms()
1130 {
1131 char *s;
1132 int p;
1133
1134 for (p=0; p<numparms; ) {
1135
1136 s = parm[p];
1137
1138 is(whereami)
1139 d2u(dxroot);
1140 printf("installed in %s\n", dxroot);
1141 exit(0);
1142 next
1143
1144 is(whicharch)
1145 printf("intelnt\n");
1146 exit(0);
1147 next
1148
1149 is(host)
1150 check("-host: missing host name");
1151 set(exhost);
1152 next
1153
1154 is(local)
1155 strcpy(exhost, thishost);
1156 next
1157
1158 skip0(queue)
1159
1160 skipwarn(connect)
1161
1162 is(directory)
1163 check("-directory: missing directory name");
1164 set(cdto);
1165 next
1166
1167 is(memory)
1168 check("-memory: missing parameter, must give number of Megabytes");
1169 strcpy(exmem, " -M");
1170 strcat(exmem, s);
1171 strcpy(uimem, "-memory");
1172 add(uimem);
1173 next
1174
1175 is(processors)
1176 check("-processors: missing parameter, must give number of processors");
1177 strcpy(exprocs, " -p");
1178 add(exprocs);
1179 next
1180
1181 /* -port is handled slightly differently from on Unix */
1182 /* The Unix script doesn't handle it explicitly, but the ui */
1183 /* understands it. I couldn't find an equivalent because */
1184 /* -uionly prevented the ui from trying to connect, while */
1185 /* !-uionly forced the ui to spawn the server, which has been */
1186 /* started manually. */
1187 is(port)
1188 check("-port: missing port number");
1189 portset = 1;
1190 set(port);
1191 next
1192
1193 isor(image) or(edit) or(java) rosi(kiosk)
1194 strcpy(uimode, s);
1195 exonly = 0;
1196 strcpy(exmode, "-r");
1197 startup = 0;
1198 next
1199
1200 is(wizard)
1201 wizard = 1;
1202 next
1203
1204 is(menubar)
1205 strcpy(uimode, "-kiosk");
1206 exonly = 0;
1207 strcpy(exmode, "-r");
1208 startup = 0;
1209 next
1210
1211 argadd(execute, uiflags)
1212
1213 argadd(execute_on_change, uiflags)
1214
1215 argadd(suppress, uiflags)
1216
1217 is(xrm)
1218 check("-xrm: missing resource value");
1219 strcpy(xparms, "-xrm");
1220 add(xparms);
1221 next
1222
1223 argadd(synchronous, uiflags)
1224
1225 is(display)
1226 check("-display: missing X name");
1227 set(display);
1228 next
1229
1230 is(log)
1231 lastoff(log);
1232 eqon
1233 strcpy(exlog, "-l");
1234 strcpy(uilog, "-log on");
1235 next eqoff
1236 strcpy(exlog, "");
1237 strcpy(uilog, "-log off");
1238 neitheroff(log);
1239 next
1240
1241 is(cache)
1242 lastoff(cache);
1243 eqon
1244 strcpy(excache, "");
1245 strcpy(uicache, "-cache on");
1246 next eqoff
1247 strcpy(excache, "-c");
1248 strcpy(uicache, "-cache off");
1249 neitheroff(cache);
1250 next
1251
1252 is(trace)
1253 lastoff(trace);
1254 eqon
1255 strcpy(extrace, "-T");
1256 strcpy(uitrace, "-trace on");
1257 next eqoff
1258 strcpy(extrace, "");
1259 strcpy(uitrace, "-trace off");
1260 neitheroff(trace);
1261 next
1262
1263 is(readahead)
1264 lastoff(readahead);
1265 eqon
1266 strcpy(exread, "");
1267 strcpy(uiread, "-readahead on");
1268 next eqoff
1269 strcpy(exread, "-u");
1270 strcpy(uiread, "-readahead off");
1271 neitheroff(readahead);
1272 next
1273
1274 is(timing)
1275 lastoff(timing)
1276 eqon
1277 strcpy(extime, "-m");
1278 strcpy(uitime, "-timing on");
1279 next eqoff
1280 strcpy(extime, "");
1281 strcpy(uitime, "-timing off");
1282 neitheroff(timing);
1283 next
1284
1285
1286 is(highlight)
1287 lastoff(highlight)
1288 eqon
1289 strcpy(exhilite, "-B");
1290 strcpy(uihilite, "-highlight on");
1291 next eqoff
1292 strcpy(exhilite, "");
1293 strcpy(uihilite, "-highlight off");
1294 neitheroff(highlight);
1295 next
1296
1297 skipnowarn(processors)
1298
1299 is(optimize)
1300 check("-optimize: missing parameter");
1301 eq(memory)
1302 putenvstr("DXPIXELTYPE", "DXByte", echo);
1303 putenvstr("DXDELAYEDCOLORS", "1", echo);
1304 next eq(precision)
1305 putenvstr("DXPIXELTYPE", "DXFloat", echo);
1306 putenvstr("DXDELAYEDCOLORS", "", echo);
1307 next
1308 {
1309 sprintf(errmsg, "-optimize: parameter \'%s\' not recognized", s);
1310 goto error;
1311 }
1312 next
1313
1314 is(script)
1315 exonly = 1;
1316 strcpy(exmode, "-R");
1317 startup = 0;
1318 if (islast)
1319 goto done;
1320 if (!nextisswitch) {
1321 advance;
1322 set(FileName);
1323 }
1324 next
1325
1326 is(native)
1327 native = 1;
1328 next
1329
1330 is(program)
1331 check("-program: missing program name");
1332 set(FileName);
1333 startup = 0;
1334 next
1335
1336 is(cfg)
1337 check("-cfg: missing configuration file");
1338 strcat(uiflags, "-cfg");
1339 add(uiflags);
1340 next
1341
1342 is(uionly)
1343 uionly = 1;
1344 startup = 0;
1345 next
1346
1347 isor(exonly) rosi(execonly)
1348 exonly = 1;
1349 startup = 0;
1350 next
1351
1352 is(dxroot)
1353 check("-dxroot: missing directory name");
1354 set(dxroot);
1355 next
1356
1357 isor(execroot) rosi(exroot)
1358 check("-execroot: missing directory name");
1359 set(dxexroot);
1360 next
1361
1362 is(uiroot)
1363 check("-uiroot: missing directory name");
1364 set(dxuiroot);
1365 next
1366
1367 is(exec)
1368 check("-exec: missing filename");
1369 set(dxexec);
1370 next
1371
1372 is(mdf)
1373 check("-mdf: missing filename");
1374 set(dxmdf);
1375 strcat(exmdf, " -F");
1376 add(exmdf);
1377 strcat(uimdf, " -mdf");
1378 add(uimdf);
1379 next
1380
1381 is(dxmdf)
1382 add(uimdf);
1383 check("-dxmdf: missing filename");
1384 add(uimdf);
1385 next
1386
1387 is(uimdf)
1388 check("-uimdf: missing filename");
1389 strcat(uimdf, " -uimdf");
1390 add(uimdf);
1391 next
1392
1393 is(ui)
1394 check("-ui: missing filename");
1395 set(dxui);
1396 next
1397
1398 is(data)
1399 check("-data: missing directory list");
1400 set(dxdata);
1401 next
1402
1403 is(macros)
1404 check("-macros: missing directory list");
1405 set(dxmacros);
1406 next
1407
1408 is(modules)
1409 check("-modules: missing directory list");
1410 set(dxmodules);
1411 next
1412
1413 is(include)
1414 check("-include: missing directory list");
1415 set(dxinclude);
1416 next
1417
1418 is(colors)
1419 check("-colors: missing file name");
1420 set(dxcolors);
1421 next
1422
1423 is(8bitcmap)
1424 set(dx8bitcmap);
1425 if (!strcmp(dx8bitcmap, "private"))
1426 strcpy(dx8bitcmap, "-1.0");
1427 else if (!strcmp(dx8bitcmap, "shared"))
1428 strcpy(dx8bitcmap, "1.0");
1429 next
1430
1431 is(hwrender)
1432 check("-hwrender: missing parameter, must be gl or opengl");
1433 eq(opengl)
1434 putenvstr("DXHWMOD", "DXHwddOGL.o", echo);
1435 next eq(gl)
1436 putenvstr("DXHWMOD", "DXHwdd.o", echo);
1437 next
1438 {
1439 sprintf(errmsg, "-hwrender: parameter \'%s\' not recognized", s);
1440 goto error;
1441 }
1442 next
1443
1444 is(jdxserver)
1445 javaserver = 1;
1446 next
1447
1448 is(verbose)
1449 seecomline = 1;
1450 next
1451
1452 is(uidebug)
1453 set(uidebug);
1454 next
1455
1456 skipwarn0(outboarddebug)
1457
1458 is(echo)
1459 echo = 1;
1460 next
1461
1462 skipwarn0(remoteecho)
1463
1464 isor(help) or(shorthelp) rosi(h)
1465 shorthelp();
1466 next
1467
1468 isor(morehelp) rosi(longhelp)
1469 longhelp();
1470 next
1471
1472 is(version)
1473 showversion = 1;
1474 next
1475
1476 is(prompter)
1477 prompter = 1;
1478 next
1479
1480 is(startup)
1481 startup = 1;
1482 next
1483
1484 isor(tutor) rosi(tutorial)
1485 tutor = 1;
1486 startup = 0;
1487 next
1488
1489 is(builder)
1490 builder = 1;
1491 startup = 0;
1492 next
1493
1494 startswith(-no)
1495 add(uirestrict);
1496 next
1497
1498 argadd(limitImageOptions, uirestrict)
1499
1500 argadd(metric, uiflags)
1501
1502 is(restrictionLevel)
1503 add(uirestrict);
1504 check("-restrictionLevel: missing level");
1505 add(uirestrict);
1506 next
1507
1508 is(appHost)
1509 add(uiflags);
1510 check("-appHost: missing host");
1511 add(uiflags);
1512 next
1513
1514 is(appPort)
1515 add(uiflags);
1516 check("-appPort: missing port");
1517 add(uiflags);
1518 next
1519
1520 is(file)
1521 check("-file: missing input filename");
1522 set(FileName);
1523 next
1524
1525 is(full)
1526 add(prompterflags);
1527 next
1528
1529 is(view)
1530 add(uiflags);
1531 check("-view: missing input filename");
1532 add(uiflags);
1533 next
1534
1535 startswith(&)
1536 sprintf(msgstr, "ignoring option: %s --- & used only on Unix systems\n", s);
1537 printf(msgstr);
1538 next
1539
1540 startswith(-)
1541 strcpy(errmsg, "Unrecognized parameter: ");
1542 strcat(errmsg, s);
1543 goto error;
1544 next
1545
1546 {
1547 if (*FileName) {
1548 sprintf(errmsg, "input filename already set to \'%s\'; \'%s\' unrecognized", FileName, s);
1549 goto error;
1550 }
1551 set(FileName);
1552 }
1553 advance;
1554 }
1555
1556 done:
1557 return 1;
1558
1559 error:
1560 printf("%s\n", errmsg);
1561 exit(1);
1562 }
1563
1564
shorthelp()1565 int shorthelp()
1566 {
1567 printf(
1568
1569
1570 "command line parameters:\n"
1571 " -program filename start UI with this network\n"
1572 " -image start DX with an image window as the anchor window \n"
1573 " -edit start DX with an editor window as the anchor window \n"
1574 " -menubar start DX with a small menubar as the anchor window \n"
1575 " -startup start DX with an initial startup panel (default) \n"
1576 "\n"
1577 " -uionly start the UI only (no exec)\n"
1578 " -script filename start the exec only, in script mode, running this script\n"
1579 " -script start the exec only, in script mode\n"
1580 "\n"
1581 " -host hostname start executive on this machine\n"
1582 " -memory #Mbytes set the amount of memory the exec uses\n"
1583 "\n"
1584 " -macros pathlist directory list to search for UI macros\n"
1585 " -data pathlist directory list to search for data files\n"
1586 "\n"
1587 " -prompter start the DX Data Prompter\n"
1588 " -builder start the DX Module Builder\n"
1589 " -tutor start the DX Tutorial\n"
1590 "\n"
1591 " -morehelp print longer help with information about other options\n"
1592
1593
1594 );
1595
1596 exit(0);
1597 }
1598
longhelp()1599 int longhelp()
1600 {
1601 printf(
1602
1603
1604 "command line parameters:\n"
1605 " -host hostname start executive on this machine \n"
1606 " -local start executive on the current machine (default)\n"
1607 "\n"
1608 " -program filename start UI with this network\n"
1609 " -script filename run exec only, in script mode, with this script\n"
1610 " -script run exec only, in script mode\n"
1611 "\n"
1612 " -image start DX with an image window as the anchor window \n"
1613 " -edit start DX with the VP Editor as the anchor \n"
1614 " -menubar start DX with a small menubar as the anchor window \n"
1615 " -startup start DX with an initial dialog (default) \n"
1616 "\n"
1617 " -uionly start the UI only (no exec)\n"
1618 " -execonly start the exec only (no UI) in remote mode\n"
1619 " -connect host:port start a distributed exec only (no UI)\n"
1620 "\n"
1621 " -prompter start the DX Data Prompter\n"
1622 " -jdxserver start the JavaDX Server\n"
1623 " -full start the Full Data Prompter\n"
1624 " -file filename start the Data Prompter with this header file\n"
1625 "\n"
1626 " -builder start the DX Module Builder\n"
1627 " -tutor start the DX Tutorial\n"
1628 "\n"
1629 " -suppress do not open control panels at startup in image mode\n"
1630 " -execute execute the program automatically at startup\n"
1631 " -execute_on_change go into execute_on_change mode at startup\n"
1632 "\n"
1633 " -optimize [memory|precision]\n"
1634 " select whether to minimize memory usage or to produce \n"
1635 " more color-accurate images. When memory is optimized, \n"
1636 " image objects are generated with 24 bits/pixel instead \n"
1637 " of 96, and ReadImage will produce delayed color images \n"
1638 " if supported by the format. (default = precision)\n"
1639 "\n"
1640 " -memory #Mbytes set the amount of memory the exec uses\n"
1641 " -processors #proc set the number of processors the exec uses \n"
1642 " (SMP versions only)\n"
1643 " -log [on|off] executive and ui logging: (default = off)\n"
1644 " -cache [on|off] executive cache: (default = on)\n"
1645 " -trace [on|off] executive trace: (default = off)\n"
1646 " -readahead [on|off] executive readahead: (default = on)\n"
1647 " -timing [on|off] module timing: (default = off)\n"
1648 " -highlight [on|off] node execution highlighting: (default = on)\n"
1649 " -directory dirname cd to this directory before starting exec\n"
1650 " -display hostname:0 set X display destination\n"
1651 " -metric have the UI use metric units when possible\n"
1652 "\n"
1653 " -exec filename execute this user executive\n"
1654 " -mdf filename use this user .mdf file\n"
1655 "\n"
1656 " -key <64bit hex> 16 character hexidecimal (64 bit) number that is used\n"
1657 " to encode and decode .net files.\n"
1658 " -encode Encode a .net file into a binary format with a key \n"
1659 " that must be specified with the -key option. \n"
1660 " For example, \n"
1661 " dx -encode -key 193495946952abed foo.net \n"
1662 " The resulting file can only be decoded by the DX\n"
1663 " user interface when using the same -key option.\n"
1664 " For example, \n"
1665 " dx -key 193495946952abed bar.net \n"
1666 "\n"
1667 " -dxroot dirname dx root directory; defaults to /usr/lpp/dx\n"
1668 "\n"
1669 " -macros pathlist directory list to search for UI macros\n"
1670 " -data pathlist directory list to search for data files\n"
1671 " -include pathlist directory list to search for script files\n"
1672 " -modules pathlist directory list to search for outboard modules\n"
1673 "\n"
1674 " -colors filename replace default color names/RGB values file\n"
1675 " -8bitcmap [private|shared|0-1|-1]\n"
1676 " private/shared colormap error threshold (default=0.1)\n"
1677 " -1 is equivalent to private.\n"
1678 " -hwrender [gl|opengl] \n"
1679 " override default hardware rendering library on platforms\n"
1680 " where both are supported. (default = opengl).\n"
1681 "\n"
1682 " -verbose echo command lines before executing\n"
1683 " -echo echo the command lines without executing them\n"
1684 " -outboarddebug let user start outboard modules by hand\n"
1685 " -version show version numbers of dxexec, dxui, dx.exe, and X server\n"
1686 " -synchronous force synchronization of X events between dx and the x server\n"
1687 "\n"
1688 " -help print a short help message\n"
1689 " -morehelp print this help message\n"
1690 "\n"
1691 "environment variables:\n"
1692 " DXHOST sets hostname for -host\n"
1693 "\n"
1694 " DXPROCESSORS sets number of processors for multiprocessor DX\n"
1695 " DXMEMORY sets memory limit in megabytes\n"
1696 " DXAXESMAXWIDTH sets the maximum number of digits in axes tick labels\n"
1697 " before a switch to scientific notation is made\n"
1698 " DXDEFAULTIMAGEFORMAT Sets the image type to either 24-bit color or floating\n"
1699 " point color (96-bit) images depending on the value\n"
1700 " DXByte (24-bit) or DXFloat (96-bit)\n"
1701 " DXDELAYEDCOLORS If set to anything other than 0, enables ReadImage to\n"
1702 " created delayed color images if the image is stored in\n"
1703 " a tiff byte-with-colormap format or a gif image\n"
1704 " DX_NESTED_LOOPS For faces, loops, and edges data, if set, allows loops\n"
1705 " other than the enclosing loop for a face to be listed\n"
1706 " first, with a consequent decrease in performance\n"
1707 " DXPIXELTYPE Sets the image type to either 24-bit color or floating\n"
1708 " point (96-bit) color. This affects the behavior of\n"
1709 " Render and ReadImage. This can be set to either DXByte\n"
1710 " or DXFloat (default).\n"
1711 " DX_USER_INTERACTOR_FILE Specifies a file containing user interactors for use by\n"
1712 " the SuperviseState and SuperviseWindow modules\n"
1713 "\n"
1714 " DXEXEC sets filename for -exec\n"
1715 " DXMDF sets filename for -mdf\n"
1716 "\n"
1717 " DXMACROS sets pathlist for -macros\n"
1718 " DXDATA sets pathlist for -data\n"
1719 " DXINCLUDE sets pathlist for -include\n"
1720 " DXMODULES sets pathlist for -modules\n"
1721 "\n"
1722 " DXCOLORS sets filename for -colors\n"
1723 " DX8BITCMAP sets threshold for -8bitcmap\n"
1724 "\n"
1725 " DXGAMMA sets gamma correction for displayed images. Default is 2.\n"
1726 " DXGAMMA_8BIT\n"
1727 " DXGAMMA_12BIT\n"
1728 " DXGAMMA_24BIT sets the gamma correction factor for the windows with \n"
1729 " the indicated window depth. Overrides the value set \n"
1730 " by DXGAMMA.\n"
1731 "\n"
1732 " DXHWMOD specifies the name of the hardware rendering library \n"
1733 " to use when more than one is supported. Should be\n"
1734 " either DXhwdd.o or DXhwddOGL.o\n"
1735 "\n"
1736 " DXROOT sets directory for -dxroot\n"
1737 "\n"
1738 " DXARGS prepends these args to the command line\n"
1739 "\n"
1740 "command line parameters override environment variables.\n"
1741 "If conflicting parameters are given, the last one has precedence.\n"
1742 "Also, there are some other less frequently used command line options\n"
1743 "that are not documented here. See the User's Guide for a complete\n"
1744 "list of options.\n"
1745 "\n"
1746
1747
1748 );
1749
1750 exit(0);
1751 }
1752 #endif
1753