From ecece62828fa0d9a5629fb0e5b0025c20e1f5b18 Mon Sep 17 00:00:00 2001 From: Daniele Forsi IU5HKX Date: Sat, 2 Aug 2025 18:13:31 +0200 Subject: [PATCH] Refactor to remove code duplication of openPort() The code wasn't indented in simic7300.c and simic7700.c but it was identical. --- simulators/sim.h | 42 +++++++++++++++++++++++++++++++++++++- simulators/simatd578.c | 39 +---------------------------------- simulators/simeasycomm.c | 39 +---------------------------------- simulators/simelecraft.c | 38 ---------------------------------- simulators/simelecraftk4.c | 38 ---------------------------------- simulators/simft1000.c | 39 +---------------------------------- simulators/simft450.c | 39 +---------------------------------- simulators/simft710.c | 39 +---------------------------------- simulators/simft736.c | 39 +---------------------------------- simulators/simft747gx.c | 39 +---------------------------------- simulators/simft817.c | 39 +---------------------------------- simulators/simft818.c | 39 +---------------------------------- simulators/simft847.c | 39 +---------------------------------- simulators/simft897.c | 39 +---------------------------------- simulators/simft990.c | 39 +---------------------------------- simulators/simft991.c | 39 +---------------------------------- simulators/simftdx101.c | 39 +---------------------------------- simulators/simftdx1200.c | 39 +---------------------------------- simulators/simftdx3000.c | 39 +---------------------------------- simulators/simftdx5000.c | 39 +---------------------------------- simulators/simic2730.c | 39 +---------------------------------- simulators/simic275.c | 39 +---------------------------------- simulators/simic7000.c | 39 +---------------------------------- simulators/simic705.c | 39 +---------------------------------- simulators/simic7100.c | 39 +---------------------------------- simulators/simic7200.c | 39 +---------------------------------- simulators/simic7300.c | 39 +---------------------------------- simulators/simic7600.c | 39 +---------------------------------- simulators/simic7610.c | 39 +---------------------------------- simulators/simic7700.c | 39 +---------------------------------- simulators/simic7851.c | 39 +---------------------------------- simulators/simic905.c | 39 ----------------------------------- simulators/simic910.c | 38 ---------------------------------- simulators/simic9100.c | 38 ---------------------------------- simulators/simic9700.c | 38 ---------------------------------- simulators/simicgeneric.c | 38 ---------------------------------- simulators/simicr8600.c | 38 ---------------------------------- simulators/simid5100.c | 39 +---------------------------------- simulators/simjupiter.c | 39 +---------------------------------- simulators/simkenwood.c | 39 +---------------------------------- simulators/simmicom.c | 39 +---------------------------------- simulators/simorion.c | 39 +---------------------------------- simulators/simpmr171.c | 39 +---------------------------------- simulators/simpowersdr.c | 39 +---------------------------------- simulators/simqrplabs.c | 39 +---------------------------------- simulators/simrotorez.c | 39 +---------------------------------- simulators/simspid.c | 39 +---------------------------------- simulators/simtmd700.c | 39 +---------------------------------- simulators/simtmd710.c | 39 +---------------------------------- simulators/simtrusdx.c | 40 +----------------------------------- simulators/simts450.c | 40 +----------------------------------- simulators/simts590.c | 38 ---------------------------------- simulators/simts890.c | 39 +---------------------------------- simulators/simts950.c | 39 +---------------------------------- simulators/simts990.c | 39 +---------------------------------- simulators/simxiegug90.c | 39 +---------------------------------- simulators/simxiegux108g.c | 39 +---------------------------------- simulators/simxiegux6100.c | 39 +---------------------------------- simulators/simyaesu.c | 39 +---------------------------------- 59 files changed, 90 insertions(+), 2208 deletions(-) diff --git a/simulators/sim.h b/simulators/sim.h index fda16b2e7..d1829d49e 100644 --- a/simulators/sim.h +++ b/simulators/sim.h @@ -1,5 +1,7 @@ -#include "../src/misc.h" #include +#include + +#include "../src/misc.h" #define WRITE(f,b,l) write_sim(f,(const unsigned char*)b,l,__func__,__LINE__) @@ -18,3 +20,41 @@ int write_sim(int fd, const unsigned char *buf, int buflen, const char *func, return n; } + +#if defined(WIN32) || defined(_WIN32) +int openPort(char *comport) // doesn't matter for using pts devices +{ + int fd; + fd = open(comport, O_RDWR); + + if (fd < 0) + { + perror(comport); + } + + return fd; +} + +#else +int openPort(char *comport) // doesn't matter for using pts devices +{ + int fd = posix_openpt(O_RDWR); + char *name = ptsname(fd); + + if (name == NULL) + { + perror("ptsname"); + return -1; + } + + printf("name=%s\n", name); + + if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) + { + perror("posix_openpt"); + return -1; + } + + return fd; +} +#endif diff --git a/simulators/simatd578.c b/simulators/simatd578.c index 977ed5652..d58689056 100644 --- a/simulators/simatd578.c +++ b/simulators/simatd578.c @@ -57,44 +57,7 @@ getmyline(int fd, unsigned char *buf) return n; } -#if defined(WIN32) || defined(_WIN32) -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd; - fd = open(comport, O_RDWR); - - if (fd < 0) - { - perror(comport); - } - - return fd; -} - -#else -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd = posix_openpt(O_RDWR); - char *name = ptsname(fd); - - if (name == NULL) - { - perror("ptsname"); - return -1; - } - - printf("name=%s\n", name); - - if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) - { - perror("posix_openpt"); - return -1; - } - - return fd; -} -#endif - +#include "sim.h" int main(int argc, char *argv[]) diff --git a/simulators/simeasycomm.c b/simulators/simeasycomm.c index 6935c3b13..76e0252c9 100644 --- a/simulators/simeasycomm.c +++ b/simulators/simeasycomm.c @@ -46,44 +46,7 @@ getmyline(int fd, char *buf) return n; } -#if defined(WIN32) || defined(_WIN32) -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd; - fd = open(comport, O_RDWR); - - if (fd < 0) - { - perror(comport); - } - - return fd; -} - -#else -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd = posix_openpt(O_RDWR); - char *name = ptsname(fd); - - if (name == NULL) - { - perror("ptsname"); - return -1; - } - - printf("name=%s\n", name); - - if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) - { - perror("posix_openpt"); - return -1; - } - - return fd; -} -#endif - +#include "sim.h" int thread_args[2]; diff --git a/simulators/simelecraft.c b/simulators/simelecraft.c index c68081891..9d08c55a8 100644 --- a/simulators/simelecraft.c +++ b/simulators/simelecraft.c @@ -59,44 +59,6 @@ getmyline(int fd, char *buf) return strlen(buf); } -#if defined(WIN32) || defined(_WIN32) -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd; - fd = open(comport, O_RDWR); - - if (fd < 0) - { - perror(comport); - } - - return fd; -} - -#else -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd = posix_openpt(O_RDWR); - char *name = ptsname(fd); - - if (name == NULL) - { - perror("ptsname"); - return -1; - } - - printf("name=%s\n", name); - - if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) - { - perror("posix_openpt"); - return -1; - } - - return fd; -} -#endif - int main(int argc, char *argv[]) diff --git a/simulators/simelecraftk4.c b/simulators/simelecraftk4.c index 0acac4449..372a48105 100644 --- a/simulators/simelecraftk4.c +++ b/simulators/simelecraftk4.c @@ -60,44 +60,6 @@ getmyline(int fd, char *buf) return strlen(buf); } -#if defined(WIN32) || defined(_WIN32) -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd; - fd = open(comport, O_RDWR); - - if (fd < 0) - { - perror(comport); - } - - return fd; -} - -#else -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd = posix_openpt(O_RDWR); - char *name = ptsname(fd); - - if (name == NULL) - { - perror("ptsname"); - return -1; - } - - printf("name=%s\n", name); - - if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) - { - perror("posix_openpt"); - return -1; - } - - return fd; -} -#endif - int main(int argc, char *argv[]) diff --git a/simulators/simft1000.c b/simulators/simft1000.c index 1cd178963..5ff83f673 100644 --- a/simulators/simft1000.c +++ b/simulators/simft1000.c @@ -44,44 +44,7 @@ getmyline(int fd, unsigned char *buf) return n; } -#if defined(WIN32) || defined(_WIN32) -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd; - fd = open(comport, O_RDWR); - - if (fd < 0) - { - perror(comport); - } - - return fd; -} - -#else -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd = posix_openpt(O_RDWR); - char *name = ptsname(fd); - - if (name == NULL) - { - perror("ptsname"); - return -1; - } - - printf("name=%s\n", name); - - if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) - { - perror("posix_openpt"); - return -1; - } - - return fd; -} -#endif - +#include "sim.h" int main(int argc, char *argv[]) diff --git a/simulators/simft450.c b/simulators/simft450.c index abee8b1c9..d53245af6 100644 --- a/simulators/simft450.c +++ b/simulators/simft450.c @@ -92,44 +92,7 @@ getmyline(int fd, char *buf) return strlen(buf); } -#if defined(WIN32) || defined(_WIN32) -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd; - fd = open(comport, O_RDWR); - - if (fd < 0) - { - perror(comport); - } - - return fd; -} - -#else -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd = posix_openpt(O_RDWR); - char *name = ptsname(fd); - - if (name == NULL) - { - perror("ptsname"); - return -1; - } - - printf("name=%s\n", name); - - if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) - { - perror("posix_openpt"); - return -1; - } - - return fd; -} -#endif - +#include "sim.h" int main(int argc, char *argv[]) diff --git a/simulators/simft710.c b/simulators/simft710.c index eeb80727c..c3b59ad77 100644 --- a/simulators/simft710.c +++ b/simulators/simft710.c @@ -94,44 +94,7 @@ getmyline(int fd, char *buf) return strlen(buf); } -#if defined(WIN32) || defined(_WIN32) -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd; - fd = open(comport, O_RDWR); - - if (fd < 0) - { - perror(comport); - } - - return fd; -} - -#else -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd = posix_openpt(O_RDWR); - char *name = ptsname(fd); - - if (name == NULL) - { - perror("ptsname"); - return -1; - } - - printf("name=%s\n", name); - - if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) - { - perror("posix_openpt"); - return -1; - } - - return fd; -} -#endif - +#include "sim.h" int main(int argc, char *argv[]) diff --git a/simulators/simft736.c b/simulators/simft736.c index bd6b3d2ad..b7c3268f6 100644 --- a/simulators/simft736.c +++ b/simulators/simft736.c @@ -44,44 +44,7 @@ getmyline(int fd, unsigned char *buf) return n; } -#if defined(WIN32) || defined(_WIN32) -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd; - fd = open(comport, O_RDWR); - - if (fd < 0) - { - perror(comport); - } - - return fd; -} - -#else -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd = posix_openpt(O_RDWR); - char *name = ptsname(fd); - - if (name == NULL) - { - perror("ptsname"); - return -1; - } - - printf("name=%s\n", name); - - if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) - { - perror("posix_openpt"); - return -1; - } - - return fd; -} -#endif - +#include "sim.h" int main(int argc, char *argv[]) diff --git a/simulators/simft747gx.c b/simulators/simft747gx.c index b996c92bb..43cccfe34 100644 --- a/simulators/simft747gx.c +++ b/simulators/simft747gx.c @@ -45,44 +45,7 @@ getmyline(int fd, unsigned char *buf) return n; } -#if defined(WIN32) || defined(_WIN32) -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd; - fd = open(comport, O_RDWR); - - if (fd < 0) - { - perror(comport); - } - - return fd; -} - -#else -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd = posix_openpt(O_RDWR); - char *name = ptsname(fd); - - if (name == NULL) - { - perror("ptsname"); - return -1; - } - - printf("name=%s\n", name); - - if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) - { - perror("posix_openpt"); - return -1; - } - - return fd; -} -#endif - +#include "sim.h" int main(int argc, char *argv[]) diff --git a/simulators/simft817.c b/simulators/simft817.c index 8352ccc64..84b4c5671 100644 --- a/simulators/simft817.c +++ b/simulators/simft817.c @@ -45,44 +45,7 @@ getmyline(int fd, unsigned char *buf) return n; } -#if defined(WIN32) || defined(_WIN32) -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd; - fd = open(comport, O_RDWR); - - if (fd < 0) - { - perror(comport); - } - - return fd; -} - -#else -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd = posix_openpt(O_RDWR); - char *name = ptsname(fd); - - if (name == NULL) - { - perror("ptsname"); - return -1; - } - - printf("name=%s\n", name); - - if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) - { - perror("posix_openpt"); - return -1; - } - - return fd; -} -#endif - +#include "sim.h" int main(int argc, char *argv[]) diff --git a/simulators/simft818.c b/simulators/simft818.c index 93fd37cc5..e0fe6762b 100644 --- a/simulators/simft818.c +++ b/simulators/simft818.c @@ -68,44 +68,7 @@ getmyline(int fd, char *buf) return strlen(buf); } -#if defined(WIN32) || defined(_WIN32) -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd; - fd = open(comport, O_RDWR); - - if (fd < 0) - { - perror(comport); - } - - return fd; -} - -#else -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd = posix_openpt(O_RDWR); - char *name = ptsname(fd); - - if (name == NULL) - { - perror("ptsname"); - return -1; - } - - printf("name=%s\n", name); - - if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) - { - perror("posix_openpt"); - return -1; - } - - return fd; -} -#endif - +#include "sim.h" int main(int argc, char *argv[]) diff --git a/simulators/simft847.c b/simulators/simft847.c index 91d031c12..8220fa6b1 100644 --- a/simulators/simft847.c +++ b/simulators/simft847.c @@ -47,44 +47,7 @@ getmyline(int fd, unsigned char *buf) return n; } -#if defined(WIN32) || defined(_WIN32) -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd; - fd = open(comport, O_RDWR); - - if (fd < 0) - { - perror(comport); - } - - return fd; -} - -#else -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd = posix_openpt(O_RDWR); - char *name = ptsname(fd); - - if (name == NULL) - { - perror("ptsname"); - return -1; - } - - printf("name=%s\n", name); - - if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) - { - perror("posix_openpt"); - return -1; - } - - return fd; -} -#endif - +#include "sim.h" int main(int argc, char *argv[]) diff --git a/simulators/simft897.c b/simulators/simft897.c index 8af0b36b9..873f46565 100644 --- a/simulators/simft897.c +++ b/simulators/simft897.c @@ -46,44 +46,7 @@ getmyline(int fd, unsigned char *buf) return n; } -#if defined(WIN32) || defined(_WIN32) -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd; - fd = open(comport, O_RDWR); - - if (fd < 0) - { - perror(comport); - } - - return fd; -} - -#else -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd = posix_openpt(O_RDWR); - char *name = ptsname(fd); - - if (name == NULL) - { - perror("ptsname"); - return -1; - } - - printf("name=%s\n", name); - - if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) - { - perror("posix_openpt"); - return -1; - } - - return fd; -} -#endif - +#include "sim.h" int main(int argc, char *argv[]) diff --git a/simulators/simft990.c b/simulators/simft990.c index 479708791..9f150b038 100644 --- a/simulators/simft990.c +++ b/simulators/simft990.c @@ -102,44 +102,7 @@ getmyline(int fd, char *buf) return n; } -#if defined(WIN32) || defined(_WIN32) -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd; - fd = open(comport, O_RDWR); - - if (fd < 0) - { - perror(comport); - } - - return fd; -} - -#else -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd = posix_openpt(O_RDWR); - char *name = ptsname(fd); - - if (name == NULL) - { - perror("ptsname"); - return -1; - } - - printf("name=%s\n", name); - - if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) - { - perror("posix_openpt"); - return -1; - } - - return fd; -} -#endif - +#include "sim.h" int main(int argc, char *argv[]) diff --git a/simulators/simft991.c b/simulators/simft991.c index 6d420ae9b..ce90880e7 100644 --- a/simulators/simft991.c +++ b/simulators/simft991.c @@ -71,44 +71,7 @@ getmyline(int fd, char *buf) return strlen(buf); } -#if defined(WIN32) || defined(_WIN32) -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd; - fd = open(comport, O_RDWR); - - if (fd < 0) - { - perror(comport); - } - - return fd; -} - -#else -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd = posix_openpt(O_RDWR); - char *name = ptsname(fd); - - if (name == NULL) - { - perror("ptsname"); - return -1; - } - - printf("name=%s\n", name); - - if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) - { - perror("posix_openpt"); - return -1; - } - - return fd; -} -#endif - +#include "sim.h" int main(int argc, char *argv[]) diff --git a/simulators/simftdx101.c b/simulators/simftdx101.c index dc0b39532..7a034a4ff 100644 --- a/simulators/simftdx101.c +++ b/simulators/simftdx101.c @@ -79,44 +79,7 @@ getmyline(int fd, char *buf) return strlen(buf); } -#if defined(WIN32) || defined(_WIN32) -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd; - fd = open(comport, O_RDWR); - - if (fd < 0) - { - perror(comport); - } - - return fd; -} - -#else -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd = posix_openpt(O_RDWR); - char *name = ptsname(fd); - - if (name == NULL) - { - perror("ptsname"); - return -1; - } - - printf("name=%s\n", name); - - if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) - { - perror("posix_openpt"); - return -1; - } - - return fd; -} -#endif - +#include "sim.h" int main(int argc, char *argv[]) diff --git a/simulators/simftdx1200.c b/simulators/simftdx1200.c index dac4e51f5..bb475394b 100644 --- a/simulators/simftdx1200.c +++ b/simulators/simftdx1200.c @@ -70,44 +70,7 @@ getmyline(int fd, char *buf) return strlen(buf); } -#if defined(WIN32) || defined(_WIN32) -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd; - fd = open(comport, O_RDWR); - - if (fd < 0) - { - perror(comport); - } - - return fd; -} - -#else -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd = posix_openpt(O_RDWR); - char *name = ptsname(fd); - - if (name == NULL) - { - perror("ptsname"); - return -1; - } - - printf("name=%s\n", name); - - if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) - { - perror("posix_openpt"); - return -1; - } - - return fd; -} -#endif - +#include "sim.h" int main(int argc, char *argv[]) diff --git a/simulators/simftdx3000.c b/simulators/simftdx3000.c index b81c88570..0e69f95b1 100644 --- a/simulators/simftdx3000.c +++ b/simulators/simftdx3000.c @@ -69,44 +69,7 @@ getmyline(int fd, char *buf) return strlen(buf); } -#if defined(WIN32) || defined(_WIN32) -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd; - fd = open(comport, O_RDWR); - - if (fd < 0) - { - perror(comport); - } - - return fd; -} - -#else -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd = posix_openpt(O_RDWR); - char *name = ptsname(fd); - - if (name == NULL) - { - perror("ptsname"); - return -1; - } - - printf("name=%s\n", name); - - if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) - { - perror("posix_openpt"); - return -1; - } - - return fd; -} -#endif - +#include "sim.h" int main(int argc, char *argv[]) diff --git a/simulators/simftdx5000.c b/simulators/simftdx5000.c index 4a843af01..fba9ced8e 100644 --- a/simulators/simftdx5000.c +++ b/simulators/simftdx5000.c @@ -71,44 +71,7 @@ getmyline(int fd, char *buf) return strlen(buf); } -#if defined(WIN32) || defined(_WIN32) -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd; - fd = open(comport, O_RDWR); - - if (fd < 0) - { - perror(comport); - } - - return fd; -} - -#else -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd = posix_openpt(O_RDWR); - char *name = ptsname(fd); - - if (name == NULL) - { - perror("ptsname"); - return -1; - } - - printf("name=%s\n", name); - - if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) - { - perror("posix_openpt"); - return -1; - } - - return fd; -} -#endif - +#include "sim.h" int main(int argc, char *argv[]) diff --git a/simulators/simic2730.c b/simulators/simic2730.c index 1410067bd..824c88a35 100644 --- a/simulators/simic2730.c +++ b/simulators/simic2730.c @@ -514,44 +514,7 @@ void frameParse(int fd, unsigned char *frame, int len) } -#if defined(WIN32) || defined(_WIN32) -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd; - fd = open(comport, O_RDWR); - - if (fd < 0) - { - perror(comport); - } - - return fd; -} - -#else -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd = posix_openpt(O_RDWR); - char *name = ptsname(fd); - - if (name == NULL) - { - perror("ptsname"); - return -1; - } - - printf("name=%s\n", name); - - if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) - { - perror("posix_openpt"); - return -1; - } - - return fd; -} -#endif - +#include "sim.h" void rigStatus() { char vfoa = current_vfo == RIG_VFO_A ? '*' : ' '; diff --git a/simulators/simic275.c b/simulators/simic275.c index 0486bdc3a..bbc729788 100644 --- a/simulators/simic275.c +++ b/simulators/simic275.c @@ -509,44 +509,7 @@ void frameParse(int fd, unsigned char *frame, int len) } -#if defined(WIN32) || defined(_WIN32) -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd; - fd = open(comport, O_RDWR); - - if (fd < 0) - { - perror(comport); - } - - return fd; -} - -#else -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd = posix_openpt(O_RDWR); - char *name = ptsname(fd); - - if (name == NULL) - { - perror("ptsname"); - return -1; - } - - printf("name=%s\n", name); - - if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) - { - perror("posix_openpt"); - return -1; - } - - return fd; -} -#endif - +#include "sim.h" void rigStatus() { char vfoa = current_vfo == RIG_VFO_A ? '*' : ' '; diff --git a/simulators/simic7000.c b/simulators/simic7000.c index 9a09881b3..b35752b02 100644 --- a/simulators/simic7000.c +++ b/simulators/simic7000.c @@ -527,44 +527,7 @@ void frameParse(int fd, unsigned char *frame, int len) } -#if defined(WIN32) || defined(_WIN32) -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd; - fd = open(comport, O_RDWR); - - if (fd < 0) - { - perror(comport); - } - - return fd; -} - -#else -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd = posix_openpt(O_RDWR); - char *name = ptsname(fd); - - if (name == NULL) - { - perror("ptsname"); - return -1; - } - - printf("name=%s\n", name); - - if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) - { - perror("posix_openpt"); - return -1; - } - - return fd; -} -#endif - +#include "sim.h" void rigStatus() { char vfoa = current_vfo == RIG_VFO_A ? '*' : ' '; diff --git a/simulators/simic705.c b/simulators/simic705.c index 7e35486a2..f9caf4070 100644 --- a/simulators/simic705.c +++ b/simulators/simic705.c @@ -583,44 +583,7 @@ void frameParse(int fd, unsigned char *frame, int len) } -#if defined(WIN32) || defined(_WIN32) -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd; - fd = open(comport, O_RDWR); - - if (fd < 0) - { - perror(comport); - } - - return fd; -} - -#else -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd = posix_openpt(O_RDWR); - char *name = ptsname(fd); - - if (name == NULL) - { - perror("ptsname"); - return -1; - } - - printf("name=%s\n", name); - - if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) - { - perror("posix_openpt"); - return -1; - } - - return fd; -} -#endif - +#include "sim.h" void rigStatus() { char vfoa = current_vfo == S_VFOA ? '*' : ' '; diff --git a/simulators/simic7100.c b/simulators/simic7100.c index 6c0e3fb51..0d458350f 100644 --- a/simulators/simic7100.c +++ b/simulators/simic7100.c @@ -473,44 +473,7 @@ void frameParse(int fd, unsigned char *frame, int len) } -#if defined(WIN32) || defined(_WIN32) -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd; - fd = open(comport, O_RDWR); - - if (fd < 0) - { - perror(comport); - } - - return fd; -} - -#else -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd = posix_openpt(O_RDWR); - char *name = ptsname(fd); - - if (name == NULL) - { - perror("ptsname"); - return -1; - } - - printf("name=%s\n", name); - - if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) - { - perror("posix_openpt"); - return -1; - } - - return fd; -} -#endif - +#include "sim.h" void rigStatus() { char vfoa = current_vfo == RIG_VFO_A ? '*' : ' '; diff --git a/simulators/simic7200.c b/simulators/simic7200.c index 865428434..c44e51c25 100644 --- a/simulators/simic7200.c +++ b/simulators/simic7200.c @@ -803,44 +803,7 @@ void frameParse(int fd, unsigned char *frame, int len) } -#if defined(WIN32) || defined(_WIN32) -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd; - fd = open(comport, O_RDWR); - - if (fd < 0) - { - perror(comport); - } - - return fd; -} - -#else -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd = posix_openpt(O_RDWR); - char *name = ptsname(fd); - - if (name == NULL) - { - perror("ptsname"); - return -1; - } - - printf("name=%s\n", name); - - if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) - { - perror("posix_openpt"); - return -1; - } - - return fd; -} -#endif - +#include "sim.h" void rigStatus() { char vfoa = current_vfo == RIG_VFO_A ? '*' : ' '; diff --git a/simulators/simic7300.c b/simulators/simic7300.c index 7fd1bcd33..12da61b79 100644 --- a/simulators/simic7300.c +++ b/simulators/simic7300.c @@ -714,44 +714,7 @@ if (n == 0) { printf("Write failed=%s\n", strerror(errno)); } } -#if defined(WIN32) || defined(_WIN32) -int openPort(char *comport) // doesn't matter for using pts devices -{ -int fd; -fd = open(comport, O_RDWR); - -if (fd < 0) -{ - perror(comport); -} - -return fd; -} - -#else -int openPort(char *comport) // doesn't matter for using pts devices -{ -int fd = posix_openpt(O_RDWR); -char *name = ptsname(fd); - -if (name == NULL) -{ - perror("ptsname"); - return -1; -} - -printf("name=%s\n", name); - -if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) -{ - perror("posix_openpt"); - return -1; -} - -return fd; -} -#endif - +#include "sim.h" void rigStatus() { char vfoa = current_vfo == RIG_VFO_A ? '*' : ' '; diff --git a/simulators/simic7600.c b/simulators/simic7600.c index 55d15233b..13f29c511 100644 --- a/simulators/simic7600.c +++ b/simulators/simic7600.c @@ -625,44 +625,7 @@ void frameParse(int fd, unsigned char *frame, int len) } -#if defined(WIN32) || defined(_WIN32) -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd; - fd = open(comport, O_RDWR); - - if (fd < 0) - { - perror(comport); - } - - return fd; -} - -#else -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd = posix_openpt(O_RDWR); - char *name = ptsname(fd); - - if (name == NULL) - { - perror("ptsname"); - return -1; - } - - printf("name=%s\n", name); - - if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) - { - perror("posix_openpt"); - return -1; - } - - return fd; -} -#endif - +#include "sim.h" void rigStatus() { char vfoa = current_vfo == RIG_VFO_A ? '*' : ' '; diff --git a/simulators/simic7610.c b/simulators/simic7610.c index decdd1c31..3312efbae 100644 --- a/simulators/simic7610.c +++ b/simulators/simic7610.c @@ -730,44 +730,7 @@ void frameParse(int fd, unsigned char *frame, int len) } -#if defined(WIN32) || defined(_WIN32) -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd; - fd = open(comport, O_RDWR); - - if (fd < 0) - { - perror(comport); - } - - return fd; -} - -#else -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd = posix_openpt(O_RDWR); - char *name = ptsname(fd); - - if (name == NULL) - { - perror("ptsname"); - return -1; - } - - printf("name=%s\n", name); - - if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) - { - perror("posix_openpt"); - return -1; - } - - return fd; -} -#endif - +#include "sim.h" void rigStatus() { char vfoa = current_vfo == RIG_VFO_A ? '*' : ' '; diff --git a/simulators/simic7700.c b/simulators/simic7700.c index ad2e9e492..72f3d0f8d 100644 --- a/simulators/simic7700.c +++ b/simulators/simic7700.c @@ -692,44 +692,7 @@ if (n == 0) { printf("Write failed=%s\n", strerror(errno)); } } -#if defined(WIN32) || defined(_WIN32) -int openPort(char *comport) // doesn't matter for using pts devices -{ -int fd; -fd = open(comport, O_RDWR); - -if (fd < 0) -{ - perror(comport); -} - -return fd; -} - -#else -int openPort(char *comport) // doesn't matter for using pts devices -{ -int fd = posix_openpt(O_RDWR); -char *name = ptsname(fd); - -if (name == NULL) -{ - perror("ptsname"); - return -1; -} - -printf("name=%s\n", name); - -if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) -{ - perror("posix_openpt"); - return -1; -} - -return fd; -} -#endif - +#include "sim.h" void rigStatus() { char vfoa = current_vfo == RIG_VFO_A ? '*' : ' '; diff --git a/simulators/simic7851.c b/simulators/simic7851.c index 57c880c48..b14cc09e9 100644 --- a/simulators/simic7851.c +++ b/simulators/simic7851.c @@ -795,44 +795,7 @@ void frameParse(int fd, unsigned char *frame, int len) } -#if defined(WIN32) || defined(_WIN32) -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd; - fd = open(comport, O_RDWR); - - if (fd < 0) - { - perror(comport); - } - - return fd; -} - -#else -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd = posix_openpt(O_RDWR); - char *name = ptsname(fd); - - if (name == NULL) - { - perror("ptsname"); - return -1; - } - - printf("name=%s\n", name); - - if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) - { - perror("posix_openpt"); - return -1; - } - - return fd; -} -#endif - +#include "sim.h" void rigStatus() { char vfoa = current_vfo == RIG_VFO_A ? '*' : ' '; diff --git a/simulators/simic905.c b/simulators/simic905.c index b01946bd3..8ccafb872 100644 --- a/simulators/simic905.c +++ b/simulators/simic905.c @@ -22,7 +22,6 @@ struct ip_mreq #include "../src/misc.h" #include "sim.h" - #define BUFSIZE 256 #define X25 @@ -592,44 +591,6 @@ void frameParse(int fd, unsigned char *frame, int len) // don't care about the rig type yet } -#if defined(WIN32) || defined(_WIN32) -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd; - fd = open(comport, O_RDWR); - - if (fd < 0) - { - perror(comport); - } - - return fd; -} - -#else -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd = posix_openpt(O_RDWR); - char *name = ptsname(fd); - - if (name == NULL) - { - perror("ptsname"); - return -1; - } - - printf("name=%s\n", name); - - if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) - { - perror("posix_openpt"); - return -1; - } - - return fd; -} -#endif - void rigStatus() { char vfoa = current_vfo == RIG_VFO_A ? '*' : ' '; diff --git a/simulators/simic910.c b/simulators/simic910.c index 703093bf5..83796e276 100644 --- a/simulators/simic910.c +++ b/simulators/simic910.c @@ -595,44 +595,6 @@ void frameParse(int fd, unsigned char *frame, int len) // don't care about the rig type yet } -#if defined(WIN32) || defined(_WIN32) -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd; - fd = open(comport, O_RDWR); - - if (fd < 0) - { - perror(comport); - } - - return fd; -} - -#else -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd = posix_openpt(O_RDWR); - char *name = ptsname(fd); - - if (name == NULL) - { - perror("ptsname"); - return -1; - } - - printf("name=%s\n", name); - - if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) - { - perror("posix_openpt"); - return -1; - } - - return fd; -} -#endif - void rigStatus() { char vfoa = current_vfo == RIG_VFO_A ? '*' : ' '; diff --git a/simulators/simic9100.c b/simulators/simic9100.c index ca53dffca..51c1d7d79 100644 --- a/simulators/simic9100.c +++ b/simulators/simic9100.c @@ -527,44 +527,6 @@ printf("+++++++++++++++ SETTING VFO +++++++++++++++++\n"); // don't care about the rig type yet } -#if defined(WIN32) || defined(_WIN32) -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd; - fd = open(comport, O_RDWR); - - if (fd < 0) - { - perror(comport); - } - - return fd; -} - -#else -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd = posix_openpt(O_RDWR); - char *name = ptsname(fd); - - if (name == NULL) - { - perror("ptsname"); - return -1; - } - - printf("name=%s\n", name); - - if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) - { - perror("posix_openpt"); - return -1; - } - - return fd; -} -#endif - void rigStatus() { char vfoa = current_vfo == RIG_VFO_A ? '*' : ' '; diff --git a/simulators/simic9700.c b/simulators/simic9700.c index 0b14f8b10..bd4d194bd 100644 --- a/simulators/simic9700.c +++ b/simulators/simic9700.c @@ -557,44 +557,6 @@ void frameParse(int fd, unsigned char *frame, int len) // don't care about the rig type yet } -#if defined(WIN32) || defined(_WIN32) -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd; - fd = open(comport, O_RDWR); - - if (fd < 0) - { - perror(comport); - } - - return fd; -} - -#else -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd = posix_openpt(O_RDWR); - char *name = ptsname(fd); - - if (name == NULL) - { - perror("ptsname"); - return -1; - } - - printf("name=%s\n", name); - - if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) - { - perror("posix_openpt"); - return -1; - } - - return fd; -} -#endif - void rigStatus() { char vfoa = current_vfo == RIG_VFO_A ? '*' : ' '; diff --git a/simulators/simicgeneric.c b/simulators/simicgeneric.c index 452d1c6c1..799bf5e29 100644 --- a/simulators/simicgeneric.c +++ b/simulators/simicgeneric.c @@ -398,44 +398,6 @@ void frameParse(int fd, unsigned char *frame, int len) } -#if defined(WIN32) || defined(_WIN32) -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd; - fd = open(comport, O_RDWR); - - if (fd < 0) - { - perror(comport); - } - - return fd; -} - -#else -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd = posix_openpt(O_RDWR); - char *name = ptsname(fd); - - if (name == NULL) - { - perror("ptsname"); - return -1; - } - - printf("name=%s\n", name); - - if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) - { - perror("posix_openpt"); - return -1; - } - - return fd; -} -#endif - void rigStatus() { char vfoa = current_vfo == RIG_VFO_A ? '*' : ' '; diff --git a/simulators/simicr8600.c b/simulators/simicr8600.c index 4b18ecf4d..af95d677a 100644 --- a/simulators/simicr8600.c +++ b/simulators/simicr8600.c @@ -393,44 +393,6 @@ void frameParse(int fd, unsigned char *frame, int len) } } -#if defined(WIN32) || defined(_WIN32) -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd; - fd = open(comport, O_RDWR); - - if (fd < 0) - { - perror(comport); - } - - return fd; -} - -#else -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd = posix_openpt(O_RDWR); - char *name = ptsname(fd); - - if (name == NULL) - { - perror("ptsname"); - return -1; - } - - printf("name=%s\n", name); - - if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) - { - perror("posix_openpt"); - return -1; - } - - return fd; -} -#endif - void rigStatus() { char vfoa = current_vfo == RIG_VFO_A ? '*' : ' '; diff --git a/simulators/simid5100.c b/simulators/simid5100.c index 05ad0608b..d0c0116ba 100644 --- a/simulators/simid5100.c +++ b/simulators/simid5100.c @@ -386,44 +386,7 @@ void frameParse(int fd, unsigned char *frame, int len) } -#if defined(WIN32) || defined(_WIN32) -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd; - fd = open(comport, O_RDWR); - - if (fd < 0) - { - perror(comport); - } - - return fd; -} - -#else -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd = posix_openpt(O_RDWR); - char *name = ptsname(fd); - - if (name == NULL) - { - perror("ptsname"); - return -1; - } - - printf("name=%s\n", name); - - if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) - { - perror("posix_openpt"); - return -1; - } - - return fd; -} -#endif - +#include "sim.h" void rigStatus() { char vfoa = current_vfo == RIG_VFO_A ? '*' : ' '; diff --git a/simulators/simjupiter.c b/simulators/simjupiter.c index e2430870f..83440b87f 100644 --- a/simulators/simjupiter.c +++ b/simulators/simjupiter.c @@ -45,44 +45,7 @@ getmyline(int fd, unsigned char *buf) return n; } -#if defined(WIN32) || defined(_WIN32) -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd; - fd = open(comport, O_RDWR); - - if (fd < 0) - { - perror(comport); - } - - return fd; -} - -#else -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd = posix_openpt(O_RDWR); - char *name = ptsname(fd); - - if (name == NULL) - { - perror("ptsname"); - return -1; - } - - printf("name=%s\n", name); - - if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) - { - perror("posix_openpt"); - return -1; - } - - return fd; -} -#endif - +#include "sim.h" int main(int argc, char *argv[]) diff --git a/simulators/simkenwood.c b/simulators/simkenwood.c index daa7575f1..97f1cdc95 100644 --- a/simulators/simkenwood.c +++ b/simulators/simkenwood.c @@ -44,44 +44,7 @@ getmyline(int fd, char *buf) return strlen(buf); } -#if defined(WIN32) || defined(_WIN32) -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd; - fd = open(comport, O_RDWR); - - if (fd < 0) - { - perror(comport); - } - - return fd; -} - -#else -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd = posix_openpt(O_RDWR); - char *name = ptsname(fd); - - if (name == NULL) - { - perror("ptsname"); - return -1; - } - - printf("name=%s\n", name); - - if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) - { - perror("posix_openpt"); - return -1; - } - - return fd; -} -#endif - +#include "sim.h" int main(int argc, char *argv[]) diff --git a/simulators/simmicom.c b/simulators/simmicom.c index bc7bd2c09..b94626870 100644 --- a/simulators/simmicom.c +++ b/simulators/simmicom.c @@ -51,44 +51,7 @@ getmyline(int fd, unsigned char *buf) return n; } -#if defined(WIN32) || defined(_WIN32) -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd; - fd = open(comport, O_RDWR); - - if (fd < 0) - { - perror(comport); - } - - return fd; -} - -#else -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd = posix_openpt(O_RDWR); - char *name = ptsname(fd); - - if (name == NULL) - { - perror("ptsname"); - return -1; - } - - printf("name=%s\n", name); - - if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) - { - perror("posix_openpt"); - return -1; - } - - return fd; -} -#endif - +#include "sim.h" int main(int argc, char *argv[]) diff --git a/simulators/simorion.c b/simulators/simorion.c index 69c958f02..738cb91f1 100644 --- a/simulators/simorion.c +++ b/simulators/simorion.c @@ -42,44 +42,7 @@ getmyline(int fd, char *buf) return n; } -#if defined(WIN32) || defined(_WIN32) -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd; - fd = open(comport, O_RDWR); - - if (fd < 0) - { - perror(comport); - } - - return fd; -} - -#else -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd = posix_openpt(O_RDWR); - char *name = ptsname(fd); - - if (name == NULL) - { - perror("ptsname"); - return -1; - } - - printf("name=%s\n", name); - - if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) - { - perror("posix_openpt"); - return -1; - } - - return fd; -} -#endif - +#include "sim.h" int main(int argc, char *argv[]) diff --git a/simulators/simpmr171.c b/simulators/simpmr171.c index 6e96cb68d..566e6eded 100644 --- a/simulators/simpmr171.c +++ b/simulators/simpmr171.c @@ -58,44 +58,7 @@ getmyline(int fd, unsigned char *buf) return n; } -#if defined(WIN32) || defined(_WIN32) -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd; - fd = open(comport, O_RDWR); - - if (fd < 0) - { - perror(comport); - } - - return fd; -} - -#else -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd = posix_openpt(O_RDWR); - char *name = ptsname(fd); - - if (name == NULL) - { - perror("ptsname"); - return -1; - } - - printf("name=%s\n", name); - - if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) - { - perror("posix_openpt"); - return -1; - } - - return fd; -} -#endif - +#include "sim.h" int main(int argc, char *argv[]) diff --git a/simulators/simpowersdr.c b/simulators/simpowersdr.c index a3701831c..05327927f 100644 --- a/simulators/simpowersdr.c +++ b/simulators/simpowersdr.c @@ -45,44 +45,7 @@ getmyline(int fd, char *buf) return strlen(buf); } -#if defined(WIN32) || defined(_WIN32) -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd; - fd = open(comport, O_RDWR); - - if (fd < 0) - { - perror(comport); - } - - return fd; -} - -#else -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd = posix_openpt(O_RDWR); - char *name = ptsname(fd); - - if (name == NULL) - { - perror("ptsname"); - return -1; - } - - printf("name=%s\n", name); - - if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) - { - perror("posix_openpt"); - return -1; - } - - return fd; -} -#endif - +#include "sim.h" int main(int argc, char *argv[]) diff --git a/simulators/simqrplabs.c b/simulators/simqrplabs.c index 4bd34be1a..d3329f642 100644 --- a/simulators/simqrplabs.c +++ b/simulators/simqrplabs.c @@ -47,44 +47,7 @@ getmyline(int fd, char *buf) return strlen(buf); } -#if defined(WIN32) || defined(_WIN32) -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd; - fd = open(comport, O_RDWR); - - if (fd < 0) - { - perror(comport); - } - - return fd; -} - -#else -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd = posix_openpt(O_RDWR); - char *name = ptsname(fd); - - if (name == NULL) - { - perror("ptsname"); - return -1; - } - - printf("name=%s\n", name); - - if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) - { - perror("posix_openpt"); - return -1; - } - - return fd; -} -#endif - +#include "sim.h" int main(int argc, char *argv[]) diff --git a/simulators/simrotorez.c b/simulators/simrotorez.c index 57e2ec73c..fa6c83a8b 100644 --- a/simulators/simrotorez.c +++ b/simulators/simrotorez.c @@ -46,44 +46,7 @@ getmyline(int fd, char *buf) return n; } -#if defined(WIN32) || defined(_WIN32) -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd; - fd = open(comport, O_RDWR); - - if (fd < 0) - { - perror(comport); - } - - return fd; -} - -#else -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd = posix_openpt(O_RDWR); - char *name = ptsname(fd); - - if (name == NULL) - { - perror("ptsname"); - return -1; - } - - printf("name=%s\n", name); - - if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) - { - perror("posix_openpt"); - return -1; - } - - return fd; -} -#endif - +#include "sim.h" int thread_args[2]; diff --git a/simulators/simspid.c b/simulators/simspid.c index 77e12fcf7..8a8d83e20 100644 --- a/simulators/simspid.c +++ b/simulators/simspid.c @@ -44,44 +44,7 @@ getmyline(int fd, unsigned char *buf) return n; } -#if defined(WIN32) || defined(_WIN32) -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd; - fd = open(comport, O_RDWR); - - if (fd < 0) - { - perror(comport); - } - - return fd; -} - -#else -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd = posix_openpt(O_RDWR); - char *name = ptsname(fd); - - if (name == NULL) - { - perror("ptsname"); - return -1; - } - - printf("name=%s\n", name); - - if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) - { - perror("posix_openpt"); - return -1; - } - - return fd; -} -#endif - +#include "sim.h" int main(int argc, char *argv[]) diff --git a/simulators/simtmd700.c b/simulators/simtmd700.c index 5bb363533..56521609b 100644 --- a/simulators/simtmd700.c +++ b/simulators/simtmd700.c @@ -44,44 +44,7 @@ getmyline(int fd, char *buf) return strlen(buf); } -#if defined(WIN32) || defined(_WIN32) -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd; - fd = open(comport, O_RDWR); - - if (fd < 0) - { - perror(comport); - } - - return fd; -} - -#else -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd = posix_openpt(O_RDWR); - char *name = ptsname(fd); - - if (name == NULL) - { - perror("ptsname"); - return -1; - } - - printf("name=%s\n", name); - - if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) - { - perror("posix_openpt"); - return -1; - } - - return fd; -} -#endif - +#include "sim.h" int main(int argc, char *argv[]) diff --git a/simulators/simtmd710.c b/simulators/simtmd710.c index 9cd53ebc1..54d55e611 100644 --- a/simulators/simtmd710.c +++ b/simulators/simtmd710.c @@ -44,44 +44,7 @@ getmyline(int fd, char *buf) return strlen(buf); } -#if defined(WIN32) || defined(_WIN32) -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd; - fd = open(comport, O_RDWR); - - if (fd < 0) - { - perror(comport); - } - - return fd; -} - -#else -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd = posix_openpt(O_RDWR); - char *name = ptsname(fd); - - if (name == NULL) - { - perror("ptsname"); - return -1; - } - - printf("name=%s\n", name); - - if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) - { - perror("posix_openpt"); - return -1; - } - - return fd; -} -#endif - +#include "sim.h" int main(int argc, char *argv[]) diff --git a/simulators/simtrusdx.c b/simulators/simtrusdx.c index ffd210bdc..67bb8125a 100644 --- a/simulators/simtrusdx.c +++ b/simulators/simtrusdx.c @@ -16,7 +16,6 @@ struct ip_mreq #include #include "hamlib/rig.h" -#include "sim.h" #include "misc.h" #define BUFSIZE 256 @@ -50,44 +49,7 @@ getmyline(int fd, char *buf) return strlen(buf); } -#if defined(WIN32) || defined(_WIN32) -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd; - fd = open(comport, O_RDWR); - - if (fd < 0) - { - perror(comport); - } - - return fd; -} - -#else -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd = posix_openpt(O_RDWR); - char *name = ptsname(fd); - - if (name == NULL) - { - perror("ptsname"); - return -1; - } - - printf("name=%s\n", name); - - if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) - { - perror("posix_openpt"); - return -1; - } - - return fd; -} -#endif - +#include "sim.h" int main(int argc, char *argv[]) diff --git a/simulators/simts450.c b/simulators/simts450.c index b4d9a59a9..2c4a3f02d 100644 --- a/simulators/simts450.c +++ b/simulators/simts450.c @@ -16,7 +16,6 @@ struct ip_mreq #include #include "hamlib/rig.h" -#include "sim.h" #include "misc.h" #define BUFSIZE 256 @@ -50,44 +49,7 @@ getmyline(int fd, char *buf) return strlen(buf); } -#if defined(WIN32) || defined(_WIN32) -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd; - fd = open(comport, O_RDWR); - - if (fd < 0) - { - perror(comport); - } - - return fd; -} - -#else -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd = posix_openpt(O_RDWR); - char *name = ptsname(fd); - - if (name == NULL) - { - perror("ptsname"); - return -1; - } - - printf("name=%s\n", name); - - if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) - { - perror("posix_openpt"); - return -1; - } - - return fd; -} -#endif - +#include "sim.h" int main(int argc, char *argv[]) diff --git a/simulators/simts590.c b/simulators/simts590.c index 27cb56f28..f28658b5f 100644 --- a/simulators/simts590.c +++ b/simulators/simts590.c @@ -57,44 +57,6 @@ getmyline(int fd, char *buf) return strlen(buf); } -#if defined(WIN32) || defined(_WIN32) -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd; - fd = open(comport, O_RDWR); - - if (fd < 0) - { - perror(comport); - } - - return fd; -} - -#else -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd = posix_openpt(O_RDWR); - char *name = ptsname(fd); - - if (name == NULL) - { - perror("ptsname"); - return -1; - } - - printf("name=%s\n", name); - - if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) - { - perror("posix_openpt"); - return -1; - } - - return fd; -} -#endif - int main(int argc, char *argv[]) diff --git a/simulators/simts890.c b/simulators/simts890.c index 3db72d076..e08ba774c 100644 --- a/simulators/simts890.c +++ b/simulators/simts890.c @@ -210,44 +210,7 @@ static void swapvfos(kvfop_t *vfoset[]); // Extracted from rig.h int hl_usleep(unsigned long usec); // Until it's replaced -#if defined(WIN32) || defined(_WIN32) -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd; - fd = open(comport, O_RDWR); - - if (fd < 0) - { - perror(comport); - } - - return fd; -} - -#else -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd = posix_openpt(O_RDWR); - char *name = ptsname(fd); - - if (name == NULL) - { - perror("ptsname"); - return -1; - } - - printf("name=%s\n", name); - - if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) - { - perror("posix_openpt"); - return -1; - } - - return fd; -} -#endif - +#include "sim.h" int getmyline(int fd, char *buf) { diff --git a/simulators/simts950.c b/simulators/simts950.c index 9deb8b6b1..b53c0cfa1 100644 --- a/simulators/simts950.c +++ b/simulators/simts950.c @@ -47,44 +47,7 @@ getmyline(int fd, char *buf) return strlen(buf); } -#if defined(WIN32) || defined(_WIN32) -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd; - fd = open(comport, O_RDWR); - - if (fd < 0) - { - perror(comport); - } - - return fd; -} - -#else -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd = posix_openpt(O_RDWR); - char *name = ptsname(fd); - - if (name == NULL) - { - perror("ptsname"); - return -1; - } - - printf("name=%s\n", name); - - if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) - { - perror("posix_openpt"); - return -1; - } - - return fd; -} -#endif - +#include "sim.h" int main(int argc, char *argv[]) diff --git a/simulators/simts990.c b/simulators/simts990.c index b2cbbe84c..41add9024 100644 --- a/simulators/simts990.c +++ b/simulators/simts990.c @@ -61,44 +61,7 @@ int mo1 = 0; int pc = 50; -#if defined(WIN32) || defined(_WIN32) -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd; - fd = open(comport, O_RDWR); - - if (fd < 0) - { - perror(comport); - } - - return fd; -} - -#else -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd = posix_openpt(O_RDWR); - char *name = ptsname(fd); - - if (name == NULL) - { - perror("ptsname"); - return -1; - } - - printf("name=%s\n", name); - - if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) - { - perror("posix_openpt"); - return -1; - } - - return fd; -} -#endif - +#include "sim.h" int getmyline(int fd, char *buf) { diff --git a/simulators/simxiegug90.c b/simulators/simxiegug90.c index 6553a051f..512923ee9 100644 --- a/simulators/simxiegug90.c +++ b/simulators/simxiegug90.c @@ -412,44 +412,7 @@ void frameParse(int fd, unsigned char *frame, int len) } -#if defined(WIN32) || defined(_WIN32) -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd; - fd = open(comport, O_RDWR); - - if (fd < 0) - { - perror(comport); - } - - return fd; -} - -#else -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd = posix_openpt(O_RDWR); - char *name = ptsname(fd); - - if (name == NULL) - { - perror("ptsname"); - return -1; - } - - printf("name=%s\n", name); - - if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) - { - perror("posix_openpt"); - return -1; - } - - return fd; -} -#endif - +#include "sim.h" void rigStatus() { char vfoa = current_vfo == RIG_VFO_A ? '*' : ' '; diff --git a/simulators/simxiegux108g.c b/simulators/simxiegux108g.c index 1b675f739..ee88333f4 100644 --- a/simulators/simxiegux108g.c +++ b/simulators/simxiegux108g.c @@ -404,44 +404,7 @@ void frameParse(int fd, unsigned char *frame, int len) } -#if defined(WIN32) || defined(_WIN32) -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd; - fd = open(comport, O_RDWR); - - if (fd < 0) - { - perror(comport); - } - - return fd; -} - -#else -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd = posix_openpt(O_RDWR); - char *name = ptsname(fd); - - if (name == NULL) - { - perror("ptsname"); - return -1; - } - - printf("name=%s\n", name); - - if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) - { - perror("posix_openpt"); - return -1; - } - - return fd; -} -#endif - +#include "sim.h" void rigStatus() { char vfoa = current_vfo == RIG_VFO_A ? '*' : ' '; diff --git a/simulators/simxiegux6100.c b/simulators/simxiegux6100.c index 714bf160c..91b14382b 100644 --- a/simulators/simxiegux6100.c +++ b/simulators/simxiegux6100.c @@ -417,44 +417,7 @@ void frameParse(int fd, unsigned char *frame, int len) } -#if defined(WIN32) || defined(_WIN32) -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd; - fd = open(comport, O_RDWR); - - if (fd < 0) - { - perror(comport); - } - - return fd; -} - -#else -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd = posix_openpt(O_RDWR); - char *name = ptsname(fd); - - if (name == NULL) - { - perror("ptsname"); - return -1; - } - - printf("name=%s\n", name); - - if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) - { - perror("posix_openpt"); - return -1; - } - - return fd; -} -#endif - +#include "sim.h" void rigStatus() { char vfoa = current_vfo == RIG_VFO_A ? '*' : ' '; diff --git a/simulators/simyaesu.c b/simulators/simyaesu.c index d0425d173..9b7a4e604 100644 --- a/simulators/simyaesu.c +++ b/simulators/simyaesu.c @@ -74,44 +74,7 @@ getmyline(int fd, char *buf) return strlen(buf); } -#if defined(WIN32) || defined(_WIN32) -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd; - fd = open(comport, O_RDWR); - - if (fd < 0) - { - perror(comport); - } - - return fd; -} - -#else -int openPort(char *comport) // doesn't matter for using pts devices -{ - int fd = posix_openpt(O_RDWR); - char *name = ptsname(fd); - - if (name == NULL) - { - perror("ptsname"); - return -1; - } - - printf("name=%s\n", name); - - if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) - { - perror("posix_openpt"); - return -1; - } - - return fd; -} -#endif - +#include "sim.h" int main(int argc, char *argv[])