[Cryptech-Commits] [sw/libhal] 02/02: Use environment variables rather than wired-in defaults in cryptech_rpcd.
git at cryptech.is
git at cryptech.is
Thu Jul 7 17:05:52 UTC 2016
This is an automated email from the git hooks/post-receive script.
sra at hactrn.net pushed a commit to branch master
in repository sw/libhal.
commit c5bbdc94037efa5050ad32454509bc1c366c288f
Author: Rob Austein <sra at hactrn.net>
AuthorDate: Thu Jul 7 12:27:37 2016 -0400
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 <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/un.h>
@@ -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;
More information about the Commits
mailing list