You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by na...@apache.org on 2006/04/24 06:19:04 UTC
svn commit: r396416 - in /webservices/axis2/trunk/c:
include/xml_schema/axis2_string_util.h modules/xml/xml_schema/string_util.c
Author: nandika
Date: Sun Apr 23 21:19:00 2006
New Revision: 396416
URL: http://svn.apache.org/viewcvs?rev=396416&view=rev
Log: (empty)
Added:
webservices/axis2/trunk/c/include/xml_schema/axis2_string_util.h
webservices/axis2/trunk/c/modules/xml/xml_schema/string_util.c
Added: webservices/axis2/trunk/c/include/xml_schema/axis2_string_util.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/include/xml_schema/axis2_string_util.h?rev=396416&view=auto
==============================================================================
--- webservices/axis2/trunk/c/include/xml_schema/axis2_string_util.h (added)
+++ webservices/axis2/trunk/c/include/xml_schema/axis2_string_util.h Sun Apr 23 21:19:00 2006
@@ -0,0 +1,45 @@
+/*
+ * 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_STRING_UTILS_H
+#define AXIS2_STRING_UTILS_H
+
+#include <axis2_array_list.h>
+#include <axis2_string.h>
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+AXIS2_DECLARE(axis2_array_list_t *)
+axis2_tokenize(axis2_env_t **env,
+ axis2_char_t *in,
+ int delim);
+
+AXIS2_DECLARE(axis2_array_list_t *)
+axis2_first_token(axis2_env_t **env,
+ axis2_char_t *in,
+ int delim);
+
+AXIS2_DECLARE(axis2_array_list_t *)
+axis2_last_token(axis2_env_t **env,
+ axis2_char_t *in,
+ int delim);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* AXIS2_STRING_UTILS_H */
Added: webservices/axis2/trunk/c/modules/xml/xml_schema/string_util.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/xml_schema/string_util.c?rev=396416&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/xml_schema/string_util.c (added)
+++ webservices/axis2/trunk/c/modules/xml/xml_schema/string_util.c Sun Apr 23 21:19:00 2006
@@ -0,0 +1,141 @@
+/*
+ * 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_string_util.h>
+#include <string.h>
+#include <axis2.h>
+
+AXIS2_DECLARE(axis2_array_list_t *)
+axis2_tokenize(axis2_env_t **env,
+ axis2_char_t *in,
+ int delim)
+{
+ axis2_array_list_t *list = NULL;
+ axis2_char_t *rest = NULL;
+ axis2_char_t *str = NULL;
+
+ int i = 0;
+ axis2_char_t *index = NULL;
+
+ if(!in || AXIS2_STRCMP(in, "") == 0)
+ return NULL;
+ list = axis2_array_list_create(env, 10);
+ if(!list)
+ return NULL;
+
+ str = AXIS2_STRDUP(in, env);
+
+ do{
+ index = strchr(str, delim);
+ if((index == NULL) && (NULL != str) && AXIS2_STRCMP(str,"") != 0)
+ {
+ AXIS2_ARRAY_LIST_ADD(list, env, str);
+ break;
+ }
+
+ rest = index + 1;
+ str[index - str] = '\0';
+ if((NULL != list) && (NULL != str) && AXIS2_STRCMP(str,"") != 0)
+ {
+
+ AXIS2_ARRAY_LIST_ADD(list, env, str);
+ }
+
+ if(!rest || AXIS2_STRCMP(rest,"") == 0)
+ break;
+ str = rest;
+ rest = NULL;
+ index = NULL;
+
+ }while(1);
+ return list;
+}
+
+AXIS2_DECLARE(axis2_array_list_t *)
+axis2_first_token(axis2_env_t **env,
+ axis2_char_t *in,
+ int delim)
+{
+ axis2_array_list_t *list = NULL;
+ axis2_char_t *str = NULL;
+ axis2_char_t *rest = NULL;
+ axis2_char_t *index = NULL;
+ AXIS2_ENV_CHECK(env, NULL);
+
+ if(!in && (AXIS2_STRCMP(in,"") == 0))
+ {
+ return NULL;
+ }
+
+ list = axis2_array_list_create(env, 2);
+ if(NULL == list)
+ return NULL;
+ str = AXIS2_STRDUP(in, env);
+
+ index = strchr(str, delim);
+ if(index == NULL)
+ {
+ AXIS2_ARRAY_LIST_ADD(list, env, str);
+ AXIS2_ARRAY_LIST_ADD(list, env, AXIS2_STRDUP("", env));
+ return list;
+ }
+
+ rest = index + 1;
+ str[index - str] = '\0';
+
+ AXIS2_ARRAY_LIST_ADD(list, env, str);
+ AXIS2_ARRAY_LIST_ADD(list, env, rest);
+ return list;
+}
+
+AXIS2_DECLARE(axis2_array_list_t *)
+axis2_last_token(axis2_env_t **env,
+ axis2_char_t *in,
+ int delim)
+{
+ axis2_array_list_t *list = NULL;
+ axis2_char_t *str = NULL;
+ axis2_char_t *rest = NULL;
+ axis2_char_t *index = NULL;
+ AXIS2_ENV_CHECK(env, NULL);
+
+ if(!in && (AXIS2_STRCMP(in,"") == 0))
+ {
+ return NULL;
+ }
+
+ list = axis2_array_list_create(env, 2);
+ if(NULL == list)
+ return NULL;
+
+ str = AXIS2_STRDUP(in, env);
+ index = AXIS2_RINDEX(str, delim);
+
+ if(index == NULL)
+ {
+ AXIS2_ARRAY_LIST_ADD(list, env, AXIS2_STRDUP("", env));
+ AXIS2_ARRAY_LIST_ADD(list, env, str);
+ return list;
+ }
+
+ rest = index + 1;
+ str[index - str] = '\0';
+
+ AXIS2_ARRAY_LIST_ADD(list, env, str);
+ AXIS2_ARRAY_LIST_ADD(list, env, rest);
+
+ return list;
+}
\ No newline at end of file