library.xml 75 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245
  1. <chapter id='library-functions'>
  2. <title>
  3. Support Function Reference
  4. </title>
  5. <section id="library-intro" >
  6. <title>
  7. Introduction
  8. </title>
  9. <para>
  10. The Atheros <application>Open Powerline Toolkit</application> includes many functions that have application outside the <application>Open Powerline Toolkit</application>. They are distributed with the toolkit but may also appear in other Atheros applications or third party packages. Consequently, we describe them separately and store them in separate folders.
  11. </para>
  12. </section>
  13. <section id="library-error">
  14. <title>
  15. tools/error.h
  16. </title>
  17. <para>
  18. The functions in this group have general application beyond the Open Powerline Toolkit. In some cases, these functions may 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.
  19. </para>
  20. <section id="function-alert">
  21. <title>
  22. alert
  23. </title>
  24. <funcsynopsis>
  25. <funcprototype>
  26. <funcdef>void <function>alert</function></funcdef>
  27. <paramdef>const char *<parameter>format</parameter></paramdef>
  28. <paramdef><parameter>...</parameter></paramdef>
  29. </funcprototype>
  30. </funcsynopsis>
  31. <para>
  32. This function is similar to function <function>printf</function> but messages are prefixed with the program name and appear on <constant>stderr</constant> instead of <constant>stdout</constant>. It is equivalent to calling function <link linkend='library-error'>error</link> with argument <varname>exitcode</varname> set to <constant>0</constant> and argument <varname>errno</varname> set to <constant>0</constant>. A typical use is to print progress messages. The function is declared in <ulink url='error.h.html'>error.h</ulink> and defined in <ulink url='alert.c.html'>alert.c</ulink>.
  33. </para>
  34. </section>
  35. <section id="function-error">
  36. <title>
  37. error
  38. </title>
  39. <funcsynopsis>
  40. <funcprototype>
  41. <funcdef>void <function>error</function></funcdef>
  42. <paramdef>int<parameter>exitcode</parameter></paramdef>
  43. <paramdef>errno_t <parameter>number</parameter></paramdef>
  44. <paramdef>const char * <parameter>format</parameter></paramdef>
  45. <paramdef><parameter>...</parameter></paramdef>
  46. </funcprototype>
  47. </funcsynopsis>
  48. <para>
  49. This function works like printf except that printed messages appear on <constant>stderr</constant> and are prefixed with the program name and error information. If argument <varname>errno</varname> is non-zero then messages are prefixed with the system error description. If argument <varname>exitcode</varname> is non-zero then function <varname>error</varname> exits the program with value <varname>exitcode</varname> after printing the message and does not return to the caller. The function is declared in <ulink url='error.h.html'>error.h</ulink> and defined in <ulink url='error.c.html'>error.c</ulink>.
  50. </para>
  51. </section>
  52. </section>
  53. <section id="library-files">
  54. <title>
  55. tools/files.h
  56. </title>
  57. <section id="function-checkfilename">
  58. <title>
  59. checkfilename
  60. </title>
  61. <funcsynopsis>
  62. <funcprototype>
  63. <funcdef>bool <function>checkfilename</function></funcdef>
  64. <paramdef>const char *<parameter>filename</parameter></paramdef>
  65. </funcprototype>
  66. </funcsynopsis>
  67. <para>
  68. Return logical <constant>true</constant> if the <varname>filename</varname> argument contains only letters, digits, slashes, periods, underscores and hyphens. This function can be used to detect cases where a user accidentally entered an Ethernet address in place of a filename on the command line. Ethernet address strings are, as it happens, also valid filenames. The function is declared in <ulink url='files.h.html'>files.h</ulink> and defined in <ulink url='checkfilename.c.html'>checkfilename.c</ulink>.
  69. </para>
  70. </section>
  71. <section id="function-filepart">
  72. <title>
  73. filepart
  74. </title>
  75. <funcsynopsis>
  76. <funcprototype>
  77. <funcdef>const char * <function>filepart</function></funcdef>
  78. <paramdef>const char * <parameter>pathname</parameter></paramdef>
  79. </funcprototype>
  80. </funcsynopsis>
  81. <para>
  82. 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>.
  83. </para>
  84. </section>
  85. </section>
  86. <section id="library-format">
  87. <title>
  88. tools/format.h
  89. </title>
  90. <section id="function-strfbits">
  91. <title>
  92. strfbits
  93. </title>
  94. <funcsynopsis>
  95. <funcprototype>
  96. <funcdef>size_t <function>strfbits</function></funcdef>
  97. <paramdef>char <parameter>buffer</parameter> []</paramdef>
  98. <paramdef>size_t <parameter>length</parameter></paramdef>
  99. <paramdef>const char *<parameter>operands</parameter> []</paramdef>
  100. <paramdef>const char *<parameter>operator</parameter></paramdef>
  101. <paramdef>unsigned <parameter>flagword</parameter></paramdef>
  102. </funcprototype>
  103. </funcsynopsis>
  104. <para>
  105. 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>const char *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='tools.h.html'>tools.h</ulink> and defined in <ulink url='strfbits.c.html'>strfbits.c</ulink>.
  106. </para>
  107. </section>
  108. </section>
  109. <section id="library-getoptv">
  110. <title>
  111. tools/getoptv.h
  112. </title>
  113. <section id="function-getoptv">
  114. <title>
  115. getoptv
  116. </title>
  117. <funcsynopsis>
  118. <funcprototype>
  119. <funcdef>int <function>getoptv</function></funcdef>
  120. <paramdef>int <parameter>argc</parameter></paramdef>
  121. <paramdef>const char * <parameter>argv</parameter> []</paramdef>
  122. <paramdef>const char * <parameter>optv</parameter> []</paramdef>
  123. </funcprototype>
  124. </funcsynopsis>
  125. <para>
  126. A custom version of the <acronym>POSIX</acronym> function <function>getopt</function>. It supports standard global variables <varname>optind</varname>, <varname>opterr</varname>, <varname>optopt</varname> and <varname>optarg</varname> and the non-standard variable <varname>optmin</varname>. It extracts the program name from <varname>argv[0]</varname> and posts it for use by functions <function>alert</function>, <function>error</function> and other functions using the global string pointer <varname>program_name</varname>. Options <userinput>-?</userinput> and <userinput>--help</userinput> both display program information on <constant>stdout</constant>. Options <userinput>-!</userinput> and <userinput>--version</userinput> both display program version information on <constant>stdout</constant>. String vector <varname>optv</varname> includes both the standard argument <varname>optstring</varname> and usage text found in many programs. The function is declared in <ulink url='getoptv.h.html'>getoptv.h</ulink> and defined in <ulink url='getoptv.c.html'>getoptv.c</ulink>.
  127. </para>
  128. </section>
  129. </section>
  130. <section id="library-memory">
  131. <title>
  132. tools/memory.h
  133. </title>
  134. <section id="function-bytespec">
  135. <title>
  136. bytespec
  137. </title>
  138. <funcsynopsis>
  139. <funcprototype>
  140. <funcdef>void <function>bytespec</function></funcdef>
  141. <paramdef>const char * <parameter>string</parameter></paramdef>
  142. <paramdef>byte <parameter>memory</parameter> []</paramdef>
  143. <paramdef>size_t <parameter>extent</parameter></paramdef>
  144. </funcprototype>
  145. </funcsynopsis>
  146. <para>
  147. Encode a <varname>memory</varname> region with the binary equivalent of a fixed-length hexadecimal string. Print an error message on stderr and exit the program with status <constant>1</constant> if a syntax error occurs or the number of octets does not equal <varname>extent</varname>. Hexadecimal octets may be separated by colons for readability but colons are not required. Empty octets are illegal. This function is typically used to enter fixed-length data, like hardware addresses and encryption keys, on the command line. The function is declared in <ulink url='memory.h.html'>memory.h</ulink> and defined in <ulink url='bytespec.c.html'>bytespec.c</ulink>.
  148. </para>
  149. </section>
  150. <section id="function-checksum32">
  151. <title>
  152. checksum32
  153. </title>
  154. <funcsynopsis>
  155. <funcprototype>
  156. <funcdef>unint32_t <function>checksum32</function></funcdef>
  157. <paramdef>const uint32_t <parameter>memory</parameter> []</paramdef>
  158. <paramdef>size_t <parameter>length</parameter></paramdef>
  159. <paramdef>uint32_t <parameter>checksum</parameter></paramdef>
  160. </funcprototype>
  161. </funcsynopsis>
  162. <para>
  163. 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 extent in 32 bit words. Argument <varname>checksum</varname> is the reference checksum. When the <varname>checksum</varname> argument is <constant>0</constant>, the function value will be the computed checksum. When the <varname>checksum</varname> argument is the computed checksum, the function value will be <constant>0</constant> such that any other value indicates a checksum error. 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>.
  164. </para>
  165. </section>
  166. <section id="function-checksum-32">
  167. <title>
  168. checksum_32
  169. </title>
  170. <funcsynopsis>
  171. <funcprototype>
  172. <funcdef>unint32_t <function>checksum_32</function></funcdef>
  173. <paramdef>const void * <parameter>memory</parameter></paramdef>
  174. <paramdef>size_t <parameter>extent</parameter></paramdef>
  175. <paramdef>uint32_t <parameter>checksum</parameter></paramdef>
  176. </funcprototype>
  177. </funcsynopsis>
  178. <para>
  179. 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 argument <varname>checksum</varname> is <constant>0</constant> and will return <constant>0</constant> if argument <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>.
  180. </para>
  181. <para>
  182. This function is similar to function <link linkend='library-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.
  183. </para>
  184. </section>
  185. <section id="function-decout">
  186. <title>
  187. decout
  188. </title>
  189. <funcsynopsis>
  190. <funcprototype>
  191. <funcdef>void <function>decout</function></funcdef>
  192. <paramdef>const byte <parameter>memory</parameter> []</paramdef>
  193. <paramdef>size_t <parameter>length</parameter></paramdef>
  194. <paramdef>char <parameter>c</parameter></paramdef>
  195. <paramdef>FILE *<parameter>fp</parameter></paramdef>
  196. </funcprototype>
  197. </funcsynopsis>
  198. <para>
  199. 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="number.h.html">number.h</ulink>, but it could be any character value. For example, specifying <varname>c</varname> as <constant>'.'</constant> and <varname>length</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. The function is declared in <ulink url='memory.h.html'>memory.h</ulink> and defined in <ulink url='decout.c.html'>decout.c</ulink>.
  200. </para>
  201. </section>
  202. <section id="function-endian">
  203. <title>
  204. endian
  205. </title>
  206. <funcsynopsis>
  207. <funcprototype>
  208. <funcdef>void <function>endian</function></funcdef>
  209. <paramdef>void * <parameter>memory</parameter></paramdef>
  210. <paramdef>size_t <parameter>extent</parameter></paramdef>
  211. </funcprototype>
  212. </funcsynopsis>
  213. <para>
  214. Reverse the byte order of a <varname>memory</varname> region. It is a variable length 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>.
  215. </para>
  216. </section>
  217. <section id="function-hexdecode">
  218. <title>
  219. hexdecode
  220. </title>
  221. <funcsynopsis>
  222. <funcprototype>
  223. <funcdef>signed <function>hexdecode</function></funcdef>
  224. <paramdef>byte <parameter>memory</parameter> []</paramdef>
  225. <paramdef>size_t <parameter>extent</parameter></paramdef>
  226. <paramdef>const char <parameter>buffer</parameter> []</paramdef>
  227. <paramdef>size_t <parameter>length</parameter></paramdef>
  228. </funcprototype>
  229. </funcsynopsis>
  230. <para>
  231. 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 length. Allow three (3) string characters for each memory byte to be decoded. The number of bytes decoded will be the lesser of argument <varname>length</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>.
  232. </para>
  233. </section>
  234. <section id="function-hexdump">
  235. <title>
  236. hexdump
  237. </title>
  238. <funcsynopsis>
  239. <funcprototype>
  240. <funcdef>void <function>hexdump</function></funcdef>
  241. <paramdef>const void * <parameter>memory</parameter></paramdef>
  242. <paramdef>size_t <parameter>offset</parameter></paramdef>
  243. <paramdef>size_t <parameter>extent</parameter></paramdef>
  244. <paramdef>FILE * <parameter>fp</parameter></paramdef>
  245. </funcprototype>
  246. </funcsynopsis>
  247. <para>
  248. 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 length. Argument <varname>offset</varname> is the starting display location. Locations <constant>memory [offset]</constant> up to <constant>memory [extent]</constant> 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>.
  249. </para>
  250. <para>
  251. This function is similar to but different from function <link linkend='library-hexview'>hexview</link> .
  252. </para>
  253. </section>
  254. <section id="function-hexencode">
  255. <title>
  256. hexencode
  257. </title>
  258. <funcsynopsis>
  259. <funcprototype>
  260. <funcdef>signed <function>hexencode</function></funcdef>
  261. <paramdef>byte <parameter>memory</parameter> []</paramdef>
  262. <paramdef>size_t <parameter>extent</parameter></paramdef>
  263. <paramdef>const char * <parameter>string</parameter></paramdef>
  264. </funcprototype>
  265. </funcsynopsis>
  266. <para>
  267. 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>.
  268. </para>
  269. </section>
  270. <section id="function-hexin">
  271. <title>
  272. hexin
  273. </title>
  274. <funcsynopsis>
  275. <funcprototype>
  276. <funcdef>void <function>hexin</function></funcdef>
  277. <paramdef>const byte <parameter>memory</parameter> []</paramdef>
  278. <paramdef>size_t <parameter>extent</parameter></paramdef>
  279. <paramdef>FILE *<parameter>fp</parameter></paramdef>
  280. </funcprototype>
  281. </funcsynopsis>
  282. <para>
  283. This function is similar to <link linkend="library-hexencode">hexencode</link> but it reads from file, instead of a string, and ignores any non-hexadecimal text and comments embedded within the input stream. Incoming text is binary encoded and written to the specified <varname>memory</varname> region. Reading terminates on the next occurance of a semicolon or end of file. The actual number of bytes encoded is returned. The function is declared in <ulink url='memory.h.html'>memory.h</ulink> and defined in <ulink url='hexin.c.html'>hexin.c</ulink>.
  284. </para>
  285. </section>
  286. <section id="function-hexout">
  287. <title>
  288. hexout
  289. </title>
  290. <funcsynopsis>
  291. <funcprototype>
  292. <funcdef>void <function>hexout</function></funcdef>
  293. <paramdef>const byte <parameter>memory</parameter> []</paramdef>
  294. <paramdef>size_t <parameter>length</parameter></paramdef>
  295. <paramdef>char <parameter>c</parameter></paramdef>
  296. <paramdef>FILE *<parameter>fp</parameter></paramdef>
  297. </funcprototype>
  298. </funcsynopsis>
  299. <para>
  300. 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="number.h.html">number.h</ulink>, but it could be any character value. For example, specifying <varname>c</varname> as <constant>':'</constant> and <varname>length</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. The function is declared in <ulink url='memory.h.html'>memory.h</ulink> and defined in <ulink url='hexout.c.html'>hexout.c</ulink>.
  301. </para>
  302. </section>
  303. <section id="function-hexstring">
  304. <title>
  305. hexstring
  306. </title>
  307. <funcsynopsis>
  308. <funcprototype>
  309. <funcdef>char * <function>hexstring</function></funcdef>
  310. <paramdef>char <parameter>buffer</parameter> []</paramdef>
  311. <paramdef>size_t <parameter>length</parameter></paramdef>
  312. <paramdef>const byte <parameter>memory</parameter> []</paramdef>
  313. <paramdef>size_t <parameter>extent</parameter></paramdef>
  314. </funcprototype>
  315. </funcsynopsis>
  316. <para>
  317. 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='library-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>.
  318. </para>
  319. </section>
  320. <section id="function-hexview">
  321. <title>
  322. hexview
  323. </title>
  324. <funcsynopsis>
  325. <funcprototype>
  326. <funcdef>void <function>hexview</function></funcdef>
  327. <paramdef>const void * <parameter>memory</parameter></paramdef>
  328. <paramdef>size_t <parameter>offset</parameter></paramdef>
  329. <paramdef>size_t <parameter>extent</parameter></paramdef>
  330. <paramdef>FILE * <parameter>fp</parameter></paramdef>
  331. </funcprototype>
  332. </funcsynopsis>
  333. <para>
  334. 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. 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>
  335. <para>
  336. This function is similar to but different from function <link linkend='library-hexdump'>hexdump</link>.
  337. </para>
  338. </section>
  339. <section id="library-ipv4spec">
  340. <title>
  341. ipv4spec
  342. </title>
  343. <funcsynopsis>
  344. <funcprototype>
  345. <funcdef>size_t <function>ipv4spec</function></funcdef>
  346. <paramdef>const char * <parameter>string</parameter></paramdef>
  347. <paramdef>byte <parameter>memory</parameter> []</paramdef>
  348. </funcprototype>
  349. </funcsynopsis>
  350. <para>
  351. Encode a 4-byte <varname>memory</varname> region with an IPv4 dotted-decimal <varname>string</varname> and return the number of bytes encoded. Terminate the program with an error message and exitcode of <constant>1</constant> on conversion error. The value returned by this function is always <constant>4</constant> and memory is always encoded in network byte order. This function is typically used to convert IPv4 strings entered as command line arguments. The function is declared in <ulink url='memory.h.html'>memory.h</ulink> and defined in <ulink url='ipv4spec.c.html'>ipv4spec.c</ulink>.
  352. </para>
  353. <para>
  354. Dotted-decimal format consists of decimal values in the range 0 through 255. Each value represents one octet or 8-bit value. IPv4 addresses require 4 such values separated by one decimal point. This function permits empty octets and leading zeros within octets. For example, <quote>...</quote> is equivalent to <quote>0.0.0.0</quote> and <quote>127.0.000.001</quote> is equivalent to <quote>127.0.0.1</quote>. The second example will encode memory as follows <constant>{ 0x7F, 0x00, 0x00, 0x01 }</constant> which is in network byte order, or big endian.
  355. </para>
  356. </section>
  357. <section id="function-ipv6spec">
  358. <title>
  359. ipv6spec
  360. </title>
  361. <funcsynopsis>
  362. <funcprototype>
  363. <funcdef>size_t <function>ipv6spec</function></funcdef>
  364. <paramdef>const char * <parameter>string</parameter></paramdef>
  365. <paramdef>byte <parameter>memory</parameter> []</paramdef>
  366. </funcprototype>
  367. </funcsynopsis>
  368. <para>
  369. Encode a 16-byte <varname>memory</varname> region with an IPv6 colon-separated hexadecimal quartet <varname>string</varname> and return the number of bytes encoded. Terminate the program with an error message and exitcode of <constant>1</constant> on conversion error. The value returned by this function is always <constant>16</constant> and memory is always encoded in network byte order. This function is typically used to convert IPv6 strings entered as command line arguments. The function is declared in <ulink url='memory.h.html'>memory.h</ulink> and defined in <ulink url='ipv6spec.c.html'>ipv6spec.c</ulink>.
  370. </para>
  371. <para>
  372. Colon-separated hexadecimal quartet notation consists of hexadecimal values in the range 0 through FFFF. Each value represents a quartet or a 32-bit value. IPv6 addresses require 8 quartets separated by one colon. By convention, an empty quartet expands with enough zeros to right-justify the remainder of the address. This function permits multiple empty quartets and leading zeros within quartets. When multiple empty quartets appear, only the right-most occurance expands to zeros. For example, <quote>AA12::BB34::CC56::DD78</quote> is equivalent to <quote>AA12:0000:BB34:0000:CC56:0000:0000:DD78</quote> because only the right-most empty field expands. This will encode memory as follows <constant>{ 0xAA, 0x12, 0x00, 0x00, 0xBB, 0x34, 0x00, 0x00, 0xCC, 0x56, 0x00, 0x00, 0x00, 0x00, 0xDD, 0x78 }</constant> which is in network byte order, or big-endian.
  373. </para>
  374. </section>
  375. <section id="function-memdecr">
  376. <title>
  377. memdecr
  378. </title>
  379. <funcsynopsis>
  380. <funcprototype>
  381. <funcdef>signed <function>memdecr</function></funcdef>
  382. <paramdef>byte <parameter>memory</parameter> []</paramdef>
  383. <paramdef>size_t <parameter>length</parameter></paramdef>
  384. </funcprototype>
  385. </funcsynopsis>
  386. <para>
  387. 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>.
  388. </para>
  389. </section>
  390. <section id="function-memincr">
  391. <title>
  392. memincr
  393. </title>
  394. <funcsynopsis>
  395. <funcprototype>
  396. <funcdef>signed <function>memincr</function></funcdef>
  397. <paramdef>byte <parameter>memory</parameter> []</paramdef>
  398. <paramdef>size_t <parameter>length</parameter></paramdef>
  399. </funcprototype>
  400. </funcsynopsis>
  401. <para>
  402. 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>.
  403. </para>
  404. </section>
  405. <section id="function-memswap">
  406. <title>
  407. memswap
  408. </title>
  409. <funcsynopsis>
  410. <funcprototype>
  411. <funcdef>void <function>memswap</function></funcdef>
  412. <paramdef>void * <parameter>buffer1</parameter></paramdef>
  413. <paramdef>void * <parameter>buffer2</parameter></paramdef>
  414. <paramdef>size_t <parameter>length</parameter></paramdef>
  415. </funcprototype>
  416. </funcsynopsis>
  417. <para>
  418. 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>.
  419. </para>
  420. </section>
  421. <section id="function-strdecr">
  422. <title>
  423. strdecr
  424. </title>
  425. <funcsynopsis>
  426. <funcprototype>
  427. <funcdef>signed <function>strdecr</function></funcdef>
  428. <paramdef>byte <parameter>memory</parameter> []</paramdef>
  429. <paramdef>size_t <parameter>length</parameter></paramdef>
  430. <paramdef>byte <parameter>min</parameter></paramdef>
  431. <paramdef>byte <parameter>max</parameter></paramdef>
  432. </funcprototype>
  433. </funcsynopsis>
  434. <para>
  435. 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>.
  436. </para>
  437. </section>
  438. <section id="function-strincr">
  439. <title>
  440. strincr
  441. </title>
  442. <funcsynopsis>
  443. <funcprototype>
  444. <funcdef>signed <function>strincr</function></funcdef>
  445. <paramdef>byte <parameter>memory</parameter> []</paramdef>
  446. <paramdef>size_t <parameter>length</parameter></paramdef>
  447. <paramdef>byte <parameter>min</parameter></paramdef>
  448. <paramdef>byte <parameter>max</parameter></paramdef>
  449. </funcprototype>
  450. </funcsynopsis>
  451. <para>
  452. 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>.
  453. </para>
  454. </section>
  455. </section>
  456. <section id="library-number">
  457. <title>
  458. tools/number.h
  459. </title>
  460. <section id="function-todigit">
  461. <title>
  462. todigit
  463. </title>
  464. <funcsynopsis>
  465. <funcprototype>
  466. <funcdef>unsigned <function>todigit</function></funcdef>
  467. <paramdef>unsigned <parameter>c</parameter></paramdef>
  468. </funcprototype>
  469. </funcsynopsis>
  470. <para>
  471. 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'>todogit.c</ulink>.
  472. </para>
  473. </section>
  474. <section id="function-basespec">
  475. <title>
  476. basespec
  477. </title>
  478. <funcsynopsis>
  479. <funcprototype>
  480. <funcdef>uint64_t <function>basespec</function></funcdef>
  481. <paramdef>const char * <parameter>string</parameter></paramdef>
  482. <paramdef>unsigned <parameter>base</parameter></paramdef>
  483. <paramdef>unsigned <parameter>size</parameter></paramdef>
  484. </funcprototype>
  485. </funcsynopsis>
  486. <para>
  487. Return the unsigned integer equivalent of a numeric <varname>string</varname>. Print an error message on <varname>stderr</varname> and exit the program with status <constant>1</constant> if a syntax error occurs or the result exceeds the capacity of the requested integer <varname>size</varname> in bytes. If <varname>base</varname> is <constant>0</constant>, numeric values may be expressed in decimal, hexadecimal or binary notation where hexadecimal values start with <constant>"0x"</constant> and binary values start with <constant>"0b"</constant>. When <varname>base</varname> is non-zero, the notation in <varname>string</varname> must conform to the corresponding number base rules. Applications should cast the return value to the appropriate data type prevent loss-of-data compiler warnings. This function is typically used to convert and length-check integers entered as command line arguments. The function is declared in <ulink url='number.h.html'>number.h</ulink> and defined in <ulink url='basespec.c.html'>basespec.c</ulink>.
  488. </para>
  489. <para>
  490. Like function <link linkend='library-uintspec'>uintspec</link>, this function both converts and range checks numeric string values, but the minimum and maximum value are implicit in the <varname>size</varname> of the integer. The minimum value is always <constant>0</constant> and the maximum value can be computed by <constant>((1 &lt;&lt; size &lt;&lt; 3) - 1)</constant>.
  491. </para>
  492. </section>
  493. <section id="function-dataspec">
  494. <title>
  495. dataspec
  496. </title>
  497. <funcsynopsis>
  498. <funcprototype>
  499. <funcdef>void <function>dataspec</function></funcdef>
  500. <paramdef>const char * <parameter>string</parameter></paramdef>
  501. <paramdef>byte <parameter>memory</parameter> []</paramdef>
  502. <paramdef>size_t <parameter>extent</parameter></paramdef>
  503. </funcprototype>
  504. </funcsynopsis>
  505. <para>
  506. Encode a <varname>memory</varname> region with the binary equivalent of a variable-length hexadecimal string. Print an error message on stderr and exit the program with the status <constant>1</constant> if a syntax error occurs or the number of octets exceeds <varname>extent</varname>. The number of octets may, however, be less than <constant>extent</constant>. Unlike function <link linkend='library-bytespec'>bytespec</link>, hexadecimal octets may not be separated by colons. This function is typically used to enter variable-length data from the command line. The function is declared in <ulink url='memory.h.html'>memory.h</ulink> and defined in <ulink url='dataspec.c.html'>dataspec.c</ulink>.
  507. </para>
  508. </section>
  509. <section id="function-uintspec">
  510. <title>
  511. uintspec
  512. </title>
  513. <funcsynopsis>
  514. <funcprototype>
  515. <funcdef>uint64_t <function>uintspec</function></funcdef>
  516. <paramdef>const char * <parameter>string</parameter></paramdef>
  517. <paramdef>uint64_t <parameter>minimum</parameter></paramdef>
  518. <paramdef>uint64_t <parameter>maximum</parameter></paramdef>
  519. </funcprototype>
  520. </funcsynopsis>
  521. <para>
  522. Return the unsigned integer equivalent of a numeric <varname>string</varname>. Print an error message on <varname>stderr</varname> and exit the program with the value <constant>1</constant> when a syntax error occurs or the result exceeds the specified <varname>minimum</varname> or <varname>maximum</varname> value. Numeric values may be expressed in decimal, hexadecimal or binary notation where hexadecimal values start with <constant>"0x"</constant> and binary values start with <constant>"0b"</constant>. Applications should cast the return value to the appropriate data type to avoid loss-of-data warnings on some compilers. This function is typically used to convert and range-check integer values entered as command-line arguments. The function is declared in <ulink url='number.h.html'>number.h</ulink> and defined in <ulink url='uintspec.c.html'>uintspec.c</ulink>.
  523. </para>
  524. </section>
  525. </section>
  526. <section id="library-symbol">
  527. <title>
  528. tools/symbol.h
  529. </title>
  530. <section id="function-assist">
  531. <title>
  532. assist
  533. </title>
  534. <funcsynopsis>
  535. <funcprototype>
  536. <funcdef>void <function>assist</function></funcdef>
  537. <paramdef>const char * <parameter>name</parameter></paramdef>
  538. <paramdef>const char * <parameter>type</parameter></paramdef>
  539. <paramdef>const struct _code_ <parameter>list</parameter> []</paramdef>
  540. <paramdef>size_t <parameter>size</parameter></paramdef>
  541. <paramdef>FILE * <parameter>fp</parameter></paramdef>
  542. </funcprototype>
  543. </funcsynopsis>
  544. <para>
  545. Show why a symbolic <varname>name</varname> was rejected by function <link linkend='library-lookup'>lookup</link> or similar functions. Argument <varname>type</varname> contains a title for the class of names stored in <varname>list</varname>. This function prints an error message on file stream <constant>fp</constant> showing the program name, the <varname>type</varname> string, the symbolic <varname>name</varname> and all names stored in the <varname>list</varname>. The <constant>_code_</constant> structure is declared in <ulink url='types.h.html'>types.h</ulink>. The function is declared in <ulink url='symbol.h.html'>symbol.h</ulink> and defined in <ulink url='assist.c.html'>assist.c</ulink>. Function <link linkend='library-expect'>expect</link> is used to print list names.
  546. </para>
  547. </section>
  548. <section id="function-expect">
  549. <title>
  550. expect
  551. </title>
  552. <funcsynopsis>
  553. <funcprototype>
  554. <funcdef>void <function>expect</function></funcdef>
  555. <paramdef>const struct _code_ <parameter>list</parameter> []</paramdef>
  556. <paramdef>size_t <parameter>size</parameter></paramdef>
  557. <paramdef>FILE * <parameter>fp</parameter></paramdef>
  558. </funcprototype>
  559. </funcsynopsis>
  560. <para>
  561. Display all names in argument <varname>list</varname> on file stream <varname>fp</varname>. This function is called by runction <link linkend='library-assist'>assist</link> to print the list of symbolic names but other function may have use for it. The <constant>_code_</constant> structure is declared in <ulink url='types.h.html'>types.h</ulink>. The function is declared in <ulink url='symbol.h.html'>symbol.h</ulink> and defined in <ulink url='expect.c.html'>expect.c</ulink>.
  562. </para>
  563. </section>
  564. <section id="function-lookup">
  565. <title>
  566. lookup
  567. </title>
  568. <funcsynopsis>
  569. <funcprototype>
  570. <funcdef>signed <function>lookup</function></funcdef>
  571. <paramdef>const char * <parameter>name</parameter></paramdef>
  572. <paramdef>const struct _code_ <parameter>list</parameter> []</paramdef>
  573. <paramdef>size_t <parameter>size</parameter></paramdef>
  574. </funcprototype>
  575. </funcsynopsis>
  576. <para>
  577. Lookup a symbolic <varname>name</varname> in a <varname>list</varname> and return an associated integer or <constant>-1</constant> if the <varname>name</varname> does not appear in the <varname>list</varname>. A typical use is the translation of symbolic command line arguments to integer codes. For example, some Toolkit programs assign symbolic names to field codes so that users can enter names instead of numbers. This approach becomes more useful as the number of permitted codes increases. The <constant>_code_</constant> structure is declared in <ulink url='types.h.html'>types.h</ulink>. The function is declared in <ulink url='symbol.h.html'>symbol.h</ulink> and defined in <ulink url='lookup.c.html'>lookup.c</ulink>.
  578. </para>
  579. <para>
  580. This function offers two benefits: 1) multiple symbols can translate to one code and 2) names can be changed or new names added without affecting program logic. This function is similar to but different from function <link linkend='library-synonym'>synonym</link> which returns a character string instead of an integer.
  581. </para>
  582. </section>
  583. <section id="function-synonym">
  584. <title>
  585. synonym
  586. </title>
  587. <funcsynopsis>
  588. <funcprototype>
  589. <funcdef>const char * <function>synonym</function></funcdef>
  590. <paramdef>const char * <parameter>string</parameter></paramdef>
  591. <paramdef>const struct _term_ <parameter>list</parameter> []</paramdef>
  592. <paramdef>size_t <parameter>size</parameter></paramdef>
  593. </funcprototype>
  594. </funcsynopsis>
  595. <para>
  596. Lookup a symbolic <varname>name</varname> in a <varname>list</varname> and return an associated string or the original <name>string</name> if the <varname>name</varname> does not appear in the <varname>list</varname>. A typical use is the translation of symbolic command line arguments to their equivalent numeric strings before encoding them. For example, many Toolkit programs convert the command line argument <quote>local</quote> to <quote>00:B0:52:00:00:01</quote> before encoding the device MAC address. The <constant>_term_</constant> structure is declared in <ulink url='types.h.html'>types.h</ulink>. The function is declared in <ulink url='symbol.h.html'>symbol.h</ulink> and defined in <ulink url='synonym.c.html'>synonym.c</ulink>.
  597. </para>
  598. <para>
  599. This function is similar to but different from function <link linkend='library-lookup'>lookup</link> which returns an integer instead of a character string.
  600. </para>
  601. </section>
  602. <section id="function-typename">
  603. <title>
  604. typename
  605. </title>
  606. <funcsynopsis>
  607. <funcprototype>
  608. <funcdef>const char * <function>typename</function></funcdef>
  609. <paramdef>const struct _type_ <parameter>list</parameter> []</paramdef>
  610. <paramdef>size_t <parameter>size</parameter></paramdef>
  611. <paramdef>type_t <parameter>type</parameter></paramdef>
  612. <paramdef>const char * <parameter>name</parameter></paramdef>
  613. </funcprototype>
  614. </funcsynopsis>
  615. <para>
  616. 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='tools.h.html'>tools.h</ulink> and defined in <ulink url='typename.c.html'>typename.c</ulink>.
  617. </para>
  618. </section>
  619. </section>
  620. <section id="library-putoptv">
  621. <title>
  622. tools/putoptv.h
  623. </title>
  624. <section id="function-putoptv">
  625. <title>
  626. putoptv
  627. </title>
  628. <funcsynopsis>
  629. <funcprototype>
  630. <funcdef>void <function>putoptv</function></funcdef>
  631. <paramdef>const char * <parameter>optv</parameter> []</paramdef>
  632. </funcprototype>
  633. </funcsynopsis>
  634. <para>
  635. Print program information on <constant>stdout</constant>. Program information is stored in string vector <varname>optv</varname>. String indexes are defined in file <filename>putoptv.h</filename>. String <varname>optv[0]</varname> is the <acronym>POSIX</acronym> standard argument <varname>optstring</varname>. This function is called by function <function>getoptv</function> whenever option <userinput>-?</userinput> or <userinput>--help</userinput> is detected on the command line. There is virtually no need to call this function directly. The function is declared in <ulink url='putoptv.h.html'>putoptv.h</ulink> and defined in <ulink url='putoptv.c.html'>putoptv.c</ulink>.
  636. </para>
  637. </section>
  638. </section>
  639. <section id="library-version">
  640. <title>
  641. tools/version.h
  642. </title>
  643. <section id="function-version">
  644. <title>
  645. version
  646. </title>
  647. <funcsynopsis>
  648. <funcprototype>
  649. <funcdef>void <function>version</function></funcdef>
  650. <void/>
  651. </funcprototype>
  652. </funcsynopsis>
  653. <para>
  654. Print package and program version information on <constant>stdout</constant>. This function is called by function <function>getoptv</function> whenever option <userinput>-!</userinput> or <userinput>--version</userinput> is detected on the command line. There is virtually no need to call this function directly. The function is declared in <ulink url='version.h.html'>version.h</ulink> and defined in <ulink url='version.c.html'>version.c</ulink>. Constants <constant>PACKAGE</constant> and <constant>VERSION</constant> define the information that is displayed. They are defined in file <ulink url="version.h.html">version.h</ulink> and must be maintained by developers.
  655. </para>
  656. </section>
  657. </section>
  658. <section id="library-mme">
  659. <title>
  660. mme/mme.h
  661. </title>
  662. <section id="function-mmecode">
  663. <title>
  664. MMECode
  665. </title>
  666. <funcsynopsis>
  667. <funcprototype>
  668. <funcdef>const char *<function>MMECode</function></funcdef>
  669. <paramdef>uint16_t <parameter>MMTYPE</parameter></paramdef>
  670. <paramdef>uint8_t <parameter>MSTATUS</parameter></paramdef>
  671. </funcprototype>
  672. </funcsynopsis>
  673. <para>
  674. Return text that explains the status code for a given Atheros vendor-specific management message. Argument <varname>MMTYPE</varname> is an unsigned integer in the range <constant>0xA000</constant> through <constant>0xAFFF</constant> and must exactly match the <varname>MMTYPE</varname> of the message returning the status code. For example, the <varname>CNF</varname> variant of a message is currently the only variant that has an <varname>MSTATUS</varname> field and so other variants return a default string. The function is declared in <ulink url="mme.h.html">mme.h</ulink> and defined in <ulink url="MMECode.c.html">MMECode.c</ulink>.
  675. </para>
  676. <para>
  677. Inclusion of this function can increase application size by 3kb because the text associated with all Atheros vendor-specific management messages and errors are included whether needed or not. Conditional compilation statements are provided internally to suppress the full table with a terse substitute.
  678. </para>
  679. <para>
  680. Although the <application>Bootloader</application> and firmware share some common Vendor Specific Management Messages, the two programs may return different codes for a given message and error condition. Where there are conflicts, Bootloader codes take precedence over firmware codes because it is unlikely that users will .issue the same messages to a device running firmware.
  681. </para>
  682. </section>
  683. <section id="function-mmemode">
  684. <title>
  685. MMEMode
  686. </title>
  687. <funcsynopsis>
  688. <funcprototype>
  689. <funcdef>const char *<function>MMEMode</function></funcdef>
  690. <paramdef>uint16_t <parameter>MMTYPE</parameter></paramdef>
  691. </funcprototype>
  692. </funcsynopsis>
  693. <para>
  694. Return the mode of a given management message type as a string. The mode is determined by the two least significant bits of argument <varname>MMTYPE</varname>. The mode string will be one of <quote>REQ</quote>, <quote>CNF</quote>, <quote>IND</quote> or <quote>RSP</quote>. The function is declared in <ulink url="ihp.h.html">ihp.h</ulink> and defined in <ulink url="MMEMode.c.html">MMEMode.c</ulink>.
  695. </para>
  696. <para>
  697. Most management messages have a request and a confirmation variant while a few have an indication and a response variant. Requests originate from the host and are acknolwedged by a confirmation from the device. Indications originate from a device and are acknowledged by a response from the host.
  698. </para>
  699. </section>
  700. <section id="function-mmename">
  701. <title>
  702. MMEName
  703. </title>
  704. <funcsynopsis>
  705. <funcprototype>
  706. <funcdef>const char *<function>MMEName</function></funcdef>
  707. <paramdef>uint16_t <parameter>MMTYPE</parameter></paramdef>
  708. </funcprototype>
  709. </funcsynopsis>
  710. <para>
  711. Return the name associated with a given management message type. The name is the mnemonic used to distinguish one message type from another in the <citetitle>HomePlug AV Specification</citetitle> or Atheros <citetitle>Firwmare Technical Reference Manual</citetitle>. Argument <varname>MMTYPE</varname> is an unsigned integer in the range <constant>0x0000</constant> through <constant>0xAFFF</constant>. The request, confirmation, indication and response variants of a management message will all return the same message name. The function is declared in <ulink url="mme.h.html">mme.h</ulink> and defined in <ulink url="MMEName.c.html">MMEName.c</ulink>.
  712. </para>
  713. </section>
  714. <section id="function-mmepeek">
  715. <title>
  716. MMEPeek
  717. </title>
  718. <funcsynopsis>
  719. <funcprototype>
  720. <funcdef>void <function>MMEPeek</function></funcdef>
  721. <paramdef>const byte <parameter>memory</parameter> []</paramdef>
  722. <paramdef>size_t <parameter>length</parameter></paramdef>
  723. <paramdef>size_t length, FILE *<parameter>fp</parameter></paramdef>
  724. </funcprototype>
  725. </funcsynopsis>
  726. <para>
  727. Prints an Atheros vendor-specific management message to stream <constant>fp</constant> in human readable format. Argument <varname>buffer</varname> is the message address and argument <varname>length</varname> is the message length in bytes. Output consists of a formatted header showing decoded header. The function is declared in <ulink url="mme.h.html">mme.h</ulink> and defined in <ulink url="MMEPeek.c.html">MMEPeek.c</ulink>.
  728. </para>
  729. </section>
  730. </section>
  731. <section id='library-keys'>
  732. <title>
  733. crypt/keys.h
  734. </title>
  735. <section id="library-MACPasswords">
  736. <title>
  737. MACPasswords
  738. </title>
  739. <funcsynopsis>
  740. <funcprototype>
  741. <funcdef>void <function>MACPasswords</function></funcdef>
  742. <paramdef>uint32_t<parameter>vendor</parameter></paramdef>
  743. <paramdef>uint32_t<parameter>device</parameter></paramdef>
  744. <paramdef>uint32_t<parameter>number</parameter></paramdef>
  745. <paramdef>unsigned <parameter>count</parameter></paramdef>
  746. <paramdef>unsigned <parameter>bunch</parameter></paramdef>
  747. <paramdef>unsigned <parameter>space</parameter></paramdef>
  748. <paramdef>flag_t <parameter>flags</parameter></paramdef>
  749. </funcprototype>
  750. </funcsynopsis>
  751. <para>
  752. Print a range of device addresses and user passwords on stdout. The calling application must split the starting device address into a three-byte <acronym>OUI</acronym> and three-byte device number and pass them as the unsigned 32-bit integers <varname>vendor</varname> and <varname>device</varname>, respectively. Argument <varname>device</varname> is the first device number in the range and <varname>number</varname> is the final device number. Argument <varname>count</varname> is the number of uppercase letters comprising a password. Passwords contain this many letters but the letters are grouped for easy reading. Letter groups are separated by hyphens. Argument <varname>bunch</varname> defines how many letters form each group. Argument <varname>space</varname> is the character used to separate groups of letters. Argument <varname>flags</varname> enables or disables function features such as insertion of a <quote>used</quote> flag for use by the Atheros Production Test System or the omission of the device address on output. The output of this function is similar to that produced by the <application>DB Builder</application> utility distributed with the <acronym>PTS</acronym>. This function is declared in <ulink url="keys.h.html">keys.h</ulink> and defined in <ulink url="MACPasswords.c.html">MACPasswords.c</ulink>. </para>
  753. </section>
  754. </section>
  755. <section id='library-HPAVKey.h'>
  756. <title>
  757. crypt/HPAVKey.h
  758. </title>
  759. <section id="function-HPAVKeyDAK">
  760. <title>
  761. HPAVKeyDAK
  762. </title>
  763. <funcsynopsis>
  764. <funcprototype>
  765. <funcdef>void <function>HPAVKeyDAK</function></funcdef>
  766. <paramdef> byte <parameter>DAK</parameter> []</paramdef>
  767. <paramdef>const char <parameter>string</parameter></paramdef>
  768. </funcprototype>
  769. </funcsynopsis>
  770. <para>
  771. Encode buffer <varname>DAK</varname> with the Device Access Key (<acronym>DAK</acronym>) derived from the <constant>NUL</constant> terminated <varname>string</varname>. The <varname>string</varname> is salted, hashed and re-hashed using the <acronym>SHA256</acronym> algorithm. The <varname>DAK</varname> is always <constant>HPAVKEY_DAK_LEN</constant> bytes, defined in <ulink url="HPAVKey.h.html">HPAVKey.h</ulink>, so no length argument is needed. See the HomePlug AV Specification for more information. This function is declared in <ulink url="HPAVKey.h.html">HPAVKey.h</ulink> and defined in <ulink url="HPAVKeyDAK.c.html">HPAVKeyDAK.c</ulink>.
  772. </para>
  773. </section>
  774. <section id="function-HPAVKeyNMK">
  775. <title>
  776. HPAVKeyNMK
  777. </title>
  778. <funcsynopsis>
  779. <funcprototype>
  780. <funcdef>void <function>HPAVKeyNMK</function></funcdef>
  781. <paramdef> byte <parameter>digest</parameter> []</paramdef>
  782. <paramdef>const char <parameter>string</parameter></paramdef>
  783. </funcprototype>
  784. </funcsynopsis>
  785. <para>
  786. Encode buffer <varname>NMK</varname> with the Network Membership Key (<acronym>NMK</acronym>) derived from the <constant>NUL</constant> terminated <varname>string</varname>. The string is salted, hashed and re-hashed using the <acronym>SHA256</acronym> algorithm. The <varname>DAK</varname> is always <constant>HPAVKEY_NMK_LEN</constant> bytes, as defined in <ulink url="HPAVKey.h.html">HPAVKey.h</ulink>, so no length argument is needed. See the HomePlug AV Specification for more information. This function is declared in <ulink url="HPAVKey.h.html">HPAVKey.h</ulink> and defined in <ulink url="HPAVKeyNMK.c.html">HPAVKeyNMK.c</ulink>.
  787. </para>
  788. </section>
  789. <section id="function-HPAVKeyNID">
  790. <title>
  791. HPAVKeyNID
  792. </title>
  793. <funcsynopsis>
  794. <funcprototype>
  795. <funcdef>void <function>HPAVKeyNID</function></funcdef>
  796. <paramdef> byte <parameter>NID</parameter> []</paramdef>
  797. <paramdef>const byte <parameter>NMK</parameter> []</paramdef>
  798. <paramdef>signed <parameter>level</parameter></paramdef>
  799. </funcprototype>
  800. </funcsynopsis>
  801. <para>
  802. Encode buffer <varname>NID</varname> with the Network Identification Key (<acronym>NID</acronym>) derived from the 16-byte Network Membership Key (<acronym>NMK</acronym>). The <varname>NMK</varname> is hashed and re-hashed using the <acronym>SHA256</acronym> algorithm then encoded with the security <varname>level</varname>. The <varname>NID</varname> is always <constant>HPAVKEY_NID_LEN</constant> bytes, as defined in <ulink url="HPAVKey.h.html">HPAVKey.h</ulink>, so no length argument is needed. See the HomePlug AV Specification for more information. This function is declared in <ulink url="HPAVKey.h.html">HPAVKey.h</ulink> and defined in <ulink url="HPAVKeyNID.c.html">HPAVKeyNID.c</ulink>.
  803. </para>
  804. </section>
  805. <section id="function-HPAVKeyOut">
  806. <title>
  807. HPAVKeyOut
  808. </title>
  809. <funcsynopsis>
  810. <funcprototype>
  811. <funcdef>void <function>HPAVKeyOut</function></funcdef>
  812. <paramdef>const byte <parameter>digest</parameter> []</paramdef>
  813. <paramdef>size_t <parameter>length</parameter></paramdef>
  814. <paramdef>const char * <parameter>phrase</parameter></paramdef>
  815. <paramdef>flag_t <parameter>flags</parameter></paramdef>
  816. </funcprototype>
  817. </funcsynopsis>
  818. <para>
  819. Decode and print up to <varname>length</varname> bytes from buffer <varname>digest</varname> on stdout. Print <constant>NUL</constant> terminated <varname>phrase</varname> on the same line following the digest when bit <varname>HPAVKEY_VERBOSE</varname>, defined in <ulink url='HPAVKey.h.html'>HPAVKey.h</ulink>, is set in <varname>flags</varname>. This procedure prints keys and phrases in a standard column-oriented format that other applications can easily read and use. This function is declared in <ulink url="HPAVKey.h.html">HPAVKey.h</ulink> and defined in <ulink url="HPAVKeyOut.c.html">HPAVKeyOut.c</ulink>.
  820. </para>
  821. </section>
  822. </section>
  823. <section id='library-SHA256'>
  824. <title>
  825. crypt/SHA256.h
  826. </title>
  827. <section id="function-SHA256Block">
  828. <title>
  829. SHA256Block
  830. </title>
  831. <funcsynopsis>
  832. <funcprototype>
  833. <funcdef>void <function>SHA256Block</function></funcdef>
  834. <paramdef>struct sha256 *<parameter>sha256</parameter></paramdef>
  835. <paramdef>const byte <parameter>buffer</parameter> []</paramdef>
  836. </funcprototype>
  837. </funcsynopsis>
  838. <para>
  839. Merge one 64 byte block of information into the current <acronym>SHA256</acronym> digest. This function performs the core computations required by the <acronym>SHA256</acronym> algoithm. It is called by function <link linkend='library-SHA256Fetch'><varname>SHA256Fetch</varname></link> and there is no reason to call this function directly. This function is declared in <ulink url="SHA256.h.html">SHA256.h</ulink> and defined in <ulink url="SHA256Block.c.html">SHA256Block.c</ulink>. The sha256 structure is defined in <ulink url="SHA256.h.html">SHA256.h</ulink>.
  840. </para>
  841. </section>
  842. <section id="function-SHA256Fetch">
  843. <title>
  844. SHA256Fetch
  845. </title>
  846. <funcsynopsis>
  847. <funcprototype>
  848. <funcdef>void <function>SHA256Fetch</function></funcdef>
  849. <paramdef>struct sha256 *<parameter>sha256</parameter></paramdef>
  850. <paramdef> byte <parameter>digest</parameter> []</paramdef>
  851. </funcprototype>
  852. </funcsynopsis>
  853. <para>
  854. Conclude <acronym>SHA256</acronym> computation and copy the result to the specified 32-byte <varname>digest</varname> buffer. The <varname>digest</varname> is always 32 bytes long regardless of the amount of information written using function <link linkend='library-SHA256Write'>SHA256Write</link>. The <varname>sha256</varname> structure is defined in <ulink url="SHA256.h.html">SHA256.h</ulink>. This function is declared in <ulink url="SHA256.h.html">SHA256.h</ulink> and defined in <ulink url="SHA256Fetch.c.html">SHA256Fetch.c</ulink>.
  855. </para>
  856. </section>
  857. <section id="function-SHA256Ident">
  858. <title>
  859. SHA256Ident
  860. </title>
  861. <funcsynopsis>
  862. <funcprototype>
  863. <funcdef>void <function>SHA256Ident</function></funcdef>
  864. <paramdef>int <parameter>fd</parameter></paramdef>
  865. <paramdef> byte <parameter>digest</parameter> []</paramdef>
  866. </funcprototype>
  867. </funcsynopsis>
  868. <para>
  869. Compute the SHA256 digest from the content of a file. The digest serves as the file <quote>fingerprint</quote> and can be used to identify identical content despite filename changes. File descriptor <varname>fd</varname> is the subject file which must be positioned to the start befor calling this function. Buffer <varname>digest</varname> will be written with the computed 256-digest and must be <constant>SHA256_DIGEST_SIZE</constant> bytes long, as defined in <ulink url="SHA256.h.html">SHA256.h</ulink>. This function is declared in <ulink url="SHA256.h.html">SHA256.h</ulink> and defined in <ulink url="SHA256Ident.c.html">SHA256Ident.c</ulink>.
  870. </para>
  871. </section>
  872. <section id="function-SHA256Match">
  873. <title>
  874. SHA256Match
  875. </title>
  876. <funcsynopsis>
  877. <funcprototype>
  878. <funcdef>void <function>SHA256Match</function></funcdef>
  879. <paramdef>int <parameter>fd</parameter></paramdef>
  880. <paramdef>const byte <parameter>digest</parameter> []</paramdef>
  881. </funcprototype>
  882. </funcsynopsis>
  883. <para>
  884. Search a registry file for a known SHA256 digest. Return <constant>true</constant> on success or <constant>false</constant> on failure. File descriptor <varname>fd</varname> is the registry file which must be positioned to the start before calling this function. Buffer <varname>digest</varname> contains the known 256-bit digest and must be <constant>SHA256_DIGEST_SIZE</constant> bytes long, as defined in <ulink url='SHA256.h.html'>SHA256.h</ulink>. A registry file consists of 64-digit hexadecimal strings that represent SHA256 digest values. Optional text may be appear between the digest and newline to document digest significance. This function ignores such text. This function is declared in <ulink url="SHA256.h.html">SHA256.h</ulink> and defined in <ulink url="SHA256Match.c.html">SHA256Match.c</ulink>.
  885. </para>
  886. </section>
  887. <section id="function-SHA256Print">
  888. <title>
  889. SHA256Print
  890. </title>
  891. <funcsynopsis>
  892. <funcprototype>
  893. <funcdef>void <function>SHA256Print</function></funcdef>
  894. <paramdef>const byte <parameter>digest</parameter> []</paramdef>
  895. <paramdef>const char * <parameter>string</parameter></paramdef>
  896. </funcprototype>
  897. </funcsynopsis>
  898. <para>
  899. Print an SHA256 <varname>digest</varname> and optional <varname>string</varname> on <constant>stdout</constant>. Buffer <varname>digest</varname> must be <constant>SHA256_DIGEST_SIZE</constant> bytes long, as defined in <ulink url='SHA256.h.html'>SHA256.h</ulink>, which results in 64 hexadecimal digits on output. Variable length string is <constant>NUL</constant> terminated but may be <constant>NULL</constant>. If <varname>string</varname> is not <constant>NULL</constant> and is not empty then a space is inserted between the digest and the string on output. This function may be used to print SHA256 digests and optional strings in standard format, such as a registry file. This function is declared in <ulink url="SHA256.h.html">SHA256.h</ulink> and defined in <ulink url="SHA256Print.c.html">SHA256Print.c</ulink>.
  900. </para>
  901. </section>
  902. <section id="function-SHA256Reset">
  903. <title>
  904. SHA256Reset
  905. </title>
  906. <funcsynopsis>
  907. <funcprototype>
  908. <funcdef>void <function>SHA256Reset</function></funcdef>
  909. <paramdef>struct sha256 *<parameter>sha256</parameter></paramdef>
  910. </funcprototype>
  911. </funcsynopsis>
  912. <para>
  913. Initialize a <varname>sha256</varname> structure before computing a new <acronym>SHA256</acronym> digest. This function should be called once before calling <link linkend='library-SHA256Write'>SHA256Write</link> for the first time for a given digest. The <varname>sha256</varname> structure is defined in <ulink url="SHA256.h.html">SHA256.h</ulink>. This function is declared in <ulink url="SHA256.h.html">SHA256.h</ulink> and defined in <ulink url="SHA256Reset.c.html">SHA256Reset.c</ulink>.
  914. </para>
  915. </section>
  916. <section id="function-SHA256Write">
  917. <title>
  918. SHA256Write
  919. </title>
  920. <funcsynopsis>
  921. <funcprototype>
  922. <funcdef>void <function>SHA256Write</function></funcdef>
  923. <paramdef>struct sha256 *<parameter>sha256</parameter></paramdef>
  924. <paramdef>const byte <parameter>buffer</parameter> []</paramdef>
  925. <paramdef>size_t <parameter>length</parameter></paramdef>
  926. </funcprototype>
  927. </funcsynopsis>
  928. <para>
  929. Writes a variable-length block of information to the current <acronym>SHA256</acronym> digest contained in an <varname>sha256</varname> structure. An application may call this function any number of times to concatinate multiple blocks of information before fetching the digest with function <function>SHA256Fetch</function>. The <varname>sha256</varname> structure is defined in <ulink url="SHA256.h.html">SHA256.h</ulink>. This function is declared in <ulink url="SHA256.h.html">SHA256.h</ulink> and defined in <ulink url="SHA256Write.c.html">SHA256Write.c</ulink>.
  930. </para>
  931. </section>
  932. </section>
  933. <section id="library-nodes">
  934. <title>
  935. nodes/node.h
  936. </title>
  937. <section id="function-xmledit">
  938. <title>
  939. xmledit
  940. </title>
  941. <funcsynopsis>
  942. <funcprototype>
  943. <funcdef>signed <function>xmledit</function></funcdef>
  944. <paramdef>struct node *<parameter>node</parameter></paramdef>
  945. <paramdef> byte <parameter>buffer</parameter> []</paramdef>
  946. <paramdef>size_t <parameter>length</parameter></paramdef>
  947. </funcprototype>
  948. </funcsynopsis>
  949. <para>
  950. Write data into <varname>buffer</varname> based on offset and length values defined in <acronym>XML</acronym> parse tree, <varname>node</varname>. This function will not apply modifications having malformed structure or having an invalid or an illegal offset, length or data value. Use function <link linkend='nodes-xmlschema'>xmlschema</link> to print the current schema. The function is declared in <ulink url='node.h.html'>node.h</ulink> and defined in <ulink url='xmledit.c.html'>xmledit.c</ulink>. The <varname>node</varname> structure is defined in <ulink url='node.h.html'>node.h</ulink>.
  951. </para>
  952. </section>
  953. <section id="function-xmlfree">
  954. <title>
  955. xmlfree
  956. </title>
  957. <funcsynopsis>
  958. <funcprototype>
  959. <funcdef>void <function>xmlfree</function></funcdef>
  960. <paramdef>struct node *<parameter>node</parameter></paramdef>
  961. </funcprototype>
  962. </funcsynopsis>
  963. <para>
  964. Release memory associated with an XML parse tree. The function is declared in <ulink url='node.h.html'>node.h</ulink> and defined in <ulink url='xmlfree.c.html'>xmlfree.c</ulink>. The <varname>node</varname> structure is defined in <ulink url='node.h.html'>node.h</ulink>.
  965. </para>
  966. <para>
  967. The <varname>text</varname> member if the parse tree root node points to memory allocated by <link linkend="nodes-xmlscan">xmlscan </link> to store the original <acronym>XML</acronym> string. The application must either deallocate that memory before calling this function or store the text address and deallocate that memory after calling this function; otherwise, memory leaks will result.
  968. </para>
  969. </section>
  970. <section id="function-xmlnode">
  971. <title>
  972. xmlnode
  973. </title>
  974. <funcsynopsis>
  975. <funcprototype>
  976. <funcdef>struct node *<function>xmlnode</function></funcdef>
  977. <paramdef>struct node *<parameter>node</parameter></paramdef>
  978. </funcprototype>
  979. </funcsynopsis>
  980. <para>
  981. Create an empty node blow the specified node and return a pointer to it. A typical application can be seen in function <ulink url="xmlscan.c.html" >xmlscan.c</ulink>. The function is declared in <ulink url='node.h.html'>node.h</ulink> and defined in <ulink url='xmlnode.c.html'>xmlnode.c</ulink>. The <varname>node</varname> structure is defined in <ulink url='node.h.html'>node.h</ulink>.
  982. </para>
  983. </section>
  984. <section id="function-xmlopen">
  985. <title>
  986. xmlopen
  987. </title>
  988. <funcsynopsis>
  989. <funcprototype>
  990. <funcdef>struct node *<function>xmlopen</function></funcdef>
  991. <paramdef>const char *<parameter>filename</parameter></paramdef>
  992. </funcprototype>
  993. </funcsynopsis>
  994. <para>
  995. Open the named XML file, parse it and return the XML parse tree. The parse tree contains, among other things, all XML elements, attributes and values specified in the file. The function is declared in <ulink url='node.h.html'>node.h</ulink> and defined in <ulink url='xmlopen.c.html'>xmlopen.c</ulink>. The <varname>node</varname> structure is defined in <ulink url='node.h.html'>node.h</ulink>.
  996. </para>
  997. <para>
  998. The returned parse tree is ready to traverse using struct <varname>node</varname> members <varname>above</varname>, <varname>below</varname>, <varname>prior</varname> and <varname>after</varname>. Each node has a <varname>line</varname>, <varname>type</varname> and <varname>test</varname> member. This function calls function <link linkend="nodes-xmlscan">xmlscan </link> to parse the file and generate the tree. The parse tree can be inspected by passing the root node to function <link linkend="nodes-xmltree">xmltree</link>.
  999. </para>
  1000. </section>
  1001. <section id="function-xmlscan">
  1002. <title>
  1003. xmlscan
  1004. </title>
  1005. <funcsynopsis>
  1006. <funcprototype>
  1007. <funcdef>signed <function>xmlscan </function></funcdef>
  1008. <paramdef>struct node *<parameter>node</parameter></paramdef>
  1009. </funcprototype>
  1010. </funcsynopsis>
  1011. <para>
  1012. Scan the XML string attached to the specified <varname>node</varname> and create a parse tree below it. Return <constant>0</constant> if parsing is successrul or <constant>-1</constant> if not. The function is declared in <ulink url='node.h.html'>node.h</ulink> and defined in <ulink url='xmlscan.c.html'>xmlscan.c</ulink>. The <varname>node</varname> structure is defined in <ulink url='node.h.html'>node.h</ulink>.
  1013. </para>
  1014. <para>
  1015. The application must point the <varname>text</varname> member to a copy of the XML string before calling this function because parsing is destructive and requires write access to the string. The application can search and manipulate the tree on return. The application should deallocate string memory before calling <link linkend="nodes-xmlfree">xmlfree</link>.
  1016. </para>
  1017. <example id="nodes-example-1">
  1018. <title>
  1019. XML Source File
  1020. </title>
  1021. <para>
  1022. The following is sample input to function <function>xmlscan</function>. The element and attribute names shown are for illustration and were selected to that they can be easily identified in the output. The parse tree from this file can be seen in the example for function <link linkend="nodes-example-2">xmltree</link>.
  1023. </para>
  1024. <screen><![CDATA[
  1025. <?xml version="1.0" encoding="UTF-8" ?>
  1026. <xmlfile
  1027. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  1028. xsi:noNamespaceSchemaLocation="myschema.xsd">
  1029. <element name="Element1">
  1030. <attribute name="Attribute1">
  1031. 1234567890
  1032. </attribute>
  1033. <attribute name="Attribute2">
  1034. The quick brown fox jumped over the lazy dog.
  1035. </attribute>
  1036. </element>
  1037. <element name="Element2">
  1038. <attribute name="Attribute1">
  1039. </attribute>
  1040. <attribute name="Attribute2">
  1041. The quick brown
  1042. fox jumped over
  1043. the lazy dog.
  1044. </attribute>
  1045. </element>
  1046. <!-- comments can go anywhere -->
  1047. <element name="Element2">
  1048. <attribute name="Attribute1"/>
  1049. <attribute name="Attribute2">
  1050. value2
  1051. </attribute>
  1052. </element>
  1053. </xmlfile>
  1054. ]]></screen>
  1055. </example>
  1056. </section>
  1057. <section id="nodes-xmlschema">
  1058. <title>
  1059. xmlschema
  1060. </title>
  1061. <funcsynopsis>
  1062. <funcprototype>
  1063. <funcdef>void <function>xmlschema</function></funcdef>
  1064. <paramdef/>
  1065. </funcprototype>
  1066. </funcsynopsis>
  1067. <para>
  1068. Print an <acronym>XML</acronym> schema that supports function <link linkend='nodes-xmledit'>xmledit</link> on stdout. This function has no argument. The schema produced by this function is guaranteed to support the parse logic implemented by function <link linkend='nodes-xmledit'>xmledit</link>. Scheme element names are defined as constants in <ulink url='node.h.html'>node.h</ulink> so that they can be referenced by applications that create their own <acronym>XML</acronym> edit instructions. The function is declared in <ulink url='node.h.html'>node.h</ulink> and defined in <ulink url='xmlschema.c.html'>xmlschema.c</ulink>.
  1069. </para>
  1070. <para>
  1071. The <varname>text</varname> member in the parse tree root node points to memory allocated by <link linkend="nodes-xmlscan">xmlscan </link> to store the original <acronym>XML</acronym> string. The application must either deallocate that memory before calling this function or store the text address and deallocate that memory after calling this function; otherwise, memory leaks will result.
  1072. </para>
  1073. <example>
  1074. <title>
  1075. XML Edit Schema
  1076. </title>
  1077. <screen><![CDATA[
  1078. <?xml version='1.0' encoding='UTF-8'?>
  1079. <xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' elementFormDefault='qualified'>
  1080. <xs:element name='pib'>
  1081. <xs:complexType>
  1082. <xs:sequence>
  1083. <xs:element maxOccurs='unbounded' ref='object'/>
  1084. </xs:sequence>
  1085. </xs:complexType>
  1086. </xs:element>
  1087. <xs:element name='object'>
  1088. <xs:complexType>
  1089. <xs:attribute name='name' use='required' type='xs:NCName'/>
  1090. <xs:sequence>
  1091. <xs:sequence>
  1092. <xs:element ref='offset'/>
  1093. <xs:element ref='length'/>
  1094. </xs:sequence>
  1095. <xs:choice>
  1096. <xs:element ref='array'/>
  1097. <xs:element ref='dataString'/>
  1098. <xs:element ref='dataByte'/>
  1099. </xs:choice>
  1100. </xs:sequence>
  1101. </xs:complexType>
  1102. </xs:element>
  1103. <xs:element name='length' type='xs:positiveInteger'/>
  1104. <xs:element name='offset' type='xs:hexBinary'/>
  1105. <xs:element name='array'>
  1106. <xs:complexType>
  1107. <xs:choice maxOccurs='unbounded'>
  1108. <xs:element ref='dataByte'/>
  1109. <xs:element ref='dataHex'/>
  1110. </xs:choice>
  1111. </xs:complexType>
  1112. </xs:element>
  1113. <xs:element name='dataString' type='xs:string'/>
  1114. <xs:element name='dataHex' type='xs:hexBinary'/>
  1115. <xs:element name='dataByte' type='xs:unsignedByte'/>
  1116. </xs:schema>
  1117. ]]></screen>
  1118. <para>
  1119. The schema shown above was produced by function <link linkend='nodes-xmlschema'>xmlschema</link>. It is should be used to validate <acronym>XML</acronym> edit instructions before submitting them to program <ulink url='pxe.7.html'>pxe</ulink>.
  1120. </para>
  1121. </example>
  1122. </section>
  1123. <section id="nodes-xmltree">
  1124. <title>
  1125. xmltree
  1126. </title>
  1127. <funcsynopsis>
  1128. <funcprototype>
  1129. <funcdef>void <function>xmltree</function></funcdef>
  1130. <paramdef>struct node *<parameter>node</parameter></paramdef>
  1131. </funcprototype>
  1132. </funcsynopsis>
  1133. <para>
  1134. Print the XML parse tree on stdout. The function is declared in <ulink url='node.h.html'>node.h</ulink> and defined in <ulink url='xmltree.c.html'>xmltree.c</ulink>.
  1135. </para>
  1136. <example id="nodes-example-2">
  1137. <title>
  1138. XML Parse Tree
  1139. </title>
  1140. <para>
  1141. The following is sample output from function <function>xmltree</function>. The XML source is shown in the example for function <link linkend="nodes-example-1">xmlscan </link>. The numbers appearing down the left margin indicate the input line number from the XML source file parsed by function <link linkend="nodes-xmlscan">xmlscan </link>. The character codes indicate the node type and are defined in <ulink url="node.h.html">node.h</ulink>. The <varname>node</varname> structure is defined in <ulink url='node.h.html'>node.h</ulink>.
  1142. </para>
  1143. <screen><![CDATA[
  1144. 001 [?] [xml]
  1145. 001 [ ] [version]
  1146. 001 [=] [1.0]
  1147. 001 [ ] [encoding]
  1148. 001 [=] [UTF-8]
  1149. 002 [<] [xmlfile]
  1150. 002 [ ] [xmlns:xsi]
  1151. 002 [=] [http://www.w3.org/2001/XMLSchema-instance]
  1152. 002 [ ] [xsi:noNamespaceSchemaLocation]
  1153. 002 [=] [myschema.xsd]
  1154. 003 [<] [element]
  1155. 003 [ ] [name]
  1156. 003 [=] [Element1]
  1157. 004 [<] [attribute]
  1158. 004 [ ] [name]
  1159. 004 [=] [Attribute1]
  1160. 005 [>] [1234567890]
  1161. 006 [/] [attribute]
  1162. 007 [<] [attribute]
  1163. 007 [ ] [name]
  1164. 007 [=] [Attribute2]
  1165. 008 [>] [The quick brown fox jumped over the lazy dog.]
  1166. 009 [/] [attribute]
  1167. 010 [/] [element]
  1168. 011 [<] [element]
  1169. 011 [ ] [name]
  1170. 011 [=] [Element2]
  1171. 012 [<] [attribute]
  1172. 012 [ ] [name]
  1173. 012 [=] [Attribute1]
  1174. 013 [/] [attribute]
  1175. 014 [<] [attribute]
  1176. 014 [ ] [name]
  1177. 014 [=] [Attribute2]
  1178. 015 [>] [The quick brown fox jumped over the lazy dog.azy]
  1179. 018 [/] [attribute]
  1180. 019 [/] [element]
  1181. 020 [!] [-- comments can go anywhere --]
  1182. 021 [<] [element]
  1183. 021 [ ] [name]
  1184. 021 [=] [Element2]
  1185. 022 [<] [attribute]
  1186. 022 [ ] [name]
  1187. 022 [=] [Attribute1]
  1188. 023 [<] [attribute]
  1189. 023 [ ] [name]
  1190. 023 [=] [Attribute2]
  1191. 024 [>] [value2]
  1192. 025 [/] [attribute]
  1193. 026 [/] [element]
  1194. 027 [/] [xmlfile]
  1195. ]]></screen>
  1196. </example>
  1197. </section>
  1198. </section>
  1199. <section id="library-scan">
  1200. <title>
  1201. scan/scan.h
  1202. </title>
  1203. <section id="function-scaninput">
  1204. <title>
  1205. scaninput
  1206. </title>
  1207. <funcsynopsis>
  1208. <funcprototype>
  1209. <funcdef>void <function>scaninput</function></funcdef>
  1210. <paramdef>struct scan * <parameter>content</parameter></paramdef>
  1211. <paramdef>const char <parameter>buffer</parameter> []</paramdef>
  1212. <paramdef>signed <parameter>length</parameter></paramdef>
  1213. </funcprototype>
  1214. </funcsynopsis>
  1215. <para>
  1216. Initializes a <constant>SCAN</constant> structure for scanning by pointing the structure a <varname>buffer</varname> of given <varname>length</varname>, resetting intermmediate pointers and clearing the token <varname>class</varname> code.
  1217. </para>
  1218. </section>
  1219. </section>
  1220. </chapter>