omemory.xml 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458
  1. <chapter id='omemory'>
  2. <title>
  3. Class omemory
  4. </title>
  5. <section id="omemory-class" >
  6. <title>
  7. Introduction
  8. </title>
  9. <para>
  10. This class is a memory manipulation Easter basket. Class methods copy, reorder, increment, decrement, encode and decode variable-length memory regions on a byte level.
  11. </para>
  12. <para>
  13. It is declared in <ulink url='omemory.hpp.html'>omemory.hpp</ulink> and implemented in <ulink url='omemory.cpp.html'>omemory.cpp</ulink>.
  14. </para>
  15. <section id="omemory-inheritance">
  16. <title>
  17. Inheritance
  18. </title>
  19. <para>
  20. None.
  21. </para>
  22. </section>
  23. <section id="omemory-dependence">
  24. <title>
  25. Dependencies
  26. </title>
  27. <para>
  28. This class depends on static class <link linkend='oerror'>oerror</link> to report errors.
  29. </para>
  30. <para>
  31. This class needs header file <filename>stdint.h</filename> for the definition of <acronym>POSIX</acronym> data types <varname>uint8_t</varname>, <varname>uint16_t</varname> and <varname>uint32_t</varname>. An abridged version of this file is provided in <ulink url='stdint.h.html'>VisualStudioNET/include/stdint.h</ulink> for systems that do not have it.
  32. </para>
  33. </section>
  34. </section>
  35. <section id="omemory-methods">
  36. <title>
  37. Methods
  38. </title>
  39. <section id="omemory-bindecode">
  40. <title>
  41. omemory::bindecode
  42. </title>
  43. <funcsynopsis>
  44. <funcprototype>
  45. <funcdef>signed <function>bindecode</function></funcdef>
  46. <paramdef>void * <parameter>memory</parameter></paramdef>
  47. <paramdef>size_t <parameter>extent</parameter></paramdef>
  48. <paramdef>char const <parameter>buffer</parameter> []</paramdef>
  49. <paramdef>size_t <parameter>length</parameter></paramdef>
  50. </funcprototype>
  51. </funcsynopsis>
  52. <para>
  53. Decode a <varname>memory</varname> region as a string of <acronym>ASCII</acronym> binary digits. Convert <varname>memory</varname> until the <varname>buffer</varname> or <varname>memory</varname> exhausts and return the string length. Allow <constant>9</constant> <varname>buffer</varname> characters for each <varname>memory</varname> byte to ensure that the entire region is decoded. If <varname>buffer</varname> is less than <constant>9</constant> characters nothing will be decoded. The number of bytes decoded will be the lesser of <varname>extent</varname> or <varname>length</varname> divided by <constant>9</constant>.
  54. </para>
  55. </section>
  56. <section id="omemory-binout">
  57. <title>
  58. omemory::binout
  59. </title>
  60. <funcsynopsis>
  61. <funcprototype>
  62. <funcdef>void <function>binout</function></funcdef>
  63. <paramdef>void const * <parameter>memory</parameter></paramdef>
  64. <paramdef>size_t <parameter>extent</parameter></paramdef>
  65. <paramdef>char <parameter>c</parameter></paramdef>
  66. <paramdef>FILE * <parameter>fp</parameter></paramdef>
  67. </funcprototype>
  68. </funcsynopsis>
  69. <para>
  70. Print a <varname>memory</varname> region as a series of binary octets separated by character <varname>c</varname>. Normally, character <varname>c</varname> will be <constant>BIN_EXTENDER</constant>, as defined in file <ulink url="number.h.html">onumber.hpp</ulink>, but it could be any character value. For example, specifying <varname>c</varname> as <constant>'-'</constant> and <varname>extent</varname> as <constant>4</constant> would produce output looking something like <computeroutput>"10101010-1111111-00000000-11001100"</computeroutput> where each octet is expressed as a binary integer. A typical use might be to print a <acronym>register</acronym> in readable format.
  71. </para>
  72. </section>
  73. <section id="omemory-binstring">
  74. <title>
  75. omemory::binstring
  76. </title>
  77. <funcsynopsis>
  78. <funcprototype>
  79. <funcdef>char * <function>binstring</function></funcdef>
  80. <paramdef>char <parameter>buffer</parameter> []</paramdef>
  81. <paramdef>size_t <parameter>length</parameter></paramdef>
  82. <paramdef>void const * <parameter>memory</parameter></paramdef>
  83. <paramdef>size_t <parameter>extent</parameter></paramdef>
  84. </funcprototype>
  85. </funcsynopsis>
  86. <para>
  87. Convert a <varname>memory</varname> region to a <constant>NUL</constant> terminated string if <acronym>ASCII</acronym> binary digits and return the string address. This method is similar to method <link linkend='omemory-bindecode'>bindecode</link> but the argument order in different and it returns the string address instead of the number of characters decoded.
  88. </para>
  89. </section>
  90. <section id="omemory-checksum16">
  91. <title>
  92. omemory::checksum16
  93. </title>
  94. <funcsynopsis>
  95. <funcprototype>
  96. <funcdef>uint16_t <function>checksum16</function></funcdef>
  97. <paramdef>const void * <parameter>memory</parameter></paramdef>
  98. <paramdef>size_t <parameter>extent</parameter></paramdef>
  99. <paramdef>uint16_t <parameter>checksum</parameter></paramdef>
  100. </funcprototype>
  101. </funcsynopsis>
  102. <para>
  103. Return the 16-bit checksum of a <varname>memory</varname> region. The checksum is the one's complement of the XOR of all 16-bit words in the region. Argument <varname>extent</varname> is the region size in bytes and is rounded down to the neares multiple of two bytes. This method will return the computed checksum when argument <varname>checksum</varname> is <constant>0</constant> and return <constant>0</constant> when argument <varname>checksum</varname> matches the computed checksum.
  104. </para>
  105. </section>
  106. <section id="omemory-checksum32">
  107. <title>
  108. omemory::checksum32
  109. </title>
  110. <funcsynopsis>
  111. <funcprototype>
  112. <funcdef>uint32_t <function>checksum32</function></funcdef>
  113. <paramdef>const void * <parameter>memory</parameter></paramdef>
  114. <paramdef>size_t <parameter>extent</parameter></paramdef>
  115. <paramdef>uint32_t <parameter>checksum</parameter></paramdef>
  116. </funcprototype>
  117. </funcsynopsis>
  118. <para>
  119. Return the 32-bit checksum of a <varname>memory</varname> region. The checksum is the one's complement of the XOR of all 32-bit words in the region. Argument <varname>length</varname> is the region size in bytes and is rounded down to the nearest multiple of four bytes. This method will return the computed checksum when argument <varname>checksum</varname> is <constant>0</constant> and return <constant>0</constant> when argument <varname>checksum</varname> matches the computed checksum. A typical use is <filename>.pib</filename> and <filename>.nvm</filename> file checksum computation or validation.
  120. </para>
  121. </section>
  122. <section id="omemory-decdecode">
  123. <title>
  124. omemory::decdecode
  125. </title>
  126. <funcsynopsis>
  127. <funcprototype>
  128. <funcdef>signed <function>decdecode</function></funcdef>
  129. <paramdef>void * <parameter>memory</parameter></paramdef>
  130. <paramdef>size_t <parameter>extent</parameter></paramdef>
  131. <paramdef>char const <parameter>buffer</parameter> []</paramdef>
  132. <paramdef>size_t <parameter>length</parameter></paramdef>
  133. </funcprototype>
  134. </funcsynopsis>
  135. <para>
  136. Decode a <varname>memory</varname> region as a <constant>NUL</constant> terminated string of <acronym>ASCII</acronym> decimal digits. Convert <varname>memory</varname> until the <varname>buffer</varname> or <varname>memory</varname> exhausts then return the string length. Allow <constant>4</constant> <varname>buffer</varname> characters for each <varname>memory</varname> byte to ensure that the entire region is decoded. If <varname>buffer</varname> is less than <constant>4</constant> characters nothing will be decoded. The number of bytes decoded will be the lesser of <varname>extent</varname> or <varname>length</varname> divided by <constant>4</constant>.
  137. </para>
  138. </section>
  139. <section id="omemory-decode">
  140. <title>
  141. omemory::decode
  142. </title>
  143. <funcsynopsis>
  144. <funcprototype>
  145. <funcdef>void const * <function>decode</function></funcdef>
  146. <paramdef>void const * <parameter>memory</parameter></paramdef>
  147. <paramdef>void * <parameter>target</parameter></paramdef>
  148. <paramdef>size_t <parameter>extent</parameter></paramdef>
  149. </funcprototype>
  150. </funcsynopsis>
  151. <para>
  152. Copy a <varname>memory</varname> region to some <varname>target</varname> location and return the address of the next uncopied memory byte. The <varname>memory</varname> address is incremented by the region <varname>extent</varname> and returned as the method value. This method is similar to the <link linkend='omemory-encode'>encode</link> method except for the direction of copy. This method may be used to sequentially unpack buffer fields into diverse memory locations.
  153. </para>
  154. </section>
  155. <section id="omemory-decstring">
  156. <title>
  157. omemory::decstring
  158. </title>
  159. <funcsynopsis>
  160. <funcprototype>
  161. <funcdef>char * <function>decstring</function></funcdef>
  162. <paramdef>char <parameter>buffer</parameter> []</paramdef>
  163. <paramdef>size_t <parameter>length</parameter></paramdef>
  164. <paramdef>void const * <parameter>memory</parameter></paramdef>
  165. <paramdef>size_t <parameter>extent</parameter></paramdef>
  166. </funcprototype>
  167. </funcsynopsis>
  168. <para>
  169. Convert a <varname>memory</varname> region to a <constant>NUL</constant> terminated string and return the string address. This method is similar to method <link linkend='omemory-decdecode'>decdecode</link> but the arguments are in different order and it returns the string address instead of the number of characters decoded.
  170. </para>
  171. </section>
  172. <section id="omemory-decout">
  173. <title>
  174. omemory::decout
  175. </title>
  176. <funcsynopsis>
  177. <funcprototype>
  178. <funcdef>void <function>decout</function></funcdef>
  179. <paramdef>void const * <parameter>memory</parameter></paramdef>
  180. <paramdef>size_t <parameter>extent</parameter></paramdef>
  181. <paramdef>char <parameter>c</parameter></paramdef>
  182. <paramdef>FILE * <parameter>fp</parameter></paramdef>
  183. </funcprototype>
  184. </funcsynopsis>
  185. <para>
  186. Print a <varname>memory</varname> region as a series of decimal octets separated by character <constant>c</constant>. Normally, character <constant>c</constant> will be <constant>DEC_EXTENDER</constant>, defined in file <ulink url="onumber.hpp.html">onumber.hpp</ulink>, but it could be any character value. For example, specifying <varname>c</varname> as <constant>'.'</constant> and <varname>extent</varname> as <constant>4</constant> would produce output looking something like <computeroutput>"192.168.099.001"</computeroutput> where each octet is expressed as a decimal integer. A typical use might be to print an <acronym>IP</acronym> or <acronym>MAC</acronym> address in readable format.
  187. </para>
  188. </section>
  189. <section id="omemory-encode">
  190. <title>
  191. omemory::encode
  192. </title>
  193. <funcsynopsis>
  194. <funcprototype>
  195. <funcdef>void * <function>encode</function></funcdef>
  196. <paramdef>void * <parameter>memory</parameter></paramdef>
  197. <paramdef>void const * <parameter>source</parameter></paramdef>
  198. <paramdef>size_t <parameter>extent</parameter></paramdef>
  199. </funcprototype>
  200. </funcsynopsis>
  201. <para>
  202. Copy a <varname>memory</varname> region from some <varname>source</varname> location and return the address of the next uncopied memory byte. The <varname>memory</varname> address is incremented by the region <varname>extent</varname> and returned as the method value. This method is similar to the <link linkend='omemory-decode'>decode</link> method except for the direction of copy. This method can be used to sequentially pack buffer fields with data from diverse memory locations.
  203. </para>
  204. </section>
  205. <section id="omemory-endian">
  206. <title>
  207. omemory::endian
  208. </title>
  209. <funcsynopsis>
  210. <funcprototype>
  211. <funcdef>void <function>endian</function></funcdef>
  212. <paramdef>void * <parameter>memory</parameter></paramdef>
  213. <paramdef>size_t <parameter>extent</parameter></paramdef>
  214. </funcprototype>
  215. </funcsynopsis>
  216. <para>
  217. Reverse the byte order of a <varname>memory</varname> region. It is a variable-length version of methods like <function>__bswap_16</function>, <function>__bswap_32</function> and <function>__bswap_64</function>.
  218. </para>
  219. </section>
  220. <section id="omemory-hexdecode">
  221. <title>
  222. omemory::hexdecode
  223. </title>
  224. <funcsynopsis>
  225. <funcprototype>
  226. <funcdef>signed <function>hexdecode</function></funcdef>
  227. <paramdef>void * <parameter>memory</parameter></paramdef>
  228. <paramdef>size_t <parameter>extent</parameter></paramdef>
  229. <paramdef>char const <parameter>buffer</parameter> []</paramdef>
  230. <paramdef>size_t <parameter>length</parameter></paramdef>
  231. </funcprototype>
  232. </funcsynopsis>
  233. <para>
  234. Decode a <varname>memory</varname> region as a string of <acronym>ASCII</acronym> hexadecimal digits. Convert memory until the <varname>buffer</varname> or <varname>memory</varname> exhausts and return the string length. Allow <constant>3</constant> <varname>buffer</varname> characters for each <varname>memory</varname> byte to ensure that the entire region is decoded. If <varname>buffer</varname> is less than <constant>3</constant> characters nothing will be decoded. The number of bytes decoded will be the lesser of <varname>extent</varname> or <varname>length</varname> divided by <constant>3</constant>.
  235. </para>
  236. </section>
  237. <section id="omemory-hexdump">
  238. <title>
  239. omemory::hexdump
  240. </title>
  241. <funcsynopsis>
  242. <funcprototype>
  243. <funcdef>void <function>hexdump</function></funcdef>
  244. <paramdef>void const * <parameter>memory</parameter></paramdef>
  245. <paramdef>size_t <parameter>offset</parameter></paramdef>
  246. <paramdef>size_t <parameter>extent</parameter></paramdef>
  247. <paramdef>FILE * <parameter>fp</parameter></paramdef>
  248. </funcprototype>
  249. </funcsynopsis>
  250. <para>
  251. Print a full or partial <varname>memory</varname> region in hexadecimal format showing memory offsets, hexadecimal byte values and ASCII character values. Argumen <varname>extent</varname> is the region size in bytes. Argument <varname>offset</varname> is the starting display location. Locations <varname>memory</varname> [<varname>offset</varname>] up to <varname>memory</varname> [<varname>extent</varname>] are displayed, allowing a partial dump of the entire region. The entire region will be displayed when argument <varname>offset</varname> is <constant>0</constant>.
  252. </para>
  253. <para>
  254. This method is similar to but different from method <link linkend='omemory-hexview'>hexview</link> .
  255. </para>
  256. </section>
  257. <section id="omemory-hexencode">
  258. <title>
  259. omemory::hexencode
  260. </title>
  261. <funcsynopsis>
  262. <funcprototype>
  263. <funcdef>signed <function>hexencode</function></funcdef>
  264. <paramdef>void const * <parameter>memory</parameter></paramdef>
  265. <paramdef>size_t <parameter>extent</parameter></paramdef>
  266. <paramdef>char const * <parameter>string</parameter></paramdef>
  267. </funcprototype>
  268. </funcsynopsis>
  269. <para>
  270. Encode a <varname>memory</varname> region with the binary equivalent of an <acronym>ASCII</acronym> hexadecimal string. Return the number of bytes encoded or <constant>0</constant> on error. The value of <varname>errno</varname> is set to <constant>EINVAL</constant> if the number of bytes encoded is less than <varname>extent</varname> or the entire string cannot be converted due to illegal digits or excessive digits. Ignore optional <constant>HEX_EXTENDER</constant> characters separating octets in argument <varname>string</varname>. Constant <constant>HEX_EXTENDER</constant> is defined in file <ulink url='onumber.hpp.html'>onumber.hpp</ulink>.
  271. </para>
  272. </section>
  273. <section id="omemory-hexin">
  274. <title>
  275. omemory::hexload
  276. </title>
  277. <funcsynopsis>
  278. <funcprototype>
  279. <funcdef>ssize_t <function>hexload</function></funcdef>
  280. <paramdef>void * <parameter>memory</parameter></paramdef>
  281. <paramdef>size_t <parameter>extent</parameter></paramdef>
  282. <paramdef>FILE * <parameter>fp</parameter></paramdef>
  283. </funcprototype>
  284. </funcsynopsis>
  285. <para>
  286. This method is similar to <link linkend="omemory-hexencode">hexencode</link> but it reads from file, instead of a string and ignores non-hexadecimal text and comments within the input stream. Incoming text is binary encoded and written to the specified <varname>memory</varname> region. The actual number of bytes encoded is returned or <constant>-1</constant> on error.
  287. </para>
  288. </section>
  289. <section id="omemory-hexout">
  290. <title>
  291. omemory::hexout
  292. </title>
  293. <funcsynopsis>
  294. <funcprototype>
  295. <funcdef>void <function>hexout</function></funcdef>
  296. <paramdef>void const * <parameter>memory</parameter></paramdef>
  297. <paramdef>size_t <parameter>extent</parameter></paramdef>
  298. <paramdef>char <parameter>c</parameter></paramdef>
  299. <paramdef>FILE * <parameter>fp</parameter></paramdef>
  300. </funcprototype>
  301. </funcsynopsis>
  302. <para>
  303. Print a <varname>memory</varname> region as a series of decimal octets separated by character <constant>c</constant>. Normally, character <constant>c</constant> will be <constant>HEX_EXTENDER</constant>, defined in file <ulink url="onumber.hpp.html">onumber.hpp</ulink>, but it could be any character value. For example, specifying <varname>c</varname> as <constant>':'</constant> and <varname>extent</varname> as <constant>6</constant> would produce output looking something like <computeroutput>"00:B0:52:DA:DA:01"</computeroutput> where each octet is expressed as a hexadecimal integer. A typical use might be to print a <acronym>MAC</acronym> or <acronym>Ethernet</acronym> address in readable format.
  304. </para>
  305. </section>
  306. <section id="omemory-hexstring">
  307. <title>
  308. omemory::hexstring
  309. </title>
  310. <funcsynopsis>
  311. <funcprototype>
  312. <funcdef>char * <function>hexstring</function></funcdef>
  313. <paramdef>char <parameter>buffer</parameter> []</paramdef>
  314. <paramdef>size_t <parameter>length</parameter></paramdef>
  315. <paramdef>void const * <parameter>memory</parameter></paramdef>
  316. <paramdef>size_t <parameter>extent</parameter></paramdef>
  317. </funcprototype>
  318. </funcsynopsis>
  319. <para>
  320. Convert a <varname>memory</varname> region to a <constant>NUL</constant> terminated string of <acronym>ASCII</acronym> hexadecimal digits and return the string address. This method is similar to method <link linkend='omemory-hexdecode'>hexdecode</link> but the arguments are in different order and it returns the string address instead of the number of characters decoded.
  321. </para>
  322. </section>
  323. <section id="omemory-hexview">
  324. <title>
  325. omemory::hexview
  326. </title>
  327. <funcsynopsis>
  328. <funcprototype>
  329. <funcdef>void <function>hexview</function></funcdef>
  330. <paramdef>void const * <parameter>memory</parameter></paramdef>
  331. <paramdef>size_t <parameter>offset</parameter></paramdef>
  332. <paramdef>size_t <parameter>extent</parameter></paramdef>
  333. <paramdef>FILE * <parameter>fp</parameter></paramdef>
  334. </funcprototype>
  335. </funcsynopsis>
  336. <para>
  337. Print a partial <varname>memory</varname> region in hexadecimal format showing memory offsets, hexadecimal byte values and ASCII character values. Argument <varname>memory</varname> contains part of a larger memory region, much like a file window. Argument <varname>extent</varname> is the window length. Argument <varname>offset</varname> is the relative offset of the window within the region. Locations <constant>memory [0]</constant> up to <constant>memory [extent]</constant> are displayed as a partial dump, providing a window into the region.
  338. </para>
  339. <para>
  340. This method is similar to but different from method <link linkend='omemory-hexdump'>hexdump</link>.
  341. </para>
  342. </section>
  343. <section id="omemory-memdecr">
  344. <title>
  345. omemory::memdecr
  346. </title>
  347. <funcsynopsis>
  348. <funcprototype>
  349. <funcdef>signed <function>memdecr</function></funcdef>
  350. <paramdef>void * <parameter>memory</parameter></paramdef>
  351. <paramdef>size_t <parameter>extent</parameter></paramdef>
  352. </funcprototype>
  353. </funcsynopsis>
  354. <para>
  355. Decrement a multi-byte <varname>memory</varname> region. Return <constant>0</constant> on success or <constant>-1</constant> if all bytes have decremented to <constant>0x00</constant>. For example, <computeroutput>{ 0xFF, 0xFF, 0xFF }</computeroutput> decrements to <computeroutput>{ 0xFF, 0xFF, 0xFE }</computeroutput> and <computeroutput>{ 0xFF, 0x00, 0x00 }</computeroutput> decrements to <computeroutput>{ 0xFE, 0xFF, 0xFF }</computeroutput>. A typical use is to iterate through a range if <acronym>IP</acronym> or <acronym>MAC</acronym> address values.
  356. </para>
  357. </section>
  358. <section id="omemory-memincr">
  359. <title>
  360. omemory::memincr
  361. </title>
  362. <funcsynopsis>
  363. <funcprototype>
  364. <funcdef>signed <function>memincr</function></funcdef>
  365. <paramdef>void * <parameter>memory</parameter></paramdef>
  366. <paramdef>size_t <parameter>extent</parameter></paramdef>
  367. </funcprototype>
  368. </funcsynopsis>
  369. <para>
  370. Increment a multi-byte <varname>memory</varname> region. Return <constant>0</constant> on success or <constant>-1</constant> once all bytes have been incremented to <constant>0xFF</constant>. For example <computeroutput>{ 0x00, 0x00, 0x00 }</computeroutput> increments to <computeroutput>{ 0x00, 0x00, 0x01 }</computeroutput> and <computeroutput>{ 0x00, 0xFF, 0xFF }</computeroutput> increments to <computeroutput>{ 0x01, 0x00, 0x00 }</computeroutput>. A typical use is to iterate through a range of <acronym>IP</acronym> or <acronym>MAC</acronym> address values.
  371. </para>
  372. </section>
  373. <section id="omemory-memtext">
  374. <title>
  375. omemory::memtext
  376. </title>
  377. <funcsynopsis>
  378. <funcprototype>
  379. <funcdef>void <function>memtext</function></funcdef>
  380. <paramdef>char const * <parameter>string</parameter></paramdef>
  381. <paramdef>char <parameter>buffer</parameter> []</paramdef>
  382. <paramdef>size_t <parameter>length</parameter></paramdef>
  383. </funcprototype>
  384. </funcsynopsis>
  385. <para>
  386. Copy a variable-length <varname>string</varname> to a fixed-length <varname>buffer</varname> ensuring that the <varname>buffer</varname> is <constant>NUL</constant> terminated. The <varname>string</varname> is right truncated on overflow and the <varname>buffer</varname> is right padded with <constant>NUL</constant> characters on undeflow. For all non-zero lengths, <varname>buffer</varname>[<varname>length</varname>-<constant>1</constant>] will be <constant>NUL</constant>. This method is an alternative to standard library function <varname>strncpy</varname> which does not terminate the destination string on overflow or pad the buffer on underflow.
  387. </para>
  388. </section>
  389. <section id="omemory-serial">
  390. <title>
  391. omemory::serial
  392. </title>
  393. <funcsynopsis>
  394. <funcprototype>
  395. <funcdef>char const * <function>serial</function></funcdef>
  396. <paramdef>void * <parameter>buffer</parameter></paramdef>
  397. <paramdef>size_t <parameter>length</parameter></paramdef>
  398. <paramdef>unsigned <parameter>value</parameter></paramdef>
  399. <paramdef>unsigned <parameter>radix</parameter></paramdef>
  400. </funcprototype>
  401. </funcsynopsis>
  402. <para>
  403. Convert unsigned integer <varname>value</varname> to a <constant>NUL</constant> terminated numeric string of specified <varname>length</varname> and <varname>radix</varname> and return the string address. The string is stored in a user allocated buffer <varname>buffer</varname> and is left truncated or left padded with <constant>'0'</constant> to match the <varname>length</varname>. This method is similar to <link linkend='omemory-binstring'>binstring</link>, <link linkend='omemory-decstring'>decstring</link> and <link linkend='omemory-hexstring'>hexstring</link> but the entire buffer is filled with digits plus the terminator and no seperators are used.
  404. </para>
  405. </section>
  406. <section id="omemory-strdecr">
  407. <title>
  408. omemory::strdecr
  409. </title>
  410. <funcsynopsis>
  411. <funcprototype>
  412. <funcdef>signed <function>strdecr</function></funcdef>
  413. <paramdef>void * <parameter>memory</parameter></paramdef>
  414. <paramdef>size_t <parameter>extent</parameter></paramdef>
  415. <paramdef> byte <parameter>min</parameter></paramdef>
  416. <paramdef> byte <parameter>max</parameter></paramdef>
  417. </funcprototype>
  418. </funcsynopsis>
  419. <para>
  420. Decrement a multi-byte <varname>memory</varname> region using only ASCII character values in the range <varname>min</varname> through <varname>max</varname>. Return <constant>0</constant> on success or <constant>-1</constant> once all characters have been decremented to the value of argument <varname>min</varname>. For example, if argument <varname>min</varname> is <constant>'A'</constant> and argument <varname>max</varname> is <constant>'Z'</constant> then <computeroutput>{ 'A', 'B', 'C' }</computeroutput> decrements to <computeroutput>{ 'A', 'B', 'B' }</computeroutput> and <computeroutput>{ 'B', 'Z', 'Z' }</computeroutput> decrements to <computeroutput>{ 'A', 'A', 'A' }</computeroutput>. A typical use is to generate a sequence of distinct character strings to seed encryption key methods. </para>
  421. </section>
  422. <section id="omemory-strincr">
  423. <title>
  424. omemory::strincr
  425. </title>
  426. <funcsynopsis>
  427. <funcprototype>
  428. <funcdef>signed <function>strincr</function></funcdef>
  429. <paramdef>void * <parameter>memory</parameter></paramdef>
  430. <paramdef>size_t <parameter>extent</parameter></paramdef>
  431. <paramdef> byte <parameter>min</parameter></paramdef>
  432. <paramdef> byte <parameter>max</parameter></paramdef>
  433. </funcprototype>
  434. </funcsynopsis>
  435. <para>
  436. Increment a multi-byte <varname>memory</varname> region using only ASCII character values in the range <varname>min</varname> through <varname>max</varname>. Return <constant>0</constant> on success or <constant>-1</constant> once all characters have been incremented to the value of argument <varname>max</varname>. For example, if argument <varname>min</varname> is <constant>'A'</constant> and argument <varname>max</varname> is <constant>'Z'</constant> then <computeroutput>{ 'A', 'B', 'C' }</computeroutput> increments to <computeroutput>{ 'A', 'B', 'D' }</computeroutput> and <computeroutput>{ 'A', 'Z', 'Z' }</computeroutput> increments to <computeroutput>{ 'B', 'A', 'A' }</computeroutput>. A typical use is to generate a sequence of distinct character strings to seed encryption key methods. </para>
  437. </section>
  438. <section id="omemory-swap">
  439. <title>
  440. omemory::swap
  441. </title>
  442. <funcsynopsis>
  443. <funcprototype>
  444. <funcdef>void <function>swap</function></funcdef>
  445. <paramdef>void *</paramdef>
  446. <paramdef>void *</paramdef>
  447. <paramdef>size_t <parameter>length</parameter></paramdef>
  448. </funcprototype>
  449. </funcsynopsis>
  450. <para>
  451. Exchange the contents of two memory regions of equal <varname>length</varname> in bytes. No provision is made for memory overlap. This method may be used to sort a list of multi-byte entries or exchange the source and destination addresses in an Ethernet frame.
  452. </para>
  453. </section>
  454. </section>
  455. </chapter>