From b9cc68ba066757a71565fd29dd0e886a17bf2e21 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 26 Aug 2009 23:49:31 +0000 Subject: Add gps_errstr() to the client API so client code doesn't have to reinvent it all the time. Use it in gpsmon. --- netlib.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'netlib.c') 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; -- cgit v1.2.1