diff options
author | Zbigniew Chyla <zbigniew.chyla@nsn.com> | 2015-01-16 15:46:59 +0100 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2015-01-21 10:47:00 -0500 |
commit | d0174ca4e78831bbdd798d02a481ba2569425722 (patch) | |
tree | 3bcdd83bb0e0fabcbc2e1e8e84c7befffc19c3cc /net_gnss_dispatch.c | |
parent | 39554efdf0416e35236ad3d23a3a893d90c68be6 (diff) | |
download | gpsd-d0174ca4e78831bbdd798d02a481ba2569425722.tar.gz |
Add str_starts_with macro, use it instead of strncmp.
This change doesn't affect generated binary code.
Diffstat (limited to 'net_gnss_dispatch.c')
-rw-r--r-- | net_gnss_dispatch.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/net_gnss_dispatch.c b/net_gnss_dispatch.c index 381e694c..b3dfd800 100644 --- a/net_gnss_dispatch.c +++ b/net_gnss_dispatch.c @@ -14,6 +14,7 @@ #endif /* S_SPLINT_S */ #include "gpsd.h" +#include "strfuncs.h" #define NETGNSS_DGPSIP "dgpsip://" #define NETGNSS_NTRIP "ntrip://" @@ -22,8 +23,8 @@ bool netgnss_uri_check(char *name) /* is given string a valid URI for GNSS/DGPS service? */ { return - strncmp(name, NETGNSS_NTRIP, strlen(NETGNSS_NTRIP)) == 0 - || strncmp(name, NETGNSS_DGPSIP, strlen(NETGNSS_DGPSIP)) == 0; + str_starts_with(name, NETGNSS_NTRIP) + || str_starts_with(name, NETGNSS_DGPSIP); } @@ -32,13 +33,13 @@ int netgnss_uri_open(struct gps_device_t *dev, char *netgnss_service) /* open a connection to a DGNSS service */ { #ifdef NTRIP_ENABLE - if (strncmp(netgnss_service, NETGNSS_NTRIP, strlen(NETGNSS_NTRIP)) == 0) { + if (str_starts_with(netgnss_service, NETGNSS_NTRIP)) { dev->ntrip.conn_state = ntrip_conn_init; return ntrip_open(dev, netgnss_service + strlen(NETGNSS_NTRIP)); } #endif - if (strncmp(netgnss_service, NETGNSS_DGPSIP, strlen(NETGNSS_DGPSIP)) == 0) + if (str_starts_with(netgnss_service, NETGNSS_DGPSIP)) return dgpsip_open(dev, netgnss_service + strlen(NETGNSS_DGPSIP)); #ifndef REQUIRE_DGNSS_PROTO |