BIO_set_callback.pod 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. =pod
  2. =head1 NAME
  3. BIO_set_callback, BIO_get_callback, BIO_set_callback_arg, BIO_get_callback_arg,
  4. BIO_debug_callback - BIO callback functions
  5. =head1 SYNOPSIS
  6. #include <openssl/bio.h>
  7. #define BIO_set_callback(b,cb) ((b)->callback=(cb))
  8. #define BIO_get_callback(b) ((b)->callback)
  9. #define BIO_set_callback_arg(b,arg) ((b)->cb_arg=(char *)(arg))
  10. #define BIO_get_callback_arg(b) ((b)->cb_arg)
  11. long BIO_debug_callback(BIO *bio,int cmd,const char *argp,int argi,
  12. long argl,long ret);
  13. typedef long (*callback)(BIO *b, int oper, const char *argp,
  14. int argi, long argl, long retvalue);
  15. =head1 DESCRIPTION
  16. BIO_set_callback() and BIO_get_callback() set and retrieve the BIO callback,
  17. they are both macros. The callback is called during most high level BIO
  18. operations. It can be used for debugging purposes to trace operations on
  19. a BIO or to modify its operation.
  20. BIO_set_callback_arg() and BIO_get_callback_arg() are macros which can be
  21. used to set and retrieve an argument for use in the callback.
  22. BIO_debug_callback() is a standard debugging callback which prints
  23. out information relating to each BIO operation. If the callback
  24. argument is set if is interpreted as a BIO to send the information
  25. to, otherwise stderr is used.
  26. callback() is the callback function itself. The meaning of each
  27. argument is described below.
  28. The BIO the callback is attached to is passed in B<b>.
  29. B<oper> is set to the operation being performed. For some operations
  30. the callback is called twice, once before and once after the actual
  31. operation, the latter case has B<oper> or'ed with BIO_CB_RETURN.
  32. The meaning of the arguments B<argp>, B<argi> and B<argl> depends on
  33. the value of B<oper>, that is the operation being performed.
  34. B<retvalue> is the return value that would be returned to the
  35. application if no callback were present. The actual value returned
  36. is the return value of the callback itself. In the case of callbacks
  37. called before the actual BIO operation 1 is placed in retvalue, if
  38. the return value is not positive it will be immediately returned to
  39. the application and the BIO operation will not be performed.
  40. The callback should normally simply return B<retvalue> when it has
  41. finished processing, unless if specifically wishes to modify the
  42. value returned to the application.
  43. =head1 CALLBACK OPERATIONS
  44. =over 4
  45. =item B<BIO_free(b)>
  46. callback(b, BIO_CB_FREE, NULL, 0L, 0L, 1L) is called before the
  47. free operation.
  48. =item B<BIO_read(b, out, outl)>
  49. callback(b, BIO_CB_READ, out, outl, 0L, 1L) is called before
  50. the read and callback(b, BIO_CB_READ|BIO_CB_RETURN, out, outl, 0L, retvalue)
  51. after.
  52. =item B<BIO_write(b, in, inl)>
  53. callback(b, BIO_CB_WRITE, in, inl, 0L, 1L) is called before
  54. the write and callback(b, BIO_CB_WRITE|BIO_CB_RETURN, in, inl, 0L, retvalue)
  55. after.
  56. =item B<BIO_gets(b, out, outl)>
  57. callback(b, BIO_CB_GETS, out, outl, 0L, 1L) is called before
  58. the operation and callback(b, BIO_CB_GETS|BIO_CB_RETURN, out, outl, 0L, retvalue)
  59. after.
  60. =item B<BIO_puts(b, in)>
  61. callback(b, BIO_CB_WRITE, in, 0, 0L, 1L) is called before
  62. the operation and callback(b, BIO_CB_WRITE|BIO_CB_RETURN, in, 0, 0L, retvalue)
  63. after.
  64. =item B<BIO_ctrl(BIO *b, int cmd, long larg, void *parg)>
  65. callback(b,BIO_CB_CTRL,parg,cmd,larg,1L) is called before the call and
  66. callback(b,BIO_CB_CTRL|BIO_CB_RETURN,parg,cmd, larg,ret) after.
  67. =back
  68. =head1 EXAMPLE
  69. The BIO_debug_callback() function is a good example, its source is
  70. in crypto/bio/bio_cb.c
  71. =head1 SEE ALSO
  72. TBA