int main(int argc, char* argv[]) { int i; printf("\nxAP Snoop - for xAP v1.2\n"); printf("Copyright (C) DBzoo 2009-2010\n\n"); xAPFilter *filter = NULL; for(i=0; i<argc; i++) { if(strcmp("-i", argv[i]) == 0 || strcmp("--interface",argv[i]) == 0) { interfaceName = argv[++i]; } else if(strcmp("-d", argv[i]) == 0 || strcmp("--debug", argv[i]) == 0) { setLoglevel(atoi(argv[++i])); } else if(strcmp("-h", argv[i]) == 0 || strcmp("--help", argv[i]) == 0) { usage(argv[0]); } else if(strcmp("-s", argv[i]) == 0 || strcmp("--source", argv[i]) == 0) { xapAddFilter(&filter, "xap-header", "source", argv[++i]); } else if(strcmp("-t", argv[i]) == 0 || strcmp("--target", argv[i]) == 0) { xapAddFilter(&filter, "xap-header", "target", argv[++i]); } else if(strcmp("-c", argv[i]) == 0 || strcmp("--class", argv[i]) == 0) { xapAddFilter(&filter, "xap-header", "class", argv[++i]); } else if(strcmp("-f", argv[i]) == 0 || strcmp("--filter", argv[i]) == 0) { char *section = argv[++i]; char *key = argv[++i]; char *value = argv[++i]; xapAddFilter(&filter, section, key, value); } } xapInitFromINI("snoop","dbzoo","Snoop","00D4",interfaceName,inifile); xapAddFilterAction(&packetDump, filter, NULL); xapProcess(); return 0; }
int AmConfig::readConfiguration() { DBG("Reading configuration..."); AmConfigReader cfg; if(cfg.loadFile(ConfigurationFile.c_str())){ ERROR("while loading main configuration file\n"); return -1; } // take values from global configuration file // they will be overwritten by command line args if (cfg.hasParameter("syslog_facility")) { set_log_facility(cfg.getParameter("syslog_facility").c_str()); } // plugin_config_path ModConfigPath = cfg.getParameter("plugin_config_path",ModConfigPath); if(!ModConfigPath.empty() && (ModConfigPath[ModConfigPath.length()-1] != '/')) ModConfigPath += '/'; // listen, sip_ip, sip_port, and media_ip if(cfg.hasParameter("sip_ip")) { LocalSIPIP = cfg.getParameter("sip_ip"); } if(cfg.hasParameter("sip_port")){ if(!setSIPPort(cfg.getParameter("sip_port").c_str())){ ERROR("invalid sip port specified\n"); return -1; } } if(cfg.hasParameter("media_ip")) { LocalIP = cfg.getParameter("media_ip"); } // public_ip if(cfg.hasParameter("public_ip")){ string p_ip = cfg.getParameter("public_ip"); DBG("Setting public_ip parameter to %s.\n", p_ip.c_str()); PublicIP = p_ip; } else { DBG("Config file has no public_ip parameter."); } // outbound_proxy OutboundProxy = cfg.getParameter("outbound_proxy"); // plugin_path PlugInPath = cfg.getParameter("plugin_path"); // load_plugins LoadPlugins = cfg.getParameter("load_plugins"); // exclude_plugins ExcludePlugins = cfg.getParameter("exclude_plugins"); // exclude_plugins ExcludePayloads = cfg.getParameter("exclude_payloads"); // user_agent if (cfg.getParameter("use_default_signature")=="yes") Signature = DEFAULT_SIGNATURE; else Signature = cfg.getParameter("signature"); // log_level if(cfg.hasParameter("loglevel")){ if(!setLoglevel(cfg.getParameter("loglevel"))){ ERROR("invalid log level specified\n"); return -1; } } LogSessions = cfg.getParameter("log_sessions")=="yes"; if (cfg.hasParameter("unhandled_reply_loglevel")) { string msglog = cfg.getParameter("unhandled_reply_loglevel"); if (msglog == "no") UnhandledReplyLoglevel = -1; else if (msglog == "error") UnhandledReplyLoglevel = 0; else if (msglog == "warn") UnhandledReplyLoglevel = 1; else if (msglog == "info") UnhandledReplyLoglevel = 2; else if (msglog == "debug") UnhandledReplyLoglevel = 3; else ERROR("Could not interpret unhandled_reply_loglevel \"%s\"\n", msglog.c_str()); } Application = cfg.getParameter("application"); if (Application == "$(ruri.user)") { AppSelect = App_RURIUSER; } else if (Application == "$(ruri.param)") { AppSelect = App_RURIPARAM; } else if (Application == "$(apphdr)") { AppSelect = App_APPHDR; } else if (Application == "$(mapping)") { AppSelect = App_MAPPING; string appcfg_fname = ModConfigPath + "app_mapping.conf"; DBG("Loading application mapping...\n"); std::ifstream appcfg(appcfg_fname.c_str()); if (!appcfg.good()) { ERROR("could not load application mapping file at '%s'\n", appcfg_fname.c_str()); return -1; } while (!appcfg.eof()) { string entry; getline (appcfg,entry); if (!entry.length() || entry[0] == '#') continue; vector<string> re_v = explode(entry, "=>"); if (re_v.size() != 2) { ERROR("Incorrect line '%s' in %s: expected format 'regexp=>app_name'\n", entry.c_str(), appcfg_fname.c_str()); return -1; } regex_t app_re; if (regcomp(&app_re, re_v[0].c_str(), REG_NOSUB)) { ERROR("compiling regex '%s' in %s.\n", re_v[0].c_str(), appcfg_fname.c_str()); return -1; } DBG("adding application mapping '%s' => '%s'\n", re_v[0].c_str(),re_v[1].c_str()); AppMapping.push_back(make_pair(app_re, re_v[1])); } } else { AppSelect = App_SPECIFIED; } // fork if(cfg.hasParameter("fork")){ if(!setFork(cfg.getParameter("fork"))){ ERROR("invalid fork value specified," " valid are only yes or no\n"); return -1; } } // stderr if(cfg.hasParameter("stderr")){ if(!setStderr(cfg.getParameter("stderr"))){ ERROR("invalid stderr value specified," " valid are only yes or no\n"); return -1; } } // user_prefix_separator PrefixSep = cfg.getParameter("user_prefix_separator",PrefixSep); // rtp_low_port if(cfg.hasParameter("rtp_low_port")){ if(!setRtpLowPort(cfg.getParameter("rtp_low_port"))){ ERROR("invalid rtp low port specified\n"); return -1; } } // rtp_high_port if(cfg.hasParameter("rtp_high_port")){ if(!setRtpHighPort(cfg.getParameter("rtp_high_port"))){ ERROR("invalid rtp high port specified\n"); return -1; } } if(cfg.hasParameter("media_processor_threads")){ if(!setMediaProcessorThreads(cfg.getParameter("media_processor_threads"))){ ERROR("invalid media_processor_threads value specified"); return -1; } } // single codec in 200 OK if(cfg.hasParameter("single_codec_in_ok")){ SingleCodecInOK = (cfg.getParameter("single_codec_in_ok") == "yes"); } // single codec in 200 OK if(cfg.hasParameter("ignore_rtpxheaders")){ IgnoreRTPXHdrs = (cfg.getParameter("ignore_rtpxheaders") == "yes"); } // codec_order CodecOrder = explode(cfg.getParameter("codec_order"), ","); // dead_rtp_time if(cfg.hasParameter("dead_rtp_time")){ if(!setDeadRtpTime(cfg.getParameter("dead_rtp_time"))){ ERROR("invalid dead_rtp_time value specified"); return -1; } } if(cfg.hasParameter("dtmf_detector")){ if (cfg.getParameter("dtmf_detector") == "spandsp") { #ifndef USE_SPANDSP WARN("spandsp support not compiled in.\n"); #endif DefaultDTMFDetector = Dtmf::SpanDSP; } } if(cfg.hasParameter("session_limit")){ vector<string> limit = explode(cfg.getParameter("session_limit"), ";"); if (limit.size() != 3) { ERROR("invalid session_limit specified.\n"); } else { if (str2i(limit[0], SessionLimit) || str2i(limit[1], SessionLimitErrCode)) { ERROR("invalid session_limit specified.\n"); } SessionLimitErrReason = limit[2]; } } return defaultSessionTimerConfig.readFromConfig(cfg); }
int main(int argc, char ** argv) { setenv("QT_PLUGIN_PATH","/usr/plugins",1); setenv("QT_QPA_PLATFORM", "minimal",1); QApplication app(argc, argv); parseCommandlineOptions(argc, argv); setLoglevel(Settings::settings()->m_logLevel.c_str()); g_log_set_default_handler(logFilter, NULL); g_warning("Started"); SystemRestore::createSpecialDirectories(); // Initialize the Preferences database (void) PrefsDb::instance(); ///and system restore (refresh settings while I'm at it...) SystemRestore::instance()->refreshDefaultSettings(); //run startup restore before anything else starts SystemRestore::startupConsistencyCheck(); Mainloop * mainLoopObj = new Mainloop(); g_gmainLoop = mainLoopObj->getMainLoopPtr(); //GMainLoop* mainLoop = g_main_loop_new(NULL, FALSE); LSPalmService* serviceHandle = NULL; LSError lsError; bool result; LSErrorInit(&lsError); // Register the service result = LSRegisterPalmService("com.palm.systemservice", &serviceHandle, &lsError); if (!result) { g_warning("Failed to register service: com.palm.sysservice"); return -1; } // LSHandle * serviceHandlePublic = LSPalmServiceGetPublicConnection(serviceHandle); LSHandle * serviceHandlePrivate = LSPalmServiceGetPrivateConnection(serviceHandle); result = LSGmainAttachPalmService(serviceHandle, g_gmainLoop, &lsError); if (!result) { g_warning("Failed to attach service handle to main loop"); return -1; } //turn novacom on if requested if (Settings::settings()->m_turnNovacomOnAtStartup) { turnNovacomOn(serviceHandlePrivate); } if ((result = LSCall(serviceHandlePrivate,"palm://com.palm.bus/signal/registerServerStatus", "{\"serviceName\":\"com.palm.image2\", \"subscribe\":true}", cbComPalmImage2Status,NULL,NULL, &lsError)) == false) { //non-fatal LSErrorFree(&lsError); LSErrorInit(&lsError); } // register for storage daemon signals result = LSCall(serviceHandlePrivate, "palm://com.palm.lunabus/signal/addmatch", "{\"category\":\"/storaged\", \"method\":\"MSMAvail\"}", SystemRestore::msmAvailCallback, NULL, SystemRestore::instance()->getLSStorageToken(), &lsError); if (!result) return -1; result = LSCall(serviceHandlePrivate, "palm://com.palm.lunabus/signal/addmatch", "{\"category\":\"/storaged\", \"method\":\"MSMProgress\"}", SystemRestore::msmProgressCallback, NULL, SystemRestore::instance()->getLSStorageToken(), &lsError); if (!result) return -1; result = LSCall(serviceHandlePrivate, "palm://com.palm.lunabus/signal/addmatch", "{\"category\":\"/storaged\", \"method\":\"MSMEntry\"}", SystemRestore::msmEntryCallback, NULL, SystemRestore::instance()->getLSStorageToken(), &lsError); if (!result) return -1; result = LSCall(serviceHandlePrivate, "palm://com.palm.lunabus/signal/addmatch", "{\"category\":\"/storaged\", \"method\":\"MSMFscking\"}", SystemRestore::msmFsckingCallback, NULL, SystemRestore::instance()->getLSStorageToken(), &lsError); if (!result) return -1; result = LSCall(serviceHandlePrivate, "palm://com.palm.lunabus/signal/addmatch", "{\"category\":\"/storaged\", \"method\":\"PartitionAvail\"}", SystemRestore::msmPartitionAvailCallback, NULL, SystemRestore::instance()->getLSStorageToken(), &lsError); if (!result) return -1; // Initialize the Prefs Factory PrefsFactory::instance()->setServiceHandle(serviceHandle); BackupManager::instance()->setServiceHandle(serviceHandle); //init the image service ImageServices * imgSvc = ImageServices::instance(mainLoopObj); if (!imgSvc) { g_warning("Image service failed init!"); } //init the timezone service; TimeZoneService* tzSvc = TimeZoneService::instance(); tzSvc->setServiceHandle(serviceHandle); // Run the main loop g_main_loop_run(g_gmainLoop); return 0; }