int main(int argc, char * *argv) { int index = my_get_opt(argc, argv); //parameter char * table = argv[index]; char * action = argv[index+1]; struct DatabaseConfig config; config.server = "localhost"; config.database = "mytable"; config.table = table; FooOBJ fobj; fobj=newFooOBJ(config); /* create a new object of type "FooOBJ" */ memset(username,0,SIZE); memset(password,0,SIZE); /*read config*/ if(!readConfig()){ fprintf(stderr,"read config fail!"); return 1; } /* Change me */ char * server = "localhost"; char * database = "mytable"; //use oop db connection connetDatabase(fobj, username, password); if( strcmp(action,"list") == 0 ){ listData(fobj); } if( strcmp(action,"add") == 0 ){ addData(fobj, argv[index+2]); } if( strcmp(action,"del") == 0 ){ delData(fobj, atoi(argv[index+2])); } if( strcmp(action,"update") == 0 ){ updateData(fobj, atoi(argv[index+2]), argv[index+3]); } closeConnection(fobj); deleteFooOBJ(fobj); return 0; }
DrawingPad::DrawingPad(QWidget *parent) : QWidget(parent) , m_canvas( 0 ) , m_listenButton( 0 ) , m_listenPortEdit( 0 ) , m_connectButton( 0 ) , m_connectAddressEdit( 0 ) , m_connectPortEdit( 0 ) , m_connected( false ) { m_canvas = new Canvas; QLayout *colorLayout = setupColorSelector(); QLayout *widthLayout = setupWidthSelector(); QVBoxLayout *settingLayout = new QVBoxLayout; settingLayout->addLayout( colorLayout ); settingLayout->addLayout( widthLayout ); settingLayout->addStretch(); QHBoxLayout *hlayout = new QHBoxLayout; hlayout->addLayout( settingLayout ); hlayout->addWidget( m_canvas ); QLayout *fileLayout = setupFileButtons(); QLayout *networkLayout1 = setupListenButtons(); QLayout *networkLayout2 = setupConnectButtons(); QVBoxLayout *buttonLayout = new QVBoxLayout; buttonLayout->setSpacing( 0 ); buttonLayout->addLayout( fileLayout ); buttonLayout->addLayout( networkLayout1 ); buttonLayout->addLayout( networkLayout2 ); QVBoxLayout *topLayout = new QVBoxLayout; topLayout->addLayout( hlayout ); topLayout->addLayout( buttonLayout ); setLayout( topLayout ); resize( 600, 500 ); m_canvas->setLineColor( Qt::black ); widthSelected( 2 ); connect( &m_listener, SIGNAL(newConnection(ServerSocket *)), this, SLOT(newConnection(ServerSocket *)) ); connect( &m_clientSocket, SIGNAL(connected()), this, SLOT(connectedToServer()) ); connect( &m_clientSocket, SIGNAL(received(QByteArray)), m_canvas, SLOT(addData(QByteArray)) ); connect( &m_clientSocket, SIGNAL(disconnected()), this, SLOT(disconnectedFromServer()) ); connect( m_canvas, SIGNAL(dataAdded(QByteArray)), &m_clientSocket, SLOT(send(QByteArray)) ); }
void StatusesMentionsTimeline::dataAdded(const QString &key, const QVariantMap &value) { Q_UNUSED(key) QVariantMap entities = value.value("entities").toMap(); QVariantList user_mentions = entities.value("user_mentions").toList(); QString id_str = OAuthManager::instance().user_id(); foreach (const QVariant &user_mention, user_mentions) { if (user_mention.toMap().value("id_str").toString() == id_str) { addData(value); break; } } }
void qmlPlotPaintedItem::addData(int index, QVariantList x, QVariantList y) { auto g = m_CustomPlot.graph(index); QVector<qreal> xx, yy; for (auto i = 0; i < x.size(); ++i) { xx.push_back(x[i].toReal()); yy.push_back(y[i].toReal()); } g->addData(xx, yy); g->rescaleAxes(); m_CustomPlot.replot(); }
void DocumentWriter::endIfNotLoadingMainResource() { if (m_frame->loader()->isLoadingMainResource() || !m_frame->page() || !m_frame->document()) return; // http://bugs.webkit.org/show_bug.cgi?id=10854 // The frame's last ref may be removed and it can be deleted by checkCompleted(), // so we'll add a protective refcount RefPtr<Frame> protector(m_frame); // make sure nothing's left in there addData(0, 0, true); m_frame->document()->finishParsing(); }
void GeoReverseGeocode::parseDone(const QVariant &result) { // DEBUG() << result; if (result.type() == QVariant::Map && result.toMap().value("result").type() == QVariant::Map) { QVariantList array = result.toMap().value("result").toMap().value("places").toList(); foreach (const QVariant &result, array) { if (result.type() == QVariant::Map) { QVariantMap map = result.toMap(); // DEBUG() << map.keys(); map.insert("id_str", map.value("id").toString()); addData(map); } } }
void SubresourceLoader::didReceiveData(const char* data, int length, long long encodedDataLength, bool allAtOnce) { ASSERT(!m_resource->resourceToRevalidate()); ASSERT(!m_resource->errorOccurred()); ASSERT(m_state == Initialized); // Reference the object in this method since the additional processing can do // anything including removing the last reference to this object; one example of this is 3266216. RefPtr<SubresourceLoader> protect(this); addData(data, length, allAtOnce); if (!m_loadingMultipartContent) sendDataToResource(data, length); if (shouldSendResourceLoadCallbacks() && m_frame) frameLoader()->notifier()->didReceiveData(this, data, length, static_cast<int>(encodedDataLength)); }
void CLinearHistogramDouble::appendHist(CLinearHistogramDouble hist) { int nSize=hist.getSize(); double delta=hist.getDelta(); double xi,xf; for(int i=0;i<nSize;i++){ xi=hist.getPosition(i); xf=xi+delta; addData(xi,xf,hist.getCounts(i)); } m_dSum+=hist.getSum(); m_dSum2+=hist.getSum2(); }
void AMRAudioFileSink::afterGettingFrame(unsigned frameSize, unsigned numTruncatedBytes, struct timeval presentationTime) { AMRAudioSource* source = (AMRAudioSource*)fSource; if (source == NULL) return; // sanity check if (!fHaveWrittenHeader && fPerFrameFileNameBuffer == NULL) { // Output the appropriate AMR header to the start of the file. // This header is defined in RFC 4867, section 5. // (However, we don't do this if we're creating one file per frame.) char headerBuffer[100]; sprintf(headerBuffer, "#!AMR%s%s\n", source->isWideband() ? "-WB" : "", source->numChannels() > 1 ? "_MC1.0" : ""); unsigned headerLength = strlen(headerBuffer); if (source->numChannels() > 1) { // Also add a 32-bit channel description field: headerBuffer[headerLength++] = 0; headerBuffer[headerLength++] = 0; headerBuffer[headerLength++] = 0; headerBuffer[headerLength++] = source->numChannels(); } addData((unsigned char*)headerBuffer, headerLength, presentationTime); } fHaveWrittenHeader = True; // Add the 1-byte header, before writing the file data proper: // (Again, we don't do this if we're creating one file per frame.) if (fPerFrameFileNameBuffer == NULL) { u_int8_t frameHeader = source->lastFrameHeader(); addData(&frameHeader, 1, presentationTime); } // Call the parent class to complete the normal file write with the input data: FileSink::afterGettingFrame(frameSize, numTruncatedBytes, presentationTime); }
void Input() { FILE *f; DATA *d; String fn,namae; int i,j,k,po[KAMO_MAX]; init(); Rel(); puts("ファイル名を入力してください"); fn=(String)malloc(STLEN); printf("→"); scanf("%s",fn); fflush(stdin); strcat(fn,".txt"); f=fopen(fn,"r"); while(f==NULL){ printf("入力した名前のファイルが存在しません\n"); printf("正しいファイル名を入力してください\n"); printf("→"); scanf("%s",fn); fflush(stdin); if(strcmp(fn,"0")==0){ printf("キャンセルします"); return; } strcat(fn,".txt"); f=fopen(fn,"r"); } fscanf(f,"%d\n",&preno); fscanf(f,"%d\n",&kamo); for(i=0;i<kamo;i++){ kam[i]=(String)malloc(STLEN); fscanf(f,"%s\n",kam[i]); } for(k=0;k<preno;k++){ fscanf(f,"%d\n",&j); namae=(String)malloc(STLEN); fscanf(f,"%s\n",namae); for(i=0;i<kamo;i++) fscanf(f,"%d¥n",&po[i]); addData(j,namae,po); } Rank(); printf("ロード成功\n"); }
void CHZDLReport::initForm() { new WText("<SCRIPT language='JavaScript' src='/basic.js'></SCRIPT>", this->elementAt(0,0)); m_pListMainTable = new WTable(this->elementAt(0,0)); string szInterTime = "时间段 "; szInterTime += m_starttime.Format(); szInterTime += "~"; szInterTime += m_endtime.Format(); InitPageTable(m_pListMainTable, szInterTime); GenList(); addData(m_pDataTable); }
void EnterISP(void) { int bit = dirPGM; uchar key[] = ENTER_ISP_KEY; resetBitBang(bit,W_25mS); addBitBang(bit); addBitBang(bit); addBitBang(bit); addBitBang(bit); flushBitBang(); resetBitBang(bit,W_1mS); addBitBang(bit); addBitBang(bit | bitMCLR); addBitBang(bit | bitMCLR); addBitBang(bit | bitMCLR); addBitBang(bit); flushBitBang(); resetBitBang(bit,W_1uS); // 32bitのKEYを送信する. addData(bswap(key[0]),8); addData(bswap(key[1]),8); flushBitBang(); //streamの長さが足りないので、ここで一回送信する. addData(bswap(key[2]),8); addData(bswap(key[3]),8); addBitBang(bit); addBitBang(bit); addBitBang(bit); addBitBang(bit); flushBitBang(); resetBitBang(bit,W_25mS); addBitBang(bit); addBitBang(bit | bitMCLR); addBitBang(bit | bitMCLR); flushBitBang(); resetBitBang(bit| bitMCLR,W_0uS); addData(b_0000,4); addData(0,5); flushBitBang(); addData(0,24); flushBitBang(); }
void storeWriteSingleCoilData(uint32_t *ptr){ int i; uint32_t id= 0x0000 | *ptr; // 32 Bit data is stored uint32_t d=0x21117778; for (i=0;i<10;i++){ addData(id++,d++); } //Print the data stored in HASH MAP // putData(); }
void H264or5VideoFileSink::afterGettingFrame(unsigned frameSize, unsigned numTruncatedBytes, struct timeval presentationTime) { unsigned char const start_code[4] = {0x00, 0x00, 0x00, 0x01}; if (!fHaveWrittenFirstFrame) { // If we have NAL units encoded in "sprop parameter strings", prepend these to the file: for (unsigned j = 0; j < 3; ++j) { unsigned numSPropRecords; SPropRecord* sPropRecords = parseSPropParameterSets(fSPropParameterSetsStr[j], numSPropRecords); for (unsigned i = 0; i < numSPropRecords; ++i) { addData(start_code, 4, presentationTime); addData(sPropRecords[i].sPropBytes, sPropRecords[i].sPropLength, presentationTime); } delete[] sPropRecords; } fHaveWrittenFirstFrame = True; // for next time } // Write the input data to the file, with the start code in front: addData(start_code, 4, presentationTime); // Call the parent class to complete the normal file write with the input data: FileSink::afterGettingFrame(frameSize, numTruncatedBytes, presentationTime); }
void storeReadDiscreteInputsData(uint32_t *ptr){ int i; uint32_t id= 0x2710 | *ptr; // 32 Bit data is stored uint32_t d=0x26767678; for (i=0;i<10;i++){ addData(id++,d++); } //Print the data stored in HASH MAP // putData(); }
void storeReadExceptionStatusData(uint32_t *ptr){ int i; uint32_t id= 0x0000 | *ptr; // 32 Bit data is stored uint32_t d=0x21117778; for (i=0;i<10;i++){ addData(id++,d++); } //putData(); }
void storeWriteMultipleRegistersData(uint32_t *ptr){ int i; uint32_t id= 0x9c40 | *ptr; // 32 Bit data is stored uint32_t d=0x21117778; for (i=0;i<10;i++){ addData(id++,d++); } // putData(); }
void storeReadInputRegistersData(uint32_t *ptr){ int i; uint32_t id = (0x7530 | *ptr); // 32 Bit data is stored uint32_t d=0x26767677; for (i=0;i<10;i++){ addData(id++,d++); } //Print the data stored in HASH MAP // putData(); }
VolumeWrap::VolumeWrap(PoolWrap *parent, virStorageVolPtr volume_ptr, virConnectPtr connect): PackageOwner<PoolWrap::PackageDefinition>(parent), ManagedObject(package().data_Volume), _volume_ptr(volume_ptr), _conn(connect), _lvm_name(""), _has_lvm_child(false), _wrap_parent(parent) { const char *volume_key; char *volume_path; const char *volume_name; volume_key = virStorageVolGetKey(_volume_ptr); if (volume_key == NULL) { REPORT_ERR(_conn, "Error getting storage volume key\n"); throw 1; } _volume_key = volume_key; volume_path = virStorageVolGetPath(_volume_ptr); if (volume_path == NULL) { REPORT_ERR(_conn, "Error getting volume path\n"); throw 1; } _volume_path = volume_path; volume_name = virStorageVolGetName(_volume_ptr); if (volume_name == NULL) { REPORT_ERR(_conn, "Error getting volume name\n"); throw 1; } _volume_name = volume_name; _data.setProperty("key", _volume_key); _data.setProperty("path", _volume_path); _data.setProperty("name", _volume_name); _data.setProperty("childLVMName", _lvm_name); _data.setProperty("storagePool", parent->objectID()); // Set defaults _data.setProperty("capacity", (uint64_t)0); _data.setProperty("allocation", (uint64_t)0); addData(_data); printf("done\n"); }
/*! Reads the data from the open QIODevice \a device until it ends and hashes it. Returns \c true if reading was successful. \since 5.0 */ bool QCryptographicHash::addData(QIODevice* device) { if (!device->isReadable()) return false; if (!device->isOpen()) return false; char buffer[1024]; int length; while ((length = device->read(buffer,sizeof(buffer))) > 0) addData(buffer,length); return device->atEnd(); }
void ResourceLoader::didReceiveData(const char* data, int length, long long lengthReceived, bool allAtOnce) { // The following assertions are not quite valid here, since a subclass // might override didReceiveData in a way that invalidates them. This // happens with the steps listed in 3266216 // ASSERT(con == connection); // ASSERT(!m_reachedTerminalState); // Protect this in this delegate method since the additional processing can do // anything including possibly derefing this; one example of this is Radar 3266216. RefPtr<ResourceLoader> protector(this); addData(data, length, allAtOnce); if (m_frame) frameLoader()->didReceiveData(this, data, length, lengthReceived); }
void BuildingDataHolder::initialize( const io::FilePath& filename ) { // populate _mapBuildingByInGood _d->mapBuildingByInGood[G_IRON] = B_WEAPONS_WORKSHOP; _d->mapBuildingByInGood[G_TIMBER] = B_FURNITURE; _d->mapBuildingByInGood[G_CLAY] = B_POTTERY; _d->mapBuildingByInGood[G_OLIVE] = B_OIL_WORKSHOP; _d->mapBuildingByInGood[G_GRAPE] = B_WINE_WORKSHOP; VariantMap constructions = SaveAdapter::load( filename.toString() ); for( VariantMap::iterator it=constructions.begin(); it != constructions.end(); it++ ) { VariantMap options = (*it).second.toMap(); const BuildingType btype = getType( (*it).first ); if( btype == B_NONE ) { StringHelper::debug( 0xff, "!!!Warning: can't associate type with %s", (*it).first.c_str() ); continue; } Impl::BuildingsMap::const_iterator bdataIt = _d->buildings.find( btype ); if( bdataIt != _d->buildings.end() ) { StringHelper::debug( 0xff, "!!!Warning: type %s also initialized", (*it).first.c_str() ); continue; } BuildingData bData( btype, (*it).first, (int)options[ "cost" ] ); const std::string pretty = options[ "pretty" ].toString(); if( !pretty.empty() ) { bData._prettyName = pretty; } bData._baseDesirability = (int)options[ "desirability" ]; bData._desirabilityRange = (int)options[ "desrange" ]; bData._desirabilityStep = (int)options[ "desstep" ]; bData._employers = (int)options[ "employers" ]; bData._buildingClass = getClass( options[ "class" ].toString() ); bData._resourceGroup = options[ "resource" ].toString(); bData._rcIndex = (int)options[ "rcindex" ]; addData( bData ); } }
void ScheduledScriptsTable::reload() { #ifdef DataConnect_DEBUG std::cout << "ScheduledScriptsTable: reload" << std::endl; #endif try { Database::SelectQuery query; query.addColumn("scheduledscripts", "sc_scriptname"); query.addColumn("scheduledscripts", "sc_mincycletime"); query.addColumn("scheduledscripts", "sc_maxcycletime"); query.addColumn("scheduledscripts", "sc_functionname"); query.addServerTable("scheduledscripts"); Database::Result results = query.execute(); if (!results.empty()) { clearOldTable(); ScriptData tmpRecord; for (Database::ResultConstIterator itr = results.begin(); itr != results.end(); ++itr) { tmpRecord.minCycleTime = (uint32_t)((*itr)["sc_mincycletime"].as<uint32_t>()); tmpRecord.maxCycleTime = (uint32_t)((*itr)["sc_maxcycletime"].as<uint32_t>()); tmpRecord.nextCycleTime = 0; if (!((*itr)["sc_scriptname"].is_null()) && !((*itr)["sc_functionname"].is_null())) { tmpRecord.functionName = ((*itr)["sc_functionname"].as<std::string>()); tmpRecord.scriptName = ((*itr)["sc_scriptname"].as<std::string>()); try { boost::shared_ptr<LuaScheduledScript> tmpScript(new LuaScheduledScript(tmpRecord.scriptName)); tmpRecord.scriptptr = tmpScript; addData(tmpRecord); } catch (ScriptException &e) { Logger::writeError("scripts", "Error while loading scheduled script: " + tmpRecord.scriptName + ":\n" + e.what() + "\n"); } } } } m_dataOk = true; } catch (std::exception &e) { std::cerr << "exception: " << e.what() << std::endl; m_dataOk = false; } }
bool CModuleConfig::translate(int gid, std::map<int,std::string> & flag, std::map<int8_t, std::vector<std::string> >* outputData) { std::map<int,std::vector<int>*>::iterator it = micGroup.find(gid); if(it!=micGroup.end()) { for(std::vector<int>::iterator pos=it->second->begin(); pos!=it->second->end(); pos++) { if(flag.find(*pos)==flag.end()) { if(outputData) addData(*outputData,0,*pos); flag[*pos]=true; } } } return true; }
DvtListSelector::DvtListSelector(QWidget *parent,const char *name) : QHBox(parent,name) { QFont font; // // Generate Font // font=QFont("Helvetica",10,QFont::Bold); font.setPixelSize(10); setSpacing(10); QVBox *source_box=new QVBox(this,"source_box"); list_source_label=new QLabel(source_box,"list_source_label"); list_source_label->setFont(font); list_source_label->setText(tr("Available Services")); list_source_label->setAlignment(AlignCenter); list_source_box=new QListBox(source_box,"list_source_box"); QVBox *button_box=new QVBox(this,"button_box"); list_add_button=new QPushButton(button_box,"list_add_button"); list_add_button->setText(tr("Add >>")); list_add_button->setDisabled(true); connect(list_add_button,SIGNAL(clicked()),this,SLOT(addData())); list_addall_button=new QPushButton(button_box,"list_addall_button"); list_addall_button->setText(tr("Add All >>")); list_addall_button->setDisabled(true); connect(list_addall_button,SIGNAL(clicked()),this,SLOT(addAllData())); list_remove_button=new QPushButton(button_box,"list_remove_button"); list_remove_button->setText(tr("<< Remove")); list_remove_button->setDisabled(true); connect(list_remove_button,SIGNAL(clicked()),this,SLOT(removeData())); list_removeall_button=new QPushButton(button_box,"list_removeall_button"); list_removeall_button->setText(tr("<< Remove All")); list_removeall_button->setDisabled(true); connect(list_removeall_button,SIGNAL(clicked()),this,SLOT(removeAllData())); QVBox *dest_box=new QVBox(this,"dest_box"); list_dest_label=new QLabel(dest_box,"list_dest_label"); list_dest_label->setFont(font); list_dest_label->setText(tr("Active Services")); list_dest_label->setAlignment(AlignCenter); list_dest_box=new QListBox(dest_box,"list_dest_box"); }
bool TxtBookReader::characterDataHandler(std::string &str) { const char *ptr = str.data(); const char *end = ptr + str.length(); for (; ptr != end; ++ptr) { if (std::isspace((unsigned char)*ptr)) { if (*ptr != '\t') { ++mySpaceCounter; } else { mySpaceCounter += myFormat.ignoredIndent() + 1; // TODO: implement single option in PlainTextFormat } } else { myLastLineIsEmpty = false; break; } } if (ptr != end) { if ((myFormat.breakType() & PlainTextFormat::BREAK_PARAGRAPH_AT_LINE_WITH_INDENT) && myNewLine && (mySpaceCounter > myFormat.ignoredIndent())) { internalEndParagraph(); beginParagraph(); } if (myInsideContentsParagraph && str.length() <= 30) { if(!myHasAddedTitle) { internalEndParagraph(); insertEndOfSectionParagraph(); beginContentsParagraph(); enterTitle(); pushKind(SECTION_TITLE); beginParagraph(); myHasAddedTitle = true; } if(str[str.size() -1] == '\n') { myHasAddedTitle = false; } addContentsData(str); } addData(str); myNewLine = false; } return true; }
void OsmNominatimRunner::handleReverseGeocodingResult( QNetworkReply* reply ) { if ( !reply->bytesAvailable() ) { returnNoReverseGeocodingResult(); return; } QDomDocument xml; if ( !xml.setContent( reply->readAll() ) ) { mDebug() << "Cannot parse osm nominatim result " << xml.toString(); returnNoReverseGeocodingResult(); return; } QDomElement root = xml.documentElement(); QDomNodeList places = root.elementsByTagName( "result" ); if ( places.size() == 1 ) { QString address = places.item( 0 ).toElement().text(); GeoDataPlacemark placemark; placemark.setAddress( address ); placemark.setCoordinate( GeoDataPoint( m_coordinates ) ); QDomNodeList details = root.elementsByTagName( "addressparts" ); if ( details.size() == 1 ) { GeoDataExtendedData extendedData; addData( details, "road", &extendedData ); addData( details, "house_number", &extendedData ); addData( details, "village", &extendedData ); addData( details, "city", &extendedData ); addData( details, "county", &extendedData ); addData( details, "state", &extendedData ); addData( details, "postcode", &extendedData ); addData( details, "country", &extendedData ); placemark.setExtendedData( extendedData ); } emit reverseGeocodingFinished( m_coordinates, placemark ); } else { returnNoReverseGeocodingResult(); } }
void ResourceLoader::didReceiveData(const char* data, int length, long long encodedDataLength, bool allAtOnce) { // The following assertions are not quite valid here, since a subclass // might override didReceiveData in a way that invalidates them. This // happens with the steps listed in 3266216 // ASSERT(con == connection); // ASSERT(!m_reachedTerminalState); // Protect this in this delegate method since the additional processing can do // anything including possibly derefing this; one example of this is Radar 3266216. RefPtr<ResourceLoader> protector(this); addData(data, length, allAtOnce); // FIXME: If we get a resource with more than 2B bytes, this code won't do the right thing. // However, with today's computers and networking speeds, this won't happen in practice. // Could be an issue with a giant local file. if (m_options.sendLoadCallbacks == SendCallbacks && m_frame) frameLoader()->notifier()->didReceiveData(this, data, length, static_cast<int>(encodedDataLength)); }
void reactToProcess(DWORD pid, LPWSTR name) { if (!isInPidList(pid)) { addData(pid); PidName x; x.pid = pid; x.name = name; } else { if ((!getOnline(pid)) && timeFromCreation(pid) >= TIME_TO_INJECT_SEC) //if you inject immediately, you might crash some processes { printf("Alert! %ws is online! pid=%d\n", name, pid); InjectorFunc(pid, PayloadName); setOnline(pid); } } }
void QHelpProjectDataPrivate::readData(const QByteArray &contents) { addData(contents); while (!atEnd()) { readNext(); if (isStartElement()) { if (name() == QLatin1String("QtHelpProject") && attributes().value(QLatin1String("version")) == QLatin1String("1.0")) readProject(); else raiseError(QObject::tr("Unknown token. Expected \"QtHelpProject\"!")); } } if (hasError()) { raiseError(QObject::tr("Error in line %1: %2").arg(lineNumber()) .arg(errorString())); } }