Diffstat (limited to 'gammu/emb/common/device/irda') (more/less context) (ignore whitespace changes)
-rw-r--r-- | gammu/emb/common/device/irda/irda.c | 8 | ||||
-rw-r--r-- | gammu/emb/common/device/irda/irda_unx.h | 2 |
2 files changed, 7 insertions, 3 deletions
diff --git a/gammu/emb/common/device/irda/irda.c b/gammu/emb/common/device/irda/irda.c index fef50ac..e680377 100644 --- a/gammu/emb/common/device/irda/irda.c +++ b/gammu/emb/common/device/irda/irda.c | |||
@@ -1,51 +1,55 @@ | |||
1 | /* (c) 2001-2004 by Marcin Wiacek */ | 1 | /* (c) 2001-2004 by Marcin Wiacek */ |
2 | /* based on some work from Ralf Thelen and MyGnokii */ | 2 | /* based on some work from Ralf Thelen and MyGnokii (www.mwiacek.com) */ |
3 | /* based on some work from Gnokii and MSDN */ | 3 | /* based on some work from MSDN */ |
4 | /* based on some work from Gnokii (www.gnokii.org) | ||
5 | * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot | ||
6 | * GNU GPL version 2 or later | ||
7 | */ | ||
4 | 8 | ||
5 | /* You have to include wsock32.lib library to MS VC project to compile it */ | 9 | /* You have to include wsock32.lib library to MS VC project to compile it */ |
6 | 10 | ||
7 | #include "../../gsmstate.h" | 11 | #include "../../gsmstate.h" |
8 | 12 | ||
9 | #ifdef GSM_ENABLE_IRDADEVICE | 13 | #ifdef GSM_ENABLE_IRDADEVICE |
10 | #ifndef DJGPP | 14 | #ifndef DJGPP |
11 | 15 | ||
12 | #ifndef WIN32 | 16 | #ifndef WIN32 |
13 | # include <stdlib.h> | 17 | # include <stdlib.h> |
14 | # include <unistd.h> | 18 | # include <unistd.h> |
15 | # include <stdio.h> | 19 | # include <stdio.h> |
16 | # include <fcntl.h> | 20 | # include <fcntl.h> |
17 | # include <errno.h> | 21 | # include <errno.h> |
18 | # include <string.h> | 22 | # include <string.h> |
19 | # include <sys/time.h> | 23 | # include <sys/time.h> |
20 | # include <sys/poll.h> | 24 | # include <sys/poll.h> |
21 | # include <sys/socket.h> | 25 | # include <sys/socket.h> |
22 | # include <sys/ioctl.h> | 26 | # include <sys/ioctl.h> |
23 | #else | 27 | #else |
24 | # include <windows.h> | 28 | # include <windows.h> |
25 | # include <io.h> | 29 | # include <io.h> |
26 | #endif | 30 | #endif |
27 | 31 | ||
28 | #include "../../gsmcomon.h" | 32 | #include "../../gsmcomon.h" |
29 | #include "../devfunc.h" | 33 | #include "../devfunc.h" |
30 | #include "irda.h" | 34 | #include "irda.h" |
31 | 35 | ||
32 | static bool irda_discover_device(GSM_StateMachine *state) | 36 | static bool irda_discover_device(GSM_StateMachine *state) |
33 | { | 37 | { |
34 | GSM_Device_IrdaData *d = &state->Device.Data.Irda; | 38 | GSM_Device_IrdaData *d = &state->Device.Data.Irda; |
35 | struct irda_device_list*list; | 39 | struct irda_device_list*list; |
36 | unsigned char *buf; | 40 | unsigned char *buf; |
37 | unsigned int sec; | 41 | unsigned int sec; |
38 | int s, z, len, fd, i; | 42 | int s, z, len, fd, i; |
39 | GSM_DateTime Date; | 43 | GSM_DateTime Date; |
40 | bool founddevice = false; | 44 | bool founddevice = false; |
41 | #ifdef WIN32 | 45 | #ifdef WIN32 |
42 | int index; | 46 | int index; |
43 | #endif | 47 | #endif |
44 | 48 | ||
45 | fd = socket(AF_IRDA, SOCK_STREAM, 0); | 49 | fd = socket(AF_IRDA, SOCK_STREAM, 0); |
46 | 50 | ||
47 | /* can handle maximally 10 devices during discovering */ | 51 | /* can handle maximally 10 devices during discovering */ |
48 | len = sizeof(struct irda_device_list) + sizeof(struct irda_device_info) * 10; | 52 | len = sizeof(struct irda_device_list) + sizeof(struct irda_device_info) * 10; |
49 | buf = malloc(len); | 53 | buf = malloc(len); |
50 | list = (struct irda_device_list *)buf; | 54 | list = (struct irda_device_list *)buf; |
51 | 55 | ||
diff --git a/gammu/emb/common/device/irda/irda_unx.h b/gammu/emb/common/device/irda/irda_unx.h index 8dbcb97..7a55273 100644 --- a/gammu/emb/common/device/irda/irda_unx.h +++ b/gammu/emb/common/device/irda/irda_unx.h | |||
@@ -1,49 +1,49 @@ | |||
1 | /* part of irda.h available in Linux kernel source */ | 1 | /* part of irda.h available in Linux kernel source (www.kernel.org) */ |
2 | 2 | ||
3 | /********************************************************************* | 3 | /********************************************************************* |
4 | * | 4 | * |
5 | * Filename: irda.h | 5 | * Filename: irda.h |
6 | * Version: | 6 | * Version: |
7 | * Description: | 7 | * Description: |
8 | * Status: Experimental. | 8 | * Status: Experimental. |
9 | * Author: Dag Brattli <dagb@cs.uit.no> | 9 | * Author: Dag Brattli <dagb@cs.uit.no> |
10 | * Created at: Mon Mar 8 14:06:12 1999 | 10 | * Created at: Mon Mar 8 14:06:12 1999 |
11 | * Modified at: Sat Dec 25 16:06:42 1999 | 11 | * Modified at: Sat Dec 25 16:06:42 1999 |
12 | * Modified by: Dag Brattli <dagb@cs.uit.no> | 12 | * Modified by: Dag Brattli <dagb@cs.uit.no> |
13 | * | 13 | * |
14 | * Copyright (c) 1999 Dag Brattli, All Rights Reserved. | 14 | * Copyright (c) 1999 Dag Brattli, All Rights Reserved. |
15 | * | 15 | * |
16 | * This program is free software; you can redistribute it and/or | 16 | * This program is free software; you can redistribute it and/or |
17 | * modify it under the terms of the GNU General Public License as | 17 | * modify it under the terms of the GNU General Public License as |
18 | * published by the Free Software Foundation; either version 2 of | 18 | * published by the Free Software Foundation; either version 2 of |
19 | * the License, or (at your option) any later version. | 19 | * the License, or (at your option) any later version. |
20 | * | 20 | * |
21 | * Neither Dag Brattli nor University of Tromsų admit liability nor | 21 | * Neither Dag Brattli nor University of Tromsų admit liability nor |
22 | * provide warranty for any of this software. This material is | 22 | * provide warranty for any of this software. This material is |
23 | * provided "AS-IS" and at no charge. | 23 | * provided "AS-IS" and at no charge. |
24 | * | 24 | * |
25 | ********************************************************************/ | 25 | ********************************************************************/ |
26 | 26 | ||
27 | #ifndef __irda_unx_h | 27 | #ifndef __irda_unx_h |
28 | #define __irda_unx_h | 28 | #define __irda_unx_h |
29 | 29 | ||
30 | #include <sys/types.h> | 30 | #include <sys/types.h> |
31 | #include <sys/socket.h> | 31 | #include <sys/socket.h> |
32 | 32 | ||
33 | #define SOL_IRLMP 266 /* Same as SOL_IRDA for now */ | 33 | #define SOL_IRLMP 266 /* Same as SOL_IRDA for now */ |
34 | #define IRLMP_ENUMDEVICES 1 /* Return discovery log */ | 34 | #define IRLMP_ENUMDEVICES 1 /* Return discovery log */ |
35 | #define LSAP_ANY 0xff | 35 | #define LSAP_ANY 0xff |
36 | 36 | ||
37 | struct sockaddr_irda { | 37 | struct sockaddr_irda { |
38 | sa_family_t irdaAddressFamily;/* AF_IRDA */ | 38 | sa_family_t irdaAddressFamily;/* AF_IRDA */ |
39 | u_int8_t sir_lsap_sel; /* LSAP selector */ | 39 | u_int8_t sir_lsap_sel; /* LSAP selector */ |
40 | u_int32_t irdaDeviceID; /* Device address */ | 40 | u_int32_t irdaDeviceID; /* Device address */ |
41 | char irdaServiceName[25]; /* Usually <service>:IrDA:TinyTP */ | 41 | char irdaServiceName[25]; /* Usually <service>:IrDA:TinyTP */ |
42 | }; | 42 | }; |
43 | 43 | ||
44 | struct irda_device_info { | 44 | struct irda_device_info { |
45 | u_int32_t saddr; /* Address of local interface */ | 45 | u_int32_t saddr; /* Address of local interface */ |
46 | u_int32_t irdaDeviceID; /* Address of remote device */ | 46 | u_int32_t irdaDeviceID; /* Address of remote device */ |
47 | char irdaDeviceName[22]; /* Description */ | 47 | char irdaDeviceName[22]; /* Description */ |
48 | u_int8_t charset; /* Charset used for description */ | 48 | u_int8_t charset; /* Charset used for description */ |
49 | u_int8_t hints[2]; /* Hint bits */ | 49 | u_int8_t hints[2]; /* Hint bits */ |