[mapserver-commits] r7328 - trunk/mapserver
svn at osgeo.org
svn at osgeo.org
Wed Jan 30 14:03:03 EST 2008
Author: tomkralidis
Date: 2008-01-30 14:03:03 -0500 (Wed, 30 Jan 2008)
New Revision: 7328
Modified:
trunk/mapserver/mapows.c
trunk/mapserver/mapows.h
Log:
add version negotiation
Modified: trunk/mapserver/mapows.c
===================================================================
--- trunk/mapserver/mapows.c 2008-01-30 15:19:56 UTC (rev 7327)
+++ trunk/mapserver/mapows.c 2008-01-30 19:03:03 UTC (rev 7328)
@@ -160,7 +160,38 @@
return MS_SUCCESS;
}
+/*
+** msOWSNegotiateVersion()
+**
+** returns the most suitable version an OWS is to support given a client
+** version parameter.
+**
+** supported_versions must be ordered from highest to lowest
+**
+** Returns a version integer of the supported version
+**
+*/
+int msOWSNegotiateVersion(int requested_version, int supported_versions[], int num_supported_versions) {
+ int i;
+
+ /* if version is not set return highest version */
+ if (! requested_version)
+ return supported_versions[0];
+
+ /* if the requested version is lower than the lowest version return the lowest version */
+ if (requested_version < supported_versions[num_supported_versions-1])
+ return supported_versions[num_supported_versions-1];
+
+ /* return the first entry that's lower than or equal to the requested version */
+ for (i = 0; i < num_supported_versions; i++) {
+ if (supported_versions[i] <= requested_version)
+ return supported_versions[i];
+ }
+
+ return requested_version;
+}
+
/*
** msOWSTerminateOnlineResource()
**
Modified: trunk/mapserver/mapows.h
===================================================================
--- trunk/mapserver/mapows.h 2008-01-30 15:19:56 UTC (rev 7327)
+++ trunk/mapserver/mapows.h 2008-01-30 19:03:03 UTC (rev 7328)
@@ -66,6 +66,7 @@
typedef struct {
char *pszVersion;
+ char *pszAcceptVersions;
char *pszUpdateSequence;
char *pszRequest;
char *pszService;
@@ -116,6 +117,7 @@
#if defined(USE_WMS_SVR) || defined (USE_WFS_SVR) || defined (USE_WCS_SVR) || defined(USE_SOS_SVR) || defined(USE_WMS_LYR) || defined(USE_WFS_LYR)
MS_DLL_EXPORT int msOWSMakeAllLayersUnique(mapObj *map);
+MS_DLL_EXPORT int msOWSNegotiateVersion(int requested_version, int supported_versions[], int num_supported_versions);
MS_DLL_EXPORT char *msOWSTerminateOnlineResource(const char *src_url);
MS_DLL_EXPORT char *msOWSGetOnlineResource(mapObj *map, const char *namespaces, const char *metadata_name, cgiRequestObj *req);
MS_DLL_EXPORT const char *msOWSGetSchemasLocation(mapObj *map);
More information about the mapserver-commits
mailing list