From 5a72e1cce9a7e872802009a853981d7e9f39a25e Mon Sep 17 00:00:00 2001 From: "Gary E. Miller" Date: Mon, 7 Mar 2005 06:49:03 +0000 Subject: Improve xgps error message on gps_open(). --- xgps.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'xgps.c') diff --git a/xgps.c b/xgps.c index 492bf80e..a94d7fe5 100644 --- a/xgps.c +++ b/xgps.c @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -338,6 +339,7 @@ int main(int argc, char *argv[]) int option; char *colon, *server = NULL, *port = DEFAULT_GPSD_PORT; char *su, *au; + char *err_str = NULL; toplevel = XtVaAppInitialize(&app, "xgps", options, XtNumber(options), @@ -384,7 +386,17 @@ altunits_ok:; gpsdata = gps_open(server, port); if (!gpsdata) { - fputs("xgps: no gpsd running or network error\n", stderr); + switch ( errno ) { + case NL_NOSERVICE: err_str = "can't get service entry"; break; + case NL_NOHOST: err_str = "can't get host entry"; break; + case NL_NOPROTO: err_str = "can't get protocol entry"; break; + case NL_NOSOCK: err_str = "can't create socket"; break; + case NL_NOSOCKOPT: err_str = "error SETSOCKOPT SO_REUSEADDR"; break; + case NL_NOCONNECT: err_str = "can't connect to host"; break; + default: err_str = "Unknown"; break; + } + fprintf( stderr, "xgps: no gpsd running or network error: %d, %s\n" + , errno, err_str); exit(2); } -- cgit v1.2.1