libmicrohttpd.vapi 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. [CCode (cheader_filename = "microhttpd.h")]
  2. namespace MHD {
  3. [CCode (cname = "enum MHD_ValueKind", cprefix = "MHD_")]
  4. public enum ValueKind {
  5. RESPONSE_HEADER_KIND,
  6. HEADER_KIND,
  7. COOKIE_KIND,
  8. POSTDATA_KIND,
  9. GET_ARGUMENT_KIND,
  10. FOOTER_KIND
  11. }
  12. [CCode (cname = "enum MHD_RequestTerminationCode", cprefix = "MHD_REQUEST_TERMINATED_")]
  13. public enum RequestTerminationCode {
  14. COMPLETED_OK,
  15. WITH_ERROR,
  16. TIMEOUT_REACHED,
  17. DAEMON_SHUTDOWN,
  18. READ_ERROR,
  19. CLIENT_ABORT
  20. }
  21. [CCode (cname = "enum MHD_ResponseMemoryMode", cprefix = "MHD_")]
  22. public enum ResponseMemoryMode {
  23. RESPMEM_PERSISTENT,
  24. RESPMEM_MUST_FREE,
  25. RESPMEM_MUST_COPY
  26. }
  27. [CCode (cname = "MHD_USE_SELECT_INTERNALLY")]
  28. public const uint USE_SELECT_INTERNALLY;
  29. [CCode (cname = "MHD_USE_THREAD_PER_CONNECTION")]
  30. public const uint USE_THREAD_PER_CONNECTION;
  31. [CCode (cname = "MHD_USE_DEBUG")]
  32. public const uint USE_DEBUG;
  33. [CCode (cname = "MHD_OPTION_END")]
  34. public const int OPTION_END;
  35. [SimpleType]
  36. [CCode (cname = "struct MHD_Connection*")]
  37. public struct Connection {}
  38. [CCode (cname = "int", cprefix = "MHD_")]
  39. public enum Result {
  40. YES = 1,
  41. NO = 0
  42. }
  43. [Compact]
  44. [CCode (cname = "struct MHD_Response", free_function = "MHD_destroy_response")]
  45. public class Response {
  46. [CCode (cname = "MHD_create_response_from_buffer")]
  47. public Response.from_buffer (size_t size, [CCode(array_length=false)] uint8[] buffer, ResponseMemoryMode mode);
  48. [CCode (cname = "MHD_add_response_header")]
  49. public int add_header (string header, string content);
  50. }
  51. [Compact]
  52. [CCode (cname = "struct MHD_Daemon", free_function = "MHD_stop_daemon")]
  53. public class Daemon {
  54. [CCode (cname = "MHD_start_daemon")]
  55. public static Daemon start (uint flags, uint16 port,
  56. AcceptPolicyCallback? apc,
  57. AccessHandlerCallback dh,
  58. ...);
  59. }
  60. [CCode (instance_pos = 0)]
  61. public delegate int AcceptPolicyCallback (void* cls, void* addr, uint addrlen);
  62. [CCode (instance_pos = 0)]
  63. public delegate int AccessHandlerCallback (Connection connection,
  64. string? url, string? method, string? version,
  65. string? upload_data, [CCode(array_length=false)] size_t* upload_data_size,
  66. void** con_cls);
  67. [CCode (cname = "MHD_queue_response")]
  68. public int queue_response (Connection connection, uint status_code, Response response);
  69. [CCode (cname = "MHD_lookup_connection_value")]
  70. public unowned string? lookup_connection_value (Connection connection, ValueKind kind, string key);
  71. }