binout.c.html 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. binout.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='baudrate.c.html' title=' baudrate.c '>PREV</a>]
  17. [<a href='toolkit.html' title=' Index '>HOME</a>]
  18. [<a href='BootDevice1.c.html' title=' BootDevice1.c '>NEXT</a>]
  19. </div>
  20. <pre>
  21. /*====================================================================*
  22. *
  23. * void binout (void const * memory, size_t extent, char c, char e, FILE * fp)
  24. *
  25. * memory.h
  26. *
  27. * print memory as a series of binary bytes separated by character
  28. * c; normally, character c will be BIN_EXTENDER as defined
  29. * in number.h;
  30. *
  31. * for example, binout (memory, 6, '-', stdout) would print
  32. *
  33. * 00000000-11010000-01010010-00000000-00000000-00000001
  34. *
  35. *
  36. * Motley Tools by Charles Maier &lt;cmaier@cmassoc.net&gt;;
  37. * Copyright (c) 2001-2006 by Charles Maier Associates;
  38. * Licensed under the Internet Software Consortium License;
  39. *
  40. *--------------------------------------------------------------------*/
  41. #ifndef BINOUT_SOURCE
  42. #define BINOUT_SOURCE
  43. #include &lt;stdio.h&gt;
  44. #include &lt;ctype.h&gt;
  45. #include &quot;../tools/memory.h&quot;
  46. #include &quot;../tools/number.h&quot;
  47. void binout (void const * memory, size_t extent, char c, char e, FILE * fp)
  48. {
  49. byte * offset = (byte *)(memory);
  50. while (extent--)
  51. {
  52. unsigned bits = 8;
  53. while (bits--)
  54. {
  55. putc (DIGITS_BIN [(* offset &gt;&gt; bits) &amp; 1], fp);
  56. }
  57. if ((extent) &amp;&amp; (c))
  58. {
  59. putc (c, fp);
  60. }
  61. offset++;
  62. }
  63. if (e)
  64. {
  65. putc (e, fp);
  66. }
  67. return;
  68. }
  69. #endif
  70. </pre>
  71. <div class='footerlink'>
  72. [<a href='baudrate.c.html' title=' baudrate.c '>PREV</a>]
  73. [<a href='toolkit.html' title=' Index '>HOME</a>]
  74. [<a href='BootDevice1.c.html' title=' BootDevice1.c '>NEXT</a>]
  75. </div>
  76. </body>
  77. </html>