source: git/Singular/tesths.cc @ ca18d3

spielwiese
Last change on this file since ca18d3 was ca18d3, checked in by Olaf Bachmann <obachman@…>, 25 years ago
* fixed stuff with MP-options git-svn-id: file:///usr/local/Singular/svn/trunk@3628 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 5.3 KB
RevLine 
[0e1846]1/****************************************
2*  Computer Algebra System SINGULAR     *
3****************************************/
[ca18d3]4/* $Id: tesths.cc,v 1.72 1999-09-21 12:03:07 obachman Exp $ */
[32df82]5
[0e1846]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>
[32df82]16#include <errno.h>
[0e1846]17#include "mod2.h"
18#include "tok.h"
19#include "ipshell.h"
[6a6dccc]20#include "sing_dld.h"
[0e1846]21#include "febase.h"
22#include "cntrlc.h"
23#include "mmemory.h"
24#include "silink.h"
[7def32f]25#include "ipid.h"
[ea986d]26#include "timer.h"
[473707b]27#include "sdb.h"
[c06a32]28#include "fegetopt.h"
29#include "feOpt.h"
30#include "distrib.h"
31#include "version.h"
32
[43d6c5]33#ifdef HAVE_FACTORY
[fda54cc]34#define SI_DONT_HAVE_GLOBAL_VARS
35#include <factory.h>
[43d6c5]36#endif
[40edb03]37
[0e1846]38/*0 implementation*/
39int main(          /* main entry to Singular */
40    int argc,      /* number of parameter */
41    char** argv)   /* parameter array */
42{
43#ifdef INIT_BUG
44  jjInitTab1();
45#endif
46#ifdef GENTABLE
[9c756f]47  extern void ttGen1();
48  extern void ttGen2();
49  #ifndef __MWERKS__
[99965c5]50    extern mpsr_ttGen(); // For initialization of (CMD, MP_COP) tables
51    mpsr_ttGen();
52  #endif
[0e1846]53  ttGen1();
54  ttGen2();
55#else
[c06a32]56  /* initialize components */
57  siRandomStart=inits();
58  feOptSpec[FE_OPT_RANDOM].value = (void*) siRandomStart;
[eea2b0]59  int optc, option_index;
[c06a32]60  char* errormsg;
[eea2b0]61
62  // do this first, because -v might print version path
[c06a32]63  feInitResources(argv[0]);
[eea2b0]64
65  // parse command line options
[9b4b45]66  while((optc = fe_getopt_long(argc, argv,
[c06a32]67                               SHORT_OPTS_STRING, feOptSpec, &option_index))
68//                               "", feOptSpec, &option_index))
[eea2b0]69        != EOF)
[0e1846]70  {
[c06a32]71    if (optc == '?' || optc == 0) 
[0e1846]72    {
[c06a32]73      fprintf(stderr, "Use '%s --help' for a complete list of options\n", feArgv0);
74      exit(1);
75    }
[e0d91c]76
[c06a32]77    if (optc != LONG_OPTION_RETURN)
78      option_index = feGetOptIndex(optc);
[eea2b0]79
[9b4b45]80    assume(option_index >= 0 && option_index < (int) FE_OPT_UNDEF);
[c06a32]81   
82    if (fe_optarg == NULL && 
83        (feOptSpec[option_index].type == feOptBool ||
84         feOptSpec[option_index].has_arg == optional_argument))
85      errormsg = feSetOptValue((feOptIndex) option_index, (int) 1);
86    else
87      errormsg = feSetOptValue((feOptIndex) option_index, fe_optarg);
88   
89    if (errormsg)
90    {
91      if (fe_optarg == NULL)
92        fprintf(stderr, "Error: Option '--%s' %s\n", 
93               feOptSpec[option_index].name, errormsg);
94      else
95        fprintf(stderr, "Error: Option '--%s=%s' %s\n", 
96               feOptSpec[option_index].name, fe_optarg, errormsg);
97      fprintf(stderr, "Use '%s --help' for a complete list of options\n", feArgv0);
98      exit(1);
[0e1846]99    }
[c06a32]100    if (optc == 'h') exit(0);
[0e1846]101  }
[c06a32]102
[726d50]103  /* say hello */
[77ff8e]104  {
105    idhdl h;
[0a3ddd]106    namespaceroot->push(NULL, "Top", 0, TRUE);
[46d09b]107#ifdef HAVE_NAMESPACES
[77ff8e]108    h=enterid(mstrdup("Top"), 0, PACKAGE_CMD, &IDROOT, TRUE);
109    IDPACKAGE(h) = NSPACK(namespaceroot);
[daeb6d]110    IDPACKAGE(h)->language = LANG_TOP;
[46d09b]111#endif /* HAVE_NAMESPACES */
[77ff8e]112  }
[f4edee]113  if (BVERBOSE(0))
[0e1846]114  {
115    printf(
[3854a98]116"                     SINGULAR                             /"
117#ifndef MAKE_DISTRIBUTION
[9a11fe]118"  Development"
[3854a98]119#endif
120"\n"
[49e4cf]121" A Computer Algebra System for Polynomial Computations   /   version %s\n"
[0cb8c8]122"                                                       0<\n"
[451bcd]123"     by: G.-M. Greuel, G. Pfister, H. Schoenemann        \\   %s\n"
[f306b3]124#ifdef SDRING
125"       preliminary experimental version\n"
126#endif
[0cb8c8]127"FB Mathematik der Universitaet, D-67653 Kaiserslautern    \\\n"
[49eeee]128, S_VERSION1,S_VERSION2);
[0e1846]129  }
130  else
131  {
[473707b]132    sdb_flags = 0;
[9c756f]133#ifdef __MWERKS__
[f4edee]134    memcpy(stderr,stdout,sizeof(FILE));
[0e1846]135#else
[f4edee]136    dup2(1,2);
[0e1846]137#endif
138  }
139  slStandardInit();
[c06a32]140  dlInit(feArgv0);
[0e1846]141  myynest=0;
[c06a32]142  if (! feOptValue(FE_OPT_NO_STDLIB))
[055021a]143  {
[e54eb4]144    int vv=verbose;
145    verbose &= ~Sy_bit(V_LOAD_LIB);
[0a3ddd]146#ifdef HAVE_NAMESPACES
147    iiLibCmd(mstrdup("standard.lib"),TRUE, TRUE);
148#else /* HAVE_NAMESPACES */
149    iiLibCmd(mstrdup("standard.lib"), TRUE);
150#endif /* HAVE_NAMESPACES */
[e54eb4]151    verbose=vv;
152  }
[9ea9c6]153  errorreported = 0;
[6e5833]154  mmMarkInitDBMCB();
[dfc6b54]155  setjmp(si_start_jmpbuf);
[eea2b0]156
157  // Now, put things on the stack of stuff to do
158
159  // Last thing to do is to execute given scripts
[c06a32]160  if (fe_optind < argc)
[057e93c]161  {
[eea2b0]162    int i = argc - 1;
[c06a32]163    while (i >= fe_optind)
[eea2b0]164    {
165      newFile(argv[i]);
166      i--;
167    }
[057e93c]168  }
169  else
170  {
171    currentVoice=feInitStdin();
172  }
[eea2b0]173
174  // before scripts, we execute -c, if it was given
[c06a32]175  if (feOptValue(FE_OPT_EXECUTE) != NULL)
176    newBuffer(mstrdup((char*) feOptValue(FE_OPT_EXECUTE)), BT_execute);
[eea2b0]177
178  // first thing, however, is to load .singularrc
[c06a32]179  if (! feOptValue(FE_OPT_NO_RC))
[7def32f]180  {
[64c6d1]181    FILE * rc=myfopen(".singularrc","r");
[7def32f]182    if (rc!=NULL)
183    {
184      fclose(rc);
[64c6d1]185      newFile(".singularrc");
186    }
187    else
188    {
189      char buf[MAXPATHLEN];
190      char *home = getenv("HOME");
191      if (home != NULL)
192      {
193        strcpy(buf, home);
194        strcat(buf, "/.singularrc");
195        rc = myfopen(buf, "r");
196        if (rc != NULL)
197        {
198          fclose(rc);
199          newFile(buf);
200        }
201      }
[7def32f]202    }
203  }
[eea2b0]204
[0e1846]205  /* start shell */
[f4edee]206  if (fe_fgets_stdin==fe_fgets_dummy)
[0e1846]207  {
[d754b7]208#ifdef HAVE_MPSR
[eea2b0]209    extern int Batch_do(const char* port, const char* host);
[ca18d3]210    return Batch_do((char*) feOptValue(FE_OPT_MPPORT),
211                    (char*) feOptValue(FE_OPT_MPHOST));
[d754b7]212#else
[eea2b0]213    assume(0);
214#endif
[0e1846]215  }
[07dacd]216  setjmp(si_start_jmpbuf);
[0e1846]217  yyparse();
218#endif
[057e93c]219  //Print("at very end\n");
220  m2_end(0);
[0e1846]221  return 0;
222}
[c06a32]223
Note: See TracBrowser for help on using the repository browser.