/lib/libmicrohttpd/src/include/microhttpd.h

https://bitbucket.org/bgiorgini/xbmc · C Header · 1312 lines · 347 code · 127 blank · 838 comment · 0 complexity · 79dc256b775b059b7034b64e4a12724a MD5 · raw file

  1. /*
  2. This file is part of libmicrohttpd
  3. (C) 2006, 2007, 2008, 2009 Christian Grothoff (and other contributing authors)
  4. This library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. This library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with this library; if not, write to the Free Software
  14. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  15. */
  16. /**
  17. * @file microhttpd.h
  18. * @brief public interface to libmicrohttpd
  19. * @author Christian Grothoff
  20. * @author Chris GauthierDickey
  21. *
  22. * All symbols defined in this header start with MHD. MHD is a small
  23. * HTTP daemon library. As such, it does not have any API for logging
  24. * errors (you can only enable or disable logging to stderr). Also,
  25. * it may not support all of the HTTP features directly, where
  26. * applicable, portions of HTTP may have to be handled by clients of
  27. * the library.<p>
  28. *
  29. * The library is supposed to handle everything that it must handle
  30. * (because the API would not allow clients to do this), such as basic
  31. * connection management; however, detailed interpretations of headers
  32. * -- such as range requests -- and HTTP methods are left to clients.
  33. * The library does understand HEAD and will only send the headers of
  34. * the response and not the body, even if the client supplied a body.
  35. * The library also understands headers that control connection
  36. * management (specifically, "Connection: close" and "Expect: 100
  37. * continue" are understood and handled automatically).<p>
  38. *
  39. * MHD understands POST data and is able to decode certain formats
  40. * (at the moment only "application/x-www-form-urlencoded") if the
  41. * entire data fits into the allowed amount of memory for the
  42. * connection. Unsupported encodings and large POST submissions are
  43. * provided as a stream to the main application (and thus can be
  44. * processed, just not conveniently by MHD).<p>
  45. *
  46. * The header file defines various constants used by the HTTP protocol.
  47. * This does not mean that MHD actually interprets all of these
  48. * values. The provided constants are exported as a convenience
  49. * for users of the library. MHD does not verify that transmitted
  50. * HTTP headers are part of the standard specification; users of the
  51. * library are free to define their own extensions of the HTTP
  52. * standard and use those with MHD.<p>
  53. *
  54. * All functions are guaranteed to be completely reentrant and
  55. * thread-safe (with the exception of 'MHD_set_connection_value',
  56. * which must only be used in a particular context).<p>
  57. *
  58. * NEW: Before including "microhttpd.h" you should add the necessary
  59. * includes to define the "uint64_t", "size_t", "fd_set", "socklen_t"
  60. * and "struct sockaddr" data types (which headers are needed may
  61. * depend on your platform; for possible suggestions consult
  62. * "platform.h" in the MHD distribution).
  63. *
  64. */
  65. #ifndef MHD_MICROHTTPD_H
  66. #define MHD_MICROHTTPD_H
  67. #ifdef __cplusplus
  68. extern "C"
  69. {
  70. #if 0 /* keep Emacsens' auto-indent happy */
  71. }
  72. #endif
  73. #endif
  74. /**
  75. * Current version of the library.
  76. */
  77. #define MHD_VERSION 0x00040500
  78. /**
  79. * MHD-internal return code for "YES".
  80. */
  81. #define MHD_YES 1
  82. /**
  83. * MHD-internal return code for "NO".
  84. */
  85. #define MHD_NO 0
  86. /**
  87. * Constant used to indicate unknown size (use when
  88. * creating a response).
  89. */
  90. #define MHD_SIZE_UNKNOWN ((uint64_t) -1LL)
  91. /**
  92. * HTTP response codes.
  93. */
  94. #define MHD_HTTP_CONTINUE 100
  95. #define MHD_HTTP_SWITCHING_PROTOCOLS 101
  96. #define MHD_HTTP_PROCESSING 102
  97. #define MHD_HTTP_OK 200
  98. #define MHD_HTTP_CREATED 201
  99. #define MHD_HTTP_ACCEPTED 202
  100. #define MHD_HTTP_NON_AUTHORITATIVE_INFORMATION 203
  101. #define MHD_HTTP_NO_CONTENT 204
  102. #define MHD_HTTP_RESET_CONTENT 205
  103. #define MHD_HTTP_PARTIAL_CONTENT 206
  104. #define MHD_HTTP_MULTI_STATUS 207
  105. #define MHD_HTTP_MULTIPLE_CHOICES 300
  106. #define MHD_HTTP_MOVED_PERMANENTLY 301
  107. #define MHD_HTTP_FOUND 302
  108. #define MHD_HTTP_SEE_OTHER 303
  109. #define MHD_HTTP_NOT_MODIFIED 304
  110. #define MHD_HTTP_USE_PROXY 305
  111. #define MHD_HTTP_SWITCH_PROXY 306
  112. #define MHD_HTTP_TEMPORARY_REDIRECT 307
  113. #define MHD_HTTP_BAD_REQUEST 400
  114. #define MHD_HTTP_UNAUTHORIZED 401
  115. #define MHD_HTTP_PAYMENT_REQUIRED 402
  116. #define MHD_HTTP_FORBIDDEN 403
  117. #define MHD_HTTP_NOT_FOUND 404
  118. #define MHD_HTTP_METHOD_NOT_ALLOWED 405
  119. #define MHD_HTTP_METHOD_NOT_ACCEPTABLE 406
  120. #define MHD_HTTP_PROXY_AUTHENTICATION_REQUIRED 407
  121. #define MHD_HTTP_REQUEST_TIMEOUT 408
  122. #define MHD_HTTP_CONFLICT 409
  123. #define MHD_HTTP_GONE 410
  124. #define MHD_HTTP_LENGTH_REQUIRED 411
  125. #define MHD_HTTP_PRECONDITION_FAILED 412
  126. #define MHD_HTTP_REQUEST_ENTITY_TOO_LARGE 413
  127. #define MHD_HTTP_REQUEST_URI_TOO_LONG 414
  128. #define MHD_HTTP_UNSUPPORTED_MEDIA_TYPE 415
  129. #define MHD_HTTP_REQUESTED_RANGE_NOT_SATISFIABLE 416
  130. #define MHD_HTTP_EXPECTATION_FAILED 417
  131. #define MHD_HTTP_UNPROCESSABLE_ENTITY 422
  132. #define MHD_HTTP_LOCKED 423
  133. #define MHD_HTTP_FAILED_DEPENDENCY 424
  134. #define MHD_HTTP_UNORDERED_COLLECTION 425
  135. #define MHD_HTTP_UPGRADE_REQUIRED 426
  136. #define MHD_HTTP_RETRY_WITH 449
  137. #define MHD_HTTP_INTERNAL_SERVER_ERROR 500
  138. #define MHD_HTTP_NOT_IMPLEMENTED 501
  139. #define MHD_HTTP_BAD_GATEWAY 502
  140. #define MHD_HTTP_SERVICE_UNAVAILABLE 503
  141. #define MHD_HTTP_GATEWAY_TIMEOUT 504
  142. #define MHD_HTTP_HTTP_VERSION_NOT_SUPPORTED 505
  143. #define MHD_HTTP_VARIANT_ALSO_NEGOTIATES 506
  144. #define MHD_HTTP_INSUFFICIENT_STORAGE 507
  145. #define MHD_HTTP_BANDWIDTH_LIMIT_EXCEEDED 509
  146. #define MHD_HTTP_NOT_EXTENDED 510
  147. /* See also: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html */
  148. #define MHD_HTTP_HEADER_ACCEPT "Accept"
  149. #define MHD_HTTP_HEADER_ACCEPT_CHARSET "Accept-Charset"
  150. #define MHD_HTTP_HEADER_ACCEPT_ENCODING "Accept-Encoding"
  151. #define MHD_HTTP_HEADER_ACCEPT_LANGUAGE "Accept-Language"
  152. #define MHD_HTTP_HEADER_ACCEPT_RANGES "Accept-Ranges"
  153. #define MHD_HTTP_HEADER_AGE "Age"
  154. #define MHD_HTTP_HEADER_ALLOW "Allow"
  155. #define MHD_HTTP_HEADER_AUTHORIZATION "Authorization"
  156. #define MHD_HTTP_HEADER_CACHE_CONTROL "Cache-Control"
  157. #define MHD_HTTP_HEADER_CONNECTION "Connection"
  158. #define MHD_HTTP_HEADER_CONTENT_ENCODING "Content-Encoding"
  159. #define MHD_HTTP_HEADER_CONTENT_LANGUAGE "Content-Language"
  160. #define MHD_HTTP_HEADER_CONTENT_LENGTH "Content-Length"
  161. #define MHD_HTTP_HEADER_CONTENT_LOCATION "Content-Location"
  162. #define MHD_HTTP_HEADER_CONTENT_MD5 "Content-MD5"
  163. #define MHD_HTTP_HEADER_CONTENT_RANGE "Content-Range"
  164. #define MHD_HTTP_HEADER_CONTENT_TYPE "Content-Type"
  165. #define MHD_HTTP_HEADER_COOKIE "Cookie"
  166. #define MHD_HTTP_HEADER_DATE "Date"
  167. #define MHD_HTTP_HEADER_ETAG "ETag"
  168. #define MHD_HTTP_HEADER_EXPECT "Expect"
  169. #define MHD_HTTP_HEADER_EXPIRES "Expires"
  170. #define MHD_HTTP_HEADER_FROM "From"
  171. #define MHD_HTTP_HEADER_HOST "Host"
  172. #define MHD_HTTP_HEADER_IF_MATCH "If-Match"
  173. #define MHD_HTTP_HEADER_IF_MODIFIED_SINCE "If-Modified-Since"
  174. #define MHD_HTTP_HEADER_IF_NONE_MATCH "If-None-Match"
  175. #define MHD_HTTP_HEADER_IF_RANGE "If-Range"
  176. #define MHD_HTTP_HEADER_IF_UNMODIFIED_SINCE "If-Unmodified-Since"
  177. #define MHD_HTTP_HEADER_LAST_MODIFIED "Last-Modified"
  178. #define MHD_HTTP_HEADER_LOCATION "Location"
  179. #define MHD_HTTP_HEADER_MAX_FORWARDS "Max-Forwards"
  180. #define MHD_HTTP_HEADER_PRAGMA "Pragma"
  181. #define MHD_HTTP_HEADER_PROXY_AUTHENTICATE "Proxy-Authenticate"
  182. #define MHD_HTTP_HEADER_PROXY_AUTHORIZATION "Proxy-Authorization"
  183. #define MHD_HTTP_HEADER_RANGE "Range"
  184. #define MHD_HTTP_HEADER_REFERER "Referer"
  185. #define MHD_HTTP_HEADER_RETRY_AFTER "Retry-After"
  186. #define MHD_HTTP_HEADER_SERVER "Server"
  187. #define MHD_HTTP_HEADER_SET_COOKIE "Set-Cookie"
  188. #define MHD_HTTP_HEADER_SET_COOKIE2 "Set-Cookie2"
  189. #define MHD_HTTP_HEADER_TE "TE"
  190. #define MHD_HTTP_HEADER_TRAILER "Trailer"
  191. #define MHD_HTTP_HEADER_TRANSFER_ENCODING "Transfer-Encoding"
  192. #define MHD_HTTP_HEADER_UPGRADE "Upgrade"
  193. #define MHD_HTTP_HEADER_USER_AGENT "User-Agent"
  194. #define MHD_HTTP_HEADER_VARY "Vary"
  195. #define MHD_HTTP_HEADER_VIA "Via"
  196. #define MHD_HTTP_HEADER_WARNING "Warning"
  197. #define MHD_HTTP_HEADER_WWW_AUTHENTICATE "WWW-Authenticate"
  198. /**
  199. * HTTP versions (used to match against the first line of the
  200. * HTTP header as well as in the response code).
  201. */
  202. #define MHD_HTTP_VERSION_1_0 "HTTP/1.0"
  203. #define MHD_HTTP_VERSION_1_1 "HTTP/1.1"
  204. /**
  205. * HTTP methods
  206. */
  207. #define MHD_HTTP_METHOD_CONNECT "CONNECT"
  208. #define MHD_HTTP_METHOD_DELETE "DELETE"
  209. #define MHD_HTTP_METHOD_GET "GET"
  210. #define MHD_HTTP_METHOD_HEAD "HEAD"
  211. #define MHD_HTTP_METHOD_OPTIONS "OPTIONS"
  212. #define MHD_HTTP_METHOD_POST "POST"
  213. #define MHD_HTTP_METHOD_PUT "PUT"
  214. #define MHD_HTTP_METHOD_TRACE "TRACE"
  215. /**
  216. * HTTP POST encodings, see also
  217. * http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4
  218. */
  219. #define MHD_HTTP_POST_ENCODING_FORM_URLENCODED "application/x-www-form-urlencoded"
  220. #define MHD_HTTP_POST_ENCODING_MULTIPART_FORMDATA "multipart/form-data"
  221. /**
  222. * Options for the MHD daemon. Note that if neither
  223. * MHD_USER_THREAD_PER_CONNECTION nor MHD_USE_SELECT_INTERNALLY are
  224. * used, the client wants control over the process and will call the
  225. * appropriate microhttpd callbacks.<p>
  226. *
  227. * Starting the daemon may also fail if a particular option is not
  228. * implemented or not supported on the target platform (i.e. no
  229. * support for SSL, threads or IPv6).
  230. */
  231. enum MHD_FLAG
  232. {
  233. /**
  234. * No options selected.
  235. */
  236. MHD_NO_FLAG = 0,
  237. /**
  238. * Run in debug mode. If this flag is used, the
  239. * library should print error messages and warnings
  240. * to stderr.
  241. */
  242. MHD_USE_DEBUG = 1,
  243. /**
  244. * Run in https mode.
  245. */
  246. MHD_USE_SSL = 2,
  247. /**
  248. * Run using one thread per connection.
  249. */
  250. MHD_USE_THREAD_PER_CONNECTION = 4,
  251. /**
  252. * Run using an internal thread doing SELECT.
  253. */
  254. MHD_USE_SELECT_INTERNALLY = 8,
  255. /**
  256. * Run using the IPv6 protocol (otherwise, MHD will
  257. * just support IPv4).
  258. */
  259. MHD_USE_IPv6 = 16,
  260. /**
  261. * Be pedantic about the protocol (as opposed to as tolerant as
  262. * possible). Specifically, at the moment, this flag causes MHD to
  263. * reject http 1.1 connections without a "Host" header. This is
  264. * required by the standard, but of course in violation of the "be
  265. * as liberal as possible in what you accept" norm. It is
  266. * recommended to turn this ON if you are testing clients against
  267. * MHD, and OFF in production.
  268. */
  269. MHD_USE_PEDANTIC_CHECKS = 32,
  270. /**
  271. * Use poll instead of select. This allows sockets with fd >= FD_SETSIZE.
  272. * This option only works in conjunction with MHD_USE_THREAD_PER_CONNECTION
  273. * (at this point).
  274. */
  275. MHD_USE_POLL = 64
  276. };
  277. /**
  278. * MHD options. Passed in the varargs portion
  279. * of MHD_start_daemon.
  280. */
  281. enum MHD_OPTION
  282. {
  283. /**
  284. * No more options / last option. This is used
  285. * to terminate the VARARGs list.
  286. */
  287. MHD_OPTION_END = 0,
  288. /**
  289. * Maximum memory size per connection (followed by a
  290. * size_t).
  291. */
  292. MHD_OPTION_CONNECTION_MEMORY_LIMIT = 1,
  293. /**
  294. * Maximum number of concurrent connections to
  295. * accept (followed by an unsigned int).
  296. */
  297. MHD_OPTION_CONNECTION_LIMIT = 2,
  298. /**
  299. * After how many seconds of inactivity should a
  300. * connection automatically be timed out? (followed
  301. * by an unsigned int; use zero for no timeout).
  302. */
  303. MHD_OPTION_CONNECTION_TIMEOUT = 3,
  304. /**
  305. * Register a function that should be called whenever a request has
  306. * been completed (this can be used for application-specific clean
  307. * up). Requests that have never been presented to the application
  308. * (via MHD_AccessHandlerCallback) will not result in
  309. * notifications.<p>
  310. *
  311. * This option should be followed by TWO pointers. First a pointer
  312. * to a function of type "MHD_RequestCompletedCallback" and second a
  313. * pointer to a closure to pass to the request completed callback.
  314. * The second pointer maybe NULL.
  315. */
  316. MHD_OPTION_NOTIFY_COMPLETED = 4,
  317. /**
  318. * Limit on the number of (concurrent) connections made to the
  319. * server from the same IP address. Can be used to prevent one
  320. * IP from taking over all of the allowed connections. If the
  321. * same IP tries to establish more than the specified number of
  322. * connections, they will be immediately rejected. The option
  323. * should be followed by an "unsigned int". The default is
  324. * zero, which means no limit on the number of connections
  325. * from the same IP address.
  326. */
  327. MHD_OPTION_PER_IP_CONNECTION_LIMIT = 5,
  328. /**
  329. * Bind daemon to the supplied sockaddr. this option should be followed by a
  330. * 'struct sockaddr *'. If 'MHD_USE_IPv6' is specified, the 'struct sockaddr*'
  331. * should point to a 'struct sockaddr_in6', otherwise to a 'struct sockaddr_in'.
  332. */
  333. MHD_OPTION_SOCK_ADDR = 6,
  334. /**
  335. * Specify a function that should be called before parsing the URI from
  336. * the client. The specified callback function can be used for processing
  337. * the URI (including the options) before it is parsed. The URI after
  338. * parsing will no longer contain the options, which maybe inconvenient for
  339. * logging. This option should be followed by two arguments, the first
  340. * one must be of the form
  341. * <pre>
  342. * void * my_logger(void * cls, const char * uri)
  343. * </pre>
  344. * where the return value will be passed as
  345. * (*con_cls) in calls to the MHD_AccessHandlerCallback
  346. * when this request is processed later; returning a
  347. * value of NULL has no special significance (however,
  348. * note that if you return non-NULL, you can no longer
  349. * rely on the first call to the access handler having
  350. * NULL == *con_cls on entry;)
  351. * "cls" will be set to the second argument following
  352. * MHD_OPTION_URI_LOG_CALLBACK. Finally, uri will
  353. * be the 0-terminated URI of the request.
  354. */
  355. MHD_OPTION_URI_LOG_CALLBACK = 7,
  356. /**
  357. * Memory pointer for the private key (key.pem) to be used by the
  358. * HTTPS daemon. This option should be followed by an
  359. * "const char*" argument.
  360. * This should be used in conjunction with 'MHD_OPTION_HTTPS_MEM_CERT'.
  361. */
  362. MHD_OPTION_HTTPS_MEM_KEY = 8,
  363. /**
  364. * Memory pointer for the certificate (cert.pem) to be used by the
  365. * HTTPS daemon. This option should be followed by an
  366. * "const char*" argument.
  367. * This should be used in conjunction with 'MHD_OPTION_HTTPS_MEM_KEY'.
  368. */
  369. MHD_OPTION_HTTPS_MEM_CERT = 9,
  370. /**
  371. * Daemon credentials type.
  372. * This option should be followed by one of the values listed in
  373. * "enum MHD_GNUTLS_CredentialsType".
  374. */
  375. MHD_OPTION_CRED_TYPE = 10,
  376. /**
  377. * SSL/TLS protocol version.
  378. *
  379. * Memory pointer to a zero (MHD_GNUTLS_PROTOCOL_END) terminated
  380. * (const) array of 'enum MHD_GNUTLS_Protocol' values representing the
  381. * protocol versions to this server should support. Unsupported
  382. * requests will be droped by the server.
  383. */
  384. MHD_OPTION_PROTOCOL_VERSION = 11,
  385. /**
  386. * Memory pointer to a zero (MHD_GNUTLS_CIPHER_UNKNOWN)
  387. * terminated (const) array of 'enum MHD_GNUTLS_CipherAlgorithm'
  388. * representing the cipher priority order to which the HTTPS
  389. * daemon should adhere.
  390. */
  391. MHD_OPTION_CIPHER_ALGORITHM = 12,
  392. /**
  393. * Use the given function for logging error messages.
  394. * This option must be followed by two arguments; the
  395. * first must be a pointer to a function
  396. * of type "void fun(void * arg, const char * fmt, va_list ap)"
  397. * and the second a pointer "void*" which will
  398. * be passed as the "arg" argument to "fun".
  399. * <p>
  400. * Note that MHD will not generate any log messages
  401. * if it was compiled without the "--enable-messages"
  402. * flag being set.
  403. */
  404. MHD_OPTION_EXTERNAL_LOGGER = 13,
  405. /**
  406. * Number (unsigned int) of threads in thread pool. Enable
  407. * thread pooling by setting this value to to something
  408. * greater than 1. Currently, thread model must be
  409. * MHD_USE_SELECT_INTERNALLY if thread pooling is enabled
  410. * (MHD_start_daemon returns NULL for an unsupported thread
  411. * model).
  412. */
  413. MHD_OPTION_THREAD_POOL_SIZE = 14,
  414. /**
  415. * Additional options given in an array of "struct MHD_OptionItem".
  416. * The array must be terminated with an entry '{MHD_OPTION_END, 0, NULL}'.
  417. * An example for code using MHD_OPTION_ARRAY is:
  418. * <code>
  419. * struct MHD_OptionItem ops[] = {
  420. * { MHD_OPTION_CONNECTION_LIMIT, 100, NULL },
  421. * { MHD_OPTION_CONNECTION_TIMEOUT, 10, NULL },
  422. * { MHD_OPTION_END, 0, NULL }
  423. * };
  424. * d = MHD_start_daemon(0, 8080, NULL, NULL, dh, NULL,
  425. * MHD_OPTION_ARRAY, ops,
  426. * MHD_OPTION_END);
  427. * </code>
  428. * For options that expect a single pointer argument, the
  429. * second member of the struct MHD_OptionItem is ignored.
  430. * For options that expect two pointer arguments, the first
  431. * argument must be cast to 'intptr_t'.
  432. */
  433. MHD_OPTION_ARRAY = 15
  434. };
  435. /**
  436. * Entry in an MHD_OPTION_ARRAY.
  437. */
  438. struct MHD_OptionItem
  439. {
  440. /**
  441. * Which option is being given. Use MHD_OPTION_END
  442. * to terminate the array.
  443. */
  444. enum MHD_OPTION option;
  445. /**
  446. * Option value (for integer arguments, and for options requiring
  447. * two pointer arguments); should be 0 for options that take no
  448. * arguments or only a single pointer argument.
  449. */
  450. intptr_t value;
  451. /**
  452. * Pointer option value (use NULL for options taking no arguments
  453. * or only an integer option).
  454. */
  455. void *ptr_value;
  456. };
  457. /**
  458. * The MHD_ValueKind specifies the source of
  459. * the key-value pairs in the HTTP protocol.
  460. */
  461. enum MHD_ValueKind
  462. {
  463. /**
  464. * Response header
  465. */
  466. MHD_RESPONSE_HEADER_KIND = 0,
  467. /**
  468. * HTTP header.
  469. */
  470. MHD_HEADER_KIND = 1,
  471. /**
  472. * Cookies. Note that the original HTTP header containing
  473. * the cookie(s) will still be available and intact.
  474. */
  475. MHD_COOKIE_KIND = 2,
  476. /**
  477. * POST data. This is available only if a content encoding
  478. * supported by MHD is used (currently only URL encoding),
  479. * and only if the posted content fits within the available
  480. * memory pool. Note that in that case, the upload data
  481. * given to the MHD_AccessHandlerCallback will be
  482. * empty (since it has already been processed).
  483. */
  484. MHD_POSTDATA_KIND = 4,
  485. /**
  486. * GET (URI) arguments.
  487. */
  488. MHD_GET_ARGUMENT_KIND = 8,
  489. /**
  490. * HTTP footer (only for http 1.1 chunked encodings).
  491. */
  492. MHD_FOOTER_KIND = 16
  493. };
  494. /**
  495. * The MHD_RequestTerminationCode specifies reasons
  496. * why a request has been terminated (or completed).
  497. */
  498. enum MHD_RequestTerminationCode
  499. {
  500. /**
  501. * We finished sending the response.
  502. */
  503. MHD_REQUEST_TERMINATED_COMPLETED_OK = 0,
  504. /**
  505. * Error handling the connection (resources
  506. * exhausted, other side closed connection,
  507. * application error accepting request, etc.)
  508. */
  509. MHD_REQUEST_TERMINATED_WITH_ERROR = 1,
  510. /**
  511. * No activity on the connection for the number
  512. * of seconds specified using
  513. * MHD_OPTION_CONNECTION_TIMEOUT.
  514. */
  515. MHD_REQUEST_TERMINATED_TIMEOUT_REACHED = 2,
  516. /**
  517. * We had to close the session since MHD was being
  518. * shut down.
  519. */
  520. MHD_REQUEST_TERMINATED_DAEMON_SHUTDOWN = 3
  521. };
  522. /**
  523. * List of symmetric ciphers.
  524. * Note that not all listed algorithms are necessarily
  525. * supported by all builds of MHD.
  526. */
  527. enum MHD_GNUTLS_CipherAlgorithm
  528. {
  529. MHD_GNUTLS_CIPHER_UNKNOWN = 0,
  530. MHD_GNUTLS_CIPHER_NULL = 1,
  531. MHD_GNUTLS_CIPHER_ARCFOUR_128,
  532. MHD_GNUTLS_CIPHER_3DES_CBC,
  533. MHD_GNUTLS_CIPHER_AES_128_CBC,
  534. MHD_GNUTLS_CIPHER_AES_256_CBC
  535. };
  536. /**
  537. * SSL/TLS Protocol types.
  538. * Note that not all listed algorithms are necessarily
  539. * supported by all builds of MHD.
  540. */
  541. enum MHD_GNUTLS_Protocol
  542. {
  543. MHD_GNUTLS_PROTOCOL_END = 0,
  544. MHD_GNUTLS_PROTOCOL_SSL3 = 1,
  545. MHD_GNUTLS_PROTOCOL_TLS1_0,
  546. MHD_GNUTLS_PROTOCOL_TLS1_1,
  547. MHD_GNUTLS_PROTOCOL_TLS1_2,
  548. MHD_GNUTLS_PROTOCOL_VERSION_UNKNOWN = 0xff
  549. };
  550. /**
  551. * Values of this enum are used to specify what
  552. * information about a connection is desired.
  553. */
  554. enum MHD_ConnectionInfoType
  555. {
  556. /**
  557. * What cipher algorithm is being used.
  558. * Takes no extra arguments.
  559. */
  560. MHD_CONNECTION_INFO_CIPHER_ALGO,
  561. /**
  562. *
  563. * Takes no extra arguments.
  564. */
  565. MHD_CONNECTION_INFO_PROTOCOL,
  566. /**
  567. * Obtain IP address of the client.
  568. * Takes no extra arguments.
  569. */
  570. MHD_CONNECTION_INFO_CLIENT_ADDRESS
  571. };
  572. /**
  573. * Values of this enum are used to specify what
  574. * information about a deamon is desired.
  575. */
  576. enum MHD_DaemonInfoType
  577. {
  578. /**
  579. * Request information about the key size for
  580. * a particular cipher algorithm. The cipher
  581. * algorithm should be passed as an extra
  582. * argument (of type 'enum MHD_GNUTLS_CipherAlgorithm').
  583. */
  584. MHD_DAEMON_INFO_KEY_SIZE,
  585. /**
  586. * Request information about the key size for
  587. * a particular cipher algorithm. The cipher
  588. * algorithm should be passed as an extra
  589. * argument (of type 'enum MHD_GNUTLS_HashAlgorithm').
  590. */
  591. MHD_DAEMON_INFO_MAC_KEY_SIZE,
  592. /**
  593. * Request the file descriptor for the listening socket.
  594. * No extra arguments should be passed.
  595. */
  596. MHD_DAEMON_INFO_LISTEN_FD
  597. };
  598. /**
  599. * Handle for the daemon (listening on a socket for HTTP traffic).
  600. */
  601. struct MHD_Daemon;
  602. /**
  603. * Handle for a connection / HTTP request. With HTTP/1.1, multiple
  604. * requests can be run over the same connection. However, MHD will
  605. * only show one request per TCP connection to the client at any given
  606. * time.
  607. */
  608. struct MHD_Connection;
  609. /**
  610. * Handle for a response.
  611. */
  612. struct MHD_Response;
  613. /**
  614. * Handle for POST processing.
  615. */
  616. struct MHD_PostProcessor;
  617. /**
  618. * Callback for serious error condition. The default action is to abort().
  619. * @param cls user specified value
  620. * @param file where the error occured
  621. * @param line where the error occured
  622. * @param reason error detail, may be NULL
  623. */
  624. typedef void (*MHD_PanicCallback) (void *cls,
  625. const char *file,
  626. unsigned int line,
  627. const char *reason);
  628. /**
  629. * Allow or deny a client to connect.
  630. *
  631. * @param addr address information from the client
  632. * @param addrlen length of the address information
  633. * @return MHD_YES if connection is allowed, MHD_NO if not
  634. */
  635. typedef int
  636. (*MHD_AcceptPolicyCallback) (void *cls,
  637. const struct sockaddr * addr,
  638. socklen_t addrlen);
  639. /**
  640. * A client has requested the given url using the given method ("GET",
  641. * "PUT", "DELETE", "POST", etc). The callback must call MHS
  642. * callbacks to provide content to give back to the client and return
  643. * an HTTP status code (i.e. 200 for OK, 404, etc.).
  644. *
  645. * @param cls argument given together with the function
  646. * pointer when the handler was registered with MHD
  647. * @param url the requested url
  648. * @param method the HTTP method used ("GET", "PUT", etc.)
  649. * @param version the HTTP version string (i.e. "HTTP/1.1")
  650. * @param upload_data the data being uploaded (excluding HEADERS,
  651. * for a POST that fits into memory and that is encoded
  652. * with a supported encoding, the POST data will NOT be
  653. * given in upload_data and is instead available as
  654. * part of MHD_get_connection_values; very large POST
  655. * data *will* be made available incrementally in
  656. * upload_data)
  657. * @param upload_data_size set initially to the size of the
  658. * upload_data provided; the method must update this
  659. * value to the number of bytes NOT processed;
  660. * @param con_cls pointer that the callback can set to some
  661. * address and that will be preserved by MHD for future
  662. * calls for this request; since the access handler may
  663. * be called many times (i.e., for a PUT/POST operation
  664. * with plenty of upload data) this allows the application
  665. * to easily associate some request-specific state.
  666. * If necessary, this state can be cleaned up in the
  667. * global "MHD_RequestCompleted" callback (which
  668. * can be set with the MHD_OPTION_NOTIFY_COMPLETED).
  669. * Initially, <tt>*con_cls</tt> will be NULL.
  670. * @return MHS_YES if the connection was handled successfully,
  671. * MHS_NO if the socket must be closed due to a serios
  672. * error while handling the request
  673. */
  674. typedef int
  675. (*MHD_AccessHandlerCallback) (void *cls,
  676. struct MHD_Connection * connection,
  677. const char *url,
  678. const char *method,
  679. const char *version,
  680. const char *upload_data,
  681. size_t *upload_data_size,
  682. void **con_cls);
  683. /**
  684. * Signature of the callback used by MHD to notify the
  685. * application about completed requests.
  686. *
  687. * @param cls client-defined closure
  688. * @param connection connection handle
  689. * @param con_cls value as set by the last call to
  690. * the MHD_AccessHandlerCallback
  691. * @param toe reason for request termination
  692. * @see MHD_OPTION_NOTIFY_COMPLETED
  693. */
  694. typedef void
  695. (*MHD_RequestCompletedCallback) (void *cls,
  696. struct MHD_Connection * connection,
  697. void **con_cls,
  698. enum MHD_RequestTerminationCode toe);
  699. /**
  700. * Iterator over key-value pairs. This iterator
  701. * can be used to iterate over all of the cookies,
  702. * headers, or POST-data fields of a request, and
  703. * also to iterate over the headers that have been
  704. * added to a response.
  705. *
  706. * @return MHD_YES to continue iterating,
  707. * MHD_NO to abort the iteration
  708. */
  709. typedef int
  710. (*MHD_KeyValueIterator) (void *cls,
  711. enum MHD_ValueKind kind,
  712. const char *key, const char *value);
  713. /**
  714. * Callback used by libmicrohttpd in order to obtain content. The
  715. * callback is to copy at most "max" bytes of content into "buf". The
  716. * total number of bytes that has been placed into "buf" should be
  717. * returned.<p>
  718. *
  719. * Note that returning zero will cause libmicrohttpd to try again,
  720. * either "immediately" if in multi-threaded mode (in which case the
  721. * callback may want to do blocking operations) or in the next round
  722. * if MHD_run is used. Returning 0 for a daemon that runs in internal
  723. * select mode is an error (since it would result in busy waiting) and
  724. * will cause the program to be aborted (abort()).
  725. *
  726. * @param cls extra argument to the callback
  727. * @param pos position in the datastream to access;
  728. * note that if an MHD_Response object is re-used,
  729. * it is possible for the same content reader to
  730. * be queried multiple times for the same data;
  731. * however, if an MHD_Response is not re-used,
  732. * libmicrohttpd guarantees that "pos" will be
  733. * the sum of all non-negative return values
  734. * obtained from the content reader so far.
  735. * @return -1 for the end of transmission (or on error);
  736. * if a content transfer size was pre-set and the callback
  737. * has provided fewer than that amount of data,
  738. * MHD will close the connection with the client;
  739. * if no content size was specified and this is an
  740. * http 1.1 connection using chunked encoding, MHD will
  741. * interpret "-1" as the normal end of the transfer
  742. * (possibly allowing the client to perform additional
  743. * requests using the same TCP connection).
  744. */
  745. typedef int
  746. (*MHD_ContentReaderCallback) (void *cls,
  747. uint64_t pos,
  748. char *buf,
  749. int max);
  750. /**
  751. * This method is called by libmicrohttpd if we
  752. * are done with a content reader. It should
  753. * be used to free resources associated with the
  754. * content reader.
  755. */
  756. typedef void (*MHD_ContentReaderFreeCallback) (void *cls);
  757. /**
  758. * Iterator over key-value pairs where the value
  759. * maybe made available in increments and/or may
  760. * not be zero-terminated. Used for processing
  761. * POST data.
  762. *
  763. * @param cls user-specified closure
  764. * @param kind type of the value
  765. * @param key 0-terminated key for the value
  766. * @param filename name of the uploaded file, NULL if not known
  767. * @param content_type mime-type of the data, NULL if not known
  768. * @param transfer_encoding encoding of the data, NULL if not known
  769. * @param data pointer to size bytes of data at the
  770. * specified offset
  771. * @param off offset of data in the overall value
  772. * @param size number of bytes in data available
  773. * @return MHD_YES to continue iterating,
  774. * MHD_NO to abort the iteration
  775. */
  776. typedef int
  777. (*MHD_PostDataIterator) (void *cls,
  778. enum MHD_ValueKind kind,
  779. const char *key,
  780. const char *filename,
  781. const char *content_type,
  782. const char *transfer_encoding,
  783. const char *data, uint64_t off, size_t size);
  784. /* **************** Daemon handling functions ***************** */
  785. /**
  786. * Start a webserver on the given port.
  787. *
  788. * @param flags combination of MHD_FLAG values
  789. * @param port port to bind to
  790. * @param apc callback to call to check which clients
  791. * will be allowed to connect; you can pass NULL
  792. * in which case connections from any IP will be
  793. * accepted
  794. * @param apc_cls extra argument to apc
  795. * @param dh handler called for all requests (repeatedly)
  796. * @param dh_cls extra argument to dh
  797. * @param ... list of options (type-value pairs,
  798. * terminated with MHD_OPTION_END).
  799. * @return NULL on error, handle to daemon on success
  800. */
  801. struct MHD_Daemon *MHD_start_daemon_va (unsigned int options,
  802. unsigned short port,
  803. MHD_AcceptPolicyCallback apc,
  804. void *apc_cls,
  805. MHD_AccessHandlerCallback dh,
  806. void *dh_cls, va_list ap);
  807. /**
  808. * Start a webserver on the given port. Variadic version of
  809. * MHD_start_daemon_va.
  810. *
  811. * @param flags combination of MHD_FLAG values
  812. * @param port port to bind to
  813. * @param apc callback to call to check which clients
  814. * will be allowed to connect; you can pass NULL
  815. * in which case connections from any IP will be
  816. * accepted
  817. * @param apc_cls extra argument to apc
  818. * @param dh handler called for all requests (repeatedly)
  819. * @param dh_cls extra argument to dh
  820. * @return NULL on error, handle to daemon on success
  821. */
  822. struct MHD_Daemon *MHD_start_daemon (unsigned int flags,
  823. unsigned short port,
  824. MHD_AcceptPolicyCallback apc,
  825. void *apc_cls,
  826. MHD_AccessHandlerCallback dh,
  827. void *dh_cls, ...);
  828. /**
  829. * Shutdown an http daemon.
  830. *
  831. * @param daemon daemon to stop
  832. */
  833. void MHD_stop_daemon (struct MHD_Daemon *daemon);
  834. /**
  835. * Obtain the select sets for this daemon.
  836. *
  837. * @param daemon daemon to get sets from
  838. * @param read_fd_set read set
  839. * @param write_fd_set write set
  840. * @param except_fd_set except set
  841. * @param max_fd increased to largest FD added (if larger
  842. * than existing value)
  843. * @return MHD_YES on success, MHD_NO if this
  844. * daemon was not started with the right
  845. * options for this call.
  846. */
  847. int
  848. MHD_get_fdset (struct MHD_Daemon *daemon,
  849. fd_set * read_fd_set,
  850. fd_set * write_fd_set, fd_set * except_fd_set, int *max_fd);
  851. /**
  852. * Obtain timeout value for select for this daemon
  853. * (only needed if connection timeout is used). The
  854. * returned value is how long select should at most
  855. * block, not the timeout value set for connections.
  856. *
  857. * @param daemon daemon to query for timeout
  858. * @param timeout set to the timeout (in milliseconds)
  859. * @return MHD_YES on success, MHD_NO if timeouts are
  860. * not used (or no connections exist that would
  861. * necessiate the use of a timeout right now).
  862. */
  863. int MHD_get_timeout (struct MHD_Daemon *daemon, unsigned long long *timeout);
  864. /**
  865. * Run webserver operations (without blocking unless
  866. * in client callbacks). This method should be called
  867. * by clients in combination with MHD_get_fdset
  868. * if the client-controlled select method is used.
  869. *
  870. * @param daemon daemon to run
  871. * @return MHD_YES on success, MHD_NO if this
  872. * daemon was not started with the right
  873. * options for this call.
  874. */
  875. int MHD_run (struct MHD_Daemon *daemon);
  876. /* **************** Connection handling functions ***************** */
  877. /**
  878. * Get all of the headers from the request.
  879. *
  880. * @param connection connection to get values from
  881. * @param kind types of values to iterate over
  882. * @param iterator callback to call on each header;
  883. * maybe NULL (then just count headers)
  884. * @param iterator_cls extra argument to iterator
  885. * @return number of entries iterated over
  886. */
  887. int
  888. MHD_get_connection_values (struct MHD_Connection *connection,
  889. enum MHD_ValueKind kind,
  890. MHD_KeyValueIterator iterator, void *iterator_cls);
  891. /**
  892. * This function can be used to add an entry to
  893. * the HTTP headers of a connection (so that the
  894. * MHD_get_connection_values function will return
  895. * them -- and the MHD PostProcessor will also
  896. * see them). This maybe required in certain
  897. * situations (see Mantis #1399) where (broken)
  898. * HTTP implementations fail to supply values needed
  899. * by the post processor (or other parts of the
  900. * application).
  901. * <p>
  902. * This function MUST only be called from within
  903. * the MHD_AccessHandlerCallback (otherwise, access
  904. * maybe improperly synchronized). Furthermore,
  905. * the client must guarantee that the key and
  906. * value arguments are 0-terminated strings that
  907. * are NOT freed until the connection is closed.
  908. * (The easiest way to do this is by passing only
  909. * arguments to permanently allocated strings.).
  910. *
  911. * @param connection the connection for which a
  912. * value should be set
  913. * @param kind kind of the value
  914. * @param key key for the value
  915. * @param value the value itself
  916. * @return MHD_NO if the operation could not be
  917. * performed due to insufficient memory;
  918. * MHD_YES on success
  919. */
  920. int
  921. MHD_set_connection_value (struct MHD_Connection *connection,
  922. enum MHD_ValueKind kind,
  923. const char *key, const char *value);
  924. /**
  925. * Sets the global error handler to a different implementation. "cb"
  926. * will only be called in the case of typically fatal, serious
  927. * internal consistency issues. These issues should only arise in the
  928. * case of serious memory corruption or similar problems with the
  929. * architecture. While "cb" is allowed to return and MHD will then
  930. * try to continue, this is never safe.
  931. *
  932. * The default implementation that is used if no panic function is set
  933. * simply calls "abort". Alternative implementations might call
  934. * "exit" or other similar functions.
  935. *
  936. * @param cb new error handler
  937. * @param cls passed to error handler
  938. */
  939. void MHD_set_panic_func (MHD_PanicCallback cb, void *cls);
  940. /**
  941. * Get a particular header value. If multiple
  942. * values match the kind, return any one of them.
  943. *
  944. * @param connection connection to get values from
  945. * @param kind what kind of value are we looking for
  946. * @param key the header to look for
  947. * @return NULL if no such item was found
  948. */
  949. const char *MHD_lookup_connection_value (struct MHD_Connection *connection,
  950. enum MHD_ValueKind kind,
  951. const char *key);
  952. /**
  953. * Queue a response to be transmitted to the client (as soon as
  954. * possible but after MHD_AccessHandlerCallback returns).
  955. *
  956. * @param connection the connection identifying the client
  957. * @param status_code HTTP status code (i.e. 200 for OK)
  958. * @param response response to transmit
  959. * @return MHD_NO on error (i.e. reply already sent),
  960. * MHD_YES on success or if message has been queued
  961. */
  962. int
  963. MHD_queue_response (struct MHD_Connection *connection,
  964. unsigned int status_code, struct MHD_Response *response);
  965. /* **************** Response manipulation functions ***************** */
  966. /**
  967. * Create a response object. The response object can be extended with
  968. * header information and then be used any number of times.
  969. *
  970. * @param size size of the data portion of the response, MHD_SIZE_UNKNOW for unknown
  971. * @param block_size preferred block size for querying crc (advisory only,
  972. * MHD may still call crc using smaller chunks); this
  973. * is essentially the buffer size used for IO, clients
  974. * should pick a value that is appropriate for IO and
  975. * memory performance requirements
  976. * @param crc callback to use to obtain response data
  977. * @param crc_cls extra argument to crc
  978. * @param crfc callback to call to free crc_cls resources
  979. * @return NULL on error (i.e. invalid arguments, out of memory)
  980. */
  981. struct MHD_Response *MHD_create_response_from_callback (uint64_t size,
  982. size_t block_size,
  983. MHD_ContentReaderCallback
  984. crc, void *crc_cls,
  985. MHD_ContentReaderFreeCallback
  986. crfc);
  987. /**
  988. * Create a response object. The response object can be extended with
  989. * header information and then be used any number of times.
  990. *
  991. * @param size size of the data portion of the response
  992. * @param data the data itself
  993. * @param must_free libmicrohttpd should free data when done
  994. * @param must_copy libmicrohttpd must make a copy of data
  995. * right away, the data maybe released anytime after
  996. * this call returns
  997. * @return NULL on error (i.e. invalid arguments, out of memory)
  998. */
  999. struct MHD_Response *MHD_create_response_from_data (size_t size,
  1000. void *data,
  1001. int must_free,
  1002. int must_copy);
  1003. /**
  1004. * Destroy a response object and associated resources. Note that
  1005. * libmicrohttpd may keep some of the resources around if the response
  1006. * is still in the queue for some clients, so the memory may not
  1007. * necessarily be freed immediatley.
  1008. *
  1009. * @param response response to destroy
  1010. */
  1011. void MHD_destroy_response (struct MHD_Response *response);
  1012. /**
  1013. * Add a header line to the response.
  1014. *
  1015. * @param response response to add a header to
  1016. * @param header the header to add
  1017. * @param content value to add
  1018. * @return MHD_NO on error (i.e. invalid header or content format),
  1019. * or out of memory
  1020. */
  1021. int
  1022. MHD_add_response_header (struct MHD_Response *response,
  1023. const char *header, const char *content);
  1024. /**
  1025. * Delete a header line from the response.
  1026. *
  1027. * @param response response to remove a header from
  1028. * @param header the header to delete
  1029. * @param content value to delete
  1030. * @return MHD_NO on error (no such header known)
  1031. */
  1032. int
  1033. MHD_del_response_header (struct MHD_Response *response,
  1034. const char *header, const char *content);
  1035. /**
  1036. * Get all of the headers added to a response.
  1037. *
  1038. * @param response response to query
  1039. * @param iterator callback to call on each header;
  1040. * maybe NULL (then just count headers)
  1041. * @param iterator_cls extra argument to iterator
  1042. * @return number of entries iterated over
  1043. */
  1044. int
  1045. MHD_get_response_headers (struct MHD_Response *response,
  1046. MHD_KeyValueIterator iterator, void *iterator_cls);
  1047. /**
  1048. * Get a particular header from the response.
  1049. *
  1050. * @param response response to query
  1051. * @param key which header to get
  1052. * @return NULL if header does not exist
  1053. */
  1054. const char *MHD_get_response_header (struct MHD_Response *response,
  1055. const char *key);
  1056. /* ********************** PostProcessor functions ********************** */
  1057. /**
  1058. * Create a PostProcessor.
  1059. *
  1060. * A PostProcessor can be used to (incrementally) parse the data
  1061. * portion of a POST request. Note that some buggy browsers fail to
  1062. * set the encoding type. If you want to support those, you may have
  1063. * to call 'MHD_set_connection_value' with the proper encoding type
  1064. * before creating a post processor (if no supported encoding type is
  1065. * set, this function will fail).
  1066. *
  1067. * @param connection the connection on which the POST is
  1068. * happening (used to determine the POST format)
  1069. * @param buffer_size maximum number of bytes to use for
  1070. * internal buffering (used only for the parsing,
  1071. * specifically the parsing of the keys). A
  1072. * tiny value (256-1024) should be sufficient.
  1073. * Do NOT use a value smaller than 256.
  1074. * @param iter iterator to be called with the parsed data,
  1075. * Must NOT be NULL.
  1076. * @param cls first argument to ikvi
  1077. * @return NULL on error (out of memory, unsupported encoding),
  1078. otherwise a PP handle
  1079. */
  1080. struct MHD_PostProcessor *MHD_create_post_processor (struct MHD_Connection
  1081. *connection,
  1082. size_t buffer_size,
  1083. MHD_PostDataIterator
  1084. iter, void *cls);
  1085. /**
  1086. * Parse and process POST data.
  1087. * Call this function when POST data is available
  1088. * (usually during an MHD_AccessHandlerCallback)
  1089. * with the upload_data and upload_data_size.
  1090. * Whenever possible, this will then cause calls
  1091. * to the MHD_IncrementalKeyValueIterator.
  1092. *
  1093. * @param pp the post processor
  1094. * @param post_data post_data_len bytes of POST data
  1095. * @param post_data_len length of post_data
  1096. * @return MHD_YES on success, MHD_NO on error
  1097. * (out-of-memory, iterator aborted, parse error)
  1098. */
  1099. int
  1100. MHD_post_process (struct MHD_PostProcessor *pp,
  1101. const char *post_data, size_t post_data_len);
  1102. /**
  1103. * Release PostProcessor resources.
  1104. *
  1105. * @param pp the PostProcessor to destroy
  1106. * @return MHD_YES if processing completed nicely,
  1107. * MHD_NO if there were spurious characters / formatting
  1108. * problems; it is common to ignore the return
  1109. * value of this function
  1110. */
  1111. int MHD_destroy_post_processor (struct MHD_PostProcessor *pp);
  1112. /* ********************** generic query functions ********************** */
  1113. /**
  1114. * Information about a connection.
  1115. */
  1116. union MHD_ConnectionInfo
  1117. {
  1118. enum MHD_GNUTLS_CipherAlgorithm cipher_algorithm;
  1119. enum MHD_GNUTLS_Protocol protocol;
  1120. /**
  1121. * Address information for the client.
  1122. */
  1123. struct sockaddr_in * client_addr;
  1124. };
  1125. /**
  1126. * Obtain information about the given connection.
  1127. *
  1128. * @param connection what connection to get information about
  1129. * @param infoType what information is desired?
  1130. * @param ... depends on infoType
  1131. * @return NULL if this information is not available
  1132. * (or if the infoType is unknown)
  1133. */
  1134. const union MHD_ConnectionInfo *MHD_get_connection_info (struct MHD_Connection
  1135. *connection,
  1136. enum
  1137. MHD_ConnectionInfoType
  1138. infoType, ...);
  1139. /**
  1140. * Information about an MHD daemon.
  1141. */
  1142. union MHD_DaemonInfo
  1143. {
  1144. /**
  1145. * Size of the key (unit??)
  1146. */
  1147. size_t key_size;
  1148. /**
  1149. * Size of the mac key (unit??)
  1150. */
  1151. size_t mac_key_size;
  1152. /**
  1153. * Listen socket file descriptor
  1154. */
  1155. int listen_fd;
  1156. };
  1157. /**
  1158. * Obtain information about the given daemon
  1159. * (not fully implemented!).
  1160. *
  1161. * @param daemon what daemon to get information about
  1162. * @param infoType what information is desired?
  1163. * @param ... depends on infoType
  1164. * @return NULL if this information is not available
  1165. * (or if the infoType is unknown)
  1166. */
  1167. const union MHD_DaemonInfo *MHD_get_daemon_info (struct MHD_Daemon *daemon,
  1168. enum MHD_DaemonInfoType
  1169. infoType, ...);
  1170. /**
  1171. * Obtain the version of this library
  1172. *
  1173. * @return static version string, e.g. "0.4.1"
  1174. */
  1175. const char* MHD_get_version(void);
  1176. #if 0 /* keep Emacsens' auto-indent happy */
  1177. {
  1178. #endif
  1179. #ifdef __cplusplus
  1180. }
  1181. #endif
  1182. #endif