![]() |
![]()
| ![]() |
![]()
NAME
SYNOPSIS
BIO *
BIO *
void
DESCRIPTIONBIOs can be joined together to form chains. A chain normally consists of one or more filter BIOs and one source/sink BIO at the end. Data read from or written to the first BIO traverses the chain to the end. Every BIO is a member of exactly one chain. It is either at the beginning of its chain or there is exactly one preceding BIO. It is either at the end of its chain or there is exactly one following BIO. If there is neither a preceding nor a following BIO, it can be regarded as a chain with one member. Every chain has exactly one beginning and exactly one end.
In LibreSSL, if new_tail is
not at the beginning of its chain, the head of that chain up to but not
including new_tail is cut off and becomes a separate
chain. For portability, it is best to make sure that
new_tail is at the beginning of its chain before
calling
In LibreSSL, if new_tail is not at the beginning of its chain, the head of that chain up to but not including new_tail is cut off and becomes a separate chain, and if b is not at the end of its chain, the tail of that chain starting after b is cut off and becomes a separate chain. For portability, it is best to make sure that
b is at the end of its chain and that
new_tail is at the beginning of its chain before
calling
In LibreSSL, the only built-in BIO type for which
BIO_ctrl(3)
calls with an argument of RETURN VALUES
EXAMPLESFor these examples suppose md1 and md2 are digest BIOs, b64 is a Base64 BIO and f is a file BIO (see BIO_f_md(3), BIO_f_base64(3), and BIO_s_file(3), respectively). If the call BIO_push(b64, f); is made then the new chain will be b64-f. After making the calls BIO_push(md2, b64); BIO_push(md1, md2); the new chain is md1-md2-b64-f. Data written to md1 will be digested by md1 and md2, Base64-encoded and written to f. It should be noted that reading causes data to pass in the reverse direction. That is, data is read from f, Base64-decoded and digested by md1 and md2. If this call is made: BIO_pop(md2); The call will return b64 and the new chain will be md1-b64-f; data can be written to md1 as before. SEE ALSOHISTORY
CAVEATSCreating a cyclic chain results in undefined behavior. For example, infinite recursion or infinite loops may ensue. If it is unknown whether b and new_tail are already members of the same chain and whether joining them would create a cycle, the calling code can use the following safe idiom: BIO *btest; for (btest = new_tail; btest != NULL; btest = BIO_next(btest)) if (btest == b) /* Bail out because this would create a cycle. */ BIO_push(b, new_tail); /* This is now safe. */ The same idiom can be used with
Often, the safe idiom is not needed because it is already known that b and new_tail are not members of the same chain, for example when b or new_tail was created right before.
|