source: git/Singular/tesths.cc @ 119f3c

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