当前位置: 首页>>代码示例>>C++>>正文


C++ ConfigurationTable::getStr方法代码示例

本文整理汇总了C++中ConfigurationTable::getStr方法的典型用法代码示例。如果您正苦于以下问题:C++ ConfigurationTable::getStr方法的具体用法?C++ ConfigurationTable::getStr怎么用?C++ ConfigurationTable::getStr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ConfigurationTable的用法示例。


在下文中一共展示了ConfigurationTable::getStr方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: startTransceiver

void startTransceiver()
{
	//if local kill the process currently listening on this port
	char killCmd[32];
	if (gConfig.getStr("TRX.IP") == "127.0.0.1"){
		sprintf(killCmd,"fuser -k -n udp %d",(int)gConfig.getNum("TRX.Port"));
		if (system(killCmd)) {}
	}

	// Start the transceiver binary, if the path is defined.
	// If the path is not defined, the transceiver must be started by some other process.
	char TRXnumARFCN[4];
	sprintf(TRXnumARFCN,"%1d",(int)gConfig.getNum("GSM.Radio.ARFCNs"));
	std::string extra_args = gConfig.getStr("TRX.Args");
	LOG(NOTICE) << "starting transceiver " << transceiverPath << " w/ " << TRXnumARFCN << " ARFCNs and Args:" << extra_args;
	gTransceiverPid = vfork();
	LOG_ASSERT(gTransceiverPid>=0);
	if (gTransceiverPid==0) {
		// Pid==0 means this is the process that starts the transceiver.
	    execlp(transceiverPath,transceiverPath,TRXnumARFCN,extra_args.c_str(),(void*)NULL);
		LOG(EMERG) << "cannot find " << transceiverPath;
		_exit(1);
	} else {
		int status;
		waitpid(gTransceiverPid, &status,0);
		LOG(EMERG) << "Transceiver quit with status " << status << ". Exiting.";
		exit(2);
	}
}
开发者ID:5728136cs,项目名称:OpenBTS-nuand,代码行数:29,代码来源:OpenBTS.cpp

示例2: RegisterProgram

void SelfDetect::RegisterProgram(const char *argv0)
{
    const char *p = strrchr((char*)argv0,'/');
    if (p == NULL) {
        p = argv0;
    }

    char buf[100];
    snprintf(buf, sizeof(buf)-1, "/var/run/%s.pid", p);
    LOG(NOTICE) << "*** Registering program " << argv0 << " to " << buf;

    // first, verify we aren't already running.
    struct stat stbuf;
    if (stat(buf, &stbuf) >= 0)
    {
        LOG(CRIT) << "*** An instance of " << p << " is already running. ";
        LOG(CRIT) << "*** If this is not the case, deleting this file will allow " << p << " to start: " << buf << " exiting...";
        Exit::exit(Exit::DETECTFILE);
    }

    FILE *fp = fopen(buf, "w");
    if (fp == NULL)
    {
        LOG(CRIT) << "*** Unable to create " << buf << ": " << strerror(errno) << " exiting...";
        Exit::exit(Exit::CREATEFILE);
    }
    fprintf(fp, "%d\n", getpid());
    fclose(fp);
    atexit(e);
    gSigVec.CoreName(gConfig.getStr("Core.File"), gConfig.getBool("Core.Pid"));
    gSigVec.TarName(gConfig.getStr("Core.TarFile"), gConfig.getBool("Core.SaveFiles"));

    // Now, register for all signals to do the cleanup
    for (int i = 1; i < UnixSignal::C_NSIG; i++)
    {
        switch(i)
        {
        // Add any signals that need to bypass the signal handling behavior
        // here.  Currently, SIGCHLD is needed because a signal is generated
        // when stuff related to the transciever (which is a child process)
        // occurs.  In that case, the openbts log output was:
        //		openbts: ALERT 3073816320 05:03:50.4 OpenBTS.cpp:491:main: starting the transceiver
        //		openbts: NOTICE 3073816320 05:03:50.4 SelfDetect.cpp:91:Exit: *** Terminating because of signal 17
        //		openbts: NOTICE 3031243584 05:03:50.4 OpenBTS.cpp:165:startTransceiver: starting transceiver ./transceiver w/ 1 ARFCNs and Args:
        //		openbts: NOTICE 3073816320 05:03:50.4 SelfDetect.cpp:98:Exit: *** Terminating ./OpenBTS
        //		openbts: NOTICE 3073816320 05:03:50.4 SelfDetect.cpp:105:Exit: *** Removing pid file /var/run/OpenBTS.pid
        case SIGCONT:
        case SIGCHLD:
            break;
        default:
            gSigVec.Register(sigfcn, i);
            break;
        }
    }
    mProg = strdup(argv0);
    mFile = strdup(buf);
}
开发者ID:jemmy655,项目名称:CommonLibs,代码行数:57,代码来源:SelfDetect.cpp

示例3: authenticate

// verify sres given rand and imsi's ki
// may set kc
// may cache sres and rand
bool authenticate(string imsi, string randx, string sres, string *kc)
{
	string ki = gSubscriberRegistry.imsiGet(imsi, "ki");
	bool ret;
	if (ki.length() == 0) {
		// Ki is unknown
		string sres2 = gSubscriberRegistry.imsiGet(imsi, "sres");
		if (sres2.length() == 0) {
			LOG(INFO) << "ki unknown, no upstream server, sres not cached";
			// first time - cache sres and rand so next time
			// correct cell phone will calc same sres from same rand
			gSubscriberRegistry.imsiSet(imsi, "sres", sres, "rand", randx);
			ret = true;
		} else {
			LOG(INFO) << "ki unknown, no upstream server, sres cached";
			// check against cached values of rand and sres
			string rand2 = gSubscriberRegistry.imsiGet(imsi, "rand");
			// TODO - on success, compute and return kc
			LOG(DEBUG) << "comparing " << sres << " to " << sres2 << " and " << randx << " to " << rand2;
			ret = sresEqual(sres, sres2) && randEqual(randx, rand2);
		}
	} else {
		LOG(INFO) << "ki known";
		// Ki is known, so do normal authentication
		ostringstream os;
		// per user value from subscriber registry
		string a3a8 = gSubscriberRegistry.imsiGet(imsi, "a3_a8");
		if (a3a8.length() == 0) {
			// config value is default
			a3a8 = gConfig.getStr("SubscriberRegistry.A3A8");
		}
		os << a3a8 << " 0x" << ki << " 0x" << randx;
		// must not put ki into the log
		// LOG(INFO) << "running " << os.str();
		FILE *f = popen(os.str().c_str(), "r");
		if (f == NULL) {
			LOG(CRIT) << "error: popen failed";
			return false;
		}
		char sres2[26];
		char *str = fgets(sres2, 26, f);
		if (str != NULL && strlen(str) == 25) str[24] = 0;
		if (str == NULL || strlen(str) != 24) {
			LOG(CRIT) << "error: popen result failed";
			return false;
		}
		int st = pclose(f);
		if (st == -1) {
			LOG(CRIT) << "error: pclose failed";
			return false;
		}
		// first 8 chars are SRES;  rest are Kc
		*kc = sres2+8;
		sres2[8] = 0;
		LOG(INFO) << "result = " << sres2;
		ret = sresEqual(sres, sres2);
	}
	LOG(INFO) << "returning = " << ret;
	return ret;
}
开发者ID:kheimerl,项目名称:subscriberRegistry,代码行数:63,代码来源:servershare.cpp

示例4: LOG

SubscriberRegistry::SubscriberRegistry()
{
	string ldb = gConfig.getStr("SubscriberRegistry.db");
	int rc = sqlite3_open(ldb.c_str(),&mDB);
	if (rc) {
		LOG(EMERG) << "Cannot open SubscriberRegistry database: " << sqlite3_errmsg(mDB);
		sqlite3_close(mDB);
		mDB = NULL;
		return;
	}
    if (!sqlite3_command(mDB,createRRLPTable)) {
        LOG(EMERG) << "Cannot create RRLP table";
    }
    if (!sqlite3_command(mDB,createDDTable)) {
        LOG(EMERG) << "Cannot create DIALDATA_TABLE table";
    }
    if (!sqlite3_command(mDB,createSBTable)) {
        LOG(EMERG) << "Cannot create SIP_BUDDIES table";
    }
	if (!getCLIDLocal("IMSI001010000000000")) {
		// This is a test SIM provided with the BTS.
		if (addUser("IMSI001010000000000", "2100") != SUCCESS) {
			LOG(EMERG) << "Cannot insert test SIM";
		}
	}
}
开发者ID:5728136cs,项目名称:Mobile_Netze_HM_OpenBTS_Handover,代码行数:26,代码来源:SubscriberRegistry.cpp

示例5: gLogInit

void gLogInit(const char* name, const char* level, int facility)
{
	// Set the level if one has been specified.
	if (level) {
		gConfig.set("Log.Level",level);
	}
	gPid = getpid();

	// Pat added, tired of the syslog facility.
	// Both the transceiver and OpenBTS use this same facility, but only OpenBTS/OpenNodeB may use this log file:
	string str = gConfig.getStr("Log.File");
	if (gLogToFile==0 && str.length() && 0==strncmp(gCmdName,"Open",4)) {
		const char *fn = str.c_str();
		if (fn && *fn && strlen(fn)>3) {	// strlen because a garbage char is getting in sometimes.
			gLogToFile = fopen(fn,"w"); // New log file each time we start.
			if (gLogToFile) {
                                time_t now = time(NULL);
                                std::string result;
                                Timeval::isoTime(now, result);
                                fprintf(gLogToFile,"Starting at %s",result.c_str());
				fflush(gLogToFile);
				std::cout << name <<" logging to file: " << fn << "\n";
			}
		}
	}

	// Open the log connection.
	openlog(name,0,facility);

	// We cant call this from the Mutex itself because the Logger uses Mutex.
	gMutexLogLevel = gGetLoggingLevel("Mutex.cpp");
}
开发者ID:telenoobie,项目名称:CommonLibs,代码行数:32,代码来源:Logger.cpp

示例6: removeUser

// For handover.  Only remove the local cache.  BS2 will have updated the global.
SubscriberRegistry::Status SubscriberRegistry::removeUser(const char* IMSI)
{
	if (!IMSI) {
		LOG(WARNING) << "SubscriberRegistry::addUser attempting add of NULL IMSI";
		return FAILURE;
	}
	LOG(INFO) << "removeUser(" << IMSI << ")";
	string server = gConfig.getStr("SubscriberRegistry.UpstreamServer");
	if (server.length() == 0) {
		LOG(INFO) << "not removing user if no upstream server";
		return FAILURE;
	}
	ostringstream os;
	os << "delete from sip_buddies where name = ";
	os << "\"" << IMSI << "\"";
	os << ";";
	LOG(INFO) << os.str();
	SubscriberRegistry::Status st = sqlLocal(os.str().c_str(), NULL);
	ostringstream os2;
	os2 << "delete from dialdata_table where dial = ";
	os2 << "\"" << IMSI << "\"";
	LOG(INFO) << os2.str();
	SubscriberRegistry::Status st2 = sqlLocal(os2.str().c_str(), NULL);
	return st == SUCCESS && st2 == SUCCESS ? SUCCESS : FAILURE;
}
开发者ID:Community-Cellular,项目名称:vbts-subscriberRegistry,代码行数:26,代码来源:SubscriberRegistry.cpp

示例7: testConfig

/* Run sanity check on configuration table
 *     The global table constructor cannot provide notification in the
 *     event of failure. Make sure that we can access the database,
 *     write to it, and that it contains the bare minimum required keys.
 */
bool testConfig()
{
    int val = 9999;
    std::string test = "asldfkjsaldkf";
    const char *key = "Log.Level";

    /* Attempt to query */
    try {
        gConfig.getStr(key);
    } catch (...) {
        std::cerr << std::endl;
        std::cerr << "Config: Failed query required key " << key
                  << std::endl;
        return false;
    }

    /* Attempt to set a test value in the global config */
    if (!gConfig.set(test, val)) {
        std::cerr << std::endl;
        std::cerr << "Config: Failed to set test key" << std::endl;
        return false;
    } else {
        gConfig.remove(test);
    }

    return true;
}
开发者ID:kkroo,项目名称:osmo-trx,代码行数:32,代码来源:osmo-trx.cpp

示例8: main

int main(int argc, char **argv)
{
	gLogInit("SubscriberRegistryTest",gConfig.getStr("Log.Level").c_str(),LOG_LOCAL7);

	// The idea is just to make sure things are connected right.  The important code is shared, and tested elsewhere.


	// add a user
	sr.addUser("imsi", "clid");
	// testing mappings of known user
	sr.getCLIDLocal("imsi");
	sr.getIMSI("clid");
	// test mapping of unknow user (so it won't be found locally)
	sr.getCLIDLocal("imsi_unknown");
	sr.getRandForAuthentication(false, "imsi_r1");
	sr.authenticate(false, "imsi_a1","rand_a1","sres_a1");


	// but test the conversions
	foo(0xffffffff, "ffffffff");
	foo(0x00000000, "00000000");
	foo(0x12345678, "12345678");
	foo(0x9abcdef0, "9abcdef0");

	foo("ffffffffffffffff0000000000000000");
	foo("0000000000000000ffffffffffffffff");
	foo("0123456789abcdef0123456789abcdef");


	// billing testing - not tested elsewhere

	sr.setPrepaid("imsi", false);
	bool b;
	sr.isPrepaid("imsi", b);
	LOG(INFO) << "should be false " << b;

	sr.setPrepaid("imsi", true);
	sr.isPrepaid("imsi", b);
	LOG(INFO) << "should be true " << b;

	sr.setSeconds("imsi", 100);
	int t;
	sr.secondsRemaining("imsi", t);
	LOG(INFO) << "should be 100 " << t;

	sr.addSeconds("imsi", -50, t);
	LOG(INFO) << "should be 50 " << t;

	sr.addSeconds("imsi", -100, t);
	LOG(INFO) << "should be 0 " << t;


}
开发者ID:0x7678,项目名称:OpenBTS,代码行数:53,代码来源:test.cpp

示例9: init

int SubscriberRegistry::init()
{
	string ldb = gConfig.getStr("SubscriberRegistry.db");
	size_t p = ldb.find_last_of('/');
	if (p == string::npos) {
		LOG(EMERG) << "SubscriberRegistry.db not in a directory?";
		mDB = NULL;
		return 1;
	}
	string dir = ldb.substr(0, p);
	struct stat buf;
	if (stat(dir.c_str(), &buf)) {
		LOG(EMERG) << dir << " does not exist";
		mDB = NULL;
		return 1;
	}
	mNumSQLTries=gConfig.getNum("Control.NumSQLTries"); 
	int rc = sqlite3_open(ldb.c_str(),&mDB);
	if (rc) {
		LOG(EMERG) << "Cannot open SubscriberRegistry database: " << ldb << " error: " << sqlite3_errmsg(mDB);
		sqlite3_close(mDB);
		mDB = NULL;
		return 1;
	}
	if (!sqlite3_command(mDB,createRRLPTable,mNumSQLTries)) {
		LOG(EMERG) << "Cannot create RRLP table";
		return 1;
	}
	if (!sqlite3_command(mDB,createDDTable,mNumSQLTries)) {
		LOG(EMERG) << "Cannot create DIALDATA_TABLE table";
		return 1;
	}
	if (!sqlite3_command(mDB,createRateTable,mNumSQLTries)) {
		LOG(EMERG) << "Cannot create rate table";
		return 1;
	}
	if (!sqlite3_command(mDB,createSBTable,mNumSQLTries)) {
		LOG(EMERG) << "Cannot create SIP_BUDDIES table";
		return 1;
	}
	// Set high-concurrency WAL mode.
	if (!sqlite3_command(mDB,enableWAL,mNumSQLTries)) {
		LOG(EMERG) << "Cannot enable WAL mode on database at " << ldb << ", error message: " << sqlite3_errmsg(mDB);
	}
	if (!getCLIDLocal("IMSI001010000000000")) {
		// This is a test SIM provided with the BTS.
		if (addUser("IMSI001010000000000", "2100") != SUCCESS) {
        		LOG(EMERG) << "Cannot insert test SIM";
		}
	}
	return 0;
}
开发者ID:Community-Cellular,项目名称:vbts-subscriberRegistry,代码行数:52,代码来源:SubscriberRegistry.cpp

示例10: main

int main(int argc, char **argv)
{
	// start the html return
	initHtml();
	// read the config file
	gVisibleSipColumns = gConfig.getStr("SubscriberRegistry.Manager.VisibleColumns");
	gUrl = "/cgi/srmanager.cgi";
	gTitle = gConfig.getStr("SubscriberRegistry.Manager.Title");
	// connect to the database
	gDatabase = gConfig.getStr("SubscriberRegistry.db");
	// decode the http query
	decodeQuery(gArgs);
	// execute command
	string what = gArgs["what"];
	if (!what.length() || what == "Main") {
		mainTables();
	} else if (what == "Add") {
		doCmd("add");
	} else if (what == "Update") {
		doCmd("update");
	} else if (what == "Delete") {
		doCmd("delete");
	} else if (what == "Provision") {
		gSubscriberRegistry.addUser(gArgs["imsi"].c_str(), gArgs["phonenumber"].c_str());
		mainTables();
	} else if (what == "Submit") {
		doVisibles();
		mainTables();
	} else {
		cout << "unrecognized what parameter<br>\n";
		map<string,string>::iterator it;
		for (it = gArgs.begin(); it != gArgs.end(); it++) {
			cout << it->first << " -> " << it->second << "<br>\n";
		}
	}
	// finish the html return
	endHtml();
}
开发者ID:Gabotero,项目名称:OpenBTS,代码行数:38,代码来源:srmanager.cpp

示例11: setAll

// Set all the Log.Group debug levels based on database settings
void LogGroup::setAll()
{
	LOG(DEBUG);
	string prefix = string(LogGroupPrefix);
	for (unsigned g = 0; g < _NumberOfLogGroups; g++) {
		int level = 0;
		string param = prefix + mGroupNames[g];
		if (gConfig.defines(param)) {
			string levelName = gConfig.getStr(param);
			// (pat) The "unconfig" command does not remove the value, it just gives it an empty value, so check for that.
			if (levelName.size()) {
				//LOG(DEBUG) << "Setting "<<LOGVAR(param)<<LOGVAR(levelName);
				level = lookupLevel2(param,levelName);
			}
		}
		mDebugLevel[g] = level;
	}
}
开发者ID:telenoobie,项目名称:CommonLibs,代码行数:19,代码来源:Logger.cpp

示例12: addAlarm

// Add an alarm to the alarm list, and send it out via udp
//
// On the first call we read the ip and port from the configuration
// TODO - is there any global setup function where this should be done? -- Alon
void addAlarm(const string& s)
{
	// Socket open and close on every alarm - wise?
	// Probably.  That way we are sure to pick up changes in the target address.
	// Alarms should not happen often.
	if (gConfig.defines("Log.Alarms.TargetIP")) {
		UDPSocket alarmsocket(0,
			gConfig.getStr("Log.Alarms.TargetIP"),
			gConfig.getNum("Log.Alarms.TargetPort"));
		alarmsocket.write(s.c_str());
	}
    // append to list and reduce list to max alarm count
    alarmsLock.lock();
    alarmsList.push_back(s);
	unsigned maxAlarms = gConfig.getNum("Log.Alarms.Max");
    while (alarmsList.size() > maxAlarms) alarmsList.pop_front();
    alarmsLock.unlock();
}
开发者ID:EricYoel,项目名称:openbts-2.6,代码行数:22,代码来源:Logger.cpp

示例13: getLoggingLevel

int getLoggingLevel(const char* filename)
{
	// Default level?
	if (!filename) return lookupLevel("Log.Level");

	// This can afford to be inefficient since it is not called that often.
	string keyName;
	keyName.reserve(100);
	keyName.append("Log.Level.");
	keyName.append(filename);
	if (gConfig.defines(keyName)) {
		string keyVal = gConfig.getStr(keyName);
		// (pat 4-2014) The CLI 'unconfig' command does not unset the value, it just gives an empty value,
		// so check for that and treat it as an unset value, ie, do nothing.
		if (keyVal.size()) {
			return lookupLevel2(keyName,keyVal);
		}
	}
	return lookupLevel("Log.Level");
}
开发者ID:telenoobie,项目名称:CommonLibs,代码行数:20,代码来源:Logger.cpp

示例14: main

int main(int argc, char *argv[])
{
  if ( signal( SIGINT, ctrlCHandler ) == SIG_ERR )
  {
    cerr << "Couldn't install signal handler for SIGINT" << endl;
    exit(1);
  }

  if ( signal( SIGTERM, ctrlCHandler ) == SIG_ERR )
  {
    cerr << "Couldn't install signal handler for SIGTERM" << endl;
    exit(1);
  }
  // Configure logger.
  gLogInit("transceiver",gConfig.getStr("Log.Level").c_str(),LOG_LOCAL7);

  srandom(time(NULL));

  int mOversamplingRate = 1;
  RAD1Device *usrp = new RAD1Device(mOversamplingRate*1625.0e3/6.0);
  usrp->make(); 

  RadioInterface* radio = new RadioInterface(usrp,3,SAMPSPERSYM,mOversamplingRate,false);
  Transceiver *trx = new Transceiver(5700,"127.0.0.1",SAMPSPERSYM,GSM::Time(2,0),radio);
  trx->receiveFIFO(radio->receiveFIFO());

  trx->start();
  //int i = 0;
  while(!gbShutdown) { sleep(1); } //i++; if (i==60) exit(1);}

  cout << "Shutting down transceiver..." << endl;

//  trx->stop();
  delete trx;
//  delete radio;
}
开发者ID:12019,项目名称:openbts-p2.8,代码行数:36,代码来源:runTransceiver.cpp

示例15: init

int SubscriberRegistry::init()
{
	string ldb = gConfig.getStr("SubscriberRegistry.db");
	int rc = sqlite3_open(ldb.c_str(),&mDB);
	if (rc) {
		LOG(EMERG) << "Cannot open SubscriberRegistry database: " << sqlite3_errmsg(mDB);
		sqlite3_close(mDB);
		mDB = NULL;
		return FAILURE;
	}
	if (!sqlite3_command(mDB,createRRLPTable)) {
		LOG(EMERG) << "Cannot create RRLP table";
	  return FAILURE;
	}
	if (!sqlite3_command(mDB,createDDTable)) {
		LOG(EMERG) << "Cannot create DIALDATA_TABLE table";
		return FAILURE;
	}
	if (!sqlite3_command(mDB,createSBTable)) {
		LOG(EMERG) << "Cannot create SIP_BUDDIES table";
		return FAILURE;
	}
	return SUCCESS;
}
开发者ID:kacipbuah,项目名称:openbts-range,代码行数:24,代码来源:SubscriberRegistry.cpp


注:本文中的ConfigurationTable::getStr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。