Sfoglia il codice sorgente

run autoformatter after rl alternative interface

Missingmew 4 anni fa
parent
commit
986041b3a1
2 ha cambiato i file con 30 aggiunte e 24 eliminazioni
  1. 3 2
      cli/include/ioman.h
  2. 27 22
      cli/src/ioman.cpp

+ 3 - 2
cli/include/ioman.h

@@ -14,7 +14,8 @@
 using boost::asio::ip::tcp;
 
 class IoMan {
-/* this is technically private and protected stuff which needs to be public for the readline callback */
+  /* this is technically private and protected stuff which needs to be public
+   * for the readline callback */
 public:
   std::mutex localmutex;
   enum OutMsgType { normal, error, debug };
@@ -69,7 +70,7 @@ private:
 
 protected:
   std::mutex msgmutex;
-  
+
   virtual void printWelcomeMessage() = 0;
   virtual std::string getCmdPrompt() = 0;
   virtual std::string getUserPrompt() = 0;

+ 27 - 22
cli/src/ioman.cpp

@@ -145,7 +145,8 @@ bool IoMan::init() {
   return true;
 }
 
-/* loop to fetch data from the network, doing light preprocessing on it to be handled by responseMain */
+/* loop to fetch data from the network, doing light preprocessing on it to be
+ * handled by responseMain */
 void IoMan::networkMain() {
   vector<Json::Value> toput;
   char *recvjson;
@@ -232,7 +233,8 @@ void IoMan::networkMain() {
   }
 }
 
-/* loop to handle input from the user and responseMain, sending data via network if required */
+/* loop to handle input from the user and responseMain, sending data via network
+ * if required */
 void IoMan::inputMain() {
   vector<string> toprocess;
   string command;
@@ -366,7 +368,8 @@ void IoMan::inputMain() {
   }
 }
 
-/* loop to handle responses that have been fetched by netMain and possibly add new commands to be handled by inputMain */
+/* loop to handle responses that have been fetched by netMain and possibly add
+ * new commands to be handled by inputMain */
 void IoMan::responseMain() {
   vector<Json::Value> toprocess;
   vector<string> toput;
@@ -477,16 +480,16 @@ void IoMan::responseMain() {
   }
 }
 
-/* this is the handler that readlines alternative interface will use to process user input */
-void ioman_readlineHandler(char* line) {
+/* this is the handler that readlines alternative interface will use to process
+ * user input */
+void ioman_readlineHandler(char *line) {
   vector<string> tokens;
-  if(!line){
+  if (!line) {
     printf("\nNULLBURGER\n");
     gIOMAN->mainmutex.lock();
     gIOMAN->runmain = 0;
     gIOMAN->mainmutex.unlock();
-  }
-  else {
+  } else {
     // split input line into tokens
     boost::algorithm::split(tokens, std::string(line),
                             boost::algorithm::is_any_of(" "),
@@ -494,14 +497,16 @@ void ioman_readlineHandler(char* line) {
     if (strlen(line) && tokens.size()) {
       add_history(line);
 
-    gIOMAN->localmutex.lock();
-    gIOMAN->printMessage(string(__PRETTY_FUNCTION__) + string(" get localmutex"),
-                 gIOMAN->debug);
-    gIOMAN->localinput.push_back(line);
-    gIOMAN->localmutex.unlock();
-    gIOMAN->printMessage(string(__PRETTY_FUNCTION__) + string(" release localmutex"),
-                 gIOMAN->debug);
-    gIOMAN->localcv.notify_all();
+      gIOMAN->localmutex.lock();
+      gIOMAN->printMessage(string(__PRETTY_FUNCTION__) +
+                               string(" get localmutex"),
+                           gIOMAN->debug);
+      gIOMAN->localinput.push_back(line);
+      gIOMAN->localmutex.unlock();
+      gIOMAN->printMessage(string(__PRETTY_FUNCTION__) +
+                               string(" release localmutex"),
+                           gIOMAN->debug);
+      gIOMAN->localcv.notify_all();
     }
     free(line);
   }
@@ -552,13 +557,14 @@ void IoMan::run() {
     return;
   initmutex.unlock();
   initcv.notify_all();
-  
-  rl_callback_handler_install(getCmdPrompt().c_str(), (rl_vcpfunc_t*) &ioman_readlineHandler);
+
+  rl_callback_handler_install(getCmdPrompt().c_str(),
+                              (rl_vcpfunc_t *)&ioman_readlineHandler);
 
   mainmutex.lock();
   while (runmain) {
     mainmutex.unlock();
-    
+
     poll(&inPipeStatus, 1, 100);
 
     if (inPipeStatus.revents & POLLIN) {
@@ -569,8 +575,7 @@ void IoMan::run() {
     mainmutex.lock();
   }
   mainmutex.unlock();
-  
- // Remove the handler
- rl_callback_handler_remove();
 
+  // Remove the handler
+  rl_callback_handler_remove();
 }