source: git/Singular/tesths.cc @ 8080db

spielwiese
Last change on this file since 8080db was 8080db, checked in by Frank Seelisch <seelisch@…>, 13 years ago
more changes blackbox cone/fan types git-svn-id: file:///usr/local/Singular/svn/trunk@13885 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 6.8 KB
Line 
1/****************************************
2*  Computer Algebra System SINGULAR     *
3****************************************/
4/* $Id$ */
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 <kernel/mod2.h>
18#include <Singular/tok.h>
19#include <kernel/options.h>
20#include <Singular/ipshell.h>
21#include <kernel/febase.h>
22#include <Singular/cntrlc.h>
23#include <omalloc/omalloc.h>
24#include <Singular/silink.h>
25#include <Singular/ipid.h>
26#include <kernel/timer.h>
27#include <Singular/sdb.h>
28#include <kernel/fegetopt.h>
29#include <Singular/feOpt.h>
30#include <Singular/distrib.h>
31#include <Singular/version.h>
32#include <Singular/slInit.h>
33#include <Singular/ssiLink.h>
34#include <Singular/bigintm.h>
35#include <Singular/bbcone.h>
36#include <Singular/bbfan.h>
37#include <Singular/pyobject_setup.h>
38
39
40#ifdef HAVE_FACTORY
41#define SI_DONT_HAVE_GLOBAL_VARS
42#include <factory/factory.h>
43#endif
44
45extern int iiInitArithmetic();
46
47#if ! defined(LIBSINGULAR)
48/*0 implementation*/
49int main(          /* main entry to Singular */
50    int argc,      /* number of parameter */
51    char** argv)   /* parameter array */
52{
53#ifdef HAVE_FACTORY
54  On(SW_USE_NTL);
55  Off(SW_USE_GCD_P);
56  On(SW_USE_NTL_GCD_0); // On -> seg11 in Old/algnorm, Old/factor...
57  On(SW_USE_NTL_GCD_P); // On -> cyle in Short/brnoeth_s: fixed
58  On(SW_USE_EZGCD);
59  On(SW_USE_CHINREM_GCD);
60  //On(SW_USE_FF_MOD_GCD);
61  //On(SW_USE_fieldGCD);
62  On(SW_USE_EZGCD_P);
63  On(SW_USE_QGCD);
64  Off(SW_USE_NTL_SORT); // may be changed by an command line option
65#endif
66
67#ifdef INIT_BUG
68  jjInitTab1();
69#endif
70  // Don't worry: ifdef OM_NDEBUG, then all these calls are undef'ed
71  omInitRet_2_Info(argv[0]);
72  omInitGetBackTrace();
73
74  /* initialize components */
75  factoryError=WerrorS;
76  siRandomStart=inits();
77  feOptSpec[FE_OPT_RANDOM].value = (void*) ((long)siRandomStart);
78  int optc, option_index;
79  const char* errormsg;
80
81  // do this first, because -v might print version path
82  feInitResources(argv[0]);
83  iiInitArithmetic();
84
85  // parse command line options
86  while((optc = fe_getopt_long(argc, argv,
87                               SHORT_OPTS_STRING, feOptSpec, &option_index))
88        != EOF)
89  {
90    if (optc == '?' || optc == 0)
91    {
92      fprintf(stderr, "Use '%s --help' for a complete list of options\n", feArgv0);
93      exit(1);
94    }
95
96    if (optc != LONG_OPTION_RETURN)
97      option_index = feGetOptIndex(optc);
98
99    assume(option_index >= 0 && option_index < (int) FE_OPT_UNDEF);
100
101    if (fe_optarg == NULL &&
102        (feOptSpec[option_index].type == feOptBool ||
103         feOptSpec[option_index].has_arg == optional_argument))
104      errormsg = feSetOptValue((feOptIndex) option_index, (int) 1);
105    else
106      errormsg = feSetOptValue((feOptIndex) option_index, fe_optarg);
107
108    if (errormsg)
109    {
110      if (fe_optarg == NULL)
111        fprintf(stderr, "Error: Option '--%s' %s\n",
112               feOptSpec[option_index].name, errormsg);
113      else
114        fprintf(stderr, "Error: Option '--%s=%s' %s\n",
115               feOptSpec[option_index].name, fe_optarg, errormsg);
116      fprintf(stderr, "Use '%s --help' for a complete list of options\n", feArgv0);
117      exit(1);
118    }
119    if (optc == 'h') exit(0);
120  }
121
122  /* say hello */
123#if 0
124  SingularBuilder::Ptr SingularInstance = SingularBuilder::instance();
125#else
126  {
127    basePack=(package)omAlloc0(sizeof(*basePack));
128    currPack=basePack;
129    idhdl h;
130    h=enterid("Top", 0, PACKAGE_CMD, &IDROOT, TRUE);
131    IDPACKAGE(h)->language = LANG_TOP;
132    IDPACKAGE(h)=basePack;
133    currPackHdl=h;
134    basePackHdl=h;
135#ifdef HAVE_FANS
136    bbcone_setup();
137    bbfan_setup();
138#endif
139    //for official version: not active
140    //bigintm_setup();
141  }
142#endif
143  if (TEST_V_QUIET)
144  {
145    (printf)(
146"                     SINGULAR                                 /"
147#ifndef MAKE_DISTRIBUTION
148"  Development"
149#endif
150"\n"
151" A Computer Algebra System for Polynomial Computations       /   version %s\n"
152"                                                           0<\n"
153" by: W. Decker, G.-M. Greuel, G. Pfister, H. Schoenemann     \\   %s\n"
154"FB Mathematik der Universitaet, D-67653 Kaiserslautern        \\\n"
155, S_VERSION1,S_VERSION2);
156  }
157  else
158  {
159#ifdef HAVE_FACTORY
160    if (feOptValue(FE_OPT_SORT)) On(SW_USE_NTL_SORT);
161#endif
162#ifdef HAVE_SDB
163    sdb_flags = 0;
164#endif
165    dup2(1,2);
166    /* alternative:
167    *    memcpy(stderr,stdout,sizeof(FILE));
168    */
169  }
170  slStandardInit();
171  myynest=0;
172  if (! feOptValue(FE_OPT_NO_STDLIB))
173  {
174    int vv=verbose;
175    verbose &= ~Sy_bit(V_LOAD_LIB);
176    iiLibCmd(omStrDup("standard.lib"), TRUE,TRUE,TRUE);
177    verbose=vv;
178  }
179  pyobject_setup();
180  errorreported = 0;
181
182  // and again, ifdef OM_NDEBUG this call is undef'ed
183  // otherwise, it marks all memory allocated so far as static
184  // i.e. as memory which is not mention on omPrintUsedAddr:
185  //omMarkMemoryAsStatic();
186
187  setjmp(si_start_jmpbuf);
188
189  // Now, put things on the stack of stuff to do
190  // Last thing to do is to execute given scripts
191  if (fe_optind < argc)
192  {
193    int i = argc - 1;
194    FILE *fd;
195    while (i >= fe_optind)
196    {
197      if ((fd = feFopen(argv[i], "r")) == NULL)
198      {
199        Warn("Can not open %s", argv[i]);
200      }
201      else
202      {
203        fclose(fd);
204        newFile(argv[i]);
205      }
206      i--;
207    }
208  }
209  else
210  {
211    currentVoice=feInitStdin(NULL);
212  }
213
214  // before scripts, we execute -c, if it was given
215  if (feOptValue(FE_OPT_EXECUTE) != NULL)
216    newBuffer(omStrDup((char*) feOptValue(FE_OPT_EXECUTE)), BT_execute);
217
218  // first thing, however, is to load .singularrc from Singularpath
219  // and cwd/$HOME (in that order).
220  if (! feOptValue(FE_OPT_NO_RC))
221  {
222    char buf[MAXPATHLEN];
223    FILE * rc = feFopen("." DIR_SEPP ".singularrc", "r", buf);
224    if (rc == NULL) rc = feFopen("~" DIR_SEPP ".singularrc", "r", buf);
225    if (rc == NULL) rc = feFopen(".singularrc", "r", buf);
226
227    if (rc != NULL)
228    {
229      if (BVERBOSE(V_LOAD_LIB))
230        Print("// ** executing %s\n", buf);
231      fclose(rc);
232      newFile(buf);
233    }
234  }
235
236  /* start shell */
237  if (fe_fgets_stdin==fe_fgets_dummy)
238  {
239    char *linkname=(char*) feOptValue(FE_OPT_LINK);
240    if((linkname!=NULL)&&(strcmp(linkname,"ssi")==0))
241    {
242      return ssiBatch((char*) feOptValue(FE_OPT_MPHOST),(char*) feOptValue(FE_OPT_MPPORT));
243      //Print("batch: p:%s, h:%s\n",(char*) feOptValue(FE_OPT_MPPORT),(char*) feOptValue(FE_OPT_MPHOST));
244      //exit(0);
245    }
246    else
247    {
248    #ifdef HAVE_MPSR
249      BatchDoProc batch_do = slInitMPBatchDo();
250      if (batch_do != NULL)
251        return (*batch_do)((char*) feOptValue(FE_OPT_MPPORT),
252                         (char*) feOptValue(FE_OPT_MPHOST));
253      else
254        return 1;
255    #else
256      assume(0);
257    #endif
258    }
259  }
260  setjmp(si_start_jmpbuf);
261  yyparse();
262  m2_end(0);
263  return 0;
264}
265#endif // not LIBSINGULAR
266
Note: See TracBrowser for help on using the repository browser.