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:16 -0500 |
commit | b500289f7af867ee5d5c236247f8f8a2a48ad342 (patch) | |
tree | e9f21c6ec5b944a2614fcee2a9f027c08a423c5f /libgps_json.c | |
parent | d0174ca4e78831bbdd798d02a481ba2569425722 (diff) | |
download | gpsd-b500289f7af867ee5d5c236247f8f8a2a48ad342.tar.gz |
Use str_starts_with instead of local macro.
This change doesn't affect generated binary code.
Diffstat (limited to 'libgps_json.c')
-rw-r--r-- | libgps_json.c | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/libgps_json.c b/libgps_json.c index d7d0c671..c479f296 100644 --- a/libgps_json.c +++ b/libgps_json.c @@ -20,6 +20,7 @@ PERMISSIONS #include <stddef.h> #include "gpsd.h" +#include "strfuncs.h" #ifdef SOCKET_EXPORT_ENABLE #include "gps_json.h" @@ -395,8 +396,7 @@ int libgps_json_unpack(const char *buf, if (classtag == NULL) return -1; -#define STARTSWITH(str, prefix) strncmp(str, prefix, strlen(prefix))==0 - if (STARTSWITH(classtag, "\"class\":\"TPV\"")) { + if (str_starts_with(classtag, "\"class\":\"TPV\"")) { status = json_tpv_read(buf, gpsdata, end); gpsdata->status = STATUS_FIX; gpsdata->set = STATUS_SET; @@ -429,45 +429,45 @@ int libgps_json_unpack(const char *buf, if (gpsdata->fix.mode != MODE_NOT_SEEN) gpsdata->set |= MODE_SET; return status; - } else if (STARTSWITH(classtag, "\"class\":\"GST\"")) { + } else if (str_starts_with(classtag, "\"class\":\"GST\"")) { status = json_noise_read(buf, gpsdata, end); if (status == 0) { gpsdata->set &= ~UNION_SET; gpsdata->set |= GST_SET; } return status; - } else if (STARTSWITH(classtag, "\"class\":\"SKY\"")) { + } else if (str_starts_with(classtag, "\"class\":\"SKY\"")) { status = json_sky_read(buf, gpsdata, end); if (status == 0) gpsdata->set |= SATELLITE_SET; return status; - } else if (STARTSWITH(classtag, "\"class\":\"ATT\"")) { + } else if (str_starts_with(classtag, "\"class\":\"ATT\"")) { status = json_att_read(buf, gpsdata, end); if (status == 0) { gpsdata->set &= ~UNION_SET; gpsdata->set |= ATTITUDE_SET; } return status; - } else if (STARTSWITH(classtag, "\"class\":\"DEVICES\"")) { + } else if (str_starts_with(classtag, "\"class\":\"DEVICES\"")) { status = json_devicelist_read(buf, gpsdata, end); if (status == 0) { gpsdata->set &= ~UNION_SET; gpsdata->set |= DEVICELIST_SET; } return status; - } else if (STARTSWITH(classtag, "\"class\":\"DEVICE\"")) { + } else if (str_starts_with(classtag, "\"class\":\"DEVICE\"")) { status = json_device_read(buf, &gpsdata->dev, end); if (status == 0) gpsdata->set |= DEVICE_SET; return status; - } else if (STARTSWITH(classtag, "\"class\":\"WATCH\"")) { + } else if (str_starts_with(classtag, "\"class\":\"WATCH\"")) { status = json_watch_read(buf, &gpsdata->policy, end); if (status == 0) { gpsdata->set &= ~UNION_SET; gpsdata->set |= POLICY_SET; } return status; - } else if (STARTSWITH(classtag, "\"class\":\"VERSION\"")) { + } else if (str_starts_with(classtag, "\"class\":\"VERSION\"")) { status = json_version_read(buf, gpsdata, end); if (status == 0) { gpsdata->set &= ~UNION_SET; @@ -475,7 +475,7 @@ int libgps_json_unpack(const char *buf, } return status; #ifdef RTCM104V2_ENABLE - } else if (STARTSWITH(classtag, "\"class\":\"RTCM2\"")) { + } else if (str_starts_with(classtag, "\"class\":\"RTCM2\"")) { status = json_rtcm2_read(buf, gpsdata->dev.path, sizeof(gpsdata->dev.path), &gpsdata->rtcm2, end); @@ -486,7 +486,7 @@ int libgps_json_unpack(const char *buf, return status; #endif /* RTCM104V2_ENABLE */ #ifdef RTCM104V3_ENABLE - } else if (STARTSWITH(classtag, "\"class\":\"RTCM3\"")) { + } else if (str_starts_with(classtag, "\"class\":\"RTCM3\"")) { status = json_rtcm3_read(buf, gpsdata->dev.path, sizeof(gpsdata->dev.path), &gpsdata->rtcm3, end); @@ -497,7 +497,7 @@ int libgps_json_unpack(const char *buf, return status; #endif /* RTCM104V3_ENABLE */ #ifdef AIVDM_ENABLE - } else if (STARTSWITH(classtag, "\"class\":\"AIS\"")) { + } else if (str_starts_with(classtag, "\"class\":\"AIS\"")) { status = json_ais_read(buf, gpsdata->dev.path, sizeof(gpsdata->dev.path), &gpsdata->ais, end); @@ -507,14 +507,14 @@ int libgps_json_unpack(const char *buf, } return status; #endif /* AIVDM_ENABLE */ - } else if (STARTSWITH(classtag, "\"class\":\"ERROR\"")) { + } else if (str_starts_with(classtag, "\"class\":\"ERROR\"")) { status = json_error_read(buf, gpsdata, end); if (status == 0) { gpsdata->set &= ~UNION_SET; gpsdata->set |= ERROR_SET; } return status; - } else if (STARTSWITH(classtag, "\"class\":\"PPS\"")) { + } else if (str_starts_with(classtag, "\"class\":\"PPS\"")) { status = json_pps_read(buf, gpsdata, end); if (status == 0) { gpsdata->set &= ~UNION_SET; @@ -523,7 +523,6 @@ int libgps_json_unpack(const char *buf, return status; } else return -1; -#undef STARTSWITH } /*@+compdef@*/ |