Data Structures | 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.

Data Structures

struct  ssiInfo
 

Macros

#define TRANSEXT_PRIVATES   1 /* allow access to transext internals */
 
#define SSI_VERSION   9
 
#define SSI_BASE   16
 

Functions

void ssiWritePoly_R (const ssiInfo *d, int typ, poly p, const ring r)
 
void ssiWriteIdeal (const ssiInfo *d, int typ, ideal I)
 
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 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
 

Data Structure Documentation

struct ssiInfo

Definition at line 69 of file ssiLink.cc.

Data Fields
s_buff f_read
FILE * f_write
int fd_read
int fd_write
char level
pid_t pid
char quit_sent
ring r
char send_quit_at_exit

Macro Definition Documentation

#define SSI_BASE   16

Definition at line 68 of file ssiLink.cc.

#define SSI_VERSION   9

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 1950 of file ssiLink.cc.

1951 {
1952  int type_id = IDTYP(h);
1953 
1954  // C-proc not to be dumped, also LIB-proc not
1955  if (type_id == PROC_CMD)
1956  {
1957  if (IDPROC(h)->language == LANG_C) return FALSE;
1958  if (IDPROC(h)->libname != NULL) return FALSE;
1959  }
1960  // do not dump links
1961  if (type_id == LINK_CMD) return FALSE;
1962 
1963  // do not dump ssi internal rings: ssiRing*
1964  if ((type_id == RING_CMD) && (strncmp(IDID(h),"ssiRing",7)==0))
1965  return FALSE;
1966 
1967  command D=(command)omAlloc0(sizeof(*D));
1968  sleftv tmp;
1969  memset(&tmp,0,sizeof(tmp));
1970  tmp.rtyp=COMMAND;
1971  tmp.data=D;
1972 
1973  if (type_id == PACKAGE_CMD)
1974  {
1975  // do not dump Top
1976  if (strcmp(IDID(h), "Top") == 0) return FALSE;
1977  package p=(package)IDDATA(h);
1978  // dump Singular-packages as load("...");
1979  if (p->language==LANG_SINGULAR)
1980  {
1981  D->op=LOAD_CMD;
1982  D->argc=1;
1983  D->arg1.rtyp=STRING_CMD;
1984  D->arg1.data=p->libname;
1985  ssiWrite(l,&tmp);
1986  omFree(D);
1987  return FALSE;
1988  }
1989  }
1990 
1991  // handle qrings separately
1992  //if (type_id == QRING_CMD)
1993  // return DumpSsiQringQring(l, h);
1994 
1995  // put type and name
1996  //Print("generic dump:%s,%s\n",IDID(h),Tok2Cmdname(IDTYP(h)));
1997  D->op='=';
1998  D->argc=2;
1999  D->arg1.rtyp=DEF_CMD;
2000  D->arg1.name=IDID(h);
2001  D->arg2.rtyp=IDTYP(h);
2002  D->arg2.data=IDDATA(h);
2003  ssiWrite(l,&tmp);
2004  omFree(D);
2005  return FALSE;
2006 }
#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
Definition: tok.h:97
void * data
Definition: subexpr.h:89
Definition: subexpr.h:20
#define IDTYP(a)
Definition: ipid.h:118
Definition: tok.h:58
#define omFree(addr)
Definition: omAllocDecl.h:261
#define IDPROC(a)
Definition: ipid.h:139
Definition: tok.h:95
#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 1908 of file ssiLink.cc.

1909 {
1910  pid_t kidpid;
1911  int status;
1912 
1913  loop
1914  {
1915  kidpid = si_waitpid(-1, &status, WNOHANG);
1916  if (kidpid==-1)
1917  {
1918  /* continue on interruption (EINTR): */
1919  if (errno == EINTR) continue;
1920  /* break on anything else (EINVAL or ECHILD according to manpage): */
1921  break;
1922  }
1923  else if (kidpid==0) break; /* no more children to process, so break */
1924 
1925  //printf("Child %ld terminated\n", kidpid);
1927  while((hh!=NULL)&&(ssiToBeClosed_inactive))
1928  {
1929  if((hh->l!=NULL) && (hh->l->m->Open==ssiOpen))
1930  {
1931  ssiInfo *d = (ssiInfo *)hh->l->data;
1932  if(d->pid==kidpid)
1933  {
1935  {
1937  slClose(hh->l);
1939  break;
1940  }
1941  else break;
1942  }
1943  else hh=(link_list)hh->next;
1944  }
1945  else hh=(link_list)hh->next;
1946  }
1947  }
1948 }
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 1522 of file ssiLink.cc.

1523 {
1524  s->Open=ssiOpen;
1525  s->Close=ssiClose;
1526  s->Kill=ssiClose;
1527  s->Read=ssiRead1;
1528  s->Read2=(slRead2Proc)NULL;
1529  s->Write=ssiWrite;
1530  s->Dump=ssiDump;
1531  s->GetDump=ssiGetDump;
1532 
1533  s->Status=slStatusSsi;
1534  s->SetRing=ssiSetRing;
1535  s->type="ssi";
1536  return s;
1537 }
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 1539 of file ssiLink.cc.

1540 {
1541  ssiInfo *d=(ssiInfo*)l->data;
1542  if (d==NULL) return "not open";
1543  if (((strcmp(l->mode,"fork")==0)
1544  ||(strcmp(l->mode,"tcp")==0)
1545  ||(strcmp(l->mode,"connect")==0))
1546  && (strcmp(request, "read") == 0))
1547  {
1548  fd_set mask;
1549  struct timeval wt;
1550  if (s_isready(d->f_read)) return "ready";
1551  loop
1552  {
1553  /* Don't block. Return socket status immediately. */
1554  wt.tv_sec = 0;
1555  wt.tv_usec = 0;
1556 
1557  FD_ZERO(&mask);
1558  FD_SET(d->fd_read, &mask);
1559  //Print("test fd %d\n",d->fd_read);
1560  /* check with select: chars waiting: no -> not ready */
1561  switch (si_select(d->fd_read+1, &mask, NULL, NULL, &wt))
1562  {
1563  case 0: /* not ready */ return "not ready";
1564  case -1: /*error*/ return "error";
1565  case 1: /*ready ? */ break;
1566  }
1567  /* yes: read 1 char*/
1568  /* if \n, check again with select else ungetc(c), ready*/
1569  int c=s_getc(d->f_read);
1570  //Print("try c=%d\n",c);
1571  if (c== -1) return "eof"; /* eof or error */
1572  else if (isdigit(c))
1573  { s_ungetc(c,d->f_read); return "ready"; }
1574  else if (c>' ')
1575  {
1576  Werror("unknown char in ssiLink(%d)",c);
1577  return "error";
1578  }
1579  /* else: next char */
1580  }
1581  }
1582  else if (strcmp(request, "read") == 0)
1583  {
1584  if (SI_LINK_R_OPEN_P(l) && (!s_iseof(d->f_read)) && (s_isready(d->f_read))) return "ready";
1585  else return "not ready";
1586  }
1587  else if (strcmp(request, "write") == 0)
1588  {
1589  if (SI_LINK_W_OPEN_P(l)) return "ready";
1590  else return "not ready";
1591  }
1592  else return "unknown status request";
1593 }
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 1595 of file ssiLink.cc.

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

1769 {
1771  char *buf=(char*)omAlloc(256);
1772  sprintf(buf,"ssi:connect %s:%s",host,port);
1773  slInit(l, buf);
1774  if (slOpen(l,SI_LINK_OPEN,NULL)) return 1;
1776 
1777  idhdl id = enterid(omStrDup("link_ll"), 0, LINK_CMD, &IDROOT, FALSE);
1778  IDLINK(id) = l;
1779 
1780  loop
1781  {
1782  leftv h=ssiRead1(l); /*contains an exit.... */
1783  if (feErrors != NULL && *feErrors != '\0')
1784  {
1785  // handle errors:
1786  PrintS(feErrors); /* currently quite simple */
1787  *feErrors = '\0';
1788  }
1789  ssiWrite(l,h);
1790  h->CleanUp();
1791  omFreeBin(h, sleftv_bin);
1792  }
1793  /* never reached*/
1794  exit(0);
1795 }
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:95
#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 1129 of file ssiLink.cc.

1130 {
1131  if (l!=NULL)
1132  {
1134  ssiInfo *d = (ssiInfo *)l->data;
1135  if (d!=NULL)
1136  {
1137  if ((d->send_quit_at_exit)
1138  && (d->quit_sent==0))
1139  {
1140  fputs("99\n",d->f_write);
1141  fflush(d->f_write);
1142  if (d->f_read!=NULL) { s_close(d->f_read);s_free(d->f_read);}
1143  if (d->f_write!=NULL) { fclose(d->f_write); d->f_write=NULL; }
1144  }
1145  if (d->r!=NULL) rKill(d->r);
1146  si_waitpid(d->pid,NULL,WNOHANG);
1147  if ((d->pid!=0)
1148  && (kill(d->pid,0)==0)) // child is still running
1149  {
1150  struct timespec t;
1151  t.tv_sec=0;
1152  t.tv_nsec=100000000; // <=100 ms
1153  struct timespec rem;
1154  int r;
1155  loop
1156  {
1157  r = nanosleep(&t, &rem);
1158  t = rem;
1159  // child finished:
1160  if (si_waitpid(d->pid,NULL,WNOHANG) != 0) break;
1161  // other signal, waited s>= 100 ms:
1162  if ((r==0) || (errno != EINTR)) break;
1163  }
1164  if (kill(d->pid,0) == 0)
1165  {
1166  kill(d->pid,15);
1167  t.tv_sec=5; // <=5s
1168  t.tv_nsec=0;
1169  loop
1170  {
1171  r = nanosleep(&t, &rem);
1172  t = rem;
1173  // child finished:
1174  if (si_waitpid(d->pid,NULL,WNOHANG) != 0) break;
1175  // other signal, waited s>= 100 ms:
1176  if ((r==0) || (errno != EINTR)) break;
1177  }
1178  if (kill(d->pid,0) == 0)
1179  {
1180  kill(d->pid,9); // just to be sure
1181  si_waitpid(d->pid,NULL,0);
1182  }
1183  }
1184  }
1185  if (d->f_read!=NULL) { s_close(d->f_read);s_free(d->f_read);}
1186  if (d->f_write!=NULL) { fclose(d->f_write); d->f_write=NULL; }
1187  if ((strcmp(l->mode,"tcp")==0)
1188  || (strcmp(l->mode,"fork")==0))
1189  {
1191  if (hh!=NULL)
1192  {
1193  if (hh->l==l)
1194  {
1196  omFreeSize(hh,sizeof(link_struct));
1197  }
1198  else while(hh->next!=NULL)
1199  {
1200  link_list hhh=(link_list)hh->next;
1201  if (hhh->l==l)
1202  {
1203  hh->next=hhh->next;
1204  omFreeSize(hhh,sizeof(link_struct));
1205  break;
1206  }
1207  else
1208  hh=(link_list)hh->next;
1209  }
1210  }
1211  }
1212  omFreeSize((ADDRESS)d,(sizeof *d));
1213  }
1214  l->data=NULL;
1215  }
1216  return FALSE;
1217 }
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:5999
#define NULL
Definition: omList.c:10
int l
Definition: cfEzgcd.cc:94
si_link ssiCommandLink ( )

Definition at line 1837 of file ssiLink.cc.

1838 {
1839  if (ssiReserved_P==0)
1840  {
1841  WerrorS("ERROR no reverved port requested");
1842  return NULL;
1843  }
1844  struct sockaddr_in cli_addr;
1845  int clilen = sizeof(cli_addr);
1846  int newsockfd = si_accept(ssiReserved_sockfd, (struct sockaddr *) &cli_addr, (socklen_t *)&clilen);
1847  if(newsockfd < 0)
1848  {
1849  Werror("ERROR on accept (errno=%d)",errno);
1850  return NULL;
1851  }
1853  si_link_extension s = si_link_root;
1854  si_link_extension prev = s;
1855  while (strcmp(s->type, "ssi") != 0)
1856  {
1857  if (s->next == NULL)
1858  {
1859  prev = s;
1860  s = NULL;
1861  break;
1862  }
1863  else
1864  {
1865  s = s->next;
1866  }
1867  }
1868  if (s != NULL)
1869  l->m = s;
1870  else
1871  {
1872  si_link_extension ns = (si_link_extension)omAlloc0Bin(s_si_link_extension_bin);
1873  prev->next=slInitSsiExtension(ns);
1874  l->m = prev->next;
1875  }
1876  l->name=omStrDup("");
1877  l->mode=omStrDup("tcp");
1878  l->ref=1;
1879  ssiInfo *d=(ssiInfo*)omAlloc0(sizeof(ssiInfo));
1880  l->data=d;
1881  d->fd_read = newsockfd;
1882  d->fd_write = newsockfd;
1883  d->f_read = s_open(newsockfd);
1884  d->f_write = fdopen(newsockfd, "w");
1887  if (ssiReserved_Clients<=0)
1888  {
1889  ssiReserved_P=0;
1890  si_close(ssiReserved_sockfd);
1891  }
1892  return l;
1893 }
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 2028 of file ssiLink.cc.

2029 {
2030  idhdl h = IDROOT, rh = currRingHdl;
2031  BOOLEAN status = ssiDumpIter(l, h);
2032 
2033  //if (! status ) status = DumpAsciiMaps(fd, h, NULL);
2034 
2035  if (currRingHdl != rh) rSetHdl(rh);
2036  //fprintf(fd, "option(set, intvec(%d, %d));\n", si_opt_1, si_opt_2);
2037 
2038  return status;
2039 }
#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:4979
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 2007 of file ssiLink.cc.

2008 {
2009  if (h == NULL) return FALSE;
2010 
2011  if (ssiDumpIter(l, IDNEXT(h))) return TRUE;
2012 
2013  // need to set the ring before writing it, otherwise we get in
2014  // trouble with minpoly
2015  if (IDTYP(h) == RING_CMD || IDTYP(h) == QRING_CMD)
2016  rSetHdl(h);
2017 
2018  if (DumpSsiIdhdl(l, h)) return TRUE;
2019 
2020  // do not dump ssi internal rings: ssiRing*
2021  // but dump objects of all other rings
2022  if ((IDTYP(h) == RING_CMD || IDTYP(h) == QRING_CMD)
2023  && (strncmp(IDID(h),"ssiRing",7)!=0))
2024  return ssiDumpIter(l, IDRING(h)->idroot);
2025  else
2026  return FALSE;
2027 }
#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:126
void rSetHdl(idhdl h)
Definition: ipshell.cc:4979
int l
Definition: cfEzgcd.cc:94
BOOLEAN ssiGetDump ( si_link  l)

Definition at line 2040 of file ssiLink.cc.

2041 {
2042  ssiInfo *d=(ssiInfo*)l->data;
2043  loop
2044  {
2045  if (!SI_LINK_OPEN_P(l)) break;
2046  if (s_iseof(d->f_read)) break;
2047  leftv h=ssiRead1(l); /*contains an exit.... */
2048  if (feErrors != NULL && *feErrors != '\0')
2049  {
2050  // handle errors:
2051  PrintS(feErrors); /* currently quite simple */
2052  return TRUE;
2053  *feErrors = '\0';
2054  }
2055  h->CleanUp();
2056  omFreeBin(h, sleftv_bin);
2057  }
2058  return FALSE;
2059 }
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 748 of file ssiLink.cc.

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

Definition at line 1111 of file ssiLink.cc.

1112 {
1113  if (l!=NULL)
1114  {
1115  ssiInfo *d = (ssiInfo *)l->data;
1116  if (d!=NULL)
1117  {
1118  if (d->send_quit_at_exit)
1119  {
1120  fputs("99\n",d->f_write);
1121  fflush(d->f_write);
1122  }
1123  d->quit_sent=1;
1124  }
1125  }
1126  return FALSE;
1127 }
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 1220 of file ssiLink.cc.

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

727 {
728  ssiInfo *d=(ssiInfo*)l->data;
729  BITSET fl=(BITSET)s_readint(d->f_read);
730  int nr_of_attr=s_readint(d->f_read);
731  if (nr_of_attr>0)
732  {
733  for(int i=1;i<nr_of_attr;i++)
734  {
735  }
736  }
737  leftv tmp=ssiRead1(l);
738  memcpy(res,tmp,sizeof(sleftv));
739  memset(tmp,0,sizeof(sleftv));
740  omFreeSize(tmp,sizeof(sleftv));
741  if (nr_of_attr>0)
742  {
743  }
744  res->flag=fl;
745 }
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 416 of file ssiLink.cc.

417 {
418  number n=ssiReadNumber_CF(d,coeffs_BIGINT);
419  if ((SR_HDL(n) & SR_INT)==0)
420  {
421  if (n->s!=3) Werror("invalid sub type in bigint:%d",n->s);
422  }
423  return n;
424 }
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 693 of file ssiLink.cc.

694 {
695  int r,c;
696  r=s_readint(d->f_read);
697  c=s_readint(d->f_read);
699  for(int i=0;i<r*c;i++)
700  {
701  (*v)[i]=ssiReadBigInt(d);
702  }
703  return v;
704 }
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 706 of file ssiLink.cc.

707 {
708  ssiInfo *d=(ssiInfo*)l->data;
709  int throwaway;
710  throwaway=s_readint(d->f_read);
711  char *name=ssiReadString(d);
712  int tok;
713  blackboxIsCmd(name,tok);
714  if (tok>MAX_TOK)
715  {
716  blackbox *b=getBlackboxStuff(tok);
717  res->rtyp=tok;
718  b->blackbox_deserialize(&b,&(res->data),l);
719  }
720  else
721  {
722  Werror("blackbox %s not found",name);
723  }
724 }
Definition: tok.h:170
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 596 of file ssiLink.cc.

597 {
598  ssiInfo *d=(ssiInfo*)l->data;
599  // syntax: <num ops> <operation> <op1> <op2> ....
600  command D=(command)omAlloc0(sizeof(*D));
601  int argc,op;
602  argc=s_readint(d->f_read);
603  op=s_readint(d->f_read);
604  D->argc=argc; D->op=op;
605  leftv v;
606  if (argc >0)
607  {
608  v=ssiRead1(l);
609  memcpy(&(D->arg1),v,sizeof(*v));
611  }
612  if (argc <4)
613  {
614  if (D->argc >1)
615  {
616  v=ssiRead1(l);
617  memcpy(&(D->arg2),v,sizeof(*v));
619  }
620  if (D->argc >2)
621  {
622  v=ssiRead1(l);
623  memcpy(&(D->arg3),v,sizeof(*v));
625  }
626  }
627  else
628  {
629  leftv prev=&(D->arg1);
630  argc--;
631  while(argc >0)
632  {
633  v=ssiRead1(l);
634  prev->next=v;
635  prev=v;
636  argc--;
637  }
638  }
639  return D;
640 }
#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 575 of file ssiLink.cc.

576 {
577  return ssiReadIdeal_R(d,d->r);
578 }
ideal ssiReadIdeal_R ( const ssiInfo d,
const ring  r 
)

Definition at line 562 of file ssiLink.cc.

563 {
564  int n,i;
565  ideal I;
566  n=s_readint(d->f_read);
567  I=idInit(n,1);
568  for(i=0;i<IDELEMS(I);i++) // read n terms
569  {
570  I->m [i]=ssiReadPoly_R(d,r);
571  }
572  return I;
573 }
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 387 of file ssiLink.cc.

388 {
389  return s_readint(fich);
390 }
int s_readint(s_buff F)
Definition: s_buff.cc:120
intvec* ssiReadIntmat ( const ssiInfo d)

Definition at line 681 of file ssiLink.cc.

682 {
683  int r,c;
684  r=s_readint(d->f_read);
685  c=s_readint(d->f_read);
686  intvec *v=new intvec(r,c,0);
687  for(int i=0;i<r*c;i++)
688  {
689  (*v)[i]=s_readint(d->f_read);
690  }
691  return v;
692 }
const ring r
Definition: syzextra.cc:208
Definition: intvec.h:16
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 670 of file ssiLink.cc.

671 {
672  int nr;
673  nr=s_readint(d->f_read);
674  intvec *v=new intvec(nr);
675  for(int i=0;i<nr;i++)
676  {
677  (*v)[i]=s_readint(d->f_read);
678  }
679  return v;
680 }
Definition: intvec.h:16
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 652 of file ssiLink.cc.

653 {
654  ssiInfo *d=(ssiInfo*)l->data;
655  int nr;
656  nr=s_readint(d->f_read);
657  lists L=(lists)omAlloc(sizeof(*L));
658  L->Init(nr);
659 
660  int i;
661  leftv v;
662  for(i=0;i<nr;i++)
663  {
664  v=ssiRead1(l);
665  memcpy(&(L->m[i]),v,sizeof(*v));
667  }
668  return L;
669 }
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 580 of file ssiLink.cc.

581 {
582  int n,m;
583  m=s_readint(d->f_read);
584  n=s_readint(d->f_read);
585  matrix M=mpNew(m,n);
586  poly p;
587  for(int i=1;i<=MATROWS(M);i++)
588  for(int j=1;j<=MATCOLS(M);j++)
589  {
590  p=ssiReadPoly(d);
591  MATELEM(M,i,j)=p;
592  }
593  return M;
594 }
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 426 of file ssiLink.cc.

427 {
428  return ssiReadNumber_CF(d,d->r->cf);
429 }
number ssiReadNumber_CF ( const ssiInfo d,
const coeffs  cf 
)

Definition at line 392 of file ssiLink.cc.

393 {
394  if (cf->cfReadFd!=NULL)
395  {
396  return n_ReadFd(d->f_read,cf);
397  }
398  else if (getCoeffType(cf) == n_transExt)
399  {
400  // poly poly
401  fraction f=(fraction)n_Init(1,cf);
402  p_Delete(&NUM(f),cf->extRing);
403  NUM(f)=ssiReadPoly_R(d,cf->extRing);
404  DEN(f)=ssiReadPoly_R(d,cf->extRing);
405  return (number)f;
406  }
407  else if (getCoeffType(cf) == n_algExt)
408  {
409  // poly
410  return (number)ssiReadPoly_R(d,cf->extRing);
411  }
412  else Werror("coeffs not implemented in ssiReadNumber");
413  return NULL;
414 }
used for all transcendental extensions, i.e., the top-most extension in an extension tower is transce...
Definition: coeffs.h:38
f
Definition: cfModGcd.cc:4022
static FORCE_INLINE number n_ReadFd(s_buff f, const coeffs r)
io via ssi:
Definition: coeffs.h:978
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
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:850
#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 556 of file ssiLink.cc.

557 {
558 // < # of terms> < term1> < .....
559  return ssiReadPoly_R(D,D->r);
560 }
poly ssiReadPoly_R ( const ssiInfo D,
const ring  r 
)

Definition at line 525 of file ssiLink.cc.

526 {
527 // < # of terms> < term1> < .....
528  int n,i,l;
529  n=ssiReadInt(D->f_read);
530  //Print("poly: terms:%d\n",n);
531  poly p;
532  poly ret=NULL;
533  poly prev=NULL;
534  for(l=0;l<n;l++) // read n terms
535  {
536 // coef,comp.exp1,..exp N
537  p=p_Init(r);
538  pSetCoeff0(p,ssiReadNumber_CF(D,r->cf));
539  int d;
540  d=s_readint(D->f_read);
541  p_SetComp(p,d,r);
542  for(i=1;i<=rVar(r);i++)
543  {
544  d=s_readint(D->f_read);
545  p_SetExp(p,i,d,r);
546  }
547  p_Setm(p,r);
548  p_Test(p,r);
549  if (ret==NULL) ret=p;
550  else pNext(prev)=p;
551  prev=p;
552  }
553  return ret;
554 }
return P p
Definition: myNF.cc:203
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition: p_polys.h:236
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:540
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:484
#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:436
#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:1248
int l
Definition: cfEzgcd.cc:94
procinfov ssiReadProc ( const ssiInfo d)

Definition at line 642 of file ssiLink.cc.

643 {
644  char *s=ssiReadString(d);
647  p->libname=omStrDup("");
648  p->procname=omStrDup("");
649  p->data.s.body=s;
650  return p;
651 }
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 431 of file ssiLink.cc.

432 {
433 /* syntax is <ch> <N> <l1> <v1> ...<lN> <vN> <number of orderings> <ord1> <block0_1> <block1_1> .... <Q-ideal> */
434  int ch, N,i;
435  char **names;
436  ch=s_readint(d->f_read);
437  N=s_readint(d->f_read);
438  if (N!=0)
439  {
440  names=(char**)omAlloc(N*sizeof(char*));
441  for(i=0;i<N;i++)
442  {
443  names[i]=ssiReadString(d);
444  }
445  }
446  // read the orderings:
447  int num_ord; // number of orderings
448  num_ord=s_readint(d->f_read);
449  int *ord=(int *)omAlloc0((num_ord+1)*sizeof(int));
450  int *block0=(int *)omAlloc0((num_ord+1)*sizeof(int));
451  int *block1=(int *)omAlloc0((num_ord+1)*sizeof(int));
452  int **wvhdl=(int**)omAlloc0((num_ord+1)*sizeof(int*));
453  for(i=0;i<num_ord;i++)
454  {
455  ord[i]=s_readint(d->f_read);
456  block0[i]=s_readint(d->f_read);
457  block1[i]=s_readint(d->f_read);
458  switch(ord[i])
459  {
460  case ringorder_a:
461  case ringorder_wp:
462  case ringorder_Wp:
463  case ringorder_ws:
464  case ringorder_Ws:
465  case ringorder_aa:
466  {
467  wvhdl[i]=(int*)omAlloc((block1[i]-block0[i]+1)*sizeof(int));
468  int ii;
469  for(ii=block0[i];ii<=block1[i];ii++)
470  wvhdl[i][ii-block0[i]]=s_readint(d->f_read);
471  }
472  break;
473 
474  case ringorder_a64:
475  case ringorder_M:
476  case ringorder_L:
477  case ringorder_IS:
478  Werror("ring oder not implemented for ssi:%d",ord[i]);
479  break;
480 
481  default: break;
482  }
483  }
484  if (N==0)
485  {
486  omFree(ord);
487  omFree(block0);
488  omFree(block1);
489  omFree(wvhdl);
490  return NULL;
491  }
492  else
493  {
494  ring r=NULL;
495  if (ch>=0) /* Q, Z/p */
496  r=rDefault(ch,N,names,num_ord,ord,block0,block1,wvhdl);
497  else if (ch==-1) /* trans ext. */
498  {
499  TransExtInfo T;
500  T.r=ssiReadRing(d);
502  r=rDefault(cf,N,names,num_ord,ord,block0,block1,wvhdl);
503  }
504  else if (ch==-2) /* alg ext. */
505  {
506  TransExtInfo T;
507  T.r=ssiReadRing(d);
508  T.r->qideal=idInit(1,1);
509  T.r->qideal->m[0]=ssiReadPoly_R(d,T.r);
511  r=rDefault(cf,N,names,num_ord,ord,block0,block1,wvhdl);
512  }
513  else
514  {
515  Werror("ssi: read unknown coeffs type (%d)",ch);
516  return NULL;
517  }
518  ideal q=ssiReadIdeal_R(d,r);
519  if (IDELEMS(q)==0) omFreeBin(q,sip_sideal_bin);
520  else r->qideal=q;
521  return r;
522  }
523 }
for idElimination, like a, except pFDeg, pWeigths ignore it
Definition: ring.h:693
for int64 weights
Definition: ring.h:673
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:695
#define IDELEMS(i)
Definition: simpleideals.h:24
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:38
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 374 of file ssiLink.cc.

375 {
376  char *buf;
377  int l;
378  l=s_readint(d->f_read);
379  buf=(char*)omAlloc0(l+1);
380  int c =s_getc(d->f_read); /* skip ' '*/
381  int ll=s_readbytes(buf,l,d->f_read);
382  //if (ll!=l) printf("want %d, got %d bytes\n",l,ll);
383  buf[l]='\0';
384  return buf;
385 }
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 1801 of file ssiLink.cc.

1802 {
1803  if (ssiReserved_P!=0)
1804  {
1805  WerrorS("ERROR already a reverved port requested");
1806  return 0;
1807  }
1808  int portno;
1809  ssiReserved_sockfd = socket(AF_INET, SOCK_STREAM, 0);
1810  if(ssiReserved_sockfd < 0)
1811  {
1812  WerrorS("ERROR opening socket");
1813  return 0;
1814  }
1815  memset((char *) &ssiResverd_serv_addr,0, sizeof(ssiResverd_serv_addr));
1816  portno = 1025;
1817  ssiResverd_serv_addr.sin_family = AF_INET;
1818  ssiResverd_serv_addr.sin_addr.s_addr = INADDR_ANY;
1819  do
1820  {
1821  portno++;
1822  ssiResverd_serv_addr.sin_port = htons(portno);
1823  if(portno > 50000)
1824  {
1825  WerrorS("ERROR on binding (no free port available?)");
1826  return 0;
1827  }
1828  }
1829  while(bind(ssiReserved_sockfd, (struct sockaddr *) &ssiResverd_serv_addr, sizeof(ssiResverd_serv_addr)) < 0);
1830  ssiReserved_P=portno;
1831  listen(ssiReserved_sockfd,clients);
1832  ssiReserved_Clients=clients;
1833  return portno;
1834 }
void WerrorS(const char *s)
Definition: feFopen.cc:24
void ssiSetCurrRing ( const ring  r)

Definition at line 92 of file ssiLink.cc.

93 {
94  // if (currRing!=NULL)
95  // Print("need to change the ring, currRing:%s, switch to: ssiRing%d\n",IDID(currRingHdl),nr);
96  // else
97  // Print("no ring, switch to ssiRing%d\n",nr);
98  if (!rEqual(r,currRing,1))
99  {
100  char name[20];
101  int nr=0;
102  do
103  { sprintf(name,"ssiRing%d",nr); nr++; }
104  while(IDROOT->get(name, 0)!=NULL);
106  IDRING(h)=r;
107  r->ref++;
108  rSetHdl(h);
109  }
110 }
#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:4979
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 1368 of file ssiLink.cc.

1369 {
1370  if(SI_LINK_W_OPEN_P(l)==0)
1371  if (slOpen(l,SI_LINK_OPEN|SI_LINK_WRITE,NULL)) return TRUE;
1372  ssiInfo *d = (ssiInfo *)l->data;
1373  if (d->r!=r)
1374  {
1375  if (send)
1376  {
1377  fputs("15 ",d->f_write);
1378  ssiWriteRing(d,r);
1379  }
1380  d->r=r;
1381  }
1382  if (currRing!=r) rChangeCurrRing(r);
1383  return FALSE;
1384 }
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 1387 of file ssiLink.cc.

1388 {
1389  if(SI_LINK_W_OPEN_P(l)==0)
1390  if (slOpen(l,SI_LINK_OPEN|SI_LINK_WRITE,NULL)) return TRUE;
1391  ssiInfo *d = (ssiInfo *)l->data;
1392  d->level++;
1393  //FILE *fich=d->f;
1394  while (data!=NULL)
1395  {
1396  int tt=data->Typ();
1397  void *dd=data->Data();
1398  attr *aa=data->Attribute();
1399  BOOLEAN with_attr=FALSE;
1400  if (((*aa)!=NULL)||(data->flag!=0))
1401  {
1402  attr a=*aa;
1403  int n=0;
1404  while(a!=NULL) { n++; a=a->next;}
1405  fprintf(d->f_write,"21 %d %d ",data->flag,n);
1406  a=*aa;
1407  }
1408  if ((dd==NULL) && (data->name!=NULL) && (tt==0)) tt=DEF_CMD;
1409  // return pure undefined names as def
1410 
1411  switch(tt /*data->Typ()*/)
1412  {
1413  case 0: /*error*/
1414  case NONE/* nothing*/:fputs("16 ",d->f_write);
1415  break;
1416  case STRING_CMD: fputs("2 ",d->f_write);
1417  ssiWriteString(d,(char *)dd);
1418  break;
1419  case INT_CMD: fputs("1 ",d->f_write);
1420  ssiWriteInt(d,(int)(long)dd);
1421  break;
1422  case BIGINT_CMD:fputs("4 ",d->f_write);
1423  ssiWriteBigInt(d,(number)dd);
1424  break;
1425  case NUMBER_CMD:
1426  if (d->r!=currRing)
1427  {
1428  fputs("15 ",d->f_write);
1430  if (d->level<=1) fputc('\n',d->f_write);
1431  }
1432  fputs("3 ",d->f_write);
1433  ssiWriteNumber(d,(number)dd);
1434  break;
1435  case QRING_CMD:
1436  case RING_CMD:fputs("5 ",d->f_write);
1437  ssiWriteRing(d,(ring)dd);
1438  break;
1439  case POLY_CMD:
1440  case VECTOR_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  if(tt==POLY_CMD) fputs("6 ",d->f_write);
1448  else fputs("9 ",d->f_write);
1449  ssiWritePoly(d,tt,(poly)dd);
1450  break;
1451  case IDEAL_CMD:
1452  case MODUL_CMD:
1453  case MATRIX_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==IDEAL_CMD) fputs("7 ",d->f_write);
1461  else if(tt==MATRIX_CMD) fputs("8 ",d->f_write);
1462  else
1463  {
1464  ideal M=(ideal)dd;
1465  fprintf(d->f_write,"10 %d ",M->rank);
1466  }
1467  ssiWriteIdeal(d,tt,(ideal)dd);
1468  break;
1469  case COMMAND:
1470  fputs("11 ",d->f_write);
1471  ssiWriteCommand(l,(command)dd);
1472  break;
1473  case DEF_CMD: /* not evaluated stuff in quotes */
1474  fputs("12 ",d->f_write);
1475  ssiWriteString(d,data->Name());
1476  break;
1477  case PROC_CMD:
1478  fputs("13 ",d->f_write);
1479  ssiWriteProc(d,(procinfov)dd);
1480  break;
1481  case LIST_CMD:
1482  fputs("14 ",d->f_write);
1483  ssiWriteList(l,(lists)dd);
1484  break;
1485  case INTVEC_CMD:
1486  fputs("17 ",d->f_write);
1487  ssiWriteIntvec(d,(intvec *)dd);
1488  break;
1489  case INTMAT_CMD:
1490  fputs("18 ",d->f_write);
1491  ssiWriteIntmat(d,(intvec *)dd);
1492  break;
1493  case BIGINTMAT_CMD:
1494  fputs("19 ",d->f_write);
1495  ssiWriteBigintmat(d,(bigintmat *)dd);
1496  break;
1497  default:
1498  if (tt>MAX_TOK)
1499  {
1500  blackbox *b=getBlackboxStuff(tt);
1501  fputs("20 ",d->f_write);
1502  b->blackbox_serialize(b,dd,l);
1503  }
1504  else
1505  {
1506  Werror("not implemented (t:%d, rtyp:%d)",tt, data->rtyp);
1507  d->level=0;
1508  return TRUE;
1509  }
1510  break;
1511  }
1512  if (d->level<=1) { fputc('\n',d->f_write); fflush(d->f_write); }
1513  data=data->next;
1514  }
1515  d->level--;
1516  return FALSE;
1517 }
ip_command * command
Definition: ipid.h:24
const poly a
Definition: syzextra.cc:212
Definition: tok.h:85
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:1366
Definition: tok.h:42
Matrices of numbers.
Definition: bigintmat.h:51
Definition: tok.h:170
#define TRUE
Definition: auxiliary.h:144
int Typ()
Definition: subexpr.cc:969
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:16
Definition: tok.h:58
const char * name
Definition: subexpr.h:88
while(1)
Definition: libparse.cc:1442
Definition: tok.h:88
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:1111
Definition: tok.h:96
Definition: tok.h:126
polyrec * poly
Definition: hilb.h:10
int BOOLEAN
Definition: auxiliary.h:131
const poly b
Definition: syzextra.cc:213
#define NONE
Definition: tok.h:173
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 124 of file ssiLink.cc.

125 {
127 }
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:974
void ssiWriteBigintmat ( const ssiInfo d,
bigintmat v 
)

Definition at line 364 of file ssiLink.cc.

365 {
366  fprintf(d->f_write,"%d %d ",v->rows(),v->cols());
367  int i;
368  for(i=0;i<v->length();i++)
369  {
370  ssiWriteBigInt(d,(*v)[i]);
371  }
372 }
int length()
Definition: bigintmat.h:146
int i
Definition: cfEzgcd.cc:123
int cols() const
Definition: bigintmat.h:147
int rows() const
Definition: bigintmat.h:148
void ssiWriteCommand ( si_link  l,
command  D 
)

Definition at line 311 of file ssiLink.cc.

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

Definition at line 283 of file ssiLink.cc.

284 {
285  // syntax: 7 # of elements <poly 1> <poly2>.....
286  // syntax: 8 <rows> <cols> <poly 1> <poly2>.....
287  matrix M=(matrix)I;
288  int mn;
289  if (typ==MATRIX_CMD)
290  {
291  mn=MATROWS(M)*MATCOLS(M);
292  fprintf(d->f_write,"%d %d ", MATROWS(M),MATCOLS(M));
293  }
294  else
295  {
296  mn=IDELEMS(I);
297  fprintf(d->f_write,"%d ",IDELEMS(I));
298  }
299 
300  int i;
301  int tt;
302  if (typ==MODUL_CMD) tt=VECTOR_CMD;
303  else tt=POLY_CMD;
304 
305  for(i=0;i<mn;i++)
306  {
307  ssiWritePoly(d,tt,I->m[i]);
308  }
309 }
#define M
Definition: sirandom.c:24
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 112 of file ssiLink.cc.

113 {
114  fprintf(d->f_write,"%d ",i);
115  //if (d->f_debug!=NULL) fprintf(d->f_debug,"int: %d ",i);
116 }
int i
Definition: cfEzgcd.cc:123
void ssiWriteIntmat ( const ssiInfo d,
intvec v 
)

Definition at line 354 of file ssiLink.cc.

355 {
356  fprintf(d->f_write,"%d %d ",v->rows(),v->cols());
357  int i;
358  for(i=0;i<v->length();i++)
359  {
360  fprintf(d->f_write,"%d ",(*v)[i]);
361  }
362 }
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 345 of file ssiLink.cc.

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

Definition at line 334 of file ssiLink.cc.

335 {
336  ssiInfo *d=(ssiInfo*)l->data;
337  int Ll=lSize(dd);
338  fprintf(d->f_write,"%d ",Ll+1);
339  int i;
340  for(i=0;i<=Ll;i++)
341  {
342  ssiWrite(l,&(dd->m[i]));
343  }
344 }
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 157 of file ssiLink.cc.

158 {
159  ssiWriteNumber_CF(d,n,d->r->cf);
160 }
void ssiWriteNumber_CF ( const ssiInfo d,
const number  n,
const coeffs  cf 
)

Definition at line 129 of file ssiLink.cc.

130 {
131  // syntax is as follows:
132  // case 1 Z/p: 3 <int>
133  // case 2 Q: 3 4 <int>
134  // or 3 0 <mpz_t nominator> <mpz_t denominator>
135  // or 3 1 dto.
136  // or 3 3 <mpz_t nominator>
137  // or 3 5 <mpz_t raw nom.> <mpz_t raw denom.>
138  // or 3 6 <mpz_t raw nom.> <mpz_t raw denom.>
139  // or 3 8 <mpz_t raw nom.>
140  if (getCoeffType(cf)==n_transExt)
141  {
142  fraction f=(fraction)n;
143  ssiWritePoly_R(d,POLY_CMD,NUM(f),cf->extRing);
144  ssiWritePoly_R(d,POLY_CMD,DEN(f),cf->extRing);
145  }
146  else if (getCoeffType(cf)==n_algExt)
147  {
148  ssiWritePoly_R(d,POLY_CMD,(poly)n,cf->extRing);
149  }
150  else if (cf->cfWriteFd!=NULL)
151  {
152  n_WriteFd(n,d->f_write,cf);
153  }
154  else WerrorS("coeff field not implemented");
155 }
used for all transcendental extensions, i.e., the top-most extension in an extension tower is transce...
Definition: coeffs.h:38
f
Definition: cfModGcd.cc:4022
void WerrorS(const char *s)
Definition: feFopen.cc:24
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:974
#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 278 of file ssiLink.cc.

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

Definition at line 260 of file ssiLink.cc.

261 {
262  fprintf(d->f_write,"%d ",pLength(p));//number of terms
263 
264  while(p!=NULL)
265  {
266  ssiWriteNumber_CF(d,pGetCoeff(p),r->cf);
267  //nWrite(fich,pGetCoeff(p));
268  fprintf(d->f_write,"%ld ",p_GetComp(p,r));//component
269 
270  for(int j=1;j<=rVar(r);j++)
271  {
272  fprintf(d->f_write,"%ld ",p_GetExp(p,j,r ));//x^j
273  }
274  pIter(p);
275  }
276 }
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:540
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:465
int j
Definition: myNF.cc:70
#define NULL
Definition: omList.c:10
void ssiWriteProc ( const ssiInfo d,
procinfov  p 
)

Definition at line 324 of file ssiLink.cc.

325 {
326  if (p->data.s.body==NULL)
328  if (p->data.s.body!=NULL)
329  ssiWriteString(d,p->data.s.body);
330  else
331  ssiWriteString(d,"");
332 }
procinfodata data
Definition: subexpr.h:62
#define NULL
Definition: omList.c:10
char * iiGetLibProcBuffer(procinfo *pi, int part)
Definition: iplib.cc:210
void ssiWriteRing ( ssiInfo d,
const ring  r 
)

Definition at line 244 of file ssiLink.cc.

245 {
246  /* 5 <ch> <N> <l1> <v1> ...<lN> <vN> <number of orderings> <ord1> <block0_1> <block1_1> .... <extRing> <Q-ideal> */
247  /* ch=-1: transext, coeff ring follows */
248  /* ch=-2: algext, coeff ring and minpoly follows */
249  if (r==currRing) // see recursive calls for transExt/algExt
250  {
251  if (d->r!=NULL) rKill(d->r);
252  d->r=r;
253  }
254  if (r!=NULL)
255  {
256  /*d->*/r->ref++;
257  }
258  ssiWriteRing_R(d,r);
259 }
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:5999
#define NULL
Definition: omList.c:10
void ssiWriteRing_R ( ssiInfo d,
const ring  r 
)

Definition at line 162 of file ssiLink.cc.

163 {
164  /* 5 <ch> <N> <l1> <v1> ...<lN> <vN> <number of orderings> <ord1> <block0_1> <block1_1> .... <extRing> <Q-ideal> */
165  /* ch=-1: transext, coeff ring follows */
166  /* ch=-2: algext, coeff ring and minpoly follows */
167  if (r!=NULL)
168  {
169  if (rField_is_Q(r) || rField_is_Zp(r))
170  fprintf(d->f_write,"%d %d ",n_GetChar(r->cf),r->N);
171  else if (rFieldType(r)==n_transExt)
172  fprintf(d->f_write,"-1 %d ",r->N);
173  else if (rFieldType(r)==n_algExt)
174  fprintf(d->f_write,"-2 %d ",r->N);
175  else /*dummy*/
176  fprintf(d->f_write,"0 %d ",r->N);
177 
178  int i;
179  for(i=0;i<r->N;i++)
180  {
181  fprintf(d->f_write,"%d %s ",(int)strlen(r->names[i]),r->names[i]);
182  }
183  /* number of orderings:*/
184  i=0;
185  // remember dummy ring: everything 0:
186  if (r->order!=NULL) while (r->order[i]!=0) i++;
187  fprintf(d->f_write,"%d ",i);
188  /* each ordering block: */
189  i=0;
190  if (r->order!=NULL) while(r->order[i]!=0)
191  {
192  fprintf(d->f_write,"%d %d %d ",r->order[i],r->block0[i], r->block1[i]);
193  switch(r->order[i])
194  {
195  case ringorder_a:
196  case ringorder_wp:
197  case ringorder_Wp:
198  case ringorder_ws:
199  case ringorder_Ws:
200  case ringorder_aa:
201  {
202  int ii;
203  for(ii=r->block0[i];ii<=r->block1[i];ii++)
204  fprintf(d->f_write,"%d ",r->wvhdl[i][ii-r->block0[i]]);
205  }
206  break;
207 
208  case ringorder_a64:
209  case ringorder_M:
210  case ringorder_L:
211  case ringorder_IS:
212  Werror("ring oder not implemented for ssi:%d",r->order[i]);
213  break;
214 
215  default: break;
216  }
217  i++;
218  }
219  if ((rFieldType(r)==n_transExt)
220  || (rFieldType(r)==n_algExt))
221  {
222  ssiWriteRing_R(d,r->cf->extRing);
223  if (rFieldType(r)==n_algExt)
224  {
225  ssiWritePoly_R(d,POLY_CMD,r->cf->extRing->qideal->m[0],r->cf->extRing);
226  }
227  }
228  /* Q-ideal :*/
229  if (r->qideal!=NULL)
230  {
231  ssiWriteIdeal(d,IDEAL_CMD,r->qideal);
232  }
233  else
234  {
235  fprintf(d->f_write,"0 "/*ideal with 0 entries */);
236  }
237  }
238  else /* dummy ring r==NULL*/
239  {
240  fprintf(d->f_write,"0 0 0 0 "/*,r->ch,r->N, blocks, q-ideal*/);
241  }
242 }
for idElimination, like a, except pFDeg, pWeigths ignore it
Definition: ring.h:693
n_coeffType rFieldType(ring r)
Definition: ring.cc:5112
for int64 weights
Definition: ring.h:673
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
int i
Definition: cfEzgcd.cc:123
Induced (Schreyer) ordering.
Definition: ring.h:695
static BOOLEAN rField_is_Q(const ring r)
Definition: ring.h:461
static BOOLEAN rField_is_Zp(const ring r)
Definition: ring.h:455
#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 118 of file ssiLink.cc.

119 {
120  fprintf(d->f_write,"%d %s ",(int)strlen(s),s);
121  //if (d->f_debug!=NULL) fprintf(d->f_debug,"stringi: %d \"%s\" ",strlen(s),s);
122 }
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 1800 of file ssiLink.cc.

int ssiReserved_P =0
static

Definition at line 1797 of file ssiLink.cc.

int ssiReserved_sockfd
static

Definition at line 1798 of file ssiLink.cc.

struct sockaddr_in ssiResverd_serv_addr
static

Definition at line 1799 of file ssiLink.cc.

link_list ssiToBeClosed =NULL

Definition at line 82 of file ssiLink.cc.

volatile BOOLEAN ssiToBeClosed_inactive =TRUE

Definition at line 83 of file ssiLink.cc.