BIO_push.pod 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. =pod
  2. =head1 NAME
  3. BIO_push, BIO_pop, BIO_set_next - add and remove BIOs from a chain
  4. =head1 SYNOPSIS
  5. #include <openssl/bio.h>
  6. BIO *BIO_push(BIO *b, BIO *next);
  7. BIO *BIO_pop(BIO *b);
  8. void BIO_set_next(BIO *b, BIO *next);
  9. =head1 DESCRIPTION
  10. BIO_push() pushes I<b> on I<next>.
  11. If I<b> is NULL the function does nothing and returns I<next>.
  12. Otherwise it prepends I<b>, which may be a single BIO or a chain of BIOs,
  13. to I<next> (unless I<next> is NULL).
  14. It then makes a control call on I<b> and returns I<b>.
  15. BIO_pop() removes the BIO I<b> from any chain is is part of.
  16. If I<b> is NULL the function does nothing and returns NULL.
  17. Otherwise it makes a control call on I<b> and
  18. returns the next BIO in the chain, or NULL if there is no next BIO.
  19. The removed BIO becomes a single BIO with no association with
  20. the original chain, it can thus be freed or be made part of a different chain.
  21. BIO_set_next() replaces the existing next BIO in a chain with the BIO pointed to
  22. by I<next>. The new chain may include some of the same BIOs from the old chain
  23. or it may be completely different.
  24. =head1 NOTES
  25. The names of these functions are perhaps a little misleading. BIO_push()
  26. joins two BIO chains whereas BIO_pop() deletes a single BIO from a chain,
  27. the deleted BIO does not need to be at the end of a chain.
  28. The process of calling BIO_push() and BIO_pop() on a BIO may have additional
  29. consequences (a control call is made to the affected BIOs).
  30. Any effects will be noted in the descriptions of individual BIOs.
  31. =head1 RETURN VALUES
  32. BIO_push() returns the head of the chain,
  33. which usually is I<b>, or I<next> if I<b> is NULL.
  34. BIO_pop() returns the next BIO in the chain,
  35. or NULL if there is no next BIO.
  36. =head1 EXAMPLES
  37. For these examples suppose I<md1> and I<md2> are digest BIOs,
  38. I<b64> is a base64 BIO and I<f> is a file BIO.
  39. If the call:
  40. BIO_push(b64, f);
  41. is made then the new chain will be I<b64-f>. After making the calls
  42. BIO_push(md2, b64);
  43. BIO_push(md1, md2);
  44. the new chain is I<md1-md2-b64-f>. Data written to I<md1> will be digested
  45. by I<md1> and I<md2>, base64 encoded, and finally written to I<f>.
  46. It should be noted that reading causes data to pass in the reverse
  47. direction, that is data is read from I<f>, base64 decoded,
  48. and digested by I<md2> and then I<md1>.
  49. The call:
  50. BIO_pop(md2);
  51. will return I<b64> and the new chain will be I<md1-b64-f>.
  52. Data can be written to and read from I<md1> as before,
  53. except that I<md2> will no more be applied.
  54. =head1 SEE ALSO
  55. L<bio(7)>
  56. =head1 HISTORY
  57. The BIO_set_next() function was added in OpenSSL 1.1.0.
  58. =head1 COPYRIGHT
  59. Copyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved.
  60. Licensed under the Apache License 2.0 (the "License"). You may not use
  61. this file except in compliance with the License. You can obtain a copy
  62. in the file LICENSE in the source distribution or at
  63. L<https://www.openssl.org/source/license.html>.
  64. =cut