Move the dummy IrDA implementation
The dummy IrDA implementation is integrated in the main file. The appropriate implementation is selected using conditional compilation based on the features detect by the autotools build system.
This commit is contained in:
parent
0b22a2ba33
commit
404cea7417
10
configure.ac
10
configure.ac
@ -114,13 +114,13 @@ AS_IF([test "x$with_hidapi" != "xno"], [
|
|||||||
AC_SUBST([DEPENDENCIES])
|
AC_SUBST([DEPENDENCIES])
|
||||||
|
|
||||||
# Checks for IrDA support.
|
# Checks for IrDA support.
|
||||||
AC_CHECK_HEADERS([winsock2.h af_irda.h], [irda_win32=yes], [irda_win32=no], [
|
AC_CHECK_HEADERS([winsock2.h af_irda.h], , , [
|
||||||
#if HAVE_WINSOCK2_H
|
#if HAVE_WINSOCK2_H
|
||||||
# include <winsock2.h>
|
# include <winsock2.h>
|
||||||
# endif
|
# endif
|
||||||
])
|
])
|
||||||
|
|
||||||
AC_CHECK_HEADERS([sys/socket.h linux/types.h linux/irda.h], [irda_linux=yes], [irda_linux=no], [
|
AC_CHECK_HEADERS([sys/socket.h linux/types.h linux/irda.h], , , [
|
||||||
#if HAVE_SYS_SOCKET_H
|
#if HAVE_SYS_SOCKET_H
|
||||||
# include <sys/socket.h>
|
# include <sys/socket.h>
|
||||||
# endif
|
# endif
|
||||||
@ -129,12 +129,6 @@ AC_CHECK_HEADERS([sys/socket.h linux/types.h linux/irda.h], [irda_linux=yes], [i
|
|||||||
# endif
|
# endif
|
||||||
])
|
])
|
||||||
|
|
||||||
if test "$irda_win32" = "yes" || test "$irda_linux" = "yes"; then
|
|
||||||
AC_DEFINE([HAVE_IRDA], [1], [IrDA support])
|
|
||||||
fi
|
|
||||||
|
|
||||||
AM_CONDITIONAL([IRDA], [test "$irda_win32" = "yes" || test "$irda_linux" = "yes"])
|
|
||||||
|
|
||||||
# Checks for header files.
|
# Checks for header files.
|
||||||
AC_CHECK_HEADERS([linux/serial.h])
|
AC_CHECK_HEADERS([linux/serial.h])
|
||||||
AC_CHECK_HEADERS([IOKit/serial/ioss.h])
|
AC_CHECK_HEADERS([IOKit/serial/ioss.h])
|
||||||
|
|||||||
@ -42,7 +42,7 @@
|
|||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="0"
|
Optimization="0"
|
||||||
AdditionalIncludeDirectories="..\include"
|
AdditionalIncludeDirectories="..\include"
|
||||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBDIVECOMPUTER_EXPORTS;ENABLE_LOGGING;HAVE_IRDA"
|
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBDIVECOMPUTER_EXPORTS;ENABLE_LOGGING;HAVE_AF_IRDA_H"
|
||||||
MinimalRebuild="true"
|
MinimalRebuild="true"
|
||||||
BasicRuntimeChecks="3"
|
BasicRuntimeChecks="3"
|
||||||
RuntimeLibrary="3"
|
RuntimeLibrary="3"
|
||||||
@ -119,7 +119,7 @@
|
|||||||
Optimization="2"
|
Optimization="2"
|
||||||
EnableIntrinsicFunctions="true"
|
EnableIntrinsicFunctions="true"
|
||||||
AdditionalIncludeDirectories="..\include"
|
AdditionalIncludeDirectories="..\include"
|
||||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBDIVECOMPUTER_EXPORTS;ENABLE_LOGGING;HAVE_IRDA"
|
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBDIVECOMPUTER_EXPORTS;ENABLE_LOGGING;HAVE_AF_IRDA_H"
|
||||||
RuntimeLibrary="2"
|
RuntimeLibrary="2"
|
||||||
EnableFunctionLevelLinking="true"
|
EnableFunctionLevelLinking="true"
|
||||||
UsePrecompiledHeader="0"
|
UsePrecompiledHeader="0"
|
||||||
|
|||||||
@ -10,6 +10,7 @@ libdivecomputer_la_LDFLAGS = \
|
|||||||
-export-symbols libdivecomputer.exp
|
-export-symbols libdivecomputer.exp
|
||||||
|
|
||||||
if OS_WIN32
|
if OS_WIN32
|
||||||
|
libdivecomputer_la_LIBADD += -lws2_32
|
||||||
libdivecomputer_la_LDFLAGS += -Wc,-static-libgcc
|
libdivecomputer_la_LDFLAGS += -Wc,-static-libgcc
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -74,15 +75,7 @@ else
|
|||||||
libdivecomputer_la_SOURCES += serial.h serial_posix.c
|
libdivecomputer_la_SOURCES += serial.h serial_posix.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if IRDA
|
|
||||||
if OS_WIN32
|
|
||||||
libdivecomputer_la_LIBADD += -lws2_32
|
|
||||||
endif
|
|
||||||
libdivecomputer_la_SOURCES += irda.h irda.c
|
libdivecomputer_la_SOURCES += irda.h irda.c
|
||||||
else
|
|
||||||
libdivecomputer_la_SOURCES += irda.h irda_dummy.c
|
|
||||||
endif
|
|
||||||
|
|
||||||
libdivecomputer_la_SOURCES += usbhid.h usbhid.c
|
libdivecomputer_la_SOURCES += usbhid.h usbhid.c
|
||||||
|
|
||||||
if OS_WIN32
|
if OS_WIN32
|
||||||
|
|||||||
@ -29,6 +29,16 @@
|
|||||||
#define USBHID
|
#define USBHID
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#ifdef HAVE_AF_IRDA_H
|
||||||
|
#define IRDA
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#ifdef HAVE_LINUX_IRDA_H
|
||||||
|
#define IRDA
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
@ -100,7 +110,7 @@ static const dc_descriptor_t g_descriptors[] = {
|
|||||||
/* Uwatec Memomouse */
|
/* Uwatec Memomouse */
|
||||||
{"Uwatec", "Memomouse", DC_FAMILY_UWATEC_MEMOMOUSE, 0},
|
{"Uwatec", "Memomouse", DC_FAMILY_UWATEC_MEMOMOUSE, 0},
|
||||||
/* Uwatec Smart */
|
/* Uwatec Smart */
|
||||||
#ifdef HAVE_IRDA
|
#ifdef IRDA
|
||||||
{"Uwatec", "Smart Pro", DC_FAMILY_UWATEC_SMART, 0x10},
|
{"Uwatec", "Smart Pro", DC_FAMILY_UWATEC_SMART, 0x10},
|
||||||
{"Uwatec", "Galileo Sol", DC_FAMILY_UWATEC_SMART, 0x11},
|
{"Uwatec", "Galileo Sol", DC_FAMILY_UWATEC_SMART, 0x11},
|
||||||
{"Uwatec", "Galileo Luna", DC_FAMILY_UWATEC_SMART, 0x11},
|
{"Uwatec", "Galileo Luna", DC_FAMILY_UWATEC_SMART, 0x11},
|
||||||
|
|||||||
48
src/irda.c
48
src/irda.c
@ -19,21 +19,31 @@
|
|||||||
* MA 02110-1301 USA
|
* MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <stdlib.h> // malloc, free
|
#include <stdlib.h> // malloc, free
|
||||||
#include <stdio.h> // snprintf
|
#include <stdio.h> // snprintf
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define NOGDI
|
#define NOGDI
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#ifdef HAVE_AF_IRDA_H
|
||||||
|
#define IRDA
|
||||||
#include <af_irda.h>
|
#include <af_irda.h>
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
#include <string.h> // strerror
|
#include <string.h> // strerror
|
||||||
#include <errno.h> // errno
|
#include <errno.h> // errno
|
||||||
#include <unistd.h> // close
|
#include <unistd.h> // close
|
||||||
#include <sys/types.h> // socket, getsockopt
|
#include <sys/types.h> // socket, getsockopt
|
||||||
#include <sys/socket.h> // socket, getsockopt
|
#include <sys/socket.h> // socket, getsockopt
|
||||||
|
#ifdef HAVE_LINUX_IRDA_H
|
||||||
|
#define IRDA
|
||||||
#include <linux/types.h> // irda
|
#include <linux/types.h> // irda
|
||||||
#include <linux/irda.h> // irda
|
#include <linux/irda.h> // irda
|
||||||
|
#endif
|
||||||
#include <sys/select.h> // select
|
#include <sys/select.h> // select
|
||||||
#include <sys/ioctl.h> // ioctl
|
#include <sys/ioctl.h> // ioctl
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
@ -86,6 +96,7 @@ struct dc_irda_t {
|
|||||||
int timeout;
|
int timeout;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef IRDA
|
||||||
static dc_status_t
|
static dc_status_t
|
||||||
syserror(s_errcode_t errcode)
|
syserror(s_errcode_t errcode)
|
||||||
{
|
{
|
||||||
@ -102,10 +113,12 @@ syserror(s_errcode_t errcode)
|
|||||||
return DC_STATUS_IO;
|
return DC_STATUS_IO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
dc_status_t
|
dc_status_t
|
||||||
dc_irda_open (dc_irda_t **out, dc_context_t *context)
|
dc_irda_open (dc_irda_t **out, dc_context_t *context)
|
||||||
{
|
{
|
||||||
|
#ifdef IRDA
|
||||||
dc_status_t status = DC_STATUS_SUCCESS;
|
dc_status_t status = DC_STATUS_SUCCESS;
|
||||||
dc_irda_t *device = NULL;
|
dc_irda_t *device = NULL;
|
||||||
|
|
||||||
@ -167,11 +180,15 @@ error_free:
|
|||||||
#endif
|
#endif
|
||||||
free (device);
|
free (device);
|
||||||
return status;
|
return status;
|
||||||
|
#else
|
||||||
|
return DC_STATUS_UNSUPPORTED;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
dc_status_t
|
dc_status_t
|
||||||
dc_irda_close (dc_irda_t *device)
|
dc_irda_close (dc_irda_t *device)
|
||||||
{
|
{
|
||||||
|
#ifdef IRDA
|
||||||
dc_status_t status = DC_STATUS_SUCCESS;
|
dc_status_t status = DC_STATUS_SUCCESS;
|
||||||
|
|
||||||
if (device == NULL)
|
if (device == NULL)
|
||||||
@ -200,11 +217,15 @@ dc_irda_close (dc_irda_t *device)
|
|||||||
free (device);
|
free (device);
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
|
#else
|
||||||
|
return DC_STATUS_UNSUPPORTED;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
dc_status_t
|
dc_status_t
|
||||||
dc_irda_set_timeout (dc_irda_t *device, int timeout)
|
dc_irda_set_timeout (dc_irda_t *device, int timeout)
|
||||||
{
|
{
|
||||||
|
#ifdef IRDA
|
||||||
if (device == NULL)
|
if (device == NULL)
|
||||||
return DC_STATUS_INVALIDARGS;
|
return DC_STATUS_INVALIDARGS;
|
||||||
|
|
||||||
@ -213,6 +234,9 @@ dc_irda_set_timeout (dc_irda_t *device, int timeout)
|
|||||||
device->timeout = timeout;
|
device->timeout = timeout;
|
||||||
|
|
||||||
return DC_STATUS_SUCCESS;
|
return DC_STATUS_SUCCESS;
|
||||||
|
#else
|
||||||
|
return DC_STATUS_UNSUPPORTED;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -230,6 +254,7 @@ dc_irda_set_timeout (dc_irda_t *device, int timeout)
|
|||||||
dc_status_t
|
dc_status_t
|
||||||
dc_irda_discover (dc_irda_t *device, dc_irda_callback_t callback, void *userdata)
|
dc_irda_discover (dc_irda_t *device, dc_irda_callback_t callback, void *userdata)
|
||||||
{
|
{
|
||||||
|
#ifdef IRDA
|
||||||
if (device == NULL)
|
if (device == NULL)
|
||||||
return DC_STATUS_INVALIDARGS;
|
return DC_STATUS_INVALIDARGS;
|
||||||
|
|
||||||
@ -303,11 +328,15 @@ dc_irda_discover (dc_irda_t *device, dc_irda_callback_t callback, void *userdata
|
|||||||
}
|
}
|
||||||
|
|
||||||
return DC_STATUS_SUCCESS;
|
return DC_STATUS_SUCCESS;
|
||||||
|
#else
|
||||||
|
return DC_STATUS_UNSUPPORTED;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
dc_status_t
|
dc_status_t
|
||||||
dc_irda_connect_name (dc_irda_t *device, unsigned int address, const char *name)
|
dc_irda_connect_name (dc_irda_t *device, unsigned int address, const char *name)
|
||||||
{
|
{
|
||||||
|
#ifdef IRDA
|
||||||
if (device == NULL)
|
if (device == NULL)
|
||||||
return DC_STATUS_INVALIDARGS;
|
return DC_STATUS_INVALIDARGS;
|
||||||
|
|
||||||
@ -341,11 +370,15 @@ dc_irda_connect_name (dc_irda_t *device, unsigned int address, const char *name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return DC_STATUS_SUCCESS;
|
return DC_STATUS_SUCCESS;
|
||||||
|
#else
|
||||||
|
return DC_STATUS_UNSUPPORTED;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
dc_status_t
|
dc_status_t
|
||||||
dc_irda_connect_lsap (dc_irda_t *device, unsigned int address, unsigned int lsap)
|
dc_irda_connect_lsap (dc_irda_t *device, unsigned int address, unsigned int lsap)
|
||||||
{
|
{
|
||||||
|
#ifdef IRDA
|
||||||
if (device == NULL)
|
if (device == NULL)
|
||||||
return DC_STATUS_INVALIDARGS;
|
return DC_STATUS_INVALIDARGS;
|
||||||
|
|
||||||
@ -374,11 +407,15 @@ dc_irda_connect_lsap (dc_irda_t *device, unsigned int address, unsigned int lsap
|
|||||||
}
|
}
|
||||||
|
|
||||||
return DC_STATUS_SUCCESS;
|
return DC_STATUS_SUCCESS;
|
||||||
|
#else
|
||||||
|
return DC_STATUS_UNSUPPORTED;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
dc_status_t
|
dc_status_t
|
||||||
dc_irda_get_available (dc_irda_t *device, size_t *value)
|
dc_irda_get_available (dc_irda_t *device, size_t *value)
|
||||||
{
|
{
|
||||||
|
#ifdef IRDA
|
||||||
if (device == NULL)
|
if (device == NULL)
|
||||||
return DC_STATUS_INVALIDARGS;
|
return DC_STATUS_INVALIDARGS;
|
||||||
|
|
||||||
@ -398,11 +435,15 @@ dc_irda_get_available (dc_irda_t *device, size_t *value)
|
|||||||
*value = bytes;
|
*value = bytes;
|
||||||
|
|
||||||
return DC_STATUS_SUCCESS;
|
return DC_STATUS_SUCCESS;
|
||||||
|
#else
|
||||||
|
return DC_STATUS_UNSUPPORTED;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
dc_status_t
|
dc_status_t
|
||||||
dc_irda_read (dc_irda_t *device, void *data, size_t size, size_t *actual)
|
dc_irda_read (dc_irda_t *device, void *data, size_t size, size_t *actual)
|
||||||
{
|
{
|
||||||
|
#ifdef IRDA
|
||||||
dc_status_t status = DC_STATUS_SUCCESS;
|
dc_status_t status = DC_STATUS_SUCCESS;
|
||||||
size_t nbytes = 0;
|
size_t nbytes = 0;
|
||||||
|
|
||||||
@ -463,11 +504,15 @@ out_invalidargs:
|
|||||||
*actual = nbytes;
|
*actual = nbytes;
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
|
#else
|
||||||
|
return DC_STATUS_UNSUPPORTED;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
dc_status_t
|
dc_status_t
|
||||||
dc_irda_write (dc_irda_t *device, const void *data, size_t size, size_t *actual)
|
dc_irda_write (dc_irda_t *device, const void *data, size_t size, size_t *actual)
|
||||||
{
|
{
|
||||||
|
#ifdef IRDA
|
||||||
dc_status_t status = DC_STATUS_SUCCESS;
|
dc_status_t status = DC_STATUS_SUCCESS;
|
||||||
size_t nbytes = 0;
|
size_t nbytes = 0;
|
||||||
|
|
||||||
@ -520,4 +565,7 @@ out_invalidargs:
|
|||||||
*actual = nbytes;
|
*actual = nbytes;
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
|
#else
|
||||||
|
return DC_STATUS_UNSUPPORTED;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,78 +0,0 @@
|
|||||||
/*
|
|
||||||
* libdivecomputer
|
|
||||||
*
|
|
||||||
* Copyright (C) 2010 Jef Driesen
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
||||||
* MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stddef.h>
|
|
||||||
|
|
||||||
#include "irda.h"
|
|
||||||
|
|
||||||
dc_status_t
|
|
||||||
dc_irda_open (dc_irda_t **out, dc_context_t *context)
|
|
||||||
{
|
|
||||||
return DC_STATUS_UNSUPPORTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
dc_status_t
|
|
||||||
dc_irda_close (dc_irda_t *device)
|
|
||||||
{
|
|
||||||
return DC_STATUS_UNSUPPORTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
dc_status_t
|
|
||||||
dc_irda_set_timeout (dc_irda_t *device, int timeout)
|
|
||||||
{
|
|
||||||
return DC_STATUS_UNSUPPORTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
dc_status_t
|
|
||||||
dc_irda_discover (dc_irda_t *device, dc_irda_callback_t callback, void *userdata)
|
|
||||||
{
|
|
||||||
return DC_STATUS_UNSUPPORTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
dc_status_t
|
|
||||||
dc_irda_connect_name (dc_irda_t *device, unsigned int address, const char *name)
|
|
||||||
{
|
|
||||||
return DC_STATUS_UNSUPPORTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
dc_status_t
|
|
||||||
dc_irda_connect_lsap (dc_irda_t *device, unsigned int address, unsigned int lsap)
|
|
||||||
{
|
|
||||||
return DC_STATUS_UNSUPPORTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
dc_status_t
|
|
||||||
dc_irda_get_available (dc_irda_t *device, size_t *value)
|
|
||||||
{
|
|
||||||
return DC_STATUS_UNSUPPORTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
dc_status_t
|
|
||||||
dc_irda_read (dc_irda_t *device, void *data, size_t size, size_t *actual)
|
|
||||||
{
|
|
||||||
return DC_STATUS_UNSUPPORTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
dc_status_t
|
|
||||||
dc_irda_write (dc_irda_t *device, const void *data, size_t size, size_t *actual)
|
|
||||||
{
|
|
||||||
return DC_STATUS_UNSUPPORTED;
|
|
||||||
}
|
|
||||||
Loading…
x
Reference in New Issue
Block a user