40 if (
l->mode[0] !=
'\0' && (strcmp(
l->mode,
"r") == 0))
46 else if (strcmp(
l->mode,
"w") == 0) mode =
"w";
50 if (
l->name[0] ==
'\0')
55 l->data = (
void *) stdin;
60 l->data = (
void *) stdout;
68 char *filename=
l->name;
85 l->data = (
void *) outfile;
99 if (
l->name[0] !=
'\0')
101 return (fclose((FILE *)
l->data)!=0);
108 FILE *
fp=(FILE *)
l->data;
118 Print(
"//Reading %ld chars\n",len);
131 WerrorS(
"read(<link>,<string>) expected");
144 memset(&tmp,0,
sizeof(
sleftv));
146 tmp.
data=(
void*)
"? ";
152 FILE *outfile=(FILE *)
l->data;
163 ideal I=(ideal)
v->Data();
167 fwrite(
s,strlen(
s),1,outfile);
169 if (
i<
IDELEMS(I)-1) fwrite(
",",1,1,outfile);
177 for(
int i=0;
i<
l->nr;
i++)
179 char *
s=
l->m[
i].String();
180 fwrite(
s,strlen(
s),1,outfile);
182 if (
i!=
l->nr-1) fputc(
',',outfile);
199 WerrorS(
"cannot convert to string");
211 if (strcmp(request,
"read") == 0)
214 else return "not ready";
216 else if (strcmp(request,
"write") == 0)
219 else return "not ready";
221 else return "unknown status request";
228 FILE *
fd = (FILE *)
l->data;
230 char **list_of_libs=
NULL;
237 char **
p=list_of_libs;
240 while((*
p!=
NULL) && (*
p!=(
char*)1))
242 fprintf(
fd,
"load(\"%s\",\"try\");\n",*
p);
247 fputs(
"RETURN();\n",
fd);
287 if (fprintf(
fd,
"setring %s;\n",
IDID(rhdl)) == EOF)
return TRUE;
289 IDMAP(
h)->preimage, rhs) == EOF)
326 if (type_str ==
NULL)
348 if (fprintf(
fd,
"%s %s", type_str,
IDID(
h)) == EOF)
354 if (fprintf(
fd,
"[%d][%d]", id->nrows, id->ncols)== EOF)
return TRUE;
364 if (fprintf(
fd,
"[%d][%d]", (
int)id->rank,
IDELEMS(
id))== EOF)
return TRUE;
369 return (fputs(
";\n",
fd) == EOF);
373 if (fputs(
" = ",
fd) == EOF)
return TRUE;
379 if (fputs(
";\n",
fd) == EOF)
return TRUE;
436 char *ring_str =
h->String();
441 if (fprintf(
fd,
"ring temp_ring = %s;\n", ring_str)
443 if (fprintf(
fd,
"ideal temp_C = %s;\n",
446 if (fprintf(
fd,
"ideal temp_D = %s;\n",
449 if (fprintf(
fd,
"def %s = nc_algebra(temp_C,temp_D);\n",
IDID(
h)) == EOF)
451 if (fputs(
"kill temp_ring;\n",
fd) == EOF)
return TRUE;
466 char *ring_str =
h->String();
468 if (fprintf(
fd,
"ring temp_ring = %s;\n", ring_str) == EOF)
return TRUE;
469 if (fprintf(
fd,
"ideal temp_ideal = %s;\n",
472 if (fputs(
"attrib(temp_ideal, \"isSB\", 1);\n",
fd) == EOF)
return TRUE;
473 if (fprintf(
fd,
"qring %s = temp_ideal;\n",
IDID(
h)) == EOF)
475 if (fputs(
"kill temp_ring;\n",
fd) == EOF)
return TRUE;
485 if (*list_of_libs==
NULL)
489 (*list_of_libs)[0]=
name;
490 (*list_of_libs)[
MAX_LIBS-1]=(
char*)1;
495 char **
p=*list_of_libs;
496 while (((*
p)!=
NULL)&&((*
p!=(
char*)1)))
541 while (*
pstr !=
'\0')
543 if (*
pstr ==
'"' || *
pstr ==
'\\') fputc(
'\\',
fd);
555 char *
pstr =
pi->data.s.body;
557 while (*
pstr !=
'\0')
559 if (*
pstr ==
'"' || *
pstr ==
'\\') fputc(
'\\',
fd);
565 else fputs(
"(null)",
fd);
569 char *rhs =
h->String();
571 if (rhs ==
NULL)
return EOF;
575 else if (type_id ==
IDEAL_CMD) { fputs(
"ideal(",
fd);need_klammer=
TRUE; }
577 { fputs(
"module(",
fd);need_klammer=
TRUE; }
580 if (fputs(rhs,
fd) == EOF)
return EOF;
589 if (fprintf(
fd,
"; minpoly = %s", rhs) == EOF) {
omFree(rhs);
return EOF;}
592 else if (need_klammer) fputc(
')',
fd);
599 if (
l->name[0] ==
'\0')
601 WerrorS(
"getdump: Can not get dump from stdin");
623 FILE *
f = (FILE *)
l->data;
static BOOLEAN slGetDumpAscii(si_link l)
static BOOLEAN DumpAscii(FILE *fd, idhdl h, char ***list_of_libs)
static const char * GetIdString(idhdl h)
static BOOLEAN CollectLibs(char *name, char ***list_of_libs)
static BOOLEAN DumpNCring(FILE *fd, idhdl h)
static leftv slReadAscii2(si_link l, leftv pr)
static BOOLEAN slCloseAscii(si_link l)
EXTERN_VAR si_link_extension si_link_root
static int DumpRhs(FILE *fd, idhdl h)
static BOOLEAN slDumpAscii(si_link l)
const char * slStatusAscii(si_link l, const char *request)
static BOOLEAN DumpAsciiMaps(FILE *fd, idhdl h, idhdl rhdl)
static BOOLEAN slWriteAscii(si_link l, leftv v)
static BOOLEAN DumpAsciiIdhdl(FILE *fd, idhdl h, char ***list_of_libs)
static leftv slReadAscii(si_link l)
static BOOLEAN slOpenAscii(si_link l, short flag, leftv)
static BOOLEAN DumpQring(FILE *fd, idhdl h)
Class used for (list of) interpreter objects.
@ n_algExt
used for all algebraic extensions, i.e., the top-most extension in an extension tower is algebraic
static FORCE_INLINE int n_GetChar(const coeffs r)
Return the characteristic of the coeff. domain.
const CanonicalForm int s
const Variable & v
< [in] a sqrfree bivariate poly
void WerrorS(const char *s)
FILE * myfopen(const char *path, const char *mode)
size_t myfread(void *ptr, size_t size, size_t nmemb, FILE *stream)
if(!FE_OPT_NO_SHELL_FLAG)(void) system(sys)
char *(* fe_fgets_stdin)(const char *pr, char *s, int size)
BOOLEAN newFile(char *fname)
const char * Tok2Cmdname(int tok)
EXTERN_VAR omBin sleftv_bin
char * iiStringMatrix(matrix im, int dim, const ring r, char ch)
void p_Write(poly p, ring lmRing, ring tailRing)
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
void StringSetS(const char *st)
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
static BOOLEAN rIsLPRing(const ring r)
static BOOLEAN rIsNCRing(const ring r)
int status int void * buf
VAR omBin s_si_link_extension_bin
#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_OPEN_P(l, flag)
int name
New type name for int.