8#define TRANSEXT_PRIVATES 1
50#include <netinet/in.h>
191 else if (
cf->cfWriteFd!=
NULL)
195 else WerrorS(
"coeff field not implemented");
251 if (r->order!=
NULL)
while (r->order[
i]!=0)
i++;
255 if (r->order!=
NULL)
while(r->order[
i]!=0)
267 int s=r->block1[
i]-r->block0[
i]+1;
274 int s=r->block1[
i]-r->block0[
i]+1;
285 Werror(
"ring oder not implemented for ssi:%d",r->order[
i]);
431 if (
p->data.s.body==
NULL)
433 if (
p->data.s.body!=
NULL)
454 for(
i=0;
i<
v->length();
i++)
463 for(
i=0;
i<
v->length();
i++)
473 for(
i=0;
i<
v->length();
i++)
483 for(
i=0;
i<
v->length();
i++)
527 else WerrorS(
"coeffs not implemented in ssiReadNumber");
536 if (n->s!=3)
Werror(
"invalid sub type in bigint:%d",n->s);
582 names=(
char**)
omAlloc(
N*
sizeof(
char*));
609 int s=block1[
i]-block0[
i]+1;
617 int s=block1[
i]-block0[
i]+1;
628 Werror(
"ring order not implemented for ssi:%d",ord[
i]);
669 Werror(
"ssi: read unknown coeffs type (%d)",ch);
795 D->argc=argc;
D->op=op;
853 for(
i=0;
i<=L->
nr;
i++)
866 for(
int i=0;
i<nr;
i++)
878 for(
int i=0;
i<r*c;
i++)
890 for(
int i=0;
i<r*c;
i++)
922 b->blackbox_deserialize(&
b,&(
res->data),
l);
966 unsigned long bm=~0L;
978 unsigned long bm=~0L;
983 d->
r->isLPring=isLPring;
1006 if (
l->mode[0] !=
'\0' && (
strcmp(
l->mode,
"r") == 0))
1012 else if (
strcmp(
l->mode,
"w") == 0) mode =
"w";
1013 else if (
strcmp(
l->mode,
"fork") == 0) mode =
"fork";
1014 else if (
strcmp(
l->mode,
"tcp") == 0) mode =
"tcp";
1015 else if (
strcmp(
l->mode,
"connect") == 0) mode =
"connect";
1025 if (
l->name[0] ==
'\0')
1027 if (
strcmp(mode,
"fork")==0)
1080#ifdef HAVE_SIMPLEIPC
1141 else if (
strcmp(mode,
"tcp")==0)
1148 WerrorS(
"ERROR opening socket");
1164 WerrorS(
"ERROR on binding (no free port available?)");
1183 PrintS(
"client accepted\n");
1194 Werror(
"invalid mode >>%s<< for ssi",mode);
1205 if(
strcmp(mode,
"tcp")==0)
1212 WerrorS(
"ERROR opening socket");
1228 WerrorS(
"ERROR on binding (no free port available?)");
1242 WerrorS(
"ERROR: no host specified");
1252 WarnS(
"program not specified, using /usr/local/bin/Singular");
1307 else if(
strcmp(mode,
"connect")==0)
1321 WerrorS(
"ERROR opening socket");
1328 WerrorS(
"ERROR, no such host");
1366 char *filename=
l->name;
1368 if(filename[0]==
'>')
1370 if (filename[1]==
'>')
1454 && (kill(d->
pid,0)==0))
1458 t.tv_nsec=100000000;
1471 if (kill(d->
pid,0) == 0)
1486 if (kill(d->
pid,0) == 0)
1495 if ((
strcmp(
l->mode,
"tcp")==0)
1496 || (
strcmp(
l->mode,
"fork")==0))
1506 else while(
hh->next!=
NULL)
1560 res->data=(
char*)d->
r;
1664 Print(
"incompatible versions of ssi: %d/%d vs %d/%d\n",
1684 default:
Werror(
"not implemented (t:%d)",t);
1693 && (
res->RingDependend()))
1741 else if (data->
flag!=0)
1859 b->blackbox_serialize(
b,
dd,
l);
1863 Werror(
"not implemented (t:%d, rtyp:%d)",
tt, data->
rtyp);
1899 if (d==
NULL)
return "not open";
1900 if (((
strcmp(
l->mode,
"fork")==0)
1902 ||(
strcmp(
l->mode,
"connect")==0))
1906#if defined(HAVE_POLL)
1917 case 0:
return "not ready";
1918 case -1:
return "error";
1942 case 0:
return "not ready";
1943 case -1:
return "error";
1951 if (c== -1)
return "eof";
1956 Werror(
"unknown char in ssiLink(%d)",c);
1965 else return "not ready";
1970 else return "not ready";
1972 else return "unknown status request";
1988#if defined(HAVE_POLL) && !defined(__APPLE__)
1995 for(
int i=L->
nr;
i>=0;
i--)
2001 {
WerrorS(
"all elements must be of type link");
return -2;}
2004 {
WerrorS(
"all links must be open");
return -2;}
2005 if (((
strcmp(
l->m->type,
"ssi")!=0) && (
strcmp(
l->m->type,
"MPtcp")!=0))
2007 && (
strcmp(
l->mode,
"launch")!=0) && (
strcmp(
l->mode,
"connect")!=0)))
2009 WerrorS(
"all links must be of type ssi:fork, ssi:tcp, ssi:connect");
2012 if (
strcmp(
l->m->type,
"ssi")==0)
2028 Werror(
"wrong link type >>%s<<",
l->m->type);
2047 for(
int i=L->
nr;
i>=0;
i--)
2099 for(
i=L->
nr;
i>=0;
i--)
2104 {
WerrorS(
"all elements must be of type link");
return -2;}
2107 {
WerrorS(
"all links must be open");
return -2;}
2108 if (((
strcmp(
l->m->type,
"ssi")!=0) && (
strcmp(
l->m->type,
"MPtcp")!=0))
2110 && (
strcmp(
l->mode,
"launch")!=0) && (
strcmp(
l->mode,
"connect")!=0)))
2112 WerrorS(
"all links must be of type ssi:fork, ssi:tcp, ssi:connect");
2115 if (
strcmp(
l->m->type,
"ssi")==0)
2132 Werror(
"wrong link type >>%s<<",
l->m->type);
2159 for(
i=L->
nr;
i>=0;
i--)
2164 if (
strcmp(
l->m->type,
"ssi")==0)
2216 WerrorS(
"ERROR already a reserved port requested");
2223 WerrorS(
"ERROR opening socket");
2236 WerrorS(
"ERROR on binding (no free port available?)");
2252 WerrorS(
"ERROR no reserved port requested");
2266 while (
strcmp(
s->type,
"ssi") != 0)
2268 if (
s->next ==
NULL)
2334 else if (
kidpid==0)
break;
2404 package p=(package)IDDATA(h);
2411 D->arg1.data=
p->libname;
2413 D->arg2.data=(
char*)
"with";
2424 D->arg1.data=
p->libname;
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
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
static void ssiWriteString(const ssiInfo *d, const char *s)
STATIC_VAR int ssiReserved_Clients
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)
static void ssiWriteInt(const ssiInfo *d, const int i)
EXTERN_VAR si_link_extension si_link_root
static bigintmat * ssiReadBigintvec(const 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)
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 int ssiReadInt(s_buff fich)
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 ssiWriteIdeal(const ssiInfo *d, int typ, const ideal I)
static ideal ssiReadIdeal(ssiInfo *d)
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)
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