1 | /***************************************** |
---|
2 | * Computer Algebra System SINGULAR * |
---|
3 | *****************************************/ |
---|
4 | /* $Id: extra.cc,v 1.47 1998-05-14 13:04:12 Singular Exp $ */ |
---|
5 | /* |
---|
6 | * ABSTRACT: general interface to internals of Singular ("system" command) |
---|
7 | */ |
---|
8 | |
---|
9 | #include <stdlib.h> |
---|
10 | #include <stdio.h> |
---|
11 | #include <string.h> |
---|
12 | #include <ctype.h> |
---|
13 | #include "mod2.h" |
---|
14 | |
---|
15 | #ifndef __MWERKS__ |
---|
16 | #ifdef TIME_WITH_SYS_TIME |
---|
17 | # include <time.h> |
---|
18 | # ifdef HAVE_SYS_TIME_H |
---|
19 | # include <sys/time.h> |
---|
20 | # endif |
---|
21 | #else |
---|
22 | # ifdef HAVE_SYS_TIME_H |
---|
23 | # include <sys/time.h> |
---|
24 | # else |
---|
25 | # include <time.h> |
---|
26 | # endif |
---|
27 | #endif |
---|
28 | #ifdef HAVE_SYS_TIMES_H |
---|
29 | #include <sys/times.h> |
---|
30 | #endif |
---|
31 | |
---|
32 | #include <unistd.h> |
---|
33 | #endif |
---|
34 | |
---|
35 | #include "tok.h" |
---|
36 | #include "ipid.h" |
---|
37 | #include "polys.h" |
---|
38 | #include "kutil.h" |
---|
39 | #include "cntrlc.h" |
---|
40 | #include "stairc.h" |
---|
41 | #include "ipshell.h" |
---|
42 | #include "algmap.h" |
---|
43 | #include "modulop.h" |
---|
44 | #include "febase.h" |
---|
45 | #include "matpol.h" |
---|
46 | #include "longalg.h" |
---|
47 | #include "ideals.h" |
---|
48 | #include "kstd1.h" |
---|
49 | #include "syz.h" |
---|
50 | #include "polys.h" |
---|
51 | |
---|
52 | // Define to enable many more system commands |
---|
53 | // #define HAVE_EXTENDED_SYSTEM |
---|
54 | |
---|
55 | #ifdef STDTRACE |
---|
56 | //#include "comm.h" |
---|
57 | #endif |
---|
58 | |
---|
59 | #ifdef HAVE_FACTORY |
---|
60 | #define SI_DONT_HAVE_GLOBAL_VARS |
---|
61 | #include "clapsing.h" |
---|
62 | #include "clapconv.h" |
---|
63 | #include "kstdfac.h" |
---|
64 | #include "fglmcomb.cc" |
---|
65 | #include "fglm.h" |
---|
66 | #endif |
---|
67 | |
---|
68 | #include "silink.h" |
---|
69 | #include "mpsr.h" |
---|
70 | |
---|
71 | #ifdef HAVE_DYNAMIC_LOADING |
---|
72 | #include <dlfcn.h> |
---|
73 | #endif /* HAVE_DYNAMIC_LOADING */ |
---|
74 | |
---|
75 | // see clapsing.cc for a description of the `FACTORY_*' options |
---|
76 | |
---|
77 | #ifdef FACTORY_GCD_STAT |
---|
78 | #include "gcd_stat.h" |
---|
79 | #endif |
---|
80 | |
---|
81 | #ifdef FACTORY_GCD_TIMING |
---|
82 | #define TIMING |
---|
83 | #include "timing.h" |
---|
84 | TIMING_DEFINE_PRINTPROTO( contentTimer ); |
---|
85 | TIMING_DEFINE_PRINTPROTO( algContentTimer ); |
---|
86 | TIMING_DEFINE_PRINTPROTO( algLcmTimer ); |
---|
87 | #endif |
---|
88 | |
---|
89 | void piShowProcList(); |
---|
90 | |
---|
91 | //void emStart(); |
---|
92 | /*2 |
---|
93 | * the "system" command |
---|
94 | */ |
---|
95 | BOOLEAN jjSYSTEM(leftv res, leftv h) |
---|
96 | { |
---|
97 | if(h->Typ() == STRING_CMD) |
---|
98 | { |
---|
99 | // ONLY documented system calls go here |
---|
100 | // Undocumented system calls go down into #ifdef HAVE_EXTENDED_SYSTEM |
---|
101 | /*==================== version ==================================*/ |
---|
102 | if(strcmp((char*)(h->Data()),"version")==0) |
---|
103 | { |
---|
104 | res->rtyp=INT_CMD; |
---|
105 | res->data=(void *)SINGULAR_VERSION; |
---|
106 | return FALSE; |
---|
107 | } |
---|
108 | else |
---|
109 | /*==================== gen ==================================*/ |
---|
110 | if(strcmp((char*)(h->Data()),"gen")==0) |
---|
111 | { |
---|
112 | res->rtyp=INT_CMD; |
---|
113 | res->data=(void *)npGen; |
---|
114 | return FALSE; |
---|
115 | } |
---|
116 | else |
---|
117 | /*==================== sh ==================================*/ |
---|
118 | #ifndef __MWERKS__ |
---|
119 | if(strcmp((char*)(h->Data()),"sh")==0) |
---|
120 | { |
---|
121 | #ifndef MSDOS |
---|
122 | #ifdef HAVE_FEREAD |
---|
123 | fe_temp_reset(); |
---|
124 | #endif |
---|
125 | #endif |
---|
126 | res->rtyp=INT_CMD; |
---|
127 | if (h->next==NULL) res->data = (void *)system("/bin/sh"); |
---|
128 | else res->data = (void*) system((char*)(h->next->Data())); |
---|
129 | #ifndef MSDOS |
---|
130 | #ifdef HAVE_FEREAD |
---|
131 | fe_temp_set(); |
---|
132 | #endif |
---|
133 | #endif |
---|
134 | return FALSE; |
---|
135 | } |
---|
136 | else |
---|
137 | #endif |
---|
138 | /*==================== with ==================================*/ |
---|
139 | if(strcmp((char*)(h->Data()),"with")==0) |
---|
140 | { |
---|
141 | if (h->next==NULL) |
---|
142 | { |
---|
143 | res->rtyp=STRING_CMD; |
---|
144 | res->data=(void *)mstrdup(versionString()); |
---|
145 | return FALSE; |
---|
146 | } |
---|
147 | else if (h->next->Typ()==STRING_CMD) |
---|
148 | { |
---|
149 | #define TEST_FOR(A) if(strcmp(s,A)==0) res->data=(void *)1; else |
---|
150 | char *s=(char *)h->next->Data(); |
---|
151 | res->rtyp=INT_CMD; |
---|
152 | #ifdef DRING |
---|
153 | TEST_FOR("DRING") |
---|
154 | #endif |
---|
155 | #ifdef HAVE_DBM |
---|
156 | TEST_FOR("DBM") |
---|
157 | #endif |
---|
158 | #ifdef HAVE_DLD |
---|
159 | TEST_FOR("DLD") |
---|
160 | #endif |
---|
161 | #ifdef HAVE_GMP |
---|
162 | TEST_FOR("gmp") |
---|
163 | #endif |
---|
164 | #ifdef HAVE_FACTORY |
---|
165 | TEST_FOR("factory") |
---|
166 | #endif |
---|
167 | #ifdef HAVE_LIBFAC_P |
---|
168 | TEST_FOR("libfac") |
---|
169 | #endif |
---|
170 | #ifdef HAVE_MPSR |
---|
171 | TEST_FOR("MP") |
---|
172 | #endif |
---|
173 | #ifdef HAVE_READLINE |
---|
174 | TEST_FOR("readline") |
---|
175 | #endif |
---|
176 | #ifdef HAVE_TCL |
---|
177 | TEST_FOR("tcl") |
---|
178 | #endif |
---|
179 | #ifdef SRING |
---|
180 | TEST_FOR("SRING") |
---|
181 | #endif |
---|
182 | #ifdef TEST_MAC_ORDER |
---|
183 | TEST_FOR("MAC_ORDER"); |
---|
184 | #endif |
---|
185 | ; |
---|
186 | return FALSE; |
---|
187 | #undef TEST_FOR |
---|
188 | } |
---|
189 | return TRUE; |
---|
190 | } |
---|
191 | else |
---|
192 | /*==================== pid ==================================*/ |
---|
193 | #ifndef MSDOS |
---|
194 | #ifndef __MWERKS__ |
---|
195 | if (strcmp((char*)(h->Data()),"pid")==0) |
---|
196 | { |
---|
197 | res->rtyp=INT_CMD; |
---|
198 | res->data=(void *)getpid(); |
---|
199 | return FALSE; |
---|
200 | } |
---|
201 | else |
---|
202 | #endif |
---|
203 | #endif |
---|
204 | /*==================== getenv ==================================*/ |
---|
205 | if (strcmp((char*)(h->Data()),"getenv")==0) |
---|
206 | { |
---|
207 | if ((h->next!=NULL) && (h->next->Typ()==STRING_CMD)) |
---|
208 | { |
---|
209 | res->rtyp=STRING_CMD; |
---|
210 | char *r=getenv((char *)h->next->Data()); |
---|
211 | if (r==NULL) r=""; |
---|
212 | res->data=(void *)mstrdup(r); |
---|
213 | return FALSE; |
---|
214 | } |
---|
215 | else |
---|
216 | { |
---|
217 | WerrorS("string expected"); |
---|
218 | } |
---|
219 | } |
---|
220 | else |
---|
221 | /*==================== tty ==================================*/ |
---|
222 | #ifndef __MWERKS__ |
---|
223 | #ifndef MSDOS |
---|
224 | #if defined(HAVE_FEREAD) || defined(HAVE_READLINE) |
---|
225 | if (strcmp((char*)(h->Data()),"tty")==0) |
---|
226 | { |
---|
227 | #ifdef HAVE_FEREAD |
---|
228 | #ifdef HAVE_ATEXIT |
---|
229 | fe_reset_input_mode(); |
---|
230 | #else |
---|
231 | fe_reset_input_mode(0,NULL); |
---|
232 | #endif |
---|
233 | #elif defined(HAVE_READLINE) |
---|
234 | system("stty sane"); |
---|
235 | #endif |
---|
236 | if ((h->next!=NULL)&&(h->next->Typ()==INT_CMD)) |
---|
237 | { |
---|
238 | fe_use_fgets=(int)h->next->Data(); |
---|
239 | fe_set_input_mode(); |
---|
240 | } |
---|
241 | return FALSE; |
---|
242 | } |
---|
243 | else |
---|
244 | #endif |
---|
245 | #endif |
---|
246 | #endif |
---|
247 | /*==================== whoami ==================================*/ |
---|
248 | if (strcmp((char*)(h->data), "whoami") == 0) |
---|
249 | { |
---|
250 | res->rtyp=STRING_CMD; |
---|
251 | res->data=(void*)feGetExpandedExecutable(); |
---|
252 | if (res->data != NULL) |
---|
253 | res->data = (void*) mstrdup((char*) res->data); |
---|
254 | else |
---|
255 | res->data = (void*) mstrdup(""); |
---|
256 | return FALSE; |
---|
257 | } |
---|
258 | else |
---|
259 | /*==================== options ==================================*/ |
---|
260 | if (strstr((char*)(h->data), "--") == (char*)(h->data)) |
---|
261 | { |
---|
262 | BOOLEAN mainGetSingOptionValue(const char* name, char** result); |
---|
263 | char* val; |
---|
264 | |
---|
265 | if (mainGetSingOptionValue(&((char*)(h->data))[2], &val)) |
---|
266 | { |
---|
267 | res->data = (void*) val; |
---|
268 | if ((unsigned int) val > 1) |
---|
269 | { |
---|
270 | res->rtyp=STRING_CMD; |
---|
271 | res->data = (void*) mstrdup((char*) res->data); |
---|
272 | } |
---|
273 | else |
---|
274 | res->rtyp=INT_CMD; |
---|
275 | return FALSE; |
---|
276 | } |
---|
277 | else |
---|
278 | { |
---|
279 | Werror("Unknown option %s\n", (char*)(h->data)); |
---|
280 | return TRUE; |
---|
281 | } |
---|
282 | } |
---|
283 | else |
---|
284 | /*==================== HC ==================================*/ |
---|
285 | if (strcmp((char*)(h->data),"HC")==0) |
---|
286 | { |
---|
287 | res->rtyp=INT_CMD; |
---|
288 | res->data=(void *)HCord; |
---|
289 | return FALSE; |
---|
290 | } |
---|
291 | else |
---|
292 | /*==================== random ==================================*/ |
---|
293 | if(strcmp((char*)(h->Data()),"random")==0) |
---|
294 | { |
---|
295 | if ((h->next!=NULL) &&(h->next->Typ()==INT_CMD)) |
---|
296 | { |
---|
297 | siRandomStart=(int)h->next->Data(); |
---|
298 | #ifdef buildin_rand |
---|
299 | siSeed=siRandomStart; |
---|
300 | #else |
---|
301 | srand((unsigned int)siRandomStart); |
---|
302 | #endif |
---|
303 | return FALSE; |
---|
304 | } |
---|
305 | else if (h->next != NULL) |
---|
306 | { |
---|
307 | WerrorS("int expected"); |
---|
308 | return TRUE; |
---|
309 | } |
---|
310 | res->rtyp=INT_CMD; |
---|
311 | res->data=(void*) siRandomStart; |
---|
312 | return FALSE; |
---|
313 | } |
---|
314 | /*==================== neworder =============================*/ |
---|
315 | // should go below |
---|
316 | #ifdef HAVE_LIBFAC_P |
---|
317 | if(strcmp((char*)(h->Data()),"neworder")==0) |
---|
318 | { |
---|
319 | if ((h->next!=NULL) &&(h->next->Typ()==IDEAL_CMD)) |
---|
320 | { |
---|
321 | res->rtyp=STRING_CMD; |
---|
322 | res->data=(void *)singclap_neworder((ideal)h->next->Data()); |
---|
323 | return FALSE; |
---|
324 | } |
---|
325 | else |
---|
326 | WerrorS("ideal expected"); |
---|
327 | } |
---|
328 | else |
---|
329 | #endif |
---|
330 | #ifdef HAVE_EXTENDED_SYSTEM |
---|
331 | // You can put your own system calls here |
---|
332 | /*==================== LaScala ==================================*/ |
---|
333 | if(strcmp((char*)(h->Data()),"LaScala")==0) |
---|
334 | { |
---|
335 | if ((h->next!=NULL) |
---|
336 | &&((h->next->Typ()==IDEAL_CMD)||(h->next->Typ()==MODUL_CMD))) |
---|
337 | { |
---|
338 | int dummy; |
---|
339 | res->data=(void *)syLaScala3((ideal)h->next->Data(),&dummy); |
---|
340 | mmTest(res->data,sizeof(ssyStrategy)); |
---|
341 | syStrategy s=(syStrategy)res->data; |
---|
342 | for (int i=s->length;i>=0;i--) |
---|
343 | { |
---|
344 | if (s->res[i]!=NULL) |
---|
345 | idTest(s->res[i]); |
---|
346 | } |
---|
347 | res->rtyp=RESOLUTION_CMD; |
---|
348 | return FALSE; |
---|
349 | } |
---|
350 | else |
---|
351 | WerrorS("ideal/module expected"); |
---|
352 | } |
---|
353 | else |
---|
354 | /*==================== naIdeal ==================================*/ |
---|
355 | if(strcmp((char*)(h->Data()),"naIdeal")==0) |
---|
356 | { |
---|
357 | if ((h->next!=NULL) &&(h->next->Typ()==IDEAL_CMD)) |
---|
358 | { |
---|
359 | naSetIdeal((ideal)h->next->Data()); |
---|
360 | return FALSE; |
---|
361 | } |
---|
362 | else |
---|
363 | WerrorS("ideal expected"); |
---|
364 | } |
---|
365 | else |
---|
366 | /*==================== isSqrFree =============================*/ |
---|
367 | #ifdef HAVE_FACTORY |
---|
368 | if(strcmp((char*)(h->Data()),"isSqrFree")==0) |
---|
369 | { |
---|
370 | if ((h->next!=NULL) &&(h->next->Typ()==POLY_CMD)) |
---|
371 | { |
---|
372 | res->rtyp=INT_CMD; |
---|
373 | res->data=(void *)singclap_isSqrFree((poly)h->next->Data()); |
---|
374 | return FALSE; |
---|
375 | } |
---|
376 | else |
---|
377 | WerrorS("poly expected"); |
---|
378 | } |
---|
379 | else |
---|
380 | #endif |
---|
381 | /*==================== alarm ==================================*/ |
---|
382 | #ifndef __MWERKS__ |
---|
383 | #ifndef MSDOS |
---|
384 | #ifndef atarist |
---|
385 | #ifdef unix |
---|
386 | if(strcmp((char*)(h->Data()),"alarm")==0) |
---|
387 | { |
---|
388 | if ((h->next!=NULL) &&(h->next->Typ()==INT_CMD)) |
---|
389 | { |
---|
390 | // standard variant -> SIGALARM (standard: abort) |
---|
391 | //alarm((unsigned)h->next->Data()); |
---|
392 | // process time (user +system): SIGVTALARM |
---|
393 | struct itimerval t,o; |
---|
394 | memset(&t,0,sizeof(t)); |
---|
395 | t.it_value.tv_sec =(unsigned)h->next->Data(); |
---|
396 | setitimer(ITIMER_VIRTUAL,&t,&o); |
---|
397 | return FALSE; |
---|
398 | } |
---|
399 | else |
---|
400 | WerrorS("int expected"); |
---|
401 | } |
---|
402 | else |
---|
403 | #endif |
---|
404 | #endif |
---|
405 | #endif |
---|
406 | #endif |
---|
407 | /*==================== red =============================*/ |
---|
408 | #if 0 |
---|
409 | if(strcmp((char*)(h->Data()),"red")==0) |
---|
410 | { |
---|
411 | if ((h->next!=NULL) &&(h->next->Typ()==IDEAL_CMD)) |
---|
412 | { |
---|
413 | res->rtyp=IDEAL_CMD; |
---|
414 | res->data=(void *)kStdred((ideal)h->next->Data(),NULL,testHomog,NULL); |
---|
415 | setFlag(res,FLAG_STD); |
---|
416 | return FALSE; |
---|
417 | } |
---|
418 | else |
---|
419 | WerrorS("ideal expected"); |
---|
420 | } |
---|
421 | else |
---|
422 | #endif |
---|
423 | #ifdef HAVE_FACTORY |
---|
424 | /*==================== pdivide ====================*/ |
---|
425 | if (strcmp((char*)(h->Data()),"pdivide")==0) |
---|
426 | { |
---|
427 | if (h->next!=NULL && h->next->next!=NULL && |
---|
428 | h->next->Typ()==POLY_CMD && h->next->next->Typ()==POLY_CMD) |
---|
429 | { |
---|
430 | res->rtyp=POLY_CMD; |
---|
431 | res->data=(void*)(singclap_pdivide((poly)(h->next->Data()), |
---|
432 | (poly)(h->next->next->Data()))); |
---|
433 | return FALSE; |
---|
434 | } |
---|
435 | else |
---|
436 | WerrorS("poly expected"); |
---|
437 | } |
---|
438 | else |
---|
439 | #endif |
---|
440 | /*==================== algfetch =====================*/ |
---|
441 | if (strcmp((char*)(h->Data()),"algfetch")==0) |
---|
442 | { |
---|
443 | int k; |
---|
444 | idhdl w; |
---|
445 | ideal i0, i1; |
---|
446 | leftv v=h->next; |
---|
447 | ring r0=(ring)v->Data(); |
---|
448 | v = v->next; |
---|
449 | w = r0->idroot->get(v->Name(),myynest); |
---|
450 | i0 = IDIDEAL(w); |
---|
451 | i1 = idInit(IDELEMS(i0),i0->rank); |
---|
452 | for (k=0; k<IDELEMS(i1); k++) |
---|
453 | { |
---|
454 | i1->m[k] = maAlgpolyFetch(r0, i0->m[k]); |
---|
455 | } |
---|
456 | res->rtyp = IDEAL_CMD; |
---|
457 | res->data = (void*)i1; |
---|
458 | return FALSE; |
---|
459 | } |
---|
460 | else |
---|
461 | /*==================== algmap =======================*/ |
---|
462 | if (strcmp((char*)(h->Data()),"algmap")==0) |
---|
463 | { |
---|
464 | int k; |
---|
465 | idhdl w; |
---|
466 | ideal i0, i1, i, j; |
---|
467 | leftv v=h->next; |
---|
468 | ring r0=(ring)v->Data(); |
---|
469 | v = v->next; |
---|
470 | w = r0->idroot->get(v->Name(),myynest); |
---|
471 | i0 = IDIDEAL(w); |
---|
472 | v = v->next; |
---|
473 | i = (ideal)v->Data(); |
---|
474 | v = v->next; |
---|
475 | j = (ideal)v->Data(); |
---|
476 | i1 = idInit(IDELEMS(i0),i0->rank); |
---|
477 | for (k=0; k<IDELEMS(i1); k++) |
---|
478 | { |
---|
479 | i1->m[k] = maAlgpolyMap(r0, i0->m[k], i, j); |
---|
480 | } |
---|
481 | res->rtyp = IDEAL_CMD; |
---|
482 | res->data = (void*)i1; |
---|
483 | return FALSE; |
---|
484 | } |
---|
485 | else |
---|
486 | /*==================== indsetall =============================*/ |
---|
487 | if(strcmp((char*)(h->Data()),"indsetall")==0) |
---|
488 | { |
---|
489 | if ((h->next!=NULL) &&(h->next->Typ()==IDEAL_CMD)) |
---|
490 | { |
---|
491 | int i=0; |
---|
492 | if (h->next->next!=NULL) |
---|
493 | { |
---|
494 | if (h->next->next->Typ()==INT_CMD) |
---|
495 | i=(int)h->next->next->Data(); |
---|
496 | else |
---|
497 | { |
---|
498 | Warn("int expected"); |
---|
499 | } |
---|
500 | } |
---|
501 | res->rtyp=LIST_CMD; |
---|
502 | res->data=(void *)scIndIndset((ideal)h->next->Data(),i,currQuotient); |
---|
503 | return FALSE; |
---|
504 | } |
---|
505 | else |
---|
506 | WerrorS("ideal expected"); |
---|
507 | } |
---|
508 | else |
---|
509 | #ifdef STDTRACE |
---|
510 | /*==================== trace =============================*/ |
---|
511 | /* Parameter : Ideal, Liste mit Links. */ |
---|
512 | if(strcmp((char*)(h->Data()),"stdtrace")==0) |
---|
513 | { |
---|
514 | if ((h->next!=NULL) &&(h->next->Typ()==IDEAL_CMD)) |
---|
515 | { |
---|
516 | leftv root = NULL, |
---|
517 | ptr = NULL, |
---|
518 | lv = NULL; |
---|
519 | lists l = NULL; |
---|
520 | ideal I = (ideal)(h->next->Data()); |
---|
521 | lists links = (lists)(h->next->next->Data()); |
---|
522 | tHomog hom = testHomog; |
---|
523 | int rw = (int)(h->next->next->next->Data()); |
---|
524 | |
---|
525 | if(I==NULL) |
---|
526 | PrintS("I==NULL\n"); |
---|
527 | for(int i=0; i <= links->nr ; i++) |
---|
528 | { |
---|
529 | lv = (leftv)Alloc0(sizeof(sleftv)); |
---|
530 | lv->Copy(&(links->m[i])); |
---|
531 | if(root==NULL) |
---|
532 | root=lv; |
---|
533 | if(ptr==NULL) |
---|
534 | { |
---|
535 | ptr=lv; |
---|
536 | ptr->next=NULL; |
---|
537 | } |
---|
538 | else |
---|
539 | { |
---|
540 | ptr->next=lv; |
---|
541 | ptr=lv; |
---|
542 | } |
---|
543 | } |
---|
544 | ptr->next=NULL; |
---|
545 | l=TraceStd(root,rw,I,currQuotient,testHomog,NULL); |
---|
546 | idSkipZeroes(((ideal)l->m[0].Data())); |
---|
547 | res->rtyp=LIST_CMD; |
---|
548 | res->data=(void *) l; |
---|
549 | res->next=NULL; |
---|
550 | root->CleanUp(); |
---|
551 | Free(root,sizeof(sleftv)); |
---|
552 | return FALSE; |
---|
553 | } |
---|
554 | else |
---|
555 | WerrorS("ideal expected"); |
---|
556 | } |
---|
557 | else |
---|
558 | #endif |
---|
559 | #ifdef HAVE_FACTORY |
---|
560 | /*==================== fastcomb =============================*/ |
---|
561 | if(strcmp((char*)(h->Data()),"fastcomb")==0) |
---|
562 | { |
---|
563 | if ((h->next!=NULL) &&(h->next->Typ()==IDEAL_CMD)) |
---|
564 | { |
---|
565 | int i=0; |
---|
566 | if (h->next->next!=NULL) |
---|
567 | { |
---|
568 | if (h->next->next->Typ()!=POLY_CMD) |
---|
569 | { |
---|
570 | Warn("Wrong types for poly= comb(ideal,poly)"); |
---|
571 | } |
---|
572 | } |
---|
573 | res->rtyp=POLY_CMD; |
---|
574 | res->data=(void *)fglmLinearCombination((ideal)h->next->Data(),(poly)h->next->next->Data()); |
---|
575 | return FALSE; |
---|
576 | } |
---|
577 | else |
---|
578 | WerrorS("ideal expected"); |
---|
579 | } |
---|
580 | else |
---|
581 | /*==================== comb =============================*/ |
---|
582 | if(strcmp((char*)(h->Data()),"comb")==0) |
---|
583 | { |
---|
584 | if ((h->next!=NULL) &&(h->next->Typ()==IDEAL_CMD)) |
---|
585 | { |
---|
586 | int i=0; |
---|
587 | if (h->next->next!=NULL) |
---|
588 | { |
---|
589 | if (h->next->next->Typ()!=POLY_CMD) |
---|
590 | { |
---|
591 | Warn("Wrong types for poly= comb(ideal,poly)"); |
---|
592 | } |
---|
593 | } |
---|
594 | res->rtyp=POLY_CMD; |
---|
595 | res->data=(void *)fglmNewLinearCombination((ideal)h->next->Data(),(poly)h->next->next->Data()); |
---|
596 | return FALSE; |
---|
597 | } |
---|
598 | else |
---|
599 | WerrorS("ideal expected"); |
---|
600 | } |
---|
601 | else |
---|
602 | #endif |
---|
603 | /*==================== barstep =============================*/ |
---|
604 | if(strcmp((char*)(h->Data()),"barstep")==0) |
---|
605 | { |
---|
606 | if ((h->next!=NULL) &&(h->next->Typ()==MATRIX_CMD)) |
---|
607 | { |
---|
608 | if (h->next->next!=NULL) |
---|
609 | { |
---|
610 | if (h->next->next->Typ()!=POLY_CMD) |
---|
611 | { |
---|
612 | Warn("Wrong types for barstep(matrix,poly)"); |
---|
613 | } |
---|
614 | } |
---|
615 | int r,c; |
---|
616 | poly div=(poly)h->next->next->Data(); |
---|
617 | res->rtyp=MATRIX_CMD; |
---|
618 | res->data=(void *)mpOneStepBareiss((matrix)h->next->Data(), |
---|
619 | &div,&r,&c); |
---|
620 | Print("div: ");pWrite(div); |
---|
621 | Print("rows: %d, cols: %d\n",r,c); |
---|
622 | pDelete(&div); |
---|
623 | return FALSE; |
---|
624 | } |
---|
625 | else |
---|
626 | WerrorS("matrix expected"); |
---|
627 | } |
---|
628 | else |
---|
629 | #ifdef FACTORY_GCD_TEST |
---|
630 | /*=======================gcd Testerei ================================*/ |
---|
631 | if ( ! strcmp( (char*)(h->Data()), "setgcd" ) ) { |
---|
632 | if ( (h->next != NULL) && (h->next->Typ() == INT_CMD) ) { |
---|
633 | CFPrimitiveGcdUtil::setAlgorithm( (int)h->next->Data() ); |
---|
634 | return FALSE; |
---|
635 | } else |
---|
636 | WerrorS("int expected"); |
---|
637 | } |
---|
638 | else |
---|
639 | #endif |
---|
640 | |
---|
641 | #ifdef FACTORY_GCD_TIMING |
---|
642 | if ( ! strcmp( (char*)(h->Data()), "gcdtime" ) ) { |
---|
643 | TIMING_PRINT( contentTimer, "time used for content: " ); |
---|
644 | TIMING_PRINT( algContentTimer, "time used for algContent: " ); |
---|
645 | TIMING_PRINT( algLcmTimer, "time used for algLcm: " ); |
---|
646 | TIMING_RESET( contentTimer ); |
---|
647 | TIMING_RESET( algContentTimer ); |
---|
648 | TIMING_RESET( algLcmTimer ); |
---|
649 | return FALSE; |
---|
650 | } |
---|
651 | else |
---|
652 | #endif |
---|
653 | |
---|
654 | #ifdef FACTORY_GCD_STAT |
---|
655 | if ( ! strcmp( (char*)(h->Data()), "gcdstat" ) ) { |
---|
656 | printGcdTotal(); |
---|
657 | printContTotal(); |
---|
658 | resetGcdTotal(); |
---|
659 | resetContTotal(); |
---|
660 | return FALSE; |
---|
661 | } |
---|
662 | else |
---|
663 | #endif |
---|
664 | /*==================== lib ==================================*/ |
---|
665 | if(strcmp((char*)(h->Data()),"LIB")==0) |
---|
666 | { |
---|
667 | #ifdef HAVE_NAMESPACES |
---|
668 | idhdl hh=namespaceroot->get((char*)h->next->Data(),0); |
---|
669 | #else /* HAVE_NAMESPACES */ |
---|
670 | idhdl hh=idroot->get((char*)h->next->Data(),0); |
---|
671 | #endif /* HAVE_NAMESPACES */ |
---|
672 | if ((hh!=NULL)&&(IDTYP(hh)==PROC_CMD)) |
---|
673 | { |
---|
674 | res->rtyp=STRING_CMD; |
---|
675 | res->data=mstrdup(iiGetLibName(IDPROC(hh))); |
---|
676 | if (res->data==NULL) res->data=mstrdup(""); |
---|
677 | return FALSE; |
---|
678 | } |
---|
679 | else |
---|
680 | Warn("`%s` not found",(char*)h->next->Data()); |
---|
681 | } |
---|
682 | else |
---|
683 | #ifdef HAVE_NAMESPACES |
---|
684 | /*==================== nspush ===================================*/ |
---|
685 | if(strcmp((char*)(h->Data()),"nspush")==0) |
---|
686 | { |
---|
687 | idhdl hh=namespaceroot->get((char*)h->next->Data(),0, TRUE); |
---|
688 | if ((hh!=NULL)&&(IDTYP(hh)==PACKAGE_CMD)) |
---|
689 | { |
---|
690 | namespaceroot = namespaceroot->push(IDPACKAGE(hh), IDID(hh)); |
---|
691 | return FALSE; |
---|
692 | } |
---|
693 | else |
---|
694 | Warn("package `%s` not found",(char*)h->next->Data()); |
---|
695 | } |
---|
696 | else |
---|
697 | /*==================== nspop ====================================*/ |
---|
698 | if(strcmp((char*)(h->Data()),"nspop")==0) |
---|
699 | { |
---|
700 | namespaceroot->pop(); |
---|
701 | return FALSE; |
---|
702 | } |
---|
703 | else |
---|
704 | /*==================== nsstack ===================================*/ |
---|
705 | if(strcmp((char*)(h->Data()),"nsstack")==0) |
---|
706 | { |
---|
707 | namehdl nshdl = namespaceroot; |
---|
708 | for( ; nshdl->isroot != TRUE; nshdl = nshdl->next) { |
---|
709 | Print("NSstack: %s:%d\n", nshdl->name, nshdl->lev); |
---|
710 | } |
---|
711 | Print("NSstack: %s:%d\n", nshdl->name, nshdl->lev); |
---|
712 | return FALSE; |
---|
713 | } |
---|
714 | else |
---|
715 | #endif /* HAVE_NAMESPACES */ |
---|
716 | /*==================== proclist =================================*/ |
---|
717 | if(strcmp((char*)(h->Data()),"proclist")==0) |
---|
718 | { |
---|
719 | //res->rtyp=STRING_CMD; |
---|
720 | //res->data=(void *)mstrdup(""); |
---|
721 | piShowProcList(); |
---|
722 | return FALSE; |
---|
723 | } |
---|
724 | else |
---|
725 | #ifdef HAVE_DYNAMIC_LOADING |
---|
726 | /*==================== load ==================================*/ |
---|
727 | if(strcmp((char*)(h->Data()),"load")==0) |
---|
728 | { |
---|
729 | if ((h->next!=NULL) && (h->next->Typ()==STRING_CMD)) { |
---|
730 | int iiAddCproc(char *libname, char *procname, BOOLEAN pstatic, |
---|
731 | BOOLEAN(*func)(leftv res, leftv v)); |
---|
732 | int (*fktn)(int(*iiAddCproc)(char *libname, char *procname, |
---|
733 | BOOLEAN pstatic, |
---|
734 | BOOLEAN(*func)(leftv res, leftv v))); |
---|
735 | void *vp; |
---|
736 | res->rtyp=STRING_CMD; |
---|
737 | |
---|
738 | fprintf(stderr, "Loading %s\n", h->next->Data()); |
---|
739 | res->data=(void *)mstrdup(""); |
---|
740 | if((vp=dlopen(h->next->Data(),RTLD_LAZY))==(void *)NULL) { |
---|
741 | WerrorS("dlopen failed"); |
---|
742 | Werror("%s not found", h->next->Data()); |
---|
743 | } else { |
---|
744 | fktn = dlsym(vp, "mod_init"); |
---|
745 | if( fktn!= NULL) (*fktn)(iiAddCproc); |
---|
746 | else Werror("mod_init: %s\n", dlerror()); |
---|
747 | piShowProcList(); |
---|
748 | } |
---|
749 | return FALSE; |
---|
750 | } |
---|
751 | else WerrorS("string expected"); |
---|
752 | } |
---|
753 | else |
---|
754 | #endif /* HAVE_DYNAMIC_LOADING */ |
---|
755 | /*==================== print all option values =================*/ |
---|
756 | #ifndef NDEBUG |
---|
757 | if (strcmp((char*)(h->data), "options") == 0) |
---|
758 | { |
---|
759 | void mainOptionValues(); |
---|
760 | mainOptionValues(); |
---|
761 | return FALSE; |
---|
762 | } |
---|
763 | else |
---|
764 | #endif |
---|
765 | #endif // HAVE_EXTENDED_SYSTEM |
---|
766 | /*============================================================*/ |
---|
767 | WerrorS( feNotImplemented ); |
---|
768 | } |
---|
769 | return TRUE; |
---|
770 | } |
---|