doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
getenv.c
Go to the documentation of this file.
1 /***************************************************************************
2  * _ _ ____ _
3  * Project ___| | | | _ \| |
4  * / __| | | | |_) | |
5  * | (__| |_| | _ <| |___
6  * \___|\___/|_| \_\_____|
7  *
8  * Copyright (C) 1998 - 2004, Daniel Stenberg, <daniel@haxx.se>, et al.
9  *
10  * This software is licensed as described in the file COPYING, which
11  * you should have received as part of this distribution. The terms
12  * are also available at http://curl.haxx.se/docs/copyright.html.
13  *
14  * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15  * copies of the Software, and permit persons to whom the Software is
16  * furnished to do so, under the terms of the COPYING file.
17  *
18  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19  * KIND, either express or implied.
20  *
21  * $Id: getenv.c,v 1.23 2004/01/29 13:56:45 bagder Exp $
22  ***************************************************************************/
23 
24 #include "setup.h"
25 
26 #include <stdio.h>
27 #include <stdlib.h>
28 #include <string.h>
29 
30 #ifdef WIN32
31 #include <windows.h>
32 #endif
33 
34 #ifdef VMS
35 #include <unixlib.h>
36 #endif
37 
38 #include <curl/curl.h>
39 
40 #ifdef CURLDEBUG
41 #include "memdebug.h"
42 #endif
43 
44 static
45 char *GetEnv(const char *variable)
46 {
47 #ifdef WIN32
48  /* This shit requires windows.h (HUGE) to be included */
49  char env[MAX_PATH]; /* MAX_PATH is from windef.h */
50  char *temp = getenv(variable);
51  env[0] = '\0';
52  if (temp != NULL)
53  ExpandEnvironmentStrings(temp, env, sizeof(env));
54 #else
55 #ifdef VMS
56  char *env = getenv(variable);
57  if (env && strcmp("HOME",variable) == 0) {
58  env = decc$translate_vms(env);
59  }
60 #else
61  /* no length control */
62  char *env = getenv(variable);
63 #endif
64 #endif
65  return (env && env[0])?strdup(env):NULL;
66 }
67 
68 char *curl_getenv(const char *v)
69 {
70  return GetEnv(v);
71 }
#define strcmp
Definition: Str.h:41
const GLdouble * v
Definition: glext.h:2936
#define NULL
Definition: Lib.h:88
char * curl_getenv(const char *v)
Definition: getenv.c:68
char * strdup(char *s1)
Definition: main.c:183