File: env.C

package info (click to toggle)
librudiments0 0.27-3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 4,528 kB
  • ctags: 2,284
  • sloc: cpp: 14,657; sh: 7,547; ansic: 2,664; makefile: 945; xml: 15
file content (35 lines) | stat: -rw-r--r-- 824 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright (c) 2003  David Muse
// See the file COPYING for more information

#include <rudiments/environment.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>

int main(int argc, const char **argv) {

	environment	env;

	// print the environment variable "TEST"
	printf("TEST=%s\n",env.getValue("TEST"));

	// set the value of "TEST" to "value"
	if (env.setValue("TEST","value")) {
		printf("TEST=%s\n",env.getValue("TEST"));
	} else {
		printf("setValue() failed\n");
	}

	// set the value of "TEST" to "newvalue"
	if (env.setValue("TEST","newvalue")) {
		printf("TEST=%s\n",env.getValue("TEST"));
	} else {
		printf("setValue() failed\n");
	}

	// remove "TEST" from the environment
	env.remove("TEST");

	// print the (non-existent) environment variable "TEST"
	printf("TEST=%s\n",env.getValue("TEST"));
}