man-pages/man3/pcre2_serialize_encode.3.html
2021-03-31 01:06:50 +01:00

87 lines
3.6 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of PCRE2_SERIALIZE_ENCODE</TITLE>
</HEAD><BODY>
<H1>PCRE2_SERIALIZE_ENCODE</H1>
Section: C Library Functions (3)<BR>Updated: 27 June 2018<BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
PCRE2 - Perl-compatible regular expressions (revised API)
<A NAME="lbAC">&nbsp;</A>
<H2>SYNOPSIS</H2>
<P>
<B>#include &lt;<A HREF="file:///usr/include/pcre2.h">pcre2.h</A>&gt;</B>
<P>
<PRE>
<B>int32_t pcre2_serialize_encode(const pcre2_code **</B><I>codes</I>,
<B> int32_t </B><I>number_of_codes</I>, uint8_t **<I>serialized_bytes</I>,
<B> PCRE2_SIZE *</B><I>serialized_size</I>, pcre2_general_context *<I>gcontext</I>);
</PRE>
<A NAME="lbAD">&nbsp;</A>
<H2>DESCRIPTION</H2>
<P>
This function encodes a list of compiled patterns into a byte stream that can
be saved on disc or elsewhere. Note that this is not an abstract format like
Java or .NET. Conversion of the byte stream back into usable compiled patterns
can only happen on a host that is running the same version of PCRE2, with the
same code unit width, and the host must also have the same endianness, pointer
width and PCRE2_SIZE type. The arguments for <B>pcre2_serialize_encode()</B>
are:
<P>
<BR>&nbsp;&nbsp;<I>codes</I>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pointer&nbsp;to&nbsp;a&nbsp;vector&nbsp;containing&nbsp;the&nbsp;list
<BR>&nbsp;&nbsp;<I>number_of_codes</I>&nbsp;&nbsp;&nbsp;number&nbsp;of&nbsp;slots&nbsp;in&nbsp;the&nbsp;vector
<BR>&nbsp;&nbsp;<I>serialized_bytes</I>&nbsp;&nbsp;set&nbsp;to&nbsp;point&nbsp;to&nbsp;the&nbsp;serialized&nbsp;byte&nbsp;stream
<BR>&nbsp;&nbsp;<I>serialized_size</I>&nbsp;&nbsp;&nbsp;set&nbsp;to&nbsp;the&nbsp;number&nbsp;of&nbsp;bytes&nbsp;in&nbsp;the&nbsp;byte&nbsp;stream
<BR>&nbsp;&nbsp;<I>gcontext</I>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pointer&nbsp;to&nbsp;a&nbsp;general&nbsp;context&nbsp;or&nbsp;NULL
<P>
The context argument is used to obtain memory for the byte stream. When the
serialized data is no longer needed, it must be freed by calling
<B>pcre2_serialize_free()</B>. The yield of the function is the number of
serialized patterns, or one of the following negative error codes:
<P>
<BR>&nbsp;&nbsp;PCRE2_ERROR_BADDATA&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<I>number_of_codes</I>&nbsp;is&nbsp;zero&nbsp;or&nbsp;less
<BR>&nbsp;&nbsp;PCRE2_ERROR_BADMAGIC&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mismatch&nbsp;of&nbsp;id&nbsp;bytes&nbsp;in&nbsp;one&nbsp;of&nbsp;the&nbsp;patterns
<BR>&nbsp;&nbsp;PCRE2_ERROR_MEMORY&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;memory&nbsp;allocation&nbsp;failed
<BR>&nbsp;&nbsp;PCRE2_ERROR_MIXEDTABLES&nbsp;&nbsp;the&nbsp;patterns&nbsp;do&nbsp;not&nbsp;all&nbsp;use&nbsp;the&nbsp;same&nbsp;tables
<BR>&nbsp;&nbsp;PCRE2_ERROR_NULL&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;an&nbsp;argument&nbsp;other&nbsp;than&nbsp;<I>gcontext</I>&nbsp;is&nbsp;NULL
<P>
PCRE2_ERROR_BADMAGIC means either that a pattern's code has been corrupted, or
that a slot in the vector does not point to a compiled pattern.
<P>
There is a complete description of the PCRE2 native API in the
<B>pcre2api</B>
page and a description of the serialization functions in the
<B>pcre2serialize</B>
page.
<P>
<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT id="1"><A HREF="#lbAB">NAME</A><DD>
<DT id="2"><A HREF="#lbAC">SYNOPSIS</A><DD>
<DT id="3"><A HREF="#lbAD">DESCRIPTION</A><DD>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 00:05:50 GMT, March 31, 2021
</BODY>
</HTML>