From 0425aadc78680e53000fd0108b540d6eca048516 Mon Sep 17 00:00:00 2001 From: gmcdonald Date: Sat, 13 Feb 2010 01:32:03 +0000 Subject: Moving axis svn, part of TLP move INFRA-2441 git-svn-id: http://svn.apache.org/repos/asf/axis/axis2/c/core/trunk@909681 13f79535-47bb-0310-9956-ffa450edef68 --- util/include/Makefile.am | 2 + util/include/axutil_allocator.h | 200 +++++ util/include/axutil_array_list.h | 250 ++++++ util/include/axutil_base64.h | 122 +++ util/include/axutil_base64_binary.h | 173 ++++ util/include/axutil_class_loader.h | 63 ++ util/include/axutil_config.h | 42 + util/include/axutil_date_time.h | 350 ++++++++ util/include/axutil_date_time_util.h | 51 ++ util/include/axutil_digest_calc.h | 109 +++ util/include/axutil_dir_handler.h | 73 ++ util/include/axutil_dll_desc.h | 191 +++++ util/include/axutil_duration.h | 181 +++++ util/include/axutil_env.h | 233 ++++++ util/include/axutil_error.h | 876 +++++++++++++++++++++ util/include/axutil_error_default.h | 52 ++ util/include/axutil_file.h | 99 +++ util/include/axutil_file_handler.h | 91 +++ util/include/axutil_generic_obj.h | 85 ++ util/include/axutil_hash.h | 301 +++++++ util/include/axutil_http_chunked_stream.h | 132 ++++ util/include/axutil_linked_list.h | 334 ++++++++ util/include/axutil_log.h | 259 ++++++ util/include/axutil_log_default.h | 64 ++ util/include/axutil_md5.h | 130 +++ util/include/axutil_network_handler.h | 194 +++++ util/include/axutil_param.h | 200 +++++ util/include/axutil_param_container.h | 134 ++++ util/include/axutil_properties.h | 137 ++++ util/include/axutil_property.h | 124 +++ util/include/axutil_qname.h | 142 ++++ util/include/axutil_rand.h | 83 ++ util/include/axutil_stack.h | 93 +++ util/include/axutil_stream.h | 294 +++++++ util/include/axutil_string.h | 350 ++++++++ util/include/axutil_string_util.h | 56 ++ util/include/axutil_thread.h | 272 +++++++ util/include/axutil_thread_pool.h | 126 +++ util/include/axutil_types.h | 73 ++ util/include/axutil_uri.h | 277 +++++++ util/include/axutil_url.h | 149 ++++ util/include/axutil_utils.h | 263 +++++++ util/include/axutil_utils_defines.h | 226 ++++++ util/include/axutil_uuid_gen.h | 51 ++ util/include/axutil_version.h | 140 ++++ .../include/platforms/axutil_platform_auto_sense.h | 63 ++ .../platforms/unix/axutil_date_time_util_unix.h | 46 ++ util/include/platforms/unix/axutil_thread_unix.h | 59 ++ util/include/platforms/unix/axutil_unix.h | 279 +++++++ util/include/platforms/unix/axutil_uuid_gen_unix.h | 94 +++ .../windows/axutil_date_time_util_windows.h | 45 ++ .../include/platforms/windows/axutil_dir_windows.h | 123 +++ .../platforms/windows/axutil_getopt_windows.h | 79 ++ .../windows/axutil_thread_mutex_windows.h | 44 ++ .../platforms/windows/axutil_thread_windows.h | 140 ++++ .../platforms/windows/axutil_uuid_gen_windows.h | 46 ++ util/include/platforms/windows/axutil_windows.h | 278 +++++++ 57 files changed, 9143 insertions(+) create mode 100644 util/include/Makefile.am create mode 100644 util/include/axutil_allocator.h create mode 100644 util/include/axutil_array_list.h create mode 100644 util/include/axutil_base64.h create mode 100644 util/include/axutil_base64_binary.h create mode 100644 util/include/axutil_class_loader.h create mode 100644 util/include/axutil_config.h create mode 100644 util/include/axutil_date_time.h create mode 100644 util/include/axutil_date_time_util.h create mode 100644 util/include/axutil_digest_calc.h create mode 100644 util/include/axutil_dir_handler.h create mode 100644 util/include/axutil_dll_desc.h create mode 100644 util/include/axutil_duration.h create mode 100644 util/include/axutil_env.h create mode 100644 util/include/axutil_error.h create mode 100644 util/include/axutil_error_default.h create mode 100644 util/include/axutil_file.h create mode 100644 util/include/axutil_file_handler.h create mode 100644 util/include/axutil_generic_obj.h create mode 100644 util/include/axutil_hash.h create mode 100644 util/include/axutil_http_chunked_stream.h create mode 100644 util/include/axutil_linked_list.h create mode 100644 util/include/axutil_log.h create mode 100644 util/include/axutil_log_default.h create mode 100644 util/include/axutil_md5.h create mode 100644 util/include/axutil_network_handler.h create mode 100644 util/include/axutil_param.h create mode 100644 util/include/axutil_param_container.h create mode 100644 util/include/axutil_properties.h create mode 100644 util/include/axutil_property.h create mode 100644 util/include/axutil_qname.h create mode 100644 util/include/axutil_rand.h create mode 100644 util/include/axutil_stack.h create mode 100644 util/include/axutil_stream.h create mode 100644 util/include/axutil_string.h create mode 100644 util/include/axutil_string_util.h create mode 100644 util/include/axutil_thread.h create mode 100644 util/include/axutil_thread_pool.h create mode 100644 util/include/axutil_types.h create mode 100644 util/include/axutil_uri.h create mode 100644 util/include/axutil_url.h create mode 100644 util/include/axutil_utils.h create mode 100644 util/include/axutil_utils_defines.h create mode 100644 util/include/axutil_uuid_gen.h create mode 100644 util/include/axutil_version.h create mode 100644 util/include/platforms/axutil_platform_auto_sense.h create mode 100644 util/include/platforms/unix/axutil_date_time_util_unix.h create mode 100644 util/include/platforms/unix/axutil_thread_unix.h create mode 100644 util/include/platforms/unix/axutil_unix.h create mode 100644 util/include/platforms/unix/axutil_uuid_gen_unix.h create mode 100644 util/include/platforms/windows/axutil_date_time_util_windows.h create mode 100644 util/include/platforms/windows/axutil_dir_windows.h create mode 100644 util/include/platforms/windows/axutil_getopt_windows.h create mode 100644 util/include/platforms/windows/axutil_thread_mutex_windows.h create mode 100644 util/include/platforms/windows/axutil_thread_windows.h create mode 100644 util/include/platforms/windows/axutil_uuid_gen_windows.h create mode 100644 util/include/platforms/windows/axutil_windows.h (limited to 'util/include') diff --git a/util/include/Makefile.am b/util/include/Makefile.am new file mode 100644 index 0000000..3cf1d6d --- /dev/null +++ b/util/include/Makefile.am @@ -0,0 +1,2 @@ +includedir=$(prefix)/include/axis2-1.6.0/ +nobase_include_HEADERS= platforms/axutil_platform_auto_sense.h platforms/unix/*.h platforms/windows/*.h diff --git a/util/include/axutil_allocator.h b/util/include/axutil_allocator.h new file mode 100644 index 0000000..698ebfe --- /dev/null +++ b/util/include/axutil_allocator.h @@ -0,0 +1,200 @@ +/* + * 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 + * limitations under the License. + */ + +#ifndef AXUTIL_ALLOCATOR_H +#define AXUTIL_ALLOCATOR_H + +/** + * @file axutil_allocator.h + * @brief Axis2 memory allocator interface + */ + +#include +#include +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axutil_allocator allocator + * @ingroup axis2_util + * @{ + */ + + /** + * \brief Axis2 memory allocator + * + * Encapsulator for memory allocating routines + */ + typedef struct axutil_allocator + { + + /** + * Function pointer representing the function that allocates memory. + * @param allocator pointer to allocator struct. In the default + * implementation this is not used, however this parameter is useful + * when the allocator implementation is dealing with a memory pool. + * @param size size of the memory block to be allocated + * @return pointer to the allocated memory block + */ + void *( + AXIS2_CALL + * malloc_fn)( + struct axutil_allocator * allocator, + size_t size); + + /** + * Function pointer representing the function that re-allocates memory. + * @param allocator pointer to allocator struct. In the default + * implementation this is not used, however this parameter is useful + * when the allocator implementation is dealing with a memory pool. + * @param ptr memory block who's size to be changed + * @param size size of the memory block to be allocated + * @return pointer to the allocated memory block + */ + void *( + AXIS2_CALL + * realloc)( + struct axutil_allocator * allocator, + void *ptr, + size_t size); + + /** + * Function pointer representing the function that frees memory. + * @param allocator pointer to allocator struct. In the default + * implementation this is not used, however this parameter is useful + * when the allocator implementation is dealing with a memory pool. + * @param ptr pointer to be freed + * @return void + */ + void( + AXIS2_CALL + * free_fn)( + struct axutil_allocator * allocator, + void *ptr); + + /** + * Local memory pool. Local pool is used to allocate per request + * local values. + */ + void *local_pool; + + /** + * Global memory pool. Global pool is used to allocate values that + * live beyond a request + */ + void *global_pool; + + /** + * Memory pool currently in use. The functions + * axutil_allocator_switch_to_global_pool and + * axutil_allocator_switch_to_local_pool should be used to + * set the current pool to global pool or to local pool respectively. + */ + void *current_pool; + + /** + * This variable has meaning only when allocator is initialized when Axis2/C is used in + * Apache2 module. When switching to global poo this ref counter is increased by one. When + * switching to local pool it is descreased by one. When creating allocator this variable + * is initialized to 0 which means it points to the local pool. If user has switched to the + * global pool several times without switching back to the local pool this ref counter has + * a positive value. If at this stage switching to lcoal pool called then this ref counter + * is reduced and checked if its value is zero. If only it's value is zero then pool is + * switched to local pool. This functionality avoid unintended switching to localpool by + * some code fragment. Still user has to make sure that each global switch has a + * corresponding local switch. + */ + int global_pool_ref; + + } + axutil_allocator_t; + + /** + * Initializes (creates) a memory allocator. + * @param allocator user defined allocator. If NULL, a default allocator + * will be returned. + * @return initialized allocator. NULL on error. + */ + AXIS2_EXTERN axutil_allocator_t *AXIS2_CALL + axutil_allocator_init( + axutil_allocator_t * allocator); + + /** + * Creates a clone of given allocator + * @param allocator user defined allocator. Cannot be NULL + * @return initialized allocator. NULL on error. + */ + AXIS2_EXTERN axutil_allocator_t *AXIS2_CALL + axutil_allocator_clone( + axutil_allocator_t * allocator); + + /** + * This function should be used to deallocate memory if the default + * allocator was provided by the axutil_allocator_init() call. + * @param allocator allocator struct to be freed + * @return void + */ + AXIS2_EXTERN void AXIS2_CALL + axutil_allocator_free( + axutil_allocator_t * allocator); + + /** + * Swaps the local_pool and global_pool and makes the global pool the + * current pool. + * In case of using pools, local_pool is supposed to hold the pool out of which + * local values are allocated. In case of values that live beyond a request + * global pool should be used, hence this method has to be called to switch to + * global pool for allocation. + * @param allocator allocator whose memory pools are to be switched + * @return void + */ + AXIS2_EXTERN void AXIS2_CALL + axutil_allocator_switch_to_global_pool( + axutil_allocator_t * allocator); + + /** + * Swaps the local_pool and global_pool and makes the local pool the + * current pool. + * In case of using pools, local_pool is supposed to hold the pool out of which + * local values are allocated. In case of values that live beyond a request + * global pool should be used. This method can be used to inverse the switching + * done by axutil_allocator_switch_to_global_pool, to start using the local pool again. + * @param allocator allocator whose memory pools are to be switched + * @return void + */ + AXIS2_EXTERN void AXIS2_CALL + axutil_allocator_switch_to_local_pool( + axutil_allocator_t * allocator); + +#define AXIS2_MALLOC(allocator, size) \ + ((allocator)->malloc_fn(allocator, size)) + +#define AXIS2_REALLOC(allocator, ptr, size) \ + ((allocator)->realloc(allocator, ptr, size)) + +#define AXIS2_FREE(allocator, ptr) \ + ((allocator)->free_fn(allocator, ptr)) + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIS2_ALLOCATOR_H */ diff --git a/util/include/axutil_array_list.h b/util/include/axutil_array_list.h new file mode 100644 index 0000000..792df3b --- /dev/null +++ b/util/include/axutil_array_list.h @@ -0,0 +1,250 @@ + +/* + * 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 + * limitations under the License. + */ + +#ifndef AXUTIL_ARRAY_LIST_H +#define AXUTIL_ARRAY_LIST_H + +/** + * @defgroup axutil_array_list array list + * @ingroup axis2_util + * Description. + * @{ + */ + +/** + * @file axutil_array_list.h + * @brief Axis2 array_list interface + */ + +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + +#define AXIS2_ARRAY_LIST_DEFAULT_CAPACITY 16 + + /** + * Array List struct + */ + typedef struct axutil_array_list axutil_array_list_t; + + /** + * Constructs a new array list with the supplied initial capacity. + * If capacity is invalid (<= 0) then default capacity is used + * @param env pointer to environment struct + * @param capacity initial capacity of this array_list + */ + AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL + axutil_array_list_create( + const axutil_env_t * env, + int capacity); + + /** + * Free array passed as void pointer. + * @param array_list pointer to array list + * @param env pointer to environment struct + */ + AXIS2_EXTERN void AXIS2_CALL + axutil_array_list_free_void_arg( + void *array_list, + const axutil_env_t * env); + + /** + * Guarantees that this list will have at least enough capacity to + * hold min_capacity elements. This implementation will grow the list to + * max(current * 2, min_capacity) + * @param array_list pointer to array_list + * @param env pointer to environment struct + * @param min_capacity the minimum guaranteed capacity + * @return AXIS2_SUCCESS on success, else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_array_list_ensure_capacity( + struct axutil_array_list *array_list, + const axutil_env_t * env, + int min_capacity); + + /** + * Returns the number of elements in this list. + * @param array_list pointer to array list + * @param env pointer to environment struct + * @return the list size + */ + AXIS2_EXTERN int AXIS2_CALL + axutil_array_list_size( + struct axutil_array_list *array_list, + const axutil_env_t * env); + + /** + * Checks if the list is empty. + * @param array_list pointer to array list + * @param env pointer to environment struct + * @return true if there are no elements, else false + */ + AXIS2_EXTERN axis2_bool_t AXIS2_CALL + axutil_array_list_is_empty( + struct axutil_array_list *array_list, + const axutil_env_t * env); + + /** + * Returns true iff element is in this array_list. + * @param array_list pointer to array list + * @param env pointer to environment struct + * @param e the element whose inclusion in the List is being tested + * @return true if the list contains e + */ + AXIS2_EXTERN axis2_bool_t AXIS2_CALL + axutil_array_list_contains( + struct axutil_array_list *array_list, + const axutil_env_t * env, + void *e); + + /** + * Returns the lowest index at which element appears in this List, or + * -1 if it does not appear. This looks for the pointer value equality only, + * does not look into pointer content + * @param array_list pointer to array list + * @param env pointer to environment struct + * @param e the element whose inclusion in the List is being tested + * @return the index where e was found + */ + AXIS2_EXTERN int AXIS2_CALL + axutil_array_list_index_of( + struct axutil_array_list *array_list, + const axutil_env_t * env, + void *e); + + /** + * Retrieves the element at the user-supplied index. + * @param array_list pointer to array list + * @param env pointer to environment struct + * @param index the index of the element we are fetching + * @return element at the given index + */ + AXIS2_EXTERN void *AXIS2_CALL + axutil_array_list_get( + struct axutil_array_list *array_list, + const axutil_env_t * env, + int index); + + /** + * Sets the element at the specified index. The new element, e, + * can be an object of any type or null. + * @param array_list pointer to array list + * @param env pointer to environment struct + * @param index the index at which the element is being set + * @param e the element to be set + * @return the element previously at the specified index + */ + AXIS2_EXTERN void *AXIS2_CALL + axutil_array_list_set( + struct axutil_array_list *array_list, + const axutil_env_t * env, + int index, + void *e); + + /** + * Appends the supplied element to the end of this list. + * The element, e, can be a pointer of any type or NULL. + * @param array_list pointer to array list + * @param env pointer to environment struct + * @param e the element to be appended to this list + * @return AXIS2_SUCCESS on success, else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_array_list_add( + struct axutil_array_list *array_list, + const axutil_env_t * env, + const void *e); + + /** + * Adds the supplied element at the specified index, shifting all + * elements currently at that index or higher one to the right. + * The element, e, can be a pointer of any type or NULL. + * @param array_list pointer to array list + * @param env pointer to environment struct + * @param index the index at which the element is being added + * @param e the item being added + * @return AXIS2_SUCCESS on success, else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_array_list_add_at( + struct axutil_array_list *array_list, + const axutil_env_t * env, + const int index, + const void *e); + + /** + * Removes the element at the user-supplied index. + * @param array_list pointer to array list + * @param env pointer to environment struct + * @param index the index of the element to be removed + * @return the removed void* pointer + */ + AXIS2_EXTERN void *AXIS2_CALL + axutil_array_list_remove( + struct axutil_array_list *array_list, + const axutil_env_t * env, + int index); + + /** + * Checks that the index is in the range of possible elements (inclusive). + * @param array_list pointer to array list + * @param env pointer to environment struct + * @param index the index to check + * @return AXIS2_FALSE if index > size or index < 0, else AXIS2_TRUE + */ + AXIS2_EXTERN axis2_bool_t AXIS2_CALL + + axutil_array_list_check_bound_inclusive( + struct axutil_array_list *array_list, + const axutil_env_t * env, + int index); + + /** + * Checks that the index is in the range of existing elements (exclusive). + * @param array_list pointer to array list + * @param env pointer to environment struct + * @param index the index to check + * @return AXIS2_FALSE if index >= size or index < 0, else AXIS2_TRUE + */ + AXIS2_EXTERN axis2_bool_t AXIS2_CALL + + axutil_array_list_check_bound_exclusive( + struct axutil_array_list *array_list, + const axutil_env_t * env, + int index); + + /** + * @param array_list pointer to array list + * @param env pointer to environment struct + * @return AXIS2_SUCCESS on success, else AXIS2_FAILURE + */ + AXIS2_EXTERN void AXIS2_CALL + axutil_array_list_free( + struct axutil_array_list *array_list, + const axutil_env_t * env); + +#ifdef __cplusplus +} +#endif + +#endif /* AXIS2_ARRAY_LIST_H */ diff --git a/util/include/axutil_base64.h b/util/include/axutil_base64.h new file mode 100644 index 0000000..d52e3af --- /dev/null +++ b/util/include/axutil_base64.h @@ -0,0 +1,122 @@ + +/* + * Copyright 2003-2004 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 + +/* + * @file axutil_base64.h + * @brief AXIS2-UTIL Base64 Encoding + */ +#ifndef AXUTIL_BASE64_H +#define AXUTIL_BASE64_H + +#ifdef __cplusplus +extern "C" +{ +#endif + + /* + * @defgroup AXIS2_Util_Base64 base64 encoding + * @ingroup AXIS2_Util + */ + + /* Simple BASE64 encode/decode functions. + * + * As we might encode binary strings, hence we require the length of + * the incoming plain source. And return the length of what we decoded. + * + * The decoding function takes any non valid char (i.e. whitespace, \0 + * or anything non A-Z,0-9 etc as terminal. + * + * plain strings/binary sequences are not assumed '\0' terminated. Encoded + * strings are neither. But probably should. + * + */ + + /* + * Given the length of an un-encrypted string, get the length of the + * encrypted string. + * @param len the length of an unencrypted string. + * @return the length of the string after it is encrypted + */ + AXIS2_EXTERN int AXIS2_CALL + axutil_base64_encode_len( + int len); + + /* + * Encode a text string using base64encoding. + * @param coded_dst The destination string for the encoded string. + * @param plain_src The original string in plain text + * @param len_plain_src The length of the plain text string + * @return the length of the encoded string + */ + AXIS2_EXTERN int AXIS2_CALL + axutil_base64_encode( + char *coded_dst, + const char *plain_src, + int len_plain_src); + + /* + * Encode an EBCDIC string using base64encoding. + * @param coded_dst The destination string for the encoded string. + * @param plain_src The original string in plain text + * @param len_plain_src The length of the plain text string + * @return the length of the encoded string + */ + AXIS2_EXTERN int AXIS2_CALL + axutil_base64_encode_binary( + char *coded_dst, + const unsigned char *plain_src, + int len_plain_src); + + /* + * Determine the length of a plain text string given the encoded version + * @param coded_src The encoded string + * @return the length of the plain text string + */ + AXIS2_EXTERN int AXIS2_CALL + axutil_base64_decode_len( + const char *coded_src); + + /* + * Decode a string to plain text + * @param plain_dst The destination string for the plain text. size of this should be axutil_base64_decode_len + 1 + * @param coded_src The encoded string + * @return the length of the plain text string + */ + AXIS2_EXTERN int AXIS2_CALL + axutil_base64_decode( + char *plain_dst, + const char *coded_src); + + /* + * Decode an EBCDIC string to plain text + * @param plain_dst The destination string for the plain text. size of this should be axutil_base64_decode_len + * @param coded_src The encoded string + * @return the length of the plain text string + */ + AXIS2_EXTERN int AXIS2_CALL + axutil_base64_decode_binary( + unsigned char *plain_dst, + const char *coded_src); + + /* @} */ +#ifdef __cplusplus +} +#endif + +#endif /* !AXIS2_BASE64_H */ diff --git a/util/include/axutil_base64_binary.h b/util/include/axutil_base64_binary.h new file mode 100644 index 0000000..ba99f0a --- /dev/null +++ b/util/include/axutil_base64_binary.h @@ -0,0 +1,173 @@ + +/* + * 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 + * limitations under the License. + */ + +#ifndef AXUTIL_BASE64_BINARY_H +#define AXUTIL_BASE64_BINARY_H + +#include +#include +#include + +/** + * @defgroup axutil_base64_binary encoding holder + * @ingroup axis2_util + * @{ + */ + +/** + * @file axutil_base64_binary.h + * @brief axis2-util base64 encoding holder + */ + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** Type name for struct axutil_base64_binary */ + typedef struct axutil_base64_binary axutil_base64_binary_t; + + /** + * Creates axutil_base64_binary struct + * @param env double pointer to environment struct. MUST NOT be NULL + * @return pointer to newly created axutil_base64_binary struct + */ + AXIS2_EXTERN axutil_base64_binary_t *AXIS2_CALL + + axutil_base64_binary_create( + const axutil_env_t * env); + + /** + * Creates axutil_base64_binary struct + * @param env double pointer to environment struct. MUST NOT be NULL + * @param plain_binary binary buffer to initialize + * @return pointer to newly created axutil_base64_binary struct + */ + AXIS2_EXTERN axutil_base64_binary_t *AXIS2_CALL + + axutil_base64_binary_create_with_plain_binary( + const axutil_env_t * env, + const unsigned char *plain_binary, + int plain_binary_len); + + /** + * Creates axutil_base64_binary struct. + * @param env double pointer to environment struct. MUST NOT be NULL + * @param encoded_binary binary buffer to initialize + * @return pointer to newly created axutil_base64_binary struct + */ + AXIS2_EXTERN axutil_base64_binary_t *AXIS2_CALL + + axutil_base64_binary_create_with_encoded_binary( + const axutil_env_t * env, + const char *encoded_binary); + + /** + * free the axutil_base64_binary. + * @param base64_binary represet the type object + * @param env pointer to environment struct. MUST NOT be NULL + * @return AXIS2_SUCCESS on success, else AXIS2_FAILURE + */ + AXIS2_EXTERN void AXIS2_CALL + axutil_base64_binary_free( + axutil_base64_binary_t * base64_binary, + const axutil_env_t * env); + + /** + * store the value from plain binary. + * @param base64_binary represet the type object + * @param env pointer to environment struct. MUST NOT be NULL + * @param plain_binary binary buffer to store + * @param plain_binary_len length of the plain_binary binary buffer + * @return AXIS2_SUCCESS on success, else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + + axutil_base64_binary_set_plain_binary( + axutil_base64_binary_t * base64_binary, + const axutil_env_t * env, + const unsigned char *plain_binary, + int plain_binary_len); + + /** + * retrieve the value from plain binary. + * @param base64_binary represet the type object + * @param env pointer to environment struct. MUST NOT be NULL + * @param plain_binary_len length of the plain_binary binary buffer + * @return the plain binary + */ + + AXIS2_EXTERN unsigned char *AXIS2_CALL + + axutil_base64_binary_get_plain_binary( + axutil_base64_binary_t * base64_binary, + const axutil_env_t * env, + int *plain_binary_len); + + /** + * store the value from encoded binary. + * @param base64_binary represet the type object + * @param env pointer to environment struct. MUST NOT be NULL + * @param encoded_binary encoded binary buffer to store + * @return AXIS2_SUCCESS on success, else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + + axutil_base64_binary_set_encoded_binary( + axutil_base64_binary_t * base64_binary, + const axutil_env_t * env, + const char *encoded_binary); + + /** + * retrieve the value from encoded binary. + * @param base64_binary represet the type object + * @param env pointer to environment struct. MUST NOT be NULL + * @return the encoded binary + */ + AXIS2_EXTERN char *AXIS2_CALL + axutil_base64_binary_get_encoded_binary( + axutil_base64_binary_t * base64_binary, + const axutil_env_t * env); + + /** + * retrieve the value from encoded binary length. + * @param base64_binary represet the type object + * @param env pointer to environment struct. MUST NOT be NULL + * @return the encoded binary length + */ + AXIS2_EXTERN int AXIS2_CALL + axutil_base64_binary_get_encoded_binary_len( + axutil_base64_binary_t * base64_binary, + const axutil_env_t * env); + + /** + * retrieve the value from decoded binary length. + * @param base64_binary represet the type object + * @param env pointer to environment struct. MUST NOT be NULL + * @return the decoded binary length + */ + AXIS2_EXTERN int AXIS2_CALL + axutil_base64_binary_get_decoded_binary_len( + axutil_base64_binary_t * base64_binary, + const axutil_env_t * env); + +#ifdef __cplusplus +} +#endif + +#endif /* AXIS2_BASE64_BINARY_H */ diff --git a/util/include/axutil_class_loader.h b/util/include/axutil_class_loader.h new file mode 100644 index 0000000..99a0f95 --- /dev/null +++ b/util/include/axutil_class_loader.h @@ -0,0 +1,63 @@ + +/* + * 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 + * limitations under the License. + */ + +#ifndef AXUTIL_CLASS_LOADER_H +#define AXUTIL_CLASS_LOADER_H + +/** + * @file axutil_class_loader.h + * @brief axis2 class loader interface + */ + +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** @defgroup axutil_class_loader class loader + * @ingroup axis2_util + * @{ + */ + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_class_loader_init( + const axutil_env_t * env); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_class_loader_delete_dll( + const axutil_env_t * env, + axutil_dll_desc_t * dll_desc); + + AXIS2_EXTERN void *AXIS2_CALL + axutil_class_loader_create_dll( + const axutil_env_t * env, + axutil_param_t * impl_info_param); + + /** @} */ +#ifdef __cplusplus +} +#endif + +#endif /* AXIS2_CLASS_LOADER_H */ diff --git a/util/include/axutil_config.h b/util/include/axutil_config.h new file mode 100644 index 0000000..a35c0bd --- /dev/null +++ b/util/include/axutil_config.h @@ -0,0 +1,42 @@ + +/* + * 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 + * limitations under the License. + */ + +#ifndef AXUTIL_CONFIG_H +#define AXUTIL_CONFIG_H + +/* undef unwated cnfig macros to avoid conflicts with APR macros */ +#undef PACKAGE +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION +#undef VERSION + +#include + +/* undef unwated cnfig macros to avoid conflicts with APR macros */ +#undef PACKAGE +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION +#undef VERSION + +#endif /* AXIS2_UTILS_H */ diff --git a/util/include/axutil_date_time.h b/util/include/axutil_date_time.h new file mode 100644 index 0000000..eeac9e6 --- /dev/null +++ b/util/include/axutil_date_time.h @@ -0,0 +1,350 @@ + +/* + * 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 + * limitations under the License. + */ + +#ifndef AXUTIL_DATE_TIME_H +#define AXUTIL_DATE_TIME_H + +#include +#include + +/** + * @file axutil_date_time.h + * @brief axis2-util + */ + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axutil_date_time + * @ingroup axis2_util + * @{ + */ + + typedef struct axutil_date_time axutil_date_time_t; + + typedef enum + { + AXIS2_DATE_TIME_COMP_RES_FAILURE = -1, + AXIS2_DATE_TIME_COMP_RES_UNKNOWN, + AXIS2_DATE_TIME_COMP_RES_EXPIRED, + AXIS2_DATE_TIME_COMP_RES_EQUAL, + AXIS2_DATE_TIME_COMP_RES_NOT_EXPIRED + } axutil_date_time_comp_result_t; + + /** + * Creates axutil_date_time struct with current date time + * @param env double pointer to environment struct. MUST NOT be NULL + * @return pointer to newly created axutil_date_time struct + */ + AXIS2_EXTERN axutil_date_time_t *AXIS2_CALL + axutil_date_time_create( + const axutil_env_t * env); + + /* + * Creates axutil_date_time struct with an additional offset value + * If the offset is a positive value then the time will be in the future + * offset is 0, then the time will be the current time + * offset is a negative value then the time is in the past. + * @param env double pointer to environment struct. MUST NOT be NULL + * @param offset the offset from the current time in seconds + * @return pointer to newly created axutil_date_time struct + **/ + AXIS2_EXTERN axutil_date_time_t *AXIS2_CALL + + axutil_date_time_create_with_offset( + const axutil_env_t * env, + int offset); + + /** + * free the axutil_date_time. + * @param date_time represet the type object + * @param env pointer to environment struct. MUST NOT be NULL + * @return AXIS2_SUCCESS on success, else AXIS2_FAILURE + */ + AXIS2_EXTERN void AXIS2_CALL + axutil_date_time_free( + axutil_date_time_t * date_time, + const axutil_env_t * env); + + /** + * store the time value from plain text. + * @param date_time represet the type object + * @param env pointer to environment struct. MUST NOT be NULL + * @param time time as a string format HH:MM:TTZ + * @return AXIS2_SUCCESS on success, else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_date_time_deserialize_time( + axutil_date_time_t * date_time, + const axutil_env_t * env, + const axis2_char_t * time_str); + + /** + * store the date value from plain text. + * @param date_time represet the type object + * @param env pointer to environment struct. MUST NOT be NULL + * @param date date as a string format YYYY-MM-DD + * @return AXIS2_SUCCESS on success, else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_date_time_deserialize_date( + axutil_date_time_t * date_time, + const axutil_env_t * env, + const axis2_char_t * date_str); + + /** + * store the date value from plain text. + * @param date_time represet the type object + * @param env pointer to environment struct. MUST NOT be NULL + * @param date_time string format YYYY-MM-DDTHH:MM:SSZ + * @return AXIS2_SUCCESS on success, else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + + axutil_date_time_deserialize_date_time( + axutil_date_time_t * date_time, + const axutil_env_t * env, + const axis2_char_t * date_time_str); + + /** + * store the date value from set of values + * @param date_time represet the type object + * @param env pointer to environment struct. MUST NOT be NULL + * @param year Integer -1 can be used to ignore + * @param month Integer -1 can be used to ignore + * @param date Integer -1 can be used to ignore + * @param hour Integer -1 can be used to ignore + * @param min Integer -1 can be used to ignore + * @param second Integer -1 can be used to ignore + * @return AXIS2_SUCCESS on success, else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_date_time_set_date_time( + axutil_date_time_t * date_time, + const axutil_env_t * env, + int year, + int month, + int date, + int hour, + int min, + int second, + int milliseconds); + + /** + * retrive the stored time as a string + * @param date_time represet the type object + * @param env pointer to environment struct. MUST NOT be NULL + * @return time as a string format HH:MM:SSZ + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axutil_date_time_serialize_time( + axutil_date_time_t * date_time, + const axutil_env_t * env); + + /** + * retrive the stored date as a string + * @param date_time represet the type object + * @param env pointer to environment struct. MUST NOT be NULL + * @return date as a string format YYYY-MM-DD + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axutil_date_time_serialize_date( + axutil_date_time_t * date_time, + const axutil_env_t * env); + + /** + * retrive the stored date time as a string with millisecond precision + * @param date_time represet the type object + * @param env pointer to environment struct. MUST NOT be NULL + * @return time as a string format YYYY-MM-DDTHH:MM:SS.msZ + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + + axutil_date_time_serialize_date_time( + axutil_date_time_t * date_time, + const axutil_env_t * env); + + /** + * retrive the stored date time as a string without millisecond + * @param date_time represet the type object + * @param env pointer to environment struct. MUST NOT be NULL + * @return time as a string format YYYY-MM-DDTHH:MM:SSZ + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axutil_date_time_serialize_date_time_without_millisecond( + axutil_date_time_t * date_time, + const axutil_env_t * env); + + /** + * retrieve the year of the date time + * @param date_time represet the type object + * @param env pointer to environment struct. MUST NOT be NULL + * @return year as an integer + */ + AXIS2_EXTERN int AXIS2_CALL + axutil_date_time_get_year( + axutil_date_time_t * date_time, + const axutil_env_t * env); + + /** + * retrieve the month of the date time + * @param date_time represet the type object + * @param env pointer to environment struct. MUST NOT be NULL + * @return month as an integer + */ + AXIS2_EXTERN int AXIS2_CALL + axutil_date_time_get_month( + axutil_date_time_t * date_time, + const axutil_env_t * env); + + /** + * retrieve the date of the date time + * @param date_time represet the type object + * @param env pointer to environment struct. MUST NOT be NULL + * @return date as an integer + */ + AXIS2_EXTERN int AXIS2_CALL + axutil_date_time_get_date( + axutil_date_time_t * date_time, + const axutil_env_t * env); + + /** + * retrieve the hour of the date time + * @param date_time represet the type object + * @param env pointer to environment struct. MUST NOT be NULL + * @return hour as an integer + */ + AXIS2_EXTERN int AXIS2_CALL + axutil_date_time_get_hour( + axutil_date_time_t * date_time, + const axutil_env_t * env); + + /** + * retrieve the minute of the date time + * @param date_time represet the type object + * @param env pointer to environment struct. MUST NOT be NULL + * @return minute as an integer + */ + AXIS2_EXTERN int AXIS2_CALL + axutil_date_time_get_minute( + axutil_date_time_t * date_time, + const axutil_env_t * env); + + /** + * retrieve the second of the date time + * @param date_time represet the type object + * @param env pointer to environment struct. MUST NOT be NULL + * @return second as an integer + */ + AXIS2_EXTERN int AXIS2_CALL + axutil_date_time_get_second( + axutil_date_time_t * date_time, + const axutil_env_t * env); + + AXIS2_EXTERN int AXIS2_CALL + axutil_date_time_get_msec( + axutil_date_time_t * date_time, + const axutil_env_t * env); + + /** + * Compare the date and time of @date_time with the reference @ref. + * If the @date_time < @ref this returns NOT_EXPIRED. + * If the @date_time > @ref this returns EXPIRED. + * If the @date_time = @ref this returns EQUAL. + * @param date_time the date time to be compared + * @param env pointer to environment struct. MUST NOT be NULL + * @ref the reference date time + * @return NOT_EXPIRED/EXPIRED/EQUAL if valid otherwise return FAILURE + */ + AXIS2_EXTERN axutil_date_time_comp_result_t AXIS2_CALL + axutil_date_time_compare( + axutil_date_time_t * date_time, + const axutil_env_t * env, + axutil_date_time_t * ref); + + AXIS2_EXTERN axutil_date_time_t *AXIS2_CALL + axutil_date_time_utc_to_local( + axutil_date_time_t * date_time, + const axutil_env_t * env, + axis2_bool_t is_positive, + int hour, + int min); + + AXIS2_EXTERN axutil_date_time_t *AXIS2_CALL + axutil_date_time_local_to_utc( + axutil_date_time_t * date_time, + const axutil_env_t * env); + + AXIS2_EXTERN int AXIS2_CALL + axutil_date_time_get_time_zone_hour( + axutil_date_time_t * date_time, + const axutil_env_t * env); + + AXIS2_EXTERN int AXIS2_CALL + axutil_date_time_get_time_zone_minute( + axutil_date_time_t * date_time, + const axutil_env_t * env); + + AXIS2_EXTERN axis2_bool_t AXIS2_CALL + axutil_date_time_is_time_zone_positive( + axutil_date_time_t * date_time, + const axutil_env_t * env); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_date_time_set_time_zone( + axutil_date_time_t * date_time, + const axutil_env_t * env, + axis2_bool_t is_positive, + int hour, + int min); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_date_time_deserialize_date_time_with_time_zone( + axutil_date_time_t * date_time, + const axutil_env_t * env, + const axis2_char_t * date_time_str); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_date_time_deserialize_time_with_time_zone( + axutil_date_time_t * date_time, + const axutil_env_t * env, + const axis2_char_t * time_str); + + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axutil_date_time_serialize_date_time_with_time_zone( + axutil_date_time_t * date_time, + const axutil_env_t * env); + + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axutil_date_time_serialize_time_with_time_zone( + axutil_date_time_t * date_time, + const axutil_env_t * env); + + AXIS2_EXTERN axis2_bool_t AXIS2_CALL + axutil_date_time_is_utc( + axutil_date_time_t * date_time, + const axutil_env_t * env); + +#ifdef __cplusplus +} +#endif + +#endif /* AXIS2_DATE_TIME_H */ diff --git a/util/include/axutil_date_time_util.h b/util/include/axutil_date_time_util.h new file mode 100644 index 0000000..bd4aca0 --- /dev/null +++ b/util/include/axutil_date_time_util.h @@ -0,0 +1,51 @@ + +/* + * 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 count 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 AXUTIL_DATE_TIME_UTIL_H +#define AXUTIL_DATE_TIME_UTIL_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axutil_uuid_gen UUID generator + * @ingroup axis2_util + * @{ + */ + + /** + * generate a uuid + * @return generated uuid as a string + */ + AXIS2_EXTERN int AXIS2_CALL + axutil_get_milliseconds( + const axutil_env_t * env); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIS2_DATE_TIME_UTIL_H */ diff --git a/util/include/axutil_digest_calc.h b/util/include/axutil_digest_calc.h new file mode 100644 index 0000000..ac27ab0 --- /dev/null +++ b/util/include/axutil_digest_calc.h @@ -0,0 +1,109 @@ +/* + * 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 + * limitations under the License. + */ + +#ifndef AXUTIL_DIGEST_CALC_H +#define AXUTIL_DIGEST_CALC_H + +/** + * @file axutil_digest_calc.h + * @brief implements the calculations of H(A1), H(A2), + * request-digest and response-digest for Axis2 based on rfc2617. + */ + +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axis2_util utilities + * @ingroup axis2 + * @{ + * @} + */ + + /** + * @defgroup axutil_digest_calc digest_calc + * @ingroup axis2_util + * @{ + */ + + #define AXIS2_DIGEST_HASH_LEN 16 + #define AXIS2_DIGEST_HASH_HEX_LEN 32 + + typedef unsigned char axutil_digest_hash_t[AXIS2_DIGEST_HASH_LEN]; + typedef unsigned char axutil_digest_hash_hex_t[AXIS2_DIGEST_HASH_HEX_LEN + 1]; + + /** + * calculate H(A1) as per HTTP Digest spec + * @param env, pointer to env struct + * @param algorithm, algorithm + * @param user_name, user name + * @param realm, reaalm + * @param password, password + * @param nonce, nonce from server + * @param cnonce, client nonce + * @param session_key, H(A1) + * @return AXIS2_SUCCESS on success or AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_digest_calc_get_h_a1( + const axutil_env_t * env, + char * algorithm, + char * user_name, + char * realm, + char * password, + char * nonce, + char * cnonce, + axutil_digest_hash_hex_t session_key); + + /** + * calculate request-digest/response-digest as per HTTP Digest spec + * @param env, pointer to env struct + * @param h_a1, H(A1) + * @param nonce, nonce from server + * @param cnonce, client nonce + * @param qop, qop-value: "", "auth", "auth-int" + * @param method, method from the request + * @param digest_uri, requested URL + * @param h_entry, H(entity body) if qop="auth-int" + * @param response, request-digest or response-digest + * @return AXIS2_SUCCESS on success or AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_digest_calc_get_response( + const axutil_env_t * env, + axutil_digest_hash_hex_t h_a1, + char * nonce, + char * nonce_count, + char * cnonce, + char * qop, + char * method, + char * digest_uri, + axutil_digest_hash_hex_t h_entity, + axutil_digest_hash_hex_t response); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIS2_DIGEST_CALC_H */ diff --git a/util/include/axutil_dir_handler.h b/util/include/axutil_dir_handler.h new file mode 100644 index 0000000..d66e42e --- /dev/null +++ b/util/include/axutil_dir_handler.h @@ -0,0 +1,73 @@ + +/* + * 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 + * limitations under the License. + */ + +#ifndef AXUTIL_DIR_HANDLER_H +#define AXUTIL_DIR_HANDLER_H + +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axutil_dir_handler dir handler + * @ingroup axis2_util + * @{ + */ + + /** + * List the dll files in the given service or module folder path + * @param pathname path to your service or module directory + * @return array list of dll file names + */ + AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL + + axutil_dir_handler_list_services_or_modules_in_dir( + const axutil_env_t * env, + const axis2_char_t * pathname); + + /** + * List services or modules directories in the services or modules folder + * respectively + * @param pathname path your modules or services folder + * @return array list of contents of services or modules folder + */ + AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL + + axutil_dir_handler_list_service_or_module_dirs( + const axutil_env_t * env, + const axis2_char_t * pathname); + + /* + *extentions for module and service archives + */ +#define AXIS2_AAR_SUFFIX ".aar" +#define AXIS2_MAR_SUFFIX ".mar" + +#ifdef __cplusplus +} +#endif + +#endif /* AXIS2_DIR_HANDLER_H */ diff --git a/util/include/axutil_dll_desc.h b/util/include/axutil_dll_desc.h new file mode 100644 index 0000000..30f69f1 --- /dev/null +++ b/util/include/axutil_dll_desc.h @@ -0,0 +1,191 @@ + +/* + * 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 + * limitations under the License. + */ + +#ifndef AXUTIL_DLL_DESC_H +#define AXUTIL_DLL_DESC_H + +/** + * @file axutil_dll_desc.h + * @brief Axis2 dll_desc interface + */ + +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axutil_dll_desc DLL description + * @ingroup axis2_util + * @{ + */ + + typedef struct axutil_dll_desc axutil_dll_desc_t; + + typedef int( + *CREATE_FUNCT)( + void **inst, + const axutil_env_t * env); + + typedef int( + *DELETE_FUNCT)( + void *inst, + const axutil_env_t * env); + + typedef int axis2_dll_type_t; + + /** + * creates dll_desc struct + * @param qname qname, can be NULL + */ + AXIS2_EXTERN axutil_dll_desc_t *AXIS2_CALL + axutil_dll_desc_create( + const axutil_env_t * env); + + AXIS2_EXTERN void AXIS2_CALL + axutil_dll_desc_free_void_arg( + void *dll_desc, + const axutil_env_t * env); + + AXIS2_EXTERN void AXIS2_CALL + axutil_dll_desc_free( + axutil_dll_desc_t * dll_desc, + const axutil_env_t * env); + + /** + * Set path qualified platform specific dll name + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_dll_desc_set_name( + axutil_dll_desc_t * dll_desc, + const axutil_env_t * env, + axis2_char_t * name); + + /** + * Return the path qualified platform specific dll name + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axutil_dll_desc_get_name( + axutil_dll_desc_t * dll_desc, + const axutil_env_t * env); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_dll_desc_set_type( + axutil_dll_desc_t * dll_desc, + const axutil_env_t * env, + axis2_dll_type_t type); + + AXIS2_EXTERN axis2_dll_type_t AXIS2_CALL + axutil_dll_desc_get_type( + axutil_dll_desc_t * dll_desc, + const axutil_env_t * env); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_dll_desc_set_load_options( + axutil_dll_desc_t * dll_desc, + const axutil_env_t * env, + int options); + + AXIS2_EXTERN int AXIS2_CALL + axutil_dll_desc_get_load_options( + axutil_dll_desc_t * dll_desc, + const axutil_env_t * env); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_dll_desc_set_dl_handler( + axutil_dll_desc_t * dll_desc, + const axutil_env_t * env, + AXIS2_DLHANDLER dl_handler); + + AXIS2_EXTERN AXIS2_DLHANDLER AXIS2_CALL + axutil_dll_desc_get_dl_handler( + axutil_dll_desc_t * dll_desc, + const axutil_env_t * env); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_dll_desc_set_create_funct( + axutil_dll_desc_t * dll_desc, + const axutil_env_t * env, + CREATE_FUNCT funct); + + AXIS2_EXTERN CREATE_FUNCT AXIS2_CALL + axutil_dll_desc_get_create_funct( + axutil_dll_desc_t * dll_desc, + const axutil_env_t * env); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_dll_desc_set_delete_funct( + axutil_dll_desc_t * dll_desc, + const axutil_env_t * env, + DELETE_FUNCT funct); + + AXIS2_EXTERN DELETE_FUNCT AXIS2_CALL + axutil_dll_desc_get_delete_funct( + axutil_dll_desc_t * dll_desc, + const axutil_env_t * env); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_dll_desc_set_timestamp( + axutil_dll_desc_t * dll_desc, + const axutil_env_t * env, + AXIS2_TIME_T timestamp); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_dll_desc_set_error_code( + axutil_dll_desc_t * dll_desc, + const axutil_env_t * env, + axutil_error_codes_t error_code); + + AXIS2_EXTERN axutil_error_codes_t AXIS2_CALL + + axutil_dll_desc_get_error_code( + axutil_dll_desc_t * dll_desc, + const axutil_env_t * env); + + AXIS2_EXTERN AXIS2_TIME_T AXIS2_CALL + axutil_dll_desc_get_timestamp( + axutil_dll_desc_t * dll_desc, + const axutil_env_t * env); + + /** + * This function will accept the library name without any platform + * dependant prefixes or suffixes. It then prefix and suffix + * platform dependant prefix and suffix macros to the original name + * and return the platform specific dll name + * + * @param class_name + * @return platform specific dll name + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + + axutil_dll_desc_create_platform_specific_dll_name( + axutil_dll_desc_t * dll_desc, + const axutil_env_t * env, + const axis2_char_t * class_name); + +#ifdef __cplusplus +} +#endif + +#endif /* AXIS2_DLL_DESC_H */ diff --git a/util/include/axutil_duration.h b/util/include/axutil_duration.h new file mode 100644 index 0000000..7de4fda --- /dev/null +++ b/util/include/axutil_duration.h @@ -0,0 +1,181 @@ + +/* + * 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 + * limitations under the License. + */ + +#ifndef AXUTIL_DURATION_H +#define AXUTIL_DURATION_H + +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axutil_duration + * @ingroup axis2_util + * @{ + */ + + typedef struct axutil_duration axutil_duration_t; + + /** + * Creates axutil_duration struct with current date time + * @param env double pointer to environment struct. MUST NOT be NULL + * @return pointer to newly created axutil_duration struct + */ + AXIS2_EXTERN axutil_duration_t *AXIS2_CALL + axutil_duration_create( + axutil_env_t * env); + + AXIS2_EXTERN axutil_duration_t *AXIS2_CALL + + axutil_duration_create_from_values( + const axutil_env_t * env, + axis2_bool_t negative, + int years, + int months, + int days, + int hours, + int minutes, + double seconds); + + AXIS2_EXTERN axutil_duration_t *AXIS2_CALL + + axutil_duration_create_from_string( + const axutil_env_t * env, + const axis2_char_t * duration_str); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_duration_free( + axutil_duration_t * duration, + const axutil_env_t * env); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + + axutil_duration_deserialize_duration( + axutil_duration_t * duration, + const axutil_env_t * env, + const char *duration_str); + + AXIS2_EXTERN char *AXIS2_CALL + axutil_duration_serialize_duration( + axutil_duration_t * duration, + const axutil_env_t * env); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_duration_set_duration( + axutil_duration_t * duration, + const axutil_env_t * env, + axis2_bool_t negative, + int years, + int months, + int days, + int hours, + int mins, + double seconds); + + AXIS2_EXTERN int AXIS2_CALL + axutil_duration_get_years( + axutil_duration_t * duration, + const axutil_env_t * env); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_duration_set_years( + axutil_duration_t * duration, + const axutil_env_t * env, + int years); + + AXIS2_EXTERN int AXIS2_CALL + axutil_duration_get_months( + axutil_duration_t * duration, + const axutil_env_t * env); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_duration_set_months( + axutil_duration_t * duration, + const axutil_env_t * env, + int months); + + AXIS2_EXTERN int AXIS2_CALL + axutil_duration_get_days( + axutil_duration_t * duration, + const axutil_env_t * env); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_duration_set_days( + axutil_duration_t * duration, + const axutil_env_t * env, + int days); + + AXIS2_EXTERN int AXIS2_CALL + axutil_duration_get_hours( + axutil_duration_t * duration, + const axutil_env_t * env); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_duration_set_hours( + axutil_duration_t * duration, + const axutil_env_t * env, + int hours); + + AXIS2_EXTERN int AXIS2_CALL + axutil_duration_get_mins( + axutil_duration_t * duration, + const axutil_env_t * env); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_duration_set_mins( + axutil_duration_t * duration, + const axutil_env_t * env, + int mins); + + AXIS2_EXTERN double AXIS2_CALL + axutil_duration_get_seconds( + axutil_duration_t * duration, + const axutil_env_t * env); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_duration_set_seconds( + axutil_duration_t * duration, + const axutil_env_t * env, + double seconds); + + AXIS2_EXTERN axis2_bool_t AXIS2_CALL + axutil_duration_get_is_negative( + axutil_duration_t * duration, + const axutil_env_t * env); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_duration_set_is_negative( + axutil_duration_t * duration, + const axutil_env_t * env, + axis2_bool_t is_negative); + + AXIS2_EXTERN axis2_bool_t AXIS2_CALL + axutil_duration_compare( + axutil_duration_t * duration_one, + axutil_duration_t * duration_two, + axutil_env_t * env); + +#ifdef __cplusplus +} +#endif + +#endif /* AXIS2_DURATION_H */ diff --git a/util/include/axutil_env.h b/util/include/axutil_env.h new file mode 100644 index 0000000..d59e5de --- /dev/null +++ b/util/include/axutil_env.h @@ -0,0 +1,233 @@ +/* + * 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 + * limitations under the License. + */ + +#ifndef AXUTIL_ENV_H +#define AXUTIL_ENV_H + +/** + * @file axutil_env.h + * @brief Axis2 environment that acts as a container for error, log and memory + * allocator routines + */ + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axis2_util utilities + * @ingroup axis2 + * @{ + * @} + */ + + struct axutil_env; + struct axutil_env_ops; + + /** + * @defgroup axutil_env environment + * @ingroup axis2_util + * @{ + */ + + /** + * \brief Axis2 Environment struct + * + * Environment acts as a container for error, log, memory allocator and + * threading routines + */ + typedef struct axutil_env + { + + /** Memory allocation routines */ + axutil_allocator_t *allocator; + + /** Error handling */ + axutil_error_t *error; + + /** Logging routines */ + axutil_log_t *log; + + /** This flag indicate whether logging is enabled or not */ + axis2_bool_t log_enabled; + + /** Thread pool routines */ + axutil_thread_pool_t *thread_pool; + + int ref; + + axis2_status_t (*set_session_fn)(void*, const char*, const char*); + char * (*get_session_fn)(void*, const char*); + } + axutil_env_t; + + /** + * Creates an environment struct. Would include a default log and error + * structs within the created environment. By default, logging would be enabled + * and the default log level would be debug. + * @param allocator pointer to an instance of allocator struct. Must not be NULL + * @return pointer to the newly created environment struct + */ + AXIS2_EXTERN axutil_env_t *AXIS2_CALL + axutil_env_create( + axutil_allocator_t * allocator); + + /** + * Creates an environment struct with all of its default parts, + * that is an allocator, error, log and a thread pool. + * @param log_file name of the log file. If NULL, a default log would be created. + * @param log_level log level to be used. If not valid, debug would be + * used as the default log level + * @return pointer to the newly created environment struct + */ + AXIS2_EXTERN axutil_env_t *AXIS2_CALL + axutil_env_create_all( + const axis2_char_t * log_file, + const axutil_log_levels_t log_level); + + + /** + * Creates an environment struct with given error struct. + * @param allocator pointer to an instance of allocator struct. Must not be NULL + * @param error pointer to an instance of error struct. Must not be NULL + * @return pointer to the newly created environment struct + */ + AXIS2_EXTERN axutil_env_t *AXIS2_CALL + axutil_env_create_with_error( + axutil_allocator_t * allocator, + axutil_error_t * error); + + /** + * Creates an environment struct with given error and log structs. + * @param allocator pointer to an instance of allocator struct. Must not be NULL + * @param error pointer to an instance of error struct. Must not be NULL + * @param log pointer to an instance of log struct. If NULL it would be + * assumed that logging is disabled. + * @return pointer to the newly created environment struct + */ + AXIS2_EXTERN axutil_env_t *AXIS2_CALL + axutil_env_create_with_error_log( + axutil_allocator_t * allocator, + axutil_error_t * error, + axutil_log_t * log); + + /** + * Creates an environment struct with given error, log and thread pool structs. + * @param allocator pointer to an instance of allocator struct. Must not be NULL + * @param error pointer to an instance of error struct. Must not be NULL + * @param log pointer to an instance of log struct. If NULL it would be + * assumed that logging is disabled. + * @param pool pointer to an instance of thread_pool. Must not be NULL + * @return pointer to the newly created environment struct + */ + AXIS2_EXTERN axutil_env_t *AXIS2_CALL + axutil_env_create_with_error_log_thread_pool( + axutil_allocator_t * allocator, + axutil_error_t * error, + axutil_log_t * log, + axutil_thread_pool_t * pool); + + /** + * Enable or disable logging. + * @param env pointer to environment struct + * @param enable AXIS2_TRUE to enable logging and AXIS2_FALSE to + * disable logging + * @return AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_env_enable_log( + axutil_env_t * env, + axis2_bool_t enable); + + /** + * Checks the status code of environment stored within error struct. + * @param env pointer to environment struct + * @return error status code or AXIS2_CRITICAL_FAILURE in case of + * a failure + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_env_check_status( + const axutil_env_t * env); + + /** + * Frees an environment struct instance. + * @param env pointer to environment struct instance to be freed. + * @return void + */ + AXIS2_EXTERN void AXIS2_CALL + axutil_env_free( + axutil_env_t * env); + + + #define AXIS_ENV_FREE_LOG 0x1 + #define AXIS_ENV_FREE_ERROR 0x2 + #define AXIS_ENV_FREE_THREADPOOL 0x4 + + /** + * Frees the environment components based on the mask. + * @param env pointer to environment struct to be freed + * @param mask bit pattern indicating which components of the env + * struct are to be freed + * AXIS_ENV_FREE_LOG - Frees the log + * AXIS_ENV_FREE_ERROR - Frees the error + * AXIS_ENV_FREE_THREADPOOL - Frees the thread pool + * You can use combinations to free multiple components as well + * E.g : AXIS_ENV_FREE_LOG | AXIS_ENV_FREE_ERROR frees both log and error, but not the thread pool + * @return void + */ + AXIS2_EXTERN void AXIS2_CALL + axutil_env_free_masked( + axutil_env_t * env, + char mask); + + /** + * Incrent the reference count.This is used when objects are created + * using this env and keeping this for future use. + * @param env pointer to environment struct instance to be freed. + * @return void + */ + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_env_increment_ref( + axutil_env_t * env); + + + +/* AXIS2_ENV_CHECK is a macro to check environment pointer. + Currently this is set to an empty value. + But it was used to be defined as: + #define AXIS2_ENV_CHECK(env, error_return) \ + if(!env) \ + { \ + return error_return; \ + } +*/ +#define AXIS2_ENV_CHECK(env, error_return) + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIS2_ENV_H */ diff --git a/util/include/axutil_error.h b/util/include/axutil_error.h new file mode 100644 index 0000000..3b27a81 --- /dev/null +++ b/util/include/axutil_error.h @@ -0,0 +1,876 @@ +/* + * 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 + * limitations under the License. + */ + +#ifndef AXUTIL_ERROR_H +#define AXUTIL_ERROR_H + +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + +#define AXUTIL_ERROR_MESSAGE_BLOCK_SIZE 512 +#define AXUTIL_ERROR_LAST AXUTIL_ERROR_MESSAGE_BLOCK_SIZE +#define NEETHI_ERROR_CODES_START AXIS2_ERROR_LAST +#define RAMPART_ERROR_CODES_START (NEETHI_ERROR_CODES_START + AXUTIL_ERROR_MESSAGE_BLOCK_SIZE) +#define SANDESHA2_ERROR_CODES_START (RAMPART_ERROR_CODES_START + AXUTIL_ERROR_MESSAGE_BLOCK_SIZE) +#define SAVAN_ERROR_CODES_START (SANDESHA2_ERROR_CODES_START + AXUTIL_ERROR_MESSAGE_BLOCK_SIZE) +#define USER_ERROR_CODES_START (SAVAN_ERROR_CODES_START + AXUTIL_ERROR_MESSAGE_BLOCK_SIZE) + +/* AXUTIL_ERROR_MAX define the maximum size of the error array */ +#define AXUTIL_ERROR_MAX (USER_ERROR_CODES_START + AXUTIL_ERROR_MESSAGE_BLOCK_SIZE) + + + /** + * \brief Axis2 status codes + * + * Possible status values for Axis2 + */ + enum axis2_status_codes + { + /** Critical Failure state */ + AXIS2_CRITICAL_FAILURE = -1, + + /** Failure state */ + AXIS2_FAILURE, + + /** Success state */ + AXIS2_SUCCESS + }; + + /** + * \brief Axis2 error codes + * + * Set of error codes for Axis2 + */ + enum axutil_error_codes + { + + /** + * No error. + * This must be the first error all the time and the assigned value of 0 + * must not be changed as it is assumed in the error message array that + * the error list starts with a value of 0. + * Further, none of the error codes in this enum should not be initialized + * to an arbitrary value as it is assumed in the implementation when mapping + * error codes to error messages that the error codes are contiguous and + * the last error value is always AXIS2_ERROR_LAST. + */ + AXIS2_ERROR_NONE = 0, + + /* + * Group - Common Errors + */ + + /** Out of memory */ + AXIS2_ERROR_NO_MEMORY, + + /** NULL parameter was passed when a non NULL parameter was expected */ + AXIS2_ERROR_INVALID_NULL_PARAM, + + /* + * Group - core:addr + */ + + /* + * Group - core:clientapi + */ + + /** Blocking invocation expects response */ + AXIS2_ERROR_BLOCKING_INVOCATION_EXPECTS_RESPONSE, + + /** cannot infer transport from URL */ + AXIS2_ERROR_CANNOT_INFER_TRANSPORT, + + /** Client side support only one configuration context */ + AXIS2_ERROR_CLIENT_SIDE_SUPPORT_ONLY_ONE_CONF_CTX, + /* MEP cannot be NULL in MEP client */ + AXIS2_ERROR_MEP_CANNOT_BE_NULL_IN_MEP_CLIENT, + /* MEP Mismatch */ + AXIS2_ERROR_MEP_MISMATCH_IN_MEP_CLIENT, + + /** Two way channel needs addressing module to be engaged */ + AXIS2_ERROR_TWO_WAY_CHANNEL_NEEDS_ADDRESSING, + + /** Unknown Transport */ + AXIS2_ERROR_UNKNOWN_TRANSPORT, + /* Unsupported SOAP style */ + AXIS2_ERROR_UNSUPPORTED_TYPE, + /* Options object is not set */ + AXIS2_ERROR_OPTIONS_OBJECT_IS_NOT_SET, + + /* Session Timeout */ + AXIS2_ERROR_SESSION_TIMEOUT, + /* + * Group - core:clientapi:diclient + */ + + /* + * Group - core:context + */ + + /** Invalid SOAP envelope state */ + AXIS2_ERROR_INVALID_SOAP_ENVELOPE_STATE, + + /** Invalid message context state */ + AXIS2_ERROR_INVALID_STATE_MSG_CTX, + + /** Service accessed has invalid state */ + AXIS2_ERROR_INVALID_STATE_SVC, + + /** Service group accessed has invalid state */ + AXIS2_ERROR_INVALID_STATE_SVC_GRP, + + /** Service not yet found */ + AXIS2_ERROR_SERVICE_NOT_YET_FOUND, + + /* + * Group - core:deployment + */ + /* Invalid phase found in phase validation */ + AXI2_ERROR_INVALID_PHASE, + /* axis2.xml cannot be found */ + AXIS2_ERROR_CONFIG_NOT_FOUND, + /* Data element of the OM Node is null */ + AXIS2_ERROR_DATA_ELEMENT_IS_NULL, + /* In transport sender, Inflow is not allowed */ + AXIS2_ERROR_IN_FLOW_NOT_ALLOWED_IN_TRS_OUT, + + /** Invalid handler state */ + AXIS2_ERROR_INVALID_HANDLER_STATE, + /* Invalid Module Ref encountered */ + AXIS2_ERROR_INVALID_MODUELE_REF, + /* Invalid Module Reference by Operation */ + AXIS2_ERROR_INVALID_MODUELE_REF_BY_OP, + /* Invalid Module Configuration */ + AXIS2_ERROR_INVALID_MODULE_CONF, + /* Description Builder is found to be in invalid state */ + AXIS2_ERROR_INVALID_STATE_DESC_BUILDER, + /* Module Not Found */ + AXIS2_ERROR_MODULE_NOT_FOUND, + /* Module Validation Failed */ + AXIS2_ERROR_MODULE_VALIDATION_FAILED, + + /** Module xml file is not found in the given path */ + AXIS2_ERROR_MODULE_XML_NOT_FOUND_FOR_THE_MODULE, + /* No dispatcher found */ + AXIS2_ERROR_NO_DISPATCHER_FOUND, + /* Operation name is missing */ + AXIS2_ERROR_OP_NAME_MISSING, + /* In transport Receiver, Outflow is not allowed */ + AXIS2_ERROR_OUT_FLOW_NOT_ALLOWED_IN_TRS_IN, + /* Repository name cannot be NULL */ + AXIS2_ERROR_REPO_CAN_NOT_BE_NULL, + /* Repository in path does not exist */ + AXIS2_ERROR_REPOSITORY_NOT_EXIST, + /* Repository Listener initialization failed */ + AXIS2_ERROR_REPOS_LISTENER_INIT_FAILED, + + /** Service xml file is not found in the given path */ + AXIS2_ERROR_SERVICE_XML_NOT_FOUND, + /* Service Name Error */ + AXIS2_ERROR_SVC_NAME_ERROR, + /* Transport Sender Error */ + AXIS2_ERROR_TRANSPORT_SENDER_ERROR, + /* Path to Config can not be NULL */ + AXIS2_PATH_TO_CONFIG_CAN_NOT_BE_NULL, + /* Invalid Service */ + AXIS2_ERROR_INVALID_SVC, + + + /* + * Group - core:description + */ + /* Cannot correlate message */ + AXIS2_ERROR_CANNOT_CORRELATE_MSG, + + /** Could not Map the MEP URI to a axis MEP constant value */ + AXIS2_ERROR_COULD_NOT_MAP_MEP_URI_TO_MEP_CONSTANT, + /* Invalid message addition , operation context completed */ + AXIS2_ERROR_INVALID_MESSAGE_ADDITION, + + /** Module description accessed has invalid state */ + AXIS2_ERROR_INVALID_STATE_MODULE_DESC, + + /** Parameter container not set */ + AXIS2_ERROR_INVALID_STATE_PARAM_CONTAINER, + + /** module has already engaged to the op op terminated !!! */ + AXIS2_ERROR_MODULE_ALREADY_ENGAGED_TO_OP, + + /** module has already been engaged on the service.Operation terminated !!! */ + AXIS2_ERROR_MODULE_ALREADY_ENGAGED_TO_SVC, + + /** module has already been engaged on the service. Group Operation terminated !!! */ + AXIS2_ERROR_MODULE_ALREADY_ENGAGED_TO_SVC_GRP, + + /** Parameter locked, Cannot override */ + AXIS2_ERROR_PARAMETER_LOCKED_CANNOT_OVERRIDE, + /* schema list is empty or NULL in svc */ + AXIS2_ERROR_EMPTY_SCHEMA_LIST, + /* + * Group - core:engine + */ + + /** Both before and after handlers cannot be the same */ + AXIS2_ERROR_BEFORE_AFTER_HANDLERS_SAME, + + /** Invalid handler rules */ + AXIS2_ERROR_INVALID_HANDLER_RULES, + /* Invalid Module */ + AXIS2_ERROR_INVALID_MODULE, + + /** Invalid first handler for phase */ + AXIS2_ERROR_INVALID_PHASE_FIRST_HANDLER, + + /** Invalid last handler for phase */ + AXIS2_ERROR_INVALID_PHASE_LAST_HANDLER, + + /** Invalid engine config state */ + AXIS2_ERROR_INVALID_STATE_CONF, + + /** Message context processing a fault already */ + AXIS2_ERROR_INVALID_STATE_PROCESSING_FAULT_ALREADY, + + /** fault to field not specified in message context */ + AXIS2_ERROR_NOWHERE_TO_SEND_FAULT, + + /** Only one handler allowed for phase, adding handler is not allowed */ + AXIS2_ERROR_PHASE_ADD_HANDLER_INVALID, + + /** First handler of phase already set */ + AXIS2_ERROR_PHASE_FIRST_HANDLER_ALREADY_SET, + + /** Last handler of phase already set */ + AXIS2_ERROR_PHASE_LAST_HANDLER_ALREADY_SET, + + /**Two service can not have same name, a service with same name already + exist in the system */ + AXIS2_ERROR_TWO_SVCS_CANNOT_HAVE_SAME_NAME, + /* + * Group - core:phase resolver + */ + /* Invalid Module Ref */ + AXIS2_ERROR_INVALID_MODULE_REF, + /* Invalid Phase */ + AXIS2_ERROR_INVALID_PHASE, + /* No Transport Receiver is configured */ + AXIS2_ERROR_NO_TRANSPORT_IN_CONFIGURED, + /* No Transport Sender is configured */ + AXIS2_ERROR_NO_TRANSPORT_OUT_CONFIGURED, + /* Phase is not specified */ + AXIS2_ERROR_PHASE_IS_NOT_SPECIFED, + /* Service module can not refer global phase */ + AXIS2_ERROR_SERVICE_MODULE_CAN_NOT_REFER_GLOBAL_PHASE, + + /* + * Group - core:wsdl + */ + + /** Schema is NULL */ + AXIS2_ERROR_WSDL_SCHEMA_IS_NULL, + /* + * Group - core:receivers + */ + /* Om Element has invalid state */ + AXIS2_ERROR_OM_ELEMENT_INVALID_STATE, + /* Om Elements do not match */ + AXIS2_ERROR_OM_ELEMENT_MISMATCH, + /* RPC style SOAP body don't have a child element */ + AXIS2_ERROR_RPC_NEED_MATCHING_CHILD, + /* Operation Description has unknown operation style */ + AXIS2_ERROR_UNKNOWN_STYLE, + /* String does not represent a valid NCName */ + AXIS2_ERROR_STRING_DOES_NOT_REPRESENT_A_VALID_NC_NAME, + /* + * Group - core:transport + */ + + /* + * Group - core:transport:http + */ + /* Error occurred in transport */ + AXIS2_ERROR_HTTP_CLIENT_TRANSPORT_ERROR, + + /** A read attempt(HTTP) for the reply without sending the request */ + AXIS2_ERROR_HTTP_REQUEST_NOT_SENT, + + /** Invalid string passed as a http header */ + AXIS2_ERROR_INVALID_HEADER, + /* Invalid header start line (request line or response line) */ + AXIS2_ERROR_INVALID_HTTP_HEADER_START_LINE, + /* Transport protocol is unsupported by axis2 */ + AXIS2_ERROR_INVALID_TRANSPORT_PROTOCOL, + + /** No body present in the request or the response */ + AXIS2_ERROR_NULL_BODY, + /* A valid conf_ctx is reqd for the http worker */ + AXIS2_ERROR_NULL_CONFIGURATION_CONTEXT, + /* HTTP version cannot be null in the status/request line */ + AXIS2_ERROR_NULL_HTTP_VERSION, + /* Input stream is NULL in msg_ctx */ + AXIS2_ERROR_NULL_IN_STREAM_IN_MSG_CTX, + /* OM output is NULL */ + AXIS2_ERROR_NULL_OM_OUTPUT, + /* Null SOAP envelope in msg_ctx */ + AXIS2_ERROR_NULL_SOAP_ENVELOPE_IN_MSG_CTX, + /* NULL stream in the http chucked stream */ + AXIS2_ERROR_NULL_STREAM_IN_CHUNKED_STREAM, + /* We got a NULL stream in the response body */ + AXIS2_ERROR_NULL_STREAM_IN_RESPONSE_BODY, + + /** URL NULL in http client */ + AXIS2_ERROR_NULL_URL, + /** Invalid URL format */ + AXIS2_ERROR_INVALID_URL_FORMAT, + /** Duplicate URL REST Mapping */ + AXIS2_ERROR_DUPLICATE_URL_REST_MAPPING, + /* We need transport_info in msg_ctx */ + AXIS2_ERROR_OUT_TRNSPORT_INFO_NULL, + /*Content-Type header missing in HTTP response" */ + AXIS2_ERROR_RESPONSE_CONTENT_TYPE_MISSING, + + /** Response timed out */ + AXIS2_ERROR_RESPONSE_TIMED_OUT, + + /** Server shutdown*/ + AXIS2_ERROR_RESPONSE_SERVER_SHUTDOWN, + + /** SOAP envelope or SOAP body NULL */ + AXIS2_ERROR_SOAP_ENVELOPE_OR_SOAP_BODY_NULL, + /* Error occurred in SSL engine */ + AXIS2_ERROR_SSL_ENGINE, + /* Either axis2c cannot find certificates or the env variable is not set */ + AXIS2_ERROR_SSL_NO_CA_FILE, + /* Error in writing the response in response writer */ + AXIS2_ERROR_WRITING_RESPONSE, + /* Required parameter is missing in URL encoded request */ + AXIS2_ERROR_REQD_PARAM_MISSING, + /* Unsupported schema type in REST */ + AXIS2_ERROR_UNSUPPORTED_SCHEMA_TYPE, + /* Service or operation not found */ + AXIS2_ERROR_SVC_OR_OP_NOT_FOUND, + /* + * Group - mod_addr + */ + AXIS2_ERROR_NO_MSG_INFO_HEADERS, + /* + * Group - platforms + */ + + /* + * Group - utils + */ + + /** Could not open the axis2 file */ + AXIS2_ERROR_COULD_NOT_OPEN_FILE, + /* Failed in creating DLL */ + AXIS2_ERROR_DLL_CREATE_FAILED, + /* DLL loading failed */ + AXIS2_ERROR_DLL_LOADING_FAILED, + + /** Environment passed is null */ + AXIS2_ERROR_ENVIRONMENT_IS_NULL, + /* Axis2 File does not have a file name */ + AXIS2_ERROR_FILE_NAME_NOT_SET, + /* DLL Description Info Object has invalid state */ + AXIS2_ERROR_INVALID_STATE_DLL_DESC, + /* Failed in creating Handler */ + AXIS2_ERROR_HANDLER_CREATION_FAILED, + + /** Array list index out of bounds */ + AXIS2_ERROR_INDEX_OUT_OF_BOUNDS, + + /** Invalid IP or host name */ + AXIS2_ERROR_INVALID_ADDRESS, + + /** Trying to do operation on invalid file descriptor */ + AXIS2_ERROR_INVALID_FD, + + /** Trying to do operation on closed/not opened socket */ + AXIS2_ERROR_INVALID_SOCKET, + + /** Parameter not set */ + AXIS2_ERROR_INVALID_STATE_PARAM, + /* Module create failed */ + AXIS2_ERROR_MODULE_CREATION_FAILED, + /* Failed in creating Message Receiver */ + AXIS2_ERROR_MSG_RECV_CREATION_FAILED, + + /** No such element */ + AXIS2_ERROR_NO_SUCH_ELEMENT, + + /** Socket bind failed. Another process may be already using this port*/ + AXIS2_ERROR_SOCKET_BIND_FAILED, + + /** Error creating a socket. Most probably error returned by OS */ + AXIS2_ERROR_SOCKET_ERROR, + /* Listen failed for the server socket */ + AXIS2_ERROR_SOCKET_LISTEN_FAILED, + /* Failed in creating Service Skeleton */ + AXIS2_ERROR_SVC_SKELETON_CREATION_FAILED, + /* Failed in creating Transport Receiver */ + AXIS2_ERROR_TRANSPORT_RECV_CREATION_FAILED, + /* Failed in creating Transport Sender */ + AXIS2_ERROR_TRANSPORT_SENDER_CREATION_FAILED, + /* Generation of platform dependent uuid failed */ + AXIS2_ERROR_UUID_GEN_FAILED, + /* Possible deadlock */ + AXIS2_ERROR_POSSIBLE_DEADLOCK, + /* + * Group - WSDL + */ + /* Interface or Port Type not found for the binding */ + AXIS2_ERROR_INTERFACE_OR_PORT_TYPE_NOT_FOUND_FOR_THE_BINDING, + /* Interfaces or Ports not found for the partially built WOM */ + AXIS2_ERROR_INTERFACES_OR_PORTS_NOT_FOUND_FOR_PARTIALLY_BUILT_WOM, + + /** Wsdl op accessed has invalid state */ + AXIS2_ERROR_INVALID_STATE_WSDL_OP, + + /** Wsdl Service accessed has invalid state */ + AXIS2_ERROR_INVALID_STATE_WSDL_SVC, + /* Cannot determine MEP */ + AXIS2_ERROR_MEP_CANNOT_DETERMINE_MEP, + /* Wsdl binding name cannot be NULL(Is required) */ + AXIS2_ERROR_WSDL_BINDING_NAME_IS_REQUIRED, + /* PortType/Interface name cannot be null(Required) */ + AXIS2_ERROR_WSDL_INTERFACE_NAME_IS_REQUIRED, + /* Wsdl parsing has resulted in an invalid state */ + AXIS2_ERROR_WSDL_PARSER_INVALID_STATE, + /* Wsdl svc name cannot be null(Required) */ + AXIS2_ERROR_WSDL_SVC_NAME_IS_REQUIRED, + /* + * Group - xml + */ + + /* + * Group - xml:attachments + */ + /** Attachment is missing */ + AXIS2_ERROR_ATTACHMENT_MISSING, + + /* + * Group - xml:om + */ + + /** Builder done with pulling. Cannot pull any more */ + AXIS2_ERROR_BUILDER_DONE_CANNOT_PULL, + + /** Discard failed because the builder state is invalid */ + AXIS2_ERROR_INVALID_BUILDER_STATE_CANNOT_DISCARD, + + /** Builder's last node is NULL when it is not supposed to be NULL */ + AXIS2_ERROR_INVALID_BUILDER_STATE_LAST_NODE_NULL, + + /** Document root is NULL, when it is not supposed to be NULL */ + AXIS2_ERROR_INVALID_DOCUMENT_STATE_ROOT_NULL, + + /** Undefined namespace used */ + AXIS2_ERROR_INVALID_DOCUMENT_STATE_UNDEFINED_NAMESPACE, + + /** error a namespace should have a valid uri */ + AXIS2_ERROR_INVALID_EMPTY_NAMESPACE_URI, + + /** next method has not been called so cannot remove + an element before calling next valid for any om iterator */ + AXIS2_ERROR_ITERATOR_NEXT_METHOD_HAS_NOT_YET_BEEN_CALLED, + + /** remove method has already been called once so cannot remove till + next method is called valid for any om children iterator*/ + AXIS2_ERROR_ITERATOR_REMOVE_HAS_ALREADY_BEING_CALLED, + + /** axiom_xml_reader returned NULL element */ + AXIS2_ERROR_XML_READER_ELEMENT_NULL, + + /** axiom_xml_reader returned NULL value */ + AXIS2_ERROR_XML_READER_VALUE_NULL, + /* + * Group - xml:parser + */ + + /** error occurred creating xml stream reader */ + AXIS2_ERROR_CREATING_XML_STREAM_READER, + + /** error occurred creating xml stream writer */ + AXIS2_ERROR_CREATING_XML_STREAM_WRITER, + + /** error in writing attribute */ + AXIS2_ERROR_WRITING_ATTRIBUTE, + + /** error in writing attribute with namespace */ + AXIS2_ERROR_WRITING_ATTRIBUTE_WITH_NAMESPACE, + + /** error in writing attribute with namespace prefix */ + AXIS2_ERROR_WRITING_ATTRIBUTE_WITH_NAMESPACE_PREFIX, + + /** error in writing comment */ + AXIS2_ERROR_WRITING_COMMENT, + + /** error in writing data source*/ + AXIS2_ERROR_WRITING_DATA_SOURCE, + + /** error in writing default namespace */ + AXIS2_ERROR_WRITING_DEFAULT_NAMESPACE, + + /** error in writing DDT */ + AXIS2_ERROR_WRITING_DTD, + + /** error occurred in writing empty element */ + AXIS2_ERROR_WRITING_EMPTY_ELEMENT, + + /** error occurred in writing empty element with namespace */ + AXIS2_ERROR_WRITING_EMPTY_ELEMENT_WITH_NAMESPACE, + + /** error in writing empty element with namespace prefix */ + AXIS2_ERROR_WRITING_EMPTY_ELEMENT_WITH_NAMESPACE_PREFIX, + + /** error occurred in writing end document in xml writer */ + AXIS2_ERROR_WRITING_END_DOCUMENT, + + /** error occurred in writing end element in xml writer */ + AXIS2_ERROR_WRITING_END_ELEMENT, + + /** error in writing processing instruction */ + AXIS2_ERROR_WRITING_PROCESSING_INSTRUCTION, + + /** error occurred in writing start element in start document in xml writer */ + AXIS2_ERROR_WRITING_START_DOCUMENT, + + /** error occurred in writing start element in xml writer */ + AXIS2_ERROR_WRITING_START_ELEMENT, + + /** error occurred in writing start element with namespace in xml writer*/ + AXIS2_ERROR_WRITING_START_ELEMENT_WITH_NAMESPACE, + + /** error occurred in writing start element with namespace prefix */ + AXIS2_ERROR_WRITING_START_ELEMENT_WITH_NAMESPACE_PREFIX, + + /** error in writing cdata section */ + AXIS2_ERROR_WRITING_CDATA, + + /** AXIS2_XML_PARSER_TYPE_BUFFER or AXIS2_XML_PARSER_TYPE_DOC is expected */ + AXIS2_ERROR_XML_PARSER_INVALID_MEM_TYPE, + + /* + * Group - xml:SOAP + */ + + /** invalid type passed */ + AXIS2_ERROR_INVALID_BASE_TYPE, + + /** invalid SOAP namespace uri found */ + AXIS2_ERROR_INVALID_SOAP_NAMESPACE_URI, + + /** Invalid SOAP version */ + AXIS2_ERROR_INVALID_SOAP_VERSION, + /* invalid value found in must understand attribute */ + AXIS2_ERROR_INVALID_VALUE_FOUND_IN_MUST_UNDERSTAND, + /*multiple code elements encountered in SOAP fault element */ + AXIS2_ERROR_MULTIPLE_CODE_ELEMENTS_ENCOUNTERED, + /*multiple detail elements encountered in SOAP fault element */ + AXIS2_ERROR_MULTIPLE_DETAIL_ELEMENTS_ENCOUNTERED, + /*multiple node elements encountered in SOAP fault element */ + AXIS2_ERROR_MULTIPLE_NODE_ELEMENTS_ENCOUNTERED, + /*multiple reason elements encountered in SOAP fault element */ + AXIS2_ERROR_MULTIPLE_REASON_ELEMENTS_ENCOUNTERED, + /*multiple role elements encountered in SOAP fault element */ + AXIS2_ERROR_MULTIPLE_ROLE_ELEMENTS_ENCOUNTERED, + /*multiple sub code values encountered in SOAP fault element */ + AXIS2_ERROR_MULTIPLE_SUB_CODE_VALUES_ENCOUNTERED, + /* multiple value elements encountered */ + AXIS2_ERROR_MULTIPLE_VALUE_ENCOUNTERED_IN_CODE_ELEMENT, + /* must understand attribute should have values of true or false */ + AXIS2_ERROR_MUST_UNDERSTAND_SHOULD_BE_1_0_TRUE_FALSE, + + /** om element is expected */ + AXIS2_ERROR_OM_ELEMENT_EXPECTED, + /* processing SOAP 1.1 fault value element should have only + text as its children */ + AXIS2_ERROR_ONLY_CHARACTERS_ARE_ALLOWED_HERE, + + /** only one SOAP fault allowed in SOAP body */ + AXIS2_ERROR_ONLY_ONE_SOAP_FAULT_ALLOWED_IN_BODY, + /*SOAP 1.1 fault actor element should not have child elements */ + AXIS2_ERROR_SOAP11_FAULT_ACTOR_SHOULD_NOT_HAVE_CHILD_ELEMENTS, + + /** SOAP builder found a child element other than header or body in envelope + element */ + AXIS2_ERROR_SOAP_BUILDER_ENVELOPE_CAN_HAVE_ONLY_HEADER_AND_BODY, + + /** SOAP builder encountered body element first and header next */ + AXIS2_ERROR_SOAP_BUILDER_HEADER_BODY_WRONG_ORDER, + + /** SOAP builder multiple body elements encountered */ + AXIS2_ERROR_SOAP_BUILDER_MULTIPLE_BODY_ELEMENTS_ENCOUNTERED, + + /** SOAP builder encountered multiple headers */ + AXIS2_ERROR_SOAP_BUILDER_MULTIPLE_HEADERS_ENCOUNTERED, + /*SOAP fault code element should a mandatory fault value element */ + AXIS2_ERROR_SOAP_FAULT_CODE_DOES_NOT_HAVE_A_VALUE, + /*SOAP fault reason element should have a text */ + AXIS2_ERROR_SOAP_FAULT_REASON_ELEMENT_SHOULD_HAVE_A_TEXT, + /*SOAP fault role element should have a text value */ + AXIS2_ERROR_SOAP_FAULT_ROLE_ELEMENT_SHOULD_HAVE_A_TEXT, + /* SOAP fault value should be present before sub code element in SOAP fault code */ + AXIS2_ERROR_SOAP_FAULT_VALUE_SHOULD_BE_PRESENT_BEFORE_SUB_CODE, + + /** SOAP message does not have an envelope element */ + AXIS2_ERROR_SOAP_MESSAGE_DOES_NOT_CONTAIN_AN_ENVELOPE, + /*SOAP message first element must contain a localname */ + AXIS2_ERROR_SOAP_MESSAGE_FIRST_ELEMENT_MUST_CONTAIN_LOCAL_NAME, + /* this localname is not supported inside a reason element */ + AXIS2_ERROR_THIS_LOCALNAME_IS_NOT_SUPPORTED_INSIDE_THE_REASON_ELEMENT, + /*this localname is not supported inside a sub code element */ + AXIS2_ERROR_THIS_LOCALNAME_IS_NOT_SUPPORTED_INSIDE_THE_SUB_CODE_ELEMENT, + /*this localname is not supported inside the code element */ + AXIS2_ERROR_THIS_LOCALNAME_NOT_SUPPORTED_INSIDE_THE_CODE_ELEMENT, + /*transport level identified SOAP version does not match with the SOAP version */ + AXIS2_ERROR_TRANSPORT_LEVEL_INFORMATION_DOES_NOT_MATCH_WITH_SOAP, + /*unsupported element in SOAP fault element */ + AXIS2_ERROR_UNSUPPORTED_ELEMENT_IN_SOAP_FAULT_ELEMENT, + /*wrong element order encountered */ + AXIS2_ERROR_WRONG_ELEMENT_ORDER_ENCOUNTERED, + /* + * Group - services + */ + + /** Invalid XML format in request */ + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + + /** Input OM node NULL, Probably error in SOAP request */ + AXIS2_ERROR_SVC_SKEL_INPUT_OM_NODE_NULL, + + /** Invalid parameters for service operation in SOAP request */ + AXIS2_ERROR_SVC_SKEL_INVALID_OPERATION_PARAMETERS_IN_SOAP_REQUEST, + + /* + * Group - repos + */ + /* not authenticated */ + AXIS2_ERROR_REPOS_NOT_AUTHENTICATED, + /* unsupported mode */ + AXIS2_ERROR_REPOS_UNSUPPORTED_MODE, + /* expired */ + AXIS2_ERROR_REPOS_EXPIRED, + /* not implemented */ + AXIS2_ERROR_REPOS_NOT_IMPLEMENTED, + /* not found */ + AXIS2_ERROR_REPOS_NOT_FOUND, + /* bad search text */ + AXIS2_ERROR_REPOS_BAD_SEARCH_TEXT, + + /* + *Group - Neethi + */ + /* No Namespace */ + AXIS2_ERROR_NEETHI_ELEMENT_WITH_NO_NAMESPACE, + /*Policy cannot be created from element */ + AXIS2_ERROR_NEETHI_POLICY_CREATION_FAILED_FROM_ELEMENT, + /*All Cannot be created from element */ + AXIS2_ERROR_NEETHI_ALL_CREATION_FAILED_FROM_ELEMENT, + /*Exactly one Cannot be created element */ + AXIS2_ERROR_NEETHI_EXACTLYONE_CREATION_FAILED_FROM_ELEMENT, + /*Reference Cannot be created from element */ + AXIS2_ERROR_NEETHI_REFERENCE_CREATION_FAILED_FROM_ELEMENT, + /*Assertion Cannot be created from element */ + AXIS2_ERROR_NEETHI_ASSERTION_CREATION_FAILED_FROM_ELEMENT, + /*All creation failed */ + AXIS2_ERROR_NEETHI_ALL_CREATION_FAILED, + /*Exactly one creation failed */ + AXIS2_ERROR_NEETHI_EXACTLYONE_CREATION_FAILED, + /*Policy Creation failed */ + AXIS2_ERROR_NEETHI_POLICY_CREATION_FAILED, + /*Normalization failed */ + AXIS2_ERROR_NEETHI_NORMALIZATION_FAILED, + /*Merging Failed. Wrong Input */ + AXIS2_ERROR_NEETHI_WRONG_INPUT_FOR_MERGE, + /*Merging Failed. Cross Product failed */ + AXIS2_ERROR_NEETHI_CROSS_PRODUCT_FAILED, + /*No Children Policy Components */ + AXIS2_ERROR_NEETHI_NO_CHILDREN_POLICY_COMPONENTS, + /*Uri Not specified */ + AXIS2_ERROR_NEETHI_URI_NOT_SPECIFIED, + /*Policy NULL for the given uri */ + AXIS2_ERROR_NEETHI_NO_ENTRY_FOR_THE_GIVEN_URI, + /*Exactly one not found in Normalized policy */ + AXIS2_ERROR_NEETHI_EXACTLYONE_NOT_FOUND_IN_NORMALIZED_POLICY, + /*Exactly one is Empty */ + AXIS2_ERROR_NEETHI_EXACTLYONE_IS_EMPTY, + /*Exactly one not found while getting cross product */ + AXIS2_ERROR_NEETHI_ALL_NOT_FOUND_WHILE_GETTING_CROSS_PRODUCT, + /*Unknown Assertion*/ + AXIS2_ERROR_NEETHI_UNKNOWN_ASSERTION, + /** + * The following has to be the last error value all the time. + * All other error codes should appear above this. + * AXIS2_ERROR_LAST is used to track the number of error codes present + * for the purpose of sizing the error messages array. + */ + AXIS2_ERROR_LAST + }; + + struct axutil_error; + typedef enum axis2_status_codes axis2_status_codes_t; + typedef enum axutil_error_codes axutil_error_codes_t; + + /** + * @defgroup axutil_error error + * @ingroup axis2_util + * @{ + */ + + /** + * Axutil error struct. + * Error holds the last error number, the status code as well as the + * last error message. + */ + typedef struct axutil_error + { + /** + * Memory allocator associated with the error struct. + * It is this allocator that would be used to allocate memory + * for the error struct instance in create method. + */ + axutil_allocator_t *allocator; + + /** Last error number. */ + int error_number; + /** Last status code. */ + int status_code; + /** + * Error message. This could be set to a custom message to be + * returned, instead of standard errors set in the error messages + * array by the axutil_error_init function call. + */ + axis2_char_t *message; + } + axutil_error_t; + + /** + * Gets the error message corresponding to the last error occurred. + * @param error pointer to error struct + * @return string representing the error message for the last error occurred + */ + AXIS2_EXTERN const axis2_char_t *AXIS2_CALL + axutil_error_get_message( + const struct axutil_error *error); + + /** + * This function is supposed to be overridden in an extended error structure. + * For example in Sandesha error structure this function is overridden so that + * errors of axis2 range call the get_message function of error struct but + * errors of sandesha2 range get the messages from an array of that struct. + * @return error message for the extended struct. + * @deprecated this function is not in use, so should be removed. + */ + /*AXIS2_EXTERN const axis2_char_t *AXIS2_CALL + axutil_error_get_extended_message( + const struct axutil_error *error);*/ + + /** + * Sets the error number. + * @param error pointer to error struct + * @param error_number error number to be set + * @return AXIS2_SUCCESS on success, else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_error_set_error_number( + struct axutil_error *error, + axutil_error_codes_t error_number); + + /** + * Sets the status code. + * @param error pointer to error struct + * @param status_code status code to be set + * @return AXIS2_SUCCESS on success, else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_error_set_status_code( + struct axutil_error *error, + axis2_status_codes_t status_code); + + /** + * Gets the status code. + * @param error pointer to error struct + * @return last status code set on error struct + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_error_get_status_code( + struct axutil_error *error); + + /** + * Sets error message to the given value. + * @param error pointer to error struct + * @param message error message to be set + * @return AXIS2_SUCCESS on success, else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_error_set_error_message( + struct axutil_error *error, + axis2_char_t *message); + + /** + * Initializes the axutil_error_messages array. This array holds the + * error messages that corresponds to the error codes. This function + * must be call before using the error struct instance. + * @return AXIS2_SUCCESS on success, else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_error_init(void); + + /** + * De-allocates an error struct instance. + * @param error pointer to error struct instance to be freed. + * @return void + */ + AXIS2_EXTERN void AXIS2_CALL + axutil_error_free( + struct axutil_error *error); + +/** + * @deprecated The following macros are no longer useful as we can use the + * function calls directly. Hence these macros should be removed + */ + +#define AXIS2_ERROR_FREE(error) axutil_error_free(error) + +#define AXIS2_ERROR_GET_MESSAGE(error) \ + axutil_error_get_message(error) + +#define AXIS2_ERROR_SET_MESSAGE(error, message) \ + axutil_error_set_error_message(error, message) + +#define AXIS2_ERROR_SET_ERROR_NUMBER(error, error_number) \ + axutil_error_set_error_number(error, error_number) + +#define AXIS2_ERROR_SET_STATUS_CODE(error, status_code) \ + axutil_error_set_status_code(error, status_code) + +#define AXIS2_ERROR_GET_STATUS_CODE(error) axutil_error_get_status_code(error) + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIS2_ERROR_H */ diff --git a/util/include/axutil_error_default.h b/util/include/axutil_error_default.h new file mode 100644 index 0000000..82a611c --- /dev/null +++ b/util/include/axutil_error_default.h @@ -0,0 +1,52 @@ + +/* + * 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 + * limitations under the License. + */ + +#ifndef AXUTIL_ERROR_DEFAULT_H +#define AXUTIL_ERROR_DEFAULT_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axutil_error error + * @ingroup axis2_util + * @{ + */ + + /** + * Creates an error struct + * @param allocator allocator to be used. Mandatory, cannot be NULL + * @return pointer to the newly created error struct + */ + AXIS2_EXTERN axutil_error_t *AXIS2_CALL + axutil_error_create( + axutil_allocator_t * allocator); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIS2_ERROR_DEFAULT_H */ diff --git a/util/include/axutil_file.h b/util/include/axutil_file.h new file mode 100644 index 0000000..d03e4df --- /dev/null +++ b/util/include/axutil_file.h @@ -0,0 +1,99 @@ + +/* + * 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 + * limitations under the License. + */ + +#ifndef AXUTIL_FILE_H +#define AXUTIL_FILE_H + +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct axutil_file axutil_file_t; + + /** + * @defgroup axutil_file file + * @ingroup axis2_util + * @{ + */ + + /** + * create new file + * @return file newly created file + */ + AXIS2_EXTERN axutil_file_t *AXIS2_CALL + axutil_file_create( + const axutil_env_t * env); + + AXIS2_EXTERN void AXIS2_CALL + axutil_file_free( + axutil_file_t * file, + const axutil_env_t * env); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_file_set_name( + axutil_file_t * file, + const axutil_env_t * env, + axis2_char_t * name); + + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axutil_file_get_name( + axutil_file_t * file, + const axutil_env_t * env); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_file_set_path( + axutil_file_t * file, + const axutil_env_t * env, + axis2_char_t * path); + + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axutil_file_get_path( + axutil_file_t * file, + const axutil_env_t * env); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_file_set_timestamp( + axutil_file_t * file, + const axutil_env_t * env, + AXIS2_TIME_T timestamp); + + AXIS2_EXTERN AXIS2_TIME_T AXIS2_CALL + axutil_file_get_timestamp( + axutil_file_t * file, + const axutil_env_t * env); + + /** + * create a newly allocated clone of the argument file + */ + AXIS2_EXTERN axutil_file_t *AXIS2_CALL + axutil_file_clone( + axutil_file_t * file, + const axutil_env_t * env); + +#ifdef __cplusplus +} +#endif + +#endif /* AXIS2_FILE_H */ diff --git a/util/include/axutil_file_handler.h b/util/include/axutil_file_handler.h new file mode 100644 index 0000000..18bc92a --- /dev/null +++ b/util/include/axutil_file_handler.h @@ -0,0 +1,91 @@ + +/* + * 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 count 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 AXUTIL_FILE_HANDLER_H +#define AXUTIL_FILE_HANDLER_H + +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axutil_file_handler file handler + * @ingroup axis2_util + * @{ + */ + + /** + * open a file for read according to the file options given + * @param file_name file to be opened + * @param options file options given. + * @return status code + */ + AXIS2_EXTERN void *AXIS2_CALL + axutil_file_handler_open( + const char *file_name, + const char *options); + + /** + * close a file + * @param file_ptr file pointer of the file need to be closed + * @return status code + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_file_handler_close( + void *file_ptr); + + /** + * determine accessibility of file + * checks the named file for accessibility according to mode + * @param path path name naming a file + * @param mode + * AXIS2_R_OK + * - test for read permission + * AXIS2_W_OK + * - test for write permission + * AXIS2_X_OK + * - test for execute or search permission + * AXIS2_F_OK + * - test whether the directories leading to the file can be searched and the + * file exists + * @return status + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_file_handler_access( + const axis2_char_t * path, + int mode); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_file_handler_copy( + FILE *from, + FILE *to); + + AXIS2_EXTERN long AXIS2_CALL + axutil_file_handler_size( + const axis2_char_t *const name); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIS2_FILE_HANDLER_H */ diff --git a/util/include/axutil_generic_obj.h b/util/include/axutil_generic_obj.h new file mode 100644 index 0000000..b724b9a --- /dev/null +++ b/util/include/axutil_generic_obj.h @@ -0,0 +1,85 @@ + +/* + * 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 + * limitations under the License. + */ + +#ifndef AXUTIL_GENERIC_OBJ_H +#define AXUTIL_GENERIC_OBJ_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct axutil_generic_obj axutil_generic_obj_t; + + /** + * @defgroup axutil_generic_obj generic object + * @ingroup axis2_util + * @{ + */ + + /** + * create new generic_obj + * @return generic_obj newly created generic_obj + */ + AXIS2_EXTERN axutil_generic_obj_t *AXIS2_CALL + axutil_generic_obj_create( + const axutil_env_t * env); + + AXIS2_EXTERN void AXIS2_CALL + axutil_generic_obj_free( + axutil_generic_obj_t * generic_obj, + const axutil_env_t * env); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_generic_obj_set_free_func( + axutil_generic_obj_t * generic_obj, + const axutil_env_t * env, + AXIS2_FREE_VOID_ARG free_func); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_generic_obj_set_value( + axutil_generic_obj_t * generic_obj, + const axutil_env_t * env, + void *value); + + AXIS2_EXTERN void *AXIS2_CALL + axutil_generic_obj_get_value( + axutil_generic_obj_t * generic_obj, + const axutil_env_t * env); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_generic_obj_set_type( + axutil_generic_obj_t * generic_obj, + const axutil_env_t * env, + int type); + + AXIS2_EXTERN int AXIS2_CALL + axutil_generic_obj_get_type( + axutil_generic_obj_t * generic_obj, + const axutil_env_t * env); + +#ifdef __cplusplus +} +#endif + +#endif /* AXIS2_GENERIC_OBJ_H */ diff --git a/util/include/axutil_hash.h b/util/include/axutil_hash.h new file mode 100644 index 0000000..084f2bc --- /dev/null +++ b/util/include/axutil_hash.h @@ -0,0 +1,301 @@ + +/* + * 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 + * limitations under the License. + */ + +#ifndef AXUTIL_HASH_H +#define AXUTIL_HASH_H + +/** + * @file axutil_hash.h + * @brief Axis2 Hash Tables + */ + +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axutil_hash hash + * @ingroup axis2_util + * @{ + */ + + /** + * When passing a key to axutil_hash_set or axutil_hash_get, this value can be + * passed to indicate a string-valued key, and have axutil_hash compute the + * length automatically. + * + * @remark axutil_hash will use strlen(key) for the length. The NUL terminator + * is not included in the hash value (why throw a constant in?). + * Since the hash table merely references the provided key (rather + * than copying it), axutil_hash_this() will return the NUL-term'd key. + */ +#define AXIS2_HASH_KEY_STRING (unsigned int)(-1) + + /** + * Abstract type for hash tables. + */ + typedef struct axutil_hash_t axutil_hash_t; + + /** + * Abstract type for scanning hash tables. + */ + typedef struct axutil_hash_index_t axutil_hash_index_t; + + /** + * Callback functions for calculating hash values. + * @param key The key. + * @param klen The length of the key, or AXIS2_HASH_KEY_STRING to use the string + * length. If AXIS2_HASH_KEY_STRING then returns the actual key length. + */ + typedef unsigned int( + *axutil_hashfunc_t)( + const char *key, + axis2_ssize_t * klen); + + /** + * The default hash function. + */ + unsigned int axutil_hashfunc_default( + const char *key, + axis2_ssize_t * klen); + + /** + * Create a hash table. + * @param env The environment to allocate the hash table out of + * @return The hash table just created + */ + AXIS2_EXTERN axutil_hash_t *AXIS2_CALL + axutil_hash_make( + const axutil_env_t * env); + + /** + * Create a hash table with a custom hash function + * @param env The environment to allocate the hash table out of + * @param hash_func A custom hash function. + * @return The hash table just created + */ + AXIS2_EXTERN axutil_hash_t *AXIS2_CALL + axutil_hash_make_custom( + const axutil_env_t * env, + axutil_hashfunc_t hash_func); + + /** + * Make a copy of a hash table + * @param ht The hash table to clone + * @param env The environment from which to allocate the new hash table + * @return The hash table just created + * @remark Makes a shallow copy + */ + AXIS2_EXTERN axutil_hash_t *AXIS2_CALL + axutil_hash_copy( + const axutil_hash_t * ht, + const axutil_env_t * env); + + /** + * Associate a value with a key in a hash table. + * @param ht The hash table + * @param key Pointer to the key + * @param klen Length of the key. Can be AXIS2_HASH_KEY_STRING to use the string length. + * @param val Value to associate with the key + * @remark If the value is NULL the hash entry is deleted. + */ + AXIS2_EXTERN void AXIS2_CALL + axutil_hash_set( + axutil_hash_t * ht, + const void *key, + axis2_ssize_t klen, + const void *val); + + /** + * Look up the value associated with a key in a hash table. + * @param ht The hash table + * @param key Pointer to the key + * @param klen Length of the key. Can be AXIS2_HASH_KEY_STRING to use the string length. + * @return Returns NULL if the key is not present. + */ + AXIS2_EXTERN void *AXIS2_CALL + axutil_hash_get( + axutil_hash_t * ht, + const void *key, + axis2_ssize_t klen); + + /** + * Start iterating over the entries in a hash table. + * @param ht The hash table + * @param p The environment to allocate the axutil_hash_index_t iterator. If this + * environment is NULL, then an internal, non-thread-safe iterator is used. + * @remark There is no restriction on adding or deleting hash entries during + * an iteration (although the results may be unpredictable unless all you do + * is delete the current entry) and multiple iterations can be in + * progress at the same time. + + * @example + */ + + /** + *
+     *
+     * int sum_values(const axutil_env_t *env, axutil_hash_t *ht)
+     * {
+     *     axutil_hash_index_t *hi;
+     *     void *val;
+     *     int sum = 0;
+     *     for (hi = axutil_hash_first(p, ht); hi; hi = axutil_hash_next(p, hi)) {
+     *         axutil_hash_this(hi, NULL, NULL, &val);
+     *         sum += *(int *)val;
+     *     }
+     *     return sum;
+     * }
+     * 
+ */ + AXIS2_EXTERN axutil_hash_index_t *AXIS2_CALL + axutil_hash_first( + axutil_hash_t * ht, + const axutil_env_t * env); + + /** + * Continue iterating over the entries in a hash table. + * @param hi The iteration state + * @return a pointer to the updated iteration state. NULL if there are no more + * entries. + */ + AXIS2_EXTERN axutil_hash_index_t *AXIS2_CALL + axutil_hash_next( + const axutil_env_t * env, + axutil_hash_index_t * hi); + + /** + * Get the current entry's details from the iteration state. + * @param hi The iteration state + * @param key Return pointer for the pointer to the key. + * @param klen Return pointer for the key length. + * @param val Return pointer for the associated value. + * @remark The return pointers should point to a variable that will be set to the + * corresponding data, or they may be NULL if the data isn't interesting. + */ + AXIS2_EXTERN void AXIS2_CALL + axutil_hash_this( + axutil_hash_index_t * hi, + const void **key, + axis2_ssize_t * klen, + void **val); + + /** + * Get the number of key/value pairs in the hash table. + * @param ht The hash table + * @return The number of key/value pairs in the hash table. + */ + AXIS2_EXTERN unsigned int AXIS2_CALL + axutil_hash_count( + axutil_hash_t * ht); + + /** + * Merge two hash tables into one new hash table. The values of the overlay + * hash override the values of the base if both have the same key. Both + * hash tables must use the same hash function. + * @param overlay The table to add to the initial table + * @param p The environment to use for the new hash table + * @param base The table that represents the initial values of the new table + * @return A new hash table containing all of the data from the two passed in + */ + AXIS2_EXTERN axutil_hash_t *AXIS2_CALL + axutil_hash_overlay( + const axutil_hash_t * overlay, + const axutil_env_t * env, + const axutil_hash_t * base); + + /** + * Merge two hash tables into one new hash table. If the same key + * is present in both tables, call the supplied merge function to + * produce a merged value for the key in the new table. Both + * hash tables must use the same hash function. + * @param h1 The first of the tables to merge + * @param p The environment to use for the new hash table + * @param h2 The second of the tables to merge + * @param merger A callback function to merge values, or NULL to + * make values from h1 override values from h2 (same semantics as + * axutil_hash_overlay()) + * @param data Client data to pass to the merger function + * @return A new hash table containing all of the data from the two passed in + */ + AXIS2_EXTERN axutil_hash_t *AXIS2_CALL + axutil_hash_merge( + const axutil_hash_t * h1, + const axutil_env_t * env, + const axutil_hash_t * h2, + void *(*merger)(const axutil_env_t * env, + const void *key, + axis2_ssize_t klen, + const void *h1_val, + const void *h2_val, + const void *data), + const void *data); + + /** + * Query whether the hash table provided as parameter contains the + * key provided as parameter. + * + * @param ht hash table to be queried for key + * @return return whether hash table contains key + */ + AXIS2_EXTERN axis2_bool_t AXIS2_CALL + axutil_hash_contains_key( + axutil_hash_t * ht, + const axutil_env_t * env, + const axis2_char_t * key); + + /** + * @param ht hash table to be freed + * @param env The environment to use for hash table + * @return return status code + * + */ + + AXIS2_EXTERN void AXIS2_CALL + axutil_hash_free( + axutil_hash_t * ht, + const axutil_env_t * env); + + /** + * Free a hash table with hash table given as void + * @param ht hash table to be freed as a void * + * @param env The environment to use for hash table + * @return return status code + */ + + AXIS2_EXTERN void AXIS2_CALL + axutil_hash_free_void_arg( + void *ht_void, + const axutil_env_t * env); + + AXIS2_EXTERN void AXIS2_CALL + axutil_hash_set_env( + axutil_hash_t * ht, + const axutil_env_t * env); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* !AXIS2_HASH_H */ diff --git a/util/include/axutil_http_chunked_stream.h b/util/include/axutil_http_chunked_stream.h new file mode 100644 index 0000000..7fc7a18 --- /dev/null +++ b/util/include/axutil_http_chunked_stream.h @@ -0,0 +1,132 @@ + +/* +* 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 +* limitations under the License. +*/ + +#ifndef AXUTIL_HTTP_CHUNKED_STREAM_H +#define AXUTIL_HTTP_CHUNKED_STREAM_H + +/** + * @defgroup axutil_http_chunked_stream http chunked stream + * @ingroup axis2_core_trans_http + * Description + * @{ + */ + +/** + * @file axutil_http_chunked_stream.h + * @brief axis2 HTTP Chunked Stream + */ + +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** Type name for struct axutil_http_chunked_stream */ + typedef struct axutil_http_chunked_stream axutil_http_chunked_stream_t; + + struct axis2_callback_info + { + const axutil_env_t *env; + void *in_stream; + int content_length; + int unread_len; + axutil_http_chunked_stream_t *chunked_stream; + }; + typedef struct axis2_callback_info axis2_callback_info_t; + + + /** + * @param chunked_stream pointer to chunked stream + * @param env pointer to environment struct + * @param buffer + * @param count + */ + AXIS2_EXTERN int AXIS2_CALL + axutil_http_chunked_stream_read( + axutil_http_chunked_stream_t * chunked_stream, + const axutil_env_t * env, + void *buffer, + size_t count); + + /** + * @param env pointer to environment struct + * @param buffer + * @param count + */ + AXIS2_EXTERN int AXIS2_CALL + axutil_http_chunked_stream_write( + axutil_http_chunked_stream_t * chunked_stream, + const axutil_env_t * env, + const void *buffer, + size_t count); + + /** + * @param chunked_stream pointer to chunked stream + * @param env pointer to environment struct + */ + AXIS2_EXTERN int AXIS2_CALL + + axutil_http_chunked_stream_get_current_chunk_size( + const axutil_http_chunked_stream_t * chunked_stream, + const axutil_env_t * env); + + /** + * @param chunked_stream pointer to chunked stream + * @param env pointer to environment struct + * @return AXIS2_SUCCESS on success, else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + + axutil_http_chunked_stream_write_last_chunk( + axutil_http_chunked_stream_t * chunked_stream, + const axutil_env_t * env); + + /** + * @param chunked_stream pointer to chunked stream + * @param env pointer to environment struct + * @return AXIS2_SUCCESS on success, else AXIS2_FAILURE + */ + AXIS2_EXTERN void AXIS2_CALL + axutil_http_chunked_stream_free( + axutil_http_chunked_stream_t * chunked_stream, + const axutil_env_t * env); + + /** + * @param env pointer to environment struct + * @param stream pointer to stream + */ + AXIS2_EXTERN axutil_http_chunked_stream_t *AXIS2_CALL + + axutil_http_chunked_stream_create( + const axutil_env_t * env, + axutil_stream_t * stream); + + AXIS2_EXTERN axis2_bool_t AXIS2_CALL + axutil_http_chunked_stream_get_end_of_chunks( + axutil_http_chunked_stream_t * chunked_stream, + const axutil_env_t * env); + + + /** @} */ +#ifdef __cplusplus +} +#endif +#endif /* AXUTIL_HTTP_CHUNKED_STREAM_H */ diff --git a/util/include/axutil_linked_list.h b/util/include/axutil_linked_list.h new file mode 100644 index 0000000..59454d5 --- /dev/null +++ b/util/include/axutil_linked_list.h @@ -0,0 +1,334 @@ + +/* + * 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 + * limitations under the License. + */ + +#ifndef AXUTIL_LINKED_LIST_H +#define AXUTIL_LINKED_LIST_H + +/** + * @file axutil_linked_list.h + * @brief Axis2 linked_list interface + */ + +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct axutil_linked_list axutil_linked_list_t; + + /** + * @defgroup axutil_linked_list linked list + * @ingroup axis2_util + * @{ + */ + + /** + * Struct to represent an entry in the list. Holds a single element. + */ + typedef struct entry_s + { + + /** The element in the list. */ + void *data; + + /** The next list entry, null if this is last. */ + struct entry_s *next; + + /** The previous list entry, null if this is first. */ + struct entry_s *previous; + + } + entry_t; /* struct entry */ + + /** + * Create an empty linked list. + */ + AXIS2_EXTERN axutil_linked_list_t *AXIS2_CALL + axutil_linked_list_create( + const axutil_env_t * env); + + AXIS2_EXTERN void AXIS2_CALL + axutil_linked_list_free( + axutil_linked_list_t * linked_list, + const axutil_env_t * env); + + /** + * Obtain the Entry at a given position in a list. This method of course + * takes linear time, but it is intelligent enough to take the shorter of the + * paths to get to the Entry required. This implies that the first or last + * entry in the list is obtained in constant time, which is a very desirable + * property. + * For speed and flexibility, range checking is not done in this method: + * Incorrect values will be returned if (n < 0) or (n >= size). + * + * @param n the number of the entry to get + * @return the entry at position n + */ + AXIS2_EXTERN entry_t *AXIS2_CALL + axutil_linked_list_get_entry( + axutil_linked_list_t * linked_list, + const axutil_env_t * env, + int n); + + /** + * Remove an entry from the list. This will adjust size and deal with + * `first' and `last' appropriatly. + * + * @param e the entry to remove + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_linked_list_remove_entry( + axutil_linked_list_t * linked_list, + const axutil_env_t * env, + entry_t * e); + + /** + * Checks that the index is in the range of possible elements (inclusive). + * + * @param index the index to check + */ + AXIS2_EXTERN axis2_bool_t AXIS2_CALL + + axutil_linked_list_check_bounds_inclusive( + axutil_linked_list_t * linked_list, + const axutil_env_t * env, + int index); + + /** + * Checks that the index is in the range of existing elements (exclusive). + * + * @param index the index to check + */ + AXIS2_EXTERN axis2_bool_t AXIS2_CALL + + axutil_linked_list_check_bounds_exclusive( + axutil_linked_list_t * linked_list, + const axutil_env_t * env, + int index); + + /** + * Returns the first element in the list. + * + * @return the first list element + */ + AXIS2_EXTERN void *AXIS2_CALL + axutil_linked_list_get_first( + axutil_linked_list_t * linked_list, + const axutil_env_t * env); + + /** + * Returns the last element in the list. + * + * @return the last list element + */ + AXIS2_EXTERN void *AXIS2_CALL + axutil_linked_list_get_last( + axutil_linked_list_t * linked_list, + const axutil_env_t * env); + + /** + * Remove and return the first element in the list. + * + * @return the former first element in the list + */ + AXIS2_EXTERN void *AXIS2_CALL + axutil_linked_list_remove_first( + axutil_linked_list_t * linked_list, + const axutil_env_t * env); + + /** + * Remove and return the last element in the list. + * + * @return the former last element in the list + */ + AXIS2_EXTERN void *AXIS2_CALL + axutil_linked_list_remove_last( + axutil_linked_list_t * linked_list, + const axutil_env_t * env); + + /** + * Insert an element at the first of the list. + * + * @param o the element to insert + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_linked_list_add_first( + axutil_linked_list_t * linked_list, + const axutil_env_t * env, + void *o); + + /** + * Insert an element at the last of the list. + * + * @param o the element to insert + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_linked_list_add_last( + axutil_linked_list_t * linked_list, + const axutil_env_t * env, + void *o); + + /** + * Returns true if the list contains the given object. Comparison is done by + * o == null ? e = null : o.equals(e). + * + * @param o the element to look for + * @return true if it is found + */ + AXIS2_EXTERN axis2_bool_t AXIS2_CALL + axutil_linked_list_contains( + axutil_linked_list_t * linked_list, + const axutil_env_t * env, + void *o); + + /** + * Returns the size of the list. + * + * @return the list size + */ + AXIS2_EXTERN int AXIS2_CALL + axutil_linked_list_size( + axutil_linked_list_t * linked_list, + const axutil_env_t * env); + + /** + * Adds an element to the end of the list. + * + * @param e the entry to add + * @return true, as it always succeeds + */ + AXIS2_EXTERN axis2_bool_t AXIS2_CALL + axutil_linked_list_add( + axutil_linked_list_t * linked_list, + const axutil_env_t * env, + void *o); + + /** + * Removes the entry at the lowest index in the list that matches the given + * object, comparing by o == null ? e = null : o.equals(e). + * + * @param o the object to remove + * @return true if an instance of the object was removed + */ + AXIS2_EXTERN axis2_bool_t AXIS2_CALL + axutil_linked_list_remove( + axutil_linked_list_t * linked_list, + const axutil_env_t * env, + void *o); + + /** + * Remove all elements from this list. + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_linked_list_clear( + axutil_linked_list_t * linked_list, + const axutil_env_t * env); + + /** + * Return the element at index. + * + * @param index the place to look + * @return the element at index + */ + AXIS2_EXTERN void *AXIS2_CALL + axutil_linked_list_get( + axutil_linked_list_t * linked_list, + const axutil_env_t * env, + int index); + + /** + * Replace the element at the given location in the list. + * + * @param index which index to change + * @param o the new element + * @return the prior element + */ + AXIS2_EXTERN void *AXIS2_CALL + axutil_linked_list_set( + axutil_linked_list_t * linked_list, + const axutil_env_t * env, + int index, + void *o); + + /** + * Inserts an element in the given position in the list. + * + * @param index where to insert the element + * @param o the element to insert + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_linked_list_add_at_index( + axutil_linked_list_t * linked_list, + const axutil_env_t * env, + int index, + void *o); + + /** + * Removes the element at the given position from the list. + * + * @param index the location of the element to remove + * @return the removed element + */ + AXIS2_EXTERN void *AXIS2_CALL + axutil_linked_list_remove_at_index( + axutil_linked_list_t * linked_list, + const axutil_env_t * env, + int index); + + /** + * Returns the first index where the element is located in the list, or -1. + * + * @param o the element to look for + * @return its position, or -1 if not found + */ + AXIS2_EXTERN int AXIS2_CALL + axutil_linked_list_index_of( + axutil_linked_list_t * linked_list, + const axutil_env_t * env, + void *o); + + /** + * Returns the last index where the element is located in the list, or -1. + * + * @param o the element to look for + * @return its position, or -1 if not found + */ + AXIS2_EXTERN int AXIS2_CALL + axutil_linked_list_last_index_of( + axutil_linked_list_t * linked_list, + const axutil_env_t * env, + void *o); + + /** + * Returns an array which contains the elements of the list in order. + * + * @return an array containing the list elements + */ + AXIS2_EXTERN void **AXIS2_CALL + axutil_linked_list_to_array( + axutil_linked_list_t * linked_list, + const axutil_env_t * env); + +#ifdef __cplusplus +} +#endif + +#endif /* AXIS2_LINKED_LIST_H */ diff --git a/util/include/axutil_log.h b/util/include/axutil_log.h new file mode 100644 index 0000000..09e9242 --- /dev/null +++ b/util/include/axutil_log.h @@ -0,0 +1,259 @@ + +/* + * 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 + * limitations under the License. + */ + +#ifndef AXUTIL_LOG_H +#define AXUTIL_LOG_H + +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct axutil_log_ops axutil_log_ops_t; + typedef struct axutil_log axutil_log_t; + +#define AXIS2_LOG_SI __FILE__,__LINE__ + + /** + * @defgroup axutil_log log + * @ingroup axis2_util + * @{ + */ + + /** + *Examples + *To write debug information to log + *AXIS2_LOG_DEBUG(log,AXIS2_LOG_SI,"log this %s %d","test",123); + *This would log + *"log this test 123" into the log file + * + *similar macros are defined for different log levels: CRITICAL,ERROR,WARNING and INFO + * and SERVICE + * + *CRITICAL and ERROR logs are always written to file and other logs are written + *depending on the log level set (log->level) + */ + + /** + * \brief Axis2 log levels + */ + typedef enum axutil_log_levels + { + + /** Critical level, logs only critical errors */ + AXIS2_LOG_LEVEL_CRITICAL = 0, + + /** Error level, logs only errors */ + AXIS2_LOG_LEVEL_ERROR, + + /** Warning level, logs only warnings */ + AXIS2_LOG_LEVEL_WARNING, + + /** Info level, logs information */ + AXIS2_LOG_LEVEL_INFO, + + /** Debug level, logs everything */ + AXIS2_LOG_LEVEL_DEBUG, + + /** User level, logs only user level debug messages */ + AXIS2_LOG_LEVEL_USER, + + /** Trace level, Enable with compiler time option AXIS2_TRACE */ + AXIS2_LOG_LEVEL_TRACE + + } axutil_log_levels_t; + + /** + * \brief Axis2 log ops struct + * + * Encapsulator struct for ops of axutil_log + */ + struct axutil_log_ops + { + + /** + * deletes the log + * @return axis2_status_t AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + + void( + AXIS2_CALL + * free)( + axutil_allocator_t * allocator, + struct axutil_log * log); + + /** + * writes to the log + * @param buffer buffer to be written to log + * @param size size of the buffer to be written to log + * @return satus of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + void( + AXIS2_CALL + * write)( + axutil_log_t * log, + const axis2_char_t * buffer, + axutil_log_levels_t level, + const axis2_char_t * file, + const int line); + }; + + /** + * \brief Axis2 Log struct + * + * Log is the encapsulating struct for all log related data and ops + */ + struct axutil_log + { + + /** Log related ops */ + const axutil_log_ops_t *ops; + + /** Log level */ + axutil_log_levels_t level; + + /** Maximum log file size */ + int size; + + /** Is logging enabled? */ + axis2_bool_t enabled; + + }; + + AXIS2_EXTERN void AXIS2_CALL + axutil_log_impl_log_critical( + axutil_log_t * log, + const axis2_char_t * filename, + const int linenumber, + const axis2_char_t * format, + ...); + + AXIS2_EXTERN void AXIS2_CALL + axutil_log_impl_log_error( + axutil_log_t * log, + const axis2_char_t * filename, + const int linenumber, + const axis2_char_t * format, + ...); + + AXIS2_EXTERN void AXIS2_CALL + axutil_log_impl_log_warning( + axutil_log_t * log, + const axis2_char_t * filename, + const int linenumber, + const axis2_char_t * format, + ...); + + AXIS2_EXTERN void AXIS2_CALL + axutil_log_impl_log_info( + axutil_log_t * log, + const axis2_char_t * format, + ...); + + AXIS2_EXTERN void AXIS2_CALL + axutil_log_impl_log_user( + axutil_log_t * log, + const axis2_char_t * filename, + const int linenumber, + const axis2_char_t * format, + ...); + + AXIS2_EXTERN void AXIS2_CALL + axutil_log_impl_log_debug( + axutil_log_t * log, + const axis2_char_t * filename, + const int linenumber, + const axis2_char_t * format, + ...); + + AXIS2_EXTERN void AXIS2_CALL + axutil_log_impl_log_trace( + axutil_log_t * log, + const axis2_char_t * filename, + const int linenumber, + const axis2_char_t * format, + ...); + + AXIS2_EXTERN void AXIS2_CALL + axutil_log_free( + axutil_allocator_t * allocator, + struct axutil_log *log); + + AXIS2_EXTERN void AXIS2_CALL + axutil_log_write( + axutil_log_t * log, + const axis2_char_t * buffer, + axutil_log_levels_t level, + const axis2_char_t * file, + const int line); + + +#define AXIS2_LOG_FREE(allocator, log) \ + axutil_log_free(allocator, log) + +#define AXIS2_LOG_WRITE(log, buffer, level, file) \ + axutil_log_write(log, buffer, level, file, AXIS2_LOG_SI) + +#define AXIS2_LOG_USER axutil_log_impl_log_user +#define AXIS2_LOG_DEBUG axutil_log_impl_log_debug +#define AXIS2_LOG_INFO axutil_log_impl_log_info +#define AXIS2_LOG_WARNING axutil_log_impl_log_warning +#define AXIS2_LOG_ERROR axutil_log_impl_log_error +#define AXIS2_LOG_CRITICAL axutil_log_impl_log_critical + +#ifdef AXIS2_TRACE +#define AXIS2_LOG_TRACE axutil_log_impl_log_trace +#else +# ifdef HAVE_GNUC_VARARGS +# define AXIS2_LOG_TRACE(params, args ...) +# elif defined HAVE_ISO_VARARGS +# define AXIS2_LOG_TRACE(params, ...) +# elif __STDC__ && __STDC_VERSION > 199901L +# define AXIS2_LOG_TRACE(params, ...) +# elif WIN32 +# define AXIS2_LOG_TRACE axutil_log_impl_log_trace +# else +# define AXIS2_LOG_TRACE axutil_log_impl_log_trace +# endif +#endif + +#ifndef AXIS2_LOG_PROJECT_PREFIX + /** Each module/project should undef and define the following.. */ +#define AXIS2_LOG_PROJECT_PREFIX "[axis2c]" +#endif + +#define AXIS2_LOG_USER_MSG(log, msg) AXIS2_LOG_USER (log, AXIS2_LOG_SI, "%s %s", AXIS2_LOG_PROJECT_PREFIX, msg) +#define AXIS2_LOG_DEBUG_MSG(log, msg) AXIS2_LOG_DEBUG (log, AXIS2_LOG_SI, "%s %s", AXIS2_LOG_PROJECT_PREFIX, msg) +#define AXIS2_LOG_INFO_MSG(log, msg) AXIS2_LOG_INFO (log, "%s %s", AXIS2_LOG_PROJECT_PREFIX, msg) +#define AXIS2_LOG_WARNING_MSG(log, msg) AXIS2_LOG_WARNING (log, AXIS2_LOG_SI, "%s %s", AXIS2_LOG_PROJECT_PREFIX, msg) +#define AXIS2_LOG_ERROR_MSG(log, msg) AXIS2_LOG_ERROR (log, AXIS2_LOG_SI, "%s %s", AXIS2_LOG_PROJECT_PREFIX, msg) +#define AXIS2_LOG_CRITICAL_MSG(log, msg) AXIS2_LOG_CRITICAL (log, AXIS2_LOG_SI, "%s %s", AXIS2_LOG_PROJECT_PREFIX, msg) +#define AXIS2_LOG_TRACE_MSG(log, msg) AXIS2_LOG_TRACE (log, AXIS2_LOG_SI, "%s %s", AXIS2_LOG_PROJECT_PREFIX, msg) + + +#define IF_AXIS2_LOG_DEBUG_ENABLED(log) if(AXIS2_LOG_LEVEL_DEBUG <= log->level && log->level != AXIS2_LOG_LEVEL_USER) + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIS2_LOG_H */ diff --git a/util/include/axutil_log_default.h b/util/include/axutil_log_default.h new file mode 100644 index 0000000..4165f85 --- /dev/null +++ b/util/include/axutil_log_default.h @@ -0,0 +1,64 @@ + +/* + * 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 + * limitations under the License. + */ + +#ifndef AXUTIL_LOG_DEFAULT_H +#define AXUTIL_LOG_DEFAULT_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axutil_log Log + * @ingroup axis2_util + * @{ + */ + +#define AXIS2_LEN_VALUE 6000 + + /** + * Creates a log struct + * @param allocator allocator to be used. Mandatory, cannot be NULL + * @return pointer to the newly created log struct + */ + AXIS2_EXTERN axutil_log_t *AXIS2_CALL + axutil_log_create( + axutil_allocator_t * allocator, + axutil_log_ops_t * ops, + const axis2_char_t * stream_name); + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axutil_log_impl_get_time_str( + void); + + AXIS2_EXTERN axutil_log_t *AXIS2_CALL + axutil_log_create_default( + axutil_allocator_t * allocator); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIS2_LOG_DEFAULT_H */ diff --git a/util/include/axutil_md5.h b/util/include/axutil_md5.h new file mode 100644 index 0000000..b13bcb1 --- /dev/null +++ b/util/include/axutil_md5.h @@ -0,0 +1,130 @@ +/* + * 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 + * limitations under the License. + */ + +#ifndef AXUTIL_MD5_H +#define AXUTIL_MD5_H + +/** + * @file axutil_md5.h + * @brief MD5 Implementation for Axis2 based on rfc1321. + */ + +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axis2_util utilities + * @ingroup axis2 + * @{ + * @} + */ + + /** + * @defgroup axutil_md5 md5 + * @ingroup axis2_util + * @{ + */ + + /** The MD5 digest size */ + #define AXIS2_MD5_DIGESTSIZE 16 + + typedef struct axutil_md5_ctx + { + /** state (ABCD) */ + unsigned int state[4]; + /** number of bits, modulo 2^64 (lsb first) */ + unsigned int count[2]; + /** input buffer */ + unsigned char buffer[64]; + } + axutil_md5_ctx_t; + + /** + * Creates md5_ctx struct, which is used for the MD5 message-digest + * operation. Initialization of the struct is done during the creation + * process. + * @param env, pointer to the env struct. + * @return pointer to md5_ctx struct created. + */ + AXIS2_EXTERN axutil_md5_ctx_t *AXIS2_CALL + axutil_md5_ctx_create( + const axutil_env_t * env); + + /** + * Frees the md5_ctx struct + * @param md5_ctx, pointer to struct to free. + * @param env, pointer to the env struct. + */ + AXIS2_EXTERN void AXIS2_CALL + axutil_md5_ctx_free( + axutil_md5_ctx_t * md5_ctx, + const axutil_env_t * env); + + /** + * MD5 block update operation. Continue an MD5 message-digest operation, + * processing another message block, and updating the context. + * @param context The MD5 content to update. + * @param env, pointer to the env struct. + * @param input_str next message block to update + * @param inputLen The length of the next message block + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_md5_update( + axutil_md5_ctx_t *context, + const axutil_env_t * env, + const void *input_str, + size_t inputLen); + + /** + * MD5 finalization. Ends an MD5 message-digest operation, writing the + * message digest and zeroing the context. + * @param digest The final MD5 digest. + * @param env, pointer to the env struct. + * @param context The MD5 content we are finalizing. + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_md5_final( + axutil_md5_ctx_t *context, + const axutil_env_t * env, + unsigned char digest[AXIS2_MD5_DIGESTSIZE]); + + /** + * MD5 in one step. + * @param env, pointer to the env struct. + * @param digest The final MD5 digest. + * @param input_str The message block to use. + * @param inputLen The length of the message block. + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_md5( + const axutil_env_t * env, + unsigned char digest[AXIS2_MD5_DIGESTSIZE], + const void *input_str, + size_t inputLen); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIS2_MD5_H */ diff --git a/util/include/axutil_network_handler.h b/util/include/axutil_network_handler.h new file mode 100644 index 0000000..3d55cd1 --- /dev/null +++ b/util/include/axutil_network_handler.h @@ -0,0 +1,194 @@ + +/* + * 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 count 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 AXUTIL_NETWORK_HANDLER_H +#define AXUTIL_NETWORK_HANDLER_H + +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axutil_network_handler network handler + * @ingroup axis2_util + * @{ + */ + + /** + * open a socket for a given server + * @param server ip address or the fqn of the server + * @param port port of the service + * @return opened socket + */ + AXIS2_EXTERN axis2_socket_t AXIS2_CALL + + axutil_network_handler_open_socket( + const axutil_env_t * env, + char *server, + int port); + + /** + * creates a server socket for a given port + * @param port port of the socket to be bound + * @return creates server socket + */ + AXIS2_EXTERN axis2_socket_t AXIS2_CALL + + axutil_network_handler_create_server_socket( + const axutil_env_t * env, + int port); + + /** + * closes a socket + * @param opened socket that need to be closed + * @return status code + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + + axutil_network_handler_close_socket( + const axutil_env_t * env, + axis2_socket_t socket); + + /** + * used to set up socket options such as timeouts, non-blocking ..etc + * @param socket valid socket (obtained by socket() or similar call) + * @param option the name of the option + * @param value Value to be set + * @return status of the operations as axis2_status_t + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + + axutil_network_handler_set_sock_option( + const axutil_env_t * env, + axis2_socket_t socket, + int option, + int value); + + /** + * Accepts remote connections for a server socket + * @param socket valid server socket (obtained by socket() or similar call) + * @return created socket to handle the incoming client connection + */ + AXIS2_EXTERN axis2_socket_t AXIS2_CALL + + axutil_network_handler_svr_socket_accept( + const axutil_env_t * env, + axis2_socket_t socket); + + /** + * Returns the ip address of the server associated with the socket + * @param socket valid socket (obtained by accept() or similar call) + * @return ip address asoociated with the socket or NULL + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axutil_network_handler_get_svr_ip( + const axutil_env_t * env, + axis2_socket_t socket); + + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axutil_network_handler_get_peer_ip( + const axutil_env_t * env, + axis2_socket_t socket); + + /* + * Create a datagram socket. + * @param env pointer to env + * @return a datagram socket + */ + AXIS2_EXTERN axis2_socket_t AXIS2_CALL + axutil_network_handler_open_dgram_socket(const axutil_env_t *env); + + /* + * Send a UDP packet to the given source and port address. + * Read a incoming UDP packet from the port and server address. + * @param env pointer to the env structure + * @param socket a datagram socket + * @param buffer a buffer containing the data to be sent + * @param buf_len length of the buffer + * @param addr address of the source field + * @param port udp port number + * @return success if everything goes well + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_network_handler_send_dgram(const axutil_env_t *env, axis2_socket_t socket, + axis2_char_t *buff, int *buf_len, + axis2_char_t *addr, int dest_port, int *source_port); + + /* + * Read a incoming UDP packet from the port and server address. + * @param env pointer to the env structure + * @param socket a datagram socket + * @param buffer a buffer allocated and passed to be filled + * @param buf_len length of the buffer allocated. In return buffer len + contains the length of the data read + * @param addr address of the sender. This is a return value. + * @param port senders port address. Return value + * @return if everything goes well return success + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_network_handler_read_dgram(const axutil_env_t *env, axis2_socket_t socket, + axis2_char_t *buffer, int *buf_len, + axis2_char_t **addr, int *port); + + /* + * Create a datagram socket to receive incoming UDP packets. + * @param env a pointer to the env structure + * @param port udp port to listen + * @return AXIS2_SUCCESS if everything goes well + */ + AXIS2_EXTERN axis2_socket_t AXIS2_CALL + axutil_network_handler_create_dgram_svr_socket( + const axutil_env_t *env, + int port); + + /* + * Bind a socket to the specified address + * @param env a pointer to the env structure + * @param sock socket + * @param port port number to bind to + * @return AXIS2_SUCCESS if binding is performed + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_network_handler_bind_socket(const axutil_env_t *env, + axis2_socket_t sock, int port); + + /* + * Create a multicast socket for listening on the given port. + * @param env a pointer to the env structure + * @param port udp port to listen + * @param mul_addr multicast address to join. The address should be valid and in dotted format. + * @param ttl TTL value. + * @return AXIS2_SUCCESS if everything goes well.s + */ + AXIS2_EXTERN axis2_socket_t AXIS2_CALL + axutil_network_hadler_create_multicast_svr_socket(const axutil_env_t *env, + int port, axis2_char_t *mul_addr); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIS2_NETWORK_HANDLER_H */ diff --git a/util/include/axutil_param.h b/util/include/axutil_param.h new file mode 100644 index 0000000..415e201 --- /dev/null +++ b/util/include/axutil_param.h @@ -0,0 +1,200 @@ + +/* + * 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 + * limitations under the License. + */ + +#ifndef AXUTIL_PARAM_H +#define AXUTIL_PARAM_H + +/** + * @file axutil_param.h + * @brief Axis2 param interface + */ + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axutil_param parameter + * @ingroup axis2_util + * @{ + */ + + /** + * TEXT PARAM + */ +#define AXIS2_TEXT_PARAM 0 + + /** + * Field DOM_PARAM + */ +#define AXIS2_DOM_PARAM 1 + + typedef struct axutil_param axutil_param_t; + + /** + * each type which is passed as a param value to a parameter, must have this + * type of function implemented. When the param value is set this function + * should also be assigned to param free function + */ + typedef void( + AXIS2_CALL + * AXIS2_PARAM_VALUE_FREE) ( + void *param_value, + const axutil_env_t * env); + + /** + * creates param struct + */ + AXIS2_EXTERN axutil_param_t *AXIS2_CALL + axutil_param_create( + const axutil_env_t * env, + axis2_char_t * name, + void *value); + + /** + * Parameter name accessor + * @return name of the param + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axutil_param_get_name( + struct axutil_param *param, + const axutil_env_t * env); + + /** + * Parameter value accessor + * @return Object + */ + AXIS2_EXTERN void *AXIS2_CALL + axutil_param_get_value( + struct axutil_param *param, + const axutil_env_t * env); + + /** + * param name mutator + * @param name + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_param_set_name( + struct axutil_param *param, + const axutil_env_t * env, + const axis2_char_t * name); + + /** + * Method setValue + * + * @param value + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_param_set_value( + struct axutil_param *param, + const axutil_env_t * env, + const void *value); + + /** + * Method isLocked + * + * @return boolean + */ + AXIS2_EXTERN axis2_bool_t AXIS2_CALL + axutil_param_is_locked( + struct axutil_param *param, + const axutil_env_t * env); + + /** + * Method setLocked + * + * @param value + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_param_set_locked( + struct axutil_param *param, + const axutil_env_t * env, + axis2_bool_t value); + + /** + * Method getParameterType + * + * @return int + */ + AXIS2_EXTERN int AXIS2_CALL + axutil_param_get_param_type( + struct axutil_param *param, + const axutil_env_t * env); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_param_set_param_type( + struct axutil_param *param, + const axutil_env_t * env, + int type); + + AXIS2_EXTERN void AXIS2_CALL + axutil_param_free( + struct axutil_param *param, + const axutil_env_t * env); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_param_set_attributes( + struct axutil_param *param, + const axutil_env_t * env, + axutil_hash_t * attrs); + + AXIS2_EXTERN axutil_hash_t *AXIS2_CALL + axutil_param_get_attributes( + struct axutil_param *param, + const axutil_env_t * env); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_param_set_value_list( + struct axutil_param *param, + const axutil_env_t * env, + axutil_array_list_t * value_list); + + AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL + axutil_param_get_value_list( + struct axutil_param *param, + const axutil_env_t * env); + + AXIS2_EXTERN void AXIS2_CALL + axutil_param_value_free( + void *param_value, + const axutil_env_t * env); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_param_set_value_free( + struct axutil_param *param, + const axutil_env_t * env, + AXIS2_PARAM_VALUE_FREE free_fn); + + AXIS2_EXTERN void AXIS2_CALL + axutil_param_dummy_free_fn( + void *param, + const axutil_env_t * env); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIS2_PARAM_H */ diff --git a/util/include/axutil_param_container.h b/util/include/axutil_param_container.h new file mode 100644 index 0000000..e61b9d5 --- /dev/null +++ b/util/include/axutil_param_container.h @@ -0,0 +1,134 @@ + +/* + * 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 + * limitations under the License. + */ + +#ifndef AXUTIL_PARAM_CONTAINER_H +#define AXUTIL_PARAM_CONTAINER_H + +/** @defgroup axutil_param_container Parameter Container + * @ingroup axis2_descript + * @{ + */ + +/** + * @file axutil_param_container.h + * @brief Axis2 Param container interface + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +/*#include */ +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct axutil_param_container axutil_param_container_t; + + /** + * Creates param container struct + * @return pointer to newly created param container + */ + AXIS2_EXTERN axutil_param_container_t *AXIS2_CALL + + axutil_param_container_create( + const axutil_env_t * env); + + /** + * Free param_container passed as void pointer. This will be + * cast into appropriate type and then pass the cast object + * into the param_container structure's free method + */ + AXIS2_EXTERN void AXIS2_CALL + axutil_param_container_free_void_arg( + void *param_container, + const axutil_env_t * env); + + /** De-allocate memory + * @return status code + */ + AXIS2_EXTERN void AXIS2_CALL + axutil_param_container_free( + axutil_param_container_t * param_container, + const axutil_env_t * env); + + /** Add a param + * @param param param to be added + * @return status code + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_param_container_add_param( + axutil_param_container_t * param_container, + const axutil_env_t * env, + axutil_param_t * param); + + /** To get a param in a given description + * @param name param name + * @return param + */ + AXIS2_EXTERN axutil_param_t *AXIS2_CALL + axutil_param_container_get_param( + axutil_param_container_t * param_container, + const axutil_env_t * env, + const axis2_char_t * name); + + /** To get all the params in a given description + * @return all the params contained + */ + AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL + + axutil_param_container_get_params( + axutil_param_container_t * param_container, + const axutil_env_t * env); + + /** To check whether the paramter is locked at any level + * @param param_name name of the param + * @return whether param is locked + */ + AXIS2_EXTERN axis2_bool_t AXIS2_CALL + + axutil_param_container_is_param_locked( + axutil_param_container_t * param_container, + const axutil_env_t * env, + const axis2_char_t * param_name); + + /** Remove parameter from the param container + * @param parameter name of the param to be removed + * @return status of AXIS2_SUCCESS or AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_param_container_delete_param( + axutil_param_container_t *param_container, + const axutil_env_t *env, + const axis2_char_t *param_name); + + /** @} */ + +#ifdef __cplusplus +} +#endif +#endif /* AXIS2_PARAM_CONTAINER_H */ diff --git a/util/include/axutil_properties.h b/util/include/axutil_properties.h new file mode 100644 index 0000000..d5610f3 --- /dev/null +++ b/util/include/axutil_properties.h @@ -0,0 +1,137 @@ + +/* + * 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 + * limitations under the License. + */ + +#ifndef AXUTIL_PROPERTIES_H +#define AXUTIL_PROPERTIES_H + +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axutil_properties properties + * @ingroup axis2_util + * @{ + */ + + typedef struct axutil_properties axutil_properties_t; + + /** + * create new properties + * @return properties newly created properties + */ + AXIS2_EXTERN axutil_properties_t *AXIS2_CALL + axutil_properties_create( + const axutil_env_t * env); + + /** + * free w2c_properties. + * @param properties pointer to properties struct + * @param env Environment. MUST NOT be NULL + * @return status of the op. AXIS2_SUCCESS on success + * else AXIS2_FAILURE + */ + AXIS2_EXTERN void AXIS2_CALL + axutil_properties_free( + axutil_properties_t * properties, + const axutil_env_t * env); + + /** + * get string value for property with specified key. + * @param properties pointer to properties struct + * @param env Environment. MUST NOT be NULL + * @param key MUST NOT be NULL + * @return value of the property + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axutil_properties_get_property( + axutil_properties_t * properties, + const axutil_env_t * env, + axis2_char_t * key); + + /** + * set a property ( key, value) pair. + * @param properties pointer to properties struct + * @param env Environment. MUST NOT be NULL + * @param key Property Key. MUST NOT be NULL + * @param value Property Value + * @return status of the op. AXIS2_SUCCESS on success + * else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_properties_set_property( + axutil_properties_t * properties, + const axutil_env_t * env, + axis2_char_t * key, + axis2_char_t * value); + + /** + * retrieve the hash with all the properties + * @param properties pointer to properties struct + * @param env Environment. MUST NOT be NULL + * @return hash (key,value) + */ + AXIS2_EXTERN axutil_hash_t *AXIS2_CALL + axutil_properties_get_all( + axutil_properties_t * properties, + const axutil_env_t * env); + + /** + * load properties + * @param properties pointer to properties struct + * @param env Environment. MUST NOT be NULL + * @param input Input Stream. MUST NOT be NULL + * @return status of the op. AXIS2_SUCCESS on success + * else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_properties_load( + axutil_properties_t * properties, + const axutil_env_t * env, + axis2_char_t * input_filename); + + /** + * store properties + * @param properties pointer to properties struct + * @param env Environment. MUST NOT be NULL + * @param ouput Output Stream. MUST NOT be NULL + * @return status of the op. AXIS2_SUCCESS on success + * else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_properties_store( + axutil_properties_t * properites, + const axutil_env_t * env, + FILE * output); + + /*************************** End of function macros ***************************/ + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIS2_PROPERTIES_H */ diff --git a/util/include/axutil_property.h b/util/include/axutil_property.h new file mode 100644 index 0000000..335db25 --- /dev/null +++ b/util/include/axutil_property.h @@ -0,0 +1,124 @@ + +/* + * 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 + * limitations under the License. + */ + +#ifndef AXUTIL_PROPERTY_H +#define AXUTIL_PROPERTY_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axutil_property property + * @ingroup axis2_util + * @{ + */ + + typedef struct axutil_property axutil_property_t; + + /** + * create new property + * @return property newly created property + */ + AXIS2_EXTERN axutil_property_t *AXIS2_CALL + axutil_property_create( + const axutil_env_t * env); + + /** + * create new property + * @param env axis2 environment + * @param scope scope can be one of following + * AXIS2_SCOPE_REQUEST + * AXIS2_SCOPE_SESSION + * AXIS2_SCOPE_APPLICATION + * pass 0 to use default scope of AXIS2_SCOPE_REQUEST + * @param own_value whether value is owned by the property or not. + * if the value is owned by the property it should be freed + * by the proeprty. + * @param free_func free function for the value freeing. Pass 0 if + * param value is a string + * @param value value of the property + * @return property newly created property + */ + AXIS2_EXTERN axutil_property_t *AXIS2_CALL + + axutil_property_create_with_args( + const axutil_env_t * env, + axis2_scope_t scope, + axis2_bool_t own_value, + AXIS2_FREE_VOID_ARG free_func, + void *value); + + AXIS2_EXTERN void AXIS2_CALL + axutil_property_free( + axutil_property_t * property, + const axutil_env_t * env); + + /** + * Default scope is AXIS2_SCOPE_REQUEST + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_property_set_scope( + axutil_property_t * property, + const axutil_env_t * env, + axis2_scope_t scope); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_property_set_free_func( + axutil_property_t * property, + const axutil_env_t * env, + AXIS2_FREE_VOID_ARG free_func); + + /*************************** Function macros **********************************/ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_property_set_value( + axutil_property_t * property, + const axutil_env_t * env, + void *value); + + AXIS2_EXTERN void *AXIS2_CALL + axutil_property_get_value( + axutil_property_t * property, + const axutil_env_t * env); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_property_set_own_value( + axutil_property_t * property, + const axutil_env_t * env, + axis2_bool_t own_value); + + AXIS2_EXTERN axutil_property_t *AXIS2_CALL + axutil_property_clone( + axutil_property_t * property, + const axutil_env_t * env); + + /*************************** End of function macros ***************************/ + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIS2_PROPERTY_H */ diff --git a/util/include/axutil_qname.h b/util/include/axutil_qname.h new file mode 100644 index 0000000..da78461 --- /dev/null +++ b/util/include/axutil_qname.h @@ -0,0 +1,142 @@ + +/* +* 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 +* limitations under the License. +*/ + +#ifndef AXUTIL_QNAME_H +#define AXUTIL_QNAME_H + +/** + * @file axutil_qname.h + * @brief represents a qualified name + */ + +#include +#include + +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axutil_qname qname + * @ingroup axis2_util + * @{ + */ + + typedef struct axutil_qname axutil_qname_t; + + /** + * creates a qname struct + * returns a pointer to a qname struct + * @localpart mandatory + * @prefix mandatory + * @ns_uri optional + * The prefix. Must not be null. Use "" (empty string) to indicate that no + * namespace URI is present or the namespace URI is not relevant + * if null is passed for prefix and uri , "'(empty string ) will be assinged to + * those fields + * @return a pointer to newly created qname struct + */ + + AXIS2_EXTERN axutil_qname_t *AXIS2_CALL + axutil_qname_create( + const axutil_env_t * env, + const axis2_char_t * localpart, + const axis2_char_t * namespace_uri, + const axis2_char_t * prefix); + + /** + * returns a newly created qname using a string genarated from + * axutil_qname_to_string method + * freeing the returned qname is users responsibility + */ + + AXIS2_EXTERN axutil_qname_t *AXIS2_CALL + axutil_qname_create_from_string( + const axutil_env_t * env, + const axis2_char_t * string); + + /** + * Free a qname struct + * @return Status code + */ + AXIS2_EXTERN void AXIS2_CALL + axutil_qname_free( + struct axutil_qname *qname, + const axutil_env_t * env); + + /** + * Compare two qnames + * prefix is ignored when comparing + * If ns_uri and localpart of qname1 and qname2 is equal returns true + * @return true if qname1 equals qname2, false otherwise + */ + + AXIS2_EXTERN axis2_bool_t AXIS2_CALL + axutil_qname_equals( + const struct axutil_qname *qname, + const axutil_env_t * env, + const struct axutil_qname *qname1); + + /** + * clones a given qname + * @param qname , qname struct instance to be cloned + * @env environment , double pointer to environment + * @returns the newly cloned qname struct instance + */ + + AXIS2_EXTERN struct axutil_qname *AXIS2_CALL + axutil_qname_clone( + struct axutil_qname *qname, + const axutil_env_t * env); + + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axutil_qname_get_uri( + const struct axutil_qname *qname, + const axutil_env_t * env); + + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axutil_qname_get_prefix( + const struct axutil_qname *qname, + const axutil_env_t * env); + + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axutil_qname_get_localpart( + const struct axutil_qname *qname, + const axutil_env_t * env); + + /** + * returns a unique string created by concatanting namespace uri + * and localpart . + * The string is of the form localpart|url + * The returned char* is freed when qname free function is called. + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axutil_qname_to_string( + struct axutil_qname *qname, + const axutil_env_t * env); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIS2_QNAME_H */ diff --git a/util/include/axutil_rand.h b/util/include/axutil_rand.h new file mode 100644 index 0000000..f89f283 --- /dev/null +++ b/util/include/axutil_rand.h @@ -0,0 +1,83 @@ + +/* + * 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 AXUTIL_RAND_H +#define AXUTIL_RAND_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axutil_rand rand + * @ingroup axis2_util + * @{ + */ + + /** + * @file axutil_rand.h + * @brief A simple thread safe and reentrant random number generator + */ + + /** + * This is reentrant and thread safe simple random number generator + * function. it is passed an pointer to an unsigned int state value + * which is used inside the function and changed in each call. + * @param seedp pointer to an unsigned int used as the internal state + * @return int int + */ + AXIS2_EXTERN int AXIS2_CALL + axutil_rand( + unsigned int *seedp); + + /** + * This is reentrant and thread safe simple random number generator + * function. it is passed an pointer to an unsigned int state value + * which is used inside the function and changed in each call. Also + * it is passed a range in which the random number is selected + * @param seedp pointer to an unsigned int used as the internal state + * @param start start of the range + * @param end end of the range + * @return int If invalid range is entered -1 is returned int + */ + AXIS2_EXTERN int AXIS2_CALL + axutil_rand_with_range( + unsigned int *seedp, + int start, + int end); + + /** + * A random seed value generated based on the time + */ + AXIS2_EXTERN unsigned int AXIS2_CALL + + axutil_rand_get_seed_value_based_on_time( + const axutil_env_t * env); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIS2_RAND_H */ diff --git a/util/include/axutil_stack.h b/util/include/axutil_stack.h new file mode 100644 index 0000000..5eba102 --- /dev/null +++ b/util/include/axutil_stack.h @@ -0,0 +1,93 @@ + +/* + * 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 + * limitations under the License. + */ + +#ifndef AXUTIL_STACK_H +#define AXUTIL_STACK_H + +/** +* @file axutil_stack.h +* @brief represents a stack +*/ + +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axis2_util_stack stack + * @ingroup axis2_util + * @{ + */ + + typedef struct axutil_stack axutil_stack_t; + + AXIS2_EXTERN axutil_stack_t *AXIS2_CALL + axutil_stack_create( + const axutil_env_t * env); + + /** + * Free function of the stack + * @param stack pointer to stack + * @param env environemnt + */ + AXIS2_EXTERN void AXIS2_CALL + axutil_stack_free( + axutil_stack_t * stack, + const axutil_env_t * env); + + AXIS2_EXTERN void *AXIS2_CALL + axutil_stack_pop( + axutil_stack_t * stack, + const axutil_env_t * env); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_stack_push( + axutil_stack_t * stack, + const axutil_env_t * env, + void *value); + + AXIS2_EXTERN int AXIS2_CALL + axutil_stack_size( + axutil_stack_t * stack, + const axutil_env_t * env); + + /** + * returns the last put value from the stack + * without removing it from stack + */ + AXIS2_EXTERN void *AXIS2_CALL + axutil_stack_get( + axutil_stack_t * stack, + const axutil_env_t * env); + + AXIS2_EXTERN void *AXIS2_CALL + axutil_stack_get_at( + axutil_stack_t * stack, + const axutil_env_t * env, + int i); + + /** @} */ + +#ifdef __cplusplus +} +#endif +#endif /* AXIS2_STACK_H */ diff --git a/util/include/axutil_stream.h b/util/include/axutil_stream.h new file mode 100644 index 0000000..729f1e3 --- /dev/null +++ b/util/include/axutil_stream.h @@ -0,0 +1,294 @@ + +/* + * 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 count 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 AXUTIL_STREAM_H +#define AXUTIL_STREAM_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + +#define AXIS2_STREAM_DEFAULT_BUF_SIZE 2048 + + /** + * @defgroup axutil_stream stream + * @ingroup axis2_util + * @{ + */ + + /** + * \brief Axis2 stream types + * + * This is used to create a stream to correspond to + * particular i/o mtd + */ + enum axutil_stream_type + { + AXIS2_STREAM_BASIC = 0, + AXIS2_STREAM_FILE, + AXIS2_STREAM_SOCKET, + AXIS2_STREAM_MANAGED /* Example Wrapper stream for Apache2 read mechanism */ + }; + + typedef enum axutil_stream_type axutil_stream_type_t; + typedef struct axutil_stream axutil_stream_t; + + typedef int( + AXIS2_CALL + * AXUTIL_STREAM_READ)( + axutil_stream_t * stream, + const axutil_env_t * env, + void *buffer, + size_t count); + + typedef int( + AXIS2_CALL + * AXUTIL_STREAM_WRITE)( + axutil_stream_t * stream, + const axutil_env_t * env, + const void *buffer, + size_t count); + + typedef int( + AXIS2_CALL + * AXUTIL_STREAM_SKIP)( + axutil_stream_t * stream, + const axutil_env_t * env, + int count); + + struct axutil_stream + { + axutil_stream_type_t stream_type; + int len; + int max_len; + /* Only one of these is used for a perticlar + * instance depending on the type + */ + axis2_char_t *buffer; + axis2_char_t *buffer_head; + FILE *fp; + int socket; + + int axis2_eof; + + /** + * reads from stream + * @param buffer buffer into which the content is to be read + * @param count size of the buffer + * @return no: of bytes read + */ + int( + AXIS2_CALL + * read)( + axutil_stream_t * stream, + const axutil_env_t * env, + void *buffer, + size_t count); + + /** + * writes into stream + * @param buffer buffer to be written + * @param count size of the buffer + * @return no: of bytes actually written + */ + int( + AXIS2_CALL + * write)( + axutil_stream_t * stream, + const axutil_env_t * env, + const void *buffer, + size_t count); + + /** + * Skips over and discards n bytes of data from this input stream. + * @param count number of bytes to be discarded + * @return no: of bytes actually skipped + */ + int( + AXIS2_CALL + * skip)( + axutil_stream_t * stream, + const axutil_env_t * env, + int count); + }; + + /** + * Deletes the stream + * @return axis2_status_t AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN void AXIS2_CALL + axutil_stream_free( + axutil_stream_t * stream, + const axutil_env_t * env); + + AXIS2_EXTERN void AXIS2_CALL + axutil_stream_free_void_arg( + void *stream, + const axutil_env_t * env); + + /** + * reads from stream + * @param buffer buffer into which the content is to be read + * @param count size of the buffer + * @return no: of bytes read + */ + AXIS2_EXTERN int AXIS2_CALL + axutil_stream_read( + axutil_stream_t * stream, + const axutil_env_t * env, + void *buffer, + size_t count); + + /** + * writes into stream + * @param buffer buffer to be written + * @param count size of the buffer + * @return no: of bytes actually written + */ + AXIS2_EXTERN int AXIS2_CALL + axutil_stream_write( + axutil_stream_t * stream, + const axutil_env_t * env, + const void *buffer, + size_t count); + + /** + * Skips over and discards n bytes of data from this input stream. + * @param count number of bytes to be discarded + * @return no: of bytes actually skipped + */ + AXIS2_EXTERN int AXIS2_CALL + axutil_stream_skip( + axutil_stream_t * stream, + const axutil_env_t * env, + int count); + + /** + * Returns the length of the stream (applicable only to basic stream) + * @return Length of the buffer if its type is basic, else -1 + * (we can't define a length of a stream unless it is just a buffer) + */ + AXIS2_EXTERN int AXIS2_CALL + axutil_stream_get_len( + axutil_stream_t * stream, + const axutil_env_t * env); + + /** \brief Constructor for creating an in memory stream + * @return axutil_stream (in memory) + */ + AXIS2_EXTERN axutil_stream_t *AXIS2_CALL + axutil_stream_create_basic( + const axutil_env_t * env); + + /** \brief Constructor for creating a file stream + * @param valid file pointer (opened file) + * @return axutil_stream (file) + */ + AXIS2_EXTERN axutil_stream_t *AXIS2_CALL + axutil_stream_create_file( + const axutil_env_t * env, + FILE * fp); + + /** \brief Constructor for creating a file stream + * @param valid socket (opened socket) + * @return axutil_stream (socket) + */ + AXIS2_EXTERN axutil_stream_t *AXIS2_CALL + axutil_stream_create_socket( + const axutil_env_t * env, + int socket); + + /** + *Free stream + */ + AXIS2_EXTERN void AXIS2_CALL + axutil_stream_free( + axutil_stream_t * stream, + const axutil_env_t * env); + + /** + * Free stream passed as void pointer. This will be + * cast into appropriate type and then pass the cast object + * into the module_desc structure's free method + */ + + AXIS2_EXTERN void AXIS2_CALL + axutil_stream_free_void_arg( + void *stream, + const axutil_env_t * env); + + /** + * Gets the buffer + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axutil_stream_get_buffer( + const axutil_stream_t * stream, + const axutil_env_t * env); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_stream_flush_buffer( + axutil_stream_t * stream, + const axutil_env_t * env); + + AXIS2_EXTERN int AXIS2_CALL + axutil_stream_peek_socket( + axutil_stream_t * stream, + const axutil_env_t * env, + void *buffer, + size_t count); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_stream_flush( + axutil_stream_t * stream, + const axutil_env_t * env); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_stream_close( + axutil_stream_t * stream, + const axutil_env_t * env); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_stream_set_read( + axutil_stream_t * stream, + const axutil_env_t * env, + AXUTIL_STREAM_READ func); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_stream_set_write( + axutil_stream_t * stream, + const axutil_env_t * env, + AXUTIL_STREAM_WRITE func); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_stream_set_skip( + axutil_stream_t * stream, + const axutil_env_t * env, + AXUTIL_STREAM_SKIP func); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIS2_STREAM_H */ diff --git a/util/include/axutil_string.h b/util/include/axutil_string.h new file mode 100644 index 0000000..6331cd8 --- /dev/null +++ b/util/include/axutil_string.h @@ -0,0 +1,350 @@ + +/** + * 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 + * limitations under the License. + */ + +#ifndef AXUTIL_STRING_H +#define AXUTIL_STRING_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axutil_string string + * @ingroup axis2_util + * @{ + */ + + typedef struct axutil_string axutil_string_t; + + /** + * Creates a string struct. + * @param str pointer to string. string struct would create a duplicate of + * this + * @param env pointer to environment struct + * @return a pointer to newly created string struct + */ + AXIS2_EXTERN axutil_string_t *AXIS2_CALL + axutil_string_create( + const axutil_env_t * env, + const axis2_char_t * str); + + /** + * Creates a string struct. + * @param str pointer to string. string struct would not create a duplicate + * of this, but would assume ownership + * @param env pointer to environment struct + * @return a pointer to newly created string struct + */ + AXIS2_EXTERN axutil_string_t *AXIS2_CALL + + axutil_string_create_assume_ownership( + const axutil_env_t * env, + axis2_char_t ** str); + + /** + * Creates a string struct. + * @param str pointer to string. string struct would not create a duplicate + * of this and assumes the str would have longer life than that of itself + * @param env pointer to environment struct + * @return a pointer to newly created string struct + */ + AXIS2_EXTERN axutil_string_t *AXIS2_CALL + axutil_string_create_const( + const axutil_env_t * env, + axis2_char_t ** str); + + /** + * Frees string struct. + * @param string pointer to string struct + * @param env pointer to environment struct + * @return AXIS2_SUCCESS on success, else AXIS2_FAILURE + */ + AXIS2_EXTERN void AXIS2_CALL + axutil_string_free( + struct axutil_string *string, + const axutil_env_t * env); + + /** + * Compares two strings. Checks if the two strings point to the same buffer. + * Do not cmpare the buffer contents. + * @param string pointer to string struct + * @param env pointer to environment struct + * @param string1 pointer to string struct to be compared + * @return AXIS2_TRUE if string equals string1, AXIS2_FALSE otherwise + */ + AXIS2_EXTERN axis2_bool_t AXIS2_CALL + axutil_string_equals( + const struct axutil_string *string, + const axutil_env_t * env, + const struct axutil_string *string1); + + /** + * Clones a given string. Does not duplicate the buffer, rather + * increments the reference count. Each call to clone needs to have a + * matching free, when the clone is done with. + * @param string pointer to string struct + * @param env pointer to environment struct + * @returns pointer to cloned string struct instance + */ + AXIS2_EXTERN struct axutil_string *AXIS2_CALL + axutil_string_clone( + struct axutil_string *string, + const axutil_env_t * env); + + /** + * Gets string buffer. + * @param string pointer to string struct + * @param env pointer to environment struct + * @returns pointer to string buffer + */ + AXIS2_EXTERN const axis2_char_t *AXIS2_CALL + axutil_string_get_buffer( + const struct axutil_string *string, + const axutil_env_t * env); + + /** + * Gets string length. * @param string pointer to string struct * @param env pointer to environment struct * @returns buffer length */ + AXIS2_EXTERN unsigned int AXIS2_CALL + axutil_string_get_length( + const struct axutil_string *string, + const axutil_env_t * env); + + /** @} */ + + /** + * @defgroup axutil_string_utils string_utils + * @ingroup axis2_util + * @{ + */ + + AXIS2_EXTERN void *AXIS2_CALL + axutil_strdup( + const axutil_env_t * env, + const void *ptr); + + /** + * duplicate the first n characters of a string into memory allocated + * the new string will be null-terminated + * @param ptr The string to duplicate + * @param n The number of characters to duplicate + * @return The new string + */ + AXIS2_EXTERN void *AXIS2_CALL + axutil_strndup( + const axutil_env_t * env, + const void *ptr, + int n); + + /** + * Create a null-terminated string by making a copy of a sequence + * of characters and appending a null byte + * @param ptr The block of characters to duplicate + * @param n The number of characters to duplicate + * @return The new string + * @remark This is a faster alternative to axis2_strndup, for use + * when you know that the string being duplicated really + * has 'n' or more characters. If the string might contain + * fewer characters, use axis2_strndup. + */ + AXIS2_EXTERN void *AXIS2_CALL + axutil_strmemdup( + const void *ptr, + size_t n, + const axutil_env_t * env); + + AXIS2_EXTERN void *AXIS2_CALL + axutil_memchr( + const void *ptr, + int c, + size_t n); + + AXIS2_EXTERN int AXIS2_CALL + axutil_strcmp( + const axis2_char_t * s1, + const axis2_char_t * s2); + + AXIS2_EXTERN int AXIS2_CALL + axutil_strncmp( + const axis2_char_t * s1, + const axis2_char_t * s2, + int n); + + AXIS2_EXTERN axis2_ssize_t AXIS2_CALL + axutil_strlen( + const axis2_char_t * s); + + AXIS2_EXTERN int AXIS2_CALL + axutil_strcasecmp( + const axis2_char_t * s1, + const axis2_char_t * s2); + + AXIS2_EXTERN int AXIS2_CALL + axutil_strncasecmp( + const axis2_char_t * s1, + const axis2_char_t * s2, + const int n); + + /* much similar to the strcat behaviour. But the difference is + * this allocates new memory to put the conatenated string rather than + * modifying the first argument. The user should free the allocated + * memory for the return value + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axutil_stracat( + const axutil_env_t * env, + const axis2_char_t * s1, + const axis2_char_t * s2); + + /** + * Concatenate multiple strings, allocating memory + * @param ... The strings to concatenate. The final string must be NULL + * @return The new string + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axutil_strcat( + const axutil_env_t * env, + ...); + + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axutil_strstr( + const axis2_char_t * heystack, + const axis2_char_t * needle); + + /** + * Finds the first occurrence of a character in a string + * @param s String in which the character is searched + * @param ch Character to be searched + * @return Pointer to to the first occurence of the charecter if it could + * be found in the string, NULL otherwise + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axutil_strchr( + const axis2_char_t * s, + axis2_char_t ch); + + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axutil_rindex( + const axis2_char_t * s, + axis2_char_t c); + + /* replaces s1 with s2 */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axutil_replace( + const axutil_env_t * env, + axis2_char_t * str, + int s1, + int s2); + + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axutil_strltrim( + const axutil_env_t * env, + const axis2_char_t * _s, + const axis2_char_t * _trim); + + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axutil_strrtrim( + const axutil_env_t * env, + const axis2_char_t * _s, + const axis2_char_t * _trim); + + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axutil_strtrim( + const axutil_env_t * env, + const axis2_char_t * _s, + const axis2_char_t * _trim); + + /** + * replace given axis2_character with a new one. + * @param str string operation apply + * @param old_char the old axis2_character which would be replaced + * @param new_char new axis2_char_tacter + * @return replaced string + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axutil_string_replace( + axis2_char_t * str, + axis2_char_t old_char, + axis2_char_t new_char); + + /** + * gives a sub string starting with given index. + * @param str string operation apply + * @param c starting index + * @return substring + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + + axutil_string_substring_starting_at( + axis2_char_t * str, + int s); + + /** + * gives a sub string ending with given index. + * @param str string operation apply + * @param c ending index + * @return substring + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axutil_string_substring_ending_at( + axis2_char_t * str, + int e); + + /** + * set a string to lowercase. + * @param str string + * @return string with lowercase + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axutil_string_tolower( + axis2_char_t * str); + + /** + * set a string to uppercase. + * @param str string + * @return string with uppercase + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axutil_string_toupper( + axis2_char_t * str); + + /** + * Finds the first occurrence of the substring needle in the string + * haystack, ignores the case of both arguments. + * @param haystack string in which the given string is to be found + * @param needle string to be found in haystack + * @return pointer to the beginning of the substring, + * or NULL if the substring is not found + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axutil_strcasestr( + const axis2_char_t * heystack, + const axis2_char_t * needle); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIS2_STRING_H */ diff --git a/util/include/axutil_string_util.h b/util/include/axutil_string_util.h new file mode 100644 index 0000000..e1de886 --- /dev/null +++ b/util/include/axutil_string_util.h @@ -0,0 +1,56 @@ + +/* + * 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 + * limitations under the License. + */ + +#ifndef AXUTIL_STRING_UTIL_H +#define AXUTIL_STRING_UTIL_H + +#include +#include +#ifdef __cplusplus +extern "C" +{ +#endif + + AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL + axutil_tokenize( + const axutil_env_t * env, + axis2_char_t * in, + int delim); + + AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL + axutil_first_token( + const axutil_env_t * env, + axis2_char_t * in, + int delim); + + /** + * @return returns array_list containing, the string portion + * without the last token as the first item and the last + * token as the second. If the last token was the only token + * found, the first item will be a "" string. + */ + AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL + axutil_last_token( + const axutil_env_t * env, + axis2_char_t * in, + int delim); + +#ifdef __cplusplus +} +#endif +#endif /* AXIS2_STRING_UTIL_H */ diff --git a/util/include/axutil_thread.h b/util/include/axutil_thread.h new file mode 100644 index 0000000..271c2aa --- /dev/null +++ b/util/include/axutil_thread.h @@ -0,0 +1,272 @@ + +/* + * 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 + * limitations under the License. + */ + +#ifndef AXUTIL_THREAD_H +#define AXUTIL_THREAD_H + +/** + * @file axutil_thread.h + * @brief axis2 thread api + */ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axutil_thread thread + * @ingroup axis2_util + * @{ + */ + + /** + * Thread callbacks from axis2 functions must be declared with AXIS2_THREAD_FUNC + * so that they follow the platform's calling convention. + */ + /*#define AXIS2_THREAD_FUNC */ + + /** Thread structure. */ + typedef struct axutil_thread_t axutil_thread_t; + + /** Thread attributes structure. */ + typedef struct axutil_threadattr_t axutil_threadattr_t; + + /** Control variable for one-time atomic variables. */ + typedef struct axutil_thread_once_t axutil_thread_once_t; + + /** + * The prototype for any AXIS2 thread worker functions. + */ + typedef void *( + AXIS2_THREAD_FUNC * axutil_thread_start_t)( + axutil_thread_t *, + void *); + + /** Thread private address space. */ + typedef struct axutil_threadkey_t axutil_threadkey_t; + + /* Thread Function definitions */ + + /** + * Create and initialize a new threadattr variable + * @param cont The pool to use + * @return Newly created thread attribute + */ + AXIS2_EXTERN axutil_threadattr_t *AXIS2_CALL + axutil_threadattr_create( + axutil_allocator_t * allocator); + + /** + * Set if newly created threads should be created in detached state. + * @param attr The threadattr to affect + * @param on Non-zero if detached threads should be created. + * @return The status of the operation + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_threadattr_detach_set( + axutil_threadattr_t * attr, + axis2_bool_t detached); + + /** + * Get the detach state for this threadattr. + * @param attr The threadattr to reference + * @return AXIS2_TRUE if threads are to be detached, or AXIS2_FALSE + * if threads are to be joinable. + */ + AXIS2_EXTERN axis2_bool_t AXIS2_CALL + axutil_threadattr_is_detach( + axutil_threadattr_t * attr, + axutil_allocator_t * allocator); + + /** + * Create a new thread of execution + * @param attr The threadattr to use to determine how to create the thread + * @param func The function to start the new thread in + * @param data Any data to be passed to the starting function + * @param cont The pool to use + * @return The newly created thread handle. + */ + AXIS2_EXTERN axutil_thread_t *AXIS2_CALL + axutil_thread_create( + axutil_allocator_t * allocator, + axutil_threadattr_t * attr, + axutil_thread_start_t func, + void *data); + + /** + * Stop the current thread + * @param thd The thread to stop + * @return The status of the operation + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_thread_exit( + axutil_thread_t * thd, + axutil_allocator_t * allocator); + + /** + * Block until the desired thread stops executing. + * @param thd The thread to join + * @return The status of the operation + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_thread_join( + axutil_thread_t * thd); + + /** + * force the current thread to yield the processor + */ + AXIS2_EXTERN void AXIS2_CALL + axutil_thread_yield(void + ); + + /** + * function is used to allocate a new key. This key now becomes valid for all threads in our process. + * When a key is created, the value it points to defaults to NULL. Later on each thread may change + * its copy of the value as it wishes. + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_thread_key_create( + axutil_threadkey_t * axis2_key); + /** + * This function is used to get the value of a given key + * @return void*. A key's value is simply a void pointer (void*) + */ + AXIS2_EXTERN void *AXIS2_CALL + axutil_thread_getspecific( + axutil_threadkey_t * axis2_key); + + /** + * This function is used to get the value of a given key + * @param keys value. A key's value is simply a void pointer (void*), so we can + * store in it anything that we want + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_thread_setspecific( + axutil_threadkey_t * axis2_key, + void *value); + + /** + * This function is used free the tls key. + */ + AXIS2_EXTERN void AXIS2_CALL + axutil_thread_key_free( + axutil_threadkey_t * axis2_key); + + /** + * Initialize the control variable for axutil_thread_once. + * @param control The control variable to initialize + * @return The status of the operation + */ + AXIS2_EXTERN axutil_thread_once_t *AXIS2_CALL + axutil_thread_once_init( + axutil_allocator_t * allocator); + + /** + * Run the specified function one time, regardless of how many threads + * call it. + * @param control The control variable. The same variable should + * be passed in each time the function is tried to be + * called. This is how the underlying functions determine + * if the function has ever been called before. + * @param func The function to call. + * @return The status of the operation + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_thread_once( + axutil_thread_once_t * control, + void(*func)(void)); + + /** + * detach a thread + * @param thd The thread to detach + * @return The status of the operation + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_thread_detach( + axutil_thread_t * thd); + + + /*************************Thread locking functions*****************************/ + + /** Opaque thread-local mutex structure */ + typedef struct axutil_thread_mutex_t axutil_thread_mutex_t; + +#define AXIS2_THREAD_MUTEX_DEFAULT 0x0 /**< platform-optimal lock behavior */ + +#define AXIS2_THREAD_MUTEX_NESTED 0x1 /**< enable nested (recursive) locks */ + +#define AXIS2_THREAD_MUTEX_UNNESTED 0x2 /**< disable nested locks */ + + /** + * Create and initialize a mutex that can be used to synchronize threads. + * @param allocator Memory allocator to allocate memory for the mutex + * @warning Be cautious in using AXIS2_THREAD_MUTEX_DEFAULT. While this is the + * most optimal mutex based on a given platform's performance characteristics, + * it will behave as either a nested or an unnested lock. + */ + AXIS2_EXTERN axutil_thread_mutex_t *AXIS2_CALL + + axutil_thread_mutex_create( + axutil_allocator_t * allocator, + unsigned int flags); + + /** + * Acquire the lock for the given mutex. If the mutex is already locked, + * the current thread will be put to sleep until the lock becomes available. + * @param mutex the mutex on which to acquire the lock. + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_thread_mutex_lock( + axutil_thread_mutex_t * mutex); + + /** + * Attempt to acquire the lock for the given mutex. If the mutex has already + * been acquired, the call returns immediately + * @param mutex the mutex on which to attempt the lock acquiring. + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_thread_mutex_trylock( + axutil_thread_mutex_t * mutex); + + /** + * Release the lock for the given mutex. + * @param mutex the mutex from which to release the lock. + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_thread_mutex_unlock( + axutil_thread_mutex_t * mutex); + + /** + * Destroy the mutex and free the memory associated with the lock. + * @param mutex the mutex to destroy. + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_thread_mutex_destroy( + axutil_thread_mutex_t * mutex); + + /** @} */ +#ifdef __cplusplus +} +#endif + +#endif /* AXIS2_THREAD_H */ diff --git a/util/include/axutil_thread_pool.h b/util/include/axutil_thread_pool.h new file mode 100644 index 0000000..d8bd8a0 --- /dev/null +++ b/util/include/axutil_thread_pool.h @@ -0,0 +1,126 @@ + +/* + * 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 + * limitations under the License. + */ + +#ifndef AXUTIL_THREAD_POOL_H +#define AXUTIL_THREAD_POOL_H + +/** + * @file axutil_thread_pool.h + * @brief Axis2 thread pool interface + */ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axutil_thread_pool thread pool + * @ingroup axis2_util + * @{ + */ + + typedef struct axutil_thread_pool axutil_thread_pool_t; + struct axutil_env; + + /** + * Retrives a thread from the thread pool + * @param func function to be executed in the new thread + * @param data arguments to be passed to the function + * @return pointer to a thread in ready state. + */ + AXIS2_EXTERN axutil_thread_t *AXIS2_CALL + axutil_thread_pool_get_thread( + axutil_thread_pool_t * pool, + axutil_thread_start_t func, + void *data); + + /** + * Blocks until the desired thread stops executing. + * @param thd The thread to joined + * @return status of the operation + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_thread_pool_join_thread( + axutil_thread_pool_t * pool, + axutil_thread_t * thd); + + /** + * Stop the execution of current thread + * @param thd thread to be stopped + * @return status of the operation + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_thread_pool_exit_thread( + axutil_thread_pool_t * pool, + axutil_thread_t * thd); + + /** + * Detaches a thread + * @param thd thread to be detached + * @return status of the operation + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_thread_pool_thread_detach( + axutil_thread_pool_t * pool, + axutil_thread_t * thd); + + /** + * Frees resources used by thread_pool + * @param pool thread_pool to be freed + */ + AXIS2_EXTERN void AXIS2_CALL + axutil_thread_pool_free( + axutil_thread_pool_t * pool); + + /** + * Initializes (creates) an thread_pool. + * @param allocator user defined allocator for the memory allocation. + * @return initialized thread_pool. NULL on error. + */ + AXIS2_EXTERN axutil_thread_pool_t *AXIS2_CALL + axutil_thread_pool_init( + axutil_allocator_t * allocator); + + /** + * This function can be used to initialize the environment in case of + * spawning a new thread via a thread function + */ + AXIS2_EXTERN struct axutil_env *AXIS2_CALL + axutil_init_thread_env( + const struct axutil_env *system_env); + + /** + * This function can be used to free the environment that was used + * in a thread function + */ + AXIS2_EXTERN void AXIS2_CALL + axutil_free_thread_env( + struct axutil_env *thread_env); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIS2_THREAD_POOL_H */ diff --git a/util/include/axutil_types.h b/util/include/axutil_types.h new file mode 100644 index 0000000..d6df339 --- /dev/null +++ b/util/include/axutil_types.h @@ -0,0 +1,73 @@ + +/** + * 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 + * limitations under the License. + */ + +#ifndef AXUTIL_TYPES_H +#define AXUTIL_TYPES_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axutil_types type convertors + * @ingroup axis2_util + * @{ + */ + + AXIS2_EXTERN int AXIS2_CALL + axutil_atoi( + const char *s); + +#define AXIS2_ATOI(s) axutil_atoi(s) + + AXIS2_EXTERN uint64_t AXIS2_CALL + axutil_strtoul( + const char *nptr, + char **endptr, + int base); + +#define AXIS2_STRTOUL(s, e, b) axutil_strtoul(s, e, b) + + AXIS2_EXTERN int64_t AXIS2_CALL + axutil_strtol( + const char *nptr, + char **endptr, + int base); + +#define AXIS2_STRTOL(s, e, b) axutil_strtol(s, e, b) + + + AXIS2_EXTERN int64_t AXIS2_CALL + axutil_atol( + const char *s); + +#define AXIS2_ATOL(s) axutil_atol(s) + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIS2_TYPES_H */ diff --git a/util/include/axutil_uri.h b/util/include/axutil_uri.h new file mode 100644 index 0000000..45edc64 --- /dev/null +++ b/util/include/axutil_uri.h @@ -0,0 +1,277 @@ + +/* + * 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 + * limitations under the License. + */ + +#ifndef AXUTIL_URI_H +#define AXUTIL_URI_H + +/** + * @file axutil_uri.h + * @brief AXIS2-UTIL URI Routines + * axutil_uri.h: External Interface of axutil_uri.c + */ + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axutil_uri URI + * @ingroup axis2_util + * @{ + */ + +#define AXIS2_URI_FTP_DEFAULT_PORT 21 /**< default FTP port */ + +#define AXIS2_URI_SSH_DEFAULT_PORT 22 /**< default SSH port */ + +#define AXIS2_URI_TELNET_DEFAULT_PORT 23 /**< default telnet port */ + +#define AXIS2_URI_GOPHER_DEFAULT_PORT 70 /**< default Gopher port */ + +#define AXIS2_URI_HTTP_DEFAULT_PORT 80 /**< default HTTP port */ + +#define AXIS2_URI_POP_DEFAULT_PORT 110 /**< default POP port */ + +#define AXIS2_URI_NNTP_DEFAULT_PORT 119 /**< default NNTP port */ + +#define AXIS2_URI_IMAP_DEFAULT_PORT 143 /**< default IMAP port */ + +#define AXIS2_URI_PROSPERO_DEFAULT_PORT 191 /**< default Prospero port */ + +#define AXIS2_URI_WAIS_DEFAULT_PORT 210 /**< default WAIS port */ + +#define AXIS2_URI_LDAP_DEFAULT_PORT 389 /**< default LDAP port */ + +#define AXIS2_URI_HTTPS_DEFAULT_PORT 443 /**< default HTTPS port */ + +#define AXIS2_URI_RTSP_DEFAULT_PORT 554 /**< default RTSP port */ + +#define AXIS2_URI_SNEWS_DEFAULT_PORT 563 /**< default SNEWS port */ + +#define AXIS2_URI_ACAP_DEFAULT_PORT 674 /**< default ACAP port */ + +#define AXIS2_URI_NFS_DEFAULT_PORT 2049 /**< default NFS port */ + +#define AXIS2_URI_TIP_DEFAULT_PORT 3372 /**< default TIP port */ + +#define AXIS2_URI_SIP_DEFAULT_PORT 5060 /**< default SIP port */ + + /** Flags passed to unparse_uri_components(): */ + + /** suppress "scheme://user\@site:port" */ +#define AXIS2_URI_UNP_OMITSITEPART (1U<<0) + + /** Just omit user */ +#define AXIS2_URI_UNP_OMITUSER (1U<<1) + + /** Just omit password */ +#define AXIS2_URI_UNP_OMITPASSWORD (1U<<2) + + /** omit "user:password\@" part */ +#define AXIS2_URI_UNP_OMITUSERINFO (AXIS2_URI_UNP_OMITUSER | \ + AXIS2_URI_UNP_OMITPASSWORD) + + /** Show plain text password (default: show XXXXXXXX) */ +#define AXIS2_URI_UNP_REVEALPASSWORD (1U<<3) + + /** Show "scheme://user\@site:port" only */ +#define AXIS2_URI_UNP_OMITPATHINFO (1U<<4) + + /** Omit the "?queryarg" from the path */ +#define AXIS2_URI_UNP_OMITQUERY_ONLY (1U<<5) + + /** Omit the "#fragment" from the path */ +#define AXIS2_URI_UNP_OMITFRAGMENT_ONLY (1U<<6) + + /** Omit the "?queryarg" and "#fragment" from the path */ +#define AXIS2_URI_UNP_OMITQUERY (AXIS2_URI_UNP_OMITQUERY_ONLY | \ + AXIS2_URI_UNP_OMITFRAGMENT_ONLY) + + /** @see axutil_uri_t */ + typedef unsigned short axis2_port_t; + /* axutil_uri.c */ + + typedef struct axutil_uri axutil_uri_t; + + /** + * Creates axutil_uri struct. + * @param env pointer to environment struct. MUST NOT be NULL + * @return pointer to newly created axutil_uri struct + */ + AXIS2_EXTERN axutil_uri_t *AXIS2_CALL + axutil_uri_create( + const axutil_env_t * env); + + /** + * Return the default port for a given scheme. The schemes recognized are + * http, ftp, https, gopher, wais, nntp, snews, and prospero + * @param scheme_str The string that contains the current scheme + * @return The default port for this scheme + */ + AXIS2_EXTERN axis2_port_t AXIS2_CALL + axutil_uri_port_of_scheme( + const axis2_char_t * scheme_str); + + /** + * Parse a given URI, fill in all supplied fields of a axutil_uri + * structure. This eliminates the necessity of extracting host, port, + * path, query info repeatedly in the modules. + * @param uri The uri to parse + * @param uptr The axutil_uri_t to fill out + * @return AXIS2_SUCCESS for success or error code + */ + AXIS2_EXTERN axutil_uri_t *AXIS2_CALL + axutil_uri_parse_string( + const axutil_env_t * env, + const axis2_char_t * uri); + + /** + * Special case for CONNECT parsing: it comes with the hostinfo part only + * @param hostinfo The hostinfo string to parse + * @param uptr The axutil_uri_t to fill out + * @return AXIS2_SUCCESS for success or error code + */ + AXIS2_EXTERN axutil_uri_t *AXIS2_CALL + axutil_uri_parse_hostinfo( + const axutil_env_t * env, + const axis2_char_t * hostinfo); + + /** Resolve relative to a base. This means host/etc, and (crucially) path */ + AXIS2_EXTERN axutil_uri_t *AXIS2_CALL + axutil_uri_resolve_relative( + const axutil_env_t * env, + const axutil_uri_t * base, + axutil_uri_t * uptr); + + /** + * Return a URI created from a context URI and a relative URI. + * If a valid URI cannot be created the only other possibility + * this method will consider is that an absolute file path has + * been passed in as the relative URI argument, and it will try + * to create a 'file' URI from it. + * + * @param context_uri the document base URI + * @param uri a file URI relative to the context_uri or an + * absolute file path + * @return the URIcreated from context_uri and uri + */ + AXIS2_EXTERN axutil_uri_t *AXIS2_CALL + axutil_uri_parse_relative( + const axutil_env_t * env, + const axutil_uri_t * base, + const char *uri); + + AXIS2_EXTERN void AXIS2_CALL + axutil_uri_free( + axutil_uri_t * uri, + const axutil_env_t * env); + + /** + * Unparse a axutil_uri_t structure to an URI string. Optionally + * suppress the password for security reasons. + * @param uptr All of the parts of the uri + * @param flags How to unparse the uri. One of: + *
+     *    AXIS2_URI_UNP_OMITSITEPART        Suppress "scheme://user\@site:port" 
+     *    AXIS2_URI_UNP_OMITUSER            Just omit user 
+     *    AXIS2_URI_UNP_OMITPASSWORD        Just omit password 
+     *    AXIS2_URI_UNP_OMITUSERINFO        Omit "user:password\@" part
+     *    AXIS2_URI_UNP_REVEALPASSWORD      Show plain text password (default: show XXXXXXXX)
+     *    AXIS2_URI_UNP_OMITPATHINFO        Show "scheme://user\@site:port" only 
+     *    AXIS2_URI_UNP_OMITQUERY           Omit "?queryarg" or "#fragment" 
+     * 
+ * @return The uri as a string + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axutil_uri_to_string( + const axutil_uri_t * uri, + const axutil_env_t * env, + unsigned flags); + + /** + * @return returns actual reference, not a cloned copy. + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axutil_uri_get_protocol( + axutil_uri_t * uri, + const axutil_env_t * env); + + /** + * @return returns actual reference, not a cloned copy. + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axutil_uri_get_server( + axutil_uri_t * uri, + const axutil_env_t * env); + + /** + * @return returns actual reference, not a cloned copy. + * For IPv6 addresses, the IPv6 Address will be returned + * rather than the IP-literal as defined in RFC3986. + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axutil_uri_get_host( + axutil_uri_t * uri, + const axutil_env_t * env); + + AXIS2_EXTERN axis2_port_t AXIS2_CALL + axutil_uri_get_port( + axutil_uri_t * uri, + const axutil_env_t * env); + + /** + * @return returns actual reference, not a cloned copy. + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axutil_uri_get_path( + axutil_uri_t * uri, + const axutil_env_t * env); + + AXIS2_EXTERN axutil_uri_t *AXIS2_CALL + axutil_uri_clone( + const axutil_uri_t * uri, + const axutil_env_t * env); + + /** + * @return returns actual reference, not a cloned copy. + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axutil_uri_get_query( + axutil_uri_t * uri, + const axutil_env_t * env); + + /** + * @return returns actual reference, not a cloned copy. + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axutil_uri_get_fragment( + axutil_uri_t * uri, + const axutil_env_t * env); + + /** @} */ +#ifdef __cplusplus +} +#endif + +#endif /* AXIS2_URI_H */ diff --git a/util/include/axutil_url.h b/util/include/axutil_url.h new file mode 100644 index 0000000..7a42c2a --- /dev/null +++ b/util/include/axutil_url.h @@ -0,0 +1,149 @@ + +/* + * 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 + * limitations under the License. + */ + +#ifndef AXUTIL_URL_H +#define AXUTIL_URL_H + +/** + * @file axutil_url.h + * @brief axis2 URL container implementation + */ + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @ingroup axis2_core_transport_http + * @{ + */ + + typedef struct axutil_url axutil_url_t; + + AXIS2_EXTERN axutil_url_t *AXIS2_CALL + axutil_url_create( + const axutil_env_t * env, + const axis2_char_t * protocol, + const axis2_char_t * host, + const int port, + const axis2_char_t * path); + + AXIS2_EXTERN axutil_url_t *AXIS2_CALL + axutil_url_parse_string( + const axutil_env_t * env, + const axis2_char_t * str_url); + + AXIS2_EXTERN axutil_uri_t *AXIS2_CALL + axutil_url_to_uri( + axutil_url_t * url, + const axutil_env_t * env); + + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axutil_url_to_external_form( + axutil_url_t * url, + const axutil_env_t * env); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_url_set_protocol( + axutil_url_t * url, + const axutil_env_t * env, + axis2_char_t * protocol); + + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axutil_url_get_protocol( + axutil_url_t * url, + const axutil_env_t * env); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_url_set_host( + axutil_url_t * url, + const axutil_env_t * env, + axis2_char_t * host); + + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axutil_url_get_host( + axutil_url_t * url, + const axutil_env_t * env); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_url_set_server( + axutil_url_t * url, + const axutil_env_t * env, + axis2_char_t * server); + + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axutil_url_get_server( + axutil_url_t * url, + const axutil_env_t * env); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_url_set_port( + axutil_url_t * url, + const axutil_env_t * env, + int port); + + AXIS2_EXTERN int AXIS2_CALL + axutil_url_get_port( + axutil_url_t * url, + const axutil_env_t * env); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_url_set_path( + axutil_url_t * url, + const axutil_env_t * env, + axis2_char_t * path); + + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axutil_url_get_path( + axutil_url_t * url, + const axutil_env_t * env); + + AXIS2_EXTERN axutil_url_t *AXIS2_CALL + axutil_url_clone( + axutil_url_t * url, + const axutil_env_t * env); + + AXIS2_EXTERN void AXIS2_CALL + axutil_url_free( + axutil_url_t * url, + const axutil_env_t * env); + + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axutil_url_encode ( + const axutil_env_t * env, + axis2_char_t * dest, + axis2_char_t * buff, int len); + + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axutil_url_get_query( + axutil_url_t * url, + const axutil_env_t * env); + + + /** @} */ +#ifdef __cplusplus +} +#endif + +#endif /* AXIS2_URL_H */ diff --git a/util/include/axutil_utils.h b/util/include/axutil_utils.h new file mode 100644 index 0000000..8c156d1 --- /dev/null +++ b/util/include/axutil_utils.h @@ -0,0 +1,263 @@ + +/* + * 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 + * limitations under the License. + */ + +#ifndef AXUTIL_UTILS_H +#define AXUTIL_UTILS_H + +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axutil_utils utils + * @ingroup axis2_util + * @{ + */ + + /** + * @file axutil_utils.h + */ + +#define AXUTIL_LOG_FILE_SIZE 1024 * 1024 * 32 +#define AXUTIL_LOG_FILE_NAME_SIZE 512 + + /** This macro is called to check whether structure on which function is called + * is NULL and to check whether the environment structure passed is valid. + * @param object structure on which function is called + * @param env environment to be checked for validity + * @param error_return If function return a status it should pass here + * AXIS2_FAILURE. If function return a type pointer it should + * pass NULL + * @return If function return a status code return AXIS2_SUCCESS. Else if + * function return a type pointer return NULL + */ +#define AXIS2_FUNC_PARAM_CHECK(object, env, error_return) \ + if (!object) \ + { \ + AXIS2_ERROR_SET_ERROR_NUMBER(env->error, AXIS2_ERROR_INVALID_NULL_PARAM); \ + AXIS2_ERROR_SET_STATUS_CODE(env->error, AXIS2_FAILURE); \ + return error_return; \ + } \ + else \ + { \ + AXIS2_ERROR_SET_STATUS_CODE(env->error, AXIS2_SUCCESS); \ + } + + + /**This macro is called to check whether an object is NULL. + * if object is NULL error number and status code is set + * @param object object to be check for NULL + * @param error_return If function return a status it should pass here + * AXIS2_FAILURE. If function return a type pointer it should + * pass NULL + * @return If function return a status code return AXIS2_SUCCESS. Else if + * function return a type pointer return NULL + */ +#define AXIS2_PARAM_CHECK(error, object, error_return) \ + if (!object) \ + { \ + AXIS2_ERROR_SET_ERROR_NUMBER(error, AXIS2_ERROR_INVALID_NULL_PARAM); \ + AXIS2_ERROR_SET_STATUS_CODE(error, AXIS2_FAILURE); \ + return error_return; \ + } \ + else \ + { \ + AXIS2_ERROR_SET_STATUS_CODE(error, AXIS2_SUCCESS); \ + } + + + +#define AXIS2_PARAM_CHECK_VOID(error, object) \ + if (!object) \ + { \ + AXIS2_ERROR_SET_ERROR_NUMBER(error, AXIS2_ERROR_INVALID_NULL_PARAM); \ + AXIS2_ERROR_SET_STATUS_CODE(error, AXIS2_FAILURE); \ + return; \ + } + + + + /**This macro is used to handle error situation. + * @param error_number Error number for the error occured + * @param error_return If function return a status it should pass here + * AXIS2_FAILURE. If function return a type pointer it should + * pass NULL + * @return If function return a status code return AXIS2_SUCCESS. Else if + * function return a type pointer return NULL + */ +#define AXIS2_ERROR_SET(error, error_number, status_code) \ + { \ + AXIS2_ERROR_SET_ERROR_NUMBER(error, error_number); \ + AXIS2_ERROR_SET_STATUS_CODE(error, status_code); \ + } + + /** + * This macro is used to set and error, and log it. In addition to that + * you are capable of specifying the file name and line number + * @param env Reference to env struct + * @param error_number Error number for the error occured + * @param status_code The Error Status to be set + * @param file_name_line_no File name and line number constant + */ +#define AXIS2_HANDLE_ERROR_WITH_FILE(env, error_number, \ + status_code, file_name_line_no) \ + { \ + AXIS2_ERROR_SET(env->error, error_number, status_code); \ + AXIS2_LOG_ERROR(env->log, file_name_line_no, \ + AXIS2_ERROR_GET_MESSAGE(env->error)); \ + } + + /** + * This macro is used to set and error, and log it + * @param env Reference to env struct + * @param error_number Error number for the error occured + * @param status_code The Error Status to be set + */ +#define AXIS2_HANDLE_ERROR(env, error_number, status_code) \ + AXIS2_HANDLE_ERROR_WITH_FILE(env, error_number, status_code, \ + AXIS2_LOG_SI) \ + + /** Method names in the loadable libraries */ + +#define AXIS2_CREATE_FUNCTION "axis2_get_instance" +#define AXIS2_DELETE_FUNCTION "axis2_remove_instance" + + typedef void( + AXIS2_CALL + * AXIS2_FREE_VOID_ARG)( + void *obj_to_be_freed, + const axutil_env_t * env); + + /* Function pointer typedef for read callback */ + typedef int( + AXIS2_CALL + * AXIS2_READ_INPUT_CALLBACK)( + char *buffer, + int size, + void *ctx); + + /* Function pointer typedef for close callback */ + typedef int( + AXIS2_CALL + * AXIS2_CLOSE_INPUT_CALLBACK)( + void *ctx); + + /** + * \brief Axis2 scopes + * + * Possible scope value for Axis2 + */ + enum axis2_scopes + { + + /** Request scope */ + AXIS2_SCOPE_REQUEST = 0, + + /** Session scope */ + AXIS2_SCOPE_SESSION, + + /** Application scope */ + AXIS2_SCOPE_APPLICATION + }; + +#define AXIS2_TARGET_EPR "target_epr" +#define AXIS2_DUMP_INPUT_MSG_TRUE "dump" + + /** + * This function allows the user match a REST URL template with the + * Request URL. It returns a 3-dimensional array with pairs of elements + * of axis2_char_t arrays (strings). The caller is responsible to free + * the memory allocated by the function for the return value. + * @param env pointer to environment struct + * @param tmpl Template to Match + * @param url Request URL + * @param match_count variable to store match count + * @param matches axis2_char_t *** axis2_char_t *** + * @return AXIS2_SUCCESS if all matches were found or AXIS2_FAILURE. + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_parse_rest_url_for_params( + const axutil_env_t * env, + const axis2_char_t * tmpl, + const axis2_char_t * url, + int * match_count, + axis2_char_t **** matches); + + /** + * This function allows users to resolve the service and op 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 env pointer to environment struct + * @param request url + * @return axis2_char_t ** axis2_char_t ** + */ + AXIS2_EXTERN axis2_char_t **AXIS2_CALL + axutil_parse_request_url_for_svc_and_op( + const axutil_env_t * env, + const axis2_char_t * request); + + /** + * Quotes an XML string. + * Replace '<', '>', and '&' with '<', '>', and '&'. + * If quotes is true, then replace '"' with '"'. + * @param env pointer to environment struct + * @param s string to be quoted + * @param quotes if AXIS2_TRUE then replace '"' with '"'. + * quotes is typically set to true for XML strings that will occur within + * double quotes -- attribute values. + * @return Encoded string if there are characters to be encoded, else NULL. + * The caller is responsible to free the memory allocated by the function + * for the return value + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axutil_xml_quote_string( + const axutil_env_t * env, + const axis2_char_t * s, + axis2_bool_t quotes); + + AXIS2_EXTERN int AXIS2_CALL + axutil_hexit(axis2_char_t c); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axutil_url_decode( + const axutil_env_t * env, + axis2_char_t * dest, + axis2_char_t * src); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axis2_char_2_byte( + const axutil_env_t *env, + axis2_char_t *char_buffer, + axis2_byte_t **byte_buffer, + int *byte_buffer_size); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIS2_UTILS_H */ diff --git a/util/include/axutil_utils_defines.h b/util/include/axutil_utils_defines.h new file mode 100644 index 0000000..c12c842 --- /dev/null +++ b/util/include/axutil_utils_defines.h @@ -0,0 +1,226 @@ + +/* + * 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 + * limitations under the License. + */ + +#ifndef AXUTIL_UTILS_DEFINES_H +#define AXUTIL_UTILS_DEFINES_H + +#include + +#if !defined(_WIN32) +#include +#endif + +#ifdef __cplusplus +extern "C" +{ +#endif + +#if defined(_WIN32) && !defined(AXIS2_SKIP_INT_TYPEDEFS) + /** + * ANSI Type definitions for Windows + */ + typedef unsigned __int8 uint8_t; + typedef __int8 int8_t; + typedef unsigned __int16 uint16_t; + typedef __int16 int16_t; + typedef unsigned __int32 uint32_t; + typedef __int32 int32_t; + typedef unsigned __int64 uint64_t; + typedef __int64 int64_t; +#endif + +/** + * Definition of format specifiers + * for printf family of functions + */ + +#if defined(_WIN32) +#define AXIS2_PRINTF_INT64_FORMAT_SPECIFIER "%I64d" +#define AXIS2_PRINTF_UINT64_FORMAT_SPECIFIER "%I64u" +#define AXIS2_PRINTF_INT32_FORMAT_SPECIFIER "%I32d" +#define AXIS2_PRINTF_UINT32_FORMAT_SPECIFIER "%I32u" +#else +#if __WORDSIZE == 64 +#define AXIS2_PRINTF_INT64_FORMAT_SPECIFIER "%ld" +#define AXIS2_PRINTF_UINT64_FORMAT_SPECIFIER "%lu" +#else +#define AXIS2_PRINTF_INT64_FORMAT_SPECIFIER "%lld" +#define AXIS2_PRINTF_UINT64_FORMAT_SPECIFIER "%llu" +#endif +#define AXIS2_PRINTF_INT32_FORMAT_SPECIFIER "%d" +#define AXIS2_PRINTF_UINT32_FORMAT_SPECIFIER "%u" +#endif + + /** + * Type definitions + */ + typedef char axis2_char_t; + typedef int axis2_bool_t; + typedef int axis2_status_t; + typedef int axis2_scope_t; + typedef unsigned int axis2_ssize_t; + typedef char axis2_byte_t; + typedef unsigned char axis2_unsigned_byte_t; + +#define AXIS2_STRING(s) s + +#define AXIS2_CHAR(c) c + +#define AXIS2_CRLF_LENGTH 2 + +#define AXIS2_CRLF "\r\n" + + /* These constant definitions should later be moved to platform dependant + * files + */ + +#define AXIS2_EOLN '\0' + + /** + * Boolean values + */ +#define AXIS2_TRUE 1 +#define AXIS2_FALSE 0 + + /** + * Exporting + */ +#if defined(_WIN32) && !defined(AXIS2_DECLARE_STATIC) +#define AXIS2_EXPORT __declspec(dllexport) +#else +#define AXIS2_EXPORT +#endif + + /** + * Importing + */ +#if defined(_WIN32) +#define AXIS2_IMPORT __declspec(dllimport) +#else +#define AXIS2_IMPORT +#endif + + /** + * Calling Conventions + */ +#if defined(__GNUC__) +#if defined(__i386) +#define AXIS2_CALL __attribute__((cdecl)) +#define AXIS2_WUR __attribute__((warn_unused_result)) +#else +#define AXIS2_CALL +#define AXIS2_WUR + + +#endif +#else +#if defined(__unix) +#define AXIS2_CALL +#define AXIS2_WUR + + +#else /* WIN32 */ +#define AXIS2_CALL __stdcall +#define AXIS2_WUR +#endif +#endif +#define AXIS2_THREAD_FUNC AXIS2_CALL + + +#ifdef DOXYGEN + + /* define these just so doxygen documents them */ + + /** + * AXIS2_DECLARE_STATIC is defined when including Axis2's Core headers, + * to provide static linkage when the dynamic library may be unavailable. + * + * @see AXIS2_DECLARE_EXPORT + * + * AXIS2_DECLARE_STATIC and AXIS2_DECLARE_EXPORT are left undefined when + * including Axis2's Core headers, to import and link the symbols from the + * dynamic Axis2 Core library and assure appropriate indirection and calling + * conventions at compile time. + */ +# define AXIS2_DECLARE_STATIC + + /** + * AXIS2_DECLARE_EXPORT is defined when building the Axis2 Core dynamic + * library, so that all public symbols are exported. + * + * @see AXIS2_DECLARE_STATIC + */ +# define AXIS2_DECLARE_EXPORT + +#endif /* def DOXYGEN */ + +#if !defined(_WIN32) + + /** + * Axis2 Core functions are declared with AXIS2_EXTERN AXIS2_CALL + + , so they may + * use the most appropriate calling convention. Other + * Core functions with variable arguments must use AXIS2_DECLARE_NONSTD(). + * @code + * AXIS2_EXTERN rettype) axis2_func(args AXIS2_CALL + + + * @endcode + */ +#define AXIS2_EXTERN + + /** + * Axis2 Core variable argument and hook functions are declared with + * AXIS2_DECLARE_NONSTD(), as they must use the C language calling convention. + * @see AXIS2_DECLARE + * @code + * AXIS2_DECLARE_NONSTD(rettype) axis2_func(args [...]) + * @endcode + */ +#define AXIS2_DECLARE_NONSTD(type) type + + /** + * Axis2 Core variables are declared with AXIS2_DECLARE_DATA. + * This assures the appropriate indirection is invoked at compile time. + * + * @code + * AXIS2_DECLARE_DATA type axis2_variable + * @endcode + */ +#define AXIS2_DECLARE_DATA + +#elif defined(AXIS2_DECLARE_STATIC) +#define AXIS2_EXTERN +#define AXIS2_EXTERN_NONSTD +#define AXIS2_DECLARE_DATA +#elif defined(AXIS2_DECLARE_EXPORT) +#define AXIS2_EXTERN AXIS2_EXPORT +#define AXIS2_EXTERN_NONSTD AXIS2_EXPORT +#define AXIS2_DECLARE_DATA +#else +#define AXIS2_EXTERN AXIS2_IMPORT +#define AXIS2_EXTERN_NONSTD AXIS2_IMPORT +#define AXIS2_DECLARE_DATA +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* AXIS2_UTILS_DEFINES_H */ diff --git a/util/include/axutil_uuid_gen.h b/util/include/axutil_uuid_gen.h new file mode 100644 index 0000000..2db4583 --- /dev/null +++ b/util/include/axutil_uuid_gen.h @@ -0,0 +1,51 @@ + +/* + * 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 count 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 AXUTIL_UUID_GEN_H +#define AXUTIL_UUID_GEN_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axutil_uuid_gen UUID generator + * @ingroup axis2_util + * @{ + */ + + /** + * generate a uuid + * @return generated uuid as a string + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axutil_uuid_gen( + const axutil_env_t * env); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIS2_UUID_GEN_H */ diff --git a/util/include/axutil_version.h b/util/include/axutil_version.h new file mode 100644 index 0000000..116ddfa --- /dev/null +++ b/util/include/axutil_version.h @@ -0,0 +1,140 @@ + +/** + * 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 + * limitations under the License. + */ + +#ifndef AXUTIL_VERSION_H +#define AXUTIL_VERSION_H + +/* The numeric compile-time version constants. These constants are the + * authoritative version numbers for AXIS2. + */ + +/** major version + * Major API changes that could cause compatibility problems for older + * programs such as structure size changes. No binary compatibility is + * possible across a change in the major version. + */ +#define AXIS2_MAJOR_VERSION 1 + +/** minor version + * Minor API changes that do not cause binary compatibility problems. + * Reset to 0 when upgrading AXIS2_MAJOR_VERSION + */ +#define AXIS2_MINOR_VERSION 6 + +/** patch level + * The Patch Level never includes API changes, simply bug fixes. + * Reset to 0 when upgrading AXIS2_MINOR_VERSION + */ +#define AXIS2_PATCH_VERSION 0 + +/** + * The symbol AXIS2_IS_DEV_VERSION is only defined for internal, + * "development" copies of AXIS2. It is undefined for released versions + * of AXIS2. + */ +#undef AXIS2_IS_DEV_VERSION + +#if defined(AXIS2_IS_DEV_VERSION) || defined(DOXYGEN) + +/** Internal: string form of the "is dev" flag */ +#define AXIS2_IS_DEV_STRING "-dev" +#else +#define AXIS2_IS_DEV_STRING "" +#endif + +/** Properly quote a value as a string in the C preprocessor */ +#define AXIS2_STRINGIFY(n) AXIS2_STRINGIFY_HELPER(n) + +/** Helper macro for AXIS2_STRINGIFY */ +#define AXIS2_STRINGIFY_HELPER(n) #n + +/** The formatted string of AXIS2's version */ +#define AXIS2_VERSION_STRING \ + AXIS2_STRINGIFY(AXIS2_MAJOR_VERSION) "." \ + AXIS2_STRINGIFY(AXIS2_MINOR_VERSION) "." \ + AXIS2_STRINGIFY(AXIS2_PATCH_VERSION) \ + AXIS2_IS_DEV_STRING + +/** An alternative formatted string of AXIS2's version */ + +/* macro for Win32 .rc files using numeric csv representation */ +#define AXIS2_VERSION_STRING_CSV AXIS2_MAJOR_VERSION ##, \ + ##AXIS2_MINOR_VERSION ##, \ + ##AXIS2_PATCH_VERSION + +#ifndef AXIS2_VERSION_ONLY + +/* The C language API to access the version at run time, + * as opposed to compile time. AXIS2_VERSION_ONLY may be defined + * externally when preprocessing axutil_version.h to obtain strictly + * the C Preprocessor macro declarations. + */ + +#include "axutil_env.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * The numeric version information is broken out into fields within this + * structure. + */ + typedef struct + { + + int major; + + /**< major number */ + + int minor; + + /**< minor number */ + + int patch; + + /**< patch number */ + + int is_dev; + + /**< is development (1 or 0) */ + } + axis2_version_t; + + /** + * Return AXIS2's version information information in a numeric form. + * + * @param pvsn Pointer to a version structure for returning the version + * information. + */ + AXIS2_EXTERN void AXIS2_CALL + axis2_version( + axis2_version_t * pvsn); + + /** Return AXIS2's version information as a string. */ + AXIS2_EXTERN const char *AXIS2_CALL + axis2_version_string( + void); + +#ifdef __cplusplus +} +#endif +#endif + +#endif /* AXIS2_VERSION_H */ diff --git a/util/include/platforms/axutil_platform_auto_sense.h b/util/include/platforms/axutil_platform_auto_sense.h new file mode 100644 index 0000000..feec323 --- /dev/null +++ b/util/include/platforms/axutil_platform_auto_sense.h @@ -0,0 +1,63 @@ + +/* + * 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 + * limitations under the License. + */ + +#ifndef AXIS2_PLATFORM_AUTOSENSE_H +#define AXIS2_PLATFORM_AUTOSENSE_H + +/** + * @file axutil_platform_auto_sense.h + * @brief axis2 platform auto sense + */ + +/* +#ifdef __cplusplus +extern "C" +{ +#endif +*/ + + /** @defgroup axis2_platform_auto_sense + * @ingroup axis2_platforms + * @{ + */ + +#if defined(_WIN32 ) +#include "windows/axutil_windows.h" +#include "windows/axutil_dir_windows.h" +#include "windows/axutil_uuid_gen_windows.h" +#include "windows/axutil_getopt_windows.h" +#include "windows/axutil_date_time_util_windows.h" +#include "windows/axutil_thread_windows.h" +#elif defined ( __OS400__ ) +#include +#elif defined ( AIX ) +#include +#elif defined ( HPUX ) +#include +#else +#include +#endif + + /** @} */ +/* +#ifdef __cplusplus +} +#endif +*/ + +#endif /* AXIS2_PLATFORM_AUTOSENSE_H */ diff --git a/util/include/platforms/unix/axutil_date_time_util_unix.h b/util/include/platforms/unix/axutil_date_time_util_unix.h new file mode 100644 index 0000000..9979395 --- /dev/null +++ b/util/include/platforms/unix/axutil_date_time_util_unix.h @@ -0,0 +1,46 @@ + +/* + * 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 count 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 AXUTIL_DATE_TIME_UTIL_UNIX_H +#define AXUTIL_DATE_TIME_UTIL_UNIX_H + +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axis2_milliseconds + * @ingroup axis2_milliseconds + * @{ + */ + AXIS2_EXTERN int AXIS2_CALL + axis2_platform_get_milliseconds(void + ); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/util/include/platforms/unix/axutil_thread_unix.h b/util/include/platforms/unix/axutil_thread_unix.h new file mode 100644 index 0000000..5ee5992 --- /dev/null +++ b/util/include/platforms/unix/axutil_thread_unix.h @@ -0,0 +1,59 @@ + +/* + * 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 + * limitations under the License. + */ + +#ifndef AXUTIL_THREAD_UNIX_H +#define AXUTIL_THREAD_UNIX_H + +#include +#include + +#define SHELL_PATH "/bin/sh" + +typedef pthread_t axis2_os_thread_t; /* Native thread */ + +struct axutil_thread_t +{ + pthread_t *td; + void *data; + axutil_thread_start_t func; + axis2_bool_t try_exit; +}; + +struct axutil_threadattr_t +{ + pthread_attr_t attr; +}; + +struct axutil_threadkey_t +{ + pthread_key_t key; +}; + +struct axutil_thread_once_t +{ + pthread_once_t once; +}; + +/*************************Thread locking functions*****************************/ +struct axutil_thread_mutex_t +{ + axutil_allocator_t *allocator; + pthread_mutex_t mutex; +}; + +#endif /* AXIS2_THREAD_UNIX_H */ diff --git a/util/include/platforms/unix/axutil_unix.h b/util/include/platforms/unix/axutil_unix.h new file mode 100644 index 0000000..fa23eae --- /dev/null +++ b/util/include/platforms/unix/axutil_unix.h @@ -0,0 +1,279 @@ + +/* + * 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 + * limitations under the License. + */ + +#ifndef AXIS2_UNIX_H +#define AXIS2_UNIX_H + +#include + +/** + * @file axutil_unix.h + * @brief axis2 unix platform specific interface + */ + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** @defgroup axis2_unix Platform Specific + * @ingroup axis2_platforms_unix + * @{ + */ + + /*************************************************************** + * Default paths to shared library/DLLs and files + *************************************************************** + */ + +#define AXIS2_PLATFORM_DEFAULT_DEPLOY_PATH "" + +#define AXIS2_PLATFORM_XMLPARSER_PATH "libaxis2_parser.so" +#define AXIS2_PLATFORM_TRANSPORTHTTP_PATH "libhttp_transport.so" +#define AXIS2_PLATFORM_CHANNEL_PATH "libhttp_channel.so" +#define AXIS2_PLATFORM_SSLCHANNEL_PATH "Unknown" + +#define AXIS2_PLATFORM_LOG_PATH "/usr/local/axis2/log/axutil_log" +#define AXIS2_PLATFORM_CLIENTLOG_PATH "/usr/local/axis2/log/axis2_client_log" +#define AXIS2_PLATFORM_CONFIG_PATH "/etc/axiscpp.conf" +#define AXIS2_PLATFORM_SECUREINFO "" + + /** + * Resource that contains the configuration + */ +#define AXIS2_CONFIGURATION_RESOURCE "/usr/local/axis2/axis2.xml" + + /***************************************************************** + * Library loading and procedure resolution + ****************************************************************/ +#ifdef USE_LTDL +#include +#define AXIS2_DLHANDLER lt_dlhandle + +#define AXIS2_PLATFORM_LOADLIBINIT lt_dlinit +#define AXIS2_PLATFORM_LOADLIB(_lib) lt_dlopen(_lib) +#define AXIS2_PLATFORM_UNLOADLIB lt_dlclose +#define AXIS2_PLATFORM_GETPROCADDR lt_dlsym +#define AXIS2_PLATFORM_LOADLIBEXIT lt_dlexit +#define AXIS2_PLATFORM_LOADLIB_ERROR lt_dlerror() +#else +#include +#define AXIS2_DLHANDLER void* + +#define AXIS2_PLATFORM_LOADLIBINIT() +#define AXIS2_PLATFORM_LOADLIB(_lib) dlopen(_lib, RTLD_LAZY) + /*#define AXIS2_PLATFORM_LOADLIB(_lib) dlopen(_lib, RTLD_NOW) */ + +#define AXIS2_PLATFORM_UNLOADLIB dlclose +#define AXIS2_PLATFORM_GETPROCADDR dlsym +#define AXIS2_PLATFORM_LOADLIBEXIT() +#define AXIS2_PLATFORM_LOADLIB_ERROR dlerror() + +#endif + + /*************************************************************** + * National Language Support + ****************************************************************/ + + /* STRTOASC is to translate single byte 'native' character representation to ASCII */ + + /* ASCTOSTR is to translate single byte ascii representation to 'native' character */ + + /* CANNOT be used with constants */ +#define AXIS2_PLATFORM_STRTOASC( x ) ( x ) +#define AXIS2_PLATFORM_ASCTOSTR( x ) ( x ) + + /*************************************************************** + * Miscellaneous + ****************************************************************/ +#include +#include + + /*#include */ +#include +#include +#include +#include +#include +#include +#include +#include +#include "axutil_uuid_gen_unix.h" /* uuid_gen unix implementation */ +#include /* TCP_NODELAY */ +#include +#include +#include "axutil_date_time_util_unix.h" + + /* for file access handling */ +#ifdef HAVE_UNISTD_H +#include +#endif /*HAVE_UNISTD_H */ + + /* network handling */ +#include +#include +#include +#include +#include + +#include + + /* dir handling */ +#include +#include + +#define AXIS2_STRRCHR(x, y) (strrchr(x, y)) + +#define AXIS2_PLATFORM_SLEEP(x) sleep(0); + + /** sleep function abstraction */ +#define AXIS2_SLEEP sleep +#define AXIS2_USLEEP usleep + + /** + * Get the last error code from the system. + * Please ensure that this is a thread safe implementation + * and that it returns a long + * @return long the last error message for this thread + */ + + /*#define AXIS2_GETLASTERROR errno; */ + + /** + * From the last error number get a sensible std::string representing it + * @param errorNumber the error Number you are trying to get a message for + * @return the error message. NOTE: The caller is responsible for deleting the returned string + */ + + /*#define AXIS2_PLATFORM_GET_ERROR_MESSAGE(errorNumber) new string(strerror(errorNumber)); */ + + /** + * Platform specific method to obtain current thread ID + */ +#include +#define AXIS2_PLATFORM_GET_THREAD_ID() pthread_self() + + /** + * Platform specific method to obtain current time in milli seconds + */ +#define AXIS2_PLATFORM_GET_TIME_IN_MILLIS ftime +#define AXIS2_PLATFORM_TIMEB timeb + + /** + * type to be used for 64bit integers + */ +#define AXIS2_LONGLONG long long +#define AXIS2_LONGLONGVALUE(value) value##LL +#define AXIS2_UNSIGNED_LONGLONGVALUE(value) value##ULL + + /** + * Format string to be used in printf for 64bit integers + */ +#define AXIS2_PRINTF_LONGLONG_FORMAT_SPECIFIER "%lld" +#define AXIS2_PRINTF_LONGLONG_FORMAT_SPECIFIER_CHARS "lld" +#define AXIS2_PRINTF_UNSIGNED_LONGLONG_FORMAT_SPECIFIER "%llu" +#define AXIS2_PRINTF_UNSIGNED_LONGLONG_FORMAT_SPECIFIER_CHARS "llu" + + /** + * Platform specific path separator char + */ +#ifdef IS_MACOSX +#define AXIS2_PATH_SEP_CHAR '/' +#define AXIS2_PATH_SEP_STR "/" +#define AXIS2_LIB_PREFIX "lib" +#define AXIS2_LIB_SUFFIX ".dylib" +#else +#define AXIS2_PATH_SEP_CHAR '/' +#define AXIS2_PATH_SEP_STR "/" +#define AXIS2_LIB_PREFIX "lib" +#define AXIS2_LIB_SUFFIX ".so" +#endif + + /** + * Platform specific time + */ +#define AXIS2_TIME_T time_t + + /** + * Platform specific file handling + */ +#define AXIS2_FOPEN fopen +#define AXIS2_FREAD fread +#define AXIS2_FWRITE fwrite +#define AXIS2_FCLOSE fclose +#define AXIS2_FTELL ftell +#define AXIS2_ACCESS(zpath,imode) access(zpath,imode) +#define AXIS2_R_OK R_OK /* test for read permission */ +#define AXIS2_W_OK W_OK /* test for write permission */ +#define AXIS2_X_OK X_OK /* test for execute or search permission */ +#define AXIS2_F_OK F_OK /* test whether the directories leading to the file can be + searched and the file exists */ + + /** + * Platform specific environment variable access method + */ +#define AXIS2_GETENV(_env_var_name) getenv(_env_var_name) + + /** + * unix specific directory handling functions + */ +#define AXIS2_SCANDIR scandir +#define AXIS2_ALPHASORT alphasort +#define AXIS2_OPENDIR opendir +#define AXIS2_CLOSEDIR closedir +#define AXIS2_READDIR readdir +#define AXIS2_READDIR_R readdir_r +#define AXIS2_REWINDDIR rewinddir +#define AXIS2_MKDIR mkdir +#define AXIS2_GETCWD getcwd +#define AXIS2_CHDIR chdir + + /** + * network specific functions and defs + */ +#define axis2_socket_t int +#define AXIS2_INVALID_SOCKET -1 +#define AXIS2_INADDR_NONE (in_addr_t)-1 +#define axis2_unsigned_short_t uint16_t +#define AXIS2_CLOSE_SOCKET(sock) close(sock) +#define AXIS2_CLOSE_SOCKET_ON_EXIT(sock) fcntl(sock,F_SETFD, FD_CLOEXEC); +#define axis2_socket_len_t socklen_t +#define AXIS2_SHUT_WR SHUT_WR + + /** getopt function */ +#define AXIS2_GETOPT getopt + + /** minizip functions */ +#define axis2_fill_win32_filefunc(ffunc) +#define AXIS2_UNZOPEN2(zipfilename,ffunc) unzOpen2(zipfilename,NULL); memset(&ffunc, 0, sizeof(ffunc)); + + /** + * handling variable number of arguments (for log.c) + */ +#define AXIS2_VSNPRINTF vsnprintf + +#define AXIS2_SNPRINTF snprintf + +#define axis2_gmtime_r gmtime_r + + /** @} */ +#ifdef __cplusplus +} +#endif + +#endif /* AXIS2_UNIX_H */ diff --git a/util/include/platforms/unix/axutil_uuid_gen_unix.h b/util/include/platforms/unix/axutil_uuid_gen_unix.h new file mode 100644 index 0000000..d3b25ba --- /dev/null +++ b/util/include/platforms/unix/axutil_uuid_gen_unix.h @@ -0,0 +1,94 @@ + +/* + * 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 count 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 AXUTIL_UUID_GEN_UNIX_H +#define AXUTIL_UUID_GEN_UNIX_H + +#include +#include + +#define UUIDS_PER_TICK 100 +#define UUID_TIMEOFFSET AXIS2_UNSIGNED_LONGLONGVALUE(0x01B21DD213814000) +#define AXIS2_LOCAL_MAC_ADDR "000000" + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axutil_uuid_gen UUID Generator + * @ingroup axis2_util + * @{ + */ + + struct axutil_uuid + { + unsigned int time_low; + unsigned short int time_mid; + unsigned short int time_high_version; + short int clock_variant; + unsigned char mac_addr[6]; + }; + + /* bits 0-59 time field + * bits 60-63 version + * bits 64-65 2 bit variant + * bits 66-79 clock sequence + * bits 80-107 node MAC address + */ + struct axutil_uuid_st + { + unsigned char mac[6]; /* pre-determined MAC address */ + struct timeval time_last; /* last retrieved timestamp */ + unsigned long time_seq; /* last timestamp sequence counter */ + short int clock; /* clock tick - incremented random number */ + }; + + typedef struct axutil_uuid axutil_uuid_t; + + /** + * Returns the mac address of the first ethernet intsrface + * @return MAC address as a char[6] + */ + char *AXIS2_CALL + axutil_uuid_get_mac_addr(void + ); + + /** + * Generates a uuid in version1 format (node - timestamp based) + * @return generated uuid as a axutil_uuid_t + */ + axutil_uuid_t *AXIS2_CALL + axutil_uuid_gen_v1(void + ); + + /** + * Generates a uuid + * @return generated uuid as a string + */ + axis2_char_t *AXIS2_CALL + axutil_platform_uuid_gen( + char *s); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIS2_UUID_GEN_UNIX_H */ diff --git a/util/include/platforms/windows/axutil_date_time_util_windows.h b/util/include/platforms/windows/axutil_date_time_util_windows.h new file mode 100644 index 0000000..2c5eef9 --- /dev/null +++ b/util/include/platforms/windows/axutil_date_time_util_windows.h @@ -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 count 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 AXUTIL_DATE_TIME_UTIL_WINDOWS_H +#define AXUTIL_DATE_TIME_UTIL_WINDOWS_H + +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axutil_date_time_util + * @ingroup axutil_date_time_util + * @{ + */ + AXIS2_EXTERN int AXIS2_CALL + axis2_platform_get_milliseconds( + ); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/util/include/platforms/windows/axutil_dir_windows.h b/util/include/platforms/windows/axutil_dir_windows.h new file mode 100644 index 0000000..89ba297 --- /dev/null +++ b/util/include/platforms/windows/axutil_dir_windows.h @@ -0,0 +1,123 @@ + +/* + * 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 READDIR_H +#define READDIR_H +#include +#include +#include +#include +#include +#include +#include +#include + + +/* struct dirent - same as Unix dirent.h */ +struct dirent +{ + long d_ino; /* inode number (always 1 in WIN32) */ + off_t d_off; /* offset to this dirent */ + unsigned short d_reclen; /* length of d_name */ + char d_name[_MAX_FNAME + 1]; /* filename (null terminated) */ + + /*unsigned char d_type; *//*type of file */ +}; + + +/* def struct DIR - different from Unix DIR */ +typedef struct +{ + long handle; /* _findfirst/_findnext handle */ + short offset; /* offset into directory */ + short finished; /* 1 if there are not more files */ + struct _finddata_t fileinfo; /* from _findfirst/_findnext */ + char *dirname; /* the dir we are reading */ + struct dirent dent; /* the dirent to return */ + +} +AXIS2_DIR; + + +/* Function prototypes */ + + +/** + * open a directory on a given name + * returns a DIR if successful, or NULL if the path cannot be opened + */ +AXIS2_EXTERN AXIS2_DIR * AXIS2_CALL + axis2_opendir(const char *); + + +/** + * Close the directory stream DIRP. + * Return 0 if successful, -1 otherwise. + */ +AXIS2_EXTERN int AXIS2_CALL + axis2_closedir( + AXIS2_DIR *); + + +/** + * Read a directory entry from DIRP. Return a pointer to a `struct + * dirent' describing the entry, or NULL for EOF or error. + */ +AXIS2_EXTERN struct dirent *AXIS2_CALL + axis2_readdir( + AXIS2_DIR *); + + +/** + * Reentrant version of `readdir' + */ +AXIS2_EXTERN int AXIS2_CALL + axis2_readdir_r( + AXIS2_DIR *, + struct dirent *, + struct dirent **); + + +/** + * Rewind DIRP to the beginning of the directory. + */ +AXIS2_EXTERN int AXIS2_CALL + axis2_rewinddir( + AXIS2_DIR *); + + +/** + * Scan the directory DIR + * Returns the number of entries selected, or -1 on error + */ +AXIS2_EXTERN int AXIS2_CALL + axis2_scandir( + const char *_dirname, + struct dirent **__namelist[], + int(*selector)(const struct dirent * entry), + int(*compare)(const struct dirent ** a, + const struct dirent ** b)); + + +/** + * Compare two `struct dirent's alphabetically + */ +extern int alphasort( + const struct dirent **__d1, + const struct dirent **__d2); + +#endif /* READDIR_H */ diff --git a/util/include/platforms/windows/axutil_getopt_windows.h b/util/include/platforms/windows/axutil_getopt_windows.h new file mode 100644 index 0000000..8234fba --- /dev/null +++ b/util/include/platforms/windows/axutil_getopt_windows.h @@ -0,0 +1,79 @@ + +/* +* 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 +* limitations under the License. +*/ + +#ifndef _AXIS2_GETOPT_WINDOWS_H_ +#define _AXIS2_GETOPT_WINDOWS_H_ + +#include + +/** + * @file axis2_getopt_windows.h + * @brief windows cutdown version of getopt function in unix + */ + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** @defgroup axis2_getopt_windows getopt + * @ingroup axis2_windows + * @{ + */ +#ifndef AXIS2_GET_OPT_DEFINE_MODE_NO_IMPORT + AXIS2_IMPORT extern int opterr; + AXIS2_IMPORT extern int optopt; + AXIS2_IMPORT extern char *optarg; +#else + AXIS2_EXPORT int opterr; + AXIS2_EXPORT int optopt; + AXIS2_EXPORT char *optarg; +#endif + + /** + * return and log error + * @param __optopt option + * @param __err error code + * @param __showerr whether or not send to stderr + * @return ':' or '?' + */ + int _axis2_opt_error( + int __optopt, + int __err, + int __showerr); + + /** + * cutdown version of getopt in unix + * @param __argc no of arguments + * @param __argv list of arguments + * @param __shortopts options + * @return option char if successful, -1 if over, ':' or '?' if error + */ + AXIS2_EXTERN int AXIS2_CALL + axis2_getopt( + int __argc, + char *const *__argv, + const char *__shortopts); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/util/include/platforms/windows/axutil_thread_mutex_windows.h b/util/include/platforms/windows/axutil_thread_mutex_windows.h new file mode 100644 index 0000000..4fed951 --- /dev/null +++ b/util/include/platforms/windows/axutil_thread_mutex_windows.h @@ -0,0 +1,44 @@ + +/* +* 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 +* limitations under the License. +*/ + +#ifndef AXIS2_THREAD_MUTEX_WINDOWS_H +#define AXIS2_THREAD_MUTEX_WINDOWS_H + +#include +#include +#include +typedef enum thread_mutex_type +{ + thread_mutex_critical_section, + thread_mutex_unnested_event, + thread_mutex_nested_mutex +} thread_mutex_type; + +/* handle applies only to unnested_event on all platforms + * and nested_mutex on Win9x only. Otherwise critical_section + * is used for NT nexted mutexes providing optimal performance. + */ +struct axutil_thread_mutex_t +{ + thread_mutex_type type; + HANDLE handle; + CRITICAL_SECTION section; + axutil_allocator_t *allocator; +}; + +#endif /* AXIS2_THREAD_MUTEX_WINDOWS_H */ diff --git a/util/include/platforms/windows/axutil_thread_windows.h b/util/include/platforms/windows/axutil_thread_windows.h new file mode 100644 index 0000000..739b4c2 --- /dev/null +++ b/util/include/platforms/windows/axutil_thread_windows.h @@ -0,0 +1,140 @@ + +/* + * 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 + * limitations under the License. + */ + +#ifndef AXIS2_THREAD_WINDOWS_H +#define AXIS2_THREAD_WINDOWS_H + +#include +#include +#include + +#define SHELL_PATH "cmd.exe" + +typedef HANDLE axis2_os_thread_t; /* Native thread */ + +/* Chosen for us by apr_initialize */ + +struct axutil_thread_t +{ + HANDLE *td; + void *data; + axutil_thread_start_t func; + axis2_bool_t try_exit; +}; + +struct axutil_threadattr_t +{ + int detach; + size_t stacksize; +}; + +struct axutil_threadkey_t +{ + DWORD key; +}; + +struct axutil_thread_once_t +{ + long value; +}; + +AXIS2_EXTERN axutil_threadattr_t *AXIS2_CALL +axutil_threadattr_create( + axutil_allocator_t * allocator); + +/* Destroy the threadattr object */ +AXIS2_EXTERN axis2_status_t AXIS2_CALL +threadattr_cleanup( + void *data); + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axutil_threadattr_detach_set( + axutil_threadattr_t * attr, + axis2_bool_t detached); + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axutil_threadattr_detach_get( + axutil_threadattr_t * attr, + const axutil_env_t * env); + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axutil_threadattr_stacksize_set( + axutil_threadattr_t * attr, + size_t stacksize); + +AXIS2_EXTERN axutil_thread_t *AXIS2_CALL +axutil_thread_create( + axutil_allocator_t * allocator, + axutil_threadattr_t * attr, + axutil_thread_start_t func, + void *data); + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axutil_thread_exit( + axutil_thread_t * thd, + axutil_allocator_t * allocator); + +AXIS2_EXTERN axis2_os_thread_t AXIS2_CALL +axis2_os_thread_current( + void); + +AXIS2_EXTERN int AXIS2_CALL +axis2_os_thread_equal( + axis2_os_thread_t tid1, + axis2_os_thread_t tid2); + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axutil_thread_join( + axutil_thread_t * thd); + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axutil_thread_detach( + axutil_thread_t * thd); + +AXIS2_EXTERN axis2_os_thread_t AXIS2_CALL +axis2_os_thread_get( + axutil_thread_t * thd, + const axutil_env_t * env); + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axutil_thread_key_create( + axutil_threadkey_t * axis2_key); + +AXIS2_EXTERN void *AXIS2_CALL +axutil_thread_getspecific( + axutil_threadkey_t * axis2_key); + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axutil_thread_setspecific( + axutil_threadkey_t * axis2_key, + void *value); + +AXIS2_EXTERN void AXIS2_CALL +axutil_thread_key_free( + axutil_threadkey_t * axis2_key); + +AXIS2_EXTERN axutil_thread_once_t *AXIS2_CALL +axutil_thread_once_init( + axutil_allocator_t * allocator); + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axutil_thread_once( + axutil_thread_once_t * control, + void(*func)(void)); + +#endif /* AXIS2_THREAD_WINDOWS_H */ diff --git a/util/include/platforms/windows/axutil_uuid_gen_windows.h b/util/include/platforms/windows/axutil_uuid_gen_windows.h new file mode 100644 index 0000000..f8c0872 --- /dev/null +++ b/util/include/platforms/windows/axutil_uuid_gen_windows.h @@ -0,0 +1,46 @@ + +/* + * 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_UDDI_GEN_WINDOWS_H +#define AXIS2_UDDI_GEN_WINDOWS_H + +#include + +#ifdef __cplusplus +extern "C" +{ + +#endif /* */ + + /* Function prototypes */ + + + /** + * Generate universally unique id + * @return a char pointer to uuid + */ + AXIS2_EXTERN axis2_char_t * AXIS2_CALL + axutil_platform_uuid_gen( + char *s); + + + /** @} */ +#ifdef __cplusplus +} +#endif /* */ + +#endif /* AXIS2_UDDI_GEN_WINDOWS_H */ diff --git a/util/include/platforms/windows/axutil_windows.h b/util/include/platforms/windows/axutil_windows.h new file mode 100644 index 0000000..a473264 --- /dev/null +++ b/util/include/platforms/windows/axutil_windows.h @@ -0,0 +1,278 @@ + +/* + * 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 + * limitations under the License. + */ + +#ifndef AXIS2_WINDOWS_H +#define AXIS2_WINDOWS_H + +/** + * @file axutil_unix.h + * @brief axis2 unix platform specific interface + */ +#include +#define _WINSOCKAPI_ /* Prevent inclusion of winsock.h in windows.h */ +#include + + /*for minizip uncompression library */ +# include + + /*for file access check */ +#include +#include + + /*for network handling */ +#include +#include +#include +#include + + /* for time */ +#include +#include + + /* get opt */ +#include "axutil_getopt_windows.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** @defgroup axis2_unix Platform Specific + * @ingroup axis2_platforms_unix + * @{ + */ + + /*enum platform_error_codes + { + PLATFORM_ERROR_UUID_NO_ADDRESS = 0, + PLATFORM_ERROR_OUT_OF_MEMORY = 1 + }; */ + + + + AXIS2_EXTERN HMODULE AXIS2_CALL + callLoadLib( + char *lib); + + AXIS2_EXTERN struct tm *AXIS2_CALL + axis2_win_gmtime( + const time_t * timep, + struct tm *result); + + + /* Get the last Error */ + AXIS2_EXTERN void AXIS2_CALL + axutil_win32_get_last_error(axis2_char_t *buff, + unsigned int buf_size); + + /* Get the last Socket Error */ + AXIS2_EXTERN void AXIS2_CALL + axutil_win32_get_last_wsa_error(axis2_char_t *buff, + unsigned int buf_size); + +#define AXUTIL_WIN32_ERROR_BUFSIZE 256 + + /*************************************************************** + * Default paths to shared library/DLLs and files + *************************************************************** + */ + +#define AXIS2_PLATFORM_DEFAULT_DEPLOY_PATH "" + +#define AXIS2_PLATFORM_XMLPARSER_PATH "axis2_parser.dll" +#define AXIS2_PLATFORM_TRANSPORTHTTP_PATH "http_transport.dll" +#define AXIS2_PLATFORM_CHANNEL_PATH "http_channel.dll" +#define AXIS2_PLATFORM_SSLCHANNEL_PATH "Unknown" + +#define AXIS2_PLATFORM_LOG_PATH "" /*/usr/local/axis2/log/axutil_log */ +#define AXIS2_PLATFORM_CLIENTLOG_PATH "" /* /usr/local/axis2/log/axis2_client_log */ +#define AXIS2_PLATFORM_CONFIG_PATH "" /* /etc/axiscpp.conf */ +#define AXIS2_PLATFORM_SECUREINFO "" + + /** + * Resource that contains the configuration + */ +#define AXIS2_CONFIGURATION_RESOURCE "" /* should be set */ + +/* + * ============================================================= + * Library loading and procedure resolution + * ============================================================= + */ +#define DLHandler HINSTANCE +#define RTLD_LAZY 0 /* not sure this is needed? */ + +#define AXIS2_PLATFORM_LOADLIBINIT() +#define AXIS2_PLATFORM_LOADLIB(_lib) /*LoadLibrary(_lib) */ callLoadLib(_lib) +#define AXIS2_PLATFORM_UNLOADLIB FreeLibrary +#define AXIS2_PLATFORM_GETPROCADDR GetProcAddress +#define AXIS2_PLATFORM_LOADLIBEXIT() +#define AXIS2_PLATFORM_LOADLIB_ERROR axutil_win32_get_last_error() + +#define AXIS2_DLHANDLER void* + + +/* + * ============================================================= + * National Language Support + * ============================================================= + */ + +/* + * STRTOASC is to translate single byte 'native' character representation to ASCII + * ASCTOSTR is to translate single byte ascii representation to 'native' character + * CANNOT be used with constants + */ +#define AXIS2_PLATFORM_STRTOASC( x ) ( x ) +#define AXIS2_PLATFORM_ASCTOSTR( x ) ( x ) + +/* + * ============================================================= + * Miscellaneous + * ============================================================= + */ + +#define AXIS2_STRRCHR(x, y) (strrchr(x, y)) + +#define AXIS2_PLATFORM_SLEEP(x) Sleep(0); + +#define AXIS2_SLEEP(x) Sleep((x)*1000) +#define AXIS2_USLEEP(x) Sleep((x)/1000); + + /** + * Get the last error code from the system. + * Please ensure that this is a thread safe implementation + * and that it returns a long + * @return long the last error message for this thread + */ +#define AXIS2_GETLASTERROR GetLastError(); + + /** + * From the last error number get a sensible std::string representing it + * @param errorNumber the error Number you are trying to get a message for + * @return the error message. NOTE: The caller is responsible for deleting the returned string + */ +#define AXIS2_PLATFORM_GET_ERROR_MESSAGE(errorNumber) getPlatformErrorMessage(errorNumber); + + /** + * Platform specific method to obtain current thread ID + */ +#define AXIS2_PLATFORM_GET_THREAD_ID() GetCurrentThreadId() + /** + * type to be used for 64bit integers + */ +#define AXIS2_LONGLONG __int64 + + /** + * Format string to be used in printf for 64bit integers + */ +#define AXIS2_PRINTF_LONGLONG_FORMAT_SPECIFIER "%I64d" +#define AXIS2_PRINTF_LONGLONG_FORMAT_SPECIFIER_CHARS "I64d" + + + /** + * Platform specific path separator char + */ +#define AXIS2_PATH_SEP_CHAR '/' +#define AXIS2_PATH_SEP_STR "/" +#define AXIS2_LIB_PREFIX "" +#define AXIS2_LIB_SUFFIX ".dll" + + /** + * Platform specific time + */ +#define AXIS2_TIME_T time_t + + /** + * Platform specific method to obtain current time in milli seconds + */ +#define AXIS2_PLATFORM_GET_TIME_IN_MILLIS _ftime +#define AXIS2_PLATFORM_TIMEB _timeb + + /** + * Platform specific file handling + */ +#define AXIS2_FOPEN fopen +#define AXIS2_FREAD fread +#define AXIS2_FWRITE fwrite +#define AXIS2_FCLOSE fclose +#define AXIS2_FTELL ftell +#define AXIS2_ACCESS(zpath,imode) _access(zpath,imode) +#define AXIS2_R_OK 04 /* test for read permission */ +#define AXIS2_W_OK 02 /* test for write permission */ +#define AXIS2_X_OK 00 /* test for execute or search permission */ +#define AXIS2_F_OK 00 /* test whether the directories leading to the file can be + searched and the file exists * / + + /** + * windows specific directory handling functions + */ +#define AXIS2_SCANDIR axis2_scandir +#define AXIS2_ALPHASORT alphasort +#define AXIS2_OPENDIR axis2_opendir +#define AXIS2_CLOSEDIR axis2_closedir +#define AXIS2_READDIR axis2_readdir +#define AXIS2_READDIR_R axis2_readdir_r +#define AXIS2_REWINDDIR axis2_rewinddir +#define AXIS2_MKDIR(path,x) _mkdir(path) +#define AXIS2_GETCWD _getcwd +#define AXIS2_CHDIR _chdir + + /** + * network specific functions and defs + */ +#define axis2_socket_t SOCKET + +#define AXIS2_INVALID_SOCKET INVALID_SOCKET +#define AXIS2_INADDR_NONE INADDR_NONE +#define axis2_unsigned_short_t u_short +#define AXIS2_CLOSE_SOCKET(sock) closesocket(sock) +#define AXIS2_CLOSE_SOCKET_ON_EXIT(sock) +#define axis2_socket_len_t int +#define AXIS2_SHUT_WR SD_SEND + + /** + * Platform specific environment variable access method + */ +#define AXIS2_GETENV(_env_var_name) getenv(_env_var_name) + + /** + * minizip functions + */ +#define axis2_fill_win32_filefunc(ffunc) fill_win32_filefunc(ffunc) +#define AXIS2_UNZOPEN2(zipfilename,ffunc) unzOpen2(zipfilename,NULL) + + /** + * handling variable number of arguments (for log.c) + */ + + /** getopt function */ +#define AXIS2_GETOPT axis2_getopt + + /** string functions */ +#define AXIS2_VSNPRINTF _vsnprintf + +#define AXIS2_SNPRINTF _snprintf + +#define axis2_gmtime_r axis2_win_gmtime + + /** @} */ +#ifdef __cplusplus +} +#endif +#endif /* AXIS2_WINDOWS_H */ -- cgit v1.1-32-gdbae