42 if (
l->mode[0] !=
'\0' && (strcmp(
l->mode,
"r") == 0))
48 else if (strcmp(
l->mode,
"w") == 0) mode =
"w";
52 if (
l->name[0] ==
'\0')
57 l->data = (
void *) stdin;
62 l->data = (
void *) stdout;
70 char *filename=
l->name;
87 l->data = (
void *) outfile;
101 if (
l->name[0] !=
'\0')
103 return (fclose((FILE *)
l->data)!=0);
110 FILE *
fp=(FILE *)
l->data;
112 if (
fp!=
NULL &&
l->name[0] !=
'\0')
120 Print(
"//Reading %ld chars\n",len);
133 WerrorS(
"read(<link>,<string>) expected");
146 memset(&tmp,0,
sizeof(
sleftv));
148 tmp.
data=(
void*)
"? ";
154 FILE *outfile=(FILE *)
l->data;
165 ideal I=(ideal)
v->Data();
169 fwrite(
s,strlen(
s),1,outfile);
171 if (
i<
IDELEMS(I)-1) fwrite(
",",1,1,outfile);
179 for(
int i=0;
i<
l->nr;
i++)
181 char *
s=
l->m[
i].String();
182 fwrite(
s,strlen(
s),1,outfile);
184 if (
i!=
l->nr-1) fputc(
',',outfile);
201 WerrorS(
"cannot convert to string");
213 if (strcmp(request,
"read") == 0)
216 else return "not ready";
218 else if (strcmp(request,
"write") == 0)
221 else return "not ready";
223 else return "unknown status request";
230 FILE *
fd = (FILE *)
l->data;
232 char **list_of_libs=
NULL;
239 char **
p=list_of_libs;
242 while((*
p!=
NULL) && (*
p!=(
char*)1))
244 fprintf(
fd,
"load(\"%s\",\"try\");\n",*
p);
249 fputs(
"RETURN();\n",
fd);
289 if (fprintf(
fd,
"setring %s;\n",
IDID(rhdl)) == EOF)
return TRUE;
291 IDMAP(
h)->preimage, rhs) == EOF)
328 if (type_str ==
NULL)
350 if (fprintf(
fd,
"%s %s", type_str,
IDID(
h)) == EOF)
356 if (fprintf(
fd,
"[%d][%d]", id->nrows, id->ncols)== EOF)
return TRUE;
366 if (fprintf(
fd,
"[%d][%d]", (
int)id->rank,
IDELEMS(
id))== EOF)
return TRUE;
371 return (fputs(
";\n",
fd) == EOF);
375 if (fputs(
" = ",
fd) == EOF)
return TRUE;
381 if (fputs(
";\n",
fd) == EOF)
return TRUE;
438 char *ring_str =
h->String();
443 if (fprintf(
fd,
"ring temp_ring = %s;\n", ring_str)
445 if (fprintf(
fd,
"ideal temp_C = %s;\n",
448 if (fprintf(
fd,
"ideal temp_D = %s;\n",
451 if (fprintf(
fd,
"def %s = nc_algebra(temp_C,temp_D);\n",
IDID(
h)) == EOF)
453 if (fputs(
"kill temp_ring;\n",
fd) == EOF)
return TRUE;
468 char *ring_str =
h->String();
470 if (fprintf(
fd,
"ring temp_ring = %s;\n", ring_str) == EOF)
return TRUE;
471 if (fprintf(
fd,
"ideal temp_ideal = %s;\n",
474 if (fputs(
"attrib(temp_ideal, \"isSB\", 1);\n",
fd) == EOF)
return TRUE;
475 if (fprintf(
fd,
"qring %s = temp_ideal;\n",
IDID(
h)) == EOF)
477 if (fputs(
"kill temp_ring;\n",
fd) == EOF)
return TRUE;
487 if (*list_of_libs==
NULL)
491 (*list_of_libs)[0]=
name;
492 (*list_of_libs)[
MAX_LIBS-1]=(
char*)1;
497 char **
p=*list_of_libs;
498 while (((*
p)!=
NULL)&&((*
p!=(
char*)1)))
543 while (*
pstr !=
'\0')
545 if (*
pstr ==
'"' || *
pstr ==
'\\') fputc(
'\\',
fd);
557 char *
pstr =
pi->data.s.body;
559 while (*
pstr !=
'\0')
561 if (*
pstr ==
'"' || *
pstr ==
'\\') fputc(
'\\',
fd);
567 else fputs(
"(null)",
fd);
571 char *rhs =
h->String();
573 if (rhs ==
NULL)
return EOF;
577 else if (type_id ==
IDEAL_CMD) { fputs(
"ideal(",
fd);need_klammer=
TRUE; }
579 { fputs(
"module(",
fd);need_klammer=
TRUE; }
582 if (fputs(rhs,
fd) == EOF)
return EOF;
591 if (fprintf(
fd,
"; minpoly = %s", rhs) == EOF) {
omFree(rhs);
return EOF;}
594 else if (need_klammer) fputc(
')',
fd);
601 if (
l->name[0] ==
'\0')
603 WerrorS(
"getdump: Can not get dump from stdin");
625 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)
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.