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