00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059 #define F__SWAP(ps,l,pd) f_swaplw((int *)ps,(int)l,(int *)pd)
00060 #ifdef VMS
00061 #define UNIXENV 0
00062 #define ENDIAN 0
00063
00064
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
00072
00073 #ifdef Lynx
00074 #define UNIXENV 1
00075 #define ENDIAN 1
00076 #endif
00077
00078 #ifdef HPUX
00079 #define UNIXENV 1
00080 #define ENDIAN 1
00081 #define _HPUX_SOURCE
00082 #define _POSIX_SOURCE
00083 #endif
00084
00085 #ifdef Linux
00086 #define UNIXENV 1
00087 #define ENDIAN 0
00088 #define _ALL_SOURCE
00089 #define _POSIX_SOURCE
00090 #endif
00091
00092 #ifdef GSI__WINNT
00093 #define UNIXENV 1
00094 #define ENDIAN 0
00095 #define _ALL_SOURCE
00096 #define _POSIX_SOURCE
00097 #endif
00098
00099
00100 #ifdef _AIX
00101 #define UNIXENV 1
00102 #define ENDIAN 1
00103 #define _ALL_SOURCE
00104 #define _POSIX_SOURCE
00105 #define IN_AIX 1
00106 #else
00107 #define IN_AIX 0
00108 #endif
00109
00110
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>
00118 #endif
00119 #include <errno.h>
00120 #include <stdio.h>
00121 #include <string.h>
00122 #endif
00123
00124
00125 #include "gps_sc_def.h"
00126 #include "f_stccomm.h"
00127 #include "clnt_buf_def.h"
00128 #include "s_filter.h"
00129 #include "s_clntbuf.h"
00130
00131 #if ENDIAN == 1
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
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
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;
00165
00166 #define EVT_MAX 1000
00167 #define TCP__TIMEOUT 3000
00168 #define FLUSH__TIME 3
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;
00176 static int unsigned l_endian_serv;
00177 static int l_len_lw1 = CLNT__BUFH_LW;
00178 int l_len_lw2;
00179 int i_channel;
00180 int unsigned l_clnt_sts;
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;
00190 int l_ack_bytes;
00191 int unsigned l_clnt_sts;
00192 } s_ackn;
00193
00194
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
00201 #include "gps_sc_def.h"
00202 #include "f_stccomm.h"
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
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
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;
00232 p_clnt_filter->l_endian = GPS__ENV_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
00248
00249
00250
00251
00252
00253
00254
00255
00256
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
00289 i_h = p_clnt_filter->l_flush_rate / 3600;
00290 i_s = p_clnt_filter->l_flush_rate - i_h * 3600;
00291 i_m = i_s / 60;
00292 i_s = i_s - i_m * 60;
00293
00294
00295
00296
00297
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
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
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
00328
00329 memset(p_clntbuf,0, sizeof(struct s_clntbuf));
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
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
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;
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)
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
00368
00369 if (p_clntbuf->l_buffertype & 16)
00370 {
00371 }
00372
00373 if (p_clntbuf->l_buffertype & 2)
00374 {
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385 }
00386 return(STC__SUCCESS);
00387 }
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
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
00408
00409 p_clntbuf = (struct s_clntbuf *) ps_chan->pc_io_buf;
00410 ps_buf=ps_chan->pc_io_buf;
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
00417 if(ps_buf != ps_chan->pc_io_buf)
00418 {
00419 f_clnup(v_mem_clnup, NULL);
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;
00430
00431
00432
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;
00438
00439
00440 pl_inbuf = &p_clntbuf->l_inbuf_read_cnt;
00441 l_sts = F__SWAP(pl_inbuf, l_len_lw2, 0);
00442 }
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452 l_sts=STC__SUCCESS;
00453 if (p_clntbuf->l_buffertype & 2)
00454 {
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;
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;
00476 ps_ve10_1 = (s_ve10_1 *) ps_chan->pc_evt_buf;
00477 return(l_sts);
00478 }
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
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
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529
00530
00531
00532
00533
00534
00535
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558 int f_fltdscr(p_clnt_filter)
00559
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;
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
00585 if (i_debug == 2)
00586 printf("--->D-%s: addr_filter p:%d\n", c_modnam, p_clnt_filter);
00587
00588
00589 p_flt_descr = (struct s_flt_descr *) &p_clnt_filter->flt_descr[0];
00590
00591
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;
00611 p_flt_descr->h_nextdescr = 0;
00612 break;
00613 }
00614
00615
00616
00617
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 {
00632
00633 p_flt_descr = (struct s_flt_descr *) &p_clnt_filter->flt_descr[0];
00634 i_descr = 0;
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
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 }
00654
00655 if (p_opc1->b1_selflt == 1)
00656 {
00657 if (i_fltdescnt == 0)
00658 i_fltdescnt++;
00659 i_descr = i_fltdescnt;
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
00668 if (p_opc1->b1_evtsev == 1)
00669 p_clnt_filter->if_fltevt = 1;
00670 else
00671 p_clnt_filter->if_fltsev = 1;
00672 }
00673
00674 }
00675
00676
00677 p_opc1->h_flt_len = i_flt_len;
00678 p_opc1->h_next_fltblk = i_next_fltblk;
00679
00680
00681
00682
00683
00684
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);
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);
00698 }
00699
00700
00701
00702 switch (p_opc1->h_fltspec)
00703 {
00704 case 0:
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:
00714
00715
00716 p_filter->l_offset = -5;
00717 p_filter->l_pattern = p_filter->l_pattern & 0xFFFF;
00718 break;
00719
00720 case 2:
00721 break;
00722
00723 case 4:
00724
00725
00726 p_filter->l_offset = -2;
00727 p_filter->l_pattern = p_filter->l_pattern & 0xFFFF;
00728
00729 break;
00730
00731 case 8:
00732
00733
00734 p_filter->l_offset = -3;
00735 p_filter->l_pattern = p_filter->l_pattern & 0xFFFF;
00736
00737 break;
00738
00739 case 12:
00740
00741
00742 p_filter->l_offset = 1;
00743
00744 break;
00745
00746 case 16:
00747
00748
00749 p_filter->l_offset = -4;
00750 p_filter->l_pattern = p_filter->l_pattern & 0xFFFF;
00751
00752 break;
00753
00754 case 32:
00755
00756
00757 p_filter->l_offset = -5;
00758 p_filter->l_pattern = p_filter->l_pattern & 0xFFFF;
00759
00760 break;
00761
00762 case 48:
00763
00764
00765 p_filter->l_offset = 2;
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 }
00775
00776
00777
00778 }
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
00794
00795
00796
00797
00798
00799
00800
00801
00802 if ( (p_clnt_filter->if_fltevt == 1) && (p_clnt_filter->if_fltsev == 1) ) {
00803 m_sort_descr:;
00804 i_lasevtflt = 0;
00805 i_1stsevflt = i_fltdescnt;
00806
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;
00815
00816 if ( (p_opc1->b1_selflt == 1) &&
00817 (p_opc1->b1_evtsev == 0) &&
00818 (i_1stsevflt == i_fltdescnt) )
00819 i_1stsevflt = i;
00820
00821 if (i_1stsevflt < i_lasevtflt) {
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
00829 pl_evtdescr = (int *) &p_clnt_filter->flt_descr[i_lasevtflt];
00830 l_evtdescr = *pl_evtdescr;
00831
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;
00840 }
00841
00842 }
00843
00844 }
00845
00846
00847 p_clnt_filter->flt_descr[0].i_descriptors = i_fltdescnt;
00848
00849
00850
00851
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
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 }
00861 }
00862
00863 return(l_retsts | 1);
00864
00865 }
00866
00867
00868
00869
00870
00871
00872
00873
00874
00875
00876
00877
00878
00879
00880
00881
00882
00883
00884
00885
00886
00887
00888
00889
00890
00891
00892
00893
00894
00895
00896
00897
00898
00899
00900
00901
00902
00903
00904
00905
00906
00907
00908
00909 int f_fltrd(p_clnt_filter, c_file)
00910 struct s_clnt_filter *p_clnt_filter;
00911 char *c_file;
00912 {
00913
00914
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
00942
00943 if ( (infile = fopen(c_file,"r")) == 0)
00944 {
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;
00972 p_com = strpbrk(c_line,"!/*");
00973 if (p_com != NULL)
00974 {
00975 if_comment = 1;
00976 strcpy(c_comment,p_com);
00977 *p_com = '\0';
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;
01024 p_com = strpbrk(c_line,"!/*");
01025 if (p_com != NULL)
01026 {
01027 if_comment = 1;
01028 strcpy(c_comment,p_com);
01029 *p_com = '\0';
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;
01046 if (l_scan == 9)
01047 goto m_ok_assign;
01048
01049 if_hex = 1;
01050 p_minus = strchr(c_line,'-');
01051
01052 if (p_minus != 0)
01053 *p_minus = ' ';
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 }
01117
01118 i_currflt = (short) p_opc1->h_next_fltblk;
01119
01120 }
01121
01122 fclose(infile);
01123
01124 return(TRUE);
01125 }
01126
01127
01128
01129
01130
01131
01132
01133
01134
01135
01136
01137
01138
01139
01140
01141
01142
01143
01144
01145
01146
01147
01148
01149
01150
01151
01152
01153
01154
01155
01156
01157
01158
01159
01160
01161
01162
01163
01164
01165
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
01180
01181
01182 i_fltdescnt = p_clnt_filter->flt_descr[0].i_descriptors;
01183
01184
01185
01186
01187
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
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
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:
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:
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:
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:
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:
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:
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:
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:
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:
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 }
01401
01402
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);
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);
01414 }
01415
01416 }
01417
01418 }
01419 if ( (i_debug == 1) || (i_debug == 2) )
01420 printf("\n\n");
01421
01422 return(TRUE);
01423 }
01424
01425
01426
01427
01428
01429
01430
01431
01432
01433
01434
01435
01436
01437
01438
01439
01440
01441
01442
01443
01444
01445
01446
01447
01448
01449
01450
01451
01452
01453
01454
01455
01456
01457
01458
01459
01460
01461
01462
01463
01464
01465
01466
01467
01468
01469
01470
01471
01472
01473
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
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
01492
01493 p_clntbuf = (struct s_clntbuf *) ps_chan->pc_io_buf;
01494 l_maxbytes=ps_chan->l_io_buf_size;
01495
01496
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
01521 l_buftord = p_clntbuf->l_numbuftosnd;
01522 l_bytrec = p_clntbuf->l_bytestosnd;
01523 l_buffertype = p_clntbuf->l_buffertype;
01524
01525
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;
01563
01564
01565
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
01594
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
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:;
01652
01653
01654
01655 s_ackn.l_ack_buf = l_buftord;
01656 s_ackn.l_ack_bytes = *p_bytrd;
01657 s_ackn.l_clnt_sts = 1;
01658
01659 if ((l_buffertype & 8) != 0)
01660 s_ackn.l_clnt_sts = s_ackn.l_clnt_sts | 8;
01661
01662 return(TRUE);
01663 }
01664
01665
01666
01667
01668
01669
01670
01671
01672
01673
01674
01675
01676
01677
01678
01679
01680
01681
01682
01683
01684
01685
01686
01687
01688
01689
01690
01691
01692
01693
01694
01695
01696
01697
01698
01699
01700
01701
01702
01703
01704 int f_send_ackn(l_clnt_sts, i_chan)
01705 int l_clnt_sts;
01706 int i_chan;
01707 {
01708
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
01721
01722 s_ackn.l_clnt_sts = s_ackn.l_clnt_sts | l_clnt_sts;
01723
01724
01725
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
01744
01745
01746
01747
01748
01749
01750
01751
01752
01753
01754
01755
01756
01757
01758
01759
01760
01761
01762
01763
01764
01765
01766
01767
01768
01769
01770
01771
01772
01773
01774
01775
01776
01777
01778
01779
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
01792
01793
01794
01795
01796
01797
01798
01799
01800
01801
01802
01803
01804
01805
01806
01807
01808
01809
01810
01811
01812
01813
01814
01815
01816
01817
01818
01819
01820
01821
01822
01823
01824
01825
01826
01827
01828
01829
01830
01831
01832
01833 void f_clnup(v_mem, p_keyb)
01834 long v_mem[];
01835 int *p_keyb;
01836
01837 {
01838
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
01846 if(v_mem[i] != 0) free((int *) v_mem[i]);
01847
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
01857 {
01858
01859 static char c_modnam[] = "f_clnup";
01860 short i;
01861 int l_status;
01862
01863
01864 v_mem[++v_mem[0]] = (long) p_keyb;
01865
01866
01867 }
01868
01869
01870