Instrument *InstrumentFactory::create(const QString &model, Workbench *parent) { if (model == "sim") return new SimInstrument(parent); QString filename = model + ".dll"; QPluginLoader loader(qApp->applicationDirPath() + "/" + filename); QObject *obj = loader.instance(); if (!obj) { critical(WBApp::tr("无法加载%1\n%2").arg(filename).arg(loader.errorString())); loader.unload(); return 0; } InstrumentPlugin *plugin = qobject_cast<InstrumentPlugin*>(obj); Instrument *instr = plugin ? plugin->create(model, parent) : 0; if (!instr) { critical(WBApp::tr("无效的插件%1\n%2").arg(filename).arg(loader.errorString())); loader.unload(); return 0; } return instr; }
bool initializeTrackerEnvironment() { registerQTrackerDbusTypes(); service_g = "org.freedesktop.Tracker1"; base_path_g = "/org/freedesktop/Tracker1"; if(!trackerBus().interface()->isServiceRegistered(service_g) && (trackerBus().interface()->startService(service_g) , !trackerBus().interface()->isServiceRegistered(service_g))) critical() << "cannot connect to org.freedesktop.Tracker1 service"; search_interface_g = service_g + ".Search"; search_path_g = base_path_g + "/Search"; resources_interface_g = service_g + ".Resources"; resources_path_g = base_path_g + "/Resources"; resources_class_interface_g = service_g + ".Resources.Class"; resources_class_path_g = base_path_g + "/Resources/Classes"; QDBusReply<QString> result = trackerBus().call(QDBusMessage::createMethodCall ( service_g, resources_path_g , "org.freedesktop.DBus.Introspectable", "Introspect")); if(!result.isValid()) critical() << "cannot access" << resources_path_g << "introspection:" << result.error(); else if(result.value().contains("GraphUpdated")) graph_update_signals_g = true; return true; }
bool hfs_extents_get_extentlist_for_fork(ExtentList* list, const HFSFork* fork) { unsigned blocks = 0; extentlist_add_record(list, fork->forkData.extents); for (int i = 0; i < kHFSPlusExtentDensity; i++) blocks += fork->forkData.extents[i].blockCount; while (blocks < fork->totalBlocks) { debug("Fetching more extents"); HFSPlusExtentRecord record; hfs_block startBlock = 0; int found = hfs_extents_find_record(&record, &startBlock, fork, blocks); if (found < 0) { error("Error while searching extent B-Tree for additional extents."); return false; } else if (found > 0) { if (startBlock > blocks) { critical("Bad extent."); } size_t offset=0, length=0; if (extentlist_find(list, startBlock, &offset, &length)) { critical("We already have this record."); } extentlist_add_record(list, record); for (int i = 0; i < kHFSPlusExtentDensity; i++) blocks += record[i].blockCount; if (record[7].blockCount == 0) break; } else { break; } } return true; }
int main (int argc, char **argv) { /* Local Vars */ virConnectPtr conn; const char *hvType; unsigned long libVer, libMajor, libMinor, libRelease; unsigned long hvVer, hvMajor, hvMinor, hvRelease; /* Set signal handling and alarm */ if (signal(SIGALRM, timeout_alarm_handler) == SIG_ERR) critical("Setup SIGALRM trap failed!"); /* Process check arguments */ if (process_arguments(argc, argv) != OK) unknown("Parsing arguments failed!"); /* Start plugin timeout */ alarm(mp_timeout); // PLUGIN CODE conn = virt_connect(); hvType = virConnectGetType(conn); if (hvType == NULL) { if (mp_verbose > 0) { virt_showError(conn); } critical("Failed to get hypervisor type."); } if (virConnectGetVersion(conn, &hvVer) != 0) { if (mp_verbose > 0) { virt_showError(conn); } critical("Failed to get hypervisor version."); } if (virConnectGetLibVersion(conn, &libVer) != 0) { if (mp_verbose > 0) { virt_showError(conn); } critical("Failed to get library version."); } virConnectClose(conn); hvMajor = hvVer / 1000000; hvVer %= 1000000; hvMinor = hvVer / 1000; hvRelease = hvVer % 1000; libMajor = libVer / 1000000; libVer %= 1000000; libMinor = libVer / 1000; libRelease = libVer % 1000; /* Output and return */ ok("libvirtd: v.%lu.%lu.%lu Hypervisor: %s (v.%lu.%lu.%lu)", libMajor, libMinor, libRelease, hvType, hvMajor, hvMinor, hvRelease); }
/** W razie niepowodzenia wczytania czcionki wyswietlanie informacji * i rzucenie wyjatku */ void Resource::fontError() { critical("Brak czcionki"); critical( TTF_GetError() ); throw std::runtime_error("Resource:load"); }
LOCAL void REGPARMS StartNextInternalRequest (ADAPTER_PTR HA) { IO_REQ_PTR IReq = &HA->Ext->InternalRequest; IO_REQ_PTR XReq; int i; TRACE(2, ("StartNextInternalRequest(): InUse flag == %s\n", (HA->State.InternalReqInUse) ? "True" : "False")); critical(HA); while (!HA->State.InternalReqInUse && HA->Ext->InternalReqDeferQueue != (IO_REQ_PTR)NILL) { HA->State.InternalReqInUse = TRUE; XReq = HA->Ext->InternalReqDeferQueue; uncritical(HA); ReqTargetID(IReq) = ReqTargetID(XReq); ReqTargetLUN(IReq) = ReqTargetLUN(XReq); ReqDevP(IReq) = ReqDevP(XReq); for (i=0; i<12;i++) ReqCDB(IReq)[i] = 0; ReqState(IReq).ReqType = ReqState(XReq).ReqType; switch(ReqState(XReq).ReqType) { case RTGetInfoReq: DeviceInfo(HA); break; case RTAutoSenseReq: AutoSense(HA); break; case RTSyncNegReq: DoTestUnitReady(HA); break; default: CompleteDeferedRequest(HA, S_REQ_REQUEST); continue; } critical(HA); } uncritical(HA); }
Application::Application(int &argc, char **argv) : QApplication(argc, argv) { setApplicationName("Installer Jukebox"); // All paths are relative to the location of the executable QString appPath = applicationDirPath(); qDebug() << "Application path:" << appPath; QDir::addSearchPath("app", appPath); // Parse configuration file (required) if (!QFileInfo("app:InstallerJukebox.ini").isReadable()) { QString configPath = appPath + QDir::separator() + "InstallerJukebox.ini"; qDebug() << "Cannot read" << configPath; critical(tr("Cannot read %1").arg(configPath)); throw 1; } config = new QSettings("app:InstallerJukebox.ini", QSettings::IniFormat); // Get working directory from config. Must be configured, exist and be writable. tmpDir = config->value("Working directory").toString(); if (tmpDir.isEmpty()) { qDebug() << "Working directory not configured!"; critical(tr("Working directory is not configured!")); throw 1; } QFileInfo fileInfo(tmpDir); if (!fileInfo.isDir()) { qDebug() << tmpDir << "is not a directory!"; Application::critical(tr("'%1' is not a directory!").arg(tmpDir)); throw 1; } if (!fileInfo.isWritable()) { qDebug() << tmpDir << "is not writable!"; Application::critical(tr("Directory '%1' is not writable!").arg(tmpDir)); throw 1; } tmpDir = QDir::cleanPath(fileInfo.absoluteFilePath()); qDebug() << "tmpDir is" << tmpDir; // Parse "Keep temp files" option. Must be valid if configured, default to "Never". QString keepTempFiles = config->value("Keep temp files", "never").toString().toLower(); qDebug() << "Keep temp files:" << keepTempFiles; if (keepTempFiles == "never") { tmpFileHandling = Never; } else if (keepTempFiles == "onerror") { tmpFileHandling = OnError; } else if (keepTempFiles == "always") { tmpFileHandling = Always; } else { qDebug() << "Invalid!"; critical(tr("'Keep temp files' setting is invalid!")); throw 1; } // Use system's default proxy configuration QNetworkProxyFactory::setUseSystemConfiguration(true); }
/* Register device that userspace will read to store results in log file */ int vmon_p_init(dev_t dev) { int result, devno; prolog (""); vmon_p_devno = dev; vmon_p_devices = \ kmalloc(VMON_P_NR_DEVS * sizeof(struct vmon_pipe), GFP_KERNEL); if (vmon_p_devices == NULL) { critical ( "vmon_pipe couldn't be allocated!" ); unregister_chrdev_region(dev, VMON_P_NR_DEVS); return 0; } prolog ( "vmon_p_devices=0x%p", vmon_p_devices ); memset(vmon_p_devices, 0, VMON_P_NR_DEVS * sizeof(struct vmon_pipe)); init_waitqueue_head(&vmon_p_devices->buffer_wait); vmon_p_devices->buffer_watershed = VMON_P_BUFFER_WATERSHED; if (vmon_p_devices->buffer_watershed >= VMON_P_BUFFERSIZE) return -EINVAL; if (!vmon_p_devices->buffer) { /* * kmalloc (kernel) * allocates contiguous memory, up to 128KB * vmalloc (virtual) * allocates non continuous memory, can go above 128KB */ vmon_p_devices->buffer = \ kmalloc(sizeof(u64) * VMON_P_BUFFERSIZE, GFP_KERNEL); if (!vmon_p_devices->buffer) { critical ( "couldn't allocate vmon_p_buffer!" ); return -ENOMEM; } } prolog ( "vmon_p_devices->buffer=0x%p", vmon_p_devices->buffer ); vmon_p_devices->buffersize = VMON_P_BUFFERSIZE; devno = MKDEV(vmon_major, vmon_minor + 0); cdev_init(&vmon_p_devices->cdev, &vmon_pipe_fops); vmon_p_devices->cdev.owner = THIS_MODULE; result = cdev_add (&vmon_p_devices->cdev, devno, 1); /* Fail gracefully if need be */ if (result) critical ("error %d adding /dev/vmon", result); epilog ( "device vmon major=%d, minor=%d", vmon_major, vmon_minor ); return result; }
int main (int argc, char **argv) { /* Local Vars */ MYSQL *conn; MYSQL_RES *result; MYSQL_ROW row; int ret; int i; const char *server_version; struct timeval start_time; double time_delta; /* Set signal handling and alarm */ if (signal(SIGALRM, timeout_alarm_handler) == SIG_ERR) critical("Setup SIGALRM trap failed!"); /* Process check arguments */ if (process_arguments(argc, argv) != OK) unknown("Parsing arguments failed!"); /* Start plugin timeout */ alarm(mp_timeout); gettimeofday(&start_time, NULL); /* Connectiong to mysqld */ conn = mp_mysql_init(); /* Get server version */ server_version = mysql_get_server_info(conn); /* Get status info */ if (mp_showperfdata) { ret = mysql_query(conn, "SHOW /*!50002 GLOBAL */ STATUS;"); if (ret != 0) critical("Query 'SHOW GLOBAL STATUS' failed: %s", mysql_error(conn)); result = mysql_store_result(conn); while ((row = mysql_fetch_row(result))) { for (i=0; i < variables; i++) { if (strcmp(variable[i], row[0]) == 0) { mp_perfdata_int(row[0], strtol(row[1], NULL, 10), unit[i], NULL); } } } mysql_free_result(result); } mp_mysql_deinit(conn); time_delta = mp_time_delta(start_time); mp_perfdata_float("time", (float)time_delta, "s", NULL); ok("MySQL v%s", server_version); critical("You should never reach this point."); }
void SandPile::caluclateDissipationdata(int point,std::vector<int> &dissipationRate) { //int point,std::vector<int> &lat,std::vector<int> &critical, int timesteps, int ×tepsMax, int &size, std::vector<int> dissipationRate std::vector<int> critical(nrOfElements); std::vector<int> lat(getLattice()); lat[point] += 1; int size = 0; int timeMax = 0; testDissipation(point,lat,critical,0,timeMax, size,dissipationRate); // coutLattice2d(critical); // int koord1[dimension]; // int koord2[dimension]; // coord(dimension,sidelength,point,koord1); // for(int i=0;i<nrOfElements;i++){ // if(critical[i]==1){ // coord(dimension,sidelength,i,koord2); // curDistance = radius(dimension,koord1,koord2); // if(curDistance >distance) distance = curDistance; // } // } // std::cout << "\t" << "SandPile:: calculate Clusterdata" << "\t" // << time << "\t" // << size << "\t" // << distance << "\t" // << "\n"; }
void SandPile::caluclateClusterdata(int point,int &time, int &size, int &distance) { std::vector<int> critical(nrOfElements); std::vector<int> lat(getLattice()); lat[point] ++; testCritical(point,lat,critical,0,time, size); distance = 0; double curDistance = 0; int koord1[dimension]; int koord2[dimension]; coord(dimension,sidelength,point,koord1); for(int i=0;i<nrOfElements;i++){ if(critical[i]==1){ coord(dimension,sidelength,i,koord2); curDistance = radius(dimension,koord1,koord2); if(curDistance >distance) distance = curDistance; } } // std::cout << "\t" << "SandPile:: calculate Clusterdata" << "\t" // << time << "\t" // << size << "\t" // << distance << "\t" // << "\n"; }
void swap_HFSPlusAttrRecord(HFSPlusAttrRecord* record) { // trace("record (%p)", record); record->recordType = be32toh(record->recordType); switch (record->recordType) { case kHFSPlusAttrInlineData: { // InlineData is no more; use AttrData. swap_HFSPlusAttrData(&record->attrData); break; } case kHFSPlusAttrForkData: { swap_HFSPlusAttrForkData(&record->forkData); break; } case kHFSPlusAttrExtents: { swap_HFSPlusAttrExtents(&record->overflowExtents); break; } default: { critical("Unknown attribute record type: %d", record->recordType); break; } } }
int GroupManager::userListtoXml(const char **data) { QString qsData; xmlEncoding(qsData, userName, prefix); QByteArray qba = qsData.toLocal8Bit(); char *buffer = static_cast<char *>(calloc(qba.size() + 1, sizeof(char))); memcpy(buffer, qba.constData(), qba.size()); buffer[qba.size()] = '\0'; if (isPrivate) { unsigned char *enc_data = NULL; size_t enc_len = 0; int res = symEncrypt(conferenceKey, NULL, (const unsigned char *) buffer, strlen(buffer), &enc_data, &enc_len, AES_BLOCK_SIZE); if (res != 0) critical("can not encrypt speaker info"); free(buffer); buffer = NULL; *data = (const char *)enc_data; return enc_len; } else { *data = buffer; return strlen(buffer); } }
static int p9_xos_chunks_array_init(struct p9_xos_endpoint *ep, int writer) { int retval = 0; int i; /* Allocate memory chunks */ ep->chunks = kmalloc(ep->regs[CARD] << ep->regs[SIZE], GFP_KERNEL); if (!ep->chunks) { critical("kmalloc of xosnp paquets failed"); ep->regs[FAIL] = 1; retval = -ENOMEM; goto bail_out; } /* Save physical address of chunks array */ ep->regs[ADDR] = __pa(ep->chunks); /* Link chunks */ BUG_ON(!ep->regs[CARD]); for (i = 0; i < ep->regs[CARD] - 1; i += 1) deque_next(i, ep) = i + 1; deque_next(i, ep) = deque_null; if (writer) { p9_xos_deque_clear(ep->rqueue); p9_xos_deque_reset(ep->lqueue, 0, ep->regs[CARD] - 1); } else { p9_xos_deque_clear(ep->lqueue); p9_xos_deque_clear(ep->rqueue); } bail_out: return retval; }
int main (int argc, char **argv) { /* Local Vars */ FILE *fp; mp_subprocess_t *subp; char line[128]; int failed = 0; int lines = 0; uid_t uid; /* Set signal handling and alarm */ if (signal(SIGALRM, timeout_alarm_handler) == SIG_ERR) critical("Setup SIGALRM trap failed!"); /* Process check arguments */ if (process_arguments(argc, argv) != OK) unknown("Parsing arguments failed!"); /* Start plugin timeout */ alarm(mp_timeout); // Need to be root if (nonroot == 0) mp_noneroot_die(); alarm(mp_timeout); // Parse clustat if (nonroot == 0) { uid = getuid(); if (setuid(0) != 0) unknown("setuid failed"); subp = mp_subprocess((char *[]) {"/sbin/multipath","-l", NULL});
void MainWindow::onFailedToRemoveFriend(int friendId) { QMessageBox critical(this); critical.setText(QString("Couldn't remove friend \"%1\"").arg(friendsWidget->getUsername(friendId))); critical.setIcon(QMessageBox::Critical); critical.exec(); }
// Block arguments are relative to the volume. ssize_t hfs_read_blocks(void* buffer, const HFSVolume *hfs, size_t block_count, size_t start_block) { // debug("Reading %u blocks starting at block %u", block_count, start_block); if (hfs->block_count && start_block > hfs->block_count) { error("Request for a block past the end of the volume (%d, %d)", start_block, hfs->block_count); errno = ESPIPE; // Illegal seek return -1; } // Trim to fit. if (hfs->block_count && hfs->block_count < (start_block + block_count)) { block_count = hfs->block_count - start_block; } size_t offset = start_block * hfs->block_size; size_t size = block_count * hfs->block_size; // debug("Reading %zd bytes at volume offset %zd.", size, offset); ssize_t bytes_read = hfs_read_raw(buffer, hfs, size, offset); if (bytes_read == -1) { perror("read blocks error"); critical("read error"); return bytes_read; } // debug("read %zd bytes", bytes_read); // This layer thinks in blocks. Blocks in, blocks out. int blocks_read = 0; if (bytes_read > 0) { blocks_read = MAX(bytes_read / hfs->block_size, 1); } return blocks_read; }
StBootstrap::StBootstrap(const Bootstrap &newBoot, const TaskPort &task) : mTask(task), locker(critical()) { mOldBoot = Bootstrap(); mTask.bootstrap(newBoot); secdebug("StBoot", "bootstrap for %d switched to %d", mTask.port(), newBoot.port()); }
void maybe_create_http_client_thread() { debug( "Creating a HTTP client thread." ); if ( http_client_thread != NULL ) { int ret = pthread_kill( *http_client_thread, 0 ); if ( ret == 0 ) { debug( "HTTP client thread is already created and active ( %#lx ).", *http_client_thread ); return; } warn( "A HTTP client thread has terminated unexpectedly ( %#lx ). Creating a new thread.", *http_client_thread ); xfree( http_client_thread ); http_client_thread = NULL; } pthread_attr_t attr; pthread_attr_init( &attr ); pthread_attr_setdetachstate( &attr, PTHREAD_CREATE_DETACHED ); http_client_thread = xmalloc( sizeof( pthread_t ) ); int ret = pthread_create( http_client_thread, &attr, http_client_main, NULL ); if ( ret != 0 ) { critical( "Failed to create a HTTP client thread ( ret = %d ).", ret ); } assert( http_client_thread != NULL ); debug( "A HTTP client is created ( %#lx ).", *http_client_thread ); }
int warrior_comm_attack(struct warrior *w) { if (w == NULL) return 0; return (w->comm.strength * w->comm_attack.ba_coefficient)* \ (critical(w->basic_critical, w->comm.critical)?2:1); }
void *mp_malloc(size_t size) { void *p; p = malloc(size); if (!p) critical("Out of memory!"); return p; }
void MainWindow::onFailedToAddFriend(const QString& userId) { QMessageBox critical(this); critical.setText(QString("Couldn't add friend with User ID\n\"%1\"").arg(userId)); critical.setIcon(QMessageBox::Critical); critical.exec(); }
void *mp_calloc(size_t nmemb, size_t size) { void *p; p = calloc(nmemb, size); if (!p) critical("Out of memory!"); return p; }
void test_critical_logs_if_logging_level_is_ERROR() { expect_string( mock_fprintf, output, "CRITICAL message.\n" ); set_logging_level( "error" ); critical( "CRITICAL message." ); }
std::vector <int> SandPile::defineCluster(int point, int& time, double& distance) { std::vector<int> copiedLattice = lattice; std::vector<int> critical(nrOfElements); copiedLattice[point]++; int size = 0; testCritical(point,copiedLattice,critical,0,time,size); distance = 0; double curDistance = 0; int koord1[dimension]; int koord2[dimension]; coord(dimension,sidelength,point,koord1); for(int i=0;i<nrOfElements;i++){ if(critical[i]==1){ coord(dimension,sidelength,i,koord2); curDistance = radius(dimension,koord1,koord2); std::cout << "distance = " << distance << " curDistance = " << curDistance << std::endl; if(curDistance >distance) distance = curDistance; } } return critical; }
/** Zamienia SDL_Surface na format openGL-a */ void RendererGL::create_gl(SDL_Surface * surf, GLuint * tex ) { GLenum format; GLint colors_amount = surf->format->BytesPerPixel; if (colors_amount == 4) { if (surf->format->Rmask == 0x000000ff) format = GL_RGBA; else format = GL_BGRA; } else if (colors_amount == 3) { if (surf->format->Rmask == 0x000000ff) format = GL_RGB; else format = GL_BGR; } else { critical("Image is not truecolor"); } glGenTextures( 1, tex ); glBindTexture( GL_TEXTURE_2D, *tex ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexImage2D( GL_TEXTURE_2D, 0, colors_amount, surf->w, surf->h, 0, format, GL_UNSIGNED_BYTE, surf->pixels ); }
void Widget::onFailedToStartCore() { QMessageBox critical(this); critical.setText("Toxcore failed to start, the application will terminate after you close this message."); critical.setIcon(QMessageBox::Critical); critical.exec(); qApp->quit(); }
// Android example void android_example() { #if defined(__ANDROID__) std::string tag = "spdlog-android"; auto android_logger = spd::android_logger("android", tag); android_logger->critical("Use \"adb shell logcat\" to view this message."); #endif }
void rpc_timeout_alarm_handler(int signo) { if (signo == SIGALRM) { if (client) { clnt_destroy(client); } critical("RPC timed out after %d seconds\n", mp_timeout); } }
std::vector<int> SandPile::defineReached(int point) { std::vector<int> copiedLattice = lattice; std::vector<int> critical(nrOfElements); copiedLattice[point]++; testReached(point,copiedLattice,critical); return critical; }