My Project
Macros | Functions | Variables
ssiLink.cc File Reference
#include "kernel/mod2.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/feOpt.h"
#include "Singular/lists.h"
#include "Singular/blackbox.h"
#include "Singular/links/ssiLink.h"
#include "Singular/links/simpleipc.h"
#include <errno.h>
#include <sys/types.h>
#include <ctype.h>
#include <netdb.h>
#include <netinet/in.h>

Go to the source code of this file.

Macros

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

Functions

static void ssiWriteIdeal (const ssiInfo *d, int typ, const ideal I)
 
static void ssiWritePoly_R (const ssiInfo *d, int typ, poly p, const ring r)
 
static void ssiWriteIdeal_R (const ssiInfo *d, int typ, const ideal I, const ring r)
 
static poly ssiReadPoly_R (const ssiInfo *D, const ring r)
 
static ideal ssiReadIdeal_R (const ssiInfo *d, const ring r)
 
static BOOLEAN ssiSetCurrRing (const ring r)
 
static void ssiCheckCurrRing (const ring r)
 
static void ssiWriteInt (const ssiInfo *d, const int i)
 
static void ssiWriteString (const ssiInfo *d, const char *s)
 
static void ssiWriteBigInt (const ssiInfo *d, const number n)
 
static void ssiWriteNumber_CF (const ssiInfo *d, const number n, const coeffs cf)
 
static void ssiWriteNumber (const ssiInfo *d, const number n)
 
static void ssiWriteRing_R (ssiInfo *d, const ring r)
 
static void ssiWriteRing (ssiInfo *d, const ring r)
 
static void ssiWritePoly (const ssiInfo *d, int typ, poly p)
 
static void ssiWriteCommand (si_link l, command D)
 
static void ssiWriteProc (const ssiInfo *d, procinfov p)
 
static void ssiWriteList (si_link l, lists dd)
 
static void ssiWriteIntvec (const ssiInfo *d, intvec *v)
 
static void ssiWriteIntmat (const ssiInfo *d, intvec *v)
 
static void ssiWriteBigintmat (const ssiInfo *d, bigintmat *v)
 
static char * ssiReadString (const ssiInfo *d)
 
static int ssiReadInt (s_buff fich)
 
static number ssiReadNumber_CF (const ssiInfo *d, const coeffs cf)
 
static number ssiReadBigInt (const ssiInfo *d)
 
static number ssiReadNumber (ssiInfo *d)
 
static ring ssiReadRing (ssiInfo *d)
 
static poly ssiReadPoly (ssiInfo *d)
 
static ideal ssiReadIdeal (ssiInfo *d)
 
static matrix ssiReadMatrix (ssiInfo *d)
 
static command ssiReadCommand (si_link l)
 
static procinfov ssiReadProc (const ssiInfo *d)
 
static lists ssiReadList (si_link l)
 
static intvecssiReadIntvec (const ssiInfo *d)
 
static intvecssiReadIntmat (const ssiInfo *d)
 
static bigintmatssiReadBigintmat (const ssiInfo *d)
 
static void ssiReadBlackbox (leftv res, si_link l)
 
static void ssiReadAttrib (leftv res, si_link l)
 
static void ssiReadRingProperties (si_link l)
 
BOOLEAN ssiOpen (si_link l, short flag, leftv u)
 
static BOOLEAN ssiPrepClose (si_link l)
 
BOOLEAN ssiClose (si_link l)
 
leftv ssiRead1 (si_link l)
 
static 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

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

Macro Definition Documentation

◆ SSI_VERSION

#define SSI_VERSION   14

Definition at line 52 of file ssiLink.cc.

◆ TRANSEXT_PRIVATES

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

Definition at line 8 of file ssiLink.cc.

Function Documentation

◆ DumpSsiIdhdl()

static BOOLEAN DumpSsiIdhdl ( si_link  l,
idhdl  h 
)
static

Definition at line 2228 of file ssiLink.cc.

2229{
2230 int type_id = IDTYP(h);
2231
2232 // C-proc not to be dumped, also LIB-proc not
2233 if (type_id == PROC_CMD)
2234 {
2235 if (IDPROC(h)->language == LANG_C) return FALSE;
2236 if (IDPROC(h)->libname != NULL) return FALSE;
2237 }
2238 // do not dump links
2239 if (type_id == LINK_CMD) return FALSE;
2240
2241 // do not dump ssi internal rings: ssiRing*
2242 if ((type_id == RING_CMD) && (strncmp(IDID(h),"ssiRing",7)==0))
2243 return FALSE;
2244
2245 // do not dump default cring:
2246 if (type_id == CRING_CMD)
2247 {
2248 if (strcmp(IDID(h),"ZZ")==0) return FALSE;
2249 if (strcmp(IDID(h),"QQ")==0) return FALSE;
2250 #ifdef SINGULAR_4_2
2251 if (strcmp(IDID(h),"AE")==0) return FALSE;
2252 if (strcmp(IDID(h),"QAE")==0) return FALSE;
2253 #endif
2254 }
2255
2256 command D=(command)omAlloc0(sizeof(*D));
2257 sleftv tmp;
2258 memset(&tmp,0,sizeof(tmp));
2259 tmp.rtyp=COMMAND;
2260 tmp.data=D;
2261
2262 if (type_id == PACKAGE_CMD)
2263 {
2264 // do not dump Top, Standard
2265 if ((strcmp(IDID(h), "Top") == 0)
2266 || (strcmp(IDID(h), "Standard") == 0))
2267 {
2268 omFreeSize(D,sizeof(*D));
2269 return FALSE;
2270 }
2271 package p=(package)IDDATA(h);
2272 // dump Singular-packages as LIB("...");
2273 if (p->language==LANG_SINGULAR)
2274 {
2275 D->op=LOAD_CMD;
2276 D->argc=2;
2277 D->arg1.rtyp=STRING_CMD;
2278 D->arg1.data=p->libname;
2279 D->arg2.rtyp=STRING_CMD;
2280 D->arg2.data=(char*)"with";
2281 ssiWrite(l,&tmp);
2282 omFreeSize(D,sizeof(*D));
2283 return FALSE;
2284 }
2285 // dump Singular-packages as load("...");
2286 else if (p->language==LANG_C)
2287 {
2288 D->op=LOAD_CMD;
2289 D->argc=1;
2290 D->arg1.rtyp=STRING_CMD;
2291 D->arg1.data=p->libname;
2292 ssiWrite(l,&tmp);
2293 omFreeSize(D,sizeof(*D));
2294 return FALSE;
2295 }
2296 }
2297
2298 // put type and name
2299 //Print("generic dump:%s,%s\n",IDID(h),Tok2Cmdname(IDTYP(h)));
2300 D->op='=';
2301 D->argc=2;
2302 D->arg1.rtyp=DEF_CMD;
2303 D->arg1.name=IDID(h);
2304 D->arg2.rtyp=IDTYP(h);
2305 D->arg2.data=IDDATA(h);
2306 ssiWrite(l,&tmp);
2307 omFreeSize(D,sizeof(*D));
2308 return FALSE;
2309}
#define FALSE
Definition: auxiliary.h:96
int l
Definition: cfEzgcd.cc:100
int p
Definition: cfModGcd.cc:4078
Class used for (list of) interpreter objects.
Definition: subexpr.h:83
int rtyp
Definition: subexpr.h:91
void * data
Definition: subexpr.h:88
#define D(A)
Definition: gentable.cc:131
@ PROC_CMD
Definition: grammar.cc:280
@ RING_CMD
Definition: grammar.cc:281
ip_command * command
Definition: ipid.h:23
#define IDDATA(a)
Definition: ipid.h:126
#define IDPROC(a)
Definition: ipid.h:140
#define IDID(a)
Definition: ipid.h:122
#define IDTYP(a)
Definition: ipid.h:119
STATIC_VAR Poly * h
Definition: janet.cc:971
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
#define omAlloc0(size)
Definition: omAllocDecl.h:211
#define NULL
Definition: omList.c:12
@ LANG_SINGULAR
Definition: subexpr.h:22
@ LANG_C
Definition: subexpr.h:22
@ CRING_CMD
Definition: tok.h:56
@ PACKAGE_CMD
Definition: tok.h:149
@ DEF_CMD
Definition: tok.h:58
@ LINK_CMD
Definition: tok.h:117
@ STRING_CMD
Definition: tok.h:185
@ LOAD_CMD
Definition: tok.h:119
#define COMMAND
Definition: tok.h:29

◆ sig_chld_hdl()

void sig_chld_hdl ( int  sig)

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

2187{
2188 pid_t kidpid;
2189 int status;
2190
2191 loop
2192 {
2193 kidpid = si_waitpid(-1, &status, WNOHANG);
2194 if (kidpid==-1)
2195 {
2196 /* continue on interruption (EINTR): */
2197 if (errno == EINTR) continue;
2198 /* break on anything else (EINVAL or ECHILD according to manpage): */
2199 break;
2200 }
2201 else if (kidpid==0) break; /* no more children to process, so break */
2202
2203 //printf("Child %ld terminated\n", kidpid);
2205 while((hh!=NULL)&&(ssiToBeClosed_inactive))
2206 {
2207 if((hh->l!=NULL) && (hh->l->m->Open==ssiOpen))
2208 {
2209 ssiInfo *d = (ssiInfo *)hh->l->data;
2210 if(d->pid==kidpid)
2211 {
2213 {
2215 slClose(hh->l);
2217 break;
2218 }
2219 else break;
2220 }
2221 else hh=(link_list)hh->next;
2222 }
2223 else hh=(link_list)hh->next;
2224 }
2225 }
2226}
#define TRUE
Definition: auxiliary.h:100
pid_t pid
Definition: s_buff.h:25
Definition: s_buff.h:21
int * status
Definition: si_signals.h:51
#define loop
Definition: structs.h:75

◆ slInitSsiExtension()

si_link_extension slInitSsiExtension ( si_link_extension  s)

Definition at line 1799 of file ssiLink.cc.

1800{
1801 s->Open=ssiOpen;
1802 s->Close=ssiClose;
1803 s->Kill=ssiClose;
1804 s->Read=ssiRead1;
1805 s->Read2=(slRead2Proc)NULL;
1806 s->Write=ssiWrite;
1807 s->Dump=ssiDump;
1808 s->GetDump=ssiGetDump;
1809
1810 s->Status=slStatusSsi;
1811 s->SetRing=ssiSetRing;
1812 s->type="ssi";
1813 return s;
1814}
const CanonicalForm int s
Definition: facAbsFact.cc:51

◆ slStatusSsi()

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

Definition at line 1816 of file ssiLink.cc.

1817{
1818 ssiInfo *d=(ssiInfo*)l->data;
1819 if (d==NULL) return "not open";
1820 if (((strcmp(l->mode,"fork")==0)
1821 ||(strcmp(l->mode,"tcp")==0)
1822 ||(strcmp(l->mode,"connect")==0))
1823 && (strcmp(request, "read") == 0))
1824 {
1825 fd_set mask;
1826 struct timeval wt;
1827 if (s_isready(d->f_read)) return "ready";
1828 loop
1829 {
1830 /* Don't block. Return socket status immediately. */
1831 wt.tv_sec = 0;
1832 wt.tv_usec = 0;
1833
1834 FD_ZERO(&mask);
1835 FD_SET(d->fd_read, &mask);
1836 //Print("test fd %d\n",d->fd_read);
1837 /* check with select: chars waiting: no -> not ready */
1838 switch (si_select(d->fd_read+1, &mask, NULL, NULL, &wt))
1839 {
1840 case 0: /* not ready */ return "not ready";
1841 case -1: /*error*/ return "error";
1842 case 1: /*ready ? */ break;
1843 }
1844 /* yes: read 1 char*/
1845 /* if \n, check again with select else ungetc(c), ready*/
1846 int c=s_getc(d->f_read);
1847 //Print("try c=%d\n",c);
1848 if (c== -1) return "eof"; /* eof or error */
1849 else if (isdigit(c))
1850 { s_ungetc(c,d->f_read); return "ready"; }
1851 else if (c>' ')
1852 {
1853 Werror("unknown char in ssiLink(%d)",c);
1854 return "error";
1855 }
1856 /* else: next char */
1857 }
1858 }
1859 else if (strcmp(request, "read") == 0)
1860 {
1861 if (SI_LINK_R_OPEN_P(l) && (!s_iseof(d->f_read)) && (s_isready(d->f_read))) return "ready";
1862 else return "not ready";
1863 }
1864 else if (strcmp(request, "write") == 0)
1865 {
1866 if (SI_LINK_W_OPEN_P(l)) return "ready";
1867 else return "not ready";
1868 }
1869 else return "unknown status request";
1870}
if(!FE_OPT_NO_SHELL_FLAG)(void) system(sys)
void Werror(const char *fmt,...)
Definition: reporter.cc:189
int s_getc(s_buff F)
Definition: s_buff.cc:58
int s_isready(s_buff F)
Definition: s_buff.cc:85
int s_iseof(s_buff F)
Definition: s_buff.cc:254
void s_ungetc(int c, s_buff F)
Definition: s_buff.cc:99
s_buff f_read
Definition: s_buff.h:22
int fd_read
Definition: s_buff.h:26

◆ slStatusSsiL()

int slStatusSsiL ( lists  L,
int  timeout 
)

Definition at line 1872 of file ssiLink.cc.

1873{
1874// input: L: a list with links of type
1875// ssi-connect, ssi-fork, ssi-tcp, MPtcp-fork or MPtcp-launch.
1876// Note: Not every entry in L must be set.
1877// timeout: timeout for select in micro-seconds
1878// or -1 for infinity
1879// or 0 for polling
1880// returns: ERROR (via Werror): L has wrong elements or link not open
1881// -2: select returns an error
1882// -1: the read state of all links is eof
1883// 0: timeout (or polling): none ready,
1884// i>0: (at least) L[i] is ready
1885 si_link l;
1886 ssiInfo *d;
1887 int d_fd;
1888 fd_set mask, fdmask;
1889 FD_ZERO(&fdmask);
1890 FD_ZERO(&mask);
1891 int max_fd=0; /* 1 + max fd in fd_set */
1892
1893 /* timeout */
1894 struct timeval wt;
1895 struct timeval *wt_ptr=&wt;
1896 int startingtime = getRTimer()/TIMER_RESOLUTION; // in seconds
1897 if (timeout== -1)
1898 {
1899 wt_ptr=NULL;
1900 }
1901 else
1902 {
1903 wt.tv_sec = timeout / 1000000;
1904 wt.tv_usec = timeout % 1000000;
1905 }
1906
1907 /* auxiliary variables */
1908 int i;
1909 int j;
1910 int k;
1911 int s;
1912 char fdmaskempty;
1913
1914 /* check the links and fill in fdmask */
1915 /* check ssi links for ungetc_buf */
1916 for(i=L->nr; i>=0; i--)
1917 {
1918 if (L->m[i].Typ()!=DEF_CMD)
1919 {
1920 if (L->m[i].Typ()!=LINK_CMD)
1921 { WerrorS("all elements must be of type link"); return -2;}
1922 l=(si_link)L->m[i].Data();
1923 if(SI_LINK_OPEN_P(l)==0)
1924 { WerrorS("all links must be open"); return -2;}
1925 if (((strcmp(l->m->type,"ssi")!=0) && (strcmp(l->m->type,"MPtcp")!=0))
1926 || ((strcmp(l->mode,"fork")!=0) && (strcmp(l->mode,"tcp")!=0)
1927 && (strcmp(l->mode,"launch")!=0) && (strcmp(l->mode,"connect")!=0)))
1928 {
1929 WerrorS("all links must be of type ssi:fork, ssi:tcp, ssi:connect");
1930 return -2;
1931 }
1932 if (strcmp(l->m->type,"ssi")==0)
1933 {
1934 d=(ssiInfo*)l->data;
1935 d_fd=d->fd_read;
1936 if (!s_isready(d->f_read))
1937 {
1938 FD_SET(d_fd, &fdmask);
1939 if (d_fd > max_fd) max_fd=d_fd;
1940 }
1941 else
1942 return i+1;
1943 }
1944 else
1945 {
1946 Werror("wrong link type >>%s<<",l->m->type);
1947 return -2;
1948 }
1949 }
1950 }
1951 max_fd++;
1952
1953do_select:
1954 /* copy fdmask to mask */
1955 FD_ZERO(&mask);
1956 for(k = 0; k < max_fd; k++)
1957 {
1958 if(FD_ISSET(k, &fdmask))
1959 {
1960 FD_SET(k, &mask);
1961 }
1962 }
1963
1964 /* check with select: chars waiting: no -> not ready */
1965 s = si_select(max_fd, &mask, NULL, NULL, wt_ptr);
1966 if (s==-1)
1967 {
1968 WerrorS("error in select call");
1969 return -2; /*error*/
1970 }
1971 if (s==0)
1972 {
1973 return 0; /*poll: not ready */
1974 }
1975 else /* s>0, at least one ready (the number of fd which are ready is s)*/
1976 {
1977 j=0;
1978 while (j<=max_fd) { if (FD_ISSET(j,&mask)) break; j++; }
1979 for(i=L->nr; i>=0; i--)
1980 {
1981 if (L->m[i].rtyp==LINK_CMD)
1982 {
1983 l=(si_link)L->m[i].Data();
1984 if (strcmp(l->m->type,"ssi")==0)
1985 {
1986 d=(ssiInfo*)l->data;
1987 d_fd=d->fd_read;
1988 if(j==d_fd) break;
1989 }
1990 else
1991 {
1992 Werror("wrong link type >>%s<<",l->m->type);
1993 return -2;
1994 }
1995 }
1996 }
1997 // only ssi links:
1998 loop
1999 {
2000 /* yes: read 1 char*/
2001 /* if \n, check again with select else ungetc(c), ready*/
2002 /* setting: d: current ssiInfo, j current fd, i current entry in L*/
2003 int c=s_getc(d->f_read);
2004 //Print("try c=%d\n",c);
2005 if (c== -1) /* eof */
2006 {
2007 FD_CLR(j,&fdmask);
2008 fdmaskempty = 1;
2009 for(k = 0; k < max_fd; k++)
2010 {
2011 if(FD_ISSET(k, &fdmask))
2012 {
2013 fdmaskempty = 0;
2014 break;
2015 }
2016 }
2017 if(fdmaskempty)
2018 {
2019 return -1;
2020 }
2021 if(timeout != -1)
2022 {
2023 timeout = si_max(0,
2024 timeout - 1000000*(getRTimer()/TIMER_RESOLUTION - startingtime));
2025 wt.tv_sec = timeout / 1000000;
2026 wt.tv_usec = (timeout % 1000000);
2027 }
2028 goto do_select;
2029 }
2030
2031 else if (isdigit(c))
2032 { s_ungetc(c,d->f_read); return i+1; }
2033 else if (c>' ')
2034 {
2035 Werror("unknown char in ssiLink(%d)",c);
2036 return -2;
2037 }
2038 /* else: next char */
2039 goto do_select;
2040 }
2041 }
2042}
static int si_max(const int a, const int b)
Definition: auxiliary.h:124
int i
Definition: cfEzgcd.cc:132
int k
Definition: cfEzgcd.cc:99
int Typ()
Definition: subexpr.cc:1030
void * Data()
Definition: subexpr.cc:1173
sleftv * m
Definition: lists.h:46
int nr
Definition: lists.h:44
int j
Definition: facHensel.cc:110
void WerrorS(const char *s)
Definition: feFopen.cc:24
#define TIMER_RESOLUTION
Definition: mod2.h:35
int getRTimer()
Definition: timer.cc:170

◆ ssiBatch()

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

Definition at line 2044 of file ssiLink.cc.

2046{
2048 char *buf=(char*)omAlloc(256);
2049 snprintf(buf,256,"ssi:connect %s:%s",host,port);
2050 slInit(l, buf);
2051 omFreeSize(buf,256);
2052 if (slOpen(l,SI_LINK_OPEN,NULL)) return 1;
2054
2055 idhdl id = enterid("link_ll", 0, LINK_CMD, &IDROOT, FALSE);
2056 IDLINK(id) = l;
2057
2058 loop
2059 {
2060 leftv h=ssiRead1(l); /*contains an exit.... */
2061 if (feErrors != NULL && *feErrors != '\0')
2062 {
2063 // handle errors:
2064 PrintS(feErrors); /* currently quite simple */
2065 *feErrors = '\0';
2066 }
2067 ssiWrite(l,h);
2068 h->CleanUp();
2070 }
2071 /* never reached*/
2072 exit(0);
2073}
Definition: idrec.h:35
idhdl enterid(const char *s, int lev, int t, idhdl *root, BOOLEAN init, BOOLEAN search)
Definition: ipid.cc:279
EXTERN_VAR omBin sleftv_bin
Definition: ipid.h:145
#define IDLINK(a)
Definition: ipid.h:138
#define IDROOT
Definition: ipid.h:19
#define omAlloc(size)
Definition: omAllocDecl.h:210
#define omAlloc0Bin(bin)
Definition: omAllocDecl.h:206
#define omFreeBin(addr, bin)
Definition: omAllocDecl.h:259
void PrintS(const char *s)
Definition: reporter.cc:284
VAR char * feErrors
Definition: reporter.cc:47
int status int void * buf
Definition: si_signals.h:59

◆ ssiCheckCurrRing()

static void ssiCheckCurrRing ( const ring  r)
static

Definition at line 119 of file ssiLink.cc.

120{
121 if ((r!=currRing)
122 ||(currRingHdl==NULL)
123 ||(IDRING(currRingHdl)!=r))
124 {
125 char name[20];
126 int nr=0;
127 idhdl h=NULL;
128 loop
129 {
130 snprintf(name,20,"ssiRing%d",nr); nr++;
131 h=IDROOT->get(name, 0);
132 if (h==NULL)
133 {
135 IDRING(h)=rIncRefCnt(r);
136 r->ref=2;/*ref==2: d->r and h */
137 break;
138 }
139 else if ((IDTYP(h)==RING_CMD)
140 && (rEqual(r,IDRING(h),1)))
141 {
142 break;
143 }
144 }
145 rSetHdl(h);
146 }
147 assume((currRing==r) || rEqual(r,currRing));
148}
char name(const Variable &v)
Definition: factory.h:189
VAR idhdl currRingHdl
Definition: ipid.cc:59
#define IDRING(a)
Definition: ipid.h:127
void rSetHdl(idhdl h)
Definition: ipshell.cc:5128
#define assume(x)
Definition: mod2.h:389
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
BOOLEAN rEqual(ring r1, ring r2, BOOLEAN qr)
returns TRUE, if r1 equals r2 FALSE, otherwise Equality is determined componentwise,...
Definition: ring.cc:1746
static ring rIncRefCnt(ring r)
Definition: ring.h:839

◆ ssiClose()

BOOLEAN ssiClose ( si_link  l)

Definition at line 1371 of file ssiLink.cc.

1372{
1373 if (l!=NULL)
1374 {
1376 ssiInfo *d = (ssiInfo *)l->data;
1377 if (d!=NULL)
1378 {
1379 // send quit signal
1380 if ((d->send_quit_at_exit)
1381 && (d->quit_sent==0))
1382 {
1383 fputs("99\n",d->f_write);
1384 fflush(d->f_write);
1385 }
1386 // clean ring
1387 if (d->r!=NULL) rKill(d->r);
1388 for(int i=0;i<SI_RING_CACHE;i++)
1389 {
1390 if (d->rings[i]!=NULL) rKill(d->rings[i]);
1391 d->rings[i]=NULL;
1392 }
1393 // did the child to stop ?
1394 si_waitpid(d->pid,NULL,WNOHANG);
1395 if ((d->pid!=0)
1396 && (kill(d->pid,0)==0)) // child is still running
1397 {
1398 struct timespec t;
1399 t.tv_sec=0;
1400 t.tv_nsec=100000000; // <=100 ms
1401 struct timespec rem;
1402 int r;
1403 loop
1404 {
1405 // wait till signal or time rem:
1406 r = nanosleep(&t, &rem);
1407 t = rem;
1408 // child finished:
1409 if (si_waitpid(d->pid,NULL,WNOHANG) != 0) break;
1410 // other signal, waited s>= 100 ms:
1411 if ((r==0) || (errno != EINTR)) break;
1412 }
1413 if (kill(d->pid,0) == 0) // pid still exists
1414 {
1415 kill(d->pid,15);
1416 t.tv_sec=5; // <=5s
1417 t.tv_nsec=0;
1418 loop
1419 {
1420 // wait till signal or time rem:
1421 r = nanosleep(&t, &rem);
1422 t = rem;
1423 // child finished:
1424 if (si_waitpid(d->pid,NULL,WNOHANG) != 0) break;
1425 // other signal, waited s>= 5 s:
1426 if ((r==0) || (errno != EINTR)) break;
1427 }
1428 if (kill(d->pid,0) == 0)
1429 {
1430 kill(d->pid,9); // just to be sure
1431 si_waitpid(d->pid,NULL,0);
1432 }
1433 }
1434 }
1435 if (d->f_read!=NULL) { s_close(d->f_read);d->f_read=NULL;}
1436 if (d->f_write!=NULL) { fclose(d->f_write); d->f_write=NULL; }
1437 if ((strcmp(l->mode,"tcp")==0)
1438 || (strcmp(l->mode,"fork")==0))
1439 {
1441 if (hh!=NULL)
1442 {
1443 if (hh->l==l)
1444 {
1446 omFreeSize(hh,sizeof(link_struct));
1447 }
1448 else while(hh->next!=NULL)
1449 {
1450 link_list hhh=(link_list)hh->next;
1451 if (hhh->l==l)
1452 {
1453 hh->next=hhh->next;
1454 omFreeSize(hhh,sizeof(link_struct));
1455 break;
1456 }
1457 else
1458 hh=(link_list)hh->next;
1459 }
1460 }
1461 }
1462 omFreeSize((ADDRESS)d,(sizeof *d));
1463 }
1464 l->data=NULL;
1465 }
1466 return FALSE;
1467}
void * ADDRESS
Definition: auxiliary.h:119
void rKill(ring r)
Definition: ipshell.cc:6182
void rem(unsigned long *a, unsigned long *q, unsigned long p, int &dega, int degq)
Definition: minpoly.cc:572
int s_close(s_buff &F)
Definition: s_buff.cc:45
ring rings[SI_RING_CACHE]
Definition: s_buff.h:31
#define SI_RING_CACHE
Definition: s_buff.h:30
char send_quit_at_exit
Definition: s_buff.h:28
char quit_sent
Definition: s_buff.h:29
FILE * f_write
Definition: s_buff.h:23
ring r
Definition: s_buff.h:24

◆ ssiCommandLink()

si_link ssiCommandLink ( )

Definition at line 2115 of file ssiLink.cc.

2116{
2117 if (ssiReserved_P==0)
2118 {
2119 WerrorS("ERROR no reserved port requested");
2120 return NULL;
2121 }
2122 struct sockaddr_in cli_addr;
2123 int clilen = sizeof(cli_addr);
2124 int newsockfd = si_accept(ssiReserved_sockfd, (struct sockaddr *) &cli_addr, (socklen_t *)&clilen);
2125 if(newsockfd < 0)
2126 {
2127 Werror("ERROR on accept (errno=%d)",errno);
2128 return NULL;
2129 }
2131 si_link_extension s = si_link_root;
2132 si_link_extension prev = s;
2133 while (strcmp(s->type, "ssi") != 0)
2134 {
2135 if (s->next == NULL)
2136 {
2137 prev = s;
2138 s = NULL;
2139 break;
2140 }
2141 else
2142 {
2143 s = s->next;
2144 }
2145 }
2146 if (s != NULL)
2147 l->m = s;
2148 else
2149 {
2150 si_link_extension ns = (si_link_extension)omAlloc0Bin(s_si_link_extension_bin);
2151 prev->next=slInitSsiExtension(ns);
2152 l->m = prev->next;
2153 }
2154 l->name=omStrDup("");
2155 l->mode=omStrDup("tcp");
2156 l->ref=1;
2157 ssiInfo *d=(ssiInfo*)omAlloc0(sizeof(ssiInfo));
2158 l->data=d;
2159 d->fd_read = newsockfd;
2160 d->fd_write = newsockfd;
2161 d->f_read = s_open(newsockfd);
2162 d->f_write = fdopen(newsockfd, "w");
2165 if (ssiReserved_Clients<=0)
2166 {
2167 ssiReserved_P=0;
2168 si_close(ssiReserved_sockfd);
2169 }
2170 return l;
2171}
#define omStrDup(s)
Definition: omAllocDecl.h:263
s_buff s_open(int fd)
Definition: s_buff.cc:31
int fd_write
Definition: s_buff.h:26

◆ ssiDump()

BOOLEAN ssiDump ( si_link  l)

Definition at line 2331 of file ssiLink.cc.

2332{
2333 idhdl h = IDROOT, rh = currRingHdl;
2335
2336 //if (! status ) status = DumpAsciiMaps(fd, h, NULL);
2337
2338 if (currRingHdl != rh) rSetHdl(rh);
2339 //fprintf(fd, "option(set, intvec(%d, %d));\n", si_opt_1, si_opt_2);
2340
2341 return status;
2342}
int BOOLEAN
Definition: auxiliary.h:87

◆ ssiDumpIter()

static BOOLEAN ssiDumpIter ( si_link  l,
idhdl  h 
)
static

Definition at line 2310 of file ssiLink.cc.

2311{
2312 if (h == NULL) return FALSE;
2313
2314 if (ssiDumpIter(l, IDNEXT(h))) return TRUE;
2315
2316 // need to set the ring before writing it, otherwise we get in
2317 // trouble with minpoly
2318 if (IDTYP(h) == RING_CMD)
2319 rSetHdl(h);
2320
2321 if (DumpSsiIdhdl(l, h)) return TRUE;
2322
2323 // do not dump ssi internal rings: ssiRing*
2324 // but dump objects of all other rings
2325 if ((IDTYP(h) == RING_CMD)
2326 && (strncmp(IDID(h),"ssiRing",7)!=0))
2327 return ssiDumpIter(l, IDRING(h)->idroot);
2328 else
2329 return FALSE;
2330}
#define IDNEXT(a)
Definition: ipid.h:118

◆ ssiGetDump()

BOOLEAN ssiGetDump ( si_link  l)

Definition at line 2343 of file ssiLink.cc.

2344{
2345 ssiInfo *d=(ssiInfo*)l->data;
2346 loop
2347 {
2348 if (!SI_LINK_OPEN_P(l)) break;
2349 if (s_iseof(d->f_read)) break;
2350 leftv h=ssiRead1(l); /*contains an exit.... */
2351 if (feErrors != NULL && *feErrors != '\0')
2352 {
2353 // handle errors:
2354 PrintS(feErrors); /* currently quite simple */
2355 return TRUE;
2356 *feErrors = '\0';
2357 }
2358 h->CleanUp();
2360 }
2361 return FALSE;
2362}

◆ ssiOpen()

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

Definition at line 957 of file ssiLink.cc.

958{
959 if (l!=NULL)
960 {
961 const char *mode;
962 ssiInfo *d=(ssiInfo*)omAlloc0(sizeof(ssiInfo));
963 if (flag & SI_LINK_OPEN)
964 {
965 if (l->mode[0] != '\0' && (strcmp(l->mode, "r") == 0))
966 flag = SI_LINK_READ;
967 else flag = SI_LINK_WRITE;
968 }
969
970 if (flag == SI_LINK_READ) mode = "r";
971 else if (strcmp(l->mode, "w") == 0) mode = "w";
972 else if (strcmp(l->mode, "fork") == 0) mode = "fork";
973 else if (strcmp(l->mode, "tcp") == 0) mode = "tcp";
974 else if (strcmp(l->mode, "connect") == 0) mode = "connect";
975 else mode = "a";
976
977
978 SI_LINK_SET_OPEN_P(l, flag);
979 if(l->data!=NULL) omFreeSize(l->data,sizeof(ssiInfo));
980 l->data=d;
981 omFreeBinAddr(l->mode);
982 l->mode = omStrDup(mode);
983
984 if (l->name[0] == '\0')
985 {
986 if (strcmp(mode,"fork")==0)
987 {
989 n->u=u;
990 n->l=l;
991 n->next=(void *)ssiToBeClosed;
993
994 int pc[2];
995 int cp[2];
996 pipe(pc);
997 pipe(cp);
998 pid_t pid = fork();
999 if (pid == -1 && errno == EAGAIN) // RLIMIT_NPROC too low?
1000 {
1002 pid = fork();
1003 }
1004 if (pid == -1)
1005 {
1006 WerrorS("could not fork");
1007 }
1008 if (pid==0) /*fork: child*/
1009 {
1010 /* block SIGINT */
1011 sigset_t sigint;
1012 sigemptyset(&sigint);
1013 sigaddset(&sigint, SIGINT);
1014 sigprocmask(SIG_BLOCK, &sigint, NULL);
1015 /* set #cpu to 1 for the child:*/
1016 feSetOptValue(FE_OPT_CPUS,1);
1017
1019 /* we know: l is the first entry in ssiToBeClosed-list */
1020 while(hh!=NULL)
1021 {
1023 ssiInfo *dd=(ssiInfo*)hh->l->data;
1024 s_close(dd->f_read);
1025 fclose(dd->f_write);
1026 if (dd->r!=NULL) rKill(dd->r);
1027 omFreeSize((ADDRESS)dd,(sizeof *dd));
1028 hh->l->data=NULL;
1029 link_list nn=(link_list)hh->next;
1030 omFree(hh);
1031 hh=nn;
1032 }
1034#ifdef HAVE_SIMPLEIPC
1035 memset(sem_acquired, 0, SIPC_MAX_SEMAPHORES*sizeof(sem_acquired[0]));
1036#endif // HAVE_SIMPLEIPC
1037 si_close(pc[1]); si_close(cp[0]);
1038 d->f_write=fdopen(cp[1],"w");
1039 d->f_read=s_open(pc[0]);
1040 d->fd_read=pc[0];
1041 d->fd_write=cp[1];
1042 //d->r=currRing;
1043 //if (d->r!=NULL) d->r->ref++;
1044 l->data=d;
1045 omFreeBinAddr(l->mode);
1046 l->mode = omStrDup(mode);
1049 //myynest=0;
1051 if ((u!=NULL)&&(u->rtyp==IDHDL))
1052 {
1053 idhdl h=(idhdl)u->data;
1054 h->lev=0;
1055 }
1056 loop
1057 {
1058 if (!SI_LINK_OPEN_P(l)) m2_end(0);
1059 if(d->f_read->is_eof) m2_end(0);
1060 leftv h=ssiRead1(l); /*contains an exit.... */
1061 if (feErrors != NULL && *feErrors != '\0')
1062 {
1063 // handle errors:
1064 PrintS(feErrors); /* currently quite simple */
1065 *feErrors = '\0';
1066 }
1067 ssiWrite(l,h);
1068 h->CleanUp();
1070 }
1071 /* never reached*/
1072 }
1073 else if (pid>0) /*fork: parent*/
1074 {
1075 d->pid=pid;
1076 si_close(pc[0]); si_close(cp[1]);
1077 d->f_write=fdopen(pc[1],"w");
1078 d->f_read=s_open(cp[0]);
1079 d->fd_read=cp[0];
1080 d->fd_write=pc[1];
1082 d->send_quit_at_exit=1;
1083 //d->r=currRing;
1084 //if (d->r!=NULL) d->r->ref++;
1085 }
1086 else
1087 {
1088 Werror("fork failed (%d)",errno);
1089 l->data=NULL;
1090 omFree(d);
1091 return TRUE;
1092 }
1093 }
1094 // ---------------------------------------------------------------------
1095 else if (strcmp(mode,"tcp")==0)
1096 {
1097 int sockfd, newsockfd, portno, clilen;
1098 struct sockaddr_in serv_addr, cli_addr;
1099 sockfd = socket(AF_INET, SOCK_STREAM, 0);
1100 if(sockfd < 0)
1101 {
1102 WerrorS("ERROR opening socket");
1103 l->data=NULL;
1104 l->flags=0;
1105 omFree(d);
1106 return TRUE;
1107 }
1108 memset((char *) &serv_addr,0, sizeof(serv_addr));
1109 portno = 1025;
1110 serv_addr.sin_family = AF_INET;
1111 serv_addr.sin_addr.s_addr = INADDR_ANY;
1112 do
1113 {
1114 portno++;
1115 serv_addr.sin_port = htons(portno);
1116 if(portno > 50000)
1117 {
1118 WerrorS("ERROR on binding (no free port available?)");
1119 l->data=NULL;
1120 l->flags=0;
1121 omFree(d);
1122 return TRUE;
1123 }
1124 }
1125 while(bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0);
1126 Print("waiting on port %d\n", portno);mflush();
1127 listen(sockfd,1);
1128 newsockfd = si_accept(sockfd, (struct sockaddr *) &cli_addr, (socklen_t *)&clilen);
1129 if(newsockfd < 0)
1130 {
1131 WerrorS("ERROR on accept");
1132 l->data=NULL;
1133 l->flags=0;
1134 omFree(d);
1135 return TRUE;
1136 }
1137 PrintS("client accepted\n");
1138 d->fd_read = newsockfd;
1139 d->fd_write = newsockfd;
1140 d->f_read = s_open(newsockfd);
1141 d->f_write = fdopen(newsockfd, "w");
1143 si_close(sockfd);
1144 }
1145 // no ssi-Link on stdin or stdout
1146 else
1147 {
1148 Werror("invalid mode >>%s<< for ssi",mode);
1149 l->data=NULL;
1150 l->flags=0;
1151 omFree(d);
1152 return TRUE;
1153 }
1154 }
1155 // =========================================================================
1156 else /*l->name=NULL*/
1157 {
1158 // tcp mode
1159 if(strcmp(mode,"tcp")==0)
1160 {
1161 int sockfd, newsockfd, portno, clilen;
1162 struct sockaddr_in serv_addr, cli_addr;
1163 sockfd = socket(AF_INET, SOCK_STREAM, 0);
1164 if(sockfd < 0)
1165 {
1166 WerrorS("ERROR opening socket");
1167 l->data=NULL;
1168 l->flags=0;
1169 omFree(d);
1170 return TRUE;
1171 }
1172 memset((char *) &serv_addr,0, sizeof(serv_addr));
1173 portno = 1025;
1174 serv_addr.sin_family = AF_INET;
1175 serv_addr.sin_addr.s_addr = INADDR_ANY;
1176 do
1177 {
1178 portno++;
1179 serv_addr.sin_port = htons(portno);
1180 if(portno > 50000)
1181 {
1182 WerrorS("ERROR on binding (no free port available?)");
1183 l->data=NULL;
1184 l->flags=0;
1185 return TRUE;
1186 }
1187 }
1188 while(bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0);
1189 //Print("waiting on port %d\n", portno);mflush();
1190 listen(sockfd,1);
1191 char* cli_host = (char*)omAlloc(256);
1192 char* path = (char*)omAlloc(1024);
1193 int r = si_sscanf(l->name,"%255[^:]:%s",cli_host,path);
1194 if(r == 0)
1195 {
1196 WerrorS("ERROR: no host specified");
1197 l->data=NULL;
1198 l->flags=0;
1199 omFree(d);
1200 omFree(path);
1201 omFree(cli_host);
1202 return TRUE;
1203 }
1204 else if(r == 1)
1205 {
1206 WarnS("program not specified, using /usr/local/bin/Singular");
1207 Warn("in line >>%s<<",my_yylinebuf);
1208 strcpy(path,"/usr/local/bin/Singular");
1209 }
1210 char* ssh_command = (char*)omAlloc(256);
1211 char* ser_host = (char*)omAlloc(64);
1212 gethostname(ser_host,64);
1213 if (strcmp(cli_host,"localhost")==0) /*avoid "ssh localhost" as key may change*/
1214 snprintf(ssh_command,256,"%s -q --batch --link=ssi --MPhost=%s --MPport=%d &",path,ser_host,portno);
1215 else
1216 snprintf(ssh_command,256,"ssh %s %s -q --batch --link=ssi --MPhost=%s --MPport=%d &",cli_host,path,ser_host,portno);
1217 //Print("client on %s started:%s\n",cli_host,path);
1218 omFree(path);
1219 omFree(cli_host);
1220 if (TEST_OPT_PROT) { Print("running >>%s<<\n",ssh_command); }
1221 system(ssh_command);
1222 omFree(ssh_command);
1223 omFree(ser_host);
1224 clilen = sizeof(cli_addr);
1225 newsockfd = si_accept(sockfd, (struct sockaddr *) &cli_addr, (socklen_t *)&clilen);
1226 if(newsockfd < 0)
1227 {
1228 WerrorS("ERROR on accept");
1229 l->data=NULL;
1230 l->flags=0;
1231 omFree(d);
1232 return TRUE;
1233 }
1234 //PrintS("client accepted\n");
1235 d->fd_read = newsockfd;
1236 d->fd_write = newsockfd;
1237 d->f_read = s_open(newsockfd);
1238 d->f_write = fdopen(newsockfd, "w");
1239 si_close(sockfd);
1241 d->send_quit_at_exit=1;
1242 link_list newlink=(link_list)omAlloc(sizeof(link_struct));
1243 newlink->u=u;
1244 newlink->l=l;
1245 newlink->next=(void *)ssiToBeClosed;
1246 ssiToBeClosed=newlink;
1247 fprintf(d->f_write,"98 %d %d %u %u\n",SSI_VERSION,MAX_TOK,si_opt_1,si_opt_2);
1248 }
1249 // ----------------------------------------------------------------------
1250 else if(strcmp(mode,"connect")==0)
1251 {
1252 char* host = (char*)omAlloc(256);
1253 int sockfd, portno;
1254 struct sockaddr_in serv_addr;
1255 struct hostent *server;
1256
1257 si_sscanf(l->name,"%255[^:]:%d",host,&portno);
1258 //Print("connect to host %s, port %d\n",host,portno);mflush();
1259 if (portno!=0)
1260 {
1261 sockfd = socket(AF_INET, SOCK_STREAM, 0);
1262 if (sockfd < 0)
1263 {
1264 WerrorS("ERROR opening socket");
1265 l->flags=0;
1266 return TRUE;
1267 }
1268 server = gethostbyname(host);
1269 if (server == NULL)
1270 {
1271 WerrorS("ERROR, no such host");
1272 l->flags=0;
1273 return TRUE;
1274 }
1275 memset((char *) &serv_addr, 0, sizeof(serv_addr));
1276 serv_addr.sin_family = AF_INET;
1277 memcpy((char *)&serv_addr.sin_addr.s_addr,
1278 (char *)server->h_addr,
1279 server->h_length);
1280 serv_addr.sin_port = htons(portno);
1281 if (si_connect(sockfd,(sockaddr*)&serv_addr,sizeof(serv_addr)) < 0)
1282 {
1283 Werror("ERROR connecting(errno=%d)",errno);
1284 l->flags=0;
1285 return TRUE;
1286 }
1287 //PrintS("connected\n");mflush();
1288 d->f_read=s_open(sockfd);
1289 d->fd_read=sockfd;
1290 d->f_write=fdopen(sockfd,"w");
1291 d->fd_write=sockfd;
1293 omFree(host);
1294 }
1295 else
1296 {
1297 l->data=NULL;
1298 l->flags=0;
1299 omFree(d);
1300 return TRUE;
1301 }
1302 }
1303 // ======================================================================
1304 else
1305 {
1306 // normal link to a file
1307 FILE *outfile;
1308 char *filename=l->name;
1309
1310 if(filename[0]=='>')
1311 {
1312 if (filename[1]=='>')
1313 {
1314 filename+=2;
1315 mode = "a";
1316 }
1317 else
1318 {
1319 filename++;
1320 mode="w";
1321 }
1322 }
1323 outfile=myfopen(filename,mode);
1324 if (outfile!=NULL)
1325 {
1326 if (strcmp(l->mode,"r")==0)
1327 {
1328 fclose(outfile);
1329 d->f_read=s_open_by_name(filename);
1330 }
1331 else
1332 {
1333 d->f_write = outfile;
1334 fprintf(d->f_write,"98 %d %d %u %u\n",SSI_VERSION,MAX_TOK,si_opt_1,si_opt_2);
1335 }
1336 }
1337 else
1338 {
1339 omFree(d);
1340 l->data=NULL;
1341 l->flags=0;
1342 return TRUE;
1343 }
1344 }
1345 }
1346 }
1347
1348 return FALSE;
1349}
VAR BOOLEAN singular_in_batchmode
Definition: cntrlc.cc:62
#define Print
Definition: emacs.cc:80
#define Warn
Definition: emacs.cc:77
#define WarnS
Definition: emacs.cc:78
FILE * myfopen(const char *path, const char *mode)
Definition: feFopen.cc:167
const char * feSetOptValue(feOptIndex opt, char *optarg)
Definition: feOpt.cc:154
VAR char my_yylinebuf[80]
Definition: febase.cc:44
char * fe_fgets_dummy(const char *, char *, int)
Definition: feread.cc:455
char *(* fe_fgets_stdin)(const char *pr, char *s, int size)
Definition: feread.cc:32
void m2_end(int i)
Definition: misc_ip.cc:1097
#define omFree(addr)
Definition: omAllocDecl.h:261
#define omFreeBinAddr(addr)
Definition: omAllocDecl.h:258
VAR unsigned si_opt_2
Definition: options.c:6
VAR unsigned si_opt_1
Definition: options.c:5
#define TEST_OPT_PROT
Definition: options.h:103
#define mflush()
Definition: reporter.h:58
idrec * idhdl
Definition: ring.h:21
int raise_rlimit_nproc()
Definition: rlimit.c:18
s_buff s_open_by_name(const char *n)
Definition: s_buff.cc:39
VAR int sem_acquired[SIPC_MAX_SEMAPHORES]
Definition: semaphore.c:25
#define SIPC_MAX_SEMAPHORES
Definition: simpleipc.h:10
#define IDHDL
Definition: tok.h:31
@ MAX_TOK
Definition: tok.h:218

◆ ssiPrepClose()

static BOOLEAN ssiPrepClose ( si_link  l)
static

Definition at line 1352 of file ssiLink.cc.

1353{
1354 if (l!=NULL)
1355 {
1357 ssiInfo *d = (ssiInfo *)l->data;
1358 if (d!=NULL)
1359 {
1360 if (d->send_quit_at_exit)
1361 {
1362 fputs("99\n",d->f_write);
1363 fflush(d->f_write);
1364 }
1365 d->quit_sent=1;
1366 }
1367 }
1368 return FALSE;
1369}

◆ ssiRead1()

leftv ssiRead1 ( si_link  l)

Definition at line 1470 of file ssiLink.cc.

1471{
1472 ssiInfo *d = (ssiInfo *)l->data;
1474 int t=0;
1475 t=s_readint(d->f_read);
1476 //Print("got type %d\n",t);
1477 switch(t)
1478 {
1479 case 1:res->rtyp=INT_CMD;
1480 res->data=(char *)(long)ssiReadInt(d->f_read);
1481 break;
1482 case 2:res->rtyp=STRING_CMD;
1483 res->data=(char *)ssiReadString(d);
1484 break;
1485 case 3:res->rtyp=NUMBER_CMD;
1486 if (d->r==NULL) goto no_ring;
1487 ssiCheckCurrRing(d->r);
1488 res->data=(char *)ssiReadNumber(d);
1489 break;
1490 case 4:res->rtyp=BIGINT_CMD;
1491 res->data=(char *)ssiReadBigInt(d);
1492 break;
1493 case 15:
1494 case 5:{
1495 d->r=ssiReadRing(d);
1496 if (errorreported) return NULL;
1497 res->data=(char*)d->r;
1498 if (d->r!=NULL) rIncRefCnt(d->r);
1499 res->rtyp=RING_CMD;
1500 if (t==15) // setring
1501 {
1502 if(ssiSetCurrRing(d->r)) { d->r=currRing; }
1504 return ssiRead1(l);
1505 }
1506 }
1507 break;
1508 case 6:res->rtyp=POLY_CMD;
1509 if (d->r==NULL) goto no_ring;
1510 ssiCheckCurrRing(d->r);
1511 res->data=(char*)ssiReadPoly(d);
1512 break;
1513 case 7:res->rtyp=IDEAL_CMD;
1514 if (d->r==NULL) goto no_ring;
1515 ssiCheckCurrRing(d->r);
1516 res->data=(char*)ssiReadIdeal(d);
1517 break;
1518 case 8:res->rtyp=MATRIX_CMD;
1519 if (d->r==NULL) goto no_ring;
1520 ssiCheckCurrRing(d->r);
1521 res->data=(char*)ssiReadMatrix(d);
1522 break;
1523 case 9:res->rtyp=VECTOR_CMD;
1524 if (d->r==NULL) goto no_ring;
1525 ssiCheckCurrRing(d->r);
1526 res->data=(char*)ssiReadPoly(d);
1527 break;
1528 case 10:
1529 case 22:if (t==22) res->rtyp=SMATRIX_CMD;
1530 else res->rtyp=MODUL_CMD;
1531 if (d->r==NULL) goto no_ring;
1532 ssiCheckCurrRing(d->r);
1533 {
1534 int rk=s_readint(d->f_read);
1535 ideal M=ssiReadIdeal(d);
1536 M->rank=rk;
1537 res->data=(char*)M;
1538 }
1539 break;
1540 case 11:
1541 {
1542 res->rtyp=COMMAND;
1543 res->data=ssiReadCommand(l);
1544 int nok=res->Eval();
1545 if (nok) WerrorS("error in eval");
1546 break;
1547 }
1548 case 12: /*DEF_CMD*/
1549 {
1550 res->rtyp=0;
1551 res->name=(char *)ssiReadString(d);
1552 int nok=res->Eval();
1553 if (nok) WerrorS("error in name lookup");
1554 break;
1555 }
1556 case 13: res->rtyp=PROC_CMD;
1557 res->data=ssiReadProc(d);
1558 break;
1559 case 14: res->rtyp=LIST_CMD;
1560 res->data=ssiReadList(l);
1561 break;
1562 case 16: res->rtyp=NONE; res->data=NULL;
1563 break;
1564 case 17: res->rtyp=INTVEC_CMD;
1565 res->data=ssiReadIntvec(d);
1566 break;
1567 case 18: res->rtyp=INTMAT_CMD;
1568 res->data=ssiReadIntmat(d);
1569 break;
1570 case 19: res->rtyp=BIGINTMAT_CMD;
1571 res->data=ssiReadBigintmat(d);
1572 break;
1573 case 20: ssiReadBlackbox(res,l);
1574 break;
1575 case 21: ssiReadAttrib(res,l);
1576 break;
1577 case 23: ssiReadRingProperties(l);
1578 return ssiRead1(l);
1579 break;
1580 // ------------
1581 case 98: // version
1582 {
1583 int n98_v,n98_m;
1584 BITSET n98_o1,n98_o2;
1585 n98_v=s_readint(d->f_read);
1586 n98_m=s_readint(d->f_read);
1587 n98_o1=s_readint(d->f_read);
1588 n98_o2=s_readint(d->f_read);
1589 if ((n98_v!=SSI_VERSION) ||(n98_m!=MAX_TOK))
1590 {
1591 Print("incompatible versions of ssi: %d/%d vs %d/%d\n",
1592 SSI_VERSION,MAX_TOK,n98_v,n98_m);
1593 }
1594 #ifndef SING_NDEBUG
1595 if (TEST_OPT_DEBUG)
1596 Print("// opening ssi-%d, MAX_TOK=%d\n",n98_v,n98_m);
1597 #endif
1598 si_opt_1=n98_o1;
1599 si_opt_2=n98_o2;
1601 return ssiRead1(l);
1602 }
1603 case 99: omFreeBin(res,sleftv_bin); ssiClose(l); m2_end(0);
1604 case 0: if (s_iseof(d->f_read))
1605 {
1606 ssiClose(l);
1607 }
1608 res->rtyp=DEF_CMD;
1609 break;
1610 default: Werror("not implemented (t:%d)",t);
1612 res=NULL;
1613 break;
1614 }
1615 // if currRing is required for the result, but lost
1616 // define "ssiRing%d" as currRing:
1617 if ((d->r!=NULL)
1618 && (currRing!=d->r)
1619 && (res->RingDependend()))
1620 {
1621 if(ssiSetCurrRing(d->r)) { d->r=currRing; }
1622 }
1623 return res;
1624no_ring: WerrorS("no ring");
1626 return NULL;
1627}
CanonicalForm res
Definition: facAbsFact.cc:60
VAR short errorreported
Definition: feFopen.cc:23
@ IDEAL_CMD
Definition: grammar.cc:284
@ MATRIX_CMD
Definition: grammar.cc:286
@ BIGINTMAT_CMD
Definition: grammar.cc:278
@ INTMAT_CMD
Definition: grammar.cc:279
@ MODUL_CMD
Definition: grammar.cc:287
@ SMATRIX_CMD
Definition: grammar.cc:291
@ VECTOR_CMD
Definition: grammar.cc:292
@ NUMBER_CMD
Definition: grammar.cc:288
@ POLY_CMD
Definition: grammar.cc:289
#define TEST_OPT_DEBUG
Definition: options.h:108
int s_readint(s_buff F)
Definition: s_buff.cc:112
#define M
Definition: sirandom.c:25
#define BITSET
Definition: structs.h:16
@ BIGINT_CMD
Definition: tok.h:38
@ LIST_CMD
Definition: tok.h:118
@ INTVEC_CMD
Definition: tok.h:101
@ INT_CMD
Definition: tok.h:96
#define NONE
Definition: tok.h:221

◆ ssiReadAttrib()

static void ssiReadAttrib ( leftv  res,
si_link  l 
)
static

Definition at line 896 of file ssiLink.cc.

897{
898 ssiInfo *d=(ssiInfo*)l->data;
900 int nr_of_attr=s_readint(d->f_read);
901 if (nr_of_attr>0)
902 {
903 for(int i=1;i<nr_of_attr;i++)
904 {
905 }
906 }
907 leftv tmp=ssiRead1(l);
908 memcpy(res,tmp,sizeof(sleftv));
909 memset(tmp,0,sizeof(sleftv));
911 if (nr_of_attr>0)
912 {
913 }
914 res->flag=fl;
915}

◆ ssiReadBigInt()

static number ssiReadBigInt ( const ssiInfo d)
static

Definition at line 510 of file ssiLink.cc.

511{
513 if ((SR_HDL(n) & SR_INT)==0)
514 {
515 if (n->s!=3) Werror("invalid sub type in bigint:%d",n->s);
516 }
517 return n;
518}
VAR coeffs coeffs_BIGINT
Definition: ipid.cc:50
#define SR_INT
Definition: longrat.h:67
#define SR_HDL(A)
Definition: tgb.cc:35

◆ ssiReadBigintmat()

static bigintmat * ssiReadBigintmat ( const ssiInfo d)
static

Definition at line 855 of file ssiLink.cc.

856{
857 int r,c;
858 r=s_readint(d->f_read);
859 c=s_readint(d->f_read);
861 for(int i=0;i<r*c;i++)
862 {
863 (*v)[i]=ssiReadBigInt(d);
864 }
865 return v;
866}
Matrices of numbers.
Definition: bigintmat.h:51
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:39

◆ ssiReadBlackbox()

static void ssiReadBlackbox ( leftv  res,
si_link  l 
)
static

Definition at line 868 of file ssiLink.cc.

869{
870 ssiInfo *d=(ssiInfo*)l->data;
871 int throwaway=s_readint(d->f_read);
872 char *name=ssiReadString(d);
873 int tok;
874 blackboxIsCmd(name,tok);
875 if (tok>MAX_TOK)
876 {
877 ring save_ring=currRing;
878 idhdl save_hdl=currRingHdl;
879 blackbox *b=getBlackboxStuff(tok);
880 res->rtyp=tok;
881 b->blackbox_deserialize(&b,&(res->data),l);
882 if (save_ring!=currRing)
883 {
884 rChangeCurrRing(save_ring);
885 if (save_hdl!=NULL) rSetHdl(save_hdl);
886 else currRingHdl=NULL;
887 }
888 }
889 else
890 {
891 Werror("blackbox %s not found",name);
892 }
893 omFree(name);
894}
blackbox * getBlackboxStuff(const int t)
return the structure to the type given by t
Definition: blackbox.cc:17
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:219
CanonicalForm b
Definition: cfModGcd.cc:4103
void rChangeCurrRing(ring r)
Definition: polys.cc:15

◆ ssiReadCommand()

static command ssiReadCommand ( si_link  l)
static

Definition at line 758 of file ssiLink.cc.

759{
760 ssiInfo *d=(ssiInfo*)l->data;
761 // syntax: <num ops> <operation> <op1> <op2> ....
762 command D=(command)omAlloc0(sizeof(*D));
763 int argc,op;
764 argc=s_readint(d->f_read);
765 op=s_readint(d->f_read);
766 D->argc=argc; D->op=op;
767 leftv v;
768 if (argc >0)
769 {
770 v=ssiRead1(l);
771 memcpy(&(D->arg1),v,sizeof(*v));
773 }
774 if (argc <4)
775 {
776 if (D->argc >1)
777 {
778 v=ssiRead1(l);
779 memcpy(&(D->arg2),v,sizeof(*v));
781 }
782 if (D->argc >2)
783 {
784 v=ssiRead1(l);
785 memcpy(&(D->arg3),v,sizeof(*v));
787 }
788 }
789 else
790 {
791 leftv prev=&(D->arg1);
792 argc--;
793 while(argc >0)
794 {
795 v=ssiRead1(l);
796 prev->next=v;
797 prev=v;
798 argc--;
799 }
800 }
801 return D;
802}
leftv next
Definition: subexpr.h:86

◆ ssiReadIdeal()

static ideal ssiReadIdeal ( ssiInfo d)
static

Definition at line 737 of file ssiLink.cc.

738{
739 return ssiReadIdeal_R(d,d->r);
740}

◆ ssiReadIdeal_R()

static ideal ssiReadIdeal_R ( const ssiInfo d,
const ring  r 
)
static

Definition at line 723 of file ssiLink.cc.

724{
725// < # of terms> < term1> < .....
726 int n,i;
727 ideal I;
728 n=s_readint(d->f_read);
729 I=idInit(n,1); // will be fixed later for module/smatrix
730 for(i=0;i<IDELEMS(I);i++) // read n terms
731 {
732 I->m [i]=ssiReadPoly_R(d,r);
733 }
734 return I;
735}
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:35
#define IDELEMS(i)
Definition: simpleideals.h:23

◆ ssiReadInt()

static int ssiReadInt ( s_buff  fich)
static

Definition at line 481 of file ssiLink.cc.

482{
483 return s_readint(fich);
484}

◆ ssiReadIntmat()

static intvec * ssiReadIntmat ( const ssiInfo d)
static

Definition at line 843 of file ssiLink.cc.

844{
845 int r,c;
846 r=s_readint(d->f_read);
847 c=s_readint(d->f_read);
848 intvec *v=new intvec(r,c,0);
849 for(int i=0;i<r*c;i++)
850 {
851 (*v)[i]=s_readint(d->f_read);
852 }
853 return v;
854}
Definition: intvec.h:23

◆ ssiReadIntvec()

static intvec * ssiReadIntvec ( const ssiInfo d)
static

Definition at line 832 of file ssiLink.cc.

833{
834 int nr;
835 nr=s_readint(d->f_read);
836 intvec *v=new intvec(nr);
837 for(int i=0;i<nr;i++)
838 {
839 (*v)[i]=s_readint(d->f_read);
840 }
841 return v;
842}

◆ ssiReadList()

static lists ssiReadList ( si_link  l)
static

Definition at line 814 of file ssiLink.cc.

815{
816 ssiInfo *d=(ssiInfo*)l->data;
817 int nr;
818 nr=s_readint(d->f_read);
820 L->Init(nr);
821
822 int i;
823 leftv v;
824 for(i=0;i<=L->nr;i++)
825 {
826 v=ssiRead1(l);
827 memcpy(&(L->m[i]),v,sizeof(*v));
829 }
830 return L;
831}
Definition: lists.h:24
INLINE_THIS void Init(int l=0)
VAR omBin slists_bin
Definition: lists.cc:23
slists * lists
Definition: mpr_numeric.h:146

◆ ssiReadMatrix()

static matrix ssiReadMatrix ( ssiInfo d)
static

Definition at line 742 of file ssiLink.cc.

743{
744 int n,m;
745 m=s_readint(d->f_read);
746 n=s_readint(d->f_read);
747 matrix M=mpNew(m,n);
748 poly p;
749 for(int i=1;i<=MATROWS(M);i++)
750 for(int j=1;j<=MATCOLS(M);j++)
751 {
752 p=ssiReadPoly(d);
753 MATELEM(M,i,j)=p;
754 }
755 return M;
756}
int m
Definition: cfEzgcd.cc:128
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:37
#define MATELEM(mat, i, j)
1-based access to matrix
Definition: matpol.h:29
#define MATROWS(i)
Definition: matpol.h:26
#define MATCOLS(i)
Definition: matpol.h:27

◆ ssiReadNumber()

static number ssiReadNumber ( ssiInfo d)
static

Definition at line 520 of file ssiLink.cc.

521{
522 return ssiReadNumber_CF(d,d->r->cf);
523}

◆ ssiReadNumber_CF()

static number ssiReadNumber_CF ( const ssiInfo d,
const coeffs  cf 
)
static

Definition at line 486 of file ssiLink.cc.

487{
488 if (cf->cfReadFd!=ndReadFd)
489 {
490 return n_ReadFd(d,cf);
491 }
492 else if (getCoeffType(cf) == n_transExt)
493 {
494 // poly poly
495 fraction f=(fraction)n_Init(1,cf);
496 p_Delete(&NUM(f),cf->extRing);
497 NUM(f)=ssiReadPoly_R(d,cf->extRing);
498 DEN(f)=ssiReadPoly_R(d,cf->extRing);
499 return (number)f;
500 }
501 else if (getCoeffType(cf) == n_algExt)
502 {
503 // poly
504 return (number)ssiReadPoly_R(d,cf->extRing);
505 }
506 else WerrorS("coeffs not implemented in ssiReadNumber");
507 return NULL;
508}
CanonicalForm cf
Definition: cfModGcd.cc:4083
FILE * f
Definition: checklibs.c:9
static FORCE_INLINE number n_ReadFd(const ssiInfo *f, const coeffs r)
io via ssi:
Definition: coeffs.h:971
@ n_algExt
used for all algebraic extensions, i.e., the top-most extension in an extension tower is algebraic
Definition: coeffs.h:35
@ n_transExt
used for all transcendental extensions, i.e., the top-most extension in an extension tower is transce...
Definition: coeffs.h:38
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:422
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:535
number ndReadFd(const ssiInfo *, const coeffs r)
Definition: numbers.cc:152
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:901
@ NUM
Definition: readcf.cc:170

◆ ssiReadPoly()

static poly ssiReadPoly ( ssiInfo d)
static

Definition at line 718 of file ssiLink.cc.

719{
720 return ssiReadPoly_R(d,d->r);
721}

◆ ssiReadPoly_R()

static poly ssiReadPoly_R ( const ssiInfo D,
const ring  r 
)
static

Definition at line 687 of file ssiLink.cc.

688{
689// < # of terms> < term1> < .....
690 int n,i,l;
691 n=ssiReadInt(d->f_read); // # of terms
692 //Print("poly: terms:%d\n",n);
693 poly p;
694 poly ret=NULL;
695 poly prev=NULL;
696 for(l=0;l<n;l++) // read n terms
697 {
698// coef,comp.exp1,..exp N
699 p=p_Init(r,r->PolyBin);
700 pSetCoeff0(p,ssiReadNumber_CF(d,r->cf));
701 int D;
702 D=s_readint(d->f_read);
703 p_SetComp(p,D,r);
704 for(i=1;i<=rVar(r);i++)
705 {
706 D=s_readint(d->f_read);
707 p_SetExp(p,i,D,r);
708 }
709 p_Setm(p,r);
710 p_Test(p,r);
711 if (ret==NULL) ret=p;
712 else pNext(prev)=p;
713 prev=p;
714 }
715 return ret;
716}
#define pNext(p)
Definition: monomials.h:36
#define pSetCoeff0(p, n)
Definition: monomials.h:59
static unsigned long p_SetExp(poly p, const unsigned long e, const unsigned long iBitmask, const int VarOffset)
set a single variable exponent @Note: VarOffset encodes the position in p->exp
Definition: p_polys.h:488
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition: p_polys.h:247
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:233
static poly p_Init(const ring r, omBin bin)
Definition: p_polys.h:1320
#define p_Test(p, r)
Definition: p_polys.h:161
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:592

◆ ssiReadProc()

static procinfov ssiReadProc ( const ssiInfo d)
static

Definition at line 804 of file ssiLink.cc.

805{
806 char *s=ssiReadString(d);
808 p->language=LANG_SINGULAR;
809 p->libname=omStrDup("");
810 p->procname=omStrDup("");
811 p->data.s.body=s;
812 return p;
813}
procinfo * procinfov
Definition: structs.h:60
VAR omBin procinfo_bin
Definition: subexpr.cc:42

◆ ssiReadRing()

static ring ssiReadRing ( ssiInfo d)
static

Definition at line 525 of file ssiLink.cc.

526{
527/* syntax is <ch> <N> <l1> <v1> ...<lN> <vN> <number of orderings> <ord1> <block0_1> <block1_1> .... <Q-ideal> */
528 int ch;
529 int new_ref=-1;
530 ch=s_readint(d->f_read);
531 if (ch==-6)
532 {
533 new_ref=s_readint(d->f_read);
534 ch=s_readint(d->f_read);
535 }
536 if (ch==-5)
537 {
538 int index=s_readint(d->f_read);
539 ring r=d->rings[index];
540 rIncRefCnt(r);
541 return r;
542 }
543 if (ch==-4)
544 return NULL;
545 int N=s_readint(d->f_read);
546 char **names;
547 coeffs cf=NULL;
548 if (ch==-3)
549 {
550 char *cf_name=ssiReadString(d);
551 cf=nFindCoeffByName(cf_name);
552 if (cf==NULL)
553 {
554 Werror("cannot find cf:%s",cf_name);
555 omFreeBinAddr(cf_name);
556 return NULL;
557 }
558 }
559 if (N!=0)
560 {
561 names=(char**)omAlloc(N*sizeof(char*));
562 for(int i=0;i<N;i++)
563 {
564 names[i]=ssiReadString(d);
565 }
566 }
567 // read the orderings:
568 int num_ord; // number of orderings
569 num_ord=s_readint(d->f_read);
570 rRingOrder_t *ord=(rRingOrder_t *)omAlloc0((num_ord+1)*sizeof(rRingOrder_t));
571 int *block0=(int *)omAlloc0((num_ord+1)*sizeof(int));
572 int *block1=(int *)omAlloc0((num_ord+1)*sizeof(int));
573 int **wvhdl=(int**)omAlloc0((num_ord+1)*sizeof(int*));
574 for(int i=0;i<num_ord;i++)
575 {
576 ord[i]=(rRingOrder_t)s_readint(d->f_read);
577 block0[i]=s_readint(d->f_read);
578 block1[i]=s_readint(d->f_read);
579 switch(ord[i])
580 {
581 case ringorder_a:
582 case ringorder_wp:
583 case ringorder_Wp:
584 case ringorder_ws:
585 case ringorder_Ws:
586 case ringorder_aa:
587 {
588 wvhdl[i]=(int*)omAlloc((block1[i]-block0[i]+1)*sizeof(int));
589 int ii;
590 for(ii=block0[i];ii<=block1[i];ii++)
591 wvhdl[i][ii-block0[i]]=s_readint(d->f_read);
592 }
593 break;
594
595 case ringorder_a64:
596 case ringorder_M:
597 case ringorder_L:
598 case ringorder_IS:
599 Werror("ring oder not implemented for ssi:%d",ord[i]);
600 break;
601
602 default: break;
603 }
604 }
605 if (N==0)
606 {
607 omFree(ord);
608 omFree(block0);
609 omFree(block1);
610 omFree(wvhdl);
611 return NULL;
612 }
613 else
614 {
615 ring r=NULL;
616 if (ch>=0) /* Q, Z/p */
617 r=rDefault(ch,N,names,num_ord,ord,block0,block1,wvhdl);
618 else if (ch==-1) /* trans ext. */
619 {
621 T.r=ssiReadRing(d);
622 if (T.r==NULL) return NULL;
624 r=rDefault(cf,N,names,num_ord,ord,block0,block1,wvhdl);
625 }
626 else if (ch==-2) /* alg ext. */
627 {
629 T.r=ssiReadRing(d); /* includes qideal */
630 if (T.r==NULL) return NULL;
632 r=rDefault(cf,N,names,num_ord,ord,block0,block1,wvhdl);
633 }
634 else if (ch==-3)
635 {
636 r=rDefault(cf,N,names,num_ord,ord,block0,block1,wvhdl);
637 }
638 else
639 {
640 Werror("ssi: read unknown coeffs type (%d)",ch);
641 for(int i=0;i<N;i++)
642 {
643 omFree(names[i]);
644 }
645 omFreeSize(names,N*sizeof(char*));
646 return NULL;
647 }
648 ideal q=ssiReadIdeal_R(d,r);
649 if (IDELEMS(q)==0) omFreeBin(q,sip_sideal_bin);
650 else r->qideal=q;
651 for(int i=0;i<N;i++)
652 {
653 omFree(names[i]);
654 }
655 omFreeSize(names,N*sizeof(char*));
656 rIncRefCnt(r);
657 // check if such ring already exist as ssiRing*
658 char name[20];
659 int nr=0;
660 idhdl h=NULL;
661 loop
662 {
663 snprintf(name,20,"ssiRing%d",nr); nr++;
664 h=IDROOT->get(name, 0);
665 if (h==NULL)
666 {
667 break;
668 }
669 else if ((IDTYP(h)==RING_CMD)
670 && (r!=IDRING(h))
671 && (rEqual(r,IDRING(h),1)))
672 {
673 rDelete(r);
674 r=rIncRefCnt(IDRING(h));
675 break;
676 }
677 }
678 if (new_ref!=-1)
679 {
680 d->rings[new_ref]=r;
681 rIncRefCnt(r);
682 }
683 return r;
684 }
685}
const CanonicalForm CFMap CFMap & N
Definition: cfEzgcd.cc:56
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
Definition: numbers.cc:414
STATIC_VAR jList * T
Definition: janet.cc:30
The main handler for Singular numbers which are suitable for Singular polynomials.
coeffs nFindCoeffByName(char *cf_name)
find an existing coeff by its "CoeffName"
Definition: numbers.cc:646
static int index(p_Length length, p_Ord ord)
Definition: p_Procs_Impl.h:592
void rDelete(ring r)
unconditionally deletes fields in r
Definition: ring.cc:450
ring rDefault(const coeffs cf, int N, char **n, int ord_size, rRingOrder_t *ord, int *block0, int *block1, int **wvhdl, unsigned long bitmask)
Definition: ring.cc:102
rRingOrder_t
order stuff
Definition: ring.h:68
@ ringorder_a
Definition: ring.h:70
@ ringorder_a64
for int64 weights
Definition: ring.h:71
@ ringorder_L
Definition: ring.h:89
@ ringorder_aa
for idElimination, like a, except pFDeg, pWeigths ignore it
Definition: ring.h:91
@ ringorder_Wp
Definition: ring.h:82
@ ringorder_ws
Definition: ring.h:86
@ ringorder_Ws
Definition: ring.h:87
@ ringorder_IS
Induced (Schreyer) ordering.
Definition: ring.h:93
@ ringorder_wp
Definition: ring.h:81
@ ringorder_M
Definition: ring.h:74
VAR omBin sip_sideal_bin
Definition: simpleideals.cc:27
struct for passing initialization parameters to naInitChar
Definition: transext.h:88

◆ ssiReadRingProperties()

static void ssiReadRingProperties ( si_link  l)
static

Definition at line 916 of file ssiLink.cc.

917{
918 ssiInfo *d=(ssiInfo*)l->data;
919 int what=s_readint(d->f_read);
920 switch(what)
921 {
922 case 0: // bitmask
923 {
924 int lb=s_readint(d->f_read);
925 unsigned long bm=~0L;
926 bm=bm<<lb;
927 bm=~bm;
928 rUnComplete(d->r);
929 d->r->bitmask=bm;
930 rComplete(d->r);
931 break;
932 }
933 case 1: // LPRing
934 {
935 int lb=s_readint(d->f_read);
936 int isLPring=s_readint(d->f_read);
937 unsigned long bm=~0L;
938 bm=bm<<lb;
939 bm=~bm;
940 rUnComplete(d->r);
941 d->r->bitmask=bm;
942 d->r->isLPring=isLPring;
943 rComplete(d->r);
944 break;
945 }
946 case 2: // Plural rings
947 {
950 nc_CallPlural(C,D,NULL,NULL,d->r,true,true,false,d->r,false);
951 break;
952 }
953 }
954}
BOOLEAN nc_CallPlural(matrix cc, matrix dd, poly cn, poly dn, ring r, bool bSetupQuotient, bool bCopyInput, bool bBeQuiet, ring curr, bool dummy_ring=false)
returns TRUE if there were errors analyze inputs, check them for consistency detects nc_type,...
Definition: old.gring.cc:2692
BOOLEAN rComplete(ring r, int force)
this needs to be called whenever a new ring is created: new fields in ring are created (like VarOffse...
Definition: ring.cc:3450
void rUnComplete(ring r)
Definition: ring.cc:3965

◆ ssiReadString()

static char * ssiReadString ( const ssiInfo d)
static

Definition at line 468 of file ssiLink.cc.

469{
470 char *buf;
471 int l;
472 l=s_readint(d->f_read);
473 buf=(char*)omAlloc0(l+1);
474 int throwaway =s_getc(d->f_read); /* skip ' '*/
475 throwaway=s_readbytes(buf,l,d->f_read);
476 //if (throwaway!=l) printf("want %d, got %d bytes\n",l,throwaway);
477 buf[l]='\0';
478 return buf;
479}
int s_readbytes(char *buff, int len, s_buff F)
Definition: s_buff.cc:168

◆ ssiReservePort()

int ssiReservePort ( int  clients)

Definition at line 2079 of file ssiLink.cc.

2080{
2081 if (ssiReserved_P!=0)
2082 {
2083 WerrorS("ERROR already a reserved port requested");
2084 return 0;
2085 }
2086 int portno;
2087 ssiReserved_sockfd = socket(AF_INET, SOCK_STREAM, 0);
2088 if(ssiReserved_sockfd < 0)
2089 {
2090 WerrorS("ERROR opening socket");
2091 return 0;
2092 }
2093 memset((char *) &ssiResverd_serv_addr,0, sizeof(ssiResverd_serv_addr));
2094 portno = 1025;
2095 ssiResverd_serv_addr.sin_family = AF_INET;
2096 ssiResverd_serv_addr.sin_addr.s_addr = INADDR_ANY;
2097 do
2098 {
2099 portno++;
2100 ssiResverd_serv_addr.sin_port = htons(portno);
2101 if(portno > 50000)
2102 {
2103 WerrorS("ERROR on binding (no free port available?)");
2104 return 0;
2105 }
2106 }
2107 while(bind(ssiReserved_sockfd, (struct sockaddr *) &ssiResverd_serv_addr, sizeof(ssiResverd_serv_addr)) < 0);
2108 ssiReserved_P=portno;
2109 listen(ssiReserved_sockfd,clients);
2110 ssiReserved_Clients=clients;
2111 return portno;
2112}

◆ ssiSetCurrRing()

static BOOLEAN ssiSetCurrRing ( const ring  r)
static

Definition at line 74 of file ssiLink.cc.

75{
76 // if (currRing!=NULL)
77 // Print("need to change the ring, currRing:%s, switch to: ssiRing%d\n",IDID(currRingHdl),nr);
78 // else
79 // Print("no ring, switch to ssiRing%d\n",nr);
80 if (r==currRing)
81 {
82 rIncRefCnt(r);
84 return TRUE;
85 }
86 else if ((currRing==NULL) || (!rEqual(r,currRing,1)))
87 {
88 char name[20];
89 int nr=0;
90 idhdl h=NULL;
91 loop
92 {
93 snprintf(name,20,"ssiRing%d",nr); nr++;
94 h=IDROOT->get(name, 0);
95 if (h==NULL)
96 {
99 r->ref=2;/*ref==2: d->r and h */
100 break;
101 }
102 else if ((IDTYP(h)==RING_CMD)
103 && (rEqual(r,IDRING(h),1)))
104 {
106 break;
107 }
108 }
109 rSetHdl(h);
110 return FALSE;
111 }
112 else
113 {
114 rKill(r);
116 return TRUE;
117 }
118}
idhdl rFindHdl(ring r, idhdl n)
Definition: ipshell.cc:1702

◆ ssiSetRing()

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

Definition at line 1629 of file ssiLink.cc.

1630{
1631 if(SI_LINK_W_OPEN_P(l)==0)
1633 ssiInfo *d = (ssiInfo *)l->data;
1634 if (d->r!=r)
1635 {
1636 if (send)
1637 {
1638 fputs("15 ",d->f_write);
1639 ssiWriteRing(d,r);
1640 }
1641 d->r=r;
1642 }
1643 if (currRing!=r) rChangeCurrRing(r);
1644 return FALSE;
1645}

◆ ssiWrite()

BOOLEAN ssiWrite ( si_link  l,
leftv  data 
)

Definition at line 1648 of file ssiLink.cc.

1649{
1650 if(SI_LINK_W_OPEN_P(l)==0)
1652 ssiInfo *d = (ssiInfo *)l->data;
1653 d->level++;
1654 //FILE *fich=d->f;
1655 while (data!=NULL)
1656 {
1657 int tt=data->Typ();
1658 void *dd=data->Data();
1659 attr *aa=data->Attribute();
1660 if ((aa!=NULL) && ((*aa)!=NULL)) // n user attributes
1661 {
1662 attr a=*aa;
1663 int n=0;
1664 while(a!=NULL) { n++; a=a->next;}
1665 fprintf(d->f_write,"21 %d %d ",data->flag,n);
1666 }
1667 else if (data->flag!=0) // only "flag" attributes
1668 {
1669 fprintf(d->f_write,"21 %d 0 ",data->flag);
1670 }
1671 if ((dd==NULL) && (data->name!=NULL) && (tt==0)) tt=DEF_CMD;
1672 // return pure undefined names as def
1673
1674 switch(tt /*data->Typ()*/)
1675 {
1676 case 0: /*error*/
1677 case NONE/* nothing*/:fputs("16 ",d->f_write);
1678 break;
1679 case STRING_CMD: fputs("2 ",d->f_write);
1680 ssiWriteString(d,(char *)dd);
1681 break;
1682 case INT_CMD: fputs("1 ",d->f_write);
1683 ssiWriteInt(d,(int)(long)dd);
1684 break;
1685 case BIGINT_CMD:fputs("4 ",d->f_write);
1686 ssiWriteBigInt(d,(number)dd);
1687 break;
1688 case NUMBER_CMD:
1689 if (d->r!=currRing)
1690 {
1691 fputs("15 ",d->f_write);
1693 if (d->level<=1) fputc('\n',d->f_write);
1694 }
1695 fputs("3 ",d->f_write);
1696 ssiWriteNumber(d,(number)dd);
1697 break;
1698 case RING_CMD:fputs("5 ",d->f_write);
1699 ssiWriteRing(d,(ring)dd);
1700 break;
1701 case BUCKET_CMD:
1702 {
1704 if (d->r!=sBucketGetRing(b))
1705 {
1706 fputs("15 ",d->f_write);
1708 if (d->level<=1) fputc('\n',d->f_write);
1709 }
1710 fputs("6 ",d->f_write);
1711 ssiWritePoly(d,tt,sBucketPeek(b));
1712 break;
1713 }
1714 case POLY_CMD:
1715 case VECTOR_CMD:
1716 if (d->r!=currRing)
1717 {
1718 fputs("15 ",d->f_write);
1720 if (d->level<=1) fputc('\n',d->f_write);
1721 }
1722 if(tt==POLY_CMD) fputs("6 ",d->f_write);
1723 else fputs("9 ",d->f_write);
1724 ssiWritePoly(d,tt,(poly)dd);
1725 break;
1726 case IDEAL_CMD:
1727 case MODUL_CMD:
1728 case MATRIX_CMD:
1729 case SMATRIX_CMD:
1730 if (d->r!=currRing)
1731 {
1732 fputs("15 ",d->f_write);
1734 if (d->level<=1) fputc('\n',d->f_write);
1735 }
1736 if(tt==IDEAL_CMD) fputs("7 ",d->f_write);
1737 else if(tt==MATRIX_CMD) fputs("8 ",d->f_write);
1738 else if(tt==SMATRIX_CMD) fputs("22 ",d->f_write);
1739 else /* tt==MODUL_CMD*/
1740 {
1741 ideal M=(ideal)dd;
1742 fprintf(d->f_write,"10 %d ",(int)M->rank);
1743 }
1744 ssiWriteIdeal(d,tt,(ideal)dd);
1745 break;
1746 case COMMAND:
1747 fputs("11 ",d->f_write);
1749 break;
1750 case DEF_CMD: /* not evaluated stuff in quotes */
1751 fputs("12 ",d->f_write);
1752 ssiWriteString(d,data->Name());
1753 break;
1754 case PROC_CMD:
1755 fputs("13 ",d->f_write);
1756 ssiWriteProc(d,(procinfov)dd);
1757 break;
1758 case LIST_CMD:
1759 fputs("14 ",d->f_write);
1760 ssiWriteList(l,(lists)dd);
1761 break;
1762 case INTVEC_CMD:
1763 fputs("17 ",d->f_write);
1764 ssiWriteIntvec(d,(intvec *)dd);
1765 break;
1766 case INTMAT_CMD:
1767 fputs("18 ",d->f_write);
1768 ssiWriteIntmat(d,(intvec *)dd);
1769 break;
1770 case BIGINTMAT_CMD:
1771 fputs("19 ",d->f_write);
1773 break;
1774 default:
1775 if (tt>MAX_TOK)
1776 {
1777 blackbox *b=getBlackboxStuff(tt);
1778 fputs("20 ",d->f_write);
1779 b->blackbox_serialize(b,dd,l);
1780 }
1781 else
1782 {
1783 Werror("not implemented (t:%d, rtyp:%d)",tt, data->rtyp);
1784 d->level=0;
1785 return TRUE;
1786 }
1787 break;
1788 }
1789 if (d->level<=1) { fputc('\n',d->f_write); fflush(d->f_write); }
1790 data=data->next;
1791 }
1792 d->level--;
1793 return FALSE;
1794}
Definition: attrib.h:21
attr next
Definition: attrib.h:26
const char * name
Definition: subexpr.h:87
const char * Name()
Definition: subexpr.h:120
attr * Attribute()
Definition: subexpr.cc:1473
BITSET flag
Definition: subexpr.h:90
@ BUCKET_CMD
Definition: grammar.cc:283
while(1)
Definition: libparse.cc:1444
char level
Definition: s_buff.h:27
poly sBucketPeek(sBucket_pt b)
Definition: sbuckets.cc:455
ring sBucketGetRing(const sBucket_pt bucket)
Returns bucket ring.
Definition: sbuckets.cc:46
sBucket * sBucket_pt
Definition: sbuckets.h:16

◆ ssiWriteBigInt()

static void ssiWriteBigInt ( const ssiInfo d,
const number  n 
)
static

Definition at line 162 of file ssiLink.cc.

163{
165}
static FORCE_INLINE void n_WriteFd(number a, const ssiInfo *f, const coeffs r)
io via ssi:
Definition: coeffs.h:967

◆ ssiWriteBigintmat()

static void ssiWriteBigintmat ( const ssiInfo d,
bigintmat v 
)
static

Definition at line 458 of file ssiLink.cc.

459{
460 fprintf(d->f_write,"%d %d ",v->rows(),v->cols());
461 int i;
462 for(i=0;i<v->length();i++)
463 {
464 ssiWriteBigInt(d,(*v)[i]);
465 }
466}

◆ ssiWriteCommand()

static void ssiWriteCommand ( si_link  l,
command  D 
)
static

Definition at line 405 of file ssiLink.cc.

406{
407 ssiInfo *d=(ssiInfo*)l->data;
408 // syntax: <num ops> <operation> <op1> <op2> ....
409 fprintf(d->f_write,"%d %d ",D->argc,D->op);
410 if (D->argc >0) ssiWrite(l, &(D->arg1));
411 if (D->argc < 4)
412 {
413 if (D->argc >1) ssiWrite(l, &(D->arg2));
414 if (D->argc >2) ssiWrite(l, &(D->arg3));
415 }
416}

◆ ssiWriteIdeal()

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

Definition at line 400 of file ssiLink.cc.

401{
402 ssiWriteIdeal_R(d,typ,I,d->r);
403}

◆ ssiWriteIdeal_R()

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

Definition at line 370 of file ssiLink.cc.

371{
372 // syntax: 7 # of elements <poly 1> <poly2>.....(ideal,module,smatrix)
373 // syntax: 8 <rows> <cols> <poly 1> <poly2>.....(matrix)
374 // syntax
375 matrix M=(matrix)I;
376 int mn;
377 if (typ==MATRIX_CMD)
378 {
379 mn=MATROWS(M)*MATCOLS(M);
380 fprintf(d->f_write,"%d %d ", MATROWS(M),MATCOLS(M));
381 }
382 else
383 {
384 mn=IDELEMS(I);
385 fprintf(d->f_write,"%d ",IDELEMS(I));
386 }
387
388 int i;
389 int tt;
390 if ((typ==MODUL_CMD)||(typ==SMATRIX_CMD))
391 tt=VECTOR_CMD;
392 else
393 tt=POLY_CMD;
394
395 for(i=0;i<mn;i++)
396 {
397 ssiWritePoly_R(d,tt,I->m[i],R);
398 }
399}
ip_smatrix * matrix
Definition: matpol.h:43
#define R
Definition: sirandom.c:27

◆ ssiWriteInt()

static void ssiWriteInt ( const ssiInfo d,
const int  i 
)
static

Definition at line 150 of file ssiLink.cc.

151{
152 fprintf(d->f_write,"%d ",i);
153 //if (d->f_debug!=NULL) fprintf(d->f_debug,"int: %d ",i);
154}

◆ ssiWriteIntmat()

static void ssiWriteIntmat ( const ssiInfo d,
intvec v 
)
static

Definition at line 448 of file ssiLink.cc.

449{
450 fprintf(d->f_write,"%d %d ",v->rows(),v->cols());
451 int i;
452 for(i=0;i<v->length();i++)
453 {
454 fprintf(d->f_write,"%d ",(*v)[i]);
455 }
456}

◆ ssiWriteIntvec()

static void ssiWriteIntvec ( const ssiInfo d,
intvec v 
)
static

Definition at line 439 of file ssiLink.cc.

440{
441 fprintf(d->f_write,"%d ",v->length());
442 int i;
443 for(i=0;i<v->length();i++)
444 {
445 fprintf(d->f_write,"%d ",(*v)[i]);
446 }
447}

◆ ssiWriteList()

static void ssiWriteList ( si_link  l,
lists  dd 
)
static

Definition at line 428 of file ssiLink.cc.

429{
430 ssiInfo *d=(ssiInfo*)l->data;
431 int Ll=dd->nr;
432 fprintf(d->f_write,"%d ",Ll+1);
433 int i;
434 for(i=0;i<=Ll;i++)
435 {
436 ssiWrite(l,&(dd->m[i]));
437 }
438}

◆ ssiWriteNumber()

static void ssiWriteNumber ( const ssiInfo d,
const number  n 
)
static

Definition at line 195 of file ssiLink.cc.

196{
197 ssiWriteNumber_CF(d,n,d->r->cf);
198}

◆ ssiWriteNumber_CF()

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

Definition at line 167 of file ssiLink.cc.

168{
169 // syntax is as follows:
170 // case 1 Z/p: 3 <int>
171 // case 2 Q: 3 4 <int>
172 // or 3 0 <mpz_t nominator> <mpz_t denominator>
173 // or 3 1 dto.
174 // or 3 3 <mpz_t nominator>
175 // or 3 5 <mpz_t raw nom.> <mpz_t raw denom.>
176 // or 3 6 <mpz_t raw nom.> <mpz_t raw denom.>
177 // or 3 8 <mpz_t raw nom.>
179 {
180 fraction f=(fraction)n;
181 ssiWritePoly_R(d,POLY_CMD,NUM(f),cf->extRing);
182 ssiWritePoly_R(d,POLY_CMD,DEN(f),cf->extRing);
183 }
184 else if (getCoeffType(cf)==n_algExt)
185 {
186 ssiWritePoly_R(d,POLY_CMD,(poly)n,cf->extRing);
187 }
188 else if (cf->cfWriteFd!=NULL)
189 {
190 n_WriteFd(n,d,cf);
191 }
192 else WerrorS("coeff field not implemented");
193}

◆ ssiWritePoly()

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

Definition at line 365 of file ssiLink.cc.

366{
367 ssiWritePoly_R(d,typ,p,d->r);
368}

◆ ssiWritePoly_R()

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

Definition at line 347 of file ssiLink.cc.

348{
349 fprintf(d->f_write,"%d ",pLength(p));//number of terms
350
351 while(p!=NULL)
352 {
353 ssiWriteNumber_CF(d,pGetCoeff(p),r->cf);
354 //nWrite(fich,pGetCoeff(p));
355 fprintf(d->f_write,"%ld ",p_GetComp(p,r));//component
356
357 for(int j=1;j<=rVar(r);j++)
358 {
359 fprintf(d->f_write,"%ld ",p_GetExp(p,j,r ));//x^j
360 }
361 pIter(p);
362 }
363}
#define p_GetComp(p, r)
Definition: monomials.h:64
#define pIter(p)
Definition: monomials.h:37
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy
Definition: monomials.h:44
static int pLength(poly a)
Definition: p_polys.h:190
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent @Note: the integer VarOffset encodes:
Definition: p_polys.h:469

◆ ssiWriteProc()

static void ssiWriteProc ( const ssiInfo d,
procinfov  p 
)
static

Definition at line 418 of file ssiLink.cc.

419{
420 if (p->data.s.body==NULL)
422 if (p->data.s.body!=NULL)
423 ssiWriteString(d,p->data.s.body);
424 else
425 ssiWriteString(d,"");
426}
char * iiGetLibProcBuffer(procinfo *pi, int part)
Definition: iplib.cc:197

◆ ssiWriteRing()

static void ssiWriteRing ( ssiInfo d,
const ring  r 
)
static

Definition at line 322 of file ssiLink.cc.

323{
324 /* 5 <ch> <N> <l1> <v1> ...<lN> <vN> <number of orderings> <ord1> <block0_1> <block1_1> .... <extRing> <Q-ideal> */
325 /* ch=-1: transext, coeff ring follows */
326 /* ch=-2: algext, coeff ring and minpoly follows */
327 /* ch=-3: cf name follows */
328 /* ch=-4: NULL */
329 /* ch=-5: reference <int> */
330 /* ch=-6: new reference <int> <ring> */
331 if ((r==NULL)||(r->cf==NULL))
332 {
333 fputs("-4 ",d->f_write);
334 return;
335 }
336 if (r==currRing) // see recursive calls for transExt/algExt
337 {
338 if (d->r!=NULL) rKill(d->r);
339 d->r=r;
340 }
341 if (r!=NULL)
342 {
343 /*d->*/rIncRefCnt(r);
344 }
345 ssiWriteRing_R(d,r);
346}

◆ ssiWriteRing_R()

static void ssiWriteRing_R ( ssiInfo d,
const ring  r 
)
static

Definition at line 200 of file ssiLink.cc.

201{
202 /* 5 <ch> <N> <l1> <v1> ...<lN> <vN> <number of orderings> <ord1> <block0_1> <block1_1> .... <extRing> <Q-ideal> */
203 /* ch=-1: transext, coeff ring follows */
204 /* ch=-2: algext, coeff ring and minpoly follows */
205 /* ch=-3: cf name follows */
206 /* ch=-4: NULL*/
207 /* ch=-5: reference <int> */
208 /* ch=-6: new reference <int> <ring> */
209 if (r!=NULL)
210 {
211 for(int i=0;i<SI_RING_CACHE;i++)
212 {
213 if (d->rings[i]==r)
214 {
215 fprintf(d->f_write,"-5 %d ",i);
216 return;
217 }
218 }
219 for(int i=0;i<SI_RING_CACHE;i++)
220 {
221 if (d->rings[i]==NULL)
222 {
223 d->rings[i]=rIncRefCnt(r);
224 fprintf(d->f_write,"-6 %d ",i);
225 break;
226 }
227 }
228 if (rField_is_Q(r) || rField_is_Zp(r))
229 fprintf(d->f_write,"%d %d ",n_GetChar(r->cf),r->N);
230 else if (rFieldType(r)==n_transExt)
231 fprintf(d->f_write,"-1 %d ",r->N);
232 else if (rFieldType(r)==n_algExt)
233 fprintf(d->f_write,"-2 %d ",r->N);
234 else /*dummy*/
235 {
236 fprintf(d->f_write,"-3 %d ",r->N);
237 ssiWriteString(d,nCoeffName(r->cf));
238 }
239
240 int i;
241 for(i=0;i<r->N;i++)
242 {
243 fprintf(d->f_write,"%d %s ",(int)strlen(r->names[i]),r->names[i]);
244 }
245 /* number of orderings:*/
246 i=0;
247 // remember dummy ring: everything 0:
248 if (r->order!=NULL) while (r->order[i]!=0) i++;
249 fprintf(d->f_write,"%d ",i);
250 /* each ordering block: */
251 i=0;
252 if (r->order!=NULL) while(r->order[i]!=0)
253 {
254 fprintf(d->f_write,"%d %d %d ",r->order[i],r->block0[i], r->block1[i]);
255 switch(r->order[i])
256 {
257 case ringorder_a:
258 case ringorder_wp:
259 case ringorder_Wp:
260 case ringorder_ws:
261 case ringorder_Ws:
262 case ringorder_aa:
263 {
264 int ii;
265 for(ii=r->block0[i];ii<=r->block1[i];ii++)
266 fprintf(d->f_write,"%d ",r->wvhdl[i][ii-r->block0[i]]);
267 }
268 break;
269
270 case ringorder_a64:
271 case ringorder_M:
272 case ringorder_L:
273 case ringorder_IS:
274 Werror("ring oder not implemented for ssi:%d",r->order[i]);
275 break;
276
277 default: break;
278 }
279 i++;
280 }
281 if ((rFieldType(r)==n_transExt)
282 || (rFieldType(r)==n_algExt))
283 {
284 ssiWriteRing_R(d,r->cf->extRing); /* includes alg.ext if rFieldType(r)==n_algExt */
285 }
286 /* Q-ideal :*/
287 if (r->qideal!=NULL)
288 {
289 ssiWriteIdeal_R(d,IDEAL_CMD,r->qideal,r);
290 }
291 else
292 {
293 fputs("0 ",d->f_write/*ideal with 0 entries */);
294 }
295 }
296 else /* dummy ring r==NULL*/
297 {
298 fputs("0 0 0 0 "/*,r->ch,r->N, blocks, q-ideal*/,d->f_write);
299 }
300 if (rIsLPRing(r)) // cannot be combined with 23 2
301 {
302 fprintf(d->f_write,"23 1 %d %d ",SI_LOG2(r->bitmask),r->isLPring);
303 }
304 else
305 {
306 unsigned long bm=0;
307 int b=0;
308 bm=rGetExpSize(bm,b,r->N);
309 if (r->bitmask!=bm)
310 {
311 fprintf(d->f_write,"23 0 %d ",SI_LOG2(r->bitmask));
312 }
313 if (rIsPluralRing(r))
314 {
315 fputs("23 2 ",d->f_write);
316 ssiWriteIdeal(d,MATRIX_CMD,(ideal)r->GetNC()->C);
317 ssiWriteIdeal(d,MATRIX_CMD,(ideal)r->GetNC()->D);
318 }
319 }
320}
static FORCE_INLINE int n_GetChar(const coeffs r)
Return the characteristic of the coeff. domain.
Definition: coeffs.h:441
static FORCE_INLINE char * nCoeffName(const coeffs cf)
Definition: coeffs.h:960
static unsigned long rGetExpSize(unsigned long bitmask, int &bits)
Definition: ring.cc:2570
static BOOLEAN rField_is_Zp(const ring r)
Definition: ring.h:500
static n_coeffType rFieldType(const ring r)
the type of the coefficient filed of r (n_Zp, n_Q, etc)
Definition: ring.h:556
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
Definition: ring.h:400
static BOOLEAN rIsLPRing(const ring r)
Definition: ring.h:411
static BOOLEAN rField_is_Q(const ring r)
Definition: ring.h:506
static int SI_LOG2(int v)
Definition: si_log2.h:6

◆ ssiWriteString()

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

Definition at line 156 of file ssiLink.cc.

157{
158 fprintf(d->f_write,"%d %s ",(int)strlen(s),s);
159 //if (d->f_debug!=NULL) fprintf(d->f_debug,"stringi: %d \"%s\" ",strlen(s),s);
160}

Variable Documentation

◆ si_link_root

EXTERN_VAR si_link_extension si_link_root

Definition at line 2114 of file ssiLink.cc.

◆ ssiReserved_Clients

STATIC_VAR int ssiReserved_Clients

Definition at line 2078 of file ssiLink.cc.

◆ ssiReserved_P

STATIC_VAR int ssiReserved_P =0

Definition at line 2075 of file ssiLink.cc.

◆ ssiReserved_sockfd

STATIC_VAR int ssiReserved_sockfd

Definition at line 2076 of file ssiLink.cc.

◆ ssiResverd_serv_addr

STATIC_VAR struct sockaddr_in ssiResverd_serv_addr

Definition at line 2077 of file ssiLink.cc.

◆ ssiToBeClosed

VAR link_list ssiToBeClosed =NULL

Definition at line 63 of file ssiLink.cc.

◆ ssiToBeClosed_inactive

VAR volatile BOOLEAN ssiToBeClosed_inactive =TRUE

Definition at line 64 of file ssiLink.cc.