]> sourceware.org Git - newlib-cygwin.git/blame - winsup/cygwin/include/sys/cygwin.h
Throughout, update copyrights to reflect dates which correspond to main-branch
[newlib-cygwin.git] / winsup / cygwin / include / sys / cygwin.h
CommitLineData
a887211b
CV
1/* sys/cygwin.h
2
bc837d22
CF
3 Copyright 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
4 2009, 2010, 2011, 2012 Red Hat, Inc.
a887211b
CV
5
6This file is part of Cygwin.
7
8This software is a copyrighted work licensed under the terms of the
9Cygwin license. Please consult the file "CYGWIN_LICENSE" for
10details. */
11
1fd5e000
CF
12#ifndef _SYS_CYGWIN_H
13#define _SYS_CYGWIN_H
14
15#include <sys/types.h>
041337fd 16#include <limits.h>
1fd5e000
CF
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
b7bb9f5f
CF
22#define _CYGWIN_SIGNAL_STRING "cYgSiGw00f"
23
edab6053
CV
24/* DEPRECATED INTERFACES. These are restricted to MAX_PATH length.
25 Don't use in modern applications. */
26extern int cygwin_win32_to_posix_path_list (const char *, char *)
27 __attribute__ ((deprecated));
28extern int cygwin_win32_to_posix_path_list_buf_size (const char *)
29 __attribute__ ((deprecated));
30extern int cygwin_posix_to_win32_path_list (const char *, char *)
31 __attribute__ ((deprecated));
32extern int cygwin_posix_to_win32_path_list_buf_size (const char *)
33 __attribute__ ((deprecated));
34extern int cygwin_conv_to_win32_path (const char *, char *)
35 __attribute__ ((deprecated));
36extern int cygwin_conv_to_full_win32_path (const char *, char *)
37 __attribute__ ((deprecated));
38extern int cygwin_conv_to_posix_path (const char *, char *)
39 __attribute__ ((deprecated));
40extern int cygwin_conv_to_full_posix_path (const char *, char *)
41 __attribute__ ((deprecated));
42
43/* Use these interfaces in favor of the above. */
44
45/* Possible 'what' values in calls to cygwin_conv_path/cygwin_create_path. */
46enum
47{
48 CCP_POSIX_TO_WIN_A = 0, /* from is char*, to is char* */
49 CCP_POSIX_TO_WIN_W, /* from is char*, to is wchar_t* */
50 CCP_WIN_A_TO_POSIX, /* from is char*, to is char* */
51 CCP_WIN_W_TO_POSIX, /* from is wchar_t*, to is char* */
52
a887cf0e
CV
53 CCP_CONVTYPE_MASK = 3,
54
edab6053
CV
55 /* Or these values to the above as needed. */
56 CCP_ABSOLUTE = 0, /* Request absolute path (default). */
57 CCP_RELATIVE = 0x100 /* Request to keep path relative. */
58};
59typedef unsigned int cygwin_conv_path_t;
60
61/* If size is 0, cygwin_conv_path returns the required buffer size in bytes.
62 Otherwise, it returns 0 on success, or -1 on error and errno is set to
63 one of the below values:
64
65 EINVAL what has an invalid value.
66 EFAULT from or to point into nirvana.
67 ENAMETOOLONG the resulting path is longer than 32K, or, in case
68 of what == CCP_POSIX_TO_WIN_A, longer than MAX_PATH.
69 ENOSPC size is less than required for the conversion.
70*/
71extern ssize_t cygwin_conv_path (cygwin_conv_path_t what, const void *from,
72 void *to, size_t size);
73/* Same, but handles path lists separated by colon or semicolon. */
74extern ssize_t cygwin_conv_path_list (cygwin_conv_path_t what, const void *from,
75 void *to, size_t size);
76/* Allocate a buffer for the conversion result using malloc(3), and return
77 a pointer to it. Returns NULL if something goes wrong with errno set
78 to one of the above values, or to ENOMEM if malloc fails. */
79extern void *cygwin_create_path (cygwin_conv_path_t what, const void *from);
1fd5e000
CF
80
81extern pid_t cygwin_winpid_to_pid (int);
1fd5e000
CF
82extern int cygwin_posix_path_list_p (const char *);
83extern void cygwin_split_path (const char *, char *, char *);
84
bd4ec496
CF
85struct __cygwin_perfile
86{
bb5d559a 87 const char *name;
bd4ec496
CF
88 unsigned flags;
89};
90
bd4ec496
CF
91/* External interface stuff */
92
b1d9a0bd 93/* Always add at the bottom. Do not add new values in the middle. */
9ee69121 94typedef enum
bd4ec496
CF
95 {
96 CW_LOCK_PINFO,
97 CW_UNLOCK_PINFO,
98 CW_GETTHREADNAME,
99 CW_GETPINFO,
100 CW_SETPINFO,
101 CW_SETTHREADNAME,
102 CW_GETVERSIONINFO,
103 CW_READ_V1_MOUNT_TABLES,
104 CW_USER_DATA,
637f5ce0 105 CW_PERFILE,
84c7d409 106 CW_GET_CYGDRIVE_PREFIXES,
239b06b8 107 CW_GETPINFO_FULL,
9bc846bd 108 CW_INIT_EXCEPTIONS,
a9f20457
CF
109 CW_GET_CYGDRIVE_INFO,
110 CW_SET_CYGWIN_REGISTRY_NAME,
494a66d9 111 CW_GET_CYGWIN_REGISTRY_NAME,
907dc7d0 112 CW_STRACE_TOGGLE,
3d456520 113 CW_STRACE_ACTIVE,
31b98a62 114 CW_CYGWIN_PID_TO_WINPID,
831d6fa5 115 CW_EXTRACT_DOMAIN_AND_USER,
5a4a19b3 116 CW_CMDLINE,
5ec9ea21 117 CW_CHECK_NTSEC,
bcd06214 118 CW_GET_ERRNO_FROM_WINERROR,
6ef3b76b 119 CW_GET_POSIX_SECURITY_ATTRIBUTE,
8e68687d
CV
120 CW_GET_SHMLBA,
121 CW_GET_UID_FROM_SID,
5ef9bbc8 122 CW_GET_GID_FROM_SID,
b1d9a0bd 123 CW_GET_BINMODE,
1cd8ccec
CF
124 CW_HOOK,
125 CW_ARGV,
5c8e6fbd 126 CW_ENVP,
6577c186 127 CW_DEBUG_SELF,
38229bcd 128 CW_SYNC_WINENV,
e7fd6e57 129 CW_CYGTLS_PADSIZE,
51303cbd 130 CW_SET_DOS_FILE_WARNING,
d95d8c53 131 CW_SET_PRIV_KEY,
c8ee587a 132 CW_SETERRNO,
0191627a 133 CW_EXIT_PROCESS,
526b0fbc 134 CW_SET_EXTERNAL_TOKEN,
f5a73638 135 CW_GET_INSTKEY,
a11a0723
CV
136 CW_INT_SETLOCALE,
137 CW_CVT_MNT_OPTS,
6259826e 138 CW_LST_MNT_OPTS,
8dfce03b 139 CW_STRERROR,
3a24189b
CV
140 CW_CVT_ENV_TO_WINENV,
141 CW_ALLOC_DRIVE_MAP,
142 CW_MAP_DRIVE_MAP,
143 CW_FREE_DRIVE_MAP
bd4ec496
CF
144 } cygwin_getinfo_types;
145
c53c656b
CV
146#define CW_LOCK_PINFO CW_LOCK_PINFO
147#define CW_UNLOCK_PINFO CW_UNLOCK_PINFO
148#define CW_GETTHREADNAME CW_GETTHREADNAME
149#define CW_GETPINFO CW_GETPINFO
150#define CW_SETPINFO CW_SETPINFO
151#define CW_SETTHREADNAME CW_SETTHREADNAME
152#define CW_GETVERSIONINFO CW_GETVERSIONINFO
153#define CW_READ_V1_MOUNT_TABLES CW_READ_V1_MOUNT_TABLES
154#define CW_USER_DATA CW_USER_DATA
155#define CW_PERFILE CW_PERFILE
156#define CW_GET_CYGDRIVE_PREFIXES CW_GET_CYGDRIVE_PREFIXES
157#define CW_GETPINFO_FULL CW_GETPINFO_FULL
158#define CW_INIT_EXCEPTIONS CW_INIT_EXCEPTIONS
159#define CW_GET_CYGDRIVE_INFO CW_GET_CYGDRIVE_INFO
160#define CW_SET_CYGWIN_REGISTRY_NAME CW_SET_CYGWIN_REGISTRY_NAME
161#define CW_GET_CYGWIN_REGISTRY_NAME CW_GET_CYGWIN_REGISTRY_NAME
162#define CW_STRACE_TOGGLE CW_STRACE_TOGGLE
163#define CW_STRACE_ACTIVE CW_STRACE_ACTIVE
164#define CW_CYGWIN_PID_TO_WINPID CW_CYGWIN_PID_TO_WINPID
165#define CW_EXTRACT_DOMAIN_AND_USER CW_EXTRACT_DOMAIN_AND_USER
166#define CW_CMDLINE CW_CMDLINE
167#define CW_CHECK_NTSEC CW_CHECK_NTSEC
168#define CW_GET_ERRNO_FROM_WINERROR CW_GET_ERRNO_FROM_WINERROR
169#define CW_GET_POSIX_SECURITY_ATTRIBUTE CW_GET_POSIX_SECURITY_ATTRIBUTE
170#define CW_GET_SHMLBA CW_GET_SHMLBA
171#define CW_GET_UID_FROM_SID CW_GET_UID_FROM_SID
172#define CW_GET_GID_FROM_SID CW_GET_GID_FROM_SID
173#define CW_GET_BINMODE CW_GET_BINMODE
174#define CW_HOOK CW_HOOK
175#define CW_ARGV CW_ARGV
176#define CW_ENVP CW_ENVP
177#define CW_DEBUG_SELF CW_DEBUG_SELF
178#define CW_SYNC_WINENV CW_SYNC_WINENV
179#define CW_CYGTLS_PADSIZE CW_CYGTLS_PADSIZE
180#define CW_SET_DOS_FILE_WARNING CW_SET_DOS_FILE_WARNING
181#define CW_SET_PRIV_KEY CW_SET_PRIV_KEY
182#define CW_SETERRNO CW_SETERRNO
183#define CW_EXIT_PROCESS CW_EXIT_PROCESS
184#define CW_SET_EXTERNAL_TOKEN CW_SET_EXTERNAL_TOKEN
185#define CW_GET_INSTKEY CW_GET_INSTKEY
186#define CW_INT_SETLOCALE CW_INT_SETLOCALE
187#define CW_CVT_MNT_OPTS CW_CVT_MNT_OPTS
188#define CW_LST_MNT_OPTS CW_LST_MNT_OPTS
189#define CW_STRERROR CW_STRERROR
190#define CW_CVT_ENV_TO_WINENV CW_CVT_ENV_TO_WINENV
b120088c
CV
191#define CW_ALLOC_DRIVE_MAP CW_ALLOC_DRIVE_MAP
192#define CW_MAP_DRIVE_MAP CW_MAP_DRIVE_MAP
193#define CW_FREE_DRIVE_MAP CW_FREE_DRIVE_MAP
c53c656b 194
0191627a
CV
195/* Token type for CW_SET_EXTERNAL_TOKEN */
196enum
197{
c53c656b
CV
198CW_TOKEN_IMPERSONATION = 0,
199CW_TOKEN_RESTRICTED = 1
0191627a
CV
200};
201
cadd065b 202#define CW_NEXTPID 0x80000000 /* or with pid to get next one */
a7ab35c1 203unsigned long cygwin_internal (cygwin_getinfo_types, ...);
bd4ec496
CF
204
205/* Flags associated with process_state */
206enum
207{
54dd79bb 208 PID_IN_USE = 0x00001, /* Entry in use. */
85b3fb96 209 PID_UNUSED = 0x00002, /* Available. */
54dd79bb
CF
210 PID_STOPPED = 0x00004, /* Waiting for SIGCONT. */
211 PID_TTYIN = 0x00008, /* Waiting for terminal input. */
212 PID_TTYOU = 0x00010, /* Waiting for terminal output. */
f95f18c9 213 PID_NOTCYGWIN = 0x00020, /* Set if process is not a cygwin app. */
54dd79bb
CF
214 PID_ACTIVE = 0x00040, /* Pid accepts signals. */
215 PID_CYGPARENT = 0x00080, /* Set if parent was a cygwin app. */
216 PID_MAP_RW = 0x00100, /* Flag to open map rw. */
217 PID_MYSELF = 0x00200, /* Flag that pid is me. */
218 PID_NOCLDSTOP = 0x00400, /* Set if no SIGCHLD signal on stop. */
219 PID_INITIALIZING = 0x00800, /* Set until ready to receive signals. */
c75b5b2d 220 PID_UNUSED1 = 0x01000, /* Available. */
54dd79bb
CF
221 PID_ALLPIDS = 0x02000, /* used by pinfo scanner */
222 PID_EXECED = 0x04000, /* redirect to original pid info block */
223 PID_NOREDIR = 0x08000, /* don't redirect if execed */
5069a2b0
CF
224 PID_EXITED = 0x40000000, /* Free entry. */
225 PID_REAPED = 0x80000000 /* Reaped */
bd4ec496
CF
226};
227
00103b7f
CV
228#ifdef WINVER
229
14a3bc2f
CF
230/* This lives in the app and is initialized before jumping into the DLL.
231 It should only contain stuff which the user's process needs to see, or
232 which is needed before the user pointer is initialized, or is needed to
233 carry inheritance information from parent to child. Note that it cannot
234 be used to carry inheritance information across exec!
235
236 Remember, this structure is linked into the application's executable.
237 Changes to this can invalidate existing executables, so we go to extra
238 lengths to avoid having to do it.
239
240 When adding/deleting members, remember to adjust {public,internal}_reserved.
241 The size of the class shouldn't change [unless you really are prepared to
242 invalidate all existing executables]. The program does a check (using
243 SIZEOF_PER_PROCESS) to make sure you remember to make the adjustment.
244*/
245
c19e7ba7 246#ifdef __cplusplus
d6483e83 247class MTinterface;
c19e7ba7 248#endif
d6483e83 249
b602bb90
DK
250struct per_process_cxx_malloc;
251
737a86d3 252struct per_process
14a3bc2f 253{
14a3bc2f
CF
254 char *initial_sp;
255
256 /* The offset of these 3 values can never change. */
257 /* magic_biscuit is the size of this class and should never change. */
258 unsigned long magic_biscuit;
259 unsigned long dll_major;
260 unsigned long dll_minor;
261
262 struct _reent **impure_ptr_ptr;
263 char ***envptr;
264
265 /* Used to point to the memory machine we should use. Usually these
266 point back into the dll, but they can be overridden by the user. */
267 void *(*malloc)(size_t);
268 void (*free)(void *);
269 void *(*realloc)(void *, size_t);
270
271 int *fmode_ptr;
272
273 int (*main)(int, char **, char **);
274 void (**ctors)(void);
275 void (**dtors)(void);
276
277 /* For fork */
278 void *data_start;
279 void *data_end;
280 void *bss_start;
281 void *bss_end;
282
283 void *(*calloc)(size_t, size_t);
284 /* For future expansion of values set by the app. */
95a8465b 285 void (*premain[4]) (int, char **, struct per_process *);
14a3bc2f 286
14a3bc2f
CF
287 /* non-zero of ctors have been run. Inherited from parent. */
288 int run_ctors_p;
289
1ff9f4b9 290 DWORD unused[7];
14a3bc2f 291
b602bb90
DK
292 /* Pointers to real operator new/delete functions for forwarding. */
293 struct per_process_cxx_malloc *cxx_malloc;
14a3bc2f
CF
294
295 HMODULE hmodule;
296
297 DWORD api_major; /* API version that this program was */
298 DWORD api_minor; /* linked with */
299 /* For future expansion, so apps won't have to be relinked if we
300 add an item. */
27f564e9
CF
301 DWORD unused2[3];
302 void *pseudo_reloc_start;
303 void *pseudo_reloc_end;
304 void *image_base;
737a86d3 305
b1aae492 306#if defined (__INSIDE_CYGWIN__) && defined (__cplusplus)
14a3bc2f 307 MTinterface *threadinterface;
52cec10c 308#else
52cec10c
CV
309 void *threadinterface;
310#endif
737a86d3 311 struct _reent *impure_ptr;
14a3bc2f 312};
a1591d3b 313#define per_process_overwrite ((unsigned) &(((struct per_process *) NULL)->threadinterface))
14a3bc2f 314
7d5d232b
CV
315#ifdef _PATH_PASSWD
316extern HANDLE cygwin_logon_user (const struct passwd *, const char *);
317#endif
d7cea2d3
CF
318extern void cygwin_set_impersonation_token (const HANDLE);
319
1fd5e000 320/* included if <windows.h> is included */
d69257a1 321extern int cygwin_attach_handle_to_fd (char *, int, HANDLE, mode_t, DWORD);
1fd5e000 322
92117cb2
CF
323extern void cygwin_premain0 (int, char **, struct per_process *);
324extern void cygwin_premain1 (int, char **, struct per_process *);
325extern void cygwin_premain2 (int, char **, struct per_process *);
326extern void cygwin_premain3 (int, char **, struct per_process *);
327
840fcfef 328#ifdef __CYGWIN__
2a6a56c2
CF
329#include <sys/resource.h>
330
b98ebf54
CF
331#define TTY_CONSOLE 0x40000000
332
3a571063
CV
333#define EXTERNAL_PINFO_VERSION_16_BIT 0
334#define EXTERNAL_PINFO_VERSION_32_BIT 1
36093cfb
CV
335#define EXTERNAL_PINFO_VERSION_32_LP 2
336#define EXTERNAL_PINFO_VERSION EXTERNAL_PINFO_VERSION_32_LP
9fef0139 337
494a66d9 338#ifndef _SYS_TYPES_H
52296b85
CV
339typedef unsigned short __uid16_t;
340typedef unsigned short __gid16_t;
a8d7ae61
CV
341typedef unsigned long __uid32_t;
342typedef unsigned long __gid32_t;
494a66d9
CF
343#endif
344
2a6a56c2
CF
345struct external_pinfo
346 {
347 pid_t pid;
348 pid_t ppid;
8cb359d9 349 DWORD exitcode;
2a6a56c2 350 DWORD dwProcessId, dwSpawnedProcessId;
52296b85
CV
351 __uid16_t uid;
352 __gid16_t gid;
2a6a56c2
CF
353 pid_t pgid;
354 pid_t sid;
355 int ctty;
356 mode_t umask;
357
358 long start_time;
359 struct rusage rusage_self;
360 struct rusage rusage_children;
361
362 char progname[MAX_PATH];
363
364 DWORD strace_mask;
9fef0139 365 DWORD version;
2a6a56c2
CF
366
367 DWORD process_state;
a8d7ae61 368
3a571063 369 /* Only available if version >= EXTERNAL_PINFO_VERSION_32_BIT */
a8d7ae61
CV
370 __uid32_t uid32;
371 __gid32_t gid32;
36093cfb
CV
372
373 /* Only available if version >= EXTERNAL_PINFO_VERSION_32_LP */
9d342d56 374 char *progname_long;
2a6a56c2 375};
840fcfef 376#endif /*__CYGWIN__*/
f33acdb8 377#endif /*WINVER*/
2a6a56c2 378
1fd5e000
CF
379#ifdef __cplusplus
380};
381#endif
1fd5e000 382#endif /* _SYS_CYGWIN_H */
This page took 0.469103 seconds and 5 git commands to generate.