8#define TRANSEXT_PRIVATES 1
52#include <netinet/in.h>
193 else if (
cf->cfWriteFd!=
NULL)
197 else WerrorS(
"coeff field not implemented");
253 if (r->order!=
NULL)
while (r->order[
i]!=0)
i++;
257 if (r->order!=
NULL)
while(r->order[
i]!=0)
269 int s=r->block1[
i]-r->block0[
i]+1;
276 int s=r->block1[
i]-r->block0[
i]+1;
287 Werror(
"ring oder not implemented for ssi:%d",r->order[
i]);
433 if (
p->data.s.body==
NULL)
435 if (
p->data.s.body!=
NULL)
456 for(
i=0;
i<
v->length();
i++)
465 for(
i=0;
i<
v->length();
i++)
475 for(
i=0;
i<
v->length();
i++)
485 for(
i=0;
i<
v->length();
i++)
529 else WerrorS(
"coeffs not implemented in ssiReadNumber");
538 if (n->s!=3)
Werror(
"invalid sub type in bigint:%d",n->s);
584 names=(
char**)
omAlloc(
N*
sizeof(
char*));
611 int s=block1[
i]-block0[
i]+1;
619 int s=block1[
i]-block0[
i]+1;
630 Werror(
"ring order not implemented for ssi:%d",ord[
i]);
671 Werror(
"ssi: read unknown coeffs type (%d)",ch);
797 D->argc=argc;
D->op=op;
855 for(
i=0;
i<=L->
nr;
i++)
868 for(
int i=0;
i<nr;
i++)
880 for(
int i=0;
i<r*c;
i++)
892 for(
int i=0;
i<r*c;
i++)
924 b->blackbox_deserialize(&
b,&(
res->data),
l);
968 unsigned long bm=~0L;
980 unsigned long bm=~0L;
985 d->
r->isLPring=isLPring;
1008 if (
l->mode[0] !=
'\0' && (
strcmp(
l->mode,
"r") == 0))
1014 else if (
strcmp(
l->mode,
"w") == 0) mode =
"w";
1015 else if (
strcmp(
l->mode,
"fork") == 0) mode =
"fork";
1016 else if (
strcmp(
l->mode,
"tcp") == 0) mode =
"tcp";
1017 else if (
strcmp(
l->mode,
"connect") == 0) mode =
"connect";
1027 if (
l->name[0] ==
'\0')
1029 if (
strcmp(mode,
"fork")==0)
1083#ifdef HAVE_SIMPLEIPC
1144 else if (
strcmp(mode,
"tcp")==0)
1151 WerrorS(
"ERROR opening socket");
1167 WerrorS(
"ERROR on binding (no free port available?)");
1186 PrintS(
"client accepted\n");
1197 Werror(
"invalid mode >>%s<< for ssi",mode);
1208 if(
strcmp(mode,
"tcp")==0)
1215 WerrorS(
"ERROR opening socket");
1231 WerrorS(
"ERROR on binding (no free port available?)");
1245 WerrorS(
"ERROR: no host specified");
1255 WarnS(
"program not specified, using /usr/local/bin/Singular");
1310 else if(
strcmp(mode,
"connect")==0)
1324 WerrorS(
"ERROR opening socket");
1331 WerrorS(
"ERROR, no such host");
1369 char *filename=
l->name;
1371 if(filename[0]==
'>')
1373 if (filename[1]==
'>')
1457 if (((
strcmp(
l->mode,
"tcp")==0)
1458 || (
strcmp(
l->mode,
"fork")==0))
1464 && (kill(d->
pid,0)==0))
1469 for(
int i=0;
i<50;
i++)
1473 t.tv_nsec=100000000;
1478 if (kill(d->
pid,0)==0)
1488 if ((
strcmp(
l->mode,
"tcp")==0)
1489 || (
strcmp(
l->mode,
"fork")==0))
1499 else while(
hh->next!=
NULL)
1553 res->data=(
char*)d->
r;
1657 Print(
"incompatible versions of ssi: %d/%d vs %d/%d\n",
1677 default:
Werror(
"not implemented (t:%d)",t);
1686 && (
res->RingDependend()))
1734 else if (data->
flag!=0)
1852 b->blackbox_serialize(
b,
dd,
l);
1856 Werror(
"not implemented (t:%d, rtyp:%d)",
tt, data->
rtyp);
1892 if (d==
NULL)
return "not open";
1893 if (((
strcmp(
l->mode,
"fork")==0)
1895 ||(
strcmp(
l->mode,
"connect")==0))
1899#if defined(HAVE_POLL)
1910 case 0:
return "not ready";
1911 case -1:
return "error";
1935 case 0:
return "not ready";
1936 case -1:
return "error";
1944 if (c== -1)
return "eof";
1949 Werror(
"unknown char in ssiLink(%d)",c);
1958 else return "not ready";
1963 else return "not ready";
1965 else return "unknown status request";
1981#if defined(HAVE_POLL) && !defined(__APPLE__)
1989 for(
int i=L->
nr;
i>=0;
i--)
1995 {
WerrorS(
"all elements must be of type link");
return -2;}
1998 {
WerrorS(
"all links must be open");
return -2;}
1999 if (((
strcmp(
l->m->type,
"ssi")!=0) && (
strcmp(
l->m->type,
"MPtcp")!=0))
2001 && (
strcmp(
l->mode,
"launch")!=0) && (
strcmp(
l->mode,
"connect")!=0)))
2003 WerrorS(
"all links must be of type ssi:fork, ssi:tcp, ssi:connect");
2006 if (
strcmp(
l->m->type,
"ssi")==0)
2022 Werror(
"wrong link type >>%s<<",
l->m->type);
2041 for(
int i=L->
nr;
i>=0;
i--)
2094 for(
i=L->
nr;
i>=0;
i--)
2099 {
WerrorS(
"all elements must be of type link");
return -2;}
2102 {
WerrorS(
"all links must be open");
return -2;}
2103 if (((
strcmp(
l->m->type,
"ssi")!=0) && (
strcmp(
l->m->type,
"MPtcp")!=0))
2105 && (
strcmp(
l->mode,
"launch")!=0) && (
strcmp(
l->mode,
"connect")!=0)))
2107 WerrorS(
"all links must be of type ssi:fork, ssi:tcp, ssi:connect");
2110 if (
strcmp(
l->m->type,
"ssi")==0)
2127 Werror(
"wrong link type >>%s<<",
l->m->type);
2154 for(
i=L->
nr;
i>=0;
i--)
2159 if (
strcmp(
l->m->type,
"ssi")==0)
2211 WerrorS(
"ERROR already a reserved port requested");
2218 WerrorS(
"ERROR opening socket");
2231 WerrorS(
"ERROR on binding (no free port available?)");
2247 WerrorS(
"ERROR no reserved port requested");
2261 while (
strcmp(
s->type,
"ssi") != 0)
2263 if (
s->next ==
NULL)
2330 else if (
kidpid==0)
break;
2401 package p=(package)IDDATA(h);
2408 D->arg1.data=
p->libname;
2410 D->arg2.data=(
char*)
"with";
2421 D->arg1.data=
p->libname;
2502 && (
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
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)
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