00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef CONFIG_H
00017 #define CONFIG_H
00018 #include<os.h>
00019 class ConfigValues
00020 {
00021 public:
00022
00023 int pageSize;
00024 int maxProcs;
00025 long maxSysSize;
00026 long maxDbSize;
00027 int sysDbKey;
00028 int userDbKey;
00029 char logFile[MAX_FILE_PATH_LEN];
00030 char dbFile[MAX_FILE_PATH_LEN];
00031 long mapAddr;
00032 int mutexSecs;
00033 int mutexUSecs;
00034 int mutexRetries;
00035 int lockSecs;
00036 int lockUSecs;
00037 int lockRetries;
00038
00039 bool isCache;
00040 char dsn[IDENTIFIER_LENGTH];
00041 char tableConfigFile[MAX_FILE_PATH_LEN];
00042 bool isTwoWay;
00043 int cacheWaitSecs;
00044
00045 bool isReplication;
00046 char replConfigFile[MAX_FILE_PATH_LEN];
00047 int networkID;
00048 int cacheNetworkID;
00049
00050 long logStoreSize;
00051 int nwResponseTimeout;
00052 int nwConnectTimeout;
00053
00054 ConfigValues()
00055 {
00056 pageSize = 8192;
00057 maxProcs = 20;
00058 maxSysSize = 10485760;
00059 maxDbSize = 104857600;
00060 sysDbKey = 2222;
00061 userDbKey = 5555;
00062 strcpy(logFile, "/tmp/log/log.out");
00063 strcpy(dbFile, "/tmp/csql/csql.db");
00064 mapAddr=400000000;
00065 mutexSecs=0;
00066 mutexUSecs=10;
00067 mutexRetries = 10;
00068 lockSecs =0;
00069 lockUSecs = 10;
00070 lockRetries = 10;
00071 isCache = false;
00072 cacheNetworkID =-1;
00073 strcpy(dsn, "myodbc3");
00074 strcpy(tableConfigFile, "/tmp/csql/csqltable.conf");
00075 isReplication = false;
00076 strcpy(replConfigFile, "/tmp/csql/csqlnw.conf");
00077 logStoreSize = 10485760;
00078 networkID=-1;
00079 nwResponseTimeout=3;
00080 nwConnectTimeout=5;
00081 isTwoWay=true;
00082 cacheWaitSecs =10;
00083 }
00084 };
00085
00086 class Config
00087 {
00088 ConfigValues cVal;
00089 int readLine(FILE *fp, char * buffer);
00090 int storeKeyVal(char *key, char *val);
00091 int validateValues();
00092
00093 public:
00094 int readAllValues(char *filename);
00095 void print();
00096
00097 inline int getPageSize() { return cVal.pageSize; }
00098 inline int getMaxProcs() { return cVal.maxProcs; }
00099 inline long getMaxSysDbSize() { return cVal.maxSysSize; }
00100 inline long getMaxDbSize() { return cVal.maxDbSize; }
00101 inline int getSysDbKey() { return cVal.sysDbKey; }
00102 inline int getUserDbKey() { return cVal.userDbKey; }
00103 inline char* getLogFile() { return cVal.logFile; }
00104 inline char* getDbFile() { return cVal.dbFile; }
00105 inline long getMapAddress() { return cVal.mapAddr; }
00106 inline int getMutexSecs() { return cVal.mutexSecs; }
00107 inline int getMutexUSecs() { return cVal.mutexUSecs; }
00108 inline int getMutexRetries() { return cVal.mutexRetries; }
00109 inline int getLockSecs() { return cVal.lockSecs; }
00110 inline int getLockUSecs() { return cVal.lockUSecs; }
00111 inline int getLockRetries() { return cVal.lockRetries; }
00112 inline bool useCache() { return cVal.isCache; }
00113 inline char* getDSN() { return cVal.dsn; }
00114 inline char* getTableConfigFile() { return cVal.tableConfigFile; }
00115 inline bool useReplication() { return cVal.isReplication; }
00116 inline char* getReplConfigFile() { return cVal.replConfigFile; }
00117 inline long getMaxLogStoreSize() { return cVal.logStoreSize; }
00118 inline int getNetworkID() { return cVal.networkID; }
00119 inline int getCacheNetworkID() { return cVal.cacheNetworkID; }
00120 inline int getNetworkResponseTimeout() { return cVal.nwResponseTimeout; }
00121 inline int getNetworkConnectTimeout() { return cVal.nwConnectTimeout; }
00122 inline bool useTwoWayCache() { return cVal.isTwoWay; }
00123 inline int getCacheWaitSecs() { return cVal.cacheWaitSecs; }
00124 };
00125
00126 class Conf
00127 {
00128 public:
00129 static Config config;
00130 };
00131
00132
00133 #endif