My Project
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

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_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, 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)
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)

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)

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:

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)

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:

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

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.

128{
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 }
143 if (!defer_shutdown && do_shutdown) m2_end(-1);
144}
void * ADDRESS
Definition auxiliary.h:120
VAR volatile BOOLEAN do_shutdown
Definition cntrlc.cc:74
VAR volatile int defer_shutdown
Definition cntrlc.cc:75
void m2_end(int i)
Definition misc_ip.cc:1106
#define omFree(addr)
#define NULL
Definition omList.c:12

◆ slClose()

BOOLEAN slClose ( si_link l)

Definition at line 240 of file silink.cc.

241{
242
243 if(! SI_LINK_OPEN_P(l))
244 return FALSE;
245
247 BOOLEAN res = TRUE;
248 if (l->m->Close != NULL)
249 {
250 res = l->m->Close(l);
251 if (res)
252 Werror("close: Error for link of type: %s, mode: %s, name: %s",
253 l->m->type, l->mode, l->name);
254 }
256 if (!defer_shutdown && do_shutdown) m2_end(-1);
258 return res;
259}
int BOOLEAN
Definition auxiliary.h:88
#define TRUE
Definition auxiliary.h:101
#define FALSE
Definition auxiliary.h:97
CanonicalForm res
Definition facAbsFact.cc:60
void Werror(const char *fmt,...)
Definition reporter.cc:189

◆ slCopy()

si_link slCopy ( si_link l)
inlinestatic

Definition at line 94 of file silink.h.

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

◆ slDump()

BOOLEAN slDump ( si_link l)

Definition at line 344 of file silink.cc.

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

◆ slGetDump()

BOOLEAN slGetDump ( si_link l)

Definition at line 374 of file silink.cc.

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

◆ 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}
int i
Definition cfEzgcd.cc:132
const CanonicalForm int s
Definition facAbsFact.cc:51
int j
Definition facHensel.cc:110
#define omStrDup(s)
int name
New type name for int.

◆ slKill()

void slKill ( si_link l)

Definition at line 146 of file silink.cc.

147{
149 slCleanUp(l);
150 if ((l!=NULL) &&(l->ref == 0))
153 if (!defer_shutdown && do_shutdown) m2_end(-1);
154}
#define omFreeBin(addr, bin)

◆ 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 const char *c="_";;
203 if (h!=NULL) c=h->Name();
204
205 if (SI_LINK_OPEN_P(l))
206 {
207 Warn("open: link of type: %s, mode: %s, name: %s is already open",
208 l->m->type, l->mode, l->name);
209 return FALSE;
210 }
211 else if (l->m->Open != NULL)
212 {
213 res = l->m->Open(l, flag, h);
214 if (res)
215 Werror("open: Error for link %s of type: %s, mode: %s, name: %s",
216 c, l->m->type, l->mode, l->name);
217 }
218 if (l->m->SetRing==NULL) l->m->SetRing=slSetRingDummy;
219 }
220 return res;
221}
#define Warn
Definition emacs.cc:77
STATIC_VAR Poly * h
Definition janet.cc:971

◆ slPrepClose()

BOOLEAN slPrepClose ( si_link l)

Definition at line 223 of file silink.cc.

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

◆ slRead()

leftv slRead ( si_link l,
leftv a = NULL )

Definition at line 261 of file silink.cc.

262{
263 leftv v = NULL;
264 if( ! SI_LINK_R_OPEN_P(l)) // open r ?
265 {
266#ifdef HAVE_DBM
267#ifdef USE_GDBM
268 if (! SI_LINK_CLOSE_P(l))
269 {
270 if (slClose(l)) return NULL;
271 }
272#endif
273#endif
274 if (slOpen(l, SI_LINK_READ,NULL)) return NULL;
275 }
276
277 if (SI_LINK_R_OPEN_P(l))
278 { // open r
279 if (a==NULL)
280 {
281 if (l->m->Read != NULL) v = l->m->Read(l);
282 }
283 else
284 {
285 if (l->m->Read2 != NULL) v = l->m->Read2(l,a);
286 }
287 }
288 else
289 {
290 Werror("read: Error to open link of type %s, mode: %s, name: %s for reading",
291 l->m->type, l->mode, l->name);
292 return NULL;
293 }
294
295 // here comes the eval:
296 if (v != NULL)
297 {
298 if (v->Eval() && !errorreported)
299 WerrorS("eval: failed");
300 }
301 else
302 Werror("read: Error for link of type %s, mode: %s, name: %s",
303 l->m->type, l->mode, l->name);
304 return v;
305}
const Variable & v
< [in] a sqrfree bivariate poly
Definition facBivar.h:39
VAR short errorreported
Definition feFopen.cc:23
void WerrorS(const char *s)
Definition feFopen.cc:24
sleftv * leftv
Definition structs.h:53

◆ slStandardInit()

void slStandardInit ( )

Definition at line 633 of file asciiLink.cc.

634{
635 si_link_extension s;
639 si_link_root->Kill=NULL;
646 si_link_root->type="ASCII";
647 s = si_link_root;
648 s->next = NULL;
649}
#define omAlloc0Bin(bin)

◆ 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}
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.

2920{
2921// input: L: a list with links of type
2922// ssi-connect, ssi-fork, ssi-tcp, MPtcp-fork or MPtcp-launch.
2923// Note: Not every entry in L must be set.
2924// timeout: timeout for select in milli-seconds
2925// or -1 for infinity
2926// or 0 for polling
2927// returns: ERROR (via Werror): L has wrong elements or link not open
2928// -2: error in L
2929// -1: the read state of all links is eof
2930// 0: timeout (or polling): none ready,
2931// i>0: (at least) L[i] is ready
2932#if defined(HAVE_POLL) && !defined(__APPLE__)
2933// fd is restricted on OsX by ulimit "file descriptors" (256)
2934 si_link l;
2935 ssiInfo *d=NULL;
2936 int d_fd;
2937 int s;
2938 int nfd=L->nr+1;
2939 pollfd *pfd=(pollfd*)omAlloc0(nfd*sizeof(pollfd));
2940 for(int i=L->nr; i>=0; i--)
2941 {
2942 pfd[i].fd=-1;
2943 if (L->m[i].Typ()!=DEF_CMD)
2944 {
2945 if (L->m[i].Typ()!=LINK_CMD)
2946 { WerrorS("all elements must be of type link"); return -2;}
2947 l=(si_link)L->m[i].Data();
2948 if(SI_LINK_OPEN_P(l)==0)
2949 { WerrorS("all links must be open"); return -2;}
2950 if (((strcmp(l->m->type,"ssi")!=0) && (strcmp(l->m->type,"MPtcp")!=0))
2951 || ((strcmp(l->mode,"fork")!=0) && (strcmp(l->mode,"tcp")!=0)
2952 && (strcmp(l->mode,"launch")!=0) && (strcmp(l->mode,"connect")!=0)))
2953 {
2954 WerrorS("all links must be of type ssi:fork, ssi:tcp, ssi:connect");
2955 return -2;
2956 }
2957 if (strcmp(l->m->type,"ssi")==0)
2958 {
2959 d=(ssiInfo*)l->data;
2960 d_fd=d->fd_read;
2961 if (!s_isready(d->f_read))
2962 {
2963 pfd[i].fd=d_fd;
2964 pfd[i].events=POLLIN;
2965 }
2966 else
2967 {
2968 return i+1;
2969 }
2970 }
2971 else
2972 {
2973 Werror("wrong link type >>%s<<",l->m->type);
2974 return -2;
2975 }
2976 }
2977 else if (ignore!=NULL)
2978 {
2979 ignore[i]=TRUE; // not a link
2980 }
2981 }
2982 s=si_poll(pfd,nfd,timeout);
2983 if (s==-1)
2984 {
2985 Werror("error in poll call (errno:%d)",errno);
2986 return -2; /*error*/
2987 }
2988 if(s==0)
2989 {
2990 return 0; /*timeout*/
2991 }
2992 for(int i=L->nr; i>=0; i--)
2993 {
2994 if ((L->m[i].rtyp==LINK_CMD)
2995 && ((ignore==NULL)||(ignore[i]==FALSE)))
2996 {
2997 // the link type is ssi, that's already tested
2998 l=(si_link)L->m[i].Data();
2999 d=(ssiInfo*)l->data;
3000 d_fd=d->fd_read;
3001 if (pfd[i].fd==d_fd)
3002 {
3003 if (pfd[i].revents &POLLIN)
3004 {
3005 omFree(pfd);
3006 return i+1;
3007 }
3008 }
3009 }
3010 }
3011 // no ready
3012 return 0;
3013#else
3014 // fd is restricted to <=1024
3015 si_link l;
3016 ssiInfo *d=NULL;
3017 int d_fd;
3018 fd_set fdmask;
3019 FD_ZERO(&fdmask);
3020 int max_fd=0; /* 1 + max fd in fd_set */
3021
3022 /* timeout */
3023 struct timeval wt;
3024 struct timeval *wt_ptr=&wt;
3025 int startingtime = getRTimer()/TIMER_RESOLUTION; // in seconds
3026 if (timeout== -1)
3027 {
3028 wt_ptr=NULL;
3029 }
3030 else
3031 {
3032 wt.tv_sec = timeout / 1000;
3033 wt.tv_usec = (timeout % 1000)*1000;
3034 }
3035
3036 /* auxiliary variables */
3037 int i;
3038 int j;
3039 int k;
3040 int s;
3041 char fdmaskempty;
3042
3043 /* check the links and fill in fdmask */
3044 /* check ssi links for ungetc_buf */
3045 for(i=L->nr; i>=0; i--)
3046 {
3047 if (L->m[i].Typ()!=DEF_CMD)
3048 {
3049 if (L->m[i].Typ()!=LINK_CMD)
3050 { WerrorS("all elements must be of type link"); return -2;}
3051 l=(si_link)L->m[i].Data();
3052 if(SI_LINK_OPEN_P(l)==0)
3053 { WerrorS("all links must be open"); return -2;}
3054 if (((strcmp(l->m->type,"ssi")!=0) && (strcmp(l->m->type,"MPtcp")!=0))
3055 || ((strcmp(l->mode,"fork")!=0) && (strcmp(l->mode,"tcp")!=0)
3056 && (strcmp(l->mode,"launch")!=0) && (strcmp(l->mode,"connect")!=0)))
3057 {
3058 WerrorS("all links must be of type ssi:fork, ssi:tcp, ssi:connect");
3059 return -2;
3060 }
3061 if (strcmp(l->m->type,"ssi")==0)
3062 {
3063 d=(ssiInfo*)l->data;
3064 d_fd=d->fd_read;
3065 if (!s_isready(d->f_read))
3066 {
3067 if ((ignore==NULL) || (ignore[i]==FALSE))
3068 {
3069 FD_SET(d_fd, &fdmask);
3070 if (d_fd > max_fd) max_fd=d_fd;
3071 }
3072 }
3073 else
3074 return i+1;
3075 }
3076 else
3077 {
3078 Werror("wrong link type >>%s<<",l->m->type);
3079 return -2;
3080 }
3081 }
3082 }
3083 max_fd++;
3084 if (FD_SETSIZE<=max_fd)
3085 {
3086 Werror("file descriptor number too high (%d)",max_fd);
3087 return -2;
3088 }
3089
3090 /* check with select: chars waiting: no -> not ready */
3091 s = si_select(max_fd, &fdmask, NULL, NULL, wt_ptr);
3092 if (s==-1)
3093 {
3094 Werror("error in select call (errno:%d)",errno);
3095 return -2; /*error*/
3096 }
3097 if (s==0)
3098 {
3099 return 0; /*poll: not ready */
3100 }
3101 else /* s>0, at least one ready (the number of fd which are ready is s)*/
3102 {
3103 j=0;
3104 while (j<=max_fd) { if (FD_ISSET(j,&fdmask)) break; j++; }
3105 for(i=L->nr; i>=0; i--)
3106 {
3107 if (L->m[i].rtyp==LINK_CMD)
3108 {
3109 l=(si_link)L->m[i].Data();
3110 if (strcmp(l->m->type,"ssi")==0)
3111 {
3112 d=(ssiInfo*)l->data;
3113 d_fd=d->fd_read;
3114 if(j==d_fd) return i+1;
3115 }
3116 }
3117 }
3118 }
3119 return 0;
3120#endif
3121}
int k
Definition cfEzgcd.cc:99
int Typ()
Definition subexpr.cc:1048
int rtyp
Definition subexpr.h:91
void * Data()
Definition subexpr.cc:1192
sleftv * m
Definition lists.h:46
int nr
Definition lists.h:44
#define TIMER_RESOLUTION
Definition mod2.h:35
#define omAlloc0(size)
int s_isready(s_buff F)
Definition s_buff.cc:86
s_buff f_read
Definition s_buff.h:22
int fd_read
Definition s_buff.h:26
int status int fd
Definition si_signals.h:69
int getRTimer()
Definition timer.cc:150
@ DEF_CMD
Definition tok.h:58
@ LINK_CMD
Definition tok.h:117

◆ slString()

char * slString ( si_link l)
inlinestatic

Definition at line 101 of file silink.h.

102{
103 if (l->name != NULL)
104 {
105 return omStrDup(l->name);
106 }
107 else
108 {
109 return omStrDup("");
110 }
111}

◆ slWrite()

BOOLEAN slWrite ( si_link l,
leftv v )

Definition at line 307 of file silink.cc.

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

◆ ssiBatch()

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

Definition at line 3123 of file ssiLink.cc.

3125{
3127 char *buf=(char*)omAlloc(256);
3128 snprintf(buf,256,"ssi:connect %s:%s",host,port);
3129 slInit(l, buf);
3130 omFreeSize(buf,256);
3131 if (slOpen(l,SI_LINK_OPEN,NULL)) return 1;
3133
3134 idhdl id = enterid("link_ll", 0, LINK_CMD, &IDROOT, FALSE);
3135 IDLINK(id) = l;
3136
3137 loop
3138 {
3139 leftv h=ssiRead1(l); /*contains an exit.... */
3140 if (feErrors != NULL && *feErrors != '\0')
3141 {
3142 // handle errors:
3143 PrintS(feErrors); /* currently quite simple */
3144 *feErrors = '\0';
3145 }
3146 ssiWrite(l,h);
3147 h->CleanUp();
3149 }
3150 /* never reached*/
3151 _exit(0);
3152}
idhdl enterid(const char *s, int lev, int t, idhdl *root, BOOLEAN init, BOOLEAN search)
Definition ipid.cc:256
EXTERN_VAR omBin sleftv_bin
Definition ipid.h:145
#define IDLINK(a)
Definition ipid.h:138
#define IDROOT
Definition ipid.h:19
#define omFreeSize(addr, size)
#define omAlloc(size)
void PrintS(const char *s)
Definition reporter.cc:288
VAR char * feErrors
Definition reporter.cc:47
idrec * idhdl
Definition ring.h:22
#define loop
Definition structs.h:71

◆ ssiWrite2()

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

Definition at line 3475 of file ssiLink.cc.

3476{
3477 if((strcmp(l->mode,"string")==0)
3478 &&(u->Typ()==STRING_CMD))
3479 {
3480 StringSetS("");
3481 ssiWrite_S(u, currRing);
3482 res->data=(void*)StringEndS();
3483 res->rtyp=STRING_CMD;
3484 return res->data==NULL;
3485 }
3486 return TRUE;
3487}
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition polys.cc:13
void StringSetS(const char *st)
Definition reporter.cc:128
char * StringEndS()
Definition reporter.cc:151
@ 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.