string JsonVehicleRecord::convertToJSON(const VehicleRecord &rVehicleRecord) { // String to represent the vehicle record object string json_obj_string; string json_license = convertString(rVehicleRecord.getLicensePlate()); string json_type = convertString(rVehicleRecord.getVehicleType()); string json_speed= convertFloat(rVehicleRecord.getSpeed()); string json_date = convertDate(rVehicleRecord.getDate()); //Adds the initial character of a json object json_obj_string += OBJ_START_CHAR; //Adds the license plate attribute json_obj_string += RECORD_LICEN_ATTR + ATTR_DECLA_CHAR + json_license; //Adds the separator character between attributes json_obj_string += ATTR_SEPAR_CHAR; //Adds the vehicle type attribute json_obj_string += RECORD_TYPE_ATTR + ATTR_DECLA_CHAR + json_type; //Adds the separator character between attributes json_obj_string += ATTR_SEPAR_CHAR; //Adds the speed attribute json_obj_string += RECORD_SPEED_ATTR + ATTR_DECLA_CHAR + json_speed; //Adds the separator character between attributes json_obj_string += ATTR_SEPAR_CHAR; //Adds the date attribute json_obj_string += RECORD_DATE_ATTR + ATTR_DECLA_CHAR + json_date; //Adds the end character of a json object json_obj_string += OBJ_END_CHAR; return json_obj_string; }
void print_menuItems(char item1[], char item2[], char item3[], char item4[]){ clear_pixelMatrix(); int xPosItem = 20; int yPosItem = 3; //Item1 int item1_ASCII [strlen(item1)]; convertString(item1, item1_ASCII); print_ASCIIString(xPosItem, yPosItem, item1_ASCII, sizeof(item1_ASCII)/sizeof(item1_ASCII[0])); yPosItem += 15; //Item2 int item2_ASCII [strlen(item2)]; convertString(item2, item2_ASCII); print_ASCIIString(xPosItem, yPosItem, item2_ASCII, sizeof(item2_ASCII)/sizeof(item2_ASCII[0])); yPosItem += 15; //Item3 int item3_ASCII [strlen(item3)]; convertString(item3, item3_ASCII); print_ASCIIString(xPosItem, yPosItem, item3_ASCII, sizeof(item3_ASCII)/sizeof(item3_ASCII[0])); yPosItem += 15; //Item4 int item4_ASCII [strlen(item4)]; convertString(item4, item4_ASCII); print_ASCIIString(xPosItem, yPosItem, item4_ASCII, sizeof(item4_ASCII)/sizeof(item4_ASCII[0])); //Haken print_symbol(16,17, hakenSymb,108,46); }
namespace LightSpeed { defineTest test_textToBase64("baseX.textToBase64","UHJpc2VybmUgemx1dG91Y2t5IGt1biB1cGVsIGRhYmVsc2tlIGtvZHk=MTIzNA==",[](PrintTextA &out) { CharsToBytesConvert charToByte; ByteToBase64Convert base64conv; ConverterChain<CharsToBytesConvert &, ByteToBase64Convert &> convChain(charToByte, base64conv); ConstStrA text("Priserne zlutoucky kun upel dabelske kody"); StringA conv = StringA(convertString(convChain, text)); out("%1") << conv; base64conv.eolb = false; ConstStrA text2("1234"); StringA conv2 = StringA(convertString(convChain, text2)); out("%1") << conv2; }); defineTest test_base64ToText("baseX.base64ToText","Priserne zlutoucky kun upel dabelske kody",[](PrintTextA &out){ BytesToCharsConvert charToByte; Base64ToByteConvert base64conv; ConverterChain<Base64ToByteConvert &, BytesToCharsConvert &> convChain(base64conv,charToByte); ConstStrA text("UHJpc2VybmUgemx1dG91Y2t5IGt1biB1cGVsIGRhYmVsc2tlIGtvZHk="); StringA conv = StringA(convertString(convChain, text)); out("%1") << conv; }); }
void displayMenu(std::shared_ptr< Overlay::ISurface > pSurface) { pSurface->Rect(150, 50, 300, 170, createRGBA(101, 71, 39, 255)); pSurface->BorderBox(150, 50, 300, 170, 3,createRGBA(10, 10, 10, 255)); pSurface->String(165, 65, "Headline", createRGBA(255, 240, 190, 255), convertString("Percentual HP - F10")); pSurface->String(175, 105, "Default", createRGBA(255, 240, 190, 255), convertString(">Calibrate")); pSurface->String(175, 130, "Default", createRGBA(255, 240, 190, 255), convertString(">Set Position")); //pSurface->BorderBox(170, 100, 150, 25, 3, createRGBA(10, 10, 10, 255)); pSurface->String(175, 180, "Default", createRGBA(255, 240, 190, 255), convertString(infoText)); //pSurface->String(175, 250, "Default", createRGBA(255, 240, 190, 255), convertString(debugText)); }
/** * Export VirtualBox medium attachment */ static void exportVirtualBoxMediumAttachment(IMediumAttachment *mediumAttachment, xmlTextWriterPtr writer) { // find info string controller; PRInt32 port = 0; PRInt32 device = 0; PRUint32 type = 0; nsCOMPtr<IMedium> medium; { nsXPIDLString value; nsresult rc = mediumAttachment->GetController(getter_Copies(value)); if (NS_SUCCEEDED(rc)) { controller = convertString(value); } } mediumAttachment->GetPort(&port); mediumAttachment->GetDevice(&device); mediumAttachment->GetType(&type); mediumAttachment->GetMedium(getter_AddRefs(medium)); // slot description char name[1024]; string location = "none"; if (type == DeviceType_Floppy || type == DeviceType_DVD) { location = "emptydrive"; } if (medium != nsnull) { nsXPIDLString value; nsresult rc = medium->GetLocation(getter_Copies(value)); if (NS_SUCCEEDED(rc)) { location = convertString(value); } } sprintf(name, "%s-%ld-%ld", controller.c_str(), (long int)port, (long int)device); WRITEXMLSTRING(name, location); if (medium != nsnull) { nsXPIDLString value; nsresult rc = medium->GetId(getter_Copies(value)); string uuid; if (NS_SUCCEEDED(rc)) { uuid = convertString(value); } sprintf(name, "%s-ImageUUID-%ld-%ld", controller.c_str(), (long int)port, (long int)device); WRITEXMLSTRING(name, uuid); } }
/** * Export VirtualBox vrde server */ static void exportVirtualBoxVRDEServer(IVRDEServer *vrdeServer, xmlTextWriterPtr writer) { nsresult rc; // find info PRBool enabled = PR_FALSE; vrdeServer->GetEnabled(&enabled); // vrde enabled ADDXMLBOOL(vrdeServer->GetEnabled, "vrde"); if (enabled == PR_TRUE) { // vrde extpack ADDXMLSTRING(vrdeServer->GetVRDEExtPack, "vrde.ext"); // vrde auth lib ADDXMLSTRING(vrdeServer->GetAuthLibrary, "vrde.authlib"); // vrde multicon ADDXMLBOOL(vrdeServer->GetAllowMultiConnection, "vrde.multicon"); // vrde reusecon ADDXMLBOOL(vrdeServer->GetReuseSingleConnection, "vrde.reusecon"); // vrde properties { PRUnichar **properties = nsnull; PRUint32 propertiesCount = 0; nsAutoString keyPrefix; rc = vrdeServer->GetVRDEProperties(&propertiesCount, &properties); if (NS_SUCCEEDED(rc)) { for (PRUint32 i = 0; i < propertiesCount; i++) { nsXPIDLString value; rc = vrdeServer->GetVRDEProperty(properties[i], getter_Copies(value)); if (NS_SUCCEEDED(rc)) { nsCAutoString key("vrde."); key.AppendWithConversion(properties[i]); WRITEXMLSTRING(convertString(key).c_str(), convertString(value)); } } NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(propertiesCount, properties); } } } }
double PCalc::calculateString(const QString &string) { QString str = convertString(string); QStringList lst = str.split(" "); QStack<double> stack; for(int i = 0; i < lst.count(); i++) { bool ok = false; double d = lst[i].toDouble(&ok); if(ok) stack.push(d); else { double d1 = stack.pop(); double d2 = stack.pop(); if( lst[i] == "+" ) stack.push(d2 + d1); else if( lst[i] == "-" ) stack.push(d2 - d1); else if( lst[i] == "*" ) stack.push(d2 * d1); else if( lst[i] == "/") stack.push(d2 / d1); else if( lst[i] == "^") stack.push( pow(d2, d1) ); } } double a = stack.pop(); return a; }
//============================================================================= CIFin::CifFile::CifFile(std::string filename) { _first = _current = _default = NULL; _curLay = NULL; _hierTree = NULL; _fileName = filename; std::ostringstream info; // Open the input file std::string fname(convertString(_fileName)); if (!(_cifFh = fopen(fname.c_str(),"rt"))) // open the input file { _status = cfs_FNF; return; } // feed the flex with the buffer of the input file void* b = new_cif_lex_buffer( _cifFh ); info << "Parsing \"" << _fileName << "\" using CIF grammar"; tell_log(console::MT_INFO,info.str()); CIFInFile = this; _default = DEBUG_NEW CifStructure(0,NULL); _default->cellNameIs(std::string(getFileNameOnly(filename) + "_cif")); // run the bison generated parser ciflloc.first_column = ciflloc.first_line = 1; ciflloc.last_column = ciflloc.last_line = 1; /* cifdebug = 1;*/ cifparse(); delete_cif_lex_buffer( b ); if (cifnerrs > 0) _status = cfs_ERR; else _status = cfs_POK; closeFile(); }
void LogsProcessor::saveAll() { for (int i=0,e=m_towrite.size(); i<e; ++i) { int id = m_towrite[i].log; if (id == -1) continue; CSectionLock _lock(m_cs_logs); int lastid = m_logs.size()-1; if (id < 0 || id > lastid || !m_logs[id]) continue; prepare(id); for (int j=i; j<e; ++j) { msg &m = m_towrite[j]; if (m.log != id) continue; m.log = -1; std::string out; convertString(m.str, &out); write(m_logs[id]->hfile, out); } } CSectionLock _lock(m_cs); for (int i=0,e=m_towrite.size(); i<e; ++i) { MudViewString *s = m_towrite[i].str; m_free.push_back(s); } m_towrite.clear(); }
size_t writeString(WriteStream &stream, const Common::UString &str, Encoding encoding, bool terminate) { ScopedPtr<MemoryReadStream> data(convertString(str, encoding, terminate)); const size_t n = stream.writeStream(*data); return n; }
void print_date(int yPos) { for(int x = 0; x<128; x++) { for(int y=yPos; y<yPos+18; y++ ){ reset_pixel(x,y); } } /*int dayWidth = get_dayWidth(); int monthWidth = get_monthWidth(); int dateWidth = dayWidth + monthWidth + 6; //6=Punkt + Leerzeichen int xPosDate = (127 - dateWidth) / 2 + 1;*/ int xPosDate = get_dateXPos(); if ((yPos == POS_DATE_STD) && (day==14) && (month==1)){ uint8_t roseSymb[90]; for(int i=0; i<90; i++){ roseSymb[i] = pgm_read_byte(&rose[0][i]); } print_symbol(16, 45, roseSymb, (127 - ROSE_WIDTH) / 2 + 1, POS_DATE_STD); } else if ((yPos == POS_DATE_STD) && (day==4) && (month==7)) { int spruch [11]; convertString("Alles Liebe", spruch); int xSpruch = (127 - get_stringWidth(spruch, 11)) / 2 + 1; print_ASCIIString(xSpruch, POS_DATE_STD, spruch, 11); uint8_t herzSymb[32]; for(int i=0; i<32; i++){ herzSymb[i] = pgm_read_byte(&herz[0][i]); } print_symbol(16, 16, herzSymb, xSpruch - 16 - 4, POS_DATE_STD); print_symbol(16, 16, herzSymb, xSpruch + get_stringWidth(spruch, 11) + 4, POS_DATE_STD); } else { print_day(xPosDate, yPos); //Tag print_letter(alphaHeight, pgm_read_byte(&alphaWidth[54]), 54, xPosDate + get_dayWidth() + 1, yPos); //Punkt print_month(xPosDate + get_dayWidth() + 6, yPos); //Monat ..+6=Punkt+Leerzeichen } }
bool EffectShaderAnnotationDX9Imp::acquireResource() { assert( effect_ ); if( NULL == effect_ ) return false; switch( searchBy_ ) { case ESEARCH_BY_INDEX: handle_ = effect_->GetAnnotation( getParentHandle(), index_ ); break; case ESEARCH_BY_NAME: handle_ = effect_->GetParameterByName( getParentHandle(), convertString( name_ ).c_str() ); break; } if( NULL == handle_ ) { wchar_t tmp[256]; _snwprintf_s( tmp, 256, L"EffectShaderAnnotationDX9Imp::acquireResource\n" ); OutputDebugStr( tmp ); return false; } assert( effect_ ); effect_->GetParameterDesc( getHandleDX9(), & desc_ ); return true; }
svd::svd(char* inPath, char* outPath,char* k) { string command="redsvd -i "; command=command+inPath+" -o "+outPath+"/matrix -r "+k; char* comm=convertString(&command); system(comm); delete comm; }
void writeStringFixed(WriteStream &stream, const Common::UString &str, Encoding encoding, size_t length) { if (length == 0) return; ScopedPtr<MemoryReadStream> data(convertString(str, encoding, false)); size_t n = stream.writeStream(*data, length); while (n++ < length) stream.writeByte(0); }
bool KSDBHandler::saveWord(const QString &word, const QString &text, bool add, const QString &id) { QString rawQuery, search; search = convertString(word); if(add) { rawQuery="INSERT INTO phrases ( name , search , text ) VALUES ( '"+word+"' , '"+search+"' , \""+text+"\" );"; } else { rawQuery="UPDATE phrases SET name='"+word+"', search='"+search+"' , text=\""+text+"\" WHERE id_phrase='"+id+"';"; } return query(rawQuery); }
/* void OnStopSending (in string aMsgID, in nsresult aStatus, in wstring aMsg, in nsIFile returnFile); */ NS_IMETHODIMP MailEwsSendListener::OnStopSending(const char *aMsgID, nsresult aStatus, const char16_t *aMsg, nsIFile *returnFile) { IMPORT_LOG0("Send end!"); m_done = true; m_location = returnFile; nsString path; returnFile->GetPath(path); NS_LossyConvertUTF16toASCII_external convertString(path); mailews_logger << "msg file:" << convertString.get() << std::endl; return NS_OK; }
void writeStringFixed(WriteStream &stream, const Common::UString &str, Encoding encoding, size_t length) { MemoryReadStream *data = 0; try { data = convertString(str, encoding, false); size_t n = stream.writeStream(*data, length); while (n++ < length) stream.writeByte(0); } catch (...) { delete data; throw; } delete data; }
void TSocket::execQuery( const QString &str ) { QString error = ""; QString data; QSqlDatabase db = QSqlDatabase::database(); if( !db.isValid() ) error = tr("Connection to the database is not established!"); if( error.isEmpty() || error.isNull() ) { //опасное место. исправить. QSqlQuery query( convertString(str) ); if( !query.isActive() ) error = query.lastError().text(); QSqlRecord rec = query.record(); if( rec.count() > 0 ) { data = ""; while( query.next() ) { int count = rec.count(); for(int i = 0; i < count; i++) { data += query.value(i).toString().simplified(); if( i != count-1 ) data += "\t"; } data += "\n"; } } QStringList list = data.split("\n"); qDebug() << "Row count: " << list.count(); qDebug() << data << "\n"; for(int i = 0; i < list.count(); i++) sendString( list[i] ); } if( !error.isEmpty() && !error.isNull() ) { writeData( error.toLocal8Bit().data(), qstrlen( error.toLocal8Bit().data() ) ); return; } }
size_t writeString(WriteStream &stream, const Common::UString &str, Encoding encoding, bool terminate) { size_t n = 0; MemoryReadStream *data = 0; try { data = convertString(str, encoding, terminate); n = stream.writeStream(*data); } catch (...) { delete data; throw; } delete data; return n; }
//============================================================================= CIFin::CifExportFile::CifExportFile(std::string fn, USMap* laymap, bool verbose) { _fileName = fn; _laymap = laymap; _verbose = verbose; _lastcellnum = 0; std::string fname(convertString(_fileName)); _file.open(_fileName.c_str(), std::ios::out); //@TODO how to check for an error ? // start writing TpdTime timec(time(NULL)); _file << "( CIF 2.0 );" << std::endl; _file << "( generator : Toped 0.9.x );" << std::endl; _file << "( user : tbd );" << std::endl; _file << "( machine : tbd );" << std::endl; _file << "( time stamp : " << timec() << ");" << std::endl; }
void layprop::ViewProperties::saveProperties(std::string filename) const { FILE * prop_file; std::string fname = convertString(filename); prop_file = fopen(fname.c_str(),"wt"); // file header here _drawprop.savePatterns(prop_file); _drawprop.saveColors(prop_file); _drawprop.saveLines(prop_file); _drawprop.saveLayers(prop_file); if ((NULL != _gdsLayMap) || (NULL != _cifLayMap)) saveLayerMaps(prop_file); saveScreenProps(prop_file); fprintf(prop_file, "layerSetup();"); if ((NULL != _gdsLayMap) || (NULL != _cifLayMap)) fprintf(prop_file, "layerMaps();"); fprintf(prop_file, "screenSetup();\n\n"); fclose(prop_file); }
Common::String ResourceManager::getNumberedString(int value) { if (_sliceBusy) { fatal("Can't read from data file", "I'm already reading something"); return NULL; } _bigDataFile->seek((value << 2) + _startOfTextIndex, 0); value = _bigDataFile->readUint32LE(); _bigDataFile->seek(value, 0); Common::String s = readString(_bigDataFile); if (gameVersion < VERSION(2, 2)) { // This is an older game - We need to convert the string to UTF-8 s = convertString(s); } return s; }
void VariantToBsonConverter::convertElement(bson_t *bson, const char *key, Variant v) { switch (v.getType()) { case KindOfUninit: case KindOfNull: convertNull(bson, key); break; case KindOfBoolean: convertBoolean(bson, key, v.toBoolean()); break; case KindOfInt64: convertInt64(bson, key, v.toInt64()); break; case KindOfDouble: convertDouble(bson, key, v.toDouble()); break; #if HIPPO_HHVM_VERSION >= 31200 case KindOfPersistentString: #else case KindOfStaticString: #endif case KindOfString: convertString(bson, key, v.toString()); break; case KindOfArray: #if HIPPO_HHVM_VERSION >= 31100 case KindOfPersistentArray: #endif case KindOfObject: convertDocument(bson, key, v); break; case KindOfRef: convertElement(bson, key, *v.getRefData()); break; case KindOfResource: throw MongoDriver::Utils::throwUnexpectedValueException("Got unsupported type 'resource'"); return; case KindOfClass: not_reached(); } }
// .--- openFile() ---. std::FILE *Platform::openFile(const UString &fileName, FileMode mode) { assert(((uint) mode) < kFileModeMAX); std::FILE *file = 0; #if defined(WIN32) static const wchar_t *modeStrings[kFileModeMAX] = { L"rb", L"wb" }; MemoryReadStream *utf16Name = convertString(fileName, kEncodingUTF16LE); file = _wfopen((const wchar_t *) utf16Name->getData(), modeStrings[(uint) mode]); delete utf16Name; #else static const char *modeStrings[kFileModeMAX] = { "rb", "wb" }; file = std::fopen(fileName.c_str(), modeStrings[(uint) mode]); #endif return file; }
void ParamConverter::editConvert() { QString editContent = mainEdit->toPlainText(); QStringList contentList = editContent.split('\n'); int stringCount = contentList.size(); QString tempString; QStringList convertedList; for(int i = 0;i < stringCount; i++) { tempString = contentList.at(i); if(tempString.length() == 0) { continue; } tempString = convertString(tempString); convertedList.push_back(tempString); } tempString = convertedList.join(' '); mainEdit->setPlainText(tempString); }
int scan(char *filename) { yyin = fopen(filename,"r"); if (!yyin) { fprintf(stderr,"scan error: unable to open %s\n",filename); exit(1); } while(yyin) { int t = yylex(); if (!t) break; printf("%s", token_string(t)); if ( t == TOKEN_STRING_LITERAL || t == TOKEN_CHAR_LITERAL) { char string[600]; strcpy(string,yytext); convertString(string); printf(" %s", string); } printf("\n"); } fclose(yyin); return 0; }
//----------------------------------------------------------------------------- Calbr::CalbrFile::CalbrFile(const std::string &fileName) :_ok(true) { std::ostringstream ost; _fileName = fileName; std::string fname(convertString(_fileName)); if (!(_calbrFile = fopen(fname.c_str(),"rt"))) // open the input file { _ok = false; ost << "Can't open file " << fname; tell_log(console::MT_ERROR,ost.str()); return; } //read header char str[512]; if (fgets(str, 512, _calbrFile)==NULL) { _ok = false; ost << "Problem of reading file " << fname; tell_log(console::MT_ERROR,ost.str()); return; } char cellName[512]; sscanf( str, "%s %ud", cellName, &_precision); //initialisation of static member drcPolygon class drcPolygon::_precision = _precision; drcEdge::_precision = _precision; _cellName = cellName; while(parse()) { } }
String OSXClipboardTextConverter::doToIClipboard(const String& data) const { return convertString(data, CFStringGetSystemEncoding(), kCFStringEncodingUTF8); }
/** * Export VirtualBox machine */ void exportVirtualBoxMachine(IVirtualBox *virtualBox, IMachine *machine, xmlTextWriterPtr writer) { nsCOMPtr<ISystemProperties> systemProperties; nsresult rc = virtualBox->GetSystemProperties(getter_AddRefs(systemProperties)); if (NS_SUCCEEDED(rc)) { xmlTextWriterStartElement(writer, TOXMLCHAR("machine")); // uuid ADDXMLSTRING(machine->GetId, "id"); // name ADDXMLSTRING(machine->GetName, "name"); // description ADDXMLSTRING(machine->GetDescription, "description"); // os type ADDXMLSTRING(machine->GetOSTypeId, "ostype"); // settings file ADDXMLSTRING(machine->GetSettingsFilePath, "path"); // hardware uuid ADDXMLSTRING(machine->GetHardwareUUID, "hardwareuuid"); // memory size ADDXMLINT32U(machine->GetMemorySize, "memory"); // memory balloon size ADDXMLINT32U(machine->GetMemoryBalloonSize, "memoryballoon"); // page fusion ADDXMLBOOL(machine->GetPageFusionEnabled, "pagefusion"); // vram size ADDXMLINT32U(machine->GetVRAMSize, "vram"); // hpet ADDXMLBOOL(machine->GetHPETEnabled, "hpet"); // cpu count ADDXMLINT32U(machine->GetCPUCount, "cpus"); // cpu execution cap ADDXMLINT32U(machine->GetCPUExecutionCap, "cpucap"); // cpu hotplug ADDXMLBOOL(machine->GetCPUHotPlugEnabled, "cpuhotplug"); // synthcpu // { // PRBool value; // rc = machine->GetCPUProperty(CPUPropertyType_Synthetic, &value); // if (NS_SUCCEEDED(rc)) { // WRITEXMLBOOL("synthcpu", value); // } // } // firmware type ADDXMLENUM(machine->GetFirmwareType, "firmware", firmwareTypeConverter); // bios settings { nsCOMPtr<IBIOSSettings> value; rc = machine->GetBIOSSettings(getter_AddRefs(value)); if (NS_SUCCEEDED(rc)) { exportVirtualBoxBIOSSettings(value, writer); } } // boot order { PRUint32 bootPositions; rc = systemProperties->GetMaxBootPosition(&bootPositions); if (NS_SUCCEEDED(rc)) { for (PRUint32 i = 1; i <= bootPositions; i++) { PRUint32 value; rc = machine->GetBootOrder(i, &value); if (NS_SUCCEEDED(rc)) { char name[256]; sprintf(name, "boot%d", i); WRITEXMLENUM(name, value, deviceTypeConverter); } } } } // pae { PRBool value; rc = machine->GetCPUProperty(CPUPropertyType_PAE, &value); if (NS_SUCCEEDED(rc)) { WRITEXMLBOOL("pae", value); } } // rtc use utc ADDXMLBOOL(machine->GetRTCUseUTC, "rtcuseutc"); // monitor count ADDXMLINT32U(machine->GetMonitorCount, "monitorcount"); // accelerate 3D ADDXMLBOOL(machine->GetAccelerate3DEnabled, "accelerate3d"); // accelerate 2D video ADDXMLBOOL(machine->GetAccelerate2DVideoEnabled, "accelerate2dvideo"); // hwvirtex { PRBool value; rc = machine->GetCPUProperty(HWVirtExPropertyType_Enabled, &value); if (NS_SUCCEEDED(rc)) { WRITEXMLBOOL("hwvirtex", value); } } // vtxvpid { PRBool value; rc = machine->GetHWVirtExProperty(HWVirtExPropertyType_VPID, &value); if (NS_SUCCEEDED(rc)) { WRITEXMLBOOL("vtxvpid", value); } } // nestedpaging { PRBool value; rc = machine->GetHWVirtExProperty(HWVirtExPropertyType_NestedPaging, &value); if (NS_SUCCEEDED(rc)) { WRITEXMLBOOL("nestedpaging", value); } } // unrestrictedexec { PRBool value; rc = machine->GetHWVirtExProperty(HWVirtExPropertyType_UnrestrictedExecution, &value); if (NS_SUCCEEDED(rc)) { WRITEXMLBOOL("unrestrictedexec", value); } } // largepages { PRBool value; rc = machine->GetHWVirtExProperty(HWVirtExPropertyType_LargePages, &value); if (NS_SUCCEEDED(rc)) { WRITEXMLBOOL("largepages", value); } } // force { PRBool value; rc = machine->GetHWVirtExProperty(HWVirtExPropertyType_Force, &value); if (NS_SUCCEEDED(rc)) { WRITEXMLBOOL("hwforce", value); } } // io cache ADDXMLBOOL(machine->GetIOCacheEnabled, "iocache"); // io cache size ADDXMLINT32U(machine->GetIOCacheSize, "iocachesize"); // chipset type ADDXMLENUM(machine->GetChipsetType, "chipset", chipsetTypeConverter); // pointing hid type ADDXMLENUM(machine->GetPointingHIDType, "mouse", pointingHidTypeConverter); // keyboard hid type ADDXMLENUM(machine->GetKeyboardHIDType, "keyboard", keyboardHidTypeConverter); // clipboard mode ADDXMLENUM(machine->GetClipboardMode, "clipboard", clipboardModeConverter); // vm state ADDXMLENUM(machine->GetState, "state", stateConverter); // vm state change ADDXMLTIMESTAMP(machine->GetLastStateChange, "statechanged"); // teleporterenabled, teleporterport, teleporteraddress, teleporterpassword // storage controller { IStorageController **storageControllers = nsnull; PRUint32 storageControllersCount = 0; rc = machine->GetStorageControllers(&storageControllersCount, &storageControllers); if (NS_SUCCEEDED(rc)) { for (PRUint32 i = 0; i < storageControllersCount; i++) { exportVirtualBoxStorageController(storageControllers[i], i, writer); } } NS_FREE_XPCOM_ISUPPORTS_POINTER_ARRAY(storageControllersCount, storageControllers); } // medium attachments { IMediumAttachment **mediumAttachments = nsnull; PRUint32 mediumAttachmentsCount = 0; rc = machine->GetMediumAttachments(&mediumAttachmentsCount, &mediumAttachments); if (NS_SUCCEEDED(rc)) { for (PRUint32 i = 0; i < mediumAttachmentsCount; i++) { exportVirtualBoxMediumAttachment(mediumAttachments[i], writer); } } NS_FREE_XPCOM_ISUPPORTS_POINTER_ARRAY(mediumAttachmentsCount, mediumAttachments); } // network adapters { PRUint32 networkAdaptersCount; PRUint32 chipsetType; rc = machine->GetChipsetType(&chipsetType); if (NS_SUCCEEDED(rc)) { rc = systemProperties->GetMaxNetworkAdapters(chipsetType, &networkAdaptersCount); if (NS_SUCCEEDED(rc)) { for (PRUint32 i = 0; i < networkAdaptersCount; i++) { nsCOMPtr<INetworkAdapter> networkAdapter; rc = machine->GetNetworkAdapter(i, getter_AddRefs(networkAdapter)); if (NS_SUCCEEDED(rc)) { exportVirtualBoxNetworkAdapter(networkAdapter, i + 1, writer); } } } } } // uartX // audio adapter { nsCOMPtr<IAudioAdapter> value; rc = machine->GetAudioAdapter(getter_AddRefs(value)); if (NS_SUCCEEDED(rc)) { exportVirtualBoxAudioAdapter(value, writer); } } // vrde server { nsCOMPtr<IVRDEServer> value; rc = machine->GetVRDEServer(getter_AddRefs(value)); if (NS_SUCCEEDED(rc)) { exportVirtualBoxVRDEServer(value, writer); } } // usb controllers // { // nsCOMPtr<IUSBController> value; // rc = machine->GetUSBController(getter_AddRefs(value)); // if (NS_SUCCEEDED(rc)) { // exportVirtualBoxUSBController(value, writer); // } // } // guest properties { PRUnichar **names = nsnull; PRUnichar **values = nsnull; PRInt64 *timestamps = nsnull; PRUnichar **flags = nsnull; PRUint32 namesCount = 0; PRUint32 valuesCount = 0; PRUint32 timestampsCount = 0; PRUint32 flagsCount = 0; rc = machine->EnumerateGuestProperties((const PRUnichar*)nsnull, &namesCount, &names, &valuesCount, &values, ×tampsCount, ×tamps, &flagsCount, &flags); if (NS_SUCCEEDED(rc)) { for (PRUint32 i = 0; i < namesCount; i++) { nsAutoString name(names[i]); nsAutoString value(values[i]); PRUint64 timestamp = timestamps[i]; nsAutoString flag(flags[i]); WRITEXMLSTRING(convertString(name).c_str(), convertString(value)); } } NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(namesCount, names); NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(valuesCount, values); nsMemory::Free(timestamps); NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(flagsCount, flags); } xmlTextWriterEndElement(writer); } }
/** * Export VirtualBox network adapter */ static void exportVirtualBoxNetworkAdapter(INetworkAdapter *networkAdapter, PRUint32 index, xmlTextWriterPtr writer) { char name[256]; nsresult rc; // find info PRUint32 attachmentType = 0; networkAdapter->GetAttachmentType(&attachmentType); // attachment type sprintf(name, "nic%d", index); ADDXMLENUM(networkAdapter->GetAttachmentType, name, networkAttachmentTypeConverter); // specific configuration switch (attachmentType) { case NetworkAttachmentType_NAT: // nat network sprintf(name, "natnet%d", index); ADDXMLSTRING(networkAdapter->GetNATNetwork, name); break; case NetworkAttachmentType_Bridged: // bridge adapter sprintf(name, "bridgeadapter%d", index); ADDXMLSTRING(networkAdapter->GetBridgedInterface, name); break; case NetworkAttachmentType_Internal: // internal network sprintf(name, "intnet%d", index); ADDXMLSTRING(networkAdapter->GetInternalNetwork, name); break; case NetworkAttachmentType_HostOnly: // host adapter sprintf(name, "hostonlyadapter%d", index); ADDXMLSTRING(networkAdapter->GetHostOnlyInterface, name); break; case NetworkAttachmentType_Generic: // generic adapter sprintf(name, "genericadapter%d", index); ADDXMLSTRING(networkAdapter->GetGenericDriver, name); break; } switch (attachmentType) { case NetworkAttachmentType_NAT: case NetworkAttachmentType_Bridged: case NetworkAttachmentType_Internal: case NetworkAttachmentType_HostOnly: case NetworkAttachmentType_Generic: // enabled sprintf(name, "nicenabled%d", index); ADDXMLBOOL(networkAdapter->GetEnabled, name); // enabled sprintf(name, "nicpriority%d", index); ADDXMLINT32U(networkAdapter->GetBootPriority, name); // adapter type sprintf(name, "nictype%d", index); ADDXMLENUM(networkAdapter->GetAdapterType, name, networkAdapterTypeConverter); // mac address sprintf(name, "macaddress%d", index); ADDXMLSTRING(networkAdapter->GetMACAddress, name); // cable connected sprintf(name, "cableconnected%d", index); ADDXMLBOOL(networkAdapter->GetCableConnected, name); // speed sprintf(name, "nicspeed%d", index); ADDXMLINT32U(networkAdapter->GetLineSpeed, name); break; // promisc policy sprintf(name, "nicpromisc%d", index); ADDXMLENUM(networkAdapter->GetPromiscModePolicy, name, promiscModePolicyConverter); // extra properties { PRUnichar **propertyNames = nsnull; PRUnichar **propertyValues = nsnull; PRUint32 propertyNamesCount = 0; PRUint32 propertyValuesCount = 0; sprintf(name, "nic%d_", index); rc = networkAdapter->GetProperties(NS_LITERAL_STRING("").get(), &propertyNamesCount, &propertyNames, &propertyValuesCount, &propertyValues); if (NS_SUCCEEDED(rc)) { for (PRUint32 i = 0; i < propertyNamesCount && i < propertyValuesCount; i++) { nsCAutoString key(name); nsString value(propertyValues[i]); key.AppendWithConversion(propertyNames[i]); WRITEXMLSTRING(convertString(key).c_str(), convertString(value)); } NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(propertyNamesCount, propertyNames); NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(propertyValuesCount, propertyValues); } } } }