GSI Object Oriented Online Offline (Go4)  GO4-6.1.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
f_evcli.c
Go to the documentation of this file.
1 // $Id: f_evcli.c 3348 2021-10-18 14:18:11Z linev $
2 //-----------------------------------------------------------------------
3 // The GSI Online Offline Object Oriented (Go4) Project
4 // Experiment Data Processing at EE department, GSI
5 //-----------------------------------------------------------------------
6 // Copyright (C) 2000- GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
7 // Planckstr. 1, 64291 Darmstadt, Germany
8 // Contact: http://go4.gsi.de
9 //-----------------------------------------------------------------------
10 // This software can be used under the license agreements as stated
11 // in Go4License.txt file which is part of the distribution.
12 //-----------------------------------------------------------------------
13 
14 /*1+ C Procedure *************+****************************************/
15 /* */
16 /*+ Module : f_evcli */
17 /* */
18 /*--------------------------------------------------------------------*/
19 /*+ CALLING : f_evcli_xxx() */
20 /*--------------------------------------------------------------------*/
21 /* */
22 /*+ PURPOSE : API for GOOSY - Event - Server or */
23 /* SBS - Event - Server . */
24 /* */
25 /*+ ARGUMENTS : */
26 /* */
27 /*2+Description***+***********+****************************************/
28 /* */
29 /*+ FUNCTION : Client for test purpose GOOSY - PAW - Server and */
30 /* SBS - Event - Server. */
31 /* (for detailed information see PC_CLIPAW) */
32 /* */
33 /*2+Implementation**********+******************************************/
34 /* */
35 /*+ PROCEDURES : see f_evcli_proc */
36 /* */
37 /*+ File name : f_evcli.c */
38 /* */
39 /*+ Version : 1.01 */
40 /*+ Author : R.S. Mayer, H.Essel */
41 /*+ Last Update : 28-feb-2000 */
42 /* */
43 /*2+Internals***************+******************************************/
44 /* */
45 /*+ Utility : */
46 /*+ File name : m_evcli.c */
47 /*+ Home direct.: LEA$SRC */
48 /*+ Created : 28-feb-2000 */
49 /* */
50 /*2+Updates*******+***********+****************************************/
51 /* */
52 /*+ Updates : Date Purpose */
53 /*1- C Procedure *************+*********************************************/
54 
55 /* ++++++++++++++ !!!! IMPLEMENTATION !!!! +++++++++++++++++++++++++++++++ */
56 #include "typedefs.h"
57 
58 
59 #define F__SWAP(ps,l,pd) f_swaplw((int *)ps,(int)l,(int *)pd)
60 #ifdef VMS /* ++++++++++++++ VMS ++++++++++++++++++++++++++++ */
61 #define UNIXENV 0 /* switch UNIX or VMS */
62 
63 /* standard headers ----- */
64 #include <stdio.h>
65 #include <errno.h>
66 #include <ctype.h>
67 #include <types.h>
68 #include <string.h>
69 #include <stdlib.h>
70 #endif /* VMS */
71 
72 #ifdef Lynx /* ++++++++++++++++ Lynx +++++++++++++++++++++++++++ */
73 #define UNIXENV 1 /* switch UNIX or VMS */
74 #endif /* Lynx */
75 
76 #ifdef HPUX /* +++++++++++++++++ HPUX ++++++++++++++++++++++++++++ */
77 #define UNIXENV 1 /* switch UNIX or VMS */
78 #define _HPUX_SOURCE /* this stuff is needed before */
79 #define _POSIX_SOURCE /* any include is done */
80 #endif /* HPUX */
81 
82 #ifdef Linux /* +++++++++++++++++ Linux ++++++++++++++++++++++++ */
83 #define UNIXENV 1 /* switch UNIX or VMS */
84 #endif
85 
86 #ifdef Solaris /* +++++++++++++++++ Solaris ++++++++++++++++++++++++ */
87 #define UNIXENV 1 /* switch UNIX or VMS */
88 #endif
89 
90 #ifdef Darwin /* +++++++++++++++++ Max OS X ++++++++++++++++++++++++ */
91 #define UNIXENV 1 /* switch UNIX or VMS */
92 #endif
93 
94 
95 #ifdef GSI__WINNT /* +++++++++++++++++ Windows NT ++++++++++++++++++++++++ */
96 #define UNIXENV 1 /* switch UNIX or VMS */
97 #define _ALL_SOURCE /* for types.h typedef u_char... */
98 #define _POSIX_SOURCE /* any include is done */
99 #endif
100 
101 
102 #ifdef _AIX /* +++++++++++++++++ AIX ++++++++++++++++++++++++++ */
103 #define UNIXENV 1 /* switch UNIX or VMS */
104 #define _ALL_SOURCE /* for types.h typedef u_char... */
105 #define _POSIX_SOURCE /* any include is done */
106 #define IN_AIX 1
107 #else
108 #define IN_AIX 0
109 #endif /* !_AIX */
110 
111 /* ++++++++++++++++ include UNIX standard headers +++++++++++++++++++++++++ */
112 #if UNIXENV == 1
113 #include <sys/types.h>
114 #ifdef GSI__WINNT
115 #include <sys/timeb.h>
116 #else
117 #include <sys/time.h> /* ? <time.h> */
118 #include <netdb.h>
119 #endif
120 #include <errno.h>
121 #include <stdio.h>
122 #include <string.h>
123 #include <stdlib.h>
124 #include <ctype.h>
125 #endif /* UNIXENV */
126 
127 /* ++++++++++++++++++++++ goopaw include files ++++++++++++++++++++++++++ */
128 #include "gps_sc_def.h" /* must be first */
129 #include "s_filter.h"
130 #include "clnt_buf_def.h"
131 #include "s_clntbuf.h"
132 
133 // DABC
134 #include "fLmd.h"
135 // --DABC
136 
137 #include "f_evcli.h"
138 #include "f_swaplw.h"
139 
140 #include "s_flt_descr.h"
141 #include "s_clnt_filter.h"
142 #include "s_opc1.h"
143 #include "s_pat.h"
144 
145 void f_clnup(long [], int *);
146 void f_clnup_save(long [], int *);
147 int f_fltdscr(struct s_clnt_filter *);
148 int f_read_server(s_evt_channel *, int *, int, int);
149 int f_send_ackn(int, int);
150 
151 unsigned short *pi_inbuf;
152 unsigned int *pl_inbuf;
153 unsigned int l_len_w;
154 int swapw(unsigned short *, unsigned short *, unsigned int);
155 int swapl(unsigned int *, unsigned int *, unsigned int);
156 static int i_debug = 0; /* message level (0-3) */
157 
158 #define EVT_MAX 1000
159 #define TCP__TIMEOUT 3000 /* TCP timeout reading buffer */
160 #define FLUSH__TIME 3 /* flush time interval for MBS event server */
161 #define STDOUT_BUFIO_ 1
162 
163 // JAM1-6-2021- test if this helps the streamserver problems
164 // #define DISABLE_POLLING_TIMEOUT 1
165 
166 
169 struct s_opc1 *p_opc1;
170 
171 static int unsigned lf_swap = 0; /* save swap on RX */
172 static int unsigned l_endian_serv; /* save endian server */
173 int i_channel; /* TCP/IP channel */
174 int unsigned l_clnt_sts; /* status for ackn. */
176 static char c_modnam[] = "f_evcli";
177 short i_sign = 1;
179 static struct s_tcpcomm s_tcpcomm_ec = {0,0,0};
180 
181 static struct {
182  int l_ack_buf; /* read client buff received */
183  int l_ack_bytes; /* read client bytes received */
184  int unsigned l_clnt_sts; /* client sts 1:o.k. 8:lst buf*/
185 } s_ackn;
186 
187 /* ++ vectors of pointer and devices for cleanup */
188 long v_mem_clnup[8];
189 
190 /***************************************************************************/
191 int f_evcli_con(s_evt_channel *ps_chan, char *pc_node, int l_aport, int l_aevents, int l_asample)
192 /***************************************************************************/
193 {
194  short i_h, i_m, i_s;
195  char c_node[32], c_retmsg[256];
196  int l_port;
197  int l_len_lw2, l_sts, l_retval; /* len for 2nd swap */
198 
199  v_mem_clnup[0] = 0;
200 
201  /* +++ allocate filter structure +++ */
202  p_clnt_filter = (struct s_clnt_filter *) malloc( sizeof(struct s_clnt_filter) );
203  if (p_clnt_filter == NULL)
204  {
205  printf("E-%s: calloc(,...s_clnt_filter) failed!\n", c_modnam);
206  printf("F-%s: aborting program execution!\n",c_modnam);
207  f_clnup(v_mem_clnup, NULL);
208  return(-1);
209  }
210  ps_chan->pc_evt_buf=(char *) p_clnt_filter;
211  /* save value for clnup */
212  f_clnup_save(v_mem_clnup, (int *) p_clnt_filter);
213  memset( (void *) p_clnt_filter, 0, sizeof(struct s_clnt_filter) );
214 
215  p_clnt_filter->l_testbit = GPS__ENV_TESTBIT; /* set testbit */
216  p_clnt_filter->l_endian = GPS__ENV_ENDIAN; /* set endian */
217  p_clnt_filter->l_numb_of_evt = l_aevents;
218  p_opc1 = (struct s_opc1 *) &p_clnt_filter->filter[0].l_opcode;
219  p_opc1->b1_evtsev = 1;
220  p_opc1->b1_selflt = 1;
221  p_opc1->b1_selwrt = 1;
222  p_opc1->b3_opc = 0;
223  p_opc1->b1_lnkf1 = 0;
224  p_opc1->b1_lnkf2 = 0;
225  p_opc1->h_fltspec = 0;
226  p_opc1->h_next_fltblk = 1;
227  p_opc1->h_flt_len = 1;
228 
229  l_status = f_fltdscr(p_clnt_filter);
230  /*
231  printf("evtsev: %d selflt: %d selwrt: %d opc: %d lnk1: %d lnk2: %d fltspec: %d next: %d len: %d\n"
232 ,p_opc1->b1_evtsev
233 ,p_opc1->b1_selflt
234 ,p_opc1->b1_selwrt
235 ,p_opc1->b3_opc
236 ,p_opc1->b1_lnkf1
237 ,p_opc1->b1_lnkf2
238 ,p_opc1->h_fltspec
239 ,p_opc1->h_next_fltblk
240 ,p_opc1->h_flt_len);
241  */
242  if ((l_status & 1) == 0)
243  {
244  printf("E-%s: Severe Error in f_fltdscr! Status:%d\n",
245  c_modnam,
246  l_status);
247  f_clnup(v_mem_clnup, NULL);
248  return(-1);
249  }
250  p_clnt_filter->l_sample_rate = l_asample;
251  p_clnt_filter->l_flush_rate = FLUSH__TIME;
252 
254  strncpy(c_node,pc_node, sizeof(c_node));
255  l_port = l_aport;
256 
257  l_status = (int) f_stc_connectserver(c_node,
258  l_port,
259  &i_channel,
260  &s_tcpcomm_ec);
261  if ((l_status & 1) != STC__SUCCESS)
262  {
263  printf("E-%s: Error connecting node:%s, port:%d. Msg:\n",
264  c_modnam,
265  c_node,
266  l_port);
267  f_stc_disperror((int) l_status,c_retmsg, 0);
268  f_stc_close(&s_tcpcomm_ec);
269  return(l_status);
270  }
271 
272  ps_chan->l_channel_no=i_channel;
273  /* + buffer flushing time + */
274  i_h = p_clnt_filter->l_flush_rate / 3600; /* hours */
275  i_s = p_clnt_filter->l_flush_rate - i_h * 3600;
276  i_m = i_s / 60; /* minutes */
277  i_s = i_s - i_m * 60; /* seconds */
278 
279  /* +++++++++++++++++++++++++++++++++ */
280  /* +++ send these data to server +++ */
281  /* +++++++++++++++++++++++++++++++++ */
282  /* len to transm [bytes] = 3 LW + filter + 1LW */
283  l_status = (int) f_stc_write( (char *) p_clnt_filter,
285  i_channel);
286  if (l_status != STC__SUCCESS)
287  {
288  printf("E-%s: Error in f_write_tcp(p_flt,...)! Status:%d. Msg:\n",
289  c_modnam,
290  l_status);
291  f_stc_disperror((int) l_status,c_retmsg, 0);
292  f_stc_close(&s_tcpcomm_ec);
293  return(l_status);
294  }
295  /* + + + + + + + + + + + + + + */
296  /* +++ alloc input buffer +++ */
297  /* + + + + + + + + + + + + + + */
298  p_clntbuf = (struct s_clntbuf *) malloc(sizeof(struct s_clntbuf));
299  if (p_clntbuf == NULL)
300  {
301  printf("E-%s: malloc(p_clntbuf) failed!\n", c_modnam);
302  printf("F-%s: aborting program execution!\n",c_modnam);
303  f_stc_close(&s_tcpcomm_ec);
304  return(-1);
305  }
306  /* save value for clnup */
307  f_clnup_save(v_mem_clnup, (int *) p_clntbuf);
308 
309  ps_chan->pc_io_buf = (char *) p_clntbuf;
311  /* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
312  /* ++++ first read on server, get machine type & swap ++++ */
313  /* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
314  memset(p_clntbuf,0, sizeof(struct s_clntbuf)); /* clear memory */
315  l_status = f_read_server(ps_chan,
316  &l_retval,
317  l_timeout,
318  i_channel);
319  if (l_status != TRUE)
320  {
321  printf("E-%s: Error reading 1st buffer: f_read_server()!\n", c_modnam);
322  f_stc_close(&s_tcpcomm_ec);
323  return(l_status);
324  }
325 
326  /* ++++++++++++++++++++++++++++++++++++ */
327  /* +++ check if a LW swap is needed +++ */
328  /* ++++++++++++++++++++++++++++++++++++ */
329  lf_swap = (p_clntbuf->l_testbit == GPS__ENV_TESTBIT) ? 0 : 1;
330  l_endian_serv = p_clntbuf->l_endian;
331 
332  if (lf_swap)
333  /* + + + + + + + + + + + + + + + + + */
334  /* +++ swap after every receive +++ */
335  /* + + + + + + + + + + + + + + + + + */
336  {
337  l_sts = F__SWAP(&p_clntbuf->l_testbit,CLNT__BUFH_LW,0);
338 
339  l_len_lw2 = CLNT__REST_LW + p_clntbuf->l_dlen/4; /* <N> !!! */
340  l_sts = F__SWAP(&p_clntbuf->l_inbuf_read_cnt, l_len_lw2, 0);
341 
342  (void) l_sts; // fix compiler warning
343 
344  if (p_clntbuf->l_testbit != GPS__ENV_TESTBIT) /* <T> */
345  {
346  printf("F-%s: Error swapping first buffer from client\n",
347  c_modnam);
348  f_stc_close(&s_tcpcomm_ec);
349  return(-1);
350  }
351  }
352 
353  /* + + + + + + + + + + + + + + + + + + + + + + + + + */
354  /* +++ first buffer should be a message buffer! +++ */
355  /* + + + + + + + + + + + + + + + + + + + + + + + + + */
356  if (p_clntbuf->l_buffertype & 16)
357  {
358  }
359 
360  if (p_clntbuf->l_buffertype & 2) { /* buffer contains message */
361  /*
362  switch (p_clntbuf->l_msgtyp & 15)
363  {
364  case 1:
365  case 2: printf("MSG-type:W: %s\n", p_clntbuf->c_message); break;
366  case 4: printf("MSG-type:E: %s\n", p_clntbuf->c_message); break;
367  case 8: printf("MSG-type:F: %s\n", p_clntbuf->c_message); break;
368  default: printf("Unknown MSG-type:%d:\n%s\n",p_clntbuf->l_msgtyp,p_clntbuf->c_message);
369  }
370  */
371  }
372 
373  return(STC__SUCCESS);
374 } /* f_evcli_con */
375 
376 
377 /***************************************************************************/
379 /***************************************************************************/
380 {
381  // s_ve10_1 *ps_ve10_1;
382  char *ps_buf;
383  int l_len_lw2, l_sts, l_retval; /* len for 2nd swap */
384 
385  /* ++++++++++++++++++++++++++++++ */
386  /* +++ send acknowledge buffer +++ */
387  /* ++++++++++++++++++++++++++++++ */
388 
389  l_status = f_send_ackn(1, ps_chan->l_channel_no);
390  if (l_status != TRUE)
391  {
392  printf("E-%s: Error sending acknowledge: f_send_ackn()!\n", c_modnam);
393  f_stc_close(&s_tcpcomm_ec);
394  return(l_status);
395  }
396  /* +++++++++++++++++++++++++ */
397  /* +++ read input buffer +++ */
398  /* +++++++++++++++++++++++++ */
399  p_clntbuf = (struct s_clntbuf *) ps_chan->pc_io_buf;
400  ps_buf = ps_chan->pc_io_buf; /* save for comparison */
401  memset(p_clntbuf,0, ps_chan->l_io_buf_size);
402  l_status = f_read_server(ps_chan,
403  &l_retval,
404  l_timeout,
405  ps_chan->l_channel_no);
406 
407  /* in case pc_io_buf has been reallocated */
408  if(ps_buf != ps_chan->pc_io_buf)
409  {
410  f_clnup(v_mem_clnup, NULL); /* free all old buffers */
411  p_clntbuf = (struct s_clntbuf *) ps_chan->pc_io_buf;
413  }
414  if (l_status != TRUE)
415  {
416  printf("E-%s: Error reading buffer: f_read_server()!\n", c_modnam);
417  f_stc_close(&s_tcpcomm_ec);
418  return(l_status);
419  }
420  l_clnt_sts = 0; /* reset */
421 
422  /* +++++++++++++++++++++++++++++++++ */
423  /* +++ swap every buffer in loop +++ */
424  /* +++++++++++++++++++++++++++++++++ */
425  if (lf_swap)
426  {
427  l_sts = F__SWAP(&p_clntbuf->l_testbit,CLNT__BUFH_LW, 0);
428  l_len_lw2 = CLNT__REST_LW + p_clntbuf->l_dlen/4; /* <N> !!! */
429 
430  /* 4 byte swap */
431  pl_inbuf = &p_clntbuf->l_inbuf_read_cnt;
432  l_sts = F__SWAP(pl_inbuf, l_len_lw2, 0);
433  }
434  /* printf("Buffer %8d bytes, dlen %8d events %6d\n",l_retval,p_clntbuf->l_dlen,p_clntbuf->l_events);
435  ps_ve10_1=(s_ve10_1 *)&p_clntbuf->c_buffer[0];
436  for(ii=0;ii<p_clntbuf->l_events;ii++)
437  {printf("Event %2d, t/s %3d %2d, len %d\n",ii+1,ps_ve10_1->i_type,ps_ve10_1->i_subtype,ps_ve10_1->l_dlen);
438  ps_ve10_1 = (s_ve10_1 *) ((short *)ps_ve10_1 + ps_ve10_1->l_dlen + 4); }
439  */
440  /* ++++++++++++++++++++++++ */
441  /* +++ message handling +++ */
442  /* ++++++++++++++++++++++++ */
443  l_sts=STC__SUCCESS;
444  if (p_clntbuf->l_buffertype & 2)
445  { /* buffer contains message */
446  switch (p_clntbuf->l_msgtyp & 15)
447  {
448  case 1:
449  case 2:
450  if((strstr(p_clntbuf->c_message, "no event data") == NULL) &&
451  (strstr(p_clntbuf->c_message, "flushed") == NULL))
452  printf("MSG-type:W: %s\n", p_clntbuf->c_message);
453  break;
454  case 4:
455  printf("MSG-type:E: %s\n", p_clntbuf->c_message);
456  break;
457  case 8:
458  printf("MSG-type:F: %s\n", p_clntbuf->c_message);
459  break;
460  default:
461  printf("Unknown MSG-type:%d:\n%s\n",p_clntbuf->l_msgtyp,p_clntbuf->c_message);
462  }
463  l_sts = STC__TIMEOUT; /* buffer without events */
464  }
465  else
466  {
467  if(p_clntbuf->l_events == 0)
468  {
469  l_sts = STC__TIMEOUT;
470  }
471  }
472  ps_chan->pc_evt_buf = (char *)&p_clntbuf->c_buffer[0];
473  ps_chan->l_evt_buf_posi = 1; /* number of events */
474  // ps_ve10_1 = (s_ve10_1 *) ps_chan->pc_evt_buf;
475  return l_sts;
476 } /* end f_evcli_buf */
477 
478 /***************************************************************************/
480 /***************************************************************************/
481 {
482  int *ps_int;
483  s_ve10_1 *ps_ve10_1;
484 
485  p_clntbuf = (struct s_clntbuf *) ps_chan->pc_io_buf;
486  if(ps_chan->l_evt_buf_posi < p_clntbuf->l_events)
487  {
488  ps_chan->l_evt_buf_posi++;
489  ps_ve10_1 = (s_ve10_1 *) ps_chan->pc_evt_buf;
490  ps_int = (int *) ps_chan->pc_evt_buf;
491  ps_int += ps_ve10_1->l_dlen/2 + 2;
492  ps_chan->pc_evt_buf = (char *) ps_int;
493  return(STC__SUCCESS);
494  }
495  else return(-1);
496 }
497 /***************************************************************************/
499 /***************************************************************************/
500 {
501  /* ++++++++++++++++++++++++++++++ */
502  /* +++ send acknowledge buffer +++ */
503  /* ++++++++++++++++++++++++++++++ */
504  l_status = f_send_ackn(8, ps_chan->l_channel_no);
505  if (l_status != TRUE)
506  {
507  printf("E-%s: Error sending acknowledge: f_send_ackn()!\n", c_modnam);
508  return(l_status);
509  }
510  f_clnup(v_mem_clnup, NULL);
511  f_stc_discclient(ps_chan->l_channel_no);
512  f_stc_close(&s_tcpcomm_ec);
513 return(STC__SUCCESS);
514 }
515 
516 
517 /*2+F_FLTDSCR***+******************************************************/
518 /* */
519 /*+ Module : F_FLTDSCR */
520 /* */
521 /* */
522 /*--------------------------------------------------------------------*/
523 /*+ CALLING : sts = f_fltdscr(p_clnt_filter) */
524 /* */
525 /* */
526 /*--------------------------------------------------------------------*/
527 /* */
528 /*+ PURPOSE : Read and check the event filter and construct the */
529 /* filter descriptor. */
530 /* */
531 /*+ ARGUMENTS : p_clnt_filter: Pointer to structure s_clnt_filter */
532 /* */
533 /*+ FUNCTION : Read and check the event filter and construct the */
534 /* filter descriptor. Output via "printf". */
535 /* See also I$PS_FLTDSC_PRTCL */
536 /* */
537 /*+ Return type : int (32 bit) */
538 /*+ Status codes: bit 0: success */
539 /* bit 1: warning */
540 /*+ Initialize : - */
541 /*+ Include name: - */
542 /* */
543 /*3+Implementation************+****************************************/
544 /* */
545 /*+ File name : PC_PROC.C */
546 /*+ Version : 1.01 */
547 /*+ Author : R.S. Mayer */
548 /*+ Last Update : 14-JUN-1993 */
549 /*+ Object libr.: GOOSHRLIB */
550 /*3+Updates*******+***********+****************************************/
551 /* */
552 /*+ Updates : Date Purpose */
553 /* */
554 /*3+Description***+***********+****************************************/
555 /*1- C Procedure ***********+******************************************/
556 int f_fltdscr(struct s_clnt_filter * p_clnt_filter) /* read filter, check and */
557 {
558  static char c_modnam[] = "f_fltdscr";
559  struct s_filter *p_filter;
560  struct s_opc1 *p_opc1;
561  struct s_flt_descr *p_flt_descr;
562 
563  short i_fltdescnt = 0;
564  // short i_fltcnt = 0;
565  short i_fltblkcnt = 0;
566  short i, i_flt_len,
567  i_fltblkbeg, i_fltblkend, j;
568  short if_newfltblk = 1;
569  short i_next_fltblk = 0; // SL 16.11.2009 add initialization to 0
570  // short i_descr; /* test */
571  int l_evtdescr, *pl_evtdescr, *pl_sev1descr, *pl_sev2descr;
572  short i_lasevtflt, i_1stsevflt;
573 
574  int unsigned l_retsts = 0;
575 
576  /* +++ action +++ */
577  if (i_debug == 2)
578  printf("--->D-%s: addr_filter p:%p\n", c_modnam, p_clnt_filter);
579 
580  /* init pointer */
581  p_flt_descr = (struct s_flt_descr *) &p_clnt_filter->flt_descr[0];
582 
583  /* +++ loop over all filter block descriptors +++ */
584  for (i = 0; i < GPS__MAXFLT; i++)
585  {
586  p_filter = (struct s_filter *) &p_clnt_filter->filter[i];
587  p_opc1 = (struct s_opc1 *) &p_filter->l_opcode;
588 
589  if (i_debug == 2)
590  printf("D-%s: i:%d opc:%x flt_len:%d\n",
591  c_modnam,
592  i,
593  p_filter->l_opcode,
594  p_opc1->h_flt_len);
595 
596  if (i == i_next_fltblk)
597  if_newfltblk = 1;
598 
599  if (p_opc1->h_flt_len == 0)
600  {
601  // i_fltcnt = i;
602  p_opc1->h_next_fltblk = 0; /* no next descriptor */
603  p_flt_descr->h_nextdescr = 0; /* no next descriptor */
604  break; /* no more filter */
605  } /* if (p_opc1->h_next_fltblk == 0) */
606 
607 /* if (p_opc1->b3_opc == 0) {
608  * printf("I-%s: b3_opc == 0. Take all events!\n",
609  * c_modnam);
610  * }
611  */
612 
613  if (if_newfltblk)
614  {
615  if_newfltblk = 0;
616  i_fltblkcnt++;
617  i_flt_len = p_opc1->h_flt_len;
618  i_next_fltblk = i + i_flt_len;
619  i_fltblkbeg = i;
620  i_fltblkend = i_next_fltblk - 1;
621 
622  if (p_opc1->b1_selwrt == 1) {
623  /* write block */
624  p_flt_descr = (struct s_flt_descr *) &p_clnt_filter->flt_descr[0];
625  // i_descr = 0; /* test */
626 
627  if (p_flt_descr->hf_wrtdescr == 1 &&
628  p_clnt_filter->flt_descr[0].i_descriptors <= 0)
629  {
630  printf("W-%s: >1 write blocks, previous one(s) ignored!\n",
631  c_modnam);
632  l_retsts = l_retsts | 2;
633  }
634 
635  p_flt_descr->hf_wrtdescr = 1;
636  p_flt_descr->hf_fltdescr = 0;
637  p_flt_descr->h_fltblkbeg = i_fltblkbeg;
638  p_flt_descr->h_fltblkend = i_fltblkend;
639  p_flt_descr->h_nextdescr = 1;
640 
641  /* save write block values */
642  p_clnt_filter->if_wrtevt = (p_opc1->b1_evtsev == 1) ? 1 : 0;
643  p_clnt_filter->if_wrtsev = (p_opc1->b1_evtsev != 1) ? 1 : 0;
644  } /* if (p_opc1->b1_selwrt == 1) */
645 
646  if (p_opc1->b1_selflt == 1) {
647  /* filter block */
648  if (i_fltdescnt == 0)
649  i_fltdescnt++;
650  // i_descr = i_fltdescnt; /* test */
651  p_flt_descr = (struct s_flt_descr *) &p_clnt_filter->flt_descr[i_fltdescnt];
652  p_flt_descr->hf_wrtdescr = 0;
653  p_flt_descr->hf_fltdescr = 1;
654  p_flt_descr->h_fltblkbeg = i_fltblkbeg;
655  p_flt_descr->h_fltblkend = i_fltblkend;
656  p_flt_descr->h_nextdescr = ++i_fltdescnt;
657  /* save write block values */
658  if (p_opc1->b1_evtsev == 1)
659  p_clnt_filter->if_fltevt = 1;
660  else
661  p_clnt_filter->if_fltsev = 1;
662  } /* if (p_opc1->b1_selflt == 1) */
663 
664  } /* if (if_newfltblk) */
665 
666  /* identical values for the whole flt blk */
667  p_opc1->h_flt_len = i_flt_len;
668  p_opc1->h_next_fltblk = i_next_fltblk;
669 
670  /* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
671  /* ++++ build pattern and offset values from h_fltspec ++++ */
672  /* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
673 
674  /* ++++ check if Filter specification is valid ++++ */
675  if ((p_opc1->h_fltspec > 15) && (p_opc1->b1_evtsev == 1))
676  {
677  printf("E-%s: Filter specification %d invalid for events\n",
678  c_modnam,
679  p_opc1->h_fltspec);
680  return(FALSE); /* abort with error */
681  }
682  if ((p_opc1->h_fltspec < 2) && (p_opc1->b1_evtsev != 1))
683  {
684  printf("E-%s: Filter specification %d invalid for subevents\n",
685  c_modnam,
686  p_opc1->h_fltspec);
687  return(FALSE); /* abort with error */
688  }
689 
690  switch (p_opc1->h_fltspec)
691  {
692  case 0: /* ++++ take all ++++ */
693  if (p_opc1->b3_opc != 0) {
694  printf("W-%s: Take all. Set opcode to 0, next time\n",
695  c_modnam);
696  p_opc1->b3_opc = 0;
697  l_retsts = l_retsts | 2;
698  }
699  break;
700 
701  case 1: /* ++++ trigger ++++ */
702 /* if (p_filter->l_offset >= 0)
703  */
704  p_filter->l_offset = -5; /* trigger = event + 5 W */
705  p_filter->l_pattern = p_filter->l_pattern & 0xFFFF;
706  break;
707 
708  case 2: /* ++++ pattern and offset ++++ */
709  break;
710 
711  case 4: /* W ++++ type ++++ */
712 /* if (p_filter->l_offset >= 0)
713  */
714  p_filter->l_offset = -2; /* type = evt(sev) + 2 W */
715  p_filter->l_pattern = p_filter->l_pattern & 0xFFFF;
716 
717  break;
718 
719  case 8: /* W ++++ subtype ++++ */
720 /* if (p_filter->l_offset >= 0)
721  */
722  p_filter->l_offset = -3; /* subtype = evt(sev) + 3 W */
723  p_filter->l_pattern = p_filter->l_pattern & 0xFFFF;
724 
725  break;
726 
727  case 12: /* LW ++++ type and subtype ++++ */
728 /* if (p_filter->l_offset >= 0)
729  */
730  p_filter->l_offset = 1; /* type-subtype = evt(sev) + 1 LW*/
731 
732  break;
733 
734  case 16: /* W ++++ procid ++++ */
735 /* if (p_filter->l_offset >= 0)
736  */
737  p_filter->l_offset = -4; /* procid = sev + 4 W */
738  p_filter->l_pattern = p_filter->l_pattern & 0xFFFF;
739 
740  break;
741 
742  case 32: /* W ++++ subcrate,contr ++++*/
743 /* if (p_filter->l_offset >= 0)
744  */
745  p_filter->l_offset = -5; /* subcrate,contr = sev + 5 W */
746  p_filter->l_pattern = p_filter->l_pattern & 0xFFFF;
747 
748  break;
749 
750  case 48: /* LW ++++procid,subcr,contr ++++*/
751 /* if (p_filter->l_offset >= 0)
752  */
753  p_filter->l_offset = 2; /* procid,subc,ctrl = sev + 2 LW */
754 
755  break;
756 
757  default:
758  printf("W-%s: FLTSPEC %d NOT FOUND\n",
759  c_modnam,
760  p_opc1->h_fltspec);
761  l_retsts = l_retsts | 2;
762  } /* switch case */
763 
764 
765 
766  } /* for */
767 
768  p_flt_descr = (struct s_flt_descr *) &p_clnt_filter->flt_descr[0];
769  if (p_flt_descr->hf_wrtdescr != 1) {
770  printf("E-%s: The write filter is missing! Filter is invalid!\n",
771  c_modnam);
772  return(FALSE);
773  }
774 
775  if (!(p_clnt_filter->if_fltevt || p_clnt_filter->if_fltsev)) {
776  printf("E-%s: The filter itself is missing! Filter is invalid!\n",
777  c_modnam);
778  return(FALSE);
779  }
780 
781 /* printf(
782  * "I-%s: p_clnt:%d: found %d flts in %d blks with %d descript.\n",
783  * c_modnam,
784  * p_clnt_filter,
785  * i_fltcnt,
786  * i_fltblkcnt,
787  * i_fltdescnt);
788  */
789 
790  if ( (p_clnt_filter->if_fltevt == 1) && (p_clnt_filter->if_fltsev == 1) ) {
791  m_sort_descr:; /* sort event and subevent filter */
792  i_lasevtflt = 0; /* last event filter init */
793  i_1stsevflt = i_fltdescnt; /* first subevent filter init */
794  /* sort filter blocks: flt event should come before flt sev */
795  for (i = 1; i < i_fltdescnt; i++) {
796  p_flt_descr = (struct s_flt_descr *) &p_clnt_filter->flt_descr[i];
797  p_filter = (struct s_filter *)
798  &p_clnt_filter->filter[(int)p_flt_descr->h_fltblkbeg];
799  p_opc1 = (struct s_opc1 *) &p_filter->l_opcode;
800 
801  if ( (p_opc1->b1_selflt == 1) && (p_opc1->b1_evtsev == 1) )
802  i_lasevtflt = i; /* save last evt flt found */
803 
804  if ( (p_opc1->b1_selflt == 1) &&
805  (p_opc1->b1_evtsev == 0) &&
806  (i_1stsevflt == i_fltdescnt) )
807  i_1stsevflt = i; /* save last evt flt found */
808 
809  if (i_1stsevflt < i_lasevtflt) { /* evt flt after sev flt */
810  printf(
811  "W-%s 1stsevflt:%d lastevtflt:%d. Evt flt should come first\n",
812  c_modnam,
813  i_1stsevflt,
814  i_lasevtflt);
815  l_retsts = l_retsts | 2;
816  /* copy first LW from evt descr */
817  pl_evtdescr = (int *) &p_clnt_filter->flt_descr[i_lasevtflt];
818  l_evtdescr = *pl_evtdescr;
819  /* shift the subevent descriptors */
820  for (j = i_lasevtflt; j > i_1stsevflt; j--) {
821  pl_sev1descr = (int *) &p_clnt_filter->flt_descr[j-1];
822  pl_sev2descr = (int *) &p_clnt_filter->flt_descr[j];
823  *pl_sev2descr = *pl_sev1descr;
824  }
825  pl_evtdescr = (int *) &p_clnt_filter->flt_descr[i_1stsevflt];
826  *pl_evtdescr = l_evtdescr;
827  goto m_sort_descr; /* until descr is in right order */
828  } /* if */
829 
830  } /* for */
831 
832  } /* if (...if_fltevt... && ...if_fltsev...) */
833 
834  /* + + + Max number of descriptors + + + */
835  p_clnt_filter->flt_descr[0].i_descriptors = i_fltdescnt;
836 
837  /* ++++ check the subevent filter blocks ++++ */
838  /* + the first filter in the sev flt blk identifies the sev + */
839  /* + normaly Procid or Procid + Subcrate + */
840  if (p_clnt_filter->if_fltsev == 1) {
841  for (i = 1; i < p_clnt_filter->flt_descr[0].i_descriptors; i++) {
842  p_flt_descr = (struct s_flt_descr *) &p_clnt_filter->flt_descr[i];
843  /* ++ addr of the first filter in the flt blk ++ */
844  p_filter = (struct s_filter *)
845  &p_clnt_filter->filter[(int)p_flt_descr->h_fltblkbeg];
846  p_opc1 = (struct s_opc1 *) &p_filter->l_opcode;
847 
848  } /* for */
849  } /* if (p_clnt_filter->if_fltsev... */
850 
851  return(l_retsts | 1);
852 
853 } /* end f_fltdscr */
854 
855 
856 
857 /*2+F_FLTRD***+********************************************************/
858 /* */
859 /*+ Module : F_FLTRD */
860 /* */
861 /* */
862 /*--------------------------------------------------------------------*/
863 /*+ CALLING : sts = f_fltrd(p_clnt_filter, c_file) */
864 /* */
865 /* */
866 /*--------------------------------------------------------------------*/
867 /* */
868 /*+ PURPOSE : Reads filter specification from a file */
869 /* */
870 /*+ ARGUMENTS : */
871 /*+ p_clnt_filter: Pointer to structure s_clnt_filter */
872 /*+ c_file : Pointer to file name string */
873 /* */
874 /*+ FUNCTION : Opens the file and reads filter specification */
875 /* */
876 /*+ Return type : int (32 bit) */
877 /*+ Status codes: - */
878 /*+ Initialize : - */
879 /*+ Include name: - */
880 /* */
881 /*3+Implementation************+****************************************/
882 /* */
883 /*+ File name : PC_PROC.C */
884 /*+ Version : 1.01 */
885 /*+ Author : R.S. Mayer */
886 /*+ Last Update : 14-JUN-1993 */
887 /*+ Object libr.: GOOSHRLIB */
888 /*3+Updates*******+***********+****************************************/
889 /* */
890 /*+ Updates : Date Purpose */
891 /*- 25-Jan-1994 : problems with sscanf removed (RSM) */
892 /* */
893 /*3+Description***+***********+****************************************/
894 /*1- C Procedure ***********+******************************************/
895 int f_fltrd(p_clnt_filter, c_file)
896 struct s_clnt_filter *p_clnt_filter;
897 char *c_file; /* ptr to file name */
898 {
899 
900  /* ++++ declaration ++++ */
901  FILE *infile;
902 
903  static char c_modnam[] = "f_fltrd";
904  struct s_filter *p_filter;
905  struct s_opc1 *p_opc1;
906 
907  char c_retmsg[256];
908  char c_line[80], c_comment[80], *c_fsts, *p_com, *p_minus;
909  short i_fltblklen = 0;
910  short i_currflt = 0;
911  short i;
912  int l_scan=0;
913 
914  int unsigned l_pattern;
915  int l_offset;
916  int unsigned l_offset_unsigned;
917 
918  short i_evtsev,i_selflt,i_selwrt,i_opc,i_lnkf1,
919  i_lnkf2,i_fltspec;
920  short if_hex, if_comment;
921 
922  char *fgets( char *str, int maxchar, FILE *file_ptr);
923 
924  /* +++ action +++ */
925 
926  if ( (infile = fopen(c_file,"r")) == 0)
927  { /* open file for data input */
928  sprintf(c_retmsg,"E-%s: fopen(File=%s) ",
929  c_modnam,
930  c_file);
931  perror(c_retmsg);
932  fclose(infile);
933  return(FALSE);
934  }
935 
936  printf("Filter definition from file %s\n", c_file);
937  printf("=======================================\n");
938 
939  while (l_scan != EOF && i_fltblklen < GPS__MAXFLT)
940  {
941  m_read_nxtblklen:;
942 
943  memset(c_line,0,sizeof(c_line));
944 
945  if ( (c_fsts = fgets(c_line, sizeof(c_line), infile)) == 0)
946  {
947  if (i_debug == 2)
948  printf("D-%s: File=%s: Last input line.\n",
949  c_modnam,
950  c_file);
951  break;
952  }
953 
954  if_comment = 0; /* reset flag */
955  p_com = strpbrk(c_line,"!/*"); /* find position of comment */
956  if (p_com != NULL) { /* found a comment */
957  if_comment = 1; /* set flag */
958  strncpy(c_comment, p_com, sizeof(c_comment)); /* copy comment */
959  *p_com = '\0'; /* mark end of str at beg of comm*/
960  if (i_debug == 2)
961  printf(" - D: comment:%s", c_comment);
962 
963  }
964 
965  l_scan = sscanf(c_line, "%hd", &i_fltblklen);
966  if (if_comment && (l_scan < 1) )
967  goto m_read_nxtblklen;
968 
969  if (l_scan == EOF || l_scan == 0 || c_fsts == NULL)
970  {
971  if (i_debug == 2)
972  printf("D-%s: Last input line.\n",c_file);
973  break;
974  }
975 
976  if (i_fltblklen + i_currflt >= GPS__MAXFLT)
977  {
978  printf("E-%s: too long. Last filter block ignored\n",
979  c_modnam);
980  fclose(infile);
981  return(3);
982  }
983  if (i_debug == 2)
984  printf("D-%s: Fltblklen:%d\n", c_modnam, i_fltblklen);
985 
986  for (i = i_currflt; i < i_fltblklen + i_currflt; i++)
987  {
988  m_read_nxtline:;
989 
990  memset(c_line,0,sizeof(c_line));
991 
992  if ( (c_fsts = fgets(c_line, sizeof(c_line), infile)) == 0)
993  {
994  sprintf(c_retmsg,"E-%s: Error reading:fgets(File=%s) ",
995  c_modnam,
996  c_file);
997  perror(c_retmsg);
998  fclose(infile);
999  return(FALSE);
1000  }
1001 
1002  if (i_debug == 2)
1003  printf("D-%s: line:%s", c_modnam, c_line);
1004 
1005  if_comment = 0; /* reset flag */
1006  p_com = strpbrk(c_line, "!/*"); /* find position of comment */
1007  if (p_com != NULL) { /* found a comment */
1008  if_comment = 1; /* set flag */
1009  strncpy(c_comment, p_com, sizeof(c_comment)); /* copy comment */
1010  *p_com = '\0'; /* mark end of str at beg of comm*/
1011  if (i_debug == 2)
1012  printf(" - D: comment:%s", c_comment);
1013  }
1014 
1015  l_scan = sscanf(c_line,"%hd %hd %hd %hd %hd %hd %hd %u %d",
1016  &i_evtsev,
1017  &i_selflt,
1018  &i_selwrt,
1019  &i_opc,
1020  &i_lnkf1,
1021  &i_lnkf2,
1022  &i_fltspec,
1023  &l_pattern,
1024  &l_offset);
1025  if_hex = 0; /* set flag null */
1026  if (l_scan == 9)
1027  goto m_ok_assign;
1028 
1029  if_hex = 1; /* set flag null */
1030  p_minus = strchr(c_line,'-'); /* find minus sign in offset */
1031 
1032  if (p_minus != NULL) /* found minus sign */
1033  *p_minus = ' '; /* replace minus with blank */
1034 
1035  l_scan = sscanf(c_line,"%hd %hd %hd %hd %hd %hd %hd %x %x",
1036  &i_evtsev,
1037  &i_selflt,
1038  &i_selwrt,
1039  &i_opc,
1040  &i_lnkf1,
1041  &i_lnkf2,
1042  &i_fltspec,
1043  &l_pattern,
1044  &l_offset_unsigned);
1045 
1046  l_offset = (p_minus != NULL) ? -1*(int)l_offset_unsigned : l_offset_unsigned;
1047 
1048  if (l_scan < 9)
1049  {
1050  if (if_comment)
1051  goto m_read_nxtline;
1052 
1053  printf(
1054  "E-%s: scanned only %d(of 9) var., last 2 must be dec or hexa\n",
1055  c_modnam,
1056  l_scan);
1057  fclose(infile);
1058  return(FALSE);
1059  }
1060 
1061  m_ok_assign:
1062  if (i_debug == 2) {
1063  sprintf( c_retmsg,
1064  "%s es:%d f:%d w:%d opc:%d lf1:%d lf2:%d flt:%d p:%x o:%x",
1065  (if_hex) ? "HEX:" : "DEC:",
1066  i_evtsev,
1067  i_selflt,
1068  i_selwrt,
1069  i_opc,
1070  i_lnkf1,
1071  i_lnkf2,
1072  i_fltspec,
1073  l_pattern,
1074  (unsigned) l_offset);
1075  printf("D-%s: %s\n", c_modnam, c_retmsg);
1076  }
1077 
1078  p_filter = (struct s_filter *) &p_clnt_filter->filter[i];
1079  p_opc1 = (struct s_opc1 *) &p_filter->l_opcode;
1080 
1081  p_opc1->h_next_fltblk = (char) i_fltblklen + i_currflt;
1082  p_opc1->h_flt_len = (char) i_fltblklen;
1083 
1084  p_filter->l_pattern = l_pattern;
1085  p_filter->l_offset = l_offset;
1086 
1087  p_opc1->b1_evtsev = i_evtsev;
1088  p_opc1->b1_selflt = i_selflt;
1089  p_opc1->b1_selwrt = i_selwrt;
1090  p_opc1->b3_opc = i_opc;
1091  p_opc1->b1_lnkf1 = i_lnkf1;
1092  p_opc1->b1_lnkf2 = i_lnkf2;
1093  p_opc1->h_fltspec = (char) i_fltspec;
1094 
1095  } /* for */
1096 
1097  i_currflt = (short) p_opc1->h_next_fltblk;
1098 
1099  } /* while */
1100 
1101  fclose(infile);
1102 
1103  return(TRUE);
1104 }
1105 
1106 
1107 
1108 /*2+F_TYPFLT***+*******************************************************/
1109 /* */
1110 /*+ Module : F_TYPFLT */
1111 /* */
1112 /* */
1113 /*--------------------------------------------------------------------*/
1114 /*+ CALLING : sts = f_typflt(p_clnt_filter) */
1115 /* */
1116 /* */
1117 /*--------------------------------------------------------------------*/
1118 /* */
1119 /*+ PURPOSE : Type the filter conditions. */
1120 /* */
1121 /*+ ARGUMENTS : p_clnt_filter: Pointer to s__clnt_filter */
1122 /* */
1123 /*+ FUNCTION : Type the filter conditions. Output via "printf". */
1124 /* See also I$PS_TYPFLT_PRTCL. */
1125 /* */
1126 /*+ Return type : int (32 bit) 1: success 0: fault */
1127 /*+ Status codes: - */
1128 /*+ Initialize : - */
1129 /*+ Include name: - */
1130 /* */
1131 /*3+Implementation************+****************************************/
1132 /* */
1133 /*+ File name : PC_PROC.C */
1134 /*+ Version : 1.01 */
1135 /*+ Author : R.S. Mayer */
1136 /*+ Last Update : 14-JUN-1993 */
1137 /*+ Object libr.: GOOSHRLIB */
1138 /*3+Updates*******+***********+****************************************/
1139 /* */
1140 /*+ Updates : Date Purpose */
1141 /*- 12-Jan-1994 : Bug removed in subcrate,control (RSM) */
1142 /* */
1143 /*3+Description***+***********+****************************************/
1144 /*1- C Procedure ***********+******************************************/
1145 int f_typflt(p_clnt_filter)
1146 struct s_clnt_filter *p_clnt_filter;
1147 {
1148  static char c_modnam[] = "f_typflt";
1149  struct s_filter *p_filter;
1150  struct s_opc1 *p_opc1;
1151  struct s_flt_descr *p_flt_descr;
1152  struct s_pat1 *p_pat1;
1153  struct s_pat2 *p_pat2;
1154  struct s_pat3 *p_pat3;
1155 
1156  short i_fltdescnt, j, i;
1157 
1158  /* +++ action +++ */
1159 
1160  /* + + + Max number of descriptors + + + */
1161  i_fltdescnt = p_clnt_filter->flt_descr[0].i_descriptors;
1162 
1163  /* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */
1164  /* + + + Output filter conditions for Write and Filter + + + */
1165  /* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */
1166 /* printf("Explanation: object OPCODE mask\n===========\n");
1167  */
1168  if ( (i_debug == 1) || (i_debug == 2) )
1169  printf(
1170  "Write:%s %s Filter:%s %s object OPCODE mask",
1171  (p_clnt_filter->if_wrtevt > 0) ? "EVENT" : "",
1172  (p_clnt_filter->if_wrtsev > 0) ? "SUBEVENT" : "",
1173  (p_clnt_filter->if_fltevt > 0) ? "EVENT" : "",
1174  (p_clnt_filter->if_fltsev > 0) ? "SUBEVENT" : "");
1175  for (i = 0; i < i_fltdescnt; i++) {
1176  p_flt_descr = (struct s_flt_descr *) &p_clnt_filter->flt_descr[i];
1177  p_filter = (struct s_filter *)
1178  &p_clnt_filter->filter[(int)p_flt_descr->h_fltblkbeg];
1179  p_opc1 = (struct s_opc1 *) &p_filter->l_opcode;
1180 
1181  if ( (i_debug == 1) || (i_debug == 2) )
1182  {
1183  if (i > 1)
1184  printf("\n<<%s>>\n", (p_opc1->b1_lnkf2 == 1) ? "A_N_D" : "O_R" );
1185  printf("\n=>>FILTER set %d :",i);
1186  printf(" Select:%s Filter:%s Write:%s Filter[%d:%d]:\n",
1187  (p_opc1->b1_evtsev == 1) ? "EVENT" : "SUBEVENT",
1188  (p_opc1->b1_selflt == 1) ? "ON" : "OFF",
1189  (p_opc1->b1_selwrt == 1) ? "ON" : "OFF",
1190  p_flt_descr->h_fltblkbeg,
1191  p_flt_descr->h_fltblkend );
1192  }
1193 
1194  /* +++ subevt flt blk id +++ */
1195  if (p_opc1->b1_evtsev == 0 && p_opc1->b1_selflt == 1)
1196  {
1197  p_filter = (struct s_filter *)
1198  &p_clnt_filter->filter[(int)p_flt_descr->h_fltblkbeg];
1199  if ( (i_debug == 1) || (i_debug == 2) )
1200  printf(
1201  " Filter set id is fltspec:%d == mask:H%x (see 1st filt. below)\n",
1202  p_opc1->h_fltspec,
1203  p_filter->l_pattern);
1204  }
1205 
1206 
1207  /* +++ loop over all filters in this filter block +++ */
1208  for (j = p_flt_descr->h_fltblkbeg;
1209  j <= p_flt_descr->h_fltblkend;
1210  j++) {
1211  p_filter = (struct s_filter *) &p_clnt_filter->filter[j];
1212  p_opc1 = (struct s_opc1 *) &p_filter->l_opcode;
1213  if ( (j > p_flt_descr->h_fltblkbeg) &&
1214  (p_opc1->b1_selflt == 1) &&
1215  ( (i_debug == 1) || (i_debug == 2) ) )
1216  printf(" <%s>\n", (p_opc1->b1_lnkf1 == 1) ? "A_N_D" : "O_R" );
1217  if ( (i_debug == 1) || (i_debug == 2) )
1218  printf(" =>%2d: opcode: ", i + 1);
1219 
1220  switch (p_opc1->b3_opc) {
1221  case 0:
1222  if ( (i_debug == 1) || (i_debug == 2) )
1223  printf("!! (ALL) ");
1224  break;
1225  case 1:
1226  if ( (i_debug == 1) || (i_debug == 2) )
1227  printf("== (IDENT) ");
1228  break;
1229 
1230  case 2:
1231  if ( (i_debug == 1) || (i_debug == 2) )
1232  printf("&& (ANY) ");
1233  break;
1234 
1235  case 3:
1236  if ( (i_debug == 1) || (i_debug == 2) )
1237  printf("&= (INCL) ");
1238  break;
1239 
1240  case 4:
1241  if ( (i_debug == 1) || (i_debug == 2) )
1242  printf("^= (EXCL) ");
1243  break;
1244 
1245  case 5:
1246  if ( (i_debug == 1) || (i_debug == 2) )
1247  printf("< (LT) ");
1248  break;
1249 
1250  case 6:
1251  if ( (i_debug == 1) || (i_debug == 2) )
1252  printf(">= (GE) ");
1253  break;
1254 
1255  default:
1256  printf("W-OPCODE %d NOT FOUND\n",p_opc1->b3_opc);
1257  }
1258 
1259  switch (p_opc1->h_fltspec) {
1260  case 0: /* ++++ take all ++++ */
1261  if (p_opc1->b3_opc != 0) {
1262  p_opc1->b3_opc = 0;
1263  printf("W-%s: Take all. Opcode is %d\n",
1264  c_modnam,
1265  p_opc1->b3_opc);
1266  }
1267  break;
1268 
1269  case 1: /* ++++ trigger ++++ */
1270  p_pat1 = (struct s_pat1 *) &p_filter->l_pattern;
1271  if ( (i_debug == 1) || (i_debug == 2) )
1272  {
1273  printf("trigger:%2d",p_pat1->i_trigger);
1274  printf(" (mask:%d offs:%d %s)\n",
1275  p_filter->l_pattern,
1276  (p_filter->l_offset >= 0) ?
1277  p_filter->l_offset : -p_filter->l_offset,
1278  (p_filter->l_offset >= 0) ? "LW" : "W");
1279  }
1280  break;
1281 
1282  case 2: /* ++++ pattern and offset ++++ */
1283  if ( (i_debug == 1) || (i_debug == 2) )
1284  printf("mask:H%x offset:%d %s\n",
1285  p_filter->l_pattern,
1286  (p_filter->l_offset >= 0) ?
1287  p_filter->l_offset : -p_filter->l_offset,
1288  (p_filter->l_offset >= 0) ?
1289  "LW" : "W" );
1290  break;
1291 
1292  case 4: /* W ++++ type ++++ */
1293  if ( (i_debug == 1) || (i_debug == 2) )
1294  {
1295  printf("type:%d ",
1296  p_filter->l_pattern);
1297  printf(" (mask:%d offs:%d %s)\n",
1298  p_filter->l_pattern,
1299  (p_filter->l_offset >= 0) ?
1300  p_filter->l_offset : -p_filter->l_offset,
1301  (p_filter->l_offset >= 0) ? "LW" : "W");
1302  }
1303  break;
1304 
1305  case 8: /* W ++++ subtype ++++ */
1306  if ( (i_debug == 1) || (i_debug == 2) )
1307  {
1308  printf("subtype:%d ",
1309  p_filter->l_pattern);
1310  printf(" (mask:%d offs:%d %s)\n",
1311  p_filter->l_pattern,
1312  (p_filter->l_offset >= 0) ?
1313  p_filter->l_offset : -p_filter->l_offset,
1314  (p_filter->l_offset >= 0) ? "LW" : "W");
1315  }
1316  break;
1317 
1318  case 12: /* W ++++ type and subtype ++++ */
1319  p_pat3 = (struct s_pat3 *) &p_filter->l_pattern;
1320  if ( (i_debug == 1) || (i_debug == 2) )
1321  {
1322  printf("type:%d subtype:%d",
1323  p_pat3->i_type,
1324  p_pat3->i_subtype);
1325  printf(" (mask:H%x offs:%d %s)\n",
1326  p_filter->l_pattern,
1327  (p_filter->l_offset >= 0) ?
1328  p_filter->l_offset : -p_filter->l_offset,
1329  (p_filter->l_offset >= 0) ? "LW" : "W");
1330  }
1331  break;
1332 
1333  case 16: /* ++++ procid ++++*/
1334  p_pat2 = (struct s_pat2 *) &p_filter->l_pattern;
1335  if ( (i_debug == 1) || (i_debug == 2) )
1336  {
1337  printf("procid:%d ",
1338  p_pat2->i_procid);
1339  printf(" (mask:%d offs:%d %s)\n",
1340  p_filter->l_pattern,
1341  (p_filter->l_offset >= 0) ?
1342  p_filter->l_offset : -p_filter->l_offset,
1343  (p_filter->l_offset >= 0) ? "LW" : "W");
1344  }
1345  break;
1346 
1347  case 32: /* W ++++ subcrate,contr ++++*/
1348  if ( (i_debug == 1) || (i_debug == 2) )
1349  {
1350  printf("subcrate:%d control:%d",
1351  p_filter->l_pattern & 0x00FF,
1352  ((unsigned) (p_filter->l_pattern & 0xFF00)) >> 8);
1353  printf(" (mask:H%x offs:%d %s)\n",
1354  p_filter->l_pattern,
1355  (p_filter->l_offset >= 0) ?
1356  p_filter->l_offset : -p_filter->l_offset,
1357  (p_filter->l_offset >= 0) ? "LW" : "W");
1358  }
1359  break;
1360 
1361  case 48: /* LW ++++procid,subcr,contr ++++*/
1362  p_pat2 = (struct s_pat2 *) &p_filter->l_pattern;
1363  if ( (i_debug == 1) || (i_debug == 2) )
1364  {
1365  printf("procid:%2d subcr:%d contr:%d",
1366  p_pat2->i_procid,
1367  p_pat2->h_subcrate,
1368  p_pat2->h_control);
1369  printf(" (mask:H%x offs:%d %s)\n",
1370  p_filter->l_pattern,
1371  (p_filter->l_offset >= 0) ?
1372  p_filter->l_offset : -p_filter->l_offset,
1373  (p_filter->l_offset >= 0) ? "LW" : "W");
1374  }
1375  break;
1376 
1377  default:
1378  printf("W-FLTSPEC %d NOT FOUND\n",p_opc1->h_fltspec);
1379  } /* switch case */
1380 
1381  /* ++++ check if Filter specification is valid ++++ */
1382  if ((p_opc1->h_fltspec > 15) && (p_opc1->b1_evtsev == 1)) {
1383  printf("E-%s: Filter specification %d invalid for events\n",
1384  c_modnam,
1385  p_opc1->h_fltspec);
1386  return(FALSE); /* abort with error */
1387  }
1388  if ((p_opc1->h_fltspec < 2) && (p_opc1->b1_evtsev != 1)) {
1389  printf("E-%s: Filter specification %d invalid for subevents\n",
1390  c_modnam,
1391  p_opc1->h_fltspec);
1392  return(FALSE); /* abort with error */
1393  }
1394 
1395  } /* for (j... */
1396 
1397  } /* for (i... */
1398  if ( (i_debug == 1) || (i_debug == 2) )
1399  printf("\n\n");
1400 
1401  return(TRUE);
1402 } /* end f_typflt */
1403 
1404 
1405 
1406 
1407 /*2+F_READ_SERVER***+**************************************************/
1408 /* */
1409 /*+ Module : F_READ_SERVER */
1410 /* */
1411 /* */
1412 /*--------------------------------------------------------------------*/
1413 /*+ CALLING : sts = f_read_server(p_clntbuf, */
1414 /* p_bytrd, */
1415 /* l_timeout, */
1416 /* i_chan) */
1417 /* */
1418 /* */
1419 /*--------------------------------------------------------------------*/
1420 /* */
1421 /*+ PURPOSE : Read a buffer from the server */
1422 /* */
1423 /*+ ARGUMENTS : */
1424 /*+ p_clntbuf: Pointer to structure s_clntbuf */
1425 /*+ p_bytrd : Pointer to (int) Number of read bytes */
1426 /*+ l_timeout: (int) Timeout in seconds */
1427 /*+ i_chan : (int) channel number */
1428 /* */
1429 /*+ FUNCTION : Read a buffer of the type s_clntbuf from the */
1430 /* server. */
1431 /* */
1432 /*+ Return type : int (32 bit) */
1433 /*+ Status codes: 1: success */
1434 /* 0: fault */
1435 /*+ Initialize : - */
1436 /*+ Include name: - */
1437 /* */
1438 /*3+Implementation************+****************************************/
1439 /* */
1440 /*+ File name : PC_PROC.C */
1441 /*+ Version : 1.01 */
1442 /*+ Author : R.S. Mayer */
1443 /*+ Last Update : 14-JUN-1993 */
1444 /*+ Object libr.: GOOSHRLIB */
1445 /*3+Updates*******+***********+****************************************/
1446 /* */
1447 /*+ Updates : Date Purpose */
1448 /*- 26-Jan-1994 : Swap inserted (RSM) */
1449 /*- 24-Feb-1994 : Bug removed (RSM) */
1450 /* */
1451 /*3+Description***+***********+****************************************/
1452 /*1- C Procedure ***********+******************************************/
1453 int f_read_server(s_evt_channel *ps_chan, int *p_bytrd, int l_timeout, int i_chan)
1454 {
1455  /* ++++ declarations ++++ */
1456  int l_maxbytes;
1457  int l_status,ii,im,*pl; /* !!! */
1458  int l_bytrec, l_2ndbuf_byt;
1459  int l_buftord, l_buffertype;
1460  static char c_modnam[] = "f_read_server";
1461  char c_retmsg[256];
1462  char *pc;
1463  int *pl_d,*pl_s;
1464 
1465 // JAM1-6-2021- test if this helps the streamserver problems
1466 #ifndef DISABLE_POLLING_TIMEOUT
1467 
1468  int _tmout, _retry;
1469 
1470  _retry = 0;
1471  _tmout = l_timeout;
1472 
1473  if (ps_chan->cb_polling) {
1474  _tmout = 555555; // special value, should produce 0.05s timeout
1475  _retry = 100000; // approx 5000 sec
1476  }
1477 #endif
1478  /* ++++ action ++++ */
1479 
1480  p_clntbuf = (struct s_clntbuf *) ps_chan->pc_io_buf;
1481  l_maxbytes = ps_chan->l_io_buf_size;
1482  /* + + + + + + + + + + + + + + + */
1483  /* + + + read first buffer + + + */
1484  /* + + + + + + + + + + + + + + + */
1485  if (i_debug == 2)
1486  printf("D-%s: **Rd 1st Buf: at %p to %p = %d bytes\n",
1487  c_modnam,
1488  (char *) p_clntbuf,
1489  ((char *) p_clntbuf) + (CLNT__SMALLBUF - 1),
1490  CLNT__SMALLBUF);
1491 
1492 
1493  *p_bytrd = CLNT__SMALLBUF;
1494 
1495 // JAM1-6-2021- test if this helps the streamserver problems
1496 #ifndef DISABLE_POLLING_TIMEOUT
1497 read_again:
1498 
1499  l_status = f_stc_read( (char *) p_clntbuf,
1500  (int) CLNT__SMALLBUF,
1501  i_chan,
1502  _tmout);
1503 
1504  if ((_retry-- > 0) && (l_status == STC__TIMEOUT)) {
1505  ps_chan->cb_polling();
1506  goto read_again;
1507  }
1508 #else
1509  l_status = f_stc_read( (char *) p_clntbuf,
1510  (int) CLNT__SMALLBUF,
1511  i_chan,
1512  l_timeout);
1513 #endif
1514 
1515  if (l_status != STC__SUCCESS)
1516  {
1517  printf("E-%s: Error reading first buffer. Msg follows:",c_modnam);
1518  f_stc_disperror(l_status,c_retmsg, 0);
1519  return(FALSE);
1520  }
1521 
1522  /* +++ copy the relevant length values +++ */
1523  l_buftord = p_clntbuf->l_numbuftosnd;
1524  l_bytrec = p_clntbuf->l_bytestosnd;
1525  l_buffertype = p_clntbuf->l_buffertype;
1526 
1527  /* +++ test for byte swap +++ */
1528  if (p_clntbuf->l_testbit != GPS__ENV_TESTBIT)
1529  {
1530  if (i_debug == 2)
1531  printf("D-%s: Need swap to receive from %s to %s ENDIAN\n",
1532  c_modnam,
1533  (p_clntbuf->l_endian == 0) ? "LITTLE" : "BIG",
1534  (GPS__ENV_ENDIAN == 0) ? "LITTLE" : "BIG");
1535 
1536  l_status = F__SWAP(&l_buftord, 1, 0);
1537  if (l_status != 0) printf("E-%s: Error swapping l_buftord. l_sts:%d\n", c_modnam,l_status);
1538  l_status = F__SWAP(&l_bytrec , 1, 0);
1539  if (l_status != 0) printf("E-%s: Error swapping l_bytrec l_sts:%d\n", c_modnam,l_status);
1540  l_status = F__SWAP(&l_buffertype, 1, 0);
1541  if (l_status != 0) printf("E-%s: Error swapping l_buffertype l_sts:%d\n", c_modnam,l_status);
1542  if (i_debug == 2)
1543  printf("D-%s: buffers:%d, bytes:%d, buffertype:%d\n",
1544  c_modnam,
1545  l_buftord,
1546  l_bytrec,
1547  l_buffertype);
1548 
1549  }
1550  if (l_buftord == 1)
1551  {
1552  if (l_bytrec > CLNT__SMALLBUF)
1553  {
1554  printf("E-%s: Buffer sent:%d Bytes_to_rd:%d > %d\n",
1555  c_modnam,
1556  l_buftord,
1557  l_bytrec,
1558  CLNT__SMALLBUF);
1559  return(FALSE);
1560  }
1561  goto m_snd_ackn;
1562  }
1563 
1564  l_2ndbuf_byt = l_bytrec - CLNT__SMALLBUF; /* rest of bytes in 2nd buffer*/
1565 
1566  /* + + + + + + + + + + + + + + */
1567  /* + + + read 2nd buffer + + + */
1568  /* + + + + + + + + + + + + + + */
1569  if (i_debug == 2)
1570  {
1571  short j;
1572  int *pl;
1573  printf("D-%s: begin of c_buffer[148] in LW (all hex)\n", c_modnam);
1574  pl = (int *) &p_clntbuf->c_buffer[148];
1575  for (j=0; j<5; j++)
1576  {
1577  printf("%p:%8x ",pl,*(pl));
1578  pl++;
1579  printf("%p:%8x ",pl,*(pl));
1580  pl++;
1581  printf("%p:%8x ",pl,*(pl));
1582  pl++;
1583  printf("\n");
1584  }
1585  printf("D-%s: **Rd 2nd Buf: at %p (buf[%d]) to %p = %d b\n",
1586  c_modnam,
1587  (char *) &p_clntbuf->c_buffer[CLNT__RESTBUF],
1588  CLNT__RESTBUF,
1589  ((char *) &p_clntbuf->c_buffer[CLNT__RESTBUF]) + (l_2ndbuf_byt - 1),
1590  l_2ndbuf_byt);
1591  }
1592  *p_bytrd += l_2ndbuf_byt;
1593  l_buftord = 2;
1594  /* check if buffer if big enough, reallocate if not */
1595  /* old buffer is freed by caller */
1596  if(l_bytrec > l_maxbytes)
1597  {
1598  im=l_bytrec;
1599  l_bytrec=(int)(1.2*(float)l_bytrec);
1600  l_bytrec=((l_bytrec>>12)+1);
1601  l_bytrec=(l_bytrec<<12);
1602  /* printf("reallocate for %d (%d) bytes\n",im,l_bytrec);fflush(stdout);*/
1603  pc = (char*) malloc(l_bytrec);
1604  pl_d=(int *)pc;
1605  for(ii=0;ii<l_bytrec/4;ii++) *pl_d++ = 0;
1606  pl_d=(int *)pc;
1607  pl_s=(int *)ps_chan->pc_io_buf;
1608  for(ii=0;ii<CLNT__SMALLBUF/4;ii++) *pl_d++ = *pl_s++;
1609  ps_chan->pc_io_buf = pc;
1610  ps_chan->l_io_buf_size = l_bytrec;
1611  p_clntbuf = (struct s_clntbuf *) pc;
1612  }
1613  pl = (int *) &p_clntbuf->c_buffer[CLNT__RESTBUF];
1614  im=l_2ndbuf_byt/16384;
1615  l_2ndbuf_byt=l_2ndbuf_byt%16384;
1616  for(ii=0;ii<im;ii++)
1617  {
1618  l_status = f_stc_read( pl,16384,i_chan,l_timeout);
1619  pl+=4096;
1620  if(l_status != STC__SUCCESS)break;
1621  }
1622  if(l_2ndbuf_byt > 0)
1623  {
1624  l_status = f_stc_read( pl,l_2ndbuf_byt,i_chan,l_timeout);
1625  }
1626  if (l_status != STC__SUCCESS)
1627  {
1628  printf("E-%s: Error reading second buffer. Msg follows:",c_modnam);
1629  f_stc_disperror(l_status,c_retmsg, 0);
1630  return(FALSE);
1631  }
1632 
1633  if (i_debug == 2)
1634  {
1635  short j;
1636  int *pl;
1637  printf("D-%s: begin of c_buffer[148] in LW (all hex)\n", c_modnam);
1638  pl = (int *) &p_clntbuf->c_buffer[148];
1639  for (j=0; j<5; j++)
1640  {
1641  printf("%p:%8x ",pl,*(pl));
1642  pl++;
1643  printf("%p:%8x ",pl,*(pl));
1644  pl++;
1645  printf("%p:%8x ",pl,*(pl));
1646  pl++;
1647 
1648  printf("\n");
1649  }
1650  }
1651 
1652  m_snd_ackn:; /* +++ set and send 12 bytes ackn */
1653  /* ++++++++++++++++++++++++++++++++++ */
1654  /* + + + send acknowledge buffer + + + */
1655  /* ++++++++++++++++++++++++++++++++++ */
1656  s_ackn.l_ack_buf = l_buftord;
1657  s_ackn.l_ack_bytes = *p_bytrd;
1658  s_ackn.l_clnt_sts = 1; /* success */
1659 
1660  if ((l_buffertype & 8) != 0)
1661  s_ackn.l_clnt_sts = s_ackn.l_clnt_sts | 8; /* set bit for last buffer */
1662 
1663  return(TRUE);
1664 }
1665 
1666 
1667 /*2+F_SEND_ACKN*****+**************************************************/
1668 /* */
1669 /*+ Module : F_SEND_ACKN */
1670 /* */
1671 /* */
1672 /*--------------------------------------------------------------------*/
1673 /*+ CALLING : sts = f_send_ackn(l_clnt_sts, i_chan) */
1674 /*--------------------------------------------------------------------*/
1675 /* */
1676 /*+ PURPOSE : Send acknowledge buffer to the server */
1677 /* */
1678 /*+ ARGUMENTS : */
1679 /*+ l_clnt_sts: Status. Status bits will be set in addition to the */
1680 /* status bits set by f_read_server in s_ackn struct. */
1681 /*+ i_chan : (int) channel number */
1682 /* */
1683 /*+ FUNCTION : Send the acknowledge buffer. Set additional bits in */
1684 /* the status word, i.e. "last buffer" etc. */
1685 /* */
1686 /*+ Return type : int (32 bit) */
1687 /*+ Status codes: 1: success */
1688 /* 0: fault */
1689 /*+ Initialize : - */
1690 /*+ Include name: - */
1691 /* */
1692 /*3+Implementation************+****************************************/
1693 /* */
1694 /*+ File name : PC_PROC.C */
1695 /*+ Version : 1.01 */
1696 /*+ Author : R.S. Mayer */
1697 /*+ Last Update : 11-Apr-1994 */
1698 /*+ Object libr.: GOOSHRLIB */
1699 /*3+Updates*******+***********+****************************************/
1700 /* */
1701 /*+ Updates : Date Purpose */
1702 /* */
1703 /*3+Description***+***********+****************************************/
1704 /*1- C Procedure ***********+******************************************/
1706 int l_clnt_sts;
1707 int i_chan;
1708 {
1709  /* ++++ declarations ++++ */
1710  int l_status; /* !!! */
1711  static char c_modnam[] = "f_send_ackn";
1712  char c_retmsg[256];
1713 
1714  if (i_debug == 2)
1715  printf("I-%s s_ackn.l_clnt_sts:%d l_clnt_sts:%d\n",
1716  c_modnam,
1717  s_ackn.l_clnt_sts,
1718  l_clnt_sts);
1719 
1720  /* +++++++++++++++++++++++++++++++ */
1721  /* +++ set status of ackn buf +++ */
1722  /* +++++++++++++++++++++++++++++++ */
1723  s_ackn.l_clnt_sts = s_ackn.l_clnt_sts | l_clnt_sts; /* success */
1724 
1725  /* ++++++++++++++++++++++++++++++ */
1726  /* +++ send acknowledge buffer +++ */
1727  /* ++++++++++++++++++++++++++++++ */
1728  l_status = f_stc_write( (char *) &s_ackn,
1729  12,
1730  i_chan);
1731 
1732  if (l_status != STC__SUCCESS)
1733  {
1734  printf("E-%s: Error in f_stc_write(&s_ackn,...)! Msg follows:",
1735  c_modnam);
1736  f_stc_disperror(l_status,c_retmsg, 0);
1737  return(FALSE);
1738  }
1739 
1740  return(TRUE);
1741 }
1742 
1743 
1744 /*2+F_STRTOUPPER***+***************************************************/
1745 /* */
1746 /*+ Module : F_STRTOUPPER */
1747 /* */
1748 /* */
1749 /*--------------------------------------------------------------------*/
1750 /*+ CALLING : sts = f_strtoupper(u, l) */
1751 /* */
1752 /* */
1753 /*--------------------------------------------------------------------*/
1754 /* */
1755 /*+ PURPOSE : Converts a '\0' terminated string to upper case. */
1756 /* */
1757 /*+ ARGUMENTS : */
1758 /*+ u : Pointer to upper case string (result) */
1759 /*+ l : Pointer to lower case string (argument) */
1760 /* */
1761 /*+ FUNCTION : Converts a '\0' terminated string to upper case. */
1762 /* */
1763 /*+ Return type : int (32 bit) */
1764 /*+ Status codes: - */
1765 /*+ Initialize : - */
1766 /*+ Include name: - */
1767 /* */
1768 /*3+Implementation************+****************************************/
1769 /* */
1770 /*+ File name : PC_PROC.C */
1771 /*+ Version : 1.01 */
1772 /*+ Author : R.S. Mayer */
1773 /*+ Last Update : 14-JUN-1993 */
1774 /*+ Object libr.: GOOSHRLIB */
1775 /*3+Updates*******+***********+****************************************/
1776 /* */
1777 /*+ Updates : Date Purpose */
1778 /* */
1779 /*3+Description***+***********+****************************************/
1780 /*1- C Procedure ***********+******************************************/
1781 void f_strtoupper(u, l)
1782 char *u, *l;
1783 {
1784  for ( ; *l != '\0'; ++l, ++u)
1785  *u = toupper(*l);
1786 
1787  *u = '\0';
1788  return;
1789 }
1790 
1791 
1792 /*2+F_CLNUP ***+*******************************************************/
1793 /* */
1794 /*+ Module : F_CLNUP */
1795 /* */
1796 /* */
1797 /*--------------------------------------------------------------------*/
1798 /*+ CALLING : f_clnup(v_mem, p_keyb) */
1799 /* */
1800 /* */
1801 /*--------------------------------------------------------------------*/
1802 /* */
1803 /*+ PURPOSE : Cleanup allocated memory and dealloc devices */
1804 /* */
1805 /*+ ARGUMENTS : */
1806 /*+ v_mem[] : (int) [0]:maxidx=n [1:n]:ptr to allocated memory */
1807 /*+ p_keyb : Pointer to s_keyb or NULL. */
1808 /* */
1809 /*+ FUNCTION : Cleanup allocated memory and dealloc devices */
1810 /* Calls free(v_mem[i]) and f_ttydass(p_keyb) */
1811 /* */
1812 /* */
1813 /*+ Return type : void */
1814 /*+ Status codes: - */
1815 /*+ Initialize : - */
1816 /*+ Include name: - */
1817 /* */
1818 /*3+Implementation************+****************************************/
1819 /* */
1820 /*+ File name : PC_PROC.C */
1821 /*+ Version : 1.01 */
1822 /*+ Author : R.S. Mayer */
1823 /*+ Last Update : 14-JUN-1993 */
1824 /*+ Object libr.: GOOSHRLIB */
1825 /*3+Updates*******+***********+****************************************/
1826 /* */
1827 /*+ Updates : Date Purpose */
1828 /*- 14-Jan-94 : prototype TTYSTUFF(f_ttydass()) (RSM) */
1829 /*- 08-Apr-94 : Accept NULL pointer for p_keyb. /HE */
1830 /* */
1831 /*3+Description***+***********+****************************************/
1832 /*1- C Procedure ***********+******************************************/
1833 /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
1834 void f_clnup(v_mem, p_keyb)
1835 long v_mem[];
1836 int *p_keyb;
1837 /* cleanup: free allocated memory and dealloc allocated device(s) */
1838 {
1839  /* ++++ declaration ++++ */
1840  short i;
1841 
1842  for (i = 1; i <= v_mem[0]; i++)
1843  {
1844  if(v_mem[i] != 0) free((int *) v_mem[i]);
1845  v_mem[i]=0;
1846  }
1847  v_mem[0]=0;
1848 }
1849 /*******************************************************************/
1850 void f_clnup_save(v_mem, p_keyb)
1851 long v_mem[];
1852 int *p_keyb;
1853 /* cleanup: free allocated memory and dealloc allocated device(s) */
1854 {
1855  /* ++++ declaration ++++ */
1856  v_mem[++v_mem[0]] = (long) p_keyb; /* was (int) before JA */
1857 }
1858 /* ------------------------------------------------------------------------- */
#define FLUSH__TIME
Definition: f_evcli.c:160
int f_evcli_evt(s_evt_channel *ps_chan)
Definition: f_evcli.c:479
void f_strtoupper(char *u, char *l)
Definition: f_evcli.c:1781
unsigned int l_endian
Definition: s_clntbuf.h:40
unsigned int l_testbit
Definition: s_clntbuf.h:39
INTU4 l_pattern
Definition: s_filter.h:25
int unsigned l_inbuf_read_cnt
Definition: s_clntbuf.h:57
INTS4 l_channel_no
Definition: f_evt.h:58
INTS4 f_stc_close(struct s_tcpcomm *ps_tcp)
Definition: f_stccomm.c:1091
CHARS * pc_evt_buf
Definition: f_evt.h:79
int l_dlen
Definition: s_clntbuf.h:43
INTS4 f_stc_read(void *p_buffer, INTS4 i_buflen, INTS4 i_channel, INTS4 i_timeout)
Definition: f_stccomm.c:134
#define GPS__ENV_TESTBIT
Definition: gps_sc_def.h:52
char h_fltspec
Definition: s_opc1.h:47
Definition: s_pat.h:50
static int i_debug
Definition: f_evcli.c:156
short unsigned if_fltsev
Definition: s_clnt_filter.h:56
INTS4 f_stc_write(void *p_buffer, INTS4 i_buflen, INTS4 i_channel)
Definition: f_stccomm.c:339
int f_send_ackn(int, int)
Definition: f_evcli.c:1705
Definition: s_pat.h:57
#define CLNT__SMALLBUF
Definition: clnt_buf_def.h:39
short i_type
Definition: s_pat.h:59
#define CLNT__OUTBUFHEAD
Definition: clnt_buf_def.h:24
int l_ack_bytes
Definition: f_evcli.c:183
unsigned b1_selflt
Definition: s_opc1.h:42
static int unsigned lf_swap
Definition: f_evcli.c:171
char h_fltblkbeg
Definition: s_flt_descr.h:45
char h_subcrate
Definition: s_pat.h:53
INTS4 f_stc_disperror(INTS4 i_error, CHARS *c_dest, INTS4 i_out)
Definition: f_stccomm.c:1399
int f_evcli_close(s_evt_channel *ps_chan)
Definition: f_evcli.c:498
short unsigned if_wrtsev
Definition: s_clnt_filter.h:58
unsigned int * pl_inbuf
Definition: f_evcli.c:152
int l
Definition: f_mbs_status.c:31
int f_read_server(s_evt_channel *, int *, int, int)
Definition: f_evcli.c:1453
Definition: s_pat.h:44
int l_events
Definition: s_clntbuf.h:45
CHARS * pc_io_buf
Definition: f_evt.h:78
static struct s_tcpcomm s_tcpcomm_ec
Definition: f_evcli.c:179
#define STC__TIMEOUT
Definition: f_stccomm.h:374
INTS4 f_stc_discclient(INTS4 i_channel)
Definition: f_stccomm.c:1172
INTS4 l_evt_buf_posi
Definition: f_evt.h:68
static struct @17 s_ackn
int swapw(unsigned short *, unsigned short *, unsigned int)
INTS4 f_stc_connectserver(CHARS *c_node, INTS4 l_port, INTS4 *pi_channel, struct s_tcpcomm *ps_client)
Definition: f_stccomm.c:494
int f_evcli_buf(s_evt_channel *ps_chan)
Definition: f_evcli.c:378
#define STC__SUCCESS
Definition: f_stccomm.h:369
INTS4 l_dlen
Definition: s_ve10_1.h:37
char h_flt_len
Definition: s_opc1.h:49
int l_status
Definition: f_evcli.c:175
#define FALSE
Definition: f_stccomm.h:355
struct s_clntbuf * p_clntbuf
Definition: f_evcli.c:168
unsigned int l_endian
Definition: s_clnt_filter.h:48
#define GPS__MAXFLT
Definition: gps_sc_def.h:36
short i_subtype
Definition: s_pat.h:60
int unsigned l_msgtyp
Definition: s_clntbuf.h:53
void f_clnup(long[], int *)
short i_descriptors
Definition: s_flt_descr.h:50
#define TRUE
Definition: f_stccomm.h:359
struct s_clnt_filter * p_clnt_filter
Definition: f_evcli.c:167
static char c_modnam[]
Definition: f_evcli.c:176
unsigned b3_opc
Definition: s_opc1.h:44
short unsigned if_wrtevt
Definition: s_clnt_filter.h:57
char c_message[CLNT__MSGLEN]
Definition: s_clntbuf.h:54
int l_ack_buf
Definition: f_evcli.c:182
unsigned short * pi_inbuf
Definition: f_evcli.c:151
long v_mem_clnup[8]
Definition: f_evcli.c:188
char h_nextdescr
Definition: s_flt_descr.h:48
INTS4 l_offset
Definition: s_filter.h:26
#define TCP__TIMEOUT
Definition: f_evcli.c:159
struct s_opc1 * p_opc1
Definition: f_evcli.c:169
Definition: s_opc1.h:39
short i_procid
Definition: s_pat.h:52
#define CLNT__BUFH_LW
Definition: clnt_buf_def.h:55
static int unsigned l_endian_serv
Definition: f_evcli.c:172
unsigned int l_testbit
Definition: s_clnt_filter.h:47
int swapl(unsigned int *, unsigned int *, unsigned int)
char h_fltblkend
Definition: s_flt_descr.h:46
unsigned b1_evtsev
Definition: s_opc1.h:41
char h_control
Definition: s_pat.h:54
int f_typflt(struct s_clnt_filter *p_clnt_filter)
Definition: f_evcli.c:1145
unsigned int l_len_w
Definition: f_evcli.c:153
struct s_filter filter[GPS__MAXFLT]
Definition: s_clnt_filter.h:53
INTS4 l_io_buf_size
Definition: f_evt.h:65
int l_numbuftosnd
Definition: s_clntbuf.h:48
int unsigned l_buffertype
Definition: s_clntbuf.h:50
int f_fltrd(struct s_clnt_filter *p_clnt_filter, char *c_file)
Definition: f_evcli.c:895
void f_clnup_save(long[], int *)
struct s_flt_descr flt_descr[GPS__MAXFLTDESCR]
Definition: s_clnt_filter.h:54
int l_bytestosnd
Definition: s_clntbuf.h:47
unsigned b1_lnkf2
Definition: s_opc1.h:46
char hf_fltdescr
Definition: s_flt_descr.h:43
#define GPS__CLNT_SNDFLT
Definition: gps_sc_def.h:40
short unsigned if_fltevt
Definition: s_clnt_filter.h:55
#define GPS__OUTBUFSIZ
Definition: gps_sc_def.h:32
short i_trigger
Definition: s_pat.h:46
short i_sign
Definition: f_evcli.c:177
int unsigned l_clnt_sts
Definition: f_evcli.c:174
char h_next_fltblk
Definition: s_opc1.h:48
unsigned b1_lnkf1
Definition: s_opc1.h:45
char hf_wrtdescr
Definition: s_flt_descr.h:42
#define CLNT__RESTBUF
Definition: clnt_buf_def.h:42
function if(typeof JSROOT!="object")
#define CLNT__REST_LW
Definition: clnt_buf_def.h:59
INTU4 l_opcode
Definition: s_filter.h:27
int i_channel
Definition: f_evcli.c:173
void(* cb_polling)()
Definition: f_evt.h:90
int l_timeout
Definition: f_evcli.c:178
#define F__SWAP(ps, l, pd)
Definition: f_evcli.c:59
int f_fltdscr(struct s_clnt_filter *)
Definition: f_evcli.c:556
char c_buffer[GPS__OUTBUFSIZ]
Definition: s_clntbuf.h:71
int f_evcli_con(s_evt_channel *ps_chan, char *pc_node, int l_aport, int l_aevents, int l_asample)
Definition: f_evcli.c:191
unsigned b1_selwrt
Definition: s_opc1.h:43