summaryrefslogtreecommitdiff
path: root/src/gdbmtool.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/gdbmtool.h')
-rw-r--r--src/gdbmtool.h27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/gdbmtool.h b/src/gdbmtool.h
index 5486ac4..f589537 100644
--- a/src/gdbmtool.h
+++ b/src/gdbmtool.h
@@ -345,14 +345,18 @@ extern struct dsegm *dsdef[];
#define VART_BOOL 1
#define VART_INT 2
-#define VAR_OK 0 /* operation succeeded */
-#define VAR_ERR_NOTSET 1 /* Only for variable_get:
- variable is not set */
-#define VAR_ERR_NOTDEF 2 /* no such variable */
-#define VAR_ERR_BADTYPE 3 /* variable cannot be coerced to the
- requested type (software error) */
-#define VAR_ERR_BADVALUE 4 /* Only for variable_set: the value is
- not valid for this variable. */
+enum
+ {
+ VAR_OK, /* operation succeeded */
+ VAR_ERR_NOTSET, /* Only for variable_get: variable is not set */
+ VAR_ERR_NOTDEF, /* no such variable */
+ VAR_ERR_BADTYPE, /* variable cannot be coerced to the requested type
+ (software error) */
+ VAR_ERR_BADVALUE, /* Only for variable_set: the value is not valid for
+ this variable. */
+ VAR_ERR_GDBM, /* GDBM error */
+ };
+
int variable_set (const char *name, int type, void *val);
int variable_get (const char *name, int type, void **val);
@@ -361,9 +365,14 @@ int variable_is_set (const char *name);
int variable_is_true (const char *name);
void variable_print_all (FILE *fp);
static inline int
+variable_has_errno (char *varname, int e)
+{
+ return variable_get (varname, VART_INT, (void**)&e) == VAR_OK && e == 1;
+}
+static inline int
gdbm_error_is_masked (int e)
{
- return variable_get ("errormask", VART_INT, (void**)&e) == VAR_OK && e == 1;
+ return variable_has_errno ("errormask", e);
}
int unescape (int c);