gpsd-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gpsd-dev] [PATCH 2/8] Shift hex functions definitions into its own head


From: Rob Norris
Subject: [gpsd-dev] [PATCH 2/8] Shift hex functions definitions into its own header file.
Date: Tue, 19 Apr 2016 21:01:39 +0100

The reduces the reliance on gpsd.h in various files (particularly those as part 
of libgps).

TESTED:
'scons build-all check' passes.
---
 SConstruct     | 16 ++++++++++++++++
 ais_json.c     |  4 +---
 drivers.c      |  1 +
 gpsctl.c       |  1 +
 gpsd.c         |  1 +
 gpsd.h-tail    | 21 ---------------------
 gpsd_json.c    |  1 +
 gpsdecode.c    |  1 +
 gpsmon.c       |  1 +
 hex.c          |  4 +++-
 hex.h          | 24 ++++++++++++++++++++++++
 libgpsd_core.c |  1 +
 packet.c       |  1 +
 serial.c       |  1 +
 14 files changed, 53 insertions(+), 25 deletions(-)
 create mode 100644 hex.h

diff --git a/SConstruct b/SConstruct
index 1d486eb..3ae7424 100644
--- a/SConstruct
+++ b/SConstruct
@@ -829,6 +829,22 @@ int clock_gettime(clockid_t, struct timespec *);
 # endif
 #endif
 
+/*
+ * Definitions shared between gpsd and gpsd clients
+ *  are here to prevent reliance on gpsd.h
+ */
+
+/*
+ * The packet buffers need to be as long than the longest packet we
+ * expect to see in any protocol, because we have to be able to hold
+ * an entire packet for checksumming...
+ * First we thought it had to be big enough for a SiRF Measured Tracker
+ * Data packet (188 bytes). Then it had to be big enough for a UBX SVINFO
+ * packet (206 bytes). Now it turns out that a couple of ITALK messages are
+ * over 512 bytes. I know we like verbose output, but this is ridiculous.
+ */
+#define MAX_PACKET_LENGTH      516     /* 7 + 506 + 3 */
+
 #define GPSD_CONFIG_H
 #endif /* GPSD_CONFIG_H */
 ''')
diff --git a/ais_json.c b/ais_json.c
index 8481e47..b412d6c 100644
--- a/ais_json.c
+++ b/ais_json.c
@@ -21,9 +21,7 @@ representations to libgps structures.
 #include "json.h"
 #ifdef SOCKET_EXPORT_ENABLE
 #include "libgps.h"
-
-/* kluge because we don't want to include gpsd.h here */
-extern int gpsd_hexpack(const char *, char *, size_t);
+#include "hex.h"
 
 static void lenhex_unpack(const char *from,
                          size_t * plen, char *to, size_t maxlen)
diff --git a/drivers.c b/drivers.c
index 85b12a9..40c9628 100644
--- a/drivers.c
+++ b/drivers.c
@@ -12,6 +12,7 @@
 #include <unistd.h>
 
 #include "gpsd.h"
+#include "hex.h"
 #include "bits.h"              /* for getbeu16(), to extract big-endian words 
*/
 #include "strfuncs.h"
 
diff --git a/gpsctl.c b/gpsctl.c
index 4617e16..b7b4fd9 100644
--- a/gpsctl.c
+++ b/gpsctl.c
@@ -18,6 +18,7 @@
 #include <unistd.h>
 
 #include "gpsd.h"
+#include "hex.h"
 #include "revision.h"
 
 #ifdef SHM_EXPORT_ENABLE
diff --git a/gpsd.c b/gpsd.c
index 28148e3..121d5de 100644
--- a/gpsd.c
+++ b/gpsd.c
@@ -41,6 +41,7 @@
 #include "gpsd_config.h"
 
 #include "gpsd.h"
+#include "hex.h"
 #include "sockaddr.h"
 #include "gps_json.h"
 #include "revision.h"
diff --git a/gpsd.h-tail b/gpsd.h-tail
index eb32eb2..f5b87b2 100644
--- a/gpsd.h-tail
+++ b/gpsd.h-tail
@@ -93,17 +93,6 @@ enum isgpsstat_t {
 #define RTCM3_MAX      512
 
 /*
- * The packet buffers need to be as long than the longest packet we
- * expect to see in any protocol, because we have to be able to hold
- * an entire packet for checksumming...
- * First we thought it had to be big enough for a SiRF Measured Tracker
- * Data packet (188 bytes). Then it had to be big enough for a UBX SVINFO
- * packet (206 bytes). Now it turns out that a couple of ITALK messages are
- * over 512 bytes. I know we like verbose output, but this is ridiculous.
- */
-#define MAX_PACKET_LENGTH      516     /* 7 + 506 + 3 */
-
-/*
  * UTC of second 0 of week 0 of the first rollover period of GPS time.
  * Used to compute UTC from GPS time. Also, the threshold value
  * under which system clock times are considered unreliable. Often,
@@ -828,17 +817,7 @@ extern gps_mask_t gpsd_interpret_subframe(struct 
gps_device_t *, unsigned int,
                                uint32_t[]);
 extern gps_mask_t gpsd_interpret_subframe_raw(struct gps_device_t *,
                                unsigned int, uint32_t[]);
-extern const char *gpsd_hexdump(char *, size_t, char *, size_t);
-extern const char *gpsd_packetdump(char *, size_t, char *, size_t);
 extern const char *gpsd_prettydump(struct gps_device_t *);
-# ifdef __cplusplus
-extern "C" {
-# endif
-extern int gpsd_hexpack(const char *, char *, size_t);
-# ifdef __cplusplus
-}
-# endif
-extern ssize_t hex_escapes(char *, const char *);
 extern void gpsd_position_fix_dump(struct gps_device_t *,
                                   char[], size_t);
 extern void gpsd_clear_data(struct gps_device_t *);
diff --git a/gpsd_json.c b/gpsd_json.c
index 7d7e911..07d13dd 100644
--- a/gpsd_json.c
+++ b/gpsd_json.c
@@ -21,6 +21,7 @@ PERMISSIONS
 #include <ctype.h>
 
 #include "gpsd.h"
+#include "hex.h"
 #include "bits.h"
 #include "strfuncs.h"
 
diff --git a/gpsdecode.c b/gpsdecode.c
index 23c7684..c7362a5 100644
--- a/gpsdecode.c
+++ b/gpsdecode.c
@@ -10,6 +10,7 @@
 #include <unistd.h>
 
 #include "gpsd.h"
+#include "hex.h"
 #include "bits.h"
 #include "gps_json.h"
 #include "strfuncs.h"
diff --git a/gpsmon.c b/gpsmon.c
index c3eb3bd..8027fdf 100644
--- a/gpsmon.c
+++ b/gpsmon.c
@@ -24,6 +24,7 @@
 #include <unistd.h>
 
 #include "gpsd.h"
+#include "hex.h"
 #include "gps_json.h"
 #include "gpsmon.h"
 #include "gpsdclient.h"
diff --git a/hex.c b/hex.c
index 0326971..384bbf4 100644
--- a/hex.c
+++ b/hex.c
@@ -2,11 +2,13 @@
  * This file is Copyright (c) 2010 by the GPSD project
  * BSD terms apply: see the file COPYING in the distribution root for details.
  */
+#include <stdbool.h>
 #include <string.h>
 #include <ctype.h>
 #include <assert.h>
 
-#include "gpsd.h"
+#include "hex.h"
+#include "gpsd_config.h"
 
 /*
  * gpsd_packetdump()
diff --git a/hex.h b/hex.h
new file mode 100644
index 0000000..83f7c25
--- /dev/null
+++ b/hex.h
@@ -0,0 +1,24 @@
+/*
+ * This file is Copyright (c) 2010 by the GPSD project
+ * BSD terms apply: see the file COPYING in the distribution root for details.
+ */
+#ifndef _GPSD_HEX_H
+#define _GPSD_HEX_H
+
+#include <stddef.h>
+#include <sys/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern const char *gpsd_hexdump(char *, size_t, char *, size_t);
+extern const char *gpsd_packetdump(char *, size_t, char *, size_t);
+extern int gpsd_hexpack(const char *, char *, size_t);
+extern ssize_t hex_escapes(char *, const char *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _GPSD_HEX_H_ */
diff --git a/libgpsd_core.c b/libgpsd_core.c
index 12655a5..d4edde8 100644
--- a/libgpsd_core.c
+++ b/libgpsd_core.c
@@ -30,6 +30,7 @@
 #include <unistd.h>
 
 #include "gpsd.h"
+#include "hex.h"
 #include "matrix.h"
 #include "strfuncs.h"
 #if defined(NMEA2000_ENABLE)
diff --git a/packet.c b/packet.c
index 6e3125f..bb57a4f 100644
--- a/packet.c
+++ b/packet.c
@@ -39,6 +39,7 @@ PERMISSIONS
 
 #include "bits.h"
 #include "gpsd.h"
+#include "hex.h"
 #include "crc24q.h"
 #include "strfuncs.h"
 
diff --git a/serial.c b/serial.c
index d8bdd8c..481babf 100644
--- a/serial.c
+++ b/serial.c
@@ -24,6 +24,7 @@
 #endif /* ENABLE_BLUEZ */
 
 #include "gpsd.h"
+#include "hex.h"
 
 /* Workaround for HP-UX 11.23, which is missing CRTSCTS */
 #ifndef CRTSCTS
-- 
2.8.0.rc3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]