1 /* cygheap.h: Cygwin heap manager.
3 Copyright 2000 Cygnus Solutions.
5 This file is part of Cygwin.
7 This software is a copyrighted work licensed under the terms of the
8 Cygwin license. Please consult the file "CYGWIN_LICENSE" for
27 #define incygheap(s) (cygheap && ((char *) (s) >= (char *) cygheap) && ((char *) (s) <= ((char *) cygheap_max)))
36 struct _cmalloc_entry *prev;
42 /* Root directory information.
43 This is used after a chroot is called. */
47 cygheap_root (cygheap_root &nroot);
49 char *operator =(const char *new_root);
50 size_t length () const { return rootlen; }
51 const char *path () const { return root; }
56 /* Extendend user information.
57 The information is derived from the internal_getlogin call
58 when on a NT system. */
59 char *pname; /* user's name */
60 char *plogsrv; /* Logon server, may be FQDN */
61 char *pdomain; /* Logon domain of the user */
62 PSID psid; /* buffer for user's SID */
64 uid_t orig_uid; /* Remains intact even after impersonation */
65 uid_t orig_gid; /* Ditto */
66 uid_t real_uid; /* Remains intact on seteuid, replaced by setuid */
67 gid_t real_gid; /* Ditto */
69 /* token is needed if set(e)uid should be called. It can be set by a call
70 to `set_impersonation_token()'. */
74 cygheap_user () : pname (NULL), plogsrv (NULL), pdomain (NULL), psid (NULL) {}
77 void set_name (const char *new_name);
78 const char *name () const { return pname; }
80 void set_logsrv (const char *new_logsrv);
81 const char *logsrv () const { return plogsrv; }
83 void set_domain (const char *new_domain);
84 const char *domain () const { return pdomain; }
86 BOOL set_sid (PSID new_sid);
87 PSID sid () const { return psid; }
89 void operator =(cygheap_user &user)
91 set_name (user.name ());
92 set_logsrv (user.logsrv ());
93 set_domain (user.domain ());
94 set_sid (user.sid ());
98 /* cwd cache stuff. */
108 char *get (char *buf, int need_posix = 1, int with_chroot = 0, unsigned ulen = MAX_PATH);
111 void fixup_after_exec (char *win32, char *posix, DWORD hash);
113 void set (const char *win32_cwd, const char *posix_cwd = NULL);
118 _cmalloc_entry *chain;
128 #define CYGHEAPSIZE (sizeof (init_cygheap) + (4000 * sizeof (fhandler_union)) + (2 * 65536))
130 extern init_cygheap *cygheap;
131 extern void *cygheap_max;
134 void __stdcall cfree (void *) __attribute__ ((regparm(1)));
135 void __stdcall cygheap_fixup_in_child (HANDLE, bool);
136 void *__stdcall cmalloc (cygheap_types, DWORD) __attribute__ ((regparm(2)));
137 void *__stdcall crealloc (void *, DWORD) __attribute__ ((regparm(2)));
138 void *__stdcall ccalloc (cygheap_types, DWORD, DWORD) __attribute__ ((regparm(3)));
139 char *__stdcall cstrdup (const char *) __attribute__ ((regparm(1)));
140 char *__stdcall cstrdup1 (const char *) __attribute__ ((regparm(1)));
141 void __stdcall cygheap_init ();