#include <iostream>
#include <mysql/errmsg.h>
+#include <log/logger.hpp>
//This static variable exists to handle initializing and finalizing the MySQL driver library
std::shared_ptr<int> MySQLJobProvider::lib_ref(
return nullptr;
}
- unsigned int num = mysql_num_fields( res.get() );
-
MYSQL_ROW row = mysql_fetch_row( res.get() );
if( !row ) {
job->to = std::string( row[4], row[4] + l[4] );
job->warning = std::string( row[5], row[5] + l[5] );
- for( unsigned int i = 0; i < num; i++ ) {
- printf( "[%.*s] ", ( int ) l[i], row[i] ? row[i] : "NULL" );
- }
-
- printf( "\n" );
+ logger::notef( "Got a job: (id=%s, target=%s, task=%s, from=%s, to=%s, warnings=%s)", job->id, job->target, job->task, job->from, job->to, job->warning );
return job;
}
return nullptr;
}
- std::shared_ptr<SAN> nSAN = std::shared_ptr<SAN>( new SAN() );
+ auto nSAN = std::make_shared<SAN>();
nSAN->content = std::string( row[0], row[0] + l[0] );
nSAN->type = std::string( row[1], row[1] + l[1] );
cert->SANs.push_back( nSAN );
return nullptr;
}
- std::shared_ptr<AVA> nAVA = std::shared_ptr<AVA>( new AVA() );
+ auto nAVA = std::make_shared<AVA>();
nAVA->name = std::string( row[0], row[0] + l[0] );
nAVA->value = std::string( row[1], row[1] + l[1] );
cert->AVAs.push_back( nAVA );
std::string read_id;
if( !row || !l ) {
- if( query( "INSERT INTO cacerts SET keyname= '" + this->escape_string( res->ca_name ) + "', subroot = 0" ).first ) {
- throw "Error while inserting new ca cert";
- }
-
- my_ulonglong insert_id = mysql_insert_id( conn.get() );
-
- read_id = std::to_string( insert_id );
+ throw "Error while inserting new ca cert not found";
} else {
read_id = std::string( row[0], row[0] + l[0] );
}