Commit 811d134978795a5acd171710999071a94beb4305

Authored by Stéphane Raimbault
1 parent d613a640

OpenBSD support by Anibal Limón

... ... @@ -15,6 +15,7 @@ libmodbus 2.1.1 (2010-XX-XX)
15 15 Reported by aladdinwu.
16 16 - Parity setting is now a single char ('N', 'E' or 'O')
17 17 - Report slave ID server side
  18 +- OpenBSD support by Anibal Limón.
18 19  
19 20 libmodbus 2.1.0 (2010-03-24)
20 21 ============================
... ...
src/modbus.c
... ... @@ -45,11 +45,16 @@
45 45 #include <limits.h>
46 46 #include <fcntl.h>
47 47  
  48 +/* Add this for macros that defined unix flavor */
  49 +#if (defined(__unix__) || defined(unix)) && !defined(USG)
  50 +#include <sys/param.h>
  51 +#endif
  52 +
48 53 /* TCP */
49 54 #include <sys/types.h>
50 55 #include <sys/socket.h>
51 56 #include <sys/ioctl.h>
52   -#if defined(__FreeBSD__ ) && __FreeBSD__ < 5
  57 +#if (defined OpenBSD) || (defined(__FreeBSD__ ) && __FreeBSD__ < 5)
53 58 #include <netinet/in_systm.h>
54 59 #endif
55 60 #include <netinet/in.h>
... ... @@ -1527,8 +1532,11 @@ modbus_t* modbus_new_rtu(const char *device,
1527 1532  
1528 1533 ctx->com = (modbus_rtu_t *) malloc(sizeof(modbus_rtu_t));
1529 1534 ctx_rtu = (modbus_rtu_t *)ctx->com;
1530   -
  1535 +#if defined(OpenBSD)
  1536 + strlcpy(ctx_rtu->device, device, sizeof(ctx_rtu->device));
  1537 +#else
1531 1538 strcpy(ctx_rtu->device, device);
  1539 +#endif
1532 1540 ctx_rtu->baud = baud;
1533 1541 if (parity == 'N' || parity == 'E' || parity == 'O') {
1534 1542 ctx_rtu->parity = parity;
... ...
src/modbus.h.in
... ... @@ -18,6 +18,11 @@
18 18 #ifndef _MODBUS_H_
19 19 #define _MODBUS_H_
20 20  
  21 +/* Add this for macros that defined unix flavor */
  22 +#if (defined(__unix__) || defined(unix)) && !defined(USG)
  23 +#include <sys/param.h>
  24 +#endif
  25 +
21 26 #ifdef HAVE_INTTYPES_H
22 27 #include <inttypes.h>
23 28 #endif
... ... @@ -25,7 +30,7 @@
25 30 #include <stdint.h>
26 31 #endif
27 32 #include <termios.h>
28   -#if defined(__FreeBSD__ ) && __FreeBSD__ < 5
  33 +#if defined(OpenBSD) || (defined(__FreeBSD__ ) && __FreeBSD__ < 5)
29 34 #include <netinet/in_systm.h>
30 35 #endif
31 36 #include <netinet/in.h>
... ...