summaryrefslogtreecommitdiff
path: root/util-misc
diff options
context:
space:
mode:
authorGraham Leggett <minfrin@apache.org>2018-08-19 11:39:35 +0000
committerGraham Leggett <minfrin@apache.org>2018-08-19 11:39:35 +0000
commit2d02c4dfffa668e7c785c201ceef4c8bf64983d3 (patch)
tree09435a71965e09eb9321bf4b67b3db9806569e62 /util-misc
parent5a1b9a92dad639eea47c78e28bae25eafa014331 (diff)
downloadapr-2d02c4dfffa668e7c785c201ceef4c8bf64983d3.tar.gz
Add apr_errprintf() as a convenience function to create and
populate apu_err_t. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1838375 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'util-misc')
-rw-r--r--util-misc/apr_error.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/util-misc/apr_error.c b/util-misc/apr_error.c
new file mode 100644
index 000000000..a3835e1a9
--- /dev/null
+++ b/util-misc/apr_error.c
@@ -0,0 +1,45 @@
+/* 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
+ * levelations under the License.
+ */
+
+#include "apu.h"
+#include "apr_strings.h"
+#include "apr_pools.h"
+#include "apu_errno.h"
+
+APR_DECLARE_NONSTD(apr_status_t) apr_errprintf(apu_err_t **result,
+ apr_pool_t *p, const char *reason, int rc, const char *fmt, ...)
+{
+ va_list ap;
+ apu_err_t *res;
+
+ res = *result;
+ if (!res) {
+ res = *result = apr_pcalloc(p, sizeof(apu_err_t));
+ if (!res) {
+ return APR_ENOMEM;
+ }
+ }
+
+ va_start(ap, fmt);
+ res->msg = apr_pvsprintf(p, fmt, ap);
+ va_end(ap);
+
+ res->reason = reason;
+ res->rc = rc;
+
+ return APR_SUCCESS;
+}
+