nghttp2_callbacks.c 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. /*
  2. * nghttp2 - HTTP/2 C Library
  3. *
  4. * Copyright (c) 2014 Tatsuhiro Tsujikawa
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining
  7. * a copy of this software and associated documentation files (the
  8. * "Software"), to deal in the Software without restriction, including
  9. * without limitation the rights to use, copy, modify, merge, publish,
  10. * distribute, sublicense, and/or sell copies of the Software, and to
  11. * permit persons to whom the Software is furnished to do so, subject to
  12. * the following conditions:
  13. *
  14. * The above copyright notice and this permission notice shall be
  15. * included in all copies or substantial portions of the Software.
  16. *
  17. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  18. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  19. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  20. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  21. * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  22. * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  23. * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  24. */
  25. #include "nghttp2_callbacks.h"
  26. #include <stdlib.h>
  27. int nghttp2_session_callbacks_new(nghttp2_session_callbacks **callbacks_ptr) {
  28. *callbacks_ptr = calloc(1, sizeof(nghttp2_session_callbacks));
  29. if (*callbacks_ptr == NULL) {
  30. return NGHTTP2_ERR_NOMEM;
  31. }
  32. return 0;
  33. }
  34. void nghttp2_session_callbacks_del(nghttp2_session_callbacks *callbacks) {
  35. free(callbacks);
  36. }
  37. void nghttp2_session_callbacks_set_send_callback(
  38. nghttp2_session_callbacks *cbs, nghttp2_send_callback send_callback) {
  39. cbs->send_callback = send_callback;
  40. }
  41. void nghttp2_session_callbacks_set_send_callback2(
  42. nghttp2_session_callbacks *cbs, nghttp2_send_callback2 send_callback) {
  43. cbs->send_callback2 = send_callback;
  44. }
  45. void nghttp2_session_callbacks_set_recv_callback(
  46. nghttp2_session_callbacks *cbs, nghttp2_recv_callback recv_callback) {
  47. cbs->recv_callback = recv_callback;
  48. }
  49. void nghttp2_session_callbacks_set_recv_callback2(
  50. nghttp2_session_callbacks *cbs, nghttp2_recv_callback2 recv_callback) {
  51. cbs->recv_callback2 = recv_callback;
  52. }
  53. void nghttp2_session_callbacks_set_on_frame_recv_callback(
  54. nghttp2_session_callbacks *cbs,
  55. nghttp2_on_frame_recv_callback on_frame_recv_callback) {
  56. cbs->on_frame_recv_callback = on_frame_recv_callback;
  57. }
  58. void nghttp2_session_callbacks_set_on_invalid_frame_recv_callback(
  59. nghttp2_session_callbacks *cbs,
  60. nghttp2_on_invalid_frame_recv_callback on_invalid_frame_recv_callback) {
  61. cbs->on_invalid_frame_recv_callback = on_invalid_frame_recv_callback;
  62. }
  63. void nghttp2_session_callbacks_set_on_data_chunk_recv_callback(
  64. nghttp2_session_callbacks *cbs,
  65. nghttp2_on_data_chunk_recv_callback on_data_chunk_recv_callback) {
  66. cbs->on_data_chunk_recv_callback = on_data_chunk_recv_callback;
  67. }
  68. void nghttp2_session_callbacks_set_before_frame_send_callback(
  69. nghttp2_session_callbacks *cbs,
  70. nghttp2_before_frame_send_callback before_frame_send_callback) {
  71. cbs->before_frame_send_callback = before_frame_send_callback;
  72. }
  73. void nghttp2_session_callbacks_set_on_frame_send_callback(
  74. nghttp2_session_callbacks *cbs,
  75. nghttp2_on_frame_send_callback on_frame_send_callback) {
  76. cbs->on_frame_send_callback = on_frame_send_callback;
  77. }
  78. void nghttp2_session_callbacks_set_on_frame_not_send_callback(
  79. nghttp2_session_callbacks *cbs,
  80. nghttp2_on_frame_not_send_callback on_frame_not_send_callback) {
  81. cbs->on_frame_not_send_callback = on_frame_not_send_callback;
  82. }
  83. void nghttp2_session_callbacks_set_on_stream_close_callback(
  84. nghttp2_session_callbacks *cbs,
  85. nghttp2_on_stream_close_callback on_stream_close_callback) {
  86. cbs->on_stream_close_callback = on_stream_close_callback;
  87. }
  88. void nghttp2_session_callbacks_set_on_begin_headers_callback(
  89. nghttp2_session_callbacks *cbs,
  90. nghttp2_on_begin_headers_callback on_begin_headers_callback) {
  91. cbs->on_begin_headers_callback = on_begin_headers_callback;
  92. }
  93. void nghttp2_session_callbacks_set_on_header_callback(
  94. nghttp2_session_callbacks *cbs,
  95. nghttp2_on_header_callback on_header_callback) {
  96. cbs->on_header_callback = on_header_callback;
  97. }
  98. void nghttp2_session_callbacks_set_on_header_callback2(
  99. nghttp2_session_callbacks *cbs,
  100. nghttp2_on_header_callback2 on_header_callback2) {
  101. cbs->on_header_callback2 = on_header_callback2;
  102. }
  103. void nghttp2_session_callbacks_set_on_invalid_header_callback(
  104. nghttp2_session_callbacks *cbs,
  105. nghttp2_on_invalid_header_callback on_invalid_header_callback) {
  106. cbs->on_invalid_header_callback = on_invalid_header_callback;
  107. }
  108. void nghttp2_session_callbacks_set_on_invalid_header_callback2(
  109. nghttp2_session_callbacks *cbs,
  110. nghttp2_on_invalid_header_callback2 on_invalid_header_callback2) {
  111. cbs->on_invalid_header_callback2 = on_invalid_header_callback2;
  112. }
  113. void nghttp2_session_callbacks_set_select_padding_callback(
  114. nghttp2_session_callbacks *cbs,
  115. nghttp2_select_padding_callback select_padding_callback) {
  116. cbs->select_padding_callback = select_padding_callback;
  117. }
  118. void nghttp2_session_callbacks_set_select_padding_callback2(
  119. nghttp2_session_callbacks *cbs,
  120. nghttp2_select_padding_callback2 select_padding_callback) {
  121. cbs->select_padding_callback2 = select_padding_callback;
  122. }
  123. void nghttp2_session_callbacks_set_data_source_read_length_callback(
  124. nghttp2_session_callbacks *cbs,
  125. nghttp2_data_source_read_length_callback data_source_read_length_callback) {
  126. cbs->read_length_callback = data_source_read_length_callback;
  127. }
  128. void nghttp2_session_callbacks_set_data_source_read_length_callback2(
  129. nghttp2_session_callbacks *cbs, nghttp2_data_source_read_length_callback2
  130. data_source_read_length_callback) {
  131. cbs->read_length_callback2 = data_source_read_length_callback;
  132. }
  133. void nghttp2_session_callbacks_set_on_begin_frame_callback(
  134. nghttp2_session_callbacks *cbs,
  135. nghttp2_on_begin_frame_callback on_begin_frame_callback) {
  136. cbs->on_begin_frame_callback = on_begin_frame_callback;
  137. }
  138. void nghttp2_session_callbacks_set_send_data_callback(
  139. nghttp2_session_callbacks *cbs,
  140. nghttp2_send_data_callback send_data_callback) {
  141. cbs->send_data_callback = send_data_callback;
  142. }
  143. void nghttp2_session_callbacks_set_pack_extension_callback(
  144. nghttp2_session_callbacks *cbs,
  145. nghttp2_pack_extension_callback pack_extension_callback) {
  146. cbs->pack_extension_callback = pack_extension_callback;
  147. }
  148. void nghttp2_session_callbacks_set_pack_extension_callback2(
  149. nghttp2_session_callbacks *cbs,
  150. nghttp2_pack_extension_callback2 pack_extension_callback) {
  151. cbs->pack_extension_callback2 = pack_extension_callback;
  152. }
  153. void nghttp2_session_callbacks_set_unpack_extension_callback(
  154. nghttp2_session_callbacks *cbs,
  155. nghttp2_unpack_extension_callback unpack_extension_callback) {
  156. cbs->unpack_extension_callback = unpack_extension_callback;
  157. }
  158. void nghttp2_session_callbacks_set_on_extension_chunk_recv_callback(
  159. nghttp2_session_callbacks *cbs,
  160. nghttp2_on_extension_chunk_recv_callback on_extension_chunk_recv_callback) {
  161. cbs->on_extension_chunk_recv_callback = on_extension_chunk_recv_callback;
  162. }
  163. void nghttp2_session_callbacks_set_error_callback(
  164. nghttp2_session_callbacks *cbs, nghttp2_error_callback error_callback) {
  165. cbs->error_callback = error_callback;
  166. }
  167. void nghttp2_session_callbacks_set_error_callback2(
  168. nghttp2_session_callbacks *cbs, nghttp2_error_callback2 error_callback2) {
  169. cbs->error_callback2 = error_callback2;
  170. }