Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-ports-kde
Path: blob/main/comms/bluegps/files/patch-bluegps.c
16461 views
1
--- bluegps.c 2006-06-26 20:28:31.000000000 +0200
2
+++ bluegps.c 2007-07-29 18:54:17.000000000 +0200
3
@@ -27,10 +27,21 @@
4
#include <stdarg.h>
5
#include <ctype.h>
6
7
+#ifdef __FreeBSD__
8
+#include <string.h>
9
+#include <sys/types.h>
10
+#include <sys/socket.h>
11
+#else
12
#include <netinet/ip.h>
13
+#endif
14
15
+
16
+#ifdef __FreeBSD__
17
+#include <bluetooth.h>
18
+#else
19
#include <bluetooth/bluetooth.h>
20
#include <bluetooth/rfcomm.h>
21
+#endif
22
23
#include "rbt3000.h"
24
25
@@ -269,19 +280,44 @@
26
int
27
rbt3000_connect (char *device_addr)
28
{
29
-
30
+#ifdef __FreeBSD__
31
+ struct sockaddr_rfcomm rem_addr;
32
+ struct hostent * he;
33
+
34
+ memset(&rem_addr, 0, sizeof(rem_addr));
35
+ rem_addr.rfcomm_len = sizeof(rem_addr);
36
+ rem_addr.rfcomm_family = AF_BLUETOOTH;
37
+ rem_addr.rfcomm_channel = RFCOMM_CHANNEL;
38
+
39
+ if ((he = bt_gethostbyname(device_addr))) {
40
+ context->device = *(bdaddr_t *) he->h_addr_list[0];
41
+ if (context->messages == MSG_VERBOSE)
42
+ printf("Actual BT address for '%s': %s\n",
43
+ device_addr, bt_ntoa(&(context->device),NULL));
44
+ } else
45
+ if (!bt_aton(device_addr, &context->device)) {
46
+ perror("No such device address");
47
+ return 0;
48
+ }
49
+ rem_addr.rfcomm_bdaddr = context->device;
50
+#else
51
struct sockaddr_rc rem_addr;
52
53
- baswap (&context->device, strtoba (device_addr));
54
-
55
rem_addr.rc_family = AF_BLUETOOTH;
56
- rem_addr.rc_bdaddr = context->device;
57
rem_addr.rc_channel = RFCOMM_CHANNEL;
58
+ baswap (&context->device, strtoba (device_addr));
59
+ rem_addr.rc_bdaddr = context->device;
60
+#endif
61
62
/* bluez connects to BlueClient */
63
if ((context->device_fd = socket (PF_BLUETOOTH,
64
SOCK_STREAM,
65
- BTPROTO_RFCOMM)) < 0 )
66
+#ifdef __FreeBSD__
67
+ BLUETOOTH_PROTO_RFCOMM
68
+#else
69
+ BTPROTO_RFCOMM
70
+#endif
71
+ )) < 0 )
72
{
73
perror ("Can't create socket");
74
return 0;
75
76