Blame doc/pcre2_serialize_encode.3

Packit 504f36
.TH PCRE2_SERIALIZE_ENCODE 3 "27 June 2018" "PCRE2 10.32"
Packit 504f36
.SH NAME
Packit 504f36
PCRE2 - Perl-compatible regular expressions (revised API)
Packit 504f36
.SH SYNOPSIS
Packit 504f36
.rs
Packit 504f36
.sp
Packit 504f36
.B #include <pcre2.h>
Packit 504f36
.PP
Packit 504f36
.nf
Packit 504f36
.B int32_t pcre2_serialize_encode(const pcre2_code **\fIcodes\fP,
Packit 504f36
.B "  int32_t \fInumber_of_codes\fP, uint8_t **\fIserialized_bytes\fP,"
Packit 504f36
.B "  PCRE2_SIZE *\fIserialized_size\fP, pcre2_general_context *\fIgcontext\fP);"
Packit 504f36
.fi
Packit 504f36
.
Packit 504f36
.SH DESCRIPTION
Packit 504f36
.rs
Packit 504f36
.sp
Packit 504f36
This function encodes a list of compiled patterns into a byte stream that can
Packit 504f36
be saved on disc or elsewhere. Note that this is not an abstract format like
Packit 504f36
Java or .NET. Conversion of the byte stream back into usable compiled patterns
Packit 504f36
can only happen on a host that is running the same version of PCRE2, with the
Packit 504f36
same code unit width, and the host must also have the same endianness, pointer
Packit 504f36
width and PCRE2_SIZE type. The arguments for \fBpcre2_serialize_encode()\fP
Packit 504f36
are:
Packit 504f36
.sp
Packit 504f36
  \fIcodes\fP             pointer to a vector containing the list
Packit 504f36
  \fInumber_of_codes\fP   number of slots in the vector
Packit 504f36
  \fIserialized_bytes\fP  set to point to the serialized byte stream
Packit 504f36
  \fIserialized_size\fP   set to the number of bytes in the byte stream
Packit 504f36
  \fIgcontext\fP          pointer to a general context or NULL
Packit 504f36
.sp
Packit 504f36
The context argument is used to obtain memory for the byte stream. When the
Packit 504f36
serialized data is no longer needed, it must be freed by calling
Packit 504f36
\fBpcre2_serialize_free()\fP. The yield of the function is the number of
Packit 504f36
serialized patterns, or one of the following negative error codes:
Packit 504f36
.sp
Packit 504f36
  PCRE2_ERROR_BADDATA      \fInumber_of_codes\fP is zero or less
Packit 504f36
  PCRE2_ERROR_BADMAGIC     mismatch of id bytes in one of the patterns
Packit 504f36
  PCRE2_ERROR_MEMORY       memory allocation failed
Packit 504f36
  PCRE2_ERROR_MIXEDTABLES  the patterns do not all use the same tables
Packit 504f36
  PCRE2_ERROR_NULL         an argument other than \fIgcontext\fP is NULL
Packit 504f36
.sp
Packit 504f36
PCRE2_ERROR_BADMAGIC means either that a pattern's code has been corrupted, or
Packit 504f36
that a slot in the vector does not point to a compiled pattern.
Packit 504f36
.P
Packit 504f36
There is a complete description of the PCRE2 native API in the
Packit 504f36
.\" HREF
Packit 504f36
\fBpcre2api\fP
Packit 504f36
.\"
Packit 504f36
page and a description of the serialization functions in the
Packit 504f36
.\" HREF
Packit 504f36
\fBpcre2serialize\fP
Packit 504f36
.\"
Packit 504f36
page.