]> git.tdb.fi Git - builder.git/blobdiff - source/externalaction.cpp
Replace per-file copyright notices with a single file
[builder.git] / source / externalaction.cpp
index 88c7e544e7907671daa82a6d8381f29f46257356..cad9ba8b23d659e3be069ce1dd7eee57c0c4e5df 100644 (file)
@@ -1,15 +1,9 @@
-/* $Id$
-
-This file is part of builder
-Copyright © 2006-2009  Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
-
-#include <sys/wait.h>
-#include <iostream>
 #include <cstring>
 #include <cstdlib>
+#include <sys/wait.h>
 #include <msp/fs/dir.h>
+#include <msp/io/print.h>
+#include <msp/strings/utils.h>
 #include "builder.h"
 #include "externalaction.h"
 
@@ -19,38 +13,30 @@ using namespace Msp;
 void ExternalAction::launch()
 {
        if(builder.get_verbose()>=2)
-       {
-               for(StringList::const_iterator i=argv.begin(); i!=argv.end(); ++i)
-               {
-                       if(i!=argv.begin())
-                               cout<<' ';
-                       cout<<*i;
-               }
-               cout<<'\n';
-       }
+               IO::print("%s\n", join(argv.begin(), argv.end()));
 
        if(builder.get_dry_run())
-               pid=-1;
+               pid = -1;
        else
        {
-               pid=fork();
+               pid = fork();
                if(pid==0)
                {
                        char *argv_[argv.size()+1];
 
-                       unsigned j=0;
+                       unsigned j = 0;
                        for(StringList::iterator i=argv.begin(); i!=argv.end(); ++i)
-                               argv_[j++]=strdup(i->c_str());
-                       argv_[j]=0;
+                               argv_[j++] = strdup(i->c_str());
+                       argv_[j] = 0;
 
                        if(!work_dir.empty())
                                FS::chdir(work_dir);
                        execvp(argv_[0], argv_);
-                       cout<<"Couldn't execute "<<argv.front()<<'\n';
+                       IO::print("Couldn't execute %s\n", argv.front());
                        exit(1);
                }
                else if(pid<0)
-                       pid=0;
+                       pid = 0;
        }
 }
 
@@ -70,10 +56,10 @@ int ExternalAction::check()
        {
                signal_done.emit();
                if(WIFEXITED(status))
-                       exit_code=WEXITSTATUS(status);
+                       exit_code = WEXITSTATUS(status);
                else
-                       exit_code=254;
-               pid=0;
+                       exit_code = 254;
+               pid = 0;
                return exit_code;
        }
        else