MIDAS
Loading...
Searching...
No Matches
mdsupport.cxx
Go to the documentation of this file.
1/* Copyright (c) 1993 TRIUMF Data Acquistion Group
2 * Please leave this header in any reproduction of that distribution
3 *
4 * TRIUMF Data Acquisition Group, 4004 Wesbrook Mall, Vancouver, B.C. V6T 2A3
5 * Email: online@triumf.ca Tel: (604) 222-1047 Fax: (604) 222-1074
6 * amaudruz@triumf.ca Local: 6234
7 * ---------------------------------------------------------------------------
8 * $Id$
9 *
10 * Description : mdsupport.c :
11 * contains support for the mdump and lazylogger data support.
12 * related to event writing, reading, display
13 */
14
26#ifndef DOXYGEN_SHOULD_SKIP_THIS
27
28
29/* include files */
30/* moved #define HAVE_FTPLIB into makefile (!vxWorks) */
31
32#define TRACE
33
34#include "midas.h"
35#include "msystem.h"
36#include "mstrlcpy.h"
37
38#ifdef HAVE_FTPLIB
39
40#include "ftplib.h"
41
42FTP_CON *ftp_con;
43#endif
44
45#include "zlib.h"
46
47#include "mdsupport.h"
48
50
52
53void md_bank_event_display(const void *pevent, INT data_fmt, INT dsp_fmt, INT dsp_mode, const char *bn);
54
55void md_raw_event_display(const void *pevent, INT data_fmt, INT dsp_fmt);
56
58
59INT midas_event_get(void **pevent, DWORD *size);
60
62
64
66
67template<typename T>
69
70struct stat *filestat;
71char *ptopmrd;
72
74
75/* General MIDAS struct for util */
76typedef struct {
77 INT handle; /* file handle */
78 char name[128]; /* Device name (/dev/nrmt0h) */
79
80 char *pmp; /* ptr to a physical TAPE_BUFFER_SIZE block */
81 EVENT_HEADER *pmh; /* ptr to Midas event (midas bank_header) */
82 EVENT_HEADER *pme; /* ptr to Midas content (event+1) (midas bank_header) */
83 char *pmrd; /* current point in the phyical record */
84
85 DWORD evtn; /* current event number */
86 DWORD serial; /* serial event number */
87 DWORD evtlen; /* current event length (-1 if not available) */
88 DWORD size; /* midas max_evt_size */
89 DWORD recn; /* current physical record number */
90 INT fmt; /* contains FORMAT type */
91 INT type; /* Device type (tape, disk, ...) */
92 DWORD runn; /* run number */
94} MY;
95
98#endif /* DOXYGEN_SHOULD_SKIP_THIS */
99
100#ifdef HAVE_FTPLIB
101
102/*------------------------------------------------------------------*/
104 INT status;
105 short port = 0;
107 user[256], pass[256], directory[256], file_name[256], file_mode[256];
108
109 /*
110 destination should have the form:
111 host, port, user, password, directory, run%05d.mid, file_mode, command, ...
112 */
113
114 /* break destination in components */
115 token = strtok(destination, ",");
116 if (token)
117 strcpy(host_name, token);
118
119 token = strtok(NULL, ",");
120 if (token)
121 port = atoi(token);
122
123 token = strtok(NULL, ",");
124 if (token)
125 strcpy(user, token);
126
127 token = strtok(NULL, ",");
128 if (token)
129 strcpy(pass, token);
130
131 token = strtok(NULL, ",");
132 if (token)
133 strcpy(directory, token);
134
135 token = strtok(NULL, ",");
136 if (token)
137 strcpy(file_name, token);
138
139 token = strtok(NULL, ",");
140 file_mode[0] = 0;
141 if (token)
142 strcpy(file_mode, token);
143
144 status = ftp_login(con, host_name, port, user, pass, "");
145 if (status >= 0)
146 return status;
147
148 status = ftp_chdir(*con, directory);
149 if (status >= 0) {
150 /* directory does not exist -> create it */
151 ftp_mkdir(*con, directory);
152 status = ftp_chdir(*con, directory);
153 }
154 if (status >= 0)
155 return status;
157 if (status >= 0)
158 return status;
159
160 if (file_mode[0]) {
161 status = ftp_command(*con, "umask %s", file_mode, 200, 250, EOF);
162 if (status >= 0)
163 return status;
164 }
165
166 while (token) {
167 token = strtok(NULL, ",");
168 if (token) {
169 status = ftp_command(*con, token, NULL, 200, 250, EOF);
170 if (status >= 0)
171 return status;
172 }
173 }
174
175 if (ftp_open_write(*con, file_name) >= 0)
176 return (*con)->err_no;
177
178 return SS_SUCCESS;
179}
180
181#endif // HAVE_FTPLIB
182
183/*------------------------------------------------------------------*/
185/********************************************************************\
186Routine: external md_any_file_ropen
187Purpose: Open data file for replay for the given data format.
188It uses the local "my" structure.
189Input:
190INT data_fmt : YBOS or MIDAS
191char * infile : Data file name
192Output:
193none
194Function value:
195status : from lower function
196\********************************************************************/
197{
198 /* fill up record with file name */
199 strcpy(my.name, infile);
200
201 /* find out what dev it is ? : check on /dev */
202 my.zipfile = FALSE;
203 if ((strncmp(my.name, "/dev", 4) == 0) || (strncmp(my.name, "\\\\.\\", 4) == 0)) {
204 /* tape device */
206 } else {
207 /* disk device */
209 if (strncmp(infile + strlen(infile) - 3, ".gz", 3) == 0) {
210 // FALSE will for now prevent the mdump to see inside the .gz
211 // But lazylogger will NOT unzip during copy!
212 if (openzip == 0) my.zipfile = FALSE; // ignore zip, copy blindly blocks
213 else my.zipfile = TRUE; // Open Zip file
214 }
215 }
216
217 /* open file */
218 if (!my.zipfile) {
219 if (my.type == LOG_TYPE_TAPE) {
221 } else if ((my.handle = open(my.name, O_RDONLY | O_BINARY | O_LARGEFILE, 0644)) == -1) {
222 printf("dev name :%s Handle:%d \n", my.name, my.handle);
223 return (SS_FILE_ERROR);
224 }
225 } else {
226 if (my.type == LOG_TYPE_TAPE) {
227 printf(" Zip on tape not yet supported \n");
228 return (SS_FILE_ERROR);
229 }
230 filegz = gzopen(my.name, "rb");
231 my.handle = 0;
232 if (filegz == NULL) {
233 printf("dev name :%s gzopen error:%d \n", my.name, my.handle);
234 return (SS_FILE_ERROR);
235 }
236 }
237
238 if (data_fmt == FORMAT_MIDAS) {
241 my.pmp = (char *) malloc(my.size);
242 if (my.pmp == NULL)
243 return SS_NO_MEMORY;
244 my.pme = (EVENT_HEADER *) my.pmp;
245
246 /* allocate memory for one full event */
247 if (my.pmrd != NULL)
248 free(my.pmrd);
249 my.pmrd = (char *) malloc(5 * max_event_size); /* in bytes */
250 ptopmrd = my.pmrd;
251 if (my.pmrd == NULL)
252 return SS_NO_MEMORY;
253 memset((char *) my.pmrd, -1, 5 * max_event_size);
254 my.pmh = (EVENT_HEADER *) my.pmrd;
255 } else {
256 assert(!"unsupported data_fmt, sorry!");
257 }
258
259 /* initialize pertinent variables */
260 my.recn = -1;
261 my.evtn = 0;
262 return (MD_SUCCESS);
263}
264
265/*------------------------------------------------------------------*/
267/********************************************************************
268Routine: external md_any_file_rclose
269Purpose: Close a data file used for replay for the given data format
270Input:
271INT data_fmt : YBOS or MIDAS
272Output:
273none
274Function value:
275status : from lower function
276*******************************************************************/
277{
278 switch (my.type) {
279 case LOG_TYPE_TAPE:
280 case LOG_TYPE_DISK:
281 /* close file */
282 if (my.zipfile) {
284 } else {
285 if (my.handle != 0)
286 close(my.handle);
287 }
288 break;
289 }
290 if (ptopmrd != NULL)
291 free(ptopmrd);
292 if (my.pmp != NULL)
293 free(my.pmp);
294 my.pmp = NULL;
295 my.pmh = NULL;
296 ptopmrd = NULL;
297 my.pmrd = NULL; /* ptopmrd and my.pmrd point to the same place. K.O. 25-FEB-2005 */
298 return (MD_SUCCESS);
299}
300
301/*------------------------------------------------------------------*/
303/********************************************************************
304Routine: external md_file_wopen
305Purpose: Open a data file for the given data format
306Input:
307INT type : Tape or Disk
308INT data_fmt : YBOS or MIDAS
309char * filename : file to open
310Output:
311INT * hDev : file handle
312Function value:
313status : from lower function
314*******************************************************************/
315{
316 INT status = 0;
317
318 if (type == LOG_TYPE_DISK)
319 /* takes care of TapeLX/NT under ss_tape_open , DiskLX/NT here */
320 {
321 if (data_fmt == FORMAT_MIDAS) {
322#ifdef OS_WINNT
323 *hDev =
327#else
328 *hDev = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY | O_LARGEFILE, 0644);
329#endif
331 } else {
332 assert(!"unsupported data_fmt, sorry!");
333 }
334 } else if (type == LOG_TYPE_TAPE) {
335 if (data_fmt == FORMAT_MIDAS) {
337 } else {
338 assert(!"unsupported data_fmt, sorry!");
339 }
340 } else if (type == LOG_TYPE_FTP) {
341#ifdef HAVE_FTPLIB
342 status = mftp_open(filename, (FTP_CON **) &ftp_con);
343 if (status != SS_SUCCESS) {
344 *hDev = 0;
345 return status;
346 } else
347 *hDev = 1;
348#else
349 cm_msg(MERROR, "mdsupport", "FTP support not included");
350 return SS_FILE_ERROR;
351#endif
352 }
353
354 return status;
355}
356
357/*------------------------------------------------------------------*/
359/********************************************************************
360Routine: external md_file_wclose
361Purpose: Close a data file used for replay for the given data format
362Input:
363INT data_fmt : YBOS or MIDAS
364Output:
365none
366Function value:
367status : from lower function
368*******************************************************************/
369{
370 INT status;
371
373 switch (type) {
374 case LOG_TYPE_TAPE:
375 /* writing EOF mark on tape Fonly */
376 status = ss_tape_write_eof(handle);
377 ss_tape_close(handle);
378 break;
379 case LOG_TYPE_DISK:
380 /* close file */
381 if (handle != 0)
382#ifdef OS_WINNT
383 CloseHandle((HANDLE) handle);
384#else
385 close(handle);
386#endif
387 break;
388 case LOG_TYPE_FTP:
389#ifdef HAVE_FTPLIB
390 {
391 char *p, filename[256];
392 int i;
393
394 ftp_close(ftp_con);
395
396 /*
397 destination should have the form:
398 host, port, user, password, directory, run%05d.mid, file_mode, command, ...
399 */
400 p = destination;
401 for (i = 0; i < 5 && p != NULL; i++) {
402 p = strchr(p, ',');
403 if (*p == ',')
404 p++;
405 }
406 if (p != NULL) {
407 mstrlcpy(filename, p, sizeof(filename));
408 if (strchr(filename, ','))
409 *strchr(filename, ',') = 0;
410 } else
411 mstrlcpy(filename, destination, sizeof(filename));
412
413 /* if filename starts with a '.' rename it */
414 if (filename[0] == '.')
415 ftp_move(ftp_con, filename, filename + 1);
416
417 ftp_bye(ftp_con);
418 }
419#endif
420 break;
421 }
422 if (status != SS_SUCCESS)
423 return status;
424 return (MD_SUCCESS);
425}
426
427/*------------------------------------------------------------------*/
429/********************************************************************\
430Routine: md_dev_os_read
431Purpose: read nbytes from the type device.
432Input:
433INT handle file handler
434INT type Type of device (TAPE or DISK)
435void * prec pointer to the record
436DWORD nbytes # of bytes to read
437Output:
438DWORD *readn # of bytes read
439Function value:
440MD_DONE No more record to read
441MD_SUCCESS Ok
442\********************************************************************/
443{
444 INT status;
445 if (type == LOG_TYPE_DISK)
446 /* --------- DISK ---------- */
447 {
448 *readn = read(handle, prec, nbytes);
449 if (*readn <= 0)
451 else
453 return status;
454 }
455 /* --------- TAPE ---------- */
456#ifdef OS_UNIX
457 else if (type == LOG_TYPE_TAPE) {
458 *readn = read(handle, prec, nbytes);
459 if (*readn <= 0)
461 else
463 return status;
464 }
465#endif
466
467#ifdef OS_WINNT
468 else if (type == LOG_TYPE_TAPE) {
469 if (!ReadFile((HANDLE) handle, prec, nbytes, readn, NULL))
471 else
475
476 return status;
477 }
478#endif /* OS_WINNT */
479 else
480 return SS_SUCCESS;
481}
482
483/*------------------------------------------------------------------*/
485/********************************************************************\
486Routine: md_dev_os_write
487Purpose: write nbytes to the device.
488Input:
489INT handle file handler
490INT type Type of device (TAPE or DISK)
491void * prec pointer to the record
492DWORD nbytes record length to be written
493Output:
494DWORD *written # of written bytes
495Function value:
496INT status # of written bytes or ERROR
497SS_FILE_ERROR write error
498SS_SUCCESS Ok
499\********************************************************************/
500{
501 INT status;
502 if (type == LOG_TYPE_DISK)
503#ifdef OS_WINNT
504 { /* --------- DISK ---------- */
505 WriteFile((HANDLE) handle, (char *) prec, nbytes, written, NULL);
507 return status; /* return for DISK */
508 }
509#else
510 { /* --------- DISK ---------- */
511 status = *written = write(handle, (char *) prec, nbytes) == (INT) nbytes ? SS_SUCCESS : SS_FILE_ERROR;
512 return status; /* return for DISK */
513 }
514#endif
515 else if (type == LOG_TYPE_TAPE) { /* --------- TAPE ---------- */
516#ifdef OS_UNIX
517 do {
518 status = write(handle, (char *) prec, nbytes);
519 } while (status == -1 && errno == EINTR);
520 *written = status;
521 if (*written != nbytes) {
522 cm_msg(MERROR, "any_dev_os_write", "write() status %d, errno %d (%s)", status, errno, strerror(errno));
523 if (errno == EIO)
524 return SS_IO_ERROR;
525 if (errno == ENOSPC)
526 return SS_NO_SPACE;
527 else
528 return SS_TAPE_ERROR;
529 }
530#endif /* OS_UNIX */
531
532#ifdef OS_WINNT
533 WriteFile((HANDLE) handle, (char *) prec, nbytes, written, NULL);
534 if (*written != nbytes) {
536 cm_msg(MERROR, "any_dev_os_write", "error %d", status);
537 return SS_IO_ERROR;
538 }
539 return SS_SUCCESS; /* return for TAPE */
540#endif /* OS_WINNT */
541 } else if (type == LOG_TYPE_FTP)
542#ifdef HAVE_FTPLIB
543 {
544 *written = status = ftp_send(ftp_con->data, (char *) prec,
545 (int) nbytes) == (int) nbytes ? SS_SUCCESS : SS_FILE_ERROR;
546 return status;
547 }
548#else
549 {
550 cm_msg(MERROR, "mdsupport", "FTP support not included");
551 return SS_IO_ERROR;
552 }
553#endif
554 return SS_SUCCESS;
555}
556
557/*------------------------------------------------------------------*/
559/********************************************************************\
560Routine: external md_physrec_get
561Purpose: Retrieve a physical record for the given data format
562Input:
563INT data_fmt : YBOS or MIDAS
564Output:
565void ** precord pointer to the record
566DWORD * readn record length in bytes
567Function value:
568status : from lower function
569\********************************************************************/
570{
571 *precord = my.pmp;
572 if (data_fmt == FORMAT_MIDAS) {
574 } else
575 return MD_UNKNOWN_FORMAT;
576}
577
578/*------------------------------------------------------------------*/
580/********************************************************************\
581Routine: external md_log_write
582Purpose: Write a physical record to the out device.
583
584Input:
585void handle : file handle
586INT data_fmt : YBOS or MIDAS
587INT type : Tape or disk
588void *prec : record pointer
589DWORD nbytes : record length to be written
590Output:
591none
592Function value:
593status : from lower function SS_SUCCESS, SS_FILE_ERROR
594\********************************************************************/
595{
596 INT status;
598
599 status = data_fmt; /* avoid compiler warning */
600 /* write record */
602 return status;
603}
604
605#if 0 // OBSOLETE, NOT USED ANYMORE
606/*------------------------------------------------------------------*/
608/********************************************************************\
609Routine: external md_physrec_skip
610Purpose: Skip physical record until block = bl for the given data
611format, Under midas the skip is an event as no physical
612record is present under that format,
613Input:
614INT data_fmt : YBOS or MIDAS
615INT bl: block number (-1==all, 0 = first block)
616in case of MIDAS the bl represent an event
617Output:
618none
619Function value:
620status : from lower function
621\********************************************************************/
622{
623 if (data_fmt == FORMAT_MIDAS) {
625 return MD_SUCCESS;
626 } else
627 return MD_UNKNOWN_FORMAT;
628}
629#endif
630
631#if 0 // NOT USED
632/*------------------------------------------------------------------*/
634/********************************************************************\
635Routine: midas_event_skip
636Purpose: skip event on a MIDAS file.
637Input:
638INT evtn event record number. (start at 0)
639if evt = -1 : skip skiping
640Output:
641none
642Function value:
643MD_SUCCESS Ok
644\********************************************************************/
645{
646 void *pevent;
647 DWORD size;
648
649 size = 0;
650 if (evtn == -1) {
651 /* if(midas_event_get(&pevent, &size) == MD_SUCCESS) */
652 return MD_SUCCESS;
653 }
654 while (midas_event_get(&pevent, &size) == MD_SUCCESS) {
655 if ((INT) my.evtn < evtn) {
656 printf("Skipping event_# ... ");
657 printf("%d \r", my.evtn);
658 fflush(stdout);
659 } else {
660 printf("\n");
661 return MD_SUCCESS;
662 }
663 }
664 return MD_DONE;
665}
666#endif
667
668/*------------------------------------------------------------------*/
670/********************************************************************\
671Routine: md_all_info_display
672Purpose: display on screen all the info about "what".
673Input:
674INT what type of display.
675Output:
676none
677Function value:
678INT MD_SUCCESS
679MD_DONE
680\********************************************************************/
681{
682 if (my.fmt == FORMAT_MIDAS) {
683 DWORD mbn, run, ser;
684 WORD id, msk;
685 mbn = my.evtn;
686 run = my.runn;
687 id = my.pmh->event_id;
688 msk = my.pmh->trigger_mask;
690 switch (what) {
691 case D_RECORD:
692 case D_HEADER:
693 printf(">>> No physical record structure for Midas format <<<\n");
694 return MD_DONE;
695 break;
696 case D_EVTLEN:
697 printf("Evt#%d- ", my.evtn);
698 printf("%irun 0x%4.4uxid 0x%4.4uxmsk %5dmevt#", run, id, msk, mbn);
699 printf("%5del/x%x %5dserial\n", my.evtlen, my.evtlen, ser);
700 break;
701 }
702 } else {
703 assert(!"unsupported data format, sorry!");
704 }
705
706 return MD_SUCCESS;
707}
708
709/*------------------------------------------------------------------*/
711/********************************************************************\
712Routine: external md_event_swap
713Purpose: Swap an event from the given data format.
714Input:
715INT data_fmt : YBOS or MIDAS
716void * pevent : pointer to either plrl or pheader
717Output:
718none
719Function value:
720status : from the lower function
721\********************************************************************/
722{
723 INT status;
725
726 if (data_fmt == FORMAT_MIDAS) {
727 if ((((EVENT_HEADER *) pevent)->event_id == EVENTID_BOR) ||
728 (((EVENT_HEADER *) pevent)->event_id == EVENTID_EOR) ||
729 (((EVENT_HEADER *) pevent)->event_id == EVENTID_MESSAGE))
730 return SS_SUCCESS;
731 pbh = (BANK_HEADER *) (((EVENT_HEADER *) pevent) + 1);
734 } else {
735 return MD_UNKNOWN_FORMAT;
736 }
737}
738
739/*------------------------------------------------------------------*/
740void md_event_display(const void *pevent, INT data_fmt, INT dsp_mode, INT dsp_fmt, const char *bn)
741/********************************************************************\
742Routine: external md_event_display
743Purpose: display on screen the event data in either Decimal or Hexadecimal.
744Input:
745void * pevent pointer to either plrl or pheader.
746INT data_fmt uses the YBOS or MIDAS event structure
747INT dsp_mode display in RAW or Bank mode
748INT dsp_fmt display format (DSP_DEC/HEX)
749Output:
750none
751Function value:
752none
753\********************************************************************/
754{
755 if (dsp_mode == DSP_RAW)
757 else if ((dsp_mode == DSP_BANK) || (dsp_mode == DSP_BANK_SINGLE))
759 else
760 printf("mdsupport- Unknown format:%i\n", dsp_fmt);
761 return;
762}
763
764/*------------------------------------------------------------------*/
765void md_raw_event_display(const void *pevent, INT data_fmt, INT dsp_fmt)
766/********************************************************************\
767Routine: md_raw_event_display
768Purpose: display on screen the RAW data of MIDAS format.
769Input:
770DWORD * pevent points to either plrl or pheader
771INT data_fmt uses the YBOS or MIDAS event structure
772INT dsp_fmt display format (DSP_DEC/HEX)
773Output:
774none
775Function value:
776none
777\********************************************************************/
778{
779 DWORD lrl = 0, *pevt = NULL, j, i, total = 0;
780
781 if (data_fmt == FORMAT_MIDAS) {
782 lrl = ((((EVENT_HEADER *) pevent)->data_size) + sizeof(EVENT_HEADER)) /
783 sizeof(DWORD); /* in I*4 for raw including the header */
784 pevt = (DWORD *) pevent; /* local copy starting from the pheader */
785 } else {
786 assert(!"unsupported data_fmt, sorry!");
787 }
788
789 for (i = 0; i < lrl; i += NLINE) {
790 printf("%6.0d->: ", total);
791 for (j = 0; j < NLINE; j++) {
792 if ((i + j) < lrl) {
793 if (dsp_fmt == DSP_DEC)
794 printf("%8.i ", *pevt);
795 else
796 printf("%8.8x ", *pevt);
797 pevt++;
798 }
799 }
800 total += NLINE;
801 printf("\n");
802 }
803}
804
805/*------------------------------------------------------------------*/
806void md_bank_event_display(const void *pevent, INT data_fmt, INT dsp_fmt, INT dsp_mode, const char *bn)
807/********************************************************************\
808Routine: md_bank_event_display
809Purpose: display on screen the event header, bank list and bank content
810for midas format.)
811Input:
812void * pevent points to either plrl or pheader
813INT data_fmt uses the YBOS or MIDAS event structure
814INT dsp_fmt display format (DSP_DEC/HEX)
815Output:
816none
817Function value:
818none
819\********************************************************************/
820{
822 DWORD *pdata, *pdata1;
824 BANK *pmbk;
825 BANK32 *pmbk32;
827 EVENT_HEADER *pheader;
828 INT status, single = 0;
829
830 if (data_fmt == FORMAT_MIDAS) {
831 /* skip these special events (NO bank structure) */
832 pheader = (EVENT_HEADER *) pevent;
833 if (pheader->event_id == EVENTID_BOR ||
834 pheader->event_id == EVENTID_EOR || pheader->event_id == EVENTID_MESSAGE)
835 return;
836
837 /* check if format is MIDAS or FIXED */
838 pbh = (BANK_HEADER *) (pheader + 1);
839
840 /* Check for single bank display request */
841 if (dsp_mode == DSP_BANK_SINGLE) {
843 single = 1;
844 }
845 /* event header (skip it if in single bank display) */
846 if (!single)
847 printf("Evid:%4.4x- Mask:%4.4x- Serial:%i- Time:0x%x- Dsize:%i/0x%x",
848 (WORD) pheader->event_id, (WORD) pheader->trigger_mask,
849 pheader->serial_number, pheader->time_stamp, pheader->data_size, pheader->data_size);
850
851 if ((pbh->data_size + 8) == pheader->data_size) {
852 /* bank list */
853 if (!single) {
854 /* Skip list if in single bank display */
855 status = bk_list((BANK_HEADER *) (pheader + 1), banklist);
856 printf("\n#banks:%i - Bank list:-%s-\n", status, banklist);
857 }
858
859 /* display bank content */
860 if (bk_is32a(pbh)) {
861 pmbk32a = NULL;
862 do {
864 if (pmbk32a != NULL)
865 if (single && (pdata == pdata1))
867 if (!single)
868 if (pmbk32a != NULL)
870 } while (pmbk32a != NULL);
871 } else if (bk_is32(pbh)) {
872 pmbk32 = NULL;
873 do {
875 if (pmbk32 != NULL)
876 if (single && (pdata == pdata1))
878 if (!single)
879 if (pmbk32 != NULL)
881 } while (pmbk32 != NULL);
882 } else {
883 pmbk = NULL;
884 do {
886 if (pmbk != NULL)
887 if (single && (pdata == pdata1))
889 if (!single)
890 if (pmbk != NULL)
892 } while (pmbk != NULL);
893 }
894 } else {
895 printf("\nFIXED event with Midas Header\n");
897 }
898 } else {
899 assert(!"unsupported data_fmt, sorry!");
900 }
901
902 return;
903}
904
905/*------------------------------------------------------------------*/
907/********************************************************************\
908Routine: external md_bank_display
909Purpose: display on screen the given bank.
910Input:
911void * pbk pointer to the bank
912INT data_fmt YBOS or MIDAS
913INT dsp_mode display mode (RAW/BANK)
914INT dsp_fmt display format (DSP_DEC/HEX)
915Output:
916none
917Function value:
918none
919\********************************************************************/
920{
921 if (dsp_mode == DSP_RAW)
923 else {
924 if (data_fmt == FORMAT_MIDAS) {
925 if (bk_is32a(pmbh)) {
927 } else if (bk_is32(pmbh)) {
929 } else {
931 }
932 } else {
933 assert(!"unsupported data_fmt, sorry!");
934 }
935 }
936 return;
937}
938
939/*------------------------------------------------------------------*/
941/********************************************************************\
942Routine: md__raw_bank_display
943Purpose: display on screen the RAW data of a given YBOS/MIDAS bank.
944Input:
945void * pbank pointer to the bank name
946INT data_fmt uses the YBOS or MIDAS event structure
947INT dsp_fmt display format (DSP_DEC/HEX)
948Output:
949none
950Function value:
951none
952\********************************************************************/
953{
954 DWORD *pdata = NULL, lrl = 0, j, i;
955
956 if (data_fmt == FORMAT_MIDAS) {
957 lrl = ((BANK *) pbank)->data_size >> 2; /* in DWORD */
958 pdata = (DWORD *) ((BANK *) (pbank) + 1);
959 } else {
960 assert(!"unsupported data_fmt, sorry!");
961 }
962
963 for (i = 0; i < lrl; i += NLINE) {
964 j = 0;
965 printf("\n%4i-> ", i + j + 1);
966 for (j = 0; j < NLINE; j++) {
967 if ((i + j) < lrl) {
968 if (dsp_fmt == DSP_DEC)
969 printf("%8.i ", *((DWORD *) pdata));
970 if (dsp_fmt == DSP_ASC)
971 printf("%8.8x ", *((DWORD *) pdata));
972 if (dsp_fmt == DSP_HEX)
973 printf("%8.8x ", *((DWORD *) pdata));
974 pdata++;
975 }
976 }
977 }
978}
979
980#if 0 // OBSOLETE, NOT USED ANYMORE
981/*------------------------------------------------------------------*/
982INT midas_event_get(void **pevent, DWORD *readn)
983/********************************************************************\
984Routine: midas_event_get
985Purpose: read one MIDAS event.
986Will detect:
987The first pass in getting the record number being -1
988The last pass in checking the midas_physrec_get() readn
989being different then the my.size then flushing the current
990buffer until pointer goes beyond last event.
991Input:
992void ** pevent points to MIDAS HEADER
993Output:
994DWORD * readn event size in bytes (MIDAS)
995Function value:
996MD_DONE No more record to read
997MD_SUCCESS Ok
998\********************************************************************/
999{
1001 DWORD fpart;
1002 static DWORD size = 0;
1003
1004 /* save pointer */
1005 *pevent = (char *) my.pmh;
1006 if (size == 0)
1007 size = my.size;
1008
1009 /* first time in get physrec once */
1010 if ((int) my.recn == -1) {
1011 status = midas_physrec_get((void *) my.pmp, &size);
1012 if (status != MD_SUCCESS)
1013 return (MD_DONE);
1014 }
1015
1016 /*-PAA- Jul 12/2002
1017 if (((my.pmp+size) - (char *)my.pme) == 0)
1018 return (MD_DONE);
1019 */
1020
1021 /* copy header only */
1022 if (((my.pmp + size) - (char *) my.pme) < (int) sizeof(EVENT_HEADER)) {
1023 fpart = (my.pmp + my.size) - (char *) my.pme;
1024 memcpy(my.pmh, my.pme, fpart);
1025 my.pmh = (EVENT_HEADER *) (((char *) my.pmh) + fpart);
1026 leftover = sizeof(EVENT_HEADER) - fpart;
1027 status = midas_physrec_get((void *) my.pmp, &size);
1028 if (status != MD_SUCCESS)
1029 return (MD_DONE);
1030 memset(my.pmp + size, -1, my.size - size);
1031 my.pme = (EVENT_HEADER *) my.pmp;
1033 my.pme = (EVENT_HEADER *) (((char *) my.pme) + leftover);
1034 my.pmh = (EVENT_HEADER *) *pevent;
1035 } else {
1036 memcpy(my.pmh, my.pme, sizeof(EVENT_HEADER));
1037 my.pme = (EVENT_HEADER *) (((char *) my.pme) + sizeof(EVENT_HEADER));
1038 }
1039 /* leave with pmh to destination header
1040 pmrd to destination event (pmh+1)
1041 pme to source event
1042 */
1043 my.pmrd = (char *) (my.pmh + 1);
1044
1045 /* check for end of file */
1046 if (my.pmh->event_id == -1)
1047 return MD_DONE;
1048
1049 /* copy event (without header) */
1051
1052 /* check for block crossing */
1053 while (((my.pmp + size) - (char *) my.pme) < leftover) {
1054 fpart = (my.pmp + my.size) - (char *) my.pme;
1055 memcpy(my.pmrd, my.pme, fpart);
1056 my.pmrd += fpart;
1057 leftover -= fpart;
1058 status = midas_physrec_get((void *) my.pmp, &size);
1059 if (status != MD_SUCCESS)
1060 return (MD_DONE);
1061 memset(my.pmp + size, -1, my.size - size);
1062 my.pme = (EVENT_HEADER *) my.pmp;
1063 }
1064
1065 /* copy left over or full event if no Xing */
1066 *readn = my.evtlen = my.pmh->data_size + sizeof(EVENT_HEADER);
1068 my.pme = (EVENT_HEADER *) (((char *) my.pme) + leftover);
1069 my.evtn++;
1070 return MD_SUCCESS;
1071}
1072#endif
1073
1074/*------------------------------------------------------------------*/
1076/********************************************************************\
1077Routine: midas_physrec_get
1078Purpose: read one physical record.from a MIDAS run
1079This is a "fake" physical record as Midas is
1080not block structured. This function is used for
1081reading a my.size record size. The return readn if different
1082then my.size, will indicate a end of run. An extra read will
1083indicate an eof.
1084
1085Input:
1086void * prec pointer to the record
1087Output:
1088DWORD *readn retrieve number of bytes
1089Function value:
1090MD_DONE No more record to read
1091MD_SUCCESS Ok
1092\********************************************************************/
1093{
1094 INT status = 0;
1095
1096 /* read one block of data */
1097 if (!my.zipfile) {
1099 } else {
1100 *readn = gzread(filegz, (char *) prec, my.size);
1101 if (*readn <= 0)
1103 else
1105 }
1106
1107 if (status != SS_SUCCESS) {
1108 return (MD_DONE);
1109 } else {
1110 /* count blocks */
1111 my.recn++;
1112 return (MD_SUCCESS);
1113 }
1114}
1115
1116/*------------------------------------------------------------------*/
1118/******************************* *************************************\
1119Routine: midas_bank_display
1120Purpose: display on screen the pointed MIDAS bank data using MIDAS Bank structure.
1121Input:
1122BANK * pbk pointer to the BANK
1123INT dsp_fmt display format (DSP_DEC/HEX)
1124Output:
1125none
1126Function value:
1127none
1128\********************************************************************/
1129{
1130 char bank_name[5], strbktype[32];
1131 char *pdata, *pendbk;
1132 DWORD length_type = 0, lrl;
1133 INT type, i, j;
1134
1135 lrl = pbk->data_size; /* in bytes */
1136 type = pbk->type & 0xff;
1137 bank_name[4] = 0;
1138 memcpy(bank_name, (char *) (pbk->name), 4);
1139 pdata = (char *) (pbk + 1);
1140
1141 j = 64; /* elements within line */
1142 i = 1; /* data counter */
1143 strcpy(strbktype, "Unknown format");
1144 if (type == TID_DOUBLE) {
1145 length_type = sizeof(double);
1146 strcpy(strbktype, "double*8");
1147 }
1148 if (type == TID_FLOAT) {
1149 length_type = sizeof(float);
1150 strcpy(strbktype, "Real*4 (FMT machine dependent)");
1151 }
1152 if (type == TID_UINT64) {
1153 length_type = sizeof(uint64_t);
1154 strcpy(strbktype, "Unsigned Integer*8");
1155 }
1156 if (type == TID_INT64) {
1157 length_type = sizeof(int64_t);
1158 strcpy(strbktype, "Signed Integer*8");
1159 }
1160 if (type == TID_DWORD) {
1161 length_type = sizeof(DWORD);
1162 strcpy(strbktype, "Unsigned Integer*4");
1163 }
1164 if (type == TID_INT) {
1165 length_type = sizeof(INT);
1166 strcpy(strbktype, "Signed Integer*4");
1167 }
1168 if (type == TID_WORD) {
1169 length_type = sizeof(WORD);
1170 strcpy(strbktype, "Unsigned Integer*2");
1171 }
1172 if (type == TID_SHORT) {
1173 length_type = sizeof(short);
1174 strcpy(strbktype, "Signed Integer*2");
1175 }
1176 if (type == TID_BYTE) {
1177 length_type = sizeof(BYTE);
1178 strcpy(strbktype, "Unsigned Bytes");
1179 }
1180 if (type == TID_SBYTE) {
1181 length_type = sizeof(BYTE);
1182 strcpy(strbktype, "Signed Bytes");
1183 }
1184 if (type == TID_BOOL) {
1185 length_type = sizeof(DWORD);
1186 strcpy(strbktype, "Boolean");
1187 }
1188 if (type == TID_CHAR) {
1189 length_type = sizeof(char);
1190 strcpy(strbktype, "8 bit ASCII");
1191 }
1192 if (type == TID_STRUCT) {
1193 length_type = sizeof(char);
1194 strcpy(strbktype, "STRUCT (not supported->8 bits)");
1195 }
1196 if (type == TID_STRING) {
1197 length_type = sizeof(char);
1198 strcpy(strbktype, "String 8bit ASCII");
1199 }
1200
1201 printf("\nBank:%s Length: %i(I*1)/%i(I*4)/%i(Type) Type:%s",
1202 bank_name, lrl, lrl >> 2, lrl / (length_type == 0 ? 1 : length_type), strbktype);
1203
1204 pendbk = pdata + lrl;
1205 while (pdata < pendbk) {
1206 switch (type) {
1207 case TID_DOUBLE:
1208 if (j > 3) {
1209 printf("\n%4i-> ", i);
1210 j = 0;
1211 i += 4;
1212 }
1213 printf("%15.5le ", *((double *) pdata));
1214 pdata = (char *) (((double *) pdata) + 1);
1215 j++;
1216 break;
1217 case TID_FLOAT:
1218 if (j > 7) {
1219 printf("\n%4i-> ", i);
1220 j = 0;
1221 i += 8;
1222 }
1223 if ((dsp_fmt == DSP_DEC) || (dsp_fmt == DSP_UNK))
1224 printf("%8.3e ", *((float *) pdata));
1225 if (dsp_fmt == DSP_HEX)
1226 printf("0x%8.8x ", *((DWORD *) pdata));
1227 pdata = (char *) (((DWORD *) pdata) + 1);
1228 j++;
1229 break;
1230 case TID_UINT64:
1231 if (j > 7) {
1232 printf("\n%4i-> ", i);
1233 j = 0;
1234 i += 8;
1235 }
1236 if (dsp_fmt == DSP_DEC)
1237 printf("%16.1llu ", (long long unsigned) *((uint64_t *) pdata));
1238 if ((dsp_fmt == DSP_HEX) || (dsp_fmt == DSP_UNK))
1239 printf("0x%16.16llx ", (long long unsigned) *((uint64_t *) pdata));
1240 pdata = (char *) (((uint64_t *) pdata) + 1);
1241 j++;
1242 break;
1243 case TID_INT64:
1244 if (j > 7) {
1245 printf("\n%4i-> ", i);
1246 j = 0;
1247 i += 8;
1248 }
1249 if ((dsp_fmt == DSP_DEC) || (dsp_fmt == DSP_UNK))
1250 printf("%16.1lli ", (long long int) *((int64_t *) pdata));
1251 if (dsp_fmt == DSP_HEX)
1252 printf("0x%16.16llx ", (long long unsigned int) *((int64_t *) pdata));
1253 pdata = (char *) (((int64_t *) pdata) + 1);
1254 j++;
1255 break;
1256 case TID_DWORD:
1257 if (j > 7) {
1258 printf("\n%4i-> ", i);
1259 j = 0;
1260 i += 8;
1261 }
1262 if (dsp_fmt == DSP_DEC)
1263 printf("%8.1i ", *((DWORD *) pdata));
1264 if ((dsp_fmt == DSP_HEX) || (dsp_fmt == DSP_UNK))
1265 printf("0x%8.8x ", *((DWORD *) pdata));
1266 pdata = (char *) (((DWORD *) pdata) + 1);
1267 j++;
1268 break;
1269 case TID_INT:
1270 if (j > 7) {
1271 printf("\n%4i-> ", i);
1272 j = 0;
1273 i += 8;
1274 }
1275 if ((dsp_fmt == DSP_DEC) || (dsp_fmt == DSP_UNK))
1276 printf("%8.1i ", *((DWORD *) pdata));
1277 if (dsp_fmt == DSP_HEX)
1278 printf("0x%8.8x ", *((DWORD *) pdata));
1279 pdata = (char *) (((DWORD *) pdata) + 1);
1280 j++;
1281 break;
1282 case TID_WORD:
1283 if (j > 7) {
1284 printf("\n%4i-> ", i);
1285 j = 0;
1286 i += 8;
1287 }
1288 if (dsp_fmt == DSP_DEC)
1289 printf("%5.1i ", *((WORD *) pdata));
1290 if ((dsp_fmt == DSP_HEX) || (dsp_fmt == DSP_UNK))
1291 printf("0x%4.4x ", *((WORD *) pdata));
1292 pdata = (char *) (((WORD *) pdata) + 1);
1293 j++;
1294 break;
1295 case TID_SHORT:
1296 if (j > 7) {
1297 printf("\n%4i-> ", i);
1298 j = 0;
1299 i += 8;
1300 }
1301 if ((dsp_fmt == DSP_DEC) || (dsp_fmt == DSP_UNK))
1302 printf("%5.1i ", *((short *) pdata));
1303 if (dsp_fmt == DSP_HEX)
1304 printf("0x%4.4x ", *((short *) pdata));
1305 pdata = (char *) (((short *) pdata) + 1);
1306 j++;
1307 break;
1308 case TID_BYTE:
1309 case TID_STRUCT:
1310 if (j > 15) {
1311 printf("\n%4i-> ", i);
1312 j = 0;
1313 i += 16;
1314 }
1315 if (dsp_fmt == DSP_DEC)
1316 printf("%4.i ", *((BYTE *) pdata));
1317 if ((dsp_fmt == DSP_HEX) || (dsp_fmt == DSP_UNK))
1318 printf("0x%2.2x ", *((BYTE *) pdata));
1319 pdata++;
1320 j++;
1321 break;
1322 case TID_SBYTE:
1323 if (j > 15) {
1324 printf("\n%4i-> ", i);
1325 j = 0;
1326 i += 16;
1327 }
1328 if ((dsp_fmt == DSP_DEC) || (dsp_fmt == DSP_UNK))
1329 printf("%4.i ", *((BYTE *) pdata));
1330 if (dsp_fmt == DSP_HEX)
1331 printf("0x%2.2x ", *((BYTE *) pdata));
1332 pdata++;
1333 j++;
1334 break;
1335 case TID_BOOL:
1336 if (j > 15) {
1337 printf("\n%4i-> ", i);
1338 j = 0;
1339 i += 16;
1340 }
1341 (*((BOOL *) pdata) != 0) ? printf("Y ") : printf("N ");
1342 pdata = (char *) (((DWORD *) pdata) + 1);
1343 j++;
1344 break;
1345 case TID_CHAR:
1346 case TID_STRING:
1347 if (j > 15) {
1348 printf("\n%4i-> ", i);
1349 j = 0;
1350 i += 16;
1351 }
1352 if (dsp_fmt == DSP_DEC)
1353 printf("%3.i ", *((BYTE *) pdata));
1354 if ((dsp_fmt == DSP_ASC) || (dsp_fmt == DSP_UNK))
1355 printf("%1.1s ", (char *) pdata);
1356 if (dsp_fmt == DSP_HEX)
1357 printf("0x%2.2x ", *((BYTE *) pdata));
1358 pdata++;
1359 j++;
1360 break;
1361 default:
1362 printf("bank type not supported (%d)\n", type);
1363 return;
1364 break;
1365 }
1366 } /* end of bank */
1367 printf("\n");
1368 return;
1369}
1370
1371/*------------------------------------------------------------------*/
1372template<typename T>
1374/********************************************************************\
1375Routine: midas_bank_display32
1376Purpose: display on screen the pointed MIDAS bank data using MIDAS Bank structure.
1377for 32bit length banks
1378Input:
1379BANK32 * pbk pointer to the BANK
1380INT dsp_fmt display format (DSP_DEC/HEX)
1381Output:
1382none
1383Function value:
1384none
1385\********************************************************************/
1386{
1387 char bank_name[5], strbktype[32];
1388 char *pdata, *pendbk;
1389 DWORD length_type = 0, lrl;
1390 INT type, i, j;
1391
1392 lrl = pbk->data_size; /* in bytes */
1393 type = pbk->type & 0xff;
1394 bank_name[4] = 0;
1395 memcpy(bank_name, (char *) (pbk->name), 4);
1396 pdata = (char *) (pbk + 1);
1397
1398 j = 64; /* elements within line */
1399 i = 1; /* data counter */
1400 strcpy(strbktype, "Unknown format");
1401 if (type == TID_DOUBLE) {
1402 length_type = sizeof(double);
1403 strcpy(strbktype, "double*8");
1404 }
1405 if (type == TID_FLOAT) {
1406 length_type = sizeof(float);
1407 strcpy(strbktype, "Real*4 (FMT machine dependent)");
1408 }
1409 if (type == TID_UINT64) {
1410 length_type = sizeof(uint64_t);
1411 strcpy(strbktype, "Unsigned Integer*8");
1412 }
1413 if (type == TID_INT64) {
1414 length_type = sizeof(int64_t);
1415 strcpy(strbktype, "Signed Integer*8");
1416 }
1417 if (type == TID_DWORD) {
1418 length_type = sizeof(DWORD);
1419 strcpy(strbktype, "Unsigned Integer*4");
1420 }
1421 if (type == TID_INT) {
1422 length_type = sizeof(INT);
1423 strcpy(strbktype, "Signed Integer*4");
1424 }
1425 if (type == TID_WORD) {
1426 length_type = sizeof(WORD);
1427 strcpy(strbktype, "Unsigned Integer*2");
1428 }
1429 if (type == TID_SHORT) {
1430 length_type = sizeof(short);
1431 strcpy(strbktype, "Signed Integer*2");
1432 }
1433 if (type == TID_BYTE) {
1434 length_type = sizeof(BYTE);
1435 strcpy(strbktype, "Unsigned Bytes");
1436 }
1437 if (type == TID_SBYTE) {
1438 length_type = sizeof(BYTE);
1439 strcpy(strbktype, "Signed Bytes");
1440 }
1441 if (type == TID_BOOL) {
1442 length_type = sizeof(DWORD);
1443 strcpy(strbktype, "Boolean");
1444 }
1445 if (type == TID_CHAR) {
1446 length_type = sizeof(char);
1447 strcpy(strbktype, "8 bit ASCII");
1448 }
1449 if (type == TID_STRUCT) {
1450 length_type = sizeof(char);
1451 strcpy(strbktype, "STRUCT (not supported->8 bits)");
1452 }
1453 if (type == TID_STRING) {
1454 length_type = sizeof(char);
1455 strcpy(strbktype, "String 8bit ASCI");
1456 }
1457
1458 printf("\nBank:%s Length: %i(I*1)/%i(I*4)/%i(Type) Type:%s",
1459 bank_name, lrl, lrl >> 2, lrl / (length_type == 0 ? 1 : length_type), strbktype);
1460
1461 pendbk = pdata + lrl;
1462 while (pdata < pendbk) {
1463 switch (type) {
1464 case TID_DOUBLE:
1465 if (j > 3) {
1466 printf("\n%4i-> ", i);
1467 j = 0;
1468 i += 4;
1469 }
1470 printf("%15.5e ", *((double *) pdata));
1471 pdata = (char *) (((double *) pdata) + 1);
1472 j++;
1473 break;
1474 case TID_FLOAT:
1475 if (j > 7) {
1476 printf("\n%4i-> ", i);
1477 j = 0;
1478 i += 8;
1479 }
1480 if ((dsp_fmt == DSP_DEC) || (dsp_fmt == DSP_UNK))
1481 printf("%8.3e ", *((float *) pdata));
1482 if (dsp_fmt == DSP_HEX)
1483 printf("0x%8.8x ", *((DWORD *) pdata));
1484 pdata = (char *) (((DWORD *) pdata) + 1);
1485 j++;
1486 break;
1487 case TID_UINT64:
1488 if (j > 7) {
1489 printf("\n%4i-> ", i);
1490 j = 0;
1491 i += 8;
1492 }
1493 if (dsp_fmt == DSP_DEC)
1494 printf("%16.1llu ", (long long unsigned int) *((uint64_t *) pdata));
1495 if ((dsp_fmt == DSP_HEX) || (dsp_fmt == DSP_UNK))
1496 printf("0x%16.16llx ", (long long unsigned int) *((uint64_t *) pdata));
1497 pdata = (char *) (((uint64_t *) pdata) + 1);
1498 j++;
1499 break;
1500 case TID_INT64:
1501 if (j > 7) {
1502 printf("\n%4i-> ", i);
1503 j = 0;
1504 i += 8;
1505 }
1506 if ((dsp_fmt == DSP_DEC) || (dsp_fmt == DSP_UNK))
1507 printf("%16.1lli ", (long long int) *((int64_t *) pdata));
1508 if (dsp_fmt == DSP_HEX)
1509 printf("0x%16.16llx ", (long long unsigned int) *((int64_t *) pdata));
1510 pdata = (char *) (((int64_t *) pdata) + 1);
1511 j++;
1512 break;
1513 case TID_DWORD:
1514 if (j > 7) {
1515 printf("\n%4i-> ", i);
1516 j = 0;
1517 i += 8;
1518 }
1519 if (dsp_fmt == DSP_DEC)
1520 printf("%8.1i ", *((DWORD *) pdata));
1521 if ((dsp_fmt == DSP_HEX) || (dsp_fmt == DSP_UNK))
1522 printf("0x%8.8x ", *((DWORD *) pdata));
1523 pdata = (char *) (((DWORD *) pdata) + 1);
1524 j++;
1525 break;
1526 case TID_INT:
1527 if (j > 7) {
1528 printf("\n%4i-> ", i);
1529 j = 0;
1530 i += 8;
1531 }
1532 if ((dsp_fmt == DSP_DEC) || (dsp_fmt == DSP_UNK))
1533 printf("%8.1i ", *((DWORD *) pdata));
1534 if (dsp_fmt == DSP_HEX)
1535 printf("0x%8.8x ", *((DWORD *) pdata));
1536 pdata = (char *) (((DWORD *) pdata) + 1);
1537 j++;
1538 break;
1539 case TID_WORD:
1540 if (j > 7) {
1541 printf("\n%4i-> ", i);
1542 j = 0;
1543 i += 8;
1544 }
1545 if (dsp_fmt == DSP_DEC)
1546 printf("%5.1i ", *((WORD *) pdata));
1547 if ((dsp_fmt == DSP_HEX) || (dsp_fmt == DSP_UNK))
1548 printf("0x%4.4x ", *((WORD *) pdata));
1549 pdata = (char *) (((WORD *) pdata) + 1);
1550 j++;
1551 break;
1552 case TID_SHORT:
1553 if (j > 7) {
1554 printf("\n%4i-> ", i);
1555 j = 0;
1556 i += 8;
1557 }
1558 if ((dsp_fmt == DSP_DEC) || (dsp_fmt == DSP_UNK))
1559 printf("%5.1i ", *((short *) pdata));
1560 if (dsp_fmt == DSP_HEX)
1561 printf("0x%4.4x ", *((short *) pdata));
1562 pdata = (char *) (((short *) pdata) + 1);
1563 j++;
1564 break;
1565 case TID_BYTE:
1566 case TID_STRUCT:
1567 if (j > 15) {
1568 printf("\n%4i-> ", i);
1569 j = 0;
1570 i += 16;
1571 }
1572 if (dsp_fmt == DSP_DEC)
1573 printf("%4.i ", *((BYTE *) pdata));
1574 if ((dsp_fmt == DSP_HEX) || (dsp_fmt == DSP_UNK))
1575 printf("0x%2.2x ", *((BYTE *) pdata));
1576 pdata++;
1577 j++;
1578 break;
1579 case TID_SBYTE:
1580 if (j > 15) {
1581 printf("\n%4i-> ", i);
1582 j = 0;
1583 i += 16;
1584 }
1585 if ((dsp_fmt == DSP_DEC) || (dsp_fmt == DSP_UNK))
1586 printf("%4.i ", *((BYTE *) pdata));
1587 if (dsp_fmt == DSP_HEX)
1588 printf("0x%2.2x ", *((BYTE *) pdata));
1589 pdata++;
1590 j++;
1591 break;
1592 case TID_BOOL:
1593 if (j > 15) {
1594 printf("\n%4i-> ", i);
1595 j = 0;
1596 i += 16;
1597 }
1598 (*((BOOL *) pdata) != 0) ? printf("Y ") : printf("N ");
1599 pdata = (char *) (((DWORD *) pdata) + 1);
1600 j++;
1601 break;
1602 case TID_CHAR:
1603 case TID_STRING:
1604 if (j > 15) {
1605 printf("\n%4i-> ", i);
1606 j = 0;
1607 i += 16;
1608 }
1609 if (dsp_fmt == DSP_DEC)
1610 printf("%3.i ", *((BYTE *) pdata));
1611 if (dsp_fmt == DSP_ASC || (dsp_fmt == DSP_UNK))
1612 printf("%1.1s ", (char *) pdata);
1613 if (dsp_fmt == DSP_HEX)
1614 printf("0x%2.2x ", *((BYTE *) pdata));
1615 pdata++;
1616 j++;
1617 break;
1618 default:
1619 printf("bank type not supported (%d)\n", type);
1620 return;
1621 break;
1622 }
1623 } /* end of bank */
1624 printf("\n");
1625 return;
1626}
1627
1628/*------------------------------------------------------------------*/
1629/*--END of MDSUPPORT.C----------------------------------------------*/
1630/*------------------------------------------------------------------*/
1631
/* end of mdsupportincludecode */
#define FALSE
Definition cfortran.h:309
int ftp_login(FTP_CON **con, const char *host, unsigned short port, const char *user, const char *password, const char *account)
Definition ftplib.cxx:388
int ftp_close(FTP_CON *con)
Definition ftplib.cxx:334
int ftp_command(FTP_CON *con, const char *command, const char *param,...)
Definition ftplib.cxx:146
int ftp_send(int sock, const char *buffer, int n_bytes_to_write)
Definition ftplib.cxx:346
int ftp_bye(FTP_CON *con)
Definition ftplib.cxx:422
int ftp_move(FTP_CON *con, const char *oldname, const char *newname)
Definition ftplib.cxx:460
#define ftp_mkdir(ftp, dir)
Definition ftplib.h:36
#define ftp_chdir(ftp, dir)
Definition ftplib.h:35
#define ftp_binary(ftp)
Definition ftplib.h:39
#define ftp_open_write(ftp, file)
Definition ftplib.h:41
INT bk_iterate32a(const void *event, BANK32A **pbk32a, void *pdata)
Definition midas.cxx:17103
INT bk_swap(void *event, BOOL force)
Definition midas.cxx:17157
BOOL bk_is32a(const void *event)
Definition midas.cxx:16437
BOOL bk_is32(const void *event)
Definition midas.cxx:16415
INT bk_iterate32(const void *event, BANK32 **pbk, void *pdata)
Definition midas.cxx:17067
INT bk_locate(const void *event, const char *name, void *pdata)
Definition midas.cxx:16889
INT bk_list(const void *event, char *bklist)
Definition midas.cxx:16840
INT bk_iterate(const void *event, BANK **pbk, void *pdata)
Definition midas.cxx:17046
#define CM_SUCCESS
Definition midas.h:582
#define SS_SUCCESS
Definition midas.h:663
#define SS_TAPE_ERROR
Definition midas.h:682
#define SS_FILE_ERROR
Definition midas.h:669
#define SS_NO_MEMORY
Definition midas.h:665
#define SS_END_OF_TAPE
Definition midas.h:684
#define SS_IO_ERROR
Definition midas.h:681
#define SS_NO_SPACE
Definition midas.h:687
unsigned short int WORD
Definition mcstd.h:49
unsigned char BYTE
Definition mcstd.h:48
unsigned int DWORD
Definition mcstd.h:51
#define TID_DOUBLE
Definition midas.h:343
#define TID_SBYTE
Definition midas.h:329
#define TID_BOOL
Definition midas.h:340
#define TID_SHORT
Definition midas.h:334
#define TID_UINT64
Definition midas.h:352
#define TID_INT64
Definition midas.h:351
#define TID_WORD
Definition midas.h:332
#define TID_BYTE
Definition midas.h:327
#define TID_STRUCT
Definition midas.h:348
#define TID_STRING
Definition midas.h:346
#define MERROR
Definition midas.h:559
#define FORMAT_MIDAS
Definition midas.h:311
#define TID_CHAR
Definition midas.h:331
#define TID_INT
Definition midas.h:338
#define TID_FLOAT
Definition midas.h:341
#define TID_DWORD
Definition midas.h:336
#define MD_STRING_BANKLIST_MAX
Definition mdsupport.h:100
#define DSP_UNK
Definition mdsupport.h:91
#define D_RECORD
Definition mdsupport.h:78
#define D_EVTLEN
Definition mdsupport.h:80
#define DSP_DEC
Definition mdsupport.h:92
#define DSP_BANK_SINGLE
Definition mdsupport.h:87
#define DSP_RAW
Definition mdsupport.h:84
#define DSP_BANK
Definition mdsupport.h:86
#define DSP_HEX
Definition mdsupport.h:93
#define DSP_ASC
Definition mdsupport.h:94
#define NLINE
Definition mdsupport.h:96
#define D_HEADER
Definition mdsupport.h:79
#define MD_EVENT_NOT_SWAPPED
Definition mdsupport.h:61
#define MD_DONE
Definition mdsupport.h:62
#define MD_SUCCESS
Definition mdsupport.h:60
#define MD_UNKNOWN_FORMAT
Definition mdsupport.h:67
void md_event_display(const void *pevent, INT data_fmt, INT dsp_mode, INT dsp_fmt, const char *bn)
INT md_file_wclose(INT handle, INT type, INT data_fmt, char *destination)
INT md_file_ropen(char *infile, INT data_fmt, INT openzip, INT max_event_size)
INT md_all_info_display(INT what)
INT md_dev_os_write(INT handle, INT type, void *prec, DWORD nbytes, DWORD *written)
INT md_physrec_get(INT data_fmt, void **precord, DWORD *readn)
char * ptopmrd
Definition mdsupport.cxx:71
void md_bank_event_display(const void *pevent, INT data_fmt, INT dsp_fmt, INT dsp_mode, const char *bn)
void midas_bank_display32(T *pbk, INT dsp_fmt)
gzFile filegz
Definition mdsupport.cxx:73
struct stat * filestat
Definition mdsupport.cxx:70
INT md_dev_os_read(INT handle, INT type, void *prec, DWORD nbytes, DWORD *nread)
INT midas_event_skip(INT evtn)
INT md_file_wopen(INT type, INT data_fmt, char *filename, INT *hDev)
void md_raw_bank_display(void *pbank, INT data_fmt, INT dsp_fmt)
void md_raw_event_display(const void *pevent, INT data_fmt, INT dsp_fmt)
INT midas_physrec_get(void *prec, DWORD *readn)
void midas_bank_display(BANK *pbk, INT dsp_fmt)
INT md_event_swap(INT data_fmt, void *pevent)
void md_bank_display(void *pmbh, void *pbk, INT data_fmt, INT dsp_mode, INT dsp_fmt)
MY my
Definition mdsupport.cxx:96
INT md_log_write(INT handle, INT data_fmt, INT type, void *prec, DWORD nbytes)
INT md_file_rclose(INT data_fmt)
INT midas_event_get(void **pevent, DWORD *size)
#define LOG_TYPE_DISK
Definition msystem.h:493
#define O_BINARY
Definition msystem.h:219
#define LOG_TYPE_TAPE
Definition msystem.h:494
#define LOG_TYPE_FTP
Definition msystem.h:495
INT ss_tape_close(INT channel)
Definition system.cxx:5902
INT ss_tape_write_eof(INT channel)
Definition system.cxx:6166
INT ss_tape_open(char *path, INT oflag, INT *channel)
Definition system.cxx:5811
INT cm_msg(INT message_type, const char *filename, INT line, const char *routine, const char *format,...)
Definition midas.cxx:915
INT data_fmt
INT hDev
INT type
Definition mana.cxx:269
char host_name[HOST_NAME_LENGTH]
Definition mana.cxx:242
char bank_name[4]
Definition mdump.cxx:26
INT dsp_mode
Definition mdump.cxx:29
INT dsp_fmt
Definition mdump.cxx:29
INT openzip
Definition mdump.cxx:30
INT i
Definition mdump.cxx:32
INT bl
Definition mdump.cxx:29
INT max_event_size
Definition mfed.cxx:30
#define DWORD
Definition mhdump.cxx:31
#define O_LARGEFILE
Definition midas.h:210
#define HOST_NAME_LENGTH
Definition midas.h:273
DWORD BOOL
Definition midas.h:105
int INT
Definition midas.h:129
#define EVENTID_MESSAGE
Definition midas.h:902
#define EVENTID_EOR
Definition midas.h:901
#define TRUE
Definition midas.h:182
#define TAPE_BUFFER_SIZE
Definition midas.h:264
#define EVENTID_BOR
Definition midas.h:900
#define STRING_BANKLIST_MAX
Definition midas.h:279
#define read(n, a, f)
#define event_id
#define write(n, a, f, d)
#define name(x)
Definition midas_macro.h:24
double total[100]
Definition odbhist.cxx:42
INT j
Definition odbhist.cxx:40
DWORD run
Definition odbhist.cxx:39
char file_name[256]
Definition odbhist.cxx:41
DWORD status
Definition odbhist.cxx:39
TH1X EXPRT * h1_book(const char *name, const char *title, int bins, double min, double max)
Definition rmidas.h:24
Definition midas.h:1215
short int event_id
Definition midas.h:852
DWORD data_size
Definition midas.h:856
DWORD serial_number
Definition midas.h:854
DWORD time_stamp
Definition midas.h:855
short int trigger_mask
Definition midas.h:853
int data
Definition ftplib.h:27
char * pmp
Definition mdsupport.cxx:80
DWORD runn
Definition mdsupport.cxx:92
INT fmt
Definition mdsupport.cxx:90
INT type
Definition mdsupport.cxx:91
INT handle
Definition mdsupport.cxx:77
char * pmrd
Definition mdsupport.cxx:83
EVENT_HEADER * pme
Definition mdsupport.cxx:82
DWORD recn
Definition mdsupport.cxx:89
BOOL zipfile
Definition mdsupport.cxx:93
DWORD evtn
Definition mdsupport.cxx:85
DWORD size
Definition mdsupport.cxx:88
DWORD evtlen
Definition mdsupport.cxx:87
EVENT_HEADER * pmh
Definition mdsupport.cxx:81
DWORD serial
Definition mdsupport.cxx:86
char name[128]
Definition mdsupport.cxx:78