1 #ifndef _SYS_CYGWIN_H 2 #define _SYS_CYGWIN_H 3 4 #include <sys/types.h> 5 6 #ifdef __cplusplus 7 extern "C" { 8 #endif 9 10 extern pid_t cygwin32_winpid_to_pid (int); 11 extern void cygwin32_win32_to_posix_path_list (const char *, char *); 12 extern int cygwin32_win32_to_posix_path_list_buf_size (const char *); 13 extern void cygwin32_posix_to_win32_path_list (const char *, char *); 14 extern int cygwin32_posix_to_win32_path_list_buf_size (const char *); 15 extern int cygwin32_conv_to_win32_path (const char *, char *); 16 extern int cygwin32_conv_to_full_win32_path (const char *, char *); 17 extern void cygwin32_conv_to_posix_path (const char *, char *); 18 extern void cygwin32_conv_to_full_posix_path (const char *, char *); 19 extern int cygwin32_posix_path_list_p (const char *); 20 extern void cygwin32_split_path (const char *, char *, char *); 21 22 extern pid_t cygwin_winpid_to_pid (int); 23 extern int cygwin_win32_to_posix_path_list (const char *, char *); 24 extern int cygwin_win32_to_posix_path_list_buf_size (const char *); 25 extern int cygwin_posix_to_win32_path_list (const char *, char *); 26 extern int cygwin_posix_to_win32_path_list_buf_size (const char *); 27 extern int cygwin_conv_to_win32_path (const char *, char *); 28 extern int cygwin_conv_to_full_win32_path (const char *, char *); 29 extern int cygwin_conv_to_posix_path (const char *, char *); 30 extern int cygwin_conv_to_full_posix_path (const char *, char *); 31 extern int cygwin_posix_path_list_p (const char *); 32 extern void cygwin_split_path (const char *, char *, char *); 33 34 extern void cygwin_premain0 (int argc, char **argv); 35 extern void cygwin_premain1 (int argc, char **argv); 36 extern void cygwin_premain2 (int argc, char **argv); 37 extern void cygwin_premain3 (int argc, char **argv); 38 39 struct __cygwin_perfile 40 { 41 const char *name; 42 unsigned flags; 43 }; 44 45 /* External interface stuff */ 46 47 typedef enum 48 { 49 CW_LOCK_PINFO, 50 CW_UNLOCK_PINFO, 51 CW_GETTHREADNAME, 52 CW_GETPINFO, 53 CW_SETPINFO, 54 CW_SETTHREADNAME, 55 CW_GETVERSIONINFO, 56 CW_READ_V1_MOUNT_TABLES, 57 CW_USER_DATA, 58 CW_PERFILE, 59 CW_GET_CYGDRIVE_PREFIXES, 60 CW_GETPINFO_FULL, 61 CW_INIT_EXCEPTIONS, 62 CW_GET_CYGDRIVE_INFO 63 } cygwin_getinfo_types; 64 65 #define CW_NEXTPID 0x80000000 // or with pid to get next one 66 67 /* Flags associated with process_state */ 68 enum 69 { 70 PID_IN_USE = 0x0001, // Entry in use. 71 PID_ZOMBIE = 0x0002, // Child exited: no parent wait. 72 PID_STOPPED = 0x0004, // Waiting for SIGCONT. 73 PID_TTYIN = 0x0008, // Waiting for terminal input. 74 PID_TTYOU = 0x0010, // Waiting for terminal output. 75 PID_ORPHANED = 0x0020, // Member of an orphaned process group. 76 PID_ACTIVE = 0x0040, // Pid accepts signals. 77 PID_CYGPARENT = 0x0080, // Set if parent was a cygwin app. 78 PID_SPLIT_HEAP = 0x0100, // Set if the heap has been split, 79 // which means we can't fork again. 80 PID_UNUSED = 0x0200, // Flag that pid should be cleared from parent's 81 // wait list 82 PID_UNUSED1 = 0x0400, // Set if process uses Winsock. 83 PID_INITIALIZING = 0x0800, // Set until ready to receive signals. 84 PID_USETTY = 0x1000, // Setting this enables or disables cygwin's 85 // tty support. This is inherited by 86 // all execed or forked processes. 87 PID_UNUSED2 = 0x2000, // child has execed 88 PID_EXECED = 0x4000, // redirect to original pid info block 89 PID_NOREDIR = 0x8000, // don't redirect if execed 90 PID_EXITED = 0x80000000 // Free entry. 91 }; 92 93 #ifdef WINVER 94 #ifdef _PATH_PASSWD 95 extern HANDLE cygwin_logon_user (const struct passwd *, const char *); 96 #endif 97 98 /* This lives in the app and is initialized before jumping into the DLL. 99 It should only contain stuff which the user's process needs to see, or 100 which is needed before the user pointer is initialized, or is needed to 101 carry inheritance information from parent to child. Note that it cannot 102 be used to carry inheritance information across exec! 103 104 Remember, this structure is linked into the application's executable. 105 Changes to this can invalidate existing executables, so we go to extra 106 lengths to avoid having to do it. 107 108 When adding/deleting members, remember to adjust {public,internal}_reserved. 109 The size of the class shouldn't change [unless you really are prepared to 110 invalidate all existing executables]. The program does a check (using 111 SIZEOF_PER_PROCESS) to make sure you remember to make the adjustment. 112 */ 113 114 #ifdef __cplusplus 115 class ResourceLocks; 116 class MTinterface; 117 #endif 118 119 struct per_process 120 { 121 char *initial_sp; 122 123 /* The offset of these 3 values can never change. */ 124 /* magic_biscuit is the size of this class and should never change. */ 125 unsigned long magic_biscuit; 126 unsigned long dll_major; 127 unsigned long dll_minor; 128 129 struct _reent **impure_ptr_ptr; 130 char ***envptr; 131 132 /* Used to point to the memory machine we should use. Usually these 133 point back into the dll, but they can be overridden by the user. */ 134 void *(*malloc)(size_t); 135 void (*free)(void *); 136 void *(*realloc)(void *, size_t); 137 138 int *fmode_ptr; 139 140 int (*main)(int, char **, char **); 141 void (**ctors)(void); 142 void (**dtors)(void); 143 144 /* For fork */ 145 void *data_start; 146 void *data_end; 147 void *bss_start; 148 void *bss_end; 149 150 void *(*calloc)(size_t, size_t); 151 /* For future expansion of values set by the app. */ 152 void (*premain[4]) (int, char **); 153 154 /* The rest are *internal* to cygwin.dll. 155 Those that are here because we want the child to inherit the value from 156 the parent (which happens when bss is copied) are marked as such. */ 157 158 /* non-zero of ctors have been run. Inherited from parent. */ 159 int run_ctors_p; 160 161 DWORD unused[3]; 162 163 /* Heap management. Inherited from parent. */ 164 void *heapbase; /* bottom of the heap */ 165 void *heapptr; /* current index into heap */ 166 void *heaptop; /* current top of heap */ 167 168 DWORD unused1; /* unused */ 169 170 /* Non-zero means the task was forked. The value is the pid. 171 Inherited from parent. */ 172 int forkee; 173 174 HMODULE hmodule; 175 176 DWORD api_major; /* API version that this program was */ 177 DWORD api_minor; /* linked with */ 178 /* For future expansion, so apps won't have to be relinked if we 179 add an item. */ 180 DWORD unused2[5]; 181 182 #ifdef __INSIDE_CYGWIN__ 183 ResourceLocks *resourcelocks; 184 MTinterface *threadinterface; 185 #else 186 void *resourcelocks; 187 void *threadinterface; 188 #endif 189 struct _reent *impure_ptr; 190 }; 191 #define per_process_overwrite ((unsigned) &(((struct per_process *) NULL)->resourcelocks)) 192 193 extern void cygwin_set_impersonation_token (const HANDLE); 194 195 /* included if <windows.h> is included */ 196 extern int cygwin32_attach_handle_to_fd (char *, int, HANDLE, mode_t, DWORD); 197 extern int cygwin_attach_handle_to_fd (char *, int, HANDLE, mode_t, DWORD); 198 199 #include <sys/resource.h> 200 201 struct external_pinfo 202 { 203 pid_t pid; 204 pid_t ppid; 205 HANDLE hProcess; 206 DWORD dwProcessId, dwSpawnedProcessId; 207 uid_t uid; 208 gid_t gid; 209 pid_t pgid; 210 pid_t sid; 211 int ctty; 212 mode_t umask; 213 214 long start_time; 215 struct rusage rusage_self; 216 struct rusage rusage_children; 217 218 char progname[MAX_PATH]; 219 220 DWORD strace_mask; 221 HANDLE strace_file; 222 223 DWORD process_state; 224 }; 225 226 DWORD cygwin_internal (cygwin_getinfo_types, ...); 227 #endif /*WINVER*/ 228 229 #ifdef __cplusplus 230 }; 231 #endif 232 233 #endif /* _SYS_CYGWIN_H */ |