[7297] Fixed profession spells sorting in trainer spell list at client.
[getmangos.git] / dep / ACE_wrappers / ace / Process.inl
blob9723ebc8c440ccd267edbe57d28b6e94efff83d7
1 // -*- C++ -*-
2 //
3 // $Id: Process.inl 80826 2008-03-04 14:51:23Z wotte $
5 #include "ace/ACE.h"
6 #include "ace/OS_NS_sys_wait.h"
7 #include "ace/OS_NS_signal.h"
8 #include "ace/OS_NS_pwd.h"
9 #include "ace/OS_NS_string.h"
11 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
13 #if defined (ACE_WIN32)
15 ACE_INLINE PROCESS_INFORMATION
16 ACE_Process::process_info (void)
18   return process_info_;
20 #endif /* ACE_WIN32 */
22 ACE_INLINE ACE_HANDLE
23 ACE_Process::gethandle (void) const
25 #if defined (ACE_WIN32)
26   return process_info_.hProcess;
27 #else
28   return ACE_HANDLE (child_id_);
29 #endif /* ACE_WIN32 */
32 ACE_INLINE pid_t
33 ACE_Process::getpid (void)
34     const
36 #if defined (ACE_WIN32)
37   return process_info_.dwProcessId;
38 #else /* ACE_WIN32 */
39   return child_id_;
40 #endif /* ACE_WIN32 */
43 ACE_INLINE pid_t
44 ACE_Process::wait (ACE_exitcode *status,
45                    int wait_options)
47   pid_t retv =
48     ACE_OS::wait (this->getpid (),
49                   &this->exit_code_,
50                   wait_options
51 #if defined (ACE_WIN32)
52                   , process_info_.hProcess
53 #endif /* ACE_WIN32 */
54                   );
55   if (status != 0)
56     *status = this->exit_code_;
58   return retv;
61 ACE_INLINE int
62 ACE_Process::kill (int signum)
64   if (this->getpid () != -1)
65     return ACE_OS::kill (this->getpid (), signum);
66   else
67     return -1;
70 ACE_INLINE int
71 ACE_Process::terminate (void)
73   if (this->getpid () != -1)
74     return ACE::terminate_process (this->getpid ());
75   else
76     return -1;
79 ACE_INLINE int
80 ACE_Process::return_value (void) const
82 #if defined (ACE_WIN32)
83   return this->exit_code_;
84 #else
85   return WEXITSTATUS (this->exit_code_);
86 #endif /* ACE_WIN32 */
89 ACE_INLINE ACE_exitcode
90 ACE_Process::exit_code (void) const
92   return this->exit_code_;
95 ACE_INLINE void
96 ACE_Process::exit_code (ACE_exitcode code)
98   this->exit_code_ = code;
101 ACE_INLINE u_long
102 ACE_Process_Options::creation_flags (void) const
104 #if defined (ACE_USES_WCHAR) && defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)
105   return creation_flags_ | CREATE_UNICODE_ENVIRONMENT;
106 #else
107   return creation_flags_;
108 #endif /* ACE_USES_WCHAR */
111 ACE_INLINE void
112 ACE_Process_Options::creation_flags (u_long cf)
114   creation_flags_ = cf;
117 ACE_INLINE pid_t
118 ACE_Process_Options::getgroup (void) const
120   return process_group_;
123 ACE_INLINE pid_t
124 ACE_Process_Options::setgroup (pid_t pgrp)
126   pid_t old = process_group_;
127   process_group_ = pgrp;
128   return old;
131 ACE_INLINE int
132 ACE_Process_Options::handle_inheritence (void)
134 #if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)
135   return handle_inheritence_;
136 #else
137   ACE_NOTSUP_RETURN (0);  // This is a benign error.
138 #endif /* ACE_WIN32 && ! ACE_HAS_WINCE */
141 ACE_INLINE void
142 ACE_Process_Options::handle_inheritence (int hi)
144 #if defined (ACE_WIN32) &&  !defined (ACE_HAS_WINCE)
145   handle_inheritence_ = hi;
146 #else
147   ACE_UNUSED_ARG (hi);
148   ACE_NOTSUP;
149 #endif /* !ACE_HAS_WINCE */
152 ACE_INLINE int
153 ACE_Process_Options::avoid_zombies (void)
155   return avoid_zombies_;
157 ACE_INLINE void
158 ACE_Process_Options::avoid_zombies (int avoid_zombies)
160   avoid_zombies_ = avoid_zombies;
163 #if defined (ACE_WIN32)
165 ACE_INLINE ACE_TEXT_STARTUPINFO *
166 ACE_Process_Options::startup_info (void)
168 #if !defined (ACE_HAS_WINCE)
169   return &startup_info_;
170 #else
171   return 0;
172 #endif /* !ACE_HAS_WINCE */
175 ACE_INLINE LPSECURITY_ATTRIBUTES
176 ACE_Process_Options::get_process_attributes (void) const
178 #if !defined (ACE_HAS_WINCE)
179   return process_attributes_;
180 #else
181   return 0;
182 #endif /* !ACE_HAS_WINCE */
185 ACE_INLINE LPSECURITY_ATTRIBUTES
186 ACE_Process_Options::set_process_attributes (void)
188 #if !defined (ACE_HAS_WINCE)
189   process_attributes_ = &security_buf1_;
190   return process_attributes_;
191 #else
192   return 0;
193 #endif /* !ACE_HAS_WINCE */
196 ACE_INLINE LPSECURITY_ATTRIBUTES
197 ACE_Process_Options::get_thread_attributes (void) const
199 #if !defined (ACE_HAS_WINCE)
200   return thread_attributes_;
201 #else
202   return 0;
203 #endif /* !ACE_HAS_WINCE */
206 ACE_INLINE LPSECURITY_ATTRIBUTES
207 ACE_Process_Options::set_thread_attributes (void)
209 #if !defined (ACE_HAS_WINCE)
210   thread_attributes_ = &security_buf2_;
211   return thread_attributes_;
212 #else
213   return 0;
214 #endif /* !ACE_HAS_WINCE */
217 #else /* !defined (ACE_WIN32) */
219 ACE_INLINE ACE_HANDLE
220 ACE_Process_Options::get_stdin (void) const
222   return stdin_;
225 ACE_INLINE ACE_HANDLE
226 ACE_Process_Options::get_stdout (void) const
228   return stdout_;
231 ACE_INLINE ACE_HANDLE
232 ACE_Process_Options::get_stderr (void) const
234   return stderr_;
237 ACE_INLINE bool
238 ACE_Process_Options::inherit_environment (void) const
240   return inherit_environment_;
243 ACE_INLINE void
244 ACE_Process_Options::inherit_environment (bool nv)
246   inherit_environment_ = nv;
249 ACE_INLINE int
250 ACE_Process_Options::setreugid (const ACE_TCHAR* user)
252 #if !defined (ACE_LACKS_PWD_FUNCTIONS)
253   struct passwd *ent = ACE_OS::getpwnam (ACE_TEXT_ALWAYS_CHAR (user));
255   if (ent != 0)
256     {
257       this->euid_ = ent->pw_uid;
258       this->ruid_ = ent->pw_uid;
259       this->egid_ = ent->pw_gid;
260       this->rgid_ = ent->pw_gid;
261       return 0;
262     }
263   else
264     return -1;
265 #else
266   ACE_UNUSED_ARG (user);
267   ACE_NOTSUP_RETURN (-1);
268 #endif /* ACE_LACKS_PWD_FUNCTIONS */
271 ACE_INLINE void
272 ACE_Process_Options::setruid (uid_t id)
274   this->ruid_ = id;
277 ACE_INLINE void
278 ACE_Process_Options::seteuid (uid_t id)
280   this->euid_ = id;
283 ACE_INLINE void
284 ACE_Process_Options::setrgid (uid_t id)
286   this->rgid_ = id;
289 ACE_INLINE void
290 ACE_Process_Options::setegid (uid_t id)
292   this->egid_ = id;
295 ACE_INLINE uid_t
296 ACE_Process_Options::getruid (void) const
298   return this->ruid_;
301 ACE_INLINE uid_t
302 ACE_Process_Options::geteuid (void) const
304   return this->euid_;
307 ACE_INLINE uid_t
308 ACE_Process_Options::getrgid (void) const
310   return this->rgid_;
313 ACE_INLINE uid_t
314 ACE_Process_Options::getegid (void) const
316   return this->egid_;
318 #endif /* ACE_WIN32 */
320 ACE_INLINE ACE_TCHAR *
321 ACE_Process_Options::command_line_buf (int *max_lenp)
323   if (max_lenp != 0)
324     *max_lenp = this->command_line_buf_len_;
325   return this->command_line_buf_;
328 ACE_INLINE ACE_TCHAR *
329 ACE_Process_Options::working_directory (void)
331 #if !defined (ACE_HAS_WINCE)
332   if (working_directory_[0] == '\0')
333     return 0;
334   else
335     return working_directory_;
336 #else
337   return 0;
338 #endif /* !ACE_HAS_WINCE */
341 ACE_INLINE void
342 ACE_Process_Options::working_directory (const char *wd)
344 #if !defined(ACE_HAS_WINCE)
345   ACE_OS::strcpy (working_directory_, ACE_TEXT_CHAR_TO_TCHAR (wd));
346 #else
347   ACE_UNUSED_ARG (wd);
348 #endif /* !ACE_HAS_WINCE */
351 #if defined (ACE_HAS_WCHAR)
352 ACE_INLINE void
353 ACE_Process_Options::working_directory (const wchar_t *wd)
355 #if !defined(ACE_HAS_WINCE)
356   ACE_OS::strcpy (working_directory_, ACE_TEXT_WCHAR_TO_TCHAR (wd));
357 #else
358   ACE_UNUSED_ARG (wd);
359 #endif /* !ACE_HAS_WINCE */
361 #endif /* ACE_HAS_WCHAR */
363 ACE_INLINE void
364 ACE_Process_Options::process_name (const ACE_TCHAR *p)
366   ACE_OS::strcpy (this->process_name_, p);
369 ACE_INLINE const ACE_TCHAR *
370 ACE_Process_Options::process_name (void)
372   if (process_name_[0] == '\0')
373     this->process_name (this->command_line_argv ()[0]);
375   return this->process_name_;
378 #if defined (ACE_HAS_WINCE)
379 // Here is a collection of inline functions which are defined only
380 // under CE.  They are not empty on most other platforms.
382 ACE_INLINE int
383 ACE_Process_Options::setenv (ACE_TCHAR * /* envp */[])
385   return -1;
388 ACE_INLINE int
389 ACE_Process_Options::setenv (const ACE_TCHAR * /* format */, ...)
391   return -1;
394 ACE_INLINE int
395 ACE_Process_Options::setenv (const ACE_TCHAR * /* variable_name */,
396                              const ACE_TCHAR * /* format */,
397                              ...)
399   return -1;
402 ACE_INLINE int
403 ACE_Process_Options::set_handles (ACE_HANDLE /* std_in */,
404                                   ACE_HANDLE /* std_out */,
405                                   ACE_HANDLE /* std_err */)
407   return -1;
410 #endif /* ACE_HAS_WINCE */
412 ACE_END_VERSIONED_NAMESPACE_DECL