~ubuntu-branches/ubuntu/breezy/tcp-wrappers/breezy

« back to all changes in this revision

Viewing changes to setenv.c

  • Committer: Bazaar Package Importer
  • Author(s): Marco d'Itri
  • Date: 2005-03-12 01:00:14 UTC
  • mfrom: (2.1.2 hoary)
  • Revision ID: james.westby@ubuntu.com-20050312010014-yi8bx76ovmnl4nmm
Tags: 7.6.dbs-8
Fixed postinst to source /usr/share/debconf/confmodule at top level, or
$@ will be reset when it re-executes $0. (Closes: #299129) 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 /*
2
 
  * Some systems do not have setenv(). This one is modeled after 4.4 BSD, but
3
 
  * is implemented in terms of portable primitives only: getenv(), putenv()
4
 
  * and malloc(). It should therefore be safe to use on every UNIX system.
5
 
  * 
6
 
  * If clobber == 0, do not overwrite an existing variable.
7
 
  * 
8
 
  * Returns nonzero if memory allocation fails.
9
 
  * 
10
 
  * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
11
 
  */
12
 
 
13
 
#ifndef lint
14
 
static char sccsid[] = "@(#) setenv.c 1.1 93/03/07 22:47:58";
15
 
#endif
16
 
 
17
 
/* setenv - update or insert environment (name,value) pair */
18
 
 
19
 
int     setenv(name, value, clobber)
20
 
char   *name;
21
 
char   *value;
22
 
int     clobber;
23
 
{
24
 
    char   *malloc();
25
 
    char   *getenv();
26
 
    char   *cp;
27
 
 
28
 
    if (clobber == 0 && getenv(name) != 0)
29
 
        return (0);
30
 
    if ((cp = malloc(strlen(name) + strlen(value) + 2)) == 0)
31
 
        return (1);
32
 
    sprintf(cp, "%s=%s", name, value);
33
 
    return (putenv(cp));
34
 
}