int MySQLConn::connect() { MYSQL* result = mysql_real_connect(conn_, option_.host.c_str(), option_.user.c_str(), option_.passwd.c_str(), option_.database.c_str(), option_.port, nullptr, 0); if (!result) { LOG_FATAL("event=[connectmysqlfailed] type=[connect]"); return Status::FAILED; } int ret = mysql_set_character_set(conn_, "utf8"); if (ret) { LOG_FATAL("connect mysql failed type=[setcharset]"); return Status::FAILED; } LOG_INFO("connected to mysql host=[%s:%d]", option_.host.c_str(), option_.port); return Status::OK; }
void Backup::figure_out_start_snapshot() { LOG_INFO(__FUNCTION__); VERIFY(source_snapshot_persistor); start_snapshot_ = source_ptree.get_optional<SnapshotName>("start_snapshot"); if(start_snapshot_ and not source_snapshot_persistor->snapshotExists(*start_snapshot_)) { LOG_FATAL("Could not find start snapshot " << *start_snapshot_ << " in source"); throw BackupException("Could not find snapshot"); } }
static int shm_initialise(RCL_Instance instance) { int id, param, perm; char *s; struct shmTime *shm; param = atoi(RCL_GetDriverParameter(instance)); s = RCL_GetDriverOption(instance, "perm"); perm = s ? strtol(s, NULL, 8) & 0777 : 0600; id = shmget(SHMKEY + param, sizeof (struct shmTime), IPC_CREAT | perm); if (id == -1) { LOG_FATAL(LOGF_Refclock, "shmget() failed"); return 0; } shm = (struct shmTime *)shmat(id, 0, 0); if ((long)shm == -1) { LOG_FATAL(LOGF_Refclock, "shmat() failed"); return 0; } RCL_SetDriverData(instance, shm); return 1; }
VOID Config::setScenarioFile(S8* filename) throw (ErrCodeEn) { if (NULL == filename || STRLEN(filename) == 0) { LOG_FATAL("Invalid Scenario file"); throw ERR_INV_CMD_LINE_PARAM; } if (0 == STRNCMP(filename, "--", 2)) { throw ERR_INV_CMD_LINE_PARAM; } pCfg->scnFile.assign(filename); }
/** * \brief initialize */ int DBLoadMimeInit() { char *ErrorBuf; pgConn = fo_dbconnect(DBConfFile, &ErrorBuf); if (!pgConn) { LOG_FATAL("Unable to connect to database"); exit(-1); } MagicCookie = magic_open(MAGIC_PRESERVE_ATIME|MAGIC_MIME); DBMime = NULL; return 0; }
Vector3r Cell::pprevFluctVel(const Vector3r& currPos, const Vector3r& pprevVel, const Real& dt){ switch(homoDeform){ case HOMO_NONE: case HOMO_POS: return pprevVel; case HOMO_VEL: case HOMO_VEL_2ND: return (pprevVel-gradV*currPos); case HOMO_GRADV2: return pprevVel-gradV*(currPos-dt/2*pprevVel); default: LOG_FATAL("Cell::ptPprevFlutVel_pprev: invalid value of homoDeform"); abort(); }; }
uint64_t ir_zext_constant(const struct ir_value *v) { switch (v->type) { case VALUE_I8: return (uint8_t)v->i8; case VALUE_I16: return (uint16_t)v->i16; case VALUE_I32: return (uint32_t)v->i32; case VALUE_I64: return (uint64_t)v->i64; default: LOG_FATAL("Unexpected value type"); break; } }
void packet_syn_set_download(packet_t *packet, char *filename) { if(packet->packet_type != PACKET_TYPE_SYN) { LOG_FATAL("Attempted to set the 'download' field of a non-SYN message\n"); exit(1); } /* Free the name if it's already set */ if(packet->body.syn.filename) safe_free(packet->body.syn.filename); packet->body.syn.options |= OPT_DOWNLOAD; packet->body.syn.filename = safe_strdup(filename); }
void packet_syn_set_name(packet_t *packet, char *name) { if(packet->packet_type != PACKET_TYPE_SYN) { LOG_FATAL("Attempted to set the 'name' field of a non-SYN message\n"); exit(1); } /* Free the name if it's already set */ if(packet->body.syn.name) safe_free(packet->body.syn.name); packet->body.syn.options |= OPT_NAME; packet->body.syn.name = safe_strdup(name); }
static void handle_message(message_t *message, void *d) { driver_dns_t *driver_dns = (driver_dns_t*) d; switch(message->type) { case MESSAGE_PACKET_OUT: handle_packet_out(driver_dns, message->message.packet_out.data, message->message.packet_out.length); break; default: LOG_FATAL("driver_dns received an invalid message!"); abort(); } }
void DNS_Name2IPAddressAsync(const char *name, DNS_NameResolveHandler handler, void *anything) { struct DNS_Async_Instance *inst; inst = MallocNew(struct DNS_Async_Instance); inst->name = name; inst->handler = handler; inst->arg = anything; inst->status = DNS_Failure; if (pipe(inst->pipe)) { LOG_FATAL(LOGF_Nameserv, "pipe() failed"); } resolving_threads++; assert(resolving_threads <= 1); if (pthread_create(&inst->thread, NULL, start_resolving, inst)) { LOG_FATAL(LOGF_Nameserv, "pthread_create() failed"); } SCH_AddFileHandler(inst->pipe[0], SCH_FILE_INPUT, end_resolving, inst); }
QCheckBox* VOptionable::addCheckBox(QLayout* layout, QString objectName, QString text, bool value) { QWidget* parentWidget = layout->parentWidget(); if (parentWidget == NULL) { LOG_FATAL("parentWidget is null(%s)", qPrintable(objectName)); return NULL; } if (parentWidget->findChild<QObject*>(objectName) != NULL) { LOG_FATAL("parentWidget->findChild(%s) is not null", qPrintable(objectName)); return NULL; } QCheckBox* checkBox = new QCheckBox(parentWidget); checkBox->setObjectName(objectName); checkBox->setText(text); checkBox->setCheckState(value ? Qt::Checked : Qt::Unchecked); layout->addWidget(checkBox); return checkBox; }
static int check_cmd_user(const char* cmd, int status, struct linked_list* list, char* line, int line_count) { char* data; char* data_extra; struct auth_info* info = 0; if (!strncmp(line, cmd, strlen(cmd))) { data = &line[strlen(cmd)]; data_extra = 0; data[0] = '\0'; data++; data = strip_white_space(data); if (!*data) { LOG_FATAL("ACL parse error on line %d", line_count); return -1; } info = hub_malloc_zero(sizeof(struct auth_info)); if (!info) { LOG_ERROR("ACL parse error. Out of memory!"); return -1; } if (strncmp(cmd, "user_", 5) == 0) { data_extra = strrchr(data, ':'); if (data_extra) { data_extra[0] = 0; data_extra++; } } strncpy(info->nickname, data, MAX_NICK_LEN); if (data_extra) strncpy(info->password, data_extra, MAX_PASS_LEN); info->credentials = status; list_append(list, info); LOG_DEBUG("ACL: Added user '%s' (%s)", info->nickname, auth_cred_to_string(info->credentials)); return 1; } return 0; }
int SBL_Execute() { int retVal = NPI_LNX_SUCCESS; LOG_INFO("[SBL] Executing Serial Bootloader\n"); if (!sblImageBuf || (sblImageLen <= 0)) { LOG_ERROR("[SBL] No binary file found\n"); retVal = NPI_LNX_FAILURE; } else { int sbResult = 0; sblState = SBL_STATE_SERIAL_BOOT; sbResult = sbExec(sblImageBuf, sblImageLen); if (sbResult != 0) { npiMsgData_t pMsg; LOG_WARN("[SBL] Serial boot loader failed. Attempting hard reset\n"); // Trying again after a hard reset pMsg.len = 0; pMsg.subSys = RPC_SYS_SRV_CTRL | RPC_CMD_AREQ; pMsg.cmdId = NPI_LNX_CMD_ID_RESET_DEVICE; // Send command NPI_SendAsynchData( &pMsg ); // After a very short delay attempt again LOG_INFO("[SBL] Send Handshake command\n"); retVal = BOOT_HandshakeReq(); if (retVal != NPI_LNX_SUCCESS) { LOG_FATAL("[SBL] Serial boot loader failed. Please restart application.\n"); } else { // Try again retVal = sbExec(sblImageBuf, sblImageLen); } } } return retVal; }
DWORD run() { DWORD exitCode; try { exitCode = myRunnable->run(); } catch(YCException& e) { LOG_FATAL("YCThread::run出现异常,线程退出:" << e.what()); myRunnable->stop(); //中断线程,退出 } ::ExitThread(exitCode); }
int pidfile_create() { if (arg_pid) { FILE* pidfile = fopen(arg_pid, "w"); if (!pidfile) { LOG_FATAL("Unable to write pid file: %s\n", arg_pid); return -1; } fprintf(pidfile, "%d", (int) getpid()); fclose(pidfile); } return 0; }
void ThreadRunner::run() { // this is the body of execution of separate thread boost::mutex::scoped_lock lock(m_runmutex); try{ workerThrew=false; while(looping()) { call(); if(m_thread_worker->shouldTerminate()){ stop(); return; } } } catch (std::exception& e){ LOG_FATAL("Exception occured: "<<std::endl<<e.what()); workerException=std::exception(e); workerThrew=true; stop(); return; } }
static struct register_set *ra_get_register_set(struct ra *ra, enum ir_type type) { if (is_is_int(type)) { return &ra->int_registers; } if (ir_is_float(type)) { return &ra->float_registers; } if (ir_is_vector(type)) { return &ra->vector_registers; } LOG_FATAL("Unexpected value type"); }
INIT static void system_init() { struct sigaction sa; memset(&sa, 0, sizeof(sa)); sa.sa_flags = SA_SIGINFO; sa.sa_sigaction = fatal_error_signal; if (sigaction(SIGSEGV, &sa, NULL) || sigaction(SIGILL, &sa, NULL) || sigaction(SIGFPE, &sa, NULL) || sigaction(SIGABRT, &sa, NULL)) { LOG_FATAL(core, "%s", errno_error(errno)); abort(); } }
static void handle_message(message_t *message, void *d) { driver_console_t *driver = (driver_console_t*) d; switch(message->type) { case MESSAGE_DATA_IN: if(message->message.data_in.session_id == driver->session_id) handle_data_in(driver, message->message.data_in.data, message->message.data_in.length); break; default: LOG_FATAL("driver_console received an invalid message: %d", message->type); abort(); } }
static size_t consume_input(int c, char **data, size_t max_len, int position_in_data) { assert(data); (*data)[position_in_data] = c; // Text too long to be stored in 'data', realloc if (position_in_data == max_len - 1) { // printf("reallocating data: position_in_data: %i, max_len: %lu, data: %c\n", position_in_data, max_len, c); char *aux = realloc(*data, max_len * 2); if (aux) { *data = aux; return max_len * 2; } else { LOG_FATAL("Could not allocate enough memory for reading input VCF file\n"); } } return max_len; }
QString gui_settings::GetCurrentUser() { // load user bool is_valid_user; const QString user = GetValue(gui::um_active_user).toString(); const u32 user_id = user.toInt(&is_valid_user); // set user if valid if (is_valid_user && user_id > 0) { return user; } LOG_FATAL(GENERAL, "Could not parse user setting: '%s' = '%d'.", user.toStdString(), user_id); return QString(); }
int LevelDB::Open(const std::string& db) { leveldb::Options options; options.create_if_missing = true; leveldb::Status status = leveldb::DB::Open(options, db, &leveldb_); if (!status.ok()) { LOG_FATAL("leveldb connect failed,msg=[%s]", status.ToString().c_str()); if (leveldb_) { delete leveldb_; leveldb_ = NULL; } return FAILED; } return OK; }
void dfescrypt_cpu(uint32_t n, uint32_t *input, uint32_t *output, uint32_t *midstate) { uint32_t* X = (uint32_t*) malloc(sizeof(uint32_t)*32*n); uint32_t* tstates = (uint32_t*) malloc(sizeof(uint32_t)*8*n); uint32_t* ostates = (uint32_t*) malloc(sizeof(uint32_t)*8*n); uint32_t *V; uint32_t i, j, k; uint32_t iterations = HybridcoinMiner_Scrypt_Iterations; char scratchpad[SCRYPT_SCRATCHPAD_SIZE]; V = (uint32_t *)(((uintptr_t)(scratchpad) + 63) & ~ (uintptr_t)(63)); if(NULL == X || NULL == tstates || NULL == ostates){ LOG_FATAL("unable to allocate buffer for Scrypt input!\n"); } #pragma omp parallel for for (int64_t i = 0; i < (int64_t)n; i++) { memcpy(&tstates[i*8], midstate, 32); SHA256_before(&tstates[i*8], &ostates[i*8], &input[20*i], &X[i*32]); } //SCRYPT CORE for (int64_t p = 0; p < (int64_t)n; p++) { uint32_t *Y = &X[p*32]; for (i = 0; i < iterations; i++) { memcpy(&V[i * 32], Y, 128); xor_salsa8(&Y[0], &Y[16]); xor_salsa8(&Y[16], &Y[0]); } for (i = 0; i < iterations; i++) { j = 32 * (Y[16] & (iterations-1)); for (k = 0; k < 32; k++) Y[k] ^= V[j + k]; xor_salsa8(&Y[0], &Y[16]); xor_salsa8(&Y[16], &Y[0]); } } #pragma omp parallel for for (int64_t i = 0; i < (int64_t)n; i++) { SHA256_after(&tstates[i*8], &ostates[i*8], &output[i*8], &X[i*32]); } free(X); free(tstates); free(ostates); }
void emu_settings::EnhanceComboBox(QComboBox* combobox, SettingsType type, bool is_ranged, bool use_max, int max) { if (!combobox) { LOG_FATAL(GENERAL, "EnhanceComboBox '%s' was used with an invalid object", GetSettingName(type)); return; } if (is_ranged) { QStringList range = GetSettingOptions(type); int max_item = use_max ? max : range.last().toInt(); for (int i = range.first().toInt(); i <= max_item; i++) { combobox->addItem(QString::number(i), QVariant(QString::number(i))); } } else { for (QString setting : GetSettingOptions(type)) { combobox->addItem(tr(setting.toStdString().c_str()), QVariant(setting)); } } std::string selected = GetSetting(type); int index = combobox->findData(qstr(selected)); if (index == -1) { std::string def = GetSettingDefault(type); LOG_ERROR(GENERAL, "EnhanceComboBox '%s' tried to set an invalid value: %s. Setting to default: %s", GetSettingName(type), selected, def); combobox->setCurrentIndex(combobox->findData(qstr(def))); m_broken_types.insert(type); } else { combobox->setCurrentIndex(index); } connect(combobox, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), [=](int index) { SetSetting(type, sstr(combobox->itemData(index))); }); }
void game_quit () { if (false == initialized) { LOG_FATAL ("not initialized"); } mouse_quit (); audio_quit (); keyboard_quit (); video_quit (); filepath_quit (); conf_quit (); initialized = false; }
Keyboard* Keyboard::getInstance() { try { if (NULL == m_pKb) { m_pKb = new Keyboard; } } catch (std::exception &e) { LOG_FATAL("Memory allocation failure, Keyboard"); throw ERR_KEYBOARD_INIT; } return m_pKb; }
int main(int argc, char* argv[]) { char filename[256]; if (argc <= 1) { printf("usage: %s <conf file>\n", argv[0]); return 1; } strncpy(filename, argv[1], strlen(argv[1])); logger_configure(filename); LOG_TRACE("trace"); LOG_DEBUG("degug"); LOG_INFO("info"); LOG_WARN("warn"); LOG_ERROR("error"); LOG_FATAL("fatal"); return 0; }
// Entry point from our subclassed NativeActivity. // // By here, the Go runtime has been initialized (as we are running in // -buildmode=c-shared) but main.main hasn't been called yet. void ANativeActivity_onCreate(ANativeActivity *activity, void* savedState, size_t savedStateSize) { JNIEnv* env = activity->env; // Note that activity->clazz is mis-named. JavaVM* current_vm = activity->vm; jobject current_ctx = activity->clazz; setCurrentContext(current_vm, (*env)->NewGlobalRef(env, current_ctx)); // Set TMPDIR. jmethodID gettmpdir = find_method(env, current_ctx_clazz, "getTmpdir", "()Ljava/lang/String;"); jstring jpath = (jstring)(*env)->CallObjectMethod(env, current_ctx, gettmpdir, NULL); const char* tmpdir = (*env)->GetStringUTFChars(env, jpath, NULL); if (setenv("TMPDIR", tmpdir, 1) != 0) { LOG_INFO("setenv(\"TMPDIR\", \"%s\", 1) failed: %d", tmpdir, errno); } (*env)->ReleaseStringUTFChars(env, jpath, tmpdir); // Call the Go main.main. uintptr_t mainPC = (uintptr_t)dlsym(RTLD_DEFAULT, "main.main"); if (!mainPC) { LOG_FATAL("missing main.main"); } callMain(mainPC); // These functions match the methods on Activity, described at // http://developer.android.com/reference/android/app/Activity.html activity->callbacks->onStart = onStart; activity->callbacks->onResume = onResume; activity->callbacks->onSaveInstanceState = onSaveInstanceState; activity->callbacks->onPause = onPause; activity->callbacks->onStop = onStop; activity->callbacks->onDestroy = onDestroy; activity->callbacks->onWindowFocusChanged = onWindowFocusChanged; activity->callbacks->onNativeWindowCreated = onNativeWindowCreated; activity->callbacks->onNativeWindowRedrawNeeded = onNativeWindowRedrawNeeded; activity->callbacks->onNativeWindowDestroyed = onNativeWindowDestroyed; activity->callbacks->onInputQueueCreated = onInputQueueCreated; activity->callbacks->onInputQueueDestroyed = onInputQueueDestroyed; activity->callbacks->onConfigurationChanged = onConfigurationChanged; activity->callbacks->onLowMemory = onLowMemory; // Note that onNativeWindowResized is not called on resize. Avoid it. // https://code.google.com/p/android/issues/detail?id=180645 onCreate(activity); }
bool PurpleIMChat::addContactCbk(void * dataIn) { Mutex::ScopedLock lock(PurpleIMChat::_mutex); PurpleIMChatCallbackData* cbData = (PurpleIMChatCallbackData*) dataIn; PurpleIMChat* imChat = cbData->getPurpleIMChat(); IMChatSession* chatSession = cbData->getIMChatSession(); PurpleAccount* gAccount = getPurpleAccount( imChat->getIMAccount() ); // const char * contactId = (const char *)((misc_t *)data)->data_ptr2; mConvInfo_t *mConv = FindChatStructById(chatSession->getId()); int BuddyNbr = chatSession->getIMContactSet().size(); PurpleConversation *gConv = NULL; if (mConv) gConv = mConv->purple_conv_session; //VOXOX - JRT - 2009.07.09 else LOG_FATAL("ConvInfo not created !!!"); if (purple_conversation_get_type(gConv) == PURPLE_CONV_TYPE_IM) { GList *mlist = NULL; IMContactSet& chatContact = const_cast<IMContactSet&>(chatSession->getIMContactSet()); IMContactSet::const_iterator it = chatContact.begin(); const std::string & firstContactId = it->getContactId(); PurpleConnection *gGC; gConv = mConv->purple_conv_session; //VOXOX - JRT - 2009.07.09 gGC = purple_conversation_get_gc(gConv); mlist = g_list_append(mlist, const_cast<char*>(cbData->getContactId().c_str()) ); mlist = g_list_append(mlist, (char *) firstContactId.c_str()); createPurpleChat(gGC, chatSession->getId(), mlist, *imChat, gAccount); //VOXOX - JRT - 2009.07.10 } else if (purple_conversation_get_type(gConv) == PURPLE_CONV_TYPE_CHAT) { serv_chat_invite(purple_conversation_get_gc(gConv), purple_conv_chat_get_id(PURPLE_CONV_CHAT(gConv)), NULL, cbData->getContactId().c_str() ); } timeoutRemove( cbData ); delete cbData; return TRUE; }