3 Copyright 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
4 2007, 2008, 2009, 2010 Red Hat, Inc.
6 This file is part of Cygwin.
8 This software is a copyrighted work licensed under the terms of the
9 Cygwin license. Please consult the file "CYGWIN_LICENSE" for
15 #include <sys/types.h>
22 #define _CYGWIN_SIGNAL_STRING "cYgSiGw00f"
24 #if 0 /* ENTIRELY DEPRECATED INTERFACES. */
25 extern pid_t cygwin32_winpid_to_pid (int);
26 extern void cygwin32_win32_to_posix_path_list (const char *, char *);
27 extern int cygwin32_win32_to_posix_path_list_buf_size (const char *);
28 extern void cygwin32_posix_to_win32_path_list (const char *, char *);
29 extern int cygwin32_posix_to_win32_path_list_buf_size (const char *);
30 extern int cygwin32_conv_to_win32_path (const char *, char *);
31 extern int cygwin32_conv_to_full_win32_path (const char *, char *);
32 extern void cygwin32_conv_to_posix_path (const char *, char *);
33 extern void cygwin32_conv_to_full_posix_path (const char *, char *);
34 extern int cygwin32_posix_path_list_p (const char *);
35 extern void cygwin32_split_path (const char *, char *, char *);
36 extern int cygwin32_attach_handle_to_fd (char *, int, HANDLE, mode_t, DWORD);
39 /* DEPRECATED INTERFACES. These are restricted to MAX_PATH length.
40 Don't use in modern applications. */
41 extern int cygwin_win32_to_posix_path_list (const char *, char *)
42 __attribute__ ((deprecated));
43 extern int cygwin_win32_to_posix_path_list_buf_size (const char *)
44 __attribute__ ((deprecated));
45 extern int cygwin_posix_to_win32_path_list (const char *, char *)
46 __attribute__ ((deprecated));
47 extern int cygwin_posix_to_win32_path_list_buf_size (const char *)
48 __attribute__ ((deprecated));
49 extern int cygwin_conv_to_win32_path (const char *, char *)
50 __attribute__ ((deprecated));
51 extern int cygwin_conv_to_full_win32_path (const char *, char *)
52 __attribute__ ((deprecated));
53 extern int cygwin_conv_to_posix_path (const char *, char *)
54 __attribute__ ((deprecated));
55 extern int cygwin_conv_to_full_posix_path (const char *, char *)
56 __attribute__ ((deprecated));
58 /* Use these interfaces in favor of the above. */
60 /* Possible 'what' values in calls to cygwin_conv_path/cygwin_create_path. */
63 CCP_POSIX_TO_WIN_A = 0, /* from is char*, to is char* */
64 CCP_POSIX_TO_WIN_W, /* from is char*, to is wchar_t* */
65 CCP_WIN_A_TO_POSIX, /* from is char*, to is char* */
66 CCP_WIN_W_TO_POSIX, /* from is wchar_t*, to is char* */
68 /* Or these values to the above as needed. */
69 CCP_ABSOLUTE = 0, /* Request absolute path (default). */
70 CCP_RELATIVE = 0x100 /* Request to keep path relative. */
72 typedef unsigned int cygwin_conv_path_t;
74 /* If size is 0, cygwin_conv_path returns the required buffer size in bytes.
75 Otherwise, it returns 0 on success, or -1 on error and errno is set to
76 one of the below values:
78 EINVAL what has an invalid value.
79 EFAULT from or to point into nirvana.
80 ENAMETOOLONG the resulting path is longer than 32K, or, in case
81 of what == CCP_POSIX_TO_WIN_A, longer than MAX_PATH.
82 ENOSPC size is less than required for the conversion.
84 extern ssize_t cygwin_conv_path (cygwin_conv_path_t what, const void *from,
85 void *to, size_t size);
86 /* Same, but handles path lists separated by colon or semicolon. */
87 extern ssize_t cygwin_conv_path_list (cygwin_conv_path_t what, const void *from,
88 void *to, size_t size);
89 /* Allocate a buffer for the conversion result using malloc(3), and return
90 a pointer to it. Returns NULL if something goes wrong with errno set
91 to one of the above values, or to ENOMEM if malloc fails. */
92 extern void *cygwin_create_path (cygwin_conv_path_t what, const void *from);
94 extern pid_t cygwin_winpid_to_pid (int);
95 extern int cygwin_posix_path_list_p (const char *);
96 extern void cygwin_split_path (const char *, char *, char *);
98 struct __cygwin_perfile
104 /* External interface stuff */
106 /* Always add at the bottom. Do not add new values in the middle. */
116 CW_READ_V1_MOUNT_TABLES,
119 CW_GET_CYGDRIVE_PREFIXES,
122 CW_GET_CYGDRIVE_INFO,
123 CW_SET_CYGWIN_REGISTRY_NAME,
124 CW_GET_CYGWIN_REGISTRY_NAME,
127 CW_CYGWIN_PID_TO_WINPID,
128 CW_EXTRACT_DOMAIN_AND_USER,
131 CW_GET_ERRNO_FROM_WINERROR,
132 CW_GET_POSIX_SECURITY_ATTRIBUTE,
143 CW_SET_DOS_FILE_WARNING,
147 CW_SET_EXTERNAL_TOKEN,
153 } cygwin_getinfo_types;
155 /* Token type for CW_SET_EXTERNAL_TOKEN */
158 CW_TOKEN_IMPERSONATION = 0,
159 CW_TOKEN_RESTRICTED = 1
162 #define CW_NEXTPID 0x80000000 /* or with pid to get next one */
163 unsigned long cygwin_internal (cygwin_getinfo_types, ...);
165 /* Flags associated with process_state */
168 PID_IN_USE = 0x00001, /* Entry in use. */
169 PID_UNUSED = 0x00002, /* Available. */
170 PID_STOPPED = 0x00004, /* Waiting for SIGCONT. */
171 PID_TTYIN = 0x00008, /* Waiting for terminal input. */
172 PID_TTYOU = 0x00010, /* Waiting for terminal output. */
173 PID_ORPHANED = 0x00020, /* Member of an orphaned process group. */
174 PID_ACTIVE = 0x00040, /* Pid accepts signals. */
175 PID_CYGPARENT = 0x00080, /* Set if parent was a cygwin app. */
176 PID_MAP_RW = 0x00100, /* Flag to open map rw. */
177 PID_MYSELF = 0x00200, /* Flag that pid is me. */
178 PID_NOCLDSTOP = 0x00400, /* Set if no SIGCHLD signal on stop. */
179 PID_INITIALIZING = 0x00800, /* Set until ready to receive signals. */
180 PID_USETTY = 0x01000, /* Setting this enables or disables cygwin's
181 tty support. This is inherited by
182 all execed or forked processes. */
183 PID_ALLPIDS = 0x02000, /* used by pinfo scanner */
184 PID_EXECED = 0x04000, /* redirect to original pid info block */
185 PID_NOREDIR = 0x08000, /* don't redirect if execed */
186 PID_EXITED = 0x80000000 /* Free entry. */
191 /* This lives in the app and is initialized before jumping into the DLL.
192 It should only contain stuff which the user's process needs to see, or
193 which is needed before the user pointer is initialized, or is needed to
194 carry inheritance information from parent to child. Note that it cannot
195 be used to carry inheritance information across exec!
197 Remember, this structure is linked into the application's executable.
198 Changes to this can invalidate existing executables, so we go to extra
199 lengths to avoid having to do it.
201 When adding/deleting members, remember to adjust {public,internal}_reserved.
202 The size of the class shouldn't change [unless you really are prepared to
203 invalidate all existing executables]. The program does a check (using
204 SIZEOF_PER_PROCESS) to make sure you remember to make the adjustment.
211 struct per_process_cxx_malloc;
217 /* The offset of these 3 values can never change. */
218 /* magic_biscuit is the size of this class and should never change. */
219 unsigned long magic_biscuit;
220 unsigned long dll_major;
221 unsigned long dll_minor;
223 struct _reent **impure_ptr_ptr;
226 /* Used to point to the memory machine we should use. Usually these
227 point back into the dll, but they can be overridden by the user. */
228 void *(*malloc)(size_t);
229 void (*free)(void *);
230 void *(*realloc)(void *, size_t);
234 int (*main)(int, char **, char **);
235 void (**ctors)(void);
236 void (**dtors)(void);
244 void *(*calloc)(size_t, size_t);
245 /* For future expansion of values set by the app. */
246 void (*premain[4]) (int, char **, struct per_process *);
248 /* non-zero of ctors have been run. Inherited from parent. */
253 /* Pointers to real operator new/delete functions for forwarding. */
254 struct per_process_cxx_malloc *cxx_malloc;
258 DWORD api_major; /* API version that this program was */
259 DWORD api_minor; /* linked with */
260 /* For future expansion, so apps won't have to be relinked if we
263 void *pseudo_reloc_start;
264 void *pseudo_reloc_end;
267 #if defined (__INSIDE_CYGWIN__) && defined (__cplusplus)
268 MTinterface *threadinterface;
270 void *threadinterface;
272 struct _reent *impure_ptr;
274 #define per_process_overwrite ((unsigned) &(((struct per_process *) NULL)->threadinterface))
276 extern void cygwin_premain0 (int argc, char **argv, struct per_process *);
277 extern void cygwin_premain1 (int argc, char **argv, struct per_process *);
278 extern void cygwin_premain2 (int argc, char **argv, struct per_process *);
279 extern void cygwin_premain3 (int argc, char **argv, struct per_process *);
282 extern HANDLE cygwin_logon_user (const struct passwd *, const char *);
284 extern void cygwin_set_impersonation_token (const HANDLE);
286 /* included if <windows.h> is included */
287 extern int cygwin_attach_handle_to_fd (char *, int, HANDLE, mode_t, DWORD);
290 #include <sys/resource.h>
292 #define TTY_CONSOLE 0x40000000
294 #define EXTERNAL_PINFO_VERSION_16_BIT 0
295 #define EXTERNAL_PINFO_VERSION_32_BIT 1
296 #define EXTERNAL_PINFO_VERSION_32_LP 2
297 #define EXTERNAL_PINFO_VERSION EXTERNAL_PINFO_VERSION_32_LP
300 typedef unsigned short __uid16_t;
301 typedef unsigned short __gid16_t;
302 typedef unsigned long __uid32_t;
303 typedef unsigned long __gid32_t;
306 struct external_pinfo
311 DWORD dwProcessId, dwSpawnedProcessId;
320 struct rusage rusage_self;
321 struct rusage rusage_children;
323 char progname[MAX_PATH];
330 /* Only available if version >= EXTERNAL_PINFO_VERSION_32_BIT */
334 /* Only available if version >= EXTERNAL_PINFO_VERSION_32_LP */
337 #endif /*__CYGWIN__*/
343 #endif /* _SYS_CYGWIN_H */