Back to index

enigmail  1.4.3
IPCProcess.h
Go to the documentation of this file.
00001 /* ***** BEGIN LICENSE BLOCK *****
00002  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00003  *
00004  * The contents of this file are subject to the Mozilla Public
00005  * License Version 1.1 (the "MPL"); you may not use this file
00006  * except in compliance with the MPL. You may obtain a copy of
00007  * the MPL at http://www.mozilla.org/MPL/
00008  *
00009  * Software distributed under the MPL is distributed on an "AS
00010  * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
00011  * implied. See the MPL for the specific language governing
00012  * rights and limitations under the MPL.
00013  *
00014  * The Original Code is the Netscape Portable Runtime (NSPR).
00015  *
00016  * The Initial Developer of the Original Code is Netscape
00017  * Communications Corporation.  Portions created by Netscape are
00018  * Copyright (C) 1998-2000 Netscape Communications Corporation.  All
00019  * Rights Reserved.
00020  *
00021  * Contributor(s):
00022  *   Ramalingam Saravanan <svn@xmlterm.org>
00023  *   Patrick Brunschwig <patrick@mozilla-enigmail.org>
00024  *
00025  * Alternatively, the contents of this file may be used under the terms of
00026  * either the GNU General Public License Version 2 or later (the "GPL"), or
00027  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00028  * in which case the provisions of the GPL or the LGPL are applicable instead
00029  * of those above. If you wish to allow use of your version of this file only
00030  * under the terms of either the GPL or the LGPL, and not to allow others to
00031  * use your version of this file under the terms of the MPL, indicate your
00032  * decision by deleting the provisions above and replace them with the notice
00033  * and other provisions required by the GPL or the LGPL. If you do not delete
00034  * the provisions above, a recipient may use your version of this file under
00035  * the terms of any one of the MPL, the GPL or the LGPL.
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 
00039 #ifndef IPCProcess_h__
00040 #define IPCProcess_h__
00041 
00042 #include "ipc.h"
00043 #include "nspr.h"
00044 #include "prproces.h"
00045 
00046 /* Define XP_WIN_IPC to enable Win32-specific IPC stuff;
00047  * this avoids some problems with the NSPR IPC implementation on Win32
00048  * which can sometimes cause processes to hang when trying to read STDIN
00049  */
00050 #ifdef XP_WIN
00051 #define XP_WIN_IPC
00052 #endif
00053 
00054 #ifdef XP_WIN_IPC
00055 
00056 #include <windows.h>
00057 #include <shellapi.h>
00058 
00059 typedef DWORD (WINAPI*GetProcessIdPtr)(HANDLE process);
00060 
00061 #define IPCProcess void
00062 #define IPCFileDesc void
00063 #define IPC_NULL_HANDLE NULL
00064 
00065 #define IPC_CreateProcessRedirected IPC_CreateProcessRedirectedWin32
00066 #define IPC_CreateInheritablePipe IPC_CreateInheritablePipeWin32
00067 
00068 #define IPC_WaitProcess IPC_WaitProcessWin32
00069 #define IPC_KillProcess IPC_KillProcessWin32
00070 #define IPC_GetProcessId IPC_GetProcessIdWin32
00071 #define IPC_Read IPC_ReadWin32
00072 #define IPC_Write IPC_WriteWin32
00073 #define IPC_Close IPC_CloseWin32
00074 #define IPC_GetError IPC_GetErrorWin32
00075 
00076 #else
00077 
00078 #define IPCProcess PRProcess
00079 #define IPCFileDesc PRFileDesc
00080 #define IPC_NULL_HANDLE nsnull
00081 
00082 #define IPC_CreateProcessRedirected IPC_CreateProcessRedirectedNSPR
00083 #define IPC_CreateInheritablePipe IPC_CreateInheritablePipeNSPR
00084 
00085 #define IPC_WaitProcess PR_WaitProcess
00086 #define IPC_KillProcess PR_KillProcess
00087 #define IPC_GetProcessId IPC_GetProcessIdNSPR
00088 #define IPC_Read PR_Read
00089 #define IPC_Write PR_Write
00090 #define IPC_Close PR_Close
00091 #define IPC_GetError PR_GetError
00092 #endif /* !XP_WIN_IPC */
00093 
00106 PRProcess* IPC_CreateProcessRedirectedNSPR(const char *path,
00107                                            char *const *argv,
00108                                            char *const *envp,
00109                                            const char *cwd,
00110                                            PRFileDesc* std_in,
00111                                            PRFileDesc* std_out,
00112                                            PRFileDesc* std_err,
00113                                            IPCBool detach);
00114 
00125 PRStatus IPC_CreateInheritablePipeNSPR(PRFileDesc* *readPipe,
00126                                        PRFileDesc* *writePipe,
00127                                        IPCBool readInherit,
00128                                        IPCBool writeInherit);
00129 
00133 PRStatus IPC_GetProcessIdNSPR(IPCProcess* process, PRInt32 *pid);
00134 
00135 
00136 void IPC_Shutdown();
00137 
00138 #ifdef XP_WIN_IPC
00139 
00143 IPCProcess* IPC_CreateProcessRedirectedWin32(const char *path,
00144                                             char *const *argv,
00145                                             char *const *envp,
00146                                             const char *cwd,
00147                                             IPCFileDesc* std_in,
00148                                             IPCFileDesc* std_out,
00149                                             IPCFileDesc* std_err,
00150                                             IPCBool detach);
00155 PRStatus IPC_CreateInheritablePipeWin32(IPCFileDesc* *readPipe,
00156                                         IPCFileDesc* *writePipe,
00157                                         IPCBool readInherit,
00158                                         IPCBool writeInherit);
00159 
00163 PRStatus IPC_WaitProcessWin32(IPCProcess* process, PRInt32 *exitCode);
00164 
00168 PRStatus IPC_KillProcessWin32(IPCProcess* process);
00169 
00173 PRInt32  IPC_ReadWin32(IPCFileDesc* fd, void *buf, PRInt32 amount);
00174 
00178 PRInt32  IPC_WriteWin32(IPCFileDesc* fd, const void *buf, PRInt32 amount);
00179 
00183 PRStatus IPC_CloseWin32(IPCFileDesc* fd);
00184 
00188 PRStatus IPC_GetProcessIdWin32(IPCProcess* process, PRInt32 *pid);
00189 
00193 PRErrorCode IPC_GetErrorWin32();
00194 #endif
00195 
00196 #endif // IPCProcess_h__