const datetime X509Certificate_OpenSSL::convertX509Date(void* time) const { char* buffer; BIO* out = BIO_new(BIO_s_mem()); BIO_set_close(out, BIO_CLOSE); ASN1_TIME* asn1_time = reinterpret_cast<ASN1_TIME*>(time); ASN1_TIME_print(out, asn1_time); int sz = BIO_get_mem_data(out, &buffer); char* dest = new char[sz + 1]; dest[sz] = 0; memcpy(dest, buffer, sz); vmime::string t(dest); BIO_free(out); delete dest; if (t.size() > 0) { char month[4] = {0}; char zone[4] = {0}; int day, hour, minute, second, year; int nrconv = sscanf(t.c_str(), "%s %2d %02d:%02d:%02d %d%s", month, &day, &hour, &minute, &second,&year,zone); if (nrconv >= 6) return datetime(year, sg_monthMap.getMonth(vmime::string(month)), day, hour, minute, second); } // let datetime try and parse it return datetime(t); }
void App::gmt_tz_offset(int tzo){ int hourof = (tzo / 100) % 100; int minof = tzo%100; if (impl_->datetime.set_gmt_offset(hourof*3600 + minof*60)){ GLOG_ERR("error gmt tz offset :%+05d", tzo); return; } GLOG_IFO("set time zone gmt offset to east of UTC:[%+05d] now:[%s] timezone:[%s]", tzo, datetime().format(datetime().now()).c_str(), datetime().timezone()); }
void LogSQLite::createSchema() { static const char *schema = "\ CREATE TABLE IF NOT EXISTS log_names \ ( timestamp INTEGER DEFAULT(strftime('%s', 'now')) \ , channel TEXT NOT NULL \ , namesList TEXT NOT NULL \ ); \ CREATE TABLE IF NOT EXISTS log_nick \ ( timestamp INTEGER DEFAULT(strftime('%s', 'now')) \ , channel TEXT NOT NULL \ , oldNick TEXT NOT NULL \ , newNick TEXT NOT NULL \ ); \ CREATE TABLE IF NOT EXISTS log_quit \ ( timestamp INTEGER DEFAULT(strftime('%s', 'now')) \ , channel TEXT NOT NULL \ , nick TEXT NOT NULL \ , quitMessage TEXT NOT NULL \ ); \ CREATE TABLE IF NOT EXISTS log_join \ ( timestamp INTEGER DEFAULT(strftime('%s', 'now')) \ , channel TEXT NOT NULL \ , nick TEXT NOT NULL \ ); \ CREATE TABLE IF NOT EXISTS log_privmsg \ ( timestamp INTEGER DEFAULT(strftime('%s', 'now')) \ , channel TEXT NOT NULL \ , nick TEXT NOT NULL \ , message TEXT NOT NULL \ ); \ CREATE VIEW IF NOT EXISTS log AS SELECT type, datetime || ' ' || line FROM \ ( \ SELECT 'privmsg' AS type, datetime(timestamp, 'unixepoch') AS datetime, '|' || channel || '| <' || nick || '> ' || message AS line FROM log_privmsg \ UNION ALL \ SELECT 'names' AS type, datetime(timestamp, 'unixepoch') AS datetime, '|' || channel || '| Users in channel: ' || namesList AS line FROM log_names \ UNION ALL \ SELECT 'nick' AS type, datetime(timestamp, 'unixepoch') AS datetime, '|' || channel || '| ' || oldNick || ' changed his nick to ' || newNick AS line FROM log_nick \ UNION ALL \ SELECT 'join' AS type, datetime(timestamp, 'unixepoch') AS datetime, '|' || channel || '| ' || nick || ' joined' AS line FROM log_join \ UNION ALL \ SELECT 'quit' AS type, datetime(timestamp, 'unixepoch') AS datetime, '|' || channel || '| ' || nick || ' has left (' || quitMessage || ')' AS line FROM log_quit \ ) \ ORDER BY datetime; \ "; char *errorMessagesPtr = NULL; if(sqlite3_exec(connection, schema, NULL, NULL, &errorMessagesPtr) != SQLITE_OK) { std::string errorMessages(errorMessagesPtr); sqlite3_free(errorMessagesPtr); throw std::runtime_error("SQLite error: " + errorMessages); } }
QString QgsOracleConn::quotedValue( const QVariant &value, QVariant::Type type ) { if ( value.isNull() ) return "NULL"; if ( type == QVariant::Invalid ) type = value.type(); if ( value.canConvert( type ) ) { switch ( type ) { case QVariant::Int: case QVariant::LongLong: case QVariant::Double: return value.toString(); case QVariant::DateTime: { QDateTime datetime( value.toDateTime() ); if ( datetime.isValid() ) return QString( "TO_DATE('%1','YYYY-MM-DD HH24:MI:SS')" ).arg( datetime.toString( "yyyy-MM-dd hh:mm:ss" ) ); break; } case QVariant::Date: { QDate date( value.toDate() ); if ( date.isValid() ) return QString( "TO_DATE('%1','YYYY-MM-DD')" ).arg( date.toString( "yyyy-MM-dd" ) ); break; } case QVariant::Time: { QDateTime datetime( value.toDateTime() ); if ( datetime.isValid() ) return QString( "TO_DATE('%1','HH24:MI:SS')" ).arg( datetime.toString( "hh:mm:ss" ) ); break; } default: break; } } QString v = value.toString(); v.replace( "'", "''" ); v.replace( "\\\"", "\\\\\"" ); return v.prepend( "'" ).append( "'" ); }
void erreur_allocation(char endroitAllouer[]) { FILE* fichier=NULL; //ouverture du fichier fichier=fopen("erreur_allocation.txt","a"); //si l'ouverture réussi if (fichier != NULL) { fprintf(fichier,"---------------------ERREUR DU : %s ",datetime()); fputs("-----------------------\n",fichier); fprintf(fichier,"Allocation échouer : %s \n ",endroitAllouer); //on ferme le fichier fclose(fichier); } //si l'ouverture échoue else { printf("Erreur ouverture du fichier erreur_allocation.txt"); } }
int main(int argc, char **argv) { OS::String lolstr("lol"); OS::String lolstr2(lolstr); OS::String interstellar("insterstellar"); OS::String lolstr3 = lolstr + lolstr2 + interstellar; std::cout << lolstr << std::endl; std::cout << lolstr2 << std::endl; std::cout << lolstr3 << std::endl; // output utcDateTime OS::DateTime datetime(OS::DateTime::Now()); std::cout << OS::DateTime::Now() << std::endl; std::cout << datetime << std::endl; // interpretation of argc, argv try { OS::ScopedMutex mutex; Core::Config::XmlConfigFileLoader config("config.xml"); } catch (Core::Config::ConfigException exp) { std::cerr << exp.what() << std::endl; } return 0; }
void erreur_image(char nomFichier[]) { FILE* fichier=NULL; //ouverture du fichier fichier=fopen("erreur_image.txt","a"); //si l'ouverture réussi if (fichier != NULL) { fprintf(fichier,"---------------------ERREUR DU : %s ",datetime()); fputs("-----------------------\n",fichier); fprintf(fichier,"Fichier manquant : %s \n ",nomFichier); //on ferme le fichier fclose(fichier); } //si l'ouverture échoue else { printf("Erreur ouverture du fichier erreur_image.txt"); } }
void erreur_indef(char msg[]) { FILE* fichier=NULL; //ouverture du fichier fichier=fopen("erreur_indef.txt","a"); //si l'ouverture réussi if (fichier != NULL) { fprintf(fichier,"---------------------ERREUR DU : %s ",datetime()); fputs("-----------------------\n",fichier); fprintf(fichier,"Message d'erreur : %s \n ",msg); //on ferme le fichier fclose(fichier); } //si l'ouverture échoue else { printf("Erreur ouverture du fichier erreur_indef.txt"); } }
static void new_quote(struct commodity_register *commodity_register) { static sqlite3_stmt *query = NULL; PREPARE_QUERY_ONCE(db, "insert into prices (guid, commodity_guid, timestamp, value) \ values ("NEW_UUID", ?1, datetime('now', 'localtime'), 0)",query); sqlite3_bind_text(query, 1, commodity_register->guid, -1, SQLITE_STATIC); run_dm_query(query); refresh_commodity_register(commodity_register); }
datetime datetime::from_number(double raw_time, calendar base_date) { auto date_part = date::from_number(static_cast<int>(raw_time), base_date); auto time_part = time::from_number(raw_time); return datetime(date_part.year, date_part.month, date_part.day, time_part.hour, time_part.minute, time_part.second, time_part.microsecond); }
INT CADOParameters::Add(const __time64_t &time) { // The database value use DATE(double) format so we // must transform time64 format to DATE by COleDateTime // and also we support such a override Add function whose // parameter is COleDateTime! COleDateTime datetime(time); return Add(datetime); }
escape_catalogue::escape_catalogue(user_interaction & dialog, const pile_descriptor & x_pdesc, const archive_version & reading_ver, compression default_algo, bool lax) : catalogue(dialog, datetime(0), label_zero) { set_esc_and_stack(x_pdesc); x_reading_ver = reading_ver; x_default_algo = default_algo; x_lax = lax; corres.clear(); status = ec_init; // with that constructor, the catalogue starts empty and get completed entry by entry each time a one asks for its contents (read() method) cat_det = NULL; min_read_offset = 0; depth = 0; // we start at the root wait_parent_depth = 0; // to disable this feature // fetching the value of ref_data_name pdesc.stack->flush_read_above(pdesc.esc); if(pdesc.esc->skip_to_next_mark(escape::seqt_data_name, false)) { // we are at least at revision "08" of archive format, or this is a collision with data of an old archive or of an archive without escape marks label tmp; try { tmp.read(*pdesc.esc); set_data_name(tmp); } catch(...) { if(!lax) throw Erange("escape_catalogue::escape_catalogue", gettext("incoherent data after escape sequence, cannot read internal data set label")); else { get_ui().warning("LAX MODE: Could not read the internal data set label, using a fake value, this will probably avoid using isolated catalogue"); set_data_name(label_zero); } } } else // skip to expected mark failed if(!lax) throw Erange("escape_catalogue::escape_catalogue", gettext("could not find the internal data set label escape sequence")); else { contextual *cont_data = NULL; pdesc.stack->find_first_from_bottom(cont_data); get_ui().warning("LAX MODE: Could not read the internal data set label, using a fake value, this will probably avoid using isolated catalogue"); if(cont_data == NULL) set_data_name(label_zero); else set_data_name(cont_data->get_data_name()); } }
void DateSettings::onConfirmButtonClicked() { QDate date; date.setDate(m_yearWidget->value(), m_monthWidget->value(), m_dayWidget->value()); QTime time; time.setHMS(m_timeWidget->hour(), m_timeWidget->minute(), 0); QDateTime datetime(date, time); Q_EMIT requestSetTime(datetime); back(); }
JP_INTERNAL(void) JP_GetDateTime(TJQuery &qry, int colNo, char *into) { memset(into, 0, 15); char* value = PQgetvalue(qry.pgResult, qry.rowIndex-1, colNo); if (value != 0) { TPGDateTime datetime(value); _FromDateTime(datetime, into); } }
// get the value as date/time QDateTime KCValue::asDateTime(const KCCalculationSettings* settings) const { QDateTime datetime(settings->referenceDate(), QTime(), Qt::UTC); const int days = asInteger(); const int msecs = qRound((numToDouble(asFloat() - double(days))) * 86400000.0); // 24*60*60*1000 datetime = datetime.addDays(days); datetime = datetime.addMSecs(msecs); return datetime; }
static void redraw(void) { desktops(5); memory(90); loadaverage(400); procs(550); cpubar(650); showfile(750); datetime(); }
void crypto_asym::fill_signing_result() { gpgme_verify_result_t inter = gpgme_op_verify_result(context); gpgme_signature_t res = NULL; signator tmp; signing_result.clear(); if(inter != NULL) res = inter->signatures; else res = NULL; while(res != NULL) { if(res->summary & (GPGME_SIGSUM_VALID|GPGME_SIGSUM_GREEN)) tmp.result = signator::good; else if(res->summary & GPGME_SIGSUM_RED) tmp.result = signator::bad; else if(res->summary & GPGME_SIGSUM_KEY_MISSING) tmp.result = signator::unknown_key; else tmp.result = signator::error; if(res->summary & GPGME_SIGSUM_KEY_REVOKED) tmp.key_validity = signator::revoked; else if(res->summary & GPGME_SIGSUM_KEY_EXPIRED) tmp.key_validity = signator::expired; else tmp.key_validity = signator::valid; tmp.fingerprint = res->fpr; tmp.signing_date = datetime(res->timestamp); tmp.signature_expiration_date = datetime(res->exp_timestamp); res = res->next; signing_result.push_back(tmp); } }
int norw2dim(FILE *fp, char *comment, int *pxdim, int *pydim, float mx[4096][512], float cal[6]) { char line[128]; int i, j; int ical = 6; int xdim, ydim; extern int datetime(char *); char dattim[20]; datetime(dattim); xdim = *pxdim; ydim = *pydim; if(cal[0] + cal[1] + cal[2] == 0){ cal[0] = 0.; cal[1] = 1.; cal[2] = 0.; } if(cal[3] + cal[4] + cal[5] == 0){ cal[3] = 0.; cal[4] = 1.; cal[5] = 0.; } /* ********************************** */ /* Matrix with header written to disk */ /* ********************************** */ if(fp == NULL){ printf("Could not open file for writing \n"); return(-1); } else { fprintf(fp, "!FILE=Disk \n"); fprintf(fp, "!KIND=Matrix \n"); fprintf(fp, "!LABORATORY=Oslo Cyclotron Laboratory (OCL) \n"); fprintf(fp, "!EXPERIMENT=Sirius \n"); fprintf(fp, "!COMMENT=%s\n", comment); fprintf(fp, "!TIME=%s\n",dattim); fprintf(fp, "!CALIBRATION EkeV=%1d",ical); for (i = 0; i < ical; i++){ fprintf(fp,"%13e,",cal[i]); } fprintf(fp, "\n!PRECISION=16\n"); fprintf(fp, "!DIMENSION=2,0:%4d,0:%4d\n",xdim-1,ydim-1); fprintf(fp, "!CHANNEL=(0:%4d,0:%4d)\n",xdim-1,ydim-1); for (j = 0; j < ydim; j++){ for (i = 0; i < xdim; i++){ fprintf(fp, "%e ", mx[i][j]); if(i == (int)((i/(xdim-1))*(xdim-1)) && i > 0)fprintf(fp, "\n"); } } fprintf(fp, "!IDEND=\n"); } return 0; }
/** * 打印信息 */ void _log(char * message) { char * _datetime = malloc(22); datetime(_datetime); _datetime[21] = '\0'; printf("\n[%s] %s\n", _datetime, message); free(_datetime); }
bool TransferRevisionFromWindow(int no, bool enabled, svn::Revision & revision) { struct RevisionControls * revCtrls = &revCtrlsArray[no]; // first we enable/disable controls according to settings revCtrls->radioUseRevision->Enable(enabled); bool useRevision = enabled && revCtrls->radioUseRevision->GetValue(); revCtrls->checkUseLatest->Enable(useRevision); bool useLatest = useRevision && revCtrls->checkUseLatest->GetValue(); revCtrls->textRevision->Enable(enabled && !useLatest); revCtrls->radioUseDate->Enable(enabled); bool useDate = enabled && revCtrls->radioUseDate->GetValue(); revCtrls->datePicker->Enable(useDate); bool enablePath = enabled && enableUrl; revCtrls->checkUsePath->Enable(enablePath); bool usePath = enablePath && revCtrls->checkUsePath->GetValue(); revCtrls->comboPath->Enable(usePath); // now transfer values bool isValid = true; if (revCtrls->radioUseRevision->GetValue()) { if (revCtrls->checkUseLatest->GetValue()) revision = svn::Revision(svn::Revision::HEAD); else { svn_revnum_t revnum; bool isValidRevision = ParseRevision( revCtrls->textRevision->GetValue(), revnum); revision = svn::Revision(revnum); if (enabled && !isValidRevision) isValid = false; } } else { apr_time_t time=0; apr_time_ansi_put( &time, revCtrls->datePicker->GetValue().GetTicks()); svn::DateTime datetime(time); revision = svn::Revision(datetime); } return isValid; }
BOOL KCacheObject::GetString(int colIdx, char* value, int len, int& readed) { const KSQLTableField* pfld = m_pCache->m_tableSchema->GetField(colIdx); if(!pfld) return FALSE; if(!m_pCache->_GetBinary(m_hRec, colIdx, 0, value, len, readed)) return FALSE; switch(pfld->m_cdt) { case KSQLTypes::sql_c_int8: case KSQLTypes::sql_c_uint8: case KSQLTypes::sql_c_int16: case KSQLTypes::sql_c_uint16: case KSQLTypes::sql_c_int32: case KSQLTypes::sql_c_uint32: case KSQLTypes::sql_c_int64: case KSQLTypes::sql_c_uint64: case KSQLTypes::sql_c_float32: case KSQLTypes::sql_c_float64: { return FALSE; } case KSQLTypes::sql_c_timestamp: { MYSQL_TIME_K val; ASSERT(readed == sizeof(val)); memcpy(&val, value, sizeof(val)); KDatetime datetime(val); System::Collections::KString<32> str = datetime.ToString(); if(len < (int)str.size() + 1) return FALSE; readed = str.size(); memcpy(value, str.c_str(), readed); value[readed] = '\0'; return TRUE; } case KSQLTypes::sql_c_string: case KSQLTypes::sql_c_varstring: { if(len < readed+1) return FALSE; value[readed] = '\0'; return TRUE; } case KSQLTypes::sql_c_binary: { return TRUE; } } return FALSE; }
RideFile *QuarqFileReader::openRideFile(QFile &file, QStringList &errors, QList<RideFile*>*) const { (void) errors; RideFile *rideFile = new RideFile(); rideFile->setDeviceType("Quarq Qollector"); rideFile->setFileFormat("Quarq ANT+ Files (qla)"); rideFile->setRecIntSecs(1.0); QuarqParser handler(rideFile); QProcess *antProcess = getInterpreterProcess( installed_path ); assert(antProcess); QXmlInputSource source (antProcess); QXmlSimpleReader reader; reader.setContentHandler (&handler); // this could done be a loop to "save memory." file.open(QIODevice::ReadOnly); antProcess->write(file.readAll()); antProcess->closeWriteChannel(); antProcess->waitForFinished(-1); assert(QProcess::NormalExit == antProcess->exitStatus()); assert(0 == antProcess->exitCode()); reader.parse(source); reader.parseContinue(); QRegExp rideTime("^.*/(\\d\\d\\d\\d)_(\\d\\d)_(\\d\\d)_" "(\\d\\d)_(\\d\\d)_(\\d\\d)\\.qla$"); if (rideTime.indexIn(file.fileName()) >= 0) { QDateTime datetime(QDate(rideTime.cap(1).toInt(), rideTime.cap(2).toInt(), rideTime.cap(3).toInt()), QTime(rideTime.cap(4).toInt(), rideTime.cap(5).toInt(), rideTime.cap(6).toInt())); rideFile->setStartTime(datetime); } delete antProcess; return rideFile; }
void plugin::eventDateTime ( const QString& id_, const QString& sceneid_, const QString& date, const QString& time) { if (sceneid_.isEmpty()) { removeEvent(id_); return; } // recalculate next event EventTimeStructure s; s.eventid = id_; s.sceneid = sceneid_; s.date = QDate::fromString(date, Qt::ISODate); s.time = QTime::fromString(time, QLatin1String("h:m")); QDateTime datetime(s.date, s.time); if (QDateTime::currentDateTime()>datetime) return; addToEvents(datetime, s); }
bool WaterDemandModel::createRainInput(MapBasedModel * m) { DM::Logger(DM::Debug) << "Start Raintank"; if (!this->from_rain_station) { this->station_ids.insert(-1); DM::Logger(DM::Standard) << "Init with rain file"; Node * rain = nodereg->createNode("IxxRainRead_v2"); if (!rain) { DM::Logger(DM::Error) << "Couldn't create " << " IxxRainRead_v2"; return false; } rain->setParameter("rain_file", this->rainfile); std::string datetime("d.M.yyyy HH:mm:ss"); rain->setParameter("datestring", datetime); m->addNode("r_1", rain); //evapo Node * evapo = nodereg->createNode("IxxRainRead_v2"); if (!evapo) { DM::Logger(DM::Error) << "Couldn't create " << " IxxRainRead_v2"; return false; } DM::Logger(DM::Debug) << this->evapofile; evapo->setParameter("rain_file", this->evapofile); evapo->setParameter("datestring", datetime); m->addNode("e_1", evapo); return true; } DM::Logger(DM::Standard) << "Init using stations"; Node * rain = nodereg->createNode("SourceVector"); if (!rain) return false; //n_d->setParameter("source",sum_demand); m->addNode("r_1", rain); Node * evapo = nodereg->createNode("SourceVector"); if (!evapo) return false; //n_d->setParameter("source",sum_demand); m->addNode("e_1", evapo); return true; }
/* * load and send headers */ int send_headers(const int fd, const resp_hdrs* hdrs) { /* HTTP/1.1 200 OK */ char hbuf[100] = "HTTP/"; strcat(hbuf, hdrs->version); strcat(hbuf, status_msg(hdrs->status_code)); strcat(hbuf, "\r\n"); send_msg(fd, hbuf); /********************/ /* Server: SBGiP/0.1 */ char rbuf[100] = "Server: "; strcat(rbuf, hdrs->server); strcat(rbuf, "\r\n"); send_msg(fd, rbuf); /************************/ /* Content-Type: text/html */ char ibuf[100] = "Content-Type: "; strcat(ibuf, hdrs->content_type); strcat(ibuf, "\r\n"); send_msg(fd, ibuf); /****************************/ /* Content-Length: 100 */ char obuf[100] = "Content-Type: "; char len[20]; sprintf(len, "%d", (int)hdrs->content_length); strcat(obuf, len); strcat(obuf, "\r\n"); send_msg(fd, obuf); /************************/ /* Last-Modified: Fri, 31 Dec 1999 23:59:59 GMT */ char pbuf[100] = "Last-Modified: "; char tbuf[30]; datetime(hdrs->last_modified, tbuf); strcat(pbuf, tbuf); strcat(pbuf, "\r\n\r\n"); send_msg(fd, pbuf); /************************************************/ return 0; }
int norw1dim(FILE *fp, char *comment, int *pxdim, float ax[8192], float cal[6]) { char line[128]; int i; int ical = 3; int xdim; extern int datetime(char *); char dattim[20]; if(cal[0] + cal[1] + cal[2] == 0){ cal[0] = 0.; cal[1] = 1.; cal[2] = 0.; } xdim = *pxdim; datetime(dattim); /* ******************************************** */ /* Singles spectrum with header written to disk */ /* ******************************************** */ if(fp == NULL){ printf("Could not open file for writing \n"); return(-1); } else { fprintf(fp, "!FILE=Disk \n"); fprintf(fp, "!KIND=Spectrum \n"); fprintf(fp, "!LABORATORY=Oslo Cyclotron Laboratory (OCL) \n"); fprintf(fp, "!EXPERIMENT=Sirius \n"); fprintf(fp, "!COMMENT=%s\n", comment); fprintf(fp, "!TIME=%s\n",dattim); fprintf(fp, "!CALIBRATION EkeV=%1d",ical); for (i = 0; i < ical; i++){ fprintf(fp,"%13e,",cal[i]); } fprintf(fp, "\n!PRECISION=16\n"); fprintf(fp, "!DIMENSION=1,0:%4d\n",xdim-1); fprintf(fp, "!CHANNEL=(0:%4d)\n",xdim-1); for (i = 0; i < xdim; i++){ fprintf(fp, "%e ", ax[i]); } fprintf(fp, "\n!IDEND=\n"); } return 0; }
/** * 打印配置信息 */ void print_config() { char * _datetime = malloc(21); datetime(_datetime); int pl = strlen(password); char _password[pl + 1]; memset(_password, '*', pl); _password[pl] = '\0'; printf("\n[%s] 节点地址:%s\n[%s] 节点端口:%d\n[%s] 代理端口:%d\n[%s] 连接密码:%s\n", _datetime, server_host, _datetime, server_port, _datetime, listen_port, _datetime, _password); free(_datetime); }
/** * Prosesses NMEA GPGGA sentences * \param[in] Buffer for parsed nmea GPGGA sentence */ void NMEAParser::nmeaProcessGPGGA(char* packet) { // start parsing just after "GPGGA," // attempt to reject empty packets right away if(packet[6]==',' && packet[7]==',') return; if(!nmeaChecksum(packet)) { // checksum not valid return; } nmeaTerminateAtChecksum(packet); QString nmeaString( packet ); QStringList tokenslist = nmeaString.split(","); GpsData.GPStime = tokenslist.at(1).toDouble(); GpsData.Latitude = tokenslist.at(2).toDouble(); int deg = (int)GpsData.Latitude/100; double min = ((GpsData.Latitude)-(deg*100))/60.0; GpsData.Latitude=deg+min; // next field: N/S indicator // correct latitute for N/S if(tokenslist.at(3).contains("S")) GpsData.Latitude = -GpsData.Latitude; GpsData.Longitude = tokenslist.at(4).toDouble(); deg = (int)GpsData.Longitude/100; min = ((GpsData.Longitude)-(deg*100))/60.0; GpsData.Longitude=deg+min; // next field: E/W indicator // correct latitute for E/W if(tokenslist.at(5).contains("W")) GpsData.Longitude = -GpsData.Longitude; GpsData.SV = tokenslist.at(7).toInt(); GpsData.Altitude = tokenslist.at(9).toDouble(); GpsData.GeoidSeparation = tokenslist.at(11).toDouble(); emit position(GpsData.Latitude,GpsData.Longitude,GpsData.Altitude); emit sv(GpsData.SV); emit datetime(GpsData.GPSdate,GpsData.GPStime); }
// ---------------------------------------------- Record SystemTable::getRecord(ID_t i_record_id) { INF("enter SystemTable::getRecord()."); std::string select_statement = "SELECT * FROM '"; select_statement += this->m_table_name; select_statement += "' WHERE ID == '"; select_statement += std::to_string(i_record_id); select_statement += "';"; this->__prepare_statement__(select_statement); sqlite3_step(this->m_db_statement); ID_t id = sqlite3_column_int64(this->m_db_statement, 0); DBG("Read id [%lli] from table ["%s"] of database ["%s"], input id was [%lli].", id, this->m_table_name.c_str(), this->m_db_name.c_str(), i_record_id); TABLE_ASSERT("Input record id does not equal to primary key value from database!" && id == i_record_id); Record record = Record::EMPTY; if (i_record_id != UNKNOWN_ID) { DBG("Read id [%lli] from table ["%s"] of database ["%s"].", id, this->m_table_name.c_str(), this->m_db_name.c_str()); ID_t extra_id = sqlite3_column_int64(this->m_db_statement, 1); uint64_t timestamp = sqlite3_column_int64(this->m_db_statement, 2); const void* raw_datetime = reinterpret_cast<const char*>(sqlite3_column_text(this->m_db_statement, 3)); WrappedString datetime(raw_datetime); const void* raw_ipaddress = reinterpret_cast<const char*>(sqlite3_column_text(this->m_db_statement, 4)); WrappedString ipaddress(raw_ipaddress); int port = sqlite3_column_int(this->m_db_statement, 5); DBG("Loaded column data: " COLUMN_NAME_EXTRA_ID " [%lli]; " D_COLUMN_NAME_TIMESTAMP " [%lu]; " D_COLUMN_NAME_DATETIME " ["%s"]; " D_COLUMN_NAME_IP_ADDRESS " ["%s"]; " D_COLUMN_NAME_PORT " [%i].", extra_id, timestamp, datetime.c_str(), ipaddress.c_str(), port); record = Record(extra_id, timestamp, ipaddress.get(), port); DBG("Proper record instance has been constructed."); } else { WRN("ID [%lli] is missing in table ["%s"] of database %p!", i_record_id, this->m_table_name.c_str(), this->m_db_handler); } this->__finalize__(select_statement.c_str()); INF("exit SystemTable::getRecord()."); return (record); }
main() { char current_time[50]; char hostname[10]; char battery_remain[4]; char status_string[100]; launch_statusbar(); for (;;sleep(1)) { host(hostname); datetime(current_time); battery_status(battery_remain); status(status_string, hostname, battery_remain, current_time); statusbar(status_string); } close_statusbar(); return 0; }