Macros | Functions | Variables
asciiLink.cc File Reference
#include <kernel/mod2.h>
#include <misc/options.h>
#include <omalloc/omalloc.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>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.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, const char *type_str)
 
static BOOLEAN DumpAsciiMaps (FILE *fd, idhdl h, idhdl rhdl)
 
static BOOLEAN CollectLibs (char *name, char ***list_of_libs)
 
BOOLEAN slOpenAscii (si_link l, short flag, leftv)
 
BOOLEAN slCloseAscii (si_link l)
 
leftv slReadAscii2 (si_link l, leftv pr)
 
leftv slReadAscii (si_link l)
 
BOOLEAN slWriteAscii (si_link l, leftv v)
 
const char * slStatusAscii (si_link l, const char *request)
 
BOOLEAN slDumpAscii (si_link l)
 
BOOLEAN slGetDumpAscii (si_link l)
 
void slStandardInit ()
 

Variables

si_link_extension si_link_root
 

Macro Definition Documentation

§ MAX_LIBS

#define MAX_LIBS   256

Function Documentation

§ CollectLibs()

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

Definition at line 427 of file asciiLink.cc.

428 {
429  if (*list_of_libs==NULL)
430  {
431  #define MAX_LIBS 256
432  (*list_of_libs)=(char**)omalloc0(MAX_LIBS*sizeof(char**));
433  (*list_of_libs)[0]=name;
434  (*list_of_libs)[MAX_LIBS-1]=(char*)1;
435  return FALSE;
436  }
437  else
438  {
439  char **p=*list_of_libs;
440  while (((*p)!=NULL)&&((*p!=(char*)1)))
441  {
442  if (strcmp((*p),name)==0) return FALSE;
443  p++;
444  }
445  if (*p==(char*)1)
446  {
447  WerrorS("too many libs");
448  return TRUE;
449  }
450  else
451  {
452  *p=name;
453  }
454  }
455  return FALSE;
456 }
#define FALSE
Definition: auxiliary.h:97
return P p
Definition: myNF.cc:203
#define TRUE
Definition: auxiliary.h:101
void WerrorS(const char *s)
Definition: feFopen.cc:24
char name(const Variable &v)
Definition: factory.h:178
#define NULL
Definition: omList.c:10
#define omalloc0(size)
Definition: omAllocDecl.h:229

§ DumpAscii()

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

Definition at line 242 of file asciiLink.cc.

243 {
244  if (h == NULL) return FALSE;
245 
246  if (DumpAscii(fd, IDNEXT(h),list_of_libs)) return TRUE;
247 
248  // need to set the ring before writing it, otherwise we get in
249  // trouble with minpoly
250  if (IDTYP(h) == RING_CMD)
251  rSetHdl(h);
252 
253  if (DumpAsciiIdhdl(fd, h,list_of_libs)) return TRUE;
254 
255  if (IDTYP(h) == RING_CMD)
256  return DumpAscii(fd, IDRING(h)->idroot,list_of_libs);
257  else
258  return FALSE;
259 }
int status int fd
Definition: si_signals.h:59
#define FALSE
Definition: auxiliary.h:97
#define IDNEXT(a)
Definition: ipid.h:115
#define TRUE
Definition: auxiliary.h:101
#define IDTYP(a)
Definition: ipid.h:116
#define NULL
Definition: omList.c:10
#define IDRING(a)
Definition: ipid.h:124
void rSetHdl(idhdl h)
Definition: ipshell.cc:5017

§ DumpAsciiIdhdl()

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

Definition at line 290 of file asciiLink.cc.

291 {
292  const char *type_str = GetIdString(h);
293  int type_id = IDTYP(h);
294 
295  if (type_id == PACKAGE_CMD)
296  {
297  if (strcmp(IDID(h),"Top")==0) return FALSE; // do not dump "Top"
298  if (IDPACKAGE(h)->language==LANG_SINGULAR) return FALSE;
299  }
300 #ifdef SINGULAR_4_1
301  if (type_id == CRING_CMD)
302  {
303  // do not dump the default CRINGs:
304  if (strcmp(IDID(h),"QQ")==0) return FALSE;
305  if (strcmp(IDID(h),"ZZ")==0) return FALSE;
306  if (strcmp(IDID(h),"AE")==0) return FALSE;
307  if (strcmp(IDID(h),"QAE")==0) return FALSE;
308  if (strcmp(IDID(h),"flint_poly_Q")==0) return FALSE;
309  }
310 #endif
311 
312  // we do not throw an error if a wrong type was attempted to be dumped
313  if (type_str == NULL)
314  return FALSE;
315 
316  // handle qrings separately
317  if ((type_id == RING_CMD)&&(IDRING(h)->qideal!=NULL))
318  return DumpQring(fd, h, type_str);
319 
320  // C-proc not to be dumped
321  if ((type_id == PROC_CMD) && (IDPROC(h)->language == LANG_C))
322  return FALSE;
323 
324  // handle libraries
325  if ((type_id == PROC_CMD)
326  && (IDPROC(h)->language == LANG_SINGULAR)
327  && (IDPROC(h)->libname!=NULL))
328  return CollectLibs(IDPROC(h)->libname,list_of_libs);
329 
330  // put type and name
331  if (fprintf(fd, "%s %s", type_str, IDID(h)) == EOF)
332  return TRUE;
333  // for matricies, append the dimension
334  if (type_id == MATRIX_CMD)
335  {
336  ideal id = IDIDEAL(h);
337  if (fprintf(fd, "[%d][%d]", id->nrows, id->ncols)== EOF) return TRUE;
338  }
339  else if (type_id == INTMAT_CMD)
340  {
341  if (fprintf(fd, "[%d][%d]", IDINTVEC(h)->rows(), IDINTVEC(h)->cols())
342  == EOF) return TRUE;
343  }
344 
345  if (type_id == PACKAGE_CMD)
346  {
347  return (fprintf(fd, ";\n") == EOF);
348  }
349 
350  // write the equal sign
351  if (fprintf(fd, " = ") == EOF) return TRUE;
352 
353  // and the right hand side
354  if (DumpRhs(fd, h) == EOF) return TRUE;
355 
356  // semicolon und tschuess
357  if (fprintf(fd, ";\n") == EOF) return TRUE;
358 
359  return FALSE;
360 }
int status int fd
Definition: si_signals.h:59
#define IDINTVEC(a)
Definition: ipid.h:125
#define IDID(a)
Definition: ipid.h:119
#define FALSE
Definition: auxiliary.h:97
#define TRUE
Definition: auxiliary.h:101
#define IDIDEAL(a)
Definition: ipid.h:130
Definition: subexpr.h:21
#define IDPACKAGE(a)
Definition: ipid.h:136
#define IDTYP(a)
Definition: ipid.h:116
Definition: tok.h:55
#define IDPROC(a)
Definition: ipid.h:137
#define NULL
Definition: omList.c:10
#define IDRING(a)
Definition: ipid.h:124

§ DumpAsciiMaps()

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

Definition at line 261 of file asciiLink.cc.

262 {
263  if (h == NULL) return FALSE;
264  if (DumpAsciiMaps(fd, IDNEXT(h), rhdl)) return TRUE;
265 
266  if (IDTYP(h) == RING_CMD)
267  return DumpAsciiMaps(fd, IDRING(h)->idroot, h);
268  else if (IDTYP(h) == MAP_CMD)
269  {
270  char *rhs;
271  rSetHdl(rhdl);
272  rhs = h->String();
273 
274  if (fprintf(fd, "setring %s;\n", IDID(rhdl)) == EOF) return TRUE;
275  if (fprintf(fd, "%s %s = %s, %s;\n", Tok2Cmdname(MAP_CMD), IDID(h),
276  IDMAP(h)->preimage, rhs) == EOF)
277  {
278  omFree(rhs);
279  return TRUE;
280  }
281  else
282  {
283  omFree(rhs);
284  return FALSE;
285  }
286  }
287  else return FALSE;
288 }
int status int fd
Definition: si_signals.h:59
#define IDID(a)
Definition: ipid.h:119
#define FALSE
Definition: auxiliary.h:97
#define IDNEXT(a)
Definition: ipid.h:115
#define TRUE
Definition: auxiliary.h:101
char * String(BOOLEAN typed=FALSE)
Definition: ipid.cc:249
#define IDTYP(a)
Definition: ipid.h:116
#define omFree(addr)
Definition: omAllocDecl.h:261
#define IDMAP(a)
Definition: ipid.h:132
#define NULL
Definition: omList.c:10
const char * Tok2Cmdname(int tok)
Definition: gentable.cc:128
#define IDRING(a)
Definition: ipid.h:124
void rSetHdl(idhdl h)
Definition: ipshell.cc:5017

§ DumpQring()

static BOOLEAN DumpQring ( FILE *  fd,
idhdl  h,
const char *  type_str 
)
static

Definition at line 408 of file asciiLink.cc.

409 {
410  char *ring_str = h->String();
411  if (fprintf(fd, "%s temp_ring = %s;\n", Tok2Cmdname(RING_CMD), ring_str)
412  == EOF) return TRUE;
413  if (fprintf(fd, "%s temp_ideal = %s;\n", Tok2Cmdname(IDEAL_CMD),
414  iiStringMatrix((matrix) IDRING(h)->qideal, 1, currRing, n_GetChar(currRing->cf)))
415  == EOF) return TRUE;
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)
418  return TRUE;
419  if (fprintf(fd, "kill temp_ring;\n") == EOF) return TRUE;
420  else
421  {
422  omFree(ring_str);
423  return FALSE;
424  }
425 }
int status int fd
Definition: si_signals.h:59
#define IDID(a)
Definition: ipid.h:119
#define FALSE
Definition: auxiliary.h:97
static FORCE_INLINE int n_GetChar(const coeffs r)
Return the characteristic of the coeff. domain.
Definition: coeffs.h:448
#define TRUE
Definition: auxiliary.h:101
char * String(BOOLEAN typed=FALSE)
Definition: ipid.cc:249
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:10
#define omFree(addr)
Definition: omAllocDecl.h:261
const char * Tok2Cmdname(int tok)
Definition: gentable.cc:128
#define IDRING(a)
Definition: ipid.h:124
char * iiStringMatrix(matrix im, int dim, const ring r, char ch)
Definition: matpol.cc:760

§ DumpRhs()

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

Definition at line 459 of file asciiLink.cc.

460 {
461  int type_id = IDTYP(h);
462 
463  if (type_id == LIST_CMD)
464  {
465  lists l = IDLIST(h);
466  int i, nl = l->nr;
467 
468  fprintf(fd, "list(");
469 
470  for (i=0; i<nl; i++)
471  {
472  if (DumpRhs(fd, (idhdl) &(l->m[i])) == EOF) return EOF;
473  fprintf(fd, ",");
474  }
475  if (nl > 0)
476  {
477  if (DumpRhs(fd, (idhdl) &(l->m[nl])) == EOF) return EOF;
478  }
479  fprintf(fd, ")");
480  }
481  else if (type_id == STRING_CMD)
482  {
483  char *pstr = IDSTRING(h);
484  fputc('"', fd);
485  while (*pstr != '\0')
486  {
487  if (*pstr == '"' || *pstr == '\\') fputc('\\', fd);
488  fputc(*pstr, fd);
489  pstr++;
490  }
491  fputc('"', fd);
492  }
493  else if (type_id == PROC_CMD)
494  {
495  procinfov pi = IDPROC(h);
496  if (pi->language == LANG_SINGULAR)
497  {
498  /* pi-Libname==NULL */
499  char *pstr = pi->data.s.body;
500  fputc('"', fd);
501  while (*pstr != '\0')
502  {
503  if (*pstr == '"' || *pstr == '\\') fputc('\\', fd);
504  fputc(*pstr, fd);
505  pstr++;
506  }
507  fputc('"', fd);
508  }
509  else fputs("(null)", fd);
510  }
511  else
512  {
513  char *rhs = h->String();
514 
515  if (rhs == NULL) return EOF;
516 
517  BOOLEAN need_klammer=FALSE;
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; }
522 
523  if (fprintf(fd, "%s", rhs) == EOF) return EOF;
524  omFree(rhs);
525 
526  if ((type_id == RING_CMD) &&
527  IDRING(h)->cf->type==n_algExt)
528  {
529  StringSetS("");
530  p_Write(IDRING(h)->cf->extRing->qideal->m[0],IDRING(h)->cf->extRing);
531  rhs = StringEndS();
532  if (fprintf(fd, "; minpoly = %s", rhs) == EOF) { omFree(rhs); return EOF;}
533  omFree(rhs);
534  }
535  else if (need_klammer) fprintf(fd, ")");
536  }
537  return 1;
538 }
int status int fd
Definition: si_signals.h:59
#define IDLIST(a)
Definition: ipid.h:134
#define pstr
Definition: libparse.cc:1244
sleftv * m
Definition: lists.h:45
Definition: lists.h:22
#define FALSE
Definition: auxiliary.h:97
Definition: tok.h:38
language_defs language
Definition: subexpr.h:59
#define TRUE
Definition: auxiliary.h:101
char * StringEndS()
Definition: reporter.cc:151
char * String(BOOLEAN typed=FALSE)
Definition: ipid.cc:249
Definition: idrec.h:34
#define IDTYP(a)
Definition: ipid.h:116
#define omFree(addr)
Definition: omAllocDecl.h:261
void StringSetS(const char *st)
Definition: reporter.cc:128
procinfodata data
Definition: subexpr.h:63
#define IDSTRING(a)
Definition: ipid.h:133
int i
Definition: cfEzgcd.cc:123
Definition: tok.h:99
#define IDPROC(a)
Definition: ipid.h:137
#define pi
Definition: libparse.cc:1143
int nr
Definition: lists.h:43
CanonicalForm cf
Definition: cfModGcd.cc:4024
#define NULL
Definition: omList.c:10
used for all algebraic extensions, i.e., the top-most extension in an extension tower is algebraic ...
Definition: coeffs.h:36
#define IDRING(a)
Definition: ipid.h:124
Definition: tok.h:116
void p_Write(poly p, ring lmRing, ring tailRing)
Definition: polys0.cc:206
int BOOLEAN
Definition: auxiliary.h:88
int l
Definition: cfEzgcd.cc:94

§ GetIdString()

static const char * GetIdString ( idhdl  h)
static

Definition at line 362 of file asciiLink.cc.

363 {
364  int type = IDTYP(h);
365 
366  switch(type)
367  {
368  case LIST_CMD:
369  {
370  lists l = IDLIST(h);
371  int i, nl = l->nr + 1;
372 
373  for (i=0; i<nl; i++)
374  if (GetIdString((idhdl) &(l->m[i])) == NULL) return NULL;
375  }
376  #ifdef SINGULAR_4_1
377  case CRING_CMD:
378  case CNUMBER_CMD:
379  case CMATRIX_CMD:
380  #endif
381  case BIGINT_CMD:
382  case PACKAGE_CMD:
383  case INT_CMD:
384  case INTVEC_CMD:
385  case INTMAT_CMD:
386  case STRING_CMD:
387  case RING_CMD:
388  case QRING_CMD:
389  case PROC_CMD:
390  case NUMBER_CMD:
391  case POLY_CMD:
392  case IDEAL_CMD:
393  case VECTOR_CMD:
394  case MODUL_CMD:
395  case MATRIX_CMD:
396  return Tok2Cmdname(type);
397 
398  case MAP_CMD:
399  case LINK_CMD:
400  return NULL;
401 
402  default:
403  Warn("Error dump data of type %s", Tok2Cmdname(IDTYP(h)));
404  return NULL;
405  }
406 }
#define IDLIST(a)
Definition: ipid.h:134
sleftv * m
Definition: lists.h:45
Definition: tok.h:94
Definition: lists.h:22
Definition: tok.h:38
Definition: idrec.h:34
#define IDTYP(a)
Definition: ipid.h:116
Definition: tok.h:55
int i
Definition: cfEzgcd.cc:123
Definition: tok.h:99
int nr
Definition: lists.h:43
Definition: tok.h:115
#define NULL
Definition: omList.c:10
const char * Tok2Cmdname(int tok)
Definition: gentable.cc:128
Definition: tok.h:116
Definition: tok.h:155
int l
Definition: cfEzgcd.cc:94
#define Warn
Definition: emacs.cc:80

§ slCloseAscii()

BOOLEAN slCloseAscii ( si_link  l)

Definition at line 102 of file asciiLink.cc.

103 {
105  if (l->name[0] != '\0')
106  {
107  return (fclose((FILE *)l->data)!=0);
108  }
109  return FALSE;
110 }
#define FALSE
Definition: auxiliary.h:97
int l
Definition: cfEzgcd.cc:94

§ slDumpAscii()

BOOLEAN slDumpAscii ( si_link  l)

Definition at line 213 of file asciiLink.cc.

214 {
215  FILE *fd = (FILE *) l->data;
216  idhdl h = IDROOT, rh = currRingHdl;
217  char **list_of_libs=NULL;
218  BOOLEAN status = DumpAscii(fd, h, &list_of_libs);
219 
220  if (! status ) status = DumpAsciiMaps(fd, h, NULL);
221 
222  if (currRingHdl != rh) rSetHdl(rh);
223  fprintf(fd, "option(set, intvec(%d, %d));\n", si_opt_1, si_opt_2);
224  char **p=list_of_libs;
225  if (p!=NULL)
226  {
227  while((*p!=NULL) && (*p!=(char*)1))
228  {
229  fprintf(fd,"load(\"%s\",\"try\");\n",*p);
230  p++;
231  }
232  omFree(list_of_libs);
233  }
234  fprintf(fd, "RETURN();\n");
235  fflush(fd);
236 
237  return status;
238 }
int status int fd
Definition: si_signals.h:59
unsigned si_opt_1
Definition: options.c:5
return P p
Definition: myNF.cc:203
#define IDROOT
Definition: ipid.h:20
Definition: idrec.h:34
#define omFree(addr)
Definition: omAllocDecl.h:261
idhdl currRingHdl
Definition: ipid.cc:65
#define NULL
Definition: omList.c:10
int * status
Definition: si_signals.h:51
void rSetHdl(idhdl h)
Definition: ipshell.cc:5017
unsigned si_opt_2
Definition: options.c:6
static Poly * h
Definition: janet.cc:978
int BOOLEAN
Definition: auxiliary.h:88
int l
Definition: cfEzgcd.cc:94

§ slGetDumpAscii()

BOOLEAN slGetDumpAscii ( si_link  l)

Definition at line 540 of file asciiLink.cc.

541 {
542  if (l->name[0] == '\0')
543  {
544  WerrorS("getdump: Can not get dump from stdin");
545  return TRUE;
546  }
547  else
548  {
549  BOOLEAN status = newFile(l->name);
550  if (status)
551  return TRUE;
552 
553  int old_echo=si_echo;
554  si_echo=0;
555 
556  status=yyparse();
557 
558  si_echo=old_echo;
559 
560  if (status)
561  return TRUE;
562  else
563  {
564  // lets reset the file pointer to the end to reflect that
565  // we are finished with reading
566  FILE *f = (FILE *) l->data;
567  fseek(f, 0L, SEEK_END);
568  return FALSE;
569  }
570  }
571 }
#define FALSE
Definition: auxiliary.h:97
#define TRUE
Definition: auxiliary.h:101
void WerrorS(const char *s)
Definition: feFopen.cc:24
FILE * f
Definition: checklibs.c:7
int yyparse(void)
Definition: grammar.cc:2101
#define SEEK_END
Definition: mod2.h:119
int * status
Definition: si_signals.h:51
BOOLEAN newFile(char *fname, FILE *f)
Definition: fevoices.cc:129
int BOOLEAN
Definition: auxiliary.h:88
int l
Definition: cfEzgcd.cc:94
int si_echo
Definition: febase.cc:41

§ slOpenAscii()

BOOLEAN slOpenAscii ( si_link  l,
short  flag,
leftv   
)

Definition at line 41 of file asciiLink.cc.

42 {
43  const char *mode;
44  if (flag & SI_LINK_OPEN)
45  {
46  if (l->mode[0] != '\0' && (strcmp(l->mode, "r") == 0))
47  flag = SI_LINK_READ;
48  else flag = SI_LINK_WRITE;
49  }
50 
51  if (flag == SI_LINK_READ) mode = "r";
52  else if (strcmp(l->mode, "w") == 0) mode = "w";
53  else mode = "a";
54 
55 
56  if (l->name[0] == '\0')
57  {
58  // stdin or stdout
59  if (flag == SI_LINK_READ)
60  {
61  l->data = (void *) stdin;
62  mode = "r";
63  }
64  else
65  {
66  l->data = (void *) stdout;
67  mode = "a";
68  }
69  }
70  else
71  {
72  // normal ascii link to a file
73  FILE *outfile;
74  char *filename=l->name;
75 
76  if(filename[0]=='>')
77  {
78  if (filename[1]=='>')
79  {
80  filename+=2;
81  mode = "a";
82  }
83  else
84  {
85  filename++;
86  mode="w";
87  }
88  }
89  outfile=myfopen(filename,mode);
90  if (outfile!=NULL)
91  l->data = (void *) outfile;
92  else
93  return TRUE;
94  }
95 
96  omFree(l->mode);
97  l->mode = omStrDup(mode);
98  SI_LINK_SET_OPEN_P(l, flag);
99  return FALSE;
100 }
#define FALSE
Definition: auxiliary.h:97
#define TRUE
Definition: auxiliary.h:101
#define omFree(addr)
Definition: omAllocDecl.h:261
FILE * myfopen(const char *path, const char *mode)
Definition: feFopen.cc:167
#define NULL
Definition: omList.c:10
int l
Definition: cfEzgcd.cc:94
#define omStrDup(s)
Definition: omAllocDecl.h:263

§ slReadAscii()

leftv slReadAscii ( si_link  l)

Definition at line 146 of file asciiLink.cc.

147 {
148  sleftv tmp;
149  memset(&tmp,0,sizeof(sleftv));
150  tmp.rtyp=STRING_CMD;
151  tmp.data=(void*) "? ";
152  return slReadAscii2(l,&tmp);
153 }
Class used for (list of) interpreter objects.
Definition: subexpr.h:84
void * data
Definition: subexpr.h:90
int rtyp
Definition: subexpr.h:93
int l
Definition: cfEzgcd.cc:94

§ slReadAscii2()

leftv slReadAscii2 ( si_link  l,
leftv  pr 
)

Definition at line 112 of file asciiLink.cc.

113 {
114  FILE * fp=(FILE *)l->data;
115  char * buf=NULL;
116  if (fp!=NULL && l->name[0] != '\0')
117  {
118  fseek(fp,0L,SEEK_END);
119  long len=ftell(fp);
120  fseek(fp,0L,SEEK_SET);
121  buf=(char *)omAlloc((int)len+1);
122  if (BVERBOSE(V_READING))
123  Print("//Reading %ld chars\n",len);
124  myfread( buf, len, 1, fp);
125  buf[len]='\0';
126  }
127  else
128  {
129  if (pr->Typ()==STRING_CMD)
130  {
131  buf=(char *)omAlloc(80);
132  fe_fgets_stdin((char *)pr->Data(),buf,80);
133  }
134  else
135  {
136  WerrorS("read(<link>,<string>) expected");
137  buf=omStrDup("");
138  }
139  }
141  v->rtyp=STRING_CMD;
142  v->data=buf;
143  return v;
144 }
char *(* fe_fgets_stdin)(const char *pr, char *s, int size)
Definition: feread.cc:33
Class used for (list of) interpreter objects.
Definition: subexpr.h:84
#define Print
Definition: emacs.cc:83
CanonicalForm fp
Definition: cfModGcd.cc:4043
if(0 > strat->sl)
Definition: myNF.cc:73
sleftv * leftv
Definition: structs.h:60
void WerrorS(const char *s)
Definition: feFopen.cc:24
int Typ()
Definition: subexpr.cc:979
#define omAlloc(size)
Definition: omAllocDecl.h:210
void * data
Definition: subexpr.h:90
size_t myfread(void *ptr, size_t size, size_t nmemb, FILE *stream)
Definition: feFopen.cc:195
int status int void * buf
Definition: si_signals.h:59
omBin sleftv_bin
Definition: subexpr.cc:50
#define V_READING
Definition: options.h:44
#define BVERBOSE(a)
Definition: options.h:33
#define omAlloc0Bin(bin)
Definition: omAllocDecl.h:206
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
#define SEEK_END
Definition: mod2.h:119
#define NULL
Definition: omList.c:10
int rtyp
Definition: subexpr.h:93
void * Data()
Definition: subexpr.cc:1121
#define SEEK_SET
Definition: mod2.h:123
int l
Definition: cfEzgcd.cc:94
#define omStrDup(s)
Definition: omAllocDecl.h:263

§ slStandardInit()

void slStandardInit ( )

Definition at line 574 of file asciiLink.cc.

575 {
576  si_link_extension s;
579  si_link_root->Close=slCloseAscii;
580  si_link_root->Kill=NULL;
582  si_link_root->Read2=slReadAscii2;
583  si_link_root->Write=slWriteAscii;
585  si_link_root->GetDump=slGetDumpAscii;
586  si_link_root->Status=slStatusAscii;
587  si_link_root->type="ASCII";
588  s = si_link_root;
589  s->next = NULL;
590 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
#define omAlloc0Bin(bin)
Definition: omAllocDecl.h:206
#define NULL
Definition: omList.c:10

§ slStatusAscii()

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

Definition at line 196 of file asciiLink.cc.

197 {
198  if (strcmp(request, "read") == 0)
199  {
200  if (SI_LINK_R_OPEN_P(l)) return "ready";
201  else return "not ready";
202  }
203  else if (strcmp(request, "write") == 0)
204  {
205  if (SI_LINK_W_OPEN_P(l)) return "ready";
206  else return "not ready";
207  }
208  else return "unknown status request";
209 }
int l
Definition: cfEzgcd.cc:94

§ slWriteAscii()

BOOLEAN slWriteAscii ( si_link  l,
leftv  v 
)

Definition at line 155 of file asciiLink.cc.

156 {
157  FILE *outfile=(FILE *)l->data;
158  BOOLEAN err=FALSE;
159  char *s;
160  while (v!=NULL)
161  {
162  switch(v->Typ())
163  {
164  case IDEAL_CMD:
165  case MODUL_CMD:
166  case MATRIX_CMD:
167  {
168  ideal I=(ideal)v->Data();
169  for(int i=0;i<IDELEMS(I);i++)
170  {
171  fprintf(outfile,"%s",pString(I->m[i]));
172  if (i<IDELEMS(I)-1) fprintf(outfile,",");
173  }
174  break;
175  }
176  default:
177  s = v->String();
178  // free v ??
179  if (s!=NULL)
180  {
181  fprintf(outfile,"%s\n",s);
182  omFree((ADDRESS)s);
183  }
184  else
185  {
186  WerrorS("cannot convert to string");
187  err=TRUE;
188  }
189  }
190  v = v->next;
191  }
192  fflush(outfile);
193  return err;
194 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
char * pString(poly p)
Definition: polys.h:289
#define FALSE
Definition: auxiliary.h:97
#define TRUE
Definition: auxiliary.h:101
void * ADDRESS
Definition: auxiliary.h:118
void WerrorS(const char *s)
Definition: feFopen.cc:24
int Typ()
Definition: subexpr.cc:979
char * String(void *d=NULL, BOOLEAN typed=FALSE, int dim=1)
Called for conversion to string (used by string(..), write(..),..)
Definition: subexpr.cc:723
#define omFree(addr)
Definition: omAllocDecl.h:261
while(1)
Definition: libparse.cc:1442
int i
Definition: cfEzgcd.cc:123
#define IDELEMS(i)
Definition: simpleideals.h:24
leftv next
Definition: subexpr.h:88
#define NULL
Definition: omList.c:10
void * Data()
Definition: subexpr.cc:1121
int BOOLEAN
Definition: auxiliary.h:88
int l
Definition: cfEzgcd.cc:94

Variable Documentation

§ si_link_root

si_link_extension si_link_root

Definition at line 51 of file silink.cc.