47dc3dec0a
(win_env::operator = ): Declare new operator. (win_env::reset): Declare new function. (win_env::~win_env): Declare new destructor. (getwinenv): Add optional third argument to declaration. * environ.cc (conv_envvars): Accommodate immediate field. (win_env::operator =): Define new operator. (win_env::~win_env): Define new destructor. (win_env::add_cache): Add value to environment immediately if "immediate" is set. (getwinenv): Accept optional third argument which will be used to store "cached" values to avoid overwriting real cache. (spenv::force): Declare new field. (spenvs): Accommodate force field. Add "PATH=" with force set to true. (spenv::retrieve): Avoid duping anything if we're not building an envblock. (build_env): Ditto. Use size of potentially constructed new environment block to determine if we need to create an environment block. Pass getwinenv temporary storage to avoid inappropriately overwriting the environment cache.
51 lines
1.8 KiB
C
51 lines
1.8 KiB
C
/* environ.h: Declarations for environ manipulation
|
|
|
|
Copyright 2000, 2001, 2002 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
|
|
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 ();
|
|
char ** __stdcall build_env (const char * const *envp, char *&envblock,
|
|
int &envc, bool need_envblock)
|
|
__attribute__ ((regparm (3)));
|