
#use wml::openssl-macros area=docs page=BIO_find_type

<title>Documents, BIO_find_type(3)</title>

<h1>BIO_find_type(3)</h1>

#use wml::imp::generic

{:
## What's this? [[s|(<STRONG>[^<].+?)</A>(</STRONG><DD>)|$1$2|sg]]
[[s|<P>\s+<P>|<P>|sg]]
[[s|<P>\s+</|</|sg]]
[[s|<DD>\s*<DT>|<DD>&nbsp;<DT>|sg]]
[[s|<DD>\s*</DL>|<DD>&nbsp;</DL>|sg]]
[[s|\[|&#91;|sg]]
[[s|\]|&#93;|sg]]

<!-- INDEX BEGIN -->

<UL>

	<LI><A HREF="#NAME">NAME</A>
	<LI><A HREF="#SYNOPSIS">SYNOPSIS</A>
	<LI><A HREF="#DESCRIPTION">DESCRIPTION</A>
	<LI><A HREF="#RETURN_VALUES">RETURN VALUES</A>
	<LI><A HREF="#NOTES">NOTES</A>
	<LI><A HREF="#BUGS">BUGS</A>
	<LI><A HREF="#EXAMPLE">EXAMPLE</A>
	<LI><A HREF="#SEE_ALSO">SEE ALSO</A>
</UL>
<!-- INDEX END -->

<HR>
<P>
<HR>
<H1><A NAME="NAME">NAME</A></H1>
<P>
BIO_find_type, BIO_next - BIO chain traversal

</P>
<P>
<HR>
<H1><A NAME="SYNOPSIS">SYNOPSIS</A></H1>
<PRE> #include &lt;openssl/bio.h&gt;
</PRE>
<PRE> BIO *  BIO_find_type(BIO *b,int bio_type);
 BIO *  BIO_next(BIO *b);
</PRE>
<PRE> #define BIO_method_type(b)             ((b)-&gt;method-&gt;type)
</PRE>
<PRE> #define BIO_TYPE_NONE          0
 \#define BIO_TYPE_MEM           (1|0x0400)
 \#define BIO_TYPE_FILE          (2|0x0400)
</PRE>
<PRE> #define BIO_TYPE_FD            (4|0x0400|0x0100)
 \#define BIO_TYPE_SOCKET                (5|0x0400|0x0100)
 \#define BIO_TYPE_NULL          (6|0x0400)
 \#define BIO_TYPE_SSL           (7|0x0200)
 \#define BIO_TYPE_MD            (8|0x0200)
 \#define BIO_TYPE_BUFFER                (9|0x0200)
 \#define BIO_TYPE_CIPHER                (10|0x0200)
 \#define BIO_TYPE_BASE64                (11|0x0200)
 \#define BIO_TYPE_CONNECT       (12|0x0400|0x0100)
 \#define BIO_TYPE_ACCEPT                (13|0x0400|0x0100)
 \#define BIO_TYPE_PROXY_CLIENT  (14|0x0200)
 \#define BIO_TYPE_PROXY_SERVER  (15|0x0200)
 \#define BIO_TYPE_NBIO_TEST     (16|0x0200)
 \#define BIO_TYPE_NULL_FILTER   (17|0x0200)
 \#define BIO_TYPE_BER           (18|0x0200)
 \#define BIO_TYPE_BIO           (19|0x0400)
</PRE>
<PRE> #define BIO_TYPE_DESCRIPTOR    0x0100
 \#define BIO_TYPE_FILTER                0x0200
 \#define BIO_TYPE_SOURCE_SINK   0x0400
</PRE>
<P>
<HR>
<H1><A NAME="DESCRIPTION">DESCRIPTION</A></H1>
<P>
The <CODE>BIO_find_type()</CODE> searches for a BIO of a given type in a
chain, starting at BIO <STRONG>b</STRONG>. If <STRONG>type</STRONG> is a specific type (such as BIO_TYPE_MEM) then a search is made for a BIO
of that type. If <STRONG>type</STRONG> is a general type (such as
<STRONG>BIO_TYPE_SOURCE_SINK</STRONG>) then the next matching BIO of the given general type is searched for.
<CODE>BIO_find_type()</CODE> returns the next matching BIO or NULL if none
is found.

</P>
<P>
Note: not all the <STRONG>BIO_TYPE_*</STRONG> types above have corresponding BIO implementations.

</P>
<P>
<CODE>BIO_next()</CODE> returns the next BIO in a chain. It can be used to
traverse all BIOs in a chain or used in conjunction with
<CODE>BIO_find_type()</CODE> to find all BIOs of a certain type.

</P>
<P>
<CODE>BIO_method_type()</CODE> returns the type of a BIO.

</P>
<P>
<HR>
<H1><A NAME="RETURN_VALUES">RETURN VALUES</A></H1>
<P>
<CODE>BIO_find_type()</CODE> returns a matching BIO or NULL for no match.

</P>
<P>
<CODE>BIO_next()</CODE> returns the next BIO in a chain.

</P>
<P>
<CODE>BIO_method_type()</CODE> returns the type of the BIO <STRONG>b</STRONG>.

</P>
<P>
<HR>
<H1><A NAME="NOTES">NOTES</A></H1>
<P>
<CODE>BIO_next()</CODE> was added to OpenSSL 0.9.6 to provide a 'clean' way
to traverse a BIO chain or find multiple matches using
<CODE>BIO_find_type().</CODE> Previous versions had to use:

</P>
<PRE> next = bio-&gt;next_bio;
</PRE>
<P>
<HR>
<H1><A NAME="BUGS">BUGS</A></H1>
<P>
<CODE>BIO_find_type()</CODE> in OpenSSL 0.9.5a and earlier could not be
safely passed a NULL pointer for the <STRONG>b</STRONG> argument.

</P>
<P>
<HR>
<H1><A NAME="EXAMPLE">EXAMPLE</A></H1>
<P>
Traverse a chain looking for digest BIOs:

</P>
<PRE> BIO *btmp;
 btmp = in_bio; /* in_bio is chain to search through */
</PRE>
<PRE> do {
        btmp = BIO_find_type(btmp, BIO_TYPE_MD);
        if(btmp == NULL) break; /* Not found */
        /* btmp is a digest BIO, do something with it ...*/
        ...
</PRE>
<PRE>        btmp = BIO_next(btmp);
 } while(btmp);
</PRE>
<P>
<HR>
<H1><A NAME="SEE_ALSO">SEE ALSO</A></H1>
<P>
TBA
</P>
:}

