axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sam...@apache.org
Subject svn commit: r581149 - in /webservices/axis2/trunk/c/util: include/axutil_env.h src/env.c
Date Tue, 02 Oct 2007 07:27:18 GMT
Author: samisa
Date: Tue Oct  2 00:27:17 2007
New Revision: 581149

URL: http://svn.apache.org/viewvc?rev=581149&view=rev
Log:
Fixed formatting and logic

Modified:
    webservices/axis2/trunk/c/util/include/axutil_env.h
    webservices/axis2/trunk/c/util/src/env.c

Modified: webservices/axis2/trunk/c/util/include/axutil_env.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/include/axutil_env.h?rev=581149&r1=581148&r2=581149&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/include/axutil_env.h (original)
+++ webservices/axis2/trunk/c/util/include/axutil_env.h Tue Oct  2 00:27:17 2007
@@ -35,11 +35,12 @@
 {
 #endif
 
-    /** @defgroup axis2_util utilities
-      * @ingroup axis2
-      * @{
-      * @}
-      */
+    /** 
+     * @defgroup axis2_util utilities
+     * @ingroup axis2
+     * @{
+     * @}
+     */
 
     struct axutil_env;
     struct axutil_env_ops;
@@ -53,7 +54,7 @@
     /**
       * \brief Axis2 Environment struct
       *
-      * Environment acts as a container for error, log, memory allocator and other
+      * Environment acts as a container for error, log, memory allocator and threading 
       * routines
       */
     typedef struct axutil_env
@@ -77,12 +78,12 @@
     axutil_env_t;
 
     /**
-    * 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
-    * @param log_level log level to be used
-    * @return pointer to the newly created environment struct 
-    */
+     * 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
+     * @param log_level log level to be used, default is debug
+     * @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,
@@ -90,8 +91,8 @@
 
     /**
      * Creates an environment struct. Users of axis2 should not use this function
-    * to create an environment. He should use the other two create functions.
-     * @param allocator pointer to an instance of allocator struct. Must be non-NULL   
+     * to create an environment. He or she should use the other two create functions.
+     * @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
@@ -99,10 +100,9 @@
         axutil_allocator_t * allocator);
 
     /**
-      * Creates an environment struct
-      * @param allocator pointer to an instance of allocator struct. Must be non-NULL
-      * @param error pointer to an instance of error struct. Must be non-NULL.
-      * it would be taken as a flag for no logging.  
+      * 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
@@ -111,11 +111,11 @@
         axutil_error_t * error);
 
     /**
-     * Creates an environment struct
-     * @param allocator pointer to an instance of allocator struct. Must be non-NULL
-     * @param error pointer to an instance of error struct. Must be non-NULL.
-     * @param log pointer to an instance of log struct. May be NULL. If NULL
-     * it would be taken as a flag for no logging.   
+     * 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
@@ -125,16 +125,15 @@
         axutil_log_t * log);
 
     /**
-    * Creates an environment struct
-    * @param allocator pointer to an instance of allocator struct. Must be non-NULL
-    * @param error pointer to an instance of error struct. Must be non-NULL.
-    * @param log pointer to an instance of log struct. May be NULL. If NULL
-    * it would be taken as a flag for no logging.
-    * @param pool pointer to an instance of thread_pool. May be NULL. If NULL
-    * @return pointer to the newly created environment struct 
-    */
+     * 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,
@@ -142,39 +141,37 @@
         axutil_thread_pool_t * pool);
 
     /**
-      * Creates an environment struct
-      * @param allocator pointer to an instance of allocator struct. 
-      * @param error pointer to an instance of error struct. 
-      * Optional, can be NULL. If NULL default error handler would be used.
-      * @param log pointer to an instance of log struct. Optional, can be NULL.
-      * If NULL default log handler would be used.
-      * @param string pointer to an instance of string struct. 
-      * Optional, can be NULL. If NULL default string handler would be used.
-      * @return pointer to the newly created environment struct 
-      */
+     * 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);
 
     /**
-    * Frees the environment
-    * @param env environment to be freed
-    * @param mask bit pattern to according to which the components of the env 
-    * struct are freed
-    *       0x1 - Frees the log
-    *       0x2 - Frees the error
-    *       0x4 - Frees the thread pool
-    *       You can use combinations to free multiple components as well
-    *       Eg : 0x3 frees both log and error
-    * @return status of the operation
-    */
+     * 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
+     *       0x1 - Frees the log
+     *       0x2 - Frees the error
+     *       0x4 - Frees the thread pool
+     *       You can use combinations to free multiple components as well
+     *       Eg : 0x3 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);
 
     /**
-     * Enables logging
+     * Enable or diable 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 elase AXIS2_FAILURE
      */
     AXIS2_EXTERN axis2_status_t AXIS2_CALL
     axutil_env_enable_log(
@@ -182,18 +179,24 @@
         axis2_bool_t enable);
 
     /**
-      * Checks the status code of environment
-      */
+     * Checks the status code of environment stroed 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);
 
-    /*#define AXIS2_ENV_CHECK(env, error_return) \
+/* 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; \
-       } */
-
+           return error_return; \
+       }
+*/
 #define AXIS2_ENV_CHECK(env, error_return)
 
     /** @} */
@@ -203,3 +206,4 @@
 #endif
 
 #endif                          /* AXIS2_ENV_H */
+

Modified: webservices/axis2/trunk/c/util/src/env.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/src/env.c?rev=581149&r1=581148&r2=581149&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/src/env.c (original)
+++ webservices/axis2/trunk/c/util/src/env.c Tue Oct  2 00:27:17 2007
@@ -39,20 +39,25 @@
 
     if (log_file)
         log = axutil_log_create(allocator, NULL, log_file);
-    else
-        log = axutil_log_create_default(allocator);
 
+    /* if log file name was not given or the log could not be create with 
+       given name, create default log */
     if (!log)
         log = axutil_log_create_default(allocator);
 
     thread_pool = axutil_thread_pool_init(allocator);
+    
     env =
         axutil_env_create_with_error_log_thread_pool(allocator, error, log,
                                                      thread_pool);
     if (env->log)
     {
-        env->log->level = log_level;
+        if (AXIS2_LOG_LEVEL_TRACE <= log_level && log_level <= AXIS2_LOG_LEVEL_TRACE)
+            env->log->level = log_level;
+        else
+            env->log->level = AXIS2_LOG_LEVEL_DEBUG; /* default log level is debug
*/
     }
+
     axutil_error_init();
 
     return env;
@@ -64,33 +69,34 @@
 {
     axutil_allocator_t *allocator = NULL;
 
-    if (env && env->allocator)
-        allocator = env->allocator;
+    if (!env)
+        return;
+
+    allocator = env->allocator;
 
-    if (env && env->log)
+    if (env->log)
     {
         AXIS2_LOG_FREE(env->allocator, env->log);
-        env->log = NULL;
     }
-    if (env && env->error)
+    
+    if (env->error)
     {
         AXIS2_ERROR_FREE(env->error);
-        env->error = NULL;
     }
-    if (env && env->thread_pool)
+    
+    if (env->thread_pool)
     {
         axutil_thread_pool_free(env->thread_pool);
-        env->thread_pool = NULL;
     }
-    if (env && env->allocator)
+    
+    if (env->allocator)
     {
         AXIS2_FREE(env->allocator, env);
-        env = NULL;
     }
+    
     if (allocator)
     {
         AXIS2_FREE(allocator, allocator);
-        allocator = NULL;
     }
 
     return;
@@ -100,30 +106,32 @@
 axutil_env_create(
     axutil_allocator_t * allocator)
 {
-    axutil_env_t *environment;
-    axutil_log_t *log = NULL;
+    axutil_env_t *env;
 
     if (!allocator)
         return NULL;
 
-    environment =
+    env =
         (axutil_env_t *) AXIS2_MALLOC(allocator, sizeof(axutil_env_t));
 
-    if (!environment)
+    if (!env)
         return NULL;
 
-    log = axutil_log_create_default(allocator);
+    memset(env, 0, sizeof(axutil_env_t));
+
+    env->log = axutil_log_create_default(allocator);
 
-    environment->allocator = allocator;
+    env->allocator = allocator;
 
     /* Create default error */
-    environment->error = axutil_error_create(allocator);
-    if (!environment->error)
+    env->error = axutil_error_create(allocator);
+    if (!env->error)
+    {
+        AXIS2_FREE(allocator, env);
         return NULL;
-    environment->log = log;
-    environment->thread_pool = NULL;
-    return environment;
-
+    }
+    
+    return env;
 }
 
 AXIS2_EXTERN axutil_env_t *AXIS2_CALL
@@ -140,34 +148,36 @@
     axutil_error_t * error,
     axutil_log_t * log)
 {
-    axutil_env_t *environment;
+    axutil_env_t *env;
     if (!allocator)
         return NULL;
     if (!error)
         return NULL;
 
-    environment =
+    env =
         (axutil_env_t *) AXIS2_MALLOC(allocator, sizeof(axutil_env_t));
 
-    if (!environment)
+    if (!env)
         return NULL;
 
-    environment->allocator = allocator;
-    environment->error = error;
+    memset(env, 0, sizeof(axutil_env_t));
+
+    env->allocator = allocator;
+    env->error = error;
 
     if (!log)
     {
-        environment->log_enabled = AXIS2_FALSE;
+        env->log_enabled = AXIS2_FALSE;
     }
     else
     {
-        environment->log_enabled = AXIS2_TRUE;
-        environment->log = log;
+        env->log_enabled = AXIS2_TRUE;
+        env->log = log;
     }
 
-    environment->thread_pool = NULL;
     axutil_error_init();
-    return environment;
+
+    return env;
 }
 
 AXIS2_EXTERN axutil_env_t *AXIS2_CALL
@@ -177,39 +187,40 @@
     axutil_log_t * log,
     axutil_thread_pool_t * pool)
 {
-    axutil_env_t *environment;
-    if (!allocator)
-        return NULL;
-    if (!error)
-        return NULL;
-    if (!pool)
+    axutil_env_t *env;
+    if (!allocator || !error || !pool)
         return NULL;
 
-    environment =
+    env =
         (axutil_env_t *) AXIS2_MALLOC(allocator, sizeof(axutil_env_t));
 
-    if (!environment)
+    if (!env)
         return NULL;
+    
+    memset(env, 0, sizeof(axutil_env_t));
 
-    environment->allocator = allocator;
-    environment->error = error;
-    environment->thread_pool = pool;
+    env->allocator = allocator;
+    env->error = error;
+    env->log = log;
+    env->thread_pool = pool;
 
-    if (!log)
-        environment->log_enabled = AXIS2_FALSE;
-    environment->log_enabled = AXIS2_TRUE;
-    environment->log = log;
+    if (env->log)
+        env->log_enabled = AXIS2_FALSE;
+    else
+        env->log_enabled = AXIS2_TRUE;
+    
 
-    return environment;
+    return env;
 }
 
 AXIS2_EXTERN axis2_status_t AXIS2_CALL
 axutil_env_check_status(
     const axutil_env_t * env)
 {
-    AXIS2_ENV_CHECK(env, AXIS2_CRITICAL_FAILURE);
+    if (env && env->error)
+        return AXIS2_ERROR_GET_STATUS_CODE(env->error);
 
-    return AXIS2_ERROR_GET_STATUS_CODE(env->error);
+    return AXIS2_CRITICAL_FAILURE;
 }
 
 AXIS2_EXTERN axis2_status_t AXIS2_CALL
@@ -217,11 +228,13 @@
     axutil_env_t * env,
     axis2_bool_t enable)
 {
-    AXIS2_ENV_CHECK(env, AXIS2_CRITICAL_FAILURE);
-
-    env->log_enabled = enable;
+    if (env)
+    {
+        env->log_enabled = enable;
+        return AXIS2_SUCCESS;
+    }
 
-    return AXIS2_SUCCESS;
+    return AXIS2_CRITICAL_FAILURE;
 }
 
 AXIS2_EXTERN void AXIS2_CALL
@@ -241,8 +254,10 @@
     {
         axutil_thread_pool_free(env->thread_pool);
     }
+
     if (env)
         AXIS2_FREE(env->allocator, env);
 
     return;
 }
+



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message