1 | /**************************************** |
---|
2 | * Computer Algebra System SINGULAR * |
---|
3 | ****************************************/ |
---|
4 | /* $Id: tesths.cc,v 1.41 1998-05-08 12:23:42 obachman Exp $ */ |
---|
5 | |
---|
6 | /* |
---|
7 | * ABSTRACT - initialize SINGULARs components, run Script and start SHELL |
---|
8 | */ |
---|
9 | |
---|
10 | #include <unistd.h> |
---|
11 | #include <string.h> |
---|
12 | #include <stdio.h> |
---|
13 | #include <stddef.h> |
---|
14 | #include <stdlib.h> |
---|
15 | #include <time.h> |
---|
16 | #include <errno.h> |
---|
17 | #include "version.h" |
---|
18 | #include "mod2.h" |
---|
19 | #include "tok.h" |
---|
20 | #include "ipshell.h" |
---|
21 | #include "sing_dld.h" |
---|
22 | #include "febase.h" |
---|
23 | #include "cntrlc.h" |
---|
24 | #include "mmemory.h" |
---|
25 | #include "silink.h" |
---|
26 | #include "ipid.h" |
---|
27 | #include "timer.h" |
---|
28 | #ifdef HAVE_FACTORY |
---|
29 | #define SI_DONT_HAVE_GLOBAL_VARS |
---|
30 | #include <factory.h> |
---|
31 | #endif |
---|
32 | |
---|
33 | #include "getopt.h" |
---|
34 | |
---|
35 | // define the long option names here |
---|
36 | #define LON_BATCH "batch" |
---|
37 | #define LON_EXECUTE "execute" |
---|
38 | #define LON_ECHO "echo" |
---|
39 | #define LON_HELP "help" |
---|
40 | #define LON_RANDOM "random" |
---|
41 | #define LON_QUIET "quiet" |
---|
42 | #define LON_NO_TTY "no-tty" |
---|
43 | #define LON_USER_OPTION "user-option" |
---|
44 | #define LON_VERSION "verbose" |
---|
45 | #define LON_MIN_TIME "min-time" |
---|
46 | #define LON_NO_STDLIB "no-stdlib" |
---|
47 | #define LON_NO_RC "no-rc" |
---|
48 | #define LON_TICKS_PER_SEC "ticks-per-sec" |
---|
49 | #define LON_TCLMODE "tclmode" |
---|
50 | #define LON_MP_PORT "MPport" |
---|
51 | #define LON_MP_HOST "MPhost" |
---|
52 | // undocumented options |
---|
53 | #ifdef HAVE_MPSR |
---|
54 | #define LON_MP_TRANSP "MPtransp" |
---|
55 | #define LON_MP_MODE "MPmode" |
---|
56 | #endif |
---|
57 | |
---|
58 | #define LONG_OPTION_RETURN 13 |
---|
59 | static struct option longopts[] = |
---|
60 | { |
---|
61 | #ifdef HAVE_MPSR |
---|
62 | {LON_BATCH, 0, 0, 'b'}, |
---|
63 | #endif |
---|
64 | {LON_EXECUTE, 1, 0, 'c'}, |
---|
65 | {LON_ECHO, 2, 0, 'e'}, |
---|
66 | {LON_HELP, 0, 0, 'h'}, |
---|
67 | {LON_QUIET, 0, 0, 'q'}, |
---|
68 | {LON_RANDOM, 1, 0, 'r'}, |
---|
69 | {LON_NO_TTY, 0, 0, 't'}, |
---|
70 | {LON_USER_OPTION, 1, 0, 'u'}, |
---|
71 | {LON_VERSION, 0, 0, 'v'}, |
---|
72 | #ifdef HAVE_TCL |
---|
73 | {LON_TCLMODE, 0, 0, 'x'}, |
---|
74 | #endif |
---|
75 | {LON_NO_STDLIB, 0, 0, LONG_OPTION_RETURN}, |
---|
76 | {LON_NO_RC, 0, 0, LONG_OPTION_RETURN}, |
---|
77 | {LON_MIN_TIME, 1, 0, LONG_OPTION_RETURN}, |
---|
78 | #ifdef HAVE_MPSR |
---|
79 | {LON_MP_PORT, 1, 0, LONG_OPTION_RETURN}, |
---|
80 | {LON_MP_HOST, 1, 0, LONG_OPTION_RETURN}, |
---|
81 | #endif |
---|
82 | {LON_TICKS_PER_SEC, 1, 0, LONG_OPTION_RETURN}, |
---|
83 | // undocumented options |
---|
84 | #ifdef HAVE_MPSR |
---|
85 | {LON_MP_TRANSP, 1, 0, LONG_OPTION_RETURN}, |
---|
86 | {LON_MP_MODE, 1, 0, LONG_OPTION_RETURN}, |
---|
87 | #endif |
---|
88 | // terminator |
---|
89 | { 0, 0, 0, 0 } |
---|
90 | }; |
---|
91 | // #define SHORT_OPTS_STRING "bc:e::hqr:tu:v" |
---|
92 | #define SHORT_OPTS_STRING "bhqtvxec:r:u:" |
---|
93 | |
---|
94 | struct sing_option |
---|
95 | { |
---|
96 | const char* name; // as in option |
---|
97 | const char* arg_name;// name of argument, if has_arg > 0 |
---|
98 | const char* help; // (short) help string |
---|
99 | char* val; // (default) value of option: 0: not set 1:set |
---|
100 | // string:"" if has_arg > 0 |
---|
101 | }; |
---|
102 | |
---|
103 | // mention only documented options here |
---|
104 | static struct sing_option sing_longopts[] = |
---|
105 | { |
---|
106 | #ifdef HAVE_MPSR |
---|
107 | {LON_BATCH, 0, "Run in MP batch mode", 0}, |
---|
108 | #endif |
---|
109 | {LON_HELP, 0, "Print help message and exit", 0}, |
---|
110 | {LON_QUIET, 0, "Do not print start-up banner and warnings", 0}, |
---|
111 | {LON_NO_TTY, 0, "Do not redefine the terminal characteristics", 0}, |
---|
112 | {LON_VERSION, 0, "Print extended version and configuration info", 0}, |
---|
113 | #ifdef HAVE_TCL |
---|
114 | {LON_TCLMODE 0, "Run in TCL mode, i.e., with TCL user interface", 0}, |
---|
115 | #endif |
---|
116 | {LON_ECHO, "VAL", "Set value of variable `echo' to (integer) VAL", ""}, |
---|
117 | {LON_EXECUTE, "STRING", "Execute STRING on start-up", ""}, |
---|
118 | {LON_RANDOM, "SEED", "Seed random generator with integer (integer) SEED", ""}, |
---|
119 | {LON_USER_OPTION, "STRING", "Return STRING on `system(\"--user-option\")'", ""}, |
---|
120 | {LON_NO_STDLIB, 0, "Do not load `standard.lib' on start-up", 0}, |
---|
121 | {LON_NO_RC, 0, "Do not execute `.singularrc' file on start-up", 0}, |
---|
122 | {LON_MIN_TIME, "SECS", "Do not display times smaller than SECS (in seconds)", "0.5"}, |
---|
123 | #ifdef HAVE_MPSR |
---|
124 | {LON_MP_PORT, "PORT", "Use PORT number for MP conections", ""}, |
---|
125 | {LON_MP_HOST, "HOST", "Use HOST for MP connections", ""}, |
---|
126 | #endif |
---|
127 | {LON_TICKS_PER_SEC, "TICKS", "Sets unit of timer to TICKS per second", "1"}, |
---|
128 | { 0, 0, 0, 0 } |
---|
129 | }; |
---|
130 | |
---|
131 | static struct sing_option* mainGetSingOption(const char* name) |
---|
132 | { |
---|
133 | int i = 0; |
---|
134 | while (sing_longopts[i].name != 0) |
---|
135 | { |
---|
136 | if (strcmp(name, sing_longopts[i].name) == 0) |
---|
137 | return &(sing_longopts[i]); |
---|
138 | i++; |
---|
139 | } |
---|
140 | return NULL; |
---|
141 | } |
---|
142 | |
---|
143 | static void mainSetSingOptionValue(const char* name, char* value) |
---|
144 | { |
---|
145 | sing_option* sopt = mainGetSingOption(name); |
---|
146 | if (sopt != NULL) |
---|
147 | { |
---|
148 | sopt->val = value; |
---|
149 | } |
---|
150 | } |
---|
151 | |
---|
152 | |
---|
153 | static char* mainGetSingOptionValue(const char* name) |
---|
154 | { |
---|
155 | sing_option* sopt = mainGetSingOption(name); |
---|
156 | if (sopt!=NULL) |
---|
157 | return sopt->val; |
---|
158 | return NULL; |
---|
159 | } |
---|
160 | |
---|
161 | |
---|
162 | // Prints help message |
---|
163 | static void mainHelp(const char* name) |
---|
164 | { |
---|
165 | int i = 0; |
---|
166 | struct sing_option *sopt; |
---|
167 | char tmp[20]; |
---|
168 | |
---|
169 | printf("Singular %s -- a CAS for polynomial computations. Usage:\n", S_VERSION1); |
---|
170 | printf(" %s [options] [file1 [file2 ...]]\n", name); |
---|
171 | printf("Options:\n"); |
---|
172 | |
---|
173 | while (longopts[i].name != 0) |
---|
174 | { |
---|
175 | sopt = mainGetSingOption(longopts[i].name); |
---|
176 | if (sopt != NULL) |
---|
177 | { |
---|
178 | if (longopts[i].has_arg > 0) |
---|
179 | { |
---|
180 | if (longopts[i].has_arg > 1) |
---|
181 | sprintf(tmp, "%s[=%s]", longopts[i].name, sopt->arg_name); |
---|
182 | else |
---|
183 | sprintf(tmp, "%s=%s", longopts[i].name, sopt->arg_name); |
---|
184 | |
---|
185 | printf(" %c%c --%-19s %s\n", |
---|
186 | (longopts[i].val != 0 ? '-' : ' '), |
---|
187 | (longopts[i].val != 0 ? longopts[i].val : ' '), |
---|
188 | tmp, |
---|
189 | sopt->help); |
---|
190 | } |
---|
191 | else |
---|
192 | { |
---|
193 | printf(" %c%c --%-19s %s\n", |
---|
194 | (longopts[i].val != 0 ? '-' : ' '), |
---|
195 | (longopts[i].val != 0 ? longopts[i].val : ' '), |
---|
196 | longopts[i].name, |
---|
197 | sopt->help); |
---|
198 | } |
---|
199 | } |
---|
200 | #ifndef NDEBUG |
---|
201 | else |
---|
202 | printf("--%s Undocumented\n", longopts[i].name); |
---|
203 | #endif |
---|
204 | i++; |
---|
205 | } |
---|
206 | |
---|
207 | printf("\nFor more information, type `help;' from within Singular or visit\n"); |
---|
208 | printf("http://www.mathematik.uni-kl.de/~zca/Singular or consult the\n"); |
---|
209 | printf("Singular manual (available as on-line info or printed manual).\n"); |
---|
210 | } |
---|
211 | |
---|
212 | // Prints usage message |
---|
213 | static void mainUsage(char* argv0) |
---|
214 | { |
---|
215 | printf("Use `%s --help' for a complete list of options\n", argv0); |
---|
216 | } |
---|
217 | |
---|
218 | #ifndef NDEBUG |
---|
219 | void mainOptionValues() |
---|
220 | { |
---|
221 | int i = 0; |
---|
222 | struct sing_option *sopt; |
---|
223 | |
---|
224 | while (longopts[i].name != 0) |
---|
225 | { |
---|
226 | sopt = mainGetSingOption(longopts[i].name); |
---|
227 | if (sopt != NULL) |
---|
228 | { |
---|
229 | if (sopt->val == NULL || sopt->val == (char*) 1) |
---|
230 | Print("// --%-10s %d\n", sopt->name, sopt->val); |
---|
231 | else |
---|
232 | Print("// --%-10s %s\n", sopt->name, sopt->val); |
---|
233 | } |
---|
234 | else |
---|
235 | Print("// --%s Undocumented \n", longopts[i].name); |
---|
236 | i++; |
---|
237 | } |
---|
238 | } |
---|
239 | #endif // NDEBUG |
---|
240 | |
---|
241 | BOOLEAN mainGetSingOptionValue(const char* name, char** val) |
---|
242 | { |
---|
243 | sing_option* sopt = mainGetSingOption(name); |
---|
244 | if (sopt == NULL) |
---|
245 | { |
---|
246 | *val = NULL; |
---|
247 | return FALSE; |
---|
248 | } |
---|
249 | else |
---|
250 | { |
---|
251 | *val = sopt->val; |
---|
252 | return TRUE; |
---|
253 | } |
---|
254 | } |
---|
255 | |
---|
256 | /*0 implementation*/ |
---|
257 | int main( /* main entry to Singular */ |
---|
258 | int argc, /* number of parameter */ |
---|
259 | char** argv) /* parameter array */ |
---|
260 | { |
---|
261 | char * thisfile; |
---|
262 | /* initialize components */ |
---|
263 | siRandomStart=inits(); |
---|
264 | #ifdef INIT_BUG |
---|
265 | jjInitTab1(); |
---|
266 | #endif |
---|
267 | #ifdef GENTABLE |
---|
268 | extern void ttGen1(); |
---|
269 | extern void ttGen2(); |
---|
270 | #ifndef __MWERKS__ |
---|
271 | extern mpsr_ttGen(); // For initialization of (CMD, MP_COP) tables |
---|
272 | mpsr_ttGen(); |
---|
273 | #endif |
---|
274 | ttGen1(); |
---|
275 | ttGen2(); |
---|
276 | #else |
---|
277 | int i; |
---|
278 | thisfile = argv[0]; |
---|
279 | BOOLEAN load_std_lib=TRUE; |
---|
280 | BOOLEAN load_rc = TRUE; |
---|
281 | char* execute_string = NULL; |
---|
282 | int optc, option_index; |
---|
283 | |
---|
284 | // do this first, because -v might print version path |
---|
285 | feGetSearchPath(thisfile); |
---|
286 | |
---|
287 | // parse command line options |
---|
288 | while((optc = getopt_long(argc, argv, |
---|
289 | SHORT_OPTS_STRING, longopts, &option_index)) |
---|
290 | != EOF) |
---|
291 | { |
---|
292 | switch(optc) |
---|
293 | { |
---|
294 | |
---|
295 | case 'b': |
---|
296 | #ifdef HAVE_MPSR |
---|
297 | feBatch=TRUE; |
---|
298 | mainSetSingOptionValue(LON_BATCH, (char*) 1); |
---|
299 | break; |
---|
300 | #else |
---|
301 | printf("%s: Option `-b' not supported in this configuration\n", argv[0]); |
---|
302 | mainUsage(argv[0]); |
---|
303 | exit(1); |
---|
304 | #endif |
---|
305 | |
---|
306 | case 'h': |
---|
307 | mainHelp(argv[0]); |
---|
308 | exit(0); |
---|
309 | |
---|
310 | case 'q': |
---|
311 | verbose &= ~(Sy_bit(0)|Sy_bit(V_LOAD_LIB)); |
---|
312 | mainSetSingOptionValue(LON_QUIET, (char*) 1); |
---|
313 | break; |
---|
314 | |
---|
315 | case 't': |
---|
316 | #if defined(HAVE_FEREAD) || defined(HAVE_READLINE) |
---|
317 | fe_use_fgets=TRUE; |
---|
318 | #endif |
---|
319 | mainSetSingOptionValue(LON_NO_TTY, (char*) 1); |
---|
320 | break; |
---|
321 | |
---|
322 | case 'v': |
---|
323 | printf("Singular %s %s (%d) %s %s\n", |
---|
324 | S_VERSION1,S_VERSION2, |
---|
325 | SINGULAR_VERSION_ID,__DATE__,__TIME__); |
---|
326 | printf("with\n"); |
---|
327 | printf(versionString()); |
---|
328 | printf("\n\n"); |
---|
329 | mainSetSingOptionValue(LON_VERSION, (char*) 1); |
---|
330 | break; |
---|
331 | |
---|
332 | case 'x': |
---|
333 | #ifdef HAVE_TCL |
---|
334 | tclmode = TRUE; |
---|
335 | mainSetSingOptionValue(LON_TCL-MODE, (char*) 1); |
---|
336 | break; |
---|
337 | #else |
---|
338 | printf("%s: Option `-x' not supported in this configuration\n", argv[0]); |
---|
339 | mainUsage(argv[0]); |
---|
340 | exit(1); |
---|
341 | #endif |
---|
342 | |
---|
343 | case 'e': |
---|
344 | if (optarg != NULL) |
---|
345 | { |
---|
346 | errno = 0; |
---|
347 | si_echo = strtol(optarg, NULL, 10); |
---|
348 | if (errno) |
---|
349 | { |
---|
350 | printf("%s: `%s' invalid integer argument for option `--%s'\n", argv[0], optarg, LON_ECHO); |
---|
351 | mainUsage(argv[0]); |
---|
352 | exit(1); |
---|
353 | } |
---|
354 | if (si_echo < 0 || si_echo > 9) |
---|
355 | { |
---|
356 | printf("%s: `%s' argument for option `--%s' is not in valid range 0..9\n", |
---|
357 | argv[0], optarg, LON_ECHO); |
---|
358 | mainUsage(argv[0]); |
---|
359 | exit(1); |
---|
360 | } |
---|
361 | mainSetSingOptionValue(LON_ECHO, optarg); |
---|
362 | } |
---|
363 | else |
---|
364 | { |
---|
365 | si_echo = 1; |
---|
366 | mainSetSingOptionValue(LON_ECHO, "1"); |
---|
367 | } |
---|
368 | break; |
---|
369 | |
---|
370 | case 'c': |
---|
371 | execute_string = optarg; |
---|
372 | mainSetSingOptionValue(LON_EXECUTE, optarg); |
---|
373 | break; |
---|
374 | |
---|
375 | case 'r': |
---|
376 | errno = 0; |
---|
377 | siRandomStart = strtol(optarg, NULL, 10); |
---|
378 | if (errno || siRandomStart == 0) |
---|
379 | { |
---|
380 | printf("%s: `%s' invalid integer argument for option `--%s'\n", argv[0], optarg, LON_RANDOM); |
---|
381 | mainUsage(argv[0]); |
---|
382 | exit(1); |
---|
383 | } |
---|
384 | #ifdef buildin_rand |
---|
385 | siSeed=siRandomStart; |
---|
386 | #else |
---|
387 | srand((unsigned int)siRandomStart); |
---|
388 | #endif |
---|
389 | #ifdef HAVE_FACTORY |
---|
390 | factoryseed(siRandomStart); |
---|
391 | #endif |
---|
392 | mainSetSingOptionValue(LON_RANDOM, optarg); |
---|
393 | break; |
---|
394 | |
---|
395 | case 'u': |
---|
396 | mainSetSingOptionValue(LON_USER_OPTION, optarg); |
---|
397 | break; |
---|
398 | |
---|
399 | case LONG_OPTION_RETURN: |
---|
400 | if (strcmp(longopts[option_index].name, LON_NO_STDLIB) == 0) |
---|
401 | { |
---|
402 | load_std_lib = FALSE; |
---|
403 | mainSetSingOptionValue(LON_NO_STDLIB, (char*) 1); |
---|
404 | } |
---|
405 | else if (strcmp(longopts[option_index].name, LON_NO_RC) == 0) |
---|
406 | { |
---|
407 | load_rc = FALSE; |
---|
408 | mainSetSingOptionValue(LON_NO_RC, (char*) 1); |
---|
409 | } |
---|
410 | else if (strcmp(longopts[option_index].name, LON_MIN_TIME) == 0) |
---|
411 | { |
---|
412 | double mintime = atof(optarg); |
---|
413 | if (mintime <= 0) |
---|
414 | { |
---|
415 | printf("%s: `%s' invalid float argument for option `--%s'\n", |
---|
416 | argv[0], optarg, LON_MIN_TIME); |
---|
417 | mainUsage(argv[0]); |
---|
418 | exit(1); |
---|
419 | } |
---|
420 | SetMinDisplayTime(mintime); |
---|
421 | mainSetSingOptionValue(LON_MIN_TIME, optarg); |
---|
422 | } |
---|
423 | #ifdef HAVE_MPSR |
---|
424 | else if (strcmp(longopts[option_index].name, LON_MP_PORT) == 0) |
---|
425 | { |
---|
426 | mainSetSingOptionValue(LON_MP_PORT, optarg); |
---|
427 | } |
---|
428 | else if (strcmp(longopts[option_index].name, LON_MP_HOST) == 0) |
---|
429 | { |
---|
430 | mainSetSingOptionValue(LON_MP_HOST, optarg); |
---|
431 | } |
---|
432 | #endif |
---|
433 | else if (strcmp(longopts[option_index].name, LON_TICKS_PER_SEC) == 0) |
---|
434 | { |
---|
435 | int ticks = atoi(optarg); |
---|
436 | if (ticks <= 0) |
---|
437 | { |
---|
438 | printf("%s: `%s' invalid integer argument for option `--%s'\n", |
---|
439 | argv[0], optarg, LON_TICKS_PER_SEC); |
---|
440 | mainUsage(argv[0]); |
---|
441 | exit(1); |
---|
442 | } |
---|
443 | SetTimerResolution(ticks); |
---|
444 | mainSetSingOptionValue(LON_TICKS_PER_SEC, optarg); |
---|
445 | } |
---|
446 | else |
---|
447 | // undocumented options |
---|
448 | #ifdef HAVE_MPSR |
---|
449 | if (strcmp(longopts[option_index].name, LON_MP_MODE) == 0 || |
---|
450 | strcmp(longopts[option_index].name, LON_MP_TRANSP) == 0) |
---|
451 | { |
---|
452 | /* ignore */ |
---|
453 | } |
---|
454 | else |
---|
455 | #endif |
---|
456 | assume(0); |
---|
457 | break; |
---|
458 | |
---|
459 | default: |
---|
460 | // Error message already emmited by getopt_long |
---|
461 | mainUsage(argv[0]); |
---|
462 | exit(1); |
---|
463 | } |
---|
464 | } |
---|
465 | /*. say hello */ |
---|
466 | if (BVERBOSE(0) && !feBatch) |
---|
467 | { |
---|
468 | printf( |
---|
469 | " SINGULAR : a Computer Algebra System /\n" |
---|
470 | " for Commutative Algebra and Algebraic Geometry / %s\n" |
---|
471 | " 0<\n" |
---|
472 | " by: G.-M. Greuel, G. Pfister, H. Schoenemann \\ %s\n" |
---|
473 | "FB Mathematik der Universitaet, D-67653 Kaiserslautern \\\n" |
---|
474 | #if 0 |
---|
475 | "contributions: O.Bachmann,W.Decker,H.Grassmann,B.Martin,M.Messollen,W.Neumann,\n" |
---|
476 | "\tW.Pohl,T.Siebert,R.Stobbe,T.Wichmann\n" |
---|
477 | "e-mail: singular@mathematik.uni-kl.de\n", S_VERSION1,S_VERSION2); |
---|
478 | #endif |
---|
479 | , S_VERSION1,S_VERSION2); |
---|
480 | #if 0 |
---|
481 | printf("%s %s (%d)",S_VERSION1,S_VERSION2, SINGULAR_VERSION_ID); |
---|
482 | #endif |
---|
483 | printf("\nPlease note: every command must end with a semicolon \";" |
---|
484 | "\"\n(e.g., help; help command; help General syntax; help ring; quit;)\n"); |
---|
485 | } |
---|
486 | else |
---|
487 | if (!feBatch) |
---|
488 | { |
---|
489 | #ifdef __MWERKS__ |
---|
490 | memcpy(stderr,stdout,sizeof(FILE)); |
---|
491 | #else |
---|
492 | dup2(1,2); |
---|
493 | #endif |
---|
494 | } |
---|
495 | slStandardInit(); |
---|
496 | dlInit(thisfile); |
---|
497 | myynest=0; |
---|
498 | if (load_std_lib) |
---|
499 | { |
---|
500 | int vv=verbose; |
---|
501 | verbose &= ~Sy_bit(V_LOAD_LIB); |
---|
502 | iiLibCmd(mstrdup("standard.lib"),TRUE); |
---|
503 | verbose=vv; |
---|
504 | } |
---|
505 | errorreported = 0; |
---|
506 | #ifndef macintosh |
---|
507 | #if defined(HAVE_FEREAD) || defined(HAVE_READLINE) |
---|
508 | fe_set_input_mode(); |
---|
509 | #endif |
---|
510 | #endif |
---|
511 | setjmp(si_start_jmpbuf); |
---|
512 | |
---|
513 | // Now, put things on the stack of stuff to do |
---|
514 | |
---|
515 | // Last thing to do is to execute given scripts |
---|
516 | if (optind < argc) |
---|
517 | { |
---|
518 | int i = argc - 1; |
---|
519 | while (i >= optind) |
---|
520 | { |
---|
521 | newFile(argv[i]); |
---|
522 | i--; |
---|
523 | } |
---|
524 | } |
---|
525 | else |
---|
526 | { |
---|
527 | currentVoice=feInitStdin(); |
---|
528 | } |
---|
529 | |
---|
530 | // before scripts, we execute -c, if it was given |
---|
531 | // now execute -c, if it was given |
---|
532 | if (execute_string != NULL) |
---|
533 | newBuffer(mstrdup(execute_string), BT_execute); |
---|
534 | |
---|
535 | // first thing, however, is to load .singularrc |
---|
536 | if (load_rc) |
---|
537 | { |
---|
538 | // Hmm, we should look into $cwd and then into $HOME, only |
---|
539 | char * where=(char *)AllocL(256); |
---|
540 | FILE * rc=feFopen(".singularrc","r",where,FALSE); |
---|
541 | if (rc!=NULL) |
---|
542 | { |
---|
543 | fclose(rc); |
---|
544 | newFile(where); |
---|
545 | } |
---|
546 | FreeL((ADDRESS)where); |
---|
547 | } |
---|
548 | |
---|
549 | /* start shell */ |
---|
550 | if (feBatch) |
---|
551 | { |
---|
552 | #ifdef HAVE_MPSR |
---|
553 | extern int Batch_do(const char* port, const char* host); |
---|
554 | return Batch_do(mainGetSingOptionValue(LON_MP_PORT), |
---|
555 | mainGetSingOptionValue(LON_MP_HOST)); |
---|
556 | #else |
---|
557 | assume(0); |
---|
558 | #endif |
---|
559 | } |
---|
560 | setjmp(si_start_jmpbuf); |
---|
561 | yyparse(); |
---|
562 | #endif |
---|
563 | //Print("at very end\n"); |
---|
564 | m2_end(0); |
---|
565 | return 0; |
---|
566 | } |
---|