You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by sa...@apache.org on 2005/12/09 10:40:15 UTC
svn commit: r355429 - in /webservices/axis2/trunk/c/modules/util/src:
axis2_utils.h utils.c
Author: samisa
Date: Fri Dec 9 01:40:01 2005
New Revision: 355429
URL: http://svn.apache.org/viewcvs?rev=355429&view=rev
Log:
Added util.c and axis2_util.h
Added:
webservices/axis2/trunk/c/modules/util/src/axis2_utils.h (with props)
webservices/axis2/trunk/c/modules/util/src/utils.c (with props)
Added: webservices/axis2/trunk/c/modules/util/src/axis2_utils.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/util/src/axis2_utils.h?rev=355429&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/util/src/axis2_utils.h (added)
+++ webservices/axis2/trunk/c/modules/util/src/axis2_utils.h Fri Dec 9 01:40:01 2005
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2004,2005 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
+ *
+ * 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.
+ */
+
+#ifndef AXIS2_UTILS_H
+#define AXIS2_UTILS_H
+
+#include <axis2.h>
+#include <axis2_defines.h>
+#include <axis2_error.h>
+#include <axis2_env.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/**
+ * @defgroup axis2_utils Utils
+ * @ingroup axis2_utils
+ * @{
+ */
+#define AXIS2_REQUEST_URL_PREFIX "/services"
+ /**
+ * This function allows users to reolve the service and operation from the
+ * url. It returns an array of 2 elements of axis2_char_t arrays (strings).
+ * The caller is responsible to free the memory allocated by the function
+ * for the return value.
+ *
+ * @param request url
+ * @return axis2_char_t ** <code>axis2_char_t **<code>
+ */
+ AXIS2_DECLARE(axis2_char_t**)
+ axis2_parse_request_url_for_svc_and_operation(axis2_env_t **env, axis2_char_t *request);
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* AXIS2_UTILS_H */
Propchange: webservices/axis2/trunk/c/modules/util/src/axis2_utils.h
------------------------------------------------------------------------------
svn:executable = *
Added: webservices/axis2/trunk/c/modules/util/src/utils.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/util/src/utils.c?rev=355429&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/util/src/utils.c (added)
+++ webservices/axis2/trunk/c/modules/util/src/utils.c Fri Dec 9 01:40:01 2005
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2004,2005 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
+ *
+ * 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 <axis2_utils.h>
+#include <stdlib.h>
+#include <axis2_string.h>
+#include <string.h>
+
+AXIS2_DECLARE(axis2_char_t**)
+axis2_parse_request_url_for_svc_and_operation(axis2_env_t **env,
+ axis2_char_t *request)
+
+{
+ AXIS2_FUNC_PARAM_CHECK(request, env, NULL);
+ axis2_char_t **ret = AXIS2_MALLOC((*env)->allocator,
+ 2*(sizeof(axis2_char_t *)));
+ memset(ret, 0, 2*sizeof(axis2_char_t*));
+
+ axis2_char_t *service_str = NULL;
+ axis2_char_t *tmp = request;
+ int i = 0;
+
+ while(1)
+ {
+ tmp = strstr(tmp, AXIS2_REQUEST_URL_PREFIX);
+ if(NULL == tmp)
+ break;
+ else
+ {
+ service_str = tmp;
+ tmp += AXIS2_STRLEN(AXIS2_REQUEST_URL_PREFIX);
+ }
+ }
+ if(NULL != service_str)
+ {
+ service_str += AXIS2_STRLEN(AXIS2_REQUEST_URL_PREFIX);
+ if('\0' != *service_str)
+ {
+ service_str++; /*to remove the leading '/' */
+ tmp = strchr(service_str, '/');
+ if(NULL != tmp)
+ {
+ i = tmp - service_str;
+ ret[0] = AXIS2_MALLOC((*env)->allocator, i*sizeof(char)+1);
+ strncpy(ret[0], service_str,i);
+ ret[0][i] = '\0';
+
+ /* Now search for the operation */
+ service_str = tmp;
+ if('\0' != *service_str)
+ {
+ service_str++;
+ tmp = strchr(service_str, '?');
+ if(NULL != tmp)
+ {
+ i = tmp - service_str;
+ ret[1] = AXIS2_MALLOC((*env)->allocator,
+ i*sizeof(char)+1);
+ strncpy(ret[1], service_str,i);
+ ret[1][i] = '\0';
+ }
+ else
+ {
+ ret[1] = AXIS2_STRDUP(service_str, env);
+ }
+ }
+ }
+ else
+ {
+ ret[0] = AXIS2_STRDUP(service_str, env);
+ }
+ }
+ }
+ return ret;
+}
Propchange: webservices/axis2/trunk/c/modules/util/src/utils.c
------------------------------------------------------------------------------
svn:executable = *