~ubuntu-branches/ubuntu/quantal/enigmail/quantal-security

« back to all changes in this revision

Viewing changes to extensions/enigmail/ipc/src/IPCProcess.h

  • Committer: Package Import Robot
  • Author(s): Chris Coulson
  • Date: 2013-09-13 16:02:15 UTC
  • mfrom: (0.12.16)
  • Revision ID: package-import@ubuntu.com-20130913160215-u3g8nmwa0pdwagwc
Tags: 2:1.5.2-0ubuntu0.12.10.1
* New upstream release v1.5.2 for Thunderbird 24

* Build enigmail using a stripped down Thunderbird 17 build system, as it's
  now quite difficult to build the way we were doing previously, with the
  latest Firefox build system
* Add debian/patches/no_libxpcom.patch - Don't link against libxpcom, as it
  doesn't exist anymore (but exists in the build system)
* Add debian/patches/use_sdk.patch - Use the SDK version of xpt.py and
  friends
* Drop debian/patches/ipc-pipe_rename.diff (not needed anymore)
* Drop debian/patches/makefile_depth.diff (not needed anymore)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* ***** BEGIN LICENSE BLOCK *****
2
 
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3
 
 *
4
 
 * The contents of this file are subject to the Mozilla Public
5
 
 * License Version 1.1 (the "MPL"); you may not use this file
6
 
 * except in compliance with the MPL. You may obtain a copy of
7
 
 * the MPL at http://www.mozilla.org/MPL/
8
 
 *
9
 
 * Software distributed under the MPL is distributed on an "AS
10
 
 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
11
 
 * implied. See the MPL for the specific language governing
12
 
 * rights and limitations under the MPL.
13
 
 *
14
 
 * The Original Code is the Netscape Portable Runtime (NSPR).
15
 
 *
16
 
 * The Initial Developer of the Original Code is Netscape
17
 
 * Communications Corporation.  Portions created by Netscape are
18
 
 * Copyright (C) 1998-2000 Netscape Communications Corporation.  All
19
 
 * Rights Reserved.
20
 
 *
21
 
 * Contributor(s):
22
 
 *   Ramalingam Saravanan <svn@xmlterm.org>
23
 
 *   Patrick Brunschwig <patrick@mozilla-enigmail.org>
24
 
 *
25
 
 * Alternatively, the contents of this file may be used under the terms of
26
 
 * either the GNU General Public License Version 2 or later (the "GPL"), or
27
 
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28
 
 * in which case the provisions of the GPL or the LGPL are applicable instead
29
 
 * of those above. If you wish to allow use of your version of this file only
30
 
 * under the terms of either the GPL or the LGPL, and not to allow others to
31
 
 * use your version of this file under the terms of the MPL, indicate your
32
 
 * decision by deleting the provisions above and replace them with the notice
33
 
 * and other provisions required by the GPL or the LGPL. If you do not delete
34
 
 * the provisions above, a recipient may use your version of this file under
35
 
 * the terms of any one of the MPL, the GPL or the LGPL.
36
 
 * ***** END LICENSE BLOCK ***** */
37
 
 
38
 
 
39
 
#ifndef IPCProcess_h__
40
 
#define IPCProcess_h__
41
 
 
42
 
#include "ipc.h"
43
 
#include "nspr.h"
44
 
#include "prproces.h"
45
 
 
46
 
/* Define XP_WIN_IPC to enable Win32-specific IPC stuff;
47
 
 * this avoids some problems with the NSPR IPC implementation on Win32
48
 
 * which can sometimes cause processes to hang when trying to read STDIN
49
 
 */
50
 
#ifdef XP_WIN
51
 
#define XP_WIN_IPC
52
 
#endif
53
 
 
54
 
#ifdef XP_WIN_IPC
55
 
 
56
 
#include <windows.h>
57
 
#include <shellapi.h>
58
 
 
59
 
typedef DWORD (WINAPI*GetProcessIdPtr)(HANDLE process);
60
 
 
61
 
#define IPCProcess void
62
 
#define IPCFileDesc void
63
 
#define IPC_NULL_HANDLE NULL
64
 
 
65
 
#define IPC_CreateProcessRedirected IPC_CreateProcessRedirectedWin32
66
 
#define IPC_CreateInheritablePipe IPC_CreateInheritablePipeWin32
67
 
 
68
 
#define IPC_WaitProcess IPC_WaitProcessWin32
69
 
#define IPC_KillProcess IPC_KillProcessWin32
70
 
#define IPC_GetProcessId IPC_GetProcessIdWin32
71
 
#define IPC_Read IPC_ReadWin32
72
 
#define IPC_Write IPC_WriteWin32
73
 
#define IPC_Close IPC_CloseWin32
74
 
#define IPC_GetError IPC_GetErrorWin32
75
 
 
76
 
#else
77
 
 
78
 
#define IPCProcess PRProcess
79
 
#define IPCFileDesc PRFileDesc
80
 
#define IPC_NULL_HANDLE NULL
81
 
 
82
 
#define IPC_CreateProcessRedirected IPC_CreateProcessRedirectedNSPR
83
 
#define IPC_CreateInheritablePipe IPC_CreateInheritablePipeNSPR
84
 
 
85
 
#define IPC_WaitProcess PR_WaitProcess
86
 
#define IPC_KillProcess PR_KillProcess
87
 
#define IPC_GetProcessId IPC_GetProcessIdNSPR
88
 
#define IPC_Read PR_Read
89
 
#define IPC_Write PR_Write
90
 
#define IPC_Close PR_Close
91
 
#define IPC_GetError PR_GetError
92
 
#endif /* !XP_WIN_IPC */
93
 
 
94
 
/**
95
 
  * Creates a process and assigns the stdin/stdout/stderr file descriptors
96
 
  *
97
 
  * @param path      Path to the executable file in native encoding
98
 
  * @param argv      Array of arguments to the process in native encoding
99
 
  * @param envp      Array of environment variables in native encoding
100
 
  * @param cwd       The subprocess' woring directory in native encoding
101
 
  * @param std_in    The STDIN file descriptor of the subprocess
102
 
  * @param std_out   The STDOUT file descriptor of the subprocess
103
 
  * @param std_err   The STDERR file descriptor of the subprocess
104
 
  * @param detach    True if the process should be detached from the parent
105
 
  */
106
 
PRProcess* IPC_CreateProcessRedirectedNSPR(const char *path,
107
 
                                           char *const *argv,
108
 
                                           char *const *envp,
109
 
                                           const char *cwd,
110
 
                                           PRFileDesc* std_in,
111
 
                                           PRFileDesc* std_out,
112
 
                                           PRFileDesc* std_err,
113
 
                                           IPCBool detach);
114
 
 
115
 
/**
116
 
  * Set the file descriptors of a pipe, e.g. STDIN, to (not) inheritable
117
 
  * Usually the file descriptor of the intended direction is inheritable (e.g.
118
 
  * "write" for STDIN.
119
 
  *
120
 
  * @param readPipe      File descriptor of the reading pipe
121
 
  * @param writePipe     File descriptor of the writing pipe
122
 
  * @param readInherit   True if reader should be inheritable
123
 
  * @param writeInherit  True if writer should be inheritable
124
 
  */
125
 
PRStatus IPC_CreateInheritablePipeNSPR(PRFileDesc* *readPipe,
126
 
                                       PRFileDesc* *writePipe,
127
 
                                       IPCBool readInherit,
128
 
                                       IPCBool writeInherit);
129
 
 
130
 
/**
131
 
  * Get the process ID of a running subprocess
132
 
  */
133
 
PRStatus IPC_GetProcessIdNSPR(IPCProcess* process, PRInt32 *pid);
134
 
 
135
 
 
136
 
void IPC_Shutdown();
137
 
 
138
 
#ifdef XP_WIN_IPC
139
 
/**
140
 
  * @see IPC_CreateProcessRedirectedNSPR
141
 
  */
142
 
 
143
 
IPCProcess* IPC_CreateProcessRedirectedWin32(const char *path,
144
 
                                            char *const *argv,
145
 
                                            char *const *envp,
146
 
                                            const char *cwd,
147
 
                                            IPCFileDesc* std_in,
148
 
                                            IPCFileDesc* std_out,
149
 
                                            IPCFileDesc* std_err,
150
 
                                            IPCBool detach);
151
 
/**
152
 
  * @see IPC_CreateInheritablePipeNSPR
153
 
  */
154
 
 
155
 
PRStatus IPC_CreateInheritablePipeWin32(IPCFileDesc* *readPipe,
156
 
                                        IPCFileDesc* *writePipe,
157
 
                                        IPCBool readInherit,
158
 
                                        IPCBool writeInherit);
159
 
 
160
 
/**
161
 
  * @see PR_WaitProcess in prprocess.h
162
 
  */
163
 
PRStatus IPC_WaitProcessWin32(IPCProcess* process, PRInt32 *exitCode);
164
 
 
165
 
/**
166
 
  * @see PR_KillProcess in prprocess.h
167
 
  */
168
 
PRStatus IPC_KillProcessWin32(IPCProcess* process);
169
 
 
170
 
/**
171
 
  * @see PR_Read in prprocess.h
172
 
  */
173
 
PRInt32  IPC_ReadWin32(IPCFileDesc* fd, void *buf, PRInt32 amount);
174
 
 
175
 
/**
176
 
  * @see PR_Write in prprocess.h
177
 
  */
178
 
PRInt32  IPC_WriteWin32(IPCFileDesc* fd, const void *buf, PRInt32 amount);
179
 
 
180
 
/**
181
 
  * @see PR_Close in prprocess.h
182
 
  */
183
 
PRStatus IPC_CloseWin32(IPCFileDesc* fd);
184
 
 
185
 
/**
186
 
  * @see PR_GetProcessId in prprocess.h
187
 
  */
188
 
PRStatus IPC_GetProcessIdWin32(IPCProcess* process, PRInt32 *pid);
189
 
 
190
 
/**
191
 
  * @see PR_GetError in prprocess.h
192
 
  */
193
 
PRErrorCode IPC_GetErrorWin32();
194
 
#endif
195
 
 
196
 
#endif // IPCProcess_h__