/* ******************************************************************************* * 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 ** * * System : * Subsystem : * Module : * $Source$ * $Author$ * $Date$ * $Revision$ * ******************************************************************************* * * Change History * * $Log$ * ******************************************************************************* */ #ident "$Header$" /* ------------------------------------------------------------------ Include files ------------------------------------------------------------------ */ #include #include #include #include /* ------------------------------------------------------------------ defines ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ Code starts here ------------------------------------------------------------------ */ static char *find_eos( char *where ) { return(where+strlen(where)); } int do_hex_dump( FILE *fp, off_t curoff, const char *where, int how_much ) { char linebuf[80]; char charbuf[20]; int count16,i; char *eos; /*fprintf(fp, "hex_dump: %p %d\n", where, how_much );*/ count16 = ((int)curoff & 0x0f); while (how_much || count16) { sprintf( linebuf, "%08x ", (int)curoff ); for (i=0;i<16;i++) { eos = find_eos(linebuf); charbuf[i] = ' '; if (i= ' ' && *where<0x7f) { charbuf[i] = *where; } how_much--; }else sprintf(eos, ".. " ); where++; count16++; curoff++; count16 &= 0x0f; } } charbuf[16] = '\0'; fprintf(fp, "%s '%s'\n", linebuf, charbuf ); }; return(1); } int hex_dump( FILE *fp, const char *where, int how_much ) { return(do_hex_dump( fp, 0, where, how_much )); } /* -- End of File -- */