]> WPIA git - cassiopeia.git/blobdiff - src/apps/client.cpp
fmt: whitespace, padding and indentation formatting
[cassiopeia.git] / src / apps / client.cpp
index 9a7add6badb44fcb0a07817e50b070afa7057cc9..c3a011531306e35685af4a7fc62413cea0b3f958 100644 (file)
@@ -16,6 +16,7 @@
 #include "io/bios.h"
 #include "io/slipBio.h"
 #include "config.h"
+#include <internal/bio.h>
 
 #ifdef NO_DAEMON
 #define DAEMON false
@@ -58,6 +59,7 @@ int main( int argc, const char* argv[] ) {
     if( argc == 2 && std::string( "--once" ) == argv[1] ) {
         once = true;
     }
+
     if( argc == 2 && std::string( "--reset" ) == argv[1] ) {
         resetOnly = true;
     }
@@ -65,7 +67,7 @@ int main( int argc, const char* argv[] ) {
     std::string path;
 
 #ifdef NDEBUG
-    path = "/etc/cacert/cassiopeia/cassiopeia.conf";
+    path = "/etc/wpia/cassiopeia/cassiopeia.conf";
 #else
     path = "config.txt";
 #endif
@@ -79,9 +81,11 @@ int main( int argc, const char* argv[] ) {
         logger::fatal( "Error: no serial device is given!" );
         return -1;
     }
+
     std::shared_ptr<JobProvider> jp = std::make_shared<PostgresJobProvider>( sqlHost, sqlUser, sqlPass, sqlDB );
     std::shared_ptr<BIO> b = openSerial( serialPath );
-    std::shared_ptr<BIO> slip1( BIO_new( toBio<SlipBIO>() ), BIO_free );
+    std::shared_ptr<BIO_METHOD> m( toBio<SlipBIO>(), BIO_meth_free );
+    std::shared_ptr<BIO> slip1( BIO_new( m.get() ), BIO_free );
     static_cast<SlipBIO*>( slip1->ptr )->setTarget( std::make_shared<OpensslBIOWrapper>( b ), false );
     auto sign = std::make_shared<RemoteSigner>( slip1, generateSSLContext( false ) );
     // std::shared_ptr<Signer> sign( new SimpleOpensslSigner() );
@@ -96,7 +100,7 @@ int main( int argc, const char* argv[] ) {
     time_t lastCRLCheck = 0;
 
     while( true ) {
-       try {
+        try {
             time_t current;
             time( &current );
 
@@ -112,20 +116,21 @@ int main( int argc, const char* argv[] ) {
             }
 
             std::shared_ptr<Job> job;
+
             try {
                 job = jp->fetchJob();
             } catch ( std::exception &e ){
-                logger::errorf ( "Exception while fetchJob: %s", e.what() );
-           }
+                logger::errorf( "Exception while fetchJob: %s", e.what() );
+            }
+
             if( !job ) {
-                logger::note( "Nothing to work on." );
                 sleep( 5 );
                 continue;
             }
 
             std::shared_ptr<std::ofstream> logPtr = openLogfile( std::string( "logs/" ) + job->id + std::string( "_" ) + job->warning + std::string( ".log" ) );
 
-            logger::logger_set log_set({logger::log_target(*logPtr, logger::level::debug)}, logger::auto_register::on);
+            logger::logger_set log_set( {logger::log_target( *logPtr, logger::level::debug )}, logger::auto_register::on );
 
             logger::note( "TASK ID: ", job->id );
             logger::note( "TRY:     ", job->warning );
@@ -167,7 +172,7 @@ int main( int argc, const char* argv[] ) {
                     }
 
                     logger::note( "FINE: CERTIFICATE LOG:\n", res->log,
-                                 "FINE: CERTIFICATE:\n", res->certificate );
+                                  "FINE: CERTIFICATE:\n", res->certificate );
 
                     std::string fn = writeBackFile( job->target.c_str(), res->certificate, keyDir );
 
@@ -221,7 +226,7 @@ int main( int argc, const char* argv[] ) {
                 return 0;
             }
         } catch ( std::exception &e ){
-            logger::errorf ( "std::exception in mainloop: %s", e.what() );
+            logger::errorf( "std::exception in mainloop: %s", e.what() );
         }
 
     }