📄 clog_record.c
字号:
int rectype; /* Save hdr->rectype before byte swapping. After byteswapping hdr->rectype will not be understandable */ rectype = hdr->rectype; CLOG_Rec_Header_swap_bytes( hdr ); switch (rectype) { /* No CLOG_REC_UNDEF in CLOG_Rec_swap_bytes, i.e. emit error message */ case CLOG_REC_ENDLOG: break; case CLOG_REC_ENDBLOCK: break; case CLOG_REC_STATEDEF: CLOG_Rec_StateDef_swap_bytes( (CLOG_Rec_StateDef_t *) hdr->rest ); break; case CLOG_REC_EVENTDEF: CLOG_Rec_EventDef_swap_bytes( (CLOG_Rec_EventDef_t *) hdr->rest ); break; case CLOG_REC_CONSTDEF: CLOG_Rec_ConstDef_swap_bytes( (CLOG_Rec_ConstDef_t *) hdr->rest ); break; case CLOG_REC_BAREEVT: CLOG_Rec_BareEvt_swap_bytes( (CLOG_Rec_BareEvt_t *) hdr->rest ); break; case CLOG_REC_CARGOEVT: CLOG_Rec_CargoEvt_swap_bytes( (CLOG_Rec_CargoEvt_t *) hdr->rest ); break; case CLOG_REC_MSGEVT: CLOG_Rec_MsgEvt_swap_bytes( (CLOG_Rec_MsgEvt_t *) hdr->rest ); break; case CLOG_REC_COLLEVT: CLOG_Rec_CollEvt_swap_bytes( (CLOG_Rec_CollEvt_t *) hdr->rest ); break; case CLOG_REC_COMMEVT: CLOG_Rec_CommEvt_swap_bytes( (CLOG_Rec_CommEvt_t *) hdr->rest ); break; case CLOG_REC_SRCLOC: CLOG_Rec_Srcloc_swap_bytes( (CLOG_Rec_Srcloc_t *) hdr->rest ); break; case CLOG_REC_TIMESHIFT: CLOG_Rec_Timeshift_swap_bytes( (CLOG_Rec_Timeshift_t *) hdr->rest ); break; default: fprintf( stderr, __FILE__":CLOG_Rec_swap_bytes_last() - Warning!\n" "\t""Unknown CLOG record type "i32fmt"\n", rectype ); fflush( stderr ); break; }}/* Assume non-readable byte ordering before byteswapping i.e. byteswapping first*/void CLOG_Rec_swap_bytes_first( CLOG_Rec_Header_t *hdr ){ CLOG_Rec_Header_swap_bytes( hdr ); /* After byteswapping, hdr->rectype is understandable */ switch (hdr->rectype) { /* No CLOG_REC_UNDEF in CLOG_Rec_pre_swap_bytes, i.e. emit error message */ case CLOG_REC_ENDLOG: break; case CLOG_REC_ENDBLOCK: break; case CLOG_REC_STATEDEF: CLOG_Rec_StateDef_swap_bytes( (CLOG_Rec_StateDef_t *) hdr->rest ); break; case CLOG_REC_EVENTDEF: CLOG_Rec_EventDef_swap_bytes( (CLOG_Rec_EventDef_t *) hdr->rest ); break; case CLOG_REC_CONSTDEF: CLOG_Rec_ConstDef_swap_bytes( (CLOG_Rec_ConstDef_t *) hdr->rest ); break; case CLOG_REC_BAREEVT: CLOG_Rec_BareEvt_swap_bytes( (CLOG_Rec_BareEvt_t *) hdr->rest ); break; case CLOG_REC_CARGOEVT: CLOG_Rec_CargoEvt_swap_bytes( (CLOG_Rec_CargoEvt_t *) hdr->rest ); break; case CLOG_REC_MSGEVT: CLOG_Rec_MsgEvt_swap_bytes( (CLOG_Rec_MsgEvt_t *) hdr->rest ); break; case CLOG_REC_COLLEVT: CLOG_Rec_CollEvt_swap_bytes( (CLOG_Rec_CollEvt_t *) hdr->rest ); break; case CLOG_REC_COMMEVT: CLOG_Rec_CommEvt_swap_bytes( (CLOG_Rec_CommEvt_t *) hdr->rest ); break; case CLOG_REC_SRCLOC: CLOG_Rec_Srcloc_swap_bytes( (CLOG_Rec_Srcloc_t *) hdr->rest ); break; case CLOG_REC_TIMESHIFT: CLOG_Rec_Timeshift_swap_bytes( (CLOG_Rec_Timeshift_t *) hdr->rest ); break; default: fprintf( stderr, __FILE__":CLOG_Rec_swap_bytes_first() - Warning!\n" "\t""Unknown CLOG record type "i32fmt"\n", hdr->rectype ); fflush( stderr ); break; }}void CLOG_Rec_print( CLOG_Rec_Header_t *hdr, FILE *stream ){ CLOG_Rec_Header_print( hdr, stream ); switch (hdr->rectype) { /* No CLOG_REC_UNDEF in CLOG_Rec_print, i.e. emit error message */ case CLOG_REC_ENDLOG: fprintf( stream, "\n\n\n" ); break; case CLOG_REC_ENDBLOCK: fprintf( stream, "\n\n" ); break; case CLOG_REC_STATEDEF: CLOG_Rec_StateDef_print( (CLOG_Rec_StateDef_t *) hdr->rest, stream ); break; case CLOG_REC_EVENTDEF: CLOG_Rec_EventDef_print( (CLOG_Rec_EventDef_t *) hdr->rest, stream ); break; case CLOG_REC_CONSTDEF: CLOG_Rec_ConstDef_print( (CLOG_Rec_ConstDef_t *) hdr->rest, stream ); break; case CLOG_REC_BAREEVT: CLOG_Rec_BareEvt_print( (CLOG_Rec_BareEvt_t *) hdr->rest, stream ); break; case CLOG_REC_CARGOEVT: CLOG_Rec_CargoEvt_print( (CLOG_Rec_CargoEvt_t *) hdr->rest, stream ); break; case CLOG_REC_MSGEVT: CLOG_Rec_MsgEvt_print( (CLOG_Rec_MsgEvt_t *) hdr->rest, stream ); break; case CLOG_REC_COLLEVT: CLOG_Rec_CollEvt_print( (CLOG_Rec_CollEvt_t *) hdr->rest, stream ); break; case CLOG_REC_COMMEVT: CLOG_Rec_CommEvt_print( (CLOG_Rec_CommEvt_t *) hdr->rest, stream ); break; case CLOG_REC_SRCLOC: CLOG_Rec_Srcloc_print( (CLOG_Rec_Srcloc_t *) hdr->rest, stream ); break; case CLOG_REC_TIMESHIFT: CLOG_Rec_Timeshift_print( (CLOG_Rec_Timeshift_t *) hdr->rest, stream ); break; default: fprintf( stderr, __FILE__":CLOG_Rec_print() - \n" "\t""Unrecognized CLOG record type "i32fmt"\n", hdr->rectype ); fflush( stderr ); break; } fflush( stream );}static int clog_reclens[ CLOG_REC_NUM ];static int clog_reclen_max;/* Pre-compute the record size or disk footprint of a complete record, i.e. CLOG_Rec_Header_t + CLOG_Rec_xxx_t, as given by CLOG_Rec_size().*/void CLOG_Rec_sizes_init( void ){ clog_reclen_max = 0; clog_reclens[ CLOG_REC_ENDLOG ] = CLOG_RECLEN_HEADER; if ( clog_reclens[ CLOG_REC_ENDLOG ] > clog_reclen_max ) clog_reclen_max = clog_reclens[ CLOG_REC_ENDLOG ]; clog_reclens[ CLOG_REC_ENDBLOCK ] = CLOG_RECLEN_HEADER; if ( clog_reclens[ CLOG_REC_ENDBLOCK ] > clog_reclen_max ) clog_reclen_max = clog_reclens[ CLOG_REC_ENDBLOCK ]; clog_reclens[ CLOG_REC_STATEDEF ] = CLOG_RECLEN_HEADER + CLOG_RECLEN_STATEDEF; if ( clog_reclens[ CLOG_REC_STATEDEF ] > clog_reclen_max ) clog_reclen_max = clog_reclens[ CLOG_REC_STATEDEF ]; clog_reclens[ CLOG_REC_EVENTDEF ] = CLOG_RECLEN_HEADER + CLOG_RECLEN_EVENTDEF; if ( clog_reclens[ CLOG_REC_EVENTDEF ] > clog_reclen_max ) clog_reclen_max = clog_reclens[ CLOG_REC_EVENTDEF ]; clog_reclens[ CLOG_REC_CONSTDEF ] = CLOG_RECLEN_HEADER + CLOG_RECLEN_CONSTDEF; if ( clog_reclens[ CLOG_REC_CONSTDEF ] > clog_reclen_max ) clog_reclen_max = clog_reclens[ CLOG_REC_CONSTDEF ]; clog_reclens[ CLOG_REC_BAREEVT ] = CLOG_RECLEN_HEADER + CLOG_RECLEN_BAREEVT; if ( clog_reclens[ CLOG_REC_BAREEVT ] > clog_reclen_max ) clog_reclen_max = clog_reclens[ CLOG_REC_BAREEVT ]; clog_reclens[ CLOG_REC_CARGOEVT ] = CLOG_RECLEN_HEADER + CLOG_RECLEN_CARGOEVT; if ( clog_reclens[ CLOG_REC_CARGOEVT ] > clog_reclen_max ) clog_reclen_max = clog_reclens[ CLOG_REC_CARGOEVT ]; clog_reclens[ CLOG_REC_MSGEVT ] = CLOG_RECLEN_HEADER + CLOG_RECLEN_MSGEVT; if ( clog_reclens[ CLOG_REC_MSGEVT ] > clog_reclen_max ) clog_reclen_max = clog_reclens[ CLOG_REC_MSGEVT ]; clog_reclens[ CLOG_REC_COLLEVT ] = CLOG_RECLEN_HEADER + CLOG_RECLEN_COLLEVT; if ( clog_reclens[ CLOG_REC_COLLEVT ] > clog_reclen_max ) clog_reclen_max = clog_reclens[ CLOG_REC_COLLEVT ]; clog_reclens[ CLOG_REC_COMMEVT ] = CLOG_RECLEN_HEADER + CLOG_RECLEN_COMMEVT; if ( clog_reclens[ CLOG_REC_COMMEVT ] > clog_reclen_max ) clog_reclen_max = clog_reclens[ CLOG_REC_COMMEVT ]; clog_reclens[ CLOG_REC_SRCLOC ] = CLOG_RECLEN_HEADER + CLOG_RECLEN_SRCLOC; if ( clog_reclens[ CLOG_REC_SRCLOC ] > clog_reclen_max ) clog_reclen_max = clog_reclens[ CLOG_REC_SRCLOC ]; clog_reclens[ CLOG_REC_TIMESHIFT ] = CLOG_RECLEN_HEADER + CLOG_RECLEN_TIMESHIFT; if ( clog_reclens[ CLOG_REC_TIMESHIFT ] > clog_reclen_max ) clog_reclen_max = clog_reclens[ CLOG_REC_TIMESHIFT ];}/* CLOG_Rec_size() - returns complete record size on the disk, ie. disk footprint.*/int CLOG_Rec_size( CLOG_int32_t rectype ){ if ( rectype < CLOG_REC_NUM && rectype >= 0 ) return clog_reclens[ rectype ]; else { fprintf( stderr, __FILE__":CLOG_Rec_size() - Warning!" "\t""Unknown record type "i32fmt"\n", rectype ); fflush( stderr ); /* Assume it has at least a CLOG_Rec_Header_t, so length of CLOG_REC_ENDLOG Instead of "return clog_reclens[ CLOG_REC_ENDLOG ];", force a coredump */ return clog_reclens[ rectype ]; }}int CLOG_Rec_size_max( void ){ return clog_reclen_max;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -