8#define TRANSEXT_PRIVATES 1
52#include <netinet/in.h>
204 else if (
cf->cfWriteFd!=
NULL)
208 else WerrorS(
"coeff field not implemented");
232 else if (
cf->cfWriteFd_S!=
NULL)
236 else WerrorS(
"coeff field not implemented");
292 if (r->order!=
NULL)
while (r->order[
i]!=0)
i++;
296 if (r->order!=
NULL)
while(r->order[
i]!=0)
308 int s=r->block1[
i]-r->block0[
i]+1;
315 int s=r->block1[
i]-r->block0[
i]+1;
326 Werror(
"ring oder not implemented for ssi:%d",r->order[
i]);
463 for(
int i=0;
i<
mn;
i++)
486 for(
int i=0;
i<
mn;
i++)
529 if (
p->data.s.body==
NULL)
531 if (
p->data.s.body!=
NULL)
538 if (
p->data.s.body==
NULL)
540 if (
p->data.s.body!=
NULL)
571 for(
i=0;
i<
v->length();
i++)
580 for(
i=0;
i<
v->length();
i++)
589 for(
i=0;
i<
v->length();
i++)
598 for(
i=0;
i<
v->length();
i++)
608 for(
i=0;
i<
v->length();
i++)
617 for(
i=0;
i<
v->length();
i++)
627 for(
i=0;
i<
v->length();
i++)
636 for(
i=0;
i<
v->length();
i++)
661 for(
int i=0;
i<
l;
i++) {
buf[
i]=(**s); (*s)++; }
695 else WerrorS(
"coeffs not implemented in ssiReadNumber");
719 else WerrorS(
"coeffs not implemented in ssiReadNumber");
728 if (n->s!=3)
Werror(
"invalid sub type in bigint:%d",n->s);
737 if (n->s!=3)
Werror(
"invalid sub type in bigint:%d",n->s);
783 names=(
char**)
omAlloc(
N*
sizeof(
char*));
810 int s=block1[
i]-block0[
i]+1;
818 int s=block1[
i]-block0[
i]+1;
829 Werror(
"ring order not implemented for ssi:%d",ord[
i]);
870 Werror(
"ssi: read unknown coeffs type (%d)",ch);
1070 D->argc=argc;
D->op=op;
1138 for(
i=0;
i<=L->
nr;
i++)
1155 for(
i=0;
i<=L->
nr;
i++)
1168 for(
int i=0;
i<nr;
i++)
1179 for(
int i=0;
i<nr;
i++)
1191 for(
int i=0;
i<r*c;
i++)
1203 for(
int i=0;
i<r*c;
i++)
1215 for(
int i=0;
i<r*c;
i++)
1227 for(
int i=0;
i<r*c;
i++)
1238 for(
int i=0;
i<c;
i++)
1249 for(
int i=0;
i<c;
i++)
1269 b->blackbox_deserialize(&
b,&(
res->data),
l);
1313 unsigned long bm=~0L;
1325 unsigned long bm=~0L;
1330 d->
r->isLPring=isLPring;
1352 if (
strcmp(
l->mode,
"r") == 0)
1354 else if (
strcmp(
l->mode,
"string")==0)
1363 && (
strcmp(
l->mode,
"string")==0))
1370 else if (
strcmp(
l->mode,
"w") == 0) mode =
"w";
1371 else if (
strcmp(
l->mode,
"fork") == 0) mode =
"fork";
1372 else if (
strcmp(
l->mode,
"tcp") == 0) mode =
"tcp";
1373 else if (
strcmp(
l->mode,
"connect") == 0) mode =
"connect";
1384 if (
l->name[0] ==
'\0')
1386 if (
strcmp(mode,
"fork")==0)
1391 WerrorS(
"no sub-processes allowed");
1456#ifdef HAVE_SIMPLEIPC
1517 else if (
strcmp(mode,
"tcp")==0)
1524 WerrorS(
"ERROR opening socket");
1540 WerrorS(
"ERROR on binding (no free port available?)");
1559 PrintS(
"client accepted\n");
1568 else if (
strcmp(mode,
"string")==0)
1574 Werror(
"invalid mode >>%s<< for ssi",mode);
1585 if(
strcmp(mode,
"tcp")==0)
1592 WerrorS(
"ERROR opening socket");
1608 WerrorS(
"ERROR on binding (no free port available?)");
1623 WerrorS(
"ERROR: no host specified");
1633 WarnS(
"program not specified, using /usr/local/bin/Singular");
1688 else if(
strcmp(mode,
"connect")==0)
1702 WerrorS(
"ERROR opening socket");
1711 WerrorS(
"ERROR, no such host");
1753 char *filename=
l->name;
1755 if(filename[0]==
'>')
1757 if (filename[1]==
'>')
1806 if (d->send_quit_at_exit)
1808 fputs(
"99\n",d->f_write);
1843 if (((
strcmp(
l->mode,
"tcp")==0)
1844 || (
strcmp(
l->mode,
"fork")==0))
1850 && (kill(d->
pid,0)==0))
1855 for(
int i=0;
i<50;
i++)
1859 t.tv_nsec=100000000;
1864 if (kill(d->
pid,0)==0)
1874 if ((
strcmp(
l->mode,
"tcp")==0)
1875 || (
strcmp(
l->mode,
"fork")==0))
1885 else while(
hh->next!=
NULL)
1939 res->data=(
char*)d->
r;
2043 Print(
"incompatible versions of ssi: %d/%d vs %d/%d\n",
2063 default:
Werror(
"not implemented (t:%d)",t);
2072 && (
res->RingDependend()))
2107 res->data=(
char*)d->r;
2210 default:
Werror(
"not implemented (t:%d)",t);
2215 while((**
s!=
'\0') &&(**
s<=
' ')) (*s)++;
2259 else if (data->
flag!=0)
2377 b->blackbox_serialize(
b,
dd,
l);
2381 Werror(
"not implemented (t:%d, rtyp:%d)",
tt, data->
rtyp);
2457 fputs(
"11 ",d->f_write);
2494 fputs(
"20 ",d->f_write);
2495 b->blackbox_serialize(
b,
dd,
l);
2500 Werror(
"not implemented (t:%d, rtyp:%d)",
tt, data->
rtyp);
2531 if (
strcmp(
l->mode,
"string")==0)
2548 if (((
strcmp(
l->mode,
"fork")==0)
2550 ||(
strcmp(
l->mode,
"connect")==0))
2554#if defined(HAVE_POLL)
2565 case 0:
return "not ready";
2566 case -1:
return "error";
2590 case 0:
return "not ready";
2591 case -1:
return "error";
2599 if (c== -1)
return "eof";
2604 Werror(
"unknown char in ssiLink(%d)",c);
2613 else return "not ready";
2618 else return "not ready";
2620 else return "unknown status request";
2636#if defined(HAVE_POLL) && !defined(__APPLE__)
2644 for(
int i=L->
nr;
i>=0;
i--)
2650 {
WerrorS(
"all elements must be of type link");
return -2;}
2653 {
WerrorS(
"all links must be open");
return -2;}
2654 if (((
strcmp(
l->m->type,
"ssi")!=0) && (
strcmp(
l->m->type,
"MPtcp")!=0))
2656 && (
strcmp(
l->mode,
"launch")!=0) && (
strcmp(
l->mode,
"connect")!=0)))
2658 WerrorS(
"all links must be of type ssi:fork, ssi:tcp, ssi:connect");
2661 if (
strcmp(
l->m->type,
"ssi")==0)
2677 Werror(
"wrong link type >>%s<<",
l->m->type);
2696 for(
int i=L->
nr;
i>=0;
i--)
2749 for(
i=L->
nr;
i>=0;
i--)
2754 {
WerrorS(
"all elements must be of type link");
return -2;}
2757 {
WerrorS(
"all links must be open");
return -2;}
2758 if (((
strcmp(
l->m->type,
"ssi")!=0) && (
strcmp(
l->m->type,
"MPtcp")!=0))
2760 && (
strcmp(
l->mode,
"launch")!=0) && (
strcmp(
l->mode,
"connect")!=0)))
2762 WerrorS(
"all links must be of type ssi:fork, ssi:tcp, ssi:connect");
2765 if (
strcmp(
l->m->type,
"ssi")==0)
2782 Werror(
"wrong link type >>%s<<",
l->m->type);
2809 for(
i=L->
nr;
i>=0;
i--)
2814 if (
strcmp(
l->m->type,
"ssi")==0)
2866 WerrorS(
"ERROR already a reserved port requested");
2873 WerrorS(
"ERROR opening socket");
2886 WerrorS(
"ERROR on binding (no free port available?)");
2902 WerrorS(
"ERROR no reserved port requested");
2916 while (
strcmp(
s->type,
"ssi") != 0)
2918 if (
s->next ==
NULL)
2985 else if (
kidpid==0)
break;
3056 package p=(package)IDDATA(h);
3063 D->arg1.data=
p->libname;
3065 D->arg2.data=(
char*)
"with";
3076 D->arg1.data=
p->libname;
3118 if (
strcmp(
l->mode,
"string")==0)
3120 WerrorS(
"no dump for ssi:string");
3135 if (
strcmp(
l->mode,
"string")==0)
3137 WerrorS(
"no dump for ssi:string");
3167 && (
strcmp(
hh->l->mode,
"fork")==0))
3181 if((
strcmp(
l->mode,
"string")==0)
3194 if((
strcmp(
l->mode,
"string")==0)
3197 char *
s=(
char*)u->
Data();
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_S(char **s, const coeffs r)
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
static FORCE_INLINE void n_WriteFd_S(number a, const coeffs 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)
static void * feOptValue(feOptIndex opt)
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)
number ndReadFd_S(char **, 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 StringSetS(const char *st)
void StringAppendS(const char *st)
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_readint_S(char **s)
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)
#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 void ssiWriteBigInt_S(const number n)
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)
void ssiWrite_S(leftv data, const ring R)
STATIC_VAR int ssiReserved_sockfd
static matrix ssiReadMatrix_R_S(char **s, const ring R)
const char * slStatusSsi(si_link l, const char *request)
BOOLEAN ssiWrite2(si_link l, leftv res, leftv u)
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)
static void ssiWriteIntmat_S(intvec *v)
VAR link_list ssiToBeClosed
static bigintmat * ssiReadBigintvec_S(char **s)
int ssiReadInt(const ssiInfo *d)
static void ssiWriteString(const ssiInfo *d, const char *s)
static intvec * ssiReadIntmat_S(char **s)
STATIC_VAR int ssiReserved_Clients
char * ssiWritePoly_S(poly p, const ring r)
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 ssiWriteNumber_CF_S(const number n, const coeffs cf)
static void ssiWriteList(si_link l, lists dd)
static void ssiWriteIdeal_R_S(int typ, const ideal I, const ring R)
int slStatusSsiL(lists L, int timeout, BOOLEAN *ignore)
BOOLEAN ssiClose(si_link l)
void ssiWriteInt_S(const int i)
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)
char * ssiWriteModule_S(const ideal M, const ring R)
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 bigintmat * ssiReadBigintmat_S(char **s)
poly ssiReadPoly_S(char *s, const ring r)
static void ssiWriteProc(const ssiInfo *d, procinfov p)
static poly ssiReadPoly_R(const ssiInfo *D, const ring r)
leftv ssiRead1_S(char **s, const ring R)
static number ssiReadBigInt_S(char **s)
static ideal ssiReadIdeal_R(const ssiInfo *d, const ring r)
static number ssiReadBigInt(const ssiInfo *d)
static void ssiWriteString_S(const char *s)
static void ssiWritePoly_R(const ssiInfo *d, poly p, const ring r)
void ssiWriteIdeal(const ssiInfo *d, int typ, const ideal I)
static void ssiWriteIntvec_S(intvec *v)
static char * ssiReadString_S(char **s)
BOOLEAN ssiOpen(si_link l, short flag, leftv u)
BOOLEAN ssiWrite(si_link l, leftv data)
static procinfov ssiReadProc_S(char **s)
static command ssiReadCommand(si_link l)
BOOLEAN ssiGetDump(si_link l)
char * ssiWriteIdeal_S(const ideal I, const ring R)
static void ssiWriteNumber(const ssiInfo *d, const number n)
char * ssiWriteMatrix_S(const matrix M, const ring R)
static BOOLEAN DumpSsiIdhdl(si_link l, idhdl h)
static void ssiWriteCommand(si_link l, command D)
static intvec * ssiReadIntmat(const ssiInfo *d)
leftv ssiRead2(si_link l, leftv u)
static number ssiReadNumber_CF_S(char **s, const coeffs cf)
static BOOLEAN ssiSetRing(si_link l, ring r, BOOLEAN send)
static number ssiReadNumber(ssiInfo *d)
static intvec * ssiReadIntvec_S(char **s)
STATIC_VAR struct sockaddr_in ssiResverd_serv_addr
static void ssiReadRingProperties(si_link l)
int ssiBatch(const char *host, const char *port)
static lists ssiReadList_S(char **s, const ring R)
VAR volatile BOOLEAN ssiToBeClosed_inactive
static void ssiWriteBigintmat(const ssiInfo *d, bigintmat *v)
static void ssiWritePoly_R_S(poly p, const ring r)
static void ssiWriteBigintvec(const ssiInfo *d, bigintmat *v)
static BOOLEAN ssiSetCurrRing(const ring r)
int ssiReadInt_S(char **s)
static poly ssiReadPoly_R_S(char **s, const ring r)
static poly ssiReadPoly(ssiInfo *d)
ideal ssiReadIdeal_S(char *s, const ring R)
void ssiWriteInt(const ssiInfo *d, const int i)
static void ssiWriteBigintvec_S(bigintmat *v)
static void ssiWriteList_S(lists dd, const ring R)
static void ssiReadAttrib(leftv res, si_link l)
static void ssiWriteBigInt(const ssiInfo *d, const number n)
static void ssiWriteProc_S(procinfov p)
static void ssiWriteNumber_CF(const ssiInfo *d, const number n, const coeffs cf)
static void ssiWriteBigintmat_S(bigintmat *v)
static number ssiReadNumber_CF(const ssiInfo *d, const coeffs cf)
int ssiReservePort(int clients)
static ideal ssiReadIdeal_R_S(char **s, const ring r)
static procinfov ssiReadProc(const ssiInfo *d)
leftv ssiRead1(si_link l)
static void ssiWritePoly(const ssiInfo *d, poly p)
struct for passing initialization parameters to naInitChar