void SessionImpl::transmit( const Response& response, const function< void ( const error_code&, size_t ) >& callback ) const { auto hdrs = m_settings->get_default_headers( ); if ( m_resource not_eq nullptr ) { const auto m_resource_headers = m_resource->m_pimpl->m_default_headers; hdrs.insert( m_resource_headers.begin( ), m_resource_headers.end( ) ); } hdrs.insert( m_headers.begin( ), m_headers.end( ) ); auto response_headers = response.get_headers( ); hdrs.insert( response_headers.begin( ), response_headers.end( ) ); auto payload = make_shared< Response >( ); payload->set_headers( hdrs ); payload->set_body( response.get_body( ) ); payload->set_version( response.get_version( ) ); payload->set_protocol( response.get_protocol( ) ); payload->set_status_code( response.get_status_code( ) ); payload->set_status_message( response.get_status_message( ) ); if ( payload->get_status_message( ).empty( ) ) { payload->set_status_message( m_settings->get_status_message( payload->get_status_code( ) ) ); } m_request->m_pimpl->m_socket->start_write( Http::to_bytes( payload ), callback ); }
void LoginResponse::MergeFrom(const LoginResponse& from) { GOOGLE_CHECK_NE(&from, this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_status()) { set_status(from.status()); } if (from.has_address()) { mutable_address()->::message::NetAddress::MergeFrom(from.address()); } if (from.has_dailyrewarddata()) { mutable_dailyrewarddata()->::message::DailyRewardSystemData::MergeFrom(from.dailyrewarddata()); } if (from.has_olduid()) { set_olduid(from.olduid()); } if (from.has_version()) { set_version(from.version()); } if (from.has_gamename()) { set_gamename(from.gamename()); } if (from.has_gamedownload()) { set_gamedownload(from.gamedownload()); } } }
AboutWindow::AboutWindow() { typedef std::vector<Glib::ustring> UStringList; moApplicationSPtr application( moApplication::Instance() ); #if defined(DEMO_VERSION) || defined(BETA_VERSION) set_name( (application->GetName() + moWCString(" Demo")).c_str() ); #else set_name( application->GetName().c_str() ); #endif set_version( (application->GetVersion() + "." BUILD_VERSION_STRING).c_str() ); set_website( WEBSITE_URL ); set_translator_credits( gettext("translator-credits") ); const char* comments = "A Dungeon Master's Initiative Manager\n\n" #if defined(DEMO_VERSION) "This version of Turn Watcher is a demonstration version only.\n\n" #elif defined(BETA_VERSION) "This version of Turn Watcher is a beta version for demonstration purposes only, " "and is intended solely for registered beta testers. " "If you are not a registered beta tester, please uninstall this application and contact " "Made to Order Software Corporation to purchase a licensed copy.\n\n" #endif "Uses Gtk+ 2.15, Gtkmm 2.12, iconv, intl, PNG and zlib.\n" "Licensed under the GNU Public License v2.\n" "https://sourceforge.net/projects/turnwatcher/\n" ; // TODO: we need to fix the comment for demo versions to work properly #if defined(DEMO_VERSION) || defined(BETA_VERSION) set_comments( comments ); #else set_comments( gettext(comments) ); #endif UStringList authors; authors.push_back( "R. Douglas Barbieri" ); authors.push_back( "Alexis Wilke" ); set_authors( authors ); UStringList artists; artists.push_back( "Nikolai Lokteff" ); set_artists( artists ); // no gettext() for this one, doesn't need translation set_copyright( "Copyright (c) 2005-2013 Made to Order Software Corporation" ); //set_license( gettext(product_license) ); moWCString logopath( Common::GetFullPathnameForImage( ABOUT_IMAGE ) ); if( logopath != "" ) { Glib::RefPtr<Gdk::Pixbuf> logo = Gdk::Pixbuf::create_from_file( logopath.c_str() ); set_logo( logo ); } }
static void send_op(struct plock_op *op) { set_version(&op->info); INIT_LIST_HEAD(&op->list); spin_lock(&ops_lock); list_add_tail(&op->list, &send_list); spin_unlock(&ops_lock); wake_up(&send_wq); }
S32 dInitCapd(stMEMSINFO **pMEMSINFO, stCIFO **pCIFO) { int dRet; // Initiate log log_init(S_SSHM_LOG_LEVEL, getpid(), guiSeqProcID, LOG_PATH"/%s", gszMyProc); // Set signal SetUpSignal(); // NIFO ZONE if((*pMEMSINFO = nifo_init_zone((U8*)gszMyProc, guiSeqProcID, FILE_NIFO_ZONE)) == NULL) { log_print(LOGN_CRI, LH"FAILED IN nifo_init_zone NULL", LT); return -1; } // NIFO GROUP if((*pCIFO = gifo_init_group(FILE_CIFO_CONF, FILE_GIFO_CONF)) == NULL ) { log_print(LOGN_CRI, LH"FAILED IN gifo_init_group, cifo=%s, gifo=%s", LT, FILE_CIFO_CONF, FILE_GIFO_CONF); return -2; } /* FIDB 초기화 부분 삭제 // Initiate FIDB dRet = dInit_FIDB(); if(dRet < 0) { log_print(LOGN_INFO, LH"ERROR IN dInit_FIDB dRet:%d", LT, dRet); exit(0); } */ // Initiate port status memset( &stPortStatus[0], 0x00, DEF_PORTSTATUS_SIZE*2 ); fidb->mirrorsts[0] = CRITICAL; fidb->mirrorsts[1] = CRITICAL; fidb->mirrorActsts[0] = DEF_ACTIVE; fidb->mirrorActsts[1] = DEF_STANDBY; // Set version //if((dRet = set_version(SEQ_PROC_CAPD, vERSION)) < 0 ) if((dRet = set_version(S_SSHM_VERSION, guiSeqProcID, gszVersion)) < 0) { log_print(LOGN_CRI, LH"SET_VERSION ERROR(RET=%d,IDX=%d,VER=%s)", LT, dRet, SEQ_PROC_CAPD, gszVersion); } log_print(LOGN_CRI, "MIRR STS:%d,%d ACT STS:%d,%d DAGREC_LEN[%ld]", fidb->mirrorsts[0], fidb->mirrorsts[1], fidb->mirrorActsts[0], fidb->mirrorActsts[1], sizeof(dag_record_t)); return 0; }
// glade/gtkbuilder needs this constructor GscAboutDialog::GscAboutDialog(BaseObjectType* gtkcobj, const app_ui_res_ref_t& ref_ui) : AppUIResWidget<GscAboutDialog, false, Gtk::AboutDialog>(gtkcobj, ref_ui) { // Connect callbacks // APP_GTKMM_CONNECT_VIRTUAL(delete_event); // make sure the event handler is called APP_GTKMM_CONNECT_VIRTUAL(response); // Note: The dialogs have ESC accelerator attached by default. set_url_hook(sigc::mem_fun(*this, &GscAboutDialog::on_activate_url)); set_email_hook(sigc::mem_fun(*this, &GscAboutDialog::on_activate_email)); // Note: AboutDialog changed "name" property to "program-name" in gtk 2.12. // We don't set either, but rely on Glib::set_application_name() during init, which // works with both older and newer versions. set_version(VERSION); // set these properties here (after setting hooks) to make the links work. set_website("http://gsmartcontrol.berlios.de/"); set_license(LicenseTextResData().get_string()); // spammers go away set_copyright("Copyright (C) 2008 - 2009 Alexander Shaduri " "<ashaduri" "" "@" "" "" "gmail.com>"); std::string authors_str = AuthorsTextResData().get_string(); hz::string_any_to_unix(authors_str); std::list<Glib::ustring> authors; hz::string_split(authors_str, '\n', authors, true); for (std::list<Glib::ustring>::iterator iter = authors.begin(); iter != authors.end(); ++iter) { std::string s = *iter; hz::string_replace(s, " '@' ", "@"); // despammer hz::string_replace(s, " 'at' ", "@"); // despammer *iter = s; } set_authors(authors); set_documenters(authors); // run(); // don't use run - it's difficult to exit it manually. // show(); // shown by the caller to enable setting the parent window. }
bool configure(int argc, char *argv[]) { #ifndef NO_CONFIG assert(options_okay()); /* I'm not too proud of this. Read command line first, because it may change * where the configuration file is. Then read the configuration file, and * read the command line again to override any options that may be set by * both. */ if (!read_cmdline(argc, argv) || !read_config()) return false; read_cmdline(argc, argv); #else // Unconfigurable build; we only do a minimal options loop. for (int a=1; argv[a]; ++a) { if (argv[a][0] != '-') { fprintf(stderr, "Invalid argument: '%s'. Try the -h option.\n", argv[a]); return false; } switch (argv[a][1]) { case 'd': break; // Quietly ignored case 'e': set_erase(0); break; case 'h': short_usage(); break; // Does not return case 'p': set_pidfile(0); break; case 'q': break; // Quietly ignored case 'v': break; // Quietly ignored case 'V': set_version(0); break; // Does not return default: fprintf(stderr,"Invalid option: '%s'. Try -h instead.\n",argv[a]); return false; } } #endif if (!main_check_config() || !memory_check_config() || !swaps_check_config() || !swapfs_large_enough()) return false; if (inspect) exit(EXIT_SUCCESS); return to_swapdir(); }
void fe_init (void) { GConfClient *client; client = gconf_client_get_default (); gconf_client_add_dir (client, "/apps/xchat", GCONF_CLIENT_PRELOAD_NONE, NULL); g_object_unref (client); u = userlist_new (); gui.quit = FALSE; palette_init (); run_migrations (); initialize_gui_1 (); if (!preferences_exist ()) { run_setup_dialog (); } else { set_version (); } servlist_init (); initialize_gui_2 (); load_preferences (); run_main_window (opt_fullscreen); /* Force various window-related options to match our interaction model */ prefs.use_server_tab = TRUE; prefs.notices_tabs = FALSE; prefs.servernotice = TRUE; prefs.slist_skip = FALSE; /* If we don't have a specific DCC IP address, force get-from-server */ if (strlen (prefs.dcc_ip_str) == 0) { prefs.ip_from_server = TRUE; } /* Don't allow the core to autoload plugins. We use our own * method for autoloading. */ arg_skip_plugins = 1; if (not_autoconnect ()) { ConnectDialog *cd; cd = connect_dialog_new (); gtk_widget_show_all (GTK_WIDGET (cd)); } #ifdef USE_PLUGIN plugins_initialize (); #endif }
AboutDialog::AboutDialog(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& refGlade) : Gtk::AboutDialog(cobject), m_refGlade(refGlade) { #ifdef WIN32 Glib::RefPtr<Gdk::Pixbuf> logo = Aeskulap::IconFactory::load_from_file("aeskulap.png"); if(logo) { set_logo(logo); } #else set_logo_icon_name("aeskulap"); #endif set_version(VERSION); }
void LoginRequest::MergeFrom(const LoginRequest& from) { GOOGLE_CHECK_NE(&from, this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_wb_uuid()) { set_wb_uuid(from.wb_uuid()); } if (from.has_channel()) { set_channel(from.channel()); } if (from.has_version()) { set_version(from.version()); } } }
int main (int argc, char *argv[]) { int ret; char logbuffer[4096]; Init_logdebug( getpid(), "CAPD", "/DSC/APPLOG" ); ret = INIT_CAPD_IPCS(); if(ret < 0) { sprintf(logbuffer, "FAIL[init_ipc] [%s] %d.", strerror(errno), ret); dAppWrite(LOG_CRI, logbuffer); exit(0); } if( gen_info->DebugLevel == 0 ) gen_info->DebugLevel = LOG_INFO; /* temporary code (without CHSMD) */ if((ret=set_version(SEQ_PROC_CAPD, vERSION)) < 0 ) { dAppLog( LOG_CRI, "SET_VERSION ERROR(RET=%d,IDX=%d,VER=%s)\n", ret,SEQ_PROC_CAPD,vERSION); } if( check_my_run_status("CAPD") < 0) exit(0); if( keepalivelib_init("CAPD") < 0 ) exit(1); #if 0 if( argc==3 ) { test_func(argv[1], atoi(argv[2])); } #endif if( argc == 3 ) { test_func2(argv[1], atoi(argv[2])); exit(0); } else if( argc!=1 ) { exit(0); } SetupSignal(); dAppLog(LOG_CRI, "CAPD %s %d] [PROCESS INIT SUCCESS", vERSION, getpid()); dAppLog(LOG_CRI, "CAPD %s %d] [PROCESS STARTED", vERSION, getpid()); open_device_dlpi(DEV_PATH); return 0; } /***** end of main *****/
/** * Set named attribute. * * @param attr Name of the attribute (must be one of "id", "version", "changeset", "timestamp", "uid", "visible") * @param value Value of the attribute */ void set_attribute(const char* attr, const char* value) { if (!strcmp(attr, "id")) { set_id(value); } else if (!strcmp(attr, "version")) { set_version(value); } else if (!strcmp(attr, "changeset")) { set_changeset(value); } else if (!strcmp(attr, "timestamp")) { set_timestamp(osmium::Timestamp(value)); } else if (!strcmp(attr, "uid")) { set_uid(value); } else if (!strcmp(attr, "visible")) { set_visible(value); } }
void RseLogin::MergeFrom(const RseLogin& from) { GOOGLE_CHECK_NE(&from, this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from._has_bit(0)) { set_currenttimemillis(from.currenttimemillis()); } if (from._has_bit(1)) { set_id(from.id()); } if (from._has_bit(2)) { set_levelbasedonscore(from.levelbasedonscore()); } if (from._has_bit(3)) { set_myaccountislocked(from.myaccountislocked()); } if (from._has_bit(4)) { set_pop(from.pop()); } if (from._has_bit(5)) { set_rqid(from.rqid()); } if (from._has_bit(6)) { set_sync(from.sync()); } if (from._has_bit(7)) { set_timefromlastlogin(from.timefromlastlogin()); } } if (from._has_bits_[8 / 32] & (0xffu << (8 % 32))) { if (from._has_bit(8)) { set_timefromlastupdate(from.timefromlastupdate()); } if (from._has_bit(9)) { set_token(from.token()); } if (from._has_bit(10)) { set_userid(from.userid()); } if (from._has_bit(11)) { set_version(from.version()); } if (from._has_bit(12)) { set_vip(from.vip()); } } mutable_unknown_fields()->MergeFrom(from.unknown_fields()); }
/** * Construct the (Singleton) about dialogue. * * @return a pointer to the (Singleton) about dialogue. */ Gtk::AboutDialog * About::create() { auto about = new Gtk::AboutDialog; std::vector<Glib::ustring> authors; authors.push_back("Michael Lamothe <*****@*****.**>"); authors.push_back("Russel Winder <*****@*****.**>"); //std::vector<Glib::ustring> documentors; about->set_authors(authors); about->set_comments(APPLICATION_NAME " is a Digital Television (DVB) viewer for GTK+3."); about->set_copyright(u8"Copyright © 2010–2011 Michael Lamothe <[email protected]\nCopyright © 2014, 2016 Russel Winder <*****@*****.**>"); //about->set_documenters(documentors); about->set_license("This program is licenced under GNU General Public Licence (GPL) version 3."); about->set_logo(Gdk::Pixbuf::create_from_resource("/me-tv/images/me-tv.png")); about->set_name(APPLICATION_NAME); about->set_translator_credits("Translator Credits"); about->set_version(VERSION); return about; }
bool HDSeed::UpdateIndex(std::string& seed, const std::uint32_t index) const { std::uint32_t oldIndex = 0; auto serialized = SerializedSeed(seed, oldIndex); if (oldIndex > index) { otErr << OT_METHOD << __FUNCTION__ << ": Index values must always increase." << std::endl; return false; } serialized->set_index(index); if (serialized->version() < 2) { serialized->set_version(2); } return storage_.Store(*serialized, seed); }
void GeneralWriter :: progMsg ( const std :: string & name, uint32_t version, uint64_t done, uint64_t total ) { switch ( state ) { case opened: break; default: return; } size_t str_size = name . size (); if ( str_size == 0 ) throw "zero-length app-name"; if ( str_size > 0x100 ) str_size = 0x100; // timestamp time_t timestamp = time ( NULL ); if ( total == 0 ) throw "illegal total value: would divide by zero"; if ( done > total ) throw "illegal done value: greater than total"; // calculate percentage done double fpercent = ( double ) done / total; assert ( fpercent >= 0.0 && fpercent <= 100.0 ); uint8_t percent = ( uint8_t ) ( fpercent * 100 ); gwp_status_evt_v1 hdr; init ( hdr, 0, evt_progmsg ); set_pid ( hdr, pid ); set_version ( hdr, version ); set_timestamp ( hdr, ( uint32_t ) timestamp ); set_size ( hdr, str_size ); set_percent ( hdr, percent ); write_event ( &hdr . dad, sizeof hdr ); internal_write ( name.data (), str_size ); }
bool payment_address::set_encoded(const std::string& encoded_address) { const data_chunk decoded_address = decode_base58(encoded_address); // version + 20 bytes short hash + 4 bytes checksum if (decoded_address.size() != 25) return false; const uint8_t version = decoded_address[0]; if (!set_version(version)) return false; const data_chunk checksum_bytes( decoded_address.end() - 4, decoded_address.end()); // version + short hash const data_chunk main_body( decoded_address.begin(), decoded_address.end() - 4); // verify checksum bytes if (generate_sha256_checksum(main_body) != cast_chunk<uint32_t>(checksum_bytes)) return false; std::copy(main_body.begin() + 1, main_body.end(), hash_.begin()); return true; }
inline void request::process(std::string::iterator begin, std::string::iterator end) { std::string::iterator cursor_start = begin; std::string::iterator cursor_end = std::find(begin,end,' '); if (cursor_end == end) { throw exception("Invalid request line1",status_code::bad_request); } set_method(std::string(cursor_start,cursor_end)); cursor_start = cursor_end+1; cursor_end = std::find(cursor_start,end,' '); if (cursor_end == end) { throw exception("Invalid request line2",status_code::bad_request); } set_uri(std::string(cursor_start,cursor_end)); set_version(std::string(cursor_end+1,end)); }
MyAboutDialog(): Gtk::AboutDialog(),m_link(PACKAGE_URL,PACKAGE_URL){ set_version(PACKAGE_VERSION); std::vector<Glib::ustring> authors; authors.push_back("Quentin Geissmann<*****@*****.**>"); set_authors(authors); set_license("GPL_3_0"); set_copyright("Quentin Geissmann 2012-2013"); #if defined _WIN64 || defined _WIN32 std::stringstream ss; ss<<ABOUT_TEXT<<std::endl<<PACKAGE_URL; set_comments(ss.str()); #else set_website(PACKAGE_URL); set_website_label("Website"); set_comments(ABOUT_TEXT); #endif set_logo(Gui_PixbufOpener::pixbufOpen(LOGO_IMG)); }
//############################################################################## //############################################################################## void BerkeleyDB::add_new_range_version() { RANGE_LOG_FUNCTION(); this->init_info(); auto lock = info_->write_lock(record_type::GRAPH_META, "graph_list"); std::string buf = info_->get_record(record_type::GRAPH_META, "range_changelist"); ChangeList changes; if(!buf.empty()) { changes.ParseFromString(buf); } std::unordered_map<std::string, uint64_t> vermap; for (auto &gname : listGraphInstances()) { auto ginst = getGraphInstance(gname); vermap[gname] = ginst->version(); } ChangeList_Change *c = changes.add_change(); for(auto &verinfo : vermap) { auto item = c->add_items(); item->set_key(verinfo.first); item->set_version(verinfo.second); } struct timeval cur_time; gettimeofday(&cur_time, NULL); auto ts = c->mutable_timestamp(); ts->set_seconds(cur_time.tv_sec); ts->set_msec(cur_time.tv_usec / 1000); changes.set_current_version(changes.current_version() + 1); info_->commit_record(std::make_tuple(record_type::GRAPH_META, "range_changelist", 0, changes.SerializeAsString())); }
DictInfo& DictInfo::operator=(const DictInfo& dict_info) { clear(); ifo_file_name = dict_info.ifo_file_name; if(dict_info.is_wordcount()) set_wordcount(dict_info.get_wordcount()); if(dict_info.is_filecount()) set_filecount(dict_info.get_filecount()); if(dict_info.is_synwordcount()) set_synwordcount(dict_info.get_synwordcount()); if(dict_info.is_bookname()) set_bookname(dict_info.get_bookname()); if(dict_info.is_author()) set_author(dict_info.get_author()); if(dict_info.is_email()) set_email(dict_info.get_email()); if(dict_info.is_website()) set_website(dict_info.get_website()); if(dict_info.is_date()) set_date(dict_info.get_date()); if(dict_info.is_description()) set_description(dict_info.get_description()); if(dict_info.is_index_file_size()) set_index_file_size(dict_info.get_index_file_size()); if(dict_info.is_sametypesequence()) set_sametypesequence(dict_info.get_sametypesequence()); if(dict_info.is_dicttype()) set_dicttype(dict_info.get_dicttype()); if(dict_info.is_version()) set_version(dict_info.get_version()); if(dict_info.is_infotype()) set_infotype(dict_info.get_infotype()); f_idxoffsetbits = dict_info.f_idxoffsetbits; return *this; }
void Sess::MergeFrom(const Sess& from) { GOOGLE_CHECK_NE(&from, this); kvs_.MergeFrom(from.kvs_); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_id()) { set_id(from.id()); } if (from.has_type()) { set_type(from.type()); } if (from.has_lasttime()) { set_lasttime(from.lasttime()); } if (from.has_sessid()) { set_sessid(from.sessid()); } if (from.has_consvid()) { set_consvid(from.consvid()); } if (from.has_version()) { set_version(from.version()); } } }
static int little_unlock(sqlite3_file *file, int lock) { int res; little_file *self = (little_file*)file; trace("LOCK DOWN %s...\n", locktypeName(lock)); switch (lock) { case SQLITE_LOCK_NONE: free_shared(self->name, self->shared_lock_number); flush(self); self->lastblock = -1; self->shared_lock_number = -1; break; case SQLITE_LOCK_SHARED: set_version(self); res = free_exclusive(self->name); if (res < 0) return SQLITE_ERROR; self->shared_lock_number = res; break; default: return SQLITE_ERROR; } trace("LOCK DOWN %s OK\n", locktypeName(lock)); return SQLITE_OK; }
/******************************************************************************* MAIN *******************************************************************************/ int main() { int dRet, i, dCheckTime; OFFSET offset; U8 *pNode; U8 *pDATA; U8 *pBODYDATA; Capture_Header_Msg *pCAPHEAD; INFO_ETH *pINFOETH; TCP_INFO *pTCPINFO; log_init(S_SSHM_LOG_LEVEL, getpid(), SEQ_PROC_A_FTP, LOG_PATH"/A_FTP", "A_FTP"); /* Process Initial */ dRet = dInitProc(); if(dRet < 0) { log_print( LOGN_CRI, "[ERR] [PROCESS INIT FAIL] [RET]:[%d]", dRet); exit(0); } dRet = set_version(S_SSHM_VERSION, SEQ_PROC_A_FTP,vERSION); if ( dRet < 0 ) log_print(LOGN_DEBUG,"set_version error(ret=%d,idx=%d,ver=%s)\n",dRet,SEQ_PROC_A_FTP,vERSION); log_print( LOGN_CRI, "[A_FTP] PROCESS STARTED : VERSION[%s]", vERSION ); dCheckTime = time(0); while(JiSTOPFlag) { g_lCurTime = time(0); if ( dCheckTime!= g_lCurTime ) { dTimeOutSess(); dCheckTime = g_lCurTime; } for( i=0; i<MAX_MSG_CNT; i++ ) { if((offset = gifo_read(pstMEMSINFO, gpCIFO, SEQ_PROC_A_FTP)) > 0) { pNode = nifo_ptr(pstMEMSINFO, offset); pCAPHEAD = (Capture_Header_Msg *)nifo_get_value(pstMEMSINFO, CAP_HEADER_NUM, offset); pINFOETH = (INFO_ETH *)nifo_get_value(pstMEMSINFO, INFO_ETH_NUM, offset); pTCPINFO = (TCP_INFO *)nifo_get_value(pstMEMSINFO, TCP_INFO_DEF_NUM, offset); pDATA = (U8 *)nifo_get_value(pstMEMSINFO, ETH_DATA_NUM, offset); pBODYDATA = &pDATA[pTCPINFO->uiSOffset]; dRet = dSvcProcess( pTCPINFO, pCAPHEAD, pBODYDATA ); if( dRet < 0 ) log_print( LOGN_INFO, "ERROR IN dSvcProcess dRet:%d", dRet ); nifo_node_delete(pstMEMSINFO, pNode); } else { usleep(0); break; } } /* FOR END (Msg-Q) */ usleep(0); } /* while-loop end (main) */ FinishProgram(); exit(0); }
int main() { int dRet, i; time_t tCurrentTime, tCheckTime; UCHAR *pNODE; Capture_Header_Msg *pCAPHEAD; INFO_ETH *pINFOETH; /* INITIALIZE log_print INFORAMTION */ log_init(S_SSHM_LOG_LEVEL, getpid(), SEQ_PROC_A_SCTP, LOG_PATH"/A_SCTP", "A_SCTP"); /* INITIALIZE S_SCTP INIT */ dRet = dInitSCTP(); if( dRet < 0 ) { log_print( LOGN_CRI, "[ERROR] FAIL IN dInitSCTP() dRet:%d", dRet ); exit(0); } /* SET TIME INFO */ time( &tCurrentTime ); tCheckTime = tCurrentTime; if((dRet = set_version(S_SSHM_VERSION, SEQ_PROC_A_SCTP, vERSION)) < 0 ) { log_print(LOGN_CRI, "SET_VERSION ERROR(RET=%d,IDX=%d,VER=%s)", dRet, SEQ_PROC_A_SCTP, vERSION); } log_print( LOGN_CRI, "## A_SCTP PROCESS START (%s)0##", vERSION); /* MAIN WHILE LOOP */ while( gdStopFlag ) { time( &tCurrentTime ); for( i=0; i<1000; i++ ) { gdOffset = gifo_read(gpMEMSINFO, gpCIFO, SEQ_PROC_A_SCTP); if (gdOffset > 0) { pCAPHEAD = (Capture_Header_Msg *)nifo_get_value(gpMEMSINFO, CAP_HEADER_NUM, gdOffset); pINFOETH = (INFO_ETH *)nifo_get_value(gpMEMSINFO, INFO_ETH_NUM, gdOffset); pNODE = nifo_ptr(gpMEMSINFO, gdOffset); if( pINFOETH == NULL ) { log_print( LOGN_CRI, "[%s][%s.%d] ERROR : Received node is NULL ", __FILE__, __FUNCTION__, __LINE__); nifo_node_delete(gpMEMSINFO, pNODE); } else { dRet = dAnalyzeSCTP(pCAPHEAD, pINFOETH, pNODE); if( dRet < 0 ) { log_print( LOGN_INFO, "ERROR IN dAnalyzeSCTP dRet:%d", dRet ); nifo_node_delete(gpMEMSINFO, pNODE); } } } else { usleep(0); break; } } /* CHECK FOR TIMEOUT */ if( tCurrentTime != tCheckTime ) { if( tCurrentTime%5 == 0 ) log_print( LOGN_INFO, "ASSO_CNT:%u, STACK_CNT:%u", pstASSOSTACKTbl->stAssoTbl.uiAssoCount, pstASSOSTACKTbl->stStackTbl.uiCurrCount ); tCheckTime = tCurrentTime; } } FinishProgram(); return 0; }
/*------------------------------------------------------------------------------ ------------------------------------------------------------------------------*/ int ixpc_initial (void) { char *env,tmp[64],fname[256]; int key,i,id; if ((env = getenv(MY_SYS_NAME)) == NULL) { fprintf(stderr,"[ixpc_init] not found %s environment name\n", MY_SYS_NAME); return -1; } strcpy (mySysName, env); strcpy (myAppName, "IXPC"); currentTime = lastPingTestTime = time(0); //commlib_setupSignals (NULL); SetUpSignal (); memset ((void*)msgQRoutTbl, 0, sizeof(msgQRoutTbl)); memset ((void*)sockRoutTbl, 0, sizeof(sockRoutTbl)); // if (keepalivelib_init (myAppName) < 0) return -1; //socklib_initial(); if ((env = getenv(IV_HOME)) == NULL) { fprintf(stderr,"[ixpc_init] not found %s environment name\n", IV_HOME); return -1; } sprintf(fname,"%s/%s", env, SYSCONF_FILE); /* ½Ã½ºÅÛ ³»ºÎ applicationµéÀÇ À̸§°ú queue key¸¦ Àоî msgQRoutTbl¿¡ settingÇÑ´Ù. */ if (ixpc_initMsgQRoutTbl(fname) < 0) return -1; /* tcp·Î Á¢¼ÓÇÒ remote ½Ã½ºÅÛµéÀÇ À̸§°ú ip address¸¦ Àоî sockRoutTbl¿¡ settingÇÑ´Ù. */ if (ixpc_initSockRoutTbl(fname) < 0) return -1; /* config file¿¡¼ ÀÚ½ÅÀÇ message queue key¸¦ Àоî, attach queue */ if (conflib_getNthTokenInFileSection (fname, "[APPLICATIONS]", myAppName, 1, tmp) < 0) return -1; key = strtol(tmp,0,0); if ((ixpcQid = msgget(key,IPC_CREAT|0666)) < 0) { fprintf(stderr,"[ixpc_init] msgget fail; key=0x%x,err=%d(%s)\n",key,errno,strerror(errno)); return -1; } //printf("IXPC key : %d, qid : %d\n", key, ixpcQid); /* config file¿¡¼ ÀÚ½ÅÀÇ bind port number¸¦ Àоî bindingÇÑ´Ù. */ if (conflib_getNthTokenInFileSection (fname, "[SOCKET_PORT]", "IXPC", 1, tmp) < 0) return -1; ixpcPortNum = strtol(tmp,0,0); if (socklib_initTcpBind(ixpcPortNum) < 0) return -1; /* IXPC connection »óÅ Á¤º¸¸¦ À§ÇÑ shared memory ÃʱâÈ */ if (conflib_getNthTokenInFileSection (fname, "[SHARED_MEMORY_KEY]", "SHM_IXPC_CON", 1, tmp) < 0) return -1; key = strtol(tmp,0,0); if ((id = (int)shmget (key, sizeof(IxpcConSts), IPC_CREAT|0666)) < 0) { fprintf(stderr,"IXPC con shmget fail; key=0x%x, err=%d(%s)\n", key, errno, strerror(errno) ); return -1; } if ((ixpcCON = (IxpcConSts*) shmat (id,0,0)) == (IxpcConSts*)-1) { fprintf(stderr,"IXPC con shmat fail; key=0x%x, err=%d(%s)\n", key, errno, strerror(errno) ); return -1; } for ( i=0; i<SYSCONF_MAX_ASSO_SYS_NUM;i++ ){ if ( sockRoutTbl[i].sysName[0] == 0 ) { ixpcCON->ixpcCon[i].name[0] = 0; continue; } strcpy ( ixpcCON->ixpcCon[i].name, sockRoutTbl[i].sysName); ixpcCON->ixpcCon[i].connSts = SFM_LAN_DISCONNECTED; } if(set_version(SEQ_PROC_IXPC,vERSION) < 0) { fprintf (stderr,"[ixpc_initial] set_version failed\n"); return -1; } /* sockRoutTbl¿¡ settingµÈ ÁÖ¼Ò·Î remote ½Ã½ºÅÛÀÇ ixpc¿¡ connectÇÑ´Ù. */ #if 0 if (!strcmp(mySysName, "SCMA")) { system ("route add -host DSCM SCMA"); system ("route add -host DSCM SCMA_S"); } else { system ("route add -host DSCM SCMB"); system ("route add -host DSCM SCMB_S"); } #endif /* watch-dog ¢¬¨¨öAAo¢¬| ¡¾¢¬¨ù¨¬CO ¢Ò¡× ¡íc¢¯eCO SYSTEM_LABEL AI¢¬¡× ¡¾¢¬CN¢¥U */ if (conflib_getNthTokenInFileSection(fname, "GENERAL", "SYSTEM_LABEL", 1, sysLabel) < 0) return -1; if(conflib_getNthTokenInFileSection(fname, "SHARED_MEMORY_KEY", "SHM_LOC_SADB", 1, tmp) < 0) return -1; key = strtol(tmp, 0, 0); if( (id = (int)shmget(key, sizeof(SFM_SysCommMsgType), 0666 | IPC_CREAT)) < 0) { if(errno != ENOENT) { fprintf(stderr, "[%s:%s:%d] shmget fail; key=0x%x, err=%d(%s)\n", __FILE__, __FUNCTION__, __LINE__, key, errno, strerror(errno)); return -1; } } if( (loc_sadb = (SFM_SysCommMsgType*)shmat(id, 0, 0)) == (SFM_SysCommMsgType*)-1) { fprintf(stderr, "[%s:%s:%d] shmat fail; key=0x%x, err=%d(%s)\n", __FILE__, __FUNCTION__, __LINE__, key, errno, strerror(errno)); return -1; } ixpc_checkConnections (); /* log fileµéÀ» openÇÑ´Ù. */ if (ixpc_initLog () < 0) return -1; logPrint (trcLogId,FL,"%s startup...\n", myAppName); logPrint (trcErrLogId,FL,"%s startup...\n", myAppName); return 1; } /** End of ixpc_initial **/
xuuid_application::xuuid_application(int argc, xchar* argv[], const xprogram_options::options_description& options_description) : xapplication(argc, argv, options_description) { set_name(_X("xuuid")); set_version(MAJOR_VALUE, MINOR_VALUE, RELEASE_VALUE, BUILD_VALUE); }
/** * Implement func. */ int main() { int i; int dRet, dSendFlag = 1; OFFSET offset; UCHAR *pNode, *pNextNode; UCHAR *p, *pdata; U32 type, len; S32 ismalloc; st_TraceMsgHdr *pTRACEHDR = NULL; UCHAR *pPACKET = NULL; int TraceHdrLen, PacketLen; char vERSION[7] = "R3.0.0"; g_dLogInStatus = DEF_LOGOUT; log_init(S_SSHM_LOG_LEVEL,getpid(), SEQ_PROC_CI_LOG, LOG_PATH"/CI_LOG", "CI_LOG"); dRet = dInitCI_LOG(&pMEMSINFO); if( dRet < 0 ) { log_print( LOGN_CRI, "Main : Failed in dInitProc" ); exit(0); } if((dRet = set_version(S_SSHM_VERSION, SEQ_PROC_CI_LOG, vERSION)) < 0 ) { log_print(LOGN_CRI, "SET_VERSION ERROR(RET=%d,IDX=%d,VER=%s)", dRet, SEQ_PROC_CI_LOG, vERSION); } log_print( LOGN_CRI, "CI_LOG(%s) : PROCESS INIT SUCCESS, PROCESS START", vERSION); while( g_JiSTOPFlag ) { /*** #### CHECK LOGOUT #### ****/ if( g_dLogInStatus == DEF_LOGOUT ) { if(dCheckSock() < 0) { log_print(LOGN_CRI, "dProc_Msg : failed in dCheckSock"); for( i=0; i<DEF_LOGOUT_MSGREAD; i++ ) { if((offset = gifo_read(pMEMSINFO, gpCIFO, SEQ_PROC_CI_LOG)) > 0) { pNode = nifo_ptr(pMEMSINFO, offset); nifo_node_delete(pMEMSINFO, pNode); } else break; } continue; } } /*** #### Check if MQ Msg In -> Process ##### ****/ for( i = 0; i < MAX_MQCHK_LOOP_CNT; i++ ) { if((offset = gifo_read(pMEMSINFO, gpCIFO, SEQ_PROC_CI_LOG)) > 0) { pNode = nifo_ptr(pMEMSINFO, offset); pNextNode = pNode; do { p = pNextNode; while(p != NULL) { dSendFlag = 1; if((dRet = nifo_read_tlv_cont(pMEMSINFO, pNextNode, &type, &len, &pdata, &ismalloc, &p)) < 0) break; log_print(LOGN_INFO, "TYPE=%d:%s LEN=%d ISMAL=%s", type, PrintTYPE(type), len, (ismalloc == DEF_READ_MALLOC) ? "MALL" : "ORI"); switch(type) { case LOG_HTTP_TRANS_DEF_NUM: case LOG_PAGE_TRANS_DEF_NUM: case LOG_TCP_SESS_DEF_NUM: dSendFlag = dCheckLogType(type, (char*)pdata); case START_CALL_NUM: case STOP_CALL_NUM: case LOG_SIGNAL_DEF_NUM: case LOG_PISIGNAL_DEF_NUM: case LOG_IM_SESS_DEF_NUM: case LOG_VT_SESS_DEF_NUM: case LOG_SIP_TRANS_DEF_NUM: case LOG_MSRP_TRANS_DEF_NUM: case LOG_VOD_SESS_DEF_NUM: case START_SERVICE_DEF_NUM: case LOG_DIALUP_SESS_DEF_NUM: case LOG_DNS_DEF_NUM: case LOG_FTP_DEF_NUM: case LOG_INET_DEF_NUM: case LOG_ITCP_SESS_DEF_NUM: case LOG_IHTTP_TRANS_DEF_NUM: case START_PI_DATA_RECALL_NUM: case START_RP_DATA_RECALL_NUM: case START_PI_SIG_RECALL_NUM: case START_RP_SIG_RECALL_NUM: case STOP_PI_RECALL_NUM: case STOP_RP_RECALL_NUM: /**** ##### SEND LOG TO TAM_APP ##### ********/ if(dSendFlag) { dRet = dSndMsgProc(type, len, (char*)pdata); if( dRet < 0 ) { log_print( LOGN_CRI, "ERROR : FAILED IN dSndMsgProc" ); /* If Client is SND SOCKET ERROR, re-connect server */ g_dLogInStatus = DEF_LOGOUT; close(g_dServerSocket); } } break; case st_TraceMsgHdr_DEF_NUM: /* TRACE INFO */ pTRACEHDR = (st_TraceMsgHdr *)pdata; TraceHdrLen = len; break; case ETH_DATA_NUM: pPACKET = pdata; PacketLen = len; break; case LOG_ONLINE_TRANS_DEF_NUM: case LOG_IV_DEF_NUM: case LOG_JNC_TRANS_DEF_NUM: case LOG_CALL_TRANS_DEF_NUM: case TCP_INFO_DEF_NUM: case HTTP_REQ_HDR_NUM: case HTTP_REQ_BODY_NUM: case HTTP_RES_HDR_NUM: case HTTP_RES_BODY_NUM: case CAP_HEADER_NUM: case INFO_ETH_NUM: /* No Transfer LOG Type */ break; default: log_print(LOGN_CRI, "NOT SUPPORT LOG TYPE=[%d]", type); break; } /* THIS NODE IS TRACE INFOMATION */ if( pTRACEHDR && pPACKET ) { dRet = dSndTraceMsgProc((char *)pTRACEHDR, (char *)pPACKET, TraceHdrLen, PacketLen); if( dRet < 0 ) { log_print( LOGN_CRI, "ERROR : FAILED IN dSndTraceMsgProc" ); /* If Client is SND SOCKET ERROR, re-connect server */ g_dLogInStatus = DEF_LOGOUT; close(g_dServerSocket); } pTRACEHDR = NULL; pPACKET = NULL; } if(ismalloc == DEF_READ_MALLOC){ free(pdata); } } pNextNode = (U8 *)nifo_entry(nifo_ptr(pMEMSINFO, ((NIFO *)pNextNode)->nont.offset_next), NIFO, nont); } while(pNode != pNextNode); /* DELETE ALL NODE */ nifo_node_delete(pMEMSINFO, pNode); } else { usleep(0); break; } } /* for loop */ /*** #### Event Check And Process #### *****/ if( dCheckNProc_Event() < 0 ) log_print( LOGN_WARN, "dProc_Msg : Failed in dCheckNProc_Event()" ); } /* WHILE() */ FinishProgram(); return 0; }
S32 main(S32 argc, S8 *argv[]) { S32 dRet; /**< 함수 Return 값 */ OFFSET offset; U8 *pNode; U8 *pNextNode; U8 *p, *data; S32 type, len, ismalloc; U8 *pBodyNode; U16 URLbuf_len; U8 URLbuf[BUFSIZ]; BODY *pBODY; S32 dSeqProcID; char *pdata_req_hdr; char *pdata_req_body; char *pdata_resp_hdr; char *pdata_resp_body; LOG_HTTP_TRANS *pLOG_HTTP_TRANS; int data_req_hdr_len; int data_req_body_len; int data_resp_hdr_len; int data_resp_body_len; char vERSION[7] = "R3.0.0"; /* log_print 초기화 */ log_init(S_SSHM_LOG_LEVEL, getpid(), SEQ_PROC_A_2G, LOG_PATH"/A_2G", "A_2G"); /* A_2G 초기화 */ if((dRet = dInit2G(&pMEMSINFO)) < 0) { log_print(LOGN_CRI, "[%s][%s.%d] dInit2G dRet[%d]", __FILE__, __FUNCTION__, __LINE__, dRet); exit(0); } if((dRet = set_version(S_SSHM_VERSION, SEQ_PROC_A_2G, vERSION)) < 0 ) { log_print(LOGN_CRI, "SET_VERSION ERROR(RET=%d,IDX=%d,VER=%s)", dRet, SEQ_PROC_A_2G, vERSION); } log_print(LOGN_CRI, "START 2G(%s) CALL[%d]", vERSION, gACALLCnt); /* MAIN LOOP */ while(giStopFlag) { if((offset = gifo_read(pMEMSINFO, gpCIFO, SEQ_PROC_A_2G)) > 0) { log_print(LOGN_INFO, "======================================================================"); /* DB LOG 전송을 목적으로 하는 NODE (삭제 하지 않고 전송하기 위함 )*/ pNode = nifo_ptr(pMEMSINFO, offset); pNextNode = pNode; pdata_req_hdr = NULL; pdata_req_body = NULL; pdata_resp_hdr = NULL; pdata_resp_body = NULL; pLOG_HTTP_TRANS = NULL; pBodyNode = NULL; URLbuf_len = 0; URLbuf[0] = 0x00; pBODY = NULL; do { p = pNextNode; while(p != NULL) { if((dRet = nifo_read_tlv_cont(pMEMSINFO, pNextNode, (U32*)&type, (U32*)&len, &data, &ismalloc, &p)) < 0) break; log_print(LOGN_INFO, "####################################################################"); log_print(LOGN_INFO, "TYPE[%d][%s] LEN[%d] ISMALLOC[%s]", type, PrintTYPE(type), len, (ismalloc == DEF_READ_MALLOC) ? "MALLOC MEM" : "ORIGIN MEM"); switch(type) { case LOG_HTTP_TRANS_DEF_NUM: pLOG_HTTP_TRANS = (LOG_HTTP_TRANS *) data; // LOG_HTTP_TRANS_Prt("PRINT LOG_HTTP_TRANS1", pLOG_HTTP_TRANS); // URL에서 port 제거한 buffer한개 가지고 있기 : shlee // Set URLbuf URLbuf_len dRet = Remake_URL_Buf( pLOG_HTTP_TRANS->usURLSize, pLOG_HTTP_TRANS->szURL, &URLbuf_len, URLbuf); if(dRet < 0) { log_print(LOGN_CRI, "%s REMAKE_URL_BUF Err[%d]", (char *)__FUNCTION__, dRet); URLbuf_len = 0; URLbuf[0] = 0x00; } break; case HTTP_REQ_HDR_NUM: pdata_req_hdr = (char *) data; data_req_hdr_len = len; log_print(LOGN_INFO, "TYPE[%s] len %d DATA[%.*s]", PrintTYPE(type), len ,len, data); if(pLOG_HTTP_TRANS){ if(pdata_req_hdr && data_req_hdr_len){ LOG_HTTP_TRANS_WIPI_REQ_HDR_LEX(pdata_req_hdr,data_req_hdr_len,(char *)pLOG_HTTP_TRANS); } } else { log_print(LOGN_CRI, "ERROR %s : LOG_HTTP_TRANS가 존재하지 않는다!!!",PrintTYPE(type)); } break; case HTTP_REQ_BODY_NUM: pdata_req_body = (char *) data; data_req_body_len = len; log_print(LOGN_INFO, "TYPE[%s] len %d DATA[%.*s]", PrintTYPE(type), len ,len, data); if(pLOG_HTTP_TRANS){ } else { log_print(LOGN_CRI, "ERROR %s : LOG_HTTP_TRANS가 존재하지 않는다!!!",PrintTYPE(type)); } break; case HTTP_RES_HDR_NUM: pdata_resp_hdr = (char *) data; data_resp_hdr_len = len; log_print(LOGN_INFO, "TYPE[%s] len %d DATA[%.*s]", PrintTYPE(type), len ,len, data); if(pLOG_HTTP_TRANS){ if(pdata_resp_hdr && data_resp_hdr_len){ LOG_HTTP_TRANS_WIPI_RESP_HDR_LEX(pdata_resp_hdr,data_resp_hdr_len,(char *)pLOG_HTTP_TRANS); } } else { log_print(LOGN_CRI, "ERROR %s : LOG_HTTP_TRANS가 존재하지 않는다!!!",PrintTYPE(type)); } break; case HTTP_RES_BODY_NUM: pdata_resp_body = (char *) data; data_resp_body_len = len; log_print(LOGN_INFO, "TYPE[%s] len %d DATA[%.*s]", PrintTYPE(type), len ,len, data); if(pLOG_HTTP_TRANS){ if(pdata_resp_body && data_resp_body_len){ U8 *pbody_data; st_LIST UrlParseList; if((pBodyNode = nifo_node_alloc(pMEMSINFO)) == NULL) { log_print(LOGN_CRI, "[%s][%s.%d] NODE IS NULL", __FILE__, __FUNCTION__, __LINE__); break; } if((pbody_data = nifo_tlv_alloc(pMEMSINFO, pBodyNode, BODY_DEF_NUM, BODY_SIZE, DEF_MEMSET_OFF)) == NULL) { log_print(LOGN_CRI, "[%s][%s.%d] TLV IS NULL", __FILE__, __FUNCTION__, __LINE__); break; } // URLParseList Set : shlee dRet = Devide_ReqURL(URLbuf_len, URLbuf, &UrlParseList); if(dRet < 0) { /* Error */ log_print(LOGN_CRI, "Devide_ReqURL Ret =[%d] < 0 [%d] [%.*s]", dRet, URLbuf_len, MAX_URL_SIZE, URLbuf); break; } else if(dRet > 0) { /* Warning */ log_print(LOGN_CRI, "Devide_ReqURL Ret =[%d] > 0 [%d] [%.*s]", dRet, URLbuf_len, MAX_URL_SIZE, URLbuf); } pBODY = (BODY *)pbody_data; BODY_LEX(pdata_resp_body, data_resp_body_len, pbody_data, &UrlParseList, pMEMSINFO); pLOG_HTTP_TRANS->link_cnt = pBODY->link_cnt; pLOG_HTTP_TRANS->href_cnt = pBODY->href_cnt; log_print(LOGN_INFO, "HREF_CNT %d", pLOG_HTTP_TRANS->href_cnt); } } else { log_print(LOGN_CRI, "ERROR %s : LOG_HTTP_TRANS가 존재하지 않는다!!!",PrintTYPE(type)); } break; default: log_print(LOGN_INFO, "????? UNKNOWN TYPE[%d]", type); break; } if(ismalloc == DEF_READ_MALLOC){ free(data); } } pNextNode = (U8 *)nifo_entry(nifo_ptr(pMEMSINFO, ((NIFO *)pNextNode)->nont.offset_next), NIFO, nont); } while(pNode != pNextNode); if(pLOG_HTTP_TRANS){ /* download 처리 */ int dn = 0; a2g_dn((char*)pLOG_HTTP_TRANS->szLOGURL, pLOG_HTTP_TRANS->usLOGURLSize, &dn); if(dn != 1) { pLOG_HTTP_TRANS->usSvcL4Type = L4_DN_2G_NODN; } /* DATA NODE DELETE */ pNextNode = (U8 *)nifo_entry(nifo_ptr(pMEMSINFO, ((NIFO *)pNode)->nont.offset_next), NIFO, nont); nifo_node_unlink_nont(pMEMSINFO, pNode); nifo_node_delete(pMEMSINFO, pNextNode); if(pBodyNode){ nifo_node_link_nont_prev(pMEMSINFO, pNode, pBodyNode); } dSeqProcID = SEQ_PROC_A_CALL + ( pLOG_HTTP_TRANS->uiClientIP % gACALLCnt ); if((dRet = dSend_2G_Data(pMEMSINFO, dSeqProcID, pNode)) < 0) { log_print(LOGN_CRI, LH"FAILED IN dSend Data to %d"EH, LT, dSeqProcID, ET); break; } } else { log_print(LOGN_CRI,"2G : pLOG_HTTP_TRANS is NULL"); /* Node 삭제 */ nifo_node_delete(pMEMSINFO, pNode); } } else { usleep(0); } } FinishProgram(); return 0; }
int main(int argc, char *argv[]) { GOptionContext *context; GError *err = NULL; guint signal; set_version(); context = g_option_context_new(NULL); g_option_context_add_main_entries(context, options, NULL); if (g_option_context_parse(context, &argc, &argv, &err) == FALSE) { if (err != NULL) { g_printerr("%s\n", err->message); g_error_free(err); } else g_printerr("An unknown error occurred\n"); exit(EXIT_FAILURE); } g_option_context_free(context); if (option_version == TRUE) { printf("%s\n", VERSION); exit(EXIT_SUCCESS); } signal = setup_signalfd(); if (!signal) return EXIT_FAILURE; if (option_dbg || option_mgmt_dbg) __btd_log_init("*", 0); else __btd_log_init(NULL, 0); if (!set_capabilities()) { __btd_log_cleanup(); g_source_remove(signal); return EXIT_FAILURE; } quit_timeout = g_timeout_add_seconds(STARTUP_GRACE_SECONDS, quit_eventloop, NULL); if (quit_timeout == 0) { error("Failed to init startup timeout"); __btd_log_cleanup(); g_source_remove(signal); return EXIT_FAILURE; } if (!bt_bluetooth_start(option_index, option_mgmt_dbg, adapter_ready)) { __btd_log_cleanup(); g_source_remove(quit_timeout); g_source_remove(signal); return EXIT_FAILURE; } /* Use params: mtu = 0, flags = 0 */ start_sdp_server(0, 0); DBG("Entering main loop"); event_loop = g_main_loop_new(NULL, FALSE); g_main_loop_run(event_loop); g_source_remove(signal); if (quit_timeout > 0) g_source_remove(quit_timeout); cleanup_services(); stop_sdp_server(); bt_bluetooth_cleanup(); g_main_loop_unref(event_loop); /* If no adapter was initialized, hal_ipc is NULL */ if (hal_ipc) { ipc_unregister(hal_ipc, HAL_SERVICE_ID_CORE); ipc_cleanup(hal_ipc); } info("Exit"); __btd_log_cleanup(); free(config_vendor); free(config_model); free(config_name); free(config_serial); free(config_fw_rev); free(config_hw_rev); return EXIT_SUCCESS; }