8#define TRANSEXT_PRIVATES 1
52#include <netinet/in.h>
192 else if (
cf->cfWriteFd!=
NULL)
196 else WerrorS(
"coeff field not implemented");
252 if (r->order!=
NULL)
while (r->order[
i]!=0)
i++;
256 if (r->order!=
NULL)
while(r->order[
i]!=0)
268 int s=r->block1[
i]-r->block0[
i]+1;
275 int s=r->block1[
i]-r->block0[
i]+1;
286 Werror(
"ring oder not implemented for ssi:%d",r->order[
i]);
432 if (
p->data.s.body==
NULL)
434 if (
p->data.s.body!=
NULL)
455 for(
i=0;
i<
v->length();
i++)
464 for(
i=0;
i<
v->length();
i++)
474 for(
i=0;
i<
v->length();
i++)
484 for(
i=0;
i<
v->length();
i++)
528 else WerrorS(
"coeffs not implemented in ssiReadNumber");
537 if (n->s!=3)
Werror(
"invalid sub type in bigint:%d",n->s);
583 names=(
char**)
omAlloc(
N*
sizeof(
char*));
610 int s=block1[
i]-block0[
i]+1;
618 int s=block1[
i]-block0[
i]+1;
629 Werror(
"ring order not implemented for ssi:%d",ord[
i]);
670 Werror(
"ssi: read unknown coeffs type (%d)",ch);
796 D->argc=argc;
D->op=op;
854 for(
i=0;
i<=L->
nr;
i++)
867 for(
int i=0;
i<nr;
i++)
879 for(
int i=0;
i<r*c;
i++)
891 for(
int i=0;
i<r*c;
i++)
923 b->blackbox_deserialize(&
b,&(
res->data),
l);
967 unsigned long bm=~0L;
979 unsigned long bm=~0L;
984 d->
r->isLPring=isLPring;
1007 if (
l->mode[0] !=
'\0' && (
strcmp(
l->mode,
"r") == 0))
1013 else if (
strcmp(
l->mode,
"w") == 0) mode =
"w";
1014 else if (
strcmp(
l->mode,
"fork") == 0) mode =
"fork";
1015 else if (
strcmp(
l->mode,
"tcp") == 0) mode =
"tcp";
1016 else if (
strcmp(
l->mode,
"connect") == 0) mode =
"connect";
1026 if (
l->name[0] ==
'\0')
1028 if (
strcmp(mode,
"fork")==0)
1082#ifdef HAVE_SIMPLEIPC
1143 else if (
strcmp(mode,
"tcp")==0)
1150 WerrorS(
"ERROR opening socket");
1166 WerrorS(
"ERROR on binding (no free port available?)");
1185 PrintS(
"client accepted\n");
1196 Werror(
"invalid mode >>%s<< for ssi",mode);
1207 if(
strcmp(mode,
"tcp")==0)
1214 WerrorS(
"ERROR opening socket");
1230 WerrorS(
"ERROR on binding (no free port available?)");
1244 WerrorS(
"ERROR: no host specified");
1254 WarnS(
"program not specified, using /usr/local/bin/Singular");
1309 else if(
strcmp(mode,
"connect")==0)
1323 WerrorS(
"ERROR opening socket");
1330 WerrorS(
"ERROR, no such host");
1368 char *filename=
l->name;
1370 if(filename[0]==
'>')
1372 if (filename[1]==
'>')
1456 if (((
strcmp(
l->mode,
"tcp")==0)
1457 || (
strcmp(
l->mode,
"fork")==0))
1463 && (kill(d->
pid,0)==0))
1468 for(
int i=0;
i<50;
i++)
1472 t.tv_nsec=100000000;
1477 if (kill(d->
pid,0)==0)
1487 if ((
strcmp(
l->mode,
"tcp")==0)
1488 || (
strcmp(
l->mode,
"fork")==0))
1498 else while(
hh->next!=
NULL)
1552 res->data=(
char*)d->
r;
1656 Print(
"incompatible versions of ssi: %d/%d vs %d/%d\n",
1676 default:
Werror(
"not implemented (t:%d)",t);
1685 && (
res->RingDependend()))
1733 else if (data->
flag!=0)
1851 b->blackbox_serialize(
b,
dd,
l);
1855 Werror(
"not implemented (t:%d, rtyp:%d)",
tt, data->
rtyp);
1891 if (d==
NULL)
return "not open";
1892 if (((
strcmp(
l->mode,
"fork")==0)
1894 ||(
strcmp(
l->mode,
"connect")==0))
1898#if defined(HAVE_POLL)
1909 case 0:
return "not ready";
1910 case -1:
return "error";
1934 case 0:
return "not ready";
1935 case -1:
return "error";
1943 if (c== -1)
return "eof";
1948 Werror(
"unknown char in ssiLink(%d)",c);
1957 else return "not ready";
1962 else return "not ready";
1964 else return "unknown status request";
1980#if defined(HAVE_POLL) && !defined(__APPLE__)
1988 for(
int i=L->
nr;
i>=0;
i--)
1994 {
WerrorS(
"all elements must be of type link");
return -2;}
1997 {
WerrorS(
"all links must be open");
return -2;}
1998 if (((
strcmp(
l->m->type,
"ssi")!=0) && (
strcmp(
l->m->type,
"MPtcp")!=0))
2000 && (
strcmp(
l->mode,
"launch")!=0) && (
strcmp(
l->mode,
"connect")!=0)))
2002 WerrorS(
"all links must be of type ssi:fork, ssi:tcp, ssi:connect");
2005 if (
strcmp(
l->m->type,
"ssi")==0)
2021 Werror(
"wrong link type >>%s<<",
l->m->type);
2040 for(
int i=L->
nr;
i>=0;
i--)
2093 for(
i=L->
nr;
i>=0;
i--)
2098 {
WerrorS(
"all elements must be of type link");
return -2;}
2101 {
WerrorS(
"all links must be open");
return -2;}
2102 if (((
strcmp(
l->m->type,
"ssi")!=0) && (
strcmp(
l->m->type,
"MPtcp")!=0))
2104 && (
strcmp(
l->mode,
"launch")!=0) && (
strcmp(
l->mode,
"connect")!=0)))
2106 WerrorS(
"all links must be of type ssi:fork, ssi:tcp, ssi:connect");
2109 if (
strcmp(
l->m->type,
"ssi")==0)
2126 Werror(
"wrong link type >>%s<<",
l->m->type);
2153 for(
i=L->
nr;
i>=0;
i--)
2158 if (
strcmp(
l->m->type,
"ssi")==0)
2210 WerrorS(
"ERROR already a reserved port requested");
2217 WerrorS(
"ERROR opening socket");
2230 WerrorS(
"ERROR on binding (no free port available?)");
2246 WerrorS(
"ERROR no reserved port requested");
2260 while (
strcmp(
s->type,
"ssi") != 0)
2262 if (
s->next ==
NULL)
2329 else if (
kidpid==0)
break;
2400 package p=(package)IDDATA(h);
2407 D->arg1.data=
p->libname;
2409 D->arg2.data=(
char*)
"with";
2420 D->arg1.data=
p->libname;
2501 && (
strcmp(
hh->l->mode,
"fork")==0))
blackbox * getBlackboxStuff(const int t)
return the structure to the type given by t
int blackboxIsCmd(const char *n, int &tok)
used by scanner: returns ROOT_DECL for known types (and the type number in tok)
const CanonicalForm CFMap CFMap & N
Class used for (list of) interpreter objects.
INLINE_THIS void Init(int l=0)
VAR BOOLEAN singular_in_batchmode
si_hdl_typ si_set_signal(int sig, si_hdl_typ signal_handler)
meta function for binding a signal to an handler
static FORCE_INLINE number n_ReadFd(const ssiInfo *f, const coeffs r)
io via ssi:
static FORCE_INLINE void n_WriteFd(number a, const ssiInfo *f, const coeffs r)
io via ssi:
@ n_algExt
used for all algebraic extensions, i.e., the top-most extension in an extension tower is algebraic
@ n_transExt
used for all transcendental extensions, i.e., the top-most extension in an extension tower is transce...
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
static FORCE_INLINE int n_GetChar(const coeffs r)
Return the characteristic of the coeff. domain.
static FORCE_INLINE char * nCoeffName(const coeffs cf)
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
const CanonicalForm int s
const Variable & v
< [in] a sqrfree bivariate poly
char name(const Variable &v)
void WerrorS(const char *s)
FILE * myfopen(const char *path, const char *mode)
const char * feSetOptValue(feOptIndex opt, char *optarg)
VAR char my_yylinebuf[80]
char * fe_fgets_dummy(const char *, char *, int)
char *(* fe_fgets_stdin)(const char *pr, char *s, int size)
idhdl enterid(const char *s, int lev, int t, idhdl *root, BOOLEAN init, BOOLEAN search)
EXTERN_VAR omBin sleftv_bin
char * iiGetLibProcBuffer(procinfo *pi, int part)
idhdl rFindHdl(ring r, idhdl n)
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,...
matrix mpNew(int r, int c)
create a r x c zero-matrix
#define MATELEM(mat, i, j)
1-based access to matrix
void rem(unsigned long *a, unsigned long *q, unsigned long p, int °a, int degq)
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy
The main handler for Singular numbers which are suitable for Singular polynomials.
number ndReadFd(const ssiInfo *, const coeffs r)
coeffs nFindCoeffByName(char *cf_name)
find an existing coeff by its "CoeffName"
#define omFreeSize(addr, size)
#define omFreeBin(addr, bin)
#define omFreeBinAddr(addr)
static int index(p_Length length, p_Ord ord)
static int pLength(poly a)
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
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
static void p_Setm(poly p, const ring r)
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent @Note: the integer VarOffset encodes:
static void p_Delete(poly *p, const ring r)
static poly p_Init(const ring r, omBin bin)
void rChangeCurrRing(ring r)
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
void PrintS(const char *s)
void Werror(const char *fmt,...)
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...
static unsigned long rGetExpSize(unsigned long bitmask, int &bits)
void rDelete(ring r)
unconditionally deletes fields in r
ring rDefault(const coeffs cf, int N, char **n, int ord_size, rRingOrder_t *ord, int *block0, int *block1, int **wvhdl, unsigned long bitmask)
BOOLEAN rEqual(ring r1, ring r2, BOOLEAN qr)
returns TRUE, if r1 equals r2 FALSE, otherwise Equality is determined componentwise,...
static BOOLEAN rField_is_Zp(const ring r)
static n_coeffType rFieldType(const ring r)
the type of the coefficient filed of r (n_Zp, n_Q, etc)
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
static ring rIncRefCnt(ring r)
static BOOLEAN rIsLPRing(const ring r)
@ ringorder_a64
for int64 weights
@ ringorder_aa
for idElimination, like a, except pFDeg, pWeigths ignore it
@ ringorder_IS
Induced (Schreyer) ordering.
static BOOLEAN rField_is_Q(const ring r)
static short rVar(const ring r)
#define rVar(r) (r->N)
s_buff s_open_by_name(const char *n)
int s_readbytes(char *buff, int len, s_buff F)
void s_ungetc(int c, s_buff F)
ring rings[SI_RING_CACHE]
poly sBucketPeek(sBucket_pt b)
ring sBucketGetRing(const sBucket_pt bucket)
Returns bucket ring.
VAR int sem_acquired[SIPC_MAX_SEMAPHORES]
static int SI_LOG2(int v)
int status int void * buf
VAR omBin s_si_link_extension_bin
BOOLEAN slClose(si_link l)
BOOLEAN slInit(si_link l, char *istr)
BOOLEAN slOpen(si_link l, short flag, leftv h)
#define SI_LINK_W_OPEN_P(l)
leftv(* slRead2Proc)(si_link l, leftv a)
#define SI_LINK_SET_CLOSE_P(l)
#define SI_LINK_R_OPEN_P(l)
#define SI_LINK_SET_RW_OPEN_P(l)
#define SI_LINK_SET_OPEN_P(l, flag)
#define SI_LINK_OPEN_P(l)
ideal idInit(int idsize, int rank)
initialise an ideal / module
#define SIPC_MAX_SEMAPHORES
static matrix ssiReadMatrix(ssiInfo *d)
si_link_extension slInitSsiExtension(si_link_extension s)
static intvec * ssiReadIntvec(const ssiInfo *d)
STATIC_VAR int ssiReserved_P
BOOLEAN ssiDump(si_link l)
static ring ssiReadRing(ssiInfo *d)
static BOOLEAN ssiPrepClose(si_link l)
STATIC_VAR int ssiReserved_sockfd
const char * slStatusSsi(si_link l, const char *request)
static BOOLEAN ssiDumpIter(si_link l, idhdl h)
static lists ssiReadList(si_link l)
static void ssiWriteIdeal_R(const ssiInfo *d, int typ, const ideal I, const ring r)
VAR link_list ssiToBeClosed
int ssiReadInt(const ssiInfo *d)
static void ssiWriteString(const ssiInfo *d, const char *s)
STATIC_VAR int ssiReserved_Clients
void singular_close_links()
static void ssiWriteIntvec(const ssiInfo *d, intvec *v)
EXTERN_VAR BOOLEAN FE_OPT_NO_SHELL_FLAG
void sig_chld_hdl(int)
additional default signal handler
static char * ssiReadString(const ssiInfo *d)
static void ssiReadBlackbox(leftv res, si_link l)
static void ssiWriteList(si_link l, lists dd)
int slStatusSsiL(lists L, int timeout, BOOLEAN *ignore)
BOOLEAN ssiClose(si_link l)
static void ssiWriteIntmat(const ssiInfo *d, intvec *v)
static void ssiWriteRing_R(ssiInfo *d, const ring r)
EXTERN_VAR si_link_extension si_link_root
static bigintmat * ssiReadBigintvec(const ssiInfo *d)
ideal ssiReadIdeal(ssiInfo *d)
static void ssiWriteRing(ssiInfo *d, const ring r)
static void ssiCheckCurrRing(const ring r)
static bigintmat * ssiReadBigintmat(const ssiInfo *d)
static void ssiWriteProc(const ssiInfo *d, procinfov p)
static poly ssiReadPoly_R(const ssiInfo *D, const ring r)
static ideal ssiReadIdeal_R(const ssiInfo *d, const ring r)
static number ssiReadBigInt(const ssiInfo *d)
static void ssiWritePoly(const ssiInfo *d, int typ, poly p)
void ssiWriteIdeal(const ssiInfo *d, int typ, const ideal I)
BOOLEAN ssiOpen(si_link l, short flag, leftv u)
BOOLEAN ssiWrite(si_link l, leftv data)
static command ssiReadCommand(si_link l)
BOOLEAN ssiGetDump(si_link l)
static void ssiWriteNumber(const ssiInfo *d, const number n)
static BOOLEAN DumpSsiIdhdl(si_link l, idhdl h)
static void ssiWriteCommand(si_link l, command D)
static intvec * ssiReadIntmat(const ssiInfo *d)
static BOOLEAN ssiSetRing(si_link l, ring r, BOOLEAN send)
static number ssiReadNumber(ssiInfo *d)
STATIC_VAR struct sockaddr_in ssiResverd_serv_addr
static void ssiReadRingProperties(si_link l)
int ssiBatch(const char *host, const char *port)
VAR volatile BOOLEAN ssiToBeClosed_inactive
static void ssiWriteBigintmat(const ssiInfo *d, bigintmat *v)
static void ssiWriteBigintvec(const ssiInfo *d, bigintmat *v)
static BOOLEAN ssiSetCurrRing(const ring r)
static poly ssiReadPoly(ssiInfo *d)
static void ssiWritePoly_R(const ssiInfo *d, int typ, poly p, const ring r)
void ssiWriteInt(const ssiInfo *d, const int i)
static void ssiReadAttrib(leftv res, si_link l)
static void ssiWriteBigInt(const ssiInfo *d, const number n)
static void ssiWriteNumber_CF(const ssiInfo *d, const number n, const coeffs cf)
static number ssiReadNumber_CF(const ssiInfo *d, const coeffs cf)
int ssiReservePort(int clients)
static procinfov ssiReadProc(const ssiInfo *d)
leftv ssiRead1(si_link l)
struct for passing initialization parameters to naInitChar