Data Structures | Macros | Typedefs | Functions | Variables
silink.h File Reference
#include <misc/auxiliary.h>
#include <kernel/structs.h>
#include <Singular/links/sing_dbm.h>
#include <Singular/lists.h>
#include <Singular/attrib.h>
#include <omalloc/omalloc.h>

Go to the source code of this file.

Data Structures

Macros

#define SI_LINK_CLOSE   0
 
#define SI_LINK_OPEN   1
 
#define SI_LINK_READ   2
 
#define SI_LINK_WRITE   4
 
#define SI_LINK_CLOSE_P(l)   (!(l)->flags)
 
#define SI_LINK_OPEN_P(l)   ((l)->flags & SI_LINK_OPEN)
 
#define SI_LINK_W_OPEN_P(l)   ((l)->flags & SI_LINK_WRITE)
 
#define SI_LINK_R_OPEN_P(l)   ((l)->flags & SI_LINK_READ)
 
#define SI_LINK_RW_OPEN_P(l)   (SI_LINK_W_OPEN_P(l) && SI_LINK_R_OPEN_P(l))
 
#define SI_LINK_SET_CLOSE_P(l)   ((l)->flags = SI_LINK_CLOSE)
 
#define SI_LINK_SET_OPEN_P(l, flag)   ((l)->flags |= SI_LINK_OPEN |flag)
 
#define SI_LINK_SET_W_OPEN_P(l)   ((l)->flags |= (SI_LINK_OPEN | SI_LINK_WRITE))
 
#define SI_LINK_SET_R_OPEN_P(l)   ((l)->flags |= (SI_LINK_OPEN | SI_LINK_READ))
 
#define SI_LINK_SET_RW_OPEN_P(l)   ((l)->flags |= (SI_LINK_OPEN | SI_LINK_READ | SI_LINK_WRITE))
 

Typedefs

typedef ip_link * si_link
 
typedef BOOLEAN(* slOpenProc) (si_link l, short flag, leftv h)
 
typedef BOOLEAN(* slWriteProc) (si_link l, leftv lv)
 
typedef BOOLEAN(* slCloseProc) (si_link l)
 
typedef BOOLEAN(* slPrepCloseProc) (si_link l)
 
typedef BOOLEAN(* slKillProc) (si_link l)
 
typedef leftv(* slReadProc) (si_link l)
 
typedef leftv(* slRead2Proc) (si_link l, leftv a)
 
typedef BOOLEAN(* slDumpProc) (si_link l)
 
typedef BOOLEAN(* slGetDumpProc) (si_link l)
 
typedef const char *(* slStatusProc) (si_link l, const char *request)
 
typedef BOOLEAN(* slSetRingProc) (si_link l, ring r, BOOLEAN send)
 
typedef link_structlink_list
 

Functions

BOOLEAN slOpen (si_link l, short flag, leftv h)
 
BOOLEAN slClose (si_link l)
 
BOOLEAN slPrepClose (si_link l)
 
leftv slRead (si_link l, leftv a=NULL)
 
BOOLEAN slWrite (si_link l, leftv v)
 
BOOLEAN slDump (si_link l)
 
BOOLEAN slGetDump (si_link l)
 
const char * slStatus (si_link l, const char *request)
 
BOOLEAN slInit (si_link l, char *str)
 
void slKill (si_link l)
 
void slCleanUp (si_link l)
 
void slStandardInit ()
 
si_link slCopy (si_link l)
 
char * slString (si_link l)
 
int slStatusSsiL (lists L, int timeout)
 
int ssiBatch (const char *host, const char *port)
 

Variables

omBin s_si_link_extension_bin
 
omBin sip_link_bin
 
omBin ip_link_bin
 
link_list ssiToBeClosed
 
volatile BOOLEAN ssiToBeClosed_inactive
 

Data Structure Documentation

struct s_si_link_extension

Definition at line 35 of file silink.h.

Data Fields
slCloseProc Close
slDumpProc Dump
slGetDumpProc GetDump
slKillProc Kill
si_link_extension next
slOpenProc Open
slPrepCloseProc PrepClose
slReadProc Read
slRead2Proc Read2
slSetRingProc SetRing
slStatusProc Status
const char * type
slWriteProc Write
struct sip_link

Definition at line 52 of file silink.h.

Data Fields
void * data
BITSET flags
si_link_extension m
char * mode
char * name
short ref
struct link_struct

Definition at line 120 of file silink.h.

Data Fields
si_link l
void * next
leftv u

Macro Definition Documentation

#define SI_LINK_CLOSE   0

Definition at line 63 of file silink.h.

#define SI_LINK_CLOSE_P (   l)    (!(l)->flags)

Definition at line 69 of file silink.h.

#define SI_LINK_OPEN   1

Definition at line 64 of file silink.h.

#define SI_LINK_OPEN_P (   l)    ((l)->flags & SI_LINK_OPEN)

Definition at line 70 of file silink.h.

#define SI_LINK_R_OPEN_P (   l)    ((l)->flags & SI_LINK_READ)

Definition at line 72 of file silink.h.

#define SI_LINK_READ   2

Definition at line 65 of file silink.h.

#define SI_LINK_RW_OPEN_P (   l)    (SI_LINK_W_OPEN_P(l) && SI_LINK_R_OPEN_P(l))

Definition at line 73 of file silink.h.

#define SI_LINK_SET_CLOSE_P (   l)    ((l)->flags = SI_LINK_CLOSE)

Definition at line 75 of file silink.h.

#define SI_LINK_SET_OPEN_P (   l,
  flag 
)    ((l)->flags |= SI_LINK_OPEN |flag)

Definition at line 76 of file silink.h.

#define SI_LINK_SET_R_OPEN_P (   l)    ((l)->flags |= (SI_LINK_OPEN | SI_LINK_READ))

Definition at line 78 of file silink.h.

#define SI_LINK_SET_RW_OPEN_P (   l)    ((l)->flags |= (SI_LINK_OPEN | SI_LINK_READ | SI_LINK_WRITE))

Definition at line 79 of file silink.h.

#define SI_LINK_SET_W_OPEN_P (   l)    ((l)->flags |= (SI_LINK_OPEN | SI_LINK_WRITE))

Definition at line 77 of file silink.h.

#define SI_LINK_W_OPEN_P (   l)    ((l)->flags & SI_LINK_WRITE)

Definition at line 71 of file silink.h.

#define SI_LINK_WRITE   4

Definition at line 66 of file silink.h.

Typedef Documentation

Definition at line 127 of file silink.h.

typedef ip_link* si_link

Definition at line 19 of file silink.h.

typedef BOOLEAN(* slCloseProc) (si_link l)

Definition at line 25 of file silink.h.

typedef BOOLEAN(* slDumpProc) (si_link l)

Definition at line 30 of file silink.h.

typedef BOOLEAN(* slGetDumpProc) (si_link l)

Definition at line 31 of file silink.h.

typedef BOOLEAN(* slKillProc) (si_link l)

Definition at line 27 of file silink.h.

typedef BOOLEAN(* slOpenProc) (si_link l, short flag, leftv h)

Definition at line 23 of file silink.h.

typedef BOOLEAN(* slPrepCloseProc) (si_link l)

Definition at line 26 of file silink.h.

typedef leftv(* slRead2Proc) (si_link l, leftv a)

Definition at line 29 of file silink.h.

typedef leftv(* slReadProc) (si_link l)

Definition at line 28 of file silink.h.

typedef BOOLEAN(* slSetRingProc) (si_link l, ring r, BOOLEAN send)

Definition at line 33 of file silink.h.

typedef const char*(* slStatusProc) (si_link l, const char *request)

Definition at line 32 of file silink.h.

typedef BOOLEAN(* slWriteProc) (si_link l, leftv lv)

Definition at line 24 of file silink.h.

Function Documentation

void slCleanUp ( si_link  l)

Definition at line 132 of file silink.cc.

133 {
134  defer_shutdown++;
135  (l->ref)--;
136  if (l->ref == 0)
137  {
138  if (SI_LINK_OPEN_P(l))
139  {
140  if (l->m->Close != NULL) l->m->Close(l);
141  }
142  if ((l->data != NULL) && (l->m->Kill != NULL)) l->m->Kill(l);
143  omFree((ADDRESS)l->name);
144  omFree((ADDRESS)l->mode);
145  memset((void *) l, 0, sizeof(ip_link));
146  }
147  defer_shutdown--;
148  if (!defer_shutdown && do_shutdown) m2_end(1);
149 }
void m2_end(int i)
Definition: misc_ip.cc:1075
void * ADDRESS
Definition: auxiliary.h:161
volatile BOOLEAN do_shutdown
Definition: cntrlc.cc:84
#define omFree(addr)
Definition: omAllocDecl.h:261
#define NULL
Definition: omList.c:10
volatile int defer_shutdown
Definition: cntrlc.cc:85
int l
Definition: cfEzgcd.cc:94
BOOLEAN slClose ( si_link  l)

Definition at line 247 of file silink.cc.

248 {
249 
250  if(! SI_LINK_OPEN_P(l))
251  return FALSE;
252 
253  defer_shutdown++;
254  BOOLEAN res = TRUE;
255  if (l->m->Close != NULL)
256  {
257  res = l->m->Close(l);
258  if (res)
259  Werror("close: Error for link of type: %s, mode: %s, name: %s",
260  l->m->type, l->mode, l->name);
261  }
262  defer_shutdown--;
263  if (!defer_shutdown && do_shutdown) m2_end(1);
264  return res;
265 }
#define FALSE
Definition: auxiliary.h:140
void m2_end(int i)
Definition: misc_ip.cc:1075
#define TRUE
Definition: auxiliary.h:144
poly res
Definition: myNF.cc:322
volatile BOOLEAN do_shutdown
Definition: cntrlc.cc:84
#define NULL
Definition: omList.c:10
volatile int defer_shutdown
Definition: cntrlc.cc:85
int BOOLEAN
Definition: auxiliary.h:131
void Werror(const char *fmt,...)
Definition: reporter.cc:199
int l
Definition: cfEzgcd.cc:94
si_link slCopy ( si_link  l)
inline

Definition at line 93 of file silink.h.

94 {
95  l->ref++;
96  return l;
97 }
int l
Definition: cfEzgcd.cc:94
BOOLEAN slDump ( si_link  l)

Definition at line 350 of file silink.cc.

351 {
352  BOOLEAN res;
353 
354  if(! SI_LINK_W_OPEN_P(l)) // open w ?
355  {
356  if (slOpen(l, SI_LINK_WRITE,NULL)) return TRUE;
357  }
358 
359  if(SI_LINK_W_OPEN_P(l))
360  { // now open w
361  if (l->m->Dump != NULL)
362  res = l->m->Dump(l);
363  else
364  res = TRUE;
365 
366  if (res)
367  Werror("dump: Error for link of type %s, mode: %s, name: %s",
368  l->m->type, l->mode, l->name);
369  if (!SI_LINK_R_OPEN_P(l)) slClose(l); // do not close r/w links
370  return res;
371  }
372  else
373  {
374  Werror("dump: Error to open link of type %s, mode: %s, name: %s for writing",
375  l->m->type, l->mode, l->name);
376  return TRUE;
377  }
378 }
#define TRUE
Definition: auxiliary.h:144
poly res
Definition: myNF.cc:322
#define NULL
Definition: omList.c:10
int BOOLEAN
Definition: auxiliary.h:131
void Werror(const char *fmt,...)
Definition: reporter.cc:199
int l
Definition: cfEzgcd.cc:94
BOOLEAN slGetDump ( si_link  l)

Definition at line 380 of file silink.cc.

381 {
382  BOOLEAN res;
383 
384  if(! SI_LINK_R_OPEN_P(l)) // open r ?
385  {
386  if (slOpen(l, SI_LINK_READ,NULL)) return TRUE;
387  }
388 
389  if(SI_LINK_R_OPEN_P(l))
390  { // now open r
391  if (l->m->GetDump != NULL)
392  res = l->m->GetDump(l);
393  else
394  res = TRUE;
395 
396  if (res)
397  Werror("getdump: Error for link of type %s, mode: %s, name: %s",
398  l->m->type, l->mode, l->name);
399  //res|=slClose(l);
400  return res;
401  }
402  else
403  {
404  Werror("dump: Error open link of type %s, mode: %s, name: %s for reading",
405  l->m->type, l->mode, l->name);
406  return TRUE;
407  }
408 }
#define TRUE
Definition: auxiliary.h:144
poly res
Definition: myNF.cc:322
#define NULL
Definition: omList.c:10
int BOOLEAN
Definition: auxiliary.h:131
void Werror(const char *fmt,...)
Definition: reporter.cc:199
int l
Definition: cfEzgcd.cc:94
BOOLEAN slInit ( si_link  l,
char *  str 
)

Definition at line 53 of file silink.cc.

54 {
55  char *type = NULL, *mode = NULL, *name = NULL;
56  int i = 0, j;
57 
58  // set mode and type
59  if (istr != NULL)
60  {
61  // find the first colon char in istr
62  i = 0;
63  while (istr[i] != ':' && istr[i] != '\0') i++;
64  if (istr[i] == ':')
65  {
66  // if found, set type
67  if (i > 0)
68  {
69  istr[i] = '\0';
70  type = omStrDup(istr);
71  istr[i] = ':';
72  }
73  // and check for mode
74  j = ++i;
75  while (istr[j] != ' ' && istr[j] != '\0') j++;
76  if (j > i)
77  {
78  mode = omStrDup(&(istr[i]));
79  mode[j - i] = '\0';
80  }
81  // and for the name
82  while (istr[j] == ' '&& istr[j] != '\0') j++;
83  if (istr[j] != '\0') name = omStrDup(&(istr[j]));
84  }
85  else // no colon find -- string is entire name
86  {
87  j=0;
88  while (istr[j] == ' '&& istr[j] != '\0') j++;
89  if (istr[j] != '\0') name = omStrDup(&(istr[j]));
90  }
91  }
92 
93  // set the link extension
94  if (type != NULL)
95  {
96  si_link_extension s = si_link_root;
97  si_link_extension prev = s;
98 
99  while (strcmp(s->type, type) != 0)
100  {
101  if (s->next == NULL)
102  {
103  prev = s;
104  s = NULL;
105  break;
106  }
107  else
108  {
109  s = s->next;
110  }
111  }
112 
113  if (s != NULL)
114  l->m = s;
115  else
116  {
117  l->m = slTypeInit(prev, type);
118  }
119  omFree(type);
120  }
121  else
122  l->m = si_link_root;
123 
124  if (l->m == NULL) return TRUE;
125 
126  l->name = (name != NULL ? name : omStrDup(""));
127  l->mode = (mode != NULL ? mode : omStrDup(""));
128  l->ref = 1;
129  return FALSE;
130 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
#define FALSE
Definition: auxiliary.h:140
#define TRUE
Definition: auxiliary.h:144
int j
Definition: myNF.cc:70
#define omFree(addr)
Definition: omAllocDecl.h:261
int i
Definition: cfEzgcd.cc:123
char name(const Variable &v)
Definition: variable.h:95
#define NULL
Definition: omList.c:10
int l
Definition: cfEzgcd.cc:94
#define omStrDup(s)
Definition: omAllocDecl.h:263
void slKill ( si_link  l)

Definition at line 151 of file silink.cc.

152 {
153  defer_shutdown++;
154  slCleanUp(l);
155  if ((l!=NULL) &&(l->ref == 0))
157  defer_shutdown--;
158  if (!defer_shutdown && do_shutdown) m2_end(1);
159 }
void m2_end(int i)
Definition: misc_ip.cc:1075
void * ADDRESS
Definition: auxiliary.h:161
volatile BOOLEAN do_shutdown
Definition: cntrlc.cc:84
#define NULL
Definition: omList.c:10
volatile int defer_shutdown
Definition: cntrlc.cc:85
#define omFreeBin(addr, bin)
Definition: omAllocDecl.h:259
int l
Definition: cfEzgcd.cc:94
BOOLEAN slOpen ( si_link  l,
short  flag,
leftv  h 
)

Definition at line 199 of file silink.cc.

200 {
201  BOOLEAN res = TRUE;
202  if (l!=NULL)
203  {
204 
205  if (l->m == NULL) slInit(l, ((char*)""));
206 
207  if (feOptValue(FE_OPT_NO_SHELL)) {WerrorS("no links allowed");return TRUE;}
208 
209  const char *c="_";;
210  if (h!=NULL) c=h->Name();
211 
212  if (SI_LINK_OPEN_P(l))
213  {
214  Warn("open: link of type: %s, mode: %s, name: %s is already open",
215  l->m->type, l->mode, l->name);
216  return FALSE;
217  }
218  else if (l->m->Open != NULL)
219  {
220  res = l->m->Open(l, flag, h);
221  if (res)
222  Werror("open: Error for link %s of type: %s, mode: %s, name: %s",
223  c, l->m->type, l->mode, l->name);
224  }
225  if (l->m->SetRing==NULL) l->m->SetRing=slSetRingDummy;
226  }
227  return res;
228 }
static void * feOptValue(feOptIndex opt)
Definition: feOpt.h:40
#define FALSE
Definition: auxiliary.h:140
#define TRUE
Definition: auxiliary.h:144
void WerrorS(const char *s)
Definition: feFopen.cc:24
const char * Name()
Definition: subexpr.h:121
poly res
Definition: myNF.cc:322
#define NULL
Definition: omList.c:10
int BOOLEAN
Definition: auxiliary.h:131
void Werror(const char *fmt,...)
Definition: reporter.cc:199
int l
Definition: cfEzgcd.cc:94
#define Warn
Definition: emacs.cc:80
BOOLEAN slPrepClose ( si_link  l)

Definition at line 230 of file silink.cc.

231 {
232 
233  if(! SI_LINK_OPEN_P(l))
234  return FALSE;
235 
236  BOOLEAN res = TRUE;
237  if (l->m->PrepClose != NULL)
238  {
239  res = l->m->PrepClose(l);
240  if (res)
241  Werror("close: Error for link of type: %s, mode: %s, name: %s",
242  l->m->type, l->mode, l->name);
243  }
244  return res;
245 }
#define FALSE
Definition: auxiliary.h:140
#define TRUE
Definition: auxiliary.h:144
poly res
Definition: myNF.cc:322
#define NULL
Definition: omList.c:10
int BOOLEAN
Definition: auxiliary.h:131
void Werror(const char *fmt,...)
Definition: reporter.cc:199
int l
Definition: cfEzgcd.cc:94
leftv slRead ( si_link  l,
leftv  a = NULL 
)

Definition at line 267 of file silink.cc.

268 {
269  leftv v = NULL;
270  if( ! SI_LINK_R_OPEN_P(l)) // open r ?
271  {
272 #ifdef HAVE_DBM
273 #ifdef USE_GDBM
274  if (! SI_LINK_CLOSE_P(l))
275  {
276  if (slClose(l)) return NULL;
277  }
278 #endif
279 #endif
280  if (slOpen(l, SI_LINK_READ,NULL)) return NULL;
281  }
282 
283  if (SI_LINK_R_OPEN_P(l))
284  { // open r
285  if (a==NULL)
286  {
287  if (l->m->Read != NULL) v = l->m->Read(l);
288  }
289  else
290  {
291  if (l->m->Read2 != NULL) v = l->m->Read2(l,a);
292  }
293  }
294  else
295  {
296  Werror("read: Error to open link of type %s, mode: %s, name: %s for reading",
297  l->m->type, l->mode, l->name);
298  return NULL;
299  }
300 
301  // here comes the eval:
302  if (v != NULL)
303  {
304  if (v->Eval() && !errorreported)
305  WerrorS("eval: failed");
306  }
307  else
308  Werror("read: Error for link of type %s, mode: %s, name: %s",
309  l->m->type, l->mode, l->name);
310  return v;
311 }
Class used for (list of) interpreter objects.
Definition: subexpr.h:83
int Eval()
Definition: subexpr.cc:1735
void WerrorS(const char *s)
Definition: feFopen.cc:24
short errorreported
Definition: feFopen.cc:23
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
#define NULL
Definition: omList.c:10
void Werror(const char *fmt,...)
Definition: reporter.cc:199
int l
Definition: cfEzgcd.cc:94
void slStandardInit ( )

Definition at line 487 of file asciiLink.cc.

488 {
489  si_link_extension s;
492  si_link_root->Close=slCloseAscii;
493  si_link_root->Kill=NULL;
495  si_link_root->Read2=slReadAscii2;
496  si_link_root->Write=slWriteAscii;
498  si_link_root->GetDump=slGetDumpAscii;
499  si_link_root->Status=slStatusAscii;
500  si_link_root->type="ASCII";
501  s = si_link_root;
502  s->next = NULL;
503 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
#define omAlloc0Bin(bin)
Definition: omAllocDecl.h:206
#define NULL
Definition: omList.c:10
const char* slStatus ( si_link  l,
const char *  request 
)

Definition at line 161 of file silink.cc.

162 {
163  if (l == NULL) return "empty link";
164  else if (l->m == NULL) return "unknown link type";
165  else if (strcmp(request, "type") == 0) return l->m->type;
166  else if (strcmp(request, "mode") == 0) return l->mode;
167  else if (strcmp(request, "name") == 0) return l->name;
168  else if (strcmp(request, "exists") ==0)
169  {
170  struct stat buf;
171  if (si_lstat(l->name,&buf)==0) return "yes";
172  else return "no";
173  }
174  else if (strcmp(request, "open") == 0)
175  {
176  if (SI_LINK_OPEN_P(l)) return "yes";
177  else return "no";
178  }
179  else if (strcmp(request, "openread") == 0)
180  {
181  if (SI_LINK_R_OPEN_P(l)) return "yes";
182  else return "no";
183  }
184  else if (strcmp(request, "openwrite") == 0)
185  {
186  if (SI_LINK_W_OPEN_P(l)) return "yes";
187  else return "no";
188  }
189  else if (l->m->Status == NULL) return "unknown status request";
190  else return l->m->Status(l, request);
191 }
int status int void * buf
Definition: si_signals.h:59
#define NULL
Definition: omList.c:10
int l
Definition: cfEzgcd.cc:94
int slStatusSsiL ( lists  L,
int  timeout 
)

Definition at line 1595 of file ssiLink.cc.

1596 {
1597 // input: L: a list with links of type
1598 // ssi-connect, ssi-fork, ssi-tcp, MPtcp-fork or MPtcp-launch.
1599 // Note: Not every entry in L must be set.
1600 // timeout: timeout for select in micro-seconds
1601 // or -1 for infinity
1602 // or 0 for polling
1603 // returns: ERROR (via Werror): L has wrong elements or link not open
1604 // -2: select returns an error
1605 // -1: the read state of all links is eof
1606 // 0: timeout (or polling): none ready,
1607 // i>0: (at least) L[i] is ready
1608  si_link l;
1609  ssiInfo *d;
1610  int d_fd;
1611  fd_set mask, fdmask;
1612  FD_ZERO(&fdmask);
1613  FD_ZERO(&mask);
1614  int max_fd=0; /* 1 + max fd in fd_set */
1615 
1616  /* timeout */
1617  struct timeval wt;
1618  struct timeval *wt_ptr=&wt;
1619  int startingtime = getRTimer()/TIMER_RESOLUTION; // in seconds
1620  if (timeout== -1)
1621  {
1622  wt_ptr=NULL;
1623  }
1624  else
1625  {
1626  wt.tv_sec = timeout / 1000000;
1627  wt.tv_usec = timeout % 1000000;
1628  }
1629 
1630  /* auxiliary variables */
1631  int i;
1632  int j;
1633  int k;
1634  int s;
1635  char fdmaskempty;
1636 
1637  /* check the links and fill in fdmask */
1638  /* check ssi links for ungetc_buf */
1639  for(i=L->nr; i>=0; i--)
1640  {
1641  if (L->m[i].Typ()!=DEF_CMD)
1642  {
1643  if (L->m[i].Typ()!=LINK_CMD)
1644  { WerrorS("all elements must be of type link"); return -2;}
1645  l=(si_link)L->m[i].Data();
1646  if(SI_LINK_OPEN_P(l)==0)
1647  { WerrorS("all links must be open"); return -2;}
1648  if (((strcmp(l->m->type,"ssi")!=0) && (strcmp(l->m->type,"MPtcp")!=0))
1649  || ((strcmp(l->mode,"fork")!=0) && (strcmp(l->mode,"tcp")!=0)
1650  && (strcmp(l->mode,"launch")!=0) && (strcmp(l->mode,"connect")!=0)))
1651  {
1652  WerrorS("all links must be of type ssi:fork, ssi:tcp, ssi:connect");
1653  return -2;
1654  }
1655  if (strcmp(l->m->type,"ssi")==0)
1656  {
1657  d=(ssiInfo*)l->data;
1658  d_fd=d->fd_read;
1659  if (!s_isready(d->f_read))
1660  {
1661  FD_SET(d_fd, &fdmask);
1662  if (d_fd > max_fd) max_fd=d_fd;
1663  }
1664  else
1665  return i+1;
1666  }
1667  else
1668  {
1669  Werror("wrong link type >>%s<<",l->m->type);
1670  return -2;
1671  }
1672  }
1673  }
1674  max_fd++;
1675 
1676 do_select:
1677  /* copy fdmask to mask */
1678  FD_ZERO(&mask);
1679  for(k = 0; k < max_fd; k++)
1680  {
1681  if(FD_ISSET(k, &fdmask))
1682  {
1683  FD_SET(k, &mask);
1684  }
1685  }
1686 
1687  /* check with select: chars waiting: no -> not ready */
1688  s = si_select(max_fd, &mask, NULL, NULL, wt_ptr);
1689  if (s==-1)
1690  {
1691  WerrorS("error in select call");
1692  return -2; /*error*/
1693  }
1694  if (s==0)
1695  {
1696  return 0; /*poll: not ready */
1697  }
1698  else /* s>0, at least one ready (the number of fd which are ready is s)*/
1699  {
1700  j=0;
1701  while (j<=max_fd) { if (FD_ISSET(j,&mask)) break; j++; }
1702  for(i=L->nr; i>=0; i--)
1703  {
1704  if (L->m[i].rtyp==LINK_CMD)
1705  {
1706  l=(si_link)L->m[i].Data();
1707  if (strcmp(l->m->type,"ssi")==0)
1708  {
1709  d=(ssiInfo*)l->data;
1710  d_fd=d->fd_read;
1711  if(j==d_fd) break;
1712  }
1713  else
1714  {
1715  Werror("wrong link type >>%s<<",l->m->type);
1716  return -2;
1717  }
1718  }
1719  }
1720  // only ssi links:
1721  loop
1722  {
1723  /* yes: read 1 char*/
1724  /* if \n, check again with select else ungetc(c), ready*/
1725  /* setting: d: current ssiInfo, j current fd, i current entry in L*/
1726  int c=s_getc(d->f_read);
1727  //Print("try c=%d\n",c);
1728  if (c== -1) /* eof */
1729  {
1730  FD_CLR(j,&fdmask);
1731  fdmaskempty = 1;
1732  for(k = 0; k < max_fd; k++)
1733  {
1734  if(FD_ISSET(k, &fdmask))
1735  {
1736  fdmaskempty = 0;
1737  break;
1738  }
1739  }
1740  if(fdmaskempty)
1741  {
1742  return -1;
1743  }
1744  if(timeout != -1)
1745  {
1746  timeout = si_max(0,
1747  timeout - 1000000*(getRTimer()/TIMER_RESOLUTION - startingtime));
1748  wt.tv_sec = timeout / 1000000;
1749  wt.tv_usec = (timeout % 1000000);
1750  }
1751  goto do_select;
1752  }
1753 
1754  else if (isdigit(c))
1755  { s_ungetc(c,d->f_read); return i+1; }
1756  else if (c>' ')
1757  {
1758  Werror("unknown char in ssiLink(%d)",c);
1759  return -2;
1760  }
1761  /* else: next char */
1762  goto do_select;
1763  }
1764  }
1765 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
sleftv * m
Definition: lists.h:45
loop
Definition: myNF.cc:98
if(0 > strat->sl)
Definition: myNF.cc:73
int getRTimer()
Definition: timer.cc:172
void WerrorS(const char *s)
Definition: feFopen.cc:24
int k
Definition: cfEzgcd.cc:93
int Typ()
Definition: subexpr.cc:969
int s_getc(s_buff F)
Definition: s_buff.cc:66
#define TIMER_RESOLUTION
Definition: mod2.h:40
int j
Definition: myNF.cc:70
Definition: tok.h:58
void s_ungetc(int c, s_buff F)
Definition: s_buff.cc:107
static int si_max(const int a, const int b)
Definition: auxiliary.h:166
int i
Definition: cfEzgcd.cc:123
int nr
Definition: lists.h:43
Definition: tok.h:95
#define NULL
Definition: omList.c:10
int rtyp
Definition: subexpr.h:92
void * Data()
Definition: subexpr.cc:1111
int s_isready(s_buff F)
Definition: s_buff.cc:93
void Werror(const char *fmt,...)
Definition: reporter.cc:199
int l
Definition: cfEzgcd.cc:94
char* slString ( si_link  l)
inline

Definition at line 100 of file silink.h.

101 {
102  if (l->name != NULL)
103  {
104  return omStrDup(l->name);
105  }
106  else
107  {
108  return omStrDup("");
109  }
110 }
#define NULL
Definition: omList.c:10
int l
Definition: cfEzgcd.cc:94
#define omStrDup(s)
Definition: omAllocDecl.h:263
BOOLEAN slWrite ( si_link  l,
leftv  v 
)

Definition at line 313 of file silink.cc.

314 {
315  BOOLEAN res;
316 
317  if(! SI_LINK_W_OPEN_P(l)) // open w ?
318  {
319 #ifdef HAVE_DBM
320 #ifdef USE_GDBM
321  if (! SI_LINK_CLOSE_P(l))
322  {
323  if (slClose(l)) return TRUE;
324  }
325 #endif
326 #endif
327  if (slOpen(l, SI_LINK_WRITE,NULL)) return TRUE;
328  }
329 
330  if (SI_LINK_W_OPEN_P(l))
331  { // now open w
332  if (l->m->Write != NULL)
333  res = l->m->Write(l,v);
334  else
335  res = TRUE;
336 
337  if (res)
338  Werror("write: Error for link of type %s, mode: %s, name: %s",
339  l->m->type, l->mode, l->name);
340  return res;
341  }
342  else
343  {
344  Werror("write: Error to open link of type %s, mode: %s, name: %s for writing",
345  l->m->type, l->mode, l->name);
346  return TRUE;
347  }
348 }
#define TRUE
Definition: auxiliary.h:144
poly res
Definition: myNF.cc:322
#define NULL
Definition: omList.c:10
int BOOLEAN
Definition: auxiliary.h:131
void Werror(const char *fmt,...)
Definition: reporter.cc:199
int l
Definition: cfEzgcd.cc:94
int ssiBatch ( const char *  host,
const char *  port 
)

Definition at line 1767 of file ssiLink.cc.

1769 {
1771  char *buf=(char*)omAlloc(256);
1772  sprintf(buf,"ssi:connect %s:%s",host,port);
1773  slInit(l, buf);
1774  if (slOpen(l,SI_LINK_OPEN,NULL)) return 1;
1776 
1777  idhdl id = enterid(omStrDup("link_ll"), 0, LINK_CMD, &IDROOT, FALSE);
1778  IDLINK(id) = l;
1779 
1780  loop
1781  {
1782  leftv h=ssiRead1(l); /*contains an exit.... */
1783  if (feErrors != NULL && *feErrors != '\0')
1784  {
1785  // handle errors:
1786  PrintS(feErrors); /* currently quite simple */
1787  *feErrors = '\0';
1788  }
1789  ssiWrite(l,h);
1790  h->CleanUp();
1791  omFreeBin(h, sleftv_bin);
1792  }
1793  /* never reached*/
1794  exit(0);
1795 }
Class used for (list of) interpreter objects.
Definition: subexpr.h:83
#define IDLINK(a)
Definition: ipid.h:137
loop
Definition: myNF.cc:98
#define FALSE
Definition: auxiliary.h:140
#define IDROOT
Definition: ipid.h:20
#define omAlloc(size)
Definition: omAllocDecl.h:210
Definition: idrec.h:34
idhdl enterid(const char *s, int lev, int t, idhdl *root, BOOLEAN init, BOOLEAN search)
Definition: ipid.cc:259
char * feErrors
Definition: reporter.cc:47
int status int void * buf
Definition: si_signals.h:59
omBin sleftv_bin
Definition: subexpr.cc:50
void PrintS(const char *s)
Definition: reporter.cc:294
#define omAlloc0Bin(bin)
Definition: omAllocDecl.h:206
Definition: tok.h:95
#define NULL
Definition: omList.c:10
void CleanUp(ring r=currRing)
Definition: subexpr.cc:321
#define omFreeBin(addr, bin)
Definition: omAllocDecl.h:259
static Poly * h
Definition: janet.cc:978
int l
Definition: cfEzgcd.cc:94
#define omStrDup(s)
Definition: omAllocDecl.h:263

Variable Documentation

omBin ip_link_bin

Definition at line 47 of file silink.cc.

omBin s_si_link_extension_bin

Definition at line 45 of file silink.cc.

omBin sip_link_bin

Definition at line 46 of file silink.cc.

link_list ssiToBeClosed

Definition at line 82 of file ssiLink.cc.

volatile BOOLEAN ssiToBeClosed_inactive

Definition at line 83 of file ssiLink.cc.