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;
110 if (fp!=
NULL && l->name[0] !=
'\0')
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);
184 WerrorS(
"cannot convert to string");
196 if (strcmp(request,
"read") == 0)
199 else return "not ready";
201 else if (strcmp(request,
"write") == 0)
204 else return "not ready";
206 else return "unknown status request";
213 FILE *
fd = (FILE *) l->data;
215 char **list_of_libs=
NULL;
222 char **
p=list_of_libs;
225 while((*p!=
NULL) && (*p!=(
char*)1))
227 fprintf(fd,
"load(\"%s\",\"try\");\n",*p);
232 fputs(
"RETURN();\n",fd);
272 if (fprintf(fd,
"setring %s;\n",
IDID(rhdl)) == EOF)
return TRUE;
274 IDMAP(h)->preimage, rhs) == EOF)
291 int type_id =
IDTYP(h);
295 if (strcmp(
IDID(h),
"Top")==0)
return FALSE;
302 if (strcmp(
IDID(h),
"QQ")==0)
return FALSE;
303 if (strcmp(
IDID(h),
"ZZ")==0)
return FALSE;
305 if (strcmp(
IDID(h),
"AE")==0)
return FALSE;
306 if (strcmp(
IDID(h),
"QAE")==0)
return FALSE;
311 if (type_str ==
NULL)
333 if (fprintf(fd,
"%s %s", type_str,
IDID(h)) == EOF)
339 if (fprintf(fd,
"[%d][%d]", id->nrows, id->ncols)== EOF)
return TRUE;
349 if (fprintf(fd,
"[%d][%d]", (
int)id->rank,
IDELEMS(
id))== EOF)
return TRUE;
354 return (fputs(
";\n",fd) == EOF);
358 if (fputs(
" = ",fd) == EOF)
return TRUE;
364 if (fputs(
";\n",fd) == EOF)
return TRUE;
421 char *ring_str = h->
String();
426 if (fprintf(fd,
"ring temp_ring = %s;\n", ring_str)
428 if (fprintf(fd,
"ideal temp_C = %s;\n",
431 if (fprintf(fd,
"ideal temp_D = %s;\n",
434 if (fprintf(fd,
"def %s = nc_algebra(temp_C,temp_D);\n",
IDID(h)) == EOF)
436 if (fputs(
"kill temp_ring;\n",fd) == EOF)
return TRUE;
442 Warn(
"cannot write LP ring %s",
IDID(h));
451 char *ring_str = h->
String();
453 if (fprintf(fd,
"ring temp_ring = %s;\n", ring_str) == EOF)
return TRUE;
454 if (fprintf(fd,
"ideal temp_ideal = %s;\n",
457 if (fputs(
"attrib(temp_ideal, \"isSB\", 1);\n",fd) == EOF)
return TRUE;
458 if (fprintf(fd,
"qring %s = temp_ideal;\n",
IDID(h)) == EOF)
460 if (fputs(
"kill temp_ring;\n",fd) == EOF)
return TRUE;
470 if (*list_of_libs==
NULL)
474 (*list_of_libs)[0]=
name;
475 (*list_of_libs)[
MAX_LIBS-1]=(
char*)1;
480 char **
p=*list_of_libs;
481 while (((*p)!=
NULL)&&((*p!=(
char*)1)))
502 int type_id =
IDTYP(h);
526 while (*pstr !=
'\0')
528 if (*pstr ==
'"' || *pstr ==
'\\') fputc(
'\\', fd);
542 while (*pstr !=
'\0')
544 if (*pstr ==
'"' || *pstr ==
'\\') fputc(
'\\', fd);
550 else fputs(
"(null)", fd);
556 if (rhs ==
NULL)
return EOF;
559 if (type_id ==
INTVEC_CMD) { fputs(
"intvec(",fd);need_klammer=
TRUE; }
560 else if (type_id ==
IDEAL_CMD) { fputs(
"ideal(",fd);need_klammer=
TRUE; }
562 { fputs(
"module(",fd);need_klammer=
TRUE; }
563 else if (type_id ==
BIGINT_CMD) { fputs(
"bigint(",fd);need_klammer=
TRUE; }
565 if (fputs(rhs,fd) == EOF)
return EOF;
574 if (fprintf(fd,
"; minpoly = %s", rhs) == EOF) {
omFree(rhs);
return EOF;}
577 else if (need_klammer) fputc(
')',fd);
584 if (l->name[0] ==
'\0')
586 WerrorS(
"getdump: Can not get dump from stdin");
608 FILE *
f = (FILE *) l->data;
const CanonicalForm int s
char *(* fe_fgets_stdin)(const char *pr, char *s, int size)
static BOOLEAN DumpAsciiIdhdl(FILE *fd, idhdl h, char ***list_of_libs)
Class used for (list of) interpreter objects.
leftv slReadAscii(si_link l)
static BOOLEAN DumpAsciiMaps(FILE *fd, idhdl h, idhdl rhdl)
BOOLEAN slOpenAscii(si_link l, short flag, leftv)
EXTERN_VAR omBin sleftv_bin
VAR omBin s_si_link_extension_bin
static BOOLEAN DumpNCring(FILE *fd, idhdl h)
static const char * GetIdString(idhdl h)
static BOOLEAN DumpQring(FILE *fd, idhdl h)
EXTERN_VAR si_link_extension si_link_root
#define SI_LINK_R_OPEN_P(l)
BOOLEAN newFile(char *fname)
static FORCE_INLINE int n_GetChar(const coeffs r)
Return the characteristic of the coeff. domain.
void WerrorS(const char *s)
static BOOLEAN rIsLPRing(const ring r)
char * String(BOOLEAN typed=FALSE)
#define SI_LINK_SET_CLOSE_P(l)
BOOLEAN slGetDumpAscii(si_link l)
char * String(void *d=NULL, BOOLEAN typed=FALSE, int dim=1)
Called for conversion to string (used by string(..), write(..),..)
#define SI_LINK_SET_OPEN_P(l, flag)
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
static int DumpRhs(FILE *fd, idhdl h)
leftv slReadAscii2(si_link l, leftv pr)
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
size_t myfread(void *ptr, size_t size, size_t nmemb, FILE *stream)
FILE * myfopen(const char *path, const char *mode)
void StringSetS(const char *st)
const char * slStatusAscii(si_link l, const char *request)
int status int void * buf
static BOOLEAN DumpAscii(FILE *fd, idhdl h, char ***list_of_libs)
char name(const Variable &v)
const Variable & v
< [in] a sqrfree bivariate poly
const char * Tok2Cmdname(int tok)
used for all algebraic extensions, i.e., the top-most extension in an extension tower is algebraic ...
#define SI_LINK_W_OPEN_P(l)
BOOLEAN slCloseAscii(si_link l)
BOOLEAN slWriteAscii(si_link l, leftv v)
static BOOLEAN CollectLibs(char *name, char ***list_of_libs)
void p_Write(poly p, ring lmRing, ring tailRing)
static BOOLEAN rIsNCRing(const ring r)
char * iiStringMatrix(matrix im, int dim, const ring r, char ch)
BOOLEAN slDumpAscii(si_link l)