usermode/library/mtm/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 <stdio.h>
00034 #include <stdlib.h>
00035 #include "config.h"
00036 
00037 mtm_config_t mtm_runtime_settings;
00038 config_t     mtm_cfg;
00039 
00040 
00041 static void
00042 config_init_internal(char *config_file)
00043 {
00044         config_init(&mtm_cfg);
00045         config_read_file(&mtm_cfg, config_file);
00046         FOREACH_RUNTIME_CONFIG_SETTING(CONFIG_SETTING_LOOKUP, mtm, &mtm_cfg, &mtm_runtime_settings);
00047 }
00048 
00049 
00050 void
00051 mtm_config_init()
00052 {
00053         char buf[128];
00054         char *config_file;
00055         config_file = getenv("MNEMOSYNE_CONFIG");
00056         if (config_file) {
00057                 config_init_internal(config_file);
00058         } else {
00059                 config_init_internal("mnemosyne.ini");
00060         }
00061 }
00062 
00063 
00064 void
00065 mtm_config_fini()
00066 {
00067         config_destroy(&mtm_cfg);
00068 }
00069 
00070 
00071 void
00072 mtm_config_print(FILE *stream) 
00073 {
00074         CONFIG_GROUP_PRINT(stream, mtm, &mtm_runtime_settings);
00075 }

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