1 /* execlass.h
2  * This file belongs to Worker, a file manager for UN*X/X11.
3  * Copyright (C) 2002-2019 Ralf Hoffmann.
4  * You can contact me at: ralf@boomerangsworld.de
5  *   or http://www.boomerangsworld.de/worker
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20  */
21 
22 #ifndef EXECLASS_H
23 #define EXECLASS_H
24 
25 #include "wdefines.h"
26 #include <string>
27 
28 class ExeClass
29 {
30 public:
31   ExeClass( class Worker *w = NULL );
32   ~ExeClass();
33   ExeClass( const ExeClass &other );
34   ExeClass &operator=( const ExeClass &other );
35 
36   void addCommand( const char *format, ... );
37   void execute();
38   char *getOutput();
39   char *getOutput( int *return_error );
40   int getOutputAndRV( char **return_output, int *return_value, int *return_error );
41   int getReturnCode();
42   int getReturnCode( int *return_error );
43   void cdDir( const char *dir );
44   int getLastError();
45 
46   int readErrorOutput( std::string &return_str, int maxsize );
47   int readOutput( std::string &return_str );
48 protected:
49   char *tmpfile, *tmpoutput, *tmperror;
50   FILE *fp;
51   int lasterror;
52   class Worker *worker;
53 };
54 
55 int Worker_buildArgvList( const char *commandstr, char ***argvlist );
56 void Worker_freeArgvList( char **argvlist );
57 std::string Worker_secureCommandForShell( const char *str );
58 char *Worker_replaceEnv( const char *str );
59 
60 #endif
61