cf_rcfile.h

Go to the documentation of this file.
00001 /*
00002  !concept {:name => "Lua based config files",
00003    :desc => "Implementing a Lua language based configuration file, using a Lua runtime instance for in-memory storage."}
00004 */
00005 
00006 #ifndef __cf_rcfile_h__
00007 #define __cf_rcfile_h__
00008 
00009 #include "application_config.h"
00010 
00011 #if __FEATURE_RCFILE__
00012 
00013 #include <glib.h>
00014 
00015 #ifdef __cplusplus
00016 extern "C" {
00017 #endif
00018 
00019   typedef struct _cf_RcFile cf_RcFile;
00020 
00021   /** Reads in the configuration from a static configuration file.
00022       A parse error or parameter value validity
00023       checking failure will cause an error return.
00024       Unrecognized settings shall be ignored.
00025       No configuration file shall cause the default static
00026       configuration information to be returned.
00027 
00028       As this object only contains fixed data (after initialization)
00029       accessing it is by nature thread safe.
00030   */
00031   cf_RcFile* cf_RcFile_new(GError** error);
00032   
00033   /** Frees any resources allocated for caching the static
00034       configuration information. */
00035   void cf_RcFile_destroy(cf_RcFile* self);
00036 
00037   int cf_RcFile_vm_id(cf_RcFile* self);
00038 
00039   int cf_RcFile_get_int_or(cf_RcFile* self, const char* name, int dval);
00040   gboolean cf_RcFile_get_bool_or(cf_RcFile* self, const char* name, gboolean dval);
00041 
00042   // Note that you must strdup any strings that must be longer lived.
00043   const char* cf_RcFile_get_str_or(cf_RcFile* self, const char* name, const char* dval);
00044   const char* cf_RcFile_get_str_maybe(cf_RcFile* self, const char* name);
00045 
00046   // The configuration parameter value getters must be consistently
00047   // named, as we have macros assuming so.
00048 #define cf_RcFile_get_compress_logs(_self) cf_RcFile_get_bool_or(_self, "compress_logs", FALSE)
00049 #define cf_RcFile_get_log_sms_body(_self) cf_RcFile_get_bool_or(_self, "log_sms_body", FALSE)
00050 #define cf_RcFile_get_username(_self) cf_RcFile_get_str_or(_self, "username", __USERNAME__)
00051 #define cf_RcFile_get_upload_url(_self) cf_RcFile_get_str_maybe(_self, "upload_url")
00052 #define cf_RcFile_get_remokon_host(_self) cf_RcFile_get_str_maybe(_self, "remokon_host")
00053 #define cf_RcFile_get_remokon_port(_self) cf_RcFile_get_int_or(_self, "remokon_port", 5222)
00054 #define cf_RcFile_get_remokon_password(_self) cf_RcFile_get_str_maybe(_self, "remokon_password")
00055 #define cf_RcFile_get_jid(_self) cf_RcFile_get_str_maybe(_self, "jid")
00056 #define cf_RcFile_get_iap(_self) cf_RcFile_get_int_or(_self, "iap", -1)
00057 #define cf_RcFile_get_database_dir(_self) cf_RcFile_get_str_or(_self, "database_dir", DATABASE_DIR_DEFAULT)
00058 #define cf_RcFile_get_database_disk_threshold(_self) cf_RcFile_get_int_or(_self, "database_disk_threshold", DATABASE_DISK_THRESHOLD_DEFAULT)
00059 #define cf_RcFile_get_mcc(_self) cf_RcFile_get_int_or(_self, "mcc", -1)
00060 #define cf_RcFile_get_operator_name(_self) cf_RcFile_get_str_maybe(_self, "operator_name")
00061 
00062 #ifdef __cplusplus
00063 } /* extern "C" */
00064 #endif
00065 
00066 #endif /* __FEATURE_RCFILE__ */
00067 
00068 #endif /* __cf_rcfile_h__ */
00069 
00070 /**
00071 
00072 cf_rcfile.h
00073 
00074 Copyright 2009 Helsinki Institute for Information Technology (HIIT)
00075 and the authors. All rights reserved.
00076 
00077 Authors: Tero Hasu <tero.hasu@hut.fi>
00078 
00079 Permission is hereby granted, free of charge, to any person
00080 obtaining a copy of this software and associated documentation files
00081 (the "Software"), to deal in the Software without restriction,
00082 including without limitation the rights to use, copy, modify, merge,
00083 publish, distribute, sublicense, and/or sell copies of the Software,
00084 and to permit persons to whom the Software is furnished to do so,
00085 subject to the following conditions:
00086 
00087 The above copyright notice and this permission notice shall be
00088 included in all copies or substantial portions of the Software.
00089 
00090 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00091 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00092 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00093 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
00094 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
00095 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
00096 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
00097 SOFTWARE.
00098 
00099  **/

ContextLogger2—ContextLogger2 Logger Daemon Internals—Generated on Mon May 2 13:49:52 2011 by Doxygen 1.6.1