MIDAS
Loading...
Searching...
No Matches
The mdsupport.h & mdsupport.c
Collaboration diagram for The mdsupport.h & mdsupport.c:

Modules

 Midas dump error code
 
 Midas dump support Define
 
 Midas dump support Macros
 

Classes

struct  MY
 

Macros

#define TRACE
 
#define EXPRT
 

Functions

INT md_dev_os_read (INT handle, INT type, void *prec, DWORD nbytes, DWORD *nread)
 
INT md_dev_os_write (INT handle, INT type, void *prec, DWORD nbytes, DWORD *written)
 
void md_bank_event_display (const void *pevent, INT data_fmt, INT dsp_fmt, INT dsp_mode, const char *bn)
 
void md_raw_event_display (const void *pevent, INT data_fmt, INT dsp_fmt)
 
void md_raw_bank_display (void *pbank, INT data_fmt, INT dsp_fmt)
 
INT midas_event_get (void **pevent, DWORD *size)
 
INT midas_physrec_get (void *prec, DWORD *readn)
 
INT midas_event_skip (INT evtn)
 
void midas_bank_display (BANK *pbk, INT dsp_fmt)
 
template<typename T >
void midas_bank_display32 (T *pbk, INT dsp_fmt)
 
INT md_file_ropen (char *infile, INT data_fmt, INT openzip, INT max_event_size)
 
INT md_file_rclose (INT data_fmt)
 
INT md_file_wopen (INT type, INT data_fmt, char *filename, INT *hDev)
 
INT md_file_wclose (INT handle, INT type, INT data_fmt, char *destination)
 
INT md_physrec_get (INT data_fmt, void **precord, DWORD *readn)
 
INT md_log_write (INT handle, INT data_fmt, INT type, void *prec, DWORD nbytes)
 
INT md_all_info_display (INT what)
 
INT md_event_swap (INT data_fmt, void *pevent)
 
void md_event_display (const void *pevent, INT data_fmt, INT dsp_mode, INT dsp_fmt, const char *bn)
 
void md_bank_display (void *pmbh, void *pbk, INT data_fmt, INT dsp_mode, INT dsp_fmt)
 

Variables

struct statfilestat
 
charptopmrd
 
gzFile filegz
 
MY my
 

Detailed Description

dox


Macro Definition Documentation

◆ EXPRT

#define EXPRT

dox

Definition at line 49 of file mdsupport.h.

◆ TRACE

#define TRACE

dox

Definition at line 32 of file mdsupport.cxx.

Function Documentation

◆ md_all_info_display()

INT EXPRT md_all_info_display ( INT  what)

Definition at line 669 of file mdsupport.cxx.

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}
unsigned short int WORD
Definition mcstd.h:49
unsigned int DWORD
Definition mcstd.h:51
#define FORMAT_MIDAS
Definition midas.h:311
#define D_RECORD
Definition mdsupport.h:78
#define D_EVTLEN
Definition mdsupport.h:80
#define D_HEADER
Definition mdsupport.h:79
#define MD_DONE
Definition mdsupport.h:62
#define MD_SUCCESS
Definition mdsupport.h:60
MY my
Definition mdsupport.cxx:96
DWORD run
Definition odbhist.cxx:39
TH1X EXPRT * h1_book(const char *name, const char *title, int bins, double min, double max)
Definition rmidas.h:24
short int event_id
Definition midas.h:852
DWORD serial_number
Definition midas.h:854
short int trigger_mask
Definition midas.h:853
DWORD runn
Definition mdsupport.cxx:92
INT fmt
Definition mdsupport.cxx:90
DWORD evtn
Definition mdsupport.cxx:85
DWORD evtlen
Definition mdsupport.cxx:87
EVENT_HEADER * pmh
Definition mdsupport.cxx:81
Here is the call graph for this function:

◆ md_bank_display()

void EXPRT md_bank_display ( void pmbh,
void pbk,
INT  fmt,
INT  dsp_mode,
INT  dsp_fmt 
)

dox

Definition at line 906 of file mdsupport.cxx.

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}
BOOL bk_is32a(const void *event)
Definition midas.cxx:16437
BOOL bk_is32(const void *event)
Definition midas.cxx:16415
#define DSP_RAW
Definition mdsupport.h:84
void md_raw_bank_display(void *pbank, INT data_fmt, INT dsp_fmt)
void midas_bank_display(BANK *pbk, INT dsp_fmt)
INT data_fmt
INT dsp_mode
Definition mdump.cxx:29
INT dsp_fmt
Definition mdump.cxx:29
Definition midas.h:1215
Here is the call graph for this function:
Here is the caller graph for this function:

◆ md_bank_event_display()

void md_bank_event_display ( const void pevent,
INT  data_fmt,
INT  dsp_fmt,
INT  dsp_mode,
const char bn 
)

Definition at line 806 of file mdsupport.cxx.

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}
INT bk_iterate32a(const void *event, BANK32A **pbk32a, void *pdata)
Definition midas.cxx:17103
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 MD_STRING_BANKLIST_MAX
Definition mdsupport.h:100
#define DSP_BANK_SINGLE
Definition mdsupport.h:87
void md_raw_event_display(const void *pevent, INT data_fmt, INT dsp_fmt)
int INT
Definition midas.h:129
#define EVENTID_MESSAGE
Definition midas.h:902
#define EVENTID_EOR
Definition midas.h:901
#define EVENTID_BOR
Definition midas.h:900
#define STRING_BANKLIST_MAX
Definition midas.h:279
DWORD status
Definition odbhist.cxx:39
DWORD data_size
Definition midas.h:856
DWORD time_stamp
Definition midas.h:855
Here is the call graph for this function:
Here is the caller graph for this function:

◆ md_dev_os_read()

INT md_dev_os_read ( INT  handle,
INT  type,
void prec,
DWORD  nbytes,
DWORD nread 
)

Definition at line 428 of file mdsupport.cxx.

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}
#define SS_SUCCESS
Definition midas.h:663
#define SS_FILE_ERROR
Definition midas.h:669
#define SS_END_OF_TAPE
Definition midas.h:684
#define LOG_TYPE_DISK
Definition msystem.h:493
#define LOG_TYPE_TAPE
Definition msystem.h:494
INT type
Definition mana.cxx:269
#define read(n, a, f)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ md_dev_os_write()

INT md_dev_os_write ( INT  handle,
INT  type,
void prec,
DWORD  nbytes,
DWORD written 
)

Definition at line 484 of file mdsupport.cxx.

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}
int ftp_send(int sock, const char *buffer, int n_bytes_to_write)
Definition ftplib.cxx:346
#define SS_TAPE_ERROR
Definition midas.h:682
#define SS_IO_ERROR
Definition midas.h:681
#define SS_NO_SPACE
Definition midas.h:687
#define MERROR
Definition midas.h:559
#define LOG_TYPE_FTP
Definition msystem.h:495
INT cm_msg(INT message_type, const char *filename, INT line, const char *routine, const char *format,...)
Definition midas.cxx:915
#define write(n, a, f, d)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ md_event_display()

void EXPRT md_event_display ( const void pevent,
INT  data_fmt,
INT  dsp_mode,
INT  dsp_fmt,
const char bn 
)

Definition at line 740 of file mdsupport.cxx.

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}
#define DSP_BANK
Definition mdsupport.h:86
void md_bank_event_display(const void *pevent, INT data_fmt, INT dsp_fmt, INT dsp_mode, const char *bn)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ md_event_swap()

INT EXPRT md_event_swap ( INT  data_fmt,
void pevent 
)

Definition at line 710 of file mdsupport.cxx.

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}
#define FALSE
Definition cfortran.h:309
INT bk_swap(void *event, BOOL force)
Definition midas.cxx:17157
#define CM_SUCCESS
Definition midas.h:582
#define MD_EVENT_NOT_SWAPPED
Definition mdsupport.h:61
#define MD_UNKNOWN_FORMAT
Definition mdsupport.h:67
#define event_id
Here is the call graph for this function:
Here is the caller graph for this function:

◆ md_file_rclose()

INT EXPRT md_file_rclose ( INT  data_fmt)

Definition at line 266 of file mdsupport.cxx.

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}
char * ptopmrd
Definition mdsupport.cxx:71
gzFile filegz
Definition mdsupport.cxx:73
char * pmp
Definition mdsupport.cxx:80
INT type
Definition mdsupport.cxx:91
INT handle
Definition mdsupport.cxx:77
char * pmrd
Definition mdsupport.cxx:83
BOOL zipfile
Definition mdsupport.cxx:93
Here is the call graph for this function:
Here is the caller graph for this function:

◆ md_file_ropen()

INT EXPRT md_file_ropen ( char infile,
INT  data_fmt,
INT  openzip,
INT  max_event_size 
)

dox

Definition at line 184 of file mdsupport.cxx.

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}
#define SS_NO_MEMORY
Definition midas.h:665
#define O_BINARY
Definition msystem.h:219
INT ss_tape_open(char *path, INT oflag, INT *channel)
Definition system.cxx:5811
INT openzip
Definition mdump.cxx:30
INT max_event_size
Definition mfed.cxx:30
#define O_LARGEFILE
Definition midas.h:210
#define TRUE
Definition midas.h:182
#define TAPE_BUFFER_SIZE
Definition midas.h:264
EVENT_HEADER * pme
Definition mdsupport.cxx:82
DWORD recn
Definition mdsupport.cxx:89
DWORD size
Definition mdsupport.cxx:88
char name[128]
Definition mdsupport.cxx:78
Here is the call graph for this function:
Here is the caller graph for this function:

◆ md_file_wclose()

INT EXPRT md_file_wclose ( INT  handle,
INT  type,
INT  data_fmt,
char destination 
)

Definition at line 358 of file mdsupport.cxx.

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}
int ftp_close(FTP_CON *con)
Definition ftplib.cxx:334
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
INT ss_tape_close(INT channel)
Definition system.cxx:5902
INT ss_tape_write_eof(INT channel)
Definition system.cxx:6166
INT i
Definition mdump.cxx:32
Here is the call graph for this function:
Here is the caller graph for this function:

◆ md_file_wopen()

INT EXPRT md_file_wopen ( INT  type,
INT  data_fmt,
char filename,
INT hDev 
)

Definition at line 302 of file mdsupport.cxx.

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}
INT hDev
Here is the call graph for this function:
Here is the caller graph for this function:

◆ md_log_write()

INT EXPRT md_log_write ( INT  handle,
INT  data_fmt,
INT  type,
void prec,
DWORD  nbytes 
)

Definition at line 579 of file mdsupport.cxx.

595{
596 INT status;
598
599 status = data_fmt; /* avoid compiler warning */
600 /* write record */
602 return status;
603}
INT md_dev_os_write(INT handle, INT type, void *prec, DWORD nbytes, DWORD *written)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ md_physrec_get()

INT EXPRT md_physrec_get ( INT  data_fmt,
void **  precord,
DWORD readn 
)

Definition at line 558 of file mdsupport.cxx.

570{
571 *precord = my.pmp;
572 if (data_fmt == FORMAT_MIDAS) {
574 } else
575 return MD_UNKNOWN_FORMAT;
576}
INT midas_physrec_get(void *prec, DWORD *readn)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ md_raw_bank_display()

void md_raw_bank_display ( void pbank,
INT  data_fmt,
INT  dsp_fmt 
)

Definition at line 940 of file mdsupport.cxx.

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}
#define DSP_DEC
Definition mdsupport.h:92
#define DSP_HEX
Definition mdsupport.h:93
#define DSP_ASC
Definition mdsupport.h:94
#define NLINE
Definition mdsupport.h:96
INT j
Definition odbhist.cxx:40
Here is the call graph for this function:
Here is the caller graph for this function:

◆ md_raw_event_display()

void md_raw_event_display ( const void pevent,
INT  data_fmt,
INT  dsp_fmt 
)

Definition at line 765 of file mdsupport.cxx.

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}
double total[100]
Definition odbhist.cxx:42
Here is the call graph for this function:
Here is the caller graph for this function:

◆ midas_bank_display()

void midas_bank_display ( BANK pbk,
INT  dsp_fmt 
)

Definition at line 1117 of file mdsupport.cxx.

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}
unsigned char BYTE
Definition mcstd.h:48
#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 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 DSP_UNK
Definition mdsupport.h:91
char bank_name[4]
Definition mdump.cxx:26
#define DWORD
Definition mhdump.cxx:31
DWORD BOOL
Definition midas.h:105
Here is the call graph for this function:
Here is the caller graph for this function:

◆ midas_bank_display32()

template<typename T >
void midas_bank_display32 ( T *  pbk,
INT  dsp_fmt 
)

Definition at line 1373 of file mdsupport.cxx.

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}
Here is the call graph for this function:

◆ midas_event_get()

INT midas_event_get ( void **  pevent,
DWORD size 
)

◆ midas_event_skip()

INT midas_event_skip ( INT  evtn)

◆ midas_physrec_get()

INT midas_physrec_get ( void prec,
DWORD readn 
)

Definition at line 1075 of file mdsupport.cxx.

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}
INT md_dev_os_read(INT handle, INT type, void *prec, DWORD nbytes, DWORD *nread)
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ filegz

gzFile filegz

Definition at line 73 of file mdsupport.cxx.

◆ filestat

struct stat* filestat

Definition at line 70 of file mdsupport.cxx.

◆ my

MY my

Definition at line 96 of file mdsupport.cxx.

◆ ptopmrd

char* ptopmrd

Definition at line 71 of file mdsupport.cxx.