aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2023-01-05 18:17:07 +0100
committerPierre Ossman <ossman@cendio.se>2023-02-04 14:03:13 +0100
commitea6afa9b791e3782455a829f97515fa721edd522 (patch)
tree9272b75f3b91512800c67538bf160ead5bf65187
parentcee09051e685e952b948cafab2d4ccdb9ab11f07 (diff)
downloadtigervnc-ea6afa9b791e3782455a829f97515fa721edd522.tar.gz
tigervnc-ea6afa9b791e3782455a829f97515fa721edd522.zip
Avoid duplicating configuration setting
Let the string helpers call the more fancy setParam(). This makes sure we can avoid duplicating things.
-rw-r--r--common/rfb/Configuration.cxx23
1 files changed, 7 insertions, 16 deletions
diff --git a/common/rfb/Configuration.cxx b/common/rfb/Configuration.cxx
index 4b376168..629214e4 100644
--- a/common/rfb/Configuration.cxx
+++ b/common/rfb/Configuration.cxx
@@ -290,16 +290,15 @@ BoolParameter::setParam(const char* v) {
if (*v == 0 || strcasecmp(v, "1") == 0 || strcasecmp(v, "on") == 0
|| strcasecmp(v, "true") == 0 || strcasecmp(v, "yes") == 0)
- value = 1;
+ setParam(true);
else if (strcasecmp(v, "0") == 0 || strcasecmp(v, "off") == 0
|| strcasecmp(v, "false") == 0 || strcasecmp(v, "no") == 0)
- value = 0;
+ setParam(false);
else {
vlog.error("Bool parameter %s: invalid value '%s'", getName(), v);
return false;
}
- vlog.debug("set %s(Bool) to %s(%d)", getName(), v, value);
return true;
}
@@ -343,12 +342,7 @@ IntParameter::IntParameter(const char* name_, const char* desc_, int v,
bool
IntParameter::setParam(const char* v) {
if (immutable) return true;
- vlog.debug("set %s(Int) to %s", getName(), v);
- int i = strtol(v, NULL, 0);
- if (i < minValue || i > maxValue)
- return false;
- value = i;
- return true;
+ return setParam(strtol(v, NULL, 0));
}
bool
@@ -440,15 +434,12 @@ BinaryParameter::~BinaryParameter() {
}
bool BinaryParameter::setParam(const char* v) {
- LOCK_CONFIG;
if (immutable) return true;
- vlog.debug("set %s(Binary) to %s", getName(), v);
- delete [] value;
- length = 0;
- value = hexToBin(v, strlen(v));
- if (value == NULL)
+ uint8_t *newValue = hexToBin(v, strlen(v));
+ if (newValue == NULL)
return false;
- length = strlen(v)/2;
+ setParam(newValue, strlen(v)/2);
+ delete [] newValue;
return true;
}