00001
00002
00003
00004
00005
00006
00007
00008
00016 #ifndef ZYPP_EXTERNALPROGRAM_H
00017 #define ZYPP_EXTERNALPROGRAM_H
00018
00019 #include <map>
00020 #include <string>
00021
00022 #include "zypp/base/ExternalDataSource.h"
00023 #include "zypp/Pathname.h"
00024
00025 namespace zypp {
00026
00034 class ExternalProgram : public zypp::externalprogram::ExternalDataSource
00035 {
00036
00037 public:
00042 enum Stderr_Disposition {
00043 Normal_Stderr,
00044 Discard_Stderr,
00045 Stderr_To_Stdout,
00046 Stderr_To_FileDesc
00047 };
00048
00052 typedef std::map<std::string,std::string> Environment;
00053
00062 ExternalProgram (std::string commandline,
00063 Stderr_Disposition stderr_disp = Normal_Stderr,
00064 bool use_pty = false, int stderr_fd = -1, bool default_locale = false,
00065 const Pathname& root = "");
00066
00073 ExternalProgram();
00074
00075 ExternalProgram (const char *const *argv,
00076 Stderr_Disposition stderr_disp = Normal_Stderr,
00077 bool use_pty = false, int stderr_fd = -1, bool default_locale = false,
00078 const Pathname& root = "");
00079
00080 ExternalProgram (const char *const *argv, const Environment & environment,
00081 Stderr_Disposition stderr_disp = Normal_Stderr,
00082 bool use_pty = false, int stderr_fd = -1, bool default_locale = false,
00083 const Pathname& root = "");
00084
00085 ExternalProgram (const char *binpath, const char *const *argv_1,
00086 bool use_pty = false);
00087
00088
00089 ExternalProgram (const char *binpath, const char *const *argv_1, const Environment & environment,
00090 bool use_pty = false);
00091
00092
00093 ~ExternalProgram();
00094
00095 int close();
00096
00100 bool kill();
00101
00105 bool running();
00106
00110 pid_t getpid() { return pid; }
00111
00115 static void renumber_fd (int origfd, int newfd);
00116
00117 protected:
00118 int checkStatus( int );
00119
00120 private:
00121
00126 bool use_pty;
00127
00128 pid_t pid;
00129 int _exitStatus;
00130
00131 void start_program (const char *const *argv, const Environment & environment,
00132 Stderr_Disposition stderr_disp = Normal_Stderr,
00133 int stderr_fd = -1, bool default_locale = false,
00134 const char* root = NULL);
00135
00136 };
00137
00138 }
00139
00140 #endif // ZYPP_EXTERNALPROGRAM_H