12 #define RFIO_open rfio_open
13 #define RFIO_close rfio_close
14 #define RFIO_read rfio_read
15 #define RFIO_lseek rfio_lseek
18 #define RFIO_open open
19 #define RFIO_close close
20 #define RFIO_read read
21 #define RFIO_lseek lseek
54 #include <sys/timeb.h>
55 #include <sys/types.h>
57 #define DEF_FILE_ACCE S_IREAD | S_IWRITE
58 #define GET__OPEN_FLAG O_RDONLY | O_BINARY
59 #define PUT__OPEN_APD_FLAG O_RDWR | O_APPEND
60 #define PUT__CRT_FLAG O_CREAT | O_RDWR
61 #define PUT__CRT_OPT ""
64 #define WS_VERSION_REQD 0x0101
65 #define WS_VERSION_MAJOR HIBYTE(WS_VERSION_REQD)
66 #define WS_VERSION_MINOR LOBYTE(WS_VERSION_REQD)
67 #define MIN_SOCKETS_REQD 6
80 #include <sys/timeb.h>
81 #include <sys/types.h>
83 #define DEF_FILE_ACCE S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH
84 #define GET__OPEN_FLAG O_RDONLY
85 #define PUT__OPEN_APD_FLAG O_RDWR | O_APPEND
86 #define PUT__CRT_FLAG O_CREAT | O_RDWR
87 #define PUT__CRT_OPT ""
99 #include <sys/timeb.h>
100 #include <sys/types.h>
102 #define DEF_FILE_ACCE S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH
103 #define GET__OPEN_FLAG O_RDONLY
104 #define PUT__OPEN_APD_FLAG O_RDWR | O_APPEND
105 #define PUT__CRT_FLAG O_CREAT | O_RDWR
106 #define PUT__CRT_OPT ""
116 #include <sys/stat.h>
117 #include <sys/time.h>
118 #include <sys/timeb.h>
119 #include <sys/types.h>
121 #define DEF_FILE_ACCE S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH
122 #define GET__OPEN_FLAG O_RDONLY
123 #define PUT__OPEN_APD_FLAG O_RDWR | O_APPEND
124 #define PUT__CRT_FLAG O_CREAT | O_RDWR
125 #define PUT__CRT_OPT ""
135 #include <sys/mode.h>
136 #include <sys/time.h>
137 #include <sys/timeb.h>
138 #include <sys/types.h>
140 #define DEF_FILE_ACCE S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH
141 #define GET__OPEN_FLAG O_RDONLY
142 #define PUT__OPEN_APD_FLAG O_RDWR | O_APPEND
143 #define PUT__CRT_FLAG O_CREAT | O_RDWR
144 #define PUT__CRT_OPT ""
168 static struct s_tcpcomm s_tcpcomm_st_evt;
231 INTS4 l_total, l_sub, l_sum;
234 if (ps_ve10_1 == NULL) {
237 pl_next = (
INTS4*)(ps_ve10_1 + 1);
238 l_total = ps_ve10_1->
l_dlen - 4;
241 while (l_sum < l_total) {
244 if (ll == l_subevent) {
245 if (pl_lwords != NULL) {
246 *pl_lwords = ps_ves10_1->
l_dlen / 2 - 1;
249 *pl_se = (
INTS4*)ps_ves10_1;
252 *pl_d = (
INTS4*)(ps_ves10_1 + 1);
256 l_sub = ps_ves10_1->
l_dlen + 4;
258 pl_next = (
INTS4*)(ps_ves10_1);
259 pl_next += l_sub / 2;
261 if (pl_lwords != NULL) {
270 if (l_subevent == 0) {
314 INTS4 l, ll, l_status, l_ldata, l_used;
321 if ((l_hex + l_long) > 0) {
326 if (ps_bufhe != NULL) {
327 sprintf(c_line,
"--------------------------------------------------------");
328 printf(
"%s\n", c_line);
330 ll = ps_bufhe->
l_dlen * 2;
332 ll += 512 - ll % 512;
339 printf(
"f_evt_type: error in f_ut_utime!");
342 printf(
"f_evt_type: error in f_ut_utime!");
345 if (ps_bufhe->
i_type == 2000) {
347 sprintf(c_line,
"File header info:");
348 printf(
"%s\n", c_line);
349 sprintf(c_line,
"Size: %d [%d b], used %d [b]", ps_filhe->
filhe_dlen, ll, ps_filhe->
filhe_used * 2);
350 printf(
"%s\n", c_line);
351 sprintf(c_line,
"Label: %s", ps_filhe->
filhe_label);
352 printf(
"%s\n", c_line);
353 sprintf(c_line,
"File: %s", ps_filhe->
filhe_file);
354 printf(
"%s\n", c_line);
355 sprintf(c_line,
"User: %s", ps_filhe->
filhe_user);
356 printf(
"%s\n", c_line);
357 sprintf(c_line,
"Time: %s", ps_filhe->
filhe_time);
358 printf(
"%s\n", c_line);
359 sprintf(c_line,
"Run: %s", ps_filhe->
filhe_run);
360 printf(
"%s\n", c_line);
361 sprintf(c_line,
"Exp: %s", ps_filhe->
filhe_exp);
362 printf(
"%s\n", c_line);
365 printf(
"%s\n", c_line);
368 l_used = ps_bufhe->
i_used;
370 l_used = ps_bufhe->
l_free[2];
373 "Buffer %9d, Length %5d[w] Size %5d[b] used %5d[w] %s",
379 printf(
"%s\n", c_line);
381 " Events %3d Type/Subtype %5d %5d FragEnd=%d FragBegin=%d Total %5d[w]",
388 printf(
"%s\n", c_line);
390 sprintf(c_line,
"--------------------------------------------------------");
391 printf(
"%s\n", c_line);
394 if (ps_evhe == NULL) {
399 if (ps_evhe->
i_type != 10) {
401 "Event type %d, subtype %d, data longwords %d",
405 printf(
"%s\n", c_line);
406 if ((l_ldata != 0) & ((ps_evhe->
i_type == 4) | (ps_evhe->
i_type == 6))) {
408 pl_data = (
INTS4*)ps_evhe;
410 for (l = 0; l < ps_evhe->
l_dlen / 2; l++) {
411 sprintf(c_line,
"%08x ", *pl_data);
412 strcat(c_full, c_line);
415 printf(
"%s\n", c_full);
419 if (strlen(c_full) > 2) {
420 printf(
"%s\n", c_full);
430 "Event %9d Type/Subtype %5d %5d Length %5d[w] Trigger %2d",
436 printf(
"%s\n", c_line);
441 while (l_status == 0) {
445 if ((l_subid < 0) | (l_subid == ps_ves10_1->
i_procid)) {
447 " SubEv ID %6d Type/Subtype %5d %5d Length %5d[w] Control %2d Subcrate %2d",
454 printf(
"%s\n", c_line);
457 if ((l_long != 0) | (l_hex != 0)) {
459 for (l = 0; l < ll; l++) {
461 sprintf(c_line,
"%04x.%04x ", (*pl_data >> 16) & 0xffff, *pl_data & 0xffff);
463 sprintf(c_line,
"%8d ", *pl_data);
465 strcat(c_full, c_line);
468 printf(
"%s\n", c_full);
472 if (strlen(c_full) > 2) {
473 printf(
"%s\n", c_full);
478 for (l = 0; l < ll; l++) {
479 sprintf(c_line,
"%8d%8d", *pl_data & 0xffff, (*pl_data >> 16) & 0xffff);
480 strcat(c_full, c_line);
483 printf(
"%s\n", c_full);
487 if (strlen(c_full) > 2) {
488 printf(
"%s\n", c_full);
515 l_gl_rev_port = l_port;
516 printf(
"Use remote event server port %d\n", l_port);
563 INTS4 l_swap, l_swap_head, l_is_goosybuf, l_filehead = 0, l_size, l_size_head, l_dummy, l_header_size;
565 CHARS c_file[256], *pc_temp;
580 if ((
GETEVT__STREAM == l_mode) && ((pc_temp = strchr(pc_server,
':')) != NULL)) {
582 pc_server = strtok(pc_server,
":");
583 CHARS* pc_streamport = strtok(NULL,
":");
585 i_streamport = atoi(pc_streamport);
591 if ((pc_temp = strchr(pc_server,
':')) != NULL) {
599 printf(
"rfio not supported!\n");
604 if (ps_info != NULL) {
612 if (strlen(pc_server) <
sizeof(ps_chan->
c_channel)) {
615 printf(
"file name to long!\n");
622 if (strlen(pc_server) <
sizeof(c_file)) {
623 strncpy(c_file, pc_server,
sizeof(c_file) - 1);
625 printf(
"file name to long!\n");
629 if (strlen(c_file) < 5) {
630 strcat(c_file,
".lmd");
632 pc_temp = (
CHARS*)&c_file[strlen(c_file) - 4];
633 if ((strcmp(pc_temp,
".LMD") != 0) && (strcmp(pc_temp,
".lmd") != 0)) {
634 strcat(c_file,
".lmd");
643 printf(
"LMD format error: no LMD file: %s\n", c_file);
649 ps_chan->
pLmd = NULL;
659 f_evt_check_buf(c_temp, &l_size_head, &l_is_goosybuf, &l_swap_head, &l_filehead);
660 if (((l_is_goosybuf == 0) & (l_filehead == 0)) | (l_size_head == 0)) {
661 printf(
"LMD format error: swap=%d, header=%d, isLMD=%d, size=%d\n",
672 if (l_filehead == 1) {
677 l_header_size = l_size_head;
679 l_header_size = ((
s_filhe*)c_temp)->filhe_used * 2 + 48;
682 if (read(ps_chan->
l_channel_no, c_temp, l_header_size) != l_header_size) {
683 printf(
"LMD format error: no LMD file: %s\n", c_file);
694 if ((l_is_goosybuf == 0) | (l_size != l_size_head) | (l_swap != l_swap_head)) {
695 printf(
"LMD format error: swap=%d, isLMD=%d, size=%d\n", l_swap, l_is_goosybuf, l_size);
706 if (ps_info != NULL) {
710 if (l_filehead == 1) {
711 if (read(ps_chan->
l_channel_no, c_temp, l_header_size) != l_header_size) {
712 printf(
"LMD format error: no LMD file: %s\n", c_file);
718 if (ps_info != NULL) {
719 if (l_swap_head == 1) {
767 if (*((
INTS4*)(c_temp)) != 1) {
777 ps_chan->
pLmd = NULL;
778 if (*((
INTS4*)(c_temp + 12)) == 0) {
780 ps_chan->
pLmd->
pTCP = &s_tcpcomm_st_evt;
788 printf(
"f_evt_get_open for STREAM: setting timeout=%d n", ps_chan->
l_timeout);
810 if (*((
INTS4*)(c_temp)) != 1) {
818 ps_chan->
pLmd = NULL;
819 if (*((
INTS4*)(c_temp + 12)) == 0) {
821 ps_chan->
pLmd->
pTCP = &s_tcpcomm_st_evt;
853 printf(
"LMD format error: no LMD file: %s\n", pc_server);
859 f_evt_check_buf(c_temp, &l_size_head, &l_is_goosybuf, &l_swap_head, &l_filehead);
860 if (((l_is_goosybuf == 0) & (l_filehead == 0)) | (l_size_head == 0)) {
861 printf(
"LMD format error: swap=%d, header=%d, isLMD=%d, size=%d\n",
871 if (l_filehead == 1) {
877 printf(
"LMD format error: no LMD file: %s\n", pc_server);
888 if ((l_is_goosybuf == 0) | (l_size != l_size_head) | (l_swap != l_swap_head)) {
889 printf(
"LMD format error: swap=%d, isLMD=%d, size=%d\n", l_swap, l_is_goosybuf, l_size);
900 if (ps_info != NULL) {
904 if (l_filehead == 1) {
906 printf(
"LMD format error: no LMD file: %s\n", pc_server);
912 if (ps_info != NULL) {
913 if (l_swap_head == 1) {
939 if (ps_info != NULL) {
947 printf(
"Memory allocation error\n");
952 printf(
"Memory allocation error\n");
995 if (ps_chan->
pLmd != NULL) {
1031 *ppl_buffer = (
INTS4*)pevt;
1080 printf(
"Unsolicited file header found!\n");
1148 printf(
"Memory allocation error\n");
1164 *ppl_goobuf = (
INTS4*)(ps_bufhe_cur);
1191 INTS4 l_close_failure;
1195 if (ps_chan->
pLmd != NULL) {
1203 free(ps_chan->
pLmd);
1204 ps_chan->
pLmd = NULL;
1208 l_close_failure = 0;
1213 l_close_failure = 1;
1226 l_close_failure = 1;
1229 l_close_failure = 1;
1241 l_close_failure = 1;
1244 l_close_failure = 1;
1268 l_close_failure = 1;
1272 if (l_close_failure == 1) {
1322 struct timeb s_timeb;
1325 CHARS c_file[256], *pc_temp;
1329 CHARS c_varstr[128];
1333 ps_chan->
pLmd = NULL;
1334 if (l_stream == 0) {
1349 printf(
"Memory allocation error\n");
1353 size_t len = strlen(pc_file);
1354 if (len <
sizeof(c_file)) {
1355 strncpy(c_file, pc_file, len);
1357 strncpy(c_file, pc_file,
sizeof(c_file) - 1);
1359 if (strlen(c_file) < 5) {
1360 strcat(c_file,
".lmd");
1362 pc_temp = (
CHARS*)&c_file[strlen(c_file) - 4];
1363 if ((strcmp(pc_temp,
".LMD") != 0) && (strcmp(pc_temp,
".lmd") != 0)) {
1364 strcat(c_file,
".lmd");
1370 if ((ps_chan->
l_channel_no =
open(c_file, PUT__CRT_FLAG, DEF_FILE_ACCE)) == -1) {
1378 if (ps_filhe != NULL) {
1379 memcpy(ps_file_head, ps_filhe, ps_chan->
l_buf_size);
1381 memset(ps_file_head,
'\0', ps_chan->
l_buf_size);
1382 sprintf(ps_file_head->
filhe_run,
"Pid %d", getpid());
1394 char* username = getenv(
"USER");
1396 size_t len = strlen(username);
1398 if (len <
sizeof(ps_file_head->
filhe_user)) {
1399 strncpy(ps_file_head->
filhe_user, username, len);
1413 char* temptime = ctime(&s_timet);
1415 if (strlen(temptime) <
sizeof(c_mode)) {
1416 strncpy(c_mode, temptime,
sizeof(c_mode) - 1);
1421 if (strlen(&c_mode[4]) <
sizeof(ps_file_head->
filhe_time)) {
1430 if (l_write_size == -1) {
1464 INTS4 l_evt_buf_posi;
1465 INTS4 l_buf_remain_size;
1466 INTS4 l_write_size, l_temp, l_free;
1472 if (ps_chan->
pLmd != NULL) {
1488 l_buf_remain_size -= l_temp;
1490 if (ps_chan->
l_evt_size > l_buf_remain_size) {
1509 if (ps_bufhe->
l_evt > 0) {
1511 if (l_write_size == -1) {
1526 l_buf_remain_size -= l_temp;
1527 l_buf_remain_size +=
sizeof(
s_evhe);
1529 if (ps_chan->
l_evt_size > l_buf_remain_size) {
1539 while (l_evt_buf_posi < ps_chan->l_evt_size) {
1544 if (l_evt_buf_posi != 0) {
1557 if (l_write_size > (ps_chan->
l_evt_size - l_evt_buf_posi)) {
1558 l_write_size = (ps_chan->
l_evt_size - l_evt_buf_posi);
1563 l_evt_buf_posi += l_write_size;
1579 if (l_evt_buf_posi != l_write_size) {
1587 if (l_evt_buf_posi < ps_chan->l_evt_size) {
1627 if (ps_chan->
pLmd != NULL) {
1635 if (l_write_size == -1) {
1666 INTS4 l_write_size, l_temp, l_temp2;
1671 if (ps_chan->
pLmd != NULL) {
1706 for (l_temp = 0; l_temp < l_write_size; l_temp += ps_chan->
l_buf_size) {
1710 if (l_temp2 == -1) {
1725 if (l_status == -1) {
1762 sprintf(c_line,
"-I-f_evt: no such input file");
1765 sprintf(c_line,
"-I-f_evt: no such tag file");
1768 sprintf(c_line,
"-I-f_evt: no such event tag");
1771 sprintf(c_line,
"-I-f_evt: time out");
1774 sprintf(c_line,
"-I-f_evt: no such server");
1777 sprintf(c_line,
"-I-f_evt: read server error");
1780 sprintf(c_line,
"-I-f_evt: read tag file error");
1783 sprintf(c_line,
"-I-f_evt: write tag file error");
1786 sprintf(c_line,
"-I-f_evt: data format error");
1789 sprintf(c_line,
"-I-f_evt: no more event");
1792 sprintf(c_line,
"-I-f_evt: close server error");
1795 sprintf(c_line,
"-I-f_evt: failure");
1798 sprintf(c_line,
"-I-f_evt: too many channels");
1801 sprintf(c_line,
"-I-f_evt: input file is no LMD file");
1804 sprintf(c_line,
"-I-f_evt: success");
1807 sprintf(c_line,
"-I-f_evt: output file already exist");
1810 sprintf(c_line,
"-I-f_evt: write file error");
1813 sprintf(c_line,
"-I-f_evt: output file too large");
1816 sprintf(c_line,
"-I-f_evt: event can not fit in a stream");
1819 sprintf(c_line,
"-I-f_evt: close output error");
1822 sprintf(c_line,
"-I-f_evt: output failure");
1825 sprintf(c_line,
"-I-f_evt: too many channels");
1828 sprintf(c_line,
"-I-f_evt: unknown message id %d", l_error);
1830 printf(
"%s\n", c_line);
1833 strcpy(pc_dest, c_line);
1839 printf(
"%s\n", c_line);
1842 strcpy(pc_dest, c_line);
1884 }
else if (l_temp == -1) {
1894 }
else if (l_temp == -1) {
1933 if (((
s_bufhe*)(ps_buffer))->l_free[0] != 1) {
2039 if (l_length % 4 == 2) {
2040 ch_temp = *(pc_source + l_length - 2);
2041 *(pc_source + l_length - 2) = *(pc_source + l_length - 1);
2042 *(pc_source + l_length - 1) = ch_temp;
2044 l_length = (l_length / 4) * 4;
2045 for (p_d = pc_source, p_s = (
CHARS*)&l_save; p_d < pc_source + l_length;) {
2046 l_save = *((
INTS4*)p_d);
2048 *(p_d++) = *(--p_s);
2049 *(p_d++) = *(--p_s);
2050 *(p_d++) = *(--p_s);
2051 *(p_d++) = *(--p_s);
2077 if (ps_bufhe->
i_type == 2000) {
2078 ps_filhe = (
s_filhe*)ps_bufhe;
2142 if (l_temp < ps_chan->l_io_buf_size) {
2168 printf(
"**** I-f_evt: Stream server request for disconnect!\n");
2184 printf(
"**** I-f_evt: Transport server request for disconnect!\n");
2203 if (l_temp < ps_chan->l_io_buf_size) {
2243 *pl_is_goosybuf = 0;
2248 if ((((
s_filhe*)(pc_head))->filhe_subtype == 1) && (((
s_filhe*)(pc_head))->filhe_type == 2000)) {
2250 *pl_is_goosybuf = 0;
2252 l_size = ((
s_bufhe*)(pc_head))->l_dlen * 2;
2253 if (l_size % 512 > 0) {
2256 if ((l_size >> 24) > 0) {
2264 if ((((
s_filhe*)(pc_head))->filhe_subtype == 1) && (((
s_filhe*)(pc_head))->filhe_type == 2000)) {
2266 *pl_is_goosybuf = 0;
2268 l_size = ((
s_bufhe*)(pc_head))->l_dlen * 2;
2269 if (l_size % 512 > 0) {
2272 if ((l_size >> 24) > 0) {
2281 l_size = ((
s_bufhe*)(pc_head))->l_dlen * 2;
2282 if (l_size % 512 > 0) {
2285 if ((((l_size >> 24) == 0) && (l_size > 0)) && (((
s_bufhe*)(pc_head))->h_begin < 2)
2286 && (((
s_bufhe*)(pc_head))->h_begin >= 0) && (((
s_bufhe*)(pc_head))->h_end < 2)
2287 && (((
s_bufhe*)(pc_head))->h_end >= 0) &&
2289 ((((
s_bufhe*)(pc_head))->i_used > 0) || (((
s_bufhe*)(pc_head))->l_free[2] > 0)) &&
2291 ((((
s_bufhe*)(pc_head))->l_free[0] == 1) || (((
s_bufhe*)(pc_head))->l_free[0] == 0) ||
2293 (((
s_bufhe*)(pc_head))->l_free[0] == 256 * 256 * 256))) {
2295 *pl_is_goosybuf = 1;
2301 if ((((l_size >> 24) == 0) && (l_size > 0)) && (((
s_bufhe*)(pc_head))->l_dlen > 0)
2302 && (((
s_bufhe*)(pc_head))->h_begin < 2) && (((
s_bufhe*)(pc_head))->h_begin >= 0)
2303 && (((
s_bufhe*)(pc_head))->h_end < 2) && (((
s_bufhe*)(pc_head))->h_end >= 0) &&
2305 ((((
s_bufhe*)(pc_head))->i_used > 0) || (((
s_bufhe*)(pc_head))->l_free[2] > 0)) &&
2307 ((((
s_bufhe*)(pc_head))->l_free[0] == 1) || (((
s_bufhe*)(pc_head))->l_free[0] == 0) ||
2309 (((
s_bufhe*)(pc_head))->l_free[0] == 256 * 256 * 256))) {
2311 *pl_is_goosybuf = 1;
2332 struct timeb s_timeb;
2405 INTS4 ii, l_take_it, l_temp, l_chan, l_out, l_file_pos = 0, l_bufnr = 0, l_events = 0;
2406 INTS4 l_firste, *pl, l_len, l_last = -1, l_lin = 0, l_fragsize;
2407 INTS4 l_swap, l_swap_head, l_is_goosybuf, l_filehead = 0, l_size, l_size_head, l_dummy, l_evsize,
2411 CHARS * pc_evt_buf = NULL;
2415 memset(&s_taghe, 0,
sizeof(s_taghe));
2420 printf(
"LMD file %s, TAG file %s\n", pc_lmd, pc_tag);
2422 if ((l_chan =
open(pc_lmd, GET__OPEN_FLAG)) == -1) {
2431 f_evt_check_buf(c_temp, &l_size_head, &l_is_goosybuf, &l_swap_head, &l_filehead);
2432 if (((l_is_goosybuf == 0) & (l_filehead == 0)) | (l_size_head == 0)) {
2433 printf(
"LMD format error: swap=%d, header=%d, isLMD=%d, size=%d\n",
2442 if (l_filehead == 1) {
2443 val = lseek(l_chan, 0, SEEK_SET);
2448 if (read(l_chan, c_temp, l_size_head) != l_size_head) {
2457 if ((l_is_goosybuf == 0) | (l_size != l_size_head) | (l_swap != l_swap_head)) {
2458 printf(
"LMD format error: swap=%d, isLMD=%d, size=%d\n", l_swap, l_is_goosybuf, l_size);
2468 val = lseek(l_chan, 0, SEEK_SET);
2474 printf(
"Buffer swap %d, File header %d, LMD buffer %d, size %d[b]\n", l_swap, l_filehead, l_is_goosybuf, l_size);
2477 if (l_filehead == 1) {
2478 if (read(l_chan, c_temp, l_size) != l_size) {
2482 l_file_pos += l_size;
2487 if ((l_out =
open(pc_tag, PUT__CRT_FLAG, DEF_FILE_ACCE)) == -1) {
2491 ssize_t wcount = write(l_out, (
CHARS*)&s_taghe,
sizeof(s_taghe));
2492 if (wcount !=
sizeof(s_taghe)) {
2501 while (read(l_chan, c_temp, l_size) == l_size) {
2502 l_file_pos = l_bufnr * l_size;
2512 ps_ve10_1 = (
s_ve10_1*)(ps_bufhe + 1);
2513 pl = (
INTS4*)ps_ve10_1;
2514 l_file_pos +=
sizeof(
s_bufhe);
2516 if (ps_bufhe->
h_end) {
2517 l_len = (*pl >> 1) + 2;
2518 l_file_pos += (l_len << 2);
2519 ps_ve10_1 = (
s_ve10_1*)(pl + l_len);
2520 pl = (
INTS4*)ps_ve10_1;
2524 for (ii = 1; ii < ps_bufhe->
l_evt; ii++) {
2526 if (e_filter != NULL) {
2527 l_take_it = (*e_filter)(ps_ve10_1);
2531 l_len = (*pl >> 1) + 2;
2536 if (ps_ve10_1->
l_count != (l_last + 1)) {
2539 l_firste = ps_ve10_1->
l_count;
2544 if (write(l_out, (
CHARS*)&s_tag,
sizeof(s_tag)) !=
sizeof(s_tag)) {
2550 l_file_pos += (l_len << 2);
2551 ps_ve10_1 = (
s_ve10_1*)(pl + l_len);
2552 pl = (
INTS4*)ps_ve10_1;
2555 if (ps_bufhe->
l_evt > 0) {
2556 if (ps_ve10_1->
l_dlen < 4)
2557 printf(
"Buffer %d Event fragment %10d dlen %d ts %d %d trigger %d\n",
2567 if (e_filter != NULL) {
2569 l_evsize = ps_bufhe->
l_free[1] + 4;
2570 if (l_evt_buf_size < l_evsize * 2) {
2571 if (pc_evt_buf != NULL) {
2574 l_evt_buf_size = l_evsize * 2;
2575 pc_evt_buf = (
CHARS*)malloc(l_evt_buf_size);
2577 if (NULL == pc_evt_buf) {
2578 l_evt_buf_size = l_evsize * 2;
2579 pc_evt_buf = (
CHARS*)malloc(l_evt_buf_size);
2582 ps = (
INTU4*)ps_ve10_1;
2583 pd = (
INTU4*)pc_evt_buf;
2584 l_fragsize = ps_ve10_1->
l_dlen + 4;
2585 for (ii = 0; ii < l_fragsize / 2; ii++) {
2589 while (l_fragsize < l_evsize) {
2590 if (read(l_chan, c_temp, l_size) != l_size) {
2597 ps = (
INTU4*)(ps_bufhe + 1);
2598 l_temp = (
INTS4)*ps;
2600 for (ii = 0; ii < l_temp / 2; ii++) {
2603 l_fragsize += l_temp;
2605 if (l_fragsize < l_evsize) {
2609 ps_ve10_1->
l_dlen = l_evsize - 4;
2612 val = lseek(l_chan, -l_size, SEEK_CUR);
2628 if (e_filter != NULL) {
2629 l_take_it = (*e_filter)(ps_ve10_1);
2635 if (ps_ve10_1->
l_count != (l_last + 1)) {
2638 l_firste = ps_ve10_1->
l_count;
2643 if (write(l_out, (
CHARS*)&s_tag,
sizeof(s_tag)) !=
sizeof(s_tag)) {
2653 val = lseek(l_out, 0, SEEK_SET);
2664 s_taghe.
l_filesize =
sizeof(s_tag) * l_events;
2668 if (write(l_out, (
CHARS*)&s_taghe,
sizeof(s_taghe)) !=
sizeof(s_taghe)) {
2675 printf(
"Buffers %6d, of size %d, Events %10d, first %d, last %d ",
2684 printf(
"not linear\n");
2725 printf(
"LMD file %s, TAG file %s\n", pc_lmd, pc_tag);
2729 if ((pc_tag == 0) || (*pc_tag == 0)) {
2740 *ps_head = (
CHARS*)ps_bufhe;
2742 printf(
"Error opening input file %s\n", pc_lmd);
2771 printf(
"Buffers %6d, of size %d, Events %10d, first %d, last %d",
2778 printf(
" linear\n");
2780 printf(
" not linear\n");
2799 if (ps_chan->
ps_tag != NULL) {
2818 if (ps_chan->
ps_tag != NULL) {
2829 if (ps_bufhe->
l_free[0] != 1) {
2838 if (ps_head != NULL) {
2839 if (ps_bufhe->
i_type == 2000) {
2840 *ps_head = (
CHARS*)ps_bufhe;
2875 INTS4 ii = 0, *pl = NULL, kk;
2879 for (kk = 0; kk <= l_skip; kk++) {
2891 if (pl_event != NULL) {
2925 INTS4 ii, kk, l_evt, l_off, l_typ, l_val, l_evsize, l_fragsize;
2926 INTS4 la_head[2], *pl;
2945 for (kk = 0; kk < l_val; kk++) {
2957 while (ps_ve10_1->
l_count != l_val) {
2963 *pl_event = (
INTS4*)ps_ve10_1;
2982 printf(
"Event index %d not found\n", l_val);
2988 ps_tag = (
s_tag*)&s_tag_l;
3002 ps_tag = ps_chan->
ps_tag;
3004 if (ps_tag->
l_event == l_val) {
3009 if (ps_tag->
l_event != l_val) {
3010 printf(
"Event number %d not found\n", l_val);
3056 l_evsize = ps_bufhe->
l_free[1] + 4;
3081 l_fragsize += ps_ve10_1->
l_dlen + 4;
3082 pc += ps_ve10_1->
l_dlen * 2;
3083 ps_ve10_1->
l_dlen = l_evsize - 4;
3085 while (l_fragsize < l_evsize) {
3097 if (read(ps_chan->
l_channel_no, pc, la_head[0] * 2) != la_head[0] * 2) {
3100 pc += la_head[0] * 2;
3101 l_fragsize += la_head[0];
3110 *pl_event = (
INTS4*)ps_ve10_1;
3137 if (ps_chan->
ps_tag != NULL) {
INTS4 f_evt_rev_port(INTS4 l_port)
#define PUTEVT__CLOSE_ERR
INTS4 f_evt_get_subevent(s_ve10_1 *ps_ve10_1, INTS4 l_subevent, INTS4 **pl_se, INTS4 **pl_d, INTS4 *pl_lwords)
INTS4 f_stc_close(struct s_tcpcomm *ps_tcp)
for(Int_t i=0;i< 100;i++)
INTS4 f_evt_type(s_bufhe *ps_bufhe, s_evhe *ps_evhe, INTS4 l_subid, INTS4 l_long, INTS4 l_hex, INTS4 l_data)
INTS4 f_evt_tag_filter(s_ve10_1 *ps_ve10_1)
INTS4 f_evt_get_close(s_evt_channel *ps_chan)
INTS4 f_evt_get_open(INTS4 l_mode, CHARS *pc_server, s_evt_channel *ps_chan, CHARS **ps_info, INTS4 l_sample, INTS4 l_param)
INTS4 f_evt_get_buffer(s_evt_channel *ps_chan, INTS4 *ps_buffer)
#define LMD__NO_OVERWRITE
INTS4 f_evt_timeout(s_evt_channel *ps_chan, INTS4 l_sec)
#define GETEVT__NOCHANNEL
INTS4 f_evt_put_event(s_evt_channel *ps_chan, INTS4 *pl_evt_buf)
s_evt_channel * f_evt_control()
#define GETEVT__NOLMDFILE
uint32_t fLmdGetMbsEvent(sLmdControl *pLmdControl, sMbsHeader **event)
parOut open("mq_ex_params.root")
INTS4 f_evt_error(INTS4 l_error, CHARS *pc_dest, INTS4 l_out)
uint32_t fLmdGetElement(sLmdControl *pLmdControl, uint32_t iEvent, sMbsHeader **event)
INTS4 f_stc_discclient(INTS4 i_channel)
CHARS * f_evt_get_buffer_ptr(s_evt_channel *ps_chan)
#define GETEVT__NOTAGFILE
uint32_t fLmdInitMbs(sLmdControl *pLmdControl, char *Nodename, uint32_t iMaxBytes, uint32_t iBuffers, uint32_t iStreams, uint32_t iPort, uint32_t iTimeout)
uint32_t fLmdPutClose(sLmdControl *pLmdControl)
uint32_t fLmdGetClose(sLmdControl *pLmdControl)
INTS4 f_stc_connectserver(CHARS *c_node, INTS4 l_port, INTS4 *pi_channel, struct s_tcpcomm *ps_client)
struct cv_string s_strings[30]
INTS4 f_evt_get_newbuf(s_evt_channel *)
INTS4 f_evt_check_buf(CHARS *, INTS4 *, INTS4 *, INTS4 *, INTS4 *)
INTS4 f_evt_get_tagnext(s_evt_channel *ps_chan, INTS4 l_skip, INTS4 **pl_event)
INTS4 f_evt_ini_bufhe(s_evt_channel *ps_chan)
#define PUTEVT__TOO_SMALLS
uint32_t fLmdGetOpen(sLmdControl *pLmdControl, char *Filename, sMbsFileHeader *pBuffHead, uint32_t iBytes, uint32_t iUseOffset)
INTS4 f_evt_cre_tagfile(CHARS *pc_lmd, CHARS *pc_tag, INTS4(*e_filter)())
#define PUTEVT__FILE_EXIST
INTS4 f_evt_put_buffer(s_evt_channel *ps_chan, s_bufhe *ps_bufhe)
uint32_t fLmdCloseMbs(sLmdControl *pLmdControl)
INTS4 f_evt_skip_buffer(s_evt_channel *ps_chan, INTS4 l_buffer)
#define PUTEVT__NOCHANNEL
INTS4 f_evt_get_tagopen(s_evt_channel *ps_chan, CHARS *pc_tag, CHARS *pc_lmd, CHARS **ps_head, INTS4 l_prihe)
INTS4 f_ut_utime(INTS4, INTS4, CHARS *)
INTS4 f_evt_get_tagevent(s_evt_channel *ps_chan, INTS4 l_value, INTS4 l_type, INTS4 **pl_event)
INTS4 f_stc_write(INTS1 *p_buffer, INTS4 i_buflen, INTS4 i_channel)
sLmdControl * fLmdAllocateControl()
INTS4 f_evt_put_close(s_evt_channel *ps_chan)
INTS4 f_evt_swap(CHARS *pc_source, INTS4 l_length)
#define PORT__STREAM_SERV
uint32_t fLmdPutElement(sLmdControl *pLmdControl, sMbsHeader *pHeader)
#define LMD__TYPE_FILE_HEADER_101_1
uint32_t fLmdPutOpen(sLmdControl *pLmdControl, char *Filename, sMbsFileHeader *pBuffHead, uint32_t iBytes, uint32_t iOver, uint32_t iUseOffset, uint32_t iLargeFile)
INTS4 f_stc_read(INTS1 *p_buffer, INTS4 i_buflen, INTS4 i_channel, INTS4 i_timeout)
INTS4 f_evt_put_open(CHARS *pc_file, INTS4 l_size, INTS4 l_stream, INTS4 l_type, INTS4 l_subtype, s_evt_channel *ps_chan, CHARS *ps_filhe)
INTS4 f_evt_get_tagclose(s_evt_channel *ps_chan)
INTS4 f_evt_get_event(s_evt_channel *ps_chan, INTS4 **ppl_buffer, INTS4 **ppl_goobuf)
uint32_t fLmdPutBuffer(sLmdControl *pLmdControl, sMbsHeader *pHeader, uint32_t Items)
INTS4 f_evt_swap_filhe(s_bufhe *)
#define GETEVT__CLOSE_ERR