GSI Object Oriented Online Offline (Go4)  GO4-5.3.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 1956 2016-11-18 16:46:37Z 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 f�r 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 
175  struct s_opc1 *p_opc1;
176 
177  static int unsigned lf_swap = 0; /* save swap on RX */
178  static int unsigned l_endian_serv; /* save endian server */
179  static int l_len_lw1 = CLNT__BUFH_LW; /* len for first swap */
180  int l_len_lw2; /* len for 2nd swap */
181  int i_channel; /* TCP/IP channel */
182  int unsigned l_clnt_sts; /* status for ackn. */
184  static char c_modnam[] = "f_evcli";
185  short if_typevt, i_sign = 1, i_len;
187  int l_retval;
188  static struct s_tcpcomm s_tcpcomm_ec = {0,0,0};
189 static struct
190 {
191  int l_ack_buf; /* read client buff received */
192  int l_ack_bytes; /* read client bytes received */
193  int unsigned l_clnt_sts; /* client sts 1:o.k. 8:lst buf*/
194 } s_ackn;
195 
196  /* ++ vectors of pointer and devices for cleanup */
197  long v_mem_clnup[8];
198 /***************************************************************************/
199 int f_evcli_con(s_evt_channel *ps_chan, char *pc_node, int l_aport, int l_aevents, int l_asample)
200 /***************************************************************************/
201 {
202  short i, i_h, i_m, i_s;
203  char arg[80], c_hms[16], c_help[4];
204  int l_evtecho,*pl;
205  char c_node[32], c_name[32], c_retmsg[256];
206  int l_port;
207 
208  v_mem_clnup[0] = 0;
209 
210  /* +++ allocate filter structure +++ */
211  p_clnt_filter = (struct s_clnt_filter *) malloc( sizeof(struct s_clnt_filter) );
212  if (p_clnt_filter == NULL)
213  {
214  printf("E-%s: calloc(,...s_clnt_filter) failed!\n", c_modnam);
215  printf("F-%s: aborting program execution!\n",c_modnam);
216  f_clnup(v_mem_clnup, NULL);
217  return(-1);
218  }
219  ps_chan->pc_evt_buf=(char *) p_clnt_filter;
220  /* save value for clnup */
221  f_clnup_save(v_mem_clnup, (int *) p_clnt_filter);
222  memset( (void *) p_clnt_filter, 0, sizeof(struct s_clnt_filter) );
223 
224  p_clnt_filter->l_testbit = GPS__ENV_TESTBIT; /* set testbit */
225  p_clnt_filter->l_endian = GPS__ENV_ENDIAN; /* set endian */
226  p_clnt_filter->l_numb_of_evt = l_aevents;
227  p_opc1 = (struct s_opc1 *) &p_clnt_filter->filter[0].l_opcode;
228  p_opc1->b1_evtsev = 1;
229  p_opc1->b1_selflt = 1;
230  p_opc1->b1_selwrt = 1;
231  p_opc1->b3_opc = 0;
232  p_opc1->b1_lnkf1 = 0;
233  p_opc1->b1_lnkf2 = 0;
234  p_opc1->h_fltspec = 0;
235  p_opc1->h_next_fltblk = 1;
236  p_opc1->h_flt_len = 1;
237 
238  l_status = f_fltdscr(p_clnt_filter);
239  /*
240  printf("evtsev: %d selflt: %d selwrt: %d opc: %d lnk1: %d lnk2: %d fltspec: %d next: %d len: %d\n"
241 ,p_opc1->b1_evtsev
242 ,p_opc1->b1_selflt
243 ,p_opc1->b1_selwrt
244 ,p_opc1->b3_opc
245 ,p_opc1->b1_lnkf1
246 ,p_opc1->b1_lnkf2
247 ,p_opc1->h_fltspec
248 ,p_opc1->h_next_fltblk
249 ,p_opc1->h_flt_len);
250  */
251  if ((l_status & 1) == 0)
252  {
253  printf("E-%s: Severe Error in f_fltdscr! Status:%d\n",
254  c_modnam,
255  l_status);
256  f_clnup(v_mem_clnup, NULL);
257  return(-1);
258  }
259  p_clnt_filter->l_sample_rate = l_asample;
260  p_clnt_filter->l_flush_rate = FLUSH__TIME;
261 
263  strcpy(c_node,pc_node);
264  l_port = l_aport;
265 
266  l_status = (int) f_stc_connectserver(c_node,
267  l_port,
268  &i_channel,
269  &s_tcpcomm_ec);
270  if ((l_status & 1) != STC__SUCCESS)
271  {
272  printf("E-%s: Error connecting node:%s, port:%d. Msg:\n",
273  c_modnam,
274  c_node,
275  l_port);
276  f_stc_disperror((int) l_status,c_retmsg, 0);
277  f_stc_close(&s_tcpcomm_ec);
278  return(l_status);
279  }
280  ps_chan->l_channel_no=i_channel;
281  /* + buffer flushing time + */
282  i_h = p_clnt_filter->l_flush_rate / 3600; /* hours */
283  i_s = p_clnt_filter->l_flush_rate - i_h * 3600;
284  i_m = i_s / 60; /* minutes */
285  i_s = i_s - i_m * 60; /* seconds */
286 
287  /* +++++++++++++++++++++++++++++++++ */
288  /* +++ send these data to server +++ */
289  /* +++++++++++++++++++++++++++++++++ */
290  /* len to transm [bytes] = 3 LW + filter + 1LW */
291  l_status = (int) f_stc_write( (char *) p_clnt_filter,
293  i_channel);
294  if (l_status != STC__SUCCESS)
295  {
296  printf("E-%s: Error in f_write_tcp(p_flt,...)! Status:%d. Msg:\n",
297  c_modnam,
298  l_status);
299  f_stc_disperror((int) l_status,c_retmsg, 0);
300  f_stc_close(&s_tcpcomm_ec);
301  return(l_status);
302  }
303  /* + + + + + + + + + + + + + + */
304  /* +++ alloc input buffer +++ */
305  /* + + + + + + + + + + + + + + */
306  p_clntbuf = (struct s_clntbuf *) malloc(sizeof(struct s_clntbuf));
307  if (p_clntbuf == NULL)
308  {
309  printf("E-%s: malloc(p_clntbuf) failed!\n", c_modnam);
310  printf("F-%s: aborting program execution!\n",c_modnam);
311  f_stc_close(&s_tcpcomm_ec);
312  return(-1);
313  }
314  /* save value for clnup */
315  f_clnup_save(v_mem_clnup, (int *) p_clntbuf);
316 
317  ps_chan->pc_io_buf = (char *) p_clntbuf;
319  /* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
320  /* ++++ first read on server, get machine type & swap ++++ */
321  /* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
322  memset(p_clntbuf,0, sizeof(struct s_clntbuf)); /* clear memory */
323  l_status = f_read_server(ps_chan,
324  &l_retval,
325  l_timeout,
326  i_channel);
327  if (l_status != TRUE)
328  {
329  printf("E-%s: Error reading 1st buffer: f_read_server()!\n", c_modnam);
330  f_stc_close(&s_tcpcomm_ec);
331  return(l_status);
332  }
333 
334  /* ++++++++++++++++++++++++++++++++++++ */
335  /* +++ check if a LW swap is needed +++ */
336  /* ++++++++++++++++++++++++++++++++++++ */
337  lf_swap = (p_clntbuf->l_testbit == GPS__ENV_TESTBIT) ? 0 : 1;
338  l_endian_serv = p_clntbuf->l_endian;
339 
340  if (lf_swap)
341  /* + + + + + + + + + + + + + + + + + */
342  /* +++ swap after every receive +++ */
343  /* + + + + + + + + + + + + + + + + + */
344  {
345  l_sts = F__SWAP(&p_clntbuf->l_testbit,CLNT__BUFH_LW,0);
346 
347  l_len_lw2 = CLNT__REST_LW + p_clntbuf->l_dlen/4; /* <N> !!! */
348  l_sts = F__SWAP(&p_clntbuf->l_inbuf_read_cnt, l_len_lw2, 0);
349 
350  if (p_clntbuf->l_testbit != GPS__ENV_TESTBIT) /* <T> */
351  {
352  printf("F-%s: Error swapping first buffer from client\n",
353  c_modnam);
354  f_stc_close(&s_tcpcomm_ec);
355  return(-1);
356  }
357  }
358 
359  /* + + + + + + + + + + + + + + + + + + + + + + + + + */
360  /* +++ first buffer should be a message buffer! +++ */
361  /* + + + + + + + + + + + + + + + + + + + + + + + + + */
362  if (p_clntbuf->l_buffertype & 16)
363  {
364  }
365 
366  if (p_clntbuf->l_buffertype & 2)
367  { /* buffer contains message */
368 /*
369  switch (p_clntbuf->l_msgtyp & 15)
370  {
371  case 1:
372  case 2: printf("MSG-type:W: %s\n", p_clntbuf->c_message); break;
373  case 4: printf("MSG-type:E: %s\n", p_clntbuf->c_message); break;
374  case 8: printf("MSG-type:F: %s\n", p_clntbuf->c_message); break;
375  default: printf("Unknown MSG-type:%d:\n%s\n",p_clntbuf->l_msgtyp,p_clntbuf->c_message);
376  }
377 */
378  }
379 return(STC__SUCCESS);
380 } /* f_evcli_con */
381 
382 /***************************************************************************/
384 /***************************************************************************/
385 {
386  s_ve10_1 *ps_ve10_1;
387  int ii;
388  char *ps_buf;
389  /* ++++++++++++++++++++++++++++++ */
390  /* +++ send acknowledge buffer +++ */
391  /* ++++++++++++++++++++++++++++++ */
392  l_status = f_send_ackn(1, ps_chan->l_channel_no);
393  if (l_status != TRUE)
394  {
395  printf("E-%s: Error sending acknowledge: f_send_ackn()!\n", c_modnam);
396  f_stc_close(&s_tcpcomm_ec);
397  return(l_status);
398  }
399  /* +++++++++++++++++++++++++ */
400  /* +++ read input buffer +++ */
401  /* +++++++++++++++++++++++++ */
402  p_clntbuf = (struct s_clntbuf *) ps_chan->pc_io_buf;
403  ps_buf=ps_chan->pc_io_buf; /* save for comparison */
404  memset(p_clntbuf,0, ps_chan->l_io_buf_size);
405  l_status = f_read_server(ps_chan,
406  &l_retval,
407  l_timeout,
408  ps_chan->l_channel_no);
409  /* in case pc_io_buf has been reallocated */
410  if(ps_buf != ps_chan->pc_io_buf)
411  {
412  f_clnup(v_mem_clnup, NULL); /* free all old buffers */
413  p_clntbuf = (struct s_clntbuf *) ps_chan->pc_io_buf;
415  }
416  if (l_status != TRUE)
417  {
418  printf("E-%s: Error reading buffer: f_read_server()!\n", c_modnam);
419  f_stc_close(&s_tcpcomm_ec);
420  return(l_status);
421  }
422  l_clnt_sts = 0; /* reset */
423 
424  /* +++++++++++++++++++++++++++++++++ */
425  /* +++ swap every buffer in loop +++ */
426  /* +++++++++++++++++++++++++++++++++ */
427  if (lf_swap)
428  {
429  l_sts = F__SWAP(&p_clntbuf->l_testbit,CLNT__BUFH_LW, 0);
430  l_len_lw2 = CLNT__REST_LW + p_clntbuf->l_dlen/4; /* <N> !!! */
431 
432  /* 4 byte swap */
433  pl_inbuf = &p_clntbuf->l_inbuf_read_cnt;
435  }
436  /* printf("Buffer %8d bytes, dlen %8d events %6d\n",l_retval,p_clntbuf->l_dlen,p_clntbuf->l_events);
437  ps_ve10_1=(s_ve10_1 *)&p_clntbuf->c_buffer[0];
438  for(ii=0;ii<p_clntbuf->l_events;ii++)
439  {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);
440  ps_ve10_1 = (s_ve10_1 *) ((short *)ps_ve10_1 + ps_ve10_1->l_dlen + 4); }
441  */
442  /* ++++++++++++++++++++++++ */
443  /* +++ message handling +++ */
444  /* ++++++++++++++++++++++++ */
446  if (p_clntbuf->l_buffertype & 2)
447  { /* buffer contains message */
448  switch (p_clntbuf->l_msgtyp & 15)
449  {
450  case 1:
451  case 2: if((strstr(p_clntbuf->c_message,"no event data") == NULL)&
452  (strstr(p_clntbuf->c_message,"flushed") == NULL))
453  printf("MSG-type:W: %s\n", p_clntbuf->c_message); break;
454  case 4: printf("MSG-type:E: %s\n", p_clntbuf->c_message); break;
455  case 8: printf("MSG-type:F: %s\n", p_clntbuf->c_message); break;
456  default: printf("Unknown MSG-type:%d:\n%s\n",p_clntbuf->l_msgtyp,p_clntbuf->c_message);
457  }
458  l_sts=STC__TIMEOUT; /* buffer without events */
459  }
460  else
461  {
462  if(p_clntbuf->l_events == 0)
463  {
465  }
466  }
467  ps_chan->pc_evt_buf = (char *)&p_clntbuf->c_buffer[0];
468  ps_chan->l_evt_buf_posi = 1; /* number of events */
469  ps_ve10_1 = (s_ve10_1 *) ps_chan->pc_evt_buf;
470 return(l_sts);
471 } /* end f_evcli_buf */
472 
473 /***************************************************************************/
475 /***************************************************************************/
476 {
477  int *ps_int;
478  s_ve10_1 *ps_ve10_1;
479 
480  p_clntbuf = (struct s_clntbuf *) ps_chan->pc_io_buf;
481  if(ps_chan->l_evt_buf_posi < p_clntbuf->l_events)
482  {
483  ps_chan->l_evt_buf_posi++;
484  ps_ve10_1 = (s_ve10_1 *) ps_chan->pc_evt_buf;
485  ps_int = (int *) ps_chan->pc_evt_buf;
486  ps_int += ps_ve10_1->l_dlen/2 + 2;
487  ps_chan->pc_evt_buf = (char *) ps_int;
488  return(STC__SUCCESS);
489  }
490  else return(-1);
491 }
492 /***************************************************************************/
494 /***************************************************************************/
495 {
496  /* ++++++++++++++++++++++++++++++ */
497  /* +++ send acknowledge buffer +++ */
498  /* ++++++++++++++++++++++++++++++ */
499  l_status = f_send_ackn(8, ps_chan->l_channel_no);
500  if (l_status != TRUE)
501  {
502  printf("E-%s: Error sending acknowledge: f_send_ackn()!\n", c_modnam);
503  return(l_status);
504  }
505  f_clnup(v_mem_clnup, NULL);
506  f_stc_discclient(ps_chan->l_channel_no);
507  f_stc_close(&s_tcpcomm_ec);
508 return(STC__SUCCESS);
509 }
510 
511 
512 /*2+F_FLTDSCR***+******************************************************/
513 /* */
514 /*+ Module : F_FLTDSCR */
515 /* */
516 /* */
517 /*--------------------------------------------------------------------*/
518 /*+ CALLING : sts = f_fltdscr(p_clnt_filter) */
519 /* */
520 /* */
521 /*--------------------------------------------------------------------*/
522 /* */
523 /*+ PURPOSE : Read and check the event filter and construct the */
524 /* filter descriptor. */
525 /* */
526 /*+ ARGUMENTS : p_clnt_filter: Pointer to structure s_clnt_filter */
527 /* */
528 /*+ FUNCTION : Read and check the event filter and construct the */
529 /* filter descriptor. Output via "printf". */
530 /* See also I$PS_FLTDSC_PRTCL */
531 /* */
532 /*+ Return type : int (32 bit) */
533 /*+ Status codes: bit 0: success */
534 /* bit 1: warning */
535 /*+ Initialize : - */
536 /*+ Include name: - */
537 /* */
538 /*3+Implementation************+****************************************/
539 /* */
540 /*+ File name : PC_PROC.C */
541 /*+ Version : 1.01 */
542 /*+ Author : R.S. Mayer */
543 /*+ Last Update : 14-JUN-1993 */
544 /*+ Object libr.: GOOSHRLIB */
545 /*3+Updates*******+***********+****************************************/
546 /* */
547 /*+ Updates : Date Purpose */
548 /* */
549 /*3+Description***+***********+****************************************/
550 /*1- C Procedure ***********+******************************************/
551 int f_fltdscr(p_clnt_filter) /* read filter, check and */
552  /* constr. flt_descriptor */
553 struct s_clnt_filter *p_clnt_filter;
554 {
555  static char c_modnam[] = "f_fltdscr";
556  struct s_filter *p_filter;
557  struct s_opc1 *p_opc1;
558  struct s_flt_descr *p_flt_descr;
559  struct s_pat1 *p_pat1;
560  struct s_pat2 *p_pat2;
561  struct s_pat3 *p_pat3;
562 
563  short i_fltdescnt = 0;
564  short i_fltcnt = 0;
565  short i_fltblkcnt = 0;
566  short i, i_flt_len,
567  i_fltblkbeg, i_fltblkend, j;
568  short if_newfltblk = 1;
569  short i_next_fltblk = 0; // SL 16.11.2009 add initialization to 0
570  short i_descr; /* test */
571  int l_evtdescr, *pl_evtdescr, *pl_sev1descr, *pl_sev2descr;
572  short i_lasevtflt, i_1stsevflt;
573 
574  int unsigned l_status, l_sts;
575  int unsigned l_retsts = 0;
576 
577  /* +++ action +++ */
578  if (i_debug == 2)
579  printf("--->D-%s: addr_filter p:%d\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[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[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  struct s_flt_descr *p_flt_descr;
914  struct s_pat1 *p_pat1;
915  struct s_pat2 *p_pat2;
916  struct s_pat3 *p_pat3;
917 
918  char c_retmsg[256];
919  char c_line[80], c_comment[80], *c_fsts, *p_com, *p_minus;
920  short i_fltblklen = 0;
921  short i_currflt = 0;
922  short i, j;
923  int l, l_scan=0;
924 
925  int unsigned l_pattern;
926  int l_offset;
927 
928  short i_evtsev,i_selflt,i_selwrt,i_opc,i_lnkf1,
929  i_lnkf2,i_fltspec;
930  short if_hex, if_comment;
931 
932  char *fgets( char *str, int maxchar, FILE *file_ptr);
933 
934  /* +++ action +++ */
935 
936  if ( (infile = fopen(c_file,"r")) == 0)
937  { /* open file for data input */
938  sprintf(c_retmsg,"E-%s: fopen(File=%s) ",
939  c_modnam,
940  c_file);
941  perror(c_retmsg);
942  fclose(infile);
943  return(FALSE);
944  }
945 
946  printf("Filter definition from file %s\n", c_file);
947  printf("=======================================\n");
948 
949  while (l_scan != EOF && i_fltblklen < GPS__MAXFLT)
950  {
951  m_read_nxtblklen:;
952 
953  memset(c_line,0,sizeof(c_line));
954 
955  if ( (c_fsts = fgets(c_line, sizeof(c_line), infile)) == 0)
956  {
957  if (i_debug == 2)
958  printf("D-%s: File=%s: Last input line.\n",
959  c_modnam,
960  c_file);
961  break;
962  }
963 
964  if_comment = 0; /* reset flag */
965  p_com = strpbrk(c_line,"!/*"); /* find position of comment */
966  if (p_com != NULL)
967  { /* found a comment */
968  if_comment = 1; /* set flag */
969  strcpy(c_comment,p_com); /* copy comment */
970  *p_com = '\0'; /* mark end of str at beg of comm*/
971  if (i_debug == 2)
972  printf(" - D: comment:%s", c_comment);
973 
974  }
975 
976  l_scan = sscanf(c_line, "%hd", &i_fltblklen);
977  if (if_comment && (l_scan < 1) )
978  goto m_read_nxtblklen;
979 
980  if (l_scan == EOF || l_scan == 0 || c_fsts == NULL)
981  {
982  if (i_debug == 2)
983  printf("D-%s: Last input line.\n",c_file);
984  break;
985  }
986 
987  if (i_fltblklen + i_currflt >= GPS__MAXFLT)
988  {
989  printf("E-%s: too long. Last filter block ignored\n",
990  c_modnam);
991  fclose(infile);
992  return(3);
993  }
994  if (i_debug == 2)
995  printf("D-%s: Fltblklen:%d\n", c_modnam, i_fltblklen);
996 
997  for (i = i_currflt; i < i_fltblklen + i_currflt; i++)
998  {
999  m_read_nxtline:;
1000 
1001  memset(c_line,0,sizeof(c_line));
1002 
1003  if ( (c_fsts = fgets(c_line, sizeof(c_line), infile)) == 0)
1004  {
1005  sprintf(c_retmsg,"E-%s: Error reading:fgets(File=%s) ",
1006  c_modnam,
1007  c_file);
1008  perror(c_retmsg);
1009  fclose(infile);
1010  return(FALSE);
1011  }
1012 
1013  if (i_debug == 2)
1014  printf("D-%s: line:%s", c_modnam, c_line);
1015 
1016  if_comment = 0; /* reset flag */
1017  p_com = strpbrk(c_line,"!/*"); /* find position of comment */
1018  if (p_com != NULL)
1019  { /* found a comment */
1020  if_comment = 1; /* set flag */
1021  strcpy(c_comment,p_com); /* copy comment */
1022  *p_com = '\0'; /* mark end of str at beg of comm*/
1023  if (i_debug == 2)
1024  printf(" - D: comment:%s", c_comment);
1025 
1026  }
1027 
1028  l_scan = sscanf(c_line,"%hd %hd %hd %hd %hd %hd %hd %ld %ld",
1029  &i_evtsev,
1030  &i_selflt,
1031  &i_selwrt,
1032  &i_opc,
1033  &i_lnkf1,
1034  &i_lnkf2,
1035  &i_fltspec,
1036  &l_pattern,
1037  &l_offset);
1038  if_hex = 0; /* set flag null */
1039  if (l_scan == 9)
1040  goto m_ok_assign;
1041 
1042  if_hex = 1; /* set flag null */
1043  p_minus = strchr(c_line,'-'); /* find minus sign in offset */
1044 
1045  if (p_minus != 0) /* found minus sign */
1046  *p_minus = ' '; /* replace minus with blank */
1047 
1048  l_scan = sscanf(c_line,"%hd %hd %hd %hd %hd %hd %hd %lx %lx",
1049  &i_evtsev,
1050  &i_selflt,
1051  &i_selwrt,
1052  &i_opc,
1053  &i_lnkf1,
1054  &i_lnkf2,
1055  &i_fltspec,
1056  &l_pattern,
1057  &l_offset);
1058 
1059  l_offset = (p_minus != NULL) ? -l_offset : l_offset;
1060 
1061  if (l_scan < 9)
1062  {
1063  if (if_comment)
1064  goto m_read_nxtline;
1065 
1066  printf(
1067  "E-%s: scanned only %d(of 9) var., last 2 must be dec or hexa\n",
1068  c_modnam,
1069  l_scan);
1070  fclose(infile);
1071  return(FALSE);
1072  }
1073 
1074  m_ok_assign:
1075  if (i_debug == 2)
1076  {
1077  sprintf( c_retmsg,
1078  "%s es:%d f:%d w:%d opc:%d lf1:%d lf2:%d flt:%d p:%x o:%x",
1079  (if_hex) ? "HEX:" : "DEC:",
1080  i_evtsev,
1081  i_selflt,
1082  i_selwrt,
1083  i_opc,
1084  i_lnkf1,
1085  i_lnkf2,
1086  i_fltspec,
1087  l_pattern,
1088  l_offset);
1089  printf("D-%s: %s\n", c_modnam, c_retmsg);
1090  }
1091 
1092  p_filter = (struct s_filter *) &p_clnt_filter->filter[i];
1093  p_opc1 = (struct s_opc1 *) &p_filter->l_opcode;
1094 
1095  p_opc1->h_next_fltblk = (char) i_fltblklen + i_currflt;
1096  p_opc1->h_flt_len = (char) i_fltblklen;
1097 
1098  p_filter->l_pattern = l_pattern;
1099  p_filter->l_offset = l_offset;
1100 
1101  p_opc1->b1_evtsev = i_evtsev;
1102  p_opc1->b1_selflt = i_selflt;
1103  p_opc1->b1_selwrt = i_selwrt;
1104  p_opc1->b3_opc = i_opc;
1105  p_opc1->b1_lnkf1 = i_lnkf1;
1106  p_opc1->b1_lnkf2 = i_lnkf2;
1107  p_opc1->h_fltspec = (char) i_fltspec;
1108 
1109  } /* for */
1110 
1111  i_currflt = (short) p_opc1->h_next_fltblk;
1112 
1113  } /* while */
1114 
1115  fclose(infile);
1116 
1117  return(TRUE);
1118 }
1119 
1120 
1121 
1122 /*2+F_TYPFLT***+*******************************************************/
1123 /* */
1124 /*+ Module : F_TYPFLT */
1125 /* */
1126 /* */
1127 /*--------------------------------------------------------------------*/
1128 /*+ CALLING : sts = f_typflt(p_clnt_filter) */
1129 /* */
1130 /* */
1131 /*--------------------------------------------------------------------*/
1132 /* */
1133 /*+ PURPOSE : Type the filter conditions. */
1134 /* */
1135 /*+ ARGUMENTS : p_clnt_filter: Pointer to s__clnt_filter */
1136 /* */
1137 /*+ FUNCTION : Type the filter conditions. Output via "printf". */
1138 /* See also I$PS_TYPFLT_PRTCL. */
1139 /* */
1140 /*+ Return type : int (32 bit) 1: success 0: fault */
1141 /*+ Status codes: - */
1142 /*+ Initialize : - */
1143 /*+ Include name: - */
1144 /* */
1145 /*3+Implementation************+****************************************/
1146 /* */
1147 /*+ File name : PC_PROC.C */
1148 /*+ Version : 1.01 */
1149 /*+ Author : R.S. Mayer */
1150 /*+ Last Update : 14-JUN-1993 */
1151 /*+ Object libr.: GOOSHRLIB */
1152 /*3+Updates*******+***********+****************************************/
1153 /* */
1154 /*+ Updates : Date Purpose */
1155 /*- 12-Jan-1994 : Bug removed in subcrate,control (RSM) */
1156 /* */
1157 /*3+Description***+***********+****************************************/
1158 /*1- C Procedure ***********+******************************************/
1159 int f_typflt(p_clnt_filter)
1160 struct s_clnt_filter *p_clnt_filter;
1161 {
1162  static char c_modnam[] = "f_typflt";
1163  struct s_filter *p_filter;
1164  struct s_opc1 *p_opc1;
1165  struct s_flt_descr *p_flt_descr;
1166  struct s_pat1 *p_pat1;
1167  struct s_pat2 *p_pat2;
1168  struct s_pat3 *p_pat3;
1169 
1170  short i_fltdescnt, j, i;
1171 
1172  /* +++ action +++ */
1173 
1174  /* + + + Max number of descriptors + + + */
1175  i_fltdescnt = p_clnt_filter->flt_descr[0].i_descriptors;
1176 
1177  /* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */
1178  /* + + + Output filter conditions for Write and Filter + + + */
1179  /* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */
1180 /* printf("Explanation: object OPCODE mask\n===========\n");
1181  */
1182  if ( (i_debug == 1) || (i_debug == 2) )
1183  printf(
1184  "Write:%s %s Filter:%s %s object OPCODE mask",
1185  (p_clnt_filter->if_wrtevt > 0) ? "EVENT" : "",
1186  (p_clnt_filter->if_wrtsev > 0) ? "SUBEVENT" : "",
1187  (p_clnt_filter->if_fltevt > 0) ? "EVENT" : "",
1188  (p_clnt_filter->if_fltsev > 0) ? "SUBEVENT" : "");
1189  for (i = 0; i < i_fltdescnt; i++) {
1190  p_flt_descr = (struct s_flt_descr *) &p_clnt_filter->flt_descr[i];
1191  p_filter = (struct s_filter *)
1192  &p_clnt_filter->filter[p_flt_descr->h_fltblkbeg];
1193  p_opc1 = (struct s_opc1 *) &p_filter->l_opcode;
1194 
1195  if ( (i_debug == 1) || (i_debug == 2) )
1196  {
1197  if (i > 1)
1198  printf("\n<<%s>>\n", (p_opc1->b1_lnkf2 == 1) ? "A_N_D" : "O_R" );
1199  printf("\n=>>FILTER set %d :",i);
1200  printf(" Select:%s Filter:%s Write:%s Filter[%d:%d]:\n",
1201  (p_opc1->b1_evtsev == 1) ? "EVENT" : "SUBEVENT",
1202  (p_opc1->b1_selflt == 1) ? "ON" : "OFF",
1203  (p_opc1->b1_selwrt == 1) ? "ON" : "OFF",
1204  p_flt_descr->h_fltblkbeg,
1205  p_flt_descr->h_fltblkend );
1206  }
1207 
1208  /* +++ subevt flt blk id +++ */
1209  if (p_opc1->b1_evtsev == 0 && p_opc1->b1_selflt == 1)
1210  {
1211  p_filter = (struct s_filter *)
1212  &p_clnt_filter->filter[p_flt_descr->h_fltblkbeg];
1213  if ( (i_debug == 1) || (i_debug == 2) )
1214  printf(
1215  " Filter set id is fltspec:%d == mask:H%x (see 1st filt. below)\n",
1216  p_opc1->h_fltspec,
1217  p_filter->l_pattern);
1218  }
1219 
1220 
1221  /* +++ loop over all filters in this filter block +++ */
1222  for (j = p_flt_descr->h_fltblkbeg;
1223  j <= p_flt_descr->h_fltblkend;
1224  j++) {
1225  p_filter = (struct s_filter *) &p_clnt_filter->filter[j];
1226  p_opc1 = (struct s_opc1 *) &p_filter->l_opcode;
1227  if ( (j > p_flt_descr->h_fltblkbeg) &&
1228  (p_opc1->b1_selflt == 1) &&
1229  ( (i_debug == 1) || (i_debug == 2) ) )
1230  printf(" <%s>\n", (p_opc1->b1_lnkf1 == 1) ? "A_N_D" : "O_R" );
1231  if ( (i_debug == 1) || (i_debug == 2) )
1232  printf(" =>%2d: opcode: ", i + 1);
1233 
1234  switch (p_opc1->b3_opc) {
1235  case 0:
1236  if ( (i_debug == 1) || (i_debug == 2) )
1237  printf("!! (ALL) ");
1238  break;
1239  case 1:
1240  if ( (i_debug == 1) || (i_debug == 2) )
1241  printf("== (IDENT) ");
1242  break;
1243 
1244  case 2:
1245  if ( (i_debug == 1) || (i_debug == 2) )
1246  printf("&& (ANY) ");
1247  break;
1248 
1249  case 3:
1250  if ( (i_debug == 1) || (i_debug == 2) )
1251  printf("&= (INCL) ");
1252  break;
1253 
1254  case 4:
1255  if ( (i_debug == 1) || (i_debug == 2) )
1256  printf("^= (EXCL) ");
1257  break;
1258 
1259  case 5:
1260  if ( (i_debug == 1) || (i_debug == 2) )
1261  printf("< (LT) ");
1262  break;
1263 
1264  case 6:
1265  if ( (i_debug == 1) || (i_debug == 2) )
1266  printf(">= (GE) ");
1267  break;
1268 
1269  default:
1270  printf("W-OPCODE %d NOT FOUND\n",p_opc1->b3_opc);
1271  }
1272 
1273  switch (p_opc1->h_fltspec) {
1274  case 0: /* ++++ take all ++++ */
1275  if (p_opc1->b3_opc != 0) {
1276  p_opc1->b3_opc = 0;
1277  printf("W-%s: Take all. Opcode is %d\n",
1278  c_modnam,
1279  p_opc1->b3_opc);
1280  }
1281  break;
1282 
1283  case 1: /* ++++ trigger ++++ */
1284  p_pat1 = (struct s_pat1 *) &p_filter->l_pattern;
1285  if ( (i_debug == 1) || (i_debug == 2) )
1286  {
1287  printf("trigger:%2d",p_pat1->i_trigger);
1288  printf(" (mask:%d offs:%d %s)\n",
1289  p_filter->l_pattern,
1290  (p_filter->l_offset >= 0) ?
1291  p_filter->l_offset : -p_filter->l_offset,
1292  (p_filter->l_offset >= 0) ? "LW" : "W");
1293  }
1294  break;
1295 
1296  case 2: /* ++++ pattern and offset ++++ */
1297  if ( (i_debug == 1) || (i_debug == 2) )
1298  printf("mask:H%x offset:%d %s\n",
1299  p_filter->l_pattern,
1300  (p_filter->l_offset >= 0) ?
1301  p_filter->l_offset : -p_filter->l_offset,
1302  (p_filter->l_offset >= 0) ?
1303  "LW" : "W" );
1304  break;
1305 
1306  case 4: /* W ++++ type ++++ */
1307  if ( (i_debug == 1) || (i_debug == 2) )
1308  {
1309  printf("type:%d ",
1310  p_filter->l_pattern);
1311  printf(" (mask:%d offs:%d %s)\n",
1312  p_filter->l_pattern,
1313  (p_filter->l_offset >= 0) ?
1314  p_filter->l_offset : -p_filter->l_offset,
1315  (p_filter->l_offset >= 0) ? "LW" : "W");
1316  }
1317  break;
1318 
1319  case 8: /* W ++++ subtype ++++ */
1320  if ( (i_debug == 1) || (i_debug == 2) )
1321  {
1322  printf("subtype:%d ",
1323  p_filter->l_pattern);
1324  printf(" (mask:%d offs:%d %s)\n",
1325  p_filter->l_pattern,
1326  (p_filter->l_offset >= 0) ?
1327  p_filter->l_offset : -p_filter->l_offset,
1328  (p_filter->l_offset >= 0) ? "LW" : "W");
1329  }
1330  break;
1331 
1332  case 12: /* W ++++ type and subtype ++++ */
1333  p_pat3 = (struct s_pat3 *) &p_filter->l_pattern;
1334  if ( (i_debug == 1) || (i_debug == 2) )
1335  {
1336  printf("type:%d subtype:%d",
1337  p_pat3->i_type,
1338  p_pat3->i_subtype);
1339  printf(" (mask:H%x offs:%d %s)\n",
1340  p_filter->l_pattern,
1341  (p_filter->l_offset >= 0) ?
1342  p_filter->l_offset : -p_filter->l_offset,
1343  (p_filter->l_offset >= 0) ? "LW" : "W");
1344  }
1345  break;
1346 
1347  case 16: /* ++++ procid ++++*/
1348  p_pat2 = (struct s_pat2 *) &p_filter->l_pattern;
1349  if ( (i_debug == 1) || (i_debug == 2) )
1350  {
1351  printf("procid:%d ",
1352  p_pat2->i_procid);
1353  printf(" (mask:%d offs:%d %s)\n",
1354  p_filter->l_pattern,
1355  (p_filter->l_offset >= 0) ?
1356  p_filter->l_offset : -p_filter->l_offset,
1357  (p_filter->l_offset >= 0) ? "LW" : "W");
1358  }
1359  break;
1360 
1361  case 32: /* W ++++ subcrate,contr ++++*/
1362  if ( (i_debug == 1) || (i_debug == 2) )
1363  {
1364  printf("subcrate:%d control:%d",
1365  p_filter->l_pattern & 0x00FF,
1366  ((unsigned) (p_filter->l_pattern & 0xFF00)) >> 8);
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  case 48: /* LW ++++procid,subcr,contr ++++*/
1376  p_pat2 = (struct s_pat2 *) &p_filter->l_pattern;
1377  if ( (i_debug == 1) || (i_debug == 2) )
1378  {
1379  printf("procid:%2d subcr:%d contr:%d",
1380  p_pat2->i_procid,
1381  p_pat2->h_subcrate,
1382  p_pat2->h_control);
1383  printf(" (mask:H%x offs:%d %s)\n",
1384  p_filter->l_pattern,
1385  (p_filter->l_offset >= 0) ?
1386  p_filter->l_offset : -p_filter->l_offset,
1387  (p_filter->l_offset >= 0) ? "LW" : "W");
1388  }
1389  break;
1390 
1391  default:
1392  printf("W-FLTSPEC %d NOT FOUND\n",p_opc1->h_fltspec);
1393  } /* switch case */
1394 
1395  /* ++++ check if Filter specification is valid ++++ */
1396  if ((p_opc1->h_fltspec > 15) && (p_opc1->b1_evtsev == 1)) {
1397  printf("E-%s: Filter specification %d invalid for events\n",
1398  c_modnam,
1399  p_opc1->h_fltspec);
1400  return(FALSE); /* abort with error */
1401  }
1402  if ((p_opc1->h_fltspec < 2) && (p_opc1->b1_evtsev != 1)) {
1403  printf("E-%s: Filter specification %d invalid for subevents\n",
1404  c_modnam,
1405  p_opc1->h_fltspec);
1406  return(FALSE); /* abort with error */
1407  }
1408 
1409  } /* for (j... */
1410 
1411  } /* for (i... */
1412  if ( (i_debug == 1) || (i_debug == 2) )
1413  printf("\n\n");
1414 
1415  return(TRUE);
1416 } /* end f_typflt */
1417 
1418 
1419 
1420 
1421 /*2+F_READ_SERVER***+**************************************************/
1422 /* */
1423 /*+ Module : F_READ_SERVER */
1424 /* */
1425 /* */
1426 /*--------------------------------------------------------------------*/
1427 /*+ CALLING : sts = f_read_server(p_clntbuf, */
1428 /* p_bytrd, */
1429 /* l_timeout, */
1430 /* i_chan) */
1431 /* */
1432 /* */
1433 /*--------------------------------------------------------------------*/
1434 /* */
1435 /*+ PURPOSE : Read a buffer from the server */
1436 /* */
1437 /*+ ARGUMENTS : */
1438 /*+ p_clntbuf: Pointer to structure s_clntbuf */
1439 /*+ p_bytrd : Pointer to (int) Number of read bytes */
1440 /*+ l_timeout: (int) Timeout in seconds */
1441 /*+ i_chan : (int) channel number */
1442 /* */
1443 /*+ FUNCTION : Read a buffer of the type s_clntbuf from the */
1444 /* server. */
1445 /* */
1446 /*+ Return type : int (32 bit) */
1447 /*+ Status codes: 1: success */
1448 /* 0: fault */
1449 /*+ Initialize : - */
1450 /*+ Include name: - */
1451 /* */
1452 /*3+Implementation************+****************************************/
1453 /* */
1454 /*+ File name : PC_PROC.C */
1455 /*+ Version : 1.01 */
1456 /*+ Author : R.S. Mayer */
1457 /*+ Last Update : 14-JUN-1993 */
1458 /*+ Object libr.: GOOSHRLIB */
1459 /*3+Updates*******+***********+****************************************/
1460 /* */
1461 /*+ Updates : Date Purpose */
1462 /*- 26-Jan-1994 : Swap inserted (RSM) */
1463 /*- 24-Feb-1994 : Bug removed (RSM) */
1464 /* */
1465 /*3+Description***+***********+****************************************/
1466 /*1- C Procedure ***********+******************************************/
1467 int f_read_server(ps_chan, p_bytrd, l_timeout, i_chan)
1468 s_evt_channel *ps_chan;
1469 int *p_bytrd;
1470 int l_timeout;
1471 int i_chan;
1472 {
1473  /* ++++ declarations ++++ */
1474 int l_maxbytes;
1475  int l_status,ii,im,*pl; /* !!! */
1476  int l_bytrec, l_2ndbuf_byt;
1477  int l_buftord, l_buffertype;
1478  static char c_modnam[] = "f_read_server";
1479  char c_retmsg[256];
1480  char *pc;
1481  int *pl_d,*pl_s;
1482  s_ve10_1 *ps_ve10_1;
1483 
1484  /* ++++ action ++++ */
1485 
1486  p_clntbuf = (struct s_clntbuf *) ps_chan->pc_io_buf;
1487  l_maxbytes=ps_chan->l_io_buf_size;
1488  /* + + + + + + + + + + + + + + + */
1489  /* + + + read first buffer + + + */
1490  /* + + + + + + + + + + + + + + + */
1491  if (i_debug == 2)
1492  printf(
1493  "D-%s: **Rd 1st Buf: at %8x to %8x = %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  l_status = f_stc_read( (char *) p_clntbuf,
1502  (int) CLNT__SMALLBUF,
1503  i_chan,
1504  l_timeout);
1505 
1506  if (l_status != STC__SUCCESS)
1507  {
1508  printf("E-%s: Error reading first buffer. Msg follows:",c_modnam);
1509  f_stc_disperror(l_status,c_retmsg, 0);
1510  return(FALSE);
1511  }
1512 
1513  /* +++ copy the relevant length values +++ */
1514  l_buftord = p_clntbuf->l_numbuftosnd;
1515  l_bytrec = p_clntbuf->l_bytestosnd;
1516  l_buffertype = p_clntbuf->l_buffertype;
1517 
1518  /* +++ test for byte swap +++ */
1519  if (p_clntbuf->l_testbit != GPS__ENV_TESTBIT)
1520  {
1521  if (i_debug == 2)
1522  printf("D-%s: Need swap to receive from %s to %s ENDIAN\n",
1523  c_modnam,
1524  (p_clntbuf->l_endian == 0) ? "LITTLE" : "BIG",
1525  (GPS__ENV_ENDIAN == 0) ? "LITTLE" : "BIG");
1526 
1527  l_status = F__SWAP(&l_buftord, 1, 0);
1528  if (l_status != 0) printf("E-%s: Error swapping l_buftord. l_sts:%d\n", c_modnam,l_status);
1529  l_status = F__SWAP(&l_bytrec , 1, 0);
1530  if (l_status != 0) printf("E-%s: Error swapping l_bytrec l_sts:%d\n", c_modnam,l_status);
1531  l_status = F__SWAP(&l_buffertype, 1, 0);
1532  if (l_status != 0) printf("E-%s: Error swapping l_buffertype l_sts:%d\n", c_modnam,l_status);
1533  if (i_debug == 2)
1534  printf("D-%s: buffers:%d, bytes:%d, buffertype:%d\n",
1535  c_modnam,
1536  l_buftord,
1537  l_bytrec,
1538  l_buffertype);
1539 
1540  }
1541  if (l_buftord == 1)
1542  {
1543  if (l_bytrec > CLNT__SMALLBUF)
1544  {
1545  printf("E-%s: Buffer sent:%d Bytes_to_rd:%d > %d\n",
1546  c_modnam,
1547  l_buftord,
1548  l_bytrec,
1549  CLNT__SMALLBUF);
1550  return(FALSE);
1551  }
1552  goto m_snd_ackn;
1553  }
1554 
1555  l_2ndbuf_byt = l_bytrec - CLNT__SMALLBUF; /* rest of bytes in 2nd buffer*/
1556 
1557  /* + + + + + + + + + + + + + + */
1558  /* + + + read 2nd buffer + + + */
1559  /* + + + + + + + + + + + + + + */
1560  if (i_debug == 2)
1561  {
1562  short j;
1563  int *pl;
1564  printf("D-%s: begin of c_buffer[148] in LW (all hex)\n", c_modnam);
1565  pl = (int *) &p_clntbuf->c_buffer[148];
1566  for (j=0; j<5; j++)
1567  {
1568  printf("%8x:%8x ",pl,*(pl));
1569  pl++;
1570  printf("%8x:%8x ",pl,*(pl));
1571  pl++;
1572  printf("%8x:%8x ",pl,*(pl));
1573  pl++;
1574 
1575  printf("\n");
1576  }
1577  printf("D-%s: **Rd 2nd Buf: at %8x (buf[%d]) to %8x = %d b\n",
1578  c_modnam,
1579  (char *) &p_clntbuf->c_buffer[CLNT__RESTBUF],
1580  CLNT__RESTBUF,
1581  ((char *) &p_clntbuf->c_buffer[CLNT__RESTBUF]) + (l_2ndbuf_byt - 1),
1582  l_2ndbuf_byt);
1583  }
1584  *p_bytrd += l_2ndbuf_byt;
1585  l_buftord = 2;
1586  /* check if buffer if big enough, reallocate if not */
1587  /* old buffer is freed by caller */
1588  if(l_bytrec > l_maxbytes)
1589  {
1590  im=l_bytrec;
1591  l_bytrec=(int)(1.2*(float)l_bytrec);
1592  l_bytrec=((l_bytrec>>12)+1);
1593  l_bytrec=(l_bytrec<<12);
1594  /* printf("reallocate for %d (%d) bytes\n",im,l_bytrec);fflush(stdout);*/
1595  pc = (char*) malloc(l_bytrec);
1596  pl_d=(int *)pc;
1597  for(ii=0;ii<l_bytrec/4;ii++) *pl_d++ = 0;
1598  pl_d=(int *)pc;
1599  pl_s=(int *)ps_chan->pc_io_buf;
1600  for(ii=0;ii<CLNT__SMALLBUF/4;ii++) *pl_d++ = *pl_s++;
1601  ps_chan->pc_io_buf = pc;
1602  ps_chan->l_io_buf_size = l_bytrec;
1603  p_clntbuf = (struct s_clntbuf *) pc;
1604  }
1605  pl = (int *) &p_clntbuf->c_buffer[CLNT__RESTBUF];
1606  im=l_2ndbuf_byt/16384;
1607  l_2ndbuf_byt=l_2ndbuf_byt%16384;
1608  for(ii=0;ii<im;ii++)
1609  {
1610  l_status = f_stc_read( pl,16384,i_chan,l_timeout);
1611  pl+=4096;
1612  if(l_status != STC__SUCCESS)break;
1613  }
1614  if(l_2ndbuf_byt > 0)
1615  {
1616  l_status = f_stc_read( pl,l_2ndbuf_byt,i_chan,l_timeout);
1617  }
1618  if (l_status != STC__SUCCESS)
1619  {
1620  printf("E-%s: Error reading second buffer. Msg follows:",c_modnam);
1621  f_stc_disperror(l_status,c_retmsg, 0);
1622  return(FALSE);
1623  }
1624 
1625  if (i_debug == 2)
1626  {
1627  short j;
1628  int *pl;
1629  printf("D-%s: begin of c_buffer[148] in LW (all hex)\n", c_modnam);
1630  pl = (int *) &p_clntbuf->c_buffer[148];
1631  for (j=0; j<5; j++)
1632  {
1633  printf("%8x:%8x ",pl,*(pl));
1634  pl++;
1635  printf("%8x:%8x ",pl,*(pl));
1636  pl++;
1637  printf("%8x:%8x ",pl,*(pl));
1638  pl++;
1639 
1640  printf("\n");
1641  }
1642  }
1643 
1644  m_snd_ackn:; /* +++ set and send 12 bytes ackn */
1645  /* ++++++++++++++++++++++++++++++++++ */
1646  /* + + + send acknowledge buffer + + + */
1647  /* ++++++++++++++++++++++++++++++++++ */
1648  s_ackn.l_ack_buf = l_buftord;
1649  s_ackn.l_ack_bytes = *p_bytrd;
1650  s_ackn.l_clnt_sts = 1; /* success */
1651 
1652  if ((l_buffertype & 8) != 0)
1653  s_ackn.l_clnt_sts = s_ackn.l_clnt_sts | 8; /* set bit for last buffer */
1654 
1655  return(TRUE);
1656 }
1657 
1658 
1659 /*2+F_SEND_ACKN*****+**************************************************/
1660 /* */
1661 /*+ Module : F_SEND_ACKN */
1662 /* */
1663 /* */
1664 /*--------------------------------------------------------------------*/
1665 /*+ CALLING : sts = f_send_ackn(l_clnt_sts, i_chan) */
1666 /*--------------------------------------------------------------------*/
1667 /* */
1668 /*+ PURPOSE : Send acknowledge buffer to the server */
1669 /* */
1670 /*+ ARGUMENTS : */
1671 /*+ l_clnt_sts: Status. Status bits will be set in addition to the */
1672 /* status bits set by f_read_server in s_ackn struct. */
1673 /*+ i_chan : (int) channel number */
1674 /* */
1675 /*+ FUNCTION : Send the acknowledge buffer. Set additional bits in */
1676 /* the status word, i.e. "last buffer" etc. */
1677 /* */
1678 /*+ Return type : int (32 bit) */
1679 /*+ Status codes: 1: success */
1680 /* 0: fault */
1681 /*+ Initialize : - */
1682 /*+ Include name: - */
1683 /* */
1684 /*3+Implementation************+****************************************/
1685 /* */
1686 /*+ File name : PC_PROC.C */
1687 /*+ Version : 1.01 */
1688 /*+ Author : R.S. Mayer */
1689 /*+ Last Update : 11-Apr-1994 */
1690 /*+ Object libr.: GOOSHRLIB */
1691 /*3+Updates*******+***********+****************************************/
1692 /* */
1693 /*+ Updates : Date Purpose */
1694 /* */
1695 /*3+Description***+***********+****************************************/
1696 /*1- C Procedure ***********+******************************************/
1698 int l_clnt_sts;
1699 int i_chan;
1700 {
1701  /* ++++ declarations ++++ */
1702  int l_status; /* !!! */
1703  static char c_modnam[] = "f_send_ackn";
1704  char c_retmsg[256];
1705 
1706  if (i_debug == 2)
1707  printf("I-%s s_ackn.l_clnt_sts:%d l_clnt_sts:%d\n",
1708  c_modnam,
1709  s_ackn.l_clnt_sts,
1710  l_clnt_sts);
1711 
1712  /* +++++++++++++++++++++++++++++++ */
1713  /* +++ set status of ackn buf +++ */
1714  /* +++++++++++++++++++++++++++++++ */
1715  s_ackn.l_clnt_sts = s_ackn.l_clnt_sts | l_clnt_sts; /* success */
1716 
1717  /* ++++++++++++++++++++++++++++++ */
1718  /* +++ send acknowledge buffer +++ */
1719  /* ++++++++++++++++++++++++++++++ */
1720  l_status = f_stc_write( (char *) &s_ackn,
1721  12,
1722  i_chan);
1723 
1724  if (l_status != STC__SUCCESS)
1725  {
1726  printf("E-%s: Error in f_stc_write(&s_ackn,...)! Msg follows:",
1727  c_modnam);
1728  f_stc_disperror(l_status,c_retmsg, 0);
1729  return(FALSE);
1730  }
1731 
1732  return(TRUE);
1733 }
1734 
1735 
1736 /*2+F_STRTOUPPER***+***************************************************/
1737 /* */
1738 /*+ Module : F_STRTOUPPER */
1739 /* */
1740 /* */
1741 /*--------------------------------------------------------------------*/
1742 /*+ CALLING : sts = f_strtoupper(u, l) */
1743 /* */
1744 /* */
1745 /*--------------------------------------------------------------------*/
1746 /* */
1747 /*+ PURPOSE : Converts a '\0' terminated string to upper case. */
1748 /* */
1749 /*+ ARGUMENTS : */
1750 /*+ u : Pointer to upper case string (result) */
1751 /*+ l : Pointer to lower case string (argument) */
1752 /* */
1753 /*+ FUNCTION : Converts a '\0' terminated string to upper case. */
1754 /* */
1755 /*+ Return type : int (32 bit) */
1756 /*+ Status codes: - */
1757 /*+ Initialize : - */
1758 /*+ Include name: - */
1759 /* */
1760 /*3+Implementation************+****************************************/
1761 /* */
1762 /*+ File name : PC_PROC.C */
1763 /*+ Version : 1.01 */
1764 /*+ Author : R.S. Mayer */
1765 /*+ Last Update : 14-JUN-1993 */
1766 /*+ Object libr.: GOOSHRLIB */
1767 /*3+Updates*******+***********+****************************************/
1768 /* */
1769 /*+ Updates : Date Purpose */
1770 /* */
1771 /*3+Description***+***********+****************************************/
1772 /*1- C Procedure ***********+******************************************/
1773 void f_strtoupper(u, l)
1774 char *u, *l;
1775 {
1776  for ( ; *l != '\0'; ++l, ++u)
1777  *u = toupper(*l);
1778 
1779  *u = '\0';
1780  return;
1781 }
1782 
1783 
1784 /*2+F_CLNUP ***+*******************************************************/
1785 /* */
1786 /*+ Module : F_CLNUP */
1787 /* */
1788 /* */
1789 /*--------------------------------------------------------------------*/
1790 /*+ CALLING : f_clnup(v_mem, p_keyb) */
1791 /* */
1792 /* */
1793 /*--------------------------------------------------------------------*/
1794 /* */
1795 /*+ PURPOSE : Cleanup allocated memory and dealloc devices */
1796 /* */
1797 /*+ ARGUMENTS : */
1798 /*+ v_mem[] : (int) [0]:maxidx=n [1:n]:ptr to allocated memory */
1799 /*+ p_keyb : Pointer to s_keyb or NULL. */
1800 /* */
1801 /*+ FUNCTION : Cleanup allocated memory and dealloc devices */
1802 /* Calls free(v_mem[i]) and f_ttydass(p_keyb) */
1803 /* */
1804 /* */
1805 /*+ Return type : void */
1806 /*+ Status codes: - */
1807 /*+ Initialize : - */
1808 /*+ Include name: - */
1809 /* */
1810 /*3+Implementation************+****************************************/
1811 /* */
1812 /*+ File name : PC_PROC.C */
1813 /*+ Version : 1.01 */
1814 /*+ Author : R.S. Mayer */
1815 /*+ Last Update : 14-JUN-1993 */
1816 /*+ Object libr.: GOOSHRLIB */
1817 /*3+Updates*******+***********+****************************************/
1818 /* */
1819 /*+ Updates : Date Purpose */
1820 /*- 14-Jan-94 : prototype TTYSTUFF(f_ttydass()) (RSM) */
1821 /*- 08-Apr-94 : Accept NULL pointer for p_keyb. /HE */
1822 /* */
1823 /*3+Description***+***********+****************************************/
1824 /*1- C Procedure ***********+******************************************/
1825 /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
1826 void f_clnup(v_mem, p_keyb)
1827 long v_mem[];
1828 int *p_keyb;
1829 /* cleanup: free allocated memory and dealloc allocated device(s) */
1830 {
1831  /* ++++ declaration ++++ */
1832  static char c_modnam[] = "f_clnup";
1833  short i;
1834  int l_status;
1835 
1836  for (i = 1; i <= v_mem[0]; i++)
1837  {
1838  /* printf("free %d of %d: %8x",i,v_mem[0],v_mem[i]);fflush(stdout);*/
1839  if(v_mem[i] != 0) free((int *) v_mem[i]);
1840  /* printf(" done\n");fflush(stdout);*/
1841  v_mem[i]=0;
1842  }
1843  v_mem[0]=0;
1844 }
1845 /*******************************************************************/
1846 void f_clnup_save(v_mem, p_keyb)
1847 long v_mem[];
1848 int *p_keyb;
1849 /* cleanup: free allocated memory and dealloc allocated device(s) */
1850 {
1851  /* ++++ declaration ++++ */
1852  static char c_modnam[] = "f_clnup";
1853  short i;
1854  int l_status;
1855 
1856  /* printf("all %d:",v_mem[0]);fflush(stdout);*/
1857  v_mem[++v_mem[0]] = (long) p_keyb; /* was (int) before JA */
1858 
1859  /* printf(" %d: %8x\n",v_mem[0],(int)p_keyb);fflush(stdout);*/
1860 }
1861 /* ------------------------------------------------------------------------- */
#define FLUSH__TIME
Definition: f_evcli.c:170
int f_evcli_evt(s_evt_channel *ps_chan)
Definition: f_evcli.c:474
void f_strtoupper(char *u, char *l)
Definition: f_evcli.c:1773
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:1068
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:129
int l_retval
Definition: f_evcli.c:187
#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
INTS4 f_stc_write(void *p_buffer, INTS4 i_buflen, INTS4 i_channel)
Definition: f_stccomm.c:315
int f_send_ackn(int, int)
Definition: f_evcli.c:1697
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:192
unsigned b1_selflt
Definition: s_opc1.h:42
static int unsigned lf_swap
Definition: f_evcli.c:177
int l_sts
Definition: f_evcli.c:183
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:1376
int f_evcli_close(s_evt_channel *ps_chan)
Definition: f_evcli.c:493
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:1467
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:188
#define STC__TIMEOUT
Definition: f_stccomm.h:369
INTS4 f_stc_discclient(INTS4 i_channel)
Definition: f_stccomm.c:1149
INTS4 l_evt_buf_posi
Definition: f_evt.h:76
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:470
int f_evcli_buf(s_evt_channel *ps_chan)
Definition: f_evcli.c:383
#define STC__SUCCESS
Definition: f_stccomm.h:364
static int l_len_lw1
Definition: f_evcli.c:179
static struct @17 s_ackn
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:183
#define FALSE
Definition: f_stccomm.h:355
struct s_clntbuf * p_clntbuf
Definition: f_evcli.c:174
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_len
Definition: f_evcli.c:185
#define TRUE
Definition: f_stccomm.h:356
struct s_clnt_filter * p_clnt_filter
Definition: f_evcli.c:173
static char c_modnam[]
Definition: f_evcli.c:184
struct s_filter filter[GPS__MAXFLT]
Definition: s_clnt_filter.h:28
unsigned b3_opc
Definition: s_opc1.h:44
char c_message[CLNT__MSGLEN]
Definition: s_clntbuf.h:51
int l_ack_buf
Definition: f_evcli.c:191
unsigned short * pi_inbuf
Definition: f_evcli.c:161
long v_mem_clnup[8]
Definition: f_evcli.c:197
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:175
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:178
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:1159
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
#define GPS__OUTBUFSIZ
Definition: gps_sc_def.h:30
short i_trigger
Definition: s_pat.h:46
short i_sign
Definition: f_evcli.c:185
int unsigned l_clnt_sts
Definition: f_evcli.c:182
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
function if(typeof JSROOT!="object")
#define CLNT__REST_LW
Definition: clnt_buf_def.h:57
INTU4 l_opcode
Definition: s_filter.h:27
short if_typevt
Definition: f_evcli.c:185
int i_channel
Definition: f_evcli.c:181
int l_timeout
Definition: f_evcli.c:186
#define F__SWAP(ps, l, pd)
Definition: f_evcli.c:59
int f_fltdscr(struct s_clnt_filter *)
Definition: f_evcli.c:551
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:199
int l_len_lw2
Definition: f_evcli.c:180
unsigned b1_selwrt
Definition: s_opc1.h:43