source: git/Singular/tesths.cc @ 9b4b45

spielwiese
Last change on this file since 9b4b45 was 9b4b45, checked in by Olaf Bachmann <obachman@…>, 25 years ago
* increased version number to 1.3.5 git-svn-id: file:///usr/local/Singular/svn/trunk@3627 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 5.3 KB
Line 
1/****************************************
2*  Computer Algebra System SINGULAR     *
3****************************************/
4/* $Id: tesths.cc,v 1.71 1999-09-20 20:00:35 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 "mod2.h"
18#include "tok.h"
19#include "ipshell.h"
20#include "sing_dld.h"
21#include "febase.h"
22#include "cntrlc.h"
23#include "mmemory.h"
24#include "silink.h"
25#include "ipid.h"
26#include "timer.h"
27#include "sdb.h"
28#include "fegetopt.h"
29#include "feOpt.h"
30#include "distrib.h"
31#include "version.h"
32
33#ifdef HAVE_FACTORY
34#define SI_DONT_HAVE_GLOBAL_VARS
35#include <factory.h>
36#endif
37
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
47  extern void ttGen1();
48  extern void ttGen2();
49  #ifndef __MWERKS__
50    extern mpsr_ttGen(); // For initialization of (CMD, MP_COP) tables
51    mpsr_ttGen();
52  #endif
53  ttGen1();
54  ttGen2();
55#else
56  /* initialize components */
57  siRandomStart=inits();
58  feOptSpec[FE_OPT_RANDOM].value = (void*) siRandomStart;
59  int optc, option_index;
60  char* errormsg;
61
62  // do this first, because -v might print version path
63  feInitResources(argv[0]);
64
65  // parse command line options
66  while((optc = fe_getopt_long(argc, argv,
67                               SHORT_OPTS_STRING, feOptSpec, &option_index))
68//                               "", feOptSpec, &option_index))
69        != EOF)
70  {
71    if (optc == '?' || optc == 0) 
72    {
73      fprintf(stderr, "Use '%s --help' for a complete list of options\n", feArgv0);
74      exit(1);
75    }
76
77    if (optc != LONG_OPTION_RETURN)
78      option_index = feGetOptIndex(optc);
79
80    assume(option_index >= 0 && option_index < (int) FE_OPT_UNDEF);
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);
99    }
100    if (optc == 'h') exit(0);
101  }
102
103  /* say hello */
104  {
105    idhdl h;
106    namespaceroot->push(NULL, "Top", 0, TRUE);
107#ifdef HAVE_NAMESPACES
108    h=enterid(mstrdup("Top"), 0, PACKAGE_CMD, &IDROOT, TRUE);
109    IDPACKAGE(h) = NSPACK(namespaceroot);
110    IDPACKAGE(h)->language = LANG_TOP;
111#endif /* HAVE_NAMESPACES */
112  }
113  if (BVERBOSE(0))
114  {
115    printf(
116"                     SINGULAR                             /"
117#ifndef MAKE_DISTRIBUTION
118"  Development"
119#endif
120"\n"
121" A Computer Algebra System for Polynomial Computations   /   version %s\n"
122"                                                       0<\n"
123"     by: G.-M. Greuel, G. Pfister, H. Schoenemann        \\   %s\n"
124#ifdef SDRING
125"       preliminary experimental version\n"
126#endif
127"FB Mathematik der Universitaet, D-67653 Kaiserslautern    \\\n"
128, S_VERSION1,S_VERSION2);
129  }
130  else
131  {
132    sdb_flags = 0;
133#ifdef __MWERKS__
134    memcpy(stderr,stdout,sizeof(FILE));
135#else
136    dup2(1,2);
137#endif
138  }
139  slStandardInit();
140  dlInit(feArgv0);
141  myynest=0;
142  if (! feOptValue(FE_OPT_NO_STDLIB))
143  {
144    int vv=verbose;
145    verbose &= ~Sy_bit(V_LOAD_LIB);
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 */
151    verbose=vv;
152  }
153  errorreported = 0;
154  mmMarkInitDBMCB();
155  setjmp(si_start_jmpbuf);
156
157  // Now, put things on the stack of stuff to do
158
159  // Last thing to do is to execute given scripts
160  if (fe_optind < argc)
161  {
162    int i = argc - 1;
163    while (i >= fe_optind)
164    {
165      newFile(argv[i]);
166      i--;
167    }
168  }
169  else
170  {
171    currentVoice=feInitStdin();
172  }
173
174  // before scripts, we execute -c, if it was given
175  if (feOptValue(FE_OPT_EXECUTE) != NULL)
176    newBuffer(mstrdup((char*) feOptValue(FE_OPT_EXECUTE)), BT_execute);
177
178  // first thing, however, is to load .singularrc
179  if (! feOptValue(FE_OPT_NO_RC))
180  {
181    FILE * rc=myfopen(".singularrc","r");
182    if (rc!=NULL)
183    {
184      fclose(rc);
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      }
202    }
203  }
204
205  /* start shell */
206  if (fe_fgets_stdin==fe_fgets_dummy)
207  {
208#ifdef HAVE_MPSR
209    extern int Batch_do(const char* port, const char* host);
210    return Batch_do((char*) feOptValue(FE_OPT_MP_PORT),
211                    (char*) feOptValue(FE_OPT_MP_HOST));
212#else
213    assume(0);
214#endif
215  }
216  setjmp(si_start_jmpbuf);
217  yyparse();
218#endif
219  //Print("at very end\n");
220  m2_end(0);
221  return 0;
222}
223
Note: See TracBrowser for help on using the repository browser.