summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorGraham Leggett <minfrin@apache.org>2021-10-19 14:30:37 +0000
committerGraham Leggett <minfrin@apache.org>2021-10-19 14:30:37 +0000
commitf65813689e5a0061e65eca5d626ebe11d088b87a (patch)
treef9d88d1e5f251da447c3c9404d21aabb8ac28ed7 /include
parent424e4ecebab9e3df6fe25c1507cc4093bc00f715 (diff)
downloadapr-f65813689e5a0061e65eca5d626ebe11d088b87a.tar.gz
apr_brigades: Add apr_brigade_split_boundary(), allowing us to split
brigades on boundaries of arbitrary length. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1894380 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'include')
-rw-r--r--include/apr_buckets.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/include/apr_buckets.h b/include/apr_buckets.h
index 0725c6cd9..065058316 100644
--- a/include/apr_buckets.h
+++ b/include/apr_buckets.h
@@ -53,6 +53,11 @@ extern "C" {
/** default bucket buffer size - 8KB minus room for memory allocator headers */
#define APR_BUCKET_BUFF_SIZE 8000
+/** if passed to apr_brigade_split_boundary(), the string length will
+ * be calculated
+ */
+#define APR_BUCKETS_STRING -1
+
/** Determines how a bucket or brigade should be read */
typedef enum {
APR_BLOCK_READ, /**< block until data becomes available */
@@ -791,6 +796,38 @@ APR_DECLARE(apr_status_t) apr_brigade_split_line(apr_bucket_brigade *bbOut,
__attribute__((nonnull(1,2)));
/**
+ * Split a brigade based on the provided boundary, or metadata buckets,
+ * whichever are encountered first.
+ *
+ * If the boundary is found, all buckets prior to the boundary are passed
+ * into bbOut, and APR_SUCCESS is returned.
+ *
+ * If a metadata bucket is found, or if the boundary is not found within
+ * the limit specified by maxbytes, all prior buckets are passed into bbOut,
+ * and APR_INCOMPLETE is returned.
+ *
+ * Any partial matches at the end of a bucket will be held back
+ * If the boundary is NULL or the empty string, APR_EINVAL is returned.
+ *
+ * If an error is encountered, the APR error code will be returned.
+ *
+ * @param bbOut The bucket brigade that will have the LF line appended to.
+ * @param bbIn The input bucket brigade to search for a LF-line.
+ * @param block The blocking mode to be used to split the line.
+ * @param boundary The boundary string.
+ * @param boundary_len The length of the boundary string. If set to
+ * APR_BUCKETS_STRING, the length will be calculated.
+ * @param maxbytes The maximum bytes to read.
+ */
+APR_DECLARE(apr_status_t) apr_brigade_split_boundary(apr_bucket_brigade *bbOut,
+ apr_bucket_brigade *bbIn,
+ apr_read_type_e block,
+ const char *boundary,
+ apr_size_t boundary_len,
+ apr_off_t maxbytes)
+ __attribute__((nonnull(1,2)));
+
+/**
* Create an iovec of the elements in a bucket_brigade... return number
* of elements used. This is useful for writing to a file or to the
* network efficiently.