You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by sa...@apache.org on 2007/10/03 06:08:20 UTC

svn commit: r581486 - /webservices/axis2/trunk/c/util/src/env.c

Author: samisa
Date: Tue Oct  2 21:08:19 2007
New Revision: 581486

URL: http://svn.apache.org/viewvc?rev=581486&view=rev
Log:
Fixed more formatting

Modified:
    webservices/axis2/trunk/c/util/src/env.c

Modified: webservices/axis2/trunk/c/util/src/env.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/src/env.c?rev=581486&r1=581485&r2=581486&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/src/env.c (original)
+++ webservices/axis2/trunk/c/util/src/env.c Tue Oct  2 21:08:19 2007
@@ -24,85 +24,6 @@
 #include <axutil_string.h>
 
 AXIS2_EXTERN axutil_env_t *AXIS2_CALL
-axutil_env_create_all(
-    const axis2_char_t * log_file,
-    const axutil_log_levels_t log_level)
-{
-    axutil_env_t *env = NULL;
-    axutil_error_t *error = NULL;
-    axutil_log_t *log = NULL;
-    axutil_allocator_t *allocator = NULL;
-    axutil_thread_pool_t *thread_pool = NULL;
-
-    allocator = axutil_allocator_init(NULL);
-    error = axutil_error_create(allocator);
-
-    if (log_file)
-        log = axutil_log_create(allocator, NULL, log_file);
-
-    /* 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)
-    {
-        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;
-}
-
-AXIS2_EXTERN void AXIS2_CALL
-axutil_env_free(
-    axutil_env_t * env)
-{
-    axutil_allocator_t *allocator = NULL;
-
-    if (!env)
-        return;
-
-    allocator = env->allocator;
-
-    if (env->log)
-    {
-        AXIS2_LOG_FREE(env->allocator, env->log);
-    }
-    
-    if (env->error)
-    {
-        AXIS2_ERROR_FREE(env->error);
-    }
-    
-    if (env->thread_pool)
-    {
-        axutil_thread_pool_free(env->thread_pool);
-    }
-    
-    if (env->allocator)
-    {
-        AXIS2_FREE(env->allocator, env);
-    }
-    
-    if (allocator)
-    {
-        AXIS2_FREE(allocator, allocator);
-    }
-
-    return;
-}
-
-AXIS2_EXTERN axutil_env_t *AXIS2_CALL
 axutil_env_create(
     axutil_allocator_t * allocator)
 {
@@ -111,19 +32,20 @@
     if (!allocator)
         return NULL;
 
-    env =
-        (axutil_env_t *) AXIS2_MALLOC(allocator, sizeof(axutil_env_t));
+    env = (axutil_env_t *) AXIS2_MALLOC(allocator, sizeof(axutil_env_t));
 
     if (!env)
         return NULL;
 
     memset(env, 0, sizeof(axutil_env_t));
 
-    env->log = axutil_log_create_default(allocator);
-
     env->allocator = allocator;
+    
+    env->log = axutil_log_create_default(allocator);
+    env->log->level = AXIS2_LOG_LEVEL_DEBUG; /* default log level is debug */
+    env->log_enabled = AXIS2_TRUE;
 
-    /* Create default error */
+    /* Create default error struct */
     env->error = axutil_error_create(allocator);
     if (!env->error)
     {
@@ -131,37 +53,28 @@
         return NULL;
     }
     
+    /* Call error init to fill in the axutil_error_messages array.
+       This array holds the error messages with respect to error codes */
+    axutil_error_init();
+    
     return env;
 }
 
 AXIS2_EXTERN axutil_env_t *AXIS2_CALL
-axutil_env_create_with_error(
-    axutil_allocator_t * allocator,
-    axutil_error_t * error)
-{
-    return axutil_env_create_with_error_log(allocator, error, NULL);
-}
-
-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)
 {
     axutil_env_t *env;
-    if (!allocator)
-        return NULL;
-    if (!error)
+    if (!allocator || !error)
         return NULL;
 
-    env =
-        (axutil_env_t *) AXIS2_MALLOC(allocator, sizeof(axutil_env_t));
+    env = axutil_env_create(allocator);
 
     if (!env)
         return NULL;
 
-    memset(env, 0, sizeof(axutil_env_t));
-
     env->allocator = allocator;
     env->error = error;
 
@@ -172,15 +85,26 @@
     else
     {
         env->log_enabled = AXIS2_TRUE;
-        env->log = log;
+        if (env->log) /* free the default log */
+        {
+            AXIS2_LOG_FREE(env->allocator, env->log);
+        }
+        env->log = log; /* set the given log */
     }
 
-    axutil_error_init();
 
     return env;
 }
 
 AXIS2_EXTERN axutil_env_t *AXIS2_CALL
+axutil_env_create_with_error(
+    axutil_allocator_t * allocator,
+    axutil_error_t * error)
+{
+    return axutil_env_create_with_error_log(allocator, error, NULL);
+}
+
+AXIS2_EXTERN axutil_env_t *AXIS2_CALL
 axutil_env_create_with_error_log_thread_pool(
     axutil_allocator_t * allocator,
     axutil_error_t * error,
@@ -191,24 +115,71 @@
     if (!allocator || !error || !pool)
         return NULL;
 
-    env =
-        (axutil_env_t *) AXIS2_MALLOC(allocator, sizeof(axutil_env_t));
+    env = axutil_env_create(allocator);
 
     if (!env)
         return NULL;
     
-    memset(env, 0, sizeof(axutil_env_t));
-
     env->allocator = allocator;
     env->error = error;
+    
+    if (env->log) /* free the default log before setting the given log */
+    {
+        AXIS2_LOG_FREE(env->allocator, env->log);
+    }
     env->log = log;
+    
     env->thread_pool = pool;
 
     if (env->log)
-        env->log_enabled = AXIS2_FALSE;
-    else
         env->log_enabled = AXIS2_TRUE;
+    else
+        env->log_enabled = AXIS2_FALSE;
+
+    return env;
+}
+
+AXIS2_EXTERN axutil_env_t *AXIS2_CALL
+axutil_env_create_all(
+    const axis2_char_t * log_file,
+    const axutil_log_levels_t log_level)
+{
+    axutil_env_t *env = NULL;
+    axutil_error_t *error = NULL;
+    axutil_log_t *log = NULL;
+    axutil_allocator_t *allocator = NULL;
+    axutil_thread_pool_t *thread_pool = NULL;
+
+    allocator = axutil_allocator_init(NULL);
+    error = axutil_error_create(allocator);
+
+    if (log_file)
+    {
+        log = axutil_log_create(allocator, NULL, log_file);
+    }
     
+    /* 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)
+    {
+        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 */
+        }
+    }
 
     return env;
 }
@@ -238,23 +209,67 @@
 }
 
 AXIS2_EXTERN void AXIS2_CALL
+axutil_env_free(
+    axutil_env_t * env)
+{
+    axutil_allocator_t *allocator = NULL;
+
+    if (!env)
+        return;
+
+    allocator = env->allocator;
+
+    if (env->log)
+    {
+        AXIS2_LOG_FREE(env->allocator, env->log);
+    }
+    
+    if (env->error)
+    {
+        AXIS2_ERROR_FREE(env->error);
+    }
+    
+    if (env->thread_pool)
+    {
+        axutil_thread_pool_free(env->thread_pool);
+    }
+    
+    if (env->allocator)
+    {
+        AXIS2_FREE(env->allocator, env);
+    }
+    
+    if (allocator)
+    {
+        AXIS2_FREE(allocator, allocator);
+    }
+
+    return;
+}
+
+AXIS2_EXTERN void AXIS2_CALL
 axutil_env_free_masked(
     axutil_env_t * env,
     char mask)
 {
+    if (!env)
+        return;
+
     if (mask & 0x1)
     {
         AXIS2_LOG_FREE(env->allocator, env->log);
     }
+    
     if (mask & 0x2)
     {
         AXIS2_ERROR_FREE(env->error);
     }
+    
     if (mask & 0x4)
     {
         axutil_thread_pool_free(env->thread_pool);
     }
-
+    
     if (env)
         AXIS2_FREE(env->allocator, env);
 



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