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