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.
This commit is contained in:
Jef Driesen 2008-09-03 10:16:35 +00:00
parent 376ce23ce2
commit 276f45acd2
10 changed files with 152 additions and 130 deletions

View File

@ -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 */
};

View File

@ -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 */
};

View File

@ -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 */
};

View File

@ -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 */
};

View File

@ -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 */
};

View File

@ -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 */
};

View File

@ -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 */
};

View File

@ -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 */
};

View File

@ -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 */
};

View File

@ -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 */
};