hexout.c.html 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?xml version='1.0' encoding='iso-8859-1'?>
  2. <!doctype html public '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
  3. <html xmlns='http://www.w3c.org/1999/xhtml' lang='en-us'>
  4. <head>
  5. <title>
  6. hexout.c
  7. </title>
  8. <meta http-equiv='content-type' content='text/html;iso-8859-1'/>
  9. <meta name='generator' content='motley-tools 1.9.4 13:40:33 Feb 18 2015'/>
  10. <meta name='author' content='cmaier@cmassoc.net'/>
  11. <meta name='robots' content='noindex,nofollow'/>
  12. <link href='toolkit.css' rel='stylesheet' type='text/css'/>
  13. </head>
  14. <body>
  15. <div class='headerlink'>
  16. [<a href='hexoffset.c.html' title=' hexoffset.c '>PREV</a>]
  17. [<a href='toolkit.html' title=' Index '>HOME</a>]
  18. [<a href='hexpeek.c.html' title=' hexpeek.c '>NEXT</a>]
  19. </div>
  20. <pre>
  21. /*====================================================================*
  22. *
  23. * void hexout (void const * memory, size_t extent, char c, char e, FILE * fp);
  24. *
  25. * memory.h
  26. *
  27. * print memory as a series of hexadecimal octets seperated by
  28. * character c; normally, character c will be HEX_EXTENDER as
  29. * defined in number.h;
  30. *
  31. * for example, hexout (memory, 6, ':', ';', stdout) would print:
  32. *
  33. * 00:B0:52:00:00:01;
  34. *
  35. * Motley Tools by Charles Maier &lt;cmaier@cmassoc.net&gt;;
  36. * Copyright (c) 2001-2006 by Charles Maier Associates;
  37. * Licensed under the Internet Software Consortium License;
  38. *
  39. *--------------------------------------------------------------------*/
  40. #ifndef HEXOUT_SOURCE
  41. #define HEXOUT_SOURCE
  42. #include &lt;stdio.h&gt;
  43. #include &lt;ctype.h&gt;
  44. #include &quot;../tools/memory.h&quot;
  45. #include &quot;../tools/number.h&quot;
  46. void hexout (void const * memory, size_t extent, char c, char e, FILE * fp)
  47. {
  48. byte * offset = (byte *)(memory);
  49. while (extent--)
  50. {
  51. putc (DIGITS_HEX [(* offset &gt;&gt; 4) &amp; 0x0F], fp);
  52. putc (DIGITS_HEX [(* offset &gt;&gt; 0) &amp; 0x0F], fp);
  53. if ((extent) &amp;&amp; (c))
  54. {
  55. putc (c, fp);
  56. }
  57. offset++;
  58. }
  59. if (e)
  60. {
  61. putc (e, fp);
  62. }
  63. return;
  64. }
  65. #endif
  66. </pre>
  67. <div class='footerlink'>
  68. [<a href='hexoffset.c.html' title=' hexoffset.c '>PREV</a>]
  69. [<a href='toolkit.html' title=' Index '>HOME</a>]
  70. [<a href='hexpeek.c.html' title=' hexpeek.c '>NEXT</a>]
  71. </div>
  72. </body>
  73. </html>