summaryrefslogtreecommitdiff
path: root/netlib.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2009-08-26 23:49:31 +0000
committerEric S. Raymond <esr@thyrsus.com>2009-08-26 23:49:31 +0000
commitb9cc68ba066757a71565fd29dd0e886a17bf2e21 (patch)
tree01d6463c81093c428f57f90d60d8f05791a6917d /netlib.c
parentf57255209c5b25c74e1fd5c84b6636bf76f02298 (diff)
downloadgpsd-b9cc68ba066757a71565fd29dd0e886a17bf2e21.tar.gz
Add gps_errstr() to the client API so client code doesn't have to
reinvent it all the time. Use it in gpsmon.
Diffstat (limited to 'netlib.c')
-rw-r--r--netlib.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/netlib.c b/netlib.c
index 219ebd1d..5d97ebea 100644
--- a/netlib.c
+++ b/netlib.c
@@ -87,6 +87,19 @@ int netlib_connectsock(const char *host, const char *service, const char *protoc
/*@ +type +mustfreefresh @*/
}
+char /*@observer@*/ *netlib_errstr(const int err)
+{
+ switch (err) {
+ case NL_NOSERVICE: return "can't get service entry"; break;
+ case NL_NOHOST: return "can't get host entry"; break;
+ case NL_NOPROTO: return "can't get protocol entry"; break;
+ case NL_NOSOCK: return "can't create socket"; break;
+ case NL_NOSOCKOPT: return "error SETSOCKOPT SO_REUSEADDR"; break;
+ case NL_NOCONNECT: return "can't connect to host/port pair"; break;
+ default: return "unknown error"; break;
+ }
+}
+
char *sock2ip(int fd)
{
struct sockaddr fsin;