ExternalProgram.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                          ____ _   __ __ ___                          |
00003 |                         |__  / \ / / . \ . \                         |
00004 |                           / / \ V /|  _/  _/                         |
00005 |                          / /__ | | | | | |                           |
00006 |                         /_____||_| |_| |_|                           |
00007 |                                                                      |
00008 \---------------------------------------------------------------------*/
00013 #ifndef ZYPP_EXTERNALPROGRAM_H
00014 #define ZYPP_EXTERNALPROGRAM_H
00015 
00016 #include <map>
00017 #include <string>
00018 
00019 #include "zypp/base/ExternalDataSource.h"
00020 #include "zypp/Pathname.h"
00021 
00022 namespace zypp {
00023 
00031     class ExternalProgram : public zypp::externalprogram::ExternalDataSource
00032     {
00033 
00034     public:
00039       enum Stderr_Disposition {
00040         Normal_Stderr,
00041         Discard_Stderr,
00042         Stderr_To_Stdout,
00043         Stderr_To_FileDesc
00044       };
00045 
00049       typedef std::map<std::string,std::string> Environment;
00050 
00059       ExternalProgram (std::string commandline,
00060                      Stderr_Disposition stderr_disp = Normal_Stderr,
00061                      bool use_pty = false, int stderr_fd = -1, bool default_locale = false,
00062                      const Pathname& root = "");
00063 
00070       ExternalProgram();
00071 
00072       ExternalProgram (const char *const *argv,
00073                      Stderr_Disposition stderr_disp = Normal_Stderr,
00074                      bool use_pty = false, int stderr_fd = -1, bool default_locale = false,
00075                      const Pathname& root = "");
00076 
00077       ExternalProgram (const char *const *argv, const Environment & environment,
00078                      Stderr_Disposition stderr_disp = Normal_Stderr,
00079                      bool use_pty = false, int stderr_fd = -1, bool default_locale = false,
00080                      const Pathname& root = "");
00081 
00082       ExternalProgram (const char *binpath, const char *const *argv_1,
00083                      bool use_pty = false);
00084 
00085 
00086       ExternalProgram (const char *binpath, const char *const *argv_1, const Environment & environment,
00087                      bool use_pty = false);
00088 
00089 
00090       ~ExternalProgram();
00091 
00092       int close();
00093 
00097       bool kill();
00098 
00102       bool running();
00103 
00107       pid_t getpid() { return pid; }
00108 
00112       static void renumber_fd (int origfd, int newfd);
00113 
00114     protected:
00115       int checkStatus( int );
00116 
00117     private:
00118 
00123       bool use_pty;
00124 
00125       pid_t pid;
00126       int _exitStatus;
00127 
00128       void start_program (const char *const *argv, const Environment & environment,
00129                         Stderr_Disposition stderr_disp = Normal_Stderr,
00130                         int stderr_fd = -1, bool default_locale = false,
00131                         const char* root = NULL);
00132 
00133     };
00134 
00135 } // namespace zypp
00136 
00137 #endif // ZYPP_EXTERNALPROGRAM_H

Generated on Tue Sep 25 19:23:01 2007 for libzypp by  doxygen 1.5.3