My Project  UNKNOWN_GIT_VERSION
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 <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 36 of file iplib.cc.

◆ MODULE_SUFFIX_STRING

#define MODULE_SUFFIX_STRING   EXPANDED_STRINGIFY(MODULE_SUFFIX)

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

◆ SI_MAX_NEST

#define SI_MAX_NEST   500

Definition at line 24 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 }

◆ 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 }

◆ iiAddCproc()

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

Definition at line 1005 of file iplib.cc.

1007 {
1008  procinfov pi;
1009  idhdl h;
1010 
1011  #ifndef SING_NDEBUG
1012  int dummy;
1013  if (IsCmd(procname,dummy))
1014  {
1015  Werror(">>%s< is a reserved name",procname);
1016  return 0;
1017  }
1018  #endif
1019 
1020  h=IDROOT->get(procname,0);
1021  if ((h!=NULL)
1022  && (IDTYP(h)==PROC_CMD))
1023  {
1024  pi = IDPROC(h);
1025  if ((pi->language == LANG_SINGULAR)
1026  &&(BVERBOSE(V_REDEFINE)))
1027  Warn("extend `%s`",procname);
1028  }
1029  else
1030  {
1031  h = enterid(procname,0, PROC_CMD, &IDROOT, TRUE);
1032  }
1033  if ( h!= NULL )
1034  {
1035  pi = IDPROC(h);
1036  if((pi->language == LANG_SINGULAR)
1037  ||(pi->language == LANG_NONE))
1038  {
1039  omfree(pi->libname);
1040  pi->libname = omStrDup(libname);
1041  omfree(pi->procname);
1042  pi->procname = omStrDup(procname);
1043  pi->language = LANG_C;
1044  pi->ref = 1;
1045  pi->is_static = pstatic;
1046  pi->data.o.function = func;
1047  }
1048  else if(pi->language == LANG_C)
1049  {
1050  if(pi->data.o.function == func)
1051  {
1052  pi->ref++;
1053  }
1054  else
1055  {
1056  omfree(pi->libname);
1057  pi->libname = omStrDup(libname);
1058  omfree(pi->procname);
1059  pi->procname = omStrDup(procname);
1060  pi->language = LANG_C;
1061  pi->ref = 1;
1062  pi->is_static = pstatic;
1063  pi->data.o.function = func;
1064  }
1065  }
1066  else
1067  Warn("internal error: unknown procedure type %d",pi->language);
1068  if (currPack->language==LANG_SINGULAR) currPack->language=LANG_MIX;
1069  return(1);
1070  }
1071  else
1072  {
1073  WarnS("iiAddCproc: failed.");
1074  }
1075  return(0);
1076 }

◆ iiAddCprocTop()

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

Definition at line 1078 of file iplib.cc.

1080 {
1081  int r=iiAddCproc(libname,procname,pstatic,func);
1082  package s=currPack;
1084  if (r) r=iiAddCproc(libname,procname,pstatic,func);
1085  currPack=s;
1086  return r;
1087 }

◆ iiAllStart()

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

Definition at line 293 of file iplib.cc.

294 {
295  // see below:
296  BITSET save1=si_opt_1;
297  BITSET save2=si_opt_2;
298  newBuffer( omStrDup(p /*pi->data.s.body*/), t /*BT_proc*/,
299  pi, l );
300  BOOLEAN err=yyparse();
301  if (sLastPrinted.rtyp!=0)
302  {
304  }
305  // the access to optionStruct and verboseStruct do not work
306  // on x86_64-Linux for pic-code
307  if ((TEST_V_ALLWARN) &&
308  (t==BT_proc) &&
309  ((save1!=si_opt_1)||(save2!=si_opt_2)) &&
310  (pi->libname!=NULL) && (pi->libname[0]!='\0'))
311  {
312  if ((pi->libname!=NULL) && (pi->libname[0]!='\0'))
313  Warn("option changed in proc %s from %s",pi->procname,pi->libname);
314  else
315  Warn("option changed in proc %s",pi->procname);
316  int i;
317  for (i=0; optionStruct[i].setval!=0; i++)
318  {
319  if ((optionStruct[i].setval & si_opt_1)
320  && (!(optionStruct[i].setval & save1)))
321  {
322  Print(" +%s",optionStruct[i].name);
323  }
324  if (!(optionStruct[i].setval & si_opt_1)
325  && ((optionStruct[i].setval & save1)))
326  {
327  Print(" -%s",optionStruct[i].name);
328  }
329  }
330  for (i=0; verboseStruct[i].setval!=0; i++)
331  {
332  if ((verboseStruct[i].setval & si_opt_2)
333  && (!(verboseStruct[i].setval & save2)))
334  {
335  Print(" +%s",verboseStruct[i].name);
336  }
337  if (!(verboseStruct[i].setval & si_opt_2)
338  && ((verboseStruct[i].setval & save2)))
339  {
340  Print(" -%s",verboseStruct[i].name);
341  }
342  }
343  PrintLn();
344  }
345  return err;
346 }

◆ iiArithAddCmd()

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

Definition at line 9205 of file iparith.cc.

9212 {
9213  //printf("AddCmd(%s, %d, %d, %d, %d)\n", szName, nAlias,
9214  // nTokval, nToktype, nPos);
9215  if(nPos>=0)
9216  {
9217  // no checks: we rely on a correct generated code in iparith.inc
9218  assume((unsigned)nPos < sArithBase.nCmdAllocated);
9219  assume(szName!=NULL);
9220  sArithBase.sCmds[nPos].name = omStrDup(szName);
9221  sArithBase.sCmds[nPos].alias = nAlias;
9222  sArithBase.sCmds[nPos].tokval = nTokval;
9223  sArithBase.sCmds[nPos].toktype = nToktype;
9224  sArithBase.nCmdUsed++;
9225  //if(nTokval>0) sArithBase.nLastIdentifier++;
9226  }
9227  else
9228  {
9229  if(szName==NULL) return -1;
9230  int nIndex = iiArithFindCmd(szName);
9231  if(nIndex>=0)
9232  {
9233  Print("'%s' already exists at %d\n", szName, nIndex);
9234  return -1;
9235  }
9236 
9238  {
9239  /* needs to create new slots */
9240  unsigned long nSize = (sArithBase.nCmdAllocated+1)*sizeof(cmdnames);
9241  sArithBase.sCmds = (cmdnames *)omRealloc(sArithBase.sCmds, nSize);
9242  if(sArithBase.sCmds==NULL) return -1;
9244  }
9245  /* still free slots available */
9246  sArithBase.sCmds[sArithBase.nCmdUsed].name = omStrDup(szName);
9247  sArithBase.sCmds[sArithBase.nCmdUsed].alias = nAlias;
9248  sArithBase.sCmds[sArithBase.nCmdUsed].tokval = nTokval;
9249  sArithBase.sCmds[sArithBase.nCmdUsed].toktype = nToktype;
9250  sArithBase.nCmdUsed++;
9251 
9252  qsort(sArithBase.sCmds, sArithBase.nCmdUsed, sizeof(cmdnames),
9253  (&_gentable_sort_cmds));
9256  {
9257  if(sArithBase.sCmds[sArithBase.nLastIdentifier].tokval>=0) break;
9258  }
9259  //Print("L=%d\n", sArithBase.nLastIdentifier);
9260  }
9261  return 0;
9262 }

◆ iiCallLibProc1()

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

Definition at line 613 of file iplib.cc.

614 {
615  idhdl h=ggetid(n);
616  if ((h==NULL)
617  || (IDTYP(h)!=PROC_CMD))
618  {
619  err=2;
620  return NULL;
621  }
622  // ring handling
623  idhdl save_ringhdl=currRingHdl;
624  ring save_ring=currRing;
626  // argument:
627  sleftv tmp;
628  tmp.Init();
629  tmp.data=arg;
630  tmp.rtyp=arg_type;
631  // call proc
632  err=iiMake_proc(h,currPack,&tmp);
633  // clean up ring
634  iiCallLibProcEnd(save_ringhdl,save_ring);
635  // return
636  if (err==FALSE)
637  {
638  void*r=iiRETURNEXPR.data;
641  return r;
642  }
643  return NULL;
644 }

◆ iiCallLibProcBegin()

static void iiCallLibProcBegin ( )
static

Definition at line 570 of file iplib.cc.

571 {
572  idhdl tmp_ring=NULL;
573  if (currRing!=NULL)
574  {
576  {
577  // clean up things depending on currRingHdl:
579  sLastPrinted.Init();
580  // need to define a ring-hdl for currRingHdl
581  tmp_ring=enterid(" tmpRing",myynest,RING_CMD,&IDROOT,FALSE);
582  IDRING(tmp_ring)=currRing;
583  currRing->ref++;
584  rSetHdl(tmp_ring);
585  }
586  }
587 }

◆ iiCallLibProcEnd()

static void iiCallLibProcEnd ( idhdl  save_ringhdl,
ring  save_ring 
)
static

Definition at line 588 of file iplib.cc.

589 {
590  if ((currRing!=NULL)
591  &&(currRing!=save_ring))
592  {
593  currRing->ref--;
594  idhdl hh=IDROOT;
595  idhdl prev=NULL;
596  while((hh!=currRingHdl) && (hh!=NULL)) { prev=hh; hh=hh->next; }
597  if (hh!=NULL)
598  {
599  if (prev==NULL) IDROOT=hh->next;
600  else prev->next=hh->next;
601  omFree((ADDRESS)IDID(hh));
603  }
604  else
605  {
606  WarnS("internal: lost ring in iiCallLib");
607  }
608  }
609  currRingHdl=save_ringhdl;
610  currRing=save_ring;
611 }

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

648 {
649  idhdl h=ggetid(n);
650  if ((h==NULL)
651  || (IDTYP(h)!=PROC_CMD))
652  {
653  err=2;
654  return NULL;
655  }
656  // ring handling
657  idhdl save_ringhdl=currRingHdl;
658  ring save_ring=currRing;
660  // argument:
661  if (arg_types[0]!=0)
662  {
663  sleftv tmp;
664  leftv tt=&tmp;
665  int i=1;
666  tmp.Init();
667  tmp.data=args[0];
668  tmp.rtyp=arg_types[0];
669  while(arg_types[i]!=0)
670  {
671  tt->next=(leftv)omAlloc0(sizeof(sleftv));
672  tt=tt->next;
673  tt->rtyp=arg_types[i];
674  tt->data=args[i];
675  i++;
676  }
677  // call proc
678  err=iiMake_proc(h,currPack,&tmp);
679  }
680  else
681  // call proc
682  err=iiMake_proc(h,currPack,NULL);
683  // clean up ring
684  iiCallLibProcEnd(save_ringhdl,save_ring);
685  // return
686  if (err==FALSE)
687  {
688  void*r=iiRETURNEXPR.data;
691  return r;
692  }
693  return NULL;
694 }

◆ iiCheckNest()

static void iiCheckNest ( )
static

Definition at line 474 of file iplib.cc.

475 {
476  if (myynest >= iiRETURNEXPR_len-1)
477  {
479  iiRETURNEXPR_len*sizeof(ring),
480  (iiRETURNEXPR_len+16)*sizeof(ring));
481  memset(&(iiLocalRing[iiRETURNEXPR_len]),0,16*sizeof(ring));
482  iiRETURNEXPR_len+=16;
483  }
484 }

◆ iiCleanProcs()

static void iiCleanProcs ( idhdl root)
static

Definition at line 870 of file iplib.cc.

871 {
872  idhdl prev=NULL;
873  loop
874  {
875  if (root==NULL) return;
876  if (IDTYP(root)==PROC_CMD)
877  {
878  procinfo *pi=(procinfo*)IDDATA(root);
879  if ((pi->language == LANG_SINGULAR)
880  && (pi->data.s.body_start == 0L))
881  {
882  // procinfo data incorrect:
883  // - no proc body can start at the beginning of the file
884  killhdl(root);
885  if (prev==NULL)
886  root=IDROOT;
887  else
888  {
889  root=prev;
890  prev=NULL;
891  }
892  continue;
893  }
894  }
895  prev=root;
896  root=IDNEXT(root);
897  }
898 }

◆ 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 }

◆ iiEStart()

BOOLEAN iiEStart ( char *  example,
procinfo pi 
)

Definition at line 699 of file iplib.cc.

700 {
701  BOOLEAN err;
702  int old_echo=si_echo;
703 
704  iiCheckNest();
705  procstack->push(example);
708  {
709  if (traceit&TRACE_SHOW_LINENO) printf("\n");
710  printf("entering example (level %d)\n",myynest);
711  }
712  myynest++;
713 
714  err=iiAllStart(pi,example,BT_example,(pi != NULL ? pi->data.s.example_lineno: 0));
715 
717  myynest--;
718  si_echo=old_echo;
720  {
721  if (traceit&TRACE_SHOW_LINENO) printf("\n");
722  printf("leaving -example- (level %d)\n",myynest);
723  }
724  if (iiLocalRing[myynest] != currRing)
725  {
726  if (iiLocalRing[myynest]!=NULL)
727  {
730  }
731  else
732  {
734  currRing=NULL;
735  }
736  }
737  procstack->pop();
738  return err;
739 }

◆ iiGetBuiltinModInit()

SModulFunc_t iiGetBuiltinModInit ( const char *  libname)

Definition at line 751 of file iplib.cc.

752 {
753 # define SI_GET_BUILTIN_MOD_INIT(name) if (strcmp(libname, #name ".so") == 0){ return SI_MOD_INIT0(name); }
755 # undef SI_GET_BUILTIN_MOD_INIT
756 
757  return NULL;
758 }

◆ iiGetLibProcBuffer()

char* iiGetLibProcBuffer ( procinfo pi,
int  part 
)

Definition at line 192 of file iplib.cc.

193 {
194  char buf[256], *s = NULL, *p;
195  long procbuflen;
196 
197  FILE * fp = feFopen( pi->libname, "rb", NULL, TRUE );
198  if (fp==NULL)
199  {
200  return NULL;
201  }
202 
203  fseek(fp, pi->data.s.proc_start, SEEK_SET);
204  if(part==0)
205  { // load help string
206  int i, offset=0;
207  long head = pi->data.s.def_end - pi->data.s.proc_start;
208  procbuflen = pi->data.s.help_end - pi->data.s.help_start;
209  if (procbuflen<5)
210  {
211  fclose(fp);
212  return NULL; // help part does not exist
213  }
214  //Print("Help=%ld-%ld=%d\n", pi->data.s.body_start,
215  // pi->data.s.proc_start, procbuflen);
216  s = (char *)omAlloc(procbuflen+head+3);
217  myfread(s, head, 1, fp);
218  s[head] = '\n';
219  fseek(fp, pi->data.s.help_start, SEEK_SET);
220  myfread(s+head+1, procbuflen, 1, fp);
221  fclose(fp);
222  s[procbuflen+head+1] = '\n';
223  s[procbuflen+head+2] = '\0';
224  offset=0;
225  for(i=0;i<=procbuflen+head+2; i++)
226  {
227  if(s[i]=='\\' &&
228  (s[i+1]=='"' || s[i+1]=='{' || s[i+1]=='}' || s[i+1]=='\\'))
229  {
230  i++;
231  offset++;
232  }
233  if(offset>0) s[i-offset] = s[i];
234  }
235  return(s);
236  }
237  else if(part==1)
238  { // load proc part - must exist
239  procbuflen = pi->data.s.def_end - pi->data.s.proc_start;
240  char *ss=(char *)omAlloc(procbuflen+2);
241  //fgets(buf, sizeof(buf), fp);
242  myfread( ss, procbuflen, 1, fp);
243  char ct;
244  char *e;
245  s=iiProcName(ss,ct,e);
246  char *argstr=NULL;
247  *e=ct;
248  argstr=iiProcArgs(e,TRUE);
249 
250  assume(pi->data.s.body_end > pi->data.s.body_start);
251 
252  procbuflen = pi->data.s.body_end - pi->data.s.body_start;
253  pi->data.s.body = (char *)omAlloc( strlen(argstr)+procbuflen+15+
254  strlen(pi->libname) );
255  //Print("Body=%ld-%ld=%d\n", pi->data.s.body_end,
256  // pi->data.s.body_start, procbuflen);
257  assume(pi->data.s.body != NULL);
258  fseek(fp, pi->data.s.body_start, SEEK_SET);
259  strcpy(pi->data.s.body,argstr);
260  myfread( pi->data.s.body+strlen(argstr), procbuflen, 1, fp);
261  fclose( fp );
262  procbuflen+=strlen(argstr);
263  omFree(argstr);
264  omFree(ss);
265  pi->data.s.body[procbuflen] = '\0';
266  strcat( pi->data.s.body+procbuflen, "\n;return();\n\n" );
267  strcat( pi->data.s.body+procbuflen+13,pi->libname);
268  s=(char *)strchr(pi->data.s.body,'{');
269  if (s!=NULL) *s=' ';
270  return NULL;
271  }
272  else if(part==2)
273  { // example
274  if ( pi->data.s.example_lineno == 0)
275  return NULL; // example part does not exist
276  // load example
277  fseek(fp, pi->data.s.example_start, SEEK_SET);
278  /*char *dummy=*/ (void) fgets(buf, sizeof(buf), fp); // skip line with "example"
279  procbuflen = pi->data.s.proc_end - pi->data.s.example_start - strlen(buf);
280  //Print("Example=%ld-%ld=%d\n", pi->data.s.proc_end,
281  // pi->data.s.example_start, procbuflen);
282  s = (char *)omAlloc(procbuflen+14);
283  myfread(s, procbuflen, 1, fp);
284  s[procbuflen] = '\0';
285  strcat(s+procbuflen-3, "\n;return();\n\n" );
286  p=(char *)strchr(s,'{');
287  if (p!=NULL) *p=' ';
288  return(s);
289  }
290  return NULL;
291 }

◆ iiGetLibStatus()

BOOLEAN iiGetLibStatus ( char *  lib)

Definition at line 74 of file iplib.cc.

75 {
76  idhdl hl;
77 
78  char *plib = iiConvName(lib);
79  hl = basePack->idroot->get(plib,0);
80  omFree(plib);
81  if((hl==NULL) ||(IDTYP(hl)!=PACKAGE_CMD))
82  {
83  return FALSE;
84  }
85  return (strcmp(lib,IDPACKAGE(hl)->libname)==0);
86 }

◆ iiInitSingularProcinfo()

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

Definition at line 991 of file iplib.cc.

993 {
994  memset(pi,0,sizeof(*pi));
995  pi->libname = omStrDup(libname);
996  pi->procname = omStrDup(procname);
997  pi->language = LANG_SINGULAR;
998  pi->ref = 1;
999  pi->is_static = pstatic;
1000  pi->data.s.proc_start = pos;
1001  return(pi);
1002 }

◆ iiLibCmd()

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

Definition at line 826 of file iplib.cc.

827 {
828  char libnamebuf[1024];
829  // procinfov pi;
830  // idhdl h;
831  idhdl pl;
832  // idhdl hl;
833  // long pos = 0L;
834  char *plib = iiConvName(newlib);
835  FILE * fp = feFopen( newlib, "r", libnamebuf, tellerror );
836  // int lines = 1;
837  BOOLEAN LoadResult = TRUE;
838 
839  if (fp==NULL)
840  {
841  return TRUE;
842  }
843  pl = basePack->idroot->get(plib,0);
844  if (pl==NULL)
845  {
846  pl = enterid( plib,0, PACKAGE_CMD,
847  &(basePack->idroot), TRUE );
848  IDPACKAGE(pl)->language = LANG_SINGULAR;
849  IDPACKAGE(pl)->libname=omStrDup(newlib);
850  }
851  else
852  {
853  if(IDTYP(pl)!=PACKAGE_CMD)
854  {
855  WarnS("not of type package.");
856  fclose(fp);
857  return TRUE;
858  }
859  if (!force) return FALSE;
860  }
861  LoadResult = iiLoadLIB(fp, libnamebuf, newlib, pl, autoexport, tellerror);
862  omFree((ADDRESS)newlib);
863 
864  if(!LoadResult) IDPACKAGE(pl)->loaded = TRUE;
865  omFree((ADDRESS)plib);
866 
867  return LoadResult;
868 }

◆ iiLoadLIB()

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

Definition at line 915 of file iplib.cc.

917 {
918  extern FILE *yylpin;
919  libstackv ls_start = library_stack;
920  lib_style_types lib_style;
921 
922  yylpin = fp;
923  #if YYLPDEBUG > 1
924  print_init();
925  #endif
926  extern int lpverbose;
928  else lpverbose=0;
929  // yylplex sets also text_buffer
930  if (text_buffer!=NULL) *text_buffer='\0';
931  yylplex(newlib, libnamebuf, &lib_style, pl, autoexport);
932  if(yylp_errno)
933  {
934  Werror("Library %s: ERROR occurred: in line %d, %d.", newlib, yylplineno,
935  current_pos(0));
937  {
941  }
942  else
944  WerrorS("Cannot load library,... aborting.");
945  reinit_yylp();
946  fclose( yylpin );
948  return TRUE;
949  }
950  if (BVERBOSE(V_LOAD_LIB))
951  Print( "// ** loaded %s %s\n", libnamebuf, text_buffer);
952  if( (lib_style == OLD_LIBSTYLE) && (BVERBOSE(V_LOAD_LIB)))
953  {
954  Warn( "library %s has old format. This format is still accepted,", newlib);
955  WarnS( "but for functionality you may wish to change to the new");
956  WarnS( "format. Please refer to the manual for further information.");
957  }
958  reinit_yylp();
959  fclose( yylpin );
960  fp = NULL;
961  iiRunInit(IDPACKAGE(pl));
962 
963  {
964  libstackv ls;
965  for(ls = library_stack; (ls != NULL) && (ls != ls_start); )
966  {
967  if(ls->to_be_done)
968  {
969  ls->to_be_done=FALSE;
970  iiLibCmd(ls->get(),autoexport,tellerror,FALSE);
971  ls = ls->pop(newlib);
972  }
973  }
974 #if 0
975  PrintS("--------------------\n");
976  for(ls = library_stack; ls != NULL; ls = ls->next)
977  {
978  Print("%s: LIB-stack:(%d), %s %s\n", newlib, ls->cnt, ls->get(),
979  ls->to_be_done ? "not loaded" : "loaded");
980  }
981  PrintS("--------------------\n");
982 #endif
983  }
984 
985  if(fp != NULL) fclose(fp);
986  return FALSE;
987 }

◆ iiLocateLib()

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

Definition at line 812 of file iplib.cc.

813 {
814  char *plib = iiConvName(lib);
815  idhdl pl = basePack->idroot->get(plib,0);
816  if( (pl!=NULL) && (IDTYP(pl)==PACKAGE_CMD) &&
817  (IDPACKAGE(pl)->language == LANG_SINGULAR))
818  {
819  strncpy(where,IDPACKAGE(pl)->libname,127);
820  return TRUE;
821  }
822  else
823  return FALSE;;
824 }

◆ iiMake_proc()

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

Definition at line 485 of file iplib.cc.

486 {
487  int err;
488  procinfov pi = IDPROC(pn);
489  if(pi->is_static && myynest==0)
490  {
491  Werror("'%s::%s()' is a local procedure and cannot be accessed by an user.",
492  pi->libname, pi->procname);
493  return TRUE;
494  }
495  iiCheckNest();
497  //Print("currRing(%d):%s(%x) in %s\n",myynest,IDID(currRingHdl),currRing,IDID(pn));
498  iiRETURNEXPR.Init();
499  procstack->push(pi->procname);
501  || (pi->trace_flag&TRACE_SHOW_PROC))
502  {
504  Print("entering%-*.*s %s (level %d)\n",myynest*2,myynest*2," ",IDID(pn),myynest);
505  }
506 #ifdef RDEBUG
508 #endif
509  switch (pi->language)
510  {
511  default:
512  case LANG_NONE:
513  WerrorS("undefined proc");
514  err=TRUE;
515  break;
516 
517  case LANG_SINGULAR:
518  if ((pi->pack!=NULL)&&(currPack!=pi->pack))
519  {
520  currPack=pi->pack;
523  //Print("set pack=%s\n",IDID(currPackHdl));
524  }
525  else if ((pack!=NULL)&&(currPack!=pack))
526  {
527  currPack=pack;
530  //Print("set pack=%s\n",IDID(currPackHdl));
531  }
532  err=iiPStart(pn,sl);
533  break;
534  case LANG_C:
536  err = (pi->data.o.function)(res, sl);
537  memcpy(&iiRETURNEXPR,res,sizeof(iiRETURNEXPR));
539  break;
540  }
542  || (pi->trace_flag&TRACE_SHOW_PROC))
543  {
545  Print("leaving %-*.*s %s (level %d)\n",myynest*2,myynest*2," ",IDID(pn),myynest);
546  }
547  //const char *n="NULL";
548  //if (currRingHdl!=NULL) n=IDID(currRingHdl);
549  //Print("currRing(%d):%s(%x) after %s\n",myynest,n,currRing,IDID(pn));
550 #ifdef RDEBUG
552 #endif
553  if (err)
554  {
556  //iiRETURNEXPR.Init(); //done by CleanUp
557  }
558  if (iiCurrArgs!=NULL)
559  {
560  if (!err) Warn("too many arguments for %s",IDID(pn));
561  iiCurrArgs->CleanUp();
564  }
565  procstack->pop();
566  if (err)
567  return TRUE;
568  return FALSE;
569 }

◆ iiProcArgs()

char* iiProcArgs ( char *  e,
BOOLEAN  withParenth 
)

Definition at line 109 of file iplib.cc.

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

◆ iiProcName()

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

Definition at line 95 of file iplib.cc.

96 {
97  char *s=buf+5;
98  while (*s==' ') s++;
99  e=s+1;
100  while ((*e>' ') && (*e!='(')) e++;
101  ct=*e;
102  *e='\0';
103  return s;
104 }

◆ iiPStart()

BOOLEAN iiPStart ( idhdl  pn,
leftv  v 
)

Definition at line 353 of file iplib.cc.

354 {
355  procinfov pi=NULL;
356  int old_echo=si_echo;
357  BOOLEAN err=FALSE;
358  char save_flags=0;
359 
360  /* init febase ======================================== */
361  /* we do not enter this case if filename != NULL !! */
362  if (pn!=NULL)
363  {
364  pi = IDPROC(pn);
365  if(pi!=NULL)
366  {
367  save_flags=pi->trace_flag;
368  if( pi->data.s.body==NULL )
369  {
371  if (pi->data.s.body==NULL) return TRUE;
372  }
373 // omUpdateInfo();
374 // int m=om_Info.UsedBytes;
375 // Print("proc %s, mem=%d\n",IDID(pn),m);
376  }
377  }
378  else return TRUE;
379  /* generate argument list ======================================*/
380  //iiCurrArgs should be NULL here, as the assignment for the parameters
381  // of the prevouis call are already done befor calling another routine
382  if (v!=NULL)
383  {
385  memcpy(iiCurrArgs,v,sizeof(sleftv)); // keeps track of v->next etc.
386  memset(v,0,sizeof(sleftv));
387  }
388  else
389  {
391  }
392  iiCurrProc=pn;
393  /* start interpreter ======================================*/
394  myynest++;
395  if (myynest > SI_MAX_NEST)
396  {
397  WerrorS("nesting too deep");
398  err=TRUE;
399  }
400  else
401  {
402  err=iiAllStart(pi,pi->data.s.body,BT_proc,pi->data.s.body_lineno-(v!=NULL));
403 
404  if (iiLocalRing[myynest-1] != currRing)
405  {
407  {
408  //idhdl hn;
409  const char *n;
410  const char *o;
411  idhdl nh=NULL, oh=NULL;
412  if (iiLocalRing[myynest-1]!=NULL)
414  if (oh!=NULL) o=oh->id;
415  else o="none";
416  if (currRing!=NULL)
417  nh=rFindHdl(currRing,NULL);
418  if (nh!=NULL) n=nh->id;
419  else n="none";
420  Werror("ring change during procedure call %s: %s -> %s (level %d)",pi->procname,o,n,myynest);
422  err=TRUE;
423  }
425  }
426  if ((currRing==NULL)
427  && (currRingHdl!=NULL))
429  else
430  if ((currRing!=NULL) &&
432  ||(IDLEV(currRingHdl)>=myynest-1)))
433  {
436  }
437  //Print("kill locals for %s (level %d)\n",IDID(pn),myynest);
439 #ifndef SING_NDEBUG
440  checkall();
441 #endif
442  //Print("end kill locals for %s (%d)\n",IDID(pn),myynest);
443  }
444  myynest--;
445  si_echo=old_echo;
446  if (pi!=NULL)
447  pi->trace_flag=save_flags;
448 // omUpdateInfo();
449 // int m=om_Info.UsedBytes;
450 // Print("exit %s, mem=%d\n",IDID(pn),m);
451  return err;
452 }

◆ iiRunInit()

static void iiRunInit ( package  p)
static

Definition at line 899 of file iplib.cc.

900 {
901  idhdl h=p->idroot->get("mod_init",0);
902  if (h==NULL) return;
903  if (IDTYP(h)==PROC_CMD)
904  {
905  int save=yylineno;
906  myynest++;
907  // procinfo *pi=(procinfo*)IDDATA(h);
908  //PrintS("mod_init found\n");
909  iiMake_proc(h,p,NULL);
910  myynest--;
911  yylineno=save;
912  }
913 }

◆ iiShowLevRings()

static void iiShowLevRings ( )
static

Definition at line 459 of file iplib.cc.

460 {
461  int i;
462  for (i=0;i<=myynest;i++)
463  {
464  Print("lev %d:",i);
465  if (iiLocalRing[i]==NULL) PrintS("NULL");
466  else Print("%lx",(long)iiLocalRing[i]);
467  PrintLn();
468  }
469  if (currRing==NULL) PrintS("curr:NULL\n");
470  else Print ("curr:%lx\n",(long)currRing);
471 }

◆ iiTryLoadLib()

BOOLEAN iiTryLoadLib ( leftv  v,
const char *  id 
)

Definition at line 764 of file iplib.cc.

765 {
766  BOOLEAN LoadResult = TRUE;
767  char libnamebuf[1024];
768  char *libname = (char *)omAlloc(strlen(id)+5);
769  const char *suffix[] = { "", ".lib", ".so", ".sl", NULL };
770  int i = 0;
771  // FILE *fp;
772  // package pack;
773  // idhdl packhdl;
774  lib_types LT;
775  for(i=0; suffix[i] != NULL; i++)
776  {
777  sprintf(libname, "%s%s", id, suffix[i]);
778  *libname = mytolower(*libname);
779  if((LT = type_of_LIB(libname, libnamebuf)) > LT_NOTFOUND)
780  {
781  char *s=omStrDup(libname);
782  #ifdef HAVE_DYNAMIC_LOADING
783  char libnamebuf[1024];
784  #endif
785 
786  if (LT==LT_SINGULAR)
787  LoadResult = iiLibCmd(s, FALSE, FALSE,TRUE);
788  #ifdef HAVE_DYNAMIC_LOADING
789  else if ((LT==LT_ELF) || (LT==LT_HPUX))
790  LoadResult = load_modules(s,libnamebuf,FALSE);
791  #endif
792  else if (LT==LT_BUILTIN)
793  {
794  LoadResult=load_builtin(s,FALSE, iiGetBuiltinModInit(s));
795  }
796  if(!LoadResult )
797  {
798  v->name = iiConvName(libname);
799  break;
800  }
801  }
802  }
803  omFree(libname);
804  return LoadResult;
805 }

◆ 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 }

◆ load_modules()

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

Definition at line 1091 of file iplib.cc.

1092 {
1093 #ifdef HAVE_STATIC
1094  WerrorS("mod_init: static version can not load modules");
1095  return TRUE;
1096 #else
1097 /*
1098  typedef int (*fktn_t)(int(*iiAddCproc)(const char *libname, const char *procname,
1099  BOOLEAN pstatic,
1100  BOOLEAN(*func)(leftv res, leftv v)));
1101 */
1102  SModulFunc_t fktn;
1103  idhdl pl;
1104  char *plib = iiConvName(newlib);
1105  BOOLEAN RET=TRUE;
1106  int token;
1107  char FullName[256];
1108 
1109  memset(FullName,0,256);
1110 
1111  if( *fullname != '/' && *fullname != '.' )
1112  sprintf(FullName, "./%s", newlib);
1113  else strncpy(FullName, fullname,255);
1114 
1115 
1116  if(IsCmd(plib, token))
1117  {
1118  Werror("'%s' is resered identifier\n", plib);
1119  goto load_modules_end;
1120  }
1121  pl = basePack->idroot->get(plib,0); /* packages only in top level
1122  (see enterid) */
1123  if ((pl!=NULL)
1124  &&(IDTYP(pl)==PACKAGE_CMD))
1125  {
1126  if(IDPACKAGE(pl)->language==LANG_C)
1127  {
1128  if (BVERBOSE(V_LOAD_LIB)) Warn( "%s already loaded as package", newlib);
1129  omFree(plib);
1130  return FALSE;
1131  }
1132  else if(IDPACKAGE(pl)->language==LANG_MIX)
1133  {
1134  if (BVERBOSE(V_LOAD_LIB)) Warn( "%s contain binary parts, cannot load", newlib);
1135  omFree(plib);
1136  return FALSE;
1137  }
1138  }
1139  else
1140  {
1141  pl = enterid( plib,0, PACKAGE_CMD, &IDROOT, TRUE );
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 }

◆ 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 }

◆ 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 }

◆ 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 }

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

◆ iiRETURNEXPR

sleftv iiRETURNEXPR

Definition at line 455 of file iplib.cc.

◆ iiRETURNEXPR_len

int iiRETURNEXPR_len =0

Definition at line 456 of file iplib.cc.

◆ library_stack

libstackv library_stack

Definition at line 65 of file iplib.cc.

◆ yylp_errlist

char* yylp_errlist[]
extern

Definition at line 1112 of file libparse.cc.

◆ yylp_errno

int yylp_errno
extern

Definition at line 1128 of file libparse.cc.

◆ yylplineno

int yylplineno
extern

Definition at line 1102 of file libparse.cc.

FALSE
#define FALSE
Definition: auxiliary.h:94
si_echo
int si_echo
Definition: febase.cc:35
iiArithFindCmd
int iiArithFindCmd(const char *szName)
Definition: iparith.cc:9110
iiCheckPack
void iiCheckPack(package &p)
Definition: ipshell.cc:1541
SEEK_SET
#define SEEK_SET
Definition: mod2.h:116
libstack::cnt
int cnt
Definition: subexpr.h:166
libstack::to_be_done
BOOLEAN to_be_done
Definition: subexpr.h:165
iiProcName
char * iiProcName(char *buf, char &ct, char *&e)
Definition: iplib.cc:95
mytolower
char mytolower(char c)
Definition: iplib.cc:1318
SModulFunctions::iiArithAddCmd
int(* iiArithAddCmd)(const char *szName, short nAlias, short nTokval, short nToktype, short nPos)
Definition: ipid.h:71
feFopen
FILE * feFopen(const char *path, const char *mode, char *where, short useWerror, short path_only)
Definition: feFopen.cc:47
omFree
#define omFree(addr)
Definition: omAllocDecl.h:261
iiCallLibProcBegin
static void iiCallLibProcBegin()
Definition: iplib.cc:570
MODULE_SUFFIX_STRING
#define MODULE_SUFFIX_STRING
Definition: iplib.cc:39
errorreported
short errorreported
Definition: feFopen.cc:23
LT_SINGULAR
@ LT_SINGULAR
Definition: mod_raw.h:16
SI_FOREACH_BUILTIN
SI_FOREACH_BUILTIN(SI_GET_BUILTIN_MOD_INIT0) }
result
return result
Definition: facAbsBiFact.cc:76
LANG_SINGULAR
@ LANG_SINGULAR
Definition: subexpr.h:22
iiMake_proc
BOOLEAN iiMake_proc(idhdl pn, package pack, leftv sl)
Definition: iplib.cc:485
OLD_LIBSTYLE
@ OLD_LIBSTYLE
Definition: libparse.h:9
ADDRESS
void * ADDRESS
Definition: auxiliary.h:133
proclevel::push
void push(char *)
Definition: ipid.cc:724
enterid
idhdl enterid(const char *s, int lev, int t, idhdl *root, BOOLEAN init, BOOLEAN search)
Definition: ipid.cc:267
libstack
Definition: subexpr.h:161
STRING_CMD
@ STRING_CMD
Definition: tok.h:183
BITSET
#define BITSET
Definition: structs.h:18
TRACE_SHOW_PROC
#define TRACE_SHOW_PROC
Definition: reporter.h:28
BT_proc
@ BT_proc
Definition: fevoices.h:20
MAX_TOK
@ MAX_TOK
Definition: tok.h:216
IDDATA
#define IDDATA(a)
Definition: ipid.h:121
yylplex
int yylplex(const char *libname, const char *libfile, lib_style_types *lib_style, idhdl pl, BOOLEAN autoexport=FALSE, lp_modes=LOAD_LIB)
libstack::get
char * get()
Definition: subexpr.h:169
procinfo
Definition: subexpr.h:54
yylineno
int yylineno
Definition: febase.cc:40
iiAllStart
BOOLEAN iiAllStart(procinfov pi, char *p, feBufferTypes t, int l)
Definition: iplib.cc:293
omStrDup
#define omStrDup(s)
Definition: omAllocDecl.h:263
yytext
#define yytext
Definition: libparse.cc:16
V_LOAD_LIB
#define V_LOAD_LIB
Definition: options.h:47
iiLocalRing
ring * iiLocalRing
Definition: iplib.cc:454
omAllocBin
#define omAllocBin(bin)
Definition: omAllocDecl.h:205
omAlloc0Bin
#define omAlloc0Bin(bin)
Definition: omAllocDecl.h:206
currPack
package currPack
Definition: ipid.cc:59
idrec_bin
omBin idrec_bin
Definition: ipid.cc:50
sleftv::RingDependend
BOOLEAN RingDependend()
Definition: subexpr.cc:424
loop
#define loop
Definition: structs.h:78
verboseStruct
const struct soptionStruct verboseStruct[]
Definition: misc_ip.cc:556
sleftv
Class used for (list of) interpreter objects.
Definition: subexpr.h:83
RING_CMD
@ RING_CMD
Definition: grammar.cc:281
procstack
proclevel * procstack
Definition: ipid.cc:54
BT_example
@ BT_example
Definition: fevoices.h:21
dynl_error
const char * dynl_error()
Definition: mod_raw.cc:183
currRingHdl
idhdl currRingHdl
Definition: ipid.cc:61
proclevel::pop
void pop()
Definition: ipid.cc:734
iiGetBuiltinModInit
SModulFunc_t iiGetBuiltinModInit(const char *libname)
Definition: iplib.cc:751
YYLP_BAD_CHAR
#define YYLP_BAD_CHAR
Definition: libparse.h:93
leftv
sleftv * leftv
Definition: structs.h:60
iiCleanProcs
static void iiCleanProcs(idhdl &root)
Definition: iplib.cc:870
current_pos
int current_pos(int i=0)
Definition: libparse.cc:3344
IDLEV
#define IDLEV(a)
Definition: ipid.h:116
omRealloc
#define omRealloc(addr, size)
Definition: omAllocDecl.h:225
iiAddCproc
int iiAddCproc(const char *libname, const char *procname, BOOLEAN pstatic, BOOLEAN(*func)(leftv res, leftv v))
Definition: iplib.cc:1005
pi
#define pi
Definition: libparse.cc:1143
packFindHdl
idhdl packFindHdl(package r)
Definition: ipid.cc:752
V_DEBUG_LIB
#define V_DEBUG_LIB
Definition: options.h:48
currRing
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
TRUE
#define TRUE
Definition: auxiliary.h:98
i
int i
Definition: cfEzgcd.cc:125
res
CanonicalForm res
Definition: facAbsFact.cc:64
fp
CanonicalForm fp
Definition: cfModGcd.cc:4043
iiLoadLIB
BOOLEAN iiLoadLIB(FILE *fp, const char *libnamebuf, const char *newlib, idhdl pl, BOOLEAN autoexport, BOOLEAN tellerror)
Definition: iplib.cc:915
buf
int status int void * buf
Definition: si_signals.h:59
yylp_buffer_start
char * yylp_buffer_start
Definition: libparse.cc:1100
DIR_SEPP
#define DIR_SEPP
Definition: feResource.h:7
PrintS
void PrintS(const char *s)
Definition: reporter.cc:284
BOOLEAN
int BOOLEAN
Definition: auxiliary.h:85
killlocals
void killlocals(int v)
Definition: ipshell.cc:383
killhdl2
void killhdl2(idhdl h, idhdl *ih, ring r)
Definition: ipid.cc:417
iiProcArgs
char * iiProcArgs(char *e, BOOLEAN withParenth)
Definition: iplib.cc:109
PROC_CMD
@ PROC_CMD
Definition: grammar.cc:280
iiRETURNEXPR_len
int iiRETURNEXPR_len
Definition: iplib.cc:456
iiCurrProc
idhdl iiCurrProc
Definition: ipshell.cc:79
TRACE_SHOW_LINENO
#define TRACE_SHOW_LINENO
Definition: reporter.h:30
iiGetLibProcBuffer
char * iiGetLibProcBuffer(procinfo *pi, int part)
Definition: iplib.cc:192
iiConvName
char * iiConvName(const char *libname)
Definition: iplib.cc:1331
IDROOT
#define IDROOT
Definition: ipid.h:18
load_modules
BOOLEAN load_modules(const char *newlib, char *fullname, BOOLEAN autoexport)
Definition: iplib.cc:1091
yy_init
static int yy_init
Definition: libparse.cc:238
sleftv::Init
void Init()
Definition: subexpr.h:107
load_builtin
BOOLEAN load_builtin(const char *newlib, BOOLEAN autoexport, SModulFunc_t init)
Definition: iplib.cc:1197
h
static Poly * h
Definition: janet.cc:972
library_stack
libstackv library_stack
Definition: iplib.cc:65
SModulFunc_t
int(* SModulFunc_t)(SModulFunctions *)
Definition: ipid.h:80
TRACE_SHOW_RINGS
#define TRACE_SHOW_RINGS
Definition: reporter.h:35
IDPROC
#define IDPROC(a)
Definition: ipid.h:135
sleftv::data
void * data
Definition: subexpr.h:88
SArithBase::nLastIdentifier
unsigned nLastIdentifier
valid indentifieres are slot 1..nLastIdentifier
Definition: iparith.cc:189
soptionStruct::setval
unsigned setval
Definition: ipid.h:148
omAlloc
#define omAlloc(size)
Definition: omAllocDecl.h:210
yylplineno
int yylplineno
Definition: libparse.cc:1102
LANG_C
@ LANG_C
Definition: subexpr.h:22
lib_types
lib_types
Definition: mod_raw.h:16
iiArithAddCmd
int iiArithAddCmd(const char *szName, short nAlias, short nTokval, short nToktype, short nPos)
Definition: iparith.cc:9205
mytoupper
char mytoupper(char c)
Definition: iplib.cc:1312
killhdl
void killhdl(idhdl h, package proot)
Definition: ipid.cc:386
myynest
int myynest
Definition: febase.cc:41
IDTYP
#define IDTYP(a)
Definition: ipid.h:114
iiAddCprocTop
int iiAddCprocTop(const char *libname, const char *procname, BOOLEAN pstatic, BOOLEAN(*func)(leftv res, leftv v))
Definition: iplib.cc:1078
type_of_LIB
lib_types type_of_LIB(const char *newlib, char *libnamebuf)
Definition: mod_lib.cc:22
LANG_NONE
@ LANG_NONE
Definition: subexpr.h:22
sleftv::CleanUp
void CleanUp(ring r=currRing)
Definition: subexpr.cc:354
LT_ELF
@ LT_ELF
Definition: mod_raw.h:16
libstack::pop
libstackv pop(const char *p)
Definition: iplib.cc:1422
help
#define help
Definition: libparse.cc:1228
IDRING
#define IDRING(a)
Definition: ipid.h:122
SI_GET_BUILTIN_MOD_INIT
#define SI_GET_BUILTIN_MOD_INIT(name)
libnamebuf
char libnamebuf[1024]
Definition: libparse.cc:1096
SArithBase::sCmds
cmdnames * sCmds
array of existing commands
Definition: iparith.cc:182
idrec::next
idhdl next
Definition: idrec.h:38
iiCallLibProcEnd
static void iiCallLibProcEnd(idhdl save_ringhdl, ring save_ring)
Definition: iplib.cc:588
dynl_open
void * dynl_open(char *filename)
Definition: mod_raw.cc:153
rFindHdl
idhdl rFindHdl(ring r, idhdl n)
Definition: ipshell.cc:1612
idrec
Definition: idrec.h:35
iiShowLevRings
static void iiShowLevRings()
Definition: iplib.cc:459
IsCmd
int IsCmd(const char *n, int &tok)
Definition: iparith.cc:8860
text_buffer
char * text_buffer
Definition: libparse.cc:1097
DIR_SEP
#define DIR_SEP
Definition: feResource.h:6
IDPACKAGE
#define IDPACKAGE(a)
Definition: ipid.h:134
print_init
void print_init()
Definition: libparse.cc:3480
iiRunInit
static void iiRunInit(package p)
Definition: iplib.cc:899
LANG_MIX
@ LANG_MIX
Definition: subexpr.h:22
BVERBOSE
#define BVERBOSE(a)
Definition: options.h:35
Print
#define Print
Definition: emacs.cc:80
iiRETURNEXPR
sleftv iiRETURNEXPR
Definition: iplib.cc:455
lib_style_types
lib_style_types
Definition: libparse.h:9
Werror
void Werror(const char *fmt,...)
Definition: reporter.cc:189
omreallocSize
#define omreallocSize(addr, o_size, size)
Definition: omAllocDecl.h:231
PACKAGE_CMD
@ PACKAGE_CMD
Definition: tok.h:149
LT_BUILTIN
@ LT_BUILTIN
Definition: mod_raw.h:16
sArithBase
static SArithBase sArithBase
Base entry for arithmetic.
Definition: iparith.cc:197
name
char name(const Variable &v)
Definition: factory.h:180
yyparse
int yyparse(void)
Definition: grammar.cc:2111
dynl_sym
void * dynl_sym(void *handle, const char *symbol)
Definition: mod_raw.cc:167
WerrorS
void WerrorS(const char *s)
Definition: feFopen.cc:24
SArithBase::nCmdAllocated
unsigned nCmdAllocated
number of commands-slots allocated
Definition: iparith.cc:188
WarnS
#define WarnS
Definition: emacs.cc:78
SModulFunctions
Definition: ipid.h:68
Variable::name
char name() const
Definition: variable.cc:122
sleftv::rtyp
int rtyp
Definition: subexpr.h:91
basePack
package basePack
Definition: ipid.cc:60
assume
#define assume(x)
Definition: mod2.h:390
sLastPrinted
sleftv sLastPrinted
Definition: subexpr.cc:52
NULL
#define NULL
Definition: omList.c:10
MAXPATHLEN
#define MAXPATHLEN
Definition: omRet2Info.c:22
currPackHdl
idhdl currPackHdl
Definition: ipid.cc:57
l
int l
Definition: cfEzgcd.cc:93
IDSTRING
#define IDSTRING(a)
Definition: ipid.h:131
feGetResource
char * feGetResource(const char id, int warn)
Definition: feResource.cc:155
IDNEXT
#define IDNEXT(a)
Definition: ipid.h:113
SI_MAX_NEST
#define SI_MAX_NEST
Definition: iplib.cc:24
iiPStart
BOOLEAN iiPStart(idhdl pn, leftv v)
Definition: iplib.cc:353
Warn
#define Warn
Definition: emacs.cc:77
lpverbose
int lpverbose
Definition: libparse.cc:1104
traceit
int traceit
Definition: febase.cc:42
v
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
sleftv_bin
omBin sleftv_bin
Definition: subexpr.cc:47
SArithBase::nCmdUsed
unsigned nCmdUsed
number of commands used
Definition: iparith.cc:187
p
int p
Definition: cfModGcd.cc:4019
iiCurrArgs
leftv iiCurrArgs
Definition: ipshell.cc:78
reinit_yylp
void reinit_yylp()
Definition: libparse.cc:3374
ggetid
idhdl ggetid(const char *n)
Definition: ipid.cc:523
s
const CanonicalForm int s
Definition: facAbsFact.cc:55
optionStruct
const struct soptionStruct optionStruct[]
Definition: misc_ip.cc:526
offset
int offset
Definition: libparse.cc:1091
SModulFunctions::iiAddCproc
int(* iiAddCproc)(const char *libname, const char *procname, BOOLEAN pstatic, BOOLEAN(*func)(leftv res, leftv v))
Definition: ipid.h:69
head
CanonicalForm head(const CanonicalForm &f)
Definition: canonicalform.h:353
IDID
#define IDID(a)
Definition: ipid.h:117
_gentable_sort_cmds
static int _gentable_sort_cmds(const void *a, const void *b)
compares to entry of cmdsname-list
Definition: iparith.cc:9038
LT_HPUX
@ LT_HPUX
Definition: mod_raw.h:16
idrec::id
const char * id
Definition: idrec.h:39
V_REDEFINE
#define V_REDEFINE
Definition: options.h:45
PrintLn
void PrintLn()
Definition: reporter.cc:310
dynl_check_opened
int dynl_check_opened(char *filename)
Definition: mod_raw.cc:146
iiCheckNest
static void iiCheckNest()
Definition: iplib.cc:474
iiLibCmd
BOOLEAN iiLibCmd(char *newlib, BOOLEAN autoexport, BOOLEAN tellerror, BOOLEAN force)
Definition: iplib.cc:826
omFreeBin
#define omFreeBin(addr, bin)
Definition: omAllocDecl.h:259
newBuffer
void newBuffer(char *s, feBufferTypes t, procinfo *pi, int lineno)
Definition: fevoices.cc:157
TEST_V_ALLWARN
#define TEST_V_ALLWARN
Definition: options.h:140
myfread
size_t myfread(void *ptr, size_t size, size_t nmemb, FILE *stream)
Definition: feFopen.cc:195
libstack::next
libstackv next
Definition: subexpr.h:163
yylp_errlist
char * yylp_errlist[]
Definition: libparse.cc:1112
omAlloc0
#define omAlloc0(size)
Definition: omAllocDecl.h:211
LT_NOTFOUND
@ LT_NOTFOUND
Definition: mod_raw.h:16
rSetHdl
void rSetHdl(idhdl h)
Definition: ipshell.cc:5081
sleftv::next
leftv next
Definition: subexpr.h:86
nSize
#define nSize(n)
Definition: numbers.h:40
si_opt_2
unsigned si_opt_2
Definition: options.c:6
omfree
#define omfree(addr)
Definition: omAllocDecl.h:237
yylp_errno
int yylp_errno
Definition: libparse.cc:1128
si_opt_1
unsigned si_opt_1
Definition: options.c:5