C: #include <gpsd.h>
libgps
Calling gpsd_init() initializes a session structure to hold the data collected by the GPS.
The second argument must be a context structure. The library will use it for information that need to be shared between sessions; presently this includes the leap-second correction and possibly a pointer to a shared-memory segment used to communicate with the Network Time Protocol daemon.
After the session structure has been set up, you may modify some of its members.
gpsd_device
baudrate
raw_hook
gpsd_activate() initializes the connection to the GPS. gpsd_deactivate() closes the connection. These functions are provided so that long-running programs can release a connection when there is no activity requiring the GPS, and re-acquire it later.
gpsd_poll() queries the GPS and updates the part of the session structure that holds position, speed, GPS signal quality, and other data returned by the GPS. It returns a mask describing which fields have changed.
gpsd_wrap() ends the session, implicitly performing a gpsd_deactivate().
The calling application must define one additional function: gpsd_report(). The library will use this to issue ordinary status messages. Use first argument of 0 for errors, 1 for ordinary status messages, and 2 or higher for debugging messages.
The low-level functions do not allocate or free any dynamic storage. They can thus be used in a long-running application (such as gpsd(8) itself) with a guarantee that they won't cause memory leaks.
Writes to the context structure members are not guarded by a mutex.
Eric S. Raymond <esr@thyrsus.com> based partly on earlier work by Remco Treffkorn, Derrick Brashear, and Russ Nelson.