From 276f45acd28a1e48850069bc095d161f642a1445 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Wed, 3 Sep 2008 10:16:35 +0000 Subject: [PATCH] Allow the library to be compiled as C++ code. Moved the initialization of the backend pointers to the beginning of the source file. Without the need for a tentative definition, the library can be compiled with a C++ compiler. --- src/oceanic_atom2.c | 29 ++++++++++++++++------------- src/reefnet_sensuspro.c | 28 +++++++++++++++------------- src/reefnet_sensusultra.c | 28 +++++++++++++++------------- src/suunto_d9.c | 30 +++++++++++++++++------------- src/suunto_eon.c | 27 ++++++++++++++------------- src/suunto_vyper.c | 29 ++++++++++++++++------------- src/suunto_vyper2.c | 30 +++++++++++++++++------------- src/uwatec_aladin.c | 27 ++++++++++++++------------- src/uwatec_memomouse.c | 27 ++++++++++++++------------- src/uwatec_smart.c | 27 ++++++++++++++------------- 10 files changed, 152 insertions(+), 130 deletions(-) diff --git a/src/oceanic_atom2.c b/src/oceanic_atom2.c index c238270..fe4e26e 100644 --- a/src/oceanic_atom2.c +++ b/src/oceanic_atom2.c @@ -48,7 +48,22 @@ struct oceanic_atom2_device_t { struct serial *port; }; -static const device_backend_t oceanic_atom2_device_backend; +static device_status_t oceanic_atom2_device_version (device_t *abstract, unsigned char data[], unsigned int size); +static device_status_t oceanic_atom2_device_read (device_t *abstract, unsigned int address, unsigned char data[], unsigned int size); +static device_status_t oceanic_atom2_device_dump (device_t *abstract, unsigned char data[], unsigned int size, unsigned int *result); +static device_status_t oceanic_atom2_device_foreach (device_t *abstract, dive_callback_t callback, void *userdata); +static device_status_t oceanic_atom2_device_close (device_t *abstract); + +static const device_backend_t oceanic_atom2_device_backend = { + DEVICE_TYPE_OCEANIC_ATOM2, + NULL, /* handshake */ + oceanic_atom2_device_version, /* version */ + oceanic_atom2_device_read, /* read */ + NULL, /* write */ + oceanic_atom2_device_dump, /* dump */ + oceanic_atom2_device_foreach, /* foreach */ + oceanic_atom2_device_close /* close */ +}; static int device_is_oceanic_atom2 (device_t *abstract) @@ -482,15 +497,3 @@ oceanic_atom2_device_foreach (device_t *abstract, dive_callback_t callback, void return DEVICE_STATUS_SUCCESS; } - - -static const device_backend_t oceanic_atom2_device_backend = { - DEVICE_TYPE_OCEANIC_ATOM2, - NULL, /* handshake */ - oceanic_atom2_device_version, /* version */ - oceanic_atom2_device_read, /* read */ - NULL, /* write */ - oceanic_atom2_device_dump, /* dump */ - oceanic_atom2_device_foreach, /* foreach */ - oceanic_atom2_device_close /* close */ -}; diff --git a/src/reefnet_sensuspro.c b/src/reefnet_sensuspro.c index 464f9fb..7a14b87 100644 --- a/src/reefnet_sensuspro.c +++ b/src/reefnet_sensuspro.c @@ -26,7 +26,21 @@ struct reefnet_sensuspro_device_t { unsigned int timestamp; }; -static const device_backend_t reefnet_sensuspro_device_backend; +static device_status_t reefnet_sensuspro_device_handshake (device_t *abstract, unsigned char *data, unsigned int size); +static device_status_t reefnet_sensuspro_device_dump (device_t *abstract, unsigned char *data, unsigned int size, unsigned int *result); +static device_status_t reefnet_sensuspro_device_foreach (device_t *abstract, dive_callback_t callback, void *userdata); +static device_status_t reefnet_sensuspro_device_close (device_t *abstract); + +static const device_backend_t reefnet_sensuspro_device_backend = { + DEVICE_TYPE_REEFNET_SENSUSPRO, + reefnet_sensuspro_device_handshake, /* handshake */ + NULL, /* version */ + NULL, /* read */ + NULL, /* write */ + reefnet_sensuspro_device_dump, /* dump */ + reefnet_sensuspro_device_foreach, /* foreach */ + reefnet_sensuspro_device_close /* close */ +}; static int device_is_reefnet_sensuspro (device_t *abstract) @@ -341,15 +355,3 @@ reefnet_sensuspro_extract_dives (const unsigned char data[], unsigned int size, return DEVICE_STATUS_SUCCESS; } - - -static const device_backend_t reefnet_sensuspro_device_backend = { - DEVICE_TYPE_REEFNET_SENSUSPRO, - reefnet_sensuspro_device_handshake, /* handshake */ - NULL, /* version */ - NULL, /* read */ - NULL, /* write */ - reefnet_sensuspro_device_dump, /* dump */ - reefnet_sensuspro_device_foreach, /* foreach */ - reefnet_sensuspro_device_close /* close */ -}; diff --git a/src/reefnet_sensusultra.c b/src/reefnet_sensusultra.c index 6a58ee0..4b49186 100644 --- a/src/reefnet_sensusultra.c +++ b/src/reefnet_sensusultra.c @@ -31,7 +31,21 @@ struct reefnet_sensusultra_device_t { unsigned int timestamp; }; -static const device_backend_t reefnet_sensusultra_device_backend; +static device_status_t reefnet_sensusultra_device_handshake (device_t *abstract, unsigned char *data, unsigned int size); +static device_status_t reefnet_sensusultra_device_dump (device_t *abstract, unsigned char *data, unsigned int size, unsigned int *result); +static device_status_t reefnet_sensusultra_device_foreach (device_t *abstract, dive_callback_t callback, void *userdata); +static device_status_t reefnet_sensusultra_device_close (device_t *abstract); + +static const device_backend_t reefnet_sensusultra_device_backend = { + DEVICE_TYPE_REEFNET_SENSUSULTRA, + reefnet_sensusultra_device_handshake, /* handshake */ + NULL, /* version */ + NULL, /* read */ + NULL, /* write */ + reefnet_sensusultra_device_dump, /* dump */ + reefnet_sensusultra_device_foreach, /* foreach */ + reefnet_sensusultra_device_close /* close */ +}; static int device_is_reefnet_sensusultra (device_t *abstract) @@ -697,15 +711,3 @@ reefnet_sensusultra_extract_dives (const unsigned char data[], unsigned int size { return reefnet_sensusultra_parse (data, 0, size, NULL, NULL, callback, userdata, timestamp); } - - -static const device_backend_t reefnet_sensusultra_device_backend = { - DEVICE_TYPE_REEFNET_SENSUSULTRA, - reefnet_sensusultra_device_handshake, /* handshake */ - NULL, /* version */ - NULL, /* read */ - NULL, /* write */ - reefnet_sensusultra_device_dump, /* dump */ - reefnet_sensusultra_device_foreach, /* foreach */ - reefnet_sensusultra_device_close /* close */ -}; diff --git a/src/suunto_d9.c b/src/suunto_d9.c index 63c9944..f17a4a2 100644 --- a/src/suunto_d9.c +++ b/src/suunto_d9.c @@ -31,7 +31,23 @@ struct suunto_d9_device_t { struct serial *port; }; -static const device_backend_t suunto_d9_device_backend; +static device_status_t suunto_d9_device_version (device_t *abstract, unsigned char data[], unsigned int size); +static device_status_t suunto_d9_device_read (device_t *abstract, unsigned int address, unsigned char data[], unsigned int size); +static device_status_t suunto_d9_device_write (device_t *abstract, unsigned int address, const unsigned char data[], unsigned int size); +static device_status_t suunto_d9_device_dump (device_t *abstract, unsigned char data[], unsigned int size, unsigned int *result); +static device_status_t suunto_d9_device_foreach (device_t *abstract, dive_callback_t callback, void *userdata); +static device_status_t suunto_d9_device_close (device_t *abstract); + +static const device_backend_t suunto_d9_device_backend = { + DEVICE_TYPE_SUUNTO_D9, + NULL, /* handshake */ + suunto_d9_device_version, /* version */ + suunto_d9_device_read, /* read */ + suunto_d9_device_write, /* write */ + suunto_d9_device_dump, /* dump */ + suunto_d9_device_foreach, /* foreach */ + suunto_d9_device_close /* close */ +}; static int device_is_suunto_d9 (device_t *abstract) @@ -516,15 +532,3 @@ suunto_d9_device_foreach (device_t *abstract, dive_callback_t callback, void *us return DEVICE_STATUS_SUCCESS; } - - -static const device_backend_t suunto_d9_device_backend = { - DEVICE_TYPE_SUUNTO_D9, - NULL, /* handshake */ - suunto_d9_device_version, /* version */ - suunto_d9_device_read, /* read */ - suunto_d9_device_write, /* write */ - suunto_d9_device_dump, /* dump */ - suunto_d9_device_foreach, /* foreach */ - suunto_d9_device_close /* close */ -}; diff --git a/src/suunto_eon.c b/src/suunto_eon.c index dec8c1a..cf9e4f8 100644 --- a/src/suunto_eon.c +++ b/src/suunto_eon.c @@ -26,7 +26,20 @@ struct suunto_eon_device_t { struct serial *port; }; -static const device_backend_t suunto_eon_device_backend; +static device_status_t suunto_eon_device_dump (device_t *abstract, unsigned char data[], unsigned int size, unsigned int *result); +static device_status_t suunto_eon_device_foreach (device_t *abstract, dive_callback_t callback, void *userdata); +static device_status_t suunto_eon_device_close (device_t *abstract); + +static const device_backend_t suunto_eon_device_backend = { + DEVICE_TYPE_SUUNTO_EON, + NULL, /* handshake */ + NULL, /* version */ + NULL, /* read */ + NULL, /* write */ + suunto_eon_device_dump, /* dump */ + suunto_eon_device_foreach, /* foreach */ + suunto_eon_device_close /* close */ +}; static int device_is_suunto_eon (device_t *abstract) @@ -242,15 +255,3 @@ suunto_eon_extract_dives (const unsigned char data[], unsigned int size, dive_ca return suunto_common_extract_dives (data, 0x100, SUUNTO_EON_MEMORY_SIZE, eop, 3, callback, userdata); } - - -static const device_backend_t suunto_eon_device_backend = { - DEVICE_TYPE_SUUNTO_EON, - NULL, /* handshake */ - NULL, /* version */ - NULL, /* read */ - NULL, /* write */ - suunto_eon_device_dump, /* dump */ - suunto_eon_device_foreach, /* foreach */ - suunto_eon_device_close /* close */ -}; diff --git a/src/suunto_vyper.c b/src/suunto_vyper.c index 0202b2f..58be3ce 100644 --- a/src/suunto_vyper.c +++ b/src/suunto_vyper.c @@ -29,7 +29,22 @@ struct suunto_vyper_device_t { unsigned int delay; }; -static const device_backend_t suunto_vyper_device_backend; +static device_status_t suunto_vyper_device_read (device_t *abstract, unsigned int address, unsigned char data[], unsigned int size); +static device_status_t suunto_vyper_device_write (device_t *abstract, unsigned int address, const unsigned char data[], unsigned int size); +static device_status_t suunto_vyper_device_dump (device_t *abstract, unsigned char data[], unsigned int size, unsigned int *result); +static device_status_t suunto_vyper_device_foreach (device_t *abstract, dive_callback_t callback, void *userdata); +static device_status_t suunto_vyper_device_close (device_t *abstract); + +static const device_backend_t suunto_vyper_device_backend = { + DEVICE_TYPE_SUUNTO_VYPER, + NULL, /* handshake */ + NULL, /* version */ + suunto_vyper_device_read, /* read */ + suunto_vyper_device_write, /* write */ + suunto_vyper_device_dump, /* dump */ + suunto_vyper_device_foreach, /* foreach */ + suunto_vyper_device_close /* close */ +}; static int device_is_suunto_vyper (device_t *abstract) @@ -618,15 +633,3 @@ suunto_spyder_extract_dives (const unsigned char data[], unsigned int size, dive return suunto_common_extract_dives (data, 0x4C, SUUNTO_VYPER_MEMORY_SIZE, eop, 3, callback, userdata); } - - -static const device_backend_t suunto_vyper_device_backend = { - DEVICE_TYPE_SUUNTO_VYPER, - NULL, /* handshake */ - NULL, /* version */ - suunto_vyper_device_read, /* read */ - suunto_vyper_device_write, /* write */ - suunto_vyper_device_dump, /* dump */ - suunto_vyper_device_foreach, /* foreach */ - suunto_vyper_device_close /* close */ -}; diff --git a/src/suunto_vyper2.c b/src/suunto_vyper2.c index a65134a..7ffa682 100644 --- a/src/suunto_vyper2.c +++ b/src/suunto_vyper2.c @@ -31,7 +31,23 @@ struct suunto_vyper2_device_t { struct serial *port; }; -static const device_backend_t suunto_vyper2_device_backend; +static device_status_t suunto_vyper2_device_version (device_t *abstract, unsigned char data[], unsigned int size); +static device_status_t suunto_vyper2_device_read (device_t *abstract, unsigned int address, unsigned char data[], unsigned int size); +static device_status_t suunto_vyper2_device_write (device_t *abstract, unsigned int address, const unsigned char data[], unsigned int size); +static device_status_t suunto_vyper2_device_dump (device_t *abstract, unsigned char data[], unsigned int size, unsigned int *result); +static device_status_t suunto_vyper2_device_foreach (device_t *abstract, dive_callback_t callback, void *userdata); +static device_status_t suunto_vyper2_device_close (device_t *abstract); + +static const device_backend_t suunto_vyper2_device_backend = { + DEVICE_TYPE_SUUNTO_VYPER2, + NULL, /* handshake */ + suunto_vyper2_device_version, /* version */ + suunto_vyper2_device_read, /* read */ + suunto_vyper2_device_write, /* write */ + suunto_vyper2_device_dump, /* dump */ + suunto_vyper2_device_foreach, /* foreach */ + suunto_vyper2_device_close /* close */ +}; static int device_is_suunto_vyper2 (device_t *abstract) @@ -503,15 +519,3 @@ suunto_vyper2_device_foreach (device_t *abstract, dive_callback_t callback, void return DEVICE_STATUS_SUCCESS; } - - -static const device_backend_t suunto_vyper2_device_backend = { - DEVICE_TYPE_SUUNTO_VYPER2, - NULL, /* handshake */ - suunto_vyper2_device_version, /* version */ - suunto_vyper2_device_read, /* read */ - suunto_vyper2_device_write, /* write */ - suunto_vyper2_device_dump, /* dump */ - suunto_vyper2_device_foreach, /* foreach */ - suunto_vyper2_device_close /* close */ -}; diff --git a/src/uwatec_aladin.c b/src/uwatec_aladin.c index 701b48c..2248fe6 100644 --- a/src/uwatec_aladin.c +++ b/src/uwatec_aladin.c @@ -30,7 +30,20 @@ struct uwatec_aladin_device_t { unsigned int timestamp; }; -static const device_backend_t uwatec_aladin_device_backend; +static device_status_t uwatec_aladin_device_dump (device_t *abstract, unsigned char data[], unsigned int size, unsigned int *result); +static device_status_t uwatec_aladin_device_foreach (device_t *abstract, dive_callback_t callback, void *userdata); +static device_status_t uwatec_aladin_device_close (device_t *abstract); + +static const device_backend_t uwatec_aladin_device_backend = { + DEVICE_TYPE_UWATEC_ALADIN, + NULL, /* handshake */ + NULL, /* version */ + NULL, /* read */ + NULL, /* write */ + uwatec_aladin_device_dump, /* dump */ + uwatec_aladin_device_foreach, /* foreach */ + uwatec_aladin_device_close /* close */ +}; static int device_is_uwatec_aladin (device_t *abstract) @@ -330,15 +343,3 @@ uwatec_aladin_extract_dives (const unsigned char* data, unsigned int size, dive_ return DEVICE_STATUS_SUCCESS; } - - -static const device_backend_t uwatec_aladin_device_backend = { - DEVICE_TYPE_UWATEC_ALADIN, - NULL, /* handshake */ - NULL, /* version */ - NULL, /* read */ - NULL, /* write */ - uwatec_aladin_device_dump, /* dump */ - uwatec_aladin_device_foreach, /* foreach */ - uwatec_aladin_device_close /* close */ -}; diff --git a/src/uwatec_memomouse.c b/src/uwatec_memomouse.c index cb95e74..aaa0f8a 100644 --- a/src/uwatec_memomouse.c +++ b/src/uwatec_memomouse.c @@ -30,7 +30,20 @@ struct uwatec_memomouse_device_t { unsigned int timestamp; }; -static const device_backend_t uwatec_memomouse_device_backend; +static device_status_t uwatec_memomouse_device_dump (device_t *abstract, unsigned char data[], unsigned int size, unsigned int *result); +static device_status_t uwatec_memomouse_device_foreach (device_t *abstract, dive_callback_t callback, void *userdata); +static device_status_t uwatec_memomouse_device_close (device_t *abstract); + +static const device_backend_t uwatec_memomouse_device_backend = { + DEVICE_TYPE_UWATEC_MEMOMOUSE, + NULL, /* handshake */ + NULL, /* version */ + NULL, /* read */ + NULL, /* write */ + uwatec_memomouse_device_dump, /* dump */ + uwatec_memomouse_device_foreach, /* foreach */ + uwatec_memomouse_device_close /* close */ +}; static int device_is_uwatec_memomouse (device_t *abstract) @@ -523,15 +536,3 @@ uwatec_memomouse_extract_dives (const unsigned char data[], unsigned int size, d return DEVICE_STATUS_SUCCESS; } - - -static const device_backend_t uwatec_memomouse_device_backend = { - DEVICE_TYPE_UWATEC_MEMOMOUSE, - NULL, /* handshake */ - NULL, /* version */ - NULL, /* read */ - NULL, /* write */ - uwatec_memomouse_device_dump, /* dump */ - uwatec_memomouse_device_foreach, /* foreach */ - uwatec_memomouse_device_close /* close */ -}; diff --git a/src/uwatec_smart.c b/src/uwatec_smart.c index b4dd9dd..4dac230 100644 --- a/src/uwatec_smart.c +++ b/src/uwatec_smart.c @@ -27,7 +27,20 @@ struct uwatec_smart_device_t { unsigned int timestamp; }; -static const device_backend_t uwatec_smart_device_backend; +static device_status_t uwatec_smart_device_dump (device_t *abstract, unsigned char data[], unsigned int size, unsigned int *result); +static device_status_t uwatec_smart_device_foreach (device_t *abstract, dive_callback_t callback, void *userdata); +static device_status_t uwatec_smart_device_close (device_t *abstract); + +static const device_backend_t uwatec_smart_device_backend = { + DEVICE_TYPE_UWATEC_SMART, + NULL, /* handshake */ + NULL, /* version */ + NULL, /* read */ + NULL, /* write */ + uwatec_smart_device_dump, /* dump */ + uwatec_smart_device_foreach, /* foreach */ + uwatec_smart_device_close /* close */ +}; static int device_is_uwatec_smart (device_t *abstract) @@ -478,15 +491,3 @@ uwatec_smart_extract_dives (const unsigned char data[], unsigned int size, dive_ return DEVICE_STATUS_SUCCESS; } - - -static const device_backend_t uwatec_smart_device_backend = { - DEVICE_TYPE_UWATEC_SMART, - NULL, /* handshake */ - NULL, /* version */ - NULL, /* read */ - NULL, /* write */ - uwatec_smart_device_dump, /* dump */ - uwatec_smart_device_foreach, /* foreach */ - uwatec_smart_device_close /* close */ -};