curl_getenv.md (1139B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: curl_getenv 5 Section: 3 6 Source: libcurl 7 See-also: 8 - getenv (3C) 9 Protocol: 10 - All 11 Added-in: 7.1 12 --- 13 14 # NAME 15 16 curl_getenv - return value for environment name 17 18 # SYNOPSIS 19 20 ~~~c 21 #include <curl/curl.h> 22 23 char *curl_getenv(const char *name); 24 ~~~ 25 26 # DESCRIPTION 27 28 curl_getenv() is a portable wrapper for the getenv() function, meant to 29 emulate its behavior and provide an identical interface for all operating 30 systems libcurl builds on (including Windows). 31 32 You must curl_free(3) the returned string when you are done with it. 33 34 # %PROTOCOLS% 35 36 # EXAMPLE 37 38 ~~~c 39 int main(void) 40 { 41 char *width = curl_getenv("COLUMNS"); 42 if(width) { 43 /* it was set */ 44 curl_free(width); 45 } 46 } 47 ~~~ 48 49 # %AVAILABILITY% 50 51 # RETURN VALUE 52 53 A pointer to a null-terminated string or NULL if it failed to find the 54 specified name. 55 56 # NOTE 57 58 Under Unix operating systems, there is no point in returning an allocated 59 memory, although other systems does not work properly if this is not done. The 60 Unix implementation thus suffers slightly from the drawbacks of other systems.