My Project  UNKNOWN_GIT_VERSION
Data Structures | Macros | Typedefs | Functions | Variables
silink.h File Reference
#include "singularconfig.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 ()
 
static si_link slCopy (si_link l)
 
static 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

◆ s_si_link_extension

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

◆ sip_link

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

◆ link_struct

struct link_struct

Definition at line 120 of file silink.h.

Data Fields
si_link l
void * next
leftv u

Macro Definition Documentation

◆ SI_LINK_CLOSE

#define SI_LINK_CLOSE   0

Definition at line 63 of file silink.h.

◆ SI_LINK_CLOSE_P

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

Definition at line 69 of file silink.h.

◆ SI_LINK_OPEN

#define SI_LINK_OPEN   1

Definition at line 64 of file silink.h.

◆ SI_LINK_OPEN_P

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

Definition at line 70 of file silink.h.

◆ SI_LINK_R_OPEN_P

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

Definition at line 72 of file silink.h.

◆ SI_LINK_READ

#define SI_LINK_READ   2

Definition at line 65 of file silink.h.

◆ SI_LINK_RW_OPEN_P

#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.

◆ SI_LINK_SET_CLOSE_P

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

Definition at line 75 of file silink.h.

◆ SI_LINK_SET_OPEN_P

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

Definition at line 76 of file silink.h.

◆ SI_LINK_SET_R_OPEN_P

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

Definition at line 78 of file silink.h.

◆ SI_LINK_SET_RW_OPEN_P

#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.

◆ SI_LINK_SET_W_OPEN_P

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

Definition at line 77 of file silink.h.

◆ SI_LINK_W_OPEN_P

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

Definition at line 71 of file silink.h.

◆ SI_LINK_WRITE

#define SI_LINK_WRITE   4

Definition at line 66 of file silink.h.

Typedef Documentation

◆ link_list

Definition at line 127 of file silink.h.

◆ si_link

typedef ip_link* si_link

Definition at line 19 of file silink.h.

◆ slCloseProc

typedef BOOLEAN(* slCloseProc) (si_link l)

Definition at line 25 of file silink.h.

◆ slDumpProc

typedef BOOLEAN(* slDumpProc) (si_link l)

Definition at line 30 of file silink.h.

◆ slGetDumpProc

typedef BOOLEAN(* slGetDumpProc) (si_link l)

Definition at line 31 of file silink.h.

◆ slKillProc

typedef BOOLEAN(* slKillProc) (si_link l)

Definition at line 27 of file silink.h.

◆ slOpenProc

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

Definition at line 23 of file silink.h.

◆ slPrepCloseProc

typedef BOOLEAN(* slPrepCloseProc) (si_link l)

Definition at line 26 of file silink.h.

◆ slRead2Proc

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

Definition at line 29 of file silink.h.

◆ slReadProc

typedef leftv(* slReadProc) (si_link l)

Definition at line 28 of file silink.h.

◆ slSetRingProc

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

Definition at line 33 of file silink.h.

◆ slStatusProc

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

Definition at line 32 of file silink.h.

◆ slWriteProc

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

Definition at line 24 of file silink.h.

Function Documentation

◆ slCleanUp()

void slCleanUp ( si_link  l)

Definition at line 127 of file silink.cc.

128 {
129  defer_shutdown++;
130  (l->ref)--;
131  if (l->ref == 0)
132  {
133  if (SI_LINK_OPEN_P(l))
134  {
135  if (l->m->Close != NULL) l->m->Close(l);
136  }
137  if ((l->data != NULL) && (l->m->Kill != NULL)) l->m->Kill(l);
138  omFree((ADDRESS)l->name);
139  omFree((ADDRESS)l->mode);
140  memset((void *) l, 0, sizeof(ip_link));
141  }
142  defer_shutdown--;
143  if (!defer_shutdown && do_shutdown) m2_end(1);
144 }

◆ slClose()

BOOLEAN slClose ( si_link  l)

Definition at line 242 of file silink.cc.

243 {
244 
245  if(! SI_LINK_OPEN_P(l))
246  return FALSE;
247 
248  defer_shutdown++;
249  BOOLEAN res = TRUE;
250  if (l->m->Close != NULL)
251  {
252  res = l->m->Close(l);
253  if (res)
254  Werror("close: Error for link of type: %s, mode: %s, name: %s",
255  l->m->type, l->mode, l->name);
256  }
257  defer_shutdown--;
258  if (!defer_shutdown && do_shutdown) m2_end(1);
260  return res;
261 }

◆ slCopy()

static si_link slCopy ( si_link  l)
inlinestatic

Definition at line 93 of file silink.h.

94 {
95  l->ref++;
96  return l;
97 }

◆ slDump()

BOOLEAN slDump ( si_link  l)

Definition at line 346 of file silink.cc.

347 {
348  BOOLEAN res;
349 
350  if(! SI_LINK_W_OPEN_P(l)) // open w ?
351  {
352  if (slOpen(l, SI_LINK_WRITE,NULL)) return TRUE;
353  }
354 
355  if(SI_LINK_W_OPEN_P(l))
356  { // now open w
357  if (l->m->Dump != NULL)
358  res = l->m->Dump(l);
359  else
360  res = TRUE;
361 
362  if (res)
363  Werror("dump: Error for link of type %s, mode: %s, name: %s",
364  l->m->type, l->mode, l->name);
365  if (!SI_LINK_R_OPEN_P(l)) slClose(l); // do not close r/w links
366  return res;
367  }
368  else
369  {
370  Werror("dump: Error to open link of type %s, mode: %s, name: %s for writing",
371  l->m->type, l->mode, l->name);
372  return TRUE;
373  }
374 }

◆ slGetDump()

BOOLEAN slGetDump ( si_link  l)

Definition at line 376 of file silink.cc.

377 {
378  BOOLEAN res;
379 
380  if(! SI_LINK_R_OPEN_P(l)) // open r ?
381  {
382  if (slOpen(l, SI_LINK_READ,NULL)) return TRUE;
383  }
384 
385  if(SI_LINK_R_OPEN_P(l))
386  { // now open r
387  if (l->m->GetDump != NULL)
388  res = l->m->GetDump(l);
389  else
390  res = TRUE;
391 
392  if (res)
393  Werror("getdump: Error for link of type %s, mode: %s, name: %s",
394  l->m->type, l->mode, l->name);
395  //res|=slClose(l);
396  return res;
397  }
398  else
399  {
400  Werror("dump: Error open link of type %s, mode: %s, name: %s for reading",
401  l->m->type, l->mode, l->name);
402  return TRUE;
403  }
404 }

◆ slInit()

BOOLEAN slInit ( si_link  l,
char *  str 
)

Definition at line 48 of file silink.cc.

49 {
50  char *type = NULL, *mode = NULL, *name = NULL;
51  int i = 0, j;
52 
53  // set mode and type
54  if (istr != NULL)
55  {
56  // find the first colon char in istr
57  i = 0;
58  while (istr[i] != ':' && istr[i] != '\0') i++;
59  if (istr[i] == ':')
60  {
61  // if found, set type
62  if (i > 0)
63  {
64  istr[i] = '\0';
65  type = omStrDup(istr);
66  istr[i] = ':';
67  }
68  // and check for mode
69  j = ++i;
70  while (istr[j] != ' ' && istr[j] != '\0') j++;
71  if (j > i)
72  {
73  mode = omStrDup(&(istr[i]));
74  mode[j - i] = '\0';
75  }
76  // and for the name
77  while (istr[j] == ' '&& istr[j] != '\0') j++;
78  if (istr[j] != '\0') name = omStrDup(&(istr[j]));
79  }
80  else // no colon find -- string is entire name
81  {
82  j=0;
83  while (istr[j] == ' '&& istr[j] != '\0') j++;
84  if (istr[j] != '\0') name = omStrDup(&(istr[j]));
85  }
86  }
87 
88  // set the link extension
89  if (type != NULL)
90  {
91  si_link_extension s = si_link_root;
92  si_link_extension prev = s;
93 
94  while (strcmp(s->type, type) != 0)
95  {
96  if (s->next == NULL)
97  {
98  prev = s;
99  s = NULL;
100  break;
101  }
102  else
103  {
104  s = s->next;
105  }
106  }
107 
108  if (s != NULL)
109  l->m = s;
110  else
111  {
112  l->m = slTypeInit(prev, type);
113  }
114  omFree(type);
115  }
116  else
117  l->m = si_link_root;
118 
119  if (l->m == NULL) return TRUE;
120 
121  l->name = (name != NULL ? name : omStrDup(""));
122  l->mode = (mode != NULL ? mode : omStrDup(""));
123  l->ref = 1;
124  return FALSE;
125 }

◆ slKill()

void slKill ( si_link  l)

Definition at line 146 of file silink.cc.

147 {
148  defer_shutdown++;
149  slCleanUp(l);
150  if ((l!=NULL) &&(l->ref == 0))
152  defer_shutdown--;
153  if (!defer_shutdown && do_shutdown) m2_end(1);
154 }

◆ slOpen()

BOOLEAN slOpen ( si_link  l,
short  flag,
leftv  h 
)

Definition at line 194 of file silink.cc.

195 {
196  BOOLEAN res = TRUE;
197  if (l!=NULL)
198  {
199 
200  if (l->m == NULL) slInit(l, ((char*)""));
201 
202  if (feOptValue(FE_OPT_NO_SHELL)) {WerrorS("no links allowed");return TRUE;}
203 
204  const char *c="_";;
205  if (h!=NULL) c=h->Name();
206 
207  if (SI_LINK_OPEN_P(l))
208  {
209  Warn("open: link of type: %s, mode: %s, name: %s is already open",
210  l->m->type, l->mode, l->name);
211  return FALSE;
212  }
213  else if (l->m->Open != NULL)
214  {
215  res = l->m->Open(l, flag, h);
216  if (res)
217  Werror("open: Error for link %s of type: %s, mode: %s, name: %s",
218  c, l->m->type, l->mode, l->name);
219  }
220  if (l->m->SetRing==NULL) l->m->SetRing=slSetRingDummy;
221  }
222  return res;
223 }

◆ slPrepClose()

BOOLEAN slPrepClose ( si_link  l)

Definition at line 225 of file silink.cc.

226 {
227 
228  if(! SI_LINK_OPEN_P(l))
229  return FALSE;
230 
231  BOOLEAN res = TRUE;
232  if (l->m->PrepClose != NULL)
233  {
234  res = l->m->PrepClose(l);
235  if (res)
236  Werror("close: Error for link of type: %s, mode: %s, name: %s",
237  l->m->type, l->mode, l->name);
238  }
239  return res;
240 }

◆ slRead()

leftv slRead ( si_link  l,
leftv  a = NULL 
)

Definition at line 263 of file silink.cc.

264 {
265  leftv v = NULL;
266  if( ! SI_LINK_R_OPEN_P(l)) // open r ?
267  {
268 #ifdef HAVE_DBM
269 #ifdef USE_GDBM
270  if (! SI_LINK_CLOSE_P(l))
271  {
272  if (slClose(l)) return NULL;
273  }
274 #endif
275 #endif
276  if (slOpen(l, SI_LINK_READ,NULL)) return NULL;
277  }
278 
279  if (SI_LINK_R_OPEN_P(l))
280  { // open r
281  if (a==NULL)
282  {
283  if (l->m->Read != NULL) v = l->m->Read(l);
284  }
285  else
286  {
287  if (l->m->Read2 != NULL) v = l->m->Read2(l,a);
288  }
289  }
290  else
291  {
292  Werror("read: Error to open link of type %s, mode: %s, name: %s for reading",
293  l->m->type, l->mode, l->name);
294  return NULL;
295  }
296 
297  // here comes the eval:
298  if (v != NULL)
299  {
300  if (v->Eval() && !errorreported)
301  WerrorS("eval: failed");
302  }
303  else
304  Werror("read: Error for link of type %s, mode: %s, name: %s",
305  l->m->type, l->mode, l->name);
306  return v;
307 }

◆ slStandardInit()

void slStandardInit ( )

Definition at line 578 of file asciiLink.cc.

579 {
580  si_link_extension s;
583  si_link_root->Close=slCloseAscii;
584  si_link_root->Kill=NULL;
586  si_link_root->Read2=slReadAscii2;
587  si_link_root->Write=slWriteAscii;
589  si_link_root->GetDump=slGetDumpAscii;
590  si_link_root->Status=slStatusAscii;
591  si_link_root->type="ASCII";
592  s = si_link_root;
593  s->next = NULL;
594 }

◆ slStatus()

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

Definition at line 156 of file silink.cc.

157 {
158  if (l == NULL) return "empty link";
159  else if (l->m == NULL) return "unknown link type";
160  else if (strcmp(request, "type") == 0) return l->m->type;
161  else if (strcmp(request, "mode") == 0) return l->mode;
162  else if (strcmp(request, "name") == 0) return l->name;
163  else if (strcmp(request, "exists") ==0)
164  {
165  struct stat buf;
166  if (si_lstat(l->name,&buf)==0) return "yes";
167  else return "no";
168  }
169  else if (strcmp(request, "open") == 0)
170  {
171  if (SI_LINK_OPEN_P(l)) return "yes";
172  else return "no";
173  }
174  else if (strcmp(request, "openread") == 0)
175  {
176  if (SI_LINK_R_OPEN_P(l)) return "yes";
177  else return "no";
178  }
179  else if (strcmp(request, "openwrite") == 0)
180  {
181  if (SI_LINK_W_OPEN_P(l)) return "yes";
182  else return "no";
183  }
184  else if (l->m->Status == NULL) return "unknown status request";
185  else return l->m->Status(l, request);
186 }

◆ slStatusSsiL()

int slStatusSsiL ( lists  L,
int  timeout 
)

Definition at line 1658 of file ssiLink.cc.

1659 {
1660 // input: L: a list with links of type
1661 // ssi-connect, ssi-fork, ssi-tcp, MPtcp-fork or MPtcp-launch.
1662 // Note: Not every entry in L must be set.
1663 // timeout: timeout for select in micro-seconds
1664 // or -1 for infinity
1665 // or 0 for polling
1666 // returns: ERROR (via Werror): L has wrong elements or link not open
1667 // -2: select returns an error
1668 // -1: the read state of all links is eof
1669 // 0: timeout (or polling): none ready,
1670 // i>0: (at least) L[i] is ready
1671  si_link l;
1672  ssiInfo *d;
1673  int d_fd;
1674  fd_set mask, fdmask;
1675  FD_ZERO(&fdmask);
1676  FD_ZERO(&mask);
1677  int max_fd=0; /* 1 + max fd in fd_set */
1678 
1679  /* timeout */
1680  struct timeval wt;
1681  struct timeval *wt_ptr=&wt;
1682  int startingtime = getRTimer()/TIMER_RESOLUTION; // in seconds
1683  if (timeout== -1)
1684  {
1685  wt_ptr=NULL;
1686  }
1687  else
1688  {
1689  wt.tv_sec = timeout / 1000000;
1690  wt.tv_usec = timeout % 1000000;
1691  }
1692 
1693  /* auxiliary variables */
1694  int i;
1695  int j;
1696  int k;
1697  int s;
1698  char fdmaskempty;
1699 
1700  /* check the links and fill in fdmask */
1701  /* check ssi links for ungetc_buf */
1702  for(i=L->nr; i>=0; i--)
1703  {
1704  if (L->m[i].Typ()!=DEF_CMD)
1705  {
1706  if (L->m[i].Typ()!=LINK_CMD)
1707  { WerrorS("all elements must be of type link"); return -2;}
1708  l=(si_link)L->m[i].Data();
1709  if(SI_LINK_OPEN_P(l)==0)
1710  { WerrorS("all links must be open"); return -2;}
1711  if (((strcmp(l->m->type,"ssi")!=0) && (strcmp(l->m->type,"MPtcp")!=0))
1712  || ((strcmp(l->mode,"fork")!=0) && (strcmp(l->mode,"tcp")!=0)
1713  && (strcmp(l->mode,"launch")!=0) && (strcmp(l->mode,"connect")!=0)))
1714  {
1715  WerrorS("all links must be of type ssi:fork, ssi:tcp, ssi:connect");
1716  return -2;
1717  }
1718  if (strcmp(l->m->type,"ssi")==0)
1719  {
1720  d=(ssiInfo*)l->data;
1721  d_fd=d->fd_read;
1722  if (!s_isready(d->f_read))
1723  {
1724  FD_SET(d_fd, &fdmask);
1725  if (d_fd > max_fd) max_fd=d_fd;
1726  }
1727  else
1728  return i+1;
1729  }
1730  else
1731  {
1732  Werror("wrong link type >>%s<<",l->m->type);
1733  return -2;
1734  }
1735  }
1736  }
1737  max_fd++;
1738 
1739 do_select:
1740  /* copy fdmask to mask */
1741  FD_ZERO(&mask);
1742  for(k = 0; k < max_fd; k++)
1743  {
1744  if(FD_ISSET(k, &fdmask))
1745  {
1746  FD_SET(k, &mask);
1747  }
1748  }
1749 
1750  /* check with select: chars waiting: no -> not ready */
1751  s = si_select(max_fd, &mask, NULL, NULL, wt_ptr);
1752  if (s==-1)
1753  {
1754  WerrorS("error in select call");
1755  return -2; /*error*/
1756  }
1757  if (s==0)
1758  {
1759  return 0; /*poll: not ready */
1760  }
1761  else /* s>0, at least one ready (the number of fd which are ready is s)*/
1762  {
1763  j=0;
1764  while (j<=max_fd) { if (FD_ISSET(j,&mask)) break; j++; }
1765  for(i=L->nr; i>=0; i--)
1766  {
1767  if (L->m[i].rtyp==LINK_CMD)
1768  {
1769  l=(si_link)L->m[i].Data();
1770  if (strcmp(l->m->type,"ssi")==0)
1771  {
1772  d=(ssiInfo*)l->data;
1773  d_fd=d->fd_read;
1774  if(j==d_fd) break;
1775  }
1776  else
1777  {
1778  Werror("wrong link type >>%s<<",l->m->type);
1779  return -2;
1780  }
1781  }
1782  }
1783  // only ssi links:
1784  loop
1785  {
1786  /* yes: read 1 char*/
1787  /* if \n, check again with select else ungetc(c), ready*/
1788  /* setting: d: current ssiInfo, j current fd, i current entry in L*/
1789  int c=s_getc(d->f_read);
1790  //Print("try c=%d\n",c);
1791  if (c== -1) /* eof */
1792  {
1793  FD_CLR(j,&fdmask);
1794  fdmaskempty = 1;
1795  for(k = 0; k < max_fd; k++)
1796  {
1797  if(FD_ISSET(k, &fdmask))
1798  {
1799  fdmaskempty = 0;
1800  break;
1801  }
1802  }
1803  if(fdmaskempty)
1804  {
1805  return -1;
1806  }
1807  if(timeout != -1)
1808  {
1809  timeout = si_max(0,
1810  timeout - 1000000*(getRTimer()/TIMER_RESOLUTION - startingtime));
1811  wt.tv_sec = timeout / 1000000;
1812  wt.tv_usec = (timeout % 1000000);
1813  }
1814  goto do_select;
1815  }
1816 
1817  else if (isdigit(c))
1818  { s_ungetc(c,d->f_read); return i+1; }
1819  else if (c>' ')
1820  {
1821  Werror("unknown char in ssiLink(%d)",c);
1822  return -2;
1823  }
1824  /* else: next char */
1825  goto do_select;
1826  }
1827  }
1828 }

◆ slString()

static char* slString ( si_link  l)
inlinestatic

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 }

◆ slWrite()

BOOLEAN slWrite ( si_link  l,
leftv  v 
)

Definition at line 309 of file silink.cc.

310 {
311  BOOLEAN res;
312 
313  if(! SI_LINK_W_OPEN_P(l)) // open w ?
314  {
315 #ifdef HAVE_DBM
316 #ifdef USE_GDBM
317  if (! SI_LINK_CLOSE_P(l))
318  {
319  if (slClose(l)) return TRUE;
320  }
321 #endif
322 #endif
323  if (slOpen(l, SI_LINK_WRITE,NULL)) return TRUE;
324  }
325 
326  if (SI_LINK_W_OPEN_P(l))
327  { // now open w
328  if (l->m->Write != NULL)
329  res = l->m->Write(l,v);
330  else
331  res = TRUE;
332 
333  if (res)
334  Werror("write: Error for link of type %s, mode: %s, name: %s",
335  l->m->type, l->mode, l->name);
336  return res;
337  }
338  else
339  {
340  Werror("write: Error to open link of type %s, mode: %s, name: %s for writing",
341  l->m->type, l->mode, l->name);
342  return TRUE;
343  }
344 }

◆ ssiBatch()

int ssiBatch ( const char *  host,
const char *  port 
)

Definition at line 1830 of file ssiLink.cc.

1832 {
1834  char *buf=(char*)omAlloc(256);
1835  sprintf(buf,"ssi:connect %s:%s",host,port);
1836  slInit(l, buf);
1837  omFreeSize(buf,256);
1838  if (slOpen(l,SI_LINK_OPEN,NULL)) return 1;
1840 
1841  idhdl id = enterid("link_ll", 0, LINK_CMD, &IDROOT, FALSE);
1842  IDLINK(id) = l;
1843 
1844  loop
1845  {
1846  leftv h=ssiRead1(l); /*contains an exit.... */
1847  if (feErrors != NULL && *feErrors != '\0')
1848  {
1849  // handle errors:
1850  PrintS(feErrors); /* currently quite simple */
1851  *feErrors = '\0';
1852  }
1853  ssiWrite(l,h);
1854  h->CleanUp();
1856  }
1857  /* never reached*/
1858  exit(0);
1859 }

Variable Documentation

◆ ip_link_bin

omBin ip_link_bin
extern

Definition at line 42 of file silink.cc.

◆ s_si_link_extension_bin

omBin s_si_link_extension_bin
extern

Definition at line 40 of file silink.cc.

◆ sip_link_bin

omBin sip_link_bin
extern

Definition at line 41 of file silink.cc.

◆ ssiToBeClosed

link_list ssiToBeClosed
extern

Definition at line 62 of file ssiLink.cc.

◆ ssiToBeClosed_inactive

volatile BOOLEAN ssiToBeClosed_inactive
extern

Definition at line 63 of file ssiLink.cc.

FALSE
#define FALSE
Definition: auxiliary.h:94
sleftv::Data
void * Data()
Definition: subexpr.cc:1182
j
int j
Definition: facHensel.cc:105
omFree
#define omFree(addr)
Definition: omAllocDecl.h:261
ssiInfo
Definition: s_buff.h:21
errorreported
short errorreported
Definition: feFopen.cc:23
k
int k
Definition: cfEzgcd.cc:92
ADDRESS
void * ADDRESS
Definition: auxiliary.h:133
enterid
idhdl enterid(const char *s, int lev, int t, idhdl *root, BOOLEAN init, BOOLEAN search)
Definition: ipid.cc:267
omStrDup
#define omStrDup(s)
Definition: omAllocDecl.h:263
DEF_CMD
@ DEF_CMD
Definition: tok.h:58
omAlloc0Bin
#define omAlloc0Bin(bin)
Definition: omAllocDecl.h:206
loop
#define loop
Definition: structs.h:78
sleftv
Class used for (list of) interpreter objects.
Definition: subexpr.h:83
slists::nr
int nr
Definition: lists.h:43
ssiInfo::f_read
s_buff f_read
Definition: s_buff.h:22
m2_end
void m2_end(int i)
Definition: misc_ip.cc:1101
IDLINK
#define IDLINK(a)
Definition: ipid.h:133
do_shutdown
volatile BOOLEAN do_shutdown
Definition: cntrlc.cc:79
TRUE
#define TRUE
Definition: auxiliary.h:98
i
int i
Definition: cfEzgcd.cc:125
res
CanonicalForm res
Definition: facAbsFact.cc:64
buf
int status int void * buf
Definition: si_signals.h:59
PrintS
void PrintS(const char *s)
Definition: reporter.cc:284
omFreeSize
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
BOOLEAN
int BOOLEAN
Definition: auxiliary.h:85
IDROOT
#define IDROOT
Definition: ipid.h:18
s_ungetc
void s_ungetc(int c, s_buff F)
Definition: s_buff.cc:97
h
static Poly * h
Definition: janet.cc:972
omAlloc
#define omAlloc(size)
Definition: omAllocDecl.h:210
slists::m
sleftv * m
Definition: lists.h:45
s_isready
int s_isready(s_buff F)
Definition: s_buff.cc:83
idrec
Definition: idrec.h:35
getRTimer
int getRTimer()
Definition: timer.cc:172
feErrors
char * feErrors
Definition: reporter.cc:47
defer_shutdown
volatile int defer_shutdown
Definition: cntrlc.cc:80
si_max
static int si_max(const int a, const int b)
Definition: auxiliary.h:138
TIMER_RESOLUTION
#define TIMER_RESOLUTION
Definition: mod2.h:34
Werror
void Werror(const char *fmt,...)
Definition: reporter.cc:189
name
char name(const Variable &v)
Definition: factory.h:180
WerrorS
void WerrorS(const char *s)
Definition: feFopen.cc:24
sleftv::Typ
int Typ()
Definition: subexpr.cc:1039
sleftv::rtyp
int rtyp
Definition: subexpr.h:91
NULL
#define NULL
Definition: omList.c:10
l
int l
Definition: cfEzgcd.cc:93
Warn
#define Warn
Definition: emacs.cc:77
v
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
sleftv_bin
omBin sleftv_bin
Definition: subexpr.cc:47
s
const CanonicalForm int s
Definition: facAbsFact.cc:55
ssiInfo::fd_read
int fd_read
Definition: s_buff.h:26
feOptValue
static void * feOptValue(feOptIndex opt)
Definition: feOpt.h:40
s_getc
int s_getc(s_buff F)
Definition: s_buff.cc:56
omFreeBin
#define omFreeBin(addr, bin)
Definition: omAllocDecl.h:259
LINK_CMD
@ LINK_CMD
Definition: tok.h:117
if
if(yy_init)
Definition: libparse.cc:1418