usermode/library/mcore/src/config.c

00001 /*
00002     Copyright (C) 2011 Computer Sciences Department, 
00003     University of Wisconsin -- Madison
00004 
00005     ----------------------------------------------------------------------
00006 
00007     This file is part of Mnemosyne: Lightweight Persistent Memory, 
00008     originally developed at the University of Wisconsin -- Madison.
00009 
00010     Mnemosyne was originally developed primarily by Haris Volos
00011     with contributions from Andres Jaan Tack.
00012 
00013     ----------------------------------------------------------------------
00014 
00015     Mnemosyne is free software; you can redistribute it and/or
00016     modify it under the terms of the GNU General Public License
00017     as published by the Free Software Foundation, version 2
00018     of the License.
00019  
00020     Mnemosyne is distributed in the hope that it will be useful,
00021     but WITHOUT ANY WARRANTY; without even the implied warranty of
00022     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023     GNU General Public License for more details.
00024 
00025     You should have received a copy of the GNU General Public License
00026     along with this program; if not, write to the Free Software
00027     Foundation, Inc., 51 Franklin Street, Fifth Floor, 
00028     Boston, MA  02110-1301, USA.
00029 
00030 ### END HEADER ###
00031 */
00032 
00033 #include <stdlib.h>
00034 #include <stdio.h>
00035 #include "config.h"
00036 
00037 mcore_config_t mcore_runtime_settings;
00038 config_t       mcore_cfg;
00039 
00040 
00041 static void
00042 config_init_internal(char *config_file)
00043 {
00044         config_init(&mcore_cfg);
00045         config_read_file(&mcore_cfg, config_file);
00046         FOREACH_RUNTIME_CONFIG_SETTING(CONFIG_SETTING_LOOKUP, mcore, &mcore_cfg, &mcore_runtime_settings);
00047 }
00048 
00049 
00050 void
00051 mcore_config_init()
00052 {
00053         char *config_file;
00054         config_file = getenv("MNEMOSYNE_CONFIG");
00055         if (config_file) {
00056                 config_init_internal(config_file);
00057         } else {
00058                 config_init_internal("mnemosyne.ini");
00059         }
00060 }
00061 
00062 void
00063 mcore_config_fini()
00064 {
00065 
00066         config_destroy(&mcore_cfg);
00067 }
00068 
00069 void
00070 mcore_config_print(FILE *stream) 
00071 {
00072         CONFIG_GROUP_PRINT(stream, mcore, &mcore_runtime_settings);
00073 }

Generated on Sat Apr 23 11:43:35 2011 for Mnemosyne by  doxygen 1.4.7