24 #include <sys/types.h> 46 if (l->mode[0] !=
'\0' && (strcmp(l->mode,
"r") == 0))
52 else if (strcmp(l->mode,
"w") == 0) mode =
"w";
56 if (l->name[0] ==
'\0')
61 l->data = (
void *) stdin;
66 l->data = (
void *) stdout;
74 char *filename=l->name;
91 l->data = (
void *) outfile;
105 if (l->name[0] !=
'\0')
107 return (fclose((FILE *)l->data)!=0);
114 FILE *
fp=(FILE *)l->data;
116 if (fp!=
NULL && l->name[0] !=
'\0')
123 Print(
"//Reading %ld chars\n",len);
136 WerrorS(
"read(<link>,<string>) expected");
149 memset(&tmp,0,
sizeof(
sleftv));
151 tmp.
data=(
void*)
"? ";
157 FILE *outfile=(FILE *)l->data;
168 ideal I=(ideal)v->
Data();
172 fwrite(s,strlen(s),1,outfile);
174 if (
i<
IDELEMS(I)-1) fwrite(
",",1,1,outfile);
183 fprintf(outfile,
"%s\n",
s);
188 WerrorS(
"cannot convert to string");
200 if (strcmp(request,
"read") == 0)
203 else return "not ready";
205 else if (strcmp(request,
"write") == 0)
208 else return "not ready";
210 else return "unknown status request";
217 FILE *
fd = (FILE *) l->data;
219 char **list_of_libs=
NULL;
226 char **
p=list_of_libs;
229 while((*p!=
NULL) && (*p!=(
char*)1))
231 fprintf(fd,
"load(\"%s\",\"try\");\n",*p);
236 fprintf(fd,
"RETURN();\n");
276 if (fprintf(fd,
"setring %s;\n",
IDID(rhdl)) == EOF)
return TRUE;
278 IDMAP(h)->preimage, rhs) == EOF)
295 int type_id =
IDTYP(h);
299 if (strcmp(
IDID(h),
"Top")==0)
return FALSE;
305 if (strcmp(
IDID(h),
"QQ")==0)
return FALSE;
306 if (strcmp(
IDID(h),
"ZZ")==0)
return FALSE;
307 if (strcmp(
IDID(h),
"AE")==0)
return FALSE;
308 if (strcmp(
IDID(h),
"QAE")==0)
return FALSE;
309 if (strcmp(
IDID(h),
"flint_poly_Q")==0)
return FALSE;
313 if (type_str ==
NULL)
331 if (fprintf(fd,
"%s %s", type_str,
IDID(h)) == EOF)
337 if (fprintf(fd,
"[%d][%d]", id->nrows, id->ncols)== EOF)
return TRUE;
347 return (fprintf(fd,
";\n") == EOF);
351 if (fprintf(fd,
" = ") == EOF)
return TRUE;
357 if (fprintf(fd,
";\n") == EOF)
return TRUE;
371 int i, nl = l->
nr + 1;
410 char *ring_str = h->
String();
416 if (fprintf(fd,
"attrib(temp_ideal, \"isSB\", 1);\n") == EOF)
return TRUE;
417 if (fprintf(fd,
"%s %s = temp_ideal;\n", type_str,
IDID(h)) == EOF)
419 if (fprintf(fd,
"kill temp_ring;\n") == EOF)
return TRUE;
429 if (*list_of_libs==
NULL)
433 (*list_of_libs)[0]=
name;
434 (*list_of_libs)[
MAX_LIBS-1]=(
char*)1;
439 char **
p=*list_of_libs;
440 while (((*p)!=
NULL)&&((*p!=(
char*)1)))
461 int type_id =
IDTYP(h);
468 fprintf(fd,
"list(");
485 while (*pstr !=
'\0')
487 if (*pstr ==
'"' || *pstr ==
'\\') fputc(
'\\', fd);
501 while (*pstr !=
'\0')
503 if (*pstr ==
'"' || *pstr ==
'\\') fputc(
'\\', fd);
509 else fputs(
"(null)", fd);
515 if (rhs ==
NULL)
return EOF;
518 if (type_id ==
INTVEC_CMD) { fprintf(fd,
"intvec(");need_klammer=
TRUE; }
519 else if (type_id ==
IDEAL_CMD) { fprintf(fd,
"ideal(");need_klammer=
TRUE; }
520 else if (type_id ==
MODUL_CMD) { fprintf(fd,
"module(");need_klammer=
TRUE; }
521 else if (type_id ==
BIGINT_CMD) { fprintf(fd,
"bigint(");need_klammer=
TRUE; }
523 if (fprintf(fd,
"%s", rhs) == EOF)
return EOF;
532 if (fprintf(fd,
"; minpoly = %s", rhs) == EOF) {
omFree(rhs);
return EOF;}
535 else if (need_klammer) fprintf(fd,
")");
542 if (l->name[0] ==
'\0')
544 WerrorS(
"getdump: Can not get dump from stdin");
566 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)
static const char * GetIdString(idhdl h)
#define SI_LINK_R_OPEN_P(l)
static FORCE_INLINE int n_GetChar(const coeffs r)
Return the characteristic of the coeff. domain.
void WerrorS(const char *s)
si_link_extension si_link_root
char * String(BOOLEAN typed=FALSE)
#define SI_LINK_SET_CLOSE_P(l)
BOOLEAN slGetDumpAscii(si_link l)
omBin s_si_link_extension_bin
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)
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)
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)
BOOLEAN newFile(char *fname, FILE *f)
static BOOLEAN CollectLibs(char *name, char ***list_of_libs)
void p_Write(poly p, ring lmRing, ring tailRing)
char * iiStringMatrix(matrix im, int dim, const ring r, char ch)
static BOOLEAN DumpQring(FILE *fd, idhdl h, const char *type_str)
BOOLEAN slDumpAscii(si_link l)