1 | /**************************************** |
---|
2 | * Computer Algebra System SINGULAR * |
---|
3 | ****************************************/ |
---|
4 | /* $Id: tesths.cc,v 1.8 1997-04-25 15:04:07 obachman Exp $ */ |
---|
5 | |
---|
6 | /* |
---|
7 | * ABSTRACT - initialize SINGULARs components, run Script and start SHELL |
---|
8 | */ |
---|
9 | |
---|
10 | #ifndef macintosh |
---|
11 | #include <unistd.h> |
---|
12 | #endif |
---|
13 | #include <string.h> |
---|
14 | #include <stdio.h> |
---|
15 | #include <stddef.h> |
---|
16 | #include <stdlib.h> |
---|
17 | #include <time.h> |
---|
18 | #include <errno.h> |
---|
19 | #include "version.h" |
---|
20 | #include "mod2.h" |
---|
21 | #include "tok.h" |
---|
22 | #include "ipshell.h" |
---|
23 | #include "febase.h" |
---|
24 | #include "cntrlc.h" |
---|
25 | #include "mmemory.h" |
---|
26 | #include "silink.h" |
---|
27 | #include "timer.h" |
---|
28 | |
---|
29 | |
---|
30 | /*0 implementation*/ |
---|
31 | int main( /* main entry to Singular */ |
---|
32 | int argc, /* number of parameter */ |
---|
33 | char** argv) /* parameter array */ |
---|
34 | { |
---|
35 | /* initialize components */ |
---|
36 | siRandomStart=inits(); |
---|
37 | #ifdef INIT_BUG |
---|
38 | jjInitTab1(); |
---|
39 | #endif |
---|
40 | #ifdef GENTABLE |
---|
41 | extern ttGen1(); |
---|
42 | extern ttGen2(); |
---|
43 | #ifdef HAVE_MPSR |
---|
44 | extern mpsr_ttGen(); // For initialization of (CMD, MP_COP) tables |
---|
45 | mpsr_ttGen(); |
---|
46 | #endif |
---|
47 | ttGen1(); |
---|
48 | ttGen2(); |
---|
49 | #else |
---|
50 | int i; |
---|
51 | char * thisfile = argv[0]; |
---|
52 | /*. process parameters */ |
---|
53 | for (;(argc > 1) && (!feBatch); --argc, ++argv) |
---|
54 | { |
---|
55 | if (strcmp(argv[1], "-m") == 0) |
---|
56 | { |
---|
57 | { |
---|
58 | if (argc > 2) |
---|
59 | { |
---|
60 | char* ptr = NULL; |
---|
61 | #ifdef HAVE_STRTOD |
---|
62 | double mintime = strtod(argv[2], &ptr); |
---|
63 | if (errno != ERANGE && ptr != argv[2]) |
---|
64 | #else |
---|
65 | double mintime = 0.0; |
---|
66 | sscanf(argv[2],"%f", &mintime); |
---|
67 | if (mintime != 0.0) |
---|
68 | #endif |
---|
69 | { |
---|
70 | argc--; |
---|
71 | argv++; |
---|
72 | SetMinDisplayTime(mintime); |
---|
73 | } |
---|
74 | else |
---|
75 | printf("Can not convert %s to a float\n", argv[2]); |
---|
76 | } |
---|
77 | else |
---|
78 | { |
---|
79 | printf("Need a float to set mintime"); |
---|
80 | } |
---|
81 | } |
---|
82 | } |
---|
83 | else if (strcmp(argv[1], "-d") == 0) |
---|
84 | { |
---|
85 | if (argc > 2) |
---|
86 | { |
---|
87 | char* ptr = NULL; |
---|
88 | #ifdef HAVE_STRTOL |
---|
89 | long res = strtol(argv[2], &ptr, 10); |
---|
90 | if (errno != ERANGE && ptr != argv[2]) |
---|
91 | #else |
---|
92 | long res = 0; |
---|
93 | sscanf(argv[2],"%d", &res); |
---|
94 | if (res != 0) |
---|
95 | #endif |
---|
96 | { |
---|
97 | argc--; |
---|
98 | argv++; |
---|
99 | SetTimerResolution(res); |
---|
100 | } |
---|
101 | else |
---|
102 | printf("Can not convert %s to an integer\n", argv[2]); |
---|
103 | } |
---|
104 | else |
---|
105 | { |
---|
106 | printf("Need an integer to set timer resolution"); |
---|
107 | } |
---|
108 | } |
---|
109 | else |
---|
110 | { |
---|
111 | |
---|
112 | if ((argv[1][0] != '-') ||(argv[1][1] == '-')) |
---|
113 | break; |
---|
114 | for (i=1;argv[1][i]!='\0';i++) |
---|
115 | { |
---|
116 | switch (argv[1][i]) |
---|
117 | { |
---|
118 | case 'V': |
---|
119 | case 'v':{ |
---|
120 | printf("Singular %s %s(%d) %s %s\n", |
---|
121 | S_VERSION1,S_VERSION2, |
---|
122 | VERSION_ID,__DATE__,__TIME__); |
---|
123 | printf("with "); |
---|
124 | #ifdef HAVE_FACTORY |
---|
125 | printf("factory,"); |
---|
126 | #endif |
---|
127 | #ifdef HAVE_FACTORY |
---|
128 | printf("fac(p),"); |
---|
129 | #endif |
---|
130 | #ifdef SRING |
---|
131 | printf("super algebra,"); |
---|
132 | #endif |
---|
133 | #ifdef DRING |
---|
134 | printf("Weyl algebra,"); |
---|
135 | #endif |
---|
136 | #ifdef HAVE_GMP |
---|
137 | printf("GMP,"); |
---|
138 | #endif |
---|
139 | #ifdef HAVE_DBM |
---|
140 | printf("DBM,"); |
---|
141 | #endif |
---|
142 | #ifdef HAVE_MPSR |
---|
143 | printf("MP,"); |
---|
144 | #endif |
---|
145 | #if defined(HAVE_READLINE) && !defined(FEREAD) |
---|
146 | printf("RL,"); |
---|
147 | #endif |
---|
148 | #ifdef HAVE_FEREAD |
---|
149 | printf("SRL,"); |
---|
150 | #endif |
---|
151 | #ifdef TEST |
---|
152 | printf("TESTs,"); |
---|
153 | #endif |
---|
154 | #if YYDEBUG |
---|
155 | printf("YYDEBUG,"); |
---|
156 | #endif |
---|
157 | #ifdef MDEBUG |
---|
158 | printf("MDEBUG=%d,",MDEBUG); |
---|
159 | #endif |
---|
160 | #ifndef __OPTIMIZE__ |
---|
161 | printf("-g,"); |
---|
162 | #endif |
---|
163 | printf("random=%d\n",siRandomStart); |
---|
164 | #ifdef MSDOS |
---|
165 | char *p=getenv("SPATH"); |
---|
166 | #else |
---|
167 | char *p=getenv("SINGULARPATH"); |
---|
168 | #endif |
---|
169 | if (p!=NULL) |
---|
170 | printf("search path:%s:%s\n\n",p,SINGULAR_DATADIR); |
---|
171 | else |
---|
172 | printf("search path:%s\n\n", SINGULAR_DATADIR); |
---|
173 | break; |
---|
174 | } |
---|
175 | case 'e': if ((argv[1][i+1]>'0') && (argv[1][i+1]<='9')) |
---|
176 | { |
---|
177 | i++; |
---|
178 | si_echo = (int)(argv[1][i] - '0'); |
---|
179 | } |
---|
180 | else si_echo = 2; |
---|
181 | break; |
---|
182 | case 'r': siRandomStart = 0; |
---|
183 | while((argv[1][i+1]>='0') && (argv[1][i+1]<='9')) |
---|
184 | { |
---|
185 | i++; |
---|
186 | siRandomStart = siRandomStart*10+(int)(argv[1][i] - '0'); |
---|
187 | } |
---|
188 | #ifdef buildin_rand |
---|
189 | siSeed=siRandomStart; |
---|
190 | #else |
---|
191 | srand((unsigned int)siRandomStart); |
---|
192 | #endif |
---|
193 | break; |
---|
194 | case 'x': tclmode=TRUE; |
---|
195 | break; |
---|
196 | #ifdef HAVE_MPSR |
---|
197 | case 'b': feBatch=TRUE; |
---|
198 | #endif |
---|
199 | case 'q': verbose &= ~(Sy_bit(0)|Sy_bit(V_LOAD_LIB)); |
---|
200 | break; |
---|
201 | case 't': |
---|
202 | #ifdef HAVE_FEREAD |
---|
203 | fe_use_fgets=TRUE; |
---|
204 | #endif |
---|
205 | break; |
---|
206 | default : printf("Unknown option -%c\n",argv[1][i]); |
---|
207 | printf("Usage: %s [-bteqvx] [file]\n",thisfile); |
---|
208 | exit(1); |
---|
209 | } |
---|
210 | } |
---|
211 | } |
---|
212 | } |
---|
213 | |
---|
214 | |
---|
215 | /*. say hello */ |
---|
216 | if (BVERBOSE(0)) |
---|
217 | { |
---|
218 | printf( |
---|
219 | " Welcome to SINGULAR /\n" |
---|
220 | " A Computer Algebra System o<\n" |
---|
221 | " for Algebraic Geometry and Singularity Theory \\\n\n" |
---|
222 | "by: G.-M. Greuel, G. Pfister, H. Schoenemann\n" |
---|
223 | "Fachbereich Mathematik der Universitaet, D-67653 Kaiserslautern\n" |
---|
224 | "contributions: O.Bachmann,W.Decker,H.Grassmann,B.Martin,M.Messollen,W.Neumann,\n" |
---|
225 | "W.Pohl,T.Siebert,R.Stobbe e-mail: singular@mathematik.uni-kl.de\n"); |
---|
226 | printf("%s%c %s",S_VERSION1,VERSION%10+'a',S_VERSION2); |
---|
227 | printf(" (%d)\n\nPlease note: EVERY COMMAND MUST END WITH A SEMICOLON \";" |
---|
228 | "\"\n(e.g. help; help command; help General syntax; help ring; quit;)\n\n", |
---|
229 | VERSION_ID); |
---|
230 | } |
---|
231 | else |
---|
232 | if (!feBatch) |
---|
233 | { |
---|
234 | #ifdef macintosh |
---|
235 | memcpy(stderr,stdout,sizeof(FILE)); |
---|
236 | #else |
---|
237 | dup2(1,2); |
---|
238 | #endif |
---|
239 | } |
---|
240 | slStandardInit(); |
---|
241 | #ifdef HAVE_DLD |
---|
242 | dlInit(thisfile); |
---|
243 | #endif |
---|
244 | myynest=0; |
---|
245 | /* if script is given */ |
---|
246 | if ((argc > 1)&&(argv[1][0]!='-')) |
---|
247 | { |
---|
248 | /* read and run the Script */ |
---|
249 | iiPStart(NULL,argv[1],NULL); |
---|
250 | } |
---|
251 | /* start shell */ |
---|
252 | if (feBatch) |
---|
253 | { |
---|
254 | #ifdef HAVE_MPSR |
---|
255 | extern int Batch_do(int argc, char **argv); |
---|
256 | return Batch_do(argc,argv); |
---|
257 | #else |
---|
258 | fprintf(stderr, "Option -b not supported in this version"); |
---|
259 | return 1; |
---|
260 | #endif // HAVE_MPSR |
---|
261 | } |
---|
262 | #ifndef macintosh |
---|
263 | #if defined(HAVE_FEREAD) || defined(HAVE_READLINE) |
---|
264 | fe_set_input_mode(); |
---|
265 | #endif |
---|
266 | #endif |
---|
267 | yyparse(); |
---|
268 | #endif |
---|
269 | return 0; |
---|
270 | } |
---|