Macros | Functions | Variables
ssiLink.cc File Reference
#include <kernel/mod2.h>
#include <omalloc/omalloc.h>
#include <misc/intvec.h>
#include <misc/options.h>
#include <reporter/si_signals.h>
#include <reporter/s_buff.h>
#include <coeffs/bigintmat.h>
#include <coeffs/longrat.h>
#include <polys/monomials/ring.h>
#include <polys/monomials/p_polys.h>
#include <polys/ext_fields/transext.h>
#include <polys/simpleideals.h>
#include <polys/matpol.h>
#include <kernel/oswrapper/timer.h>
#include <kernel/oswrapper/feread.h>
#include <kernel/oswrapper/rlimit.h>
#include <Singular/tok.h>
#include <Singular/ipid.h>
#include <Singular/ipshell.h>
#include <Singular/subexpr.h>
#include <Singular/links/silink.h>
#include <Singular/cntrlc.h>
#include <Singular/lists.h>
#include <Singular/blackbox.h>
#include <Singular/links/ssiLink.h>
#include <Singular/links/simpleipc.h>
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
#include <signal.h>
#include <sys/select.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <ctype.h>
#include <netdb.h>
#include <sys/wait.h>
#include <time.h>

Go to the source code of this file.

Macros

#define TRANSEXT_PRIVATES   1 /* allow access to transext internals */
 
#define SSI_VERSION   10
 

Functions

void ssiWritePoly_R (const ssiInfo *d, int typ, poly p, const ring r)
 
void ssiWriteIdeal_R (const ssiInfo *d, int typ, const ideal I, const ring r)
 
poly ssiReadPoly_R (const ssiInfo *D, const ring r)
 
ideal ssiReadIdeal_R (const ssiInfo *d, const ring r)
 
void ssiSetCurrRing (const ring r)
 
void ssiWriteInt (const ssiInfo *d, const int i)
 
void ssiWriteString (const ssiInfo *d, const char *s)
 
void ssiWriteBigInt (const ssiInfo *d, const number n)
 
void ssiWriteNumber_CF (const ssiInfo *d, const number n, const coeffs cf)
 
void ssiWriteNumber (const ssiInfo *d, const number n)
 
void ssiWriteRing_R (ssiInfo *d, const ring r)
 
void ssiWriteRing (ssiInfo *d, const ring r)
 
void ssiWritePoly (const ssiInfo *d, int typ, poly p)
 
void ssiWriteIdeal (const ssiInfo *d, int typ, const ideal I)
 
void ssiWriteCommand (si_link l, command D)
 
void ssiWriteProc (const ssiInfo *d, procinfov p)
 
void ssiWriteList (si_link l, lists dd)
 
void ssiWriteIntvec (const ssiInfo *d, intvec *v)
 
void ssiWriteIntmat (const ssiInfo *d, intvec *v)
 
void ssiWriteBigintmat (const ssiInfo *d, bigintmat *v)
 
char * ssiReadString (const ssiInfo *d)
 
int ssiReadInt (s_buff fich)
 
number ssiReadNumber_CF (const ssiInfo *d, const coeffs cf)
 
number ssiReadBigInt (const ssiInfo *d)
 
number ssiReadNumber (const ssiInfo *d)
 
ring ssiReadRing (const ssiInfo *d)
 
poly ssiReadPoly (const ssiInfo *D)
 
ideal ssiReadIdeal (const ssiInfo *d)
 
matrix ssiReadMatrix (const ssiInfo *d)
 
command ssiReadCommand (si_link l)
 
procinfov ssiReadProc (const ssiInfo *d)
 
lists ssiReadList (si_link l)
 
intvecssiReadIntvec (const ssiInfo *d)
 
intvecssiReadIntmat (const ssiInfo *d)
 
bigintmatssiReadBigintmat (const ssiInfo *d)
 
void ssiReadBlackbox (leftv res, si_link l)
 
void ssiReadAttrib (leftv res, si_link l)
 
BOOLEAN ssiOpen (si_link l, short flag, leftv u)
 
BOOLEAN ssiPrepClose (si_link l)
 
BOOLEAN ssiClose (si_link l)
 
leftv ssiRead1 (si_link l)
 
BOOLEAN ssiSetRing (si_link l, ring r, BOOLEAN send)
 
BOOLEAN ssiWrite (si_link l, leftv data)
 
BOOLEAN ssiGetDump (si_link l)
 
BOOLEAN ssiDump (si_link l)
 
si_link_extension slInitSsiExtension (si_link_extension s)
 
const char * slStatusSsi (si_link l, const char *request)
 
int slStatusSsiL (lists L, int timeout)
 
int ssiBatch (const char *host, const char *port)
 
int ssiReservePort (int clients)
 
si_link ssiCommandLink ()
 
void sig_chld_hdl (int)
 additional default signal handler More...
 
static BOOLEAN DumpSsiIdhdl (si_link l, idhdl h)
 
static BOOLEAN ssiDumpIter (si_link l, idhdl h)
 

Variables

link_list ssiToBeClosed =NULL
 
volatile BOOLEAN ssiToBeClosed_inactive =TRUE
 
static int ssiReserved_P =0
 
static int ssiReserved_sockfd
 
static struct sockaddr_in ssiResverd_serv_addr
 
static int ssiReserved_Clients
 
si_link_extension si_link_root
 

Macro Definition Documentation

§ SSI_VERSION

#define SSI_VERSION   10

Definition at line 62 of file ssiLink.cc.

§ TRANSEXT_PRIVATES

#define TRANSEXT_PRIVATES   1 /* allow access to transext internals */

Definition at line 8 of file ssiLink.cc.

Function Documentation

§ DumpSsiIdhdl()

static BOOLEAN DumpSsiIdhdl ( si_link  l,
idhdl  h 
)
static

Definition at line 1964 of file ssiLink.cc.

1965 {
1966  int type_id = IDTYP(h);
1967 
1968  // C-proc not to be dumped, also LIB-proc not
1969  if (type_id == PROC_CMD)
1970  {
1971  if (IDPROC(h)->language == LANG_C) return FALSE;
1972  if (IDPROC(h)->libname != NULL) return FALSE;
1973  }
1974  // do not dump links
1975  if (type_id == LINK_CMD) return FALSE;
1976 
1977  // do not dump ssi internal rings: ssiRing*
1978  if ((type_id == RING_CMD) && (strncmp(IDID(h),"ssiRing",7)==0))
1979  return FALSE;
1980 
1981  command D=(command)omAlloc0(sizeof(*D));
1982  sleftv tmp;
1983  memset(&tmp,0,sizeof(tmp));
1984  tmp.rtyp=COMMAND;
1985  tmp.data=D;
1986 
1987  if (type_id == PACKAGE_CMD)
1988  {
1989  // do not dump Top, Standard
1990  if ((strcmp(IDID(h), "Top") == 0)
1991  || (strcmp(IDID(h), "Standard") == 0))
1992  {
1993  omFreeSize(D,sizeof(*D));
1994  return FALSE;
1995  }
1996  package p=(package)IDDATA(h);
1997  // dump Singular-packages as LIB("...");
1998  if (p->language==LANG_SINGULAR)
1999  {
2000  D->op=LOAD_CMD;
2001  D->argc=2;
2002  D->arg1.rtyp=STRING_CMD;
2003  D->arg1.data=p->libname;
2004  D->arg2.rtyp=STRING_CMD;
2005  D->arg2.data=(char*)"with";
2006  ssiWrite(l,&tmp);
2007  omFreeSize(D,sizeof(*D));
2008  return FALSE;
2009  }
2010  // dump Singular-packages as load("...");
2011  else if (p->language==LANG_C)
2012  {
2013  D->op=LOAD_CMD;
2014  D->argc=1;
2015  D->arg1.rtyp=STRING_CMD;
2016  D->arg1.data=p->libname;
2017  ssiWrite(l,&tmp);
2018  omFreeSize(D,sizeof(*D));
2019  return FALSE;
2020  }
2021  }
2022 
2023  // put type and name
2024  //Print("generic dump:%s,%s\n",IDID(h),Tok2Cmdname(IDTYP(h)));
2025  D->op='=';
2026  D->argc=2;
2027  D->arg1.rtyp=DEF_CMD;
2028  D->arg1.name=IDID(h);
2029  D->arg2.rtyp=IDTYP(h);
2030  D->arg2.data=IDDATA(h);
2031  ssiWrite(l,&tmp);
2032  omFreeSize(D,sizeof(*D));
2033  return FALSE;
2034 }
#define D(A)
Definition: gentable.cc:119
Class used for (list of) interpreter objects.
Definition: subexpr.h:84
ip_command * command
Definition: ipid.h:24
#define IDID(a)
Definition: ipid.h:119
#define FALSE
Definition: auxiliary.h:97
return P p
Definition: myNF.cc:203
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
Definition: tok.h:117
void * data
Definition: subexpr.h:90
Definition: subexpr.h:21
#define IDTYP(a)
Definition: ipid.h:116
Definition: tok.h:57
#define IDPROC(a)
Definition: ipid.h:137
Definition: tok.h:115
#define NULL
Definition: omList.c:10
int rtyp
Definition: subexpr.h:93
#define IDDATA(a)
Definition: ipid.h:123
#define omAlloc0(size)
Definition: omAllocDecl.h:211
int l
Definition: cfEzgcd.cc:94
#define COMMAND
Definition: tok.h:29

§ sig_chld_hdl()

void sig_chld_hdl ( int  )

additional default signal handler

some newer Linux version cannot have SIG_IGN for SIGCHLD, so use this nice routine here: SuSe 9.x reports -1 always Redhat 9.x/FC x reports sometimes -1 see also: hpux_system also needed by getrusage (timer etc.)

Parameters
[in]sig

Definition at line 1922 of file ssiLink.cc.

1923 {
1924  pid_t kidpid;
1925  int status;
1926 
1927  loop
1928  {
1929  kidpid = si_waitpid(-1, &status, WNOHANG);
1930  if (kidpid==-1)
1931  {
1932  /* continue on interruption (EINTR): */
1933  if (errno == EINTR) continue;
1934  /* break on anything else (EINVAL or ECHILD according to manpage): */
1935  break;
1936  }
1937  else if (kidpid==0) break; /* no more children to process, so break */
1938 
1939  //printf("Child %ld terminated\n", kidpid);
1941  while((hh!=NULL)&&(ssiToBeClosed_inactive))
1942  {
1943  if((hh->l!=NULL) && (hh->l->m->Open==ssiOpen))
1944  {
1945  ssiInfo *d = (ssiInfo *)hh->l->data;
1946  if(d->pid==kidpid)
1947  {
1949  {
1951  slClose(hh->l);
1953  break;
1954  }
1955  else break;
1956  }
1957  else hh=(link_list)hh->next;
1958  }
1959  else hh=(link_list)hh->next;
1960  }
1961  }
1962 }
loop
Definition: myNF.cc:98
#define FALSE
Definition: auxiliary.h:97
#define TRUE
Definition: auxiliary.h:101
#define NULL
Definition: omList.c:10
int * status
Definition: si_signals.h:51

§ slInitSsiExtension()

si_link_extension slInitSsiExtension ( si_link_extension  s)

Definition at line 1536 of file ssiLink.cc.

1537 {
1538  s->Open=ssiOpen;
1539  s->Close=ssiClose;
1540  s->Kill=ssiClose;
1541  s->Read=ssiRead1;
1542  s->Read2=(slRead2Proc)NULL;
1543  s->Write=ssiWrite;
1544  s->Dump=ssiDump;
1545  s->GetDump=ssiGetDump;
1546 
1547  s->Status=slStatusSsi;
1548  s->SetRing=ssiSetRing;
1549  s->type="ssi";
1550  return s;
1551 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
#define NULL
Definition: omList.c:10

§ slStatusSsi()

const char* slStatusSsi ( si_link  l,
const char *  request 
)

Definition at line 1553 of file ssiLink.cc.

1554 {
1555  ssiInfo *d=(ssiInfo*)l->data;
1556  if (d==NULL) return "not open";
1557  if (((strcmp(l->mode,"fork")==0)
1558  ||(strcmp(l->mode,"tcp")==0)
1559  ||(strcmp(l->mode,"connect")==0))
1560  && (strcmp(request, "read") == 0))
1561  {
1562  fd_set mask;
1563  struct timeval wt;
1564  if (s_isready(d->f_read)) return "ready";
1565  loop
1566  {
1567  /* Don't block. Return socket status immediately. */
1568  wt.tv_sec = 0;
1569  wt.tv_usec = 0;
1570 
1571  FD_ZERO(&mask);
1572  FD_SET(d->fd_read, &mask);
1573  //Print("test fd %d\n",d->fd_read);
1574  /* check with select: chars waiting: no -> not ready */
1575  switch (si_select(d->fd_read+1, &mask, NULL, NULL, &wt))
1576  {
1577  case 0: /* not ready */ return "not ready";
1578  case -1: /*error*/ return "error";
1579  case 1: /*ready ? */ break;
1580  }
1581  /* yes: read 1 char*/
1582  /* if \n, check again with select else ungetc(c), ready*/
1583  int c=s_getc(d->f_read);
1584  //Print("try c=%d\n",c);
1585  if (c== -1) return "eof"; /* eof or error */
1586  else if (isdigit(c))
1587  { s_ungetc(c,d->f_read); return "ready"; }
1588  else if (c>' ')
1589  {
1590  Werror("unknown char in ssiLink(%d)",c);
1591  return "error";
1592  }
1593  /* else: next char */
1594  }
1595  }
1596  else if (strcmp(request, "read") == 0)
1597  {
1598  if (SI_LINK_R_OPEN_P(l) && (!s_iseof(d->f_read)) && (s_isready(d->f_read))) return "ready";
1599  else return "not ready";
1600  }
1601  else if (strcmp(request, "write") == 0)
1602  {
1603  if (SI_LINK_W_OPEN_P(l)) return "ready";
1604  else return "not ready";
1605  }
1606  else return "unknown status request";
1607 }
loop
Definition: myNF.cc:98
if(0 > strat->sl)
Definition: myNF.cc:73
int s_getc(s_buff F)
Definition: s_buff.cc:65
void s_ungetc(int c, s_buff F)
Definition: s_buff.cc:106
int s_iseof(s_buff F)
Definition: s_buff.cc:259
#define NULL
Definition: omList.c:10
int s_isready(s_buff F)
Definition: s_buff.cc:92
void Werror(const char *fmt,...)
Definition: reporter.cc:189
int l
Definition: cfEzgcd.cc:94

§ slStatusSsiL()

int slStatusSsiL ( lists  L,
int  timeout 
)

Definition at line 1609 of file ssiLink.cc.

1610 {
1611 // input: L: a list with links of type
1612 // ssi-connect, ssi-fork, ssi-tcp, MPtcp-fork or MPtcp-launch.
1613 // Note: Not every entry in L must be set.
1614 // timeout: timeout for select in micro-seconds
1615 // or -1 for infinity
1616 // or 0 for polling
1617 // returns: ERROR (via Werror): L has wrong elements or link not open
1618 // -2: select returns an error
1619 // -1: the read state of all links is eof
1620 // 0: timeout (or polling): none ready,
1621 // i>0: (at least) L[i] is ready
1622  si_link l;
1623  ssiInfo *d;
1624  int d_fd;
1625  fd_set mask, fdmask;
1626  FD_ZERO(&fdmask);
1627  FD_ZERO(&mask);
1628  int max_fd=0; /* 1 + max fd in fd_set */
1629 
1630  /* timeout */
1631  struct timeval wt;
1632  struct timeval *wt_ptr=&wt;
1633  int startingtime = getRTimer()/TIMER_RESOLUTION; // in seconds
1634  if (timeout== -1)
1635  {
1636  wt_ptr=NULL;
1637  }
1638  else
1639  {
1640  wt.tv_sec = timeout / 1000000;
1641  wt.tv_usec = timeout % 1000000;
1642  }
1643 
1644  /* auxiliary variables */
1645  int i;
1646  int j;
1647  int k;
1648  int s;
1649  char fdmaskempty;
1650 
1651  /* check the links and fill in fdmask */
1652  /* check ssi links for ungetc_buf */
1653  for(i=L->nr; i>=0; i--)
1654  {
1655  if (L->m[i].Typ()!=DEF_CMD)
1656  {
1657  if (L->m[i].Typ()!=LINK_CMD)
1658  { WerrorS("all elements must be of type link"); return -2;}
1659  l=(si_link)L->m[i].Data();
1660  if(SI_LINK_OPEN_P(l)==0)
1661  { WerrorS("all links must be open"); return -2;}
1662  if (((strcmp(l->m->type,"ssi")!=0) && (strcmp(l->m->type,"MPtcp")!=0))
1663  || ((strcmp(l->mode,"fork")!=0) && (strcmp(l->mode,"tcp")!=0)
1664  && (strcmp(l->mode,"launch")!=0) && (strcmp(l->mode,"connect")!=0)))
1665  {
1666  WerrorS("all links must be of type ssi:fork, ssi:tcp, ssi:connect");
1667  return -2;
1668  }
1669  if (strcmp(l->m->type,"ssi")==0)
1670  {
1671  d=(ssiInfo*)l->data;
1672  d_fd=d->fd_read;
1673  if (!s_isready(d->f_read))
1674  {
1675  FD_SET(d_fd, &fdmask);
1676  if (d_fd > max_fd) max_fd=d_fd;
1677  }
1678  else
1679  return i+1;
1680  }
1681  else
1682  {
1683  Werror("wrong link type >>%s<<",l->m->type);
1684  return -2;
1685  }
1686  }
1687  }
1688  max_fd++;
1689 
1690 do_select:
1691  /* copy fdmask to mask */
1692  FD_ZERO(&mask);
1693  for(k = 0; k < max_fd; k++)
1694  {
1695  if(FD_ISSET(k, &fdmask))
1696  {
1697  FD_SET(k, &mask);
1698  }
1699  }
1700 
1701  /* check with select: chars waiting: no -> not ready */
1702  s = si_select(max_fd, &mask, NULL, NULL, wt_ptr);
1703  if (s==-1)
1704  {
1705  WerrorS("error in select call");
1706  return -2; /*error*/
1707  }
1708  if (s==0)
1709  {
1710  return 0; /*poll: not ready */
1711  }
1712  else /* s>0, at least one ready (the number of fd which are ready is s)*/
1713  {
1714  j=0;
1715  while (j<=max_fd) { if (FD_ISSET(j,&mask)) break; j++; }
1716  for(i=L->nr; i>=0; i--)
1717  {
1718  if (L->m[i].rtyp==LINK_CMD)
1719  {
1720  l=(si_link)L->m[i].Data();
1721  if (strcmp(l->m->type,"ssi")==0)
1722  {
1723  d=(ssiInfo*)l->data;
1724  d_fd=d->fd_read;
1725  if(j==d_fd) break;
1726  }
1727  else
1728  {
1729  Werror("wrong link type >>%s<<",l->m->type);
1730  return -2;
1731  }
1732  }
1733  }
1734  // only ssi links:
1735  loop
1736  {
1737  /* yes: read 1 char*/
1738  /* if \n, check again with select else ungetc(c), ready*/
1739  /* setting: d: current ssiInfo, j current fd, i current entry in L*/
1740  int c=s_getc(d->f_read);
1741  //Print("try c=%d\n",c);
1742  if (c== -1) /* eof */
1743  {
1744  FD_CLR(j,&fdmask);
1745  fdmaskempty = 1;
1746  for(k = 0; k < max_fd; k++)
1747  {
1748  if(FD_ISSET(k, &fdmask))
1749  {
1750  fdmaskempty = 0;
1751  break;
1752  }
1753  }
1754  if(fdmaskempty)
1755  {
1756  return -1;
1757  }
1758  if(timeout != -1)
1759  {
1760  timeout = si_max(0,
1761  timeout - 1000000*(getRTimer()/TIMER_RESOLUTION - startingtime));
1762  wt.tv_sec = timeout / 1000000;
1763  wt.tv_usec = (timeout % 1000000);
1764  }
1765  goto do_select;
1766  }
1767 
1768  else if (isdigit(c))
1769  { s_ungetc(c,d->f_read); return i+1; }
1770  else if (c>' ')
1771  {
1772  Werror("unknown char in ssiLink(%d)",c);
1773  return -2;
1774  }
1775  /* else: next char */
1776  goto do_select;
1777  }
1778  }
1779 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
sleftv * m
Definition: lists.h:45
loop
Definition: myNF.cc:98
if(0 > strat->sl)
Definition: myNF.cc:73
int getRTimer()
Definition: timer.cc:172
void WerrorS(const char *s)
Definition: feFopen.cc:24
int k
Definition: cfEzgcd.cc:93
int Typ()
Definition: subexpr.cc:979
int s_getc(s_buff F)
Definition: s_buff.cc:65
#define TIMER_RESOLUTION
Definition: mod2.h:38
int j
Definition: myNF.cc:70
Definition: tok.h:57
void s_ungetc(int c, s_buff F)
Definition: s_buff.cc:106
static int si_max(const int a, const int b)
Definition: auxiliary.h:123
int i
Definition: cfEzgcd.cc:123
int nr
Definition: lists.h:43
Definition: tok.h:115
#define NULL
Definition: omList.c:10
int rtyp
Definition: subexpr.h:93
void * Data()
Definition: subexpr.cc:1121
int s_isready(s_buff F)
Definition: s_buff.cc:92
void Werror(const char *fmt,...)
Definition: reporter.cc:189
int l
Definition: cfEzgcd.cc:94

§ ssiBatch()

int ssiBatch ( const char *  host,
const char *  port 
)

Definition at line 1781 of file ssiLink.cc.

1783 {
1785  char *buf=(char*)omAlloc(256);
1786  sprintf(buf,"ssi:connect %s:%s",host,port);
1787  slInit(l, buf);
1788  if (slOpen(l,SI_LINK_OPEN,NULL)) return 1;
1790 
1791  idhdl id = enterid(omStrDup("link_ll"), 0, LINK_CMD, &IDROOT, FALSE);
1792  IDLINK(id) = l;
1793 
1794  loop
1795  {
1796  leftv h=ssiRead1(l); /*contains an exit.... */
1797  if (feErrors != NULL && *feErrors != '\0')
1798  {
1799  // handle errors:
1800  PrintS(feErrors); /* currently quite simple */
1801  *feErrors = '\0';
1802  }
1803  ssiWrite(l,h);
1804  h->CleanUp();
1805  omFreeBin(h, sleftv_bin);
1806  }
1807  /* never reached*/
1808  exit(0);
1809 }
Class used for (list of) interpreter objects.
Definition: subexpr.h:84
#define IDLINK(a)
Definition: ipid.h:135
loop
Definition: myNF.cc:98
#define FALSE
Definition: auxiliary.h:97
#define IDROOT
Definition: ipid.h:20
#define omAlloc(size)
Definition: omAllocDecl.h:210
Definition: idrec.h:34
idhdl enterid(const char *s, int lev, int t, idhdl *root, BOOLEAN init, BOOLEAN search)
Definition: ipid.cc:259
char * feErrors
Definition: reporter.cc:47
int status int void * buf
Definition: si_signals.h:59
omBin sleftv_bin
Definition: subexpr.cc:50
void PrintS(const char *s)
Definition: reporter.cc:284
#define omAlloc0Bin(bin)
Definition: omAllocDecl.h:206
Definition: tok.h:115
#define NULL
Definition: omList.c:10
void CleanUp(ring r=currRing)
Definition: subexpr.cc:320
#define omFreeBin(addr, bin)
Definition: omAllocDecl.h:259
static Poly * h
Definition: janet.cc:978
int l
Definition: cfEzgcd.cc:94
#define omStrDup(s)
Definition: omAllocDecl.h:263

§ ssiClose()

BOOLEAN ssiClose ( si_link  l)

Definition at line 1143 of file ssiLink.cc.

1144 {
1145  if (l!=NULL)
1146  {
1148  ssiInfo *d = (ssiInfo *)l->data;
1149  if (d!=NULL)
1150  {
1151  // send quit signal
1152  if ((d->send_quit_at_exit)
1153  && (d->quit_sent==0))
1154  {
1155  fputs("99\n",d->f_write);
1156  fflush(d->f_write);
1157  }
1158  // clean ring
1159  if (d->r!=NULL) rKill(d->r);
1160  // did the child to stop ?
1161  si_waitpid(d->pid,NULL,WNOHANG);
1162  if ((d->pid!=0)
1163  && (kill(d->pid,0)==0)) // child is still running
1164  {
1165  struct timespec t;
1166  t.tv_sec=0;
1167  t.tv_nsec=100000000; // <=100 ms
1168  struct timespec rem;
1169  int r;
1170  loop
1171  {
1172  // wait till signal or time rem:
1173  r = nanosleep(&t, &rem);
1174  t = rem;
1175  // child finished:
1176  if (si_waitpid(d->pid,NULL,WNOHANG) != 0) break;
1177  // other signal, waited s>= 100 ms:
1178  if ((r==0) || (errno != EINTR)) break;
1179  }
1180  if (kill(d->pid,0) == 0) // pid still exists
1181  {
1182  kill(d->pid,15);
1183  t.tv_sec=5; // <=5s
1184  t.tv_nsec=0;
1185  loop
1186  {
1187  // wait till signal or time rem:
1188  r = nanosleep(&t, &rem);
1189  t = rem;
1190  // child finished:
1191  if (si_waitpid(d->pid,NULL,WNOHANG) != 0) break;
1192  // other signal, waited s>= 5 s:
1193  if ((r==0) || (errno != EINTR)) break;
1194  }
1195  if (kill(d->pid,0) == 0)
1196  {
1197  kill(d->pid,9); // just to be sure
1198  si_waitpid(d->pid,NULL,0);
1199  }
1200  }
1201  }
1202  if (d->f_read!=NULL) { s_close(d->f_read);s_free(d->f_read);d->f_read=NULL;}
1203  if (d->f_write!=NULL) { fclose(d->f_write); d->f_write=NULL; }
1204  if ((strcmp(l->mode,"tcp")==0)
1205  || (strcmp(l->mode,"fork")==0))
1206  {
1208  if (hh!=NULL)
1209  {
1210  if (hh->l==l)
1211  {
1213  omFreeSize(hh,sizeof(link_struct));
1214  }
1215  else while(hh->next!=NULL)
1216  {
1217  link_list hhh=(link_list)hh->next;
1218  if (hhh->l==l)
1219  {
1220  hh->next=hhh->next;
1221  omFreeSize(hhh,sizeof(link_struct));
1222  break;
1223  }
1224  else
1225  hh=(link_list)hh->next;
1226  }
1227  }
1228  }
1229  omFreeSize((ADDRESS)d,(sizeof *d));
1230  }
1231  l->data=NULL;
1232  }
1233  return FALSE;
1234 }
void rem(unsigned long *a, unsigned long *q, unsigned long p, int &dega, int degq)
Definition: minpoly.cc:574
loop
Definition: myNF.cc:98
if(0 > strat->sl)
Definition: myNF.cc:73
#define FALSE
Definition: auxiliary.h:97
int s_free(s_buff &F)
Definition: s_buff.cc:44
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
void * ADDRESS
Definition: auxiliary.h:118
int s_close(s_buff &F)
Definition: s_buff.cc:55
const ring r
Definition: syzextra.cc:208
void rKill(ring r)
Definition: ipshell.cc:6044
#define NULL
Definition: omList.c:10
int l
Definition: cfEzgcd.cc:94

§ ssiCommandLink()

si_link ssiCommandLink ( )

Definition at line 1851 of file ssiLink.cc.

1852 {
1853  if (ssiReserved_P==0)
1854  {
1855  WerrorS("ERROR no reverved port requested");
1856  return NULL;
1857  }
1858  struct sockaddr_in cli_addr;
1859  int clilen = sizeof(cli_addr);
1860  int newsockfd = si_accept(ssiReserved_sockfd, (struct sockaddr *) &cli_addr, (socklen_t *)&clilen);
1861  if(newsockfd < 0)
1862  {
1863  Werror("ERROR on accept (errno=%d)",errno);
1864  return NULL;
1865  }
1867  si_link_extension s = si_link_root;
1868  si_link_extension prev = s;
1869  while (strcmp(s->type, "ssi") != 0)
1870  {
1871  if (s->next == NULL)
1872  {
1873  prev = s;
1874  s = NULL;
1875  break;
1876  }
1877  else
1878  {
1879  s = s->next;
1880  }
1881  }
1882  if (s != NULL)
1883  l->m = s;
1884  else
1885  {
1886  si_link_extension ns = (si_link_extension)omAlloc0Bin(s_si_link_extension_bin);
1887  prev->next=slInitSsiExtension(ns);
1888  l->m = prev->next;
1889  }
1890  l->name=omStrDup("");
1891  l->mode=omStrDup("tcp");
1892  l->ref=1;
1893  ssiInfo *d=(ssiInfo*)omAlloc0(sizeof(ssiInfo));
1894  l->data=d;
1895  d->fd_read = newsockfd;
1896  d->fd_write = newsockfd;
1897  d->f_read = s_open(newsockfd);
1898  d->f_write = fdopen(newsockfd, "w");
1901  if (ssiReserved_Clients<=0)
1902  {
1903  ssiReserved_P=0;
1904  si_close(ssiReserved_sockfd);
1905  }
1906  return l;
1907 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
void WerrorS(const char *s)
Definition: feFopen.cc:24
#define omAlloc0Bin(bin)
Definition: omAllocDecl.h:206
#define NULL
Definition: omList.c:10
void Werror(const char *fmt,...)
Definition: reporter.cc:189
#define omAlloc0(size)
Definition: omAllocDecl.h:211
int l
Definition: cfEzgcd.cc:94
s_buff s_open(int fd)
Definition: s_buff.cc:30
#define omStrDup(s)
Definition: omAllocDecl.h:263

§ ssiDump()

BOOLEAN ssiDump ( si_link  l)

Definition at line 2056 of file ssiLink.cc.

2057 {
2058  idhdl h = IDROOT, rh = currRingHdl;
2059  BOOLEAN status = ssiDumpIter(l, h);
2060 
2061  //if (! status ) status = DumpAsciiMaps(fd, h, NULL);
2062 
2063  if (currRingHdl != rh) rSetHdl(rh);
2064  //fprintf(fd, "option(set, intvec(%d, %d));\n", si_opt_1, si_opt_2);
2065 
2066  return status;
2067 }
#define IDROOT
Definition: ipid.h:20
Definition: idrec.h:34
idhdl currRingHdl
Definition: ipid.cc:65
int * status
Definition: si_signals.h:51
void rSetHdl(idhdl h)
Definition: ipshell.cc:5017
static Poly * h
Definition: janet.cc:978
int BOOLEAN
Definition: auxiliary.h:88
int l
Definition: cfEzgcd.cc:94

§ ssiDumpIter()

static BOOLEAN ssiDumpIter ( si_link  l,
idhdl  h 
)
static

Definition at line 2035 of file ssiLink.cc.

2036 {
2037  if (h == NULL) return FALSE;
2038 
2039  if (ssiDumpIter(l, IDNEXT(h))) return TRUE;
2040 
2041  // need to set the ring before writing it, otherwise we get in
2042  // trouble with minpoly
2043  if (IDTYP(h) == RING_CMD)
2044  rSetHdl(h);
2045 
2046  if (DumpSsiIdhdl(l, h)) return TRUE;
2047 
2048  // do not dump ssi internal rings: ssiRing*
2049  // but dump objects of all other rings
2050  if ((IDTYP(h) == RING_CMD)
2051  && (strncmp(IDID(h),"ssiRing",7)!=0))
2052  return ssiDumpIter(l, IDRING(h)->idroot);
2053  else
2054  return FALSE;
2055 }
#define IDID(a)
Definition: ipid.h:119
#define FALSE
Definition: auxiliary.h:97
#define IDNEXT(a)
Definition: ipid.h:115
#define TRUE
Definition: auxiliary.h:101
#define IDTYP(a)
Definition: ipid.h:116
#define NULL
Definition: omList.c:10
#define IDRING(a)
Definition: ipid.h:124
void rSetHdl(idhdl h)
Definition: ipshell.cc:5017
int l
Definition: cfEzgcd.cc:94

§ ssiGetDump()

BOOLEAN ssiGetDump ( si_link  l)

Definition at line 2068 of file ssiLink.cc.

2069 {
2070  ssiInfo *d=(ssiInfo*)l->data;
2071  loop
2072  {
2073  if (!SI_LINK_OPEN_P(l)) break;
2074  if (s_iseof(d->f_read)) break;
2075  leftv h=ssiRead1(l); /*contains an exit.... */
2076  if (feErrors != NULL && *feErrors != '\0')
2077  {
2078  // handle errors:
2079  PrintS(feErrors); /* currently quite simple */
2080  return TRUE;
2081  *feErrors = '\0';
2082  }
2083  h->CleanUp();
2084  omFreeBin(h, sleftv_bin);
2085  }
2086  return FALSE;
2087 }
Class used for (list of) interpreter objects.
Definition: subexpr.h:84
loop
Definition: myNF.cc:98
if(0 > strat->sl)
Definition: myNF.cc:73
#define FALSE
Definition: auxiliary.h:97
#define TRUE
Definition: auxiliary.h:101
char * feErrors
Definition: reporter.cc:47
omBin sleftv_bin
Definition: subexpr.cc:50
void PrintS(const char *s)
Definition: reporter.cc:284
int s_iseof(s_buff F)
Definition: s_buff.cc:259
#define NULL
Definition: omList.c:10
void CleanUp(ring r=currRing)
Definition: subexpr.cc:320
#define omFreeBin(addr, bin)
Definition: omAllocDecl.h:259
static Poly * h
Definition: janet.cc:978
int l
Definition: cfEzgcd.cc:94

§ ssiOpen()

BOOLEAN ssiOpen ( si_link  l,
short  flag,
leftv  u 
)

Definition at line 758 of file ssiLink.cc.

759 {
760  if (l!=NULL)
761  {
762  const char *mode;
763  ssiInfo *d=(ssiInfo*)omAlloc0(sizeof(ssiInfo));
764  if (flag & SI_LINK_OPEN)
765  {
766  if (l->mode[0] != '\0' && (strcmp(l->mode, "r") == 0))
767  flag = SI_LINK_READ;
768  else flag = SI_LINK_WRITE;
769  }
770 
771  if (flag == SI_LINK_READ) mode = "r";
772  else if (strcmp(l->mode, "w") == 0) mode = "w";
773  else if (strcmp(l->mode, "fork") == 0) mode = "fork";
774  else if (strcmp(l->mode, "tcp") == 0) mode = "tcp";
775  else if (strcmp(l->mode, "connect") == 0) mode = "connect";
776  else mode = "a";
777 
778 
779  SI_LINK_SET_OPEN_P(l, flag);
780  l->data=d;
781  omFree(l->mode);
782  l->mode = omStrDup(mode);
783 
784  if (l->name[0] == '\0')
785  {
786  if (strcmp(mode,"fork")==0)
787  {
789  n->u=u;
790  n->l=l;
791  n->next=(void *)ssiToBeClosed;
792  ssiToBeClosed=n;
793 
794  int pc[2];
795  int cp[2];
796  pipe(pc);
797  pipe(cp);
798  pid_t pid = fork();
799  if (pid == -1 && errno == EAGAIN) // RLIMIT_NPROC too low?
800  {
802  pid = fork();
803  }
804  if (pid == -1)
805  {
806  WerrorS("could not fork");
807  }
808  if (pid==0) /*fork: child*/
809  {
810  /* block SIGINT */
811  sigset_t sigint;
812  sigemptyset(&sigint);
813  sigaddset(&sigint, SIGINT);
814  sigprocmask(SIG_BLOCK, &sigint, NULL);
815 
817  /* we know: l is the first entry in ssiToBeClosed-list */
818  while(hh!=NULL)
819  {
820  SI_LINK_SET_CLOSE_P(hh->l);
821  ssiInfo *dd=(ssiInfo*)hh->l->data;
822  s_close(dd->f_read);
823  s_free(dd->f_read);
824  fclose(dd->f_write);
825  if (dd->r!=NULL) rKill(dd->r);
826  omFreeSize((ADDRESS)dd,(sizeof *dd));
827  hh->l->data=NULL;
828  link_list nn=(link_list)hh->next;
829  omFree(hh);
830  hh=nn;
831  }
833 #ifdef HAVE_SIMPLEIPC
834  memset(sem_acquired, 0, SIPC_MAX_SEMAPHORES*sizeof(sem_acquired[0]));
835 #endif // HAVE_SIMPLEIPC
836  si_close(pc[1]); si_close(cp[0]);
837  d->f_write=fdopen(cp[1],"w");
838  d->f_read=s_open(pc[0]);
839  d->fd_read=pc[0];
840  d->fd_write=cp[1];
841  //d->r=currRing;
842  //if (d->r!=NULL) d->r->ref++;
843  l->data=d;
844  omFree(l->mode);
845  l->mode = omStrDup(mode);
848  //myynest=0;
850  if ((u!=NULL)&&(u->rtyp==IDHDL))
851  {
852  idhdl h=(idhdl)u->data;
853  h->lev=0;
854  }
855  loop
856  {
857  if (!SI_LINK_OPEN_P(l)) m2_end(0);
858  if(d->f_read->is_eof) m2_end(0);
859  leftv h=ssiRead1(l); /*contains an exit.... */
860  if (feErrors != NULL && *feErrors != '\0')
861  {
862  // handle errors:
863  PrintS(feErrors); /* currently quite simple */
864  *feErrors = '\0';
865  }
866  ssiWrite(l,h);
867  h->CleanUp();
868  omFreeBin(h, sleftv_bin);
869  }
870  /* never reached*/
871  }
872  else if (pid>0) /*fork: parent*/
873  {
874  d->pid=pid;
875  si_close(pc[0]); si_close(cp[1]);
876  d->f_write=fdopen(pc[1],"w");
877  d->f_read=s_open(cp[0]);
878  d->fd_read=cp[0];
879  d->fd_write=pc[1];
881  d->send_quit_at_exit=1;
882  //d->r=currRing;
883  //if (d->r!=NULL) d->r->ref++;
884  }
885  else
886  {
887  Werror("fork failed (%d)",errno);
888  l->data=NULL;
889  omFree(d);
890  return TRUE;
891  }
892  }
893  // ---------------------------------------------------------------------
894  else if (strcmp(mode,"tcp")==0)
895  {
896  int sockfd, newsockfd, portno, clilen;
897  struct sockaddr_in serv_addr, cli_addr;
898  sockfd = socket(AF_INET, SOCK_STREAM, 0);
899  if(sockfd < 0)
900  {
901  WerrorS("ERROR opening socket");
902  l->data=NULL;
903  omFree(d);
904  return TRUE;
905  }
906  memset((char *) &serv_addr,0, sizeof(serv_addr));
907  portno = 1025;
908  serv_addr.sin_family = AF_INET;
909  serv_addr.sin_addr.s_addr = INADDR_ANY;
910  do
911  {
912  portno++;
913  serv_addr.sin_port = htons(portno);
914  if(portno > 50000)
915  {
916  WerrorS("ERROR on binding (no free port available?)");
917  l->data=NULL;
918  omFree(d);
919  return TRUE;
920  }
921  }
922  while(bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0);
923  Print("waiting on port %d\n", portno);mflush();
924  listen(sockfd,1);
925  newsockfd = si_accept(sockfd, (struct sockaddr *) &cli_addr, (socklen_t *)&clilen);
926  if(newsockfd < 0)
927  {
928  WerrorS("ERROR on accept");
929  l->data=NULL;
930  omFree(d);
931  return TRUE;
932  }
933  PrintS("client accepted\n");
934  d->fd_read = newsockfd;
935  d->fd_write = newsockfd;
936  d->f_read = s_open(newsockfd);
937  d->f_write = fdopen(newsockfd, "w");
939  si_close(sockfd);
940  }
941  // no ssi-Link on stdin or stdout
942  else
943  {
944  Werror("invalid mode >>%s<< for ssi",mode);
945  l->data=NULL;
946  omFree(d);
947  return TRUE;
948  }
949  }
950  // =========================================================================
951  else /*l->name=NULL*/
952  {
953  // tcp mode
954  if(strcmp(mode,"tcp")==0)
955  {
956  int sockfd, newsockfd, portno, clilen;
957  struct sockaddr_in serv_addr, cli_addr;
958  sockfd = socket(AF_INET, SOCK_STREAM, 0);
959  if(sockfd < 0)
960  {
961  WerrorS("ERROR opening socket");
962  l->data=NULL;
963  omFree(d);
964  return TRUE;
965  }
966  memset((char *) &serv_addr,0, sizeof(serv_addr));
967  portno = 1025;
968  serv_addr.sin_family = AF_INET;
969  serv_addr.sin_addr.s_addr = INADDR_ANY;
970  do
971  {
972  portno++;
973  serv_addr.sin_port = htons(portno);
974  if(portno > 50000)
975  {
976  WerrorS("ERROR on binding (no free port available?)");
977  l->data=NULL;
978  return TRUE;
979  }
980  }
981  while(bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0);
982  //Print("waiting on port %d\n", portno);mflush();
983  listen(sockfd,1);
984  char* cli_host = (char*)omAlloc(256);
985  char* path = (char*)omAlloc(1024);
986  int r = si_sscanf(l->name,"%255[^:]:%s",cli_host,path);
987  if(r == 0)
988  {
989  WerrorS("ERROR: no host specified");
990  l->data=NULL;
991  omFree(d);
992  omFree(path);
993  omFree(cli_host);
994  return TRUE;
995  }
996  else if(r == 1)
997  {
998  WarnS("program not specified, using /usr/local/bin/Singular");
999  Warn("in line >>%s<<",my_yylinebuf);
1000  strcpy(path,"/usr/local/bin/Singular");
1001  }
1002  char* ssh_command = (char*)omAlloc(256);
1003  char* ser_host = (char*)omAlloc(64);
1004  gethostname(ser_host,64);
1005  sprintf(ssh_command,"ssh %s %s -q --batch --link=ssi --MPhost=%s --MPport=%d &",cli_host,path,ser_host,portno);
1006  //Print("client on %s started:%s\n",cli_host,path);
1007  omFree(path);
1008  omFree(cli_host);
1009  if (TEST_OPT_PROT) { Print("running >>%s<<\n",ssh_command); }
1010  system(ssh_command);
1011  omFree(ssh_command);
1012  omFree(ser_host);
1013  clilen = sizeof(cli_addr);
1014  newsockfd = si_accept(sockfd, (struct sockaddr *) &cli_addr, (socklen_t *)&clilen);
1015  if(newsockfd < 0)
1016  {
1017  WerrorS("ERROR on accept");
1018  l->data=NULL;
1019  omFree(d);
1020  return TRUE;
1021  }
1022  //PrintS("client accepted\n");
1023  d->fd_read = newsockfd;
1024  d->fd_write = newsockfd;
1025  d->f_read = s_open(newsockfd);
1026  d->f_write = fdopen(newsockfd, "w");
1027  si_close(sockfd);
1029  d->send_quit_at_exit=1;
1030  link_list newlink=(link_list)omAlloc(sizeof(link_struct));
1031  newlink->u=u;
1032  newlink->l=l;
1033  newlink->next=(void *)ssiToBeClosed;
1034  ssiToBeClosed=newlink;
1035  fprintf(d->f_write,"98 %d %d %u %u\n",SSI_VERSION,MAX_TOK,si_opt_1,si_opt_2);
1036  }
1037  // ----------------------------------------------------------------------
1038  else if(strcmp(mode,"connect")==0)
1039  {
1040  char* host = (char*)omAlloc(256);
1041  int sockfd, portno;
1042  struct sockaddr_in serv_addr;
1043  struct hostent *server;
1044 
1045  si_sscanf(l->name,"%255[^:]:%d",host,&portno);
1046  //Print("connect to host %s, port %d\n",host,portno);mflush();
1047  if (portno!=0)
1048  {
1049  sockfd = socket(AF_INET, SOCK_STREAM, 0);
1050  if (sockfd < 0) { WerrorS("ERROR opening socket"); return TRUE; }
1051  server = gethostbyname(host);
1052  if (server == NULL) { WerrorS("ERROR, no such host"); return TRUE; }
1053  memset((char *) &serv_addr, 0, sizeof(serv_addr));
1054  serv_addr.sin_family = AF_INET;
1055  memcpy((char *)&serv_addr.sin_addr.s_addr,
1056  (char *)server->h_addr,
1057  server->h_length);
1058  serv_addr.sin_port = htons(portno);
1059  if (si_connect(sockfd,(sockaddr*)&serv_addr,sizeof(serv_addr)) < 0)
1060  { Werror("ERROR connecting(errno=%d)",errno); return TRUE; }
1061  //PrintS("connected\n");mflush();
1062  d->f_read=s_open(sockfd);
1063  d->fd_read=sockfd;
1064  d->f_write=fdopen(sockfd,"w");
1065  d->fd_write=sockfd;
1067  omFree(host);
1068  }
1069  else
1070  {
1071  l->data=NULL;
1072  omFree(d);
1073  return TRUE;
1074  }
1075  }
1076  // ======================================================================
1077  else
1078  {
1079  // normal link to a file
1080  FILE *outfile;
1081  char *filename=l->name;
1082 
1083  if(filename[0]=='>')
1084  {
1085  if (filename[1]=='>')
1086  {
1087  filename+=2;
1088  mode = "a";
1089  }
1090  else
1091  {
1092  filename++;
1093  mode="w";
1094  }
1095  }
1096  outfile=myfopen(filename,mode);
1097  if (outfile!=NULL)
1098  {
1099  if (strcmp(l->mode,"r")==0)
1100  {
1101  fclose(outfile);
1102  d->f_read=s_open_by_name(filename);
1103  }
1104  else
1105  {
1106  d->f_write = outfile;
1107  fprintf(d->f_write,"98 %d %d %u %u\n",SSI_VERSION,MAX_TOK,si_opt_1,si_opt_2);
1108  }
1109  }
1110  else
1111  {
1112  omFree(d);
1113  l->data=NULL;
1114  return TRUE;
1115  }
1116  }
1117  }
1118  }
1119 
1120  return FALSE;
1121 }
unsigned si_opt_1
Definition: options.c:5
char *(* fe_fgets_stdin)(const char *pr, char *s, int size)
Definition: feread.cc:33
Class used for (list of) interpreter objects.
Definition: subexpr.h:84
#define Print
Definition: emacs.cc:83
#define TEST_OPT_PROT
Definition: options.h:98
loop
Definition: myNF.cc:98
#define FALSE
Definition: auxiliary.h:97
int s_free(s_buff &F)
Definition: s_buff.cc:44
Definition: tok.h:213
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
char * fe_fgets_dummy(const char *, char *, int)
Definition: feread.cc:432
void m2_end(int i)
Definition: misc_ip.cc:1072
#define TRUE
Definition: auxiliary.h:101
void * ADDRESS
Definition: auxiliary.h:118
void WerrorS(const char *s)
Definition: feFopen.cc:24
int s_close(s_buff &F)
Definition: s_buff.cc:55
#define WarnS
Definition: emacs.cc:81
#define omAlloc(size)
Definition: omAllocDecl.h:210
Definition: idrec.h:34
#define IDHDL
Definition: tok.h:31
void * data
Definition: subexpr.h:90
#define mflush()
Definition: reporter.h:57
char * feErrors
Definition: reporter.cc:47
char my_yylinebuf[80]
Definition: febase.cc:48
const ring r
Definition: syzextra.cc:208
BOOLEAN singular_in_batchmode
Definition: cntrlc.cc:72
void rKill(ring r)
Definition: ipshell.cc:6044
#define omFree(addr)
Definition: omAllocDecl.h:261
FILE * myfopen(const char *path, const char *mode)
Definition: feFopen.cc:167
void system(sys)
int raise_rlimit_nproc()
Definition: rlimit.c:18
idrec * idhdl
Definition: ring.h:18
omBin sleftv_bin
Definition: subexpr.cc:50
void PrintS(const char *s)
Definition: reporter.cc:284
#define NULL
Definition: omList.c:10
short lev
Definition: idrec.h:45
int rtyp
Definition: subexpr.h:93
#define SIPC_MAX_SEMAPHORES
Definition: simpleipc.h:10
void CleanUp(ring r=currRing)
Definition: subexpr.cc:320
#define omFreeBin(addr, bin)
Definition: omAllocDecl.h:259
int sem_acquired[SIPC_MAX_SEMAPHORES]
Definition: semaphore.c:30
s_buff s_open_by_name(const char *n)
Definition: s_buff.cc:38
unsigned si_opt_2
Definition: options.c:6
static Poly * h
Definition: janet.cc:978
void Werror(const char *fmt,...)
Definition: reporter.cc:189
#define omAlloc0(size)
Definition: omAllocDecl.h:211
int l
Definition: cfEzgcd.cc:94
s_buff s_open(int fd)
Definition: s_buff.cc:30
#define Warn
Definition: emacs.cc:80
#define omStrDup(s)
Definition: omAllocDecl.h:263

§ ssiPrepClose()

BOOLEAN ssiPrepClose ( si_link  l)

Definition at line 1124 of file ssiLink.cc.

1125 {
1126  if (l!=NULL)
1127  {
1129  ssiInfo *d = (ssiInfo *)l->data;
1130  if (d!=NULL)
1131  {
1132  if (d->send_quit_at_exit)
1133  {
1134  fputs("99\n",d->f_write);
1135  fflush(d->f_write);
1136  }
1137  d->quit_sent=1;
1138  }
1139  }
1140  return FALSE;
1141 }
if(0 > strat->sl)
Definition: myNF.cc:73
#define FALSE
Definition: auxiliary.h:97
#define NULL
Definition: omList.c:10
int l
Definition: cfEzgcd.cc:94

§ ssiRead1()

leftv ssiRead1 ( si_link  l)

Definition at line 1237 of file ssiLink.cc.

1238 {
1239  ssiInfo *d = (ssiInfo *)l->data;
1240  leftv res=(leftv)omAlloc0(sizeof(sleftv));
1241  int t=0;
1242  t=s_readint(d->f_read);
1243  //Print("got type %d\n",t);
1244  switch(t)
1245  {
1246  case 1:res->rtyp=INT_CMD;
1247  res->data=(char *)(long)ssiReadInt(d->f_read);
1248  break;
1249  case 2:res->rtyp=STRING_CMD;
1250  res->data=(char *)ssiReadString(d);
1251  break;
1252  case 3:res->rtyp=NUMBER_CMD;
1253  res->data=(char *)ssiReadNumber(d);
1254  break;
1255  case 4:res->rtyp=BIGINT_CMD;
1256  res->data=(char *)ssiReadBigInt(d);
1257  break;
1258  case 15:
1259  case 5:{
1260  d->r=ssiReadRing(d);
1261  if (d->r==NULL) return NULL;
1262  res->data=(char*)d->r;
1263  res->rtyp=RING_CMD;
1264  // we are in the top-level, so set the basering to d->r:
1265  if (d->r!=NULL)
1266  {
1267  d->r->ref++;
1268  ssiSetCurrRing(d->r);
1269  }
1270  if (t==15) return ssiRead1(l);
1271  }
1272  break;
1273  case 6:res->rtyp=POLY_CMD;
1274  if (d->r==NULL) goto no_ring;
1275  res->data=(char*)ssiReadPoly(d);
1276  break;
1277  case 7:res->rtyp=IDEAL_CMD;
1278  if (d->r==NULL) goto no_ring;
1279  res->data=(char*)ssiReadIdeal(d);
1280  break;
1281  case 8:res->rtyp=MATRIX_CMD;
1282  if (d->r==NULL) goto no_ring;
1283  res->data=(char*)ssiReadMatrix(d);
1284  break;
1285  case 9:res->rtyp=VECTOR_CMD;
1286  if (d->r==NULL) goto no_ring;
1287  res->data=(char*)ssiReadPoly(d);
1288  break;
1289  case 10:res->rtyp=MODUL_CMD;
1290  if (d->r==NULL) goto no_ring;
1291  {
1292  int rk=s_readint(d->f_read);
1293  ideal M=ssiReadIdeal(d);
1294  M->rank=rk;
1295  res->data=(char*)M;
1296  }
1297  break;
1298  case 11:
1299  {
1300  res->rtyp=COMMAND;
1301  res->data=ssiReadCommand(l);
1302  int nok=res->Eval();
1303  if (nok) WerrorS("error in eval");
1304  break;
1305  }
1306  case 12: /*DEF_CMD*/
1307  {
1308  res->rtyp=0;
1309  res->name=(char *)ssiReadString(d);
1310  int nok=res->Eval();
1311  if (nok) WerrorS("error in name lookup");
1312  break;
1313  }
1314  case 13: res->rtyp=PROC_CMD;
1315  res->data=ssiReadProc(d);
1316  break;
1317  case 14: res->rtyp=LIST_CMD;
1318  res->data=ssiReadList(l);
1319  break;
1320  case 16: res->rtyp=NONE; res->data=NULL;
1321  break;
1322  case 17: res->rtyp=INTVEC_CMD;
1323  res->data=ssiReadIntvec(d);
1324  break;
1325  case 18: res->rtyp=INTMAT_CMD;
1326  res->data=ssiReadIntmat(d);
1327  break;
1328  case 19: res->rtyp=BIGINTMAT_CMD;
1329  res->data=ssiReadBigintmat(d);
1330  break;
1331  case 20: ssiReadBlackbox(res,l);
1332  break;
1333  case 21: ssiReadAttrib(res,l);
1334  break;
1335  // ------------
1336  case 98: // version
1337  {
1338  int n98_v,n98_m;
1339  BITSET n98_o1,n98_o2;
1340  n98_v=s_readint(d->f_read);
1341  n98_m=s_readint(d->f_read);
1342  n98_o1=s_readint(d->f_read);
1343  n98_o2=s_readint(d->f_read);
1344  if ((n98_v!=SSI_VERSION) ||(n98_m!=MAX_TOK))
1345  {
1346  Print("incompatible versions of ssi: %d/%d vs %d/%d",
1347  SSI_VERSION,MAX_TOK,n98_v,n98_m);
1348  }
1349  #ifndef SING_NDEBUG
1350  if (TEST_OPT_DEBUG)
1351  Print("// opening ssi-%d, MAX_TOK=%d\n",n98_v,n98_m);
1352  #endif
1353  si_opt_1=n98_o1;
1354  si_opt_2=n98_o2;
1355  return ssiRead1(l);
1356  }
1357  case 99: ssiClose(l); m2_end(0);
1358  case 0: if (s_iseof(d->f_read))
1359  {
1360  ssiClose(l);
1361  }
1362  res->rtyp=DEF_CMD;
1363  break;
1364  default: Werror("not implemented (t:%d)",t);
1365  omFreeSize(res,sizeof(sleftv));
1366  res=NULL;
1367  break;
1368  }
1369  // if currRing is required for the result, but lost
1370  // define "ssiRing%d" as currRing:
1371  if ((d->r!=NULL)
1372  && (currRing!=d->r)
1373  && (res->RingDependend()))
1374  {
1375  ssiSetCurrRing(d->r);
1376  }
1377  return res;
1378 no_ring: WerrorS("no ring");
1379  omFreeSize(res,sizeof(sleftv));
1380  return NULL;
1381 }
unsigned si_opt_1
Definition: options.c:5
Class used for (list of) interpreter objects.
Definition: subexpr.h:84
#define Print
Definition: emacs.cc:83
Definition: tok.h:94
if(0 > strat->sl)
Definition: myNF.cc:73
Definition: tok.h:38
Definition: tok.h:213
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
void m2_end(int i)
Definition: misc_ip.cc:1072
void WerrorS(const char *s)
Definition: feFopen.cc:24
#define TEST_OPT_DEBUG
Definition: options.h:103
#define BITSET
Definition: structs.h:18
poly res
Definition: myNF.cc:322
#define M
Definition: sirandom.c:24
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:10
int s_readint(s_buff F)
Definition: s_buff.cc:119
Definition: tok.h:57
int s_iseof(s_buff F)
Definition: s_buff.cc:259
Definition: tok.h:99
#define NULL
Definition: omList.c:10
Definition: tok.h:116
unsigned si_opt_2
Definition: options.c:6
#define NONE
Definition: tok.h:216
void Werror(const char *fmt,...)
Definition: reporter.cc:189
#define omAlloc0(size)
Definition: omAllocDecl.h:211
int l
Definition: cfEzgcd.cc:94
#define COMMAND
Definition: tok.h:29

§ ssiReadAttrib()

void ssiReadAttrib ( leftv  res,
si_link  l 
)

Definition at line 736 of file ssiLink.cc.

737 {
738  ssiInfo *d=(ssiInfo*)l->data;
739  BITSET fl=(BITSET)s_readint(d->f_read);
740  int nr_of_attr=s_readint(d->f_read);
741  if (nr_of_attr>0)
742  {
743  for(int i=1;i<nr_of_attr;i++)
744  {
745  }
746  }
747  leftv tmp=ssiRead1(l);
748  memcpy(res,tmp,sizeof(sleftv));
749  memset(tmp,0,sizeof(sleftv));
750  omFreeSize(tmp,sizeof(sleftv));
751  if (nr_of_attr>0)
752  {
753  }
754  res->flag=fl;
755 }
Class used for (list of) interpreter objects.
Definition: subexpr.h:84
BITSET flag
Definition: subexpr.h:92
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
#define BITSET
Definition: structs.h:18
int s_readint(s_buff F)
Definition: s_buff.cc:119
int i
Definition: cfEzgcd.cc:123
int l
Definition: cfEzgcd.cc:94

§ ssiReadBigInt()

number ssiReadBigInt ( const ssiInfo d)

Definition at line 414 of file ssiLink.cc.

415 {
416  number n=ssiReadNumber_CF(d,coeffs_BIGINT);
417  if ((SR_HDL(n) & SR_INT)==0)
418  {
419  if (n->s!=3) Werror("invalid sub type in bigint:%d",n->s);
420  }
421  return n;
422 }
coeffs coeffs_BIGINT
Definition: ipid.cc:54
#define SR_INT
Definition: longrat.h:68
#define SR_HDL(A)
Definition: tgb.cc:35
void Werror(const char *fmt,...)
Definition: reporter.cc:189

§ ssiReadBigintmat()

bigintmat* ssiReadBigintmat ( const ssiInfo d)

Definition at line 703 of file ssiLink.cc.

704 {
705  int r,c;
706  r=s_readint(d->f_read);
707  c=s_readint(d->f_read);
709  for(int i=0;i<r*c;i++)
710  {
711  (*v)[i]=ssiReadBigInt(d);
712  }
713  return v;
714 }
Matrices of numbers.
Definition: bigintmat.h:51
coeffs coeffs_BIGINT
Definition: ipid.cc:54
const ring r
Definition: syzextra.cc:208
int s_readint(s_buff F)
Definition: s_buff.cc:119
int i
Definition: cfEzgcd.cc:123
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37

§ ssiReadBlackbox()

void ssiReadBlackbox ( leftv  res,
si_link  l 
)

Definition at line 716 of file ssiLink.cc.

717 {
718  ssiInfo *d=(ssiInfo*)l->data;
719  int throwaway;
720  throwaway=s_readint(d->f_read);
721  char *name=ssiReadString(d);
722  int tok;
723  blackboxIsCmd(name,tok);
724  if (tok>MAX_TOK)
725  {
726  blackbox *b=getBlackboxStuff(tok);
727  res->rtyp=tok;
728  b->blackbox_deserialize(&b,&(res->data),l);
729  }
730  else
731  {
732  Werror("blackbox %s not found",name);
733  }
734 }
Definition: tok.h:213
void * data
Definition: subexpr.h:90
int s_readint(s_buff F)
Definition: s_buff.cc:119
char name(const Variable &v)
Definition: factory.h:178
int blackboxIsCmd(const char *n, int &tok)
used by scanner: returns ROOT_DECL for known types (and the type number in tok)
Definition: blackbox.cc:189
int rtyp
Definition: subexpr.h:93
const poly b
Definition: syzextra.cc:213
void Werror(const char *fmt,...)
Definition: reporter.cc:189
int l
Definition: cfEzgcd.cc:94
blackbox * getBlackboxStuff(const int t)
return the structure to the type given by t
Definition: blackbox.cc:16

§ ssiReadCommand()

command ssiReadCommand ( si_link  l)

Definition at line 606 of file ssiLink.cc.

607 {
608  ssiInfo *d=(ssiInfo*)l->data;
609  // syntax: <num ops> <operation> <op1> <op2> ....
610  command D=(command)omAlloc0(sizeof(*D));
611  int argc,op;
612  argc=s_readint(d->f_read);
613  op=s_readint(d->f_read);
614  D->argc=argc; D->op=op;
615  leftv v;
616  if (argc >0)
617  {
618  v=ssiRead1(l);
619  memcpy(&(D->arg1),v,sizeof(*v));
621  }
622  if (argc <4)
623  {
624  if (D->argc >1)
625  {
626  v=ssiRead1(l);
627  memcpy(&(D->arg2),v,sizeof(*v));
629  }
630  if (D->argc >2)
631  {
632  v=ssiRead1(l);
633  memcpy(&(D->arg3),v,sizeof(*v));
635  }
636  }
637  else
638  {
639  leftv prev=&(D->arg1);
640  argc--;
641  while(argc >0)
642  {
643  v=ssiRead1(l);
644  prev->next=v;
645  prev=v;
646  argc--;
647  }
648  }
649  return D;
650 }
#define D(A)
Definition: gentable.cc:119
Class used for (list of) interpreter objects.
Definition: subexpr.h:84
ip_command * command
Definition: ipid.h:24
int s_readint(s_buff F)
Definition: s_buff.cc:119
omBin sleftv_bin
Definition: subexpr.cc:50
leftv next
Definition: subexpr.h:88
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
#define omFreeBin(addr, bin)
Definition: omAllocDecl.h:259
#define omAlloc0(size)
Definition: omAllocDecl.h:211
int l
Definition: cfEzgcd.cc:94

§ ssiReadIdeal()

ideal ssiReadIdeal ( const ssiInfo d)

Definition at line 585 of file ssiLink.cc.

586 {
587  return ssiReadIdeal_R(d,d->r);
588 }

§ ssiReadIdeal_R()

ideal ssiReadIdeal_R ( const ssiInfo d,
const ring  r 
)

Definition at line 572 of file ssiLink.cc.

573 {
574  int n,i;
575  ideal I;
576  n=s_readint(d->f_read);
577  I=idInit(n,1);
578  for(i=0;i<IDELEMS(I);i++) // read n terms
579  {
580  I->m [i]=ssiReadPoly_R(d,r);
581  }
582  return I;
583 }
const ring r
Definition: syzextra.cc:208
int s_readint(s_buff F)
Definition: s_buff.cc:119
int i
Definition: cfEzgcd.cc:123
#define IDELEMS(i)
Definition: simpleideals.h:24
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:38

§ ssiReadInt()

int ssiReadInt ( s_buff  fich)

Definition at line 385 of file ssiLink.cc.

386 {
387  return s_readint(fich);
388 }
int s_readint(s_buff F)
Definition: s_buff.cc:119

§ ssiReadIntmat()

intvec* ssiReadIntmat ( const ssiInfo d)

Definition at line 691 of file ssiLink.cc.

692 {
693  int r,c;
694  r=s_readint(d->f_read);
695  c=s_readint(d->f_read);
696  intvec *v=new intvec(r,c,0);
697  for(int i=0;i<r*c;i++)
698  {
699  (*v)[i]=s_readint(d->f_read);
700  }
701  return v;
702 }
const ring r
Definition: syzextra.cc:208
Definition: intvec.h:14
int s_readint(s_buff F)
Definition: s_buff.cc:119
int i
Definition: cfEzgcd.cc:123
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37

§ ssiReadIntvec()

intvec* ssiReadIntvec ( const ssiInfo d)

Definition at line 680 of file ssiLink.cc.

681 {
682  int nr;
683  nr=s_readint(d->f_read);
684  intvec *v=new intvec(nr);
685  for(int i=0;i<nr;i++)
686  {
687  (*v)[i]=s_readint(d->f_read);
688  }
689  return v;
690 }
Definition: intvec.h:14
int s_readint(s_buff F)
Definition: s_buff.cc:119
int i
Definition: cfEzgcd.cc:123
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37

§ ssiReadList()

lists ssiReadList ( si_link  l)

Definition at line 662 of file ssiLink.cc.

663 {
664  ssiInfo *d=(ssiInfo*)l->data;
665  int nr;
666  nr=s_readint(d->f_read);
667  lists L=(lists)omAlloc(sizeof(*L));
668  L->Init(nr);
669 
670  int i;
671  leftv v;
672  for(i=0;i<nr;i++)
673  {
674  v=ssiRead1(l);
675  memcpy(&(L->m[i]),v,sizeof(*v));
677  }
678  return L;
679 }
sleftv * m
Definition: lists.h:45
Class used for (list of) interpreter objects.
Definition: subexpr.h:84
Definition: lists.h:22
#define omAlloc(size)
Definition: omAllocDecl.h:210
int s_readint(s_buff F)
Definition: s_buff.cc:119
omBin sleftv_bin
Definition: subexpr.cc:50
int i
Definition: cfEzgcd.cc:123
INLINE_THIS void Init(int l=0)
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
slists * lists
Definition: mpr_numeric.h:146
#define omFreeBin(addr, bin)
Definition: omAllocDecl.h:259
int l
Definition: cfEzgcd.cc:94

§ ssiReadMatrix()

matrix ssiReadMatrix ( const ssiInfo d)

Definition at line 590 of file ssiLink.cc.

591 {
592  int n,m;
593  m=s_readint(d->f_read);
594  n=s_readint(d->f_read);
595  matrix M=mpNew(m,n);
596  poly p;
597  for(int i=1;i<=MATROWS(M);i++)
598  for(int j=1;j<=MATCOLS(M);j++)
599  {
600  p=ssiReadPoly(d);
601  MATELEM(M,i,j)=p;
602  }
603  return M;
604 }
return P p
Definition: myNF.cc:203
#define M
Definition: sirandom.c:24
int s_readint(s_buff F)
Definition: s_buff.cc:119
int j
Definition: myNF.cc:70
int m
Definition: cfEzgcd.cc:119
int i
Definition: cfEzgcd.cc:123
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:48
#define MATCOLS(i)
Definition: matpol.h:28
#define MATROWS(i)
Definition: matpol.h:27
polyrec * poly
Definition: hilb.h:10
#define MATELEM(mat, i, j)
Definition: matpol.h:29

§ ssiReadNumber()

number ssiReadNumber ( const ssiInfo d)

Definition at line 424 of file ssiLink.cc.

425 {
426  return ssiReadNumber_CF(d,d->r->cf);
427 }

§ ssiReadNumber_CF()

number ssiReadNumber_CF ( const ssiInfo d,
const coeffs  cf 
)

Definition at line 390 of file ssiLink.cc.

391 {
392  if (cf->cfReadFd!=NULL)
393  {
394  return n_ReadFd(d->f_read,cf);
395  }
396  else if (getCoeffType(cf) == n_transExt)
397  {
398  // poly poly
399  fraction f=(fraction)n_Init(1,cf);
400  p_Delete(&NUM(f),cf->extRing);
401  NUM(f)=ssiReadPoly_R(d,cf->extRing);
402  DEN(f)=ssiReadPoly_R(d,cf->extRing);
403  return (number)f;
404  }
405  else if (getCoeffType(cf) == n_algExt)
406  {
407  // poly
408  return (number)ssiReadPoly_R(d,cf->extRing);
409  }
410  else WerrorS("coeffs not implemented in ssiReadNumber");
411  return NULL;
412 }
used for all transcendental extensions, i.e., the top-most extension in an extension tower is transce...
Definition: coeffs.h:39
static FORCE_INLINE number n_ReadFd(s_buff f, const coeffs r)
io via ssi:
Definition: coeffs.h:988
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition: coeffs.h:542
void WerrorS(const char *s)
Definition: feFopen.cc:24
FILE * f
Definition: checklibs.c:7
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:425
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:843
#define NULL
Definition: omList.c:10
used for all algebraic extensions, i.e., the top-most extension in an extension tower is algebraic ...
Definition: coeffs.h:36

§ ssiReadPoly()

poly ssiReadPoly ( const ssiInfo D)

Definition at line 566 of file ssiLink.cc.

567 {
568 // < # of terms> < term1> < .....
569  return ssiReadPoly_R(D,D->r);
570 }

§ ssiReadPoly_R()

poly ssiReadPoly_R ( const ssiInfo D,
const ring  r 
)

Definition at line 535 of file ssiLink.cc.

536 {
537 // < # of terms> < term1> < .....
538  int n,i,l;
539  n=ssiReadInt(D->f_read); // # of terms
540  //Print("poly: terms:%d\n",n);
541  poly p;
542  poly ret=NULL;
543  poly prev=NULL;
544  for(l=0;l<n;l++) // read n terms
545  {
546 // coef,comp.exp1,..exp N
547  p=p_Init(r);
548  pSetCoeff0(p,ssiReadNumber_CF(D,r->cf));
549  int d;
550  d=s_readint(D->f_read);
551  p_SetComp(p,d,r);
552  for(i=1;i<=rVar(r);i++)
553  {
554  d=s_readint(D->f_read);
555  p_SetExp(p,i,d,r);
556  }
557  p_Setm(p,r);
558  p_Test(p,r);
559  if (ret==NULL) ret=p;
560  else pNext(prev)=p;
561  prev=p;
562  }
563  return ret;
564 }
return P p
Definition: myNF.cc:203
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition: p_polys.h:242
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:580
const ring r
Definition: syzextra.cc:208
int s_readint(s_buff F)
Definition: s_buff.cc:119
int i
Definition: cfEzgcd.cc:123
#define p_Test(p, r)
Definition: p_polys.h:160
static unsigned long p_SetExp(poly p, const unsigned long e, const unsigned long iBitmask, const int VarOffset)
set a single variable exponent : VarOffset encodes the position in p->exp
Definition: p_polys.h:483
#define NULL
Definition: omList.c:10
#define pNext(p)
Definition: monomials.h:43
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:228
#define pSetCoeff0(p, n)
Definition: monomials.h:67
polyrec * poly
Definition: hilb.h:10
static poly p_Init(const ring r, omBin bin)
Definition: p_polys.h:1243
int l
Definition: cfEzgcd.cc:94

§ ssiReadProc()

procinfov ssiReadProc ( const ssiInfo d)

Definition at line 652 of file ssiLink.cc.

653 {
654  char *s=ssiReadString(d);
657  p->libname=omStrDup("");
658  p->procname=omStrDup("");
659  p->data.s.body=s;
660  return p;
661 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
return P p
Definition: myNF.cc:203
language_defs language
Definition: subexpr.h:59
omBin procinfo_bin
Definition: subexpr.cc:51
char * procname
Definition: subexpr.h:57
char * libname
Definition: subexpr.h:56
procinfodata data
Definition: subexpr.h:63
#define omAlloc0Bin(bin)
Definition: omAllocDecl.h:206
procinfo * procinfov
Definition: structs.h:63
#define omStrDup(s)
Definition: omAllocDecl.h:263

§ ssiReadRing()

ring ssiReadRing ( const ssiInfo d)

Definition at line 429 of file ssiLink.cc.

430 {
431 /* syntax is <ch> <N> <l1> <v1> ...<lN> <vN> <number of orderings> <ord1> <block0_1> <block1_1> .... <Q-ideal> */
432  int ch, N,i;
433  char **names;
434  ch=s_readint(d->f_read);
435  N=s_readint(d->f_read);
436  coeffs cf=NULL;
437  if (ch==-3)
438  {
439  char *cf_name=ssiReadString(d);
440  cf=nFindCoeffByName(cf_name);
441  if (cf==NULL)
442  { Werror("cannot find cf:%s",cf_name);return NULL;}
443  }
444  if (N!=0)
445  {
446  names=(char**)omAlloc(N*sizeof(char*));
447  for(i=0;i<N;i++)
448  {
449  names[i]=ssiReadString(d);
450  }
451  }
452  // read the orderings:
453  int num_ord; // number of orderings
454  num_ord=s_readint(d->f_read);
455  int *ord=(int *)omAlloc0((num_ord+1)*sizeof(int));
456  int *block0=(int *)omAlloc0((num_ord+1)*sizeof(int));
457  int *block1=(int *)omAlloc0((num_ord+1)*sizeof(int));
458  int **wvhdl=(int**)omAlloc0((num_ord+1)*sizeof(int*));
459  for(i=0;i<num_ord;i++)
460  {
461  ord[i]=s_readint(d->f_read);
462  block0[i]=s_readint(d->f_read);
463  block1[i]=s_readint(d->f_read);
464  switch(ord[i])
465  {
466  case ringorder_a:
467  case ringorder_wp:
468  case ringorder_Wp:
469  case ringorder_ws:
470  case ringorder_Ws:
471  case ringorder_aa:
472  {
473  wvhdl[i]=(int*)omAlloc((block1[i]-block0[i]+1)*sizeof(int));
474  int ii;
475  for(ii=block0[i];ii<=block1[i];ii++)
476  wvhdl[i][ii-block0[i]]=s_readint(d->f_read);
477  }
478  break;
479 
480  case ringorder_a64:
481  case ringorder_M:
482  case ringorder_L:
483  case ringorder_IS:
484  Werror("ring oder not implemented for ssi:%d",ord[i]);
485  break;
486 
487  default: break;
488  }
489  }
490  if (N==0)
491  {
492  omFree(ord);
493  omFree(block0);
494  omFree(block1);
495  omFree(wvhdl);
496  return NULL;
497  }
498  else
499  {
500  ring r=NULL;
501  if (ch>=0) /* Q, Z/p */
502  r=rDefault(ch,N,names,num_ord,ord,block0,block1,wvhdl);
503  else if (ch==-1) /* trans ext. */
504  {
505  TransExtInfo T;
506  T.r=ssiReadRing(d);
507  if (T.r==NULL) return NULL;
508  cf=nInitChar(n_transExt,&T);
509  r=rDefault(cf,N,names,num_ord,ord,block0,block1,wvhdl);
510  }
511  else if (ch==-2) /* alg ext. */
512  {
513  TransExtInfo T;
514  T.r=ssiReadRing(d); /* includes qideal */
515  if (T.r==NULL) return NULL;
516  cf=nInitChar(n_algExt,&T);
517  r=rDefault(cf,N,names,num_ord,ord,block0,block1,wvhdl);
518  }
519  else if (ch==-3)
520  {
521  r=rDefault(cf,N,names,num_ord,ord,block0,block1,wvhdl);
522  }
523  else
524  {
525  Werror("ssi: read unknown coeffs type (%d)",ch);
526  return NULL;
527  }
528  ideal q=ssiReadIdeal_R(d,r);
529  if (IDELEMS(q)==0) omFreeBin(q,sip_sideal_bin);
530  else r->qideal=q;
531  return r;
532  }
533 }
for idElimination, like a, except pFDeg, pWeigths ignore it
Definition: ring.h:99
for int64 weights
Definition: ring.h:79
coeffs nFindCoeffByName(const char *cf_name)
find an existing coeff by its "CoeffName"
Definition: numbers.cc:549
used for all transcendental extensions, i.e., the top-most extension in an extension tower is transce...
Definition: coeffs.h:39
omBin sip_sideal_bin
Definition: simpleideals.cc:30
#define omAlloc(size)
Definition: omAllocDecl.h:210
const ring r
Definition: syzextra.cc:208
const CanonicalForm CFMap CFMap & N
Definition: cfEzgcd.cc:49
int s_readint(s_buff F)
Definition: s_buff.cc:119
#define omFree(addr)
Definition: omAllocDecl.h:261
The main handler for Singular numbers which are suitable for Singular polynomials.
ring rDefault(const coeffs cf, int N, char **n, int ord_size, int *ord, int *block0, int *block1, int **wvhdl)
Definition: ring.cc:113
struct for passing initialization parameters to naInitChar
Definition: transext.h:92
int i
Definition: cfEzgcd.cc:123
Induced (Schreyer) ordering.
Definition: ring.h:101
#define IDELEMS(i)
Definition: simpleideals.h:24
CanonicalForm cf
Definition: cfModGcd.cc:4024
#define NULL
Definition: omList.c:10
used for all algebraic extensions, i.e., the top-most extension in an extension tower is algebraic ...
Definition: coeffs.h:36
static jList * T
Definition: janet.cc:37
#define omFreeBin(addr, bin)
Definition: omAllocDecl.h:259
void Werror(const char *fmt,...)
Definition: reporter.cc:189
#define omAlloc0(size)
Definition: omAllocDecl.h:211
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
Definition: numbers.cc:329

§ ssiReadString()

char* ssiReadString ( const ssiInfo d)

Definition at line 372 of file ssiLink.cc.

373 {
374  char *buf;
375  int l;
376  l=s_readint(d->f_read);
377  buf=(char*)omAlloc0(l+1);
378  int c =s_getc(d->f_read); /* skip ' '*/
379  int ll=s_readbytes(buf,l,d->f_read);
380  //if (ll!=l) printf("want %d, got %d bytes\n",l,ll);
381  buf[l]='\0';
382  return buf;
383 }
int s_readbytes(char *buff, int len, s_buff F)
Definition: s_buff.cc:175
int s_getc(s_buff F)
Definition: s_buff.cc:65
int s_readint(s_buff F)
Definition: s_buff.cc:119
int status int void * buf
Definition: si_signals.h:59
#define omAlloc0(size)
Definition: omAllocDecl.h:211
int l
Definition: cfEzgcd.cc:94

§ ssiReservePort()

int ssiReservePort ( int  clients)

Definition at line 1815 of file ssiLink.cc.

1816 {
1817  if (ssiReserved_P!=0)
1818  {
1819  WerrorS("ERROR already a reverved port requested");
1820  return 0;
1821  }
1822  int portno;
1823  ssiReserved_sockfd = socket(AF_INET, SOCK_STREAM, 0);
1824  if(ssiReserved_sockfd < 0)
1825  {
1826  WerrorS("ERROR opening socket");
1827  return 0;
1828  }
1829  memset((char *) &ssiResverd_serv_addr,0, sizeof(ssiResverd_serv_addr));
1830  portno = 1025;
1831  ssiResverd_serv_addr.sin_family = AF_INET;
1832  ssiResverd_serv_addr.sin_addr.s_addr = INADDR_ANY;
1833  do
1834  {
1835  portno++;
1836  ssiResverd_serv_addr.sin_port = htons(portno);
1837  if(portno > 50000)
1838  {
1839  WerrorS("ERROR on binding (no free port available?)");
1840  return 0;
1841  }
1842  }
1843  while(bind(ssiReserved_sockfd, (struct sockaddr *) &ssiResverd_serv_addr, sizeof(ssiResverd_serv_addr)) < 0);
1844  ssiReserved_P=portno;
1845  listen(ssiReserved_sockfd,clients);
1846  ssiReserved_Clients=clients;
1847  return portno;
1848 }
void WerrorS(const char *s)
Definition: feFopen.cc:24

§ ssiSetCurrRing()

void ssiSetCurrRing ( const ring  r)

Definition at line 80 of file ssiLink.cc.

81 {
82  // if (currRing!=NULL)
83  // Print("need to change the ring, currRing:%s, switch to: ssiRing%d\n",IDID(currRingHdl),nr);
84  // else
85  // Print("no ring, switch to ssiRing%d\n",nr);
86  if (!rEqual(r,currRing,1))
87  {
88  char name[20];
89  int nr=0;
90  do
91  { sprintf(name,"ssiRing%d",nr); nr++; }
92  while(IDROOT->get(name, 0)!=NULL);
94  IDRING(h)=r;
95  r->ref++;
96  rSetHdl(h);
97  }
98 }
#define FALSE
Definition: auxiliary.h:97
#define IDROOT
Definition: ipid.h:20
Definition: idrec.h:34
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:259
const ring r
Definition: syzextra.cc:208
char name(const Variable &v)
Definition: factory.h:178
BOOLEAN rEqual(ring r1, ring r2, BOOLEAN qr)
returns TRUE, if r1 equals r2 FALSE, otherwise Equality is determined componentwise, if qr == 1, then qrideal equality is tested, as well
Definition: ring.cc:1634
#define NULL
Definition: omList.c:10
#define IDRING(a)
Definition: ipid.h:124
void rSetHdl(idhdl h)
Definition: ipshell.cc:5017
static Poly * h
Definition: janet.cc:978
#define omStrDup(s)
Definition: omAllocDecl.h:263

§ ssiSetRing()

BOOLEAN ssiSetRing ( si_link  l,
ring  r,
BOOLEAN  send 
)

Definition at line 1383 of file ssiLink.cc.

1384 {
1385  if(SI_LINK_W_OPEN_P(l)==0)
1386  if (slOpen(l,SI_LINK_OPEN|SI_LINK_WRITE,NULL)) return TRUE;
1387  ssiInfo *d = (ssiInfo *)l->data;
1388  if (d->r!=r)
1389  {
1390  if (send)
1391  {
1392  fputs("15 ",d->f_write);
1393  ssiWriteRing(d,r);
1394  }
1395  d->r=r;
1396  }
1397  if (currRing!=r) rChangeCurrRing(r);
1398  return FALSE;
1399 }
if(0 > strat->sl)
Definition: myNF.cc:73
#define FALSE
Definition: auxiliary.h:97
#define TRUE
Definition: auxiliary.h:101
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:10
const ring r
Definition: syzextra.cc:208
void rChangeCurrRing(ring r)
Definition: polys.cc:12
#define NULL
Definition: omList.c:10
int l
Definition: cfEzgcd.cc:94

§ ssiWrite()

BOOLEAN ssiWrite ( si_link  l,
leftv  data 
)

Definition at line 1402 of file ssiLink.cc.

1403 {
1404  if(SI_LINK_W_OPEN_P(l)==0)
1405  if (slOpen(l,SI_LINK_OPEN|SI_LINK_WRITE,NULL)) return TRUE;
1406  ssiInfo *d = (ssiInfo *)l->data;
1407  d->level++;
1408  //FILE *fich=d->f;
1409  while (data!=NULL)
1410  {
1411  int tt=data->Typ();
1412  void *dd=data->Data();
1413  attr *aa=data->Attribute();
1414  BOOLEAN with_attr=FALSE;
1415  if (((*aa)!=NULL)||(data->flag!=0))
1416  {
1417  attr a=*aa;
1418  int n=0;
1419  while(a!=NULL) { n++; a=a->next;}
1420  fprintf(d->f_write,"21 %d %d ",data->flag,n);
1421  a=*aa;
1422  }
1423  if ((dd==NULL) && (data->name!=NULL) && (tt==0)) tt=DEF_CMD;
1424  // return pure undefined names as def
1425 
1426  switch(tt /*data->Typ()*/)
1427  {
1428  case 0: /*error*/
1429  case NONE/* nothing*/:fputs("16 ",d->f_write);
1430  break;
1431  case STRING_CMD: fputs("2 ",d->f_write);
1432  ssiWriteString(d,(char *)dd);
1433  break;
1434  case INT_CMD: fputs("1 ",d->f_write);
1435  ssiWriteInt(d,(int)(long)dd);
1436  break;
1437  case BIGINT_CMD:fputs("4 ",d->f_write);
1438  ssiWriteBigInt(d,(number)dd);
1439  break;
1440  case NUMBER_CMD:
1441  if (d->r!=currRing)
1442  {
1443  fputs("15 ",d->f_write);
1445  if (d->level<=1) fputc('\n',d->f_write);
1446  }
1447  fputs("3 ",d->f_write);
1448  ssiWriteNumber(d,(number)dd);
1449  break;
1450  case RING_CMD:fputs("5 ",d->f_write);
1451  ssiWriteRing(d,(ring)dd);
1452  break;
1453  case POLY_CMD:
1454  case VECTOR_CMD:
1455  if (d->r!=currRing)
1456  {
1457  fputs("15 ",d->f_write);
1459  if (d->level<=1) fputc('\n',d->f_write);
1460  }
1461  if(tt==POLY_CMD) fputs("6 ",d->f_write);
1462  else fputs("9 ",d->f_write);
1463  ssiWritePoly(d,tt,(poly)dd);
1464  break;
1465  case IDEAL_CMD:
1466  case MODUL_CMD:
1467  case MATRIX_CMD:
1468  if (d->r!=currRing)
1469  {
1470  fputs("15 ",d->f_write);
1472  if (d->level<=1) fputc('\n',d->f_write);
1473  }
1474  if(tt==IDEAL_CMD) fputs("7 ",d->f_write);
1475  else if(tt==MATRIX_CMD) fputs("8 ",d->f_write);
1476  else
1477  {
1478  ideal M=(ideal)dd;
1479  fprintf(d->f_write,"10 %d ",(int)M->rank);
1480  }
1481  ssiWriteIdeal(d,tt,(ideal)dd);
1482  break;
1483  case COMMAND:
1484  fputs("11 ",d->f_write);
1485  ssiWriteCommand(l,(command)dd);
1486  break;
1487  case DEF_CMD: /* not evaluated stuff in quotes */
1488  fputs("12 ",d->f_write);
1489  ssiWriteString(d,data->Name());
1490  break;
1491  case PROC_CMD:
1492  fputs("13 ",d->f_write);
1493  ssiWriteProc(d,(procinfov)dd);
1494  break;
1495  case LIST_CMD:
1496  fputs("14 ",d->f_write);
1497  ssiWriteList(l,(lists)dd);
1498  break;
1499  case INTVEC_CMD:
1500  fputs("17 ",d->f_write);
1501  ssiWriteIntvec(d,(intvec *)dd);
1502  break;
1503  case INTMAT_CMD:
1504  fputs("18 ",d->f_write);
1505  ssiWriteIntmat(d,(intvec *)dd);
1506  break;
1507  case BIGINTMAT_CMD:
1508  fputs("19 ",d->f_write);
1509  ssiWriteBigintmat(d,(bigintmat *)dd);
1510  break;
1511  default:
1512  if (tt>MAX_TOK)
1513  {
1514  blackbox *b=getBlackboxStuff(tt);
1515  fputs("20 ",d->f_write);
1516  b->blackbox_serialize(b,dd,l);
1517  }
1518  else
1519  {
1520  Werror("not implemented (t:%d, rtyp:%d)",tt, data->rtyp);
1521  d->level=0;
1522  return TRUE;
1523  }
1524  break;
1525  }
1526  if (d->level<=1) { fputc('\n',d->f_write); fflush(d->f_write); }
1527  data=data->next;
1528  }
1529  d->level--;
1530  return FALSE;
1531 }
ip_command * command
Definition: ipid.h:24
const poly a
Definition: syzextra.cc:212
Definition: tok.h:94
Definition: attrib.h:15
BITSET flag
Definition: subexpr.h:92
Definition: lists.h:22
#define FALSE
Definition: auxiliary.h:97
attr * Attribute()
Definition: subexpr.cc:1376
Definition: tok.h:38
Matrices of numbers.
Definition: bigintmat.h:51
Definition: tok.h:213
#define TRUE
Definition: auxiliary.h:101
int Typ()
Definition: subexpr.cc:979
const char * Name()
Definition: subexpr.h:122
#define M
Definition: sirandom.c:24
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:10
Definition: intvec.h:14
Definition: tok.h:57
const char * name
Definition: subexpr.h:89
while(1)
Definition: libparse.cc:1442
Definition: tok.h:99
leftv next
Definition: subexpr.h:88
#define NULL
Definition: omList.c:10
attr next
Definition: attrib.h:21
int rtyp
Definition: subexpr.h:93
void * Data()
Definition: subexpr.cc:1121
Definition: tok.h:116
polyrec * poly
Definition: hilb.h:10
int BOOLEAN
Definition: auxiliary.h:88
const poly b
Definition: syzextra.cc:213
#define NONE
Definition: tok.h:216
void Werror(const char *fmt,...)
Definition: reporter.cc:189
int l
Definition: cfEzgcd.cc:94
#define COMMAND
Definition: tok.h:29
blackbox * getBlackboxStuff(const int t)
return the structure to the type given by t
Definition: blackbox.cc:16

§ ssiWriteBigInt()

void ssiWriteBigInt ( const ssiInfo d,
const number  n 
)

Definition at line 112 of file ssiLink.cc.

113 {
115 }
coeffs coeffs_BIGINT
Definition: ipid.cc:54
static FORCE_INLINE void n_WriteFd(number a, FILE *f, const coeffs r)
io via ssi:
Definition: coeffs.h:984

§ ssiWriteBigintmat()

void ssiWriteBigintmat ( const ssiInfo d,
bigintmat v 
)

Definition at line 362 of file ssiLink.cc.

363 {
364  fprintf(d->f_write,"%d %d ",v->rows(),v->cols());
365  int i;
366  for(i=0;i<v->length();i++)
367  {
368  ssiWriteBigInt(d,(*v)[i]);
369  }
370 }
int rows() const
Definition: bigintmat.h:146
int length()
Definition: bigintmat.h:144
int cols() const
Definition: bigintmat.h:145
int i
Definition: cfEzgcd.cc:123

§ ssiWriteCommand()

void ssiWriteCommand ( si_link  l,
command  D 
)

Definition at line 309 of file ssiLink.cc.

310 {
311  ssiInfo *d=(ssiInfo*)l->data;
312  // syntax: <num ops> <operation> <op1> <op2> ....
313  fprintf(d->f_write,"%d %d ",D->argc,D->op);
314  if (D->argc >0) ssiWrite(l, &(D->arg1));
315  if (D->argc < 4)
316  {
317  if (D->argc >1) ssiWrite(l, &(D->arg2));
318  if (D->argc >2) ssiWrite(l, &(D->arg3));
319  }
320 }
#define D(A)
Definition: gentable.cc:119
int l
Definition: cfEzgcd.cc:94

§ ssiWriteIdeal()

void ssiWriteIdeal ( const ssiInfo d,
int  typ,
const ideal  I 
)

Definition at line 304 of file ssiLink.cc.

305 {
306  ssiWriteIdeal_R(d,typ,I,d->r);
307 }

§ ssiWriteIdeal_R()

void ssiWriteIdeal_R ( const ssiInfo d,
int  typ,
const ideal  I,
const ring  r 
)

Definition at line 277 of file ssiLink.cc.

278 {
279  // syntax: 7 # of elements <poly 1> <poly2>.....
280  // syntax: 8 <rows> <cols> <poly 1> <poly2>.....
281  matrix M=(matrix)I;
282  int mn;
283  if (typ==MATRIX_CMD)
284  {
285  mn=MATROWS(M)*MATCOLS(M);
286  fprintf(d->f_write,"%d %d ", MATROWS(M),MATCOLS(M));
287  }
288  else
289  {
290  mn=IDELEMS(I);
291  fprintf(d->f_write,"%d ",IDELEMS(I));
292  }
293 
294  int i;
295  int tt;
296  if (typ==MODUL_CMD) tt=VECTOR_CMD;
297  else tt=POLY_CMD;
298 
299  for(i=0;i<mn;i++)
300  {
301  ssiWritePoly_R(d,tt,I->m[i],R);
302  }
303 }
#define M
Definition: sirandom.c:24
const ring R
Definition: DebugPrint.cc:36
ip_smatrix * matrix
int i
Definition: cfEzgcd.cc:123
#define IDELEMS(i)
Definition: simpleideals.h:24
#define MATCOLS(i)
Definition: matpol.h:28
#define MATROWS(i)
Definition: matpol.h:27

§ ssiWriteInt()

void ssiWriteInt ( const ssiInfo d,
const int  i 
)

Definition at line 100 of file ssiLink.cc.

101 {
102  fprintf(d->f_write,"%d ",i);
103  //if (d->f_debug!=NULL) fprintf(d->f_debug,"int: %d ",i);
104 }
int i
Definition: cfEzgcd.cc:123

§ ssiWriteIntmat()

void ssiWriteIntmat ( const ssiInfo d,
intvec v 
)

Definition at line 352 of file ssiLink.cc.

353 {
354  fprintf(d->f_write,"%d %d ",v->rows(),v->cols());
355  int i;
356  for(i=0;i<v->length();i++)
357  {
358  fprintf(d->f_write,"%d ",(*v)[i]);
359  }
360 }
int rows() const
Definition: intvec.h:88
int i
Definition: cfEzgcd.cc:123
int length() const
Definition: intvec.h:86
int cols() const
Definition: intvec.h:87

§ ssiWriteIntvec()

void ssiWriteIntvec ( const ssiInfo d,
intvec v 
)

Definition at line 343 of file ssiLink.cc.

344 {
345  fprintf(d->f_write,"%d ",v->length());
346  int i;
347  for(i=0;i<v->length();i++)
348  {
349  fprintf(d->f_write,"%d ",(*v)[i]);
350  }
351 }
int i
Definition: cfEzgcd.cc:123
int length() const
Definition: intvec.h:86

§ ssiWriteList()

void ssiWriteList ( si_link  l,
lists  dd 
)

Definition at line 332 of file ssiLink.cc.

333 {
334  ssiInfo *d=(ssiInfo*)l->data;
335  int Ll=lSize(dd);
336  fprintf(d->f_write,"%d ",Ll+1);
337  int i;
338  for(i=0;i<=Ll;i++)
339  {
340  ssiWrite(l,&(dd->m[i]));
341  }
342 }
sleftv * m
Definition: lists.h:45
int i
Definition: cfEzgcd.cc:123
int lSize(lists L)
Definition: lists.cc:25
int l
Definition: cfEzgcd.cc:94

§ ssiWriteNumber()

void ssiWriteNumber ( const ssiInfo d,
const number  n 
)

Definition at line 145 of file ssiLink.cc.

146 {
147  ssiWriteNumber_CF(d,n,d->r->cf);
148 }

§ ssiWriteNumber_CF()

void ssiWriteNumber_CF ( const ssiInfo d,
const number  n,
const coeffs  cf 
)

Definition at line 117 of file ssiLink.cc.

118 {
119  // syntax is as follows:
120  // case 1 Z/p: 3 <int>
121  // case 2 Q: 3 4 <int>
122  // or 3 0 <mpz_t nominator> <mpz_t denominator>
123  // or 3 1 dto.
124  // or 3 3 <mpz_t nominator>
125  // or 3 5 <mpz_t raw nom.> <mpz_t raw denom.>
126  // or 3 6 <mpz_t raw nom.> <mpz_t raw denom.>
127  // or 3 8 <mpz_t raw nom.>
128  if (getCoeffType(cf)==n_transExt)
129  {
130  fraction f=(fraction)n;
131  ssiWritePoly_R(d,POLY_CMD,NUM(f),cf->extRing);
132  ssiWritePoly_R(d,POLY_CMD,DEN(f),cf->extRing);
133  }
134  else if (getCoeffType(cf)==n_algExt)
135  {
136  ssiWritePoly_R(d,POLY_CMD,(poly)n,cf->extRing);
137  }
138  else if (cf->cfWriteFd!=NULL)
139  {
140  n_WriteFd(n,d->f_write,cf);
141  }
142  else WerrorS("coeff field not implemented");
143 }
used for all transcendental extensions, i.e., the top-most extension in an extension tower is transce...
Definition: coeffs.h:39
void WerrorS(const char *s)
Definition: feFopen.cc:24
FILE * f
Definition: checklibs.c:7
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:425
static FORCE_INLINE void n_WriteFd(number a, FILE *f, const coeffs r)
io via ssi:
Definition: coeffs.h:984
#define NULL
Definition: omList.c:10
used for all algebraic extensions, i.e., the top-most extension in an extension tower is algebraic ...
Definition: coeffs.h:36
polyrec * poly
Definition: hilb.h:10

§ ssiWritePoly()

void ssiWritePoly ( const ssiInfo d,
int  typ,
poly  p 
)

Definition at line 272 of file ssiLink.cc.

273 {
274  ssiWritePoly_R(d,typ,p,d->r);
275 }
return P p
Definition: myNF.cc:203

§ ssiWritePoly_R()

void ssiWritePoly_R ( const ssiInfo d,
int  typ,
poly  p,
const ring  r 
)

Definition at line 254 of file ssiLink.cc.

255 {
256  fprintf(d->f_write,"%d ",pLength(p));//number of terms
257 
258  while(p!=NULL)
259  {
260  ssiWriteNumber_CF(d,pGetCoeff(p),r->cf);
261  //nWrite(fich,pGetCoeff(p));
262  fprintf(d->f_write,"%ld ",p_GetComp(p,r));//component
263 
264  for(int j=1;j<=rVar(r);j++)
265  {
266  fprintf(d->f_write,"%ld ",p_GetExp(p,j,r ));//x^j
267  }
268  pIter(p);
269  }
270 }
return P p
Definition: myNF.cc:203
#define p_GetComp(p, r)
Definition: monomials.h:72
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:580
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy ...
Definition: monomials.h:51
static int pLength(poly a)
Definition: p_polys.h:189
#define pIter(p)
Definition: monomials.h:44
const ring r
Definition: syzextra.cc:208
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent : the integer VarOffset encodes:
Definition: p_polys.h:464
int j
Definition: myNF.cc:70
#define NULL
Definition: omList.c:10

§ ssiWriteProc()

void ssiWriteProc ( const ssiInfo d,
procinfov  p 
)

Definition at line 322 of file ssiLink.cc.

323 {
324  if (p->data.s.body==NULL)
326  if (p->data.s.body!=NULL)
327  ssiWriteString(d,p->data.s.body);
328  else
329  ssiWriteString(d,"");
330 }
procinfodata data
Definition: subexpr.h:63
#define NULL
Definition: omList.c:10
char * iiGetLibProcBuffer(procinfo *pi, int part)
Definition: iplib.cc:210

§ ssiWriteRing()

void ssiWriteRing ( ssiInfo d,
const ring  r 
)

Definition at line 232 of file ssiLink.cc.

233 {
234  /* 5 <ch> <N> <l1> <v1> ...<lN> <vN> <number of orderings> <ord1> <block0_1> <block1_1> .... <extRing> <Q-ideal> */
235  /* ch=-1: transext, coeff ring follows */
236  /* ch=-2: algext, coeff ring and minpoly follows */
237  /* ch=-3: cf name follows */
238  if ((r==NULL)||(r->cf==NULL))
239  {
240  WerrorS("undefined ring");
241  return;
242  }
243  if (r==currRing) // see recursive calls for transExt/algExt
244  {
245  if (d->r!=NULL) rKill(d->r);
246  d->r=r;
247  }
248  if (r!=NULL)
249  {
250  /*d->*/r->ref++;
251  }
252  ssiWriteRing_R(d,r);
253 }
void WerrorS(const char *s)
Definition: feFopen.cc:24
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:10
const ring r
Definition: syzextra.cc:208
void rKill(ring r)
Definition: ipshell.cc:6044
#define NULL
Definition: omList.c:10

§ ssiWriteRing_R()

void ssiWriteRing_R ( ssiInfo d,
const ring  r 
)

Definition at line 150 of file ssiLink.cc.

151 {
152  /* 5 <ch> <N> <l1> <v1> ...<lN> <vN> <number of orderings> <ord1> <block0_1> <block1_1> .... <extRing> <Q-ideal> */
153  /* ch=-1: transext, coeff ring follows */
154  /* ch=-2: algext, coeff ring and minpoly follows */
155  /* ch=-3: cf name follows */
156  if (r!=NULL)
157  {
158  if (rField_is_Q(r) || rField_is_Zp(r))
159  fprintf(d->f_write,"%d %d ",n_GetChar(r->cf),r->N);
160  else if (rFieldType(r)==n_transExt)
161  fprintf(d->f_write,"-1 %d ",r->N);
162  else if (rFieldType(r)==n_algExt)
163  fprintf(d->f_write,"-2 %d ",r->N);
164  else /*dummy*/
165  {
166  fprintf(d->f_write,"-3 %d ",r->N);
167  ssiWriteString(d,nCoeffName(r->cf));
168  }
169 
170  int i;
171  for(i=0;i<r->N;i++)
172  {
173  fprintf(d->f_write,"%d %s ",(int)strlen(r->names[i]),r->names[i]);
174  }
175  /* number of orderings:*/
176  i=0;
177  // remember dummy ring: everything 0:
178  if (r->order!=NULL) while (r->order[i]!=0) i++;
179  fprintf(d->f_write,"%d ",i);
180  /* each ordering block: */
181  i=0;
182  if (r->order!=NULL) while(r->order[i]!=0)
183  {
184  fprintf(d->f_write,"%d %d %d ",r->order[i],r->block0[i], r->block1[i]);
185  switch(r->order[i])
186  {
187  case ringorder_a:
188  case ringorder_wp:
189  case ringorder_Wp:
190  case ringorder_ws:
191  case ringorder_Ws:
192  case ringorder_aa:
193  {
194  int ii;
195  for(ii=r->block0[i];ii<=r->block1[i];ii++)
196  fprintf(d->f_write,"%d ",r->wvhdl[i][ii-r->block0[i]]);
197  }
198  break;
199 
200  case ringorder_a64:
201  case ringorder_M:
202  case ringorder_L:
203  case ringorder_IS:
204  Werror("ring oder not implemented for ssi:%d",r->order[i]);
205  break;
206 
207  default: break;
208  }
209  i++;
210  }
211  if ((rFieldType(r)==n_transExt)
212  || (rFieldType(r)==n_algExt))
213  {
214  ssiWriteRing_R(d,r->cf->extRing); /* includes alg.ext if rFieldType(r)==n_algExt */
215  }
216  /* Q-ideal :*/
217  if (r->qideal!=NULL)
218  {
219  ssiWriteIdeal_R(d,IDEAL_CMD,r->qideal,r);
220  }
221  else
222  {
223  fprintf(d->f_write,"0 "/*ideal with 0 entries */);
224  }
225  }
226  else /* dummy ring r==NULL*/
227  {
228  fprintf(d->f_write,"0 0 0 0 "/*,r->ch,r->N, blocks, q-ideal*/);
229  }
230 }
for idElimination, like a, except pFDeg, pWeigths ignore it
Definition: ring.h:99
n_coeffType rFieldType(ring r)
Definition: ring.cc:5110
for int64 weights
Definition: ring.h:79
used for all transcendental extensions, i.e., the top-most extension in an extension tower is transce...
Definition: coeffs.h:39
static FORCE_INLINE int n_GetChar(const coeffs r)
Return the characteristic of the coeff. domain.
Definition: coeffs.h:448
const ring r
Definition: syzextra.cc:208
static FORCE_INLINE char * nCoeffName(const coeffs cf)
Definition: coeffs.h:977
int i
Definition: cfEzgcd.cc:123
Induced (Schreyer) ordering.
Definition: ring.h:101
static BOOLEAN rField_is_Q(const ring r)
Definition: ring.h:501
static BOOLEAN rField_is_Zp(const ring r)
Definition: ring.h:495
#define NULL
Definition: omList.c:10
used for all algebraic extensions, i.e., the top-most extension in an extension tower is algebraic ...
Definition: coeffs.h:36
void Werror(const char *fmt,...)
Definition: reporter.cc:189

§ ssiWriteString()

void ssiWriteString ( const ssiInfo d,
const char *  s 
)

Definition at line 106 of file ssiLink.cc.

107 {
108  fprintf(d->f_write,"%d %s ",(int)strlen(s),s);
109  //if (d->f_debug!=NULL) fprintf(d->f_debug,"stringi: %d \"%s\" ",strlen(s),s);
110 }
const CanonicalForm int s
Definition: facAbsFact.cc:55

Variable Documentation

§ si_link_root

si_link_extension si_link_root

Definition at line 51 of file silink.cc.

§ ssiReserved_Clients

int ssiReserved_Clients
static

Definition at line 1814 of file ssiLink.cc.

§ ssiReserved_P

int ssiReserved_P =0
static

Definition at line 1811 of file ssiLink.cc.

§ ssiReserved_sockfd

int ssiReserved_sockfd
static

Definition at line 1812 of file ssiLink.cc.

§ ssiResverd_serv_addr

struct sockaddr_in ssiResverd_serv_addr
static

Definition at line 1813 of file ssiLink.cc.

§ ssiToBeClosed

link_list ssiToBeClosed =NULL

Definition at line 70 of file ssiLink.cc.

§ ssiToBeClosed_inactive

volatile BOOLEAN ssiToBeClosed_inactive =TRUE

Definition at line 71 of file ssiLink.cc.