source: git/Singular/extra.cc @ 50abaf2

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