]> rtime.felk.cvut.cz Git - can-eth-gw.git/blobdiff - utils/cegw/cegw.c
Understand -h option
[can-eth-gw.git] / utils / cegw / cegw.c
index feb083af9ee61cb38d9edc95878d7cf40e9698b5..e513aec4db211dffe50051aadb0e19905e12da29 100644 (file)
@@ -37,12 +37,11 @@ enum {
        CEGW_ERR_COLON,
        CEGW_ERR_GETADDRI,
        CEGW_ERR_FLTALCK,
-       CEGW_ERR_FLTPARSE
+       CEGW_ERR_FLTPARSE,
+       CEGW_ERR_LAST
 };
 
 char *cegw_errlist[] = {
-
-       [CEGW_ERR_UNKNOWN ] = "",
        [CEGW_ERR_COLON   ] = "expected ':' (<hostname>:<port>)",
        [CEGW_ERR_GETADDRI] = "getaddrinfo failed",
        [CEGW_ERR_FLTALCK ] = "filter alloc failed",
@@ -69,7 +68,7 @@ const struct addrinfo hints = {
 static void perr(char *s)
 {
        if (s) {
-               if (cegw_errno == 0) {
+               if (cegw_errno == 0 || cegw_errno >= CEGW_ERR_LAST) {
                        fprintf(stderr, "error: %s\n", s);
 
                } else {
@@ -190,7 +189,7 @@ int main(int argc, char *argv[])
        struct cegw_ioctl *gwctl = NULL;
        struct can_filter *filter = NULL;
 
-       if (argc == 1) {
+       if (argc == 1 || (argc == 2 && strcmp(argv[1], "-h") == 0)) {
                printf(help_msg, argv[0], argv[0]);
                return 0;
        }
@@ -310,4 +309,3 @@ int main(int argc, char *argv[])
 
        return 0;
 }
-