nghttp2_callbacks.c 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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_recv_callback(
  42. nghttp2_session_callbacks *cbs, nghttp2_recv_callback recv_callback) {
  43. cbs->recv_callback = recv_callback;
  44. }
  45. void nghttp2_session_callbacks_set_on_frame_recv_callback(
  46. nghttp2_session_callbacks *cbs,
  47. nghttp2_on_frame_recv_callback on_frame_recv_callback) {
  48. cbs->on_frame_recv_callback = on_frame_recv_callback;
  49. }
  50. void nghttp2_session_callbacks_set_on_invalid_frame_recv_callback(
  51. nghttp2_session_callbacks *cbs,
  52. nghttp2_on_invalid_frame_recv_callback on_invalid_frame_recv_callback) {
  53. cbs->on_invalid_frame_recv_callback = on_invalid_frame_recv_callback;
  54. }
  55. void nghttp2_session_callbacks_set_on_data_chunk_recv_callback(
  56. nghttp2_session_callbacks *cbs,
  57. nghttp2_on_data_chunk_recv_callback on_data_chunk_recv_callback) {
  58. cbs->on_data_chunk_recv_callback = on_data_chunk_recv_callback;
  59. }
  60. void nghttp2_session_callbacks_set_before_frame_send_callback(
  61. nghttp2_session_callbacks *cbs,
  62. nghttp2_before_frame_send_callback before_frame_send_callback) {
  63. cbs->before_frame_send_callback = before_frame_send_callback;
  64. }
  65. void nghttp2_session_callbacks_set_on_frame_send_callback(
  66. nghttp2_session_callbacks *cbs,
  67. nghttp2_on_frame_send_callback on_frame_send_callback) {
  68. cbs->on_frame_send_callback = on_frame_send_callback;
  69. }
  70. void nghttp2_session_callbacks_set_on_frame_not_send_callback(
  71. nghttp2_session_callbacks *cbs,
  72. nghttp2_on_frame_not_send_callback on_frame_not_send_callback) {
  73. cbs->on_frame_not_send_callback = on_frame_not_send_callback;
  74. }
  75. void nghttp2_session_callbacks_set_on_stream_close_callback(
  76. nghttp2_session_callbacks *cbs,
  77. nghttp2_on_stream_close_callback on_stream_close_callback) {
  78. cbs->on_stream_close_callback = on_stream_close_callback;
  79. }
  80. void nghttp2_session_callbacks_set_on_begin_headers_callback(
  81. nghttp2_session_callbacks *cbs,
  82. nghttp2_on_begin_headers_callback on_begin_headers_callback) {
  83. cbs->on_begin_headers_callback = on_begin_headers_callback;
  84. }
  85. void nghttp2_session_callbacks_set_on_header_callback(
  86. nghttp2_session_callbacks *cbs,
  87. nghttp2_on_header_callback on_header_callback) {
  88. cbs->on_header_callback = on_header_callback;
  89. }
  90. void nghttp2_session_callbacks_set_on_header_callback2(
  91. nghttp2_session_callbacks *cbs,
  92. nghttp2_on_header_callback2 on_header_callback2) {
  93. cbs->on_header_callback2 = on_header_callback2;
  94. }
  95. void nghttp2_session_callbacks_set_on_invalid_header_callback(
  96. nghttp2_session_callbacks *cbs,
  97. nghttp2_on_invalid_header_callback on_invalid_header_callback) {
  98. cbs->on_invalid_header_callback = on_invalid_header_callback;
  99. }
  100. void nghttp2_session_callbacks_set_on_invalid_header_callback2(
  101. nghttp2_session_callbacks *cbs,
  102. nghttp2_on_invalid_header_callback2 on_invalid_header_callback2) {
  103. cbs->on_invalid_header_callback2 = on_invalid_header_callback2;
  104. }
  105. void nghttp2_session_callbacks_set_select_padding_callback(
  106. nghttp2_session_callbacks *cbs,
  107. nghttp2_select_padding_callback select_padding_callback) {
  108. cbs->select_padding_callback = select_padding_callback;
  109. }
  110. void nghttp2_session_callbacks_set_data_source_read_length_callback(
  111. nghttp2_session_callbacks *cbs,
  112. nghttp2_data_source_read_length_callback data_source_read_length_callback) {
  113. cbs->read_length_callback = data_source_read_length_callback;
  114. }
  115. void nghttp2_session_callbacks_set_on_begin_frame_callback(
  116. nghttp2_session_callbacks *cbs,
  117. nghttp2_on_begin_frame_callback on_begin_frame_callback) {
  118. cbs->on_begin_frame_callback = on_begin_frame_callback;
  119. }
  120. void nghttp2_session_callbacks_set_send_data_callback(
  121. nghttp2_session_callbacks *cbs,
  122. nghttp2_send_data_callback send_data_callback) {
  123. cbs->send_data_callback = send_data_callback;
  124. }
  125. void nghttp2_session_callbacks_set_pack_extension_callback(
  126. nghttp2_session_callbacks *cbs,
  127. nghttp2_pack_extension_callback pack_extension_callback) {
  128. cbs->pack_extension_callback = pack_extension_callback;
  129. }
  130. void nghttp2_session_callbacks_set_unpack_extension_callback(
  131. nghttp2_session_callbacks *cbs,
  132. nghttp2_unpack_extension_callback unpack_extension_callback) {
  133. cbs->unpack_extension_callback = unpack_extension_callback;
  134. }
  135. void nghttp2_session_callbacks_set_on_extension_chunk_recv_callback(
  136. nghttp2_session_callbacks *cbs,
  137. nghttp2_on_extension_chunk_recv_callback on_extension_chunk_recv_callback) {
  138. cbs->on_extension_chunk_recv_callback = on_extension_chunk_recv_callback;
  139. }
  140. void nghttp2_session_callbacks_set_error_callback(
  141. nghttp2_session_callbacks *cbs, nghttp2_error_callback error_callback) {
  142. cbs->error_callback = error_callback;
  143. }
  144. void nghttp2_session_callbacks_set_error_callback2(
  145. nghttp2_session_callbacks *cbs, nghttp2_error_callback2 error_callback2) {
  146. cbs->error_callback2 = error_callback2;
  147. }