mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
common: Add function gnupg_getcwd.
* tools/gpg-connect-agent.c (gnu_getcwd): Move to ... * common/sysutils.c (gnupg_getcwd): .. here. * tools/gpg-connect-agent.c (get_var_ext): Use gnupg_getcwd.
This commit is contained in:
parent
ffa39be5eb
commit
1a87edab66
3 changed files with 32 additions and 25 deletions
|
@ -212,30 +212,6 @@ my_strusage( int level )
|
|||
}
|
||||
|
||||
|
||||
static char *
|
||||
gnu_getcwd (void)
|
||||
{
|
||||
char *buffer;
|
||||
size_t size = 100;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
buffer = xmalloc (size+1);
|
||||
#ifdef HAVE_W32CE_SYSTEM
|
||||
strcpy (buffer, "/");
|
||||
return buffer;
|
||||
#else
|
||||
if (getcwd (buffer, size) == buffer)
|
||||
return buffer;
|
||||
xfree (buffer);
|
||||
if (errno != ERANGE)
|
||||
return NULL;
|
||||
size *= 2;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Unescape STRING and returned the malloced result. The surrounding
|
||||
quotes must already be removed from STRING. */
|
||||
static char *
|
||||
|
@ -568,7 +544,7 @@ get_var_ext (const char *name)
|
|||
s++;
|
||||
if (!strcmp (s, "cwd"))
|
||||
{
|
||||
result = gnu_getcwd ();
|
||||
result = gnupg_getcwd ();
|
||||
if (!result)
|
||||
log_error ("getcwd failed: %s\n", strerror (errno));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue