forked from dmoulding/editenv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
editenv.hpp
executable file
·127 lines (113 loc) · 4.64 KB
/
editenv.hpp
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
////////////////////////////////////////////////////////////////////////////////
//
// editenv - Environment Variable Editor Library Header File
// Copyright (c) 2009 Dan Moulding
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
// See COPYING.txt for the full terms of the GNU Lesser General Public License.
//
////////////////////////////////////////////////////////////////////////////////
#ifndef EDITENV_EDITENV_HPP
#define EDITENV_EDITENV_HPP
#ifdef EDITENV_BUILD
#define EDITENV_API __declspec(dllexport)
#else
#define EDITENV_API __declspec(dllimport)
#endif // EDITENV_BUILD
#include "editenvTypes.hpp"
#include "EnvVar.hpp"
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
// Removes all matching instances of the specified value from the named
// environment variable's value.
//
// scope [in] Environment scope (user environment or system environment).
//
// name [in] Name of the variable to edit.
//
// value [in] String to match against and cut from the variable.
//
// Return Value: Returns the number of matching instances within the variable's
// value that were cut.
EDITENV_API unsigned int envCut (editenv::env_scope scope,
char const *name,
char const *value);
// Appends the specified value to the name environment variable's value.
//
// scope [in] Environment scope (user environment or system environment).
//
// name [in] Name of the variable to edit.
//
// value [in] Value to paste to at the end of the variable's value.
//
// Return Value: Nothing.
EDITENV_API void envPaste (editenv::env_scope scope,
char const *name,
char const *value);
// Sets the named environment variable's value to the specified value. Creates
// the variable if it does not yet exist in the environment.
//
// scope [in] Environment scope (user environment or system environment).
//
// name [in] Name of the variable to set.
//
// value [in] Value to be assigned to the variable.
//
// Return Value: Nothing.
EDITENV_API void envSet (editenv::env_scope scope,
char const *name,
char const *value);
// Deletes the named environment variable.
//
// scope [in] Environment scope (user environment or system environment).
//
// name [in] Name of the variable to delete.
//
// Return Value: Nothing.
EDITENV_API void envUnset (editenv::env_scope scope, char const *name);
// Retrieves the value currently assigned to the named variable.
//
// scope [in] Environment scope (user environment or system environment).
//
// name [in] Name of the variable whose value to retrieve.
//
// Return Value: Returns a const string containing the variable's value.
EDITENV_API char const * envValue (editenv::env_scope scope, char const *name);
// Appends the specified path to the Path environment variable. Only adds to
// the Path environment variable if the specified path is not already in the
// Path environment variable (i.e. calling this function will not add duplicate
// entries to the Path environment variable).
//
// scope [in] Environment scope (user path or system path).
//
// path [in] Path to append to the Path environment variable.
//
// Return Value: Nothing.
EDITENV_API void pathAdd (editenv::env_scope, char const *path);
// Removes all matching instances of the specified path from the Path
// environment variable.
//
// scope [in] Environment scope (user path or system path).
//
// path [in] Path to remove from the Path environment variable.
//
// Return value: Returns the number of matching instances that were removed.
EDITENV_API unsigned int pathRemove (editenv::env_scope, char const *path);
#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
#endif // EDITENV_EDITENV_HPP