summaryrefslogtreecommitdiff
path: root/libgps_core.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2011-08-26 14:47:05 -0400
committerEric S. Raymond <esr@thyrsus.com>2011-08-26 14:47:05 -0400
commit574a52109b76e59e71fd4a8099ba0493e47e1e41 (patch)
tree210e232cc0d83eaf2db63726db52182437d13bd2 /libgps_core.c
parent13c7e896247e24d86b10249ce73d999559a99727 (diff)
downloadgpsd-574a52109b76e59e71fd4a8099ba0493e47e1e41.tar.gz
Make the sock_export=no build.
The way I fixed this extends the library API so some functions which were previously undefined for shm transport are now defined. This doesn't change the binary API of the library in the normal (sock_export=yes) case at all, so I'm not bumping its version. No changes in the daemon. All regression tests pass (in the normal sock_export=yes build).
Diffstat (limited to 'libgps_core.c')
-rw-r--r--libgps_core.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/libgps_core.c b/libgps_core.c
index 1aa11e44..eefaf783 100644
--- a/libgps_core.c
+++ b/libgps_core.c
@@ -7,6 +7,7 @@
*/
#include <stdio.h>
#include <stdlib.h>
+#include <stdarg.h>
#include <stdbool.h>
#include <string.h>
#include <ctype.h>
@@ -136,6 +137,64 @@ int gps_read(struct gps_data_t *gpsdata)
return status;
}
+int gps_send(struct gps_data_t *gpsdata CONDITIONALLY_UNUSED, const char *fmt CONDITIONALLY_UNUSED, ...)
+/* send a command to the gpsd instance */
+{
+ int status = -1;
+ char buf[BUFSIZ];
+ va_list ap;
+
+ va_start(ap, fmt);
+ (void)vsnprintf(buf, sizeof(buf) - 2, fmt, ap);
+ va_end(ap);
+ if (buf[strlen(buf) - 1] != '\n')
+ (void)strlcat(buf, "\n", BUFSIZ);
+
+#ifdef SOCKET_EXPORT_ENABLE
+ status = gps_sock_send(gpsdata, buf);
+#endif /* SOCKET_EXPORT_ENABLE */
+
+ return status;
+}
+
+int gps_stream(struct gps_data_t *gpsdata CONDITIONALLY_UNUSED,
+ unsigned int flags CONDITIONALLY_UNUSED,
+ /*@null@*/ void *d CONDITIONALLY_UNUSED)
+{
+ int status = -1;
+
+#ifdef SOCKET_EXPORT_ENABLE
+ status = gps_sock_stream(gpsdata, flags, d);
+#endif /* SOCKET_EXPORT_ENABLE */
+
+ return status;
+}
+
+const char /*@observer@*/ *gps_data(const struct gps_data_t *gpsdata CONDITIONALLY_UNUSED)
+/* return the contents of the client data buffer */
+{
+ const char *bufp = NULL;
+
+#ifdef SOCKET_EXPORT_ENABLE
+ bufp = gps_sock_data(gpsdata);
+#endif /* SOCKET_EXPORT_ENABLE */
+
+ return bufp;
+}
+
+bool gps_waiting(const struct gps_data_t *gpsdata CONDITIONALLY_UNUSED, int timeout CONDITIONALLY_UNUSED)
+/* is there input waiting from the GPS? */
+{
+ /* this is bogus, but I can't think of a better solution yet */
+ bool waiting = true;
+
+#ifdef SOCKET_EXPORT_ENABLE
+ waiting = gps_sock_waiting(gpsdata, timeout);
+#endif /* SOCKET_EXPORT_ENABLE */
+
+ return waiting;
+}
+
extern const char /*@observer@*/ *gps_errstr(const int err)
{
/*