//---------------------------------------------------------------------------- void medHTMLTemplateParserBlock::PushBlock( wxString name, int blockType ) //---------------------------------------------------------------------------- { int varPos=SubstitutionPos(&name); int blockPos; //blocks can be pushed only on loop blocks if (m_BlockType!=MED_HTML_TEMPLATE_LOOP) { mafLogMessage("HTML Template ERROR: You can push sub-blocks only on Loop blocks, , use AddBLock instead"); return; } //we need to set the loop number before any push else if (m_LoopsNumber<0) { mafLogMessage("HTML Template ERROR: You must set the loops number before push any sub-block"); return; } //if the block does not exists i need to create the array entry if (varPos<0) { //creating the new array for this block and //adding the substitution in the substitution table std::vector<medHTMLTemplateParserBlock *> newArray; m_SubBlocksArray.push_back(newArray); HTMLTemplateSubstitution subst; subst.Name=name; subst.Pos=m_SubBlocksArray.size()-1; subst.Type=MED_HTML_SUBSTITUTION_BLOCK_ARRAY; varPos=m_SubstitutionTable.size(); m_SubstitutionTable.push_back(subst); } //if the block already exist there are already the correspondent array //and the relative substitution so we don't need to add it blockPos=m_SubstitutionTable[varPos].Pos; //checking if the existent substitution refers to a block array to if (m_SubstitutionTable[varPos].Type!=MED_HTML_SUBSTITUTION_BLOCK_ARRAY) { mafLogMessage("HTML Template ERROR: Array: \"%s\" has incompatible type",name.ToAscii()); return; } //checking if there are free slots for pushing blocks else if (m_SubBlocksArray[blockPos].size()>m_LoopsNumber) { mafLogMessage("HTML Template ERROR: to many push for: '%s'",name.ToAscii()); return; } else { medHTMLTemplateParserBlock *newBlock; newBlock=new medHTMLTemplateParserBlock(blockType, name); newBlock->SetFather(this); m_SubBlocksArray[blockPos].push_back(newBlock); } }
void Trace::layoutGraph(wxString infile, wxString outfile) { char tmpinfile[FILELEN] = {0}; char tmpoutfile[FILELEN] = {0}; strncpy(tmpinfile, infile.ToAscii(), sizeof(tmpinfile) - 1); strncpy(tmpoutfile, outfile.ToAscii(), sizeof(tmpoutfile) - 1); this->layoutGraph(tmpinfile, tmpoutfile); }
//---------------------------------------------------------------------------- void medHTMLTemplateParserBlock::PushVar( wxString name, wxString varValue ) //---------------------------------------------------------------------------- { int varPos=SubstitutionPos(&name); int blockPos; //We can push Variables only to the loops block if (m_BlockType!=MED_HTML_TEMPLATE_LOOP) { mafLogMessage("HTML Template ERROR: You can push variables only on Loop blocks, use AddVar instead"); return; } //We need to set the loop number before pushing anything to the loop else if (m_LoopsNumber<0) { mafLogMessage("HTML Template ERROR: You must set the loops number before push any variable"); return; } //if the vars does not exists i need to create the array entry if (varPos<0) { std::vector<wxString> newArray; m_VariablesArray.push_back(newArray); HTMLTemplateSubstitution subst; subst.Name=name; subst.Pos=m_VariablesArray.size()-1; subst.Type=MED_HTML_SUBSTITUTION_VARIABLE_ARRAY; //if a new entry is created in the substitution table the position is //equal at the size before the push varPos=m_SubstitutionTable.size(); m_SubstitutionTable.push_back(subst); } blockPos=m_SubstitutionTable[varPos].Pos; //checking substitusion type before push if (m_SubstitutionTable[varPos].Type!=MED_HTML_SUBSTITUTION_VARIABLE_ARRAY) { mafLogMessage("HTML Template ERROR: Array: \"%s\" has incompatible type",name.ToAscii()); return; } //checking if there are free slots for pushing vars else if (m_VariablesArray[blockPos].size()>m_LoopsNumber) { mafLogMessage("HTML Template ERROR: to many push for: '%s'",name.ToAscii()); return; } m_VariablesArray[blockPos].push_back(varValue); }
/*! Converts multiple files * * @param dirPath - path to directory * * @param filename - name of file, may include wild-cards */ int convertDirectory(const wxString &dirPath, const wxString &filename, MyTraverser &converter ) { wxDir directory(dirPath); fprintf(stdout, "------------------------------------------------------------------\n"); fprintf(stdout, " convertDirectory(): \n" " dirPath = \'%s\'\n" " filename = \'%s\'\n", (const char *)dirPath.ToAscii(), (const char *)filename.ToAscii() ); // printf("Processing Pattern %s\n", (const char *)dirPath.ToAscii()); directory.Traverse(converter, filename, wxDIR_FILES); fprintf(stdout, "------------------------------------------------------------------\n"); return converter.getRc(); }
// private utility function which returns output of the given command, removing // the trailing newline static wxString wxGetCommandOutput(const wxString &cmd) { FILE *f = popen(cmd.ToAscii(), "r"); if ( !f ) { wxLogSysError(wxT("Executing \"%s\" failed"), cmd.c_str()); return wxEmptyString; } wxString s; char buf[256]; while ( !feof(f) ) { if ( !fgets(buf, sizeof(buf), f) ) break; s += wxString::FromAscii(buf); } pclose(f); if ( !s.empty() && s.Last() == wxT('\n') ) s.RemoveLast(); return s; }
// Wrapper for wxWidgets void Trace::writeGmlFile(wxString infile) { char gmlfile[FILELEN] = {0}; strncpy(gmlfile, infile.ToAscii(), sizeof(gmlfile)); this->writeGmlFile(gmlfile); }
/** @brief Function Resolve the hostname to ip */ bool turbotrace::resolve_host(wxString host) { //Get hostname as a char pointer char *target = strdup( (char*) host.ToAscii().data()); log( _("Will now resolve : ") + wxString(target , wxConvUTF8) ); //Is it just a simple IP if( inet_addr( target ) != INADDR_NONE) { dest_ip.s_addr = inet_addr( target ); tlog(_("Valid IP provided")); } //Domain name , resolve it else { char *ip = iputils::hostname_to_ip( (char*) target ); if(ip != NULL) { tlog( wxString(target , wxConvUTF8) + _(" resolved to ") + wxString(ip , wxConvUTF8)); //Convert domain name to IP dest_ip.s_addr = inet_addr( ip ); } else { tlog( _("Unable to resolve hostname : ") + wxString(target , wxConvUTF8) ); return false; } } return true; }
wxString CSourceDataGenerator::GetFontDefinition(const EMGL_font_t *font, const wxString &name) { wxString result; result += wxString::Format("const EMGL_font_t font_%s = {%d, %u, %u, codePageTable};\n", name.ToAscii(), font->ascender, font->bpp, font->numCodepages); return result; }
bool isoimage::OpenImage(const wxString &filename) { const wxCharBuffer buffer = filename.ToAscii(); const char *path = buffer.data(); return m_image.open(path, ISO_EXTENSION_ALL); }
static void runTest(const wxString inputLine) { done = false; time(&startTime); TestCommand command = parseInputLine(std::string(inputLine.ToAscii())); string& pathOrURL = command.pathOrURL; dumpPixelsForCurrentTest = command.shouldDumpPixels; // CURL isn't happy if we don't have a protocol. size_t http = pathOrURL.find("http://"); if (http == string::npos) pathOrURL.insert(0, "file://"); gTestRunner = TestRunner::create(pathOrURL, command.expectedPixelHash); if (!gTestRunner) { wxTheApp->ExitMainLoop(); } WorkQueue::shared()->clear(); WorkQueue::shared()->setFrozen(false); webView->LoadURL(wxString(pathOrURL.c_str(), wxConvUTF8)); // wait until load completes and the results are dumped while (!done) wxSafeYield(); }
bool isoimage::ReadDir(const wxString &path, stat_vector_t& stat_vector) { const wxCharBuffer buffer = path.ToAscii(); const char *spath = buffer.data(); return m_image.readdir(spath, stat_vector); }
void ProfileFindInFilesCodeMode() { printf("*******\n"); wxLongLong time = wxGetLocalTimeMillis(); t4p::DirectorySearchClass directorySearch; t4p::SourceClass src; src.RootDirectory.AssignDir(DirName); src.SetIncludeWildcards(wxT("*.php")); std::vector<t4p::SourceClass> sources; sources.push_back(src); if (directorySearch.Init(sources)) { t4p::FindInFilesClass findInFiles; findInFiles.Expression = UNICODE_STRING_SIMPLE("class Db"); findInFiles.Mode = t4p::FinderClass::EXACT; if (findInFiles.Prepare()) { while (directorySearch.More()) { directorySearch.Walk(findInFiles); } std::vector<wxString> matchedFiles = directorySearch.GetMatchedFiles(); for (size_t i = 0; i < matchedFiles.size(); ++i) { printf("Found at least one match in file %s.\n", (const char*)matchedFiles[i].ToUTF8()); } time = wxGetLocalTimeMillis() - time; printf("time for findInFiles Code Mode:%ld ms\n", time.ToLong()); } else { puts("Invalid expression: class Db\n"); } } else { printf("Could not open Directory: %s\n", (const char*)DirName.ToAscii()); } }
void ProfileFindInFilesExactMode() { printf("*******\n"); wxLongLong time = wxGetLocalTimeMillis(); t4p::DirectorySearchClass directorySearch; if (directorySearch.Init(DirName)) { t4p::FindInFilesClass findInFiles; findInFiles.Expression = UNICODE_STRING_SIMPLE("class Db"); findInFiles.Mode = t4p::FinderClass::EXACT; if (findInFiles.Prepare()) { while (directorySearch.More()) { directorySearch.Walk(findInFiles); } std::vector<wxString> matchedFiles = directorySearch.GetMatchedFiles(); for (size_t i = 0; i < matchedFiles.size(); ++i) { printf("Found at least one match in file %s.\n", (const char*)matchedFiles[i].ToUTF8()); } time = wxGetLocalTimeMillis() - time; printf("time for findInFiles Exact Mode:%ld ms \n", time.ToLong()); } else { puts("Invalid expression: class Db\n"); } } else { printf("Could not open Directory: %s\n", (const char*)DirName.ToAscii()); } }
void wxDataFormat::SetId( const wxString& id ) { #if !wxUSE_NANOX PrepareFormats(); m_type = wxDF_PRIVATE; m_format = XInternAtom( (Display*) wxGetDisplay(), id.ToAscii(), FALSE ); #endif }
double StrToDouble(const wxString &value) { wxCharBuffer buf = value.ToAscii(); char *p = (char *)strchr(buf, '.'); if (p) *p = localeconv()->decimal_point[0]; return strtod(buf, 0); }
Object RaceAnalyzerComm::ParseJSON(wxString &json){ Object root; std::stringstream stream; for (size_t i = 0; i < json.Len(); i++){ stream.put(json.ToAscii()[i]); } Reader::Read(root, stream); return root; }
wxString RaceAnalyzerComm::SendCommand(CComm *comPort, const wxString &buffer, size_t timeout){ wxMutexLocker lock(_commMutex); wxString response; try{ VERBOSE(FMT("Send Cmd (%d): '%s'",buffer.Len(), buffer.ToAscii())); size_t bufferSize = 8192; comPort->sendCommand(buffer.ToAscii(),wxStringBuffer(response,bufferSize),bufferSize,timeout,true); VERBOSE(FMT("Cmd Response: %s", response.ToAscii())); } catch(SerialException &e){ throw CommException(e.GetErrorStatus(), e.GetErrorDetail()); } catch(...){ throw CommException(-1, "Unknown exception while sending command"); } return response.Trim(true).Trim(false); }
void wxMessageOutputStderr::Output(const wxString& str) { const wxString strWithLF = AppendLineFeedIfNeeded(str); const wxWX2MBbuf buf = strWithLF.mb_str(); if ( buf ) fprintf(stderr, "%s", (const char*) buf); else // print at least something fprintf(stderr, "%s", (const char*) strWithLF.ToAscii()); }
void wxTopLevelWindowX11::SetTitle(const wxString& title) { m_title = title; if (X11GetMainWindow()) { #if wxUSE_UNICODE // I wonder of e.g. Metacity takes UTF-8 here XStoreName(wxGlobalDisplay(), (Window) X11GetMainWindow(), (const char*) title.ToAscii() ); XSetIconName(wxGlobalDisplay(), (Window) X11GetMainWindow(), (const char*) title.ToAscii() ); #else XStoreName(wxGlobalDisplay(), (Window) X11GetMainWindow(), (const char*) title); XSetIconName(wxGlobalDisplay(), (Window) X11GetMainWindow(), (const char*) title); #endif } }
void SerialConnection::SendNMEAMessage( wxString &message, wxString &source ) { if ( !IsOpen() ) return; if ( FilterOutput( message, source ) ) { wxCharBuffer buffer = message.ToAscii(); WriteDevice( buffer.data(), strlen( buffer.data() ) ); buffer = m_EOS.ToAscii(); WriteDevice( buffer.data(), strlen( buffer.data() ) ); } }
void CppCheck::DoCppCheckAnalysis(const wxString& Xml) { // clear the list m_ListLog->Clear(); TiXmlDocument Doc; Doc.Parse( Xml.ToAscii() ); if ( Doc.Error() ) { wxString msg = _("Failed to parse cppcheck XML file.\nProbably it's not produced correctly."); AppendToLog(msg); cbMessageBox(msg, _("Error"), wxICON_ERROR | wxOK, Manager::Get()->GetAppWindow()); } else { TiXmlHandle Handle(&Doc); Handle = Handle.FirstChildElement("results"); bool ErrorsPresent = false; TiXmlElement* resultNode = Handle.ToElement(); if (nullptr!=resultNode->Attribute("version")) { wxString Version = wxString::FromAscii(resultNode->Attribute("version")); if ( Version.IsSameAs(wxT("2")) ) ErrorsPresent = DoCppCheckParseXMLv2(Handle); else { cbMessageBox(_("Unsupported XML file version of CppCheck."), _("Error"), wxICON_ERROR | wxOK, Manager::Get()->GetAppWindow()); } } else { ErrorsPresent = DoCppCheckParseXMLv1(Handle); } if (ErrorsPresent) { if ( Manager::Get()->GetLogManager() ) { CodeBlocksLogEvent evtSwitch(cbEVT_SWITCH_TO_LOG_WINDOW, m_ListLog); Manager::Get()->ProcessEvent(evtSwitch); } } if ( !Doc.SaveFile("CppCheckResults.xml") ) { cbMessageBox(_("Failed to create output file 'CppCheckResults.xml' for cppcheck.\nPlease check file/folder access rights."), _("Error"), wxICON_ERROR | wxOK, Manager::Get()->GetAppWindow()); } } }
static bool needsQuoting(wxString &value, bool forTypes) { // Is it a number? if (value.IsNumber()) return true; else { // certain types should not be quoted even though it contains a space. Evilness. wxString valNoArray; if (forTypes && value.Right(2) == wxT("[]")) valNoArray = value.Mid(0, value.Len() - 2); else valNoArray = value; if (forTypes && (!valNoArray.CmpNoCase(wxT("character varying")) || !valNoArray.CmpNoCase(wxT("\"char\"")) || !valNoArray.CmpNoCase(wxT("bit varying")) || !valNoArray.CmpNoCase(wxT("double precision")) || !valNoArray.CmpNoCase(wxT("timestamp without time zone")) || !valNoArray.CmpNoCase(wxT("timestamp with time zone")) || !valNoArray.CmpNoCase(wxT("time without time zone")) || !valNoArray.CmpNoCase(wxT("time with time zone")) || !valNoArray.CmpNoCase(wxT("\"trigger\"")) || !valNoArray.CmpNoCase(wxT("\"unknown\"")))) return false; int pos = 0; while (pos < (int)valNoArray.length()) { wxChar c = valNoArray.GetChar(pos); if (!((pos > 0) && (c >= '0' && c <= '9')) && !(c >= 'a' && c <= 'z') && !(c == '_')) { return true; } pos++; } } // is it a keyword? const ScanKeyword *sk = ScanKeywordLookup(value.ToAscii()); if (!sk) return false; if (sk->category == UNRESERVED_KEYWORD) return false; if (forTypes && sk->category == COL_NAME_KEYWORD) return false; return true; }
Trace::Trace(wxString tracefile, wxString orig_exe_file, wxString outputfile) { char tfile[FILELEN] = {0}; char ogfile[FILELEN] = {0}; char opfile[FILELEN] = {0}; doColorBlind = false; graphColoringAlgorithm = GRAPH_COLOR_PACKER; strncpy(this->tracefile, tracefile.ToAscii(), sizeof(this->tracefile) - 1); if (orig_exe_file.length() > 0) // Zero length string means don't process the exe { doProcessExe = true; strncpy(this->orig_exe_file, orig_exe_file.ToAscii(), sizeof(this->orig_exe_file) - 1); } else { doProcessExe = false; } strncpy(this->outputfile, outputfile.ToAscii(), sizeof(this->outputfile) -1); this->parseFiles(); }
//---------------------------------------------------------------------------- void medHTMLTemplateParserBlock::AddVar( wxString name, wxString varValue ) //---------------------------------------------------------------------------- { //if Variable already exists we dont add it again if (SubstitutionPos(&name)>0) mafLogMessage("HTML Template ERROR: Variable: \"%s\" already exists",name.ToAscii()); else { //Adding the Variable to the array and the relative substitution to the substitution table HTMLTemplateSubstitution subst; subst.Name=name; subst.Pos=m_Variables.size(); subst.Type=MED_HTML_SUBSTITUTION_VARIABLE; m_SubstitutionTable.push_back(subst); m_Variables.push_back(varValue); } }
wxString ExecProcess(const wxString &cmd) { wxString res; FILE *f = popen(cmd.ToAscii(), "r"); if (f) { char buffer[1024]; int cnt; while ((cnt = fread(buffer, 1, 1024, f)) > 0) { res += wxString::FromAscii(buffer); } pclose(f); } return res; }
bool wxCurlHTTP::AddForm(const bool& bClear, const wxString& szName, struct curl_forms* pForms, CURLFORMcode* outErr) { if(bClear) ResetPostData(); CURLFORMcode res = CURL_FORMADD_OK; res = curl_formadd(&m_pPostHead, &m_pPostTail, CURLFORM_COPYNAME, (const char*)szName.ToAscii(), CURLFORM_ARRAY, pForms, CURLFORM_END); if (outErr != NULL) *outErr = res; // sometimes you want to/need to see what's going on return (res == CURL_FORMADD_OK); }
//---------------------------------------------------------------------------- medHTMLTemplateParserBlock::HTMLTemplateSubstitution medHTMLTemplateParserBlock::GetSubstitution( wxString name ) //---------------------------------------------------------------------------- { HTMLTemplateSubstitution retValue; int retPos; //get the position of the substitution retPos=SubstitutionPos(&name); if (retPos>=0) { retValue=m_SubstitutionTable[retPos]; } else { mafLogMessage("HTML Template ERROR: Substitution: \"%s\" not found",name.ToAscii()); } return retValue; }
void CreateCodeDialog::PressOK(wxCommandEvent& ev) { const wxString code_name = textctrl_name->GetValue(); if (code_name.empty()) { PanicAlertT("You must enter a name!"); return; } long code_value; if (!textctrl_value->GetValue().ToLong(&code_value, 10 + checkbox_use_hex->GetValue()*6)) { PanicAlertT("Invalid Value!"); return; } //wxString full_code = textctrl_code->GetValue(); //full_code += wxT(' '); //full_code += wxString::Format(wxT("0x%08x"), code_value); // create the new code ActionReplay::ARCode new_cheat; new_cheat.active = false; new_cheat.name = std::string(code_name.ToAscii()); const ActionReplay::AREntry new_entry(code_address, code_value); new_cheat.ops.push_back(new_entry); // pretty hacky - add the code to the gameini { CISOProperties isoprops(SConfig::GetInstance().m_LastFilename, this); // add the code to the isoproperties arcode list arCodes.push_back(new_cheat); // save the gameini isoprops.SaveGameConfig(); isoprops.ActionReplayList_Load(); // loads the new arcodes //ActionReplay::UpdateActiveList(); } // refresh arcode list in other tab ::g_cheat_window->Load_ARCodes(); Close(); }
wxSocketClientPtr SocketTestCase::GetHTTPSocket(int flags) const { wxSockAddressPtr addr = GetServer(); if ( !addr.get() ) return wxSocketClientPtr(); wxSocketClient *sock = new wxSocketClient(flags); sock->SetTimeout(1); CPPUNIT_ASSERT( sock->Connect(*addr) ); const wxString httpGetRoot = "GET / HTTP/1.1\r\n" "Host: " + gs_serverHost + "\r\n" "\r\n"; sock->Write(httpGetRoot.ToAscii(), httpGetRoot.length()); return wxSocketClientPtr(sock); }
bool wxCurlHTTP::AddBufferToForm(const bool& bClear, const wxString& szName, char* buffer, size_t len, CURLFORMcode* outErr) { if(bClear) ResetPostData(); CURLFORMcode res = CURL_FORMADD_OK; res = curl_formadd(&m_pPostHead, &m_pPostTail, CURLFORM_COPYNAME, (const char*)szName.ToAscii(), CURLFORM_COPYCONTENTS, buffer, CURLFORM_CONTENTSLENGTH, len, CURLFORM_END); if (outErr != NULL) *outErr = res; // sometimes you want to/need to see what's going on return (res == CURL_FORMADD_OK); }