Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

/MbsAPI/f_evcli.c

Go to the documentation of this file.
00001 //---------------------------------------------------------------
00002 //        Go4 Release Package v2.10-5 (build 21005) 
00003 //                      03-Nov-2005
00004 //---------------------------------------------------------------
00005 //       The GSI Online Offline Object Oriented (Go4) Project
00006 //       Experiment Data Processing at DVEE department, GSI
00007 //---------------------------------------------------------------
00008 //
00009 //Copyright (C) 2000- Gesellschaft f. Schwerionenforschung, GSI
00010 //                    Planckstr. 1, 64291 Darmstadt, Germany
00011 //Contact:            http://go4.gsi.de
00012 //----------------------------------------------------------------
00013 //This software can be used under the license agreements as stated
00014 //in Go4License.txt file which is part of the distribution.
00015 //----------------------------------------------------------------
00016 /*1+ C Procedure *************+****************************************/
00017 /*                                                                    */
00018 /*+ Module      : f_evcli                                           */
00019 /*                                                                    */
00020 /*--------------------------------------------------------------------*/
00021 /*+ CALLING     : f_evcli_xxx()                                */
00022 /*--------------------------------------------------------------------*/
00023 /*                                                                    */
00024 /*+ PURPOSE     :  API for GOOSY - Event - Server or    */
00025 /*                 SBS - Event - Server .     */
00026 /*                                                                    */
00027 /*+ ARGUMENTS   :                                                     */
00028 /*                                                                    */
00029 /*2+Description***+***********+****************************************/
00030 /*                                                                    */
00031 /*+ FUNCTION    : Client for test purpose GOOSY - PAW - Server and    */
00032 /*                SBS - Event - Server.                               */
00033 /*                (for detailed information see PC_CLIPAW)            */
00034 /*                                                                    */
00035 /*2+Implementation**********+******************************************/
00036 /*                                                                    */
00037 /*+ PROCEDURES  : see f_evcli_proc                                         */
00038 /*                                                                    */
00039 /*+ File name   : f_evcli.c                                         */
00040 /*                                                                    */
00041 /*+ Version     : 1.01                                                */
00042 /*+ Author      : R.S. Mayer, H.Essel                                          */
00043 /*+ Last Update : 28-feb-2000                                         */
00044 /*                                                                    */
00045 /*2+Internals***************+******************************************/
00046 /*                                                                    */
00047 /*+ Utility     :                                                     */
00048 /*+ File name   : m_evcli.c                                         */
00049 /*+ Home direct.: LEA$SRC                                         */
00050 /*+ Created     : 28-feb-2000                                         */
00051 /*                                                                    */
00052 /*2+Updates*******+***********+****************************************/
00053 /*                                                                    */
00054 /*+ Updates     : Date          Purpose                               */
00055 /*1- C Procedure *************+*********************************************/
00056 
00057 /* ++++++++++++++ !!!! IMPLEMENTATION !!!! +++++++++++++++++++++++++++++++ */
00058 
00059 #define F__SWAP(ps,l,pd) f_swaplw((int *)ps,(int)l,(int *)pd)
00060 #ifdef VMS        /* ++++++++++++++ VMS ++++++++++++++++++++++++++++ */
00061 #define UNIXENV 0                           /* switch UNIX or VMS          */
00062 #define ENDIAN  0                           /* little endian               */
00063 
00064 /* standard headers ----- */
00065 #include <stdio.h>
00066 #include <errno.h>
00067 #include <ctype.h>
00068 #include <types.h>
00069 #include <string.h>
00070 #include <stdlib.h>
00071 #endif /* VMS */
00072 
00073 #ifdef Lynx      /* ++++++++++++++++ Lynx +++++++++++++++++++++++++++ */
00074 #define UNIXENV 1                           /* switch UNIX or VMS          */
00075 #define ENDIAN  1                           /* big    endian               */
00076 #endif /* Lynx */
00077 
00078 #ifdef HPUX      /* +++++++++++++++++ HPUX ++++++++++++++++++++++++++++ */
00079 #define UNIXENV 1                           /* switch UNIX or VMS          */
00080 #define ENDIAN  1                           /* big    endian               */
00081 #define _HPUX_SOURCE                    /* this stuff is needed before    */
00082 #define _POSIX_SOURCE                   /*   any include is done          */
00083 #endif /* HPUX */
00084 
00085 #ifdef Linux     /* +++++++++++++++++ Linux ++++++++++++++++++++++++ */
00086 #define UNIXENV 1                           /* switch UNIX or VMS          */
00087 #define ENDIAN  0                           /* little endian               */
00088 #define _ALL_SOURCE                     /* for types.h typedef u_char...  */
00089 #define _POSIX_SOURCE                   /*   any include is done          */
00090 #endif
00091 
00092 #ifdef GSI__WINNT  /* +++++++++++++++++ Windows NT ++++++++++++++++++++++++ */
00093 #define UNIXENV 1                           /* switch UNIX or VMS          */
00094 #define ENDIAN  0                           /* little endian               */
00095 #define _ALL_SOURCE                     /* for types.h typedef u_char...  */
00096 #define _POSIX_SOURCE                   /*   any include is done          */
00097 #endif
00098 
00099 
00100 #ifdef _AIX      /* +++++++++++++++++ AIX ++++++++++++++++++++++++++ */
00101 #define UNIXENV 1                           /* switch UNIX or VMS          */
00102 #define ENDIAN  1                           /* big    endian               */
00103 #define _ALL_SOURCE                     /* for types.h typedef u_char...  */
00104 #define _POSIX_SOURCE                   /*   any include is done          */
00105 #define IN_AIX 1
00106 #else
00107 #define IN_AIX 0
00108 #endif /* !_AIX */
00109 
00110 /* ++++++++++++++++ include UNIX standard headers +++++++++++++++++++++++++ */
00111 #if UNIXENV == 1
00112 #include <sys/types.h>
00113 #ifdef GSI__WINNT
00114 #include <sys/timeb.h>
00115 #else
00116 #include <netdb.h>
00117 #include <sys/time.h>                   /* ?  <time.h> */
00118 #endif
00119 #include <errno.h>
00120 #include <stdio.h>
00121 #include <string.h>
00122 #endif                                  /* UNIXENV */
00123 
00124 /* ++++++++++++++++++++++ goopaw include files ++++++++++++++++++++++++++ */
00125 #include "gps_sc_def.h"                 /* must be first */
00126 #include "f_stccomm.h"                  /* port server stuff  */
00127 #include "clnt_buf_def.h"
00128 #include "s_filter.h"
00129 #include "s_clntbuf.h"
00130 
00131 #if ENDIAN == 1                         /* big ENDIAN ?                 */
00132 #include "s_flt_descr_swap.h"
00133 #include "s_opc1_swap.h"
00134 #include "s_pat_swap.h"
00135 #include "s_clnt_filter_swap.h"
00136 #include "s_bufhe.h"
00137 #include "s_ve10_1.h"
00138 #include "s_evhe.h"
00139 #include "s_ves10_1.h"
00140 #else                                   /* ENDIAN == 0                    */
00141 #include "s_flt_descr.h"
00142 #include "s_opc1.h"
00143 #include "s_pat.h"
00144 #include "s_clnt_filter.h"
00145 #include "s_bufhe_swap.h"
00146 #include "s_ve10_1_swap.h"
00147 #include "s_evhe_swap.h"
00148 #include "s_ves10_1_swap.h"
00149 #endif                                  /* ENDIAN                         */
00150 
00151 #include "f_evt.h"
00152 #include "f_swaplw.h"
00153 void f_clnup(long [], int *);
00154 void f_clnup_save(long [], int *);
00155 int f_fltdscr(struct s_clnt_filter *);
00156 int f_read_server(s_evt_channel *, int *, int, int);
00157 int f_send_ackn(int, int);
00158 
00159 unsigned short *pi_inbuf;
00160 unsigned int *pl_inbuf;
00161 unsigned int l_len_w;
00162 int swapw(unsigned short *, unsigned short *, unsigned int);
00163 int swapl(unsigned int *, unsigned int *, unsigned int);
00164 static int i_debug = 0;                  /* message level (0-3) */
00165 
00166 #define EVT_MAX 1000
00167 #define TCP__TIMEOUT 3000                /* TCP timeout reading buffer   */
00168 #define FLUSH__TIME 3                    /* flush time interval for MBS event server */
00169 #define STDOUT_BUFIO_ 1
00170 
00171   struct s_clnt_filter  *p_clnt_filter;
00172   struct s_clntbuf      *p_clntbuf;
00173   struct s_opc1         *p_opc1;
00174 
00175   static int unsigned  lf_swap = 0;                  /* save swap on RX     */
00176   static int unsigned  l_endian_serv;                /* save endian server  */
00177   static int           l_len_lw1 = CLNT__BUFH_LW;    /* len for first swap  */
00178   int                  l_len_lw2;                    /* len for 2nd   swap  */
00179   int                   i_channel;                    /* TCP/IP channel      */
00180   int unsigned         l_clnt_sts;                   /* status for ackn.    */
00181   int         l_status, l_sts;
00182   static char           c_modnam[] = "f_evcli";
00183   short         if_typevt, i_sign = 1, i_len;
00184   int                  l_timeout;
00185   int         l_retval;
00186   static struct s_tcpcomm s_tcpcomm_ec = {0,0,0};
00187 static struct
00188 {
00189    int                l_ack_buf;          /* read client buff received  */
00190    int                l_ack_bytes;        /* read client bytes received */
00191    int unsigned       l_clnt_sts;         /* client sts 1:o.k. 8:lst buf*/
00192 }  s_ackn;
00193 
00194   /* ++ vectors of pointer and devices for cleanup */
00195   long          v_mem_clnup[8];
00196 /***************************************************************************/
00197 int f_evcli_con(s_evt_channel *ps_chan, char *pc_node, int l_aport, int l_aevents, int l_asample)
00198 /***************************************************************************/
00199 {
00200    #ifdef GSI__WINNT  /* +++++++++++++++++ Windows NT ++++++++++++++++++++++++ */
00201    #include "gps_sc_def.h"                 /* must be first */
00202    #include "f_stccomm.h"                  /* port server stuff  */
00203    #include "clnt_buf_def.h"
00204    #include "s_filter.h"
00205    #include "s_clntbuf.h"
00206 
00207    #endif
00208 
00209   short                 i, i_h, i_m, i_s;
00210   char                  arg[80], c_hms[16], c_help[4];
00211   int                  l_evtecho,*pl;
00212   char                  c_node[32], c_name[32], c_retmsg[256];
00213   int                  l_port;
00214 
00215   v_mem_clnup[0] = 0;
00216 
00217   /* +++ allocate filter structure +++ */
00218   p_clnt_filter = (struct s_clnt_filter *) malloc( sizeof(struct s_clnt_filter) );
00219   if (p_clnt_filter == NULL)
00220   {
00221      printf("E-%s: calloc(,...s_clnt_filter) failed!\n", c_modnam);
00222      printf("F-%s: aborting program execution!\n",c_modnam);
00223      f_clnup(v_mem_clnup, NULL);
00224      return(-1);
00225   }
00226   ps_chan->pc_evt_buf=(char *) p_clnt_filter;
00227   /* save value for clnup */
00228   f_clnup_save(v_mem_clnup, (int *) p_clnt_filter);
00229   memset( (void *) p_clnt_filter, 0, sizeof(struct s_clnt_filter) );
00230 
00231   p_clnt_filter->l_testbit = GPS__ENV_TESTBIT;   /* set testbit              */
00232   p_clnt_filter->l_endian  = GPS__ENV_ENDIAN;    /* set endian               */
00233   p_clnt_filter->l_numb_of_evt = l_aevents;
00234    p_opc1 = (struct s_opc1 *) &p_clnt_filter->filter[0].l_opcode;
00235    p_opc1->b1_evtsev = 1;
00236    p_opc1->b1_selflt = 1;
00237    p_opc1->b1_selwrt = 1;
00238    p_opc1->b3_opc    = 0;
00239    p_opc1->b1_lnkf1  = 0;
00240    p_opc1->b1_lnkf2  = 0;
00241    p_opc1->h_fltspec = 0;
00242    p_opc1->h_next_fltblk = 1;
00243    p_opc1->h_flt_len     = 1;
00244 
00245   l_status = f_fltdscr(p_clnt_filter);
00246   /*
00247   printf("evtsev: %d selflt: %d selwrt: %d opc: %d lnk1: %d lnk2: %d fltspec: %d next: %d len: %d\n"
00248 ,p_opc1->b1_evtsev
00249 ,p_opc1->b1_selflt
00250 ,p_opc1->b1_selwrt
00251 ,p_opc1->b3_opc
00252 ,p_opc1->b1_lnkf1
00253 ,p_opc1->b1_lnkf2
00254 ,p_opc1->h_fltspec
00255 ,p_opc1->h_next_fltblk
00256 ,p_opc1->h_flt_len);
00257   */
00258   if ((l_status & 1) == 0)
00259   {
00260      printf("E-%s: Severe Error in f_fltdscr! Status:%d\n",
00261             c_modnam,
00262             l_status);
00263      f_clnup(v_mem_clnup, NULL);
00264      return(-1);
00265   }
00266   p_clnt_filter->l_sample_rate = l_asample;
00267   p_clnt_filter->l_flush_rate = FLUSH__TIME;
00268 
00269   l_timeout = TCP__TIMEOUT ;
00270   strcpy(c_node,pc_node);
00271   l_port = l_aport;
00272 
00273   l_status = (int) f_stc_connectserver(c_node,
00274                                         l_port,
00275                                         &i_channel,
00276                                         &s_tcpcomm_ec);
00277   if ((l_status & 1) != STC__SUCCESS)
00278   {
00279      printf("E-%s: Error connecting node:%s, port:%d. Msg:\n",
00280             c_modnam,
00281             c_node,
00282             l_port);
00283      f_stc_disperror((int) l_status,c_retmsg, 0);
00284      f_stc_close(&s_tcpcomm_ec);
00285      return(l_status);
00286   }
00287   ps_chan->l_channel_no=i_channel;
00288      /* + buffer flushing time + */
00289      i_h = p_clnt_filter->l_flush_rate / 3600;      /* hours                 */
00290      i_s = p_clnt_filter->l_flush_rate - i_h * 3600;
00291      i_m = i_s / 60;                     /* minutes               */
00292      i_s = i_s - i_m * 60;             /* seconds               */
00293 
00294   /* +++++++++++++++++++++++++++++++++ */
00295   /* +++ send these data to server +++ */
00296   /* +++++++++++++++++++++++++++++++++ */
00297   /* len to transm [bytes] = 3 LW + filter + 1LW  */
00298   l_status = (int) f_stc_write( (char *) p_clnt_filter,
00299                           GPS__CLNT_SNDFLT,
00300                           i_channel);
00301   if (l_status != STC__SUCCESS)
00302   {
00303      printf("E-%s: Error in f_write_tcp(p_flt,...)! Status:%d. Msg:\n",
00304             c_modnam,
00305             l_status);
00306      f_stc_disperror((int) l_status,c_retmsg, 0);
00307      f_stc_close(&s_tcpcomm_ec);
00308      return(l_status);
00309   }
00310   /* + + + + + + + + + + + + + + */
00311   /* +++ alloc input buffer  +++ */
00312   /* + + + + + + + + + + + + + + */
00313   p_clntbuf = (struct s_clntbuf *) malloc(sizeof(struct s_clntbuf));
00314   if (p_clntbuf == NULL)
00315   {
00316      printf("E-%s: malloc(p_clntbuf) failed!\n", c_modnam);
00317      printf("F-%s: aborting program execution!\n",c_modnam);
00318      f_stc_close(&s_tcpcomm_ec);
00319      return(-1);
00320   }
00321   /* save value for clnup */
00322   f_clnup_save(v_mem_clnup, (int *) p_clntbuf);
00323 
00324   ps_chan->pc_io_buf = (char *) p_clntbuf;
00325   ps_chan->l_io_buf_size = GPS__OUTBUFSIZ + CLNT__OUTBUFHEAD;
00326   /* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
00327   /* ++++ first read on server, get machine type & swap  ++++ */
00328   /* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
00329   memset(p_clntbuf,0, sizeof(struct s_clntbuf));      /* clear memory  */
00330   l_status = f_read_server(ps_chan,
00331                            &l_retval,
00332                            l_timeout,
00333                            i_channel);
00334   if (l_status != TRUE)
00335   {
00336      printf("E-%s: Error reading 1st buffer: f_read_server()!\n", c_modnam);
00337      f_stc_close(&s_tcpcomm_ec);
00338      return(l_status);
00339   }
00340 
00341   /* ++++++++++++++++++++++++++++++++++++ */
00342   /* +++ check if a LW swap is needed +++ */
00343   /* ++++++++++++++++++++++++++++++++++++ */
00344   lf_swap       = (p_clntbuf->l_testbit == GPS__ENV_TESTBIT) ? 0 : 1;
00345   l_endian_serv = p_clntbuf->l_endian;
00346 
00347   if (lf_swap)
00348   /* + + + + + + + + + + + + + + + + + */
00349   /* +++ swap after every receive  +++ */
00350   /* + + + + + + + + + + + + + + + + + */
00351   {
00352      l_sts     = F__SWAP(&p_clntbuf->l_testbit,CLNT__BUFH_LW,0);
00353 
00354      l_len_lw2 = CLNT__REST_LW + p_clntbuf->l_dlen/4; /* <N> !!! */
00355      l_sts     = F__SWAP(&p_clntbuf->l_inbuf_read_cnt, l_len_lw2, 0);
00356 
00357      if (p_clntbuf->l_testbit != GPS__ENV_TESTBIT)  /* <T> */
00358      {
00359         printf("F-%s: Error swapping first buffer from client\n",
00360                 c_modnam);
00361      f_stc_close(&s_tcpcomm_ec);
00362         return(-1);
00363      }
00364   }
00365 
00366   /* + + + + + + + + + + + + + + + + + + + + + + + + + */
00367   /* +++ first buffer should be a message buffer!  +++ */
00368   /* + + + + + + + + + + + + + + + + + + + + + + + + + */
00369   if (p_clntbuf->l_buffertype & 16)
00370   {
00371   }
00372 
00373   if (p_clntbuf->l_buffertype & 2)
00374   {                                          /* buffer contains message   */
00375 /*
00376      switch (p_clntbuf->l_msgtyp & 15)
00377      {
00378         case 1:
00379         case 2:  printf("MSG-type:W:  %s\n", p_clntbuf->c_message);  break;
00380         case 4:  printf("MSG-type:E:  %s\n", p_clntbuf->c_message);  break;
00381         case 8:  printf("MSG-type:F:  %s\n", p_clntbuf->c_message);  break;
00382         default: printf("Unknown MSG-type:%d:\n%s\n",p_clntbuf->l_msgtyp,p_clntbuf->c_message);
00383      }
00384 */
00385   }
00386 return(STC__SUCCESS);
00387 } /* f_evcli_con */
00388 
00389 /***************************************************************************/
00390 int f_evcli_buf(s_evt_channel *ps_chan)
00391 /***************************************************************************/
00392 {
00393   s_ve10_1 *ps_ve10_1;
00394   int ii;
00395   char *ps_buf;
00396   /* ++++++++++++++++++++++++++++++ */
00397   /* +++ send acknowledge buffer +++ */
00398   /* ++++++++++++++++++++++++++++++ */
00399   l_status = f_send_ackn(1, ps_chan->l_channel_no);
00400   if (l_status != TRUE)
00401   {
00402      printf("E-%s: Error sending acknowledge: f_send_ackn()!\n", c_modnam);
00403      f_stc_close(&s_tcpcomm_ec);
00404      return(l_status);
00405   }
00406     /* +++++++++++++++++++++++++ */
00407     /* +++ read input buffer +++ */
00408     /* +++++++++++++++++++++++++ */
00409     p_clntbuf =  (struct s_clntbuf *) ps_chan->pc_io_buf;
00410     ps_buf=ps_chan->pc_io_buf; /* save for comparison */
00411     memset(p_clntbuf,0, ps_chan->l_io_buf_size);
00412     l_status = f_read_server(ps_chan,
00413                              &l_retval,
00414                              l_timeout,
00415                              ps_chan->l_channel_no);
00416     /* in case pc_io_buf has been reallocated */
00417     if(ps_buf != ps_chan->pc_io_buf)
00418     {
00419       f_clnup(v_mem_clnup, NULL); /* free all old buffers */
00420       p_clntbuf =  (struct s_clntbuf *) ps_chan->pc_io_buf;
00421       f_clnup_save(v_mem_clnup, (int *) p_clntbuf);
00422     }
00423     if (l_status != TRUE)
00424     {
00425        printf("E-%s: Error reading buffer: f_read_server()!\n", c_modnam);
00426        f_stc_close(&s_tcpcomm_ec);
00427        return(l_status);
00428     }
00429     l_clnt_sts = 0;                                                /* reset */
00430 
00431     /* +++++++++++++++++++++++++++++++++ */
00432     /* +++ swap every buffer in loop +++ */
00433     /* +++++++++++++++++++++++++++++++++ */
00434     if (lf_swap)
00435     {
00436        l_sts     = F__SWAP(&p_clntbuf->l_testbit,CLNT__BUFH_LW, 0);
00437        l_len_lw2 = CLNT__REST_LW + p_clntbuf->l_dlen/4; /* <N> !!! */
00438 
00439    /*  4 byte swap */
00440        pl_inbuf = &p_clntbuf->l_inbuf_read_cnt;
00441        l_sts = F__SWAP(pl_inbuf, l_len_lw2, 0);
00442     }
00443     /* printf("Buffer %8d bytes, dlen %8d events %6d\n",l_retval,p_clntbuf->l_dlen,p_clntbuf->l_events);
00444            ps_ve10_1=(s_ve10_1 *)&p_clntbuf->c_buffer[0];
00445             for(ii=0;ii<p_clntbuf->l_events;ii++)
00446       {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);
00447       ps_ve10_1 = (s_ve10_1 *) ((short *)ps_ve10_1 + ps_ve10_1->l_dlen + 4); }
00448     */
00449     /* ++++++++++++++++++++++++ */
00450     /* +++ message handling +++ */
00451     /* ++++++++++++++++++++++++ */
00452     l_sts=STC__SUCCESS;
00453     if (p_clntbuf->l_buffertype & 2)
00454     {                                         /* buffer contains message   */
00455        switch (p_clntbuf->l_msgtyp & 15)
00456        {
00457         case 1:
00458         case 2:  if((strstr(p_clntbuf->c_message,"no event data") == NULL)&
00459                     (strstr(p_clntbuf->c_message,"flushed") == NULL))
00460                  printf("MSG-type:W:  %s\n", p_clntbuf->c_message);  break;
00461         case 4:  printf("MSG-type:E:  %s\n", p_clntbuf->c_message);  break;
00462         case 8:  printf("MSG-type:F:  %s\n", p_clntbuf->c_message);  break;
00463         default: printf("Unknown MSG-type:%d:\n%s\n",p_clntbuf->l_msgtyp,p_clntbuf->c_message);
00464        }
00465        l_sts=STC__TIMEOUT; /* buffer without events */
00466     }
00467     else
00468       {
00469    if(p_clntbuf->l_events == 0)
00470      {
00471        l_sts=STC__TIMEOUT;
00472      }
00473       }
00474     ps_chan->pc_evt_buf = (char *)&p_clntbuf->c_buffer[0];
00475     ps_chan->l_evt_buf_posi = 1; /* number of events */
00476     ps_ve10_1 = (s_ve10_1 *) ps_chan->pc_evt_buf;
00477 return(l_sts);
00478 }  /*  end f_evcli_buf  */
00479 
00480 /***************************************************************************/
00481 int f_evcli_evt(s_evt_channel *ps_chan)
00482 /***************************************************************************/
00483 {
00484   int *ps_int;
00485   s_ve10_1 *ps_ve10_1;
00486 
00487   p_clntbuf =  (struct s_clntbuf *) ps_chan->pc_io_buf;
00488   if(ps_chan->l_evt_buf_posi < p_clntbuf->l_events)
00489   {
00490     ps_chan->l_evt_buf_posi++;
00491     ps_ve10_1 = (s_ve10_1 *) ps_chan->pc_evt_buf;
00492     ps_int   = (int *) ps_chan->pc_evt_buf;
00493     ps_int += ps_ve10_1->l_dlen/2 + 2;
00494     ps_chan->pc_evt_buf = (char *) ps_int;
00495     return(STC__SUCCESS);
00496   }
00497   else  return(-1);
00498 }
00499 /***************************************************************************/
00500 int f_evcli_close(s_evt_channel *ps_chan)
00501 /***************************************************************************/
00502 {
00503   /* ++++++++++++++++++++++++++++++ */
00504   /* +++ send acknowledge buffer +++ */
00505   /* ++++++++++++++++++++++++++++++ */
00506   l_status = f_send_ackn(8, ps_chan->l_channel_no);
00507   if (l_status != TRUE)
00508   {
00509      printf("E-%s: Error sending acknowledge: f_send_ackn()!\n", c_modnam);
00510      return(l_status);
00511   }
00512      f_clnup(v_mem_clnup, NULL);
00513      f_stc_discclient(ps_chan->l_channel_no);
00514      f_stc_close(&s_tcpcomm_ec);
00515 return(STC__SUCCESS);
00516 }
00517 
00518 
00519 /*2+F_FLTDSCR***+******************************************************/
00520 /*                                                                    */
00521 /*+ Module      : F_FLTDSCR                                           */
00522 /*                                                                    */
00523 /*                                                                    */
00524 /*--------------------------------------------------------------------*/
00525 /*+ CALLING     : sts = f_fltdscr(p_clnt_filter)                      */
00526 /*                                                                    */
00527 /*                                                                    */
00528 /*--------------------------------------------------------------------*/
00529 /*                                                                    */
00530 /*+ PURPOSE     : Read and check the event filter and construct the   */
00531 /*                filter descriptor.                                  */
00532 /*                                                                    */
00533 /*+ ARGUMENTS   : p_clnt_filter: Pointer to structure s_clnt_filter   */
00534 /*                                                                    */
00535 /*+ FUNCTION    : Read and check the event filter and construct the   */
00536 /*                filter descriptor.  Output via "printf".            */
00537 /*                See also I$PS_FLTDSC_PRTCL                          */
00538 /*                                                                    */
00539 /*+ Return type : int (32 bit)                                       */
00540 /*+ Status codes: bit 0: success                                      */
00541 /*                bit 1: warning                                      */
00542 /*+ Initialize  : -                                                   */
00543 /*+ Include name: -                                                   */
00544 /*                                                                    */
00545 /*3+Implementation************+****************************************/
00546 /*                                                                    */
00547 /*+ File name   : PC_PROC.C                                           */
00548 /*+ Version     : 1.01                                                */
00549 /*+ Author      : R.S. Mayer                                          */
00550 /*+ Last Update : 14-JUN-1993                                         */
00551 /*+ Object libr.: GOOSHRLIB                                           */
00552 /*3+Updates*******+***********+****************************************/
00553 /*                                                                    */
00554 /*+ Updates     : Date        Purpose                                 */
00555 /*                                                                    */
00556 /*3+Description***+***********+****************************************/
00557 /*1- C Procedure ***********+******************************************/
00558 int f_fltdscr(p_clnt_filter)           /* read filter, check and         */
00559                                            /* constr. flt_descriptor         */
00560 struct s_clnt_filter *p_clnt_filter;
00561 {
00562    static char               c_modnam[] = "f_fltdscr";
00563    struct s_filter    *p_filter;
00564    struct s_opc1      *p_opc1;
00565    struct s_flt_descr *p_flt_descr;
00566    struct s_pat1      *p_pat1;
00567    struct s_pat2      *p_pat2;
00568    struct s_pat3      *p_pat3;
00569 
00570    short              i_fltdescnt = 0;
00571    short              i_fltcnt = 0;
00572    short              i_fltblkcnt = 0;
00573    short              i, i_flt_len,
00574                       i_fltblkbeg, i_fltblkend, j;
00575    short              if_newfltblk = 1;
00576    short              i_next_fltblk;
00577    short              i_descr;        /* test */
00578    int               l_evtdescr, *pl_evtdescr, *pl_sev1descr, *pl_sev2descr;
00579    short              i_lasevtflt, i_1stsevflt;
00580 
00581    int unsigned      l_status, l_sts;
00582    int unsigned      l_retsts = 0;
00583 
00584    /* +++ action +++ */
00585    if (i_debug == 2)
00586       printf("--->D-%s: addr_filter p:%d\n", c_modnam, p_clnt_filter);
00587 
00588    /* init pointer */
00589    p_flt_descr = (struct s_flt_descr *) &p_clnt_filter->flt_descr[0];
00590 
00591    /* +++ loop over all filter block descriptors +++ */
00592    for (i = 0; i < GPS__MAXFLT; i++)
00593    {
00594       p_filter    = (struct s_filter *)    &p_clnt_filter->filter[i];
00595       p_opc1      = (struct s_opc1 *)      &p_filter->l_opcode;
00596 
00597       if (i_debug == 2)
00598          printf("D-%s: i:%d opc:%x flt_len:%d\n",
00599                 c_modnam,
00600                 i,
00601                 p_filter->l_opcode,
00602                 p_opc1->h_flt_len);
00603 
00604       if (i == i_next_fltblk)
00605          if_newfltblk = 1;
00606 
00607       if (p_opc1->h_flt_len == 0)
00608       {
00609     i_fltcnt = i;
00610     p_opc1->h_next_fltblk    = 0;    /* no next descriptor              */
00611     p_flt_descr->h_nextdescr = 0;    /* no next descriptor              */
00612          break;              /* no more filter                  */
00613       } /* if (p_opc1->h_next_fltblk == 0) */
00614 
00615 /*      if (p_opc1->b3_opc == 0) {
00616  *        printf("I-%s: b3_opc == 0. Take all events!\n",
00617  *           c_modnam);
00618  *        }
00619  */
00620 
00621       if (if_newfltblk)
00622       {
00623     if_newfltblk = 0;
00624     i_fltblkcnt++;
00625     i_flt_len     = p_opc1->h_flt_len;
00626     i_next_fltblk = i + i_flt_len;
00627          i_fltblkbeg   = i;
00628     i_fltblkend   = i_next_fltblk - 1;
00629 
00630     if (p_opc1->b1_selwrt == 1)
00631          {                            /* write block               */
00632 
00633             p_flt_descr = (struct s_flt_descr *) &p_clnt_filter->flt_descr[0];
00634        i_descr = 0;         /* test */
00635 
00636        if (p_flt_descr->hf_wrtdescr == 1 &&
00637                 p_clnt_filter->flt_descr[0].i_descriptors <= 0)
00638             {
00639           printf("W-%s: >1 write blocks, previous one(s) ignored!\n",
00640                         c_modnam);
00641           l_retsts = l_retsts | 2;
00642        }
00643 
00644        p_flt_descr->hf_wrtdescr = 1;
00645        p_flt_descr->hf_fltdescr = 0;
00646        p_flt_descr->h_fltblkbeg = i_fltblkbeg;
00647        p_flt_descr->h_fltblkend = i_fltblkend;
00648        p_flt_descr->h_nextdescr = 1;
00649 
00650        /* save write block values */
00651        p_clnt_filter->if_wrtevt = (p_opc1->b1_evtsev == 1) ? 1 : 0;
00652        p_clnt_filter->if_wrtsev = (p_opc1->b1_evtsev != 1) ? 1 : 0;
00653          } /* if (p_opc1->b1_selwrt == 1) */
00654 
00655     if (p_opc1->b1_selflt == 1)
00656          {                            /* filter block              */
00657        if (i_fltdescnt == 0)
00658           i_fltdescnt++;
00659        i_descr = i_fltdescnt;              /* test */
00660             p_flt_descr = (struct s_flt_descr *)
00661                           &p_clnt_filter->flt_descr[i_fltdescnt];
00662        p_flt_descr->hf_wrtdescr = 0;
00663        p_flt_descr->hf_fltdescr = 1;
00664        p_flt_descr->h_fltblkbeg = i_fltblkbeg;
00665        p_flt_descr->h_fltblkend = i_fltblkend;
00666        p_flt_descr->h_nextdescr = ++i_fltdescnt;
00667        /* save write block values */
00668        if (p_opc1->b1_evtsev == 1)
00669           p_clnt_filter->if_fltevt = 1;
00670             else
00671           p_clnt_filter->if_fltsev = 1;
00672          }    /* if (p_opc1->b1_selflt == 1) */
00673 
00674       } /* if (if_newfltblk) */
00675 
00676       /* identical values for the whole flt blk */
00677       p_opc1->h_flt_len     = i_flt_len;
00678       p_opc1->h_next_fltblk = i_next_fltblk;
00679 
00680       /* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
00681       /* ++++ build pattern and offset values from h_fltspec ++++ */
00682       /* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
00683 
00684       /* ++++ check if Filter specification is valid ++++ */
00685       if ((p_opc1->h_fltspec > 15) && (p_opc1->b1_evtsev == 1))
00686       {
00687          printf("E-%s: Filter specification %d invalid for events\n",
00688                      c_modnam,
00689                      p_opc1->h_fltspec);
00690          return(FALSE);                /* abort with error                */
00691       }
00692       if ((p_opc1->h_fltspec < 2) && (p_opc1->b1_evtsev != 1))
00693       {
00694          printf("E-%s: Filter specification %d invalid for subevents\n",
00695                      c_modnam,
00696                      p_opc1->h_fltspec);
00697          return(FALSE);                /* abort with error                */
00698       }
00699 
00700 
00701 
00702       switch (p_opc1->h_fltspec)
00703       {
00704             case 0:                       /* ++++ take all ++++ */
00705                  if (p_opc1->b3_opc != 0) {
00706                     printf("W-%s: Take all. Set opcode to 0, next time\n",
00707                         c_modnam);
00708                     p_opc1->b3_opc = 0;
00709           l_retsts = l_retsts | 2;
00710                     }
00711                  break;
00712 
00713        case 1:                       /* ++++ trigger  ++++ */
00714 /*       if (p_filter->l_offset >= 0)
00715  */
00716                  p_filter->l_offset = -5; /* trigger = event + 5 W        */
00717        p_filter->l_pattern = p_filter->l_pattern & 0xFFFF;
00718        break;
00719 
00720             case 2:                       /* ++++ pattern and offset ++++ */
00721        break;
00722 
00723             case 4:                /* W ++++ type ++++ */
00724 /*       if (p_filter->l_offset >= 0)
00725  */
00726                  p_filter->l_offset = -2; /* type = evt(sev) + 2 W        */
00727        p_filter->l_pattern = p_filter->l_pattern & 0xFFFF;
00728 
00729                  break;
00730 
00731             case 8:                       /* W ++++ subtype ++++ */
00732 /*       if (p_filter->l_offset >= 0)
00733  */
00734                  p_filter->l_offset = -3; /* subtype = evt(sev) + 3 W     */
00735        p_filter->l_pattern = p_filter->l_pattern & 0xFFFF;
00736 
00737                  break;
00738 
00739             case 12:                     /* LW ++++ type and subtype ++++ */
00740 /*       if (p_filter->l_offset >= 0)
00741  */
00742                  p_filter->l_offset = 1; /* type-subtype = evt(sev) + 1 LW*/
00743 
00744                  break;
00745 
00746             case 16:                     /* W ++++ procid ++++ */
00747 /*       if (p_filter->l_offset >= 0)
00748  */
00749                  p_filter->l_offset = -4; /* procid = sev + 4 W        */
00750        p_filter->l_pattern = p_filter->l_pattern & 0xFFFF;
00751 
00752                  break;
00753 
00754             case 32:               /* W ++++ subcrate,contr ++++*/
00755 /*       if (p_filter->l_offset >= 0)
00756  */
00757                  p_filter->l_offset = -5; /* subcrate,contr = sev + 5 W */
00758        p_filter->l_pattern = p_filter->l_pattern & 0xFFFF;
00759 
00760                  break;
00761 
00762             case 48:               /* LW ++++procid,subcr,contr ++++*/
00763 /*       if (p_filter->l_offset >= 0)
00764  */
00765                  p_filter->l_offset = 2; /* procid,subc,ctrl = sev + 2 LW */
00766 
00767                  break;
00768 
00769        default:
00770             printf("W-%s: FLTSPEC %d NOT FOUND\n",
00771                     c_modnam,
00772           p_opc1->h_fltspec);
00773        l_retsts = l_retsts | 2;
00774       }                            /* switch case  */
00775 
00776 
00777 
00778    }    /* for */
00779 
00780    p_flt_descr = (struct s_flt_descr *) &p_clnt_filter->flt_descr[0];
00781    if (p_flt_descr->hf_wrtdescr != 1) {
00782       printf("E-%s: The write filter is missing! Filter is invalid!\n",
00783              c_modnam);
00784       return(FALSE);
00785       }
00786 
00787    if (!(p_clnt_filter->if_fltevt || p_clnt_filter->if_fltsev)) {
00788       printf("E-%s: The filter itself is missing! Filter is invalid!\n",
00789              c_modnam);
00790       return(FALSE);
00791       }
00792 
00793 /*   printf(
00794  *     "I-%s: p_clnt:%d: found %d flts in %d blks with %d descript.\n",
00795  *         c_modnam,
00796  *         p_clnt_filter,
00797  *         i_fltcnt,
00798  *         i_fltblkcnt,
00799  *         i_fltdescnt);
00800  */
00801 
00802    if ( (p_clnt_filter->if_fltevt == 1) && (p_clnt_filter->if_fltsev == 1) ) {
00803       m_sort_descr:;                      /* sort event and subevent filter  */
00804       i_lasevtflt = 0;           /* last event filter     init      */
00805       i_1stsevflt = i_fltdescnt;     /* first subevent filter init        */
00806       /* sort filter blocks: flt event should come before flt sev */
00807       for (i = 1; i < i_fltdescnt; i++) {
00808     p_flt_descr = (struct s_flt_descr *) &p_clnt_filter->flt_descr[i];
00809     p_filter    = (struct s_filter *)
00810                        &p_clnt_filter->filter[p_flt_descr->h_fltblkbeg];
00811     p_opc1      = (struct s_opc1 *)      &p_filter->l_opcode;
00812 
00813     if ( (p_opc1->b1_selflt == 1) && (p_opc1->b1_evtsev == 1) )
00814        i_lasevtflt = i;              /* save last evt flt found         */
00815 
00816          if ( (p_opc1->b1_selflt == 1) &&
00817               (p_opc1->b1_evtsev == 0) &&
00818               (i_1stsevflt == i_fltdescnt) )
00819             i_1stsevflt = i;              /* save last evt flt found         */
00820 
00821     if (i_1stsevflt < i_lasevtflt) { /* evt flt after sev flt           */
00822        printf(
00823               "W-%s 1stsevflt:%d lastevtflt:%d. Evt flt should come first\n",
00824                    c_modnam,
00825          i_1stsevflt,
00826          i_lasevtflt);
00827        l_retsts = l_retsts | 2;
00828             /* copy first LW from evt descr */
00829        pl_evtdescr = (int *) &p_clnt_filter->flt_descr[i_lasevtflt];
00830             l_evtdescr  = *pl_evtdescr;
00831        /* shift the subevent descriptors */
00832        for (j = i_lasevtflt; j > i_1stsevflt; j--) {
00833           pl_sev1descr  = (int *) &p_clnt_filter->flt_descr[j-1];
00834           pl_sev2descr  = (int *) &p_clnt_filter->flt_descr[j];
00835           *pl_sev2descr = *pl_sev1descr;
00836                }
00837             pl_evtdescr  = (int *) &p_clnt_filter->flt_descr[i_1stsevflt];
00838        *pl_evtdescr = l_evtdescr;
00839        goto m_sort_descr;            /* until descr is in right order   */
00840             }    /* if */
00841 
00842          }    /* for */
00843 
00844       }    /* if (...if_fltevt... && ...if_fltsev...) */
00845 
00846    /* + + + Max number of descriptors + + + */
00847    p_clnt_filter->flt_descr[0].i_descriptors = i_fltdescnt;
00848 
00849    /* ++++ check the subevent filter blocks                       ++++ */
00850    /*    + the first filter in the sev flt blk identifies the sev +    */
00851    /*    + normaly Procid or Procid + Subcrate                    +    */
00852    if (p_clnt_filter->if_fltsev == 1) {
00853       for (i = 1; i < p_clnt_filter->flt_descr[0].i_descriptors; i++) {
00854      p_flt_descr = (struct s_flt_descr *) &p_clnt_filter->flt_descr[i];
00855     /* ++ addr of the first filter in the flt blk ++ */
00856     p_filter    = (struct s_filter *)
00857                        &p_clnt_filter->filter[p_flt_descr->h_fltblkbeg];
00858     p_opc1      = (struct s_opc1 *)      &p_filter->l_opcode;
00859 
00860          } /* for */
00861       } /* if (p_clnt_filter->if_fltsev... */
00862 
00863    return(l_retsts | 1);
00864 
00865 } /* end f_fltdscr */
00866 
00867 
00868 
00869 
00870 
00871 /*2+F_FLTRD***+********************************************************/
00872 /*                                                                    */
00873 /*+ Module      : F_FLTRD                                             */
00874 /*                                                                    */
00875 /*                                                                    */
00876 /*--------------------------------------------------------------------*/
00877 /*+ CALLING     : sts = f_fltrd(p_clnt_filter, c_file)                */
00878 /*                                                                    */
00879 /*                                                                    */
00880 /*--------------------------------------------------------------------*/
00881 /*                                                                    */
00882 /*+ PURPOSE     : Reads filter specification from a file              */
00883 /*                                                                    */
00884 /*+ ARGUMENTS   :                                                     */
00885 /*+    p_clnt_filter: Pointer to structure s_clnt_filter              */
00886 /*+    c_file       : Pointer to file name string                     */
00887 /*                                                                    */
00888 /*+ FUNCTION    : Opens the file and reads filter specification       */
00889 /*                                                                    */
00890 /*+ Return type : int (32 bit)                                       */
00891 /*+ Status codes: -                                                   */
00892 /*+ Initialize  : -                                                   */
00893 /*+ Include name: -                                                   */
00894 /*                                                                    */
00895 /*3+Implementation************+****************************************/
00896 /*                                                                    */
00897 /*+ File name   : PC_PROC.C                                           */
00898 /*+ Version     : 1.01                                                */
00899 /*+ Author      : R.S. Mayer                                          */
00900 /*+ Last Update : 14-JUN-1993                                         */
00901 /*+ Object libr.: GOOSHRLIB                                           */
00902 /*3+Updates*******+***********+****************************************/
00903 /*                                                                    */
00904 /*+ Updates     : Date          Purpose                               */
00905 /*-               25-Jan-1994 : problems with sscanf removed (RSM)    */
00906 /*                                                                    */
00907 /*3+Description***+***********+****************************************/
00908 /*1- C Procedure ***********+******************************************/
00909 int f_fltrd(p_clnt_filter, c_file)
00910 struct s_clnt_filter *p_clnt_filter;
00911 char                 *c_file;                     /* ptr to file name        */
00912 {
00913 
00914    /* ++++ declaration ++++ */
00915    FILE               *infile;
00916 
00917    static char        c_modnam[] = "f_fltrd";
00918    struct s_filter    *p_filter;
00919    struct s_opc1      *p_opc1;
00920    struct s_flt_descr *p_flt_descr;
00921    struct s_pat1      *p_pat1;
00922    struct s_pat2      *p_pat2;
00923    struct s_pat3      *p_pat3;
00924 
00925    char               c_retmsg[256];
00926    char               c_line[80], c_comment[80], *c_fsts, *p_com, *p_minus;
00927    short              i_fltblklen = 0;
00928    short         i_currflt = 0;
00929    short              i, j;
00930    int               l, l_scan=0;
00931 
00932    int unsigned      l_pattern;
00933    int               l_offset;
00934 
00935    short              i_evtsev,i_selflt,i_selwrt,i_opc,i_lnkf1,
00936                       i_lnkf2,i_fltspec;
00937    short              if_hex, if_comment;
00938 
00939    char               *fgets( char *str, int maxchar, FILE *file_ptr);
00940 
00941    /* +++ action +++ */
00942 
00943    if ( (infile = fopen(c_file,"r"))  == 0)
00944    {                                          /* open file for data input   */
00945       sprintf(c_retmsg,"E-%s: fopen(File=%s) ",
00946               c_modnam,
00947               c_file);
00948       perror(c_retmsg);
00949       fclose(infile);
00950       return(FALSE);
00951    }
00952 
00953    printf("Filter definition from file %s\n", c_file);
00954    printf("=======================================\n");
00955 
00956    while (l_scan != EOF && i_fltblklen < GPS__MAXFLT)
00957    {
00958       m_read_nxtblklen:;
00959 
00960       memset(c_line,0,sizeof(c_line));
00961 
00962       if ( (c_fsts = fgets(c_line, sizeof(c_line), infile)) == 0)
00963       {
00964          if (i_debug == 2)
00965             printf("D-%s: File=%s: Last input line.\n",
00966                    c_modnam,
00967                    c_file);
00968          break;
00969       }
00970 
00971       if_comment = 0;                      /* reset flag                    */
00972       p_com = strpbrk(c_line,"!/*");       /* find position of comment      */
00973       if (p_com != NULL)
00974       {                                    /* found a comment               */
00975          if_comment = 1;                   /* set flag                      */
00976     strcpy(c_comment,p_com);          /* copy comment                  */
00977     *p_com = '\0';                    /* mark end of str at beg of comm*/
00978          if (i_debug == 2)
00979             printf(" - D: comment:%s", c_comment);
00980 
00981       }
00982 
00983       l_scan = sscanf(c_line, "%hd", &i_fltblklen);
00984       if (if_comment && (l_scan < 1) )
00985          goto m_read_nxtblklen;
00986 
00987       if (l_scan == EOF || l_scan == 0 || c_fsts == NULL)
00988       {
00989          if (i_debug == 2)
00990        printf("D-%s: Last input line.\n",c_file);
00991          break;
00992       }
00993 
00994       if (i_fltblklen + i_currflt >= GPS__MAXFLT)
00995       {
00996          printf("E-%s: too long. Last filter block ignored\n",
00997                c_modnam);
00998     fclose(infile);
00999          return(3);
01000       }
01001       if (i_debug == 2)
01002          printf("D-%s: Fltblklen:%d\n", c_modnam, i_fltblklen);
01003 
01004       for (i = i_currflt; i < i_fltblklen + i_currflt; i++)
01005       {
01006     m_read_nxtline:;
01007 
01008          memset(c_line,0,sizeof(c_line));
01009 
01010          if ( (c_fsts = fgets(c_line, sizeof(c_line), infile)) == 0)
01011          {
01012             sprintf(c_retmsg,"E-%s: Error reading:fgets(File=%s) ",
01013               c_modnam,
01014               c_file);
01015             perror(c_retmsg);
01016             fclose(infile);
01017        return(FALSE);
01018          }
01019 
01020          if (i_debug == 2)
01021             printf("D-%s: line:%s", c_modnam, c_line);
01022 
01023     if_comment = 0;                   /* reset flag                    */
01024     p_com = strpbrk(c_line,"!/*");    /* find position of comment      */
01025     if (p_com != NULL)
01026          {                                 /* found a comment               */
01027             if_comment = 1;                /* set flag                      */
01028        strcpy(c_comment,p_com);       /* copy comment                  */
01029        *p_com = '\0';                 /* mark end of str at beg of comm*/
01030             if (i_debug == 2)
01031                printf(" - D: comment:%s", c_comment);
01032 
01033     }
01034 
01035          l_scan = sscanf(c_line,"%hd %hd %hd %hd %hd %hd %hd %ld %ld",
01036                   &i_evtsev,
01037         &i_selflt,
01038         &i_selwrt,
01039         &i_opc,
01040                   &i_lnkf1,
01041         &i_lnkf2,
01042         &i_fltspec,
01043         &l_pattern,
01044         &l_offset);
01045     if_hex = 0;                           /* set flag null             */
01046          if (l_scan == 9)
01047             goto m_ok_assign;
01048 
01049     if_hex = 1;                           /* set flag null             */
01050     p_minus = strchr(c_line,'-');         /* find minus sign in offset */
01051 
01052     if (p_minus != 0)                     /* found minus sign          */
01053             *p_minus = ' ';                    /* replace minus with blank  */
01054 
01055          l_scan = sscanf(c_line,"%hd %hd %hd %hd %hd %hd %hd %lx %lx",
01056                   &i_evtsev,
01057                   &i_selflt,
01058                   &i_selwrt,
01059                   &i_opc,
01060                   &i_lnkf1,
01061                   &i_lnkf2,
01062                   &i_fltspec,
01063                   &l_pattern,
01064                   &l_offset);
01065 
01066     l_offset = (p_minus != NULL) ? -l_offset : l_offset;
01067 
01068          if (l_scan < 9)
01069          {
01070        if (if_comment)
01071                goto m_read_nxtline;
01072 
01073             printf(
01074              "E-%s: scanned only %d(of 9) var., last 2 must be dec or hexa\n",
01075                 c_modnam,
01076                 l_scan);
01077        fclose(infile);
01078        return(FALSE);
01079     }
01080 
01081      m_ok_assign:
01082          if (i_debug == 2)
01083          {
01084             sprintf( c_retmsg,
01085                   "%s es:%d f:%d w:%d opc:%d lf1:%d lf2:%d flt:%d p:%x o:%x",
01086                   (if_hex) ? "HEX:" : "DEC:",
01087                   i_evtsev,
01088                   i_selflt,
01089                   i_selwrt,
01090                   i_opc,
01091                   i_lnkf1,
01092                   i_lnkf2,
01093                   i_fltspec,
01094                   l_pattern,
01095                   l_offset);
01096             printf("D-%s: %s\n", c_modnam, c_retmsg);
01097          }
01098 
01099      p_filter    = (struct s_filter *)    &p_clnt_filter->filter[i];
01100     p_opc1      = (struct s_opc1 *)      &p_filter->l_opcode;
01101 
01102     p_opc1->h_next_fltblk = (char) i_fltblklen + i_currflt;
01103     p_opc1->h_flt_len     = (char) i_fltblklen;
01104 
01105     p_filter->l_pattern   = l_pattern;
01106          p_filter->l_offset    = l_offset;
01107 
01108     p_opc1->b1_evtsev =        i_evtsev;
01109     p_opc1->b1_selflt =        i_selflt;
01110     p_opc1->b1_selwrt =        i_selwrt;
01111     p_opc1->b3_opc    =        i_opc;
01112     p_opc1->b1_lnkf1  =        i_lnkf1;
01113     p_opc1->b1_lnkf2  =        i_lnkf2;
01114     p_opc1->h_fltspec = (char) i_fltspec;
01115 
01116       } /* for */
01117 
01118       i_currflt = (short) p_opc1->h_next_fltblk;
01119 
01120   } /* while */
01121 
01122   fclose(infile);
01123 
01124   return(TRUE);
01125 }
01126 
01127 
01128 
01129 /*2+F_TYPFLT***+*******************************************************/
01130 /*                                                                    */
01131 /*+ Module      : F_TYPFLT                                            */
01132 /*                                                                    */
01133 /*                                                                    */
01134 /*--------------------------------------------------------------------*/
01135 /*+ CALLING     : sts = f_typflt(p_clnt_filter)                       */
01136 /*                                                                    */
01137 /*                                                                    */
01138 /*--------------------------------------------------------------------*/
01139 /*                                                                    */
01140 /*+ PURPOSE     : Type the filter conditions.                         */
01141 /*                                                                    */
01142 /*+ ARGUMENTS   : p_clnt_filter: Pointer to s__clnt_filter            */
01143 /*                                                                    */
01144 /*+ FUNCTION    : Type the filter conditions. Output via "printf".    */
01145 /*                See also I$PS_TYPFLT_PRTCL.                         */
01146 /*                                                                    */
01147 /*+ Return type : int (32 bit) 1: success   0: fault                 */
01148 /*+ Status codes: -                                                   */
01149 /*+ Initialize  : -                                                   */
01150 /*+ Include name: -                                                   */
01151 /*                                                                    */
01152 /*3+Implementation************+****************************************/
01153 /*                                                                    */
01154 /*+ File name   : PC_PROC.C                                           */
01155 /*+ Version     : 1.01                                                */
01156 /*+ Author      : R.S. Mayer                                          */
01157 /*+ Last Update : 14-JUN-1993                                         */
01158 /*+ Object libr.: GOOSHRLIB                                           */
01159 /*3+Updates*******+***********+****************************************/
01160 /*                                                                    */
01161 /*+ Updates     : Date          Purpose                               */
01162 /*-               12-Jan-1994 : Bug removed in subcrate,control (RSM) */
01163 /*                                                                    */
01164 /*3+Description***+***********+****************************************/
01165 /*1- C Procedure ***********+******************************************/
01166 int f_typflt(p_clnt_filter)
01167 struct s_clnt_filter *p_clnt_filter;
01168 {
01169    static char               c_modnam[] = "f_typflt";
01170    struct s_filter    *p_filter;
01171    struct s_opc1      *p_opc1;
01172    struct s_flt_descr *p_flt_descr;
01173    struct s_pat1      *p_pat1;
01174    struct s_pat2      *p_pat2;
01175    struct s_pat3      *p_pat3;
01176 
01177    short              i_fltdescnt, j, i;
01178 
01179    /* +++ action +++ */
01180 
01181    /* + + + Max number of descriptors + + + */
01182    i_fltdescnt = p_clnt_filter->flt_descr[0].i_descriptors;
01183 
01184    /* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */
01185    /* + + + Output filter conditions for Write and Filter     + + + */
01186    /* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */
01187 /*   printf("Explanation: object OPCODE mask\n===========\n");
01188  */
01189    if ( (i_debug == 1) || (i_debug == 2) )
01190       printf(
01191           "Write:%s %s   Filter:%s %s         object OPCODE mask",
01192      (p_clnt_filter->if_wrtevt > 0) ? "EVENT" : "",
01193      (p_clnt_filter->if_wrtsev > 0) ? "SUBEVENT" : "",
01194      (p_clnt_filter->if_fltevt > 0) ? "EVENT" : "",
01195      (p_clnt_filter->if_fltsev > 0) ? "SUBEVENT" : "");
01196    for (i = 0; i < i_fltdescnt; i++) {
01197       p_flt_descr = (struct s_flt_descr *) &p_clnt_filter->flt_descr[i];
01198       p_filter    = (struct s_filter *)
01199                     &p_clnt_filter->filter[p_flt_descr->h_fltblkbeg];
01200       p_opc1      = (struct s_opc1 *)      &p_filter->l_opcode;
01201 
01202     if ( (i_debug == 1) || (i_debug == 2) )
01203     {
01204       if (i > 1)
01205          printf("\n<<%s>>\n", (p_opc1->b1_lnkf2 == 1) ? "A_N_D" : "O_R" );
01206       printf("\n=>>FILTER set %d :",i);
01207       printf(" Select:%s Filter:%s Write:%s    Filter[%d:%d]:\n",
01208             (p_opc1->b1_evtsev == 1) ? "EVENT" : "SUBEVENT",
01209             (p_opc1->b1_selflt == 1) ? "ON" : "OFF",
01210             (p_opc1->b1_selwrt == 1) ? "ON" : "OFF",
01211        p_flt_descr->h_fltblkbeg,
01212        p_flt_descr->h_fltblkend );
01213     }
01214 
01215       /* +++ subevt flt blk id +++ */
01216       if (p_opc1->b1_evtsev == 0 && p_opc1->b1_selflt == 1)
01217       {
01218     p_filter = (struct s_filter *)
01219                     &p_clnt_filter->filter[p_flt_descr->h_fltblkbeg];
01220          if ( (i_debug == 1) || (i_debug == 2) )
01221     printf(
01222          "   Filter set id is fltspec:%d == mask:H%x  (see 1st filt. below)\n",
01223           p_opc1->h_fltspec,
01224           p_filter->l_pattern);
01225        }
01226 
01227 
01228       /* +++ loop over all filters in this filter block +++ */
01229       for (j =  p_flt_descr->h_fltblkbeg;
01230       j <= p_flt_descr->h_fltblkend;
01231            j++) {
01232          p_filter = (struct s_filter *) &p_clnt_filter->filter[j];
01233     p_opc1 = (struct s_opc1 *) &p_filter->l_opcode;
01234     if ( (j > p_flt_descr->h_fltblkbeg) &&
01235               (p_opc1->b1_selflt == 1)       &&
01236               ( (i_debug == 1) || (i_debug == 2) ) )
01237             printf("  <%s>\n", (p_opc1->b1_lnkf1 == 1) ? "A_N_D" : "O_R" );
01238          if ( (i_debug == 1) || (i_debug == 2) )
01239             printf("  =>%2d: opcode: ", i + 1);
01240 
01241     switch (p_opc1->b3_opc) {
01242        case 0:
01243                  if ( (i_debug == 1) || (i_debug == 2) )
01244                     printf("!! (ALL)   ");
01245        break;
01246        case 1:
01247                  if ( (i_debug == 1) || (i_debug == 2) )
01248                     printf("== (IDENT) ");
01249        break;
01250 
01251        case 2:
01252                  if ( (i_debug == 1) || (i_debug == 2) )
01253                     printf("&& (ANY)   ");
01254        break;
01255 
01256        case 3:
01257                  if ( (i_debug == 1) || (i_debug == 2) )
01258                     printf("&= (INCL)  ");
01259        break;
01260 
01261        case 4:
01262                  if ( (i_debug == 1) || (i_debug == 2) )
01263                     printf("^= (EXCL)  ");
01264        break;
01265 
01266        case 5:
01267                  if ( (i_debug == 1) || (i_debug == 2) )
01268                     printf("<  (LT)    ");
01269        break;
01270 
01271        case 6:
01272                  if ( (i_debug == 1) || (i_debug == 2) )
01273                     printf(">= (GE)    ");
01274        break;
01275 
01276        default:
01277             printf("W-OPCODE %d NOT FOUND\n",p_opc1->b3_opc);
01278        }
01279 
01280     switch (p_opc1->h_fltspec) {
01281             case 0:                       /* ++++ take all ++++ */
01282                  if (p_opc1->b3_opc != 0) {
01283                     p_opc1->b3_opc = 0;
01284                     printf("W-%s: Take all. Opcode is %d\n",
01285                         c_modnam,
01286                         p_opc1->b3_opc);
01287           }
01288                  break;
01289 
01290        case 1:                       /* ++++ trigger  ++++ */
01291        p_pat1 = (struct s_pat1 *) &p_filter->l_pattern;
01292                  if ( (i_debug == 1) || (i_debug == 2) )
01293                  {
01294                     printf("trigger:%2d",p_pat1->i_trigger);
01295           printf(" (mask:%d offs:%d %s)\n",
01296             p_filter->l_pattern,
01297            (p_filter->l_offset >= 0) ?
01298                            p_filter->l_offset : -p_filter->l_offset,
01299            (p_filter->l_offset >= 0) ? "LW" : "W");
01300                  }
01301        break;
01302 
01303             case 2:                       /* ++++ pattern and offset ++++ */
01304                  if ( (i_debug == 1) || (i_debug == 2) )
01305           printf("mask:H%x offset:%d %s\n",
01306                  p_filter->l_pattern,
01307            (p_filter->l_offset >= 0) ?
01308                            p_filter->l_offset : -p_filter->l_offset,
01309                 (p_filter->l_offset >= 0) ?
01310                            "LW" : "W" );
01311        break;
01312 
01313             case 4:                /* W ++++ type ++++ */
01314                  if ( (i_debug == 1) || (i_debug == 2) )
01315                  {
01316                     printf("type:%d ",
01317                            p_filter->l_pattern);
01318           printf(" (mask:%d offs:%d %s)\n",
01319             p_filter->l_pattern,
01320              (p_filter->l_offset >= 0) ?
01321                            p_filter->l_offset : -p_filter->l_offset,
01322                 (p_filter->l_offset >= 0) ? "LW" : "W");
01323                  }
01324                  break;
01325 
01326             case 8:                       /* W ++++ subtype ++++ */
01327                  if ( (i_debug == 1) || (i_debug == 2) )
01328                  {
01329                     printf("subtype:%d ",
01330             p_filter->l_pattern);
01331           printf(" (mask:%d offs:%d %s)\n",
01332             p_filter->l_pattern,
01333            (p_filter->l_offset >= 0) ?
01334                            p_filter->l_offset : -p_filter->l_offset,
01335            (p_filter->l_offset >= 0) ? "LW" : "W");
01336                  }
01337                  break;
01338 
01339             case 12:                     /* W ++++ type and subtype ++++ */
01340        p_pat3 = (struct s_pat3 *) &p_filter->l_pattern;
01341                  if ( (i_debug == 1) || (i_debug == 2) )
01342                  {
01343                     printf("type:%d subtype:%d",
01344                            p_pat3->i_type,
01345             p_pat3->i_subtype);
01346           printf(" (mask:H%x offs:%d %s)\n",
01347             p_filter->l_pattern,
01348            (p_filter->l_offset >= 0) ?
01349                            p_filter->l_offset : -p_filter->l_offset,
01350             (p_filter->l_offset >= 0) ? "LW" : "W");
01351                  }
01352                  break;
01353 
01354             case 16:               /* ++++ procid ++++*/
01355                  p_pat2 = (struct s_pat2 *) &p_filter->l_pattern;
01356                  if ( (i_debug == 1) || (i_debug == 2) )
01357                  {
01358                     printf("procid:%d ",
01359                            p_pat2->i_procid);
01360           printf(" (mask:%d offs:%d %s)\n",
01361             p_filter->l_pattern,
01362            (p_filter->l_offset >= 0) ?
01363                            p_filter->l_offset : -p_filter->l_offset,
01364            (p_filter->l_offset >= 0) ? "LW" : "W");
01365                  }
01366                  break;
01367 
01368             case 32:               /* W ++++ subcrate,contr ++++*/
01369                  if ( (i_debug == 1) || (i_debug == 2) )
01370                  {
01371                     printf("subcrate:%d control:%d",
01372                            p_filter->l_pattern & 0x00FF,
01373                            ((unsigned) (p_filter->l_pattern & 0xFF00)) >> 8);
01374           printf(" (mask:H%x offs:%d %s)\n",
01375             p_filter->l_pattern,
01376            (p_filter->l_offset >= 0) ?
01377                            p_filter->l_offset : -p_filter->l_offset,
01378            (p_filter->l_offset >= 0) ? "LW" : "W");
01379                  }
01380                  break;
01381 
01382             case 48:               /* LW ++++procid,subcr,contr ++++*/
01383                  p_pat2 = (struct s_pat2 *) &p_filter->l_pattern;
01384                  if ( (i_debug == 1) || (i_debug == 2) )
01385                  {
01386                     printf("procid:%2d subcr:%d contr:%d",
01387                            p_pat2->i_procid,
01388             p_pat2->h_subcrate,
01389                  p_pat2->h_control);
01390           printf(" (mask:H%x offs:%d %s)\n",
01391             p_filter->l_pattern,
01392            (p_filter->l_offset >= 0) ?
01393                            p_filter->l_offset : -p_filter->l_offset,
01394            (p_filter->l_offset >= 0) ? "LW" : "W");
01395                  }
01396                  break;
01397 
01398        default:
01399             printf("W-FLTSPEC %d NOT FOUND\n",p_opc1->h_fltspec);
01400        }                            /* switch case  */
01401 
01402        /* ++++ check if Filter specification is valid ++++ */
01403        if ((p_opc1->h_fltspec > 15) && (p_opc1->b1_evtsev == 1)) {
01404                printf("E-%s: Filter specification %d invalid for events\n",
01405                      c_modnam,
01406                      p_opc1->h_fltspec);
01407                return(FALSE);                /* abort with error                */
01408                }
01409        if ((p_opc1->h_fltspec < 2) && (p_opc1->b1_evtsev != 1)) {
01410                printf("E-%s: Filter specification %d invalid for subevents\n",
01411                      c_modnam,
01412                      p_opc1->h_fltspec);
01413                return(FALSE);                /* abort with error                */
01414           }
01415 
01416          } /* for (j... */
01417 
01418       } /* for (i... */
01419    if ( (i_debug == 1) || (i_debug == 2) )
01420       printf("\n\n");
01421 
01422    return(TRUE);
01423 } /* end f_typflt */
01424 
01425 
01426 
01427 
01428 /*2+F_READ_SERVER***+**************************************************/
01429 /*                                                                    */
01430 /*+ Module      : F_READ_SERVER                                       */
01431 /*                                                                    */
01432 /*                                                                    */
01433 /*--------------------------------------------------------------------*/
01434 /*+ CALLING     : sts = f_read_server(p_clntbuf,                      */
01435 /*                                       p_bytrd,                     */
01436 /*                                       l_timeout,                   */
01437 /*                                       i_chan)                      */
01438 /*                                                                    */
01439 /*                                                                    */
01440 /*--------------------------------------------------------------------*/
01441 /*                                                                    */
01442 /*+ PURPOSE     : Read a buffer from the server                       */
01443 /*                                                                    */
01444 /*+ ARGUMENTS   :                                                     */
01445 /*+    p_clntbuf: Pointer to structure s_clntbuf                      */
01446 /*+    p_bytrd  : Pointer to (int) Number of read bytes              */
01447 /*+    l_timeout: (int) Timeout in seconds                           */
01448 /*+    i_chan   : (int) channel number                                */
01449 /*                                                                    */
01450 /*+ FUNCTION    : Read a buffer of the type s_clntbuf from the        */
01451 /*                server.                                             */
01452 /*                                                                    */
01453 /*+ Return type : int (32 bit)                                       */
01454 /*+ Status codes: 1: success                                          */
01455 /*                0: fault                                            */
01456 /*+ Initialize  : -                                                   */
01457 /*+ Include name: -                                                   */
01458 /*                                                                    */
01459 /*3+Implementation************+****************************************/
01460 /*                                                                    */
01461 /*+ File name   : PC_PROC.C                                           */
01462 /*+ Version     : 1.01                                                */
01463 /*+ Author      : R.S. Mayer                                          */
01464 /*+ Last Update : 14-JUN-1993                                         */
01465 /*+ Object libr.: GOOSHRLIB                                           */
01466 /*3+Updates*******+***********+****************************************/
01467 /*                                                                    */
01468 /*+ Updates     : Date          Purpose                               */
01469 /*-               26-Jan-1994 : Swap inserted (RSM)                   */
01470 /*-               24-Feb-1994 : Bug removed (RSM)                     */
01471 /*                                                                    */
01472 /*3+Description***+***********+****************************************/
01473 /*1- C Procedure ***********+******************************************/
01474 int        f_read_server(ps_chan, p_bytrd, l_timeout, i_chan)
01475 s_evt_channel *ps_chan;
01476 int             *p_bytrd;
01477 int             l_timeout;
01478 int              i_chan;
01479 {
01480   /* ++++ declarations ++++ */
01481 int             l_maxbytes;
01482   int            l_status,ii,im,*pl;                              /* !!! */
01483   int           l_bytrec, l_2ndbuf_byt;
01484   int           l_buftord, l_buffertype;
01485   static char    c_modnam[] = "f_read_server";
01486   char           c_retmsg[256];
01487   char *pc;
01488   int *pl_d,*pl_s;
01489   s_ve10_1 *ps_ve10_1;
01490 
01491   /* ++++ action       ++++ */
01492 
01493   p_clntbuf =  (struct s_clntbuf *) ps_chan->pc_io_buf;
01494   l_maxbytes=ps_chan->l_io_buf_size;
01495   /* + + + + + + + + + + + + + + + */
01496   /* + + + read first buffer + + + */
01497   /* + + + + + + + + + + + + + + + */
01498   if (i_debug == 2)
01499      printf(
01500      "D-%s: **Rd 1st Buf: at %8x to %8x = %d bytes\n",
01501             c_modnam,
01502             (char *) p_clntbuf,
01503             ((char *) p_clntbuf) + (CLNT__SMALLBUF - 1),
01504             CLNT__SMALLBUF);
01505 
01506 
01507   *p_bytrd = CLNT__SMALLBUF;
01508   l_status = f_stc_read( (char *) p_clntbuf,
01509                          (int) CLNT__SMALLBUF,
01510                          i_chan,
01511                          l_timeout);
01512 
01513   if (l_status != STC__SUCCESS)
01514   {
01515      printf("E-%s: Error reading first buffer. Msg follows:",c_modnam);
01516      f_stc_disperror(l_status,c_retmsg, 0);
01517      return(FALSE);
01518   }
01519 
01520   /* +++ copy the relevant length values +++ */
01521   l_buftord    = p_clntbuf->l_numbuftosnd;
01522   l_bytrec     = p_clntbuf->l_bytestosnd;
01523   l_buffertype = p_clntbuf->l_buffertype;
01524 
01525   /* +++ test for byte swap +++ */
01526   if (p_clntbuf->l_testbit != GPS__ENV_TESTBIT)
01527   {
01528      if (i_debug == 2)
01529         printf("D-%s: Need swap to receive from %s to %s ENDIAN\n",
01530                c_modnam,
01531                (p_clntbuf->l_endian == 0) ? "LITTLE" : "BIG",
01532                (GPS__ENV_ENDIAN     == 0) ? "LITTLE" : "BIG");
01533 
01534      l_status = F__SWAP(&l_buftord, 1, 0);
01535      if (l_status != 0)        printf("E-%s: Error swapping l_buftord. l_sts:%d\n", c_modnam,l_status);
01536      l_status = F__SWAP(&l_bytrec , 1, 0);
01537      if (l_status != 0)        printf("E-%s: Error swapping l_bytrec l_sts:%d\n", c_modnam,l_status);
01538      l_status = F__SWAP(&l_buffertype, 1, 0);
01539      if (l_status != 0)        printf("E-%s: Error swapping l_buffertype l_sts:%d\n", c_modnam,l_status);
01540      if (i_debug == 2)
01541         printf("D-%s: buffers:%d, bytes:%d, buffertype:%d\n",
01542                c_modnam,
01543                l_buftord,
01544                l_bytrec,
01545                l_buffertype);
01546 
01547   }
01548   if (l_buftord == 1)
01549   {
01550      if (l_bytrec  > CLNT__SMALLBUF)
01551      {
01552         printf("E-%s: Buffer sent:%d Bytes_to_rd:%d > %d\n",
01553                c_modnam,
01554                l_buftord,
01555                l_bytrec,
01556                CLNT__SMALLBUF);
01557         return(FALSE);
01558      }
01559      goto m_snd_ackn;
01560   }
01561 
01562   l_2ndbuf_byt = l_bytrec - CLNT__SMALLBUF;     /* rest of bytes in 2nd buffer*/
01563 
01564   /* + + + + + + + + + + + + + + */
01565   /* + + + read 2nd buffer + + + */
01566   /* + + + + + + + + + + + + + + */
01567   if (i_debug == 2)
01568   {
01569      short  j;
01570      int  *pl;
01571      printf("D-%s: begin of c_buffer[148] in LW (all hex)\n", c_modnam);
01572      pl = (int *) &p_clntbuf->c_buffer[148];
01573      for (j=0; j<5; j++)
01574      {
01575         printf("%8x:%8x ",pl,*(pl));
01576         pl++;
01577         printf("%8x:%8x ",pl,*(pl));
01578         pl++;
01579         printf("%8x:%8x ",pl,*(pl));
01580         pl++;
01581 
01582         printf("\n");
01583      }
01584      printf("D-%s: **Rd 2nd Buf: at %8x (buf[%d]) to %8x = %d b\n",
01585             c_modnam,
01586             (char *) &p_clntbuf->c_buffer[CLNT__RESTBUF],
01587             CLNT__RESTBUF,
01588             ((char *) &p_clntbuf->c_buffer[CLNT__RESTBUF]) + (l_2ndbuf_byt - 1),
01589             l_2ndbuf_byt);
01590   }
01591   *p_bytrd += l_2ndbuf_byt;
01592   l_buftord = 2;
01593   /* check if buffer if big enough, reallocate if not */
01594   /* old buffer is freed by caller */
01595   if(l_bytrec > l_maxbytes)
01596   {
01597       im=l_bytrec;
01598       l_bytrec=(int)(1.2*(float)l_bytrec);
01599       l_bytrec=((l_bytrec>>12)+1);
01600       l_bytrec=(l_bytrec<<12);
01601       /*      printf("reallocate for %d (%d) bytes\n",im,l_bytrec);fflush(stdout);*/
01602       pc =  malloc(l_bytrec);
01603       pl_d=(int *)pc;
01604       for(ii=0;ii<l_bytrec/4;ii++) *pl_d++ = 0;
01605       pl_d=(int *)pc;
01606       pl_s=(int *)ps_chan->pc_io_buf;
01607       for(ii=0;ii<CLNT__SMALLBUF/4;ii++) *pl_d++ = *pl_s++;
01608       ps_chan->pc_io_buf = pc;
01609       ps_chan->l_io_buf_size = l_bytrec;
01610       p_clntbuf = (struct s_clntbuf *) pc;
01611   }
01612   pl = (int *) &p_clntbuf->c_buffer[CLNT__RESTBUF];
01613   im=l_2ndbuf_byt/16384;
01614   l_2ndbuf_byt=l_2ndbuf_byt%16384;
01615   for(ii=0;ii<im;ii++)
01616   {
01617     l_status = f_stc_read( pl,16384,i_chan,l_timeout);
01618     pl+=4096;
01619     if(l_status != STC__SUCCESS)break;
01620   }
01621   if(l_2ndbuf_byt > 0)
01622   {
01623     l_status = f_stc_read( pl,l_2ndbuf_byt,i_chan,l_timeout);
01624   }
01625   if (l_status != STC__SUCCESS)
01626   {
01627      printf("E-%s: Error reading second buffer. Msg follows:",c_modnam);
01628      f_stc_disperror(l_status,c_retmsg, 0);
01629      return(FALSE);
01630   }
01631 
01632   if (i_debug == 2)
01633   {
01634      short  j;
01635      int  *pl;
01636      printf("D-%s: begin of c_buffer[148] in LW (all hex)\n", c_modnam);
01637      pl = (int *) &p_clntbuf->c_buffer[148];
01638      for (j=0; j<5; j++)
01639      {
01640         printf("%8x:%8x ",pl,*(pl));
01641         pl++;
01642         printf("%8x:%8x ",pl,*(pl));
01643         pl++;
01644         printf("%8x:%8x ",pl,*(pl));
01645         pl++;
01646 
01647         printf("\n");
01648      }
01649   }
01650 
01651   m_snd_ackn:;                             /* +++ set and send 12 bytes ackn */
01652   /* ++++++++++++++++++++++++++++++++++ */
01653   /* + + + send acknowledge buffer + + + */
01654   /* ++++++++++++++++++++++++++++++++++ */
01655   s_ackn.l_ack_buf   = l_buftord;
01656   s_ackn.l_ack_bytes = *p_bytrd;
01657   s_ackn.l_clnt_sts  = 1;                    /* success                      */
01658 
01659   if ((l_buffertype & 8) != 0)
01660      s_ackn.l_clnt_sts = s_ackn.l_clnt_sts | 8;  /* set bit for last buffer  */
01661 
01662   return(TRUE);
01663 }
01664 
01665 
01666 /*2+F_SEND_ACKN*****+**************************************************/
01667 /*                                                                    */
01668 /*+ Module      : F_SEND_ACKN                                         */
01669 /*                                                                    */
01670 /*                                                                    */
01671 /*--------------------------------------------------------------------*/
01672 /*+ CALLING     : sts = f_send_ackn(l_clnt_sts, i_chan)               */
01673 /*--------------------------------------------------------------------*/
01674 /*                                                                    */
01675 /*+ PURPOSE     : Send acknowledge buffer to the server                */
01676 /*                                                                    */
01677 /*+ ARGUMENTS   :                                                     */
01678 /*+   l_clnt_sts: Status. Status bits will be set in addition to the  */
01679 /*                status  bits set by f_read_server in s_ackn struct. */
01680 /*+    i_chan   : (int) channel number                                */
01681 /*                                                                    */
01682 /*+ FUNCTION    : Send the acknowledge buffer. Set additional bits in  */
01683 /*                the status word, i.e. "last buffer" etc.            */
01684 /*                                                                    */
01685 /*+ Return type : int (32 bit)                                       */
01686 /*+ Status codes: 1: success                                          */
01687 /*                0: fault                                            */
01688 /*+ Initialize  : -                                                   */
01689 /*+ Include name: -                                                   */
01690 /*                                                                    */
01691 /*3+Implementation************+****************************************/
01692 /*                                                                    */
01693 /*+ File name   : PC_PROC.C                                           */
01694 /*+ Version     : 1.01                                                */
01695 /*+ Author      : R.S. Mayer                                          */
01696 /*+ Last Update : 11-Apr-1994                                         */
01697 /*+ Object libr.: GOOSHRLIB                                           */
01698 /*3+Updates*******+***********+****************************************/
01699 /*                                                                    */
01700 /*+ Updates     : Date          Purpose                               */
01701 /*                                                                    */
01702 /*3+Description***+***********+****************************************/
01703 /*1- C Procedure ***********+******************************************/
01704 int        f_send_ackn(l_clnt_sts, i_chan)
01705 int             l_clnt_sts;
01706 int              i_chan;
01707 {
01708   /* ++++ declarations ++++ */
01709   int            l_status;                              /* !!! */
01710   static char    c_modnam[] = "f_send_ackn";
01711   char           c_retmsg[256];
01712 
01713   if (i_debug == 2)
01714      printf("I-%s s_ackn.l_clnt_sts:%d l_clnt_sts:%d\n",
01715              c_modnam,
01716              s_ackn.l_clnt_sts,
01717              l_clnt_sts);
01718 
01719   /* +++++++++++++++++++++++++++++++ */
01720   /* +++ set status of ackn buf  +++ */
01721   /* +++++++++++++++++++++++++++++++ */
01722   s_ackn.l_clnt_sts  = s_ackn.l_clnt_sts | l_clnt_sts; /* success            */
01723 
01724   /* ++++++++++++++++++++++++++++++ */
01725   /* +++ send acknowledge buffer +++ */
01726   /* ++++++++++++++++++++++++++++++ */
01727   l_status = f_stc_write( (char *) &s_ackn,
01728                           12,
01729                           i_chan);
01730 
01731   if (l_status != STC__SUCCESS)
01732   {
01733      printf("E-%s: Error in f_stc_write(&s_ackn,...)! Msg follows:",
01734             c_modnam);
01735      f_stc_disperror(l_status,c_retmsg, 0);
01736      return(FALSE);
01737   }
01738 
01739   return(TRUE);
01740 }
01741 
01742 
01743 /*2+F_STRTOUPPER***+***************************************************/
01744 /*                                                                    */
01745 /*+ Module      : F_STRTOUPPER                                        */
01746 /*                                                                    */
01747 /*                                                                    */
01748 /*--------------------------------------------------------------------*/
01749 /*+ CALLING     : sts = f_strtoupper(u, l)                            */
01750 /*                                                                    */
01751 /*                                                                    */
01752 /*--------------------------------------------------------------------*/
01753 /*                                                                    */
01754 /*+ PURPOSE     : Converts a '\0' terminated string to upper case.    */
01755 /*                                                                    */
01756 /*+ ARGUMENTS   :                                                     */
01757 /*+    u        : Pointer to upper case string (result)               */
01758 /*+    l        : Pointer to lower case string (argument)             */
01759 /*                                                                    */
01760 /*+ FUNCTION    : Converts a '\0' terminated string to upper case.    */
01761 /*                                                                    */
01762 /*+ Return type : int (32 bit)                                       */
01763 /*+ Status codes: -                                                   */
01764 /*+ Initialize  : -                                                   */
01765 /*+ Include name: -                                                   */
01766 /*                                                                    */
01767 /*3+Implementation************+****************************************/
01768 /*                                                                    */
01769 /*+ File name   : PC_PROC.C                                           */
01770 /*+ Version     : 1.01                                                */
01771 /*+ Author      : R.S. Mayer                                          */
01772 /*+ Last Update : 14-JUN-1993                                         */
01773 /*+ Object libr.: GOOSHRLIB                                           */
01774 /*3+Updates*******+***********+****************************************/
01775 /*                                                                    */
01776 /*+ Updates     : Date        Purpose                                 */
01777 /*                                                                    */
01778 /*3+Description***+***********+****************************************/
01779 /*1- C Procedure ***********+******************************************/
01780 void f_strtoupper(u, l)
01781 char *u, *l;
01782 {
01783      for ( ; *l != '\0'; ++l, ++u)
01784          *u = toupper(*l);
01785 
01786      *u = '\0';
01787      return;
01788 }
01789 
01790 
01791 /*2+F_CLNUP ***+*******************************************************/
01792 /*                                                                    */
01793 /*+ Module      : F_CLNUP                                             */
01794 /*                                                                    */
01795 /*                                                                    */
01796 /*--------------------------------------------------------------------*/
01797 /*+ CALLING     : f_clnup(v_mem, p_keyb)                              */
01798 /*                                                                    */
01799 /*                                                                    */
01800 /*--------------------------------------------------------------------*/
01801 /*                                                                    */
01802 /*+ PURPOSE     : Cleanup allocated memory and dealloc devices        */
01803 /*                                                                    */
01804 /*+ ARGUMENTS   :                                                     */
01805 /*+    v_mem[]  : (int) [0]:maxidx=n [1:n]:ptr to allocated memory   */
01806 /*+    p_keyb   : Pointer to s_keyb or NULL.                          */
01807 /*                                                                    */
01808 /*+ FUNCTION    : Cleanup allocated memory and dealloc devices        */
01809 /*                Calls free(v_mem[i]) and f_ttydass(p_keyb)          */
01810 /*                                                                    */
01811 /*                                                                    */
01812 /*+ Return type : void                                                */
01813 /*+ Status codes: -                                                   */
01814 /*+ Initialize  : -                                                   */
01815 /*+ Include name: -                                                   */
01816 /*                                                                    */
01817 /*3+Implementation************+****************************************/
01818 /*                                                                    */
01819 /*+ File name   : PC_PROC.C                                           */
01820 /*+ Version     : 1.01                                                */
01821 /*+ Author      : R.S. Mayer                                          */
01822 /*+ Last Update : 14-JUN-1993                                         */
01823 /*+ Object libr.: GOOSHRLIB                                           */
01824 /*3+Updates*******+***********+****************************************/
01825 /*                                                                    */
01826 /*+ Updates     : Date          Purpose                               */
01827 /*-               14-Jan-94 : prototype TTYSTUFF(f_ttydass()) (RSM)   */
01828 /*-               08-Apr-94 : Accept NULL pointer for p_keyb. /HE     */
01829 /*                                                                    */
01830 /*3+Description***+***********+****************************************/
01831 /*1- C Procedure ***********+******************************************/
01832 /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
01833 void f_clnup(v_mem, p_keyb)
01834 long v_mem[];
01835 int *p_keyb;
01836 /* cleanup: free allocated memory and dealloc allocated device(s) */
01837 {
01838   /* ++++ declaration ++++ */
01839   static char     c_modnam[] = "f_clnup";
01840   short    i;
01841   int     l_status;
01842 
01843   for (i = 1; i <= v_mem[0]; i++)
01844   {
01845     /*    printf("free %d of %d: %8x",i,v_mem[0],v_mem[i]);fflush(stdout);*/
01846      if(v_mem[i] != 0) free((int *) v_mem[i]);
01847      /*     printf(" done\n");fflush(stdout);*/
01848      v_mem[i]=0;
01849   }
01850   v_mem[0]=0;
01851 }
01852 /*******************************************************************/
01853 void f_clnup_save(v_mem, p_keyb)
01854 long v_mem[];
01855 int *p_keyb;
01856 /* cleanup: free allocated memory and dealloc allocated device(s) */
01857 {
01858   /* ++++ declaration ++++ */
01859   static char     c_modnam[] = "f_clnup";
01860   short    i;
01861   int     l_status;
01862 
01863   /*  printf("all  %d:",v_mem[0]);fflush(stdout);*/
01864   v_mem[++v_mem[0]] = (long) p_keyb; /* was (int) before JA */
01865   
01866   /*  printf("  %d: %8x\n",v_mem[0],(int)p_keyb);fflush(stdout);*/
01867 }
01868 /* ------------------------------------------------------------------------- */
01869 
01870 //----------------------------END OF GO4 SOURCE FILE ---------------------

Generated on Tue Nov 8 10:56:08 2005 for Go4-v2.10-5 by doxygen1.2.15