Add OPTION_ARG_TIME for parsing a (64 bit if needed) time_t
authorderaadt <deraadt@openbsd.org>
Tue, 30 Aug 2016 14:34:59 +0000 (14:34 +0000)
committerderaadt <deraadt@openbsd.org>
Tue, 30 Aug 2016 14:34:59 +0000 (14:34 +0000)
prodding & ok jsing

usr.bin/openssl/apps.c
usr.bin/openssl/apps.h
usr.bin/openssl/s_time.c

index 2902fb7..7c8df2b 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: apps.c,v 1.38 2016/08/26 15:04:15 deraadt Exp $ */
+/* $OpenBSD: apps.c,v 1.39 2016/08/30 14:34:59 deraadt Exp $ */
 /*
  * Copyright (c) 2014 Joel Sing <jsing@openbsd.org>
  *
@@ -2272,6 +2272,16 @@ options_parse(int argc, char **argv, struct option *opts, char **unnamed,
                        *opt->opt.lvalue = (long)val;
                        break;
 
+               case OPTION_ARG_TIME:
+                       val = strtonum(argv[i], 0, LLONG_MAX, &errstr);
+                       if (errstr != NULL) {
+                               fprintf(stderr, "%s %s argument for -%s\n",
+                                   errstr, opt->argname, opt->name);
+                               return (1);
+                       }
+                       *opt->opt.tvalue = val;
+                       break;
+
                case OPTION_DISCARD:
                        break;
 
index 217931a..4276e53 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: apps.h,v 1.18 2016/08/30 11:30:14 deraadt Exp $ */
+/* $OpenBSD: apps.h,v 1.19 2016/08/30 14:34:59 deraadt Exp $ */
 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  * All rights reserved.
  *
@@ -294,6 +294,7 @@ struct option {
                OPTION_ARG_FUNC,
                OPTION_ARG_INT,
                OPTION_ARG_LONG,
+               OPTION_ARG_TIME,
                OPTION_DISCARD,
                OPTION_FUNC,
                OPTION_FLAG,
index 6df03af..a88df1b 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: s_time.c,v 1.15 2016/08/30 11:30:14 deraadt Exp $ */
+/* $OpenBSD: s_time.c,v 1.16 2016/08/30 14:34:59 deraadt Exp $ */
 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  * All rights reserved.
  *
@@ -194,7 +194,7 @@ struct option s_time_options[] = {
                .name = "time",
                .argname = "seconds",
                .desc = "Duration to perform timing tests for (default 30)",
-               .type = OPTION_ARG_INT,
+               .type = OPTION_ARG_TIME,
                .opt.tvalue = &s_time_config.maxtime,
        },
        {