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 #include "typedefs.h"
00059
00060
00061 #define F__SWAP(ps,l,pd) f_swaplw((int *)ps,(int)l,(int *)pd)
00062 #ifdef VMS
00063 #define UNIXENV 0
00064
00065
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
00073
00074 #ifdef Lynx
00075 #define UNIXENV 1
00076 #endif
00077
00078 #ifdef HPUX
00079 #define UNIXENV 1
00080 #define _HPUX_SOURCE
00081 #define _POSIX_SOURCE
00082 #endif
00083
00084 #ifdef Linux
00085 #define UNIXENV 1
00086 #endif
00087
00088 #ifdef Solaris
00089 #define UNIXENV 1
00090 #endif
00091
00092 #ifdef GSI__WINNT
00093 #define UNIXENV 1
00094 #define _ALL_SOURCE
00095 #define _POSIX_SOURCE
00096 #endif
00097
00098
00099 #ifdef _AIX
00100 #define UNIXENV 1
00101 #define _ALL_SOURCE
00102 #define _POSIX_SOURCE
00103 #define IN_AIX 1
00104 #else
00105 #define IN_AIX 0
00106 #endif
00107
00108
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>
00115 #include <netdb.h>
00116 #endif
00117 #include <errno.h>
00118 #include <stdio.h>
00119 #include <string.h>
00120 #include <stdlib.h>
00121 #endif
00122
00123
00124 #include "gps_sc_def.h"
00125 #include "s_filter.h"
00126 #include "clnt_buf_def.h"
00127 #include "s_clntbuf.h"
00128
00129
00130 #include "fLmd.h"
00131
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;
00163
00164 #define EVT_MAX 1000
00165 #define TCP__TIMEOUT 3000
00166 #define FLUSH__TIME 3
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;
00174 static int unsigned l_endian_serv;
00175 static int l_len_lw1 = CLNT__BUFH_LW;
00176 int l_len_lw2;
00177 int i_channel;
00178 int unsigned l_clnt_sts;
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;
00188 int l_ack_bytes;
00189 int unsigned l_clnt_sts;
00190 } s_ackn;
00191
00192
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
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
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;
00221 p_clnt_filter->l_endian = GPS__ENV_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
00237
00238
00239
00240
00241
00242
00243
00244
00245
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
00278 i_h = p_clnt_filter->l_flush_rate / 3600;
00279 i_s = p_clnt_filter->l_flush_rate - i_h * 3600;
00280 i_m = i_s / 60;
00281 i_s = i_s - i_m * 60;
00282
00283
00284
00285
00286
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
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
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
00317
00318 memset(p_clntbuf,0, sizeof(struct s_clntbuf));
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
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
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;
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)
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
00357
00358 if (p_clntbuf->l_buffertype & 16)
00359 {
00360 }
00361
00362 if (p_clntbuf->l_buffertype & 2)
00363 {
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374 }
00375 return(STC__SUCCESS);
00376 }
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
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
00397
00398 p_clntbuf = (struct s_clntbuf *) ps_chan->pc_io_buf;
00399 ps_buf=ps_chan->pc_io_buf;
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
00406 if(ps_buf != ps_chan->pc_io_buf)
00407 {
00408 f_clnup(v_mem_clnup, NULL);
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;
00419
00420
00421
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;
00427
00428
00429 pl_inbuf = &p_clntbuf->l_inbuf_read_cnt;
00430 l_sts = F__SWAP(pl_inbuf, l_len_lw2, 0);
00431 }
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441 l_sts=STC__SUCCESS;
00442 if (p_clntbuf->l_buffertype & 2)
00443 {
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;
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;
00465 ps_ve10_1 = (s_ve10_1 *) ps_chan->pc_evt_buf;
00466 return(l_sts);
00467 }
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
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
00509
00510
00511
00512
00513
00514
00515
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 int f_fltdscr(p_clnt_filter)
00548
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;
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
00574 if (i_debug == 2)
00575 printf("--->D-%s: addr_filter p:%d\n", c_modnam, p_clnt_filter);
00576
00577
00578 p_flt_descr = (struct s_flt_descr *) &p_clnt_filter->flt_descr[0];
00579
00580
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;
00600 p_flt_descr->h_nextdescr = 0;
00601 break;
00602 }
00603
00604
00605
00606
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 {
00621
00622 p_flt_descr = (struct s_flt_descr *) &p_clnt_filter->flt_descr[0];
00623 i_descr = 0;
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
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 }
00643
00644 if (p_opc1->b1_selflt == 1)
00645 {
00646 if (i_fltdescnt == 0)
00647 i_fltdescnt++;
00648 i_descr = i_fltdescnt;
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
00657 if (p_opc1->b1_evtsev == 1)
00658 p_clnt_filter->if_fltevt = 1;
00659 else
00660 p_clnt_filter->if_fltsev = 1;
00661 }
00662
00663 }
00664
00665
00666 p_opc1->h_flt_len = i_flt_len;
00667 p_opc1->h_next_fltblk = i_next_fltblk;
00668
00669
00670
00671
00672
00673
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);
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);
00687 }
00688
00689
00690
00691 switch (p_opc1->h_fltspec)
00692 {
00693 case 0:
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:
00703
00704
00705 p_filter->l_offset = -5;
00706 p_filter->l_pattern = p_filter->l_pattern & 0xFFFF;
00707 break;
00708
00709 case 2:
00710 break;
00711
00712 case 4:
00713
00714
00715 p_filter->l_offset = -2;
00716 p_filter->l_pattern = p_filter->l_pattern & 0xFFFF;
00717
00718 break;
00719
00720 case 8:
00721
00722
00723 p_filter->l_offset = -3;
00724 p_filter->l_pattern = p_filter->l_pattern & 0xFFFF;
00725
00726 break;
00727
00728 case 12:
00729
00730
00731 p_filter->l_offset = 1;
00732
00733 break;
00734
00735 case 16:
00736
00737
00738 p_filter->l_offset = -4;
00739 p_filter->l_pattern = p_filter->l_pattern & 0xFFFF;
00740
00741 break;
00742
00743 case 32:
00744
00745
00746 p_filter->l_offset = -5;
00747 p_filter->l_pattern = p_filter->l_pattern & 0xFFFF;
00748
00749 break;
00750
00751 case 48:
00752
00753
00754 p_filter->l_offset = 2;
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 }
00764
00765
00766
00767 }
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
00783
00784
00785
00786
00787
00788
00789
00790
00791 if ( (p_clnt_filter->if_fltevt == 1) && (p_clnt_filter->if_fltsev == 1) ) {
00792 m_sort_descr:;
00793 i_lasevtflt = 0;
00794 i_1stsevflt = i_fltdescnt;
00795
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;
00804
00805 if ( (p_opc1->b1_selflt == 1) &&
00806 (p_opc1->b1_evtsev == 0) &&
00807 (i_1stsevflt == i_fltdescnt) )
00808 i_1stsevflt = i;
00809
00810 if (i_1stsevflt < i_lasevtflt) {
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
00818 pl_evtdescr = (int *) &p_clnt_filter->flt_descr[i_lasevtflt];
00819 l_evtdescr = *pl_evtdescr;
00820
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;
00829 }
00830
00831 }
00832
00833 }
00834
00835
00836 p_clnt_filter->flt_descr[0].i_descriptors = i_fltdescnt;
00837
00838
00839
00840
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
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 }
00850 }
00851
00852 return(l_retsts | 1);
00853
00854 }
00855
00856
00857
00858
00859
00860
00861
00862
00863
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 int f_fltrd(p_clnt_filter, c_file)
00899 struct s_clnt_filter *p_clnt_filter;
00900 char *c_file;
00901 {
00902
00903
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
00931
00932 if ( (infile = fopen(c_file,"r")) == 0)
00933 {
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;
00961 p_com = strpbrk(c_line,"!/*");
00962 if (p_com != NULL)
00963 {
00964 if_comment = 1;
00965 strcpy(c_comment,p_com);
00966 *p_com = '\0';
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;
01013 p_com = strpbrk(c_line,"!/*");
01014 if (p_com != NULL)
01015 {
01016 if_comment = 1;
01017 strcpy(c_comment,p_com);
01018 *p_com = '\0';
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;
01035 if (l_scan == 9)
01036 goto m_ok_assign;
01037
01038 if_hex = 1;
01039 p_minus = strchr(c_line,'-');
01040
01041 if (p_minus != 0)
01042 *p_minus = ' ';
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 }
01106
01107 i_currflt = (short) p_opc1->h_next_fltblk;
01108
01109 }
01110
01111 fclose(infile);
01112
01113 return(TRUE);
01114 }
01115
01116
01117
01118
01119
01120
01121
01122
01123
01124
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 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
01169
01170
01171 i_fltdescnt = p_clnt_filter->flt_descr[0].i_descriptors;
01172
01173
01174
01175
01176
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
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
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:
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:
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:
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:
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:
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:
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:
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:
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:
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 }
01390
01391
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);
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);
01403 }
01404
01405 }
01406
01407 }
01408 if ( (i_debug == 1) || (i_debug == 2) )
01409 printf("\n\n");
01410
01411 return(TRUE);
01412 }
01413
01414
01415
01416
01417
01418
01419
01420
01421
01422
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 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
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
01481
01482 p_clntbuf = (struct s_clntbuf *) ps_chan->pc_io_buf;
01483 l_maxbytes=ps_chan->l_io_buf_size;
01484
01485
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
01510 l_buftord = p_clntbuf->l_numbuftosnd;
01511 l_bytrec = p_clntbuf->l_bytestosnd;
01512 l_buffertype = p_clntbuf->l_buffertype;
01513
01514
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;
01552
01553
01554
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
01583
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
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:;
01641
01642
01643
01644 s_ackn.l_ack_buf = l_buftord;
01645 s_ackn.l_ack_bytes = *p_bytrd;
01646 s_ackn.l_clnt_sts = 1;
01647
01648 if ((l_buffertype & 8) != 0)
01649 s_ackn.l_clnt_sts = s_ackn.l_clnt_sts | 8;
01650
01651 return(TRUE);
01652 }
01653
01654
01655
01656
01657
01658
01659
01660
01661
01662
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 int f_send_ackn(l_clnt_sts, i_chan)
01694 int l_clnt_sts;
01695 int i_chan;
01696 {
01697
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
01710
01711 s_ackn.l_clnt_sts = s_ackn.l_clnt_sts | l_clnt_sts;
01712
01713
01714
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
01733
01734
01735
01736
01737
01738
01739
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 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
01781
01782
01783
01784
01785
01786
01787
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 void f_clnup(v_mem, p_keyb)
01823 long v_mem[];
01824 int *p_keyb;
01825
01826 {
01827
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
01835 if(v_mem[i] != 0) free((int *) v_mem[i]);
01836
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
01846 {
01847
01848 static char c_modnam[] = "f_clnup";
01849 short i;
01850 int l_status;
01851
01852
01853 v_mem[++v_mem[0]] = (long) p_keyb;
01854
01855
01856 }
01857
01858
01859