exec.h

Go to the documentation of this file.
00001 /***************************************************************************
00002                           exec.h  -  description
00003                              -------------------
00004     begin                : Thu Dec 9 2004
00005     copyright            : (C) 2004 by VooDooMan
00006     email                : vdmfun@hotmail.com
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010 
00011 VooDoo cIRCle - an IRC (ro)bot
00012 Copyright (C) 2004 by Marian VooDooMan Meravy (vdmfun@hotmail.com)
00013 
00014 This program is free software; you can redistribute it and/or
00015 modify it under the terms of the GNU General Public License
00016 as published by the Free Software Foundation; either version 2
00017 of the License, or (at your option) any later version.
00018 
00019 This program is distributed in the hope that it will be useful,
00020 but WITHOUT ANY WARRANTY; without even the implied warranty of
00021 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00022 GNU General Public License for more details.
00023 
00024 You should have received a copy of the GNU General Public License
00025 along with this program; if not, write to the Free Software
00026 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00027 
00028 ****************************************************************************/
00029 
00030 /*!
00031     \file
00032     \brief Handles child processes. Used to platform abstraction
00033 */
00034 
00035 //---------------------------------------------------------------------------
00036 
00037 #ifndef execH
00038 #define execH
00039 //---------------------------------------------------------------------------
00040 
00041 #include <stdio.h>
00042 
00043 #ifdef _WIN32
00044 #   define _WINSOCKAPI_
00045 #   include <windows.h>
00046 #   define popen _popen
00047 #   define pclose _pclose
00048 #endif
00049 
00050 /*!
00051     \brief Stores handle to process and aditional resources
00052     \author VooDooMan
00053     \version 1
00054     \date 2004
00055 */
00056 struct s_exec_handle {
00057 #ifdef _WIN32
00058     HANDLE os_hnd;                              //!< Handle of child process
00059     HANDLE hOutputWrite;                        //!< Handle of stdout for writing
00060     HANDLE hOutputRead;                         //!< Handle of stdout for reading
00061     HANDLE hInputWrite;                         //!< Handle of stdin for writing
00062     HANDLE hInputRead;                          //!< Handle of stdin for reading
00063     HANDLE hErrorWrite;                         //!< Handle of stderr
00064 
00065     _PROCESS_INFORMATION PI;                    //!< Process information structure
00066 #else
00067     FILE* os_hnd;                               //!< Handle of pipe
00068 #endif
00069     char* out_buffer;                           //!< Output buffer from console
00070     int out_buffer_size;                        //!< Current size of output buffer
00071     int exit_code;                              //!< Exit code of process
00072     bool error;                                 //!< true for error in execution
00073 
00074     s_exec_handle()
00075     {
00076         memset(this,0,sizeof(*this));
00077     }
00078 };
00079 
00080 s_exec_handle* exec_async_exec(const char* cmd, const char* params, const char* dir);
00081 s_exec_handle* exec_async_exec2(const char* cmd, const char* params, const char* dir);
00082 
00083 bool exec_process_active(s_exec_handle* h);
00084 
00085 int exec_read_output(s_exec_handle* h, char*& lpBuffer, int& buffer_size);
00086 
00087 int exec_process_end(s_exec_handle* h);
00088 
00089 void exec_terminate_process(s_exec_handle* h, int error_code);
00090 
00091 #ifndef _WIN32
00092 #   define DWORD int
00093 #endif
00094 
00095 DWORD exec_get_exit_code(s_exec_handle* h);
00096 
00097 #endif

Generated on Sun Jul 10 03:22:52 2005 for VooDoo cIRCle by doxygen 1.4.3

Hosted by SourceForge.net Logo