Return-Path: Delivered-To: apmail-httpd-dev-archive@www.apache.org Received: (qmail 75440 invoked from network); 6 Dec 2008 09:06:16 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 6 Dec 2008 09:06:16 -0000 Received: (qmail 96036 invoked by uid 500); 6 Dec 2008 09:06:25 -0000 Delivered-To: apmail-httpd-dev-archive@httpd.apache.org Received: (qmail 95982 invoked by uid 500); 6 Dec 2008 09:06:25 -0000 Mailing-List: contact dev-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list dev@httpd.apache.org Received: (qmail 95973 invoked by uid 99); 6 Dec 2008 09:06:25 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 06 Dec 2008 01:06:25 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received: from [140.211.11.9] (HELO minotaur.apache.org) (140.211.11.9) by apache.org (qpsmtpd/0.29) with SMTP; Sat, 06 Dec 2008 09:05:04 +0000 Received: (qmail 75194 invoked by uid 2161); 6 Dec 2008 09:05:52 -0000 Received: from [192.168.2.4] (euler.heimnetz.de [192.168.2.4]) by cerberus.heimnetz.de (Postfix on SuSE Linux 7.0 (i386)) with ESMTP id 250261721C for ; Sat, 6 Dec 2008 10:05:41 +0100 (CET) Message-ID: <493A4064.2020506@apache.org> Date: Sat, 06 Dec 2008 10:05:40 +0100 From: Ruediger Pluem User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.18) Gecko/20081030 SeaMonkey/1.1.13 MIME-Version: 1.0 To: dev@httpd.apache.org Subject: Re: svn commit: r723627 - in /httpd/httpd/branches/wombat-integration: include/util_script.h server/util_script.c References: <20081205071523.676422388988@eris.apache.org> <493A3BE2.6090002@apache.org> In-Reply-To: <493A3BE2.6090002@apache.org> X-Enigmail-Version: 0.95.7 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Virus-Checked: Checked by ClamAV on apache.org On 12/06/2008 09:46 AM, Ruediger Pluem wrote: > > On 12/05/2008 08:15 AM, pquerna@apache.org wrote: >> Author: pquerna >> Date: Thu Dec 4 23:15:22 2008 >> New Revision: 723627 >> >> URL: http://svn.apache.org/viewvc?rev=723627&view=rev >> Log: >> Add new api, ap_args_to_table, to parse a request's arguments into a table. >> >> Modified: >> httpd/httpd/branches/wombat-integration/include/util_script.h >> httpd/httpd/branches/wombat-integration/server/util_script.c >> >> Modified: httpd/httpd/branches/wombat-integration/include/util_script.h >> URL: http://svn.apache.org/viewvc/httpd/httpd/branches/wombat-integration/include/util_script.h?rev=723627&r1=723626&r2=723627&view=diff >> ============================================================================== >> --- httpd/httpd/branches/wombat-integration/include/util_script.h (original) >> +++ httpd/httpd/branches/wombat-integration/include/util_script.h Thu Dec 4 23:15:22 2008 >> @@ -140,6 +140,8 @@ >> int (*getsfunc) (char *, int, void *), >> void *getsfunc_data); >> >> +AP_DECLARE(void) ap_args_to_table(request_rec *r, apr_table_t **table); >> + > > Hm. This requires a minor bump. > >> #ifdef __cplusplus >> } >> #endif >> >> Modified: httpd/httpd/branches/wombat-integration/server/util_script.c >> URL: http://svn.apache.org/viewvc/httpd/httpd/branches/wombat-integration/server/util_script.c?rev=723627&r1=723626&r2=723627&view=diff >> ============================================================================== >> --- httpd/httpd/branches/wombat-integration/server/util_script.c (original) >> +++ httpd/httpd/branches/wombat-integration/server/util_script.c Thu Dec 4 23:15:22 2008 >> @@ -721,3 +721,41 @@ >> va_end(strs.args); >> return res; >> } >> + >> + >> +static void >> +argstr_to_table(apr_pool_t *p, char *str, apr_table_t *parms) >> +{ >> + char *key; >> + char *value; >> + char *strtok_state; >> + > > Hm, we should make a copy of str before changing it in the while lopp > below. Reading further on in the commits I changed my mind. We should not do a copy here, but passing the pool as argument to the function seems to be pointless to me. > >> + key = apr_strtok(str, "&", &strtok_state); >> + while (key) { >> + value = strchr(key, '='); >> + if (value) { >> + *value = '\0'; /* Split the string in two */ >> + value++; /* Skip passed the = */ >> + } >> + else { >> + value = "1"; >> + } >> + ap_unescape_url(key); >> + ap_unescape_url(value); >> + apr_table_set(parms, key, value); >> + /* >> + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, > > r is no parameter for this function. > >> + "Found query arg: %s = %s", key, value); >> + */ >> + key = apr_strtok(NULL, "&", &strtok_state); >> + } >> +} >> + >> +AP_DECLARE(void) ap_args_to_table(request_rec *r, apr_table_t **table) >> +{ >> + apr_table_t *t = apr_table_make(r->pool, 10); >> + argstr_to_table(r->pool, r->args, t); We should make a copy of r->args here before passing as argstr_to_table changes the contents of the second parameter. Regards RĂ¼diger