support4.xml 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  1. <section id="support-generic">
  2. <title>
  3. Generic Functions
  4. </title>
  5. <para>
  6. The functions in this chapter are generic and may have application beyond the Open Powerline Toolkit. In some cases, these functions appear in other Atheros or Open Source software packages. In a few cases, the Toolkit may include complementary or supplementary support functions but only use one or two of them. For example, functions <function>memincr</function> and <function>memdecr</function> are both included but <function>memdecr</function> is not used.
  7. </para>
  8. <section id="support-binout">
  9. <title>
  10. binout
  11. </title>
  12. <funcsynopsis>
  13. <funcprototype>
  14. <funcdef>void <function>binout</function></funcdef>
  15. <paramdef>void const * <parameter>memory</parameter></paramdef>
  16. <paramdef>size_t <parameter>extent</parameter></paramdef>
  17. <paramdef>char <parameter>c</parameter></paramdef>
  18. <paramdef>char <parameter>e</parameter></paramdef>
  19. <paramdef>FILE * <parameter>fp</parameter></paramdef>
  20. </funcprototype>
  21. </funcsynopsis>
  22. <para>
  23. Print a <varname>memory</varname> region as a series of binary octets separated by character <varname>c</varname> and terminated by character <varname>e</varname>. Normally, character <constant>c</constant> will be <constant>BIN_EXTENDER</constant>, defined in file <ulink url="number.h.html">number.h</ulink>, but it could be any character value. Normally, character <varname>e</varname> will be a space or newline, but it could be any character value. A typical use might be to print a <acronym>register</acronym> in readable format. For example, specifying <varname>c</varname> as <constant>'-'</constant>, <varname>e</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. The function is declared in <ulink url='memory.h.html'>memory.h</ulink> and defined in <ulink url='binout.c.html'>binout.c</ulink>.
  24. </para>
  25. </section>
  26. <section id="support-checksum32">
  27. <title>
  28. checksum32
  29. </title>
  30. <funcsynopsis>
  31. <funcprototype>
  32. <funcdef>unint32_t <function>checksum32</function></funcdef>
  33. <paramdef>const uint32_t <parameter>memory</parameter> []</paramdef>
  34. <paramdef>size_t <parameter>extent</parameter></paramdef>
  35. <paramdef>uint32_t <parameter>checksum</parameter></paramdef>
  36. </funcprototype>
  37. </funcsynopsis>
  38. <para>
  39. 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>extent</varname> is the region extent in 32 bit words. Argument <varname>checksum</varname> is the reference checksum. The function will return the computed checksum when reference<varname>checksum</varname> is <constant>0</constant> and will return <constant>0</constant> if reference <varname>checksum</varname> equals the computed checksum. A typical use is to validate <acronym>PIB</acronym> and <acronym>NVM</acronym> files or compute new checksums when these files are created or modified. The function is declared in <ulink url='memory.h.html'>memory.h</ulink> and defined in <ulink url='checksum32.c.html'>checksum32.c</ulink>.
  40. </para>
  41. <para>
  42. This function is similar to <link linkend='support-checksum-32'>checksum_32</link> but is used exclusively by API functions. It may be deprecated at some point in the future.
  43. </para>
  44. </section>
  45. <section id="support-checksum-32">
  46. <title>
  47. checksum_32
  48. </title>
  49. <funcsynopsis>
  50. <funcprototype>
  51. <funcdef>unint32_t <function>checksum_32</function></funcdef>
  52. <paramdef>void const * <parameter>memory</parameter></paramdef>
  53. <paramdef>size_t <parameter>extent</parameter></paramdef>
  54. <paramdef>uint32_t <parameter>checksum</parameter></paramdef>
  55. </funcprototype>
  56. </funcsynopsis>
  57. <para>
  58. 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. The region <varname>extent</varname> is specified in bytes but it will be rounded down to the nearest multiple of 4 bytes. Argument <varname>checksum</varname> is the reference checksum. The function will return the computed checksum when reference<varname>checksum</varname> is <constant>0</constant> and will return <constant>0</constant> if reference <varname>checksum</varname> equals the computed checksum. A typical use is to validate <acronym>PIB</acronym> and <acronym>NVM</acronym> files or compute new checksums when these files are created or modified. The function is declared in <ulink url='memory.h.html'>memory.h</ulink> and defined in <ulink url='checksum_32.c.html'>checksum_32.c</ulink>.
  59. </para>
  60. <para>
  61. This function is similar to function <link linkend='support-checksum32'>checksum32</link> however there is no need to cast <varname>memory</varname> to <varname>uint32_t</varname> and there is no need to round <varname>extent</varname> down to a multiple of 4 bytes before calling the function because both operations are performed internally. Also, there is no unecessary endian manipulation of the checksum. It is the prefered method of computing a checksum.
  62. </para>
  63. </section>
  64. <section id="support-chrout">
  65. <title>
  66. chrout
  67. </title>
  68. <funcsynopsis>
  69. <funcprototype>
  70. <funcdef>void <function>chrout</function></funcdef>
  71. <paramdef>void const * <parameter>memory</parameter></paramdef>
  72. <paramdef>size_t <parameter>extent</parameter></paramdef>
  73. <paramdef>char <parameter>c</parameter></paramdef>
  74. <paramdef>char <parameter>e</parameter></paramdef>
  75. <paramdef>FILE * <parameter>fp</parameter></paramdef>
  76. </funcprototype>
  77. </funcsynopsis>
  78. <para>
  79. Print a <varname>memory</varname> region as a string of printable ASCII characters terminated by character <varname>e</varname>. Character <varname>c</varname> is printed in place of non-printable characters. The string is terminated by character <constant>e</constant>. Normally, character <varname>c</varname> is <constant>'.'</constant> but it could be any character value. Normally, character <varname>e</varname> is space or newline but it could be any charcter value. A typical use might be to print a memory region that may (or may not) contain an <acronym>HFID</acronym> or other printable text. The function is declared in <ulink url='memory.h.html'>memory.h</ulink> and defined in <ulink url='chrout.c.html'>chrout.c</ulink>.
  80. </para>
  81. </section>
  82. <section id="support-decout">
  83. <title>
  84. decout
  85. </title>
  86. <funcsynopsis>
  87. <funcprototype>
  88. <funcdef>void <function>decout</function></funcdef>
  89. <paramdef>void const * <parameter>memory</parameter></paramdef>
  90. <paramdef>size_t <parameter>extent</parameter></paramdef>
  91. <paramdef>char <parameter>c</parameter></paramdef>
  92. <paramdef>char <parameter>e</parameter></paramdef>
  93. <paramdef>FILE * <parameter>fp</parameter></paramdef>
  94. </funcprototype>
  95. </funcsynopsis>
  96. <para>
  97. Print a <varname>memory</varname> region as a series of decimal octets separated by character <varname>c</varname> and terminated by character <varname>e</varname>. Normally, character <varname>c</varname> will be <constant>DEC_EXTENDER</constant>, defined in file <ulink url="number.h.html">number.h</ulink>, but it could be any character value. Normally, character <varname>e</varname> will be a space or newline but it could be any character value. A typical use might be to print an <acronym>IP</acronym> address in readable format. For example, specifying <varname>c</varname> as <constant>'.'</constant>, character <varname>e</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. The function is declared in <ulink url='memory.h.html'>memory.h</ulink> and defined in <ulink url='decout.c.html'>decout.c</ulink>.
  98. </para>
  99. </section>
  100. <section id="support-endian">
  101. <title>
  102. endian
  103. </title>
  104. <funcsynopsis>
  105. <funcprototype>
  106. <funcdef>void <function>endian</function></funcdef>
  107. <paramdef>void * <parameter>memory</parameter></paramdef>
  108. <paramdef>size_t <parameter>extent</parameter></paramdef>
  109. </funcprototype>
  110. </funcsynopsis>
  111. <para>
  112. Reverse the byte order of a <varname>memory</varname> region. It is a variable extent version of functions like <function>__bswap_16</function>, <function>__bswap_32</function> and <function>__bswap_64</function>. The function is declared in <ulink url='memory.h.html'>memory.h</ulink> and defined in <ulink url='endian.c.html'>endian.c</ulink>.
  113. </para>
  114. </section>
  115. <section id="support-fdchecksum32">
  116. <title>
  117. fdchecksum32
  118. </title>
  119. <funcsynopsis>
  120. <funcprototype>
  121. <funcdef>unit32_t <function>fdchecksum32</function></funcdef>
  122. <paramdef>int <parameter>fd</parameter></paramdef>
  123. <paramdef>size_t <parameter>extent</parameter></paramdef>
  124. <paramdef>unit32_t <parameter>checksum</parameter></paramdef>
  125. </funcprototype>
  126. </funcsynopsis>
  127. <para>
  128. Return the 32 bit checksum of a file region starting from the current file position. The checksum is the one's complement of the XOR or of all 32 bit words in the region. Argument <varname>extent</varname> must be specified in 32 bit words, not bytes. Argument <varname>checksum</varname> is the reference checksum. The function will return the computed checksum when reference<varname>checksum</varname> is <constant>0</constant> and will return <constant>0</constant> if reference <varname>checksum</varname> equals the computed checksum. A typical use is to validate <acronym>NVM</acronym> files header by header or section by section. The function is declared in <ulink url='memory.h.html'>memory.h</ulink> and defined in <ulink url='fdchecksum32.c.html'>fdchecksum32.c</ulink>.
  129. </para>
  130. </section>
  131. <section id="support-fdchecksum-32">
  132. <title>
  133. fdchecksum_32
  134. </title>
  135. <funcsynopsis>
  136. <funcprototype>
  137. <funcdef>unit32_t <function>fdchecksum_32</function></funcdef>
  138. <paramdef>int <parameter>fd</parameter></paramdef>
  139. <paramdef>size_t <parameter>extent</parameter></paramdef>
  140. <paramdef>unit32_t <parameter>checksum</parameter></paramdef>
  141. </funcprototype>
  142. </funcsynopsis>
  143. <para>
  144. Return the 32 bit checksum of a file region starting from the current file position. The checksum is the one's complement of the XOR or of all 32 bit words in the region. Argument <varname>extent</varname> is specified in bytes but is rounded down to the nearest multiple of 4 bytes. Argument <varname>checksum</varname> is the reference checksum. The function will return the computed checksum when reference<varname>checksum</varname> is <constant>0</constant> and will return <constant>0</constant> if reference <varname>checksum</varname> equals the computed checksum. A typical use is to validate <acronym>NVM</acronym> files header by header or section by section. The function is declared in <ulink url='memory.h.html'>memory.h</ulink> and defined in <ulink url='fdchecksum_32.c.html'>fdchecksum_32.c</ulink>.
  145. </para>
  146. <para>
  147. This function is similar to function <link linkend='support-fdchecksum32'>fdchecksum32</link> but there is no need to round <varname>extent</varname> down to the nearest multiple of 4 bytes before calling the function because that is done internally. Also, there is no unecessary endian manuipulation of the checksum.
  148. </para>
  149. </section>
  150. <section id="support-filepar">
  151. <title>
  152. filepart
  153. </title>
  154. <funcsynopsis>
  155. <funcprototype>
  156. <funcdef>char const * <function>filepart</function></funcdef>
  157. <paramdef>char const * <parameter>pathname</parameter></paramdef>
  158. </funcprototype>
  159. </funcsynopsis>
  160. <para>
  161. Return the address of the filename portion of a <varname>pathname</varname> string. The filename portion is everything after the rightmost path separator. If a path separator is not present then the address of the <varname>pathname</varname> string is returned. This function is similar to the <acronym>POSIX</acronym> <constant>basename</constant> function but it returns an empty string whenever the rightmost character is a path separator. The path separator can be either slash (<constant>'/'</constant>) or backslash (<constant>'\\'</constant>). The function is declared in <ulink url='files.h.html'>files.h</ulink> and defined in <ulink url='filepart.c.html'>filepart.c</ulink>.
  162. </para>
  163. </section>
  164. <section id="support-hexdecode">
  165. <title>
  166. hexdecode
  167. </title>
  168. <funcsynopsis>
  169. <funcprototype>
  170. <funcdef>signed <function>hexdecode</function></funcdef>
  171. <paramdef>void * <parameter>memory</parameter></paramdef>
  172. <paramdef>size_t <parameter>extent</parameter></paramdef>
  173. <paramdef>char const <parameter>buffer</parameter> []</paramdef>
  174. <paramdef>size_t <parameter>extent</parameter></paramdef>
  175. </funcprototype>
  176. </funcsynopsis>
  177. <para>
  178. Decode a <varname>memory</varname> region as a string of <acronym>ASCII</acronym> hexadecimal digits. Convert memory until the buffer or memory exhausts and return the string extent. Allow three (3) string characters for each memory byte to be decoded. The number of bytes decoded will be the lesser of argument <varname>extent</varname> divided by <constant>3</constant> or argument <varname>extent</varname>. The function is declared in <ulink url='memory.h.html'>memory.h</ulink> and defined in <ulink url='hexdecode.c.html'>hexdecode.c</ulink>.
  179. </para>
  180. </section>
  181. <section id="support-hexdump">
  182. <title>
  183. hexdump
  184. </title>
  185. <funcsynopsis>
  186. <funcprototype>
  187. <funcdef>void <function>hexdump</function></funcdef>
  188. <paramdef>void const * <parameter>memory</parameter></paramdef>
  189. <paramdef>size_t <parameter>offset</parameter></paramdef>
  190. <paramdef>size_t <parameter>extent</parameter></paramdef>
  191. <paramdef>FILE * <parameter>fp</parameter></paramdef>
  192. </funcprototype>
  193. </funcsynopsis>
  194. <para>
  195. Print a full or partial <varname>memory</varname> region in hexadecimal format showing memory offsets, hexadecimal byte values and ASCII character values. Argument <varname>memory</varname> contains some memory region. Argument <varname>extent</varname> is the region extent. 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 memory region. An <varname>offset</varname> of <constant>0</constant> will display the entire region. The function is declared in <ulink url='memory.h.html'>memory.h</ulink> and defined in <ulink url='hexdump.c.html'>hexdump.c</ulink>.
  196. </para>
  197. <para>
  198. This function is similar to but different from function <link linkend='support-hexview'>hexview</link> .
  199. </para>
  200. </section>
  201. <section id="support-hexencode">
  202. <title>
  203. hexencode
  204. </title>
  205. <funcsynopsis>
  206. <funcprototype>
  207. <funcdef>signed <function>hexencode</function></funcdef>
  208. <paramdef>void * <parameter>memory</parameter></paramdef>
  209. <paramdef>size_t <parameter>extent</parameter></paramdef>
  210. <paramdef>char const * <parameter>string</parameter></paramdef>
  211. </funcprototype>
  212. </funcsynopsis>
  213. <para>
  214. 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='number.h.html'>number.h</ulink>. The function is declared in <ulink url='memory.h.html'>memory.h</ulink> and defined in <ulink url='hexencode.c.html'>hexencode.c</ulink>.
  215. </para>
  216. </section>
  217. <section id="support-hexin">
  218. <title>
  219. hexin
  220. </title>
  221. <funcsynopsis>
  222. <funcprototype>
  223. <funcdef>ssize_t <function>hexin</function></funcdef>
  224. <paramdef>void const * <parameter>memory</parameter></paramdef>
  225. <paramdef>size_t <parameter>extent</parameter></paramdef>
  226. <paramdef>FILE * <parameter>fp</parameter></paramdef>
  227. </funcprototype>
  228. </funcsynopsis>
  229. <para>
  230. This function is similar to <link linkend="support-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. See the <ulink url='efsu.7.html'>efsu</ulink> man page for a thorough explanation of function behavior. The function is declared in <ulink url='memory.h.html'>memory.h</ulink> and defined in <ulink url='hexin.c.html'>hexin.c</ulink>.
  231. </para>
  232. </section>
  233. <section id="support-hexout">
  234. <title>
  235. hexout
  236. </title>
  237. <funcsynopsis>
  238. <funcprototype>
  239. <funcdef>void <function>hexout</function></funcdef>
  240. <paramdef>void const * <parameter>memory</parameter></paramdef>
  241. <paramdef>size_t <parameter>extent</parameter></paramdef>
  242. <paramdef>char <parameter>c</parameter></paramdef>
  243. <paramdef>char <parameter>e</parameter></paramdef>
  244. <paramdef>FILE * <parameter>fp</parameter></paramdef>
  245. </funcprototype>
  246. </funcsynopsis>
  247. <para>
  248. Print a <varname>memory</varname> region as a series of hexdecimal octets separated by character <varname>c</varname> and termianted by character <varname>e</varname>. Normally, character <varname>c</varname> will be <constant>HEX_EXTENDER</constant>, defined in file <ulink url="number.h.html">number.h</ulink>, but it could be any character value. Normally, character <varname>e</varname> will be a space or newline but it could be any character value. A typical use might be to print a <acronym>MAC</acronym> or <acronym>Ethernet</acronym> address in readable format. For example, specifying <varname>c</varname> as <constant>':'</constant>, character <varname>e</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. The function is declared in <ulink url='memory.h.html'>memory.h</ulink> and defined in <ulink url='hexout.c.html'>hexout.c</ulink>.
  249. </para>
  250. </section>
  251. <section id="support-hexstring">
  252. <title>
  253. hexstring
  254. </title>
  255. <funcsynopsis>
  256. <funcprototype>
  257. <funcdef>char * <function>hexstring</function></funcdef>
  258. <paramdef>char <parameter>buffer</parameter> []</paramdef>
  259. <paramdef>size_t <parameter>length</parameter></paramdef>
  260. <paramdef>void const * <parameter>memory</parameter></paramdef>
  261. <paramdef>size_t <parameter>extent</parameter></paramdef>
  262. </funcprototype>
  263. </funcsynopsis>
  264. <para>
  265. Convert a <varname>memory</varname> region to a <constant>NUL</constant> terminated string and return the string address. This function is identical to function <link linkend='support-hexdecode'>hexdecode</link> but it return the string address instead of the number of characters decoded. The function is declared in <ulink url='memory.h.html'>memory.h</ulink> and defined in <ulink url='hexstring.c.html'>hexstring.c</ulink>.
  266. </para>
  267. </section>
  268. <section id="support-hexview">
  269. <title>
  270. hexview
  271. </title>
  272. <funcsynopsis>
  273. <funcprototype>
  274. <funcdef>void <function>hexview</function></funcdef>
  275. <paramdef>void const * <parameter>memory</parameter></paramdef>
  276. <paramdef>size_t <parameter>offset</parameter></paramdef>
  277. <paramdef>size_t <parameter>extent</parameter></paramdef>
  278. <paramdef>FILE * <parameter>fp</parameter></paramdef>
  279. </funcprototype>
  280. </funcsynopsis>
  281. <para>
  282. 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 <varname>memory</varname> [<constant>0</constant>] up to but excluding <varname>memory</varname> [<varname>extent</varname>] are displayed as a partial dump, providing a window into the region. The function is declared in <ulink url='memory.h.html'>memory.h</ulink> and defined in <ulink url='hexview.c.html'>hexview.c</ulink>. </para>
  283. <para>
  284. This function is similar to but different from function <link linkend='support-hexdump'>hexdump</link>.
  285. </para>
  286. </section>
  287. <section id="support-memdecr">
  288. <title>
  289. memdecr
  290. </title>
  291. <funcsynopsis>
  292. <funcprototype>
  293. <funcdef>signed <function>memdecr</function></funcdef>
  294. <paramdef>void * <parameter>memory</parameter></paramdef>
  295. <paramdef>size_t <parameter>extent</parameter></paramdef>
  296. </funcprototype>
  297. </funcsynopsis>
  298. <para>
  299. 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. The function is declared in <ulink url='memory.h.html'>memory.h</ulink> and defined in <ulink url='memdecr.c.html'>memdecr.c</ulink>.
  300. </para>
  301. </section>
  302. <section id="support-memincr">
  303. <title>
  304. memincr
  305. </title>
  306. <funcsynopsis>
  307. <funcprototype>
  308. <funcdef>signed <function>memincr</function></funcdef>
  309. <paramdef>void * <parameter>memory</parameter></paramdef>
  310. <paramdef>size_t <parameter>extent</parameter></paramdef>
  311. </funcprototype>
  312. </funcsynopsis>
  313. <para>
  314. 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. The function is declared in <ulink url='memory.h.html'>memory.h</ulink> and defined in <ulink url='memincr.c.html'>memincr.c</ulink>.
  315. </para>
  316. </section>
  317. <section id="support-memout">
  318. <title>
  319. memout
  320. </title>
  321. <funcsynopsis>
  322. <funcprototype>
  323. <funcdef>void <function>memout</function></funcdef>
  324. <paramdef>void const * <parameter>memory</parameter></paramdef>
  325. <paramdef>size_t <parameter>extent</parameter></paramdef>
  326. <paramdef>char const * <parameter>format</parameter></paramdef>
  327. <paramdef>unsigned <parameter>group</parameter></paramdef>
  328. <paramdef>signed <parameter>c</parameter></paramdef>
  329. <paramdef>FILE * <parameter>fp</parameter></paramdef>
  330. </funcprototype>
  331. </funcsynopsis>
  332. <para>
  333. Print a <varname>memory</varname> region as a series of octet groups wach separated by character <constant>c</constant>. The <varname>group</varname> argument specifies the number of octets per group. The <varname>format</varname> argument determines how each octet is displayed. Normally, character <constant>c</constant> will be one of <constant>BIN_EXTENDER</constant>, <constant>DEC_EXTENDER</constant> or <constant>HEX_EXTENDER</constant> as defined in file <ulink url="number.h.html">number.h</ulink>, but it could be any character value. The function is declared in <ulink url='memory.h.html'>memory.h</ulink> and defined in <ulink url='memout.c.html'>memout.c</ulink>.
  334. </para>
  335. </section>
  336. <section id="support-memswap">
  337. <title>
  338. memswap
  339. </title>
  340. <funcsynopsis>
  341. <funcprototype>
  342. <funcdef>void <function>memswap</function></funcdef>
  343. <paramdef>void * <parameter>buffer1</parameter></paramdef>
  344. <paramdef>void * <parameter>buffer2</parameter></paramdef>
  345. <paramdef>size_t <parameter>length</parameter></paramdef>
  346. </funcprototype>
  347. </funcsynopsis>
  348. <para>
  349. Exchange the contents of one buffer with that of another. No provision is made for buffer overlap. No value is returned. A typical use might be to exchange source and destination addresses in an ethernet packet. The function is declared in <ulink url='memory.h.html'>memory.h</ulink> and defined in <ulink url='memswap.c.html'>memswap.c</ulink>.
  350. </para>
  351. </section>
  352. <section id="support-strdecr">
  353. <title>
  354. strdecr
  355. </title>
  356. <funcsynopsis>
  357. <funcprototype>
  358. <funcdef>signed <function>strdecr</function></funcdef>
  359. <paramdef>void * <parameter>memory</parameter></paramdef>
  360. <paramdef>size_t <parameter>extent</parameter></paramdef>
  361. <paramdef>byte <parameter>min</parameter></paramdef>
  362. <paramdef>byte <parameter>max</parameter></paramdef>
  363. </funcprototype>
  364. </funcsynopsis>
  365. <para>
  366. 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 functions. The function is declared in <ulink url='memory.h.html'>memory.h</ulink> and defined in <ulink url='strdecr.c.html'>strdecr.c</ulink>.
  367. </para>
  368. </section>
  369. <section id="support-strfbits">
  370. <title>
  371. strfbits
  372. </title>
  373. <funcsynopsis>
  374. <funcprototype>
  375. <funcdef>size_t <function>strfbits</function></funcdef>
  376. <paramdef>char const <parameter>buffer</parameter> []</paramdef>
  377. <paramdef>size_t <parameter>length</parameter></paramdef>
  378. <paramdef>char const * <parameter>operands</parameter> []</paramdef>
  379. <paramdef>char const * <parameter>operator</parameter></paramdef>
  380. <paramdef>unsigned <parameter>flagword</parameter></paramdef>
  381. </funcprototype>
  382. </funcsynopsis>
  383. <para>
  384. Encode a <varname>buffer</varname> with an enumerated list of the <varname>operands</varname> associated with the corresponding bits in <varname>flagword</varname>. separate enumerated <varname>operands</varname> with an <varname>operator</varname> string. For example, given <computeroutput>char const *operands [] = { "loop", "wait", "busy" }</computeroutput> and <computeroutput>unsigned flagword = 0x05</computeroutput> then <computeroutput>strfbits (buffer, length, operands, "|", flagword)</computeroutput> would encode buffer with <constant>"loop|busy"</constant>. Observe that each bit set in <varname>flagword</varname> appears in <varname>buffer</varname> as the corresponding string from <varname>operands</varname>. A typical application for this function is the enumeration of flagword states. The function is declared in <ulink url='format.h.html'>format.h</ulink> and defined in <ulink url='strfbits.c.html'>strfbits.c</ulink>.
  385. </para>
  386. </section>
  387. <section id="support-strincr">
  388. <title>
  389. strincr
  390. </title>
  391. <funcsynopsis>
  392. <funcprototype>
  393. <funcdef>signed <function>strincr</function></funcdef>
  394. <paramdef>void * <parameter>memory</parameter></paramdef>
  395. <paramdef>size_t <parameter>extent</parameter></paramdef>
  396. <paramdef>byte <parameter>min</parameter></paramdef>
  397. <paramdef>byte <parameter>max</parameter></paramdef>
  398. </funcprototype>
  399. </funcsynopsis>
  400. <para>
  401. 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 functions. The function is declared in <ulink url='memory.h.html'>memory.h</ulink> and defined in <ulink url='strincr.c.html'>strincr.c</ulink>.
  402. </para>
  403. </section>
  404. <section id="support-todigit">
  405. <title>
  406. todigit
  407. </title>
  408. <funcsynopsis>
  409. <funcprototype>
  410. <funcdef>unsigned <function>todigit</function></funcdef>
  411. <paramdef>unsigned <parameter>c</parameter></paramdef>
  412. </funcprototype>
  413. </funcsynopsis>
  414. <para>
  415. Return the integer value of character <varname>c</varname> interpreted as digit in the base 36 number system. It is called by many encode functions to support number base conversion. If the value of <varname>c</varname> is <constant>'0'</constant> through <constant>'9'</constant> then integer <constant>0</constant> through <constant>9</constant> is returned. If the value of <varname>c</varname> is <constant>'A'</constant> through <constant>'Z'</constant> or <constant>'a'</constant> through <constant>'z'</constant> then integer <constant>10</constant> through <constant>35</constant> is returned. The function is declared in <ulink url='number.h.html'>number.h</ulink> and defined in <ulink url='todigit.c.html'>todigit.c</ulink>.
  416. </para>
  417. </section>
  418. <section id="support-typename">
  419. <title>
  420. typename
  421. </title>
  422. <funcsynopsis>
  423. <funcprototype>
  424. <funcdef>char const * <function>typename</function></funcdef>
  425. <paramdef>const struct _type_ <parameter>list</parameter> []</paramdef>
  426. <paramdef>size_t <parameter>size</parameter></paramdef>
  427. <paramdef>type_t <parameter>type</parameter></paramdef>
  428. <paramdef>char const * <parameter>name</parameter></paramdef>
  429. </funcprototype>
  430. </funcsynopsis>
  431. <para>
  432. Return the name associated with a message <varname>type</varname> by searching a list arranged in ascending order by message type. Return argument <varname>name</varname> as the function value if the message <varname>type</varname> is not present in the <varname>list</varname>. Data types <varname>struct _type_</varname> and <varname>type_t</varname> are defined in file <ulink url="types.h.html">types.h</ulink>. A typical use might be to return the name of message based on the message type. The function is declared in <ulink url='symbol.h.html'>symbol.h</ulink> and defined in <ulink url='typename.c.html'>typename.c</ulink>.
  433. </para>
  434. </section>
  435. </section>