]> git.sur5r.net Git - tio/blobdiff - src/options.c
New upstream version 2.7
[tio] / src / options.c
index 6217cc48ef932c631b63651d9cfe34cb9aabeaab..4f08e6dcc971203d8cceb4287f02ea6ee1c0f812 100644 (file)
@@ -46,6 +46,7 @@ enum opt_t
     OPT_TIMESTAMP_FORMAT,
     OPT_LOG_FILE,
     OPT_LOG_STRIP,
+    OPT_LOG_APPEND,
     OPT_LINE_PULSE_DURATION,
     OPT_RESPONSE_TIMEOUT,
     OPT_RS485,
@@ -253,6 +254,7 @@ void options_parse(int argc, char *argv[])
             {"list-devices",         no_argument,       0, 'L'                     },
             {"log",                  no_argument,       0, 'l'                     },
             {"log-file",             required_argument, 0, OPT_LOG_FILE            },
+            {"log-append",           no_argument,       0, OPT_LOG_APPEND          },
             {"log-strip",            no_argument,       0, OPT_LOG_STRIP           },
             {"socket",               required_argument, 0, 'S'                     },
             {"map",                  required_argument, 0, 'm'                     },
@@ -357,6 +359,10 @@ void options_parse(int argc, char *argv[])
                 option.log_strip = true;
                 break;
 
+            case OPT_LOG_APPEND:
+                option.log_append = true;
+                break;
+
             case 'S':
                 option.socket = optarg;
                 break;
@@ -486,6 +492,19 @@ void options_parse_final(int argc, char *argv[])
     optind = 1; // Reset option index to restart scanning of argv
     options_parse(argc, argv);
 
+#ifdef __CYGWIN__
+    unsigned char portnum;
+    char *tty_win;
+    if ( ((strncmp("COM", tty_device, 3) == 0)
+        || (strncmp("com", tty_device, 3) == 0) )
+        && (sscanf(tty_device + 3, "%hhu", &portnum) == 1)
+        && (portnum > 0) ) 
+    {
+        asprintf(&tty_win, "/dev/ttyS%hhu", portnum - 1);
+        tty_device = tty_win;
+    }
+#endif
+
     /* Restore tty device */
     option.tty_device = tty_device;
 }