mirror of
https://github.com/openssl/openssl.git
synced 2024-12-03 05:41:46 +08:00
a43ce58f55
Reviewed-by: Paul Dale <paul.dale@oracle.com> Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/6975)
65 lines
1.4 KiB
C
65 lines
1.4 KiB
C
/*
|
|
* Copyright 2018 The OpenSSL Project Authors. All Rights Reserved.
|
|
*
|
|
* Licensed under the OpenSSL license (the "License"). You may not use
|
|
* this file except in compliance with the License. You can obtain a copy
|
|
* in the file LICENSE in the source distribution or at
|
|
* https://www.openssl.org/source/license.html
|
|
*/
|
|
|
|
#include "../testutil.h"
|
|
#include "internal/nelem.h"
|
|
#include "tu_local.h"
|
|
#include "output.h"
|
|
|
|
|
|
static int used[100] = { 0 };
|
|
|
|
|
|
size_t test_get_argument_count(void)
|
|
{
|
|
return opt_num_rest();
|
|
}
|
|
|
|
char *test_get_argument(size_t n)
|
|
{
|
|
char **argv = opt_rest();
|
|
|
|
OPENSSL_assert(n < sizeof(used));
|
|
if ((int)n >= opt_num_rest() || argv == NULL)
|
|
return NULL;
|
|
used[n] = 1;
|
|
return argv[n];
|
|
}
|
|
|
|
void opt_check_usage(void)
|
|
{
|
|
int i;
|
|
char **argv = opt_rest();
|
|
int n, arg_count = opt_num_rest();
|
|
|
|
if (arg_count > (int)OSSL_NELEM(used))
|
|
n = (int)OSSL_NELEM(used);
|
|
else
|
|
n = arg_count;
|
|
for (i = 0; i < n; i++) {
|
|
if (used[i] == 0)
|
|
test_printf_stderr("Warning ignored command-line argument %d: %s\n",
|
|
i, argv[i]);
|
|
}
|
|
if (i < arg_count)
|
|
test_printf_stderr("Warning arguments %d and later unchecked\n", i);
|
|
}
|
|
|
|
int opt_printf_stderr(const char *fmt, ...)
|
|
{
|
|
va_list ap;
|
|
int ret;
|
|
|
|
va_start(ap, fmt);
|
|
ret = test_vprintf_stderr(fmt, ap);
|
|
va_end(ap);
|
|
return ret;
|
|
}
|
|
|