Macros | Functions | Variables
iplib.cc File Reference
#include "kernel/mod2.h"
#include "Singular/tok.h"
#include "misc/options.h"
#include "Singular/ipid.h"
#include "polys/monomials/ring.h"
#include "Singular/subexpr.h"
#include "Singular/ipshell.h"
#include "Singular/fevoices.h"
#include "Singular/lists.h"
#include <ctype.h>
#include "libparse.h"
#include "Singular/mod_lib.h"

Go to the source code of this file.

Macros

#define SI_MAX_NEST   500
 
#define MODULE_SUFFIX   so
 
#define MODULE_SUFFIX_STRING   EXPANDED_STRINGIFY(MODULE_SUFFIX)
 
#define SI_GET_BUILTIN_MOD_INIT0(name)   int SI_MOD_INIT0(name)(SModulFunctions*);
 
#define SI_GET_BUILTIN_MOD_INIT(name)   if (strcmp(libname, #name ".so") == 0){ return SI_MOD_INIT0(name); }
 

Functions

BOOLEAN load_modules (const char *newlib, char *fullname, BOOLEAN autoexport)
 
int iiArithAddCmd (const char *szName, short nAlias, short nTokval, short nToktype, short nPos)
 
void yylprestart (FILE *input_file)
 
int current_pos (int i=0)
 
void print_init ()
 
char mytolower (char c)
 
BOOLEAN iiGetLibStatus (char *lib)
 
char * iiProcName (char *buf, char &ct, char *&e)
 
char * iiProcArgs (char *e, BOOLEAN withParenth)
 
char * iiGetLibProcBuffer (procinfo *pi, int part)
 
BOOLEAN iiAllStart (procinfov pi, char *p, feBufferTypes t, int l)
 
BOOLEAN iiPStart (idhdl pn, leftv v)
 
static void iiShowLevRings ()
 
static void iiCheckNest ()
 
BOOLEAN iiMake_proc (idhdl pn, package pack, leftv sl)
 
static void iiCallLibProcBegin ()
 
static void iiCallLibProcEnd (idhdl save_ringhdl, ring save_ring)
 
void * iiCallLibProc1 (const char *n, void *arg, int arg_type, BOOLEAN &err)
 
void * iiCallLibProcM (const char *n, void **args, int *arg_types, BOOLEAN &err)
 args: NULL terminated arry of arguments arg_types: 0 terminated array of corresponding types More...
 
BOOLEAN iiEStart (char *example, procinfo *pi)
 
 SI_FOREACH_BUILTIN (SI_GET_BUILTIN_MOD_INIT0) }
 
SModulFunc_t iiGetBuiltinModInit (const char *libname)
 
BOOLEAN iiTryLoadLib (leftv v, const char *id)
 
BOOLEAN iiLocateLib (const char *lib, char *where)
 
BOOLEAN iiLibCmd (char *newlib, BOOLEAN autoexport, BOOLEAN tellerror, BOOLEAN force)
 
static void iiCleanProcs (idhdl &root)
 
static void iiRunInit (package p)
 
BOOLEAN iiLoadLIB (FILE *fp, const char *libnamebuf, const char *newlib, idhdl pl, BOOLEAN autoexport, BOOLEAN tellerror)
 
procinfoiiInitSingularProcinfo (procinfov pi, const char *libname, const char *procname, int, long pos, BOOLEAN pstatic)
 
int iiAddCproc (const char *libname, const char *procname, BOOLEAN pstatic, BOOLEAN(*func)(leftv res, leftv v))
 
int iiAddCprocTop (const char *libname, const char *procname, BOOLEAN pstatic, BOOLEAN(*func)(leftv res, leftv v))
 
BOOLEAN load_builtin (const char *newlib, BOOLEAN autoexport, SModulFunc_t init)
 
void module_help_main (const char *newlib, const char *help)
 
void module_help_proc (const char *newlib, const char *p, const char *help)
 
void * binary_module_function (const char *newlib, const char *funcname)
 
char mytoupper (char c)
 
char * iiConvName (const char *libname)
 

Variables

int yylp_errno
 
int yylplineno
 
char * yylp_errlist []
 
libstackv library_stack
 
ring * iiLocalRing
 
sleftv iiRETURNEXPR
 
int iiRETURNEXPR_len =0
 

Macro Definition Documentation

◆ MODULE_SUFFIX

#define MODULE_SUFFIX   so

Definition at line 35 of file iplib.cc.

◆ MODULE_SUFFIX_STRING

#define MODULE_SUFFIX_STRING   EXPANDED_STRINGIFY(MODULE_SUFFIX)

Definition at line 38 of file iplib.cc.

◆ SI_GET_BUILTIN_MOD_INIT

#define SI_GET_BUILTIN_MOD_INIT (   name)    if (strcmp(libname, #name ".so") == 0){ return SI_MOD_INIT0(name); }

◆ SI_GET_BUILTIN_MOD_INIT0

#define SI_GET_BUILTIN_MOD_INIT0 (   name)    int SI_MOD_INIT0(name)(SModulFunctions*);

Definition at line 743 of file iplib.cc.

◆ SI_MAX_NEST

#define SI_MAX_NEST   500

Definition at line 23 of file iplib.cc.

Function Documentation

◆ binary_module_function()

void* binary_module_function ( const char *  newlib,
const char *  funcname 
)

Definition at line 1288 of file iplib.cc.

1289 {
1290  void* result = NULL;
1291 
1292  const char* bin_dir = feGetResource('b');
1293  if (!bin_dir) { return NULL; }
1294 
1295  char path_name[MAXPATHLEN];
1296  sprintf(path_name, "%s%s%s.%s", bin_dir, DIR_SEPP, newlib, MODULE_SUFFIX_STRING);
1297 
1298  void* openlib = dynl_open(path_name);
1299  if(!openlib)
1300  {
1301  Werror("dynl_open of %s failed:%s", path_name, dynl_error());
1302  return NULL;
1303  }
1304  result = dynl_sym(openlib, funcname);
1305  if (!result) Werror("%s: %s\n", funcname, dynl_error());
1306 
1307  return result;
1308 }
#define MAXPATHLEN
Definition: omRet2Info.c:22
void * dynl_sym(void *handle, const char *symbol)
Definition: mod_raw.cc:159
void * dynl_open(char *filename)
Definition: mod_raw.cc:145
char * feGetResource(const char id, int warn)
Definition: feResource.cc:155
#define DIR_SEPP
Definition: feResource.h:7
#define MODULE_SUFFIX_STRING
Definition: iplib.cc:38
#define NULL
Definition: omList.c:12
void Werror(const char *fmt,...)
Definition: reporter.cc:189
return result
Definition: facAbsBiFact.cc:76
const char * dynl_error()
Definition: mod_raw.cc:175

◆ current_pos()

int current_pos ( int  i = 0)

Definition at line 3344 of file libparse.cc.

3345 {
3346  return(i+offset+(int)(yytext-yylp_buffer_start));
3347 }
#define yytext
Definition: libparse.cc:16
int i
Definition: cfEzgcd.cc:125
char * yylp_buffer_start
Definition: libparse.cc:1100
int offset
Definition: libparse.cc:1091

◆ iiAddCproc()

int iiAddCproc ( const char *  libname,
const char *  procname,
BOOLEAN  pstatic,
BOOLEAN(*)(leftv res, leftv v func 
)

Definition at line 1004 of file iplib.cc.

1006 {
1007  procinfov pi;
1008  idhdl h;
1009 
1010  #ifndef SING_NDEBUG
1011  int dummy;
1012  if (IsCmd(procname,dummy))
1013  {
1014  Werror(">>%s< is a reserved name",procname);
1015  return 0;
1016  }
1017  #endif
1018 
1019  h=IDROOT->get(procname,0);
1020  if ((h!=NULL)
1021  && (IDTYP(h)==PROC_CMD))
1022  {
1023  pi = IDPROC(h);
1024  if ((pi->language == LANG_SINGULAR)
1025  &&(BVERBOSE(V_REDEFINE)))
1026  Warn("extend `%s`",procname);
1027  }
1028  else
1029  {
1030  h = enterid(procname,0, PROC_CMD, &IDROOT, TRUE);
1031  }
1032  if ( h!= NULL )
1033  {
1034  pi = IDPROC(h);
1035  if((pi->language == LANG_SINGULAR)
1036  ||(pi->language == LANG_NONE))
1037  {
1038  omfree(pi->libname);
1039  pi->libname = omStrDup(libname);
1040  omfree(pi->procname);
1041  pi->procname = omStrDup(procname);
1042  pi->language = LANG_C;
1043  pi->ref = 1;
1044  pi->is_static = pstatic;
1045  pi->data.o.function = func;
1046  }
1047  else if(pi->language == LANG_C)
1048  {
1049  if(pi->data.o.function == func)
1050  {
1051  pi->ref++;
1052  }
1053  else
1054  {
1055  omfree(pi->libname);
1056  pi->libname = omStrDup(libname);
1057  omfree(pi->procname);
1058  pi->procname = omStrDup(procname);
1059  pi->language = LANG_C;
1060  pi->ref = 1;
1061  pi->is_static = pstatic;
1062  pi->data.o.function = func;
1063  }
1064  }
1065  else
1066  Warn("internal error: unknown procedure type %d",pi->language);
1067  if (currPack->language==LANG_SINGULAR) currPack->language=LANG_MIX;
1068  return(1);
1069  }
1070  else
1071  {
1072  WarnS("iiAddCproc: failed.");
1073  }
1074  return(0);
1075 }
language_defs language
Definition: subexpr.h:59
#define IDROOT
Definition: ipid.h:18
#define TRUE
Definition: auxiliary.h:98
short ref
Definition: subexpr.h:60
#define WarnS
Definition: emacs.cc:78
Definition: idrec.h:34
char * procname
Definition: subexpr.h:57
Definition: subexpr.h:22
#define IDTYP(a)
Definition: ipid.h:114
idhdl enterid(const char *s, int lev, int t, idhdl *root, BOOLEAN init, BOOLEAN search)
Definition: ipid.cc:265
char * libname
Definition: subexpr.h:56
#define omfree(addr)
Definition: omAllocDecl.h:237
procinfodata data
Definition: subexpr.h:63
#define BVERBOSE(a)
Definition: options.h:35
char is_static
Definition: subexpr.h:61
#define IDPROC(a)
Definition: ipid.h:135
#define pi
Definition: libparse.cc:1143
#define NULL
Definition: omList.c:12
package currPack
Definition: ipid.cc:57
static Poly * h
Definition: janet.cc:971
#define V_REDEFINE
Definition: options.h:45
void Werror(const char *fmt,...)
Definition: reporter.cc:189
int IsCmd(const char *n, int &tok)
Definition: iparith.cc:8897
#define Warn
Definition: emacs.cc:77
#define omStrDup(s)
Definition: omAllocDecl.h:263

◆ iiAddCprocTop()

int iiAddCprocTop ( const char *  libname,
const char *  procname,
BOOLEAN  pstatic,
BOOLEAN(*)(leftv res, leftv v func 
)

Definition at line 1077 of file iplib.cc.

1079 {
1080  int r=iiAddCproc(libname,procname,pstatic,func);
1081  package s=currPack;
1083  if (r) r=iiAddCproc(libname,procname,pstatic,func);
1084  currPack=s;
1085  return r;
1086 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
package basePack
Definition: ipid.cc:58
package currPack
Definition: ipid.cc:57
int iiAddCproc(const char *libname, const char *procname, BOOLEAN pstatic, BOOLEAN(*func)(leftv res, leftv v))
Definition: iplib.cc:1004

◆ iiAllStart()

BOOLEAN iiAllStart ( procinfov  pi,
char *  p,
feBufferTypes  t,
int  l 
)

Definition at line 292 of file iplib.cc.

293 {
294  // see below:
295  BITSET save1=si_opt_1;
296  BITSET save2=si_opt_2;
297  newBuffer( omStrDup(p /*pi->data.s.body*/), t /*BT_proc*/,
298  pi, l );
299  BOOLEAN err=yyparse();
300  if (sLastPrinted.rtyp!=0)
301  {
303  }
304  // the access to optionStruct and verboseStruct do not work
305  // on x86_64-Linux for pic-code
306  if ((TEST_V_ALLWARN) &&
307  (t==BT_proc) &&
308  ((save1!=si_opt_1)||(save2!=si_opt_2)) &&
309  (pi->libname!=NULL) && (pi->libname[0]!='\0'))
310  {
311  if ((pi->libname!=NULL) && (pi->libname[0]!='\0'))
312  Warn("option changed in proc %s from %s",pi->procname,pi->libname);
313  else
314  Warn("option changed in proc %s",pi->procname);
315  int i;
316  for (i=0; optionStruct[i].setval!=0; i++)
317  {
318  if ((optionStruct[i].setval & si_opt_1)
319  && (!(optionStruct[i].setval & save1)))
320  {
321  Print(" +%s",optionStruct[i].name);
322  }
323  if (!(optionStruct[i].setval & si_opt_1)
324  && ((optionStruct[i].setval & save1)))
325  {
326  Print(" -%s",optionStruct[i].name);
327  }
328  }
329  for (i=0; verboseStruct[i].setval!=0; i++)
330  {
331  if ((verboseStruct[i].setval & si_opt_2)
332  && (!(verboseStruct[i].setval & save2)))
333  {
334  Print(" +%s",verboseStruct[i].name);
335  }
336  if (!(verboseStruct[i].setval & si_opt_2)
337  && ((verboseStruct[i].setval & save2)))
338  {
339  Print(" -%s",verboseStruct[i].name);
340  }
341  }
342  PrintLn();
343  }
344  return err;
345 }
const struct soptionStruct optionStruct[]
Definition: misc_ip.cc:521
unsigned si_opt_1
Definition: options.c:5
void PrintLn()
Definition: reporter.cc:310
#define Print
Definition: emacs.cc:80
unsigned setval
Definition: ipid.h:148
#define BITSET
Definition: structs.h:20
char * procname
Definition: subexpr.h:57
char * libname
Definition: subexpr.h:56
int i
Definition: cfEzgcd.cc:125
char name(const Variable &v)
Definition: factory.h:180
int yyparse(void)
Definition: grammar.cc:2111
#define NULL
Definition: omList.c:12
int rtyp
Definition: subexpr.h:91
sleftv sLastPrinted
Definition: subexpr.cc:46
void CleanUp(ring r=currRing)
Definition: subexpr.cc:348
void newBuffer(char *s, feBufferTypes t, procinfo *pi, int lineno)
Definition: fevoices.cc:156
int p
Definition: cfModGcd.cc:4019
const struct soptionStruct verboseStruct[]
Definition: misc_ip.cc:551
unsigned si_opt_2
Definition: options.c:6
int BOOLEAN
Definition: auxiliary.h:85
#define TEST_V_ALLWARN
Definition: options.h:140
int l
Definition: cfEzgcd.cc:93
#define Warn
Definition: emacs.cc:77
#define omStrDup(s)
Definition: omAllocDecl.h:263

◆ iiArithAddCmd()

int iiArithAddCmd ( const char *  szName,
short  nAlias,
short  nTokval,
short  nToktype,
short  nPos 
)

Definition at line 9242 of file iparith.cc.

9249 {
9250  //printf("AddCmd(%s, %d, %d, %d, %d)\n", szName, nAlias,
9251  // nTokval, nToktype, nPos);
9252  if(nPos>=0)
9253  {
9254  // no checks: we rely on a correct generated code in iparith.inc
9255  assume((unsigned)nPos < sArithBase.nCmdAllocated);
9256  assume(szName!=NULL);
9257  sArithBase.sCmds[nPos].name = omStrDup(szName);
9258  sArithBase.sCmds[nPos].alias = nAlias;
9259  sArithBase.sCmds[nPos].tokval = nTokval;
9260  sArithBase.sCmds[nPos].toktype = nToktype;
9261  sArithBase.nCmdUsed++;
9262  //if(nTokval>0) sArithBase.nLastIdentifier++;
9263  }
9264  else
9265  {
9266  if(szName==NULL) return -1;
9267  int nIndex = iiArithFindCmd(szName);
9268  if(nIndex>=0)
9269  {
9270  Print("'%s' already exists at %d\n", szName, nIndex);
9271  return -1;
9272  }
9273 
9275  {
9276  /* needs to create new slots */
9277  unsigned long nSize = (sArithBase.nCmdAllocated+1)*sizeof(cmdnames);
9278  sArithBase.sCmds = (cmdnames *)omRealloc(sArithBase.sCmds, nSize);
9279  if(sArithBase.sCmds==NULL) return -1;
9281  }
9282  /* still free slots available */
9283  sArithBase.sCmds[sArithBase.nCmdUsed].name = omStrDup(szName);
9284  sArithBase.sCmds[sArithBase.nCmdUsed].alias = nAlias;
9285  sArithBase.sCmds[sArithBase.nCmdUsed].tokval = nTokval;
9286  sArithBase.sCmds[sArithBase.nCmdUsed].toktype = nToktype;
9287  sArithBase.nCmdUsed++;
9288 
9289  qsort(sArithBase.sCmds, sArithBase.nCmdUsed, sizeof(cmdnames),
9290  (&_gentable_sort_cmds));
9293  {
9294  if(sArithBase.sCmds[sArithBase.nLastIdentifier].tokval>=0) break;
9295  }
9296  //Print("L=%d\n", sArithBase.nLastIdentifier);
9297  }
9298  return 0;
9299 }
static int _gentable_sort_cmds(const void *a, const void *b)
compares to entry of cmdsname-list
Definition: iparith.cc:9075
#define Print
Definition: emacs.cc:80
unsigned nCmdAllocated
number of commands-slots allocated
Definition: iparith.cc:186
#define assume(x)
Definition: mod2.h:390
unsigned nLastIdentifier
valid indentifieres are slot 1..nLastIdentifier
Definition: iparith.cc:187
#define NULL
Definition: omList.c:12
unsigned nCmdUsed
number of commands used
Definition: iparith.cc:185
#define nSize(n)
Definition: numbers.h:39
static SArithBase sArithBase
Base entry for arithmetic.
Definition: iparith.cc:195
int iiArithFindCmd(const char *szName)
Definition: iparith.cc:9147
cmdnames * sCmds
array of existing commands
Definition: iparith.cc:180
#define omRealloc(addr, size)
Definition: omAllocDecl.h:225
#define omStrDup(s)
Definition: omAllocDecl.h:263

◆ iiCallLibProc1()

void* iiCallLibProc1 ( const char *  n,
void *  arg,
int  arg_type,
BOOLEAN err 
)

Definition at line 612 of file iplib.cc.

613 {
614  idhdl h=ggetid(n);
615  if ((h==NULL)
616  || (IDTYP(h)!=PROC_CMD))
617  {
618  err=2;
619  return NULL;
620  }
621  // ring handling
622  idhdl save_ringhdl=currRingHdl;
623  ring save_ring=currRing;
625  // argument:
626  sleftv tmp;
627  tmp.Init();
628  tmp.data=arg;
629  tmp.rtyp=arg_type;
630  // call proc
631  err=iiMake_proc(h,currPack,&tmp);
632  // clean up ring
633  iiCallLibProcEnd(save_ringhdl,save_ring);
634  // return
635  if (err==FALSE)
636  {
637  void*r=iiRETURNEXPR.data;
640  return r;
641  }
642  return NULL;
643 }
idhdl ggetid(const char *n)
Definition: ipid.cc:521
Class used for (list of) interpreter objects.
Definition: subexpr.h:82
#define FALSE
Definition: auxiliary.h:94
sleftv iiRETURNEXPR
Definition: iplib.cc:454
static void iiCallLibProcEnd(idhdl save_ringhdl, ring save_ring)
Definition: iplib.cc:587
void Init()
Definition: subexpr.h:107
Definition: idrec.h:34
void * data
Definition: subexpr.h:88
#define IDTYP(a)
Definition: ipid.h:114
idhdl currRingHdl
Definition: ipid.cc:59
static void iiCallLibProcBegin()
Definition: iplib.cc:569
BOOLEAN iiMake_proc(idhdl pn, package pack, leftv sl)
Definition: iplib.cc:484
#define NULL
Definition: omList.c:12
package currPack
Definition: ipid.cc:57
int rtyp
Definition: subexpr.h:91
void CleanUp(ring r=currRing)
Definition: subexpr.cc:348
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
static Poly * h
Definition: janet.cc:971

◆ iiCallLibProcBegin()

static void iiCallLibProcBegin ( )
static

Definition at line 569 of file iplib.cc.

570 {
571  idhdl tmp_ring=NULL;
572  if (currRing!=NULL)
573  {
575  {
576  // clean up things depending on currRingHdl:
578  sLastPrinted.Init();
579  // need to define a ring-hdl for currRingHdl
580  tmp_ring=enterid(" tmpRing",myynest,RING_CMD,&IDROOT,FALSE);
581  IDRING(tmp_ring)=currRing;
582  currRing->ref++;
583  rSetHdl(tmp_ring);
584  }
585  }
586 }
#define FALSE
Definition: auxiliary.h:94
#define IDROOT
Definition: ipid.h:18
void Init()
Definition: subexpr.h:107
Definition: idrec.h:34
int myynest
Definition: febase.cc:41
idhdl enterid(const char *s, int lev, int t, idhdl *root, BOOLEAN init, BOOLEAN search)
Definition: ipid.cc:265
idhdl currRingHdl
Definition: ipid.cc:59
#define NULL
Definition: omList.c:12
#define IDRING(a)
Definition: ipid.h:122
sleftv sLastPrinted
Definition: subexpr.cc:46
void CleanUp(ring r=currRing)
Definition: subexpr.cc:348
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
void rSetHdl(idhdl h)
Definition: ipshell.cc:5086

◆ iiCallLibProcEnd()

static void iiCallLibProcEnd ( idhdl  save_ringhdl,
ring  save_ring 
)
static

Definition at line 587 of file iplib.cc.

588 {
589  if ((currRing!=NULL)
590  &&(currRing!=save_ring))
591  {
592  currRing->ref--;
593  idhdl hh=IDROOT;
594  idhdl prev=NULL;
595  while((hh!=currRingHdl) && (hh!=NULL)) { prev=hh; hh=hh->next; }
596  if (hh!=NULL)
597  {
598  if (prev==NULL) IDROOT=hh->next;
599  else prev->next=hh->next;
600  omFree((ADDRESS)IDID(hh));
602  }
603  else
604  {
605  WarnS("internal: lost ring in iiCallLib");
606  }
607  }
608  currRingHdl=save_ringhdl;
609  currRing=save_ring;
610 }
#define IDID(a)
Definition: ipid.h:117
#define IDROOT
Definition: ipid.h:18
void * ADDRESS
Definition: auxiliary.h:133
#define WarnS
Definition: emacs.cc:78
Definition: idrec.h:34
omBin idrec_bin
Definition: ipid.cc:48
#define omFree(addr)
Definition: omAllocDecl.h:261
idhdl currRingHdl
Definition: ipid.cc:59
idhdl next
Definition: idrec.h:38
#define NULL
Definition: omList.c:12
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
#define omFreeBin(addr, bin)
Definition: omAllocDecl.h:259

◆ iiCallLibProcM()

void* iiCallLibProcM ( const char *  n,
void **  args,
int *  arg_types,
BOOLEAN err 
)

args: NULL terminated arry of arguments arg_types: 0 terminated array of corresponding types

Definition at line 646 of file iplib.cc.

647 {
648  idhdl h=ggetid(n);
649  if ((h==NULL)
650  || (IDTYP(h)!=PROC_CMD))
651  {
652  err=2;
653  return NULL;
654  }
655  // ring handling
656  idhdl save_ringhdl=currRingHdl;
657  ring save_ring=currRing;
659  // argument:
660  if (arg_types[0]!=0)
661  {
662  sleftv tmp;
663  leftv tt=&tmp;
664  int i=1;
665  tmp.Init();
666  tmp.data=args[0];
667  tmp.rtyp=arg_types[0];
668  while(arg_types[i]!=0)
669  {
670  tt->next=(leftv)omAlloc0(sizeof(sleftv));
671  tt=tt->next;
672  tt->rtyp=arg_types[i];
673  tt->data=args[i];
674  i++;
675  }
676  // call proc
677  err=iiMake_proc(h,currPack,&tmp);
678  }
679  else
680  // call proc
681  err=iiMake_proc(h,currPack,NULL);
682  // clean up ring
683  iiCallLibProcEnd(save_ringhdl,save_ring);
684  // return
685  if (err==FALSE)
686  {
687  void*r=iiRETURNEXPR.data;
690  return r;
691  }
692  return NULL;
693 }
idhdl ggetid(const char *n)
Definition: ipid.cc:521
Class used for (list of) interpreter objects.
Definition: subexpr.h:82
#define FALSE
Definition: auxiliary.h:94
sleftv iiRETURNEXPR
Definition: iplib.cc:454
static void iiCallLibProcEnd(idhdl save_ringhdl, ring save_ring)
Definition: iplib.cc:587
void Init()
Definition: subexpr.h:107
sleftv * leftv
Definition: structs.h:62
Definition: idrec.h:34
void * data
Definition: subexpr.h:88
#define IDTYP(a)
Definition: ipid.h:114
idhdl currRingHdl
Definition: ipid.cc:59
int i
Definition: cfEzgcd.cc:125
static void iiCallLibProcBegin()
Definition: iplib.cc:569
leftv next
Definition: subexpr.h:86
BOOLEAN iiMake_proc(idhdl pn, package pack, leftv sl)
Definition: iplib.cc:484
#define NULL
Definition: omList.c:12
package currPack
Definition: ipid.cc:57
int rtyp
Definition: subexpr.h:91
void CleanUp(ring r=currRing)
Definition: subexpr.cc:348
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
static Poly * h
Definition: janet.cc:971
#define omAlloc0(size)
Definition: omAllocDecl.h:211

◆ iiCheckNest()

static void iiCheckNest ( )
static

Definition at line 473 of file iplib.cc.

474 {
475  if (myynest >= iiRETURNEXPR_len-1)
476  {
478  iiRETURNEXPR_len*sizeof(ring),
479  (iiRETURNEXPR_len+16)*sizeof(ring));
480  memset(&(iiLocalRing[iiRETURNEXPR_len]),0,16*sizeof(ring));
481  iiRETURNEXPR_len+=16;
482  }
483 }
int iiRETURNEXPR_len
Definition: iplib.cc:455
#define omreallocSize(addr, o_size, size)
Definition: omAllocDecl.h:231
int myynest
Definition: febase.cc:41
ring * iiLocalRing
Definition: iplib.cc:453

◆ iiCleanProcs()

static void iiCleanProcs ( idhdl root)
static

Definition at line 869 of file iplib.cc.

870 {
871  idhdl prev=NULL;
872  loop
873  {
874  if (root==NULL) return;
875  if (IDTYP(root)==PROC_CMD)
876  {
877  procinfo *pi=(procinfo*)IDDATA(root);
878  if ((pi->language == LANG_SINGULAR)
879  && (pi->data.s.body_start == 0L))
880  {
881  // procinfo data incorrect:
882  // - no proc body can start at the beginning of the file
883  killhdl(root);
884  if (prev==NULL)
885  root=IDROOT;
886  else
887  {
888  root=prev;
889  prev=NULL;
890  }
891  continue;
892  }
893  }
894  prev=root;
895  root=IDNEXT(root);
896  }
897 }
#define IDNEXT(a)
Definition: ipid.h:113
language_defs language
Definition: subexpr.h:59
#define IDROOT
Definition: ipid.h:18
#define loop
Definition: structs.h:80
Definition: idrec.h:34
#define IDTYP(a)
Definition: ipid.h:114
procinfodata data
Definition: subexpr.h:63
#define pi
Definition: libparse.cc:1143
#define NULL
Definition: omList.c:12
void killhdl(idhdl h, package proot)
Definition: ipid.cc:384
#define IDDATA(a)
Definition: ipid.h:121

◆ iiConvName()

char* iiConvName ( const char *  libname)

Definition at line 1331 of file iplib.cc.

1332 {
1333  char *tmpname = omStrDup(libname);
1334  char *p = strrchr(tmpname, DIR_SEP);
1335  char *r;
1336  if(p==NULL) p = tmpname; else p++;
1337  // p is now the start of the file name (without path)
1338  r=p;
1339  while(isalnum(*r)||(*r=='_')) r++;
1340  // r point the the end of the main part of the filename
1341  *r = '\0';
1342  r = omStrDup(p);
1343  *r = mytoupper(*r);
1344  // printf("iiConvName: '%s' '%s' => '%s'\n", libname, tmpname, r);
1345  omFree((ADDRESS)tmpname);
1346 
1347  return(r);
1348 }
char mytoupper(char c)
Definition: iplib.cc:1312
void * ADDRESS
Definition: auxiliary.h:133
#define DIR_SEP
Definition: feResource.h:6
#define omFree(addr)
Definition: omAllocDecl.h:261
#define NULL
Definition: omList.c:12
int p
Definition: cfModGcd.cc:4019
#define omStrDup(s)
Definition: omAllocDecl.h:263

◆ iiEStart()

BOOLEAN iiEStart ( char *  example,
procinfo pi 
)

Definition at line 698 of file iplib.cc.

699 {
700  BOOLEAN err;
701  int old_echo=si_echo;
702 
703  iiCheckNest();
704  procstack->push(example);
707  {
708  if (traceit&TRACE_SHOW_LINENO) printf("\n");
709  printf("entering example (level %d)\n",myynest);
710  }
711  myynest++;
712 
713  err=iiAllStart(pi,example,BT_example,(pi != NULL ? pi->data.s.example_lineno: 0));
714 
716  myynest--;
717  si_echo=old_echo;
718  if (traceit&TRACE_SHOW_PROC)
719  {
720  if (traceit&TRACE_SHOW_LINENO) printf("\n");
721  printf("leaving -example- (level %d)\n",myynest);
722  }
723  if (iiLocalRing[myynest] != currRing)
724  {
725  if (iiLocalRing[myynest]!=NULL)
726  {
729  }
730  else
731  {
733  currRing=NULL;
734  }
735  }
736  procstack->pop();
737  return err;
738 }
#define TRACE_SHOW_LINENO
Definition: reporter.h:30
proclevel * procstack
Definition: ipid.cc:52
int traceit
Definition: febase.cc:42
static void iiCheckNest()
Definition: iplib.cc:473
int myynest
Definition: febase.cc:41
void killlocals(int v)
Definition: ipshell.cc:381
procinfodata data
Definition: subexpr.h:63
idhdl currRingHdl
Definition: ipid.cc:59
idhdl rFindHdl(ring r, idhdl n)
Definition: ipshell.cc:1610
BOOLEAN iiAllStart(procinfov pi, char *p, feBufferTypes t, int l)
Definition: iplib.cc:292
ring * iiLocalRing
Definition: iplib.cc:453
#define NULL
Definition: omList.c:12
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
#define TRACE_SHOW_PROC
Definition: reporter.h:28
void rSetHdl(idhdl h)
Definition: ipshell.cc:5086
void push(char *)
Definition: ipid.cc:722
void pop()
Definition: ipid.cc:732
int BOOLEAN
Definition: auxiliary.h:85
int si_echo
Definition: febase.cc:35

◆ iiGetBuiltinModInit()

SModulFunc_t iiGetBuiltinModInit ( const char *  libname)

Definition at line 750 of file iplib.cc.

751 {
752 # define SI_GET_BUILTIN_MOD_INIT(name) if (strcmp(libname, #name ".so") == 0){ return SI_MOD_INIT0(name); }
754 # undef SI_GET_BUILTIN_MOD_INIT
755 
756  return NULL;
757 }
#define SI_GET_BUILTIN_MOD_INIT(name)
SI_FOREACH_BUILTIN(SI_GET_BUILTIN_MOD_INIT0) }
#define NULL
Definition: omList.c:12

◆ iiGetLibProcBuffer()

char* iiGetLibProcBuffer ( procinfo pi,
int  part 
)

Definition at line 191 of file iplib.cc.

192 {
193  char buf[256], *s = NULL, *p;
194  long procbuflen;
195 
196  FILE * fp = feFopen( pi->libname, "rb", NULL, TRUE );
197  if (fp==NULL)
198  {
199  return NULL;
200  }
201 
202  fseek(fp, pi->data.s.proc_start, SEEK_SET);
203  if(part==0)
204  { // load help string
205  int i, offset=0;
206  long head = pi->data.s.def_end - pi->data.s.proc_start;
207  procbuflen = pi->data.s.help_end - pi->data.s.help_start;
208  if (procbuflen<5)
209  {
210  fclose(fp);
211  return NULL; // help part does not exist
212  }
213  //Print("Help=%ld-%ld=%d\n", pi->data.s.body_start,
214  // pi->data.s.proc_start, procbuflen);
215  s = (char *)omAlloc(procbuflen+head+3);
216  myfread(s, head, 1, fp);
217  s[head] = '\n';
218  fseek(fp, pi->data.s.help_start, SEEK_SET);
219  myfread(s+head+1, procbuflen, 1, fp);
220  fclose(fp);
221  s[procbuflen+head+1] = '\n';
222  s[procbuflen+head+2] = '\0';
223  offset=0;
224  for(i=0;i<=procbuflen+head+2; i++)
225  {
226  if(s[i]=='\\' &&
227  (s[i+1]=='"' || s[i+1]=='{' || s[i+1]=='}' || s[i+1]=='\\'))
228  {
229  i++;
230  offset++;
231  }
232  if(offset>0) s[i-offset] = s[i];
233  }
234  return(s);
235  }
236  else if(part==1)
237  { // load proc part - must exist
238  procbuflen = pi->data.s.def_end - pi->data.s.proc_start;
239  char *ss=(char *)omAlloc(procbuflen+2);
240  //fgets(buf, sizeof(buf), fp);
241  myfread( ss, procbuflen, 1, fp);
242  char ct;
243  char *e;
244  s=iiProcName(ss,ct,e);
245  char *argstr=NULL;
246  *e=ct;
247  argstr=iiProcArgs(e,TRUE);
248 
249  assume(pi->data.s.body_end > pi->data.s.body_start);
250 
251  procbuflen = pi->data.s.body_end - pi->data.s.body_start;
252  pi->data.s.body = (char *)omAlloc( strlen(argstr)+procbuflen+15+
253  strlen(pi->libname) );
254  //Print("Body=%ld-%ld=%d\n", pi->data.s.body_end,
255  // pi->data.s.body_start, procbuflen);
256  assume(pi->data.s.body != NULL);
257  fseek(fp, pi->data.s.body_start, SEEK_SET);
258  strcpy(pi->data.s.body,argstr);
259  myfread( pi->data.s.body+strlen(argstr), procbuflen, 1, fp);
260  fclose( fp );
261  procbuflen+=strlen(argstr);
262  omFree(argstr);
263  omFree(ss);
264  pi->data.s.body[procbuflen] = '\0';
265  strcat( pi->data.s.body+procbuflen, "\n;return();\n\n" );
266  strcat( pi->data.s.body+procbuflen+13,pi->libname);
267  s=(char *)strchr(pi->data.s.body,'{');
268  if (s!=NULL) *s=' ';
269  return NULL;
270  }
271  else if(part==2)
272  { // example
273  if ( pi->data.s.example_lineno == 0)
274  return NULL; // example part does not exist
275  // load example
276  fseek(fp, pi->data.s.example_start, SEEK_SET);
277  /*char *dummy=*/ (void) fgets(buf, sizeof(buf), fp); // skip line with "example"
278  procbuflen = pi->data.s.proc_end - pi->data.s.example_start - strlen(buf);
279  //Print("Example=%ld-%ld=%d\n", pi->data.s.proc_end,
280  // pi->data.s.example_start, procbuflen);
281  s = (char *)omAlloc(procbuflen+14);
282  myfread(s, procbuflen, 1, fp);
283  s[procbuflen] = '\0';
284  strcat(s+procbuflen-3, "\n;return();\n\n" );
285  p=(char *)strchr(s,'{');
286  if (p!=NULL) *p=' ';
287  return(s);
288  }
289  return NULL;
290 }
char * iiProcArgs(char *e, BOOLEAN withParenth)
Definition: iplib.cc:108
const CanonicalForm int s
Definition: facAbsFact.cc:55
CanonicalForm fp
Definition: cfModGcd.cc:4043
#define TRUE
Definition: auxiliary.h:98
#define omAlloc(size)
Definition: omAllocDecl.h:210
char * libname
Definition: subexpr.h:56
#define omFree(addr)
Definition: omAllocDecl.h:261
#define assume(x)
Definition: mod2.h:390
size_t myfread(void *ptr, size_t size, size_t nmemb, FILE *stream)
Definition: feFopen.cc:195
int status int void * buf
Definition: si_signals.h:59
procinfodata data
Definition: subexpr.h:63
FILE * feFopen(const char *path, const char *mode, char *where, short useWerror, short path_only)
Definition: feFopen.cc:47
int i
Definition: cfEzgcd.cc:125
char * iiProcName(char *buf, char &ct, char *&e)
Definition: iplib.cc:94
#define NULL
Definition: omList.c:12
CanonicalForm head(const CanonicalForm &f)
#define SEEK_SET
Definition: mod2.h:116
int p
Definition: cfModGcd.cc:4019
int offset
Definition: libparse.cc:1091

◆ iiGetLibStatus()

BOOLEAN iiGetLibStatus ( char *  lib)

Definition at line 73 of file iplib.cc.

74 {
75  idhdl hl;
76 
77  char *plib = iiConvName(lib);
78  hl = basePack->idroot->get(plib,0);
79  omFree(plib);
80  if((hl==NULL) ||(IDTYP(hl)!=PACKAGE_CMD))
81  {
82  return FALSE;
83  }
84  return (strcmp(lib,IDPACKAGE(hl)->libname)==0);
85 }
#define FALSE
Definition: auxiliary.h:94
Definition: idrec.h:34
#define IDPACKAGE(a)
Definition: ipid.h:134
#define IDTYP(a)
Definition: ipid.h:114
#define omFree(addr)
Definition: omAllocDecl.h:261
#define NULL
Definition: omList.c:12
package basePack
Definition: ipid.cc:58
char * iiConvName(const char *libname)
Definition: iplib.cc:1331

◆ iiInitSingularProcinfo()

procinfo* iiInitSingularProcinfo ( procinfov  pi,
const char *  libname,
const char *  procname,
int  ,
long  pos,
BOOLEAN  pstatic 
)

Definition at line 990 of file iplib.cc.

992 {
993  memset(pi,0,sizeof(*pi));
994  pi->libname = omStrDup(libname);
995  pi->procname = omStrDup(procname);
996  pi->language = LANG_SINGULAR;
997  pi->ref = 1;
998  pi->is_static = pstatic;
999  pi->data.s.proc_start = pos;
1000  return(pi);
1001 }
language_defs language
Definition: subexpr.h:59
short ref
Definition: subexpr.h:60
char * procname
Definition: subexpr.h:57
char * libname
Definition: subexpr.h:56
procinfodata data
Definition: subexpr.h:63
char is_static
Definition: subexpr.h:61
#define omStrDup(s)
Definition: omAllocDecl.h:263

◆ iiLibCmd()

BOOLEAN iiLibCmd ( char *  newlib,
BOOLEAN  autoexport,
BOOLEAN  tellerror,
BOOLEAN  force 
)

Definition at line 825 of file iplib.cc.

826 {
827  char libnamebuf[1024];
828  // procinfov pi;
829  // idhdl h;
830  idhdl pl;
831  // idhdl hl;
832  // long pos = 0L;
833  char *plib = iiConvName(newlib);
834  FILE * fp = feFopen( newlib, "r", libnamebuf, tellerror );
835  // int lines = 1;
836  BOOLEAN LoadResult = TRUE;
837 
838  if (fp==NULL)
839  {
840  return TRUE;
841  }
842  pl = basePack->idroot->get(plib,0);
843  if (pl==NULL)
844  {
845  pl = enterid( plib,0, PACKAGE_CMD,
846  &(basePack->idroot), TRUE );
847  IDPACKAGE(pl)->language = LANG_SINGULAR;
848  IDPACKAGE(pl)->libname=omStrDup(newlib);
849  }
850  else
851  {
852  if(IDTYP(pl)!=PACKAGE_CMD)
853  {
854  WarnS("not of type package.");
855  fclose(fp);
856  return TRUE;
857  }
858  if (!force) return FALSE;
859  }
860  LoadResult = iiLoadLIB(fp, libnamebuf, newlib, pl, autoexport, tellerror);
861  omFree((ADDRESS)newlib);
862 
863  if(!LoadResult) IDPACKAGE(pl)->loaded = TRUE;
864  omFree((ADDRESS)plib);
865 
866  return LoadResult;
867 }
CanonicalForm fp
Definition: cfModGcd.cc:4043
#define FALSE
Definition: auxiliary.h:94
#define TRUE
Definition: auxiliary.h:98
void * ADDRESS
Definition: auxiliary.h:133
#define WarnS
Definition: emacs.cc:78
Definition: idrec.h:34
#define IDPACKAGE(a)
Definition: ipid.h:134
#define IDTYP(a)
Definition: ipid.h:114
idhdl enterid(const char *s, int lev, int t, idhdl *root, BOOLEAN init, BOOLEAN search)
Definition: ipid.cc:265
#define omFree(addr)
Definition: omAllocDecl.h:261
FILE * feFopen(const char *path, const char *mode, char *where, short useWerror, short path_only)
Definition: feFopen.cc:47
char libnamebuf[1024]
Definition: libparse.cc:1096
#define NULL
Definition: omList.c:12
package basePack
Definition: ipid.cc:58
BOOLEAN iiLoadLIB(FILE *fp, const char *libnamebuf, const char *newlib, idhdl pl, BOOLEAN autoexport, BOOLEAN tellerror)
Definition: iplib.cc:914
char * iiConvName(const char *libname)
Definition: iplib.cc:1331
int BOOLEAN
Definition: auxiliary.h:85
#define omStrDup(s)
Definition: omAllocDecl.h:263

◆ iiLoadLIB()

BOOLEAN iiLoadLIB ( FILE *  fp,
const char *  libnamebuf,
const char *  newlib,
idhdl  pl,
BOOLEAN  autoexport,
BOOLEAN  tellerror 
)

Definition at line 914 of file iplib.cc.

916 {
917  extern FILE *yylpin;
918  libstackv ls_start = library_stack;
919  lib_style_types lib_style;
920 
921  yylpin = fp;
922  #if YYLPDEBUG > 1
923  print_init();
924  #endif
925  extern int lpverbose;
926  if (BVERBOSE(V_DEBUG_LIB)) lpverbose=1;
927  else lpverbose=0;
928  // yylplex sets also text_buffer
929  if (text_buffer!=NULL) *text_buffer='\0';
930  yylplex(newlib, libnamebuf, &lib_style, pl, autoexport);
931  if(yylp_errno)
932  {
933  Werror("Library %s: ERROR occurred: in line %d, %d.", newlib, yylplineno,
934  current_pos(0));
936  {
940  }
941  else
943  WerrorS("Cannot load library,... aborting.");
944  reinit_yylp();
945  fclose( yylpin );
947  return TRUE;
948  }
949  if (BVERBOSE(V_LOAD_LIB))
950  Print( "// ** loaded %s %s\n", libnamebuf, text_buffer);
951  if( (lib_style == OLD_LIBSTYLE) && (BVERBOSE(V_LOAD_LIB)))
952  {
953  Warn( "library %s has old format. This format is still accepted,", newlib);
954  WarnS( "but for functionality you may wish to change to the new");
955  WarnS( "format. Please refer to the manual for further information.");
956  }
957  reinit_yylp();
958  fclose( yylpin );
959  fp = NULL;
960  iiRunInit(IDPACKAGE(pl));
961 
962  {
963  libstackv ls;
964  for(ls = library_stack; (ls != NULL) && (ls != ls_start); )
965  {
966  if(ls->to_be_done)
967  {
968  ls->to_be_done=FALSE;
969  iiLibCmd(ls->get(),autoexport,tellerror,FALSE);
970  ls = ls->pop(newlib);
971  }
972  }
973 #if 0
974  PrintS("--------------------\n");
975  for(ls = library_stack; ls != NULL; ls = ls->next)
976  {
977  Print("%s: LIB-stack:(%d), %s %s\n", newlib, ls->cnt, ls->get(),
978  ls->to_be_done ? "not loaded" : "loaded");
979  }
980  PrintS("--------------------\n");
981 #endif
982  }
983 
984  if(fp != NULL) fclose(fp);
985  return FALSE;
986 }
int cnt
Definition: subexpr.h:166
#define Print
Definition: emacs.cc:80
CanonicalForm fp
Definition: cfModGcd.cc:4043
int yylplex(const char *libname, const char *libfile, lib_style_types *lib_style, idhdl pl, BOOLEAN autoexport=FALSE, lp_modes=LOAD_LIB)
libstackv next
Definition: subexpr.h:163
#define FALSE
Definition: auxiliary.h:94
static void iiRunInit(package p)
Definition: iplib.cc:898
#define V_LOAD_LIB
Definition: options.h:47
#define IDROOT
Definition: ipid.h:18
BOOLEAN to_be_done
Definition: subexpr.h:165
#define TRUE
Definition: auxiliary.h:98
void print_init()
Definition: libparse.cc:3480
void * ADDRESS
Definition: auxiliary.h:133
void WerrorS(const char *s)
Definition: feFopen.cc:24
char * get()
Definition: subexpr.h:169
#define V_DEBUG_LIB
Definition: options.h:48
#define WarnS
Definition: emacs.cc:78
libstackv pop(const char *p)
Definition: iplib.cc:1422
BOOLEAN iiLibCmd(char *newlib, BOOLEAN autoexport, BOOLEAN tellerror, BOOLEAN force)
Definition: iplib.cc:825
#define IDPACKAGE(a)
Definition: ipid.h:134
#define YYLP_BAD_CHAR
Definition: libparse.h:93
int lpverbose
Definition: libparse.cc:1104
int yylp_errno
Definition: libparse.cc:1128
#define omFree(addr)
Definition: omAllocDecl.h:261
char * yylp_errlist[]
Definition: libparse.cc:1112
void PrintS(const char *s)
Definition: reporter.cc:284
char libnamebuf[1024]
Definition: libparse.cc:1096
#define BVERBOSE(a)
Definition: options.h:35
#define NULL
Definition: omList.c:12
char * text_buffer
Definition: libparse.cc:1097
int current_pos(int i=0)
Definition: libparse.cc:3344
lib_style_types
Definition: libparse.h:9
static void iiCleanProcs(idhdl &root)
Definition: iplib.cc:869
void Werror(const char *fmt,...)
Definition: reporter.cc:189
libstackv library_stack
Definition: iplib.cc:64
int yylplineno
Definition: libparse.cc:1102
#define Warn
Definition: emacs.cc:77
void reinit_yylp()
Definition: libparse.cc:3374

◆ iiLocateLib()

BOOLEAN iiLocateLib ( const char *  lib,
char *  where 
)

Definition at line 811 of file iplib.cc.

812 {
813  char *plib = iiConvName(lib);
814  idhdl pl = basePack->idroot->get(plib,0);
815  if( (pl!=NULL) && (IDTYP(pl)==PACKAGE_CMD) &&
816  (IDPACKAGE(pl)->language == LANG_SINGULAR))
817  {
818  strncpy(where,IDPACKAGE(pl)->libname,127);
819  return TRUE;
820  }
821  else
822  return FALSE;;
823 }
#define FALSE
Definition: auxiliary.h:94
#define TRUE
Definition: auxiliary.h:98
Definition: idrec.h:34
#define IDPACKAGE(a)
Definition: ipid.h:134
#define IDTYP(a)
Definition: ipid.h:114
#define NULL
Definition: omList.c:12
package basePack
Definition: ipid.cc:58
char * iiConvName(const char *libname)
Definition: iplib.cc:1331

◆ iiMake_proc()

BOOLEAN iiMake_proc ( idhdl  pn,
package  pack,
leftv  sl 
)

Definition at line 484 of file iplib.cc.

485 {
486  int err;
487  procinfov pi = IDPROC(pn);
488  if(pi->is_static && myynest==0)
489  {
490  Werror("'%s::%s()' is a local procedure and cannot be accessed by an user.",
491  pi->libname, pi->procname);
492  return TRUE;
493  }
494  iiCheckNest();
496  //Print("currRing(%d):%s(%x) in %s\n",myynest,IDID(currRingHdl),currRing,IDID(pn));
497  iiRETURNEXPR.Init();
498  procstack->push(pi->procname);
500  || (pi->trace_flag&TRACE_SHOW_PROC))
501  {
503  Print("entering%-*.*s %s (level %d)\n",myynest*2,myynest*2," ",IDID(pn),myynest);
504  }
505 #ifdef RDEBUG
507 #endif
508  switch (pi->language)
509  {
510  default:
511  case LANG_NONE:
512  WerrorS("undefined proc");
513  err=TRUE;
514  break;
515 
516  case LANG_SINGULAR:
517  if ((pi->pack!=NULL)&&(currPack!=pi->pack))
518  {
519  currPack=pi->pack;
522  //Print("set pack=%s\n",IDID(currPackHdl));
523  }
524  else if ((pack!=NULL)&&(currPack!=pack))
525  {
526  currPack=pack;
529  //Print("set pack=%s\n",IDID(currPackHdl));
530  }
531  err=iiPStart(pn,sl);
532  break;
533  case LANG_C:
535  err = (pi->data.o.function)(res, sl);
536  memcpy(&iiRETURNEXPR,res,sizeof(iiRETURNEXPR));
538  break;
539  }
540  if ((traceit&TRACE_SHOW_PROC)
541  || (pi->trace_flag&TRACE_SHOW_PROC))
542  {
543  if (traceit&TRACE_SHOW_LINENO) PrintLn();
544  Print("leaving %-*.*s %s (level %d)\n",myynest*2,myynest*2," ",IDID(pn),myynest);
545  }
546  //const char *n="NULL";
547  //if (currRingHdl!=NULL) n=IDID(currRingHdl);
548  //Print("currRing(%d):%s(%x) after %s\n",myynest,n,currRing,IDID(pn));
549 #ifdef RDEBUG
550  if (traceit&TRACE_SHOW_RINGS) iiShowLevRings();
551 #endif
552  if (err)
553  {
555  //iiRETURNEXPR.Init(); //done by CleanUp
556  }
557  if (iiCurrArgs!=NULL)
558  {
559  if (!err) Warn("too many arguments for %s",IDID(pn));
560  iiCurrArgs->CleanUp();
563  }
564  procstack->pop();
565  if (err)
566  return TRUE;
567  return FALSE;
568 }
#define TRACE_SHOW_LINENO
Definition: reporter.h:30
Class used for (list of) interpreter objects.
Definition: subexpr.h:82
#define TRACE_SHOW_RINGS
Definition: reporter.h:35
void PrintLn()
Definition: reporter.cc:310
#define Print
Definition: emacs.cc:80
package pack
Definition: subexpr.h:58
idhdl currPackHdl
Definition: ipid.cc:55
#define IDID(a)
Definition: ipid.h:117
#define FALSE
Definition: auxiliary.h:94
sleftv iiRETURNEXPR
Definition: iplib.cc:454
language_defs language
Definition: subexpr.h:59
proclevel * procstack
Definition: ipid.cc:52
static void iiShowLevRings()
Definition: iplib.cc:458
#define TRUE
Definition: auxiliary.h:98
void Init()
Definition: subexpr.h:107
void * ADDRESS
Definition: auxiliary.h:133
sleftv * leftv
Definition: structs.h:62
void WerrorS(const char *s)
Definition: feFopen.cc:24
int traceit
Definition: febase.cc:42
static void iiCheckNest()
Definition: iplib.cc:473
BOOLEAN iiPStart(idhdl pn, leftv v)
Definition: iplib.cc:352
char * procname
Definition: subexpr.h:57
Definition: subexpr.h:22
int myynest
Definition: febase.cc:41
char * libname
Definition: subexpr.h:56
CanonicalForm res
Definition: facAbsFact.cc:64
procinfodata data
Definition: subexpr.h:63
omBin sleftv_bin
Definition: subexpr.cc:41
char is_static
Definition: subexpr.h:61
#define omAlloc0Bin(bin)
Definition: omAllocDecl.h:206
#define IDPROC(a)
Definition: ipid.h:135
#define pi
Definition: libparse.cc:1143
ring * iiLocalRing
Definition: iplib.cc:453
#define NULL
Definition: omList.c:12
package currPack
Definition: ipid.cc:57
leftv iiCurrArgs
Definition: ipshell.cc:76
void CleanUp(ring r=currRing)
Definition: subexpr.cc:348
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
#define TRACE_SHOW_PROC
Definition: reporter.h:28
idhdl packFindHdl(package r)
Definition: ipid.cc:750
void iiCheckPack(package &p)
Definition: ipshell.cc:1539
#define omFreeBin(addr, bin)
Definition: omAllocDecl.h:259
void push(char *)
Definition: ipid.cc:722
void pop()
Definition: ipid.cc:732
char trace_flag
Definition: subexpr.h:62
void Werror(const char *fmt,...)
Definition: reporter.cc:189
#define Warn
Definition: emacs.cc:77

◆ iiProcArgs()

char* iiProcArgs ( char *  e,
BOOLEAN  withParenth 
)

Definition at line 108 of file iplib.cc.

109 {
110  while ((*e==' ') || (*e=='\t') || (*e=='(')) e++;
111  if (*e<' ')
112  {
113  if (withParenth)
114  {
115  // no argument list, allow list #
116  return omStrDup("parameter list #;");
117  }
118  else
119  {
120  // empty list
121  return omStrDup("");
122  }
123  }
124  BOOLEAN in_args;
125  BOOLEAN args_found;
126  char *s;
127  char *argstr=(char *)omAlloc(127); // see ../omalloc/omTables.inc
128  int argstrlen=127;
129  *argstr='\0';
130  int par=0;
131  do
132  {
133  args_found=FALSE;
134  s=e; // set s to the starting point of the arg
135  // and search for the end
136  // skip leading spaces:
137  loop
138  {
139  if ((*s==' ')||(*s=='\t'))
140  s++;
141  else if ((*s=='\n')&&(*(s+1)==' '))
142  s+=2;
143  else // start of new arg or \0 or )
144  break;
145  }
146  e=s;
147  while ((*e!=',')
148  &&((par!=0) || (*e!=')'))
149  &&(*e!='\0'))
150  {
151  if (*e=='(') par++;
152  else if (*e==')') par--;
153  args_found=args_found || (*e>' ');
154  e++;
155  }
156  in_args=(*e==',');
157  if (args_found)
158  {
159  *e='\0';
160  // check for space:
161  if ((int)strlen(argstr)+12 /* parameter + ;*/ +(int)strlen(s)>= argstrlen)
162  {
163  argstrlen*=2;
164  char *a=(char *)omAlloc( argstrlen);
165  strcpy(a,argstr);
166  omFree((ADDRESS)argstr);
167  argstr=a;
168  }
169  // copy the result to argstr
170  if(strncmp(s,"alias ",6)!=0)
171  {
172  strcat(argstr,"parameter ");
173  }
174  strcat(argstr,s);
175  strcat(argstr,"; ");
176  e++; // e was pointing to ','
177  }
178  } while (in_args);
179  return argstr;
180 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
#define FALSE
Definition: auxiliary.h:94
void * ADDRESS
Definition: auxiliary.h:133
#define loop
Definition: structs.h:80
#define omAlloc(size)
Definition: omAllocDecl.h:210
#define omFree(addr)
Definition: omAllocDecl.h:261
int BOOLEAN
Definition: auxiliary.h:85
#define omStrDup(s)
Definition: omAllocDecl.h:263

◆ iiProcName()

char* iiProcName ( char *  buf,
char &  ct,
char *&  e 
)

Definition at line 94 of file iplib.cc.

95 {
96  char *s=buf+5;
97  while (*s==' ') s++;
98  e=s+1;
99  while ((*e>' ') && (*e!='(')) e++;
100  ct=*e;
101  *e='\0';
102  return s;
103 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
int status int void * buf
Definition: si_signals.h:59

◆ iiPStart()

BOOLEAN iiPStart ( idhdl  pn,
leftv  v 
)

Definition at line 352 of file iplib.cc.

353 {
354  procinfov pi=NULL;
355  int old_echo=si_echo;
356  BOOLEAN err=FALSE;
357  char save_flags=0;
358 
359  /* init febase ======================================== */
360  /* we do not enter this case if filename != NULL !! */
361  if (pn!=NULL)
362  {
363  pi = IDPROC(pn);
364  if(pi!=NULL)
365  {
366  save_flags=pi->trace_flag;
367  if( pi->data.s.body==NULL )
368  {
369  iiGetLibProcBuffer(pi);
370  if (pi->data.s.body==NULL) return TRUE;
371  }
372 // omUpdateInfo();
373 // int m=om_Info.UsedBytes;
374 // Print("proc %s, mem=%d\n",IDID(pn),m);
375  }
376  }
377  else return TRUE;
378  /* generate argument list ======================================*/
379  //iiCurrArgs should be NULL here, as the assignment for the parameters
380  // of the prevouis call are already done befor calling another routine
381  if (v!=NULL)
382  {
384  memcpy(iiCurrArgs,v,sizeof(sleftv)); // keeps track of v->next etc.
385  memset(v,0,sizeof(sleftv));
386  }
387  else
388  {
390  }
391  iiCurrProc=pn;
392  /* start interpreter ======================================*/
393  myynest++;
394  if (myynest > SI_MAX_NEST)
395  {
396  WerrorS("nesting too deep");
397  err=TRUE;
398  }
399  else
400  {
401  err=iiAllStart(pi,pi->data.s.body,BT_proc,pi->data.s.body_lineno-(v!=NULL));
402 
403  if (iiLocalRing[myynest-1] != currRing)
404  {
406  {
407  //idhdl hn;
408  const char *n;
409  const char *o;
410  idhdl nh=NULL, oh=NULL;
411  if (iiLocalRing[myynest-1]!=NULL)
413  if (oh!=NULL) o=oh->id;
414  else o="none";
415  if (currRing!=NULL)
416  nh=rFindHdl(currRing,NULL);
417  if (nh!=NULL) n=nh->id;
418  else n="none";
419  Werror("ring change during procedure call %s: %s -> %s (level %d)",pi->procname,o,n,myynest);
421  err=TRUE;
422  }
424  }
425  if ((currRing==NULL)
426  && (currRingHdl!=NULL))
428  else
429  if ((currRing!=NULL) &&
431  ||(IDLEV(currRingHdl)>=myynest-1)))
432  {
435  }
436  //Print("kill locals for %s (level %d)\n",IDID(pn),myynest);
438 #ifndef SING_NDEBUG
439  checkall();
440 #endif
441  //Print("end kill locals for %s (%d)\n",IDID(pn),myynest);
442  }
443  myynest--;
444  si_echo=old_echo;
445  if (pi!=NULL)
446  pi->trace_flag=save_flags;
447 // omUpdateInfo();
448 // int m=om_Info.UsedBytes;
449 // Print("exit %s, mem=%d\n",IDID(pn),m);
450  return err;
451 }
#define omAllocBin(bin)
Definition: omAllocDecl.h:205
Class used for (list of) interpreter objects.
Definition: subexpr.h:82
#define FALSE
Definition: auxiliary.h:94
sleftv iiRETURNEXPR
Definition: iplib.cc:454
#define TRUE
Definition: auxiliary.h:98
sleftv * leftv
Definition: structs.h:62
void WerrorS(const char *s)
Definition: feFopen.cc:24
Definition: idrec.h:34
idhdl iiCurrProc
Definition: ipshell.cc:77
#define SI_MAX_NEST
Definition: iplib.cc:23
char * procname
Definition: subexpr.h:57
int myynest
Definition: febase.cc:41
BOOLEAN RingDependend()
Definition: subexpr.cc:418
void killlocals(int v)
Definition: ipshell.cc:381
procinfodata data
Definition: subexpr.h:63
idhdl currRingHdl
Definition: ipid.cc:59
omBin sleftv_bin
Definition: subexpr.cc:41
idhdl rFindHdl(ring r, idhdl n)
Definition: ipshell.cc:1610
#define IDLEV(a)
Definition: ipid.h:116
BOOLEAN iiAllStart(procinfov pi, char *p, feBufferTypes t, int l)
Definition: iplib.cc:292
#define IDPROC(a)
Definition: ipid.h:135
#define pi
Definition: libparse.cc:1143
ring * iiLocalRing
Definition: iplib.cc:453
#define NULL
Definition: omList.c:12
#define IDRING(a)
Definition: ipid.h:122
leftv iiCurrArgs
Definition: ipshell.cc:76
void CleanUp(ring r=currRing)
Definition: subexpr.cc:348
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
const char * id
Definition: idrec.h:39
void rSetHdl(idhdl h)
Definition: ipshell.cc:5086
char * iiGetLibProcBuffer(procinfo *pi, int part)
Definition: iplib.cc:191
int BOOLEAN
Definition: auxiliary.h:85
char trace_flag
Definition: subexpr.h:62
void Werror(const char *fmt,...)
Definition: reporter.cc:189
int si_echo
Definition: febase.cc:35

◆ iiRunInit()

static void iiRunInit ( package  p)
static

Definition at line 898 of file iplib.cc.

899 {
900  idhdl h=p->idroot->get("mod_init",0);
901  if (h==NULL) return;
902  if (IDTYP(h)==PROC_CMD)
903  {
904  int save=yylineno;
905  myynest++;
906  // procinfo *pi=(procinfo*)IDDATA(h);
907  //PrintS("mod_init found\n");
908  iiMake_proc(h,p,NULL);
909  myynest--;
910  yylineno=save;
911  }
912 }
int yylineno
Definition: febase.cc:40
Definition: idrec.h:34
int myynest
Definition: febase.cc:41
#define IDTYP(a)
Definition: ipid.h:114
BOOLEAN iiMake_proc(idhdl pn, package pack, leftv sl)
Definition: iplib.cc:484
#define NULL
Definition: omList.c:12
int p
Definition: cfModGcd.cc:4019
static Poly * h
Definition: janet.cc:971

◆ iiShowLevRings()

static void iiShowLevRings ( )
static

Definition at line 458 of file iplib.cc.

459 {
460  int i;
461  for (i=0;i<=myynest;i++)
462  {
463  Print("lev %d:",i);
464  if (iiLocalRing[i]==NULL) PrintS("NULL");
465  else Print("%lx",(long)iiLocalRing[i]);
466  PrintLn();
467  }
468  if (currRing==NULL) PrintS("curr:NULL\n");
469  else Print ("curr:%lx\n",(long)currRing);
470 }
void PrintLn()
Definition: reporter.cc:310
#define Print
Definition: emacs.cc:80
int myynest
Definition: febase.cc:41
int i
Definition: cfEzgcd.cc:125
void PrintS(const char *s)
Definition: reporter.cc:284
ring * iiLocalRing
Definition: iplib.cc:453
#define NULL
Definition: omList.c:12
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12

◆ iiTryLoadLib()

BOOLEAN iiTryLoadLib ( leftv  v,
const char *  id 
)

Definition at line 763 of file iplib.cc.

764 {
765  BOOLEAN LoadResult = TRUE;
766  char libnamebuf[1024];
767  char *libname = (char *)omAlloc(strlen(id)+5);
768  const char *suffix[] = { "", ".lib", ".so", ".sl", NULL };
769  int i = 0;
770  // FILE *fp;
771  // package pack;
772  // idhdl packhdl;
773  lib_types LT;
774  for(i=0; suffix[i] != NULL; i++)
775  {
776  sprintf(libname, "%s%s", id, suffix[i]);
777  *libname = mytolower(*libname);
778  if((LT = type_of_LIB(libname, libnamebuf)) > LT_NOTFOUND)
779  {
780  char *s=omStrDup(libname);
781  #ifdef HAVE_DYNAMIC_LOADING
782  char libnamebuf[1024];
783  #endif
784 
785  if (LT==LT_SINGULAR)
786  LoadResult = iiLibCmd(s, FALSE, FALSE,TRUE);
787  #ifdef HAVE_DYNAMIC_LOADING
788  else if ((LT==LT_ELF) || (LT==LT_HPUX))
789  LoadResult = load_modules(s,libnamebuf,FALSE);
790  #endif
791  else if (LT==LT_BUILTIN)
792  {
793  LoadResult=load_builtin(s,FALSE, iiGetBuiltinModInit(s));
794  }
795  if(!LoadResult )
796  {
797  v->name = iiConvName(libname);
798  break;
799  }
800  }
801  }
802  omFree(libname);
803  return LoadResult;
804 }
BOOLEAN load_builtin(const char *newlib, BOOLEAN autoexport, SModulFunc_t init)
Definition: iplib.cc:1197
const CanonicalForm int s
Definition: facAbsFact.cc:55
#define FALSE
Definition: auxiliary.h:94
Definition: mod_raw.h:16
#define TRUE
Definition: auxiliary.h:98
lib_types type_of_LIB(const char *newlib, char *libnamebuf)
Definition: mod_lib.cc:22
#define omAlloc(size)
Definition: omAllocDecl.h:210
BOOLEAN iiLibCmd(char *newlib, BOOLEAN autoexport, BOOLEAN tellerror, BOOLEAN force)
Definition: iplib.cc:825
const char * name
Definition: subexpr.h:87
#define omFree(addr)
Definition: omAllocDecl.h:261
int i
Definition: cfEzgcd.cc:125
lib_types
Definition: mod_raw.h:16
char libnamebuf[1024]
Definition: libparse.cc:1096
char mytolower(char c)
Definition: iplib.cc:1318
#define NULL
Definition: omList.c:12
SModulFunc_t iiGetBuiltinModInit(const char *libname)
Definition: iplib.cc:750
char * iiConvName(const char *libname)
Definition: iplib.cc:1331
int BOOLEAN
Definition: auxiliary.h:85
BOOLEAN load_modules(const char *newlib, char *fullname, BOOLEAN autoexport)
Definition: iplib.cc:1090
#define omStrDup(s)
Definition: omAllocDecl.h:263

◆ load_builtin()

BOOLEAN load_builtin ( const char *  newlib,
BOOLEAN  autoexport,
SModulFunc_t  init 
)

Definition at line 1197 of file iplib.cc.

1198 {
1199  int iiAddCproc(const char *libname, const char *procname, BOOLEAN pstatic,
1200  BOOLEAN(*func)(leftv res, leftv v));
1201 /*
1202  typedef int (*fktn_t)(int(*iiAddCproc)(const char *libname, const char *procname,
1203  BOOLEAN pstatic,
1204  BOOLEAN(*func)(leftv res, leftv v)));
1205 */
1206  // SModulFunc_t fktn;
1207  idhdl pl;
1208  char *plib = iiConvName(newlib);
1209  // BOOLEAN RET=TRUE;
1210  // int token;
1211 
1212  pl = basePack->idroot->get(plib,0); // search PACKAGE only in Top
1213  if ((pl!=NULL)
1214  &&(IDTYP(pl)==PACKAGE_CMD))
1215  {
1216  if(IDPACKAGE(pl)->language==LANG_C)
1217  {
1218  if (BVERBOSE(V_LOAD_LIB)) Warn( "(builtin) %s already loaded", newlib);
1219  omFree(plib);
1220  return FALSE;
1221  }
1222  }
1223  else
1224  {
1225  pl = enterid( plib,0, PACKAGE_CMD, &IDROOT, TRUE );
1226  IDPACKAGE(pl)->libname=omStrDup(newlib);
1227  }
1228  IDPACKAGE(pl)->language = LANG_C;
1229 
1230  IDPACKAGE(pl)->handle=(void *)NULL;
1231  SModulFunctions sModulFunctions;
1232 
1233  package s=currPack;
1234  currPack=IDPACKAGE(pl);
1235  if( init!= NULL)
1236  {
1237  sModulFunctions.iiArithAddCmd = iiArithAddCmd;
1238  if (autoexport) sModulFunctions.iiAddCproc = iiAddCprocTop;
1239  else sModulFunctions.iiAddCproc = iiAddCproc;
1240  (*init)(&sModulFunctions);
1241  }
1242  if (BVERBOSE(V_LOAD_LIB)) Print( "// ** loaded (builtin) %s \n", newlib);
1243  currPack->loaded=1;
1244  currPack=s;
1245 
1246  return FALSE;
1247 }
int iiAddCprocTop(const char *libname, const char *procname, BOOLEAN pstatic, BOOLEAN(*func)(leftv res, leftv v))
Definition: iplib.cc:1077
const CanonicalForm int s
Definition: facAbsFact.cc:55
Class used for (list of) interpreter objects.
Definition: subexpr.h:82
#define Print
Definition: emacs.cc:80
#define FALSE
Definition: auxiliary.h:94
#define V_LOAD_LIB
Definition: options.h:47
#define IDROOT
Definition: ipid.h:18
#define TRUE
Definition: auxiliary.h:98
Definition: idrec.h:34
Definition: subexpr.h:22
#define IDPACKAGE(a)
Definition: ipid.h:134
#define IDTYP(a)
Definition: ipid.h:114
idhdl enterid(const char *s, int lev, int t, idhdl *root, BOOLEAN init, BOOLEAN search)
Definition: ipid.cc:265
CanonicalForm res
Definition: facAbsFact.cc:64
#define omFree(addr)
Definition: omAllocDecl.h:261
#define BVERBOSE(a)
Definition: options.h:35
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
#define NULL
Definition: omList.c:12
package basePack
Definition: ipid.cc:58
package currPack
Definition: ipid.cc:57
int(* iiAddCproc)(const char *libname, const char *procname, BOOLEAN pstatic, BOOLEAN(*func)(leftv res, leftv v))
Definition: ipid.h:69
int iiAddCproc(const char *libname, const char *procname, BOOLEAN pstatic, BOOLEAN(*func)(leftv res, leftv v))
Definition: iplib.cc:1004
char * iiConvName(const char *libname)
Definition: iplib.cc:1331
int BOOLEAN
Definition: auxiliary.h:85
int(* iiArithAddCmd)(const char *szName, short nAlias, short nTokval, short nToktype, short nPos)
Definition: ipid.h:71
#define Warn
Definition: emacs.cc:77
#define omStrDup(s)
Definition: omAllocDecl.h:263
int iiArithAddCmd(const char *szName, short nAlias, short nTokval, short nToktype, short nPos)
Definition: iparith.cc:9242

◆ load_modules()

BOOLEAN load_modules ( const char *  newlib,
char *  fullname,
BOOLEAN  autoexport 
)

Definition at line 1090 of file iplib.cc.

1091 {
1092 #ifdef HAVE_STATIC
1093  WerrorS("mod_init: static version can not load modules");
1094  return TRUE;
1095 #else
1096 /*
1097  typedef int (*fktn_t)(int(*iiAddCproc)(const char *libname, const char *procname,
1098  BOOLEAN pstatic,
1099  BOOLEAN(*func)(leftv res, leftv v)));
1100 */
1101  SModulFunc_t fktn;
1102  idhdl pl;
1103  char *plib = iiConvName(newlib);
1104  BOOLEAN RET=TRUE;
1105  int token;
1106  char FullName[256];
1107 
1108  memset(FullName,0,256);
1109 
1110  if( *fullname != '/' && *fullname != '.' )
1111  sprintf(FullName, "./%s", newlib);
1112  else strncpy(FullName, fullname,255);
1113 
1114 
1115  if(IsCmd(plib, token))
1116  {
1117  Werror("'%s' is resered identifier\n", plib);
1118  goto load_modules_end;
1119  }
1120  pl = basePack->idroot->get(plib,0); /* packages only in top level
1121  (see enterid) */
1122  if ((pl!=NULL)
1123  &&(IDTYP(pl)==PACKAGE_CMD))
1124  {
1125  if(IDPACKAGE(pl)->language==LANG_C)
1126  {
1127  if (BVERBOSE(V_LOAD_LIB)) Warn( "%s already loaded as package", newlib);
1128  omFree(plib);
1129  return FALSE;
1130  }
1131  else if(IDPACKAGE(pl)->language==LANG_MIX)
1132  {
1133  if (BVERBOSE(V_LOAD_LIB)) Warn( "%s contain binary parts, cannot load", newlib);
1134  omFree(plib);
1135  return FALSE;
1136  }
1137  }
1138  else
1139  {
1140  pl = enterid( plib,0, PACKAGE_CMD, &IDROOT, TRUE );
1141  omFree(plib); /* enterid copied plib*/
1142  IDPACKAGE(pl)->libname=omStrDup(newlib);
1143  }
1144  IDPACKAGE(pl)->language = LANG_C;
1145  if (dynl_check_opened(FullName))
1146  {
1147  if (BVERBOSE(V_LOAD_LIB)) Warn( "%s already loaded as C library", fullname);
1148  return FALSE;
1149  }
1150  if((IDPACKAGE(pl)->handle=dynl_open(FullName))==(void *)NULL)
1151  {
1152  Werror("dynl_open failed:%s", dynl_error());
1153  Werror("%s not found", newlib);
1154  killhdl2(pl,&(basePack->idroot),NULL); // remove package
1155  goto load_modules_end;
1156  }
1157  else
1158  {
1159  SModulFunctions sModulFunctions;
1160 
1161  package s=currPack;
1162  currPack=IDPACKAGE(pl);
1163  fktn = (SModulFunc_t)dynl_sym(IDPACKAGE(pl)->handle, "mod_init");
1164  if( fktn!= NULL)
1165  {
1166  sModulFunctions.iiArithAddCmd = iiArithAddCmd;
1167  if (autoexport) sModulFunctions.iiAddCproc = iiAddCprocTop;
1168  else sModulFunctions.iiAddCproc = iiAddCproc;
1169  int ver=(*fktn)(&sModulFunctions);
1170  if (ver==MAX_TOK)
1171  {
1172  if (BVERBOSE(V_LOAD_LIB)) Print( "// ** loaded %s\n", fullname);
1173  }
1174  else
1175  {
1176  Warn("loaded %s for a different version of Singular(expected MAX_TOK: %d, got %d)",fullname,MAX_TOK,ver);
1177  }
1178  currPack->loaded=1;
1179  currPack=s; /* reset currPack to previous */
1180  RET=FALSE;
1181  }
1182  else
1183  {
1184  Werror("mod_init not found:: %s\nThis is probably not a dynamic module for Singular!\n", dynl_error());
1185  errorreported=0;
1186  if(IDPACKAGE(pl)->idroot==NULL)
1187  killhdl2(pl,&(basePack->idroot),NULL); // remove package
1188  }
1189  }
1190 
1191  load_modules_end:
1192  return RET;
1193 #endif /*STATIC */
1194 }
int iiAddCprocTop(const char *libname, const char *procname, BOOLEAN pstatic, BOOLEAN(*func)(leftv res, leftv v))
Definition: iplib.cc:1077
const CanonicalForm int s
Definition: facAbsFact.cc:55
#define Print
Definition: emacs.cc:80
#define FALSE
Definition: auxiliary.h:94
#define V_LOAD_LIB
Definition: options.h:47
Definition: tok.h:216
#define IDROOT
Definition: ipid.h:18
#define TRUE
Definition: auxiliary.h:98
void * dynl_sym(void *handle, const char *symbol)
Definition: mod_raw.cc:159
void WerrorS(const char *s)
Definition: feFopen.cc:24
Definition: idrec.h:34
void * dynl_open(char *filename)
Definition: mod_raw.cc:145
int dynl_check_opened(char *filename)
Definition: mod_raw.cc:138
Definition: subexpr.h:22
#define IDPACKAGE(a)
Definition: ipid.h:134
#define IDTYP(a)
Definition: ipid.h:114
void killhdl2(idhdl h, idhdl *ih, ring r)
Definition: ipid.cc:415
idhdl enterid(const char *s, int lev, int t, idhdl *root, BOOLEAN init, BOOLEAN search)
Definition: ipid.cc:265
#define omFree(addr)
Definition: omAllocDecl.h:261
short errorreported
Definition: feFopen.cc:23
#define BVERBOSE(a)
Definition: options.h:35
#define NULL
Definition: omList.c:12
package basePack
Definition: ipid.cc:58
package currPack
Definition: ipid.cc:57
int(* SModulFunc_t)(SModulFunctions *)
Definition: ipid.h:80
int(* iiAddCproc)(const char *libname, const char *procname, BOOLEAN pstatic, BOOLEAN(*func)(leftv res, leftv v))
Definition: ipid.h:69
int iiAddCproc(const char *libname, const char *procname, BOOLEAN pstatic, BOOLEAN(*func)(leftv res, leftv v))
Definition: iplib.cc:1004
char * iiConvName(const char *libname)
Definition: iplib.cc:1331
int BOOLEAN
Definition: auxiliary.h:85
int(* iiArithAddCmd)(const char *szName, short nAlias, short nTokval, short nToktype, short nPos)
Definition: ipid.h:71
void Werror(const char *fmt,...)
Definition: reporter.cc:189
const char * dynl_error()
Definition: mod_raw.cc:175
int IsCmd(const char *n, int &tok)
Definition: iparith.cc:8897
#define Warn
Definition: emacs.cc:77
#define omStrDup(s)
Definition: omAllocDecl.h:263
int iiArithAddCmd(const char *szName, short nAlias, short nTokval, short nToktype, short nPos)
Definition: iparith.cc:9242

◆ module_help_main()

void module_help_main ( const char *  newlib,
const char *  help 
)

Definition at line 1249 of file iplib.cc.

1250 {
1251  char *plib = iiConvName(newlib);
1252  idhdl pl = basePack->idroot->get(plib,0);
1253  if ((pl==NULL)||(IDTYP(pl)!=PACKAGE_CMD))
1254  Werror(">>%s<< is not a package (trying to add package help)",plib);
1255  else
1256  {
1257  package s=currPack;
1258  currPack=IDPACKAGE(pl);
1259  idhdl h=enterid("info",0,STRING_CMD,&IDROOT,FALSE);
1260  IDSTRING(h)=omStrDup(help);
1261  currPack=s;
1262  }
1263 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
#define FALSE
Definition: auxiliary.h:94
#define IDROOT
Definition: ipid.h:18
Definition: idrec.h:34
#define IDPACKAGE(a)
Definition: ipid.h:134
#define IDTYP(a)
Definition: ipid.h:114
idhdl enterid(const char *s, int lev, int t, idhdl *root, BOOLEAN init, BOOLEAN search)
Definition: ipid.cc:265
#define IDSTRING(a)
Definition: ipid.h:131
#define help
Definition: libparse.cc:1228
#define NULL
Definition: omList.c:12
package basePack
Definition: ipid.cc:58
package currPack
Definition: ipid.cc:57
char * iiConvName(const char *libname)
Definition: iplib.cc:1331
static Poly * h
Definition: janet.cc:971
void Werror(const char *fmt,...)
Definition: reporter.cc:189
#define omStrDup(s)
Definition: omAllocDecl.h:263

◆ module_help_proc()

void module_help_proc ( const char *  newlib,
const char *  p,
const char *  help 
)

Definition at line 1264 of file iplib.cc.

1265 {
1266  char *plib = iiConvName(newlib);
1267  idhdl pl = basePack->idroot->get(plib,0);
1268  if ((pl==NULL)||(IDTYP(pl)!=PACKAGE_CMD))
1269  Werror(">>%s<< is not a package(trying to add help for %s)",plib,p);
1270  else
1271  {
1272  package s=currPack;
1273  currPack=IDPACKAGE(pl);
1274  char buff[256];
1275  buff[255]='\0';
1276  strncpy(buff,p,255);
1277  strncat(buff,"_help",255-strlen(p));
1278  idhdl h=enterid(buff,0,STRING_CMD,&IDROOT,FALSE);
1279  IDSTRING(h)=omStrDup(help);
1280  currPack=s;
1281  }
1282 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
#define FALSE
Definition: auxiliary.h:94
#define IDROOT
Definition: ipid.h:18
Definition: idrec.h:34
#define IDPACKAGE(a)
Definition: ipid.h:134
#define IDTYP(a)
Definition: ipid.h:114
idhdl enterid(const char *s, int lev, int t, idhdl *root, BOOLEAN init, BOOLEAN search)
Definition: ipid.cc:265
#define IDSTRING(a)
Definition: ipid.h:131
#define help
Definition: libparse.cc:1228
#define NULL
Definition: omList.c:12
package basePack
Definition: ipid.cc:58
package currPack
Definition: ipid.cc:57
int p
Definition: cfModGcd.cc:4019
char * iiConvName(const char *libname)
Definition: iplib.cc:1331
static Poly * h
Definition: janet.cc:971
void Werror(const char *fmt,...)
Definition: reporter.cc:189
#define omStrDup(s)
Definition: omAllocDecl.h:263

◆ mytolower()

char mytolower ( char  c)

Definition at line 1318 of file iplib.cc.

1319 {
1320  if(c>=65 && c<=(65+26)) c+=32;
1321  return(c);
1322 }

◆ mytoupper()

char mytoupper ( char  c)

Definition at line 1312 of file iplib.cc.

1313 {
1314  if(c>=97 && c<=(97+26)) c-=32;
1315  return(c);
1316 }

◆ print_init()

void print_init ( )

Definition at line 3480 of file libparse.cc.

3481 {
3482  printf("Init=%d\n", yy_init);
3483 }
static int yy_init
Definition: libparse.cc:238

◆ SI_FOREACH_BUILTIN()

SI_FOREACH_BUILTIN ( SI_GET_BUILTIN_MOD_INIT0  )

◆ yylprestart()

void yylprestart ( FILE *  input_file)

Variable Documentation

◆ iiLocalRing

ring* iiLocalRing

Definition at line 453 of file iplib.cc.

◆ iiRETURNEXPR

sleftv iiRETURNEXPR

Definition at line 454 of file iplib.cc.

◆ iiRETURNEXPR_len

int iiRETURNEXPR_len =0

Definition at line 455 of file iplib.cc.

◆ library_stack

libstackv library_stack

Definition at line 64 of file iplib.cc.

◆ yylp_errlist

char* yylp_errlist[]

Definition at line 1112 of file libparse.cc.

◆ yylp_errno

int yylp_errno

Definition at line 1128 of file libparse.cc.

◆ yylplineno

int yylplineno

Definition at line 1102 of file libparse.cc.