Subversion Repositories Kolibri OS

Rev

Rev 4874 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4349 Serge 1
/*
2
FUNCTION
3
<>---look up environment variable
4
 
5
INDEX
6
	getenv
7
INDEX
8
	environ
9
 
10
ANSI_SYNOPSIS
11
	#include 
12
	char *getenv(const char *<[name]>);
13
 
14
TRAD_SYNOPSIS
15
	#include 
16
	char *getenv(<[name]>)
17
	char *<[name]>;
18
 
19
DESCRIPTION
20
<> searches the list of environment variable names and values
21
(using the global pointer ``<>'') for a variable whose
22
name matches the string at <[name]>.  If a variable name matches,
23
<> returns a pointer to the associated value.
24
 
25
RETURNS
26
A pointer to the (string) value of the environment variable, or
27
<> if there is no such environment variable.
28
 
29
PORTABILITY
30
<> is ANSI, but the rules for properly forming names of environment
31
variables vary from one system to another.
32
 
33
<> requires a global pointer <>.
34
*/
35
 
36
/*
37
 * Copyright (c) 1987, 2000 Regents of the University of California.
38
 * All rights reserved.
39
 *
40
 * Redistribution and use in source and binary forms are permitted
41
 * provided that: (1) source distributions retain this entire copyright
42
 * notice and comment, and (2) distributions including binaries display
43
 * the following acknowledgement:  ``This product includes software
44
 * developed by the University of California, Berkeley and its contributors''
45
 * in the documentation or other materials provided with the distribution
46
 * and in all advertising materials mentioning features or use of this
47
 * software. Neither the name of the University nor the names of its
48
 * contributors may be used to endorse or promote products derived
49
 * from this software without specific prior written permission.
50
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
51
 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
52
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
53
 */
54
 
55
#ifndef _REENT_ONLY
56
 
57
#include 
58
#include 
59
#include 
60
 
61
/*
62
 * _findenv --
63
 *	Returns pointer to value associated with name, if any, else NULL.
64
 *	Sets offset to be the offset of the name/value combination in the
65
 *	environmental array, for use by setenv(3) and unsetenv(3).
66
 *	Explicitly removes '=' in argument name.
67
 *
68
 *	This routine *should* be a static; don't use it.
69
 */
70
 
71
char *
72
_DEFUN (_findenv, (name, offset),
73
	register _CONST char *name _AND
74
	int *offset)
75
{
9959 turbocat 76
  return _findenv_r (_REENT, name, offset);
4349 Serge 77
}
78
 
79
/*
80
 * getenv --
81
 *	Returns ptr to value associated with name, if any, else NULL.
82
 */
83
 
84
char *
85
_DEFUN (getenv, (name),
86
	_CONST char *name)
87
{
88
  int offset;
9959 turbocat 89
  return _findenv_r (_REENT, name, &offset);
4349 Serge 90
}
91
 
92
#endif /* !_REENT_ONLY */