httpd-apreq-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pgollu...@apache.org
Subject svn commit: r724901 - in /httpd/apreq/branches/apr-build-system/libapreq: include/ library/
Date Tue, 09 Dec 2008 21:33:22 GMT
Author: pgollucci
Date: Tue Dec  9 13:33:21 2008
New Revision: 724901

URL: http://svn.apache.org/viewvc?rev=724901&view=rev
Log:
sync from trunk@724900


Modified:
    httpd/apreq/branches/apr-build-system/libapreq/include/apreq.h
    httpd/apreq/branches/apr-build-system/libapreq/include/apreq_cookie.h
    httpd/apreq/branches/apr-build-system/libapreq/include/apreq_error.h
    httpd/apreq/branches/apr-build-system/libapreq/include/apreq_module.h
    httpd/apreq/branches/apr-build-system/libapreq/include/apreq_param.h
    httpd/apreq/branches/apr-build-system/libapreq/include/apreq_parser.h
    httpd/apreq/branches/apr-build-system/libapreq/include/apreq_util.h
    httpd/apreq/branches/apr-build-system/libapreq/include/apreq_version.h
    httpd/apreq/branches/apr-build-system/libapreq/library/cookie.c
    httpd/apreq/branches/apr-build-system/libapreq/library/error.c
    httpd/apreq/branches/apr-build-system/libapreq/library/module.c
    httpd/apreq/branches/apr-build-system/libapreq/library/module_cgi.c
    httpd/apreq/branches/apr-build-system/libapreq/library/module_custom.c
    httpd/apreq/branches/apr-build-system/libapreq/library/param.c
    httpd/apreq/branches/apr-build-system/libapreq/library/parser.c
    httpd/apreq/branches/apr-build-system/libapreq/library/parser_header.c
    httpd/apreq/branches/apr-build-system/libapreq/library/parser_multipart.c
    httpd/apreq/branches/apr-build-system/libapreq/library/parser_urlencoded.c
    httpd/apreq/branches/apr-build-system/libapreq/library/util.c
    httpd/apreq/branches/apr-build-system/libapreq/library/version.c

Modified: httpd/apreq/branches/apr-build-system/libapreq/include/apreq.h
URL: http://svn.apache.org/viewvc/httpd/apreq/branches/apr-build-system/libapreq/include/apreq.h?rev=724901&r1=724900&r2=724901&view=diff
==============================================================================
--- httpd/apreq/branches/apr-build-system/libapreq/include/apreq.h (original)
+++ httpd/apreq/branches/apr-build-system/libapreq/include/apreq.h Tue Dec  9 13:33:21 2008
@@ -1,9 +1,10 @@
 /*
-**  Copyright 2003-2006  The Apache Software Foundation
-**
-**  Licensed under the Apache License, Version 2.0 (the "License");
-**  you may not use this file except in compliance with the License.
-**  You may obtain a copy of the License at
+**  Licensed to the Apache Software Foundation (ASF) under one or more
+** contributor license agreements.  See the NOTICE file distributed with
+** this work for additional information regarding copyright ownership.
+** The ASF licenses this file to You under the Apache License, Version 2.0
+** (the "License"); you may not use this file except in compliance with
+** the License.  You may obtain a copy of the License at
 **
 **      http://www.apache.org/licenses/LICENSE-2.0
 **
@@ -68,10 +69,18 @@
  * APREQ_DECLARE_DATA type apr_variable = value;
  */
 #define APREQ_DECLARE_DATA
-#else
+#elif defined (APREQ_DECLARE_STATIC)
+#define APREQ_DECLARE(type)             type __stdcall
+#define APREQ_DECLARE_NONSTD(type)      type
+#define APREQ_DECLARE_DATA
+#elif defined (APREQ_DECLARE_EXPORT)
 #define APREQ_DECLARE(type)             __declspec(dllexport) type __stdcall
 #define APREQ_DECLARE_NONSTD(type)      __declspec(dllexport) type
 #define APREQ_DECLARE_DATA              __declspec(dllexport)
+#else
+#define APREQ_DECLARE(type)             __declspec(dllimport) type __stdcall
+#define APREQ_DECLARE_NONSTD(type)      __declspec(dllimport) type
+#define APREQ_DECLARE_DATA              __declspec(dllimport)
 #endif
 
 /**

Modified: httpd/apreq/branches/apr-build-system/libapreq/include/apreq_cookie.h
URL: http://svn.apache.org/viewvc/httpd/apreq/branches/apr-build-system/libapreq/include/apreq_cookie.h?rev=724901&r1=724900&r2=724901&view=diff
==============================================================================
--- httpd/apreq/branches/apr-build-system/libapreq/include/apreq_cookie.h (original)
+++ httpd/apreq/branches/apr-build-system/libapreq/include/apreq_cookie.h Tue Dec  9 13:33:21 2008
@@ -1,9 +1,10 @@
 /*
-**  Copyright 2003-2006  The Apache Software Foundation
-**
-**  Licensed under the Apache License, Version 2.0 (the "License");
-**  you may not use this file except in compliance with the License.
-**  You may obtain a copy of the License at
+**  Licensed to the Apache Software Foundation (ASF) under one or more
+** contributor license agreements.  See the NOTICE file distributed with
+** this work for additional information regarding copyright ownership.
+** The ASF licenses this file to You under the Apache License, Version 2.0
+** (the "License"); you may not use this file except in compliance with
+** the License.  You may obtain a copy of the License at
 **
 **      http://www.apache.org/licenses/LICENSE-2.0
 **

Modified: httpd/apreq/branches/apr-build-system/libapreq/include/apreq_error.h
URL: http://svn.apache.org/viewvc/httpd/apreq/branches/apr-build-system/libapreq/include/apreq_error.h?rev=724901&r1=724900&r2=724901&view=diff
==============================================================================
--- httpd/apreq/branches/apr-build-system/libapreq/include/apreq_error.h (original)
+++ httpd/apreq/branches/apr-build-system/libapreq/include/apreq_error.h Tue Dec  9 13:33:21 2008
@@ -1,9 +1,10 @@
 /*
-**  Copyright 2003-2006  The Apache Software Foundation
-**
-**  Licensed under the Apache License, Version 2.0 (the "License");
-**  you may not use this file except in compliance with the License.
-**  You may obtain a copy of the License at
+**  Licensed to the Apache Software Foundation (ASF) under one or more
+** contributor license agreements.  See the NOTICE file distributed with
+** this work for additional information regarding copyright ownership.
+** The ASF licenses this file to You under the Apache License, Version 2.0
+** (the "License"); you may not use this file except in compliance with
+** the License.  You may obtain a copy of the License at
 **
 **      http://www.apache.org/licenses/LICENSE-2.0
 **

Modified: httpd/apreq/branches/apr-build-system/libapreq/include/apreq_module.h
URL: http://svn.apache.org/viewvc/httpd/apreq/branches/apr-build-system/libapreq/include/apreq_module.h?rev=724901&r1=724900&r2=724901&view=diff
==============================================================================
--- httpd/apreq/branches/apr-build-system/libapreq/include/apreq_module.h (original)
+++ httpd/apreq/branches/apr-build-system/libapreq/include/apreq_module.h Tue Dec  9 13:33:21 2008
@@ -1,9 +1,10 @@
 /*
-**  Copyright 2003-2006  The Apache Software Foundation
-**
-**  Licensed under the Apache License, Version 2.0 (the "License");
-**  you may not use this file except in compliance with the License.
-**  You may obtain a copy of the License at
+**  Licensed to the Apache Software Foundation (ASF) under one or more
+** contributor license agreements.  See the NOTICE file distributed with
+** this work for additional information regarding copyright ownership.
+** The ASF licenses this file to You under the Apache License, Version 2.0
+** (the "License"); you may not use this file except in compliance with
+** the License.  You may obtain a copy of the License at
 **
 **      http://www.apache.org/licenses/LICENSE-2.0
 **

Modified: httpd/apreq/branches/apr-build-system/libapreq/include/apreq_param.h
URL: http://svn.apache.org/viewvc/httpd/apreq/branches/apr-build-system/libapreq/include/apreq_param.h?rev=724901&r1=724900&r2=724901&view=diff
==============================================================================
--- httpd/apreq/branches/apr-build-system/libapreq/include/apreq_param.h (original)
+++ httpd/apreq/branches/apr-build-system/libapreq/include/apreq_param.h Tue Dec  9 13:33:21 2008
@@ -1,9 +1,10 @@
 /*
-**  Copyright 2003-2006  The Apache Software Foundation
-**
-**  Licensed under the Apache License, Version 2.0 (the "License");
-**  you may not use this file except in compliance with the License.
-**  You may obtain a copy of the License at
+**  Licensed to the Apache Software Foundation (ASF) under one or more
+** contributor license agreements.  See the NOTICE file distributed with
+** this work for additional information regarding copyright ownership.
+** The ASF licenses this file to You under the Apache License, Version 2.0
+** (the "License"); you may not use this file except in compliance with
+** the License.  You may obtain a copy of the License at
 **
 **      http://www.apache.org/licenses/LICENSE-2.0
 **

Modified: httpd/apreq/branches/apr-build-system/libapreq/include/apreq_parser.h
URL: http://svn.apache.org/viewvc/httpd/apreq/branches/apr-build-system/libapreq/include/apreq_parser.h?rev=724901&r1=724900&r2=724901&view=diff
==============================================================================
--- httpd/apreq/branches/apr-build-system/libapreq/include/apreq_parser.h (original)
+++ httpd/apreq/branches/apr-build-system/libapreq/include/apreq_parser.h Tue Dec  9 13:33:21 2008
@@ -1,9 +1,10 @@
 /*
-**  Copyright 2003-2006  The Apache Software Foundation
-**
-**  Licensed under the Apache License, Version 2.0 (the "License");
-**  you may not use this file except in compliance with the License.
-**  You may obtain a copy of the License at
+**  Licensed to the Apache Software Foundation (ASF) under one or more
+** contributor license agreements.  See the NOTICE file distributed with
+** this work for additional information regarding copyright ownership.
+** The ASF licenses this file to You under the Apache License, Version 2.0
+** (the "License"); you may not use this file except in compliance with
+** the License.  You may obtain a copy of the License at
 **
 **      http://www.apache.org/licenses/LICENSE-2.0
 **

Modified: httpd/apreq/branches/apr-build-system/libapreq/include/apreq_util.h
URL: http://svn.apache.org/viewvc/httpd/apreq/branches/apr-build-system/libapreq/include/apreq_util.h?rev=724901&r1=724900&r2=724901&view=diff
==============================================================================
--- httpd/apreq/branches/apr-build-system/libapreq/include/apreq_util.h (original)
+++ httpd/apreq/branches/apr-build-system/libapreq/include/apreq_util.h Tue Dec  9 13:33:21 2008
@@ -1,9 +1,10 @@
 /*
-**  Copyright 2003-2006  The Apache Software Foundation
-**
-**  Licensed under the Apache License, Version 2.0 (the "License");
-**  you may not use this file except in compliance with the License.
-**  You may obtain a copy of the License at
+**  Licensed to the Apache Software Foundation (ASF) under one or more
+** contributor license agreements.  See the NOTICE file distributed with
+** this work for additional information regarding copyright ownership.
+** The ASF licenses this file to You under the Apache License, Version 2.0
+** (the "License"); you may not use this file except in compliance with
+** the License.  You may obtain a copy of the License at
 **
 **      http://www.apache.org/licenses/LICENSE-2.0
 **
@@ -269,8 +270,8 @@
  * @return Error status code from either an unsuccessful apr_bucket_read(),
  *         or a failed apr_file_writev().
  *
- * @remarks       In the future, this function may do something
- *                intelligent with file buckets.
+ * @remarks       This function leaks a bucket brigade into bb->p whenever
+ *                the final bucket in bb is a spool bucket.
  */
 
 APREQ_DECLARE(apr_status_t) apreq_brigade_fwrite(apr_file_t *f,

Modified: httpd/apreq/branches/apr-build-system/libapreq/include/apreq_version.h
URL: http://svn.apache.org/viewvc/httpd/apreq/branches/apr-build-system/libapreq/include/apreq_version.h?rev=724901&r1=724900&r2=724901&view=diff
==============================================================================
--- httpd/apreq/branches/apr-build-system/libapreq/include/apreq_version.h (original)
+++ httpd/apreq/branches/apr-build-system/libapreq/include/apreq_version.h Tue Dec  9 13:33:21 2008
@@ -1,9 +1,10 @@
 /*
-**  Copyright 2003-2006  The Apache Software Foundation
-**
-**  Licensed under the Apache License, Version 2.0 (the "License");
-**  you may not use this file except in compliance with the License.
-**  You may obtain a copy of the License at
+**  Licensed to the Apache Software Foundation (ASF) under one or more
+** contributor license agreements.  See the NOTICE file distributed with
+** this work for additional information regarding copyright ownership.
+** The ASF licenses this file to You under the Apache License, Version 2.0
+** (the "License"); you may not use this file except in compliance with
+** the License.  You may obtain a copy of the License at
 **
 **      http://www.apache.org/licenses/LICENSE-2.0
 **
@@ -61,7 +62,7 @@
 #define APREQ_MINOR_VERSION       6
 
 /** patch level */
-#define APREQ_PATCH_VERSION       0
+#define APREQ_PATCH_VERSION       3
 
 /**
  *  This symbol is defined for internal, "development" copies of libapreq.

Modified: httpd/apreq/branches/apr-build-system/libapreq/library/cookie.c
URL: http://svn.apache.org/viewvc/httpd/apreq/branches/apr-build-system/libapreq/library/cookie.c?rev=724901&r1=724900&r2=724901&view=diff
==============================================================================
--- httpd/apreq/branches/apr-build-system/libapreq/library/cookie.c (original)
+++ httpd/apreq/branches/apr-build-system/libapreq/library/cookie.c Tue Dec  9 13:33:21 2008
@@ -1,9 +1,205 @@
 /*
-**  Copyright 2003-2006  The Apache Software Foundation
+**  Licensed to the Apache Software Foundation (ASF) under one or more
+** contributor license agreements.  See the NOTICE file distributed with
+** this work for additional information regarding copyright ownership.
+** The ASF licenses this file to You under the Apache License, Version 2.0
+** (the "License"); you may not use this file except in compliance with
+** the License.  You may obtain a copy of the License at
 **
-**  Licensed under the Apache License, Version 2.0 (the "License");
-**  you may not use this file except in compliance with the License.
-**  You may obtain a copy of the License at
+**      http://www.apache.org/licenses/LICENSE-2.0
+**
+**  Unless required by applicable law or agreed to in writing, software
+**  distributed under the License is distributed on an "AS IS" BASIS,
+**  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+**  See the License for the specific language governing permissions and
+**  limitations under the License.
+*/
+
+#include "apr_strings.h"
+#include "apreq_cookie.h"
+#include "apreq_error.h"
+#include "apreq_module.h"
+#include "apreq_util.h"
+#include "at.h"
+
+static const char nscookies[] = "a=1; foo=bar; fl=left; fr=right;bad; "
+                                "ns=foo=1&bar=2,frl=right-left; "
+                                "flr=left-right; fll=left-left; "
+                                "good_one=1;=;bad";
+
+static const char rfccookies[] = "$Version=1; first=a;$domain=quux;second=be,"
+                                 "$Version=1;third=cie";
+
+static apr_table_t *jar, *jar2;
+static apr_pool_t *p;
+
+static void jar_make(dAT)
+{
+    jar = apr_table_make(p, APREQ_DEFAULT_NELTS);
+    AT_not_null(jar);
+    AT_int_eq(apreq_parse_cookie_header(p, jar, nscookies), APREQ_ERROR_NOTOKEN);
+    jar2 = apr_table_make(p, APREQ_DEFAULT_NELTS);
+    AT_not_null(jar2);
+    AT_int_eq(apreq_parse_cookie_header(p, jar2, rfccookies), APR_SUCCESS);
+}
+
+static void jar_get_rfc(dAT)
+{
+    const char *val;
+    AT_not_null(val = apr_table_get(jar2, "first"));
+    AT_str_eq(val, "a");
+    AT_not_null(val = apr_table_get(jar2, "second"));
+    AT_str_eq(val, "be");
+    AT_not_null(val = apr_table_get(jar2, "third"));
+    AT_str_eq(val, "cie");
+}
+
+static void jar_get_ns(dAT)
+{
+
+    AT_str_eq(apr_table_get(jar, "a"), "1");
+
+    /* ignore wacky cookies that don't have an '=' sign */
+    AT_is_null(apr_table_get(jar, "bad"));
+
+    /* accept wacky cookies that contain multiple '=' */
+    AT_str_eq(apr_table_get(jar, "ns"), "foo=1&bar=2");
+
+    AT_str_eq(apr_table_get(jar,"foo"), "bar");
+    AT_str_eq(apr_table_get(jar,"fl"),  "left");
+    AT_str_eq(apr_table_get(jar,"fr"),  "right");
+    AT_str_eq(apr_table_get(jar,"frl"), "right-left");
+    AT_str_eq(apr_table_get(jar,"flr"), "left-right");
+    AT_str_eq(apr_table_get(jar,"fll"), "left-left");
+    AT_is_null(apr_table_get(jar,""));
+}
+
+
+static void netscape_cookie(dAT)
+{
+    char expires[APR_RFC822_DATE_LEN];
+    char *val;
+    apreq_cookie_t *c;
+
+    *(const char **)&val = apr_table_get(jar, "foo");
+    AT_not_null(val);
+
+    c = apreq_value_to_cookie(val);
+
+    AT_str_eq(c->v.data, "bar");
+    AT_int_eq(apreq_cookie_version(c), 0);
+    AT_str_eq(apreq_cookie_as_string(c, p), "foo=bar");
+
+    c->domain = apr_pstrdup(p, "example.com");
+    AT_str_eq(apreq_cookie_as_string(c, p), "foo=bar; domain=example.com");
+
+    c->path = apr_pstrdup(p, "/quux");
+    AT_str_eq(apreq_cookie_as_string(c, p),
+              "foo=bar; path=/quux; domain=example.com");
+
+    apreq_cookie_expires(c, "+1y");
+    apr_rfc822_date(expires, apr_time_now()
+                             + apr_time_from_sec(apreq_atoi64t("+1y")));
+    expires[7] = '-';
+    expires[11] = '-';
+    val = apr_pstrcat(p, "foo=bar; path=/quux; domain=example.com; expires=",
+                      expires, NULL);
+
+    AT_str_eq(apreq_cookie_as_string(c, p), val);
+}
+
+
+static void rfc_cookie(dAT)
+{
+    apreq_cookie_t *c = apreq_cookie_make(p,"rfc",3,"out",3);
+    const char *expected;
+    long expires;
+
+    AT_str_eq(c->v.data, "out");
+
+    apreq_cookie_version_set(c, 1);
+    AT_int_eq(apreq_cookie_version(c), 1);
+    AT_str_eq(apreq_cookie_as_string(c,p),"rfc=out; Version=1");
+
+    c->domain = apr_pstrdup(p, "example.com");
+
+#ifndef WIN32
+
+    AT_str_eq(apreq_cookie_as_string(c,p),
+              "rfc=out; Version=1; domain=\"example.com\"");
+    c->path = apr_pstrdup(p, "/quux");
+    AT_str_eq(apreq_cookie_as_string(c,p),
+              "rfc=out; Version=1; path=\"/quux\"; domain=\"example.com\"");
+
+    apreq_cookie_expires(c, "+3m");
+    expires = apreq_atoi64t("+3m");
+    expected = apr_psprintf(p, "rfc=out; Version=1; path=\"/quux\"; "
+                       "domain=\"example.com\"; max-age=%ld",
+                       expires);
+    AT_str_eq(apreq_cookie_as_string(c,p), expected);
+
+#else
+
+    expected = "rfc=out; Version=1; domain=\"example.com\"";
+    AT_str_eq(apreq_cookie_as_string(c,p), expected);
+
+    c->path = apr_pstrdup(p, "/quux");
+    expected = "rfc=out; Version=1; path=\"/quux\"; domain=\"example.com\"";
+    AT_str_eq(apreq_cookie_as_string(c,p), expected);
+
+    apreq_cookie_expires(c, "+3m");
+    expires = apreq_atoi64t("+3m");
+    expected = apr_psprintf(p, "rfc=out; Version=1; path=\"/quux\"; "
+                           "domain=\"example.com\"; max-age=%ld",
+                           expires);
+    AT_str_eq(apreq_cookie_as_string(c,p), expected);
+
+#endif
+
+}
+
+
+#define dT(func, plan) #func, func, plan
+
+
+int main(int argc, char *argv[])
+{
+    unsigned i, plan = 0;
+    dAT;
+    at_test_t test_list [] = {
+        { dT(jar_make, 4) },
+        { dT(jar_get_rfc, 6), "1 3 5" },
+        { dT(jar_get_ns, 10) },
+        { dT(netscape_cookie, 7) },
+        { dT(rfc_cookie, 6) },
+    };
+
+    apr_initialize();
+    atexit(apr_terminate);
+
+    apr_pool_create(&p, NULL);
+
+    AT = at_create(p, 0, at_report_stdout_make(p));
+
+    for (i = 0; i < sizeof(test_list) / sizeof(at_test_t);  ++i)
+        plan += test_list[i].plan;
+
+    AT_begin(plan);
+
+    for (i = 0; i < sizeof(test_list) / sizeof(at_test_t);  ++i)
+        AT_run(&test_list[i]);
+
+    AT_end();
+
+    return 0;
+}
+/*
+**  Licensed to the Apache Software Foundation (ASF) under one or more
+** contributor license agreements.  See the NOTICE file distributed with
+** this work for additional information regarding copyright ownership.
+** The ASF licenses this file to You under the Apache License, Version 2.0
+** (the "License"); you may not use this file except in compliance with
+** the License.  You may obtain a copy of the License at
 **
 **      http://www.apache.org/licenses/LICENSE-2.0
 **

Modified: httpd/apreq/branches/apr-build-system/libapreq/library/error.c
URL: http://svn.apache.org/viewvc/httpd/apreq/branches/apr-build-system/libapreq/library/error.c?rev=724901&r1=724900&r2=724901&view=diff
==============================================================================
--- httpd/apreq/branches/apr-build-system/libapreq/library/error.c (original)
+++ httpd/apreq/branches/apr-build-system/libapreq/library/error.c Tue Dec  9 13:33:21 2008
@@ -1,8 +1,102 @@
-/* Copyright 2000-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+/*
+**  Licensed to the Apache Software Foundation (ASF) under one or more
+** contributor license agreements.  See the NOTICE file distributed with
+** this work for additional information regarding copyright ownership.
+** The ASF licenses this file to You under the Apache License, Version 2.0
+** (the "License"); you may not use this file except in compliance with
+** the License.  You may obtain a copy of the License at
+**
+**      http://www.apache.org/licenses/LICENSE-2.0
+**
+**  Unless required by applicable law or agreed to in writing, software
+**  distributed under the License is distributed on an "AS IS" BASIS,
+**  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+**  See the License for the specific language governing permissions and
+**  limitations under the License.
+*/
+
+#include "apr_strings.h"
+#include "apreq_error.h"
+#include "at.h"
+
+
+static void test_strerror(dAT)
+{
+    char buf[256], *str;
+
+    str = apreq_strerror(APREQ_ERROR_GENERAL, buf, sizeof buf);
+    AT_ptr_eq(str, buf);
+    AT_str_eq(str, "Internal apreq error");
+
+    str = apreq_strerror(APREQ_ERROR_TAINTED, buf, sizeof buf);
+    AT_str_eq(str, "Attempt to perform unsafe action with tainted data");
+
+    str = apreq_strerror(APREQ_ERROR_BADSEQ, buf, sizeof buf);
+    AT_str_eq(str, "Invalid byte sequence");
+
+    str = apreq_strerror(APREQ_ERROR_NODATA, buf, sizeof buf);
+    AT_str_eq(str, "Missing input data");
+
+    str = apreq_strerror(APREQ_ERROR_GENERAL+99, buf, sizeof buf);
+    AT_str_eq(str, "Error string not yet specified by apreq");
+
+
+
+
+    /* Test some common APR status codes also */
+
+    str = apreq_strerror(APR_EINIT, buf, sizeof buf);
+    AT_str_eq(str, "There is no error, this value signifies an initialized "
+                   "error code");
+
+    str = apreq_strerror(APR_INCOMPLETE, buf, sizeof buf);
+    AT_str_eq(str, "Partial results are valid but processing is incomplete");
+
+    str = apreq_strerror(APR_EOF, buf, sizeof buf);
+    AT_str_eq(str, "End of file found");
+
+    str = apreq_strerror(APR_ENOTIMPL, buf, sizeof buf);
+    AT_str_eq(str, "This function has not been implemented on this platform");
+
+ }
+
+#define dT(func, plan) #func, func, plan
+
+
+int main(int argc, char *argv[])
+{
+    unsigned i, plan = 0;
+    apr_pool_t *p;
+    dAT;
+    at_test_t test_list [] = {
+        { dT(test_strerror, 10), "1" }
+    };
+
+    apr_initialize();
+    atexit(apr_terminate);
+
+    apr_pool_create(&p, NULL);
+
+    AT = at_create(p, 0, at_report_stdout_make(p));
+
+    for (i = 0; i < sizeof(test_list) / sizeof(at_test_t);  ++i)
+        plan += test_list[i].plan;
+
+    AT_begin(plan);
+
+    for (i = 0; i < sizeof(test_list) / sizeof(at_test_t);  ++i)
+        AT_run(&test_list[i]);
+
+    AT_end();
+
+    return 0;
+}
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
  *
  *     http://www.apache.org/licenses/LICENSE-2.0
  *

Modified: httpd/apreq/branches/apr-build-system/libapreq/library/module.c
URL: http://svn.apache.org/viewvc/httpd/apreq/branches/apr-build-system/libapreq/library/module.c?rev=724901&r1=724900&r2=724901&view=diff
==============================================================================
--- httpd/apreq/branches/apr-build-system/libapreq/library/module.c (original)
+++ httpd/apreq/branches/apr-build-system/libapreq/library/module.c Tue Dec  9 13:33:21 2008
@@ -1,9 +1,10 @@
 /*
-**  Copyright 2003-2006  The Apache Software Foundation
-**
-**  Licensed under the Apache License, Version 2.0 (the "License");
-**  you may not use this file except in compliance with the License.
-**  You may obtain a copy of the License at
+**  Licensed to the Apache Software Foundation (ASF) under one or more
+** contributor license agreements.  See the NOTICE file distributed with
+** this work for additional information regarding copyright ownership.
+** The ASF licenses this file to You under the Apache License, Version 2.0
+** (the "License"); you may not use this file except in compliance with
+** the License.  You may obtain a copy of the License at
 **
 **      http://www.apache.org/licenses/LICENSE-2.0
 **

Modified: httpd/apreq/branches/apr-build-system/libapreq/library/module_cgi.c
URL: http://svn.apache.org/viewvc/httpd/apreq/branches/apr-build-system/libapreq/library/module_cgi.c?rev=724901&r1=724900&r2=724901&view=diff
==============================================================================
--- httpd/apreq/branches/apr-build-system/libapreq/library/module_cgi.c (original)
+++ httpd/apreq/branches/apr-build-system/libapreq/library/module_cgi.c Tue Dec  9 13:33:21 2008
@@ -1,9 +1,10 @@
 /*
-**  Copyright 2003-2006  The Apache Software Foundation
-**
-**  Licensed under the Apache License, Version 2.0 (the "License");
-**  you may not use this file except in compliance with the License.
-**  You may obtain a copy of the License at
+**  Licensed to the Apache Software Foundation (ASF) under one or more
+** contributor license agreements.  See the NOTICE file distributed with
+** this work for additional information regarding copyright ownership.
+** The ASF licenses this file to You under the Apache License, Version 2.0
+** (the "License"); you may not use this file except in compliance with
+** the License.  You may obtain a copy of the License at
 **
 **      http://www.apache.org/licenses/LICENSE-2.0
 **
@@ -473,7 +474,7 @@
         h = req->find_param;
         h->next = req->parser->hook;
         req->parser->hook = h;
-        *(const char **)&h->ctx = name;
+        h->ctx = (void *)name;
 
         do {
             cgi_read(handle, APREQ_DEFAULT_READ_BLOCK_SIZE);

Modified: httpd/apreq/branches/apr-build-system/libapreq/library/module_custom.c
URL: http://svn.apache.org/viewvc/httpd/apreq/branches/apr-build-system/libapreq/library/module_custom.c?rev=724901&r1=724900&r2=724901&view=diff
==============================================================================
--- httpd/apreq/branches/apr-build-system/libapreq/library/module_custom.c (original)
+++ httpd/apreq/branches/apr-build-system/libapreq/library/module_custom.c Tue Dec  9 13:33:21 2008
@@ -1,9 +1,10 @@
 /*
-**  Copyright 2003-2006  The Apache Software Foundation
-**
-**  Licensed under the Apache License, Version 2.0 (the "License");
-**  you may not use this file except in compliance with the License.
-**  You may obtain a copy of the License at
+**  Licensed to the Apache Software Foundation (ASF) under one or more
+** contributor license agreements.  See the NOTICE file distributed with
+** this work for additional information regarding copyright ownership.
+** The ASF licenses this file to You under the Apache License, Version 2.0
+** (the "License"); you may not use this file except in compliance with
+** the License.  You may obtain a copy of the License at
 **
 **      http://www.apache.org/licenses/LICENSE-2.0
 **
@@ -249,7 +250,7 @@
 }
 
 
-static APREQ_MODULE(custom, 20050516);
+static APREQ_MODULE(custom, 20070428);
 
 APREQ_DECLARE(apreq_handle_t *)apreq_handle_custom(apr_pool_t *pool,
                                                    const char *query_string,
@@ -264,6 +265,7 @@
     req->handle.pool = pool;
     req->handle.bucket_alloc = in->bucket_alloc;
     req->read_limit = read_limit;
+    req->bytes_read = 0;
     req->parser = parser;
     req->in = apr_brigade_create(pool, in->bucket_alloc);
     req->tmpbb = apr_brigade_create(pool, in->bucket_alloc);

Modified: httpd/apreq/branches/apr-build-system/libapreq/library/param.c
URL: http://svn.apache.org/viewvc/httpd/apreq/branches/apr-build-system/libapreq/library/param.c?rev=724901&r1=724900&r2=724901&view=diff
==============================================================================
--- httpd/apreq/branches/apr-build-system/libapreq/library/param.c (original)
+++ httpd/apreq/branches/apr-build-system/libapreq/library/param.c Tue Dec  9 13:33:21 2008
@@ -1,9 +1,10 @@
 /*
-**  Copyright 2003-2006  The Apache Software Foundation
-**
-**  Licensed under the Apache License, Version 2.0 (the "License");
-**  you may not use this file except in compliance with the License.
-**  You may obtain a copy of the License at
+**  Licensed to the Apache Software Foundation (ASF) under one or more
+** contributor license agreements.  See the NOTICE file distributed with
+** this work for additional information regarding copyright ownership.
+** The ASF licenses this file to You under the Apache License, Version 2.0
+** (the "License"); you may not use this file except in compliance with
+** the License.  You may obtain a copy of the License at
 **
 **      http://www.apache.org/licenses/LICENSE-2.0
 **

Modified: httpd/apreq/branches/apr-build-system/libapreq/library/parser.c
URL: http://svn.apache.org/viewvc/httpd/apreq/branches/apr-build-system/libapreq/library/parser.c?rev=724901&r1=724900&r2=724901&view=diff
==============================================================================
--- httpd/apreq/branches/apr-build-system/libapreq/library/parser.c (original)
+++ httpd/apreq/branches/apr-build-system/libapreq/library/parser.c Tue Dec  9 13:33:21 2008
@@ -1,9 +1,10 @@
 /*
-**  Copyright 2003-2006  The Apache Software Foundation
-**
-**  Licensed under the Apache License, Version 2.0 (the "License");
-**  you may not use this file except in compliance with the License.
-**  You may obtain a copy of the License at
+**  Licensed to the Apache Software Foundation (ASF) under one or more
+** contributor license agreements.  See the NOTICE file distributed with
+** this work for additional information regarding copyright ownership.
+** The ASF licenses this file to You under the Apache License, Version 2.0
+** (the "License"); you may not use this file except in compliance with
+** the License.  You may obtain a copy of the License at
 **
 **      http://www.apache.org/licenses/LICENSE-2.0
 **

Modified: httpd/apreq/branches/apr-build-system/libapreq/library/parser_header.c
URL: http://svn.apache.org/viewvc/httpd/apreq/branches/apr-build-system/libapreq/library/parser_header.c?rev=724901&r1=724900&r2=724901&view=diff
==============================================================================
--- httpd/apreq/branches/apr-build-system/libapreq/library/parser_header.c (original)
+++ httpd/apreq/branches/apr-build-system/libapreq/library/parser_header.c Tue Dec  9 13:33:21 2008
@@ -1,9 +1,10 @@
 /*
-**  Copyright 2003-2006  The Apache Software Foundation
-**
-**  Licensed under the Apache License, Version 2.0 (the "License");
-**  you may not use this file except in compliance with the License.
-**  You may obtain a copy of the License at
+**  Licensed to the Apache Software Foundation (ASF) under one or more
+** contributor license agreements.  See the NOTICE file distributed with
+** this work for additional information regarding copyright ownership.
+** The ASF licenses this file to You under the Apache License, Version 2.0
+** (the "License"); you may not use this file except in compliance with
+** the License.  You may obtain a copy of the License at
 **
 **      http://www.apache.org/licenses/LICENSE-2.0
 **

Modified: httpd/apreq/branches/apr-build-system/libapreq/library/parser_multipart.c
URL: http://svn.apache.org/viewvc/httpd/apreq/branches/apr-build-system/libapreq/library/parser_multipart.c?rev=724901&r1=724900&r2=724901&view=diff
==============================================================================
--- httpd/apreq/branches/apr-build-system/libapreq/library/parser_multipart.c (original)
+++ httpd/apreq/branches/apr-build-system/libapreq/library/parser_multipart.c Tue Dec  9 13:33:21 2008
@@ -1,9 +1,10 @@
 /*
-**  Copyright 2003-2006  The Apache Software Foundation
-**
-**  Licensed under the Apache License, Version 2.0 (the "License");
-**  you may not use this file except in compliance with the License.
-**  You may obtain a copy of the License at
+**  Licensed to the Apache Software Foundation (ASF) under one or more
+** contributor license agreements.  See the NOTICE file distributed with
+** this work for additional information regarding copyright ownership.
+** The ASF licenses this file to You under the Apache License, Version 2.0
+** (the "License"); you may not use this file except in compliance with
+** the License.  You may obtain a copy of the License at
 **
 **      http://www.apache.org/licenses/LICENSE-2.0
 **
@@ -161,11 +162,18 @@
              * so we can move previous buckets across
              * and retest buf against the full bdry.
              */
+
+            /* give hints to GCC by making the brigade volatile, otherwise the
+             * loop below will end up being endless. See:
+             * https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=193740
+             */
+            apr_bucket_brigade * volatile in_v = in;
+
             do {
-                apr_bucket *f = APR_BRIGADE_FIRST(in);
+                apr_bucket *f = APR_BRIGADE_FIRST(in_v);
                 APR_BUCKET_REMOVE(f);
                 APR_BRIGADE_INSERT_TAIL(out, f);
-            } while (e != APR_BRIGADE_FIRST(in));
+            } while (e != APR_BRIGADE_FIRST(in_v));
             off = 0;
             goto look_for_boundary_up_front;
         }

Modified: httpd/apreq/branches/apr-build-system/libapreq/library/parser_urlencoded.c
URL: http://svn.apache.org/viewvc/httpd/apreq/branches/apr-build-system/libapreq/library/parser_urlencoded.c?rev=724901&r1=724900&r2=724901&view=diff
==============================================================================
--- httpd/apreq/branches/apr-build-system/libapreq/library/parser_urlencoded.c (original)
+++ httpd/apreq/branches/apr-build-system/libapreq/library/parser_urlencoded.c Tue Dec  9 13:33:21 2008
@@ -1,9 +1,10 @@
 /*
-**  Copyright 2003-2006  The Apache Software Foundation
-**
-**  Licensed under the Apache License, Version 2.0 (the "License");
-**  you may not use this file except in compliance with the License.
-**  You may obtain a copy of the License at
+**  Licensed to the Apache Software Foundation (ASF) under one or more
+** contributor license agreements.  See the NOTICE file distributed with
+** this work for additional information regarding copyright ownership.
+** The ASF licenses this file to You under the Apache License, Version 2.0
+** (the "License"); you may not use this file except in compliance with
+** the License.  You may obtain a copy of the License at
 **
 **      http://www.apache.org/licenses/LICENSE-2.0
 **

Modified: httpd/apreq/branches/apr-build-system/libapreq/library/util.c
URL: http://svn.apache.org/viewvc/httpd/apreq/branches/apr-build-system/libapreq/library/util.c?rev=724901&r1=724900&r2=724901&view=diff
==============================================================================
--- httpd/apreq/branches/apr-build-system/libapreq/library/util.c (original)
+++ httpd/apreq/branches/apr-build-system/libapreq/library/util.c Tue Dec  9 13:33:21 2008
@@ -1,9 +1,350 @@
 /*
-**  Copyright 2003-2006  The Apache Software Foundation
+**  Licensed to the Apache Software Foundation (ASF) under one or more
+** contributor license agreements.  See the NOTICE file distributed with
+** this work for additional information regarding copyright ownership.
+** The ASF licenses this file to You under the Apache License, Version 2.0
+** (the "License"); you may not use this file except in compliance with
+** the License.  You may obtain a copy of the License at
 **
-**  Licensed under the Apache License, Version 2.0 (the "License");
-**  you may not use this file except in compliance with the License.
-**  You may obtain a copy of the License at
+**      http://www.apache.org/licenses/LICENSE-2.0
+**
+**  Unless required by applicable law or agreed to in writing, software
+**  distributed under the License is distributed on an "AS IS" BASIS,
+**  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+**  See the License for the specific language governing permissions and
+**  limitations under the License.
+*/
+
+#include "apr_strings.h"
+#include "apreq_error.h"
+#include "apreq_util.h"
+#include "at.h"
+
+
+static void test_atoi64f(dAT)
+{
+    AT_int_eq(apreq_atoi64f("0"), 0);
+    AT_int_eq(apreq_atoi64f("-1"), -1);
+    AT_int_eq(apreq_atoi64f("-"), 0);
+    AT_int_eq(apreq_atoi64f("5"), 5);
+    AT_int_eq(apreq_atoi64f("3.333"), 3);
+    AT_int_eq(apreq_atoi64f("33k"), 33 * 1024);
+    AT_int_eq(apreq_atoi64f(" +8M "), 8 * 1024 * 1024);
+    AT_ok(apreq_atoi64f("44GB") == (apr_int64_t)44 * 1024 * 1024 * 1024,
+          "44GB test");
+    AT_ok(apreq_atoi64f("0xaBcDefg") == (apr_int64_t)11259375 * 1024 * 1024 * 1024,
+          "hex test");
+}
+
+static void test_atoi64t(dAT)
+{
+    AT_int_eq(apreq_atoi64t("0"), 0);
+    AT_int_eq(apreq_atoi64t("-1"), -1);
+    AT_int_eq(apreq_atoi64t("-g088l3dyg00k"), 0);
+    AT_int_eq(apreq_atoi64t("5s"), 5);
+    AT_int_eq(apreq_atoi64t("3.333"), 3);
+    AT_int_eq(apreq_atoi64t("33d"), 33 * 60 * 60 * 24);
+    AT_int_eq(apreq_atoi64t(" +8M "), 8 * 60 * 60 * 24 * 30);
+    AT_int_eq(apreq_atoi64t("+9m"), 9 * 60);
+    AT_int_eq(apreq_atoi64t("6h"), 6 * 60 * 60);
+
+}
+
+static void test_index(dAT)
+{
+    const char haystack[] = "Four score and seven years ago";
+    apr_size_t hlen = sizeof haystack - 1;
+    AT_int_eq(apreq_index(haystack, hlen, "Four", 4, APREQ_MATCH_FULL),
+              0);
+    AT_int_eq(apreq_index(haystack, hlen, "Four", 4, APREQ_MATCH_PARTIAL),
+              0);
+    AT_int_eq(apreq_index(haystack, hlen, "Fourteen", 8, APREQ_MATCH_FULL),
+              -1);
+    AT_int_eq(apreq_index(haystack, hlen, "Fourteen", 8, APREQ_MATCH_PARTIAL),
+              -1);
+    AT_int_eq(apreq_index(haystack, hlen, "agoraphobia", 11, APREQ_MATCH_FULL),
+              -1);
+    AT_int_eq(apreq_index(haystack, hlen, "agoraphobia", 11, APREQ_MATCH_PARTIAL),
+              hlen - 3);
+}
+
+#define A_GRAVE  0xE5
+#define KATAKANA_A 0xFF71
+
+static void test_decode(dAT)
+{
+    apr_size_t elen;
+    char src1[] = "%C3%80%E3%82%a2"; /* A_GRAVE KATAKANA_A as utf8 */
+    unsigned char expect[6];
+
+    AT_int_eq(apreq_decode((char *)expect, &elen, src1, sizeof(src1) -1),
+              APR_SUCCESS);
+    AT_int_eq(elen, 5);
+    AT_int_eq(expect[0], 0xC3);
+    AT_int_eq(expect[1], 0x80);
+    AT_int_eq(expect[2], 0xE3);
+    AT_int_eq(expect[3], 0x82);
+    AT_int_eq(expect[4], 0xA2);
+}
+
+static void test_charset_divine(dAT)
+{
+    apr_size_t elen;
+    char src1[] = "%C3%80%E3%82%a2"; /* A_GRAVE KATAKANA_A as utf8 */
+    char src2[] = "pound%A3";/* latin-1 */
+    char src3[] = "euro%80";/* cp-1252 */
+    char expect[7];
+
+    AT_int_eq(apreq_decode(expect, &elen, src1, sizeof(src1) -1),
+              APR_SUCCESS);
+
+    AT_int_eq(apreq_charset_divine(expect, elen), APREQ_CHARSET_UTF8);
+
+    AT_int_eq(apreq_decode(expect, &elen, src2, sizeof(src2) -1),
+              APR_SUCCESS);
+
+    AT_int_eq(apreq_charset_divine(expect, elen), APREQ_CHARSET_LATIN1);
+    AT_int_eq(apreq_decode(expect, &elen, src3, sizeof(src3) -1),
+              APR_SUCCESS);
+
+    AT_int_eq(apreq_charset_divine(expect, elen), APREQ_CHARSET_CP1252);
+
+}
+
+
+static void test_decodev(dAT)
+{
+    char src1[] = "%2540%2";
+    char src2[] = "0%u0";
+    char src3[] = "041";
+    struct iovec iovec1[] = {
+        { src1, sizeof(src1) - 1 },
+        { src2, sizeof(src2) - 1 },
+        { src3, sizeof(src3) - 1 },
+    };
+    struct iovec iovec2[] = {
+        { src1, sizeof(src1) - 1 },
+        { src2, sizeof(src2) - 1 },
+    };
+    const char expect1[] = "%40 A";
+    const char expect2[] = "%40 ";
+    char dest[sizeof(src1) + sizeof(src2) + sizeof(src3)];
+    apr_size_t dest_len;
+    apr_status_t status;
+
+    status = apreq_decodev(dest, &dest_len, iovec1, 3);
+    AT_int_eq(status, APR_SUCCESS);
+    AT_int_eq(dest_len, sizeof(expect1) - 1);
+    AT_mem_eq(dest, expect1, sizeof(expect1) - 1);
+
+    status = apreq_decodev(dest, &dest_len, iovec2, 2);
+    AT_int_eq(status, APR_INCOMPLETE);
+    AT_int_eq(dest_len, sizeof(expect2) - 1);
+    AT_mem_eq(dest, expect2, sizeof(expect2) - 1);
+}
+
+
+static void test_encode(dAT)
+{
+
+}
+
+static void test_cp1252_to_utf8(dAT)
+{
+    char src1[] = "%C3%80%E3%82%a2"; /* A_GRAVE KATAKANA_A as utf8 */
+    char src2[5];
+    unsigned char expect[16];
+    apr_size_t slen;
+
+    AT_int_eq(apreq_decode((char *)src2, &slen, src1, sizeof(src1) -1),
+              APR_SUCCESS);
+    AT_int_eq(apreq_cp1252_to_utf8((char *)expect, src2, 5),
+              12);
+
+    /* 0xC3 */
+    AT_int_eq(expect[0], 0xC0 | (0xC3 >> 6));
+    AT_int_eq(expect[1], 0xC3 - 0x40);
+
+    /* 0x20AC */
+    AT_int_eq(expect[2], 0xE0 | (0x20AC >> 12));
+    AT_int_eq(expect[3], 0x80 | ((0x20AC >> 6) & 0x3F));
+    AT_int_eq(expect[4], 0x80 | (0x20AC & 0x3F));
+
+    /* 0xE3 */
+    AT_int_eq(expect[5], 0xC3);
+    AT_int_eq(expect[6], 0xE3 - 0x40);
+
+    /* 0x201A */
+    AT_int_eq(expect[7], 0xE0 | (0x201A >> 12));
+    AT_int_eq(expect[8], 0x80 | ((0x201A >> 6) & 0x3F));
+    AT_int_eq(expect[9], 0x80 | (0x201A & 0x3F));
+
+
+    /* 0xA2 */
+    AT_int_eq(expect[10], 0xC0 | (0xA2 >> 6));
+    AT_int_eq(expect[11], 0xA2);
+
+}
+
+static void test_quote(dAT)
+{
+    size_t len;
+    char dst[64];
+
+    len = apreq_quote(dst, "foo", 3);
+    AT_int_eq(len, 5);
+    AT_str_eq(dst, "\"foo\"");
+
+    len = apreq_quote(dst, "\"foo", 4);
+    AT_int_eq(len, 7);
+    AT_str_eq(dst, "\"\\\"foo\"");
+
+    len = apreq_quote(dst, "foo\\bar", 7);
+    AT_int_eq(len, 10);
+    AT_str_eq(dst, "\"foo\\\\bar\"");
+
+    len = apreq_quote(dst, "foo\0bar", 7);
+    AT_int_eq(len, 10);
+    AT_str_eq(dst, "\"foo\\0bar\"");
+}
+
+static void test_quote_once(dAT)
+{
+    size_t len;
+    char dst[64];
+
+    len = apreq_quote_once(dst, "foo", 3);
+    AT_int_eq(len, 5);
+    AT_str_eq(dst, "\"foo\"");
+
+    len = apreq_quote_once(dst, "\"foo", 4);
+    AT_int_eq(len, 7);
+    AT_str_eq(dst, "\"\\\"foo\"");
+
+    len = apreq_quote_once(dst, "foo\"", 4);
+    AT_int_eq(len, 7);
+    AT_str_eq(dst, "\"foo\\\"\"");
+
+    len = apreq_quote_once(dst, "foo\0bar", 7);
+    AT_int_eq(len, 10);
+    AT_str_eq(dst, "\"foo\\0bar\"");
+
+    /* null byte must be escaped, even when there are already double
+       quotes */
+    len = apreq_quote_once(dst, "\"foo\0bar\"", 9);
+    AT_int_eq(len, 14);
+    AT_str_eq(dst, "\"\\\"foo\\0bar\\\"\"");
+
+    len = apreq_quote_once(dst, "\"foo\"", 5);
+    AT_int_eq(len, 5);
+    AT_str_eq(dst, "\"foo\"");
+
+    len = apreq_quote_once(dst, "'foo'", 5);
+    AT_int_eq(len, 7);
+    AT_str_eq(dst, "\"'foo'\"");
+
+    len = apreq_quote_once(dst, "\"fo\\o\"", 6);
+    AT_int_eq(len, 6);
+    AT_str_eq(dst, "\"fo\\o\"");
+
+    len = apreq_quote_once(dst, "\"foo\"bar\"", 9);
+    AT_int_eq(len, 14);
+    AT_str_eq(dst, "\"\\\"foo\\\"bar\\\"\"");
+}
+
+static void test_join(dAT)
+{
+
+}
+
+static void test_brigade_fwrite(dAT)
+{
+
+}
+
+static void test_file_mktemp(dAT)
+{
+
+
+}
+
+static void test_header_attribute(dAT)
+{
+    const char hdr[] = "filename=\"filename=foo\" filename=\"quux.txt\"";
+    const char *val;
+    apr_size_t vlen;
+
+    AT_int_eq(apreq_header_attribute(hdr+4, "name", 4, &val, &vlen),
+              APR_SUCCESS);
+    AT_int_eq(vlen, 12);
+    AT_mem_eq("filename=foo", val, 12);
+
+    AT_int_eq(apreq_header_attribute(hdr+4, "filename", 8, &val, &vlen),
+              APR_SUCCESS);
+    AT_int_eq(vlen, 8);
+    AT_mem_eq("quux.txt", val, 8);
+
+}
+
+static void test_brigade_concat(dAT)
+{
+
+}
+
+
+
+#define dT(func, plan) #func, func, plan
+
+
+int main(int argc, char *argv[])
+{
+    unsigned i, plan = 0;
+    apr_pool_t *p;
+    dAT;
+    at_test_t test_list [] = {
+        { dT(test_atoi64f, 9) },
+        { dT(test_atoi64t, 9) },
+        { dT(test_index, 6) },
+        { dT(test_decode, 7) },
+        { dT(test_charset_divine, 6) },
+        { dT(test_decodev, 6) },
+        { dT(test_encode, 0) },
+        { dT(test_cp1252_to_utf8, 14) },
+        { dT(test_quote, 8) },
+        { dT(test_quote_once, 18), },
+        { dT(test_join, 0) },
+        { dT(test_brigade_fwrite, 0) },
+        { dT(test_file_mktemp, 0) },
+        { dT(test_header_attribute, 6) },
+        { dT(test_brigade_concat, 0) },
+    };
+
+    apr_initialize();
+    atexit(apr_terminate);
+
+    apr_pool_create(&p, NULL);
+
+    AT = at_create(p, 0, at_report_stdout_make(p));
+
+    for (i = 0; i < sizeof(test_list) / sizeof(at_test_t);  ++i)
+        plan += test_list[i].plan;
+
+    AT_begin(plan);
+
+    for (i = 0; i < sizeof(test_list) / sizeof(at_test_t);  ++i)
+        AT_run(&test_list[i]);
+
+    AT_end();
+
+    return 0;
+}
+/*
+**  Licensed to the Apache Software Foundation (ASF) under one or more
+** contributor license agreements.  See the NOTICE file distributed with
+** this work for additional information regarding copyright ownership.
+** The ASF licenses this file to You under the Apache License, Version 2.0
+** (the "License"); you may not use this file except in compliance with
+** the License.  You may obtain a copy of the License at
 **
 **      http://www.apache.org/licenses/LICENSE-2.0
 **
@@ -692,6 +1033,10 @@
     return rv;
 }
 
+/*
+ * This is intentionally not apr_file_writev()
+ * note, this is iterative and not recursive
+ */
 APR_INLINE
 static apr_status_t apreq_fwritev(apr_file_t *f, struct iovec *v,
                                   int *nelts, apr_size_t *bytes_written)
@@ -713,7 +1058,30 @@
 
         /* see how far we've come */
         n = 0;
+
+#ifdef SOLARIS2
+# ifdef __GNUC__
+        /*
+         * iovec.iov_len is a long here
+         * which causes a comparison between 
+         * signed(long) and unsigned(apr_size_t)
+         *
+         */
+        while (n < *nelts && len >= (apr_size_t)v[n].iov_len)
+# else
+          /*
+           * Sun C however defines this as size_t which is unsigned
+           * 
+           */
+        while (n < *nelts && len >= v[n].iov_len)
+# endif /* !__GNUC__ */
+#else
+          /*
+           * Hopefully everything else does this
+           * (this was the default for years)
+           */
         while (n < *nelts && len >= v[n].iov_len)
+#endif
             len -= v[n++].iov_len;
 
         if (n == *nelts) {
@@ -743,43 +1111,6 @@
 }
 
 
-APREQ_DECLARE(apr_status_t) apreq_brigade_fwrite(apr_file_t *f,
-                                                 apr_off_t *wlen,
-                                                 apr_bucket_brigade *bb)
-{
-    struct iovec v[APREQ_DEFAULT_NELTS];
-    apr_status_t s;
-    apr_bucket *e;
-    int n = 0;
-    *wlen = 0;
-
-    for (e = APR_BRIGADE_FIRST(bb); e != APR_BRIGADE_SENTINEL(bb);
-         e = APR_BUCKET_NEXT(e))
-    {
-        apr_size_t len;
-        if (n == APREQ_DEFAULT_NELTS) {
-            s = apreq_fwritev(f, v, &n, &len);
-            if (s != APR_SUCCESS)
-                return s;
-            *wlen += len;
-        }
-        s = apr_bucket_read(e, (const char **)&(v[n].iov_base),
-                            &len, APR_BLOCK_READ);
-        if (s != APR_SUCCESS)
-            return s;
-
-        v[n++].iov_len = len;
-    }
-
-    while (n > 0) {
-        apr_size_t len;
-        s = apreq_fwritev(f, v, &n, &len);
-        if (s != APR_SUCCESS)
-            return s;
-        *wlen += len;
-    }
-    return APR_SUCCESS;
-}
 
 
 struct cleanup_data {
@@ -811,6 +1142,7 @@
     apr_status_t rc;
     char *tmpl;
     struct cleanup_data *data;
+    apr_int32_t flag;
 
     if (path == NULL) {
         rc = apr_temp_dir_get(&path, pool);
@@ -829,9 +1161,10 @@
     apr_pool_cleanup_register(pool, data,
                               apreq_file_cleanup, apreq_file_cleanup);
 
-    rc = apr_file_mktemp(fp, tmpl, /* NO APR_DELONCLOSE! see comment above */
-                           APR_CREATE | APR_READ | APR_WRITE
-                           | APR_EXCL | APR_BINARY, pool);
+    /* NO APR_DELONCLOSE! see comment above */
+    flag = APR_CREATE | APR_READ | APR_WRITE | APR_EXCL | APR_BINARY;
+
+    rc = apr_file_mktemp(fp, tmpl, flag, pool);
 
     if (rc == APR_SUCCESS) {
         apr_file_name_get(&data->fname, *fp);
@@ -1116,3 +1449,60 @@
     return s;
 }
 
+APREQ_DECLARE(apr_status_t) apreq_brigade_fwrite(apr_file_t *f,
+                                                 apr_off_t *wlen,
+                                                 apr_bucket_brigade *bb)
+{
+    struct iovec v[APREQ_DEFAULT_NELTS];
+    apr_status_t s;
+    apr_bucket *e, *first;
+    int n = 0;
+    apr_bucket_brigade *tmp = bb;
+    *wlen = 0;
+
+    if (BUCKET_IS_SPOOL(APR_BRIGADE_LAST(bb))) {
+        tmp = apr_brigade_create(bb->p, bb->bucket_alloc);
+
+        s = apreq_brigade_copy(tmp, bb);
+        if (s != APR_SUCCESS)
+            return s;
+    }
+
+    for (e = APR_BRIGADE_FIRST(tmp); e != APR_BRIGADE_SENTINEL(tmp);
+         e = APR_BUCKET_NEXT(e))
+    {
+        apr_size_t len;
+        if (n == APREQ_DEFAULT_NELTS) {
+            s = apreq_fwritev(f, v, &n, &len);
+            if (s != APR_SUCCESS)
+                return s;
+
+            if (tmp != bb) {
+                while ((first = APR_BRIGADE_FIRST(tmp)) != e)
+                    apr_bucket_delete(first);
+            }
+
+            *wlen += len;
+        }
+        s = apr_bucket_read(e, (const char **)&(v[n].iov_base),
+                            &len, APR_BLOCK_READ);
+        if (s != APR_SUCCESS)
+            return s;
+
+        v[n++].iov_len = len;
+    }
+
+    while (n > 0) {
+        apr_size_t len;
+        s = apreq_fwritev(f, v, &n, &len);
+        if (s != APR_SUCCESS)
+            return s;
+        *wlen += len;
+
+        if (tmp != bb) {
+            while ((first = APR_BRIGADE_FIRST(tmp)) != e)
+                apr_bucket_delete(first);
+        }
+    }
+    return APR_SUCCESS;
+}

Modified: httpd/apreq/branches/apr-build-system/libapreq/library/version.c
URL: http://svn.apache.org/viewvc/httpd/apreq/branches/apr-build-system/libapreq/library/version.c?rev=724901&r1=724900&r2=724901&view=diff
==============================================================================
--- httpd/apreq/branches/apr-build-system/libapreq/library/version.c (original)
+++ httpd/apreq/branches/apr-build-system/libapreq/library/version.c Tue Dec  9 13:33:21 2008
@@ -1,9 +1,79 @@
 /*
-**  Copyright 2003-2006  The Apache Software Foundation
+**  Licensed to the Apache Software Foundation (ASF) under one or more
+** contributor license agreements.  See the NOTICE file distributed with
+** this work for additional information regarding copyright ownership.
+** The ASF licenses this file to You under the Apache License, Version 2.0
+** (the "License"); you may not use this file except in compliance with
+** the License.  You may obtain a copy of the License at
 **
-**  Licensed under the Apache License, Version 2.0 (the "License");
-**  you may not use this file except in compliance with the License.
-**  You may obtain a copy of the License at
+**      http://www.apache.org/licenses/LICENSE-2.0
+**
+**  Unless required by applicable law or agreed to in writing, software
+**  distributed under the License is distributed on an "AS IS" BASIS,
+**  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+**  See the License for the specific language governing permissions and
+**  limitations under the License.
+*/
+
+#include "apreq_version.h"
+#include "at.h"
+
+static void version_string(dAT)
+{
+    const char *vstring = apreq_version_string();
+    AT_not_null(vstring);
+    AT_str_eq(vstring, APREQ_VERSION_STRING);
+}
+static void version_type(dAT)
+{
+    apr_version_t v;
+    apreq_version(&v);
+    AT_int_eq(v.major, APREQ_MAJOR_VERSION);
+    AT_int_eq(v.minor, APREQ_MINOR_VERSION);
+    AT_int_eq(v.patch, APREQ_PATCH_VERSION);
+#ifdef APREQ_IS_DEV_VERSION
+    AT_int_eq(v.is_dev, 1);
+#else
+    AT_int_eq(v.is_dev, 0);
+#endif
+}
+
+int main(int argc, char *argv[])
+{
+    apr_pool_t *p;
+    unsigned i, plan = 0;
+    dAT;
+    at_test_t test_list [] = {
+        {"version_string", version_string, 2, "1"},
+        {"version_type", version_type, 4}
+    };
+
+    apr_initialize();
+    atexit(apr_terminate);
+
+    apr_pool_create(&p, NULL);
+
+    AT = at_create(p, 0, at_report_stdout_make(p));
+
+    for (i = 0; i < sizeof(test_list) / sizeof(at_test_t);  ++i)
+        plan += test_list[i].plan;
+
+    AT_begin(plan);
+
+    for (i = 0; i < sizeof(test_list) / sizeof(at_test_t);  ++i)
+        AT_run(&test_list[i]);
+
+    AT_end();
+
+    return 0;
+}
+/*
+**  Licensed to the Apache Software Foundation (ASF) under one or more
+** contributor license agreements.  See the NOTICE file distributed with
+** this work for additional information regarding copyright ownership.
+** The ASF licenses this file to You under the Apache License, Version 2.0
+** (the "License"); you may not use this file except in compliance with
+** the License.  You may obtain a copy of the License at
 **
 **      http://www.apache.org/licenses/LICENSE-2.0
 **



Mime
View raw message