memory.h.html 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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. memory.h
  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='mdio.h.html' title=' mdio.h '>PREV</a>]
  17. [<a href='toolkit.html' title=' Index '>HOME</a>]
  18. [<a href='mme.h.html' title=' mme.h '>NEXT</a>]
  19. </div>
  20. <pre>
  21. /*====================================================================*
  22. *
  23. * memory.h - memory encode/decode definitions and delcaration;
  24. *
  25. * this file is a subset of the original that includes only those
  26. * definitions and declaration needed for toolkit programs;
  27. *
  28. * Motley Tools by Charles Maier &lt;cmaier@cmassoc.net&gt;;
  29. * Copyright 2001-2006 by Charles Maier Associates;
  30. * Licensed under the Internet Software Consortium License;
  31. *
  32. *--------------------------------------------------------------------*/
  33. #ifndef MEMORY_HEADER
  34. #define MEMORY_HEADER
  35. /*====================================================================*
  36. * system header files;
  37. *--------------------------------------------------------------------*/
  38. #include &lt;stdio.h&gt;
  39. #include &lt;unistd.h&gt;
  40. #include &lt;stdint.h&gt;
  41. #include &lt;netinet/in.h&gt;
  42. /*====================================================================*
  43. * custom header files;
  44. *--------------------------------------------------------------------*/
  45. #include &quot;../tools/types.h&quot;
  46. #include &quot;../tools/endian.h&quot;
  47. /*====================================================================*
  48. *
  49. *--------------------------------------------------------------------*/
  50. #define IPv4_LEN 4
  51. #define IPv6_LEN 16
  52. /*====================================================================*
  53. *
  54. *--------------------------------------------------------------------*/
  55. #ifndef offset
  56. #define offset(struct, member) (signed)(&amp;struct.member)-(signed)(&amp;struct)
  57. #endif
  58. /*====================================================================*
  59. *
  60. *--------------------------------------------------------------------*/
  61. #define HEXSTRING(string, memory) hexstring (string, sizeof (string), memory, sizeof (memory))
  62. #define HEXDUMP_HEADER &quot;-------- 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F ----------------\n&quot;
  63. #define REGVIEW32_HEADER &quot;REGISTER CONTENTS 31----24 23----16 15----08 07----00\n&quot;
  64. #define REGVIEW16_HEADER &quot;ADDR DATA 5432 1098 7654 3210\n&quot;
  65. #define ADDRSIZE 8
  66. /*====================================================================*
  67. * macro expansions;
  68. *--------------------------------------------------------------------*/
  69. #define NEW(object) (object *)(emalloc(sizeof(object)))
  70. #define STR(length) (char *)(emalloc((length)+1))
  71. /*====================================================================*
  72. * memory increment/decrement functions;
  73. *--------------------------------------------------------------------*/
  74. signed strincr (void * memory, size_t extent, byte min, byte max);
  75. signed strdecr (void * memory, size_t extent, byte min, byte max);
  76. signed memincr (void * memory, size_t extent);
  77. signed memdecr (void * memory, size_t extent);
  78. /*====================================================================*
  79. *
  80. *--------------------------------------------------------------------*/
  81. bool memseek (void const * memory, size_t extent, void const * buffer, size_t length);
  82. /*====================================================================*
  83. * memory allocation functions;
  84. *--------------------------------------------------------------------*/
  85. void * emalloc (size_t length);
  86. /*====================================================================*
  87. * memory movement functions;
  88. *--------------------------------------------------------------------*/
  89. void memswap (void *, void *, size_t extent);
  90. void reverse (void * memory, size_t extent);
  91. /*====================================================================*
  92. * memory validation functions (deprecated);
  93. *--------------------------------------------------------------------*/
  94. uint32_t checksum_32 (const uint32_t memory [], size_t extent, uint32_t checksum);
  95. uint32_t fdchecksum_32 (int fd, size_t extent, uint32_t checksum);
  96. /*====================================================================*
  97. * memory validation functions;
  98. *--------------------------------------------------------------------*/
  99. uint32_t checksum32 (void const * memory, size_t extent, uint32_t checksum);
  100. uint32_t fdchecksum32 (int fd, size_t extent, uint32_t checksum);
  101. /*====================================================================*
  102. * memory encode functions;
  103. *--------------------------------------------------------------------*/
  104. size_t memencode (void * memory, size_t extent, char const * format, char const * string);
  105. size_t hexencode (void * memory, size_t extent, char const * string);
  106. size_t hexcopy (void * memory, size_t extent, char const * string);
  107. size_t decencode (void * memory, size_t extent, char const * string);
  108. size_t memdecode (void const * memory, size_t extent, char const * format, char const * string);
  109. size_t hexdecode (void const * memory, size_t extent, char buffer [], size_t length);
  110. size_t decdecode (void const * memory, size_t extent, char buffer [], size_t length);
  111. char * hexstring (char buffer [], size_t length, void const * memory, size_t extent);
  112. char * decstring (char buffer [], size_t length, void const * memory, size_t extent);
  113. char * hexoffset (char buffer [], size_t length, off_t offset);
  114. size_t bytespec (char const * string, void * memory, size_t extent);
  115. size_t dataspec (char const * string, void * memory, size_t extent);
  116. size_t ipv4spec (char const * string, void * memory);
  117. size_t ipv6spec (char const * string, void * memory);
  118. /*====================================================================*
  119. * memory input functions;
  120. *--------------------------------------------------------------------*/
  121. size_t hexload (void * memory, size_t extent, FILE *fp);
  122. /*====================================================================*
  123. * memory output functions;
  124. *--------------------------------------------------------------------*/
  125. void hexwrite (signed fd, void const * memory, size_t extent);
  126. void hexsave (void const * memory, size_t extent, size_t column, FILE *fp);
  127. void hexdump (void const * memory, size_t offset, size_t extent, FILE *fp);
  128. void bindump (void const * memory, size_t offset, size_t extent, FILE *fp);
  129. void hexview (void const * memory, size_t offset, size_t extent, FILE *fp);
  130. void hexpeek (void const * memory, size_t origin, size_t offset, size_t extent, size_t window, FILE * fp);
  131. void regview16 (void const * memory, size_t offset, size_t extent, FILE *fp);
  132. void regview32 (void const * memory, size_t offset, size_t extent, FILE *fp);
  133. void hexout (void const * memory, size_t extent, char c, char e, FILE *fp);
  134. void decout (void const * memory, size_t extent, char c, char e, FILE *fp);
  135. void binout (void const * memory, size_t extent, char c, char e, FILE *fp);
  136. void chrout (void const * memory, size_t extent, char c, char e, FILE *fp);
  137. void memout (void const * memory, size_t extent, char const * format, unsigned group, char c, char e, FILE *fp);
  138. /*====================================================================*
  139. * end definitions;
  140. *--------------------------------------------------------------------*/
  141. #endif
  142. </pre>
  143. <div class='footerlink'>
  144. [<a href='mdio.h.html' title=' mdio.h '>PREV</a>]
  145. [<a href='toolkit.html' title=' Index '>HOME</a>]
  146. [<a href='mme.h.html' title=' mme.h '>NEXT</a>]
  147. </div>
  148. </body>
  149. </html>