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