File: environment.C.html

package info (click to toggle)
rudiments 0.31-2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 7,516 kB
  • ctags: 3,248
  • sloc: asm: 23,776; cpp: 22,792; sh: 7,769; ansic: 1,769; makefile: 1,054; xml: 169; perl: 19
file content (55 lines) | stat: -rw-r--r-- 3,456 bytes parent folder | download | duplicates (2)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55







<pre>
<font color="#0000ff">// Copyright (c) 2003  David Muse</font>
<font color="#0000ff">// See the file COPYING for more information</font>

<font color="#a020f0">#include </font><font color="#ff00ff">&lt;rudiments/environment.h&gt;</font>
<font color="#a020f0">#include </font><font color="#ff00ff">&lt;stdio.h&gt;</font>

<font color="#a020f0">#ifdef RUDIMENTS_NAMESPACE</font>
<font color="#a52a2a"><b>using</b></font> <font color="#2e8b57"><b>namespace</b></font> rudiments;
<font color="#a020f0">#endif</font>

<font color="#2e8b57"><b>int</b></font> main(<font color="#2e8b57"><b>int</b></font> argc, <font color="#2e8b57"><b>const</b></font> <font color="#2e8b57"><b>char</b></font> **argv) {

        <font color="#0000ff">// print the environment variable &quot;TEST&quot;</font>
        printf(<font color="#ff00ff">&quot;TEST=</font><font color="#6a5acd">%s</font><font color="#6a5acd">\n</font><font color="#ff00ff">&quot;</font>,environment::getValue(<font color="#ff00ff">&quot;TEST&quot;</font>));

        <font color="#0000ff">// set the value of &quot;TEST&quot; to &quot;value&quot;</font>
        <font color="#a52a2a"><b>if</b></font> (environment::setValue(<font color="#ff00ff">&quot;TEST&quot;</font>,<font color="#ff00ff">&quot;value&quot;</font>)) {
                printf(<font color="#ff00ff">&quot;TEST=</font><font color="#6a5acd">%s</font><font color="#6a5acd">\n</font><font color="#ff00ff">&quot;</font>,environment::getValue(<font color="#ff00ff">&quot;TEST&quot;</font>));
        } <font color="#a52a2a"><b>else</b></font> {
                printf(<font color="#ff00ff">&quot;setValue() failed</font><font color="#6a5acd">\n</font><font color="#ff00ff">&quot;</font>);
        }

        <font color="#0000ff">// set the value of &quot;TEST&quot; to &quot;newvalue&quot;</font>
        <font color="#a52a2a"><b>if</b></font> (environment::setValue(<font color="#ff00ff">&quot;TEST&quot;</font>,<font color="#ff00ff">&quot;newvalue&quot;</font>)) {
                printf(<font color="#ff00ff">&quot;TEST=</font><font color="#6a5acd">%s</font><font color="#6a5acd">\n</font><font color="#ff00ff">&quot;</font>,environment::getValue(<font color="#ff00ff">&quot;TEST&quot;</font>));
        } <font color="#a52a2a"><b>else</b></font> {
                printf(<font color="#ff00ff">&quot;setValue() failed</font><font color="#6a5acd">\n</font><font color="#ff00ff">&quot;</font>);
        }

        <font color="#0000ff">// remove &quot;TEST&quot; from the environment</font>
        environment::remove(<font color="#ff00ff">&quot;TEST&quot;</font>);

        <font color="#0000ff">// print the (non-existent) environment variable &quot;TEST&quot;</font>
        printf(<font color="#ff00ff">&quot;TEST=</font><font color="#6a5acd">%s</font><font color="#6a5acd">\n</font><font color="#ff00ff">&quot;</font>,environment::getValue(<font color="#ff00ff">&quot;TEST&quot;</font>));

        printf(<font color="#ff00ff">&quot;</font><font color="#6a5acd">\n\n</font><font color="#ff00ff">&quot;</font>);
        environment::print();

        printf(<font color="#ff00ff">&quot;</font><font color="#6a5acd">\n\n</font><font color="#ff00ff">&quot;</font>);
        environment::clear();

        printf(<font color="#ff00ff">&quot;</font><font color="#6a5acd">\n\n</font><font color="#ff00ff">clear?</font><font color="#6a5acd">\n</font><font color="#ff00ff">&quot;</font>);
        environment::print();
}
</pre>