From c5bbdc94037efa5050ad32454509bc1c366c288f Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Thu, 7 Jul 2016 12:27:37 -0400 Subject: Use environment variables rather than wired-in defaults in cryptech_rpcd. This change allows the RPC MUX daemon to use the same environment variable scheme to configure the RPC device and line speed as the stand-alone RPC client code does, the only difference being that the daemon, being an independent program, still allows one to override these settings from the command line. --- daemon.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/daemon.c b/daemon.c index f22ad45..b30d730 100644 --- a/daemon.c +++ b/daemon.c @@ -34,6 +34,7 @@ */ #include +#include #include #include #include @@ -143,8 +144,15 @@ int main(int argc, char *argv[]) int lsock; int dsock; int opt; - const char *device = HAL_CLIENT_SERIAL_DEFAULT_DEVICE; - uint32_t speed = HAL_CLIENT_SERIAL_DEFAULT_SPEED; + const char *device = getenv(HAL_CLIENT_SERIAL_DEVICE_ENVVAR); + const char *speed_ = getenv(HAL_CLIENT_SERIAL_SPEED_ENVVAR); + uint32_t speed = HAL_CLIENT_SERIAL_DEFAULT_SPEED; + + if (device == NULL) + device = HAL_CLIENT_SERIAL_DEFAULT_DEVICE; + + if (speed_ != NULL) + speed = (uint32_t) strtoul(speed_, NULL, 10); while ((opt = getopt(argc, argv, "hn:d:s:")) != -1) { switch (opt) { @@ -158,7 +166,8 @@ int main(int argc, char *argv[]) device = optarg; break; case 's': - switch (atoi(optarg)) { + speed = (uint32_t) strtoul(optarg, NULL, 10); + switch (speed) { case 115200: case 921600: break; -- cgit v1.2.3