]> rtime.felk.cvut.cz Git - can-utils.git/blobdiff - slcand.c
slcand: remove #define EXIT_FAILURE, EXIT_SUCCESS
[can-utils.git] / slcand.c
index 69d30f7b2064472b841bb31d617b5048aa79a2f2..c4c81c54bbcf2d1b7bfffd51fb6f987764404797 100644 (file)
--- a/slcand.c
+++ b/slcand.c
@@ -28,6 +28,7 @@
 #include <unistd.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <sys/socket.h>
 #include <fcntl.h>
 #include <syslog.h>
 #include <errno.h>
@@ -49,9 +50,6 @@
 /* The length of ttypath buffer */
 #define TTYPATH_LENGTH 64
 
-#define EXIT_SUCCESS 0
-#define EXIT_FAILURE 1
-
 /* UART flow control types */
 #define FLOW_NONE 0
 #define FLOW_HW 1
@@ -70,8 +68,9 @@ void print_usage(char *prg)
        fprintf(stderr, "         -F         (stay in foreground; no daemonize)\n");
        fprintf(stderr, "         -h         (show this help page)\n");
        fprintf(stderr, "\nExamples:\n");
-       fprintf(stderr, "slcand -o -c -f -s6 ttyslcan0\n");
-       fprintf(stderr, "slcand -o -c -f -s6 ttyslcan0 can0\n");
+       fprintf(stderr, "slcand -o -c -f -s6 ttyUSB0\n");
+       fprintf(stderr, "slcand -o -c -f -s6 ttyUSB0 can0\n");
+       fprintf(stderr, "slcand -o -c -f -s6 /dev/ttyUSB0\n");
        fprintf(stderr, "\n");
        exit(EXIT_FAILURE);
 }
@@ -251,10 +250,11 @@ int main(int argc, char *argv[])
 
        /* Prepare the tty device name string */
        pch = strstr(tty, devprefix);
-       if (pch == tty)
-               print_usage(argv[0]);
+       if (pch != tty)
+               snprintf(ttypath, TTYPATH_LENGTH, "%s%s", devprefix, tty);
+       else
+               snprintf(ttypath, TTYPATH_LENGTH, "%s", tty);
 
-       snprintf(ttypath, TTYPATH_LENGTH, "%s%s", devprefix, tty);
        syslog(LOG_INFO, "starting on TTY device %s", ttypath);
 
        /* Daemonize */