appweb.html 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. <h1>APPWEB API</h1>
  2. <a name="Extensions"></a><h2>Extensions</h2>
  3. <table class="apiIndex" title="Extensions">
  4. <tr class="apiDef">
  5. <td class="apiName"><a href="#group___ma_state" class="nameRef">MaState</a></td>
  6. <td class="apiBrief">Current configuration parse state.</td></tr>
  7. </table>
  8. <a name="Functions"></a><h2>Functions</h2>
  9. <table class="apiIndex" title="Functions">
  10. <tr class="apiDef"><td class="apiType">void</td><td><a href="#group___ma_state_1ga0625b7b754d921353acac4505eb9de02" class="nameRef">maAddDirective</a>(<a href="osdep.html#group___osdep_1ga4f52f6802d742ebd12c628e69a2bd162" class="ref">cchar</a> *directive, <a href="#group___ma_state_1ga77e98d350eaa12e72d0caee671b4d0d2" class="ref">MaDirective</a> proc)</td></tr><tr class="apiBrief"><td>&nbsp;</td><td>Define a new appweb configuration file directive.</td></tr>
  11. <tr class="apiDef"><td class="apiType">int</td><td><a href="#group___ma_state_1ga3a076271dc5d0227cf3e4c79dcb3f026" class="nameRef">maConfigureServer</a>(<a href="osdep.html#group___osdep_1ga4f52f6802d742ebd12c628e69a2bd162" class="ref">cchar</a> *configFile, <a href="osdep.html#group___osdep_1ga4f52f6802d742ebd12c628e69a2bd162" class="ref">cchar</a> *home, <a href="osdep.html#group___osdep_1ga4f52f6802d742ebd12c628e69a2bd162" class="ref">cchar</a> *documents, <a href="osdep.html#group___osdep_1ga4f52f6802d742ebd12c628e69a2bd162" class="ref">cchar</a> *ip, int port)</td></tr><tr class="apiBrief"><td>&nbsp;</td><td>Configure a web server.</td></tr>
  12. <tr class="apiDef"><td class="apiType">char*</td><td><a href="#group___ma_state_1ga55e8a5ed07c0c10d79fd20d3c0e1d602" class="nameRef">maGetNextArg</a>(char *s, char **tok)</td></tr><tr class="apiBrief"><td>&nbsp;</td><td>Get the argument in a directive.</td></tr>
  13. <tr class="apiDef"><td class="apiType">int</td><td><a href="#group___ma_state_1ga94cd7d8346894055cff0fc79dcd09a48" class="nameRef">maLoadModule</a>(<a href="osdep.html#group___osdep_1ga4f52f6802d742ebd12c628e69a2bd162" class="ref">cchar</a> *name, <a href="osdep.html#group___osdep_1ga4f52f6802d742ebd12c628e69a2bd162" class="ref">cchar</a> *libname)</td></tr><tr class="apiBrief"><td>&nbsp;</td><td>Load an appweb module.</td></tr>
  14. <tr class="apiDef"><td class="apiType">int</td><td><a href="#group___ma_state_1gaa70fb4c9b9835739719c049af17180ef" class="nameRef">maLoadModules</a>(void)</td></tr><tr class="apiBrief"><td>&nbsp;</td><td>Load default modules.</td></tr>
  15. <tr class="apiDef"><td class="apiType">int</td><td><a href="#group___ma_state_1gae9c5d28320c9ebe7f2a6e810215be37c" class="nameRef">maParseConfig</a>(<a href="osdep.html#group___osdep_1ga4f52f6802d742ebd12c628e69a2bd162" class="ref">cchar</a> *path)</td></tr><tr class="apiBrief"><td>&nbsp;</td><td>Parse an Appweb configuration file.</td></tr>
  16. <tr class="apiDef"><td class="apiType">int</td><td><a href="#group___ma_state_1gaf65d5f6135abce2b2cbf625e02a5d1f4" class="nameRef">maParseFile</a>(<a href="#group___ma_state" class="ref">MaState</a> *state, <a href="osdep.html#group___osdep_1ga4f52f6802d742ebd12c628e69a2bd162" class="ref">cchar</a> *path)</td></tr><tr class="apiBrief"><td>&nbsp;</td><td>Parse a configuration file.</td></tr>
  17. <tr class="apiDef"><td class="apiType"><a href="#group___ma_state" class="ref">MaState*</a></td><td><a href="#group___ma_state_1ga2ff0312d66ba2c173b2ff6882e1f4ce9" class="nameRef">maPopState</a>(<a href="#group___ma_state" class="ref">MaState</a> *state)</td></tr><tr class="apiBrief"><td>&nbsp;</td><td>Pop the state.</td></tr>
  18. <tr class="apiDef"><td class="apiType"><a href="#group___ma_state" class="ref">MaState*</a></td><td><a href="#group___ma_state_1gad960c7ab5089293e33a0cf221f41072d" class="nameRef">maPushState</a>(<a href="#group___ma_state" class="ref">MaState</a> *state)</td></tr><tr class="apiBrief"><td>&nbsp;</td><td>Push the state.</td></tr>
  19. <tr class="apiDef"><td class="apiType">int</td><td><a href="#group___ma_state_1ga88a2bd1d0f26f024e6cb2d693c13e4f7" class="nameRef">maRunSimpleWebServer</a>(<a href="osdep.html#group___osdep_1ga4f52f6802d742ebd12c628e69a2bd162" class="ref">cchar</a> *ip, int port, <a href="osdep.html#group___osdep_1ga4f52f6802d742ebd12c628e69a2bd162" class="ref">cchar</a> *home, <a href="osdep.html#group___osdep_1ga4f52f6802d742ebd12c628e69a2bd162" class="ref">cchar</a> *documents)</td></tr><tr class="apiBrief"><td>&nbsp;</td><td>Create and run a simple web server listening on a single IP address.</td></tr>
  20. <tr class="apiDef"><td class="apiType">int</td><td><a href="#group___ma_state_1ga4994c273e87409b094418dd7bd370ee4" class="nameRef">maRunWebServer</a>(<a href="osdep.html#group___osdep_1ga4f52f6802d742ebd12c628e69a2bd162" class="ref">cchar</a> *configFile)</td></tr><tr class="apiBrief"><td>&nbsp;</td><td>Create and run a web server based on a configuration file.</td></tr>
  21. <tr class="apiDef"><td class="apiType"><a href="osdep.html#group___osdep_1gad5c9d4ba3dc37783a528b0925dc981a0" class="ref">bool</a></td><td><a href="#group___ma_state_1gabb856e86d408307d5e31ad0ff2d2f69a" class="nameRef">maTokenize</a>(<a href="#group___ma_state" class="ref">MaState</a> *state, <a href="osdep.html#group___osdep_1ga4f52f6802d742ebd12c628e69a2bd162" class="ref">cchar</a> *str, <a href="osdep.html#group___osdep_1ga4f52f6802d742ebd12c628e69a2bd162" class="ref">cchar</a> *fmt, ...)</td></tr><tr class="apiBrief"><td>&nbsp;</td><td>Tokenize a string based on route data.</td></tr>
  22. </table>
  23. <a name="Typedefs"></a><h2>Typedefs</h2>
  24. <table class="apiIndex" title="typedefs">
  25. <tr class="apiDef"><td class="apiName"><a href="#group___ma_state_1ga77e98d350eaa12e72d0caee671b4d0d2" class="nameRef">MaDirective</a></td><td class="apiBrief">Appweb configuration file directive parsing callback function.</td></tr>
  26. </table>
  27. <a name="Defines"></a><h2>Defines</h2>
  28. <table class="apiIndex" title="Defines">
  29. <tr class="apiDef">
  30. <td>#define</td><td><a href="#appweb_8h_1a3b315098fc2d1fc56d9d2832902dacff" class="nameRef">MA_PARSE_NON_SERVER</a>&nbsp;&nbsp;&nbsp;0x1</td>
  31. </tr>
  32. <tr class="apiBrief"><td>&nbsp;</td><td>Command file being parsed by a utility program.</td></tr>
  33. <tr class="apiDef">
  34. <td>#define</td><td><a href="#appweb_8h_1aba0a3eb51d76651562bc5c0bb2c0f424" class="nameRef">MA_UNLOAD_TIMEOUT</a>&nbsp;&nbsp;&nbsp;&quot;5mins&quot;</td>
  35. </tr>
  36. <tr class="apiBrief"><td>&nbsp;</td><td>Default module inactivity timeout.</td></tr>
  37. </table>
  38. <h2>MaState</h2>
  39. <a name="group___ma_state"></a>
  40. <div class="api">
  41. <div class="prototype">MaState</div>
  42. <div class="apiDetail">
  43. <p>Current configuration parse state.</p>
  44. <dl><dt><b>API</b> Stability:</dt><dd>Evolving.</dd></dl>
  45. <dl><dt>See Also:</dt><dd>
  46. <a href="#group___ma_state_1ga77e98d350eaa12e72d0caee671b4d0d2" class="ref">MaDirective</a>, <a href="#group___ma_state_1ga0625b7b754d921353acac4505eb9de02" class="ref">maAddDirective</a>, <a href="#group___ma_state_1ga2ff0312d66ba2c173b2ff6882e1f4ce9" class="ref">maPopState</a>, <a href="#group___ma_state_1gad960c7ab5089293e33a0cf221f41072d" class="ref">maPushState</a>, <a href="#group___ma_state_1gabb856e86d408307d5e31ad0ff2d2f69a" class="ref">maTokenize</a></dd></dl>
  47. <dl><dt><b>API</b> Stability:</dt><dd>Evolving.</dd></dl>
  48. <dl><dt>Fields:</dt><dd>
  49. <table class="parameters" title="Parameters">
  50. <tr><td class="param">HttpAuth *</td><td><td>auth</td><td>
  51. Quick alias for route-&gt;auth.
  52. </td>
  53. <tr><td class="param">char *</td><td><td>configDir</td><td>
  54. Directory containing config file.
  55. </td>
  56. <tr><td class="param">struct MaState *</td><td><td>current</td><td>
  57. Current state.
  58. </td>
  59. <tr><td class="param">char *</td><td><td>data</td><td>
  60. Config data (managed).
  61. </td>
  62. <tr><td class="param">int</td><td><td>enabled</td><td>
  63. True if the current block is enabled.
  64. </td>
  65. <tr><td class="param">char *</td><td><td>endpoints</td><td>
  66. Virtual host endpoints.
  67. </td>
  68. <tr><td class="param">MprFile *</td><td><td>file</td><td>
  69. Config file handle.
  70. </td>
  71. <tr><td class="param">char *</td><td><td>filename</td><td>
  72. Config file name.
  73. </td>
  74. <tr><td class="param">int</td><td><td>flags</td><td>
  75. Parsing flags.
  76. </td>
  77. <tr><td class="param">HttpHost *</td><td><td>host</td><td>
  78. Current host.
  79. </td>
  80. <tr><td class="param">char *</td><td><td>key</td><td>
  81. Current directive being parsed.
  82. </td>
  83. <tr><td class="param">int</td><td><td>lineNumber</td><td>
  84. Current line number.
  85. </td>
  86. <tr><td class="param">struct MaState *</td><td><td>prev</td><td>
  87. Previous (inherited) state.
  88. </td>
  89. <tr><td class="param">HttpRoute *</td><td><td>route</td><td>
  90. Current route.
  91. </td>
  92. <tr><td class="param">struct MaState *</td><td><td>top</td><td>
  93. Top level state.
  94. </td>
  95. </table></dd></dl>
  96. </div>
  97. </div>
  98. <a name="group___ma_state_1ga0625b7b754d921353acac4505eb9de02"></a>
  99. <div class="api">
  100. <div class="prototype">
  101. void
  102. maAddDirective
  103. (<a href="osdep.html#group___osdep_1ga4f52f6802d742ebd12c628e69a2bd162" class="ref">cchar</a> *directive, <a href="#group___ma_state_1ga77e98d350eaa12e72d0caee671b4d0d2" class="ref">MaDirective</a> proc)
  104. </div>
  105. <div class="apiDetail">
  106. <p>Define a new appweb configuration file directive.</p>
  107. <dl><dt><b>Description</b>:</dt><dd>The appweb configuration file parse is extensible. New directives can be registered by this call. When encountered in the config file, the given callback proc will be invoked to parse.</dd></dl>
  108. <dl><dt>Parameters:</dt><dd>
  109. <table class="parameters" title="Parameters">
  110. <tr><td class="param">directive</td><td>Directive name.</td>
  111. <tr><td class="param">proc</td><td>Directive callback procedure of the type <a class="ref" href="#group___ma_state_1ga77e98d350eaa12e72d0caee671b4d0d2">MaDirective</a></td>
  112. </table></dd></dl>
  113. <dl><dt><b>API</b> Stability:</dt><dd>Evolving.</dd></dl>
  114. <dl><dt>See Also:</dt><dd>
  115. <a href="#group___ma_state_1ga77e98d350eaa12e72d0caee671b4d0d2" class="ref">MaDirective</a>, <a href="#group___ma_state" class="ref">MaState</a>, <a href="#group___ma_state_1ga2ff0312d66ba2c173b2ff6882e1f4ce9" class="ref">maPopState</a>, <a href="#group___ma_state_1gad960c7ab5089293e33a0cf221f41072d" class="ref">maPushState</a>, <a href="#group___ma_state_1gabb856e86d408307d5e31ad0ff2d2f69a" class="ref">maTokenize</a></dd></dl>
  116. </div>
  117. </div>
  118. <a name="group___ma_state_1ga3a076271dc5d0227cf3e4c79dcb3f026"></a>
  119. <div class="api">
  120. <div class="prototype">
  121. int
  122. maConfigureServer
  123. (<a href="osdep.html#group___osdep_1ga4f52f6802d742ebd12c628e69a2bd162" class="ref">cchar</a> *configFile, <a href="osdep.html#group___osdep_1ga4f52f6802d742ebd12c628e69a2bd162" class="ref">cchar</a> *home, <a href="osdep.html#group___osdep_1ga4f52f6802d742ebd12c628e69a2bd162" class="ref">cchar</a> *documents, <a href="osdep.html#group___osdep_1ga4f52f6802d742ebd12c628e69a2bd162" class="ref">cchar</a> *ip, int port)
  124. </div>
  125. <div class="apiDetail">
  126. <p>Configure a web server.</p>
  127. <dl><dt><b>Description</b>:</dt><dd>This will configure a web server based on either a configuration file or using the supplied IP address and port.</dd></dl>
  128. <dl><dt>Parameters:</dt><dd>
  129. <table class="parameters" title="Parameters">
  130. <tr><td class="param">configFile</td><td>File name of the Appweb configuration file (appweb.conf) that defines the web server configuration.</td>
  131. <tr><td class="param">home</td><td>Admin directory for the server. This overrides the value in the config file.</td>
  132. <tr><td class="param">documents</td><td>Default directory for web documents to serve. This overrides the value in the config file.</td>
  133. <tr><td class="param">ip</td><td>IP address to listen on. This overrides the value specified in the config file.</td>
  134. <tr><td class="param">port</td><td>Port address to listen on. This overrides the value specified in the config file.</td>
  135. </table></dd></dl>
  136. <dl><dt>Returns:</dt><dd>Zero if successful, otherwise a negative Mpr error code. See the Appweb log for diagnostics.</dd></dl>
  137. <dl><dt><b>API</b> Stability:</dt><dd>Evolving.</dd></dl>
  138. <dl><dt>See Also:</dt><dd>
  139. <a href="#group___ma_state_1ga77e98d350eaa12e72d0caee671b4d0d2" class="ref">MaDirective</a>, <a href="#group___ma_state" class="ref">MaState</a>, <a href="#group___ma_state_1ga0625b7b754d921353acac4505eb9de02" class="ref">maAddDirective</a>, <a href="#group___ma_state_1ga2ff0312d66ba2c173b2ff6882e1f4ce9" class="ref">maPopState</a>, <a href="#group___ma_state_1gad960c7ab5089293e33a0cf221f41072d" class="ref">maPushState</a>, <a href="#group___ma_state_1gabb856e86d408307d5e31ad0ff2d2f69a" class="ref">maTokenize</a></dd></dl>
  140. </div>
  141. </div>
  142. <a name="group___ma_state_1ga55e8a5ed07c0c10d79fd20d3c0e1d602"></a>
  143. <div class="api">
  144. <div class="prototype">
  145. char *
  146. maGetNextArg
  147. (char *s, char **tok)
  148. </div>
  149. <div class="apiDetail">
  150. <p>Get the argument in a directive.</p>
  151. <dl><dt><b>Description</b>:</dt><dd>Break into arguments. Args may be quoted. An outer quoting of the entire arg is removed.</dd></dl>
  152. <dl><dt>Parameters:</dt><dd>
  153. <table class="parameters" title="Parameters">
  154. <tr><td class="param">s</td><td>String to examine.</td>
  155. <tr><td class="param">tok</td><td>Next token reference.</td>
  156. </table></dd></dl>
  157. <dl><dt>Returns:</dt><dd>Reference to the next token. (Not allocate.</dd></dl>
  158. <dl><dt><b>API</b> Stability:</dt><dd>Evolving.</dd></dl>
  159. <dl><dt>See Also:</dt><dd>
  160. <a href="#group___ma_state_1ga77e98d350eaa12e72d0caee671b4d0d2" class="ref">MaDirective</a>, <a href="#group___ma_state" class="ref">MaState</a>, <a href="#group___ma_state_1ga0625b7b754d921353acac4505eb9de02" class="ref">maAddDirective</a>, <a href="#group___ma_state_1ga2ff0312d66ba2c173b2ff6882e1f4ce9" class="ref">maPopState</a>, <a href="#group___ma_state_1gad960c7ab5089293e33a0cf221f41072d" class="ref">maPushState</a>, <a href="#group___ma_state_1gabb856e86d408307d5e31ad0ff2d2f69a" class="ref">maTokenize</a></dd></dl>
  161. </div>
  162. </div>
  163. <a name="group___ma_state_1ga94cd7d8346894055cff0fc79dcd09a48"></a>
  164. <div class="api">
  165. <div class="prototype">
  166. int
  167. maLoadModule
  168. (<a href="osdep.html#group___osdep_1ga4f52f6802d742ebd12c628e69a2bd162" class="ref">cchar</a> *name, <a href="osdep.html#group___osdep_1ga4f52f6802d742ebd12c628e69a2bd162" class="ref">cchar</a> *libname)
  169. </div>
  170. <div class="apiDetail">
  171. <p>Load an appweb module.</p>
  172. <dl><dt><b>Description</b>:</dt><dd>Load an appweb module. If the module is already loaded, this call will return successfully without reloading. Modules can be dynamically loaded or may also be pre-loaded using static linking.</dd></dl>
  173. <dl><dt>Parameters:</dt><dd>
  174. <table class="parameters" title="Parameters">
  175. <tr><td class="param">name</td><td>User name. Must be defined in the system password file.</td>
  176. <tr><td class="param">libname</td><td>Library path name.</td>
  177. </table></dd></dl>
  178. <dl><dt>Returns:</dt><dd>Zero if successful, otherwise a negative Mpr error code. See the Appweb log for diagnostics.</dd></dl>
  179. <dl><dt><b>API</b> Stability:</dt><dd>Evolving.</dd></dl>
  180. <dl><dt>See Also:</dt><dd>
  181. <a href="#group___ma_state_1ga77e98d350eaa12e72d0caee671b4d0d2" class="ref">MaDirective</a>, <a href="#group___ma_state" class="ref">MaState</a>, <a href="#group___ma_state_1ga0625b7b754d921353acac4505eb9de02" class="ref">maAddDirective</a>, <a href="#group___ma_state_1ga2ff0312d66ba2c173b2ff6882e1f4ce9" class="ref">maPopState</a>, <a href="#group___ma_state_1gad960c7ab5089293e33a0cf221f41072d" class="ref">maPushState</a>, <a href="#group___ma_state_1gabb856e86d408307d5e31ad0ff2d2f69a" class="ref">maTokenize</a></dd></dl>
  182. </div>
  183. </div>
  184. <a name="group___ma_state_1gaa70fb4c9b9835739719c049af17180ef"></a>
  185. <div class="api">
  186. <div class="prototype">
  187. int
  188. maLoadModules
  189. (void )
  190. </div>
  191. <div class="apiDetail">
  192. <p>Load default modules.</p>
  193. <dl><dt>Returns:</dt><dd>Zero if successful, otherwise a negative Mpr error code. See the Appweb log for diagnostics.</dd></dl>
  194. <dl><dt><b>API</b> Stability:</dt><dd>Prototype.</dd></dl>
  195. <dl><dt>See Also:</dt><dd>
  196. <a href="#group___ma_state_1ga77e98d350eaa12e72d0caee671b4d0d2" class="ref">MaDirective</a>, <a href="#group___ma_state" class="ref">MaState</a>, <a href="#group___ma_state_1ga0625b7b754d921353acac4505eb9de02" class="ref">maAddDirective</a>, <a href="#group___ma_state_1ga2ff0312d66ba2c173b2ff6882e1f4ce9" class="ref">maPopState</a>, <a href="#group___ma_state_1gad960c7ab5089293e33a0cf221f41072d" class="ref">maPushState</a>, <a href="#group___ma_state_1gabb856e86d408307d5e31ad0ff2d2f69a" class="ref">maTokenize</a></dd></dl>
  197. </div>
  198. </div>
  199. <a name="group___ma_state_1gae9c5d28320c9ebe7f2a6e810215be37c"></a>
  200. <div class="api">
  201. <div class="prototype">
  202. int
  203. maParseConfig
  204. (<a href="osdep.html#group___osdep_1ga4f52f6802d742ebd12c628e69a2bd162" class="ref">cchar</a> *path)
  205. </div>
  206. <div class="apiDetail">
  207. <p>Parse an Appweb configuration file.</p>
  208. <dl><dt><b>Description</b>:</dt><dd>Parse the configuration file and configure the server. This creates a default host and route and then configures the server based on config file directives.</dd></dl>
  209. <dl><dt>Parameters:</dt><dd>
  210. <table class="parameters" title="Parameters">
  211. <tr><td class="param">path</td><td>Configuration file pathname.</td>
  212. </table></dd></dl>
  213. <dl><dt>Returns:</dt><dd>Zero if successful, otherwise a negative Mpr error code. See the Appweb log for diagnostics.</dd></dl>
  214. <dl><dt><b>API</b> Stability:</dt><dd>Evolving.</dd></dl>
  215. <dl><dt>See Also:</dt><dd>
  216. <a href="#group___ma_state_1ga77e98d350eaa12e72d0caee671b4d0d2" class="ref">MaDirective</a>, <a href="#group___ma_state" class="ref">MaState</a>, <a href="#group___ma_state_1ga0625b7b754d921353acac4505eb9de02" class="ref">maAddDirective</a>, <a href="#group___ma_state_1ga2ff0312d66ba2c173b2ff6882e1f4ce9" class="ref">maPopState</a>, <a href="#group___ma_state_1gad960c7ab5089293e33a0cf221f41072d" class="ref">maPushState</a>, <a href="#group___ma_state_1gabb856e86d408307d5e31ad0ff2d2f69a" class="ref">maTokenize</a></dd></dl>
  217. </div>
  218. </div>
  219. <a name="group___ma_state_1gaf65d5f6135abce2b2cbf625e02a5d1f4"></a>
  220. <div class="api">
  221. <div class="prototype">
  222. int
  223. maParseFile
  224. (<a href="#group___ma_state" class="ref">MaState</a> *state, <a href="osdep.html#group___osdep_1ga4f52f6802d742ebd12c628e69a2bd162" class="ref">cchar</a> *path)
  225. </div>
  226. <div class="apiDetail">
  227. <p>Parse a configuration file.</p>
  228. <dl><dt>Parameters:</dt><dd>
  229. <table class="parameters" title="Parameters">
  230. <tr><td class="param">state</td><td>Current state level object.</td>
  231. <tr><td class="param">path</td><td>Filename to parse.</td>
  232. </table></dd></dl>
  233. <dl><dt>Returns:</dt><dd>Zero if successful, otherwise a negative Mpr error code. See the Appweb log for diagnostics.</dd></dl>
  234. <dl><dt><b>API</b> Stability:</dt><dd>Prototype.</dd></dl>
  235. <dl><dt>See Also:</dt><dd>
  236. <a href="#group___ma_state_1ga77e98d350eaa12e72d0caee671b4d0d2" class="ref">MaDirective</a>, <a href="#group___ma_state" class="ref">MaState</a>, <a href="#group___ma_state_1ga0625b7b754d921353acac4505eb9de02" class="ref">maAddDirective</a>, <a href="#group___ma_state_1ga2ff0312d66ba2c173b2ff6882e1f4ce9" class="ref">maPopState</a>, <a href="#group___ma_state_1gad960c7ab5089293e33a0cf221f41072d" class="ref">maPushState</a>, <a href="#group___ma_state_1gabb856e86d408307d5e31ad0ff2d2f69a" class="ref">maTokenize</a></dd></dl>
  237. </div>
  238. </div>
  239. <a name="group___ma_state_1ga2ff0312d66ba2c173b2ff6882e1f4ce9"></a>
  240. <div class="api">
  241. <div class="prototype">
  242. <a href="#group___ma_state" class="ref">MaState</a> *
  243. maPopState
  244. (<a href="#group___ma_state" class="ref">MaState</a> *state)
  245. </div>
  246. <div class="apiDetail">
  247. <p>Pop the state.</p>
  248. <dl><dt><b>Description</b>:</dt><dd>This is used when parsing config files to handle nested include files and block level directives.</dd></dl>
  249. <dl><dt>Parameters:</dt><dd>
  250. <table class="parameters" title="Parameters">
  251. <tr><td class="param">state</td><td>Current state.</td>
  252. </table></dd></dl>
  253. <dl><dt>Returns:</dt><dd>The next lower level state object.</dd></dl>
  254. <dl><dt><b>API</b> Stability:</dt><dd>Evolving.</dd></dl>
  255. <dl><dt>See Also:</dt><dd>
  256. <a href="#group___ma_state_1ga77e98d350eaa12e72d0caee671b4d0d2" class="ref">MaDirective</a>, <a href="#group___ma_state" class="ref">MaState</a>, <a href="#group___ma_state_1ga0625b7b754d921353acac4505eb9de02" class="ref">maAddDirective</a>, <a href="#group___ma_state_1gad960c7ab5089293e33a0cf221f41072d" class="ref">maPushState</a>, <a href="#group___ma_state_1gabb856e86d408307d5e31ad0ff2d2f69a" class="ref">maTokenize</a></dd></dl>
  257. </div>
  258. </div>
  259. <a name="group___ma_state_1gad960c7ab5089293e33a0cf221f41072d"></a>
  260. <div class="api">
  261. <div class="prototype">
  262. <a href="#group___ma_state" class="ref">MaState</a> *
  263. maPushState
  264. (<a href="#group___ma_state" class="ref">MaState</a> *state)
  265. </div>
  266. <div class="apiDetail">
  267. <p>Push the state.</p>
  268. <dl><dt><b>Description</b>:</dt><dd>This is used when parsing config files to handle nested include files and block level directives.</dd></dl>
  269. <dl><dt>Parameters:</dt><dd>
  270. <table class="parameters" title="Parameters">
  271. <tr><td class="param">state</td><td>Current state.</td>
  272. </table></dd></dl>
  273. <dl><dt>Returns:</dt><dd>The state passed as a parameter which becomes the new top level state.</dd></dl>
  274. <dl><dt><b>API</b> Stability:</dt><dd>Evolving.</dd></dl>
  275. <dl><dt>See Also:</dt><dd>
  276. <a href="#group___ma_state_1ga77e98d350eaa12e72d0caee671b4d0d2" class="ref">MaDirective</a>, <a href="#group___ma_state" class="ref">MaState</a>, <a href="#group___ma_state_1ga0625b7b754d921353acac4505eb9de02" class="ref">maAddDirective</a>, <a href="#group___ma_state_1ga2ff0312d66ba2c173b2ff6882e1f4ce9" class="ref">maPopState</a>, <a href="#group___ma_state_1gabb856e86d408307d5e31ad0ff2d2f69a" class="ref">maTokenize</a></dd></dl>
  277. </div>
  278. </div>
  279. <a name="group___ma_state_1ga88a2bd1d0f26f024e6cb2d693c13e4f7"></a>
  280. <div class="api">
  281. <div class="prototype">
  282. int
  283. maRunSimpleWebServer
  284. (<a href="osdep.html#group___osdep_1ga4f52f6802d742ebd12c628e69a2bd162" class="ref">cchar</a> *ip, int port, <a href="osdep.html#group___osdep_1ga4f52f6802d742ebd12c628e69a2bd162" class="ref">cchar</a> *home, <a href="osdep.html#group___osdep_1ga4f52f6802d742ebd12c628e69a2bd162" class="ref">cchar</a> *documents)
  285. </div>
  286. <div class="apiDetail">
  287. <p>Create and run a simple web server listening on a single IP address.</p>
  288. <dl><dt><b>Description</b>:</dt><dd>Create a simple web server without using a configuration file. The server is created to listen on the specified IP address and port. This routine provides a one-line embedding of Appweb. If you want to use a config file, try the <a class="ref" href="#group___ma_state_1ga4994c273e87409b094418dd7bd370ee4">maRunWebServer</a> instead.</dd></dl>
  289. <dl><dt>Parameters:</dt><dd>
  290. <table class="parameters" title="Parameters">
  291. <tr><td class="param">ip</td><td>IP address on which to listen. Set to &quot;0.0.0.0&quot; to listen on all interfaces.</td>
  292. <tr><td class="param">port</td><td>Port number to listen to.</td>
  293. <tr><td class="param">home</td><td>Home directory for the web server.</td>
  294. <tr><td class="param">documents</td><td>Directory containing the documents to serve.</td>
  295. </table></dd></dl>
  296. <dl><dt>Returns:</dt><dd>Zero if successful, otherwise a negative Mpr error code. See the Appweb log for diagnostics.</dd></dl>
  297. <dl><dt><b>API</b> Stability:</dt><dd>Evolving.</dd></dl>
  298. <dl><dt>See Also:</dt><dd>
  299. <a href="#group___ma_state_1ga77e98d350eaa12e72d0caee671b4d0d2" class="ref">MaDirective</a>, <a href="#group___ma_state" class="ref">MaState</a>, <a href="#group___ma_state_1ga0625b7b754d921353acac4505eb9de02" class="ref">maAddDirective</a>, <a href="#group___ma_state_1ga2ff0312d66ba2c173b2ff6882e1f4ce9" class="ref">maPopState</a>, <a href="#group___ma_state_1gad960c7ab5089293e33a0cf221f41072d" class="ref">maPushState</a>, <a href="#group___ma_state_1gabb856e86d408307d5e31ad0ff2d2f69a" class="ref">maTokenize</a></dd></dl>
  300. </div>
  301. </div>
  302. <a name="group___ma_state_1ga4994c273e87409b094418dd7bd370ee4"></a>
  303. <div class="api">
  304. <div class="prototype">
  305. int
  306. maRunWebServer
  307. (<a href="osdep.html#group___osdep_1ga4f52f6802d742ebd12c628e69a2bd162" class="ref">cchar</a> *configFile)
  308. </div>
  309. <div class="apiDetail">
  310. <p>Create and run a web server based on a configuration file.</p>
  311. <dl><dt><b>Description</b>:</dt><dd>Create a web server configuration based on the supplied config file. This routine provides a one-line embedding of Appweb. If you don&apos;t want to use a config file, try the <a class="ref" href="#group___ma_state_1ga88a2bd1d0f26f024e6cb2d693c13e4f7">maRunSimpleWebServer</a> instead.</dd></dl>
  312. <dl><dt>Parameters:</dt><dd>
  313. <table class="parameters" title="Parameters">
  314. <tr><td class="param">configFile</td><td>File name of the Appweb configuration file (appweb.conf) that defines the web server configuration.</td>
  315. </table></dd></dl>
  316. <dl><dt>Returns:</dt><dd>Zero if successful, otherwise a negative Mpr error code. See the Appweb log for diagnostics.</dd></dl>
  317. <dl><dt><b>API</b> Stability:</dt><dd>Evolving.</dd></dl>
  318. <dl><dt>See Also:</dt><dd>
  319. <a href="#group___ma_state_1ga77e98d350eaa12e72d0caee671b4d0d2" class="ref">MaDirective</a>, <a href="#group___ma_state" class="ref">MaState</a>, <a href="#group___ma_state_1ga0625b7b754d921353acac4505eb9de02" class="ref">maAddDirective</a>, <a href="#group___ma_state_1ga2ff0312d66ba2c173b2ff6882e1f4ce9" class="ref">maPopState</a>, <a href="#group___ma_state_1gad960c7ab5089293e33a0cf221f41072d" class="ref">maPushState</a>, <a href="#group___ma_state_1gabb856e86d408307d5e31ad0ff2d2f69a" class="ref">maTokenize</a></dd></dl>
  320. </div>
  321. </div>
  322. <a name="group___ma_state_1gabb856e86d408307d5e31ad0ff2d2f69a"></a>
  323. <div class="api">
  324. <div class="prototype">
  325. <a href="osdep.html#group___osdep_1gad5c9d4ba3dc37783a528b0925dc981a0" class="ref">bool</a>
  326. maTokenize
  327. (<a href="#group___ma_state" class="ref">MaState</a> *state, <a href="osdep.html#group___osdep_1ga4f52f6802d742ebd12c628e69a2bd162" class="ref">cchar</a> *str, <a href="osdep.html#group___osdep_1ga4f52f6802d742ebd12c628e69a2bd162" class="ref">cchar</a> *fmt, ...)
  328. </div>
  329. <div class="apiDetail">
  330. <p>Tokenize a string based on route data.</p>
  331. <dl><dt><b>Description</b>:</dt><dd>This is a utility routine to parse a string into tokens given a format specifier. Mandatory tokens can be specified with &quot;%&quot; format specifier. Optional tokens are specified with &quot;?&quot; format. Values wrapped in quotes will have the outermost quotes trimmed.</dd></dl>
  332. <dl><dt>Parameters:</dt><dd>
  333. <table class="parameters" title="Parameters">
  334. <tr><td class="param">state</td><td>Current config parsing state.</td>
  335. <tr><td class="param">str</td><td>String to expand.</td>
  336. <tr><td class="param">fmt</td><td>Format string specifier Supported tokens: <ul><li>B - Boolean. Parses: on/off, true/false, yes/no. </li><li>N - Number. Parses numbers in base 10. </li><li>S - String. Removes quotes. </li><li>P - Path string. Removes quotes and expands ${PathVars}. Resolved relative to host-&gt;dir (ServerRoot). </li><li>W - Parse words into a list </li><li>%! - Optional negate. Set value to HTTP_ROUTE_NOT present, otherwise zero. </li></ul></td>
  337. </table></dd></dl>
  338. <dl><dt>Returns:</dt><dd>True if the string can be successfully parsed.</dd></dl>
  339. <dl><dt><b>API</b> Stability:</dt><dd>Evolving.</dd></dl>
  340. <dl><dt>See Also:</dt><dd>
  341. <a href="#group___ma_state_1ga77e98d350eaa12e72d0caee671b4d0d2" class="ref">MaDirective</a>, <a href="#group___ma_state" class="ref">MaState</a>, <a href="#group___ma_state_1ga0625b7b754d921353acac4505eb9de02" class="ref">maAddDirective</a>, <a href="#group___ma_state_1ga2ff0312d66ba2c173b2ff6882e1f4ce9" class="ref">maPopState</a>, <a href="#group___ma_state_1gad960c7ab5089293e33a0cf221f41072d" class="ref">maPushState</a></dd></dl>
  342. </div>
  343. </div>
  344. <h2>Functions</h2>
  345. <h2>Typedefs</h2>
  346. <a name="group___ma_state_1ga77e98d350eaa12e72d0caee671b4d0d2"></a>
  347. <div class="api">
  348. <div class="prototype">
  349. typedef int() MaDirective(MaState *state, cchar *key, cchar *value).
  350. </div>
  351. <div class="apiDetail">
  352. <p>Appweb configuration file directive parsing callback function.</p>
  353. <dl><dt><b>Description</b>:</dt><dd>Directive callbacks are invoked to parse a directive. Directive callbacks are registered using <a class="ref" href="#group___ma_state_1ga0625b7b754d921353acac4505eb9de02">maAddDirective</a></dd></dl>
  354. <dl><dt>Parameters:</dt><dd>
  355. <table class="parameters" title="Parameters">
  356. <tr><td class="param">state</td><td>Current config parse state.</td>
  357. <tr><td class="param">key</td><td>Directive key name.</td>
  358. <tr><td class="param">value</td><td>Directive key value.</td>
  359. </table></dd></dl>
  360. <dl><dt>Returns:</dt><dd>Zero if successful, otherwise a negative Mpr error code. See the Appweb log for diagnostics.</dd></dl>
  361. <dl><dt><b>API</b> Stability:</dt><dd>Evolving.</dd></dl>
  362. <dl><dt>See Also:</dt><dd>
  363. <a href="#group___ma_state" class="ref">MaState</a>, <a href="#group___ma_state_1ga0625b7b754d921353acac4505eb9de02" class="ref">maAddDirective</a>, <a href="#group___ma_state_1ga2ff0312d66ba2c173b2ff6882e1f4ce9" class="ref">maPopState</a>, <a href="#group___ma_state_1gad960c7ab5089293e33a0cf221f41072d" class="ref">maPushState</a>, <a href="#group___ma_state_1gabb856e86d408307d5e31ad0ff2d2f69a" class="ref">maTokenize</a></dd></dl>
  364. </div>
  365. </div>