Loading...
Searching...
No Matches
asciiLink.cc File Reference
`#include "kernel/mod2.h"`
`#include "misc/options.h"`
`#include "Singular/tok.h"`
`#include "Singular/subexpr.h"`
`#include "Singular/ipshell.h"`
`#include "Singular/ipid.h"`
`#include "Singular/fevoices.h"`
`#include "kernel/oswrapper/feread.h"`
`#include "Singular/links/silink.h"`

Go to the source code of this file.

## Macros

#define | MAX_LIBS 256

## Functions

static BOOLEAN | DumpAscii (FILE *fd, idhdl h, char ***list_of_libs)
static BOOLEAN | DumpAsciiIdhdl (FILE *fd, idhdl h, char ***list_of_libs)
static const char * | GetIdString (idhdl h)
static int | DumpRhs (FILE *fd, idhdl h)
static BOOLEAN | DumpQring (FILE *fd, idhdl h)
static BOOLEAN | DumpNCring (FILE *fd, idhdl h)
static BOOLEAN | DumpAsciiMaps (FILE *fd, idhdl h, idhdl rhdl)
static BOOLEAN | CollectLibs (char *name, char ***list_of_libs)
static BOOLEAN | slOpenAscii (si_link l, short flag, leftv)
static BOOLEAN | slCloseAscii (si_link l)
static leftv | slReadAscii2 (si_link l, leftv pr)
static leftv | slReadAscii (si_link l)
static BOOLEAN | slWriteAscii (si_link l, leftv v)
const char * | slStatusAscii (si_link l, const char *request)
static BOOLEAN | slDumpAscii (si_link l)
static BOOLEAN | slGetDumpAscii (si_link l)
void | slStandardInit ()

## Variables

EXTERN_VAR si_link_extension | si_link_root
EXTERN_VAR BOOLEAN | FE_OPT_NO_SHELL_FLAG

## Macro Definition Documentation

## MAX_LIBS

#define MAX_LIBS 256

## Function Documentation

## CollectLibs()

BOOLEAN CollectLibs | ( | char * | name,
|  | char *** | list_of_libs )

static

Definition at line 485 of file asciiLink.cc.

{
if (*list_of_libs==NULL)
{
#define MAX_LIBS 256
(*list_of_libs)=(char**)omAlloc0(MAX_LIBS*sizeof(char**));
(*list_of_libs)[0]=name;
(*list_of_libs)[MAX_LIBS-1]=(char*)1;
return FALSE;
}
else
{
char **p=*list_of_libs;
while (((*p)!=NULL)&&((*p!=(char*)1)))
{
if (strcmp((*p),name)==0) return FALSE;
p++;
}
if (*p==(char*)1)
{
WerrorS("too many libs");
return TRUE;
}
else
{
*p=name;
}
}
return FALSE;
}
MAX_LIBS
#define MAX_LIBS
TRUE
#define TRUE
Definition auxiliary.h:101
FALSE
#define FALSE
Definition auxiliary.h:97
p
int p
Definition cfModGcd.cc:4086
name
char name(const Variable &v)
Definition factory.h:189
WerrorS
void WerrorS(const char *s)
Definition feFopen.cc:24
omAlloc0
#define omAlloc0(size)
Definition omAllocDecl.h:211
NULL
#define NULL
Definition omList.c:12

## DumpAscii()

BOOLEAN DumpAscii | ( | FILE * | fd,
|  | idhdl | h,
|  | char *** | list_of_libs )

static

Definition at line 257 of file asciiLink.cc.

{
if (h == NULL) return FALSE;
if (DumpAscii(fd, IDNEXT(h),list_of_libs)) return TRUE;
// need to set the ring before writing it, otherwise we get in
// trouble with minpoly
if (IDTYP(h) == RING_CMD)
rSetHdl(h);
if (DumpAsciiIdhdl(fd, h,list_of_libs)) return TRUE;
if (IDTYP(h) == RING_CMD)
return DumpAscii(fd, IDRING(h)->idroot,list_of_libs);
else
return FALSE;
}
DumpAscii
static BOOLEAN DumpAscii(FILE *fd, idhdl h, char ***list_of_libs)
Definition asciiLink.cc:257
DumpAsciiIdhdl
static BOOLEAN DumpAsciiIdhdl(FILE *fd, idhdl h, char ***list_of_libs)
Definition asciiLink.cc:305
RING_CMD
@ RING_CMD
Definition grammar.cc:282
IDNEXT
#define IDNEXT(a)
Definition ipid.h:118
IDRING
#define IDRING(a)
Definition ipid.h:127
IDTYP
#define IDTYP(a)
Definition ipid.h:119
rSetHdl
void rSetHdl(idhdl h)
Definition ipshell.cc:5129
h
STATIC_VAR Poly * h
Definition janet.cc:971
fd
int status int fd
Definition si_signals.h:69

## DumpAsciiIdhdl()

BOOLEAN DumpAsciiIdhdl | ( | FILE * | fd,
|  | idhdl | h,
|  | char *** | list_of_libs )

static

Definition at line 305 of file asciiLink.cc.

{
const char *type_str = GetIdString(h);
int type_id = IDTYP(h);
if (type_id == PACKAGE_CMD)
{
if (strcmp(IDID(h),"Top")==0) return FALSE; // do not dump "Top"
if (IDPACKAGE(h)->language==LANG_SINGULAR) return FALSE;
if (IDPACKAGE(h)->language==LANG_MIX) return FALSE;
}
if (type_id == CRING_CMD)
{
// do not dump the default CRINGs:
if (strcmp(IDID(h),"QQ")==0) return FALSE;
if (strcmp(IDID(h),"ZZ")==0) return FALSE;
#ifdef SINGULAR_4_2
if (strcmp(IDID(h),"AE")==0) return FALSE;
if (strcmp(IDID(h),"QAE")==0) return FALSE;
#endif
}
// we do not throw an error if a wrong type was attempted to be dumped
if (type_str == NULL)
return FALSE;
// handle nc-rings separately
if ((type_id == RING_CMD)&&(rIsNCRing(IDRING(h))))
return DumpNCring(fd,h);
// handle qrings separately
if ((type_id == RING_CMD)&&(IDRING(h)->qideal!=NULL))
return DumpQring(fd, h);
// C-proc not to be dumped
if ((type_id == PROC_CMD) && (IDPROC(h)->language == LANG_C))
return FALSE;
// handle libraries
if ((type_id == PROC_CMD)
&& (IDPROC(h)->language == LANG_SINGULAR)
&& (IDPROC(h)->libname!=NULL))
return CollectLibs(IDPROC(h)->libname,list_of_libs);
// put type and name
if (fprintf(fd, "%s %s", type_str, IDID(h)) == EOF)
return TRUE;
// for matricies, append the dimension
if (type_id == MATRIX_CMD)
{
ideal id = IDIDEAL(h);
if (fprintf(fd, "[%d][%d]", id->nrows, id->ncols)== EOF) return TRUE;
}
else if (type_id == INTMAT_CMD)
{
if (fprintf(fd, "[%d][%d]", IDINTVEC(h)->rows(), IDINTVEC(h)->cols())
== EOF) return TRUE;
}
else if (type_id == SMATRIX_CMD)
{
ideal id = IDIDEAL(h);
if (fprintf(fd, "[%d][%d]", (int)id->rank, IDELEMS(id))== EOF) return TRUE;
}
if (type_id == PACKAGE_CMD)
{
return (fputs(";\n",fd) == EOF);
}
// write the equal sign
if (fputs(" = ",fd) == EOF) return TRUE;
// and the right hand side
if (DumpRhs(fd, h) == EOF) return TRUE;
// semicolon und tschuess
if (fputs(";\n",fd) == EOF) return TRUE;
return FALSE;
}
GetIdString
static const char * GetIdString(idhdl h)
Definition asciiLink.cc:386
CollectLibs
static BOOLEAN CollectLibs(char *name, char ***list_of_libs)
Definition asciiLink.cc:485
DumpNCring
static BOOLEAN DumpNCring(FILE *fd, idhdl h)
Definition asciiLink.cc:436
DumpRhs
static int DumpRhs(FILE *fd, idhdl h)
Definition asciiLink.cc:517
DumpQring
static BOOLEAN DumpQring(FILE *fd, idhdl h)
Definition asciiLink.cc:466
MATRIX_CMD
@ MATRIX_CMD
Definition grammar.cc:287
PROC_CMD
@ PROC_CMD
Definition grammar.cc:281
INTMAT_CMD
@ INTMAT_CMD
Definition grammar.cc:280
SMATRIX_CMD
@ SMATRIX_CMD
Definition grammar.cc:292
IDPROC
#define IDPROC(a)
Definition ipid.h:140
IDINTVEC
#define IDINTVEC(a)
Definition ipid.h:128
IDIDEAL
#define IDIDEAL(a)
Definition ipid.h:133
IDID
#define IDID(a)
Definition ipid.h:122
IDPACKAGE
#define IDPACKAGE(a)
Definition ipid.h:139
rIsNCRing
static BOOLEAN rIsNCRing(const ring r)
Definition ring.h:427
IDELEMS
#define IDELEMS(i)
Definition simpleideals.h:23
LANG_SINGULAR
@ LANG_SINGULAR
Definition subexpr.h:22
LANG_MIX
@ LANG_MIX
Definition subexpr.h:22
LANG_C
@ LANG_C
Definition subexpr.h:22
CRING_CMD
@ CRING_CMD
Definition tok.h:56
PACKAGE_CMD
@ PACKAGE_CMD
Definition tok.h:150

## DumpAsciiMaps()

BOOLEAN DumpAsciiMaps | ( | FILE * | fd,
|  | idhdl | h,
|  | idhdl | rhdl )

static

Definition at line 276 of file asciiLink.cc.

{
if (h == NULL) return FALSE;
if (DumpAsciiMaps(fd, IDNEXT(h), rhdl)) return TRUE;
if (IDTYP(h) == RING_CMD)
return DumpAsciiMaps(fd, IDRING(h)->idroot, h);
else if (IDTYP(h) == MAP_CMD)
{
char *rhs;
rSetHdl(rhdl);
rhs = h->String();
if (fprintf(fd, "setring %s;\n", IDID(rhdl)) == EOF) return TRUE;
if (fprintf(fd, "%s %s = %s, %s;\n", Tok2Cmdname(MAP_CMD), IDID(h),
IDMAP(h)->preimage, rhs) == EOF)
{
omFree(rhs);
return TRUE;
}
else
{
omFree(rhs);
return FALSE;
}
}
else return FALSE;
}
DumpAsciiMaps
static BOOLEAN DumpAsciiMaps(FILE *fd, idhdl h, idhdl rhdl)
Definition asciiLink.cc:276
Tok2Cmdname
const char * Tok2Cmdname(int tok)
Definition gentable.cc:137
MAP_CMD
@ MAP_CMD
Definition grammar.cc:286
IDMAP
#define IDMAP(a)
Definition ipid.h:135
omFree
#define omFree(addr)
Definition omAllocDecl.h:261

## DumpNCring()

BOOLEAN DumpNCring | ( | FILE * | fd,
|  | idhdl | h )

static

Definition at line 436 of file asciiLink.cc.

{
char *ring_str = h->String();
ring r=IDRING(h);
if (rIsPluralRing(r))
{
if (fprintf(fd, "ring temp_ring = %s;\n", ring_str)
== EOF) return TRUE;
if (fprintf(fd, "ideal temp_C = %s;\n",
iiStringMatrix((matrix) r->GetNC()->C, 2, r, n_GetChar(r->cf)))
== EOF) return TRUE;
if (fprintf(fd, "ideal temp_D = %s;\n",
iiStringMatrix((matrix) r->GetNC()->D, 2, r, n_GetChar(r->cf)))
== EOF) return TRUE;
if (fprintf(fd, "def %s = nc_algebra(temp_C,temp_D);\n",IDID(h)) == EOF)
return TRUE;
if (fputs("kill temp_ring;\n",fd) == EOF) return TRUE;
}
if (rIsLPRing(r))
{
//if (fprintf(fd, "ring %s = %s;\n", IDID(h), ring_str) == EOF) return TRUE;
//if (fprintf(fd, "attrib(%s,\"isLetterplaceRing\",%d);\n",IDID(h),r->isLPring) ==EOF) return TRUE;
Warn("cannot write LP ring %s",IDID(h));
return TRUE;
}
omFree(ring_str);
return FALSE;
}
n_GetChar
static FORCE_INLINE int n_GetChar(const coeffs r)
Return the characteristic of the coeff. domain.
Definition coeffs.h:450
Warn
#define Warn
Definition emacs.cc:77
iiStringMatrix
char * iiStringMatrix(matrix im, int dim, const ring r, char ch)
Definition matpol.cc:849
matrix
ip_smatrix * matrix
Definition matpol.h:43
rIsPluralRing
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
Definition ring.h:406
rIsLPRing
static BOOLEAN rIsLPRing(const ring r)
Definition ring.h:417

## DumpQring()

BOOLEAN DumpQring | ( | FILE * | fd,
|  | idhdl | h )

static

Definition at line 466 of file asciiLink.cc.

{
char *ring_str = h->String();
ring r=IDRING(h);
if (fprintf(fd, "ring temp_ring = %s;\n", ring_str) == EOF) return TRUE;
if (fprintf(fd, "ideal temp_ideal = %s;\n",
iiStringMatrix((matrix) r->qideal, 1, currRing, n_GetChar(r->cf)))
== EOF) return TRUE;
if (fputs("attrib(temp_ideal, \"isSB\", 1);\n",fd) == EOF) return TRUE;
if (fprintf(fd, "qring %s = temp_ideal;\n",IDID(h)) == EOF)
return TRUE;
if (fputs("kill temp_ring;\n",fd) == EOF) return TRUE;
else
{
omFree(ring_str);
return FALSE;
}
}
currRing
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition polys.cc:13

## DumpRhs()

int DumpRhs | ( | FILE * | fd,
|  | idhdl | h )

static

Definition at line 517 of file asciiLink.cc.

{
int type_id = IDTYP(h);
if (type_id == LIST_CMD)
{
lists l = IDLIST(h);
int i, nl = l->nr;
fputs("list(",fd);
for (i=0; i<nl; i++)
{
if (DumpRhs(fd, (idhdl) &(l->m[i])) == EOF) return EOF;
fputs(",",fd);
}
if (nl >= 0)
{
if (DumpRhs(fd, (idhdl) &(l->m[nl])) == EOF) return EOF;
}
fputs(")",fd);
}
else if (type_id == STRING_CMD)
{
char *pstr = IDSTRING(h);
fputc('"', fd);
while (*pstr != '\0')
{
if (*pstr == '"' || *pstr == '\\') fputc('\\', fd);
fputc(*pstr, fd);
pstr++;
}
fputc('"', fd);
}
else if (type_id == PROC_CMD)
{
procinfov pi = IDPROC(h);
if (pi->language == LANG_SINGULAR)
{
/* pi-Libname==NULL */
char *pstr = pi->data.s.body;
fputc('"', fd);
while (*pstr != '\0')
{
if (*pstr == '"' || *pstr == '\\') fputc('\\', fd);
fputc(*pstr, fd);
pstr++;
}
fputc('"', fd);
}
else fputs("(null)", fd);
}
else
{
char *rhs = h->String();
if (rhs == NULL) return EOF;
BOOLEAN need_klammer=FALSE;
if (type_id == INTVEC_CMD) { fputs("intvec(",fd);need_klammer=TRUE; }
else if (type_id == IDEAL_CMD) { fputs("ideal(",fd);need_klammer=TRUE; }
else if ((type_id == MODUL_CMD)||(type_id == SMATRIX_CMD))
{ fputs("module(",fd);need_klammer=TRUE; }
else if (type_id == BIGINT_CMD) { fputs("bigint(",fd);need_klammer=TRUE; }
if (fputs(rhs,fd) == EOF) return EOF;
omFree(rhs);
if ((type_id == RING_CMD) &&
IDRING(h)->cf->type==n_algExt)
{
StringSetS("");
p_Write(IDRING(h)->cf->extRing->qideal->m[0],IDRING(h)->cf->extRing);
rhs = StringEndS();
if (fprintf(fd, "; minpoly = %s", rhs) == EOF) { omFree(rhs); return EOF;}
omFree(rhs);
}
else if (need_klammer) fputc(')',fd);
}
return 1;
}
BOOLEAN
int BOOLEAN
Definition auxiliary.h:88
l
int l
Definition cfEzgcd.cc:100
i
int i
Definition cfEzgcd.cc:132
cf
CanonicalForm cf
Definition cfModGcd.cc:4091
n_algExt
@ n_algExt
used for all algebraic extensions, i.e., the top-most extension in an extension tower is algebraic
Definition coeffs.h:35
IDEAL_CMD
@ IDEAL_CMD
Definition grammar.cc:285
MODUL_CMD
@ MODUL_CMD
Definition grammar.cc:288
IDSTRING
#define IDSTRING(a)
Definition ipid.h:136
IDLIST
#define IDLIST(a)
Definition ipid.h:137
pstr
#define pstr
Definition libparse.cc:1246
pi
#define pi
Definition libparse.cc:1145
lists
slists * lists
Definition mpr_numeric.h:146
p_Write
void p_Write(poly p, ring lmRing, ring tailRing)
Definition polys0.cc:342
StringSetS
void StringSetS(const char *st)
Definition reporter.cc:128
StringEndS
char * StringEndS()
Definition reporter.cc:151
idhdl
idrec * idhdl
Definition ring.h:22
procinfov
procinfo * procinfov
Definition structs.h:56
BIGINT_CMD
@ BIGINT_CMD
Definition tok.h:38
LIST_CMD
@ LIST_CMD
Definition tok.h:118
INTVEC_CMD
@ INTVEC_CMD
Definition tok.h:101
STRING_CMD
@ STRING_CMD
Definition tok.h:187

## GetIdString()

const char * GetIdString | ( | idhdl | h | ) |

static

Definition at line 386 of file asciiLink.cc.

{
int type = IDTYP(h);
switch(type)
{
case LIST_CMD:
//{
//
//
// lists l = IDLIST(h);
// int i, nl = l->nr + 1;
//
// for (i=0; i<nl; i++)
// if (GetIdString((idhdl) &(l->m[i])) == NULL) return NULL;
// break;
//}
case CRING_CMD:
#ifdef SINGULAR_4_2
case CNUMBER_CMD:
case CMATRIX_CMD:
#endif
case BIGINT_CMD:
case PACKAGE_CMD:
case INT_CMD:
case INTVEC_CMD:
case INTMAT_CMD:
case STRING_CMD:
case RING_CMD:
case QRING_CMD:
case PROC_CMD:
case NUMBER_CMD:
case POLY_CMD:
case IDEAL_CMD:
case VECTOR_CMD:
case MODUL_CMD:
case MATRIX_CMD:
case SMATRIX_CMD:
return Tok2Cmdname(type);
case MAP_CMD:
case LINK_CMD:
return NULL;
default:
Warn("Error dump data of type %s", Tok2Cmdname(IDTYP(h)));
return NULL;
}
}
VECTOR_CMD
@ VECTOR_CMD
Definition grammar.cc:293
NUMBER_CMD
@ NUMBER_CMD
Definition grammar.cc:289
POLY_CMD
@ POLY_CMD
Definition grammar.cc:290
CMATRIX_CMD
@ CMATRIX_CMD
Definition tok.h:46
CNUMBER_CMD
@ CNUMBER_CMD
Definition tok.h:47
LINK_CMD
@ LINK_CMD
Definition tok.h:117
QRING_CMD
@ QRING_CMD
Definition tok.h:160
INT_CMD
@ INT_CMD
Definition tok.h:96

## slCloseAscii()

BOOLEAN slCloseAscii | ( | si_link | l | ) |

static

Definition at line 98 of file asciiLink.cc.

{
SI_LINK_SET_CLOSE_P(l);
if (l->name[0] != '\0')
{
return (fclose((FILE *)l->data)!=0);
}
return FALSE;
}
SI_LINK_SET_CLOSE_P
#define SI_LINK_SET_CLOSE_P(l)
Definition silink.h:76

## slDumpAscii()

BOOLEAN slDumpAscii | ( | si_link | l | ) |

static

Definition at line 228 of file asciiLink.cc.

{
FILE *fd = (FILE *) l->data;
idhdl h = IDROOT, rh = currRingHdl;
char **list_of_libs=NULL;
BOOLEAN status = DumpAscii(fd, h, &list_of_libs);
if (! status ) status = DumpAsciiMaps(fd, h, NULL);
if (currRingHdl != rh) rSetHdl(rh);
fprintf(fd, "option(set, intvec(%d, %d));\n", si_opt_1, si_opt_2);
char **p=list_of_libs;
if (p!=NULL)
{
while((*p!=NULL) && (*p!=(char*)1))
{
fprintf(fd,"load(\"%s\",\"try\");\n",*p);
p++;
}
omFree(list_of_libs);
}
fputs("RETURN();\n",fd);
fflush(fd);
return status;
}
currRingHdl
VAR idhdl currRingHdl
Definition ipid.cc:57
IDROOT
#define IDROOT
Definition ipid.h:19
si_opt_2
VAR unsigned si_opt_2
Definition options.c:6
si_opt_1
VAR unsigned si_opt_1
Definition options.c:5
status
int * status
Definition si_signals.h:61

## slGetDumpAscii()

BOOLEAN slGetDumpAscii | ( | si_link | l | ) |

static

Definition at line 599 of file asciiLink.cc.

{
if (l->name[0] == '\0')
{
WerrorS("getdump: Can not get dump from stdin");
return TRUE;
}
else
{
BOOLEAN status = newFile(l->name);
if (status)
return TRUE;
int old_echo=si_echo;
si_echo=0;
status=yyparse();
si_echo=old_echo;
if (status)
return TRUE;
else
{
// lets reset the file pointer to the end to reflect that
// we are finished with reading
FILE *f = (FILE *) l->data;
fseek(f, 0L, SEEK_END);
return FALSE;
}
}
}
f
FILE * f
Definition checklibs.c:9
si_echo
VAR int si_echo
Definition febase.cc:35
newFile
BOOLEAN newFile(char *fname)
Definition fevoices.cc:129
yyparse
int yyparse(void)
Definition grammar.cc:2149
SEEK_END
#define SEEK_END
Definition mod2.h:111

## slOpenAscii()

BOOLEAN slOpenAscii | ( | si_link | l,
|  | short | flag,
|  | leftv | )

static

Definition at line 36 of file asciiLink.cc.

{
if (FE_OPT_NO_SHELL_FLAG) {WerrorS("no links allowed");return TRUE;}
const char *mode;
if (flag & SI_LINK_OPEN)
{
if (l->mode[0] != '\0' && (strcmp(l->mode, "r") == 0))
flag = SI_LINK_READ;
else flag = SI_LINK_WRITE;
}
if (flag == SI_LINK_READ) mode = "r";
else if (strcmp(l->mode, "w") == 0) mode = "w";
else mode = "a";
if (l->name[0] == '\0')
{
// stdin or stdout
if (flag == SI_LINK_READ)
{
l->data = (void *) stdin;
mode = "r";
}
else
{
l->data = (void *) stdout;
mode = "a";
}
}
else
{
// normal ascii link to a file
FILE *outfile;
char *filename=l->name;
if(filename[0]=='>')
{
if (filename[1]=='>')
{
filename+=2;
mode = "a";
}
else
{
filename++;
mode="w";
}
}
outfile=myfopen(filename,mode);
if (outfile!=NULL)
l->data = (void *) outfile;
else
return TRUE;
}
omFree(l->mode);
l->mode = omStrDup(mode);
SI_LINK_SET_OPEN_P(l, flag);
return FALSE;
}
FE_OPT_NO_SHELL_FLAG
EXTERN_VAR BOOLEAN FE_OPT_NO_SHELL_FLAG
Definition extra.cc:166
myfopen
FILE * myfopen(const char *path, const char *mode)
Definition feFopen.cc:167
omStrDup
#define omStrDup(s)
Definition omAllocDecl.h:263
SI_LINK_WRITE
#define SI_LINK_WRITE
Definition silink.h:67
SI_LINK_OPEN
#define SI_LINK_OPEN
Definition silink.h:65
SI_LINK_SET_OPEN_P
#define SI_LINK_SET_OPEN_P(l, flag)
Definition silink.h:77
SI_LINK_READ
#define SI_LINK_READ
Definition silink.h:66

## slReadAscii()

leftv slReadAscii | ( | si_link | l | ) |

static

Definition at line 143 of file asciiLink.cc.

{
sleftv tmp;
memset(&tmp,0,sizeof(sleftv));
tmp.rtyp=STRING_CMD;
tmp.data=(void*) "? ";
return slReadAscii2(l,&tmp);
}
slReadAscii2
static leftv slReadAscii2(si_link l, leftv pr)
Definition asciiLink.cc:108
sleftv
Class used for (list of) interpreter objects.
Definition subexpr.h:83
sleftv::rtyp
int rtyp
Definition subexpr.h:91
sleftv::data
void * data
Definition subexpr.h:88

## slReadAscii2()

leftv slReadAscii2 | ( | si_link | l,
|  | leftv | pr )

static

Definition at line 108 of file asciiLink.cc.

{
FILE * fp=(FILE *)l->data;
char * buf=NULL;
if (fp!=NULL && l->name[0] != '\0')
{
fseek(fp,0L,SEEK_END);
long len=ftell(fp);
if (len<0) len=0;
fseek(fp,0L,SEEK_SET);
buf=(char *)omAlloc((int)len+1);
if (BVERBOSE(V_READING))
Print("//Reading %ld chars\n",len);
if (len>0) myfread( buf, len, 1, fp);
buf[len]='\0';
}
else
{
if (pr->Typ()==STRING_CMD)
{
buf=(char *)omAlloc(80);
fe_fgets_stdin((char *)pr->Data(),buf,80);
}
else
{
WerrorS("read(<link>,<string>) expected");
buf=omStrDup("");
}
}
leftv v=(leftv)omAlloc0Bin(sleftv_bin);
v->rtyp=STRING_CMD;
v->data=buf;
return v;
}
fp
CanonicalForm fp
Definition cfModGcd.cc:4110
sleftv::Typ
int Typ()
Definition subexpr.cc:1048
sleftv::Data
void * Data()
Definition subexpr.cc:1192
Print
#define Print
Definition emacs.cc:80
v
const Variable & v
< [in] a sqrfree bivariate poly
Definition facBivar.h:39
myfread
size_t myfread(void *ptr, size_t size, size_t nmemb, FILE *stream)
Definition feFopen.cc:195
fe_fgets_stdin
char *(* fe_fgets_stdin)(const char *pr, char *s, int size)
Definition feread.cc:32
sleftv_bin
EXTERN_VAR omBin sleftv_bin
Definition ipid.h:145
SEEK_SET
#define SEEK_SET
Definition mod2.h:115
omAlloc
#define omAlloc(size)
Definition omAllocDecl.h:210
omAlloc0Bin
#define omAlloc0Bin(bin)
Definition omAllocDecl.h:206
BVERBOSE
#define BVERBOSE(a)
Definition options.h:35
V_READING
#define V_READING
Definition options.h:46
buf
int status int void * buf
Definition si_signals.h:69
leftv
sleftv * leftv
Definition structs.h:53

## slStandardInit()

void slStandardInit | ( |  | ) |

Definition at line 633 of file asciiLink.cc.

{
si_link_extension s;
si_link_root=(si_link_extension)omAlloc0Bin(s_si_link_extension_bin);
si_link_root->Open=slOpenAscii;
si_link_root->Close=slCloseAscii;
si_link_root->Kill=NULL;
si_link_root->Read=slReadAscii;
si_link_root->Read2=slReadAscii2;
si_link_root->Write=slWriteAscii;
si_link_root->Dump=slDumpAscii;
si_link_root->GetDump=slGetDumpAscii;
si_link_root->Status=slStatusAscii;
si_link_root->type="ASCII";
s = si_link_root;
s->next = NULL;
}
slGetDumpAscii
static BOOLEAN slGetDumpAscii(si_link l)
Definition asciiLink.cc:599
slCloseAscii
static BOOLEAN slCloseAscii(si_link l)
Definition asciiLink.cc:98
si_link_root
EXTERN_VAR si_link_extension si_link_root
Definition asciiLink.cc:32
slDumpAscii
static BOOLEAN slDumpAscii(si_link l)
Definition asciiLink.cc:228
slStatusAscii
const char * slStatusAscii(si_link l, const char *request)
Definition asciiLink.cc:211
slWriteAscii
static BOOLEAN slWriteAscii(si_link l, leftv v)
Definition asciiLink.cc:152
slReadAscii
static leftv slReadAscii(si_link l)
Definition asciiLink.cc:143
slOpenAscii
static BOOLEAN slOpenAscii(si_link l, short flag, leftv)
Definition asciiLink.cc:36
s
const CanonicalForm int s
Definition facAbsFact.cc:51
s_si_link_extension_bin
VAR omBin s_si_link_extension_bin
Definition silink.cc:39

## slStatusAscii()

const char * slStatusAscii | ( | si_link | l,
|  | const char * | request )

Definition at line 211 of file asciiLink.cc.

{
if (strcmp(request, "read") == 0)
{
if (SI_LINK_R_OPEN_P(l)) return "ready";
else return "not ready";
}
else if (strcmp(request, "write") == 0)
{
if (SI_LINK_W_OPEN_P(l)) return "ready";
else return "not ready";
}
else return "unknown status request";
}
SI_LINK_W_OPEN_P
#define SI_LINK_W_OPEN_P(l)
Definition silink.h:72
SI_LINK_R_OPEN_P
#define SI_LINK_R_OPEN_P(l)
Definition silink.h:73

## slWriteAscii()

BOOLEAN slWriteAscii | ( | si_link | l,
|  | leftv | v )

static

Definition at line 152 of file asciiLink.cc.

{
FILE *outfile=(FILE *)l->data;
BOOLEAN err=FALSE;
char *s;
while (v!=NULL)
{
switch(v->Typ())
{
case IDEAL_CMD:
case MODUL_CMD:
case MATRIX_CMD:
{
ideal I=(ideal)v->Data();
for(int i=0;i<IDELEMS(I);i++)
{
char *s=pString(I->m[i]);
fwrite(s,strlen(s),1,outfile);
omFree(s);
if (i<IDELEMS(I)-1) fwrite(",",1,1,outfile);
}
break;
}
#if 1
case LIST_CMD:
{
lists l=(lists)v->Data();
for(int i=0;i<l->nr;i++)
{
char *s=l->m[i].String();
fwrite(s,strlen(s),1,outfile);
omFree(s);
if (i!=l->nr-1) fputc(',',outfile);
fputc('\n',outfile);
}
break;
}
#endif
default:
s = v->String();
// free v ??
if (s!=NULL)
{
fputs(s,outfile);
fputc('\n',outfile);
omFree((ADDRESS)s);
}
else
{
WerrorS("cannot convert to string");
err=TRUE;
}
}
v = v->next;
}
fflush(outfile);
return err;
}
ADDRESS
void * ADDRESS
Definition auxiliary.h:120
pString
char * pString(poly p)
Definition polys.h:307

## Variable Documentation

## FE_OPT_NO_SHELL_FLAG

EXTERN_VAR BOOLEAN FE_OPT_NO_SHELL_FLAG

Definition at line 33 of file asciiLink.cc.

## si_link_root

EXTERN_VAR si_link_extension si_link_root

Definition at line 32 of file asciiLink.cc.