1 /**********
2 Copyright 1990 Regents of the University of California. All rights reserved.
3 Author: 1986 Wayne A. Christopher, U. C. Berkeley CAD Group
4 **********/
5
6 /*
7 * The main routine for the help system in stand-alone mode.
8 */
9
10 #include "ngspice/ngspice.h"
11 #include "ngspice/cpdefs.h"
12 #include "ngspice/hlpdefs.h"
13
14 #include "frontend/variable.h"
15
16 #include "misc/tilde.h"
17
18 #ifndef X_DISPLAY_MISSING
19 Widget toplevel;
20 #endif
21
22
23 FILE *cp_in, *cp_out, *cp_err;
24
25
26 /* dummy declaration so CP.a doesn't pull in lexical.o and other objects */
27 bool cp_interactive = FALSE;
28
29 char *hlp_filelist[] = { "ngspice", 0 };
30
31 extern void ivars(char*);
32
33 #ifdef HAS_WINGUI
34 FILE *flogp; /* hvogt 15.12.2001 */
35 #endif /* HAS_WINGUI */
36
37 int
38 #ifdef HAS_WINGUI
xmain(int ac,char ** av)39 xmain(int ac, char **av)
40 #else
41 main(int ac, char **av)
42 #endif /* HAS_WINGUI */
43 {
44 wordlist *wl = NULL;
45
46 #ifndef X_DISPLAY_MISSING
47 char *displayname;
48 /* grrr, Xtk forced contortions */
49 char *argv[2];
50 int argc = 2;
51 char buf[512];
52 #endif /* X_DISPLAY_MISSING */
53
54 ivars(NULL);
55
56 cp_in = stdin;
57 cp_out = stdout;
58 cp_err = stderr;
59
60 #ifndef X_DISPLAY_MISSING
61
62 if (cp_getvar("display", CP_STRING, buf, sizeof(buf))) {
63 displayname = buf;
64 } else if (!(displayname = getenv("DISPLAY"))) {
65 fprintf(stderr, "Can't open X display.");
66 goto out;
67 }
68
69 argv[0] = "nutmeg";
70 argv[1] = displayname;
71 /* initialize X toolkit */
72 toplevel = XtInitialize("nutmeg", "Nutmeg", NULL, 0, &argc, argv);
73
74 out:
75 #endif /* X_DISPLAY_MISSING */
76
77 if (ac > 1)
78 wl = wl_build(av + 1);
79 hlp_main(Help_Path, wl);
80
81 #ifndef X_DISPLAY_MISSING
82 if (hlp_usex) {
83 printf("Hit control-C when done.\n"); /* sigh */
84 XtMainLoop();
85 }
86 #endif /* X_DISPLAY_MISSING */
87
88 #ifdef HAS_WINGUI
89 /* Keep window open untill a key is pressed */
90 printf("Press a key to quit\n");
91 while( getchar() == EOF) {}
92 #endif /* HAS_WINGUI */
93
94 return EXIT_NORMAL;
95 }
96 /*
97 void
98 fatal(char *s)
99 {
100 fprintf(stderr, "fatal error: %s\n", s);
101 exit(1);
102 }
103
104 There is a conflict with another cp_printword in cp/quote.c
105 static void
106 cp_printword(s)
107 char *s;
108 {
109 printf("%s", s);
110 return;
111 }
112
113 */
114
115 bool
cp_getvar(char * n,enum cp_types type,void * r,size_t rs)116 cp_getvar(char *n, enum cp_types type, void *r, size_t rs)
117 {
118 return (FALSE);
119 }
120
121 char *
cp_tildexpand(const char * s)122 cp_tildexpand(const char *s)
123 {
124 return tildexpand(s);
125 }
126
127 void
controlled_exit(int status)128 controlled_exit(int status) { exit(status); }
129