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

2245{
2246 int type_id = IDTYP(h);
2247
2248 // C-proc not to be dumped, also LIB-proc not
2249 if (type_id == PROC_CMD)
2250 {
2251 if (IDPROC(h)->language == LANG_C) return FALSE;
2252 if (IDPROC(h)->libname != NULL) return FALSE;
2253 }
2254 // do not dump links
2255 if (type_id == LINK_CMD) return FALSE;
2256
2257 // do not dump ssi internal rings: ssiRing*
2258 if ((type_id == RING_CMD) && (strncmp(IDID(h),"ssiRing",7)==0))
2259 return FALSE;
2260
2261 // do not dump default cring:
2262 if (type_id == CRING_CMD)
2263 {
2264 if (strcmp(IDID(h),"ZZ")==0) return FALSE;
2265 if (strcmp(IDID(h),"QQ")==0) return FALSE;
2266 #ifdef SINGULAR_4_2
2267 if (strcmp(IDID(h),"AE")==0) return FALSE;
2268 if (strcmp(IDID(h),"QAE")==0) return FALSE;
2269 #endif
2270 }
2271
2272 command D=(command)omAlloc0(sizeof(*D));
2273 sleftv tmp;
2274 memset(&tmp,0,sizeof(tmp));
2275 tmp.rtyp=COMMAND;
2276 tmp.data=D;
2277
2278 if (type_id == PACKAGE_CMD)
2279 {
2280 // do not dump Top, Standard
2281 if ((strcmp(IDID(h), "Top") == 0)
2282 || (strcmp(IDID(h), "Standard") == 0))
2283 {
2284 omFreeSize(D,sizeof(*D));
2285 return FALSE;
2286 }
2287 package p=(package)IDDATA(h);
2288 // dump Singular-packages as LIB("...");
2289 if (p->language==LANG_SINGULAR)
2290 {
2291 D->op=LOAD_CMD;
2292 D->argc=2;
2293 D->arg1.rtyp=STRING_CMD;
2294 D->arg1.data=p->libname;
2295 D->arg2.rtyp=STRING_CMD;
2296 D->arg2.data=(char*)"with";
2297 ssiWrite(l,&tmp);
2298 omFreeSize(D,sizeof(*D));
2299 return FALSE;
2300 }
2301 // dump Singular-packages as load("...");
2302 else if (p->language==LANG_C)
2303 {
2304 D->op=LOAD_CMD;
2305 D->argc=1;
2306 D->arg1.rtyp=STRING_CMD;
2307 D->arg1.data=p->libname;
2308 ssiWrite(l,&tmp);
2309 omFreeSize(D,sizeof(*D));
2310 return FALSE;
2311 }
2312 }
2313
2314 // put type and name
2315 //Print("generic dump:%s,%s\n",IDID(h),Tok2Cmdname(IDTYP(h)));
2316 D->op='=';
2317 D->argc=2;
2318 D->arg1.rtyp=DEF_CMD;
2319 D->arg1.name=IDID(h);
2320 D->arg2.rtyp=IDTYP(h);
2321 D->arg2.data=IDDATA(h);
2322 ssiWrite(l,&tmp);
2323 omFreeSize(D,sizeof(*D));
2324 return FALSE;
2325}
#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 2202 of file ssiLink.cc.

2203{
2204 pid_t kidpid;
2205 int status;
2206
2207 loop
2208 {
2209 kidpid = si_waitpid(-1, &status, WNOHANG);
2210 if (kidpid==-1)
2211 {
2212 /* continue on interruption (EINTR): */
2213 if (errno == EINTR) continue;
2214 /* break on anything else (EINVAL or ECHILD according to manpage): */
2215 break;
2216 }
2217 else if (kidpid==0) break; /* no more children to process, so break */
2218
2219 //printf("Child %ld terminated\n", kidpid);
2221 while((hh!=NULL)&&(ssiToBeClosed_inactive))
2222 {
2223 if((hh->l!=NULL) && (hh->l->m->Open==ssiOpen))
2224 {
2225 ssiInfo *d = (ssiInfo *)hh->l->data;
2226 if(d->pid==kidpid)
2227 {
2229 {
2231 slClose(hh->l);
2233 break;
2234 }
2235 else break;
2236 }
2237 else hh=(link_list)hh->next;
2238 }
2239 else hh=(link_list)hh->next;
2240 }
2241 }
2242}
#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 1815 of file ssiLink.cc.

1816{
1817 s->Open=ssiOpen;
1818 s->Close=ssiClose;
1819 s->Kill=ssiClose;
1820 s->Read=ssiRead1;
1821 s->Read2=(slRead2Proc)NULL;
1822 s->Write=ssiWrite;
1823 s->Dump=ssiDump;
1824 s->GetDump=ssiGetDump;
1825
1826 s->Status=slStatusSsi;
1827 s->SetRing=ssiSetRing;
1828 s->type="ssi";
1829 return s;
1830}
const CanonicalForm int s
Definition: facAbsFact.cc:51

◆ slStatusSsi()

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

Definition at line 1832 of file ssiLink.cc.

1833{
1834 ssiInfo *d=(ssiInfo*)l->data;
1835 if (d==NULL) return "not open";
1836 if (((strcmp(l->mode,"fork")==0)
1837 ||(strcmp(l->mode,"tcp")==0)
1838 ||(strcmp(l->mode,"connect")==0))
1839 && (strcmp(request, "read") == 0))
1840 {
1841 fd_set mask;
1842 struct timeval wt;
1843 if (s_isready(d->f_read)) return "ready";
1844 loop
1845 {
1846 /* Don't block. Return socket status immediately. */
1847 wt.tv_sec = 0;
1848 wt.tv_usec = 0;
1849
1850 FD_ZERO(&mask);
1851 FD_SET(d->fd_read, &mask);
1852 //Print("test fd %d\n",d->fd_read);
1853 /* check with select: chars waiting: no -> not ready */
1854 switch (si_select(d->fd_read+1, &mask, NULL, NULL, &wt))
1855 {
1856 case 0: /* not ready */ return "not ready";
1857 case -1: /*error*/ return "error";
1858 case 1: /*ready ? */ break;
1859 }
1860 /* yes: read 1 char*/
1861 /* if \n, check again with select else ungetc(c), ready*/
1862 int c=s_getc(d->f_read);
1863 //Print("try c=%d\n",c);
1864 if (c== -1) return "eof"; /* eof or error */
1865 else if (isdigit(c))
1866 { s_ungetc(c,d->f_read); return "ready"; }
1867 else if (c>' ')
1868 {
1869 Werror("unknown char in ssiLink(%d)",c);
1870 return "error";
1871 }
1872 /* else: next char */
1873 }
1874 }
1875 else if (strcmp(request, "read") == 0)
1876 {
1877 if (SI_LINK_R_OPEN_P(l) && (!s_iseof(d->f_read)) && (s_isready(d->f_read))) return "ready";
1878 else return "not ready";
1879 }
1880 else if (strcmp(request, "write") == 0)
1881 {
1882 if (SI_LINK_W_OPEN_P(l)) return "ready";
1883 else return "not ready";
1884 }
1885 else return "unknown status request";
1886}
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 1888 of file ssiLink.cc.

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

2062{
2064 char *buf=(char*)omAlloc(256);
2065 snprintf(buf,256,"ssi:connect %s:%s",host,port);
2066 slInit(l, buf);
2067 omFreeSize(buf,256);
2068 if (slOpen(l,SI_LINK_OPEN,NULL)) return 1;
2070
2071 idhdl id = enterid("link_ll", 0, LINK_CMD, &IDROOT, FALSE);
2072 IDLINK(id) = l;
2073
2074 loop
2075 {
2076 leftv h=ssiRead1(l); /*contains an exit.... */
2077 if (feErrors != NULL && *feErrors != '\0')
2078 {
2079 // handle errors:
2080 PrintS(feErrors); /* currently quite simple */
2081 *feErrors = '\0';
2082 }
2083 ssiWrite(l,h);
2084 h->CleanUp();
2086 }
2087 /* never reached*/
2088 exit(0);
2089}
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:840

◆ ssiClose()

BOOLEAN ssiClose ( si_link  l)

Definition at line 1387 of file ssiLink.cc.

1388{
1389 if (l!=NULL)
1390 {
1392 ssiInfo *d = (ssiInfo *)l->data;
1393 if (d!=NULL)
1394 {
1395 // send quit signal
1396 if ((d->send_quit_at_exit)
1397 && (d->quit_sent==0))
1398 {
1399 fputs("99\n",d->f_write);
1400 fflush(d->f_write);
1401 }
1402 // clean ring
1403 if (d->r!=NULL) rKill(d->r);
1404 for(int i=0;i<SI_RING_CACHE;i++)
1405 {
1406 if (d->rings[i]!=NULL) rKill(d->rings[i]);
1407 d->rings[i]=NULL;
1408 }
1409 // did the child to stop ?
1410 si_waitpid(d->pid,NULL,WNOHANG);
1411 if ((d->pid!=0)
1412 && (kill(d->pid,0)==0)) // child is still running
1413 {
1414 struct timespec t;
1415 t.tv_sec=0;
1416 t.tv_nsec=100000000; // <=100 ms
1417 struct timespec rem;
1418 int r;
1419 loop
1420 {
1421 // wait till signal or time rem:
1422 r = nanosleep(&t, &rem);
1423 t = rem;
1424 // child finished:
1425 if (si_waitpid(d->pid,NULL,WNOHANG) != 0) break;
1426 // other signal, waited s>= 100 ms:
1427 if ((r==0) || (errno != EINTR)) break;
1428 }
1429 if (kill(d->pid,0) == 0) // pid still exists
1430 {
1431 kill(d->pid,15);
1432 t.tv_sec=5; // <=5s
1433 t.tv_nsec=0;
1434 loop
1435 {
1436 // wait till signal or time rem:
1437 r = nanosleep(&t, &rem);
1438 t = rem;
1439 // child finished:
1440 if (si_waitpid(d->pid,NULL,WNOHANG) != 0) break;
1441 // other signal, waited s>= 5 s:
1442 if ((r==0) || (errno != EINTR)) break;
1443 }
1444 if (kill(d->pid,0) == 0)
1445 {
1446 kill(d->pid,9); // just to be sure
1447 si_waitpid(d->pid,NULL,0);
1448 }
1449 }
1450 }
1451 if (d->f_read!=NULL) { s_close(d->f_read);d->f_read=NULL;}
1452 if (d->f_write!=NULL) { fclose(d->f_write); d->f_write=NULL; }
1453 if ((strcmp(l->mode,"tcp")==0)
1454 || (strcmp(l->mode,"fork")==0))
1455 {
1457 if (hh!=NULL)
1458 {
1459 if (hh->l==l)
1460 {
1462 omFreeSize(hh,sizeof(link_struct));
1463 }
1464 else while(hh->next!=NULL)
1465 {
1466 link_list hhh=(link_list)hh->next;
1467 if (hhh->l==l)
1468 {
1469 hh->next=hhh->next;
1470 omFreeSize(hhh,sizeof(link_struct));
1471 break;
1472 }
1473 else
1474 hh=(link_list)hh->next;
1475 }
1476 }
1477 }
1478 omFreeSize((ADDRESS)d,(sizeof *d));
1479 }
1480 l->data=NULL;
1481 }
1482 return FALSE;
1483}
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 2131 of file ssiLink.cc.

2132{
2133 if (ssiReserved_P==0)
2134 {
2135 WerrorS("ERROR no reserved port requested");
2136 return NULL;
2137 }
2138 struct sockaddr_in cli_addr;
2139 int clilen = sizeof(cli_addr);
2140 int newsockfd = si_accept(ssiReserved_sockfd, (struct sockaddr *) &cli_addr, (socklen_t *)&clilen);
2141 if(newsockfd < 0)
2142 {
2143 Werror("ERROR on accept (errno=%d)",errno);
2144 return NULL;
2145 }
2147 si_link_extension s = si_link_root;
2148 si_link_extension prev = s;
2149 while (strcmp(s->type, "ssi") != 0)
2150 {
2151 if (s->next == NULL)
2152 {
2153 prev = s;
2154 s = NULL;
2155 break;
2156 }
2157 else
2158 {
2159 s = s->next;
2160 }
2161 }
2162 if (s != NULL)
2163 l->m = s;
2164 else
2165 {
2166 si_link_extension ns = (si_link_extension)omAlloc0Bin(s_si_link_extension_bin);
2167 prev->next=slInitSsiExtension(ns);
2168 l->m = prev->next;
2169 }
2170 l->name=omStrDup("");
2171 l->mode=omStrDup("tcp");
2172 l->ref=1;
2173 ssiInfo *d=(ssiInfo*)omAlloc0(sizeof(ssiInfo));
2174 l->data=d;
2175 d->fd_read = newsockfd;
2176 d->fd_write = newsockfd;
2177 d->f_read = s_open(newsockfd);
2178 d->f_write = fdopen(newsockfd, "w");
2181 if (ssiReserved_Clients<=0)
2182 {
2183 ssiReserved_P=0;
2184 si_close(ssiReserved_sockfd);
2185 }
2186 return l;
2187}
#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 2347 of file ssiLink.cc.

2348{
2349 idhdl h = IDROOT, rh = currRingHdl;
2351
2352 //if (! status ) status = DumpAsciiMaps(fd, h, NULL);
2353
2354 if (currRingHdl != rh) rSetHdl(rh);
2355 //fprintf(fd, "option(set, intvec(%d, %d));\n", si_opt_1, si_opt_2);
2356
2357 return status;
2358}
int BOOLEAN
Definition: auxiliary.h:87

◆ ssiDumpIter()

static BOOLEAN ssiDumpIter ( si_link  l,
idhdl  h 
)
static

Definition at line 2326 of file ssiLink.cc.

2327{
2328 if (h == NULL) return FALSE;
2329
2330 if (ssiDumpIter(l, IDNEXT(h))) return TRUE;
2331
2332 // need to set the ring before writing it, otherwise we get in
2333 // trouble with minpoly
2334 if (IDTYP(h) == RING_CMD)
2335 rSetHdl(h);
2336
2337 if (DumpSsiIdhdl(l, h)) return TRUE;
2338
2339 // do not dump ssi internal rings: ssiRing*
2340 // but dump objects of all other rings
2341 if ((IDTYP(h) == RING_CMD)
2342 && (strncmp(IDID(h),"ssiRing",7)!=0))
2343 return ssiDumpIter(l, IDRING(h)->idroot);
2344 else
2345 return FALSE;
2346}
#define IDNEXT(a)
Definition: ipid.h:118

◆ ssiGetDump()

BOOLEAN ssiGetDump ( si_link  l)

Definition at line 2359 of file ssiLink.cc.

2360{
2361 ssiInfo *d=(ssiInfo*)l->data;
2362 loop
2363 {
2364 if (!SI_LINK_OPEN_P(l)) break;
2365 if (s_iseof(d->f_read)) break;
2366 leftv h=ssiRead1(l); /*contains an exit.... */
2367 if (feErrors != NULL && *feErrors != '\0')
2368 {
2369 // handle errors:
2370 PrintS(feErrors); /* currently quite simple */
2371 return TRUE;
2372 *feErrors = '\0';
2373 }
2374 h->CleanUp();
2376 }
2377 return FALSE;
2378}

◆ ssiOpen()

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

Definition at line 973 of file ssiLink.cc.

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

1369{
1370 if (l!=NULL)
1371 {
1373 ssiInfo *d = (ssiInfo *)l->data;
1374 if (d!=NULL)
1375 {
1376 if (d->send_quit_at_exit)
1377 {
1378 fputs("99\n",d->f_write);
1379 fflush(d->f_write);
1380 }
1381 d->quit_sent=1;
1382 }
1383 }
1384 return FALSE;
1385}

◆ ssiRead1()

leftv ssiRead1 ( si_link  l)

Definition at line 1486 of file ssiLink.cc.

1487{
1488 ssiInfo *d = (ssiInfo *)l->data;
1490 int t=0;
1491 t=s_readint(d->f_read);
1492 //Print("got type %d\n",t);
1493 switch(t)
1494 {
1495 case 1:res->rtyp=INT_CMD;
1496 res->data=(char *)(long)ssiReadInt(d->f_read);
1497 break;
1498 case 2:res->rtyp=STRING_CMD;
1499 res->data=(char *)ssiReadString(d);
1500 break;
1501 case 3:res->rtyp=NUMBER_CMD;
1502 if (d->r==NULL) goto no_ring;
1503 ssiCheckCurrRing(d->r);
1504 res->data=(char *)ssiReadNumber(d);
1505 break;
1506 case 4:res->rtyp=BIGINT_CMD;
1507 res->data=(char *)ssiReadBigInt(d);
1508 break;
1509 case 15:
1510 case 5:{
1511 d->r=ssiReadRing(d);
1512 if (errorreported) return NULL;
1513 res->data=(char*)d->r;
1514 if (d->r!=NULL) rIncRefCnt(d->r);
1515 res->rtyp=RING_CMD;
1516 if (t==15) // setring
1517 {
1518 if(ssiSetCurrRing(d->r)) { d->r=currRing; }
1520 return ssiRead1(l);
1521 }
1522 }
1523 break;
1524 case 6:res->rtyp=POLY_CMD;
1525 if (d->r==NULL) goto no_ring;
1526 ssiCheckCurrRing(d->r);
1527 res->data=(char*)ssiReadPoly(d);
1528 break;
1529 case 7:res->rtyp=IDEAL_CMD;
1530 if (d->r==NULL) goto no_ring;
1531 ssiCheckCurrRing(d->r);
1532 res->data=(char*)ssiReadIdeal(d);
1533 break;
1534 case 8:res->rtyp=MATRIX_CMD;
1535 if (d->r==NULL) goto no_ring;
1536 ssiCheckCurrRing(d->r);
1537 res->data=(char*)ssiReadMatrix(d);
1538 break;
1539 case 9:res->rtyp=VECTOR_CMD;
1540 if (d->r==NULL) goto no_ring;
1541 ssiCheckCurrRing(d->r);
1542 res->data=(char*)ssiReadPoly(d);
1543 break;
1544 case 10:
1545 case 22:if (t==22) res->rtyp=SMATRIX_CMD;
1546 else res->rtyp=MODUL_CMD;
1547 if (d->r==NULL) goto no_ring;
1548 ssiCheckCurrRing(d->r);
1549 {
1550 int rk=s_readint(d->f_read);
1551 ideal M=ssiReadIdeal(d);
1552 M->rank=rk;
1553 res->data=(char*)M;
1554 }
1555 break;
1556 case 11:
1557 {
1558 res->rtyp=COMMAND;
1559 res->data=ssiReadCommand(l);
1560 int nok=res->Eval();
1561 if (nok) WerrorS("error in eval");
1562 break;
1563 }
1564 case 12: /*DEF_CMD*/
1565 {
1566 res->rtyp=0;
1567 res->name=(char *)ssiReadString(d);
1568 int nok=res->Eval();
1569 if (nok) WerrorS("error in name lookup");
1570 break;
1571 }
1572 case 13: res->rtyp=PROC_CMD;
1573 res->data=ssiReadProc(d);
1574 break;
1575 case 14: res->rtyp=LIST_CMD;
1576 res->data=ssiReadList(l);
1577 break;
1578 case 16: res->rtyp=NONE; res->data=NULL;
1579 break;
1580 case 17: res->rtyp=INTVEC_CMD;
1581 res->data=ssiReadIntvec(d);
1582 break;
1583 case 18: res->rtyp=INTMAT_CMD;
1584 res->data=ssiReadIntmat(d);
1585 break;
1586 case 19: res->rtyp=BIGINTMAT_CMD;
1587 res->data=ssiReadBigintmat(d);
1588 break;
1589 case 20: ssiReadBlackbox(res,l);
1590 break;
1591 case 21: ssiReadAttrib(res,l);
1592 break;
1593 case 23: ssiReadRingProperties(l);
1594 return ssiRead1(l);
1595 break;
1596 // ------------
1597 case 98: // version
1598 {
1599 int n98_v,n98_m;
1600 BITSET n98_o1,n98_o2;
1601 n98_v=s_readint(d->f_read);
1602 n98_m=s_readint(d->f_read);
1603 n98_o1=s_readint(d->f_read);
1604 n98_o2=s_readint(d->f_read);
1605 if ((n98_v!=SSI_VERSION) ||(n98_m!=MAX_TOK))
1606 {
1607 Print("incompatible versions of ssi: %d/%d vs %d/%d\n",
1608 SSI_VERSION,MAX_TOK,n98_v,n98_m);
1609 }
1610 #ifndef SING_NDEBUG
1611 if (TEST_OPT_DEBUG)
1612 Print("// opening ssi-%d, MAX_TOK=%d\n",n98_v,n98_m);
1613 #endif
1614 si_opt_1=n98_o1;
1615 si_opt_2=n98_o2;
1617 return ssiRead1(l);
1618 }
1619 case 99: omFreeBin(res,sleftv_bin); ssiClose(l); m2_end(0);
1620 case 0: if (s_iseof(d->f_read))
1621 {
1622 ssiClose(l);
1623 }
1624 res->rtyp=DEF_CMD;
1625 break;
1626 default: Werror("not implemented (t:%d)",t);
1628 res=NULL;
1629 break;
1630 }
1631 // if currRing is required for the result, but lost
1632 // define "ssiRing%d" as currRing:
1633 if ((d->r!=NULL)
1634 && (currRing!=d->r)
1635 && (res->RingDependend()))
1636 {
1637 if(ssiSetCurrRing(d->r)) { d->r=currRing; }
1638 }
1639 return res;
1640no_ring: WerrorS("no ring");
1642 return NULL;
1643}
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 912 of file ssiLink.cc.

913{
914 ssiInfo *d=(ssiInfo*)l->data;
916 int nr_of_attr=s_readint(d->f_read);
917 if (nr_of_attr>0)
918 {
919 for(int i=1;i<nr_of_attr;i++)
920 {
921 }
922 }
923 leftv tmp=ssiRead1(l);
924 memcpy(res,tmp,sizeof(sleftv));
925 memset(tmp,0,sizeof(sleftv));
927 if (nr_of_attr>0)
928 {
929 }
930 res->flag=fl;
931}

◆ ssiReadBigInt()

static number ssiReadBigInt ( const ssiInfo d)
static

Definition at line 518 of file ssiLink.cc.

519{
521 if ((SR_HDL(n) & SR_INT)==0)
522 {
523 if (n->s!=3) Werror("invalid sub type in bigint:%d",n->s);
524 }
525 return n;
526}
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 871 of file ssiLink.cc.

872{
873 int r,c;
874 r=s_readint(d->f_read);
875 c=s_readint(d->f_read);
877 for(int i=0;i<r*c;i++)
878 {
879 (*v)[i]=ssiReadBigInt(d);
880 }
881 return v;
882}
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 884 of file ssiLink.cc.

885{
886 ssiInfo *d=(ssiInfo*)l->data;
887 int throwaway=s_readint(d->f_read);
888 char *name=ssiReadString(d);
889 int tok;
890 blackboxIsCmd(name,tok);
891 if (tok>MAX_TOK)
892 {
893 ring save_ring=currRing;
894 idhdl save_hdl=currRingHdl;
895 blackbox *b=getBlackboxStuff(tok);
896 res->rtyp=tok;
897 b->blackbox_deserialize(&b,&(res->data),l);
898 if (save_ring!=currRing)
899 {
900 rChangeCurrRing(save_ring);
901 if (save_hdl!=NULL) rSetHdl(save_hdl);
902 else currRingHdl=NULL;
903 }
904 }
905 else
906 {
907 Werror("blackbox %s not found",name);
908 }
909 omFree(name);
910}
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 774 of file ssiLink.cc.

775{
776 ssiInfo *d=(ssiInfo*)l->data;
777 // syntax: <num ops> <operation> <op1> <op2> ....
778 command D=(command)omAlloc0(sizeof(*D));
779 int argc,op;
780 argc=s_readint(d->f_read);
781 op=s_readint(d->f_read);
782 D->argc=argc; D->op=op;
783 leftv v;
784 if (argc >0)
785 {
786 v=ssiRead1(l);
787 memcpy(&(D->arg1),v,sizeof(*v));
789 }
790 if (argc <4)
791 {
792 if (D->argc >1)
793 {
794 v=ssiRead1(l);
795 memcpy(&(D->arg2),v,sizeof(*v));
797 }
798 if (D->argc >2)
799 {
800 v=ssiRead1(l);
801 memcpy(&(D->arg3),v,sizeof(*v));
803 }
804 }
805 else
806 {
807 leftv prev=&(D->arg1);
808 argc--;
809 while(argc >0)
810 {
811 v=ssiRead1(l);
812 prev->next=v;
813 prev=v;
814 argc--;
815 }
816 }
817 return D;
818}
leftv next
Definition: subexpr.h:86

◆ ssiReadIdeal()

static ideal ssiReadIdeal ( ssiInfo d)
static

Definition at line 753 of file ssiLink.cc.

754{
755 return ssiReadIdeal_R(d,d->r);
756}

◆ ssiReadIdeal_R()

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

Definition at line 739 of file ssiLink.cc.

740{
741// < # of terms> < term1> < .....
742 int n,i;
743 ideal I;
744 n=s_readint(d->f_read);
745 I=idInit(n,1); // will be fixed later for module/smatrix
746 for(i=0;i<IDELEMS(I);i++) // read n terms
747 {
748 I->m [i]=ssiReadPoly_R(d,r);
749 }
750 return I;
751}
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 489 of file ssiLink.cc.

490{
491 return s_readint(fich);
492}

◆ ssiReadIntmat()

static intvec * ssiReadIntmat ( const ssiInfo d)
static

Definition at line 859 of file ssiLink.cc.

860{
861 int r,c;
862 r=s_readint(d->f_read);
863 c=s_readint(d->f_read);
864 intvec *v=new intvec(r,c,0);
865 for(int i=0;i<r*c;i++)
866 {
867 (*v)[i]=s_readint(d->f_read);
868 }
869 return v;
870}
Definition: intvec.h:23

◆ ssiReadIntvec()

static intvec * ssiReadIntvec ( const ssiInfo d)
static

Definition at line 848 of file ssiLink.cc.

849{
850 int nr;
851 nr=s_readint(d->f_read);
852 intvec *v=new intvec(nr);
853 for(int i=0;i<nr;i++)
854 {
855 (*v)[i]=s_readint(d->f_read);
856 }
857 return v;
858}

◆ ssiReadList()

static lists ssiReadList ( si_link  l)
static

Definition at line 830 of file ssiLink.cc.

831{
832 ssiInfo *d=(ssiInfo*)l->data;
833 int nr;
834 nr=s_readint(d->f_read);
836 L->Init(nr);
837
838 int i;
839 leftv v;
840 for(i=0;i<=L->nr;i++)
841 {
842 v=ssiRead1(l);
843 memcpy(&(L->m[i]),v,sizeof(*v));
845 }
846 return L;
847}
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 758 of file ssiLink.cc.

759{
760 int n,m;
761 m=s_readint(d->f_read);
762 n=s_readint(d->f_read);
763 matrix M=mpNew(m,n);
764 poly p;
765 for(int i=1;i<=MATROWS(M);i++)
766 for(int j=1;j<=MATCOLS(M);j++)
767 {
768 p=ssiReadPoly(d);
769 MATELEM(M,i,j)=p;
770 }
771 return M;
772}
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 528 of file ssiLink.cc.

529{
530 return ssiReadNumber_CF(d,d->r->cf);
531}

◆ ssiReadNumber_CF()

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

Definition at line 494 of file ssiLink.cc.

495{
496 if (cf->cfReadFd!=ndReadFd)
497 {
498 return n_ReadFd(d,cf);
499 }
500 else if (getCoeffType(cf) == n_transExt)
501 {
502 // poly poly
503 fraction f=(fraction)n_Init(1,cf);
504 p_Delete(&NUM(f),cf->extRing);
505 NUM(f)=ssiReadPoly_R(d,cf->extRing);
506 DEN(f)=ssiReadPoly_R(d,cf->extRing);
507 return (number)f;
508 }
509 else if (getCoeffType(cf) == n_algExt)
510 {
511 // poly
512 return (number)ssiReadPoly_R(d,cf->extRing);
513 }
514 else WerrorS("coeffs not implemented in ssiReadNumber");
515 return NULL;
516}
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 734 of file ssiLink.cc.

735{
736 return ssiReadPoly_R(d,d->r);
737}

◆ ssiReadPoly_R()

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

Definition at line 703 of file ssiLink.cc.

704{
705// < # of terms> < term1> < .....
706 int n,i,l;
707 n=ssiReadInt(d->f_read); // # of terms
708 //Print("poly: terms:%d\n",n);
709 poly p;
710 poly ret=NULL;
711 poly prev=NULL;
712 for(l=0;l<n;l++) // read n terms
713 {
714// coef,comp.exp1,..exp N
715 p=p_Init(r,r->PolyBin);
716 pSetCoeff0(p,ssiReadNumber_CF(d,r->cf));
717 int D;
718 D=s_readint(d->f_read);
719 p_SetComp(p,D,r);
720 for(i=1;i<=rVar(r);i++)
721 {
722 D=s_readint(d->f_read);
723 p_SetExp(p,i,D,r);
724 }
725 p_Setm(p,r);
726 p_Test(p,r);
727 if (ret==NULL) ret=p;
728 else pNext(prev)=p;
729 prev=p;
730 }
731 return ret;
732}
#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 820 of file ssiLink.cc.

821{
822 char *s=ssiReadString(d);
824 p->language=LANG_SINGULAR;
825 p->libname=omStrDup("");
826 p->procname=omStrDup("");
827 p->data.s.body=s;
828 return p;
829}
procinfo * procinfov
Definition: structs.h:60
VAR omBin procinfo_bin
Definition: subexpr.cc:42

◆ ssiReadRing()

static ring ssiReadRing ( ssiInfo d)
static

Definition at line 533 of file ssiLink.cc.

534{
535/* syntax is <ch> <N> <l1> <v1> ...<lN> <vN> <number of orderings> <ord1> <block0_1> <block1_1> .... <Q-ideal> */
536 int ch;
537 int new_ref=-1;
538 ch=s_readint(d->f_read);
539 if (ch==-6)
540 {
541 new_ref=s_readint(d->f_read);
542 ch=s_readint(d->f_read);
543 }
544 if (ch==-5)
545 {
546 int index=s_readint(d->f_read);
547 ring r=d->rings[index];
548 rIncRefCnt(r);
549 return r;
550 }
551 if (ch==-4)
552 return NULL;
553 int N=s_readint(d->f_read);
554 char **names;
555 coeffs cf=NULL;
556 if (ch==-3)
557 {
558 char *cf_name=ssiReadString(d);
559 cf=nFindCoeffByName(cf_name);
560 if (cf==NULL)
561 {
562 Werror("cannot find cf:%s",cf_name);
563 omFreeBinAddr(cf_name);
564 return NULL;
565 }
566 }
567 if (N!=0)
568 {
569 names=(char**)omAlloc(N*sizeof(char*));
570 for(int i=0;i<N;i++)
571 {
572 names[i]=ssiReadString(d);
573 }
574 }
575 // read the orderings:
576 int num_ord; // number of orderings
577 num_ord=s_readint(d->f_read);
578 rRingOrder_t *ord=(rRingOrder_t *)omAlloc0((num_ord+1)*sizeof(rRingOrder_t));
579 int *block0=(int *)omAlloc0((num_ord+1)*sizeof(int));
580 int *block1=(int *)omAlloc0((num_ord+1)*sizeof(int));
581 int **wvhdl=(int**)omAlloc0((num_ord+1)*sizeof(int*));
582 for(int i=0;i<num_ord;i++)
583 {
584 ord[i]=(rRingOrder_t)s_readint(d->f_read);
585 block0[i]=s_readint(d->f_read);
586 block1[i]=s_readint(d->f_read);
587 switch(ord[i])
588 {
589 case ringorder_a:
590 case ringorder_wp:
591 case ringorder_Wp:
592 case ringorder_ws:
593 case ringorder_Ws:
594 case ringorder_aa:
595 {
596 int s=block1[i]-block0[i]+1; // #vars
597 wvhdl[i]=(int*)omAlloc(s*sizeof(int));
598 for(int ii=0;ii<s;ii++)
599 wvhdl[i][ii]=s_readint(d->f_read);
600 }
601 break;
602 case ringorder_M:
603 {
604 int s=block1[i]-block0[i]+1; // #vars
605 wvhdl[i]=(int*)omAlloc(s*s*sizeof(int));
606 for(int ii=0;ii<s*s;ii++)
607 {
608 wvhdl[i][ii]=s_readint(d->f_read);
609 }
610 }
611 break;
612 case ringorder_a64:
613 case ringorder_L:
614 case ringorder_IS:
615 Werror("ring order not implemented for ssi:%d",ord[i]);
616 break;
617
618 default: break;
619 }
620 }
621 if (N==0)
622 {
623 omFree(ord);
624 omFree(block0);
625 omFree(block1);
626 omFree(wvhdl);
627 return NULL;
628 }
629 else
630 {
631 ring r=NULL;
632 if (ch>=0) /* Q, Z/p */
633 r=rDefault(ch,N,names,num_ord,ord,block0,block1,wvhdl);
634 else if (ch==-1) /* trans ext. */
635 {
637 T.r=ssiReadRing(d);
638 if (T.r==NULL) return NULL;
640 r=rDefault(cf,N,names,num_ord,ord,block0,block1,wvhdl);
641 }
642 else if (ch==-2) /* alg ext. */
643 {
645 T.r=ssiReadRing(d); /* includes qideal */
646 if (T.r==NULL) return NULL;
648 r=rDefault(cf,N,names,num_ord,ord,block0,block1,wvhdl);
649 }
650 else if (ch==-3)
651 {
652 r=rDefault(cf,N,names,num_ord,ord,block0,block1,wvhdl);
653 }
654 else
655 {
656 Werror("ssi: read unknown coeffs type (%d)",ch);
657 for(int i=0;i<N;i++)
658 {
659 omFree(names[i]);
660 }
661 omFreeSize(names,N*sizeof(char*));
662 return NULL;
663 }
664 ideal q=ssiReadIdeal_R(d,r);
665 if (IDELEMS(q)==0) omFreeBin(q,sip_sideal_bin);
666 else r->qideal=q;
667 for(int i=0;i<N;i++)
668 {
669 omFree(names[i]);
670 }
671 omFreeSize(names,N*sizeof(char*));
672 rIncRefCnt(r);
673 // check if such ring already exist as ssiRing*
674 char name[20];
675 int nr=0;
676 idhdl h=NULL;
677 loop
678 {
679 snprintf(name,20,"ssiRing%d",nr); nr++;
680 h=IDROOT->get(name, 0);
681 if (h==NULL)
682 {
683 break;
684 }
685 else if ((IDTYP(h)==RING_CMD)
686 && (r!=IDRING(h))
687 && (rEqual(r,IDRING(h),1)))
688 {
689 rDelete(r);
690 r=rIncRefCnt(IDRING(h));
691 break;
692 }
693 }
694 if (new_ref!=-1)
695 {
696 d->rings[new_ref]=r;
697 rIncRefCnt(r);
698 }
699 return r;
700 }
701}
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 932 of file ssiLink.cc.

933{
934 ssiInfo *d=(ssiInfo*)l->data;
935 int what=s_readint(d->f_read);
936 switch(what)
937 {
938 case 0: // bitmask
939 {
940 int lb=s_readint(d->f_read);
941 unsigned long bm=~0L;
942 bm=bm<<lb;
943 bm=~bm;
944 rUnComplete(d->r);
945 d->r->bitmask=bm;
946 rComplete(d->r);
947 break;
948 }
949 case 1: // LPRing
950 {
951 int lb=s_readint(d->f_read);
952 int isLPring=s_readint(d->f_read);
953 unsigned long bm=~0L;
954 bm=bm<<lb;
955 bm=~bm;
956 rUnComplete(d->r);
957 d->r->bitmask=bm;
958 d->r->isLPring=isLPring;
959 rComplete(d->r);
960 break;
961 }
962 case 2: // Plural rings
963 {
966 nc_CallPlural(C,D,NULL,NULL,d->r,true,true,false,d->r,false);
967 break;
968 }
969 }
970}
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:3459
void rUnComplete(ring r)
Definition: ring.cc:3974

◆ ssiReadString()

static char * ssiReadString ( const ssiInfo d)
static

Definition at line 476 of file ssiLink.cc.

477{
478 char *buf;
479 int l;
480 l=s_readint(d->f_read);
481 buf=(char*)omAlloc0(l+1);
482 int throwaway =s_getc(d->f_read); /* skip ' '*/
483 throwaway=s_readbytes(buf,l,d->f_read);
484 //if (throwaway!=l) printf("want %d, got %d bytes\n",l,throwaway);
485 buf[l]='\0';
486 return buf;
487}
int s_readbytes(char *buff, int len, s_buff F)
Definition: s_buff.cc:168

◆ ssiReservePort()

int ssiReservePort ( int  clients)

Definition at line 2095 of file ssiLink.cc.

2096{
2097 if (ssiReserved_P!=0)
2098 {
2099 WerrorS("ERROR already a reserved port requested");
2100 return 0;
2101 }
2102 int portno;
2103 ssiReserved_sockfd = socket(AF_INET, SOCK_STREAM, 0);
2104 if(ssiReserved_sockfd < 0)
2105 {
2106 WerrorS("ERROR opening socket");
2107 return 0;
2108 }
2109 memset((char *) &ssiResverd_serv_addr,0, sizeof(ssiResverd_serv_addr));
2110 portno = 1025;
2111 ssiResverd_serv_addr.sin_family = AF_INET;
2112 ssiResverd_serv_addr.sin_addr.s_addr = INADDR_ANY;
2113 do
2114 {
2115 portno++;
2116 ssiResverd_serv_addr.sin_port = htons(portno);
2117 if(portno > 50000)
2118 {
2119 WerrorS("ERROR on binding (no free port available?)");
2120 return 0;
2121 }
2122 }
2123 while(bind(ssiReserved_sockfd, (struct sockaddr *) &ssiResverd_serv_addr, sizeof(ssiResverd_serv_addr)) < 0);
2124 ssiReserved_P=portno;
2125 listen(ssiReserved_sockfd,clients);
2126 ssiReserved_Clients=clients;
2127 return portno;
2128}

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

1646{
1647 if(SI_LINK_W_OPEN_P(l)==0)
1649 ssiInfo *d = (ssiInfo *)l->data;
1650 if (d->r!=r)
1651 {
1652 if (send)
1653 {
1654 fputs("15 ",d->f_write);
1655 ssiWriteRing(d,r);
1656 }
1657 d->r=r;
1658 }
1659 if (currRing!=r) rChangeCurrRing(r);
1660 return FALSE;
1661}

◆ ssiWrite()

BOOLEAN ssiWrite ( si_link  l,
leftv  data 
)

Definition at line 1664 of file ssiLink.cc.

1665{
1666 if(SI_LINK_W_OPEN_P(l)==0)
1668 ssiInfo *d = (ssiInfo *)l->data;
1669 d->level++;
1670 //FILE *fich=d->f;
1671 while (data!=NULL)
1672 {
1673 int tt=data->Typ();
1674 void *dd=data->Data();
1675 attr *aa=data->Attribute();
1676 if ((aa!=NULL) && ((*aa)!=NULL)) // n user attributes
1677 {
1678 attr a=*aa;
1679 int n=0;
1680 while(a!=NULL) { n++; a=a->next;}
1681 fprintf(d->f_write,"21 %d %d ",data->flag,n);
1682 }
1683 else if (data->flag!=0) // only "flag" attributes
1684 {
1685 fprintf(d->f_write,"21 %d 0 ",data->flag);
1686 }
1687 if ((dd==NULL) && (data->name!=NULL) && (tt==0)) tt=DEF_CMD;
1688 // return pure undefined names as def
1689
1690 switch(tt /*data->Typ()*/)
1691 {
1692 case 0: /*error*/
1693 case NONE/* nothing*/:fputs("16 ",d->f_write);
1694 break;
1695 case STRING_CMD: fputs("2 ",d->f_write);
1696 ssiWriteString(d,(char *)dd);
1697 break;
1698 case INT_CMD: fputs("1 ",d->f_write);
1699 ssiWriteInt(d,(int)(long)dd);
1700 break;
1701 case BIGINT_CMD:fputs("4 ",d->f_write);
1702 ssiWriteBigInt(d,(number)dd);
1703 break;
1704 case NUMBER_CMD:
1705 if (d->r!=currRing)
1706 {
1707 fputs("15 ",d->f_write);
1709 if (d->level<=1) fputc('\n',d->f_write);
1710 }
1711 fputs("3 ",d->f_write);
1712 ssiWriteNumber(d,(number)dd);
1713 break;
1714 case RING_CMD:fputs("5 ",d->f_write);
1715 ssiWriteRing(d,(ring)dd);
1716 break;
1717 case BUCKET_CMD:
1718 {
1720 if (d->r!=sBucketGetRing(b))
1721 {
1722 fputs("15 ",d->f_write);
1724 if (d->level<=1) fputc('\n',d->f_write);
1725 }
1726 fputs("6 ",d->f_write);
1727 ssiWritePoly(d,tt,sBucketPeek(b));
1728 break;
1729 }
1730 case POLY_CMD:
1731 case VECTOR_CMD:
1732 if (d->r!=currRing)
1733 {
1734 fputs("15 ",d->f_write);
1736 if (d->level<=1) fputc('\n',d->f_write);
1737 }
1738 if(tt==POLY_CMD) fputs("6 ",d->f_write);
1739 else fputs("9 ",d->f_write);
1740 ssiWritePoly(d,tt,(poly)dd);
1741 break;
1742 case IDEAL_CMD:
1743 case MODUL_CMD:
1744 case MATRIX_CMD:
1745 case SMATRIX_CMD:
1746 if (d->r!=currRing)
1747 {
1748 fputs("15 ",d->f_write);
1750 if (d->level<=1) fputc('\n',d->f_write);
1751 }
1752 if(tt==IDEAL_CMD) fputs("7 ",d->f_write);
1753 else if(tt==MATRIX_CMD) fputs("8 ",d->f_write);
1754 else if(tt==SMATRIX_CMD) fputs("22 ",d->f_write);
1755 else /* tt==MODUL_CMD*/
1756 {
1757 ideal M=(ideal)dd;
1758 fprintf(d->f_write,"10 %d ",(int)M->rank);
1759 }
1760 ssiWriteIdeal(d,tt,(ideal)dd);
1761 break;
1762 case COMMAND:
1763 fputs("11 ",d->f_write);
1765 break;
1766 case DEF_CMD: /* not evaluated stuff in quotes */
1767 fputs("12 ",d->f_write);
1768 ssiWriteString(d,data->Name());
1769 break;
1770 case PROC_CMD:
1771 fputs("13 ",d->f_write);
1772 ssiWriteProc(d,(procinfov)dd);
1773 break;
1774 case LIST_CMD:
1775 fputs("14 ",d->f_write);
1776 ssiWriteList(l,(lists)dd);
1777 break;
1778 case INTVEC_CMD:
1779 fputs("17 ",d->f_write);
1780 ssiWriteIntvec(d,(intvec *)dd);
1781 break;
1782 case INTMAT_CMD:
1783 fputs("18 ",d->f_write);
1784 ssiWriteIntmat(d,(intvec *)dd);
1785 break;
1786 case BIGINTMAT_CMD:
1787 fputs("19 ",d->f_write);
1789 break;
1790 default:
1791 if (tt>MAX_TOK)
1792 {
1793 blackbox *b=getBlackboxStuff(tt);
1794 fputs("20 ",d->f_write);
1795 b->blackbox_serialize(b,dd,l);
1796 }
1797 else
1798 {
1799 Werror("not implemented (t:%d, rtyp:%d)",tt, data->rtyp);
1800 d->level=0;
1801 return TRUE;
1802 }
1803 break;
1804 }
1805 if (d->level<=1) { fputc('\n',d->f_write); fflush(d->f_write); }
1806 data=data->next;
1807 }
1808 d->level--;
1809 return FALSE;
1810}
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 466 of file ssiLink.cc.

467{
468 fprintf(d->f_write,"%d %d ",v->rows(),v->cols());
469 int i;
470 for(i=0;i<v->length();i++)
471 {
472 ssiWriteBigInt(d,(*v)[i]);
473 }
474}

◆ ssiWriteCommand()

static void ssiWriteCommand ( si_link  l,
command  D 
)
static

Definition at line 413 of file ssiLink.cc.

414{
415 ssiInfo *d=(ssiInfo*)l->data;
416 // syntax: <num ops> <operation> <op1> <op2> ....
417 fprintf(d->f_write,"%d %d ",D->argc,D->op);
418 if (D->argc >0) ssiWrite(l, &(D->arg1));
419 if (D->argc < 4)
420 {
421 if (D->argc >1) ssiWrite(l, &(D->arg2));
422 if (D->argc >2) ssiWrite(l, &(D->arg3));
423 }
424}

◆ ssiWriteIdeal()

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

Definition at line 408 of file ssiLink.cc.

409{
410 ssiWriteIdeal_R(d,typ,I,d->r);
411}

◆ ssiWriteIdeal_R()

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

Definition at line 378 of file ssiLink.cc.

379{
380 // syntax: 7 # of elements <poly 1> <poly2>.....(ideal,module,smatrix)
381 // syntax: 8 <rows> <cols> <poly 1> <poly2>.....(matrix)
382 // syntax
383 matrix M=(matrix)I;
384 int mn;
385 if (typ==MATRIX_CMD)
386 {
387 mn=MATROWS(M)*MATCOLS(M);
388 fprintf(d->f_write,"%d %d ", MATROWS(M),MATCOLS(M));
389 }
390 else
391 {
392 mn=IDELEMS(I);
393 fprintf(d->f_write,"%d ",IDELEMS(I));
394 }
395
396 int i;
397 int tt;
398 if ((typ==MODUL_CMD)||(typ==SMATRIX_CMD))
399 tt=VECTOR_CMD;
400 else
401 tt=POLY_CMD;
402
403 for(i=0;i<mn;i++)
404 {
405 ssiWritePoly_R(d,tt,I->m[i],R);
406 }
407}
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 456 of file ssiLink.cc.

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

◆ ssiWriteIntvec()

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

Definition at line 447 of file ssiLink.cc.

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

◆ ssiWriteList()

static void ssiWriteList ( si_link  l,
lists  dd 
)
static

Definition at line 436 of file ssiLink.cc.

437{
438 ssiInfo *d=(ssiInfo*)l->data;
439 int Ll=dd->nr;
440 fprintf(d->f_write,"%d ",Ll+1);
441 int i;
442 for(i=0;i<=Ll;i++)
443 {
444 ssiWrite(l,&(dd->m[i]));
445 }
446}

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

374{
375 ssiWritePoly_R(d,typ,p,d->r);
376}

◆ ssiWritePoly_R()

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

Definition at line 355 of file ssiLink.cc.

356{
357 fprintf(d->f_write,"%d ",pLength(p));//number of terms
358
359 while(p!=NULL)
360 {
361 ssiWriteNumber_CF(d,pGetCoeff(p),r->cf);
362 //nWrite(fich,pGetCoeff(p));
363 fprintf(d->f_write,"%ld ",p_GetComp(p,r));//component
364
365 for(int j=1;j<=rVar(r);j++)
366 {
367 fprintf(d->f_write,"%ld ",p_GetExp(p,j,r ));//x^j
368 }
369 pIter(p);
370 }
371}
#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 426 of file ssiLink.cc.

427{
428 if (p->data.s.body==NULL)
430 if (p->data.s.body!=NULL)
431 ssiWriteString(d,p->data.s.body);
432 else
433 ssiWriteString(d,"");
434}
char * iiGetLibProcBuffer(procinfo *pi, int part)
Definition: iplib.cc:197

◆ ssiWriteRing()

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

Definition at line 330 of file ssiLink.cc.

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

◆ 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 s=r->block1[i]-r->block0[i]+1; // #vars
265 for(int ii=0;ii<s;ii++)
266 fprintf(d->f_write,"%d ",r->wvhdl[i][ii]);
267 }
268 break;
269 case ringorder_M:
270 {
271 int s=r->block1[i]-r->block0[i]+1; // #vars
272 for(int ii=0;ii<s*s;ii++)
273 {
274 fprintf(d->f_write,"%d ",r->wvhdl[i][ii]);
275 }
276 }
277 break;
278
279 case ringorder_a64:
280 case ringorder_L:
281 case ringorder_IS:
282 Werror("ring oder not implemented for ssi:%d",r->order[i]);
283 break;
284
285 default: break;
286 }
287 i++;
288 }
289 if ((rFieldType(r)==n_transExt)
290 || (rFieldType(r)==n_algExt))
291 {
292 ssiWriteRing_R(d,r->cf->extRing); /* includes alg.ext if rFieldType(r)==n_algExt */
293 }
294 /* Q-ideal :*/
295 if (r->qideal!=NULL)
296 {
297 ssiWriteIdeal_R(d,IDEAL_CMD,r->qideal,r);
298 }
299 else
300 {
301 fputs("0 ",d->f_write/*ideal with 0 entries */);
302 }
303 }
304 else /* dummy ring r==NULL*/
305 {
306 fputs("0 0 0 0 "/*,r->ch,r->N, blocks, q-ideal*/,d->f_write);
307 }
308 if (rIsLPRing(r)) // cannot be combined with 23 2
309 {
310 fprintf(d->f_write,"23 1 %d %d ",SI_LOG2(r->bitmask),r->isLPring);
311 }
312 else
313 {
314 unsigned long bm=0;
315 int b=0;
316 bm=rGetExpSize(bm,b,r->N);
317 if (r->bitmask!=bm)
318 {
319 fprintf(d->f_write,"23 0 %d ",SI_LOG2(r->bitmask));
320 }
321 if (rIsPluralRing(r))
322 {
323 fputs("23 2 ",d->f_write);
324 ssiWriteIdeal(d,MATRIX_CMD,(ideal)r->GetNC()->C);
325 ssiWriteIdeal(d,MATRIX_CMD,(ideal)r->GetNC()->D);
326 }
327 }
328}
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:2579
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 2130 of file ssiLink.cc.

◆ ssiReserved_Clients

STATIC_VAR int ssiReserved_Clients

Definition at line 2094 of file ssiLink.cc.

◆ ssiReserved_P

STATIC_VAR int ssiReserved_P =0

Definition at line 2091 of file ssiLink.cc.

◆ ssiReserved_sockfd

STATIC_VAR int ssiReserved_sockfd

Definition at line 2092 of file ssiLink.cc.

◆ ssiResverd_serv_addr

STATIC_VAR struct sockaddr_in ssiResverd_serv_addr

Definition at line 2093 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.