Changeset 48ef1b7 in git


Ignore:
Timestamp:
Apr 27, 1998, 5:00:50 PM (26 years ago)
Author:
Kai Krüger <krueger@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
20e38e12826eb51bd172dbde212f3fe280ede7f2
Parents:
1d110184c43ad191d6eb86c741b1c450e6d5846c
Message:
Added nspush,nspop,nsstack calls for namespaces
Added load call for dynamic-modules


git-svn-id: file:///usr/local/Singular/svn/trunk@1491 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/extra.cc

    r1d1101 r48ef1b7  
    22*  Computer Algebra System SINGULAR      *
    33*****************************************/
    4 /* $Id: extra.cc,v 1.41 1998-04-27 12:34:11 obachman Exp $ */
     4/* $Id: extra.cc,v 1.42 1998-04-27 15:00:50 krueger Exp $ */
    55/*
    66* ABSTRACT: general interface to internals of Singular ("system" command)
     
    6666#include "mpsr.h"
    6767
     68#ifdef HAVE_DYNAMIC_LOADING
     69#include <dlfcn.h>
     70#endif /* HAVE_DYNAMIC_LOADING */
     71
    6872// see clapsing.cc for a description of the `FACTORY_*' options
    6973
     
    7983TIMING_DEFINE_PRINTPROTO( algLcmTimer );
    8084#endif
     85
     86void piShowProcList();
    8187
    8288//void emStart();
     
    9197    if(strcmp((char*)(h->Data()),"LIB")==0)
    9298    {
     99#ifdef HAVE_NAMESPACES
     100      idhdl hh=namespaceroot->get((char*)h->next->Data(),0);
     101#else /* HAVE_NAMESPACES */
    93102      idhdl hh=idroot->get((char*)h->next->Data(),0);
     103#endif /* HAVE_NAMESPACES */
    94104      if ((hh!=NULL)&&(IDTYP(hh)==PROC_CMD))
    95105      {
     
    103113    }
    104114    else
     115#ifdef HAVE_NAMESPACES
     116/*==================== nspush ===================================*/
     117    if(strcmp((char*)(h->Data()),"nspush")==0)
     118    {
     119      idhdl hh=namespaceroot->get((char*)h->next->Data(),0, TRUE);
     120      if ((hh!=NULL)&&(IDTYP(hh)==PACKAGE_CMD))
     121      {
     122        namespaceroot = namespaceroot->push(IDPACKAGE(hh), IDID(hh));
     123        return FALSE;
     124      } else
     125        Warn("package `%s` not found",(char*)h->next->Data());
     126    }
     127    else
     128/*==================== nspop ====================================*/
     129    if(strcmp((char*)(h->Data()),"nspop")==0)
     130    {
     131      namespaceroot->pop();
     132      return FALSE;
     133    }
     134    else
     135/*==================== nsstack ===================================*/
     136    if(strcmp((char*)(h->Data()),"nsstack")==0)
     137    {
     138      namehdl nshdl = namespaceroot;
     139      for( ; nshdl->isroot != TRUE; nshdl = nshdl->next) {
     140        Print("NSstack: %s:%d\n", nshdl->name, nshdl->lev);
     141      }
     142      Print("NSstack: %s:%d\n", nshdl->name, nshdl->lev);
     143      return FALSE;
     144    }
     145    else
     146#endif /* HAVE_NAMESPACES */
    105147/*==================== proclist =================================*/
    106148    if(strcmp((char*)(h->Data()),"proclist")==0)
    107149    {
    108       void piShowProcList();
    109150      //res->rtyp=STRING_CMD;
    110151      //res->data=(void *)mstrdup("");
     
    121162    }
    122163    else
     164#ifdef HAVE_DYNAMIC_LOADING
     165/*==================== load ==================================*/
     166    if(strcmp((char*)(h->Data()),"load")==0)
     167    {
     168      if ((h->next!=NULL) && (h->next->Typ()==STRING_CMD)) {
     169        int iiAddCproc(char *libname, char *procname, BOOLEAN pstatic,
     170                       BOOLEAN(*func)(leftv res, leftv v));
     171        int (*fktn)(int(*iiAddCproc)(char *libname, char *procname,
     172                                     BOOLEAN pstatic,
     173                                     BOOLEAN(*func)(leftv res, leftv v)));
     174        void *vp;
     175        res->rtyp=STRING_CMD;
     176
     177        fprintf(stderr, "Loading %s\n", h->next->Data());
     178        res->data=(void *)mstrdup("");
     179        if((vp=dlopen(h->next->Data(),RTLD_LAZY))==(void *)NULL) {
     180          WerrorS("dlopen failed");
     181          Werror("%s not found", h->next->Data());
     182        } else {
     183          fktn = dlsym(vp, "mod_init");
     184          if( fktn!= NULL) (*fktn)(iiAddCproc);
     185          else Werror("mod_init: %s\n", dlerror());
     186          piShowProcList();
     187        }
     188        return FALSE;
     189      }
     190      else WerrorS("string expected");
     191    }
     192    else
     193#endif /* HAVE_DYNAMIC_LOADING */
    123194/*==================== gen ==================================*/
    124195    if(strcmp((char*)(h->Data()),"gen")==0)
Note: See TracChangeset for help on using the changeset viewer.