From 6b770ad8109b434c733702600d91f21bdf6870b0 Mon Sep 17 00:00:00 2001 From: joan2937 Date: Wed, 27 Nov 2019 21:25:35 +0000 Subject: [PATCH] V71+: #268 obey host name setting with env vars --- pigpio.h | 4 ++-- pigpiod_if2.c | 50 +++++++++++++++++++++----------------------------- 2 files changed, 23 insertions(+), 31 deletions(-) diff --git a/pigpio.h b/pigpio.h index 7d8df6a..0010fd8 100644 --- a/pigpio.h +++ b/pigpio.h @@ -30,7 +30,7 @@ For more information, please refer to #include #include -#define PIGPIO_VERSION 7103 +#define PIGPIO_VERSION 7104 /*TEXT @@ -6491,7 +6491,7 @@ after this command is issued. #define PI_DEFAULT_DMA_NOT_SET 15 #define PI_DEFAULT_SOCKET_PORT 8888 #define PI_DEFAULT_SOCKET_PORT_STR "8888" -#define PI_DEFAULT_SOCKET_ADDR_STR "127.0.0.1" +#define PI_DEFAULT_SOCKET_ADDR_STR "localhost" #define PI_DEFAULT_UPDATE_MASK_UNKNOWN 0x0000000FFFFFFCLL #define PI_DEFAULT_UPDATE_MASK_B1 0x03E7CF93 #define PI_DEFAULT_UPDATE_MASK_A_B2 0xFBC7CF9C diff --git a/pigpiod_if2.c b/pigpiod_if2.c index 6854d65..36f01aa 100644 --- a/pigpiod_if2.c +++ b/pigpiod_if2.c @@ -234,33 +234,10 @@ static int pigpio_command_ext return cmd.res; } -static int pigpioOpenSocket(char *addr, char *port) +static int pigpioOpenSocket(char *addrStr, char *portStr) { int sock, err, opt; struct addrinfo hints, *res, *rp; - const char *addrStr, *portStr; - - if (!addr) - { - addrStr = getenv(PI_ENVADDR); - - if ((!addrStr) || (!strlen(addrStr))) - { - addrStr = PI_DEFAULT_SOCKET_ADDR_STR; - } - } - else addrStr = addr; - - if (!port) - { - portStr = getenv(PI_ENVPORT); - - if ((!portStr) || (!strlen(portStr))) - { - portStr = PI_DEFAULT_SOCKET_PORT_STR; - } - } - else portStr = port; memset (&hints, 0, sizeof (hints)); @@ -713,11 +690,6 @@ int pigpio_start(char *addrStr, char *portStr) int pi; int *userdata; - if ((!addrStr) || (strlen(addrStr) == 0)) - { - addrStr = "localhost"; - } - for (pi=0; pi