chrout.c 946 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*====================================================================*
  2. *
  3. * void chrout (void const * memory, size_t extent, char c, char e, FILE * fp)
  4. *
  5. * memory.h
  6. *
  7. * print memory as an ASCII character string; replace non-printable
  8. * characters with (c) on output; terminate output with (e);
  9. *
  10. * Motley Tools by Charles Maier <cmaier@cmassoc.net>;
  11. * Copyright (c) 2001-2006 by Charles Maier Associates;
  12. * Licensed under the Internet Software Consortium License;
  13. *
  14. *--------------------------------------------------------------------*/
  15. #ifndef CHROUT_SOURCE
  16. #define CHROUT_SOURCE
  17. #include <stdio.h>
  18. #include <ctype.h>
  19. #include "../tools/memory.h"
  20. void chrout (void const * memory, size_t extent, char c, char e, FILE * fp)
  21. {
  22. byte * offset = (byte *) (memory);
  23. while (extent--)
  24. {
  25. putc (isprint (* offset)? * offset: c, fp);
  26. offset++;
  27. }
  28. if (e)
  29. {
  30. putc (e, fp);
  31. }
  32. return;
  33. }
  34. #endif