MCPcopy Create free account
hub / github.com/RangeNetworks/openbts / tmsiTabOpen

Method tmsiTabOpen

Control/TMSITable.cpp:247–290  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

245
246
247int TMSITable::tmsiTabOpen(const char* wPath)
248{
249 // FIXME -- We can't call the logger here because it has not been initialized yet.
250 // (pat) I think this has been fixed - the TMSITable initialization is now in main().
251 //printf("TMSITable::open(%s)\n",wPath); fflush(stdout);
252 LOG(INFO) << "TMSITable::open "<<wPath;
253 mTablePath = string(wPath);
254
255 int rc = sqlite3_open(wPath,&mTmsiDB);
256 if (rc) {
257 // (pat) Lets just create the directory if it does not exist.
258 char dirpath[strlen(wPath)+100];
259 strcpy(dirpath,wPath);
260 char *sp = strrchr(dirpath,'/');
261 if (sp) {
262 *sp = 0;
263 mkdir(dirpath,0777);
264 rc = sqlite3_open(wPath,&mTmsiDB); // try try again.
265 }
266 }
267 if (rc) {
268 LOG(EMERG) << "Cannot open TMSITable database at " << wPath << ": " << sqlite3_errmsg(mTmsiDB);
269 sqlite3_close(mTmsiDB);
270 mTmsiDB = NULL;
271 exit(1);
272 //return 1;
273 }
274
275 tmsiTabCheckVersion();
276
277 if (!sqlite_command(mTmsiDB,TmsiTableDefinition::create)) {
278 LOG(EMERG) << "Cannot create TMSI table in file:" <<mTablePath <<" using:" <<TmsiTableDefinition::create ;
279 exit(1);
280 //return 1;
281 }
282 // Set high-concurrency WAL mode.
283 if (!sqlite_command(mTmsiDB,enableWAL)) {
284 LOG(EMERG) << "Cannot enable WAL mode on database at " << wPath << ", error message: " << sqlite3_errmsg(mTmsiDB);
285 }
286 LOG(INFO) << "Opened TMSI table version "<<TmsiTableDefinition::tmsiTableVersion<< ":"<<wPath;
287 LOG(DEBUG) << "TEST sqlite3_db_filename:"<< sqlite3_db_filename(mTmsiDB,"main");
288 tmsiTabInit();
289 return 0;
290}
291
292TMSITable::~TMSITable()
293{

Callers 1

controlInitFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected