From d359dd9981f4137e8873a7a571e5c54c5b2449c4 Mon Sep 17 00:00:00 2001 From: Uros Majstorovic Date: Wed, 2 Feb 2022 08:14:56 +0100 Subject: linux and freebsd compatibility --- ecp/build.sh | 20 +++++++++++++------- ecp/src/platform/posix/transport.c | 1 + ecp/util/util.c | 11 ++++++----- 3 files changed, 20 insertions(+), 12 deletions(-) (limited to 'ecp') diff --git a/ecp/build.sh b/ecp/build.sh index acb1a14..d28c794 100755 --- a/ecp/build.sh +++ b/ecp/build.sh @@ -5,24 +5,30 @@ if [ -z $1 ]; then else ARG=$1 fi + + +if [ -z $MAKE ]; then + MAKE=make +fi + PLATFORM=posix cd src/ecp if [ "$ARG" != "clean" ]; then - make platform=$PLATFORM clean + $MAKE platform=$PLATFORM clean fi -make platform=$PLATFORM $ARG || exit +$MAKE platform=$PLATFORM $ARG || exit if [ "$ARG" == "all" ]; then - make platform=$PLATFORM install + $MAKE platform=$PLATFORM install fi cd ../../util if [ "$ARG" != "clean" ]; then - make platform=$PLATFORM clean + $MAKE platform=$PLATFORM clean fi -make platform=$PLATFORM $ARG || exit +$MAKE platform=$PLATFORM $ARG || exit cd ../test if [ "$ARG" != "clean" ]; then - make platform=$PLATFORM clean + $MAKE platform=$PLATFORM clean fi -make platform=$PLATFORM $ARG || exit +$MAKE platform=$PLATFORM $ARG || exit diff --git a/ecp/src/platform/posix/transport.c b/ecp/src/platform/posix/transport.c index 2032ce2..c41f0df 100644 --- a/ecp/src/platform/posix/transport.c +++ b/ecp/src/platform/posix/transport.c @@ -1,5 +1,6 @@ #include #include +#include #include #include #include diff --git a/ecp/util/util.c b/ecp/util/util.c index 4f4adc2..7ce8da5 100644 --- a/ecp/util/util.c +++ b/ecp/util/util.c @@ -1,6 +1,7 @@ #include #include #include +#include #include "core.h" #include "cr.h" @@ -9,7 +10,7 @@ int ecp_util_key_save(ECPContext *ctx, ECPDHKey *key, char *filename) { int fd; ssize_t rv; - + if ((fd = open(filename, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR)) < 0) return ECP_ERR; rv = write(fd, ecp_cr_dh_pub_get_buf(&key->public), ECP_ECDH_SIZE_KEY); if (rv != ECP_ECDH_SIZE_KEY) { @@ -29,7 +30,7 @@ int ecp_util_key_load(ECPContext *ctx, ECPDHKey *key, char *filename) { int fd; ssize_t rv; unsigned char buf[ECP_ECDH_SIZE_KEY]; - + if ((fd = open(filename, O_RDONLY)) < 0) return ECP_ERR; rv = read(fd, buf, ECP_ECDH_SIZE_KEY); if (rv != ECP_ECDH_SIZE_KEY) { @@ -44,7 +45,7 @@ int ecp_util_key_load(ECPContext *ctx, ECPDHKey *key, char *filename) { close(fd); ecp_cr_dh_pub_from_buf(&key->public, buf); - + key->valid = 1; return ECP_OK; } @@ -52,7 +53,7 @@ int ecp_util_key_load(ECPContext *ctx, ECPDHKey *key, char *filename) { int ecp_util_node_save(ECPContext *ctx, ECPNode *node, char *filename) { int fd; ssize_t rv; - + if ((fd = open(filename, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR)) < 0) return ECP_ERR; rv = write(fd, ecp_cr_dh_pub_get_buf(&node->public), ECP_ECDH_SIZE_KEY); if (rv != ECP_ECDH_SIZE_KEY) { @@ -72,7 +73,7 @@ int ecp_util_node_load(ECPContext *ctx, ECPNode *node, char *filename) { int fd; ssize_t rv; unsigned char buf[ECP_ECDH_SIZE_KEY]; - + if ((fd = open(filename, O_RDONLY)) < 0) return ECP_ERR; rv = read(fd, buf, ECP_ECDH_SIZE_KEY); if (rv != ECP_ECDH_SIZE_KEY) { -- cgit v1.2.3