bufferevent_struct.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*
  2. * Copyright (c) 2000-2007 Niels Provos <provos@citi.umich.edu>
  3. * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions
  7. * are met:
  8. * 1. Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * 2. Redistributions in binary form must reproduce the above copyright
  11. * notice, this list of conditions and the following disclaimer in the
  12. * documentation and/or other materials provided with the distribution.
  13. * 3. The name of the author may not be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  17. * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  18. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  19. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  20. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  21. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  22. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  23. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  25. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. #ifndef EVENT2_BUFFEREVENT_STRUCT_H_INCLUDED_
  28. #define EVENT2_BUFFEREVENT_STRUCT_H_INCLUDED_
  29. /** @file event2/bufferevent_struct.h
  30. Data structures for bufferevents. Using these structures may hurt forward
  31. compatibility with later versions of Libevent: be careful!
  32. @deprecated Use of bufferevent_struct.h is completely deprecated; these
  33. structures are only exposed for backward compatibility with programs
  34. written before Libevent 2.0 that used them.
  35. */
  36. #ifdef __cplusplus
  37. extern "C" {
  38. #endif
  39. #include <event2/event-config.h>
  40. #ifdef EVENT__HAVE_SYS_TYPES_H
  41. #include <sys/types.h>
  42. #endif
  43. #ifdef EVENT__HAVE_SYS_TIME_H
  44. #include <sys/time.h>
  45. #endif
  46. /* For int types. */
  47. #include <event2/util.h>
  48. /* For struct event */
  49. #include <event2/event_struct.h>
  50. struct event_watermark {
  51. size_t low;
  52. size_t high;
  53. };
  54. /**
  55. Shared implementation of a bufferevent.
  56. This type is exposed only because it was exposed in previous versions,
  57. and some people's code may rely on manipulating it. Otherwise, you
  58. should really not rely on the layout, size, or contents of this structure:
  59. it is fairly volatile, and WILL change in future versions of the code.
  60. **/
  61. struct bufferevent {
  62. /** Event base for which this bufferevent was created. */
  63. struct event_base *ev_base;
  64. /** Pointer to a table of function pointers to set up how this
  65. bufferevent behaves. */
  66. const struct bufferevent_ops *be_ops;
  67. /** A read event that triggers when a timeout has happened or a socket
  68. is ready to read data. Only used by some subtypes of
  69. bufferevent. */
  70. struct event ev_read;
  71. /** A write event that triggers when a timeout has happened or a socket
  72. is ready to write data. Only used by some subtypes of
  73. bufferevent. */
  74. struct event ev_write;
  75. /** An input buffer. Only the bufferevent is allowed to add data to
  76. this buffer, though the user is allowed to drain it. */
  77. struct evbuffer *input;
  78. /** An input buffer. Only the bufferevent is allowed to drain data
  79. from this buffer, though the user is allowed to add it. */
  80. struct evbuffer *output;
  81. struct event_watermark wm_read;
  82. struct event_watermark wm_write;
  83. bufferevent_data_cb readcb;
  84. bufferevent_data_cb writecb;
  85. /* This should be called 'eventcb', but renaming it would break
  86. * backward compatibility */
  87. bufferevent_event_cb errorcb;
  88. void *cbarg;
  89. struct timeval timeout_read;
  90. struct timeval timeout_write;
  91. /** Events that are currently enabled: currently EV_READ and EV_WRITE
  92. are supported. */
  93. short enabled;
  94. };
  95. #ifdef __cplusplus
  96. }
  97. #endif
  98. #endif /* EVENT2_BUFFEREVENT_STRUCT_H_INCLUDED_ */