source: git/Singular/tesths.cc @ d315d69

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