Loading...
Searching...
No Matches
silink.h File Reference
`#include "singularconfig.h"`
`#include "omalloc/omalloc.h"`
`#include "kernel/structs.h"`
`#include "Singular/links/sing_dbm.h"`
`#include "Singular/lists.h"`
`#include "Singular/attrib.h"`

Go to the source code of this file.

## Data Structures

struct | si_link_extension
struct | ip_link
struct | link_struct

## 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)
#define | SI_LINK_OPEN_P(l)
#define | SI_LINK_W_OPEN_P(l)
#define | SI_LINK_R_OPEN_P(l)
#define | SI_LINK_RW_OPEN_P(l)
#define | SI_LINK_SET_CLOSE_P(l)
#define | SI_LINK_SET_OPEN_P(l, flag)
#define | SI_LINK_SET_W_OPEN_P(l)
#define | SI_LINK_SET_R_OPEN_P(l)
#define | SI_LINK_SET_RW_OPEN_P(l)

## 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_struct * | link_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, BOOLEAN *ignore=NULL)
int | ssiBatch (const char *host, const char *port)
BOOLEAN | ssiWrite2 (si_link l, leftv res, leftv v)

## Variables

EXTERN_VAR omBin | s_si_link_extension_bin
EXTERN_VAR omBin | sip_link_bin
EXTERN_VAR omBin | ip_link_bin
EXTERN_VAR link_list | ssiToBeClosed
EXTERN_VAR volatile BOOLEAN | ssiToBeClosed_inactive

## Data Structure Documentation

## s_si_link_extension

struct s_si_link_extension

Definition at line 36 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 53 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 121 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 64 of file silink.h.

## SI_LINK_CLOSE_P

#define SI_LINK_CLOSE_P | ( |  | l | ) |

Value:
(!(l)->flags)
l
int l
Definition cfEzgcd.cc:100

Definition at line 70 of file silink.h.

## SI_LINK_OPEN

#define SI_LINK_OPEN 1

Definition at line 65 of file silink.h.

## SI_LINK_OPEN_P

#define SI_LINK_OPEN_P | ( |  | l | ) |

Value:
((l)->flags & SI_LINK_OPEN)
SI_LINK_OPEN
#define SI_LINK_OPEN
Definition silink.h:65

Definition at line 71 of file silink.h.

## SI_LINK_R_OPEN_P

#define SI_LINK_R_OPEN_P | ( |  | l | ) |

Value:
((l)->flags & SI_LINK_READ)
SI_LINK_READ
#define SI_LINK_READ
Definition silink.h:66

Definition at line 73 of file silink.h.

## SI_LINK_READ

#define SI_LINK_READ 2

Definition at line 66 of file silink.h.

## SI_LINK_RW_OPEN_P

#define SI_LINK_RW_OPEN_P | ( |  | l | ) |

Value:
(SI_LINK_W_OPEN_P(l) && SI_LINK_R_OPEN_P(l))
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

Definition at line 74 of file silink.h.

## SI_LINK_SET_CLOSE_P

#define SI_LINK_SET_CLOSE_P | ( |  | l | ) |

Value:
((l)->flags = SI_LINK_CLOSE)
SI_LINK_CLOSE
#define SI_LINK_CLOSE
Definition silink.h:64

Definition at line 76 of file silink.h.

## SI_LINK_SET_OPEN_P

#define SI_LINK_SET_OPEN_P | ( |  | l,
|  |  | flag )

Value:
((l)->flags |= SI_LINK_OPEN |flag)

Definition at line 77 of file silink.h.

## SI_LINK_SET_R_OPEN_P

#define SI_LINK_SET_R_OPEN_P | ( |  | l | ) |

Value:
((l)->flags |= (SI_LINK_OPEN | SI_LINK_READ))

Definition at line 79 of file silink.h.

## SI_LINK_SET_RW_OPEN_P

#define SI_LINK_SET_RW_OPEN_P | ( |  | l | ) |

Value:
((l)->flags |= (SI_LINK_OPEN | SI_LINK_READ | SI_LINK_WRITE))
SI_LINK_WRITE
#define SI_LINK_WRITE
Definition silink.h:67

Definition at line 80 of file silink.h.

## SI_LINK_SET_W_OPEN_P

#define SI_LINK_SET_W_OPEN_P | ( |  | l | ) |

Value:
((l)->flags |= (SI_LINK_OPEN | SI_LINK_WRITE))

Definition at line 78 of file silink.h.

## SI_LINK_W_OPEN_P

#define SI_LINK_W_OPEN_P | ( |  | l | ) |

Value:
((l)->flags & SI_LINK_WRITE)

Definition at line 72 of file silink.h.

## SI_LINK_WRITE

#define SI_LINK_WRITE 4

Definition at line 67 of file silink.h.

## Typedef Documentation

## link_list

typedef link_struct* link_list

Definition at line 128 of file silink.h.

## si_link

typedef ip_link* si_link

Definition at line 20 of file silink.h.

## slCloseProc

typedef BOOLEAN(* slCloseProc) (si_link l)

Definition at line 26 of file silink.h.

## slDumpProc

typedef BOOLEAN(* slDumpProc) (si_link l)

Definition at line 31 of file silink.h.

## slGetDumpProc

typedef BOOLEAN(* slGetDumpProc) (si_link l)

Definition at line 32 of file silink.h.

## slKillProc

typedef BOOLEAN(* slKillProc) (si_link l)

Definition at line 28 of file silink.h.

## slOpenProc

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

Definition at line 24 of file silink.h.

## slPrepCloseProc

typedef BOOLEAN(* slPrepCloseProc) (si_link l)

Definition at line 27 of file silink.h.

## slRead2Proc

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

Definition at line 30 of file silink.h.

## slReadProc

typedef leftv(* slReadProc) (si_link l)

Definition at line 29 of file silink.h.

## slSetRingProc

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

Definition at line 34 of file silink.h.

## slStatusProc

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

Definition at line 33 of file silink.h.

## slWriteProc

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

Definition at line 25 of file silink.h.

## Function Documentation

## slCleanUp()

void slCleanUp | ( | si_link | l | ) |

Definition at line 127 of file silink.cc.

{
defer_shutdown++;
(l->ref)--;
if (l->ref == 0)
{
if (SI_LINK_OPEN_P(l))
{
if (l->m->Close != NULL) l->m->Close(l);
}
if ((l->data != NULL) && (l->m->Kill != NULL)) l->m->Kill(l);
omFree((ADDRESS)l->name);
omFree((ADDRESS)l->mode);
memset((void *) l, 0, sizeof(ip_link));
}
defer_shutdown--;
if (!defer_shutdown && do_shutdown) m2_end(-1);
}
ADDRESS
void * ADDRESS
Definition auxiliary.h:120
do_shutdown
VAR volatile BOOLEAN do_shutdown
Definition cntrlc.cc:74
defer_shutdown
VAR volatile int defer_shutdown
Definition cntrlc.cc:75
m2_end
void m2_end(int i)
Definition misc_ip.cc:1104
omFree
#define omFree(addr)
Definition omAllocDecl.h:261
NULL
#define NULL
Definition omList.c:12
SI_LINK_OPEN_P
#define SI_LINK_OPEN_P(l)
Definition silink.h:71

## slClose()

BOOLEAN slClose | ( | si_link | l | ) |

Definition at line 240 of file silink.cc.

{
if(! SI_LINK_OPEN_P(l))
return FALSE;
defer_shutdown++;
BOOLEAN res = TRUE;
if (l->m->Close != NULL)
{
res = l->m->Close(l);
if (res)
Werror("close: Error for link of type: %s, mode: %s, name: %s",
l->m->type, l->mode, l->name);
}
defer_shutdown--;
if (!defer_shutdown && do_shutdown) m2_end(-1);
SI_LINK_SET_CLOSE_P(l);
return res;
}
BOOLEAN
int BOOLEAN
Definition auxiliary.h:88
TRUE
#define TRUE
Definition auxiliary.h:101
FALSE
#define FALSE
Definition auxiliary.h:97
res
CanonicalForm res
Definition facAbsFact.cc:60
Werror
void Werror(const char *fmt,...)
Definition reporter.cc:189
SI_LINK_SET_CLOSE_P
#define SI_LINK_SET_CLOSE_P(l)
Definition silink.h:76

## slCopy()

si_link slCopy | ( | si_link | l | ) |

inline static

Definition at line 94 of file silink.h.

{
l->ref++;
return l;
}

## slDump()

BOOLEAN slDump | ( | si_link | l | ) |

Definition at line 344 of file silink.cc.

{
BOOLEAN res;
if(! SI_LINK_W_OPEN_P(l)) // open w ?
{
if (slOpen(l, SI_LINK_WRITE,NULL)) return TRUE;
}
if(SI_LINK_W_OPEN_P(l))
{ // now open w
if (l->m->Dump != NULL)
res = l->m->Dump(l);
else
res = TRUE;
if (res)
Werror("dump: Error for link of type %s, mode: %s, name: %s",
l->m->type, l->mode, l->name);
if (!SI_LINK_R_OPEN_P(l)) slClose(l); // do not close r/w links
return res;
}
else
{
Werror("dump: Error to open link of type %s, mode: %s, name: %s for writing",
l->m->type, l->mode, l->name);
return TRUE;
}
}
slClose
BOOLEAN slClose(si_link l)
Definition silink.cc:240
slOpen
BOOLEAN slOpen(si_link l, short flag, leftv h)
Definition silink.cc:194

## slGetDump()

BOOLEAN slGetDump | ( | si_link | l | ) |

Definition at line 374 of file silink.cc.

{
BOOLEAN res;
if(! SI_LINK_R_OPEN_P(l)) // open r ?
{
if (slOpen(l, SI_LINK_READ,NULL)) return TRUE;
}
if(SI_LINK_R_OPEN_P(l))
{ // now open r
if (l->m->GetDump != NULL)
res = l->m->GetDump(l);
else
res = TRUE;
if (res)
Werror("getdump: Error for link of type %s, mode: %s, name: %s",
l->m->type, l->mode, l->name);
//res|=slClose(l);
return res;
}
else
{
Werror("dump: Error open link of type %s, mode: %s, name: %s for reading",
l->m->type, l->mode, l->name);
return TRUE;
}
}

## slInit()

BOOLEAN slInit | ( | si_link | l,
|  | char * | str )

Definition at line 48 of file silink.cc.

{
char *type = NULL, *mode = NULL, *name = NULL;
int i = 0, j;
// set mode and type
if (istr != NULL)
{
// find the first colon char in istr
i = 0;
while (istr[i] != ':' && istr[i] != '\0') i++;
if (istr[i] == ':')
{
// if found, set type
if (i > 0)
{
istr[i] = '\0';
type = omStrDup(istr);
istr[i] = ':';
}
// and check for mode
j = ++i;
while (istr[j] != ' ' && istr[j] != '\0') j++;
if (j > i)
{
mode = omStrDup(&(istr[i]));
mode[j - i] = '\0';
}
// and for the name
while (istr[j] == ' '&& istr[j] != '\0') j++;
if (istr[j] != '\0') name = omStrDup(&(istr[j]));
}
else // no colon find -- string is entire name
{
j=0;
while (istr[j] == ' '&& istr[j] != '\0') j++;
if (istr[j] != '\0') name = omStrDup(&(istr[j]));
}
}
// set the link extension
if (type != NULL)
{
si_link_extension s = si_link_root;
si_link_extension prev = s;
while (strcmp(s->type, type) != 0)
{
if (s->next == NULL)
{
prev = s;
s = NULL;
break;
}
else
{
s = s->next;
}
}
if (s != NULL)
l->m = s;
else
{
l->m = slTypeInit(prev, type);
}
omFree(type);
}
else
l->m = si_link_root;
if (l->m == NULL) return TRUE;
l->name = (name != NULL ? name : omStrDup(""));
l->mode = (mode != NULL ? mode : omStrDup(""));
l->ref = 1;
return FALSE;
}
si_link_root
EXTERN_VAR si_link_extension si_link_root
Definition asciiLink.cc:32
i
int i
Definition cfEzgcd.cc:132
s
const CanonicalForm int s
Definition facAbsFact.cc:51
j
int j
Definition facHensel.cc:110
name
char name(const Variable &v)
Definition factory.h:189
omStrDup
#define omStrDup(s)
Definition omAllocDecl.h:263
slTypeInit
static si_link_extension slTypeInit(si_link_extension s, const char *type)
Definition silink.cc:407

## slKill()

void slKill | ( | si_link | l | ) |

Definition at line 146 of file silink.cc.

{
defer_shutdown++;
slCleanUp(l);
if ((l!=NULL) &&(l->ref == 0))
omFreeBin((ADDRESS)l, ip_link_bin);
defer_shutdown--;
if (!defer_shutdown && do_shutdown) m2_end(-1);
}
omFreeBin
#define omFreeBin(addr, bin)
Definition omAllocDecl.h:259
ip_link_bin
VAR omBin ip_link_bin
Definition silink.cc:41
slCleanUp
void slCleanUp(si_link l)
Definition silink.cc:127

## slOpen()

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

Definition at line 194 of file silink.cc.

{
BOOLEAN res = TRUE;
if (l!=NULL)
{
if (l->m == NULL) slInit(l, ((char*)""));
const char *c="_";;
if (h!=NULL) c=h->Name();
if (SI_LINK_OPEN_P(l))
{
Warn("open: link of type: %s, mode: %s, name: %s is already open",
l->m->type, l->mode, l->name);
return FALSE;
}
else if (l->m->Open != NULL)
{
res = l->m->Open(l, flag, h);
if (res)
Werror("open: Error for link %s of type: %s, mode: %s, name: %s",
c, l->m->type, l->mode, l->name);
}
if (l->m->SetRing==NULL) l->m->SetRing=slSetRingDummy;
}
return res;
}
Warn
#define Warn
Definition emacs.cc:77
h
STATIC_VAR Poly * h
Definition janet.cc:971
slInit
BOOLEAN slInit(si_link l, char *istr)
Definition silink.cc:48
slSetRingDummy
BOOLEAN slSetRingDummy(si_link, ring r, BOOLEAN)
Definition silink.cc:189

## slPrepClose()

BOOLEAN slPrepClose | ( | si_link | l | ) |

Definition at line 223 of file silink.cc.

{
if(! SI_LINK_OPEN_P(l))
return FALSE;
BOOLEAN res = TRUE;
if (l->m->PrepClose != NULL)
{
res = l->m->PrepClose(l);
if (res)
Werror("close: Error for link of type: %s, mode: %s, name: %s",
l->m->type, l->mode, l->name);
}
return res;
}

## slRead()

leftv slRead | ( | si_link | l,
|  | leftv | a = NULL )

Definition at line 261 of file silink.cc.

{
leftv v = NULL;
if( ! SI_LINK_R_OPEN_P(l)) // open r ?
{
#ifdef HAVE_DBM
#ifdef USE_GDBM
if (! SI_LINK_CLOSE_P(l))
{
if (slClose(l)) return NULL;
}
#endif
#endif
if (slOpen(l, SI_LINK_READ,NULL)) return NULL;
}
if (SI_LINK_R_OPEN_P(l))
{ // open r
if (a==NULL)
{
if (l->m->Read != NULL) v = l->m->Read(l);
}
else
{
if (l->m->Read2 != NULL) v = l->m->Read2(l,a);
}
}
else
{
Werror("read: Error to open link of type %s, mode: %s, name: %s for reading",
l->m->type, l->mode, l->name);
return NULL;
}
// here comes the eval:
if (v != NULL)
{
if (v->Eval() && !errorreported)
WerrorS("eval: failed");
}
else
Werror("read: Error for link of type %s, mode: %s, name: %s",
l->m->type, l->mode, l->name);
return v;
}
v
const Variable & v
< [in] a sqrfree bivariate poly
Definition facBivar.h:39
errorreported
VAR short errorreported
Definition feFopen.cc:23
WerrorS
void WerrorS(const char *s)
Definition feFopen.cc:24
SI_LINK_CLOSE_P
#define SI_LINK_CLOSE_P(l)
Definition silink.h:70
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
slReadAscii2
static leftv slReadAscii2(si_link l, leftv pr)
Definition asciiLink.cc:108
slCloseAscii
static BOOLEAN slCloseAscii(si_link l)
Definition asciiLink.cc:98
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
omAlloc0Bin
#define omAlloc0Bin(bin)
Definition omAllocDecl.h:206
s_si_link_extension_bin
VAR omBin s_si_link_extension_bin
Definition silink.cc:39

## slStatus()

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

Definition at line 156 of file silink.cc.

{
if (l == NULL) return "empty link";
else if (l->m == NULL) return "unknown link type";
else if (strcmp(request, "type") == 0) return l->m->type;
else if (strcmp(request, "mode") == 0) return l->mode;
else if (strcmp(request, "name") == 0) return l->name;
else if (strcmp(request, "exists") ==0)
{
struct stat buf;
if (si_lstat(l->name,&buf)==0) return "yes";
else return "no";
}
else if (strcmp(request, "open") == 0)
{
if (SI_LINK_OPEN_P(l)) return "yes";
else return "no";
}
else if (strcmp(request, "openread") == 0)
{
if (SI_LINK_R_OPEN_P(l)) return "yes";
else return "no";
}
else if (strcmp(request, "openwrite") == 0)
{
if (SI_LINK_W_OPEN_P(l)) return "yes";
else return "no";
}
else if (l->m->Status == NULL) return "unknown status request";
else return l->m->Status(l, request);
}
buf
int status int void * buf
Definition si_signals.h:69

## slStatusSsiL()

int slStatusSsiL | ( | lists | L,
|  | int | timeout,
|  | BOOLEAN * | ignore = NULL )

Definition at line 2919 of file ssiLink.cc.

{
// input: L: a list with links of type
// ssi-connect, ssi-fork, ssi-tcp, MPtcp-fork or MPtcp-launch.
// Note: Not every entry in L must be set.
// timeout: timeout for select in milli-seconds
// or -1 for infinity
// or 0 for polling
// returns: ERROR (via Werror): L has wrong elements or link not open
// -2: error in L
// -1: the read state of all links is eof
// 0: timeout (or polling): none ready,
// i>0: (at least) L[i] is ready
#if defined(HAVE_POLL) && !defined(__APPLE__)
// fd is restricted on OsX by ulimit "file descriptors" (256)
si_link l;
ssiInfo *d=NULL;
int d_fd;
int s;
int nfd=L->nr+1;
pollfd *pfd=(pollfd*)omAlloc0(nfd*sizeof(pollfd));
for(int i=L->nr; i>=0; i--)
{
pfd[i].fd=-1;
if (L->m[i].Typ()!=DEF_CMD)
{
if (L->m[i].Typ()!=LINK_CMD)
{ WerrorS("all elements must be of type link"); return -2;}
l=(si_link)L->m[i].Data();
if(SI_LINK_OPEN_P(l)==0)
{ WerrorS("all links must be open"); return -2;}
if (((strcmp(l->m->type,"ssi")!=0) && (strcmp(l->m->type,"MPtcp")!=0))
|| ((strcmp(l->mode,"fork")!=0) && (strcmp(l->mode,"tcp")!=0)
&& (strcmp(l->mode,"launch")!=0) && (strcmp(l->mode,"connect")!=0)))
{
WerrorS("all links must be of type ssi:fork, ssi:tcp, ssi:connect");
return -2;
}
if (strcmp(l->m->type,"ssi")==0)
{
d=(ssiInfo*)l->data;
d_fd=d->fd_read;
if (!s_isready(d->f_read))
{
pfd[i].fd=d_fd;
pfd[i].events=POLLIN;
}
else
{
return i+1;
}
}
else
{
Werror("wrong link type >>%s<<",l->m->type);
return -2;
}
}
else if (ignore!=NULL)
{
ignore[i]=TRUE; // not a link
}
}
s=si_poll(pfd,nfd,timeout);
if (s==-1)
{
Werror("error in poll call (errno:%d)",errno);
return -2; /*error*/
}
if(s==0)
{
return 0; /*timeout*/
}
for(int i=L->nr; i>=0; i--)
{
if ((L->m[i].rtyp==LINK_CMD)
&& ((ignore==NULL)||(ignore[i]==FALSE)))
{
// the link type is ssi, that's already tested
l=(si_link)L->m[i].Data();
d=(ssiInfo*)l->data;
d_fd=d->fd_read;
if (pfd[i].fd==d_fd)
{
if (pfd[i].revents &POLLIN)
{
omFree(pfd);
return i+1;
}
}
}
}
// no ready
return 0;
#else
// fd is restricted to <=1024
si_link l;
ssiInfo *d=NULL;
int d_fd;
fd_set fdmask;
FD_ZERO(&fdmask);
int max_fd=0; /* 1 + max fd in fd_set */
/* timeout */
struct timeval wt;
struct timeval *wt_ptr=&wt;
int startingtime = getRTimer()/TIMER_RESOLUTION; // in seconds
if (timeout== -1)
{
wt_ptr=NULL;
}
else
{
wt.tv_sec = timeout / 1000;
wt.tv_usec = (timeout % 1000)*1000;
}
/* auxiliary variables */
int i;
int j;
int k;
int s;
char fdmaskempty;
/* check the links and fill in fdmask */
/* check ssi links for ungetc_buf */
for(i=L->nr; i>=0; i--)
{
if (L->m[i].Typ()!=DEF_CMD)
{
if (L->m[i].Typ()!=LINK_CMD)
{ WerrorS("all elements must be of type link"); return -2;}
l=(si_link)L->m[i].Data();
if(SI_LINK_OPEN_P(l)==0)
{ WerrorS("all links must be open"); return -2;}
if (((strcmp(l->m->type,"ssi")!=0) && (strcmp(l->m->type,"MPtcp")!=0))
|| ((strcmp(l->mode,"fork")!=0) && (strcmp(l->mode,"tcp")!=0)
&& (strcmp(l->mode,"launch")!=0) && (strcmp(l->mode,"connect")!=0)))
{
WerrorS("all links must be of type ssi:fork, ssi:tcp, ssi:connect");
return -2;
}
if (strcmp(l->m->type,"ssi")==0)
{
d=(ssiInfo*)l->data;
d_fd=d->fd_read;
if (!s_isready(d->f_read))
{
if ((ignore==NULL) || (ignore[i]==FALSE))
{
FD_SET(d_fd, &fdmask);
if (d_fd > max_fd) max_fd=d_fd;
}
}
else
return i+1;
}
else
{
Werror("wrong link type >>%s<<",l->m->type);
return -2;
}
}
}
max_fd++;
if (FD_SETSIZE<=max_fd)
{
Werror("file descriptor number too high (%d)",max_fd);
return -2;
}
/* check with select: chars waiting: no -> not ready */
s = si_select(max_fd, &fdmask, NULL, NULL, wt_ptr);
if (s==-1)
{
Werror("error in select call (errno:%d)",errno);
return -2; /*error*/
}
if (s==0)
{
return 0; /*poll: not ready */
}
else /* s>0, at least one ready (the number of fd which are ready is s)*/
{
j=0;
while (j<=max_fd) { if (FD_ISSET(j,&fdmask)) break; j++; }
for(i=L->nr; i>=0; i--)
{
if (L->m[i].rtyp==LINK_CMD)
{
l=(si_link)L->m[i].Data();
if (strcmp(l->m->type,"ssi")==0)
{
d=(ssiInfo*)l->data;
d_fd=d->fd_read;
if(j==d_fd) return i+1;
}
}
}
}
return 0;
#endif
}
k
int k
Definition cfEzgcd.cc:99
sleftv::Typ
int Typ()
Definition subexpr.cc:1048
sleftv::rtyp
int rtyp
Definition subexpr.h:91
sleftv::Data
void * Data()
Definition subexpr.cc:1192
slists::m
sleftv * m
Definition lists.h:46
slists::nr
int nr
Definition lists.h:44
TIMER_RESOLUTION
#define TIMER_RESOLUTION
Definition mod2.h:35
omAlloc0
#define omAlloc0(size)
Definition omAllocDecl.h:211
s_isready
int s_isready(s_buff F)
Definition s_buff.cc:86
ssiInfo::f_read
s_buff f_read
Definition s_buff.h:22
ssiInfo::fd_read
int fd_read
Definition s_buff.h:26
ssiInfo
Definition s_buff.h:21
fd
int status int fd
Definition si_signals.h:69
si_link
ip_link * si_link
Definition silink.h:20
getRTimer
int getRTimer()
Definition timer.cc:150
DEF_CMD
@ DEF_CMD
Definition tok.h:58
LINK_CMD
@ LINK_CMD
Definition tok.h:117

## slString()

char * slString | ( | si_link | l | ) |

inline static

Definition at line 101 of file silink.h.

{
if (l->name != NULL)
{
return omStrDup(l->name);
}
else
{
return omStrDup("");
}
}

## slWrite()

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

Definition at line 307 of file silink.cc.

{
BOOLEAN res;
if(! SI_LINK_W_OPEN_P(l)) // open w ?
{
#ifdef HAVE_DBM
#ifdef USE_GDBM
if (! SI_LINK_CLOSE_P(l))
{
if (slClose(l)) return TRUE;
}
#endif
#endif
if (slOpen(l, SI_LINK_WRITE,NULL)) return TRUE;
}
if (SI_LINK_W_OPEN_P(l))
{ // now open w
if (l->m->Write != NULL)
res = l->m->Write(l,v);
else
res = TRUE;
if (res)
Werror("write: Error for link of type %s, mode: %s, name: %s",
l->m->type, l->mode, l->name);
return res;
}
else
{
Werror("write: Error to open link of type %s, mode: %s, name: %s for writing",
l->m->type, l->mode, l->name);
return TRUE;
}
}

## ssiBatch()

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

Definition at line 3123 of file ssiLink.cc.

{
si_link l=(si_link) omAlloc0Bin(sip_link_bin);
char *buf=(char*)omAlloc(256);
snprintf(buf,256,"ssi:connect %s:%s",host,port);
slInit(l, buf);
omFreeSize(buf,256);
if (slOpen(l,SI_LINK_OPEN,NULL)) return 1;
SI_LINK_SET_RW_OPEN_P(l);
idhdl id = enterid("link_ll", 0, LINK_CMD, &IDROOT, FALSE);
IDLINK(id) = l;
loop
{
leftv h=ssiRead1(l); /*contains an exit.... */
if (feErrors != NULL && *feErrors != '\0')
{
// handle errors:
PrintS(feErrors); /* currently quite simple */
*feErrors = '\0';
}
ssiWrite(l,h);
h->CleanUp();
omFreeBin(h, sleftv_bin);
}
/* never reached*/
_exit(0);
}
enterid
idhdl enterid(const char *s, int lev, int t, idhdl *root, BOOLEAN init, BOOLEAN search)
Definition ipid.cc:279
sleftv_bin
EXTERN_VAR omBin sleftv_bin
Definition ipid.h:145
IDLINK
#define IDLINK(a)
Definition ipid.h:138
IDROOT
#define IDROOT
Definition ipid.h:19
omFreeSize
#define omFreeSize(addr, size)
Definition omAllocDecl.h:260
omAlloc
#define omAlloc(size)
Definition omAllocDecl.h:210
PrintS
void PrintS(const char *s)
Definition reporter.cc:288
feErrors
VAR char * feErrors
Definition reporter.cc:47
idhdl
idrec * idhdl
Definition ring.h:22
sip_link_bin
VAR omBin sip_link_bin
Definition silink.cc:40
SI_LINK_SET_RW_OPEN_P
#define SI_LINK_SET_RW_OPEN_P(l)
Definition silink.h:80
ssiWrite
BOOLEAN ssiWrite(si_link l, leftv data)
Definition ssiLink.cc:2537
ssiRead1
leftv ssiRead1(si_link l)
Definition ssiLink.cc:2209
loop
#define loop
Definition structs.h:71

## ssiWrite2()

BOOLEAN ssiWrite2 | ( | si_link | l,
|  | leftv | res,
|  | leftv | v )

Definition at line 3475 of file ssiLink.cc.

{
if((strcmp(l->mode,"string")==0)
&&(u->Typ()==STRING_CMD))
{
StringSetS("");
ssiWrite_S(u, currRing);
res->data=(void*)StringEndS();
res->rtyp=STRING_CMD;
return res->data==NULL;
}
return TRUE;
}
currRing
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition polys.cc:13
StringSetS
void StringSetS(const char *st)
Definition reporter.cc:128
StringEndS
char * StringEndS()
Definition reporter.cc:151
ssiWrite_S
void ssiWrite_S(leftv data, const ring R)
Definition ssiLink.cc:2691
STRING_CMD
@ STRING_CMD
Definition tok.h:187

## Variable Documentation

## ip_link_bin

EXTERN_VAR omBin ip_link_bin

Definition at line 115 of file silink.h.

## s_si_link_extension_bin

EXTERN_VAR omBin s_si_link_extension_bin

Definition at line 113 of file silink.h.

## sip_link_bin

EXTERN_VAR omBin sip_link_bin

Definition at line 114 of file silink.h.

## ssiToBeClosed

EXTERN_VAR link_list ssiToBeClosed

Definition at line 130 of file silink.h.

## ssiToBeClosed_inactive

EXTERN_VAR volatile BOOLEAN ssiToBeClosed_inactive

Definition at line 131 of file silink.h.