- renamed logger_manager method get_logger to create_logger
authorMartin Willi <martin@strongswan.org>
Fri, 11 Nov 2005 13:12:23 +0000 (13:12 -0000)
committerMartin Willi <martin@strongswan.org>
Fri, 11 Nov 2005 13:12:23 +0000 (13:12 -0000)
Source/charon/logger_manager.c
Source/charon/logger_manager.h
Source/charon/parser.c
Source/charon/testcases/generator_test.c
Source/charon/testcases/parser_test.c
Source/charon/thread_pool.c

index 80721bb..37fd146 100644 (file)
@@ -89,16 +89,17 @@ struct loggers_entry_s{
 };
 
 /**
- * Implements logger_manager_t-function get_logger.
- * @see logger_manager_s.get_logger.
+ * Implements logger_manager_t-function create_logger.
+ * @see logger_manager_s.create_logger.
  */
-static status_t get_logger (private_logger_manager_t *this, logger_context_t context, logger_t **logger,char * name)
+static logger_t *create_logger(private_logger_manager_t *this, logger_context_t context, char * name)
 {
        
        char * context_name;
        FILE * output = NULL;
        char buffer[MAX_LOGGER_NAME];
        loggers_entry_t *entry;
+       logger_t *logger;
        logger_level_t logger_level = this->public.get_logger_level(&(this->public),context);
 
        switch(context)
@@ -144,42 +145,42 @@ static status_t get_logger (private_logger_manager_t *this, logger_context_t con
        {
                snprintf(buffer, MAX_LOGGER_NAME, "%s - %s",context_name,name);
                        /* create logger with default log_level */
-               *logger = logger_create(buffer,logger_level,output);
+               logger = logger_create(buffer,logger_level,output);
        }
        else
        {
-               *logger = logger_create(context_name,logger_level,output);
+               logger = logger_create(context_name,logger_level,output);
        }
        
        
-       if (*logger == NULL)
+       if (logger == NULL)
        {
                pthread_mutex_unlock(&(this->mutex));           
-               return OUT_OF_RES;
+               return NULL;
        }
 
        entry = allocator_alloc_thing(loggers_entry_t);
        
        if (entry == NULL)
        {
-               (*logger)->destroy(*logger);
+               logger->destroy(logger);
                pthread_mutex_unlock(&(this->mutex));           
-               return OUT_OF_RES;
+               return NULL;
        }
 
        entry->context = context;
-       entry->logger = *logger;
+       entry->logger = logger;
 
        if (this->loggers->insert_last(this->loggers,entry) != SUCCESS)
        {
                allocator_free(entry);
-               (*logger)->destroy(*logger);
+               logger->destroy(logger);
                pthread_mutex_unlock(&(this->mutex));           
-               return OUT_OF_RES;
+               return NULL;
        }
 
        pthread_mutex_unlock(&(this->mutex));
-       return SUCCESS;
+       return logger;
        
 }
 
@@ -426,7 +427,7 @@ logger_manager_t *logger_manager_create(logger_level_t default_log_level)
                return NULL;    
        }
 
-       this->public.get_logger = (status_t(*)(logger_manager_t*,logger_context_t context, logger_t **logger, char *))get_logger;
+       this->public.create_logger = (logger_t *(*)(logger_manager_t*,logger_context_t context, char *))create_logger;
        this->public.destroy_logger = (status_t(*)(logger_manager_t*,logger_t *logger))destroy_logger;
        this->public.destroy = (status_t(*)(logger_manager_t*))destroy;
        this->public.get_logger_level = (logger_level_t (*)(logger_manager_t *, logger_context_t)) get_logger_level;
index 59c88d1..4a27077 100644 (file)
@@ -67,10 +67,10 @@ struct logger_manager_s {
         * @param name                  name for the new logger. Context name is already included 
         *                                              and has not to be specified.
         * @return
-        *                                              - SUCCESS
-        *                                              - OUT_OF_RES
+        *                                              - logger_t on SUCCESS
+        *                                              - NULL otherwise
         */
-       status_t (*get_logger) (logger_manager_t *this, logger_context_t context, logger_t **logger, char *name);
+       logger_t *(*create_logger) (logger_manager_t *this, logger_context_t context, char *name);
        
        
        /**
index b666379..35c9dd7 100644 (file)
@@ -401,7 +401,7 @@ parser_t *parser_create(payload_info_t **payload_infos)
                return NULL;
        }
        
-       global_logger_manager->get_logger(global_logger_manager,PARSER,&(this->logger), NULL);
+       this->logger = global_logger_manager->create_logger(global_logger_manager,PARSER, NULL);
        
        if (this->logger == NULL)
        {
index 380ae55..98903c9 100644 (file)
@@ -67,7 +67,7 @@ void test_generator_with_header_payload(tester_t *tester)
        status_t status;
        logger_t *logger;
        
-       global_logger_manager->get_logger(global_logger_manager,TESTER,&logger,"header payload");
+       logger = global_logger_manager->create_logger(global_logger_manager,TESTER,"header payload");
        
        header_data.initiator_spi = 1;
        header_data.responder_spi = 2;
index b3ad315..9ad77fc 100644 (file)
@@ -48,7 +48,7 @@ void test_parser_with_header_payload(tester_t *tester)
        
        logger_t *logger;
        
-       global_logger_manager->get_logger(global_logger_manager,TESTER,&logger,"header payload");
+       logger = global_logger_manager->create_logger(global_logger_manager,TESTER, "header payload");
        
        u_int8_t test_bytes[] = {
                0x00,0x00,0x00,0x00,
index 532587e..c73317a 100644 (file)
@@ -143,7 +143,7 @@ thread_pool_t *thread_pool_create(size_t pool_size)
                allocator_free(this);
                return NULL;
        }       
-       global_logger_manager->get_logger(global_logger_manager,THREAD_POOL,&(this->logger),NULL);
+       this->logger = global_logger_manager->create_logger(global_logger_manager,THREAD_POOL,NULL);
        if (this->threads == NULL)
        {
                allocator_free(this);