summaryrefslogtreecommitdiff
path: root/xgps.c
diff options
context:
space:
mode:
authorGary E. Miller <gem@rellim.com>2005-03-07 06:49:03 +0000
committerGary E. Miller <gem@rellim.com>2005-03-07 06:49:03 +0000
commit5a72e1cce9a7e872802009a853981d7e9f39a25e (patch)
tree46eeb7dce685c8513e4e29d782fba9aba75cccaa /xgps.c
parent29596c00a96ee0b7fd1fda2f9e02557ef9304994 (diff)
downloadgpsd-5a72e1cce9a7e872802009a853981d7e9f39a25e.tar.gz
Improve xgps error message on gps_open().
Diffstat (limited to 'xgps.c')
-rw-r--r--xgps.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/xgps.c b/xgps.c
index 492bf80e..a94d7fe5 100644
--- a/xgps.c
+++ b/xgps.c
@@ -4,6 +4,7 @@
#include <ctype.h>
#include <unistd.h>
#include <math.h>
+#include <errno.h>
#include <Xm/Xm.h>
#include <Xm/MwmUtil.h>
#include <Xm/PushB.h>
@@ -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);
}