libetpan - fdik
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

133 lines
4.1 KiB

11 years ago
11 years ago
11 years ago
9 years ago
9 years ago
9 years ago
9 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
  1. /*
  2. * libEtPan! -- a mail stuff library
  3. *
  4. * Copyright (C) 2001, 2005 - DINH Viet Hoa
  5. * All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions
  9. * are met:
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. * 3. Neither the name of the libEtPan! project nor the names of its
  16. * contributors may be used to endorse or promote products derived
  17. * from this software without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
  20. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  21. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  22. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
  23. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  24. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  25. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  26. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  27. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  28. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  29. * SUCH DAMAGE.
  30. */
  31. /*
  32. * $Id: mailstream_types.h,v 1.17 2011/04/19 12:22:17 hoa Exp $
  33. */
  34. #ifndef MAILSTREAM_TYPES_H
  35. #define MAILSTREAM_TYPES_H
  36. #ifdef __cplusplus
  37. extern "C" {
  38. #endif
  39. #define LIBETPAN_MAILSTREAM_DEBUG
  40. #ifndef LIBETPAN_CONFIG_H
  41. # include <libetpan/libetpan-config.h>
  42. #endif
  43. #include <libetpan/carray.h>
  44. struct _mailstream;
  45. typedef struct _mailstream mailstream;
  46. struct _mailstream_low;
  47. typedef struct _mailstream_low mailstream_low;
  48. enum {
  49. /* Buffer is a log text string. */
  50. MAILSTREAM_LOG_TYPE_INFO_RECEIVED,
  51. MAILSTREAM_LOG_TYPE_INFO_SENT,
  52. /* Buffer is data sent over the network. */
  53. MAILSTREAM_LOG_TYPE_ERROR_PARSE,
  54. MAILSTREAM_LOG_TYPE_ERROR_RECEIVED, /* no data */
  55. MAILSTREAM_LOG_TYPE_ERROR_SENT, /* no data */
  56. /* Buffer is data sent over the network. */
  57. MAILSTREAM_LOG_TYPE_DATA_RECEIVED,
  58. MAILSTREAM_LOG_TYPE_DATA_SENT,
  59. MAILSTREAM_LOG_TYPE_DATA_SENT_PRIVATE, /* data is private, for example a password. */
  60. };
  61. struct _mailstream {
  62. size_t buffer_max_size;
  63. char * write_buffer;
  64. size_t write_buffer_len;
  65. char * read_buffer;
  66. size_t read_buffer_len;
  67. mailstream_low * low;
  68. struct mailstream_cancel * idle;
  69. int idling;
  70. void (* logger)(mailstream * s, int log_type,
  71. const char * str, size_t size, void * logger_context);
  72. void * logger_context;
  73. };
  74. struct mailstream_low_driver {
  75. ssize_t (* mailstream_read)(mailstream_low *, void *, size_t);
  76. ssize_t (* mailstream_write)(mailstream_low *, const void *, size_t);
  77. int (* mailstream_close)(mailstream_low *);
  78. int (* mailstream_get_fd)(mailstream_low *);
  79. void (* mailstream_free)(mailstream_low *);
  80. void (* mailstream_cancel)(mailstream_low *);
  81. struct mailstream_cancel * (* mailstream_get_cancel)(mailstream_low *);
  82. /* Returns an array of MMAPString containing DER data or NULL if it's not a SSL connection */
  83. carray * (* mailstream_get_certificate_chain)(mailstream_low *);
  84. };
  85. typedef struct mailstream_low_driver mailstream_low_driver;
  86. struct _mailstream_low {
  87. void * data;
  88. mailstream_low_driver * driver;
  89. int privacy;
  90. char * identifier;
  91. unsigned long timeout; /* in seconds, 0 will use the global value */
  92. void (* logger)(mailstream_low * s, int log_type,
  93. const char * str, size_t size, void * logger_context);
  94. void * logger_context;
  95. };
  96. typedef void progress_function(size_t current, size_t maximum);
  97. typedef void mailprogress_function(size_t current, size_t maximum, void * context);
  98. enum {
  99. MAILSTREAM_IDLE_ERROR,
  100. MAILSTREAM_IDLE_INTERRUPTED,
  101. MAILSTREAM_IDLE_HASDATA,
  102. MAILSTREAM_IDLE_TIMEOUT,
  103. MAILSTREAM_IDLE_CANCELLED
  104. };
  105. #ifdef __cplusplus
  106. }
  107. #endif
  108. #endif