libc/winsup/cygwin/environ.h

53 lines
1.9 KiB
C
Raw Normal View History

/* environ.h: Declarations for environ manipulation
Copyright 2000, 2001, 2002, 2003, 2005, 2006 Red Hat, Inc.
This file is part of Cygwin.
This software is a copyrighted work licensed under the terms of the
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
/* Initialize the environment */
void environ_init (char **, int)
__attribute__ ((regparm (2)));
/* The structure below is used to control conversion to/from posix-style
* cygheap.cc (cygheap_user::set_name): Set homedrive and homepath to NULL on user name change. (cygheap_user::set_logsrv): Allocate enough space for leading \\ so that we can put this in the environment, if needed. * cygheap.h (homebodies): New enum. (cygheap_user::homedrive): New field. (cygheap_user::homepath): Ditto. (cygheap_user::env_logsrv): New method. (cygheap_user::env_homepath): New method. (cygheap_user::env_homedrive): New method. (cygheap_user::env_userprofile): New method. (cygheap_user::ontherange): New method. * environ.cc (envsize): Eliminate debugging argument. (environ_init): Assume that envc counts number of elments not total size. (spenv): New class. (spenvs): New array, renamed from forced_winenv_vars, using spenv. (spenv::retrieve): New method. (build_env): Rename from 'winenv' -- one stop shopping for building new environment blocks for both windows and "unix". * environ.h (build_env: Declare. (winenv): Delete declaration. (envsize): Ditto. * spawn.cc (spawn_guts): Use build_env to build windows and cygwin environment blocks. * uinfo.cc (internal_getlogin): Eliminate environment manipulation. Default to info from GetUserName if it exists. Move HOMEPATH and HOMEDRIVE stuff elsewhere. Move HOME setting elsewhere. Only set HOME environment variable in processes that are not parented by a cygwin process. (cygheap_user::ontherange): Define new method. (cygheap_user::env_logsrv): Ditto. (cygheap_user::env_homepath): Ditto. (cygheap_user::env_homedrive): Ditto. (cygheap_user::env_userprofile): Ditto.
2002-06-12 07:13:54 +02:00
file specs. Currently, only PATH and HOME are converted, but PATH
needs to use a "convert path list" function while HOME needs a simple
"convert to posix/win32". For the simple case, where a calculated length
is required, just return CYG_MAX_PATH. *FIXME* */
struct win_env
{
const char *name;
size_t namelen;
char *posix;
char *native;
int (*toposix) (const char *, char *);
int (*towin32) (const char *, char *);
int (*posix_len) (const char *);
int (*win32_len) (const char *);
bool immediate;
void add_cache (const char *in_posix, const char *in_native = NULL)
__attribute__ ((regparm (3)));
const char * get_native () const {return native ? native + namelen : NULL;}
const char * get_posix () const {return posix ? posix : NULL;}
struct win_env& operator = (struct win_env& x);
void reset () {native = posix = NULL;}
~win_env ();
};
win_env * __stdcall getwinenv (const char *name, const char *posix = NULL, win_env * = NULL)
__attribute__ ((regparm (3)));
char * __stdcall getwinenveq (const char *name, size_t len, int)
__attribute__ ((regparm (3)));
void __stdcall update_envptrs ();
extern char **__cygwin_environ, ***main_environ;
extern "C" char __stdcall **cur_environ ();
* Makefile.in (DLL_OFILES): Add tls_pbuf.o. * autoload.cc (CreateDesktopW): Replace CreateDesktopA. (CreateWindowStationW): Replace CreateWindowStationA. (GetUserObjectInformationW): Replace GetUserObjectInformationA. * cygheap.h (cwdstuff::get): Assume default buffer size NT_MAX_PATH. * cygtls.cc (_cygtls::remove): Free temporary TLS path buffers. * cygtls.h (TP_NUM_C_BUFS): Define. (TP_NUM_W_BUFS): Define. (class tls_pathbuf): New class to store pointers to thread local temporary path buffers. (_local_storage::pathbufs): New member. * environ.cc (win_env::add_cache): Use temporary TLS path buffer instead of stack based buffer. (posify): Get temporary outenv buffer from calling function. (environ_init): Create temporary TLS path buffer for posify. (build_env): Create Windows environment block as WCHAR buffer. * environ.h (build_env): Change declaration accordingly. * external.cc (sync_winenv): Accommodate build_env change. * fhandler_console.cc (fhandler_console::need_invisible): Use GetUserObjectInformationW and CreateWindowStationW. * fhandler_process.cc (format_process_maps): Use temporary TLS path buffer instead of stack based buffer. * fork.cc (frok::parent): Convert to use CreateProcessW. * path.cc: Throughout use temporary TLS path buffers instead of stack based buffer. Replace checks for CYG_MAX_PATH by checks for NT_MAX_PATH. (getfileattr): New function to replace GetFileAttributesA. (normalize_win32_path): Remove Win32 and NT long path prefixes. (getwd): Assume PATH_MAX + 1 buffer per SUSv3. * path.h (class path_conv): Set path buffer to size NT_MAX_PATH. (iswdrive): Define. * pinfo.cc (commune_process): Use temporary TLS path buffer instead of stack based buffer. * registry.cc (get_registry_hive_path): Ditto. (load_registry_hive): Ditto. * spawn.cc (spawn_guts): Convert to use CreateProcessW and CreateProcessAsUserW. (av::fixup): Open/close file using NtOpenFile/NtClose. * syscalls.cc (mknod_worker): Allow PATH_MAX file name. (mknod32): Ditto. (getusershell): Ditto. * tls_pbuf.cc: New file implementing tls_pathbuf and tmp_pathbuf methods. * tls_pbuf.h: New header for files using tmp_pathbuf. * tlsoffsets.h: Regenerate. * winsup.h (NT_MAX_PATH): Define as 32767 to avoid USHORT overflow.
2008-03-07 12:24:51 +01:00
char ** __stdcall build_env (const char * const *envp, PWCHAR &envblock,
int &envc, bool need_envblock)
__attribute__ ((regparm (3)));
#define ENV_CVT -1