Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id E49B0200D6F for ; Mon, 1 Jan 2018 15:22:05 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id D9661160C25; Mon, 1 Jan 2018 14:22:05 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id F419A160C05 for ; Mon, 1 Jan 2018 15:22:04 +0100 (CET) Received: (qmail 91952 invoked by uid 500); 1 Jan 2018 14:21:58 -0000 Mailing-List: contact users-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: users@httpd.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list users@httpd.apache.org Received: (qmail 91942 invoked by uid 99); 1 Jan 2018 14:21:58 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Jan 2018 14:21:58 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 0C9F8C0740 for ; Mon, 1 Jan 2018 14:21:58 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.002 X-Spam-Level: X-Spam-Status: No, score=-0.002 tagged_above=-999 required=6.31 tests=[SPF_HELO_PASS=-0.001, SPF_PASS=-0.001] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id MpF4eaRLk1Mr for ; Mon, 1 Jan 2018 14:21:57 +0000 (UTC) Received: from explicit.technology (ns3012277.ip-5-39-95.eu [5.39.95.171]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id B0C645F27E for ; Mon, 1 Jan 2018 14:21:56 +0000 (UTC) Received: from [192.168.2.117] (unknown [92.84.24.41]) by explicit.technology (Postfix) with ESMTPSA id DDFDF16205BA for ; Mon, 1 Jan 2018 14:45:42 +0000 (UTC) To: users@httpd.apache.org References: <21fe14d1-aef3-5e48-0659-ecca645e7391@gikaku.com> From: Simon Walter Message-ID: <3f301b2d-e737-139b-1a0c-118c24937049@gikaku.com> Date: Mon, 1 Jan 2018 23:21:53 +0900 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------ECFF7900BBF6B58BD1AA52C8" Content-Language: en-US Subject: Re: [users@httpd] apr_bucket_split data remains archived-at: Mon, 01 Jan 2018 14:22:06 -0000 --------------ECFF7900BBF6B58BD1AA52C8 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit On 01/01/2018 10:44 PM, Eric Covener wrote: > On Mon, Jan 1, 2018 at 8:37 AM, Simon Walter wrote: >> I am interested in how apr_bucket_split(e, point) works. >> >> It seems that after splitting e, it still contains everything after >> point. Only when flattened is this data "removed" from e. >> >> If that is correct, then is it also correct to assume that I would need >> to use apr_bucket_read with snprintf and make a copy of the data in >> order to display it accurately? >> >> Is there another way to show the contents of buckets after they've been >> split/manipulated? >> >> I need to flatten the brigade (or flush it to a socket? that's a >> different question), but for debugging purposes, to check my logic, I am >> trying to see the contents of individual buckets. >> > > I don't think that's right. For example mod_substitute does this to > remove the pattern that matched from the input: > > #define SEDRMPATBCKT(b, offset, tmp_b, patlen) do { \ > apr_bucket_split(b, offset); \ > tmp_b = APR_BUCKET_NEXT(b); \ > apr_bucket_split(tmp_b, patlen); \ > b = APR_BUCKET_NEXT(tmp_b); \ > apr_bucket_delete(tmp_b); \ > } while (0) > > > The dump_brigade macro in .gdbinit in the source tree will help here. > You can also use the code there to add your own trace. > I see such code as the example you gave in various places. However, this bit of code (attached) shows me that I cannot simply printf the data. Again, I am probably doing something wrong. --------------ECFF7900BBF6B58BD1AA52C8 Content-Type: text/x-csrc; name="loop.c" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="loop.c" #include #include #include int main(int ArgCount, char * Arg[]) { apr_initialize(); atexit(apr_terminate); =20 apr_pool_t * Pool; apr_pool_create(&Pool, NULL); apr_bucket_alloc_t * BucketAlloc =3D apr_bucket_alloc_create(Pool); apr_bucket_brigade * Brigade =3D apr_brigade_create(Pool, BucketAlloc= ); =20 char * String0 =3D "_ASCII_String0_!"; apr_bucket * Bucket0 =3D apr_bucket_immortal_create(String0, strlen(S= tring0), BucketAlloc); APR_BRIGADE_INSERT_TAIL(Brigade, Bucket0); =20 char * String1 =3D "_ASCII_String1_!"; apr_bucket * Bucket1 =3D apr_bucket_immortal_create(String1, strlen(S= tring1), BucketAlloc); APR_BRIGADE_INSERT_TAIL(Brigade, Bucket1); =20 char * String2 =3D "_ASCII_String2_!"; apr_bucket * Bucket2 =3D apr_bucket_immortal_create(String2, strlen(S= tring2), BucketAlloc); APR_BRIGADE_INSERT_TAIL(Brigade, Bucket2); =20 char * String3 =3D "_ASCII_String3_!"; apr_bucket * Bucket3 =3D apr_bucket_immortal_create(String3, strlen(S= tring3), BucketAlloc); APR_BRIGADE_INSERT_TAIL(Brigade, Bucket3); =20 apr_bucket * Index; apr_bucket * NextBucket; apr_bucket * PrevBucket; =20 const char * TestBuffer =3D NULL; int Marker =3D 0; size_t Length =3D 0; =20 for (Index =3D APR_BRIGADE_FIRST(Brigade); Index !=3D APR_BRIGADE_SEN= TINEL(Brigade); Index =3D APR_BUCKET_NEXT(Index)) { printf("Marker: %d\n", Marker); if (Marker =3D=3D 1) { char * String4 =3D "_ASCII_String4_!"; apr_bucket * Bucket4 =3D apr_bucket_immortal_create(String4, = strlen(String4), BucketAlloc); =20 apr_bucket_split(Index, 1); APR_BUCKET_INSERT_AFTER(Index, Bucket4); } =20 TestBuffer =3D NULL; Length =3D 0; if (apr_bucket_read(Index, &TestBuffer, &Length, APR_BLOCK_READ) = =3D=3D APR_SUCCESS) { printf("CurrBucket: %s\n", TestBuffer); printf("Length: %zu\n", Length); } =20 NextBucket =3D APR_BUCKET_NEXT(Index); TestBuffer =3D NULL; Length =3D 0; if (NextBucket !=3D APR_BRIGADE_SENTINEL(Brigade) && apr_bucket_read(NextBucket, &TestBuffer, &Length, APR_BLOCK_R= EAD) =3D=3D APR_SUCCESS) { printf("NextBucket: %s\n", TestBuffer); printf("Length: %zu\n", Length); } =20 PrevBucket =3D APR_BUCKET_PREV(Index); TestBuffer =3D NULL; if (PrevBucket !=3D APR_BRIGADE_SENTINEL(Brigade) && apr_bucket_read(PrevBucket, &TestBuffer, &Length, APR_BLOCK_R= EAD) =3D=3D APR_SUCCESS) { printf("PrevBucket: %s\n", TestBuffer); printf("Length: %zu\n", Length); } Marker++; } =20 char * Output =3D NULL; apr_size_t OutputLength; apr_brigade_pflatten(Brigade, &Output, &OutputLength, Pool); =20 printf("output: %s\n", Output); =20 apr_pool_destroy(Pool); } --------------ECFF7900BBF6B58BD1AA52C8 Content-Type: text/plain; charset=us-ascii --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org For additional commands, e-mail: users-help@httpd.apache.org --------------ECFF7900BBF6B58BD1AA52C8--