Skip to content
Snippets Groups Projects
getenv.c 1.88 KiB
Newer Older
  • Learn to ignore specific revisions
  • Daniel Stenberg's avatar
    Daniel Stenberg committed
    /*****************************************************************************
     *                                  _   _ ____  _     
     *  Project                     ___| | | |  _ \| |    
     *                             / __| | | | |_) | |    
     *                            | (__| |_| |  _ <| |___ 
     *                             \___|\___/|_| \_\_____|
     *
     *  The contents of this file are subject to the Mozilla Public License
     *  Version 1.0 (the "License"); you may not use this file except in
     *  compliance with the License. You may obtain a copy of the License at
     *  http://www.mozilla.org/MPL/
     *
     *  Software distributed under the License is distributed on an "AS IS"
     *  basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
     *  License for the specific language governing rights and limitations
     *  under the License.
     *
     *  The Original Code is Curl.
     *
     *  The Initial Developer of the Original Code is Daniel Stenberg.
     *
     *  Portions created by the Initial Developer are Copyright (C) 1998.
     *  All Rights Reserved.
     *
     * ------------------------------------------------------------
     * Main author:
    
    Daniel Stenberg's avatar
    Daniel Stenberg committed
     * - Daniel Stenberg <daniel@haxx.se>
    
    Daniel Stenberg's avatar
    Daniel Stenberg committed
     *
    
    Daniel Stenberg's avatar
    Daniel Stenberg committed
     * 	http://curl.haxx.se
    
    Daniel Stenberg's avatar
    Daniel Stenberg committed
     *
     * $Source$
     * $Revision$
     * $Date$
     * $Author$
     * $State$
     * $Locker$
     *
     ****************************************************************************/
    
    #include <stdio.h>
    #include <stdlib.h>
    
    #include <string.h>
    
    Daniel Stenberg's avatar
    Daniel Stenberg committed
    
    #ifdef WIN32
    #include <windows.h>
    #endif
    
    
    #ifdef MALLOCDEBUG
    #include "memdebug.h"
    #endif
    
    
    Daniel Stenberg's avatar
    Daniel Stenberg committed
    char *GetEnv(char *variable)
    {
    #ifdef WIN32
      /* This shit requires windows.h (HUGE) to be included */
    
      char env[MAX_PATH]; /* MAX_PATH is from windef.h */
    
    Daniel Stenberg's avatar
    Daniel Stenberg committed
      char *temp = getenv(variable);
      env[0] = '\0';
      ExpandEnvironmentStrings(temp, env, sizeof(env));
    #else
      /* no length control */
      char *env = getenv(variable);
    #endif
    
      return env?strdup(env):NULL;
    
    Daniel Stenberg's avatar
    Daniel Stenberg committed
    }
    
    
    char *curl_getenv(char *v)
    
    Daniel Stenberg's avatar
    Daniel Stenberg committed
    {
      return GetEnv(v);
    }