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