pkgsrc-wip/gnokii/patches/patch-ag
Sergey Svishchev 6726b9f1d3 Update to 0.6.22. Over 600 lines of changes -- see ChangeLog.
At the same time, drop maintainership.
2007-12-08 16:13:11 +00:00

132 lines
3.5 KiB
Text

$NetBSD: patch-ag,v 1.3 2007/12/08 16:13:11 shattered Exp $
--- common/devices/unixbluetooth.c.orig 2006-08-27 23:36:54.000000000 +0100
+++ common/devices/unixbluetooth.c
@@ -34,7 +34,7 @@
#include "gnokii.h"
#include "devices/unixbluetooth.h"
-#if defined(HAVE_BLUETOOTH_BLUEZ) || defined(HAVE_BLUETOOTH_NETGRAPH)
+#if defined(HAVE_BLUETOOTH_BLUEZ) || defined(HAVE_BLUETOOTH_NETGRAPH) || defined(HAVE_BLUETOOTH_NETBT)
#include <stdlib.h>
#include <stdio.h>
@@ -45,7 +45,7 @@
#include <sys/time.h>
#include <sys/socket.h>
-#ifdef HAVE_BLUETOOTH_NETGRAPH /* FreeBSD / netgraph */
+#if defined(HAVE_BLUETOOTH_NETGRAPH) /* FreeBSD / netgraph */
#include <bitstring.h>
#include <netgraph/bluetooth/include/ng_hci.h>
@@ -54,46 +54,64 @@
#define BTPROTO_RFCOMM BLUETOOTH_PROTO_RFCOMM
#define BDADDR_ANY NG_HCI_BDADDR_ANY
-#define sockaddr_rc sockaddr_rfcomm
-#define rc_family rfcomm_family
-#define rc_bdaddr rfcomm_bdaddr
-#define rc_channel rfcomm_channel
-#define bacpy(dst, src) memcpy((dst), (src), sizeof(bdaddr_t))
+#define sockaddr_rc sockaddr_rfcomm
+#define rc_len rfcomm_len
+#define rc_family rfcomm_family
+#define rc_bdaddr rfcomm_bdaddr
+#define rc_channel rfcomm_channel
+
+#elif defined(HAVE_BLUETOOTH_NETBT) /* NetBSD */
+
+#include <bluetooth.h>
+
+#define sockaddr_rc sockaddr_bt
+#define rc_len bt_len
+#define rc_family bt_family
+#define rc_bdaddr bt_bdaddr
+#define rc_channel bt_channel
-#ifndef HAVE_BT_ATON
+#else /* HAVE_BLUETOOTH_BLUEZ */ /* Linux / BlueZ support */
-static int bt_aton(const char *str, bdaddr_t *ba)
-{
- char ch;
- unsigned int b[6];
-
- memset(ba, 0, sizeof(*ba));
- if (sscanf(str, "%x:%x:%x:%x:%x:%x%c", b + 0, b + 1, b + 2, b + 3, b + 4, b + 5, &ch) != 6) return 0;
- if ((b[0] | b[1] | b[2] | b[3] | b[4] | b[5]) > 0xff) return 0;
-
- ba->b[0] = b[0];
- ba->b[1] = b[1];
- ba->b[2] = b[2];
- ba->b[3] = b[3];
- ba->b[4] = b[4];
- ba->b[5] = b[5];
+#include <bluetooth/bluetooth.h>
+#include <bluetooth/rfcomm.h>
- return 1;
-}
+#endif /* HAVE_BLUETOOTH_XXXX */
-#endif /* HAVE_BT_ATON */
+#ifdef SOCKADDR_HAS_LEN
+#define SOCKLEN(sa) ((sa).rc_len = sizeof(sa))
+#else
+#define SOCKLEN(sa)
+#endif /* SOCKADDR_HAS_LEN */
+
+#ifndef HAVE_BACPY
+#define bacpy(dst, src) memcpy((dst), (src), sizeof(bdaddr_t))
+#endif /* HAVE_BACPY */
+
+#ifndef HAVE_BASWAP /* don't have == don't need */
+#define baswap(dst, src) bacpy(dst, src)
+#endif /* HAVE_BASWAP */
+#ifndef HAVE_STR2BA
static int str2ba(const char *str, bdaddr_t *ba)
{
+#ifdef HAVE_BT_ATON
return !bt_aton(str, ba);
+#else
+ uint8_t b[6];
+ const char *ptr = str;
+ int i;
+
+ for (i = 0; i < 6; i++) {
+ b[i] = (uint8_t) strtol(ptr, NULL, 16);
+ if (i != 5 && !(ptr = strchr(ptr, ':')))
+ ptr = ":00:00:00:00:00";
+ ptr++;
+ }
+ baswap(ba, (bdaddr_t *) b);
+ return 0;
+#endif /* HAVE_BT_ATON */
}
-
-#else /* Linux / BlueZ support */
-
-#include <bluetooth/bluetooth.h>
-#include <bluetooth/rfcomm.h>
-
-#endif
+#endif /* HAVE_STR2BA */
/* From: http://www.kegel.com/dkftpbench/nonblocking.html */
static int setNonblocking(int fd)
@@ -121,6 +140,7 @@ int bluetooth_open(const char *addr, uin
}
memset(&raddr, 0, sizeof(raddr));
+ SOCKLEN(raddr);
raddr.rc_family = AF_BLUETOOTH;
bacpy(&raddr.rc_bdaddr, &bdaddr);
raddr.rc_channel = channel;
@@ -159,4 +179,4 @@ int bluetooth_select(int fd, struct time
return select(fd + 1, &readfds, NULL, NULL, timeout);
}
-#endif /* HAVE_BLUETOOTH_BLUEZ || HAVE_BLUETOOTH_NETGRAPH */
+#endif /* HAVE_BLUETOOTH_BLUEZ || HAVE_BLUETOOTH_NETGRAPH || HAVE_BLUETOOTH_NETBT */