aboutsummaryrefslogtreecommitdiffhomepage
path: root/env.h
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2014-07-13 17:30:48 -0700
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2014-07-13 17:30:48 -0700
commit7def1390204d8d73109a2725bf48b8f8c61c419a (patch)
tree3af1dffac67bef96bdd9bed76a612126ae35788c /env.h
parentb667eee35163951fd8de191cfcdcdfd47c064e60 (diff)
Turn the 'mode' parameter of environment variables into an enum
Diffstat (limited to 'env.h')
-rw-r--r--env.h66
1 files changed, 31 insertions, 35 deletions
diff --git a/env.h b/env.h
index 3fa64e91..7afa9b9c 100644
--- a/env.h
+++ b/env.h
@@ -11,37 +11,33 @@
#include "util.h"
#include "common.h"
-/**
- Flag for local (to the current block) variable
-*/
-#define ENV_LOCAL 1
-
-/**
- Flag for exported (to commands) variable
-*/
-#define ENV_EXPORT 2
-
-/**
- Flag for unexported variable
-*/
-#define ENV_UNEXPORT 16
-
-/**
- Flag for global variable
-*/
-#define ENV_GLOBAL 4
-
-/**
- Flag for variable update request from the user. All variable
- changes that are made directly by the user, such as those from the
- 'set' builtin must have this flag set.
-*/
-#define ENV_USER 8
-
-/**
- Flag for universal variable
-*/
-#define ENV_UNIVERSAL 32
+/* Flags that may be passed as the 'mode' in env_set / env_get_string */
+enum
+{
+ /* Default mode */
+ ENV_DEFAULT = 0,
+
+ /** Flag for local (to the current block) variable */
+ ENV_LOCAL = 1,
+
+ /** Flag for exported (to commands) variable */
+ ENV_EXPORT = 2,
+
+ /** Flag for unexported variable */
+ ENV_UNEXPORT = 16,
+
+ /** Flag for global variable */
+ ENV_GLOBAL = 4,
+
+ /** Flag for variable update request from the user. All variable
+ changes that are made directly by the user, such as those from the
+ 'set' builtin must have this flag set. */
+ ENV_USER = 8,
+
+ /** Flag for universal variable */
+ ENV_UNIVERSAL = 32
+};
+typedef uint32_t env_mode_flags_t;
/**
Error code for trying to alter read-only variable
@@ -87,7 +83,7 @@ void env_init(const struct config_paths_t *paths = NULL);
* ENV_INVALID, the variable name or mode was invalid
*/
-int env_set(const wcstring &key, const wchar_t *val, int mode);
+int env_set(const wcstring &key, const wchar_t *val, env_mode_flags_t mode);
/**
@@ -175,16 +171,16 @@ public:
\param key The name of the variable to get
\param mode An optional scope to search in. All scopes are searched if unset
*/
-env_var_t env_get_string(const wcstring &key, int mode = 0);
+env_var_t env_get_string(const wcstring &key, env_mode_flags_t mode = ENV_DEFAULT);
/**
Returns true if the specified key exists. This can't be reliably done
using env_get, since env_get returns null for 0-element arrays
\param key The name of the variable to remove
- \param mode the scope to search in. All scopes are searched if unset
+ \param mode the scope to search in. All scopes are searched if set to default
*/
-bool env_exist(const wchar_t *key, int mode);
+bool env_exist(const wchar_t *key, env_mode_flags_t mode);
/**
Remove environemnt variable