int PatcherApplication::run() { if (args.containsKey('h', "help")) { printHelp(); return Ok; } if (args.containsKey('v', "version")) { printVersion(); return Ok; } if ( !isArgumentsValid(args) ) { printErrorMessage("", InvalidArguments); return InvalidArguments; } // --- main workflow std::string pathToQt = args.list().at(1); Error error = patchQtInDir(pathToQt); if (error != Ok) { printErrorMessage(pathToQt, error); return error; } return Ok; }
void MainWindow::runScript() { //проверяем есть ли файл настроек QFile file(ui->filePath_lineEdit->text()); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)){ printErrorMessage("Can't open file"); printErrorMessage("Script aborted"); return; } QTextStream script(&file); QString tmp; //проходим по каждой строчке скрипта while (!script.atEnd()) { script>>tmp; if (tmp.contains("SendSTR")) { tmp.clear(); //считываем все до конца строки tmp = script.readLine(); //обрезаем все до " tmp.remove(0,tmp.indexOf('\"',0)+1); //обрезаем все после " tmp.truncate(tmp.lastIndexOf('\"')); printMessageFromScrip(tmp); port.sendData(tmp + '\r'); continue; } if (tmp.contains("SendHEX")) { tmp.clear(); tmp = script.readLine(); tmp.remove(0,tmp.indexOf('\"',0)+1); tmp.truncate(tmp.lastIndexOf('\"')); QString tmp_message_at_hex = tmp; if (!hexToString(tmp)) { printErrorMessage("Inappropriate script. Error at \"" + tmp_message_at_hex + "\" . Script aborted"); file.close(); return; } printMessageFromScrip(tmp); port.sendData(tmp); continue; } if (tmp.contains("DELAY")) { bool ok = false; tmp.clear(); tmp = script.readLine().trimmed(); quint32 ms = tmp.toUInt(&ok,10); if (!ok ) { printErrorMessage("Inappropriate value for delay. Error at \"" + tmp + "\" . Script aborted"); return; } QThread::msleep(ms); continue; } printErrorMessage("Inappropriate script. Error at \"" + tmp + "\" . Script aborted"); return; } file.close(); }
bool SoundEffect::load() noexcept { // Check if we have a path if (mFilePath.str() == nullptr) { printErrorMessage("%s", "Attempting to load() sdl::SoundEffect without path."); return false; } // If already loaded we unload first if (this->isLoaded()) { this->unload(); } Mix_Chunk* tmpPtr = Mix_LoadWAV(mFilePath.str()); // If load failed we print an error and return false if (tmpPtr == NULL) { printErrorMessage("Mix_LoadWAV() failed for \"%s\", error: %s", mFilePath.str(), Mix_GetError()); return false; } // If load was succesful we return true mChunkPtr = tmpPtr; return true; }
void assembler_t::assemble (address_t* address) { ___CBTPUSH; error_t error; bool done = false; while (!done) { printf ("%04X:%04X ", address->segment (), address->offset ()); m_inputReader->getLineFromStdin (); m_input = m_inputReader->readAll (m_input, &m_inputSize); done = m_input[0] == 0; if (!done) { list_t* tokens = m_tokenizer->getTokens (&error, m_input); if (error.code == 0) { instruction_t* instruction = m_instructionBuilder->getInstruction (&error, tokens, address); if (error.code == 0) { m_compiler->compile (address, instruction); instruction->dump (); } else { printErrorMessage (&error); } } else { printErrorMessage (&error); } tokens->dump (); } } ___CBTPOP; }
int main(){ FILE *ptr; ptr = openFile(ptr); menuItem *menu = (menuItem*)malloc(8*sizeof(menuItem)); menuItemsInit(menu); // Показать меню int working = 1; int scannedItem; while(working){ showMenu(menu); printf("\n"); scannedItem = enterInt(scannedItem); if(scannedItem < 1 || scannedItem > 5) {printErrorMessage(); continue;} if((menu+3)->opened){ if(scannedItem < 1 || scannedItem > 3) {printErrorMessage(); continue;} // Запустить функцию if (scannedItem == 1) {(menu + 4)->pointer(NULL);} if (scannedItem == 2) {(menu + 5)->pointer(0);} if (scannedItem == 3) {(menu + 6)->pointer(1);} (menu + 3)->opened = 0; } else { if(scannedItem == 1){ //(menu+scannedItem-1)->opened = 1; menu->pointer(NULL); continue; } if(scannedItem == 4){ (menu+scannedItem-1)->opened = 1; continue; } if(scannedItem == 3){ (menu+2)->pointer(NULL); continue; } if(scannedItem == 2){ Field *tmp = (Field*)malloc(sizeof(Field)); (menu+1)->pointer(tmp); // Запись в файл continue; } if(scannedItem == 5){ return 0; } } } }
//Check directory/file condition whether it's possible to proceed. boolean isReadyToProcess(char* dirName) { DIR* directory = NULL; FILE* file = NULL; boolean ret = TRUE; char* writeTestPath = malloc(strlen(dirName) + 16); //For write access check directoryName = malloc(strlen(dirName) + 2); //Remember the directory name in the global variable if((writeTestPath == NULL) || (directoryName == NULL)) { printErrorMessage(CANNOT_ALLOCATE_MEMORY); return FALSE; } strcpy(writeTestPath, dirName); strcpy(directoryName, dirName); #if defined(__linux__) || defined(__linux) strcat(writeTestPath, "/writeTest"); strcat(directoryName, "/"); #elif defined(_WIN32) || defined(_WIN64) strcat(writeTestPath, "\\writeTest"); strcat(directoryName, "\\"); #endif printf("\n Checking directory status ...\n (%s)\n", directoryName); //Check directory existence and read permission. if((directory = opendir(dirName)) == NULL) { printErrorMessage(DIRECTORY_UNAVAILABLE); ret = FALSE; } //Check write permission into the speficied directory. else if((file = fopen(writeTestPath, "w")) == NULL) { printErrorMessage(DIRECTORY_NOT_WRITABLE); ret = FALSE; } else { fclose(file); remove(writeTestPath); } if(ret == TRUE) { //Scan the specified directory and remember the existing WAV files with the linear list. ret = fetchWavFiles(directory); } if(directory != NULL) { closedir(directory); } if(writeTestPath != NULL) { free(writeTestPath); } return ret; }
void SurvivalMode::setup() { _window = initWindow(_windowRef); if (!_window) { printErrorMessage("SurvivalMode", "Window"); } _renderer = initRenderer(_window, _rendererRef); if (!_renderer) { printErrorMessage("SurvivalMode", "Renderer"); } _running = true; }
void GameplayModeScene::setup() { _window = initWindow(_windowRef); if (!_window) { printErrorMessage("GameplayModeScene", "Window"); } _renderer = initRenderer(_window, _rendererRef); if (!_renderer) { printErrorMessage("GameplayModeScene", "Renderer"); } _running = true; }
//Scan the specified directory and remember the existing WAV files with the linear list. boolean fetchWavFiles(DIR* directory) { struct dirent *entry = NULL; struct MusicFile** endOfMusicFileList = &MusicFileList; int wavFileCount = 0; boolean ret = FALSE; while((entry = readdir(directory)) != NULL) { size_t nameLength = strlen(entry->d_name); if(nameLength > 4) { if(strcmp(&(entry->d_name[nameLength - 4]), ".wav") == 0 || strcmp(&(entry->d_name[nameLength - 4]), ".WAV") == 0) { if(hasWavHeader(entry->d_name) == FALSE) { continue; } else if((*endOfMusicFileList = malloc(sizeof(*endOfMusicFileList))) == NULL) { printErrorMessage(CANNOT_ALLOCATE_MEMORY); return FALSE; } else if(((*endOfMusicFileList)->wavFileName = malloc(nameLength + 1)) == NULL) { printErrorMessage(CANNOT_ALLOCATE_MEMORY); return FALSE; } else { strcpy((*endOfMusicFileList)->wavFileName, entry->d_name); (*endOfMusicFileList)->wavFileName[nameLength] = '\0'; (*endOfMusicFileList)->nextFile = NULL; endOfMusicFileList = &((*endOfMusicFileList)->nextFile); wavFileCount ++; ret = TRUE; } } } } if(ret == FALSE) { printErrorMessage(NO_WAV_FILE_FOUND); } else if(wavFileCount == 1) { printf(" 1 WAV file was found.\n"); } else { printf(" %d WAV files were found.\n", wavFileCount); } return ret; }
static int convertTo_std_vector_1900(PyObject *sipPy,void **sipCppPtrV,int *sipIsErr,PyObject *sipTransferObj) { std::vector<uint> **sipCppPtr = reinterpret_cast<std::vector<uint> **>(sipCppPtrV); #line 330 "/home/kdbanman/browseRDF/tulip-3.8.0-src/library/tulip-python/stl/vector.sip" // Check if type is compatible if (sipIsErr == NULL) { if (!PyList_Check(sipPy)) { return 0; } for (SIP_SSIZE_T i = 0; i < PyList_GET_SIZE(sipPy); ++i) { PyObject *item = PyList_GET_ITEM(sipPy, i); if (!PyLong_Check(item)) { printErrorMessage("TypeError : object in list of type " + std::string(item->ob_type->tp_name) + " can not be converted to int"); return 0; } } return 1; } // Convert Python list of integers to a std::vector<int> std::vector<unsigned int> *v = new std::vector<unsigned int>(); v->reserve(PyList_GET_SIZE(sipPy)); for (SIP_SSIZE_T i = 0; i < PyList_GET_SIZE(sipPy); ++i) { v->push_back(PyLong_AsUnsignedLong(PyList_GET_ITEM(sipPy, i))); } *sipCppPtr = v; return sipGetState(sipTransferObj); #line 76 "/home/kdbanman/browseRDF/tulip-3.8.0-src/build/library/tulip-python/stl/sipstlstdvector1900.cpp" }
Context::Context(SDL_Window* window, int major, int minor, GLContextProfile profile, bool debug) noexcept : mActive(true) { // Set context attributes if (SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, major) < 0) { error("Failed to set gl context major version: %s", SDL_GetError()); } if (SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, minor) < 0) { error("Failed to set gl context minor version: %s", SDL_GetError()); } if (SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, int(Uint32(profile))) < 0) { error("Failed to set gl context profile: %s", SDL_GetError()); } // Set debug context if requested if (debug) { if (SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG) < 0) { printErrorMessage("Failed to request debug context: %s", SDL_GetError()); } } handle = SDL_GL_CreateContext(window); if (handle == NULL) { error("Failed to create GL context: %s", + SDL_GetError()); } }
void TestRunner::overridePreference(const CppArgumentList& arguments, CppVariant* result) { result->setNull(); if (arguments.size() != 2 || !arguments[0].isString()) return; string key = arguments[0].toString(); CppVariant value = arguments[1]; WebPreferences* prefs = m_delegate->preferences(); if (key == "WebKitDefaultFontSize") prefs->defaultFontSize = cppVariantToInt32(value); else if (key == "WebKitMinimumFontSize") prefs->minimumFontSize = cppVariantToInt32(value); else if (key == "WebKitDefaultTextEncodingName") prefs->defaultTextEncodingName = cppVariantToWebString(value); else if (key == "WebKitJavaScriptEnabled") prefs->javaScriptEnabled = cppVariantToBool(value); else if (key == "WebKitSupportsMultipleWindows") prefs->supportsMultipleWindows = cppVariantToBool(value); else if (key == "WebKitDisplayImagesKey") prefs->loadsImagesAutomatically = cppVariantToBool(value); else if (key == "WebKitPluginsEnabled") prefs->pluginsEnabled = cppVariantToBool(value); else if (key == "WebKitJavaEnabled") prefs->javaEnabled = cppVariantToBool(value); else if (key == "WebKitUsesPageCachePreferenceKey") prefs->usesPageCache = cppVariantToBool(value); else if (key == "WebKitPageCacheSupportsPluginsPreferenceKey") prefs->pageCacheSupportsPlugins = cppVariantToBool(value); else if (key == "WebKitOfflineWebApplicationCacheEnabled") prefs->offlineWebApplicationCacheEnabled = cppVariantToBool(value); else if (key == "WebKitTabToLinksPreferenceKey") prefs->tabsToLinks = cppVariantToBool(value); else if (key == "WebKitWebGLEnabled") prefs->experimentalWebGLEnabled = cppVariantToBool(value); else if (key == "WebKitCSSRegionsEnabled") prefs->experimentalCSSRegionsEnabled = cppVariantToBool(value); else if (key == "WebKitCSSGridLayoutEnabled") prefs->experimentalCSSGridLayoutEnabled = cppVariantToBool(value); else if (key == "WebKitHyperlinkAuditingEnabled") prefs->hyperlinkAuditingEnabled = cppVariantToBool(value); else if (key == "WebKitEnableCaretBrowsing") prefs->caretBrowsingEnabled = cppVariantToBool(value); else if (key == "WebKitAllowDisplayingInsecureContent") prefs->allowDisplayOfInsecureContent = cppVariantToBool(value); else if (key == "WebKitAllowRunningInsecureContent") prefs->allowRunningOfInsecureContent = cppVariantToBool(value); else if (key == "WebKitCSSCustomFilterEnabled") prefs->cssCustomFilterEnabled = cppVariantToBool(value); else if (key == "WebKitShouldRespectImageOrientation") prefs->shouldRespectImageOrientation = cppVariantToBool(value); else if (key == "WebKitWebAudioEnabled") ASSERT(cppVariantToBool(value)); else { string message("Invalid name for preference: "); message.append(key); printErrorMessage(message); } m_delegate->applyPreferences(); }
//Thread entry for WAV to MP3 encoding void encodingThread(const char* wavFileName) { char* wavFilePath = malloc(strlen(directoryName) + strlen(wavFileName) + 1); char* mp3FilePath = malloc(strlen(directoryName) + strlen(wavFileName) + 1); if((wavFilePath == NULL) || (mp3FilePath == NULL)) { printErrorMessage(CANNOT_ALLOCATE_MEMORY); return; } strcpy(wavFilePath, directoryName); strcat(wavFilePath, wavFileName); //put mp3 extension as the output file name strcpy(mp3FilePath, wavFilePath); mp3FilePath[strlen(mp3FilePath) - 4] = '\0'; strcat(mp3FilePath, ".mp3"); printf(" Encoding \"%s\" ...\n", wavFilePath); encode(wavFilePath, mp3FilePath); printf(" Done encoding \"%s\".\n New MP3 file generated \"%s\".\n\n", wavFileName, mp3FilePath); free(wavFilePath); free(mp3FilePath); return; }
struct hostent *info_Host(char * serverName){ struct hostent *hostptr; hostptr = gethostbyname(serverName); if(hostptr == NULL) printErrorMessage("That Host Does Not Exist"); return hostptr; }
void warning(errorType theError, ...) { va_list ap; va_start(ap, theError); printErrorMessage(theError, ap); va_end(ap); }
WebString TestRunner::cppVariantToWebString(const CppVariant& value) { if (!value.isString()) { printErrorMessage("Invalid value for preference. Expected string value."); return WebString(); } return WebString::fromUTF8(value.toString()); }
void CompanyBuilder::addNode(string first, string last, string title, string team_name) { Node* emp = constructEmp(first, last, title); Group* team = getTeam(team_name); if (team != nullptr) { team->AddChild(emp); print(); } else {printErrorMessage("find", team_name);} }
void CompanyBuilder::addNode(string team_name, string supervisor) { Node* grp = constructGrp(team_name); Group* super = getTeam(supervisor); if (super != nullptr) { super->AddChild(grp); print(); }else {printErrorMessage("find", supervisor);} }
void checkConsistency() { /* test if an error occurred */ if (errorcode != AXE_OK) { printErrorMessage(errorcode); abortProgram(); } if (cflow_errorcode != CFLOW_OK) { fprintf(stderr, "An error occurred while working with the " "cflow graph. cflow_errorcode = %d" "\n(see axe_cflow_graph.[ch])\n", cflow_errorcode); printErrorMessage(AXE_UNKNOWN_ERROR); abortProgram(); } }
void error(errorType theError, ...) { va_list ap; va_start(ap, theError); printErrorMessage(theError, ap); va_end(ap); errorFlag = TRUE; }
void CompanyBuilder::removeNode(string team_name , string supervisor) { if (supervisor == "None") { printErrorMessage("remove", team_name); return;} Node* team = getNode(team_name); Group* super = getTeam(supervisor); super->RemoveChild(team); //remove team's pointer from super's vector delete team; //deletes team and all of its children print(); }
void fatalError(errorType theError, ...) { va_list ap; va_start(ap, theError); printErrorMessage(theError, ap); va_end(ap); chokePukeAndDie(); }
/* * Sends a request for service to the server. This is an asynchronous call to the server, * so do not wait for a reply in this function. * * sock - the socket identifier * request - the request to be sent encoded as a string * dest - the server's address information * * return - 0, if no error; otherwise, a negative number indicating the error */ int sendRequest(int sock, char * request, struct sockaddr_in * dest){ int error = 0; if(request[0] == '\0') { printErrorMessage("Cannot Send NULL Message to the Server"); return -1; } error = sendto(sock, request, strlen(request), 0, (struct sockaddr *) dest, sizeof(*dest)); if(error == -1) return -1; return 0; }
int main() { printf("Using shared library functions!\n"); printErrorMessage(); printOkMessage(); printf("sin(60) is %f\n", customSin(60)); printf("cos(60) is %f\n", customCos(60)); return 0; }
void MainWindow::sendMessage() { QString message = ui->send_text_lineEdit->displayText(); printSentMessage(message.trimmed()); if (ui->hex_radioButton->isChecked()) if (!hexToString(message)){ printErrorMessage("Messange can't be send"); return; }; port.sendData(message.trimmed() + "\r"); }
/* * dropTable -- 表(テーブル)の削除 * * 引数: * tableName: 削除するテーブルの名前 * * 返り値: * Result */ Result dropTable(char *tableName) { /*tableFileName.[DEF_FILE_EXT]という文字列を作る*/ char tableFileName[260]; int len = strlen(tableName) + strlen(DEF_FILE_EXT) + 1; memset(tableFileName, '\0', strlen(tableFileName)); snprintf(tableFileName, len, "%s%s", tableName, DEF_FILE_EXT); /*tableFileNameという名前を持つファイルを削除する*/ if((deleteFile(tableFileName) == NG)){ printErrorMessage(ERR_MSG_UNLINK, __func__, __LINE__); return NG; } if(deleteDataFile(tableName) != OK){ printErrorMessage(ERR_MSG_UNLINK, __func__, __LINE__); return NG; } /*okを返す*/ return OK; }
void MainWindow::loadSettings() { if (!QFile::exists("settings.ini")) { printErrorMessage("No previous settings"); return; } QSettings settings("settings.ini", QSettings::IniFormat); ui->comPort_comboBox->setCurrentText(settings.value("comPort").toString()); ui->bitsRate_comboBox->setCurrentText(settings.value("bitsRate").toString()); ui->dataBits_comboBox->setCurrentText(settings.value("dataBits").toString()); ui->stopBits_comboBox->setCurrentText(settings.value("stopBits").toString()); ui->parity__comboBox->setCurrentText(settings.value("parity").toString()); ui->flowControl_comboBox->setCurrentText(settings.value("flowControl").toString()); }
int32_t TestRunner::cppVariantToInt32(const CppVariant& value) { if (value.isNumber()) return value.toInt32(); if (value.isString()) { string stringSource = value.toString(); const char* source = stringSource.data(); char* end; long number = strtol(source, &end, 10); if (end == source + stringSource.length() && number >= numeric_limits<int32_t>::min() && number <= numeric_limits<int32_t>::max()) return static_cast<int32_t>(number); } printErrorMessage("Invalid value for preference. Expected integer value."); return 0; }
void CompanyBuilder::disbandNode(string team_name , string supervisor) { if (supervisor == "None") { printErrorMessage("disband", team_name); return;} Node* team = getNode(team_name); Group* teamGrp = getTeam(team_name); Group* super = getTeam(supervisor); super->RemoveChild(team); //remove team's pointer from super's vector for (int i=0; i < teamGrp->get_children_size(); i++) { super->AddChild(teamGrp->get_child(i)); } teamGrp->ClearNodeVec(); //prevent team from deleting its children when destructor called delete teamGrp; print(); }
// Need these conversions because the format of the value for booleans // may vary - for example, on mac "1" and "0" are used for boolean. bool TestRunner::cppVariantToBool(const CppVariant& value) { if (value.isBool()) return value.toBoolean(); if (value.isNumber()) return value.toInt32(); if (value.isString()) { string valueString = value.toString(); if (valueString == "true" || valueString == "1") return true; if (valueString == "false" || valueString == "0") return false; } printErrorMessage("Invalid value. Expected boolean value."); return false; }