ExternalProgram.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00013 #ifndef ZYPP_EXTERNALPROGRAM_H
00014 #define ZYPP_EXTERNALPROGRAM_H
00015
00016 #include <map>
00017 #include <string>
00018 #include <vector>
00019
00020 #include "zypp/base/ExternalDataSource.h"
00021 #include "zypp/Pathname.h"
00022
00023 namespace zypp {
00024
00056 class ExternalProgram : public zypp::externalprogram::ExternalDataSource
00057 {
00058
00059 public:
00060
00061 typedef std::vector<std::string> Arguments;
00062
00067 enum Stderr_Disposition {
00068 Normal_Stderr,
00069 Discard_Stderr,
00070 Stderr_To_Stdout,
00071 Stderr_To_FileDesc
00072 };
00073
00074
00078 typedef std::map<std::string,std::string> Environment;
00079
00088 ExternalProgram (std::string commandline,
00089 Stderr_Disposition stderr_disp = Normal_Stderr,
00090 bool use_pty = false, int stderr_fd = -1, bool default_locale = false,
00091 const Pathname& root = "");
00092
00108 ExternalProgram();
00109
00110 ExternalProgram (const Arguments &argv,
00111 Stderr_Disposition stderr_disp = Normal_Stderr,
00112 bool use_pty = false, int stderr_fd = -1, bool default_locale = false,
00113 const Pathname& root = "");
00114
00115 ExternalProgram (const Arguments &argv, const Environment & environment,
00116 Stderr_Disposition stderr_disp = Normal_Stderr,
00117 bool use_pty = false, int stderr_fd = -1, bool default_locale = false,
00118 const Pathname& root = "");
00119
00120 ExternalProgram (const char *const *argv,
00121 Stderr_Disposition stderr_disp = Normal_Stderr,
00122 bool use_pty = false, int stderr_fd = -1, bool default_locale = false,
00123 const Pathname& root = "");
00124
00125 ExternalProgram (const char *const *argv, const Environment & environment,
00126 Stderr_Disposition stderr_disp = Normal_Stderr,
00127 bool use_pty = false, int stderr_fd = -1, bool default_locale = false,
00128 const Pathname& root = "");
00129
00130 ExternalProgram (const char *binpath, const char *const *argv_1,
00131 bool use_pty = false);
00132
00133
00134 ExternalProgram (const char *binpath, const char *const *argv_1, const Environment & environment,
00135 bool use_pty = false);
00136
00137
00138 ~ExternalProgram();
00139
00141 int close();
00142
00146 bool kill();
00147
00151 bool running();
00152
00156 pid_t getpid() { return pid; }
00157
00159 const std::string & command() const
00160 { return _command; }
00161
00171 const std::string & execError() const
00172 { return _execError; }
00173
00177 static void renumber_fd (int origfd, int newfd);
00178
00179 public:
00180
00199 std::ostream & operator>>( std::ostream & out_r );
00200
00201 protected:
00202 int checkStatus( int );
00203
00204 private:
00205
00210 bool use_pty;
00211
00212 pid_t pid;
00213 int _exitStatus;
00215 std::string _command;
00217 std::string _execError;
00218
00219 void start_program (const char *const *argv, const Environment & environment,
00220 Stderr_Disposition stderr_disp = Normal_Stderr,
00221 int stderr_fd = -1, bool default_locale = false,
00222 const char* root = NULL);
00223
00224 };
00225
00226 }
00227
00228 #endif // ZYPP_EXTERNALPROGRAM_H