Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

f_evcli.c

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

Generated on Fri Nov 28 12:59:31 2008 for Go4-v3.04-1 by  doxygen 1.4.2