[mapserver-commits] r12171 - in trunk/mapserver/mapcache: include
src
svn at osgeo.org
svn at osgeo.org
Fri Aug 26 07:04:06 EDT 2011
Author: tbonfort
Date: 2011-08-26 04:04:06 -0700 (Fri, 26 Aug 2011)
New Revision: 12171
Modified:
trunk/mapserver/mapcache/include/util.h
trunk/mapserver/mapcache/src/util.c
Log:
prefer pthread locks if available
thomas.bonfort | 2010-12-09 18:05:25 +0100 (Thu, 09 Dec 2010)
Modified: trunk/mapserver/mapcache/include/util.h
===================================================================
--- trunk/mapserver/mapcache/include/util.h 2011-08-26 11:04:01 UTC (rev 12170)
+++ trunk/mapserver/mapcache/include/util.h 2011-08-26 11:04:06 UTC (rev 12171)
@@ -1,16 +1,51 @@
/*
- * util.h
+ * Copyright 2010 Thomas Bonfort
*
- * Created on: Oct 11, 2010
- * Author: tom
+ * 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_version.h>
#ifndef UTIL_H_
#define UTIL_H_
#define GEOCACHE_MAX(a,b) (((a)>(b))?(a):(b))
#define GEOCACHE_MIN(a,b) (((a)<(b))?(a):(b))
+#if APR_MAJOR_VERSION < 2 && APR_MINOR_VERSION < 3
+/**
+ * Create a hard link to the specified file.
+ * @param from_path The full path to the original file (using / on all systems)
+ * @param to_path The full path to the new file (using / on all systems)
+ * @remark Both files must reside on the same device.
+ */
+APR_DECLARE(apr_status_t) apr_file_link(const char *from_path, const char *to_path);
+
+/**
+ * Create a new table whose contents are deep copied from the given
+ * table. A deep copy operation copies all fields, and makes copies
+ * of dynamically allocated memory pointed to by the fields.
+ * @param p The pool to allocate the new table out of
+ * @param t The table to clone
+ * @return A deep copy of the table passed in
+ */
+APR_DECLARE(apr_table_t *) apr_table_clone(apr_pool_t *p,
+ const apr_table_t *t);
+
+
+#endif
+
+
+
#endif /* UTIL_H_ */
Modified: trunk/mapserver/mapcache/src/util.c
===================================================================
--- trunk/mapserver/mapcache/src/util.c 2011-08-26 11:04:01 UTC (rev 12170)
+++ trunk/mapserver/mapcache/src/util.c 2011-08-26 11:04:06 UTC (rev 12171)
@@ -14,7 +14,8 @@
* limitations under the License.
*/
-#include <geocache.h>
+#include "geocache.h"
+#include "util.h"
#include <apr_strings.h>
#include <apr_tables.h>
#include <curl/curl.h>
@@ -65,6 +66,34 @@
return GEOCACHE_SUCCESS;
}
+
+#if APR_MAJOR_VERSION < 2 && APR_MINOR_VERSION < 3
+
+APR_DECLARE(apr_status_t) apr_file_link(const char *from_path,
+ const char *to_path)
+{
+ if (link(from_path, to_path) == -1) {
+ return errno;
+ }
+ return APR_SUCCESS;
+}
+
+APR_DECLARE(apr_table_t *) apr_table_clone(apr_pool_t *p, const apr_table_t *t)
+{
+ const apr_array_header_t *array = apr_table_elts(t);
+ apr_table_entry_t *elts = (apr_table_entry_t *) array->elts;
+ apr_table_t *new = apr_table_make(p, array->nelts);
+ int i;
+
+ for (i = 0; i < array->nelts; i++) {
+ apr_table_add(new, elts[i].key, elts[i].val);
+ }
+
+ return new;
+}
+
+#endif
+
geocache_error_code _geocache_context_get_error_default(geocache_context *ctx) {
return ctx->_errcode;
}
@@ -97,5 +126,3 @@
ctx->set_error = _geocache_context_set_error_default;
}
-
-
More information about the mapserver-commits
mailing list