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 #include "typedefs.h"
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
00063
00064 #include <stdio.h>
00065 #include <errno.h>
00066 #include <ctype.h>
00067 #include <types.h>
00068 #include <string.h>
00069 #include <stdlib.h>
00070 #endif
00071
00072 #ifdef Lynx
00073 #define UNIXENV 1
00074 #endif
00075
00076 #ifdef HPUX
00077 #define UNIXENV 1
00078 #define _HPUX_SOURCE
00079 #define _POSIX_SOURCE
00080 #endif
00081
00082 #ifdef Linux
00083 #define UNIXENV 1
00084 #endif
00085
00086 #ifdef Solaris
00087 #define UNIXENV 1
00088 #endif
00089
00090 #ifdef Darwin
00091 #define UNIXENV 1
00092 #endif
00093
00094
00095 #ifdef GSI__WINNT
00096 #define UNIXENV 1
00097 #define _ALL_SOURCE
00098 #define _POSIX_SOURCE
00099 #endif
00100
00101
00102 #ifdef _AIX
00103 #define UNIXENV 1
00104 #define _ALL_SOURCE
00105 #define _POSIX_SOURCE
00106 #define IN_AIX 1
00107 #else
00108 #define IN_AIX 0
00109 #endif
00110
00111
00112 #if UNIXENV == 1
00113 #include <sys/types.h>
00114 #ifdef GSI__WINNT
00115 #include <sys/timeb.h>
00116 #else
00117 #include <sys/time.h>
00118 #include <netdb.h>
00119 #endif
00120 #include <errno.h>
00121 #include <stdio.h>
00122 #include <string.h>
00123 #include <stdlib.h>
00124 #endif
00125
00126
00127 #include "gps_sc_def.h"
00128 #include "s_filter.h"
00129 #include "clnt_buf_def.h"
00130 #include "s_clntbuf.h"
00131
00132
00133 #include "fLmd.h"
00134
00135
00136 #include "f_evcli.h"
00137 #include "f_swaplw.h"
00138
00139 #include "s_filter.h"
00140
00141 #if MBS_ENDIAN == 1
00142 #include "s_flt_descr_swap.h"
00143 #include "s_clnt_filter_swap.h"
00144 #else
00145 #include "s_flt_descr.h"
00146 #include "s_clnt_filter.h"
00147 #endif
00148
00149 #include "s_opc1.h"
00150 #include "s_pat.h"
00151
00152 #include "gps_sc_def.h"
00153
00154 void f_clnup(long [], int *);
00155 void f_clnup_save(long [], int *);
00156 int f_fltdscr(struct s_clnt_filter *);
00157 int f_read_server(s_evt_channel *, int *, int, int);
00158 int f_send_ackn(int, int);
00159
00160 unsigned short *pi_inbuf;
00161 unsigned int *pl_inbuf;
00162 unsigned int l_len_w;
00163 int swapw(unsigned short *, unsigned short *, unsigned int);
00164 int swapl(unsigned int *, unsigned int *, unsigned int);
00165 static int i_debug = 0;
00166
00167 #define EVT_MAX 1000
00168 #define TCP__TIMEOUT 3000
00169 #define FLUSH__TIME 3
00170 #define STDOUT_BUFIO_ 1
00171
00172 struct s_clnt_filter *p_clnt_filter;
00173 struct s_clntbuf *p_clntbuf;
00174 struct s_opc1 *p_opc1;
00175
00176 static int unsigned lf_swap = 0;
00177 static int unsigned l_endian_serv;
00178 static int l_len_lw1 = CLNT__BUFH_LW;
00179 int l_len_lw2;
00180 int i_channel;
00181 int unsigned l_clnt_sts;
00182 int l_status, l_sts;
00183 static char c_modnam[] = "f_evcli";
00184 short if_typevt, i_sign = 1, i_len;
00185 int l_timeout;
00186 int l_retval;
00187 static struct s_tcpcomm s_tcpcomm_ec = {0,0,0};
00188 static struct
00189 {
00190 int l_ack_buf;
00191 int l_ack_bytes;
00192 int unsigned l_clnt_sts;
00193 } s_ackn;
00194
00195
00196 long v_mem_clnup[8];
00197
00198 int f_evcli_con(s_evt_channel *ps_chan, char *pc_node, int l_aport, int l_aevents, int l_asample)
00199
00200 {
00201 short i, i_h, i_m, i_s;
00202 char arg[80], c_hms[16], c_help[4];
00203 int l_evtecho,*pl;
00204 char c_node[32], c_name[32], c_retmsg[256];
00205 int l_port;
00206
00207 v_mem_clnup[0] = 0;
00208
00209
00210 p_clnt_filter = (struct s_clnt_filter *) malloc( sizeof(struct s_clnt_filter) );
00211 if (p_clnt_filter == NULL)
00212 {
00213 printf("E-%s: calloc(,...s_clnt_filter) failed!\n", c_modnam);
00214 printf("F-%s: aborting program execution!\n",c_modnam);
00215 f_clnup(v_mem_clnup, NULL);
00216 return(-1);
00217 }
00218 ps_chan->pc_evt_buf=(char *) p_clnt_filter;
00219
00220 f_clnup_save(v_mem_clnup, (int *) p_clnt_filter);
00221 memset( (void *) p_clnt_filter, 0, sizeof(struct s_clnt_filter) );
00222
00223 p_clnt_filter->l_testbit = GPS__ENV_TESTBIT;
00224 p_clnt_filter->l_endian = GPS__ENV_ENDIAN;
00225 p_clnt_filter->l_numb_of_evt = l_aevents;
00226 p_opc1 = (struct s_opc1 *) &p_clnt_filter->filter[0].l_opcode;
00227 p_opc1->b1_evtsev = 1;
00228 p_opc1->b1_selflt = 1;
00229 p_opc1->b1_selwrt = 1;
00230 p_opc1->b3_opc = 0;
00231 p_opc1->b1_lnkf1 = 0;
00232 p_opc1->b1_lnkf2 = 0;
00233 p_opc1->h_fltspec = 0;
00234 p_opc1->h_next_fltblk = 1;
00235 p_opc1->h_flt_len = 1;
00236
00237 l_status = f_fltdscr(p_clnt_filter);
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250 if ((l_status & 1) == 0)
00251 {
00252 printf("E-%s: Severe Error in f_fltdscr! Status:%d\n",
00253 c_modnam,
00254 l_status);
00255 f_clnup(v_mem_clnup, NULL);
00256 return(-1);
00257 }
00258 p_clnt_filter->l_sample_rate = l_asample;
00259 p_clnt_filter->l_flush_rate = FLUSH__TIME;
00260
00261 l_timeout = TCP__TIMEOUT ;
00262 strcpy(c_node,pc_node);
00263 l_port = l_aport;
00264
00265 l_status = (int) f_stc_connectserver(c_node,
00266 l_port,
00267 &i_channel,
00268 &s_tcpcomm_ec);
00269 if ((l_status & 1) != STC__SUCCESS)
00270 {
00271 printf("E-%s: Error connecting node:%s, port:%d. Msg:\n",
00272 c_modnam,
00273 c_node,
00274 l_port);
00275 f_stc_disperror((int) l_status,c_retmsg, 0);
00276 f_stc_close(&s_tcpcomm_ec);
00277 return(l_status);
00278 }
00279 ps_chan->l_channel_no=i_channel;
00280
00281 i_h = p_clnt_filter->l_flush_rate / 3600;
00282 i_s = p_clnt_filter->l_flush_rate - i_h * 3600;
00283 i_m = i_s / 60;
00284 i_s = i_s - i_m * 60;
00285
00286
00287
00288
00289
00290 l_status = (int) f_stc_write( (char *) p_clnt_filter,
00291 GPS__CLNT_SNDFLT,
00292 i_channel);
00293 if (l_status != STC__SUCCESS)
00294 {
00295 printf("E-%s: Error in f_write_tcp(p_flt,...)! Status:%d. Msg:\n",
00296 c_modnam,
00297 l_status);
00298 f_stc_disperror((int) l_status,c_retmsg, 0);
00299 f_stc_close(&s_tcpcomm_ec);
00300 return(l_status);
00301 }
00302
00303
00304
00305 p_clntbuf = (struct s_clntbuf *) malloc(sizeof(struct s_clntbuf));
00306 if (p_clntbuf == NULL)
00307 {
00308 printf("E-%s: malloc(p_clntbuf) failed!\n", c_modnam);
00309 printf("F-%s: aborting program execution!\n",c_modnam);
00310 f_stc_close(&s_tcpcomm_ec);
00311 return(-1);
00312 }
00313
00314 f_clnup_save(v_mem_clnup, (int *) p_clntbuf);
00315
00316 ps_chan->pc_io_buf = (char *) p_clntbuf;
00317 ps_chan->l_io_buf_size = GPS__OUTBUFSIZ + CLNT__OUTBUFHEAD;
00318
00319
00320
00321 memset(p_clntbuf,0, sizeof(struct s_clntbuf));
00322 l_status = f_read_server(ps_chan,
00323 &l_retval,
00324 l_timeout,
00325 i_channel);
00326 if (l_status != TRUE)
00327 {
00328 printf("E-%s: Error reading 1st buffer: f_read_server()!\n", c_modnam);
00329 f_stc_close(&s_tcpcomm_ec);
00330 return(l_status);
00331 }
00332
00333
00334
00335
00336 lf_swap = (p_clntbuf->l_testbit == GPS__ENV_TESTBIT) ? 0 : 1;
00337 l_endian_serv = p_clntbuf->l_endian;
00338
00339 if (lf_swap)
00340
00341
00342
00343 {
00344 l_sts = F__SWAP(&p_clntbuf->l_testbit,CLNT__BUFH_LW,0);
00345
00346 l_len_lw2 = CLNT__REST_LW + p_clntbuf->l_dlen/4;
00347 l_sts = F__SWAP(&p_clntbuf->l_inbuf_read_cnt, l_len_lw2, 0);
00348
00349 if (p_clntbuf->l_testbit != GPS__ENV_TESTBIT)
00350 {
00351 printf("F-%s: Error swapping first buffer from client\n",
00352 c_modnam);
00353 f_stc_close(&s_tcpcomm_ec);
00354 return(-1);
00355 }
00356 }
00357
00358
00359
00360
00361 if (p_clntbuf->l_buffertype & 16)
00362 {
00363 }
00364
00365 if (p_clntbuf->l_buffertype & 2)
00366 {
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377 }
00378 return(STC__SUCCESS);
00379 }
00380
00381
00382 int f_evcli_buf(s_evt_channel *ps_chan)
00383
00384 {
00385 s_ve10_1 *ps_ve10_1;
00386 int ii;
00387 char *ps_buf;
00388
00389
00390
00391 l_status = f_send_ackn(1, ps_chan->l_channel_no);
00392 if (l_status != TRUE)
00393 {
00394 printf("E-%s: Error sending acknowledge: f_send_ackn()!\n", c_modnam);
00395 f_stc_close(&s_tcpcomm_ec);
00396 return(l_status);
00397 }
00398
00399
00400
00401 p_clntbuf = (struct s_clntbuf *) ps_chan->pc_io_buf;
00402 ps_buf=ps_chan->pc_io_buf;
00403 memset(p_clntbuf,0, ps_chan->l_io_buf_size);
00404 l_status = f_read_server(ps_chan,
00405 &l_retval,
00406 l_timeout,
00407 ps_chan->l_channel_no);
00408
00409 if(ps_buf != ps_chan->pc_io_buf)
00410 {
00411 f_clnup(v_mem_clnup, NULL);
00412 p_clntbuf = (struct s_clntbuf *) ps_chan->pc_io_buf;
00413 f_clnup_save(v_mem_clnup, (int *) p_clntbuf);
00414 }
00415 if (l_status != TRUE)
00416 {
00417 printf("E-%s: Error reading buffer: f_read_server()!\n", c_modnam);
00418 f_stc_close(&s_tcpcomm_ec);
00419 return(l_status);
00420 }
00421 l_clnt_sts = 0;
00422
00423
00424
00425
00426 if (lf_swap)
00427 {
00428 l_sts = F__SWAP(&p_clntbuf->l_testbit,CLNT__BUFH_LW, 0);
00429 l_len_lw2 = CLNT__REST_LW + p_clntbuf->l_dlen/4;
00430
00431
00432 pl_inbuf = &p_clntbuf->l_inbuf_read_cnt;
00433 l_sts = F__SWAP(pl_inbuf, l_len_lw2, 0);
00434 }
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444 l_sts=STC__SUCCESS;
00445 if (p_clntbuf->l_buffertype & 2)
00446 {
00447 switch (p_clntbuf->l_msgtyp & 15)
00448 {
00449 case 1:
00450 case 2: if((strstr(p_clntbuf->c_message,"no event data") == NULL)&
00451 (strstr(p_clntbuf->c_message,"flushed") == NULL))
00452 printf("MSG-type:W: %s\n", p_clntbuf->c_message); break;
00453 case 4: printf("MSG-type:E: %s\n", p_clntbuf->c_message); break;
00454 case 8: printf("MSG-type:F: %s\n", p_clntbuf->c_message); break;
00455 default: printf("Unknown MSG-type:%d:\n%s\n",p_clntbuf->l_msgtyp,p_clntbuf->c_message);
00456 }
00457 l_sts=STC__TIMEOUT;
00458 }
00459 else
00460 {
00461 if(p_clntbuf->l_events == 0)
00462 {
00463 l_sts=STC__TIMEOUT;
00464 }
00465 }
00466 ps_chan->pc_evt_buf = (char *)&p_clntbuf->c_buffer[0];
00467 ps_chan->l_evt_buf_posi = 1;
00468 ps_ve10_1 = (s_ve10_1 *) ps_chan->pc_evt_buf;
00469 return(l_sts);
00470 }
00471
00472
00473 int f_evcli_evt(s_evt_channel *ps_chan)
00474
00475 {
00476 int *ps_int;
00477 s_ve10_1 *ps_ve10_1;
00478
00479 p_clntbuf = (struct s_clntbuf *) ps_chan->pc_io_buf;
00480 if(ps_chan->l_evt_buf_posi < p_clntbuf->l_events)
00481 {
00482 ps_chan->l_evt_buf_posi++;
00483 ps_ve10_1 = (s_ve10_1 *) ps_chan->pc_evt_buf;
00484 ps_int = (int *) ps_chan->pc_evt_buf;
00485 ps_int += ps_ve10_1->l_dlen/2 + 2;
00486 ps_chan->pc_evt_buf = (char *) ps_int;
00487 return(STC__SUCCESS);
00488 }
00489 else return(-1);
00490 }
00491
00492 int f_evcli_close(s_evt_channel *ps_chan)
00493
00494 {
00495
00496
00497
00498 l_status = f_send_ackn(8, ps_chan->l_channel_no);
00499 if (l_status != TRUE)
00500 {
00501 printf("E-%s: Error sending acknowledge: f_send_ackn()!\n", c_modnam);
00502 return(l_status);
00503 }
00504 f_clnup(v_mem_clnup, NULL);
00505 f_stc_discclient(ps_chan->l_channel_no);
00506 f_stc_close(&s_tcpcomm_ec);
00507 return(STC__SUCCESS);
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
00548
00549
00550 int f_fltdscr(p_clnt_filter)
00551
00552 struct s_clnt_filter *p_clnt_filter;
00553 {
00554 static char c_modnam[] = "f_fltdscr";
00555 struct s_filter *p_filter;
00556 struct s_opc1 *p_opc1;
00557 struct s_flt_descr *p_flt_descr;
00558 struct s_pat1 *p_pat1;
00559 struct s_pat2 *p_pat2;
00560 struct s_pat3 *p_pat3;
00561
00562 short i_fltdescnt = 0;
00563 short i_fltcnt = 0;
00564 short i_fltblkcnt = 0;
00565 short i, i_flt_len,
00566 i_fltblkbeg, i_fltblkend, j;
00567 short if_newfltblk = 1;
00568 short i_next_fltblk = 0;
00569 short i_descr;
00570 int l_evtdescr, *pl_evtdescr, *pl_sev1descr, *pl_sev2descr;
00571 short i_lasevtflt, i_1stsevflt;
00572
00573 int unsigned l_status, l_sts;
00574 int unsigned l_retsts = 0;
00575
00576
00577 if (i_debug == 2)
00578 printf("--->D-%s: addr_filter p:%d\n", c_modnam, p_clnt_filter);
00579
00580
00581 p_flt_descr = (struct s_flt_descr *) &p_clnt_filter->flt_descr[0];
00582
00583
00584 for (i = 0; i < GPS__MAXFLT; i++)
00585 {
00586 p_filter = (struct s_filter *) &p_clnt_filter->filter[i];
00587 p_opc1 = (struct s_opc1 *) &p_filter->l_opcode;
00588
00589 if (i_debug == 2)
00590 printf("D-%s: i:%d opc:%x flt_len:%d\n",
00591 c_modnam,
00592 i,
00593 p_filter->l_opcode,
00594 p_opc1->h_flt_len);
00595
00596 if (i == i_next_fltblk)
00597 if_newfltblk = 1;
00598
00599 if (p_opc1->h_flt_len == 0)
00600 {
00601 i_fltcnt = i;
00602 p_opc1->h_next_fltblk = 0;
00603 p_flt_descr->h_nextdescr = 0;
00604 break;
00605 }
00606
00607
00608
00609
00610
00611
00612
00613 if (if_newfltblk)
00614 {
00615 if_newfltblk = 0;
00616 i_fltblkcnt++;
00617 i_flt_len = p_opc1->h_flt_len;
00618 i_next_fltblk = i + i_flt_len;
00619 i_fltblkbeg = i;
00620 i_fltblkend = i_next_fltblk - 1;
00621
00622 if (p_opc1->b1_selwrt == 1)
00623 {
00624
00625 p_flt_descr = (struct s_flt_descr *) &p_clnt_filter->flt_descr[0];
00626 i_descr = 0;
00627
00628 if (p_flt_descr->hf_wrtdescr == 1 &&
00629 p_clnt_filter->flt_descr[0].i_descriptors <= 0)
00630 {
00631 printf("W-%s: >1 write blocks, previous one(s) ignored!\n",
00632 c_modnam);
00633 l_retsts = l_retsts | 2;
00634 }
00635
00636 p_flt_descr->hf_wrtdescr = 1;
00637 p_flt_descr->hf_fltdescr = 0;
00638 p_flt_descr->h_fltblkbeg = i_fltblkbeg;
00639 p_flt_descr->h_fltblkend = i_fltblkend;
00640 p_flt_descr->h_nextdescr = 1;
00641
00642
00643 p_clnt_filter->if_wrtevt = (p_opc1->b1_evtsev == 1) ? 1 : 0;
00644 p_clnt_filter->if_wrtsev = (p_opc1->b1_evtsev != 1) ? 1 : 0;
00645 }
00646
00647 if (p_opc1->b1_selflt == 1)
00648 {
00649 if (i_fltdescnt == 0)
00650 i_fltdescnt++;
00651 i_descr = i_fltdescnt;
00652 p_flt_descr = (struct s_flt_descr *)
00653 &p_clnt_filter->flt_descr[i_fltdescnt];
00654 p_flt_descr->hf_wrtdescr = 0;
00655 p_flt_descr->hf_fltdescr = 1;
00656 p_flt_descr->h_fltblkbeg = i_fltblkbeg;
00657 p_flt_descr->h_fltblkend = i_fltblkend;
00658 p_flt_descr->h_nextdescr = ++i_fltdescnt;
00659
00660 if (p_opc1->b1_evtsev == 1)
00661 p_clnt_filter->if_fltevt = 1;
00662 else
00663 p_clnt_filter->if_fltsev = 1;
00664 }
00665
00666 }
00667
00668
00669 p_opc1->h_flt_len = i_flt_len;
00670 p_opc1->h_next_fltblk = i_next_fltblk;
00671
00672
00673
00674
00675
00676
00677 if ((p_opc1->h_fltspec > 15) && (p_opc1->b1_evtsev == 1))
00678 {
00679 printf("E-%s: Filter specification %d invalid for events\n",
00680 c_modnam,
00681 p_opc1->h_fltspec);
00682 return(FALSE);
00683 }
00684 if ((p_opc1->h_fltspec < 2) && (p_opc1->b1_evtsev != 1))
00685 {
00686 printf("E-%s: Filter specification %d invalid for subevents\n",
00687 c_modnam,
00688 p_opc1->h_fltspec);
00689 return(FALSE);
00690 }
00691
00692
00693
00694 switch (p_opc1->h_fltspec)
00695 {
00696 case 0:
00697 if (p_opc1->b3_opc != 0) {
00698 printf("W-%s: Take all. Set opcode to 0, next time\n",
00699 c_modnam);
00700 p_opc1->b3_opc = 0;
00701 l_retsts = l_retsts | 2;
00702 }
00703 break;
00704
00705 case 1:
00706
00707
00708 p_filter->l_offset = -5;
00709 p_filter->l_pattern = p_filter->l_pattern & 0xFFFF;
00710 break;
00711
00712 case 2:
00713 break;
00714
00715 case 4:
00716
00717
00718 p_filter->l_offset = -2;
00719 p_filter->l_pattern = p_filter->l_pattern & 0xFFFF;
00720
00721 break;
00722
00723 case 8:
00724
00725
00726 p_filter->l_offset = -3;
00727 p_filter->l_pattern = p_filter->l_pattern & 0xFFFF;
00728
00729 break;
00730
00731 case 12:
00732
00733
00734 p_filter->l_offset = 1;
00735
00736 break;
00737
00738 case 16:
00739
00740
00741 p_filter->l_offset = -4;
00742 p_filter->l_pattern = p_filter->l_pattern & 0xFFFF;
00743
00744 break;
00745
00746 case 32:
00747
00748
00749 p_filter->l_offset = -5;
00750 p_filter->l_pattern = p_filter->l_pattern & 0xFFFF;
00751
00752 break;
00753
00754 case 48:
00755
00756
00757 p_filter->l_offset = 2;
00758
00759 break;
00760
00761 default:
00762 printf("W-%s: FLTSPEC %d NOT FOUND\n",
00763 c_modnam,
00764 p_opc1->h_fltspec);
00765 l_retsts = l_retsts | 2;
00766 }
00767
00768
00769
00770 }
00771
00772 p_flt_descr = (struct s_flt_descr *) &p_clnt_filter->flt_descr[0];
00773 if (p_flt_descr->hf_wrtdescr != 1) {
00774 printf("E-%s: The write filter is missing! Filter is invalid!\n",
00775 c_modnam);
00776 return(FALSE);
00777 }
00778
00779 if (!(p_clnt_filter->if_fltevt || p_clnt_filter->if_fltsev)) {
00780 printf("E-%s: The filter itself is missing! Filter is invalid!\n",
00781 c_modnam);
00782 return(FALSE);
00783 }
00784
00785
00786
00787
00788
00789
00790
00791
00792
00793
00794 if ( (p_clnt_filter->if_fltevt == 1) && (p_clnt_filter->if_fltsev == 1) ) {
00795 m_sort_descr:;
00796 i_lasevtflt = 0;
00797 i_1stsevflt = i_fltdescnt;
00798
00799 for (i = 1; i < i_fltdescnt; i++) {
00800 p_flt_descr = (struct s_flt_descr *) &p_clnt_filter->flt_descr[i];
00801 p_filter = (struct s_filter *)
00802 &p_clnt_filter->filter[p_flt_descr->h_fltblkbeg];
00803 p_opc1 = (struct s_opc1 *) &p_filter->l_opcode;
00804
00805 if ( (p_opc1->b1_selflt == 1) && (p_opc1->b1_evtsev == 1) )
00806 i_lasevtflt = i;
00807
00808 if ( (p_opc1->b1_selflt == 1) &&
00809 (p_opc1->b1_evtsev == 0) &&
00810 (i_1stsevflt == i_fltdescnt) )
00811 i_1stsevflt = i;
00812
00813 if (i_1stsevflt < i_lasevtflt) {
00814 printf(
00815 "W-%s 1stsevflt:%d lastevtflt:%d. Evt flt should come first\n",
00816 c_modnam,
00817 i_1stsevflt,
00818 i_lasevtflt);
00819 l_retsts = l_retsts | 2;
00820
00821 pl_evtdescr = (int *) &p_clnt_filter->flt_descr[i_lasevtflt];
00822 l_evtdescr = *pl_evtdescr;
00823
00824 for (j = i_lasevtflt; j > i_1stsevflt; j--) {
00825 pl_sev1descr = (int *) &p_clnt_filter->flt_descr[j-1];
00826 pl_sev2descr = (int *) &p_clnt_filter->flt_descr[j];
00827 *pl_sev2descr = *pl_sev1descr;
00828 }
00829 pl_evtdescr = (int *) &p_clnt_filter->flt_descr[i_1stsevflt];
00830 *pl_evtdescr = l_evtdescr;
00831 goto m_sort_descr;
00832 }
00833
00834 }
00835
00836 }
00837
00838
00839 p_clnt_filter->flt_descr[0].i_descriptors = i_fltdescnt;
00840
00841
00842
00843
00844 if (p_clnt_filter->if_fltsev == 1) {
00845 for (i = 1; i < p_clnt_filter->flt_descr[0].i_descriptors; i++) {
00846 p_flt_descr = (struct s_flt_descr *) &p_clnt_filter->flt_descr[i];
00847
00848 p_filter = (struct s_filter *)
00849 &p_clnt_filter->filter[p_flt_descr->h_fltblkbeg];
00850 p_opc1 = (struct s_opc1 *) &p_filter->l_opcode;
00851
00852 }
00853 }
00854
00855 return(l_retsts | 1);
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
00899
00900
00901 int f_fltrd(p_clnt_filter, c_file)
00902 struct s_clnt_filter *p_clnt_filter;
00903 char *c_file;
00904 {
00905
00906
00907 FILE *infile;
00908
00909 static char c_modnam[] = "f_fltrd";
00910 struct s_filter *p_filter;
00911 struct s_opc1 *p_opc1;
00912 struct s_flt_descr *p_flt_descr;
00913 struct s_pat1 *p_pat1;
00914 struct s_pat2 *p_pat2;
00915 struct s_pat3 *p_pat3;
00916
00917 char c_retmsg[256];
00918 char c_line[80], c_comment[80], *c_fsts, *p_com, *p_minus;
00919 short i_fltblklen = 0;
00920 short i_currflt = 0;
00921 short i, j;
00922 int l, l_scan=0;
00923
00924 int unsigned l_pattern;
00925 int l_offset;
00926
00927 short i_evtsev,i_selflt,i_selwrt,i_opc,i_lnkf1,
00928 i_lnkf2,i_fltspec;
00929 short if_hex, if_comment;
00930
00931 char *fgets( char *str, int maxchar, FILE *file_ptr);
00932
00933
00934
00935 if ( (infile = fopen(c_file,"r")) == 0)
00936 {
00937 sprintf(c_retmsg,"E-%s: fopen(File=%s) ",
00938 c_modnam,
00939 c_file);
00940 perror(c_retmsg);
00941 fclose(infile);
00942 return(FALSE);
00943 }
00944
00945 printf("Filter definition from file %s\n", c_file);
00946 printf("=======================================\n");
00947
00948 while (l_scan != EOF && i_fltblklen < GPS__MAXFLT)
00949 {
00950 m_read_nxtblklen:;
00951
00952 memset(c_line,0,sizeof(c_line));
00953
00954 if ( (c_fsts = fgets(c_line, sizeof(c_line), infile)) == 0)
00955 {
00956 if (i_debug == 2)
00957 printf("D-%s: File=%s: Last input line.\n",
00958 c_modnam,
00959 c_file);
00960 break;
00961 }
00962
00963 if_comment = 0;
00964 p_com = strpbrk(c_line,"!/*");
00965 if (p_com != NULL)
00966 {
00967 if_comment = 1;
00968 strcpy(c_comment,p_com);
00969 *p_com = '\0';
00970 if (i_debug == 2)
00971 printf(" - D: comment:%s", c_comment);
00972
00973 }
00974
00975 l_scan = sscanf(c_line, "%hd", &i_fltblklen);
00976 if (if_comment && (l_scan < 1) )
00977 goto m_read_nxtblklen;
00978
00979 if (l_scan == EOF || l_scan == 0 || c_fsts == NULL)
00980 {
00981 if (i_debug == 2)
00982 printf("D-%s: Last input line.\n",c_file);
00983 break;
00984 }
00985
00986 if (i_fltblklen + i_currflt >= GPS__MAXFLT)
00987 {
00988 printf("E-%s: too long. Last filter block ignored\n",
00989 c_modnam);
00990 fclose(infile);
00991 return(3);
00992 }
00993 if (i_debug == 2)
00994 printf("D-%s: Fltblklen:%d\n", c_modnam, i_fltblklen);
00995
00996 for (i = i_currflt; i < i_fltblklen + i_currflt; i++)
00997 {
00998 m_read_nxtline:;
00999
01000 memset(c_line,0,sizeof(c_line));
01001
01002 if ( (c_fsts = fgets(c_line, sizeof(c_line), infile)) == 0)
01003 {
01004 sprintf(c_retmsg,"E-%s: Error reading:fgets(File=%s) ",
01005 c_modnam,
01006 c_file);
01007 perror(c_retmsg);
01008 fclose(infile);
01009 return(FALSE);
01010 }
01011
01012 if (i_debug == 2)
01013 printf("D-%s: line:%s", c_modnam, c_line);
01014
01015 if_comment = 0;
01016 p_com = strpbrk(c_line,"!/*");
01017 if (p_com != NULL)
01018 {
01019 if_comment = 1;
01020 strcpy(c_comment,p_com);
01021 *p_com = '\0';
01022 if (i_debug == 2)
01023 printf(" - D: comment:%s", c_comment);
01024
01025 }
01026
01027 l_scan = sscanf(c_line,"%hd %hd %hd %hd %hd %hd %hd %ld %ld",
01028 &i_evtsev,
01029 &i_selflt,
01030 &i_selwrt,
01031 &i_opc,
01032 &i_lnkf1,
01033 &i_lnkf2,
01034 &i_fltspec,
01035 &l_pattern,
01036 &l_offset);
01037 if_hex = 0;
01038 if (l_scan == 9)
01039 goto m_ok_assign;
01040
01041 if_hex = 1;
01042 p_minus = strchr(c_line,'-');
01043
01044 if (p_minus != 0)
01045 *p_minus = ' ';
01046
01047 l_scan = sscanf(c_line,"%hd %hd %hd %hd %hd %hd %hd %lx %lx",
01048 &i_evtsev,
01049 &i_selflt,
01050 &i_selwrt,
01051 &i_opc,
01052 &i_lnkf1,
01053 &i_lnkf2,
01054 &i_fltspec,
01055 &l_pattern,
01056 &l_offset);
01057
01058 l_offset = (p_minus != NULL) ? -l_offset : l_offset;
01059
01060 if (l_scan < 9)
01061 {
01062 if (if_comment)
01063 goto m_read_nxtline;
01064
01065 printf(
01066 "E-%s: scanned only %d(of 9) var., last 2 must be dec or hexa\n",
01067 c_modnam,
01068 l_scan);
01069 fclose(infile);
01070 return(FALSE);
01071 }
01072
01073 m_ok_assign:
01074 if (i_debug == 2)
01075 {
01076 sprintf( c_retmsg,
01077 "%s es:%d f:%d w:%d opc:%d lf1:%d lf2:%d flt:%d p:%x o:%x",
01078 (if_hex) ? "HEX:" : "DEC:",
01079 i_evtsev,
01080 i_selflt,
01081 i_selwrt,
01082 i_opc,
01083 i_lnkf1,
01084 i_lnkf2,
01085 i_fltspec,
01086 l_pattern,
01087 l_offset);
01088 printf("D-%s: %s\n", c_modnam, c_retmsg);
01089 }
01090
01091 p_filter = (struct s_filter *) &p_clnt_filter->filter[i];
01092 p_opc1 = (struct s_opc1 *) &p_filter->l_opcode;
01093
01094 p_opc1->h_next_fltblk = (char) i_fltblklen + i_currflt;
01095 p_opc1->h_flt_len = (char) i_fltblklen;
01096
01097 p_filter->l_pattern = l_pattern;
01098 p_filter->l_offset = l_offset;
01099
01100 p_opc1->b1_evtsev = i_evtsev;
01101 p_opc1->b1_selflt = i_selflt;
01102 p_opc1->b1_selwrt = i_selwrt;
01103 p_opc1->b3_opc = i_opc;
01104 p_opc1->b1_lnkf1 = i_lnkf1;
01105 p_opc1->b1_lnkf2 = i_lnkf2;
01106 p_opc1->h_fltspec = (char) i_fltspec;
01107
01108 }
01109
01110 i_currflt = (short) p_opc1->h_next_fltblk;
01111
01112 }
01113
01114 fclose(infile);
01115
01116 return(TRUE);
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
01156
01157
01158 int f_typflt(p_clnt_filter)
01159 struct s_clnt_filter *p_clnt_filter;
01160 {
01161 static char c_modnam[] = "f_typflt";
01162 struct s_filter *p_filter;
01163 struct s_opc1 *p_opc1;
01164 struct s_flt_descr *p_flt_descr;
01165 struct s_pat1 *p_pat1;
01166 struct s_pat2 *p_pat2;
01167 struct s_pat3 *p_pat3;
01168
01169 short i_fltdescnt, j, i;
01170
01171
01172
01173
01174 i_fltdescnt = p_clnt_filter->flt_descr[0].i_descriptors;
01175
01176
01177
01178
01179
01180
01181 if ( (i_debug == 1) || (i_debug == 2) )
01182 printf(
01183 "Write:%s %s Filter:%s %s object OPCODE mask",
01184 (p_clnt_filter->if_wrtevt > 0) ? "EVENT" : "",
01185 (p_clnt_filter->if_wrtsev > 0) ? "SUBEVENT" : "",
01186 (p_clnt_filter->if_fltevt > 0) ? "EVENT" : "",
01187 (p_clnt_filter->if_fltsev > 0) ? "SUBEVENT" : "");
01188 for (i = 0; i < i_fltdescnt; i++) {
01189 p_flt_descr = (struct s_flt_descr *) &p_clnt_filter->flt_descr[i];
01190 p_filter = (struct s_filter *)
01191 &p_clnt_filter->filter[p_flt_descr->h_fltblkbeg];
01192 p_opc1 = (struct s_opc1 *) &p_filter->l_opcode;
01193
01194 if ( (i_debug == 1) || (i_debug == 2) )
01195 {
01196 if (i > 1)
01197 printf("\n<<%s>>\n", (p_opc1->b1_lnkf2 == 1) ? "A_N_D" : "O_R" );
01198 printf("\n=>>FILTER set %d :",i);
01199 printf(" Select:%s Filter:%s Write:%s Filter[%d:%d]:\n",
01200 (p_opc1->b1_evtsev == 1) ? "EVENT" : "SUBEVENT",
01201 (p_opc1->b1_selflt == 1) ? "ON" : "OFF",
01202 (p_opc1->b1_selwrt == 1) ? "ON" : "OFF",
01203 p_flt_descr->h_fltblkbeg,
01204 p_flt_descr->h_fltblkend );
01205 }
01206
01207
01208 if (p_opc1->b1_evtsev == 0 && p_opc1->b1_selflt == 1)
01209 {
01210 p_filter = (struct s_filter *)
01211 &p_clnt_filter->filter[p_flt_descr->h_fltblkbeg];
01212 if ( (i_debug == 1) || (i_debug == 2) )
01213 printf(
01214 " Filter set id is fltspec:%d == mask:H%x (see 1st filt. below)\n",
01215 p_opc1->h_fltspec,
01216 p_filter->l_pattern);
01217 }
01218
01219
01220
01221 for (j = p_flt_descr->h_fltblkbeg;
01222 j <= p_flt_descr->h_fltblkend;
01223 j++) {
01224 p_filter = (struct s_filter *) &p_clnt_filter->filter[j];
01225 p_opc1 = (struct s_opc1 *) &p_filter->l_opcode;
01226 if ( (j > p_flt_descr->h_fltblkbeg) &&
01227 (p_opc1->b1_selflt == 1) &&
01228 ( (i_debug == 1) || (i_debug == 2) ) )
01229 printf(" <%s>\n", (p_opc1->b1_lnkf1 == 1) ? "A_N_D" : "O_R" );
01230 if ( (i_debug == 1) || (i_debug == 2) )
01231 printf(" =>%2d: opcode: ", i + 1);
01232
01233 switch (p_opc1->b3_opc) {
01234 case 0:
01235 if ( (i_debug == 1) || (i_debug == 2) )
01236 printf("!! (ALL) ");
01237 break;
01238 case 1:
01239 if ( (i_debug == 1) || (i_debug == 2) )
01240 printf("== (IDENT) ");
01241 break;
01242
01243 case 2:
01244 if ( (i_debug == 1) || (i_debug == 2) )
01245 printf("&& (ANY) ");
01246 break;
01247
01248 case 3:
01249 if ( (i_debug == 1) || (i_debug == 2) )
01250 printf("&= (INCL) ");
01251 break;
01252
01253 case 4:
01254 if ( (i_debug == 1) || (i_debug == 2) )
01255 printf("^= (EXCL) ");
01256 break;
01257
01258 case 5:
01259 if ( (i_debug == 1) || (i_debug == 2) )
01260 printf("< (LT) ");
01261 break;
01262
01263 case 6:
01264 if ( (i_debug == 1) || (i_debug == 2) )
01265 printf(">= (GE) ");
01266 break;
01267
01268 default:
01269 printf("W-OPCODE %d NOT FOUND\n",p_opc1->b3_opc);
01270 }
01271
01272 switch (p_opc1->h_fltspec) {
01273 case 0:
01274 if (p_opc1->b3_opc != 0) {
01275 p_opc1->b3_opc = 0;
01276 printf("W-%s: Take all. Opcode is %d\n",
01277 c_modnam,
01278 p_opc1->b3_opc);
01279 }
01280 break;
01281
01282 case 1:
01283 p_pat1 = (struct s_pat1 *) &p_filter->l_pattern;
01284 if ( (i_debug == 1) || (i_debug == 2) )
01285 {
01286 printf("trigger:%2d",p_pat1->i_trigger);
01287 printf(" (mask:%d offs:%d %s)\n",
01288 p_filter->l_pattern,
01289 (p_filter->l_offset >= 0) ?
01290 p_filter->l_offset : -p_filter->l_offset,
01291 (p_filter->l_offset >= 0) ? "LW" : "W");
01292 }
01293 break;
01294
01295 case 2:
01296 if ( (i_debug == 1) || (i_debug == 2) )
01297 printf("mask:H%x offset:%d %s\n",
01298 p_filter->l_pattern,
01299 (p_filter->l_offset >= 0) ?
01300 p_filter->l_offset : -p_filter->l_offset,
01301 (p_filter->l_offset >= 0) ?
01302 "LW" : "W" );
01303 break;
01304
01305 case 4:
01306 if ( (i_debug == 1) || (i_debug == 2) )
01307 {
01308 printf("type:%d ",
01309 p_filter->l_pattern);
01310 printf(" (mask:%d offs:%d %s)\n",
01311 p_filter->l_pattern,
01312 (p_filter->l_offset >= 0) ?
01313 p_filter->l_offset : -p_filter->l_offset,
01314 (p_filter->l_offset >= 0) ? "LW" : "W");
01315 }
01316 break;
01317
01318 case 8:
01319 if ( (i_debug == 1) || (i_debug == 2) )
01320 {
01321 printf("subtype:%d ",
01322 p_filter->l_pattern);
01323 printf(" (mask:%d offs:%d %s)\n",
01324 p_filter->l_pattern,
01325 (p_filter->l_offset >= 0) ?
01326 p_filter->l_offset : -p_filter->l_offset,
01327 (p_filter->l_offset >= 0) ? "LW" : "W");
01328 }
01329 break;
01330
01331 case 12:
01332 p_pat3 = (struct s_pat3 *) &p_filter->l_pattern;
01333 if ( (i_debug == 1) || (i_debug == 2) )
01334 {
01335 printf("type:%d subtype:%d",
01336 p_pat3->i_type,
01337 p_pat3->i_subtype);
01338 printf(" (mask:H%x offs:%d %s)\n",
01339 p_filter->l_pattern,
01340 (p_filter->l_offset >= 0) ?
01341 p_filter->l_offset : -p_filter->l_offset,
01342 (p_filter->l_offset >= 0) ? "LW" : "W");
01343 }
01344 break;
01345
01346 case 16:
01347 p_pat2 = (struct s_pat2 *) &p_filter->l_pattern;
01348 if ( (i_debug == 1) || (i_debug == 2) )
01349 {
01350 printf("procid:%d ",
01351 p_pat2->i_procid);
01352 printf(" (mask:%d offs:%d %s)\n",
01353 p_filter->l_pattern,
01354 (p_filter->l_offset >= 0) ?
01355 p_filter->l_offset : -p_filter->l_offset,
01356 (p_filter->l_offset >= 0) ? "LW" : "W");
01357 }
01358 break;
01359
01360 case 32:
01361 if ( (i_debug == 1) || (i_debug == 2) )
01362 {
01363 printf("subcrate:%d control:%d",
01364 p_filter->l_pattern & 0x00FF,
01365 ((unsigned) (p_filter->l_pattern & 0xFF00)) >> 8);
01366 printf(" (mask:H%x offs:%d %s)\n",
01367 p_filter->l_pattern,
01368 (p_filter->l_offset >= 0) ?
01369 p_filter->l_offset : -p_filter->l_offset,
01370 (p_filter->l_offset >= 0) ? "LW" : "W");
01371 }
01372 break;
01373
01374 case 48:
01375 p_pat2 = (struct s_pat2 *) &p_filter->l_pattern;
01376 if ( (i_debug == 1) || (i_debug == 2) )
01377 {
01378 printf("procid:%2d subcr:%d contr:%d",
01379 p_pat2->i_procid,
01380 p_pat2->h_subcrate,
01381 p_pat2->h_control);
01382 printf(" (mask:H%x offs:%d %s)\n",
01383 p_filter->l_pattern,
01384 (p_filter->l_offset >= 0) ?
01385 p_filter->l_offset : -p_filter->l_offset,
01386 (p_filter->l_offset >= 0) ? "LW" : "W");
01387 }
01388 break;
01389
01390 default:
01391 printf("W-FLTSPEC %d NOT FOUND\n",p_opc1->h_fltspec);
01392 }
01393
01394
01395 if ((p_opc1->h_fltspec > 15) && (p_opc1->b1_evtsev == 1)) {
01396 printf("E-%s: Filter specification %d invalid for events\n",
01397 c_modnam,
01398 p_opc1->h_fltspec);
01399 return(FALSE);
01400 }
01401 if ((p_opc1->h_fltspec < 2) && (p_opc1->b1_evtsev != 1)) {
01402 printf("E-%s: Filter specification %d invalid for subevents\n",
01403 c_modnam,
01404 p_opc1->h_fltspec);
01405 return(FALSE);
01406 }
01407
01408 }
01409
01410 }
01411 if ( (i_debug == 1) || (i_debug == 2) )
01412 printf("\n\n");
01413
01414 return(TRUE);
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
01464
01465
01466 int f_read_server(ps_chan, p_bytrd, l_timeout, i_chan)
01467 s_evt_channel *ps_chan;
01468 int *p_bytrd;
01469 int l_timeout;
01470 int i_chan;
01471 {
01472
01473 int l_maxbytes;
01474 int l_status,ii,im,*pl;
01475 int l_bytrec, l_2ndbuf_byt;
01476 int l_buftord, l_buffertype;
01477 static char c_modnam[] = "f_read_server";
01478 char c_retmsg[256];
01479 char *pc;
01480 int *pl_d,*pl_s;
01481 s_ve10_1 *ps_ve10_1;
01482
01483
01484
01485 p_clntbuf = (struct s_clntbuf *) ps_chan->pc_io_buf;
01486 l_maxbytes=ps_chan->l_io_buf_size;
01487
01488
01489
01490 if (i_debug == 2)
01491 printf(
01492 "D-%s: **Rd 1st Buf: at %8x to %8x = %d bytes\n",
01493 c_modnam,
01494 (char *) p_clntbuf,
01495 ((char *) p_clntbuf) + (CLNT__SMALLBUF - 1),
01496 CLNT__SMALLBUF);
01497
01498
01499 *p_bytrd = CLNT__SMALLBUF;
01500 l_status = f_stc_read( (char *) p_clntbuf,
01501 (int) CLNT__SMALLBUF,
01502 i_chan,
01503 l_timeout);
01504
01505 if (l_status != STC__SUCCESS)
01506 {
01507 printf("E-%s: Error reading first buffer. Msg follows:",c_modnam);
01508 f_stc_disperror(l_status,c_retmsg, 0);
01509 return(FALSE);
01510 }
01511
01512
01513 l_buftord = p_clntbuf->l_numbuftosnd;
01514 l_bytrec = p_clntbuf->l_bytestosnd;
01515 l_buffertype = p_clntbuf->l_buffertype;
01516
01517
01518 if (p_clntbuf->l_testbit != GPS__ENV_TESTBIT)
01519 {
01520 if (i_debug == 2)
01521 printf("D-%s: Need swap to receive from %s to %s ENDIAN\n",
01522 c_modnam,
01523 (p_clntbuf->l_endian == 0) ? "LITTLE" : "BIG",
01524 (GPS__ENV_ENDIAN == 0) ? "LITTLE" : "BIG");
01525
01526 l_status = F__SWAP(&l_buftord, 1, 0);
01527 if (l_status != 0) printf("E-%s: Error swapping l_buftord. l_sts:%d\n", c_modnam,l_status);
01528 l_status = F__SWAP(&l_bytrec , 1, 0);
01529 if (l_status != 0) printf("E-%s: Error swapping l_bytrec l_sts:%d\n", c_modnam,l_status);
01530 l_status = F__SWAP(&l_buffertype, 1, 0);
01531 if (l_status != 0) printf("E-%s: Error swapping l_buffertype l_sts:%d\n", c_modnam,l_status);
01532 if (i_debug == 2)
01533 printf("D-%s: buffers:%d, bytes:%d, buffertype:%d\n",
01534 c_modnam,
01535 l_buftord,
01536 l_bytrec,
01537 l_buffertype);
01538
01539 }
01540 if (l_buftord == 1)
01541 {
01542 if (l_bytrec > CLNT__SMALLBUF)
01543 {
01544 printf("E-%s: Buffer sent:%d Bytes_to_rd:%d > %d\n",
01545 c_modnam,
01546 l_buftord,
01547 l_bytrec,
01548 CLNT__SMALLBUF);
01549 return(FALSE);
01550 }
01551 goto m_snd_ackn;
01552 }
01553
01554 l_2ndbuf_byt = l_bytrec - CLNT__SMALLBUF;
01555
01556
01557
01558
01559 if (i_debug == 2)
01560 {
01561 short j;
01562 int *pl;
01563 printf("D-%s: begin of c_buffer[148] in LW (all hex)\n", c_modnam);
01564 pl = (int *) &p_clntbuf->c_buffer[148];
01565 for (j=0; j<5; j++)
01566 {
01567 printf("%8x:%8x ",pl,*(pl));
01568 pl++;
01569 printf("%8x:%8x ",pl,*(pl));
01570 pl++;
01571 printf("%8x:%8x ",pl,*(pl));
01572 pl++;
01573
01574 printf("\n");
01575 }
01576 printf("D-%s: **Rd 2nd Buf: at %8x (buf[%d]) to %8x = %d b\n",
01577 c_modnam,
01578 (char *) &p_clntbuf->c_buffer[CLNT__RESTBUF],
01579 CLNT__RESTBUF,
01580 ((char *) &p_clntbuf->c_buffer[CLNT__RESTBUF]) + (l_2ndbuf_byt - 1),
01581 l_2ndbuf_byt);
01582 }
01583 *p_bytrd += l_2ndbuf_byt;
01584 l_buftord = 2;
01585
01586
01587 if(l_bytrec > l_maxbytes)
01588 {
01589 im=l_bytrec;
01590 l_bytrec=(int)(1.2*(float)l_bytrec);
01591 l_bytrec=((l_bytrec>>12)+1);
01592 l_bytrec=(l_bytrec<<12);
01593
01594 pc = (char*) malloc(l_bytrec);
01595 pl_d=(int *)pc;
01596 for(ii=0;ii<l_bytrec/4;ii++) *pl_d++ = 0;
01597 pl_d=(int *)pc;
01598 pl_s=(int *)ps_chan->pc_io_buf;
01599 for(ii=0;ii<CLNT__SMALLBUF/4;ii++) *pl_d++ = *pl_s++;
01600 ps_chan->pc_io_buf = pc;
01601 ps_chan->l_io_buf_size = l_bytrec;
01602 p_clntbuf = (struct s_clntbuf *) pc;
01603 }
01604 pl = (int *) &p_clntbuf->c_buffer[CLNT__RESTBUF];
01605 im=l_2ndbuf_byt/16384;
01606 l_2ndbuf_byt=l_2ndbuf_byt%16384;
01607 for(ii=0;ii<im;ii++)
01608 {
01609 l_status = f_stc_read( pl,16384,i_chan,l_timeout);
01610 pl+=4096;
01611 if(l_status != STC__SUCCESS)break;
01612 }
01613 if(l_2ndbuf_byt > 0)
01614 {
01615 l_status = f_stc_read( pl,l_2ndbuf_byt,i_chan,l_timeout);
01616 }
01617 if (l_status != STC__SUCCESS)
01618 {
01619 printf("E-%s: Error reading second buffer. Msg follows:",c_modnam);
01620 f_stc_disperror(l_status,c_retmsg, 0);
01621 return(FALSE);
01622 }
01623
01624 if (i_debug == 2)
01625 {
01626 short j;
01627 int *pl;
01628 printf("D-%s: begin of c_buffer[148] in LW (all hex)\n", c_modnam);
01629 pl = (int *) &p_clntbuf->c_buffer[148];
01630 for (j=0; j<5; j++)
01631 {
01632 printf("%8x:%8x ",pl,*(pl));
01633 pl++;
01634 printf("%8x:%8x ",pl,*(pl));
01635 pl++;
01636 printf("%8x:%8x ",pl,*(pl));
01637 pl++;
01638
01639 printf("\n");
01640 }
01641 }
01642
01643 m_snd_ackn:;
01644
01645
01646
01647 s_ackn.l_ack_buf = l_buftord;
01648 s_ackn.l_ack_bytes = *p_bytrd;
01649 s_ackn.l_clnt_sts = 1;
01650
01651 if ((l_buffertype & 8) != 0)
01652 s_ackn.l_clnt_sts = s_ackn.l_clnt_sts | 8;
01653
01654 return(TRUE);
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
01694
01695
01696 int f_send_ackn(l_clnt_sts, i_chan)
01697 int l_clnt_sts;
01698 int i_chan;
01699 {
01700
01701 int l_status;
01702 static char c_modnam[] = "f_send_ackn";
01703 char c_retmsg[256];
01704
01705 if (i_debug == 2)
01706 printf("I-%s s_ackn.l_clnt_sts:%d l_clnt_sts:%d\n",
01707 c_modnam,
01708 s_ackn.l_clnt_sts,
01709 l_clnt_sts);
01710
01711
01712
01713
01714 s_ackn.l_clnt_sts = s_ackn.l_clnt_sts | l_clnt_sts;
01715
01716
01717
01718
01719 l_status = f_stc_write( (char *) &s_ackn,
01720 12,
01721 i_chan);
01722
01723 if (l_status != STC__SUCCESS)
01724 {
01725 printf("E-%s: Error in f_stc_write(&s_ackn,...)! Msg follows:",
01726 c_modnam);
01727 f_stc_disperror(l_status,c_retmsg, 0);
01728 return(FALSE);
01729 }
01730
01731 return(TRUE);
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
01770
01771
01772 void f_strtoupper(u, l)
01773 char *u, *l;
01774 {
01775 for ( ; *l != '\0'; ++l, ++u)
01776 *u = toupper(*l);
01777
01778 *u = '\0';
01779 return;
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
01823
01824
01825 void f_clnup(v_mem, p_keyb)
01826 long v_mem[];
01827 int *p_keyb;
01828
01829 {
01830
01831 static char c_modnam[] = "f_clnup";
01832 short i;
01833 int l_status;
01834
01835 for (i = 1; i <= v_mem[0]; i++)
01836 {
01837
01838 if(v_mem[i] != 0) free((int *) v_mem[i]);
01839
01840 v_mem[i]=0;
01841 }
01842 v_mem[0]=0;
01843 }
01844
01845 void f_clnup_save(v_mem, p_keyb)
01846 long v_mem[];
01847 int *p_keyb;
01848
01849 {
01850
01851 static char c_modnam[] = "f_clnup";
01852 short i;
01853 int l_status;
01854
01855
01856 v_mem[++v_mem[0]] = (long) p_keyb;
01857
01858
01859 }
01860