/* ******************************************************************************* * Copyright (c) 1996 Martin Poole * ******************************************************************************* ** ** WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! ** ** Any changes to be made to this file should first be checked with ** mplib1 source control for library integrity. ** ** mplib1 source control can be reached at mplib1@quatermass.co.uk ** * * $Source: /home/cvs/cvsroot/onelan/onelan/src/mplib1/libsrc/vre_disp.c,v $ * $Author: mpoole $ * $Date: 2002/10/07 09:37:40 $ * $Revision: 1.2 $ * ******************************************************************************* * * Change History * * $Log: vre_disp.c,v $ * Revision 1.2 2002/10/07 09:37:40 mpoole * Initial checkin of mplib1-3.1.0 * * Revision 1.1 2002/10/07 09:36:57 mpoole * Initial checkin of mplib1-3.1.0 * * ******************************************************************************* */ #ident "$Header: /home/cvs/cvsroot/onelan/onelan/src/mplib1/libsrc/vre_disp.c,v 1.2 2002/10/07 09:37:40 mpoole Exp $" /* vre2disp.c vogon record editor. Display only version ******************************************************************** Copyright 1989,90,91,94,95 Martin Poole Released for use by Y2 Computing Limited - 1990 Released for use by Perot Systems Europe Limited - 1995. ******************************************************************** */ /* ------------------------------------------------------------------ Include files ------------------------------------------------------------------ */ #include #include #include #include #include #include #include #include #include /* ------------------------------------------------------------------ defines ------------------------------------------------------------------ */ static int done_init=0; /* ------------------------------------------------------------------ Code starts here ------------------------------------------------------------------ */ /* let's cut to the chase */ static int disp_char( void *ptr, struct vre_disp_walk_item *dwip ) { int boring=1,tlen,mlen; char *cp; if (dwip->eop->eo_Arr_sz>0) { /* might be a printable string */ cp = ptr; tlen=0; mlen = (dwip->eop->eo_Arr_sz==1)?512 : dwip->eop->eo_Arr_sz; while (*cp++ && ++tlen < mlen); if (tlen < mlen) { fprintf( dwip->fp, "\"%s\"", (char *)ptr ); boring=0; } } if (boring) fprintf( dwip->fp, "'%c'",(char) (*(char *)ptr >= ' ' && *(char *)ptr < 0x7f) ? *(char *)ptr : '.' ); return(0); } static int disp_byte( void *ptr, struct vre_disp_walk_item *dwip ) { fprintf( dwip->fp, "%02x",(int) *(unsigned char *)ptr ); return(0); } static int disp_word( void *ptr, struct vre_disp_walk_item *dwip ) { fprintf( dwip->fp, "%04x",(int) *(unsigned short *)ptr ); return(0); } static int disp_long( void *ptr, struct vre_disp_walk_item *dwip ) { fprintf( dwip->fp, "%08x",(int) *(unsigned int *)ptr ); return(0); } static int disp_double( void *ptr, struct vre_disp_walk_item *dwip ) { fprintf( dwip->fp, "%f", *(double *)ptr ); return(0); } static int disp_string( void *ptr, struct vre_disp_walk_item *dwip ) { fprintf( dwip->fp, "%s", (char *)ptr ); return(0); } static int disp_char_ptr( void *ptr, struct vre_disp_walk_item *dwip ) { fprintf( dwip->fp, "%s", *(char **)ptr ); return(0); } static int disp_ptr( void *ptr, struct vre_disp_walk_item *dwip ) { fprintf( dwip->fp, "%p", *(void **)ptr ); return(0); } #ifndef NO_VLONG static int disp_vlong( void *ptr, struct vre_disp_walk_item *dwip ) { /* fprintf( dwip->fp, "%qx",(long long) *(unsigned long long *)ptr );*/ #ifdef L_FOR_LONGLONG fprintf( dwip->fp, "%Lx",(long long) *(unsigned long long *)ptr ); #else fprintf( dwip->fp, "%llx",(long long) *(unsigned long long *)ptr ); #endif return(0); } #endif int vre_Init_Disp_Primitives( FILE *fp ) { vre_Init_VRE( fp ); if (done_init==0) { done_init=1; vre_New_Type( "char", (vre_disp_t)disp_char, 1, MPLIB_ALIGN_SPC_CHAR, 1 ); vre_New_Type( "byte", (vre_disp_t)disp_byte, 1, MPLIB_ALIGN_SPC_CHAR, 1 ); vre_New_Type( "word", (vre_disp_t)disp_word, 2, MPLIB_ALIGN_SPC_SHORT, 1 ); vre_New_Type( "short", (vre_disp_t)disp_word, 2, MPLIB_ALIGN_SPC_SHORT, 1 ); vre_New_Type( "long", (vre_disp_t)disp_long, 4, MPLIB_ALIGN_SPC_LONG, 1 ); vre_New_Type( "int", (vre_disp_t)disp_long, 4, MPLIB_ALIGN_SPC_INT, 1 ); vre_New_Type( "double", (vre_disp_t)disp_double, 8, MPLIB_ALIGN_SPC_DOUBLE, 1 ); vre_New_Type( "string", (vre_disp_t)disp_string, 0, MPLIB_ALIGN_SPC_CHAR, 1 ); vre_New_Type( "char*", (vre_disp_t)disp_char_ptr, 4, MPLIB_ALIGN_SPC_PTR, 1 ); vre_New_Type( "pointer", (vre_disp_t)disp_ptr, 4, MPLIB_ALIGN_SPC_PTR, 1 ); #ifndef NO_VLONG vre_New_Type( "vlong", (vre_disp_t)disp_vlong, 8, MPLIB_ALIGN_SPC_VLONG, 1 ); #endif } return(0); } /* -- End of File -- */