changes for open source mmdb build
[csql.git] / include / Config.h
blob11cac25f901546fe31df5d6b1eea020753cdfefc
1 /***************************************************************************
2 * *
3 * Copyright (C) Lakshya Solutions Ltd. All rights reserved. *
4 * *
5 ***************************************************************************/
7 #ifndef CONFIG_H
8 #define CONFIG_H
9 #include<os.h>
10 #include<Util.h>
12 enum CacheMode {
13 SYNC_MODE=0,
14 ASYNC_MODE=1,
15 UNKNOWN=100
17 enum TDBInfo
19 mysql=0,
20 postgres
23 class ConfigValues
25 public:
26 //All the members of the configuration file
27 char logFile[MAX_FILE_PATH_LEN];
28 char dbFile[MAX_FILE_PATH_LEN];
29 char tableConfigFile[MAX_FILE_PATH_LEN];
30 char dsConfigFile[MAX_FILE_PATH_LEN];// DSN Config file
31 char stderrFile[MAX_FILE_PATH_LEN];
32 char conflResoFile[MAX_FILE_PATH_LEN];
34 bool isDurable;
35 bool mmap;
36 bool isCsqlSqlServer;
37 bool isCache;
38 bool isTwoWay;
40 int siteID;
41 int sysDbKey;
42 int userDbKey;
43 long maxSysSize;
44 long maxDbSize;
45 int pageSize;
46 int maxProcs;
48 long mapAddr;
50 int mutexSecs;
51 int mutexUSecs;
52 int mutexRetries;
53 int lockSecs;
54 int lockUSecs;
55 int lockRetries;
56 int logLevel;
58 int durableMode;
59 char dsn[IDENTIFIER_LENGTH];
60 CacheMode mode;
61 int cacheWaitSecs;
63 int port;
64 int nwResponseTimeout;
65 int nwConnectTimeout;
67 int msgKey;
68 int asyncMsgMax;
69 int shmKeyForId;
70 long maxQueueLogs;
71 int noOfProcessors;
73 ConfigValues()
75 strcpy(logFile, "/tmp/log/log.out");
76 strcpy(dbFile, "/tmp/csql/db");
77 strcpy(tableConfigFile, "/tmp/csql/csqltable.conf");
78 strcpy(dsConfigFile,"/tmp/csql/csqlds.conf"); // DSN Config file
79 strcpy(stderrFile, "stderr");
80 strcpy(conflResoFile, "/tmp/csql/ConflResoFile.txt");
82 isDurable = false;
83 mmap = false;
84 isCsqlSqlServer = false;
85 isCache = false;
86 isTwoWay=false;
88 siteID=1;
89 sysDbKey = 2222;
90 userDbKey = 5555;
91 maxSysSize = 10485760;
92 maxDbSize = 104857600;
93 pageSize = 8192;
94 maxProcs = 20;
96 mapAddr=400000000;
98 mutexSecs=0;
99 mutexUSecs=10;
100 mutexRetries = 10;
101 lockSecs =0;
102 lockUSecs = 10;
103 lockRetries = 10;
104 logLevel = 0;
106 durableMode=1;
107 strcpy(dsn,"myodbc3");
108 mode = SYNC_MODE;
109 cacheWaitSecs =10;
111 port = 5678;
112 nwResponseTimeout=3;
113 nwConnectTimeout=5;
114 msgKey=-1;
115 asyncMsgMax = 8192; //default for linux
116 shmKeyForId = -1;
117 maxQueueLogs = 100;
118 noOfProcessors = 1;
122 class Config
124 ConfigValues cVal;
125 bool isLoaded;
126 int readLine(FILE *fp, char * buffer);
127 int storeKeyVal(char *key, char *val);
128 int validateValues();
130 public:
131 Config() { isLoaded = false; }
132 int readAllValues(char *filename);
133 void print();
134 void logConfig();
135 inline int getPageSize() { return cVal.pageSize; }
136 inline int getMaxProcs() { return cVal.maxProcs; }
137 inline long getMaxSysDbSize() { return cVal.maxSysSize; }
138 inline long getMaxDbSize() { return cVal.maxDbSize; }
139 inline int getSysDbKey() { return cVal.sysDbKey; }
140 inline int getUserDbKey() { return cVal.userDbKey; }
141 inline bool useMmap() { return cVal.mmap; }
142 inline char* getLogFile() { return cVal.logFile; }
143 inline char* getDbFile() { return cVal.dbFile; }
144 inline long getMapAddress() { return cVal.mapAddr; }
145 inline int getMutexSecs() { return cVal.mutexSecs; }
146 inline int getMutexUSecs() { return cVal.mutexUSecs; }
147 inline int getMutexRetries() { return cVal.mutexRetries; }
148 inline int getLockSecs() { return cVal.lockSecs; }
149 inline int getLockUSecs() { return cVal.lockUSecs; }
150 inline int getLockRetries() { return cVal.lockRetries; }
151 inline int getSiteID(){ return cVal.siteID;}
152 inline bool useCache() { return cVal.isCache; }
153 inline int getCacheMode() { return (int) cVal.mode; }
154 inline char* getDSN() { return cVal.dsn; }
155 inline char* getDsConfigFile() { return cVal.dsConfigFile; }
156 inline char* getTableConfigFile() { return cVal.tableConfigFile; }
157 inline char* getStderrFile() { return cVal.stderrFile; }
158 inline bool useDurability() { return cVal.isDurable; }
159 inline int getDurableMode() { return cVal.durableMode; }
160 inline bool useCsqlSqlServer() { return cVal.isCsqlSqlServer; }
161 inline int getPort() { return cVal.port; }
162 inline char* getConflResoFile() { return cVal.conflResoFile; }
163 inline long getMaxQueueLogs() { return cVal.maxQueueLogs; }
164 inline int getMsgKey() { return cVal.msgKey; }
165 inline int getAsyncMsgMax() { return cVal.asyncMsgMax; }
166 inline int getShmIDKey() { return cVal.shmKeyForId; }
167 inline int getNetworkResponseTimeout() { return cVal.nwResponseTimeout; }
168 inline int getNetworkConnectTimeout() { return cVal.nwConnectTimeout; }
169 inline bool useTwoWayCache() { return cVal.isTwoWay; }
170 inline int getCacheWaitSecs() { return cVal.cacheWaitSecs; }
171 inline int getLogLevel() { return cVal.logLevel; }
172 inline int getNoOfProcessors() { return cVal.noOfProcessors; }
175 class Conf
177 public:
178 static Config config;
179 static Logger logger;
182 #endif