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

#define SSI_VERSION   10

Definition at line 62 of file ssiLink.cc.

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

Definition at line 8 of file ssiLink.cc.

Function Documentation

static BOOLEAN DumpSsiIdhdl ( si_link  l,
idhdl  h 
)
static

Definition at line 1963 of file ssiLink.cc.

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

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

Definition at line 1535 of file ssiLink.cc.

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

Definition at line 1552 of file ssiLink.cc.

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

Definition at line 1608 of file ssiLink.cc.

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

Definition at line 1780 of file ssiLink.cc.

1782 {
1784  char *buf=(char*)omAlloc(256);
1785  sprintf(buf,"ssi:connect %s:%s",host,port);
1786  slInit(l, buf);
1787  if (slOpen(l,SI_LINK_OPEN,NULL)) return 1;
1789 
1790  idhdl id = enterid(omStrDup("link_ll"), 0, LINK_CMD, &IDROOT, FALSE);
1791  IDLINK(id) = l;
1792 
1793  loop
1794  {
1795  leftv h=ssiRead1(l); /*contains an exit.... */
1796  if (feErrors != NULL && *feErrors != '\0')
1797  {
1798  // handle errors:
1799  PrintS(feErrors); /* currently quite simple */
1800  *feErrors = '\0';
1801  }
1802  ssiWrite(l,h);
1803  h->CleanUp();
1804  omFreeBin(h, sleftv_bin);
1805  }
1806  /* never reached*/
1807  exit(0);
1808 }
Class used for (list of) interpreter objects.
Definition: subexpr.h:83
#define IDLINK(a)
Definition: ipid.h:137
loop
Definition: myNF.cc:98
#define FALSE
Definition: auxiliary.h:140
#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:294
#define omAlloc0Bin(bin)
Definition: omAllocDecl.h:206
Definition: tok.h:119
#define NULL
Definition: omList.c:10
void CleanUp(ring r=currRing)
Definition: subexpr.cc:321
#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
BOOLEAN ssiClose ( si_link  l)

Definition at line 1138 of file ssiLink.cc.

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

Definition at line 1850 of file ssiLink.cc.

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

Definition at line 2059 of file ssiLink.cc.

2060 {
2061  idhdl h = IDROOT, rh = currRingHdl;
2062  BOOLEAN status = ssiDumpIter(l, h);
2063 
2064  //if (! status ) status = DumpAsciiMaps(fd, h, NULL);
2065 
2066  if (currRingHdl != rh) rSetHdl(rh);
2067  //fprintf(fd, "option(set, intvec(%d, %d));\n", si_opt_1, si_opt_2);
2068 
2069  return status;
2070 }
#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:5030
static Poly * h
Definition: janet.cc:978
int BOOLEAN
Definition: auxiliary.h:131
int l
Definition: cfEzgcd.cc:94
static BOOLEAN ssiDumpIter ( si_link  l,
idhdl  h 
)
static

Definition at line 2038 of file ssiLink.cc.

2039 {
2040  if (h == NULL) return FALSE;
2041 
2042  if (ssiDumpIter(l, IDNEXT(h))) return TRUE;
2043 
2044  // need to set the ring before writing it, otherwise we get in
2045  // trouble with minpoly
2046  if (IDTYP(h) == RING_CMD || IDTYP(h) == QRING_CMD)
2047  rSetHdl(h);
2048 
2049  if (DumpSsiIdhdl(l, h)) return TRUE;
2050 
2051  // do not dump ssi internal rings: ssiRing*
2052  // but dump objects of all other rings
2053  if ((IDTYP(h) == RING_CMD || IDTYP(h) == QRING_CMD)
2054  && (strncmp(IDID(h),"ssiRing",7)!=0))
2055  return ssiDumpIter(l, IDRING(h)->idroot);
2056  else
2057  return FALSE;
2058 }
#define IDID(a)
Definition: ipid.h:121
#define FALSE
Definition: auxiliary.h:140
#define IDNEXT(a)
Definition: ipid.h:117
#define TRUE
Definition: auxiliary.h:144
#define IDTYP(a)
Definition: ipid.h:118
#define NULL
Definition: omList.c:10
#define IDRING(a)
Definition: ipid.h:126
Definition: tok.h:159
void rSetHdl(idhdl h)
Definition: ipshell.cc:5030
int l
Definition: cfEzgcd.cc:94
BOOLEAN ssiGetDump ( si_link  l)

Definition at line 2071 of file ssiLink.cc.

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

Definition at line 753 of file ssiLink.cc.

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

Definition at line 1119 of file ssiLink.cc.

1120 {
1121  if (l!=NULL)
1122  {
1124  ssiInfo *d = (ssiInfo *)l->data;
1125  if (d!=NULL)
1126  {
1127  if (d->send_quit_at_exit)
1128  {
1129  fputs("99\n",d->f_write);
1130  fflush(d->f_write);
1131  }
1132  d->quit_sent=1;
1133  }
1134  }
1135  return FALSE;
1136 }
if(0 > strat->sl)
Definition: myNF.cc:73
#define FALSE
Definition: auxiliary.h:140
#define NULL
Definition: omList.c:10
int l
Definition: cfEzgcd.cc:94
leftv ssiRead1 ( si_link  l)

Definition at line 1232 of file ssiLink.cc.

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

Definition at line 731 of file ssiLink.cc.

732 {
733  ssiInfo *d=(ssiInfo*)l->data;
734  BITSET fl=(BITSET)s_readint(d->f_read);
735  int nr_of_attr=s_readint(d->f_read);
736  if (nr_of_attr>0)
737  {
738  for(int i=1;i<nr_of_attr;i++)
739  {
740  }
741  }
742  leftv tmp=ssiRead1(l);
743  memcpy(res,tmp,sizeof(sleftv));
744  memset(tmp,0,sizeof(sleftv));
745  omFreeSize(tmp,sizeof(sleftv));
746  if (nr_of_attr>0)
747  {
748  }
749  res->flag=fl;
750 }
Class used for (list of) interpreter objects.
Definition: subexpr.h:83
BITSET flag
Definition: subexpr.h:91
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
#define BITSET
Definition: structs.h:17
int s_readint(s_buff F)
Definition: s_buff.cc:120
int i
Definition: cfEzgcd.cc:123
int l
Definition: cfEzgcd.cc:94
number ssiReadBigInt ( const ssiInfo d)

Definition at line 409 of file ssiLink.cc.

410 {
411  number n=ssiReadNumber_CF(d,coeffs_BIGINT);
412  if ((SR_HDL(n) & SR_INT)==0)
413  {
414  if (n->s!=3) Werror("invalid sub type in bigint:%d",n->s);
415  }
416  return n;
417 }
coeffs coeffs_BIGINT
Definition: ipid.cc:54
#define SR_INT
Definition: longrat.h:65
#define SR_HDL(A)
Definition: tgb.cc:35
void Werror(const char *fmt,...)
Definition: reporter.cc:199
bigintmat* ssiReadBigintmat ( const ssiInfo d)

Definition at line 698 of file ssiLink.cc.

699 {
700  int r,c;
701  r=s_readint(d->f_read);
702  c=s_readint(d->f_read);
704  for(int i=0;i<r*c;i++)
705  {
706  (*v)[i]=ssiReadBigInt(d);
707  }
708  return v;
709 }
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:120
int i
Definition: cfEzgcd.cc:123
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
void ssiReadBlackbox ( leftv  res,
si_link  l 
)

Definition at line 711 of file ssiLink.cc.

712 {
713  ssiInfo *d=(ssiInfo*)l->data;
714  int throwaway;
715  throwaway=s_readint(d->f_read);
716  char *name=ssiReadString(d);
717  int tok;
718  blackboxIsCmd(name,tok);
719  if (tok>MAX_TOK)
720  {
721  blackbox *b=getBlackboxStuff(tok);
722  res->rtyp=tok;
723  b->blackbox_deserialize(&b,&(res->data),l);
724  }
725  else
726  {
727  Werror("blackbox %s not found",name);
728  }
729 }
Definition: tok.h:217
void * data
Definition: subexpr.h:89
int s_readint(s_buff F)
Definition: s_buff.cc:120
char name(const Variable &v)
Definition: variable.h:95
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:193
int rtyp
Definition: subexpr.h:92
const poly b
Definition: syzextra.cc:213
void Werror(const char *fmt,...)
Definition: reporter.cc:199
int l
Definition: cfEzgcd.cc:94
blackbox * getBlackboxStuff(const int t)
return the structure to the type given by t
Definition: blackbox.cc:20
command ssiReadCommand ( si_link  l)

Definition at line 601 of file ssiLink.cc.

602 {
603  ssiInfo *d=(ssiInfo*)l->data;
604  // syntax: <num ops> <operation> <op1> <op2> ....
605  command D=(command)omAlloc0(sizeof(*D));
606  int argc,op;
607  argc=s_readint(d->f_read);
608  op=s_readint(d->f_read);
609  D->argc=argc; D->op=op;
610  leftv v;
611  if (argc >0)
612  {
613  v=ssiRead1(l);
614  memcpy(&(D->arg1),v,sizeof(*v));
616  }
617  if (argc <4)
618  {
619  if (D->argc >1)
620  {
621  v=ssiRead1(l);
622  memcpy(&(D->arg2),v,sizeof(*v));
624  }
625  if (D->argc >2)
626  {
627  v=ssiRead1(l);
628  memcpy(&(D->arg3),v,sizeof(*v));
630  }
631  }
632  else
633  {
634  leftv prev=&(D->arg1);
635  argc--;
636  while(argc >0)
637  {
638  v=ssiRead1(l);
639  prev->next=v;
640  prev=v;
641  argc--;
642  }
643  }
644  return D;
645 }
#define D(A)
Definition: gentable.cc:119
Class used for (list of) interpreter objects.
Definition: subexpr.h:83
ip_command * command
Definition: ipid.h:24
int s_readint(s_buff F)
Definition: s_buff.cc:120
omBin sleftv_bin
Definition: subexpr.cc:50
leftv next
Definition: subexpr.h:87
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
ideal ssiReadIdeal ( const ssiInfo d)

Definition at line 580 of file ssiLink.cc.

581 {
582  return ssiReadIdeal_R(d,d->r);
583 }
ideal ssiReadIdeal_R ( const ssiInfo d,
const ring  r 
)

Definition at line 567 of file ssiLink.cc.

568 {
569  int n,i;
570  ideal I;
571  n=s_readint(d->f_read);
572  I=idInit(n,1);
573  for(i=0;i<IDELEMS(I);i++) // read n terms
574  {
575  I->m [i]=ssiReadPoly_R(d,r);
576  }
577  return I;
578 }
const ring r
Definition: syzextra.cc:208
int s_readint(s_buff F)
Definition: s_buff.cc:120
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
int ssiReadInt ( s_buff  fich)

Definition at line 380 of file ssiLink.cc.

381 {
382  return s_readint(fich);
383 }
int s_readint(s_buff F)
Definition: s_buff.cc:120
intvec* ssiReadIntmat ( const ssiInfo d)

Definition at line 686 of file ssiLink.cc.

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

Definition at line 675 of file ssiLink.cc.

676 {
677  int nr;
678  nr=s_readint(d->f_read);
679  intvec *v=new intvec(nr);
680  for(int i=0;i<nr;i++)
681  {
682  (*v)[i]=s_readint(d->f_read);
683  }
684  return v;
685 }
Definition: intvec.h:14
int s_readint(s_buff F)
Definition: s_buff.cc:120
int i
Definition: cfEzgcd.cc:123
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
lists ssiReadList ( si_link  l)

Definition at line 657 of file ssiLink.cc.

658 {
659  ssiInfo *d=(ssiInfo*)l->data;
660  int nr;
661  nr=s_readint(d->f_read);
662  lists L=(lists)omAlloc(sizeof(*L));
663  L->Init(nr);
664 
665  int i;
666  leftv v;
667  for(i=0;i<nr;i++)
668  {
669  v=ssiRead1(l);
670  memcpy(&(L->m[i]),v,sizeof(*v));
672  }
673  return L;
674 }
sleftv * m
Definition: lists.h:45
Class used for (list of) interpreter objects.
Definition: subexpr.h:83
Definition: lists.h:22
#define omAlloc(size)
Definition: omAllocDecl.h:210
int s_readint(s_buff F)
Definition: s_buff.cc:120
omBin sleftv_bin
Definition: subexpr.cc:50
int i
Definition: cfEzgcd.cc:123
INLINE_THIS void Init(int l=0)
Definition: lists.h:66
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
matrix ssiReadMatrix ( const ssiInfo d)

Definition at line 585 of file ssiLink.cc.

586 {
587  int n,m;
588  m=s_readint(d->f_read);
589  n=s_readint(d->f_read);
590  matrix M=mpNew(m,n);
591  poly p;
592  for(int i=1;i<=MATROWS(M);i++)
593  for(int j=1;j<=MATCOLS(M);j++)
594  {
595  p=ssiReadPoly(d);
596  MATELEM(M,i,j)=p;
597  }
598  return M;
599 }
return P p
Definition: myNF.cc:203
#define M
Definition: sirandom.c:24
int s_readint(s_buff F)
Definition: s_buff.cc:120
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
number ssiReadNumber ( const ssiInfo d)

Definition at line 419 of file ssiLink.cc.

420 {
421  return ssiReadNumber_CF(d,d->r->cf);
422 }
number ssiReadNumber_CF ( const ssiInfo d,
const coeffs  cf 
)

Definition at line 385 of file ssiLink.cc.

386 {
387  if (cf->cfReadFd!=NULL)
388  {
389  return n_ReadFd(d->f_read,cf);
390  }
391  else if (getCoeffType(cf) == n_transExt)
392  {
393  // poly poly
394  fraction f=(fraction)n_Init(1,cf);
395  p_Delete(&NUM(f),cf->extRing);
396  NUM(f)=ssiReadPoly_R(d,cf->extRing);
397  DEN(f)=ssiReadPoly_R(d,cf->extRing);
398  return (number)f;
399  }
400  else if (getCoeffType(cf) == n_algExt)
401  {
402  // poly
403  return (number)ssiReadPoly_R(d,cf->extRing);
404  }
405  else Werror("coeffs not implemented in ssiReadNumber");
406  return NULL;
407 }
used for all transcendental extensions, i.e., the top-most extension in an extension tower is transce...
Definition: coeffs.h:38
static FORCE_INLINE number n_ReadFd(s_buff f, const coeffs r)
io via ssi:
Definition: coeffs.h:977
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:539
FILE * f
Definition: checklibs.c:7
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:422
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:849
#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:35
void Werror(const char *fmt,...)
Definition: reporter.cc:199
poly ssiReadPoly ( const ssiInfo D)

Definition at line 561 of file ssiLink.cc.

562 {
563 // < # of terms> < term1> < .....
564  return ssiReadPoly_R(D,D->r);
565 }
poly ssiReadPoly_R ( const ssiInfo D,
const ring  r 
)

Definition at line 530 of file ssiLink.cc.

531 {
532 // < # of terms> < term1> < .....
533  int n,i,l;
534  n=ssiReadInt(D->f_read); // # of terms
535  //Print("poly: terms:%d\n",n);
536  poly p;
537  poly ret=NULL;
538  poly prev=NULL;
539  for(l=0;l<n;l++) // read n terms
540  {
541 // coef,comp.exp1,..exp N
542  p=p_Init(r);
543  pSetCoeff0(p,ssiReadNumber_CF(D,r->cf));
544  int d;
545  d=s_readint(D->f_read);
546  p_SetComp(p,d,r);
547  for(i=1;i<=rVar(r);i++)
548  {
549  d=s_readint(D->f_read);
550  p_SetExp(p,i,d,r);
551  }
552  p_Setm(p,r);
553  p_Test(p,r);
554  if (ret==NULL) ret=p;
555  else pNext(prev)=p;
556  prev=p;
557  }
558  return ret;
559 }
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:537
const ring r
Definition: syzextra.cc:208
int s_readint(s_buff F)
Definition: s_buff.cc:120
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:1249
int l
Definition: cfEzgcd.cc:94
procinfov ssiReadProc ( const ssiInfo d)

Definition at line 647 of file ssiLink.cc.

648 {
649  char *s=ssiReadString(d);
652  p->libname=omStrDup("");
653  p->procname=omStrDup("");
654  p->data.s.body=s;
655  return p;
656 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
return P p
Definition: myNF.cc:203
language_defs language
Definition: subexpr.h:58
omBin procinfo_bin
Definition: subexpr.cc:51
char * procname
Definition: subexpr.h:56
char * libname
Definition: subexpr.h:55
procinfodata data
Definition: subexpr.h:62
#define omAlloc0Bin(bin)
Definition: omAllocDecl.h:206
procinfo * procinfov
Definition: structs.h:63
#define omStrDup(s)
Definition: omAllocDecl.h:263
ring ssiReadRing ( const ssiInfo d)

Definition at line 424 of file ssiLink.cc.

425 {
426 /* syntax is <ch> <N> <l1> <v1> ...<lN> <vN> <number of orderings> <ord1> <block0_1> <block1_1> .... <Q-ideal> */
427  int ch, N,i;
428  char **names;
429  ch=s_readint(d->f_read);
430  N=s_readint(d->f_read);
431  coeffs cf=NULL;
432  if (ch==-3)
433  {
434  char *cf_name=ssiReadString(d);
435  cf=nFindCoeffByName(cf_name);
436  if (cf==NULL)
437  { Werror("cannot find cf:%s",cf_name);return NULL;}
438  }
439  if (N!=0)
440  {
441  names=(char**)omAlloc(N*sizeof(char*));
442  for(i=0;i<N;i++)
443  {
444  names[i]=ssiReadString(d);
445  }
446  }
447  // read the orderings:
448  int num_ord; // number of orderings
449  num_ord=s_readint(d->f_read);
450  int *ord=(int *)omAlloc0((num_ord+1)*sizeof(int));
451  int *block0=(int *)omAlloc0((num_ord+1)*sizeof(int));
452  int *block1=(int *)omAlloc0((num_ord+1)*sizeof(int));
453  int **wvhdl=(int**)omAlloc0((num_ord+1)*sizeof(int*));
454  for(i=0;i<num_ord;i++)
455  {
456  ord[i]=s_readint(d->f_read);
457  block0[i]=s_readint(d->f_read);
458  block1[i]=s_readint(d->f_read);
459  switch(ord[i])
460  {
461  case ringorder_a:
462  case ringorder_wp:
463  case ringorder_Wp:
464  case ringorder_ws:
465  case ringorder_Ws:
466  case ringorder_aa:
467  {
468  wvhdl[i]=(int*)omAlloc((block1[i]-block0[i]+1)*sizeof(int));
469  int ii;
470  for(ii=block0[i];ii<=block1[i];ii++)
471  wvhdl[i][ii-block0[i]]=s_readint(d->f_read);
472  }
473  break;
474 
475  case ringorder_a64:
476  case ringorder_M:
477  case ringorder_L:
478  case ringorder_IS:
479  Werror("ring oder not implemented for ssi:%d",ord[i]);
480  break;
481 
482  default: break;
483  }
484  }
485  if (N==0)
486  {
487  omFree(ord);
488  omFree(block0);
489  omFree(block1);
490  omFree(wvhdl);
491  return NULL;
492  }
493  else
494  {
495  ring r=NULL;
496  if (ch>=0) /* Q, Z/p */
497  r=rDefault(ch,N,names,num_ord,ord,block0,block1,wvhdl);
498  else if (ch==-1) /* trans ext. */
499  {
500  TransExtInfo T;
501  T.r=ssiReadRing(d);
502  if (T.r==NULL) return NULL;
503  cf=nInitChar(n_transExt,&T);
504  r=rDefault(cf,N,names,num_ord,ord,block0,block1,wvhdl);
505  }
506  else if (ch==-2) /* alg ext. */
507  {
508  TransExtInfo T;
509  T.r=ssiReadRing(d); /* includes qideal */
510  if (T.r==NULL) return NULL;
511  cf=nInitChar(n_algExt,&T);
512  r=rDefault(cf,N,names,num_ord,ord,block0,block1,wvhdl);
513  }
514  else if (ch==-3)
515  {
516  r=rDefault(cf,N,names,num_ord,ord,block0,block1,wvhdl);
517  }
518  else
519  {
520  Werror("ssi: read unknown coeffs type (%d)",ch);
521  return NULL;
522  }
523  ideal q=ssiReadIdeal_R(d,r);
524  if (IDELEMS(q)==0) omFreeBin(q,sip_sideal_bin);
525  else r->qideal=q;
526  return r;
527  }
528 }
for idElimination, like a, except pFDeg, pWeigths ignore it
Definition: ring.h:690
for int64 weights
Definition: ring.h:670
coeffs nFindCoeffByName(const char *cf_name)
find an existing coeff by its "CoeffName"
Definition: numbers.cc:548
used for all transcendental extensions, i.e., the top-most extension in an extension tower is transce...
Definition: coeffs.h:38
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:120
#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:692
#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:35
static jList * T
Definition: janet.cc:37
#define omFreeBin(addr, bin)
Definition: omAllocDecl.h:259
void Werror(const char *fmt,...)
Definition: reporter.cc:199
#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:327
char* ssiReadString ( const ssiInfo d)

Definition at line 367 of file ssiLink.cc.

368 {
369  char *buf;
370  int l;
371  l=s_readint(d->f_read);
372  buf=(char*)omAlloc0(l+1);
373  int c =s_getc(d->f_read); /* skip ' '*/
374  int ll=s_readbytes(buf,l,d->f_read);
375  //if (ll!=l) printf("want %d, got %d bytes\n",l,ll);
376  buf[l]='\0';
377  return buf;
378 }
int s_readbytes(char *buff, int len, s_buff F)
Definition: s_buff.cc:176
int s_getc(s_buff F)
Definition: s_buff.cc:66
int s_readint(s_buff F)
Definition: s_buff.cc:120
int status int void * buf
Definition: si_signals.h:59
#define omAlloc0(size)
Definition: omAllocDecl.h:211
int l
Definition: cfEzgcd.cc:94
int ssiReservePort ( int  clients)

Definition at line 1814 of file ssiLink.cc.

1815 {
1816  if (ssiReserved_P!=0)
1817  {
1818  WerrorS("ERROR already a reverved port requested");
1819  return 0;
1820  }
1821  int portno;
1822  ssiReserved_sockfd = socket(AF_INET, SOCK_STREAM, 0);
1823  if(ssiReserved_sockfd < 0)
1824  {
1825  WerrorS("ERROR opening socket");
1826  return 0;
1827  }
1828  memset((char *) &ssiResverd_serv_addr,0, sizeof(ssiResverd_serv_addr));
1829  portno = 1025;
1830  ssiResverd_serv_addr.sin_family = AF_INET;
1831  ssiResverd_serv_addr.sin_addr.s_addr = INADDR_ANY;
1832  do
1833  {
1834  portno++;
1835  ssiResverd_serv_addr.sin_port = htons(portno);
1836  if(portno > 50000)
1837  {
1838  WerrorS("ERROR on binding (no free port available?)");
1839  return 0;
1840  }
1841  }
1842  while(bind(ssiReserved_sockfd, (struct sockaddr *) &ssiResverd_serv_addr, sizeof(ssiResverd_serv_addr)) < 0);
1843  ssiReserved_P=portno;
1844  listen(ssiReserved_sockfd,clients);
1845  ssiReserved_Clients=clients;
1846  return portno;
1847 }
void WerrorS(const char *s)
Definition: feFopen.cc:24
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:140
#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:12
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
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:1633
char name(const Variable &v)
Definition: variable.h:95
#define NULL
Definition: omList.c:10
#define IDRING(a)
Definition: ipid.h:126
void rSetHdl(idhdl h)
Definition: ipshell.cc:5030
static Poly * h
Definition: janet.cc:978
#define omStrDup(s)
Definition: omAllocDecl.h:263
BOOLEAN ssiSetRing ( si_link  l,
ring  r,
BOOLEAN  send 
)

Definition at line 1381 of file ssiLink.cc.

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

Definition at line 1400 of file ssiLink.cc.

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

Definition at line 357 of file ssiLink.cc.

358 {
359  fprintf(d->f_write,"%d %d ",v->rows(),v->cols());
360  int i;
361  for(i=0;i<v->length();i++)
362  {
363  ssiWriteBigInt(d,(*v)[i]);
364  }
365 }
int length()
Definition: bigintmat.h:144
int i
Definition: cfEzgcd.cc:123
int cols() const
Definition: bigintmat.h:145
int rows() const
Definition: bigintmat.h:146
void ssiWriteCommand ( si_link  l,
command  D 
)

Definition at line 304 of file ssiLink.cc.

305 {
306  ssiInfo *d=(ssiInfo*)l->data;
307  // syntax: <num ops> <operation> <op1> <op2> ....
308  fprintf(d->f_write,"%d %d ",D->argc,D->op);
309  if (D->argc >0) ssiWrite(l, &(D->arg1));
310  if (D->argc < 4)
311  {
312  if (D->argc >1) ssiWrite(l, &(D->arg2));
313  if (D->argc >2) ssiWrite(l, &(D->arg3));
314  }
315 }
#define D(A)
Definition: gentable.cc:119
int l
Definition: cfEzgcd.cc:94
void ssiWriteIdeal ( const ssiInfo d,
int  typ,
const ideal  I 
)

Definition at line 299 of file ssiLink.cc.

300 {
301  ssiWriteIdeal_R(d,typ,I,d->r);
302 }
void ssiWriteIdeal_R ( const ssiInfo d,
int  typ,
const ideal  I,
const ring  r 
)

Definition at line 272 of file ssiLink.cc.

273 {
274  // syntax: 7 # of elements <poly 1> <poly2>.....
275  // syntax: 8 <rows> <cols> <poly 1> <poly2>.....
276  matrix M=(matrix)I;
277  int mn;
278  if (typ==MATRIX_CMD)
279  {
280  mn=MATROWS(M)*MATCOLS(M);
281  fprintf(d->f_write,"%d %d ", MATROWS(M),MATCOLS(M));
282  }
283  else
284  {
285  mn=IDELEMS(I);
286  fprintf(d->f_write,"%d ",IDELEMS(I));
287  }
288 
289  int i;
290  int tt;
291  if (typ==MODUL_CMD) tt=VECTOR_CMD;
292  else tt=POLY_CMD;
293 
294  for(i=0;i<mn;i++)
295  {
296  ssiWritePoly_R(d,tt,I->m[i],R);
297  }
298 }
#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
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
void ssiWriteIntmat ( const ssiInfo d,
intvec v 
)

Definition at line 347 of file ssiLink.cc.

348 {
349  fprintf(d->f_write,"%d %d ",v->rows(),v->cols());
350  int i;
351  for(i=0;i<v->length();i++)
352  {
353  fprintf(d->f_write,"%d ",(*v)[i]);
354  }
355 }
int length() const
Definition: intvec.h:86
int i
Definition: cfEzgcd.cc:123
int cols() const
Definition: intvec.h:87
int rows() const
Definition: intvec.h:88
void ssiWriteIntvec ( const ssiInfo d,
intvec v 
)

Definition at line 338 of file ssiLink.cc.

339 {
340  fprintf(d->f_write,"%d ",v->length());
341  int i;
342  for(i=0;i<v->length();i++)
343  {
344  fprintf(d->f_write,"%d ",(*v)[i]);
345  }
346 }
int length() const
Definition: intvec.h:86
int i
Definition: cfEzgcd.cc:123
void ssiWriteList ( si_link  l,
lists  dd 
)

Definition at line 327 of file ssiLink.cc.

328 {
329  ssiInfo *d=(ssiInfo*)l->data;
330  int Ll=lSize(dd);
331  fprintf(d->f_write,"%d ",Ll+1);
332  int i;
333  for(i=0;i<=Ll;i++)
334  {
335  ssiWrite(l,&(dd->m[i]));
336  }
337 }
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
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 }
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:38
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:422
static FORCE_INLINE void n_WriteFd(number a, FILE *f, const coeffs r)
io via ssi:
Definition: coeffs.h:973
#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:35
polyrec * poly
Definition: hilb.h:10
void ssiWritePoly ( const ssiInfo d,
int  typ,
poly  p 
)

Definition at line 267 of file ssiLink.cc.

268 {
269  ssiWritePoly_R(d,typ,p,d->r);
270 }
return P p
Definition: myNF.cc:203
void ssiWritePoly_R ( const ssiInfo d,
int  typ,
poly  p,
const ring  r 
)

Definition at line 249 of file ssiLink.cc.

250 {
251  fprintf(d->f_write,"%d ",pLength(p));//number of terms
252 
253  while(p!=NULL)
254  {
255  ssiWriteNumber_CF(d,pGetCoeff(p),r->cf);
256  //nWrite(fich,pGetCoeff(p));
257  fprintf(d->f_write,"%ld ",p_GetComp(p,r));//component
258 
259  for(int j=1;j<=rVar(r);j++)
260  {
261  fprintf(d->f_write,"%ld ",p_GetExp(p,j,r ));//x^j
262  }
263  pIter(p);
264  }
265 }
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:537
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
void ssiWriteProc ( const ssiInfo d,
procinfov  p 
)

Definition at line 317 of file ssiLink.cc.

318 {
319  if (p->data.s.body==NULL)
321  if (p->data.s.body!=NULL)
322  ssiWriteString(d,p->data.s.body);
323  else
324  ssiWriteString(d,"");
325 }
procinfodata data
Definition: subexpr.h:62
#define NULL
Definition: omList.c:10
char * iiGetLibProcBuffer(procinfo *pi, int part)
Definition: iplib.cc:211
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==currRing) // see recursive calls for transExt/algExt
239  {
240  if (d->r!=NULL) rKill(d->r);
241  d->r=r;
242  }
243  if (r!=NULL)
244  {
245  /*d->*/r->ref++;
246  }
247  ssiWriteRing_R(d,r);
248 }
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
const ring r
Definition: syzextra.cc:208
void rKill(ring r)
Definition: ipshell.cc:6057
#define NULL
Definition: omList.c:10
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:690
n_coeffType rFieldType(ring r)
Definition: ring.cc:5112
for int64 weights
Definition: ring.h:670
used for all transcendental extensions, i.e., the top-most extension in an extension tower is transce...
Definition: coeffs.h:38
static FORCE_INLINE int n_GetChar(const coeffs r)
Return the characteristic of the coeff. domain.
Definition: coeffs.h:445
const ring r
Definition: syzextra.cc:208
static FORCE_INLINE char * nCoeffName(const coeffs cf)
Definition: coeffs.h:966
int i
Definition: cfEzgcd.cc:123
Induced (Schreyer) ordering.
Definition: ring.h:692
static BOOLEAN rField_is_Q(const ring r)
Definition: ring.h:458
static BOOLEAN rField_is_Zp(const ring r)
Definition: ring.h:452
#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:35
void Werror(const char *fmt,...)
Definition: reporter.cc:199
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_extension si_link_root

Definition at line 51 of file silink.cc.

int ssiReserved_Clients
static

Definition at line 1813 of file ssiLink.cc.

int ssiReserved_P =0
static

Definition at line 1810 of file ssiLink.cc.

int ssiReserved_sockfd
static

Definition at line 1811 of file ssiLink.cc.

struct sockaddr_in ssiResverd_serv_addr
static

Definition at line 1812 of file ssiLink.cc.

link_list ssiToBeClosed =NULL

Definition at line 70 of file ssiLink.cc.

volatile BOOLEAN ssiToBeClosed_inactive =TRUE

Definition at line 71 of file ssiLink.cc.