Macros | Functions | Variables
iplib.cc File Reference
#include <kernel/mod2.h>
#include <Singular/tok.h>
#include <misc/options.h>
#include <Singular/ipid.h>
#include <omalloc/omalloc.h>
#include <polys/monomials/ring.h>
#include <Singular/subexpr.h>
#include <Singular/ipshell.h>
#include <Singular/fevoices.h>
#include <Singular/lists.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <sys/stat.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 * iiGetLibName (procinfov pi)
 
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 45 of file iplib.cc.

◆ MODULE_SUFFIX_STRING

#define MODULE_SUFFIX_STRING   EXPANDED_STRINGIFY(MODULE_SUFFIX)

Definition at line 48 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 762 of file iplib.cc.

◆ SI_MAX_NEST

#define SI_MAX_NEST   500

Definition at line 33 of file iplib.cc.

Function Documentation

◆ binary_module_function()

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

Definition at line 1297 of file iplib.cc.

1298 {
1299  void* result = NULL;
1300 
1301  const char* bin_dir = feGetResource('b');
1302  if (!bin_dir) { return NULL; }
1303 
1304  char path_name[MAXPATHLEN];
1305  sprintf(path_name, "%s%s%s.%s", bin_dir, DIR_SEPP, newlib, MODULE_SUFFIX_STRING);
1306 
1307  void* openlib = dynl_open(path_name);
1308  if(!openlib)
1309  {
1310  Werror("dynl_open of %s failed:%s", path_name, dynl_error());
1311  return NULL;
1312  }
1313  result = dynl_sym(openlib, funcname);
1314  if (!result) Werror("%s: %s\n", funcname, dynl_error());
1315 
1316  return result;
1317 }
#define MAXPATHLEN
Definition: omRet2Info.c:22
void * dynl_sym(void *handle, const char *symbol)
Definition: mod_raw.cc:167
void * dynl_open(char *filename)
Definition: mod_raw.cc:153
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:48
#define NULL
Definition: omList.c:10
void Werror(const char *fmt,...)
Definition: reporter.cc:189
return result
Definition: facAbsBiFact.cc:76
const char * dynl_error()
Definition: mod_raw.cc:183

◆ 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:123
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 1023 of file iplib.cc.

1025 {
1026  procinfov pi;
1027  idhdl h;
1028 
1029  #ifndef SING_NDEBUG
1030  int dummy;
1031  if (IsCmd(procname,dummy))
1032  {
1033  Werror(">>%s< is a reserved name",procname);
1034  return 0;
1035  }
1036  #endif
1037 
1038  h=IDROOT->get(procname,0);
1039  if ((h!=NULL)
1040  && (IDTYP(h)==PROC_CMD))
1041  {
1042  pi = IDPROC(h);
1043  if ((pi->language == LANG_SINGULAR)
1044  &&(BVERBOSE(V_REDEFINE)))
1045  Warn("extend `%s`",procname);
1046  }
1047  else
1048  {
1049  h = enterid(procname,0, PROC_CMD, &IDROOT, TRUE);
1050  }
1051  if ( h!= NULL )
1052  {
1053  pi = IDPROC(h);
1054  if((pi->language == LANG_SINGULAR)
1055  ||(pi->language == LANG_NONE))
1056  {
1057  omfree(pi->libname);
1058  pi->libname = omStrDup(libname);
1059  omfree(pi->procname);
1060  pi->procname = omStrDup(procname);
1061  pi->language = LANG_C;
1062  pi->ref = 1;
1063  pi->is_static = pstatic;
1064  pi->data.o.function = func;
1065  }
1066  else if(pi->language == LANG_C)
1067  {
1068  if(pi->data.o.function == func)
1069  {
1070  pi->ref++;
1071  }
1072  else
1073  {
1074  omfree(pi->libname);
1075  pi->libname = omStrDup(libname);
1076  omfree(pi->procname);
1077  pi->procname = omStrDup(procname);
1078  pi->language = LANG_C;
1079  pi->ref = 1;
1080  pi->is_static = pstatic;
1081  pi->data.o.function = func;
1082  }
1083  }
1084  else
1085  Warn("internal error: unknown procedure type %d",pi->language);
1086  return(1);
1087  }
1088  else
1089  {
1090  WarnS("iiAddCproc: failed.");
1091  }
1092  return(0);
1093 }
language_defs language
Definition: subexpr.h:59
#define IDROOT
Definition: ipid.h:20
#define TRUE
Definition: auxiliary.h:98
short ref
Definition: subexpr.h:60
#define WarnS
Definition: emacs.cc:81
Definition: idrec.h:34
char * procname
Definition: subexpr.h:57
Definition: subexpr.h:22
#define IDTYP(a)
Definition: ipid.h:116
idhdl enterid(const char *s, int lev, int t, idhdl *root, BOOLEAN init, BOOLEAN search)
Definition: ipid.cc:258
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:33
char is_static
Definition: subexpr.h:61
#define IDPROC(a)
Definition: ipid.h:137
#define pi
Definition: libparse.cc:1143
#define NULL
Definition: omList.c:10
static Poly * h
Definition: janet.cc:978
#define V_REDEFINE
Definition: options.h:43
void Werror(const char *fmt,...)
Definition: reporter.cc:189
int IsCmd(const char *n, int &tok)
Definition: iparith.cc:8729
#define Warn
Definition: emacs.cc:80
#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 1095 of file iplib.cc.

1097 {
1098  int r=iiAddCproc(libname,procname,pstatic,func);
1099  package s=currPack;
1101  if (r) r=iiAddCproc(libname,procname,pstatic,func);
1102  currPack=s;
1103  return r;
1104 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
const ring r
Definition: syzextra.cc:208
package basePack
Definition: ipid.cc:64
package currPack
Definition: ipid.cc:63
int iiAddCproc(const char *libname, const char *procname, BOOLEAN pstatic, BOOLEAN(*func)(leftv res, leftv v))
Definition: iplib.cc:1023

◆ iiAllStart()

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

Definition at line 311 of file iplib.cc.

312 {
313  // see below:
314  BITSET save1=si_opt_1;
315  BITSET save2=si_opt_2;
316  newBuffer( omStrDup(p /*pi->data.s.body*/), t /*BT_proc*/,
317  pi, l );
318  BOOLEAN err=yyparse();
319  if (sLastPrinted.rtyp!=0)
320  {
322  }
323  // the access to optionStruct and verboseStruct do not work
324  // on x86_64-Linux for pic-code
325  if ((TEST_V_ALLWARN) &&
326  (t==BT_proc) &&
327  ((save1!=si_opt_1)||(save2!=si_opt_2)) &&
328  (pi->libname!=NULL) && (pi->libname[0]!='\0'))
329  {
330  if ((pi->libname!=NULL) && (pi->libname[0]!='\0'))
331  Warn("option changed in proc %s from %s",pi->procname,pi->libname);
332  else
333  Warn("option changed in proc %s",pi->procname);
334  int i;
335  for (i=0; optionStruct[i].setval!=0; i++)
336  {
337  if ((optionStruct[i].setval & si_opt_1)
338  && (!(optionStruct[i].setval & save1)))
339  {
340  Print(" +%s",optionStruct[i].name);
341  }
342  if (!(optionStruct[i].setval & si_opt_1)
343  && ((optionStruct[i].setval & save1)))
344  {
345  Print(" -%s",optionStruct[i].name);
346  }
347  }
348  for (i=0; verboseStruct[i].setval!=0; i++)
349  {
350  if ((verboseStruct[i].setval & si_opt_2)
351  && (!(verboseStruct[i].setval & save2)))
352  {
353  Print(" +%s",verboseStruct[i].name);
354  }
355  if (!(verboseStruct[i].setval & si_opt_2)
356  && ((verboseStruct[i].setval & save2)))
357  {
358  Print(" -%s",verboseStruct[i].name);
359  }
360  }
361  PrintLn();
362  }
363  return err;
364 }
const struct soptionStruct optionStruct[]
Definition: misc_ip.cc:516
unsigned si_opt_1
Definition: options.c:5
void PrintLn()
Definition: reporter.cc:310
#define Print
Definition: emacs.cc:83
return P p
Definition: myNF.cc:203
unsigned setval
Definition: ipid.h:152
#define BITSET
Definition: structs.h:18
char * procname
Definition: subexpr.h:57
char * libname
Definition: subexpr.h:56
int i
Definition: cfEzgcd.cc:123
char name(const Variable &v)
Definition: factory.h:178
int yyparse(void)
Definition: grammar.cc:2101
#define NULL
Definition: omList.c:10
int rtyp
Definition: subexpr.h:91
sleftv sLastPrinted
Definition: subexpr.cc:55
void CleanUp(ring r=currRing)
Definition: subexpr.cc:332
void newBuffer(char *s, feBufferTypes t, procinfo *pi, int lineno)
Definition: fevoices.cc:171
const struct soptionStruct verboseStruct[]
Definition: misc_ip.cc:546
unsigned si_opt_2
Definition: options.c:6
int BOOLEAN
Definition: auxiliary.h:85
#define TEST_V_ALLWARN
Definition: options.h:135
int l
Definition: cfEzgcd.cc:94
#define Warn
Definition: emacs.cc:80
#define omStrDup(s)
Definition: omAllocDecl.h:263

◆ iiArithAddCmd()

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

Definition at line 9067 of file iparith.cc.

9074 {
9075  //printf("AddCmd(%s, %d, %d, %d, %d)\n", szName, nAlias,
9076  // nTokval, nToktype, nPos);
9077  if(nPos>=0)
9078  {
9079  // no checks: we rely on a correct generated code in iparith.inc
9080  assume((unsigned)nPos < sArithBase.nCmdAllocated);
9081  assume(szName!=NULL);
9082  sArithBase.sCmds[nPos].name = omStrDup(szName);
9083  sArithBase.sCmds[nPos].alias = nAlias;
9084  sArithBase.sCmds[nPos].tokval = nTokval;
9085  sArithBase.sCmds[nPos].toktype = nToktype;
9086  sArithBase.nCmdUsed++;
9087  //if(nTokval>0) sArithBase.nLastIdentifier++;
9088  }
9089  else
9090  {
9091  if(szName==NULL) return -1;
9092  int nIndex = iiArithFindCmd(szName);
9093  if(nIndex>=0)
9094  {
9095  Print("'%s' already exists at %d\n", szName, nIndex);
9096  return -1;
9097  }
9098 
9100  {
9101  /* needs to create new slots */
9102  unsigned long nSize = (sArithBase.nCmdAllocated+1)*sizeof(cmdnames);
9103  sArithBase.sCmds = (cmdnames *)omRealloc(sArithBase.sCmds, nSize);
9104  if(sArithBase.sCmds==NULL) return -1;
9106  }
9107  /* still free slots available */
9108  sArithBase.sCmds[sArithBase.nCmdUsed].name = omStrDup(szName);
9109  sArithBase.sCmds[sArithBase.nCmdUsed].alias = nAlias;
9110  sArithBase.sCmds[sArithBase.nCmdUsed].tokval = nTokval;
9111  sArithBase.sCmds[sArithBase.nCmdUsed].toktype = nToktype;
9112  sArithBase.nCmdUsed++;
9113 
9114  qsort(sArithBase.sCmds, sArithBase.nCmdUsed, sizeof(cmdnames),
9115  (&_gentable_sort_cmds));
9118  {
9119  if(sArithBase.sCmds[sArithBase.nLastIdentifier].tokval>=0) break;
9120  }
9121  //Print("L=%d\n", sArithBase.nLastIdentifier);
9122  }
9123  return 0;
9124 }
static int _gentable_sort_cmds(const void *a, const void *b)
compares to entry of cmdsname-list
Definition: iparith.cc:8900
#define Print
Definition: emacs.cc:83
unsigned nCmdAllocated
number of commands-slots allocated
Definition: iparith.cc:194
#define assume(x)
Definition: mod2.h:394
unsigned nLastIdentifier
valid indentifieres are slot 1..nLastIdentifier
Definition: iparith.cc:195
#define NULL
Definition: omList.c:10
unsigned nCmdUsed
number of commands used
Definition: iparith.cc:193
#define nSize(n)
Definition: numbers.h:39
static SArithBase sArithBase
Base entry for arithmetic.
Definition: iparith.cc:203
int iiArithFindCmd(const char *szName)
Definition: iparith.cc:8972
cmdnames * sCmds
array of existing commands
Definition: iparith.cc:188
#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 631 of file iplib.cc.

632 {
633  idhdl h=ggetid(n);
634  if ((h==NULL)
635  || (IDTYP(h)!=PROC_CMD))
636  {
637  err=2;
638  return NULL;
639  }
640  // ring handling
641  idhdl save_ringhdl=currRingHdl;
642  ring save_ring=currRing;
644  // argument:
645  sleftv tmp;
646  tmp.Init();
647  tmp.data=arg;
648  tmp.rtyp=arg_type;
649  // call proc
650  err=iiMake_proc(h,currPack,&tmp);
651  // clean up ring
652  iiCallLibProcEnd(save_ringhdl,save_ring);
653  // return
654  if (err==FALSE)
655  {
656  void*r=iiRETURNEXPR.data;
659  return r;
660  }
661  return NULL;
662 }
idhdl ggetid(const char *n)
Definition: ipid.cc:510
Class used for (list of) interpreter objects.
Definition: subexpr.h:82
#define FALSE
Definition: auxiliary.h:94
sleftv iiRETURNEXPR
Definition: iplib.cc:473
static void iiCallLibProcEnd(idhdl save_ringhdl, ring save_ring)
Definition: iplib.cc:606
void Init()
Definition: subexpr.h:107
Definition: idrec.h:34
void * data
Definition: subexpr.h:88
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:10
#define IDTYP(a)
Definition: ipid.h:116
const ring r
Definition: syzextra.cc:208
idhdl currRingHdl
Definition: ipid.cc:65
static void iiCallLibProcBegin()
Definition: iplib.cc:588
BOOLEAN iiMake_proc(idhdl pn, package pack, leftv sl)
Definition: iplib.cc:503
#define NULL
Definition: omList.c:10
package currPack
Definition: ipid.cc:63
int rtyp
Definition: subexpr.h:91
void CleanUp(ring r=currRing)
Definition: subexpr.cc:332
static Poly * h
Definition: janet.cc:978

◆ iiCallLibProcBegin()

static void iiCallLibProcBegin ( )
static

Definition at line 588 of file iplib.cc.

589 {
590  idhdl tmp_ring=NULL;
591  if (currRing!=NULL)
592  {
594  {
595  // clean up things depending on currRingHdl:
597  sLastPrinted.Init();
598  // need to define a ring-hdl for currRingHdl
599  tmp_ring=enterid(" tmpRing",myynest,RING_CMD,&IDROOT,FALSE);
600  IDRING(tmp_ring)=currRing;
601  currRing->ref++;
602  rSetHdl(tmp_ring);
603  }
604  }
605 }
#define FALSE
Definition: auxiliary.h:94
#define IDROOT
Definition: ipid.h:20
void Init()
Definition: subexpr.h:107
Definition: idrec.h:34
int myynest
Definition: febase.cc:46
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:10
idhdl enterid(const char *s, int lev, int t, idhdl *root, BOOLEAN init, BOOLEAN search)
Definition: ipid.cc:258
idhdl currRingHdl
Definition: ipid.cc:65
#define NULL
Definition: omList.c:10
#define IDRING(a)
Definition: ipid.h:124
sleftv sLastPrinted
Definition: subexpr.cc:55
void CleanUp(ring r=currRing)
Definition: subexpr.cc:332
void rSetHdl(idhdl h)
Definition: ipshell.cc:5038

◆ iiCallLibProcEnd()

static void iiCallLibProcEnd ( idhdl  save_ringhdl,
ring  save_ring 
)
static

Definition at line 606 of file iplib.cc.

607 {
608  if ((currRing!=NULL)
609  &&(currRing!=save_ring))
610  {
611  currRing->ref--;
612  idhdl hh=IDROOT;
613  idhdl prev=NULL;
614  while((hh!=currRingHdl) && (hh!=NULL)) { prev=hh; hh=hh->next; }
615  if (hh!=NULL)
616  {
617  if (prev==NULL) IDROOT=hh->next;
618  else prev->next=hh->next;
619  omFree((ADDRESS)IDID(hh));
621  }
622  else
623  {
624  WarnS("internal: lost ring in iiCallLib");
625  }
626  }
627  currRingHdl=save_ringhdl;
628  currRing=save_ring;
629 }
#define IDID(a)
Definition: ipid.h:119
#define IDROOT
Definition: ipid.h:20
void * ADDRESS
Definition: auxiliary.h:115
#define WarnS
Definition: emacs.cc:81
Definition: idrec.h:34
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:10
omBin idrec_bin
Definition: ipid.cc:52
#define omFree(addr)
Definition: omAllocDecl.h:261
idhdl currRingHdl
Definition: ipid.cc:65
idhdl next
Definition: idrec.h:38
#define NULL
Definition: omList.c:10
#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 665 of file iplib.cc.

666 {
667  idhdl h=ggetid(n);
668  if ((h==NULL)
669  || (IDTYP(h)!=PROC_CMD))
670  {
671  err=2;
672  return NULL;
673  }
674  // ring handling
675  idhdl save_ringhdl=currRingHdl;
676  ring save_ring=currRing;
678  // argument:
679  if (arg_types[0]!=0)
680  {
681  sleftv tmp;
682  leftv tt=&tmp;
683  int i=1;
684  tmp.Init();
685  tmp.data=args[0];
686  tmp.rtyp=arg_types[0];
687  while(arg_types[i]!=0)
688  {
689  tt->next=(leftv)omAlloc0(sizeof(sleftv));
690  tt=tt->next;
691  tt->rtyp=arg_types[i];
692  tt->data=args[i];
693  i++;
694  }
695  // call proc
696  err=iiMake_proc(h,currPack,&tmp);
697  }
698  else
699  // call proc
700  err=iiMake_proc(h,currPack,NULL);
701  // clean up ring
702  iiCallLibProcEnd(save_ringhdl,save_ring);
703  // return
704  if (err==FALSE)
705  {
706  void*r=iiRETURNEXPR.data;
709  return r;
710  }
711  return NULL;
712 }
idhdl ggetid(const char *n)
Definition: ipid.cc:510
Class used for (list of) interpreter objects.
Definition: subexpr.h:82
#define FALSE
Definition: auxiliary.h:94
sleftv iiRETURNEXPR
Definition: iplib.cc:473
static void iiCallLibProcEnd(idhdl save_ringhdl, ring save_ring)
Definition: iplib.cc:606
void Init()
Definition: subexpr.h:107
sleftv * leftv
Definition: structs.h:60
Definition: idrec.h:34
void * data
Definition: subexpr.h:88
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:10
#define IDTYP(a)
Definition: ipid.h:116
const ring r
Definition: syzextra.cc:208
idhdl currRingHdl
Definition: ipid.cc:65
int i
Definition: cfEzgcd.cc:123
static void iiCallLibProcBegin()
Definition: iplib.cc:588
leftv next
Definition: subexpr.h:86
BOOLEAN iiMake_proc(idhdl pn, package pack, leftv sl)
Definition: iplib.cc:503
#define NULL
Definition: omList.c:10
package currPack
Definition: ipid.cc:63
int rtyp
Definition: subexpr.h:91
void CleanUp(ring r=currRing)
Definition: subexpr.cc:332
static Poly * h
Definition: janet.cc:978
#define omAlloc0(size)
Definition: omAllocDecl.h:211

◆ iiCheckNest()

static void iiCheckNest ( )
static

Definition at line 492 of file iplib.cc.

493 {
494  if (myynest >= iiRETURNEXPR_len-1)
495  {
497  iiRETURNEXPR_len*sizeof(ring),
498  (iiRETURNEXPR_len+16)*sizeof(ring));
499  memset(&(iiLocalRing[iiRETURNEXPR_len]),0,16*sizeof(ring));
500  iiRETURNEXPR_len+=16;
501  }
502 }
int iiRETURNEXPR_len
Definition: iplib.cc:474
#define omreallocSize(addr, o_size, size)
Definition: omAllocDecl.h:231
int myynest
Definition: febase.cc:46
ring * iiLocalRing
Definition: iplib.cc:472

◆ iiCleanProcs()

static void iiCleanProcs ( idhdl root)
static

Definition at line 888 of file iplib.cc.

889 {
890  idhdl prev=NULL;
891  loop
892  {
893  if (root==NULL) return;
894  if (IDTYP(root)==PROC_CMD)
895  {
896  procinfo *pi=(procinfo*)IDDATA(root);
897  if ((pi->language == LANG_SINGULAR)
898  && (pi->data.s.body_start == 0L))
899  {
900  // procinfo data incorrect:
901  // - no proc body can start at the beginning of the file
902  killhdl(root);
903  if (prev==NULL)
904  root=IDROOT;
905  else
906  {
907  root=prev;
908  prev=NULL;
909  }
910  continue;
911  }
912  }
913  prev=root;
914  root=IDNEXT(root);
915  }
916 }
loop
Definition: myNF.cc:98
#define IDNEXT(a)
Definition: ipid.h:115
language_defs language
Definition: subexpr.h:59
#define IDROOT
Definition: ipid.h:20
Definition: idrec.h:34
#define IDTYP(a)
Definition: ipid.h:116
procinfodata data
Definition: subexpr.h:63
#define pi
Definition: libparse.cc:1143
#define NULL
Definition: omList.c:10
void killhdl(idhdl h, package proot)
Definition: ipid.cc:377
#define IDDATA(a)
Definition: ipid.h:123

◆ iiConvName()

char* iiConvName ( const char *  libname)

Definition at line 1340 of file iplib.cc.

1341 {
1342  char *tmpname = omStrDup(libname);
1343  char *p = strrchr(tmpname, DIR_SEP);
1344  char *r;
1345  if(p==NULL) p = tmpname;
1346  else p++;
1347  r = (char *)strchr(p, '.');
1348  if( r!= NULL) *r = '\0';
1349  r = omStrDup(p);
1350  *r = mytoupper(*r);
1351  // printf("iiConvName: '%s' '%s' => '%s'\n", libname, tmpname, r);
1352  omFree((ADDRESS)tmpname);
1353 
1354  return(r);
1355 }
char mytoupper(char c)
Definition: iplib.cc:1321
return P p
Definition: myNF.cc:203
void * ADDRESS
Definition: auxiliary.h:115
#define DIR_SEP
Definition: feResource.h:6
const ring r
Definition: syzextra.cc:208
#define omFree(addr)
Definition: omAllocDecl.h:261
#define NULL
Definition: omList.c:10
#define omStrDup(s)
Definition: omAllocDecl.h:263

◆ iiEStart()

BOOLEAN iiEStart ( char *  example,
procinfo pi 
)

Definition at line 717 of file iplib.cc.

718 {
719  BOOLEAN err;
720  int old_echo=si_echo;
721 
722  iiCheckNest();
723  procstack->push(example);
726  {
727  if (traceit&TRACE_SHOW_LINENO) printf("\n");
728  printf("entering example (level %d)\n",myynest);
729  }
730  myynest++;
731 
732  err=iiAllStart(pi,example,BT_example,(pi != NULL ? pi->data.s.example_lineno: 0));
733 
735  myynest--;
736  si_echo=old_echo;
737  if (traceit&TRACE_SHOW_PROC)
738  {
739  if (traceit&TRACE_SHOW_LINENO) printf("\n");
740  printf("leaving -example- (level %d)\n",myynest);
741  }
742  if (iiLocalRing[myynest] != currRing)
743  {
744  if (iiLocalRing[myynest]!=NULL)
745  {
748  }
749  else
750  {
752  currRing=NULL;
753  }
754  }
755  procstack->pop();
756  return err;
757 }
#define TRACE_SHOW_LINENO
Definition: reporter.h:30
proclevel * procstack
Definition: ipid.cc:58
int traceit
Definition: febase.cc:47
static void iiCheckNest()
Definition: iplib.cc:492
int myynest
Definition: febase.cc:46
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:10
void killlocals(int v)
Definition: ipshell.cc:378
procinfodata data
Definition: subexpr.h:63
idhdl currRingHdl
Definition: ipid.cc:65
idhdl rFindHdl(ring r, idhdl n)
Definition: ipshell.cc:1594
BOOLEAN iiAllStart(procinfov pi, char *p, feBufferTypes t, int l)
Definition: iplib.cc:311
ring * iiLocalRing
Definition: iplib.cc:472
#define NULL
Definition: omList.c:10
#define TRACE_SHOW_PROC
Definition: reporter.h:28
void rSetHdl(idhdl h)
Definition: ipshell.cc:5038
void push(char *)
Definition: ipid.cc:711
void pop()
Definition: ipid.cc:721
int BOOLEAN
Definition: auxiliary.h:85
int si_echo
Definition: febase.cc:41

◆ iiGetBuiltinModInit()

SModulFunc_t iiGetBuiltinModInit ( const char *  libname)

Definition at line 769 of file iplib.cc.

770 {
771 # define SI_GET_BUILTIN_MOD_INIT(name) if (strcmp(libname, #name ".so") == 0){ return SI_MOD_INIT0(name); }
773 # undef SI_GET_BUILTIN_MOD_INIT
774 
775  return NULL;
776 }
#define SI_GET_BUILTIN_MOD_INIT(name)
SI_FOREACH_BUILTIN(SI_GET_BUILTIN_MOD_INIT0) }
#define NULL
Definition: omList.c:10

◆ iiGetLibName()

char* iiGetLibName ( procinfov  pi)

Definition at line 101 of file iplib.cc.

102 {
103  return pi->libname;
104 }
char * libname
Definition: subexpr.h:56

◆ iiGetLibProcBuffer()

char* iiGetLibProcBuffer ( procinfo pi,
int  part 
)

Definition at line 210 of file iplib.cc.

211 {
212  char buf[256], *s = NULL, *p;
213  long procbuflen;
214 
215  FILE * fp = feFopen( pi->libname, "rb", NULL, TRUE );
216  if (fp==NULL)
217  {
218  return NULL;
219  }
220 
221  fseek(fp, pi->data.s.proc_start, SEEK_SET);
222  if(part==0)
223  { // load help string
224  int i, offset=0;
225  long head = pi->data.s.def_end - pi->data.s.proc_start;
226  procbuflen = pi->data.s.help_end - pi->data.s.help_start;
227  if (procbuflen<5)
228  {
229  fclose(fp);
230  return NULL; // help part does not exist
231  }
232  //Print("Help=%ld-%ld=%d\n", pi->data.s.body_start,
233  // pi->data.s.proc_start, procbuflen);
234  s = (char *)omAlloc(procbuflen+head+3);
235  myfread(s, head, 1, fp);
236  s[head] = '\n';
237  fseek(fp, pi->data.s.help_start, SEEK_SET);
238  myfread(s+head+1, procbuflen, 1, fp);
239  fclose(fp);
240  s[procbuflen+head+1] = '\n';
241  s[procbuflen+head+2] = '\0';
242  offset=0;
243  for(i=0;i<=procbuflen+head+2; i++)
244  {
245  if(s[i]=='\\' &&
246  (s[i+1]=='"' || s[i+1]=='{' || s[i+1]=='}' || s[i+1]=='\\'))
247  {
248  i++;
249  offset++;
250  }
251  if(offset>0) s[i-offset] = s[i];
252  }
253  return(s);
254  }
255  else if(part==1)
256  { // load proc part - must exist
257  procbuflen = pi->data.s.def_end - pi->data.s.proc_start;
258  char *ss=(char *)omAlloc(procbuflen+2);
259  //fgets(buf, sizeof(buf), fp);
260  myfread( ss, procbuflen, 1, fp);
261  char ct;
262  char *e;
263  s=iiProcName(ss,ct,e);
264  char *argstr=NULL;
265  *e=ct;
266  argstr=iiProcArgs(e,TRUE);
267 
268  assume(pi->data.s.body_end > pi->data.s.body_start);
269 
270  procbuflen = pi->data.s.body_end - pi->data.s.body_start;
271  pi->data.s.body = (char *)omAlloc( strlen(argstr)+procbuflen+15+
272  strlen(pi->libname) );
273  //Print("Body=%ld-%ld=%d\n", pi->data.s.body_end,
274  // pi->data.s.body_start, procbuflen);
275  assume(pi->data.s.body != NULL);
276  fseek(fp, pi->data.s.body_start, SEEK_SET);
277  strcpy(pi->data.s.body,argstr);
278  myfread( pi->data.s.body+strlen(argstr), procbuflen, 1, fp);
279  fclose( fp );
280  procbuflen+=strlen(argstr);
281  omFree(argstr);
282  omFree(ss);
283  pi->data.s.body[procbuflen] = '\0';
284  strcat( pi->data.s.body+procbuflen, "\n;return();\n\n" );
285  strcat( pi->data.s.body+procbuflen+13,pi->libname);
286  s=(char *)strchr(pi->data.s.body,'{');
287  if (s!=NULL) *s=' ';
288  return NULL;
289  }
290  else if(part==2)
291  { // example
292  if ( pi->data.s.example_lineno == 0)
293  return NULL; // example part does not exist
294  // load example
295  fseek(fp, pi->data.s.example_start, SEEK_SET);
296  /*char *dummy=*/ (void) fgets(buf, sizeof(buf), fp); // skip line with "example"
297  procbuflen = pi->data.s.proc_end - pi->data.s.example_start - strlen(buf);
298  //Print("Example=%ld-%ld=%d\n", pi->data.s.proc_end,
299  // pi->data.s.example_start, procbuflen);
300  s = (char *)omAlloc(procbuflen+14);
301  myfread(s, procbuflen, 1, fp);
302  s[procbuflen] = '\0';
303  strcat(s+procbuflen-3, "\n;return();\n\n" );
304  p=(char *)strchr(s,'{');
305  if (p!=NULL) *p=' ';
306  return(s);
307  }
308  return NULL;
309 }
char * iiProcArgs(char *e, BOOLEAN withParenth)
Definition: iplib.cc:127
const CanonicalForm int s
Definition: facAbsFact.cc:55
CanonicalForm fp
Definition: cfModGcd.cc:4043
return P p
Definition: myNF.cc:203
#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:394
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:123
char * iiProcName(char *buf, char &ct, char *&e)
Definition: iplib.cc:113
#define NULL
Definition: omList.c:10
CanonicalForm head(const CanonicalForm &f)
#define SEEK_SET
Definition: mod2.h:114
int offset
Definition: libparse.cc:1091

◆ iiGetLibStatus()

BOOLEAN iiGetLibStatus ( char *  lib)

Definition at line 83 of file iplib.cc.

84 {
85  idhdl hl;
86 
87  char *plib = iiConvName(lib);
88  hl = basePack->idroot->get(plib,0);
89  omFree(plib);
90  if((hl==NULL) ||(IDTYP(hl)!=PACKAGE_CMD))
91  {
92  return FALSE;
93  }
94  return (strcmp(lib,IDPACKAGE(hl)->libname)==0);
95 }
#define FALSE
Definition: auxiliary.h:94
Definition: idrec.h:34
#define IDPACKAGE(a)
Definition: ipid.h:136
#define IDTYP(a)
Definition: ipid.h:116
#define omFree(addr)
Definition: omAllocDecl.h:261
#define NULL
Definition: omList.c:10
package basePack
Definition: ipid.cc:64
char * iiConvName(const char *libname)
Definition: iplib.cc:1340

◆ iiInitSingularProcinfo()

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

Definition at line 1009 of file iplib.cc.

1011 {
1012  memset(pi,0,sizeof(*pi));
1013  pi->libname = omStrDup(libname);
1014  pi->procname = omStrDup(procname);
1015  pi->language = LANG_SINGULAR;
1016  pi->ref = 1;
1017  pi->is_static = pstatic;
1018  pi->data.s.proc_start = pos;
1019  return(pi);
1020 }
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 844 of file iplib.cc.

845 {
846  char libnamebuf[1024];
847  // procinfov pi;
848  // idhdl h;
849  idhdl pl;
850  // idhdl hl;
851  // long pos = 0L;
852  char *plib = iiConvName(newlib);
853  FILE * fp = feFopen( newlib, "r", libnamebuf, tellerror );
854  // int lines = 1;
855  BOOLEAN LoadResult = TRUE;
856 
857  if (fp==NULL)
858  {
859  return TRUE;
860  }
861  pl = basePack->idroot->get(plib,0);
862  if (pl==NULL)
863  {
864  pl = enterid( plib,0, PACKAGE_CMD,
865  &(basePack->idroot), TRUE );
866  IDPACKAGE(pl)->language = LANG_SINGULAR;
867  IDPACKAGE(pl)->libname=omStrDup(newlib);
868  }
869  else
870  {
871  if(IDTYP(pl)!=PACKAGE_CMD)
872  {
873  WarnS("not of type package.");
874  fclose(fp);
875  return TRUE;
876  }
877  if (!force) return FALSE;
878  }
879  LoadResult = iiLoadLIB(fp, libnamebuf, newlib, pl, autoexport, tellerror);
880  omFree((ADDRESS)newlib);
881 
882  if(!LoadResult) IDPACKAGE(pl)->loaded = TRUE;
883  omFree((ADDRESS)plib);
884 
885  return LoadResult;
886 }
CanonicalForm fp
Definition: cfModGcd.cc:4043
#define FALSE
Definition: auxiliary.h:94
#define TRUE
Definition: auxiliary.h:98
void * ADDRESS
Definition: auxiliary.h:115
#define WarnS
Definition: emacs.cc:81
Definition: idrec.h:34
#define IDPACKAGE(a)
Definition: ipid.h:136
#define IDTYP(a)
Definition: ipid.h:116
idhdl enterid(const char *s, int lev, int t, idhdl *root, BOOLEAN init, BOOLEAN search)
Definition: ipid.cc:258
#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:10
package basePack
Definition: ipid.cc:64
BOOLEAN iiLoadLIB(FILE *fp, const char *libnamebuf, const char *newlib, idhdl pl, BOOLEAN autoexport, BOOLEAN tellerror)
Definition: iplib.cc:933
char * iiConvName(const char *libname)
Definition: iplib.cc:1340
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 933 of file iplib.cc.

935 {
936  extern FILE *yylpin;
937  libstackv ls_start = library_stack;
938  lib_style_types lib_style;
939 
940  yylpin = fp;
941  #if YYLPDEBUG > 1
942  print_init();
943  #endif
944  extern int lpverbose;
945  if (BVERBOSE(V_DEBUG_LIB)) lpverbose=1;
946  else lpverbose=0;
947  // yylplex sets also text_buffer
948  if (text_buffer!=NULL) *text_buffer='\0';
949  yylplex(newlib, libnamebuf, &lib_style, pl, autoexport);
950  if(yylp_errno)
951  {
952  Werror("Library %s: ERROR occurred: in line %d, %d.", newlib, yylplineno,
953  current_pos(0));
955  {
959  }
960  else
962  WerrorS("Cannot load library,... aborting.");
963  reinit_yylp();
964  fclose( yylpin );
966  return TRUE;
967  }
968  if (BVERBOSE(V_LOAD_LIB))
969  Print( "// ** loaded %s %s\n", libnamebuf, text_buffer);
970  if( (lib_style == OLD_LIBSTYLE) && (BVERBOSE(V_LOAD_LIB)))
971  {
972  Warn( "library %s has old format. This format is still accepted,", newlib);
973  Warn( "but for functionality you may wish to change to the new");
974  Warn( "format. Please refer to the manual for further information.");
975  }
976  reinit_yylp();
977  fclose( yylpin );
978  fp = NULL;
979  iiRunInit(IDPACKAGE(pl));
980 
981  {
982  libstackv ls;
983  for(ls = library_stack; (ls != NULL) && (ls != ls_start); )
984  {
985  if(ls->to_be_done)
986  {
987  ls->to_be_done=FALSE;
988  iiLibCmd(ls->get(),autoexport,tellerror,FALSE);
989  ls = ls->pop(newlib);
990  }
991  }
992 #if 0
993  PrintS("--------------------\n");
994  for(ls = library_stack; ls != NULL; ls = ls->next)
995  {
996  Print("%s: LIB-stack:(%d), %s %s\n", newlib, ls->cnt, ls->get(),
997  ls->to_be_done ? "not loaded" : "loaded");
998  }
999  PrintS("--------------------\n");
1000 #endif
1001  }
1002 
1003  if(fp != NULL) fclose(fp);
1004  return FALSE;
1005 }
int cnt
Definition: subexpr.h:166
#define Print
Definition: emacs.cc:83
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:917
#define V_LOAD_LIB
Definition: options.h:45
#define IDROOT
Definition: ipid.h:20
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:115
void WerrorS(const char *s)
Definition: feFopen.cc:24
char * get()
Definition: subexpr.h:169
#define V_DEBUG_LIB
Definition: options.h:46
libstackv pop(const char *p)
Definition: iplib.cc:1429
BOOLEAN iiLibCmd(char *newlib, BOOLEAN autoexport, BOOLEAN tellerror, BOOLEAN force)
Definition: iplib.cc:844
#define IDPACKAGE(a)
Definition: ipid.h:136
#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:33
#define NULL
Definition: omList.c:10
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:888
void Werror(const char *fmt,...)
Definition: reporter.cc:189
libstackv library_stack
Definition: iplib.cc:74
int yylplineno
Definition: libparse.cc:1102
#define Warn
Definition: emacs.cc:80
void reinit_yylp()
Definition: libparse.cc:3374

◆ iiLocateLib()

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

Definition at line 830 of file iplib.cc.

831 {
832  char *plib = iiConvName(lib);
833  idhdl pl = basePack->idroot->get(plib,0);
834  if( (pl!=NULL) && (IDTYP(pl)==PACKAGE_CMD) &&
835  (IDPACKAGE(pl)->language == LANG_SINGULAR))
836  {
837  strncpy(where,IDPACKAGE(pl)->libname,127);
838  return TRUE;
839  }
840  else
841  return FALSE;;
842 }
#define FALSE
Definition: auxiliary.h:94
#define TRUE
Definition: auxiliary.h:98
Definition: idrec.h:34
#define IDPACKAGE(a)
Definition: ipid.h:136
#define IDTYP(a)
Definition: ipid.h:116
#define NULL
Definition: omList.c:10
package basePack
Definition: ipid.cc:64
char * iiConvName(const char *libname)
Definition: iplib.cc:1340

◆ iiMake_proc()

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

Definition at line 503 of file iplib.cc.

504 {
505  int err;
506  procinfov pi = IDPROC(pn);
507  if(pi->is_static && myynest==0)
508  {
509  Werror("'%s::%s()' is a local procedure and cannot be accessed by an user.",
510  pi->libname, pi->procname);
511  return TRUE;
512  }
513  iiCheckNest();
515  //Print("currRing(%d):%s(%x) in %s\n",myynest,IDID(currRingHdl),currRing,IDID(pn));
516  iiRETURNEXPR.Init();
517  procstack->push(pi->procname);
519  || (pi->trace_flag&TRACE_SHOW_PROC))
520  {
522  Print("entering%-*.*s %s (level %d)\n",myynest*2,myynest*2," ",IDID(pn),myynest);
523  }
524 #ifdef RDEBUG
526 #endif
527  switch (pi->language)
528  {
529  default:
530  case LANG_NONE:
531  WerrorS("undefined proc");
532  err=TRUE;
533  break;
534 
535  case LANG_SINGULAR:
536  if ((pi->pack!=NULL)&&(currPack!=pi->pack))
537  {
538  currPack=pi->pack;
541  //Print("set pack=%s\n",IDID(currPackHdl));
542  }
543  else if ((pack!=NULL)&&(currPack!=pack))
544  {
545  currPack=pack;
548  //Print("set pack=%s\n",IDID(currPackHdl));
549  }
550  err=iiPStart(pn,sl);
551  break;
552  case LANG_C:
554  err = (pi->data.o.function)(res, sl);
555  memcpy(&iiRETURNEXPR,res,sizeof(iiRETURNEXPR));
557  break;
558  }
559  if ((traceit&TRACE_SHOW_PROC)
560  || (pi->trace_flag&TRACE_SHOW_PROC))
561  {
562  if (traceit&TRACE_SHOW_LINENO) PrintLn();
563  Print("leaving %-*.*s %s (level %d)\n",myynest*2,myynest*2," ",IDID(pn),myynest);
564  }
565  //const char *n="NULL";
566  //if (currRingHdl!=NULL) n=IDID(currRingHdl);
567  //Print("currRing(%d):%s(%x) after %s\n",myynest,n,currRing,IDID(pn));
568 #ifdef RDEBUG
569  if (traceit&TRACE_SHOW_RINGS) iiShowLevRings();
570 #endif
571  if (err)
572  {
574  //iiRETURNEXPR.Init(); //done by CleanUp
575  }
576  if (iiCurrArgs!=NULL)
577  {
578  if (!err) Warn("too many arguments for %s",IDID(pn));
579  iiCurrArgs->CleanUp();
582  }
583  procstack->pop();
584  if (err)
585  return TRUE;
586  return FALSE;
587 }
#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:83
package pack
Definition: subexpr.h:58
idhdl currPackHdl
Definition: ipid.cc:61
#define IDID(a)
Definition: ipid.h:119
#define FALSE
Definition: auxiliary.h:94
sleftv iiRETURNEXPR
Definition: iplib.cc:473
language_defs language
Definition: subexpr.h:59
proclevel * procstack
Definition: ipid.cc:58
static void iiShowLevRings()
Definition: iplib.cc:477
#define TRUE
Definition: auxiliary.h:98
void Init()
Definition: subexpr.h:107
void * ADDRESS
Definition: auxiliary.h:115
sleftv * leftv
Definition: structs.h:60
void WerrorS(const char *s)
Definition: feFopen.cc:24
int traceit
Definition: febase.cc:47
static void iiCheckNest()
Definition: iplib.cc:492
BOOLEAN iiPStart(idhdl pn, leftv v)
Definition: iplib.cc:371
char * procname
Definition: subexpr.h:57
poly res
Definition: myNF.cc:322
Definition: subexpr.h:22
int myynest
Definition: febase.cc:46
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:10
char * libname
Definition: subexpr.h:56
procinfodata data
Definition: subexpr.h:63
omBin sleftv_bin
Definition: subexpr.cc:50
char is_static
Definition: subexpr.h:61
#define omAlloc0Bin(bin)
Definition: omAllocDecl.h:206
#define IDPROC(a)
Definition: ipid.h:137
#define pi
Definition: libparse.cc:1143
ring * iiLocalRing
Definition: iplib.cc:472
#define NULL
Definition: omList.c:10
package currPack
Definition: ipid.cc:63
leftv iiCurrArgs
Definition: ipshell.cc:78
void CleanUp(ring r=currRing)
Definition: subexpr.cc:332
#define TRACE_SHOW_PROC
Definition: reporter.h:28
idhdl packFindHdl(package r)
Definition: ipid.cc:739
void iiCheckPack(package &p)
Definition: ipshell.cc:1535
#define omFreeBin(addr, bin)
Definition: omAllocDecl.h:259
void push(char *)
Definition: ipid.cc:711
void pop()
Definition: ipid.cc:721
char trace_flag
Definition: subexpr.h:62
void Werror(const char *fmt,...)
Definition: reporter.cc:189
#define Warn
Definition: emacs.cc:80

◆ iiProcArgs()

char* iiProcArgs ( char *  e,
BOOLEAN  withParenth 
)

Definition at line 127 of file iplib.cc.

128 {
129  while ((*e==' ') || (*e=='\t') || (*e=='(')) e++;
130  if (*e<' ')
131  {
132  if (withParenth)
133  {
134  // no argument list, allow list #
135  return omStrDup("parameter list #;");
136  }
137  else
138  {
139  // empty list
140  return omStrDup("");
141  }
142  }
143  BOOLEAN in_args;
144  BOOLEAN args_found;
145  char *s;
146  char *argstr=(char *)omAlloc(127); // see ../omalloc/omTables.inc
147  int argstrlen=127;
148  *argstr='\0';
149  int par=0;
150  do
151  {
152  args_found=FALSE;
153  s=e; // set s to the starting point of the arg
154  // and search for the end
155  // skip leading spaces:
156  loop
157  {
158  if ((*s==' ')||(*s=='\t'))
159  s++;
160  else if ((*s=='\n')&&(*(s+1)==' '))
161  s+=2;
162  else // start of new arg or \0 or )
163  break;
164  }
165  e=s;
166  while ((*e!=',')
167  &&((par!=0) || (*e!=')'))
168  &&(*e!='\0'))
169  {
170  if (*e=='(') par++;
171  else if (*e==')') par--;
172  args_found=args_found || (*e>' ');
173  e++;
174  }
175  in_args=(*e==',');
176  if (args_found)
177  {
178  *e='\0';
179  // check for space:
180  if ((int)strlen(argstr)+12 /* parameter + ;*/ +(int)strlen(s)>= argstrlen)
181  {
182  argstrlen*=2;
183  char *a=(char *)omAlloc( argstrlen);
184  strcpy(a,argstr);
185  omFree((ADDRESS)argstr);
186  argstr=a;
187  }
188  // copy the result to argstr
189  if(strncmp(s,"alias ",6)!=0)
190  {
191  strcat(argstr,"parameter ");
192  }
193  strcat(argstr,s);
194  strcat(argstr,"; ");
195  e++; // e was pointing to ','
196  }
197  } while (in_args);
198  return argstr;
199 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
const poly a
Definition: syzextra.cc:212
loop
Definition: myNF.cc:98
#define FALSE
Definition: auxiliary.h:94
void * ADDRESS
Definition: auxiliary.h:115
#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 113 of file iplib.cc.

114 {
115  char *s=buf+5;
116  while (*s==' ') s++;
117  e=s+1;
118  while ((*e>' ') && (*e!='(')) e++;
119  ct=*e;
120  *e='\0';
121  return s;
122 }
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 371 of file iplib.cc.

372 {
373  procinfov pi=NULL;
374  int old_echo=si_echo;
375  BOOLEAN err=FALSE;
376  char save_flags=0;
377 
378  /* init febase ======================================== */
379  /* we do not enter this case if filename != NULL !! */
380  if (pn!=NULL)
381  {
382  pi = IDPROC(pn);
383  if(pi!=NULL)
384  {
385  save_flags=pi->trace_flag;
386  if( pi->data.s.body==NULL )
387  {
388  iiGetLibProcBuffer(pi);
389  if (pi->data.s.body==NULL) return TRUE;
390  }
391 // omUpdateInfo();
392 // int m=om_Info.UsedBytes;
393 // Print("proc %s, mem=%d\n",IDID(pn),m);
394  }
395  }
396  else return TRUE;
397  /* generate argument list ======================================*/
398  //iiCurrArgs should be NULL here, as the assignment for the parameters
399  // of the prevouis call are already done befor calling another routine
400  if (v!=NULL)
401  {
403  memcpy(iiCurrArgs,v,sizeof(sleftv)); // keeps track of v->next etc.
404  memset(v,0,sizeof(sleftv));
405  }
406  else
407  {
409  }
410  iiCurrProc=pn;
411  /* start interpreter ======================================*/
412  myynest++;
413  if (myynest > SI_MAX_NEST)
414  {
415  WerrorS("nesting too deep");
416  err=TRUE;
417  }
418  else
419  {
420  err=iiAllStart(pi,pi->data.s.body,BT_proc,pi->data.s.body_lineno-(v!=NULL));
421 
422  if (iiLocalRing[myynest-1] != currRing)
423  {
425  {
426  //idhdl hn;
427  const char *n;
428  const char *o;
429  idhdl nh=NULL, oh=NULL;
430  if (iiLocalRing[myynest-1]!=NULL)
432  if (oh!=NULL) o=oh->id;
433  else o="none";
434  if (currRing!=NULL)
435  nh=rFindHdl(currRing,NULL);
436  if (nh!=NULL) n=nh->id;
437  else n="none";
438  Werror("ring change during procedure call %s: %s -> %s (level %d)",pi->procname,o,n,myynest);
440  err=TRUE;
441  }
443  }
444  if ((currRing==NULL)
445  && (currRingHdl!=NULL))
447  else
448  if ((currRing!=NULL) &&
450  ||(IDLEV(currRingHdl)>=myynest-1)))
451  {
454  }
455  //Print("kill locals for %s (level %d)\n",IDID(pn),myynest);
457 #ifndef SING_NDEBUG
458  checkall();
459 #endif
460  //Print("end kill locals for %s (%d)\n",IDID(pn),myynest);
461  }
462  myynest--;
463  si_echo=old_echo;
464  if (pi!=NULL)
465  pi->trace_flag=save_flags;
466 // omUpdateInfo();
467 // int m=om_Info.UsedBytes;
468 // Print("exit %s, mem=%d\n",IDID(pn),m);
469  return err;
470 }
#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:473
#define TRUE
Definition: auxiliary.h:98
sleftv * leftv
Definition: structs.h:60
void WerrorS(const char *s)
Definition: feFopen.cc:24
Definition: idrec.h:34
idhdl iiCurrProc
Definition: ipshell.cc:79
#define SI_MAX_NEST
Definition: iplib.cc:33
char * procname
Definition: subexpr.h:57
int myynest
Definition: febase.cc:46
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:10
BOOLEAN RingDependend()
Definition: subexpr.cc:402
void killlocals(int v)
Definition: ipshell.cc:378
procinfodata data
Definition: subexpr.h:63
idhdl currRingHdl
Definition: ipid.cc:65
omBin sleftv_bin
Definition: subexpr.cc:50
idhdl rFindHdl(ring r, idhdl n)
Definition: ipshell.cc:1594
#define IDLEV(a)
Definition: ipid.h:118
BOOLEAN iiAllStart(procinfov pi, char *p, feBufferTypes t, int l)
Definition: iplib.cc:311
#define IDPROC(a)
Definition: ipid.h:137
#define pi
Definition: libparse.cc:1143
ring * iiLocalRing
Definition: iplib.cc:472
#define NULL
Definition: omList.c:10
#define IDRING(a)
Definition: ipid.h:124
leftv iiCurrArgs
Definition: ipshell.cc:78
void CleanUp(ring r=currRing)
Definition: subexpr.cc:332
const char * id
Definition: idrec.h:39
void rSetHdl(idhdl h)
Definition: ipshell.cc:5038
char * iiGetLibProcBuffer(procinfo *pi, int part)
Definition: iplib.cc:210
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:41

◆ iiRunInit()

static void iiRunInit ( package  p)
static

Definition at line 917 of file iplib.cc.

918 {
919  idhdl h=p->idroot->get("mod_init",0);
920  if (h==NULL) return;
921  if (IDTYP(h)==PROC_CMD)
922  {
923  int save=yylineno;
924  myynest++;
925  // procinfo *pi=(procinfo*)IDDATA(h);
926  //PrintS("mod_init found\n");
927  iiMake_proc(h,p,NULL);
928  myynest--;
929  yylineno=save;
930  }
931 }
int yylineno
Definition: febase.cc:45
return P p
Definition: myNF.cc:203
Definition: idrec.h:34
int myynest
Definition: febase.cc:46
#define IDTYP(a)
Definition: ipid.h:116
BOOLEAN iiMake_proc(idhdl pn, package pack, leftv sl)
Definition: iplib.cc:503
#define NULL
Definition: omList.c:10
static Poly * h
Definition: janet.cc:978

◆ iiShowLevRings()

static void iiShowLevRings ( )
static

Definition at line 477 of file iplib.cc.

478 {
479  int i;
480  for (i=0;i<=myynest;i++)
481  {
482  Print("lev %d:",i);
483  if (iiLocalRing[i]==NULL) PrintS("NULL");
484  else Print("%lx",(long)iiLocalRing[i]);
485  PrintLn();
486  }
487  if (currRing==NULL) PrintS("curr:NULL\n");
488  else Print ("curr:%lx\n",(long)currRing);
489 }
void PrintLn()
Definition: reporter.cc:310
#define Print
Definition: emacs.cc:83
int myynest
Definition: febase.cc:46
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:10
int i
Definition: cfEzgcd.cc:123
void PrintS(const char *s)
Definition: reporter.cc:284
ring * iiLocalRing
Definition: iplib.cc:472
#define NULL
Definition: omList.c:10

◆ iiTryLoadLib()

BOOLEAN iiTryLoadLib ( leftv  v,
const char *  id 
)

Definition at line 782 of file iplib.cc.

783 {
784  BOOLEAN LoadResult = TRUE;
785  char libnamebuf[1024];
786  char *libname = (char *)omAlloc(strlen(id)+5);
787  const char *suffix[] = { "", ".lib", ".so", ".sl", NULL };
788  int i = 0;
789  // FILE *fp;
790  // package pack;
791  // idhdl packhdl;
792  lib_types LT;
793  for(i=0; suffix[i] != NULL; i++)
794  {
795  sprintf(libname, "%s%s", id, suffix[i]);
796  *libname = mytolower(*libname);
797  if((LT = type_of_LIB(libname, libnamebuf)) > LT_NOTFOUND)
798  {
799  char *s=omStrDup(libname);
800  #ifdef HAVE_DYNAMIC_LOADING
801  char libnamebuf[1024];
802  #endif
803 
804  if (LT==LT_SINGULAR)
805  LoadResult = iiLibCmd(s, FALSE, FALSE,TRUE);
806  #ifdef HAVE_DYNAMIC_LOADING
807  else if ((LT==LT_ELF) || (LT==LT_HPUX))
808  LoadResult = load_modules(s,libnamebuf,FALSE);
809  #endif
810  else if (LT==LT_BUILTIN)
811  {
812  LoadResult=load_builtin(s,FALSE, iiGetBuiltinModInit(s));
813  }
814  if(!LoadResult )
815  {
816  v->name = iiConvName(libname);
817  break;
818  }
819  }
820  }
821  omFree(libname);
822  return LoadResult;
823 }
BOOLEAN load_builtin(const char *newlib, BOOLEAN autoexport, SModulFunc_t init)
Definition: iplib.cc:1206
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:24
#define omAlloc(size)
Definition: omAllocDecl.h:210
BOOLEAN iiLibCmd(char *newlib, BOOLEAN autoexport, BOOLEAN tellerror, BOOLEAN force)
Definition: iplib.cc:844
const char * name
Definition: subexpr.h:87
#define omFree(addr)
Definition: omAllocDecl.h:261
int i
Definition: cfEzgcd.cc:123
lib_types
Definition: mod_raw.h:16
char libnamebuf[1024]
Definition: libparse.cc:1096
char mytolower(char c)
Definition: iplib.cc:1327
#define NULL
Definition: omList.c:10
SModulFunc_t iiGetBuiltinModInit(const char *libname)
Definition: iplib.cc:769
char * iiConvName(const char *libname)
Definition: iplib.cc:1340
int BOOLEAN
Definition: auxiliary.h:85
BOOLEAN load_modules(const char *newlib, char *fullname, BOOLEAN autoexport)
Definition: iplib.cc:1108
#define omStrDup(s)
Definition: omAllocDecl.h:263

◆ load_builtin()

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

Definition at line 1206 of file iplib.cc.

1207 {
1208  int iiAddCproc(const char *libname, const char *procname, BOOLEAN pstatic,
1209  BOOLEAN(*func)(leftv res, leftv v));
1210 /*
1211  typedef int (*fktn_t)(int(*iiAddCproc)(const char *libname, const char *procname,
1212  BOOLEAN pstatic,
1213  BOOLEAN(*func)(leftv res, leftv v)));
1214 */
1215  // SModulFunc_t fktn;
1216  idhdl pl;
1217  char *plib = iiConvName(newlib);
1218  // BOOLEAN RET=TRUE;
1219  // int token;
1220 
1221  pl = basePack->idroot->get(plib,0); // search PACKAGE only in Top
1222  if ((pl!=NULL)
1223  &&(IDTYP(pl)==PACKAGE_CMD))
1224  {
1225  if(IDPACKAGE(pl)->language==LANG_C)
1226  {
1227  if (BVERBOSE(V_LOAD_LIB)) Warn( "(builtin) %s already loaded", newlib);
1228  omFree(plib);
1229  return FALSE;
1230  }
1231  }
1232  else
1233  {
1234  pl = enterid( plib,0, PACKAGE_CMD, &IDROOT, TRUE );
1235  IDPACKAGE(pl)->libname=omStrDup(newlib);
1236  }
1237  IDPACKAGE(pl)->language = LANG_C;
1238 
1239  IDPACKAGE(pl)->handle=(void *)NULL;
1240  SModulFunctions sModulFunctions;
1241 
1242  package s=currPack;
1243  currPack=IDPACKAGE(pl);
1244  if( init!= NULL)
1245  {
1246  sModulFunctions.iiArithAddCmd = iiArithAddCmd;
1247  if (autoexport) sModulFunctions.iiAddCproc = iiAddCprocTop;
1248  else sModulFunctions.iiAddCproc = iiAddCproc;
1249  (*init)(&sModulFunctions);
1250  }
1251  if (BVERBOSE(V_LOAD_LIB)) Print( "// ** loaded (builtin) %s \n", newlib);
1252  currPack->loaded=1;
1253  currPack=s;
1254 
1255  return FALSE;
1256 }
int iiAddCprocTop(const char *libname, const char *procname, BOOLEAN pstatic, BOOLEAN(*func)(leftv res, leftv v))
Definition: iplib.cc:1095
const CanonicalForm int s
Definition: facAbsFact.cc:55
Class used for (list of) interpreter objects.
Definition: subexpr.h:82
#define Print
Definition: emacs.cc:83
#define FALSE
Definition: auxiliary.h:94
#define V_LOAD_LIB
Definition: options.h:45
#define IDROOT
Definition: ipid.h:20
#define TRUE
Definition: auxiliary.h:98
Definition: idrec.h:34
poly res
Definition: myNF.cc:322
Definition: subexpr.h:22
#define IDPACKAGE(a)
Definition: ipid.h:136
#define IDTYP(a)
Definition: ipid.h:116
idhdl enterid(const char *s, int lev, int t, idhdl *root, BOOLEAN init, BOOLEAN search)
Definition: ipid.cc:258
#define omFree(addr)
Definition: omAllocDecl.h:261
#define BVERBOSE(a)
Definition: options.h:33
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
#define NULL
Definition: omList.c:10
package basePack
Definition: ipid.cc:64
package currPack
Definition: ipid.cc:63
int(* iiAddCproc)(const char *libname, const char *procname, BOOLEAN pstatic, BOOLEAN(*func)(leftv res, leftv v))
Definition: ipid.h:71
int iiAddCproc(const char *libname, const char *procname, BOOLEAN pstatic, BOOLEAN(*func)(leftv res, leftv v))
Definition: iplib.cc:1023
char * iiConvName(const char *libname)
Definition: iplib.cc:1340
int BOOLEAN
Definition: auxiliary.h:85
int(* iiArithAddCmd)(const char *szName, short nAlias, short nTokval, short nToktype, short nPos)
Definition: ipid.h:73
#define Warn
Definition: emacs.cc:80
#define omStrDup(s)
Definition: omAllocDecl.h:263
int iiArithAddCmd(const char *szName, short nAlias, short nTokval, short nToktype, short nPos)
Definition: iparith.cc:9067

◆ load_modules()

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

Definition at line 1108 of file iplib.cc.

1109 {
1110 #ifdef HAVE_STATIC
1111  WerrorS("mod_init: static version can not load modules");
1112  return TRUE;
1113 #else
1114 /*
1115  typedef int (*fktn_t)(int(*iiAddCproc)(const char *libname, const char *procname,
1116  BOOLEAN pstatic,
1117  BOOLEAN(*func)(leftv res, leftv v)));
1118 */
1119  SModulFunc_t fktn;
1120  idhdl pl;
1121  char *plib = iiConvName(newlib);
1122  BOOLEAN RET=TRUE;
1123  int token;
1124  char FullName[256];
1125 
1126  memset(FullName,0,256);
1127 
1128  if( *fullname != '/' && *fullname != '.' )
1129  sprintf(FullName, "./%s", newlib);
1130  else strncpy(FullName, fullname,255);
1131 
1132 
1133  if(IsCmd(plib, token))
1134  {
1135  Werror("'%s' is resered identifier\n", plib);
1136  goto load_modules_end;
1137  }
1138  pl = basePack->idroot->get(plib,0); /* packages only in top level
1139  (see enterid) */
1140  if ((pl!=NULL)
1141  &&(IDTYP(pl)==PACKAGE_CMD))
1142  {
1143  if(IDPACKAGE(pl)->language==LANG_C)
1144  {
1145  if (BVERBOSE(V_LOAD_LIB)) Warn( "%s already loaded as package", newlib);
1146  omFree(plib);
1147  return FALSE;
1148  }
1149  }
1150  else
1151  {
1152  pl = enterid( plib,0, PACKAGE_CMD, &IDROOT, TRUE );
1153  IDPACKAGE(pl)->libname=omStrDup(newlib);
1154  }
1155  IDPACKAGE(pl)->language = LANG_C;
1156  if (dynl_check_opened(FullName))
1157  {
1158  if (BVERBOSE(V_LOAD_LIB)) Warn( "%s already loaded as C library", fullname);
1159  return FALSE;
1160  }
1161  if((IDPACKAGE(pl)->handle=dynl_open(FullName))==(void *)NULL)
1162  {
1163  Werror("dynl_open failed:%s", dynl_error());
1164  Werror("%s not found", newlib);
1165  killhdl2(pl,&(basePack->idroot),NULL); // remove package
1166  goto load_modules_end;
1167  }
1168  else
1169  {
1170  SModulFunctions sModulFunctions;
1171 
1172  package s=currPack;
1173  currPack=IDPACKAGE(pl);
1174  fktn = (SModulFunc_t)dynl_sym(IDPACKAGE(pl)->handle, "mod_init");
1175  if( fktn!= NULL)
1176  {
1177  sModulFunctions.iiArithAddCmd = iiArithAddCmd;
1178  if (autoexport) sModulFunctions.iiAddCproc = iiAddCprocTop;
1179  else sModulFunctions.iiAddCproc = iiAddCproc;
1180  int ver=(*fktn)(&sModulFunctions);
1181  if (ver==MAX_TOK)
1182  {
1183  if (BVERBOSE(V_LOAD_LIB)) Print( "// ** loaded %s\n", fullname);
1184  }
1185  else
1186  {
1187  Warn("loaded %s for a different version of Singular(expected MAX_TOK: %d, got %d)",fullname,MAX_TOK,ver);
1188  }
1189  currPack->loaded=1;
1190  currPack=s;
1191  RET=FALSE;
1192  }
1193  else
1194  {
1195  Werror("mod_init not found:: %s\nThis is probably not a dynamic module for Singular!\n", dynl_error());
1196  killhdl2(pl,&(basePack->idroot),NULL); // remove package
1197  }
1198  }
1199 
1200  load_modules_end:
1201  return RET;
1202 #endif /*STATIC */
1203 }
int iiAddCprocTop(const char *libname, const char *procname, BOOLEAN pstatic, BOOLEAN(*func)(leftv res, leftv v))
Definition: iplib.cc:1095
const CanonicalForm int s
Definition: facAbsFact.cc:55
#define Print
Definition: emacs.cc:83
#define FALSE
Definition: auxiliary.h:94
#define V_LOAD_LIB
Definition: options.h:45
Definition: tok.h:213
#define IDROOT
Definition: ipid.h:20
#define TRUE
Definition: auxiliary.h:98
void * dynl_sym(void *handle, const char *symbol)
Definition: mod_raw.cc:167
void WerrorS(const char *s)
Definition: feFopen.cc:24
Definition: idrec.h:34
void * dynl_open(char *filename)
Definition: mod_raw.cc:153
int dynl_check_opened(char *filename)
Definition: mod_raw.cc:146
Definition: subexpr.h:22
#define IDPACKAGE(a)
Definition: ipid.h:136
#define IDTYP(a)
Definition: ipid.h:116
void killhdl2(idhdl h, idhdl *ih, ring r)
Definition: ipid.cc:408
idhdl enterid(const char *s, int lev, int t, idhdl *root, BOOLEAN init, BOOLEAN search)
Definition: ipid.cc:258
#define omFree(addr)
Definition: omAllocDecl.h:261
#define BVERBOSE(a)
Definition: options.h:33
#define NULL
Definition: omList.c:10
package basePack
Definition: ipid.cc:64
package currPack
Definition: ipid.cc:63
int(* SModulFunc_t)(SModulFunctions *)
Definition: ipid.h:82
int(* iiAddCproc)(const char *libname, const char *procname, BOOLEAN pstatic, BOOLEAN(*func)(leftv res, leftv v))
Definition: ipid.h:71
int iiAddCproc(const char *libname, const char *procname, BOOLEAN pstatic, BOOLEAN(*func)(leftv res, leftv v))
Definition: iplib.cc:1023
char * iiConvName(const char *libname)
Definition: iplib.cc:1340
int BOOLEAN
Definition: auxiliary.h:85
int(* iiArithAddCmd)(const char *szName, short nAlias, short nTokval, short nToktype, short nPos)
Definition: ipid.h:73
void Werror(const char *fmt,...)
Definition: reporter.cc:189
const char * dynl_error()
Definition: mod_raw.cc:183
int IsCmd(const char *n, int &tok)
Definition: iparith.cc:8729
#define Warn
Definition: emacs.cc:80
#define omStrDup(s)
Definition: omAllocDecl.h:263
int iiArithAddCmd(const char *szName, short nAlias, short nTokval, short nToktype, short nPos)
Definition: iparith.cc:9067

◆ module_help_main()

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

Definition at line 1258 of file iplib.cc.

1259 {
1260  char *plib = iiConvName(newlib);
1261  idhdl pl = basePack->idroot->get(plib,0);
1262  if ((pl==NULL)||(IDTYP(pl)!=PACKAGE_CMD))
1263  Werror(">>%s<< is not a package (trying to add package help)",plib);
1264  else
1265  {
1266  package s=currPack;
1267  currPack=IDPACKAGE(pl);
1269  IDSTRING(h)=omStrDup(help);
1270  currPack=s;
1271  }
1272 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
#define FALSE
Definition: auxiliary.h:94
#define IDROOT
Definition: ipid.h:20
Definition: idrec.h:34
#define IDPACKAGE(a)
Definition: ipid.h:136
#define IDTYP(a)
Definition: ipid.h:116
idhdl enterid(const char *s, int lev, int t, idhdl *root, BOOLEAN init, BOOLEAN search)
Definition: ipid.cc:258
#define IDSTRING(a)
Definition: ipid.h:133
#define help
Definition: libparse.cc:1228
#define NULL
Definition: omList.c:10
package basePack
Definition: ipid.cc:64
package currPack
Definition: ipid.cc:63
char * iiConvName(const char *libname)
Definition: iplib.cc:1340
static Poly * h
Definition: janet.cc:978
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 1273 of file iplib.cc.

1274 {
1275  char *plib = iiConvName(newlib);
1276  idhdl pl = basePack->idroot->get(plib,0);
1277  if ((pl==NULL)||(IDTYP(pl)!=PACKAGE_CMD))
1278  Werror(">>%s<< is not a package(trying to add help for %s)",plib,p);
1279  else
1280  {
1281  package s=currPack;
1282  currPack=IDPACKAGE(pl);
1283  char buff[256];
1284  buff[255]='\0';
1285  strncpy(buff,p,255);
1286  strncat(buff,"_help",255-strlen(p));
1288  IDSTRING(h)=omStrDup(help);
1289  currPack=s;
1290  }
1291 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
#define FALSE
Definition: auxiliary.h:94
return P p
Definition: myNF.cc:203
#define IDROOT
Definition: ipid.h:20
Definition: idrec.h:34
#define IDPACKAGE(a)
Definition: ipid.h:136
#define IDTYP(a)
Definition: ipid.h:116
idhdl enterid(const char *s, int lev, int t, idhdl *root, BOOLEAN init, BOOLEAN search)
Definition: ipid.cc:258
#define IDSTRING(a)
Definition: ipid.h:133
#define help
Definition: libparse.cc:1228
#define NULL
Definition: omList.c:10
package basePack
Definition: ipid.cc:64
package currPack
Definition: ipid.cc:63
char * iiConvName(const char *libname)
Definition: iplib.cc:1340
static Poly * h
Definition: janet.cc:978
void Werror(const char *fmt,...)
Definition: reporter.cc:189
#define omStrDup(s)
Definition: omAllocDecl.h:263

◆ mytolower()

char mytolower ( char  c)

Definition at line 1327 of file iplib.cc.

1328 {
1329  if(c>=65 && c<=(65+26)) c+=32;
1330  return(c);
1331 }

◆ mytoupper()

char mytoupper ( char  c)

Definition at line 1321 of file iplib.cc.

1322 {
1323  if(c>=97 && c<=(97+26)) c-=32;
1324  return(c);
1325 }

◆ 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 472 of file iplib.cc.

◆ iiRETURNEXPR

sleftv iiRETURNEXPR

Definition at line 473 of file iplib.cc.

◆ iiRETURNEXPR_len

int iiRETURNEXPR_len =0

Definition at line 474 of file iplib.cc.

◆ library_stack

libstackv library_stack

Definition at line 74 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.