From d0174ca4e78831bbdd798d02a481ba2569425722 Mon Sep 17 00:00:00 2001 From: Zbigniew Chyla Date: Fri, 16 Jan 2015 15:46:59 +0100 Subject: Add str_starts_with macro, use it instead of strncmp. This change doesn't affect generated binary code. --- net_gnss_dispatch.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'net_gnss_dispatch.c') 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 -- cgit v1.2.1