memout.c.html 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. memout.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='memincr.c.html' title=' memincr.c '>PREV</a>]
  17. [<a href='toolkit.html' title=' Index '>HOME</a>]
  18. [<a href='memswap.c.html' title=' memswap.c '>NEXT</a>]
  19. </div>
  20. <pre>
  21. /*====================================================================*
  22. *
  23. * void memout (void const * memory, size_t extent, char const * format, unsigned group, char c, char e, FILE * fp)
  24. *
  25. * memory.h
  26. *
  27. * print memory as a series of octets formatted by format string fmt,
  28. * seperated by character c every mod prints;
  29. *
  30. * for example, memout (memory, IPv4_LEN, &quot;%d&quot;, 1, '.', stdout) would print:
  31. *
  32. * 192.168.1.1
  33. *
  34. * another example, memout (memory, IPv6_LEN, &quot;%02x&quot;, 2, ':', stdout) would print:
  35. *
  36. * 0032:0045:0000:0000:0000:0000:1123:4456
  37. *
  38. * Motley Tools by Charles Maier &lt;cmaier@cmassoc.net&gt;;
  39. * Copyright (c) 2001-2006 by Charles Maier Associates;
  40. * Licensed under the Internet Software Consortium License;
  41. *
  42. * Contributor(s):
  43. * Nathaniel Houghton &lt;nhoughto@qca.qualcomm.com&gt;
  44. *
  45. *--------------------------------------------------------------------*/
  46. #ifndef MEMOUT_SOURCE
  47. #define MEMOUT_SOURCE
  48. #include &lt;stdio.h&gt;
  49. #include &lt;stddef.h&gt;
  50. #include &quot;../tools/memory.h&quot;
  51. void memout (void const * memory, size_t extent, char const * format, unsigned group, char c, char e, FILE * fp)
  52. {
  53. byte * origin = (byte *) (memory);
  54. byte * offset = (byte *) (memory);
  55. while (extent--)
  56. {
  57. ptrdiff_t count = (offset - origin) + 1;
  58. fprintf (fp, format, * offset);
  59. if ((count % group) == 0 &amp;&amp; extent)
  60. {
  61. putc (c, fp);
  62. }
  63. offset++;
  64. }
  65. if (e)
  66. {
  67. putc (c, fp);
  68. }
  69. return;
  70. }
  71. #endif
  72. </pre>
  73. <div class='footerlink'>
  74. [<a href='memincr.c.html' title=' memincr.c '>PREV</a>]
  75. [<a href='toolkit.html' title=' Index '>HOME</a>]
  76. [<a href='memswap.c.html' title=' memswap.c '>NEXT</a>]
  77. </div>
  78. </body>
  79. </html>