curl/lib/getenv.c

70 lines
1.8 KiB
C
Raw Normal View History

2002-09-03 13:52:59 +02:00
/***************************************************************************
1999-12-29 15:20:26 +01:00
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2003, Daniel Stenberg, <daniel@haxx.se>, et al.
1999-12-29 15:20:26 +01:00
*
2002-09-03 13:52:59 +02:00
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://curl.haxx.se/docs/copyright.html.
*
2001-01-03 10:29:33 +01:00
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
2002-09-03 13:52:59 +02:00
* furnished to do so, under the terms of the COPYING file.
1999-12-29 15:20:26 +01:00
*
2001-01-03 10:29:33 +01:00
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
1999-12-29 15:20:26 +01:00
*
2001-01-03 10:29:33 +01:00
* $Id$
2002-09-03 13:52:59 +02:00
***************************************************************************/
1999-12-29 15:20:26 +01:00
2001-11-12 11:19:36 +01:00
#include "setup.h"
1999-12-29 15:20:26 +01:00
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
1999-12-29 15:20:26 +01:00
#ifdef WIN32
#include <windows.h>
#endif
2001-08-06 14:19:26 +02:00
#ifdef VMS
#include <unixlib.h>
#endif
#ifdef CURLDEBUG
2000-10-09 13:12:34 +02:00
#include "memdebug.h"
#endif
static
2001-08-14 10:25:47 +02:00
char *GetEnv(const char *variable)
1999-12-29 15:20:26 +01:00
{
#ifdef WIN32
/* This shit requires windows.h (HUGE) to be included */
char env[MAX_PATH]; /* MAX_PATH is from windef.h */
1999-12-29 15:20:26 +01:00
char *temp = getenv(variable);
env[0] = '\0';
2001-01-24 10:01:32 +01:00
if (temp != NULL)
ExpandEnvironmentStrings(temp, env, sizeof(env));
2001-08-06 14:19:26 +02:00
#else
#ifdef VMS
char *env = getenv(variable);
if (env && strcmp("HOME",variable) == 0) {
env = decc$translate_vms(env);
}
1999-12-29 15:20:26 +01:00
#else
/* no length control */
char *env = getenv(variable);
2001-08-06 14:19:26 +02:00
#endif
1999-12-29 15:20:26 +01:00
#endif
2001-01-24 10:01:32 +01:00
return (env && env[0])?strdup(env):NULL;
1999-12-29 15:20:26 +01:00
}
2001-08-14 10:25:47 +02:00
char *curl_getenv(const char *v)
1999-12-29 15:20:26 +01:00
{
return GetEnv(v);
}