fix windows build with command line examples
This commit is contained in:
parent
aecdb33e4e
commit
90385bb4b3
@ -1102,6 +1102,8 @@ void InitDecodedCert(DecodedCert* cert, byte* source, word32 inSz, void* heap)
|
||||
|
||||
void FreeAltNames(DNS_entry* altNames, void* heap)
|
||||
{
|
||||
(void)heap;
|
||||
|
||||
while (altNames) {
|
||||
DNS_entry* tmp = altNames->next;
|
||||
|
||||
|
@ -152,6 +152,74 @@ static INLINE void err_sys(const char* msg)
|
||||
}
|
||||
|
||||
|
||||
#define MY_EX_USAGE 2
|
||||
|
||||
extern int myoptind;
|
||||
extern char* myoptarg;
|
||||
|
||||
static int mygetopt(int argc, char** argv, char* optstring)
|
||||
{
|
||||
static char* next = NULL;
|
||||
|
||||
char c;
|
||||
char* cp;
|
||||
|
||||
if (myoptind == 0)
|
||||
next = NULL; /* we're starting new/over */
|
||||
|
||||
if (next == NULL || *next == '\0') {
|
||||
if (myoptind == 0)
|
||||
myoptind++;
|
||||
|
||||
if (myoptind >= argc || argv[myoptind][0] != '-' ||
|
||||
argv[myoptind][1] == '\0') {
|
||||
myoptarg = NULL;
|
||||
if (myoptind < argc)
|
||||
myoptarg = argv[myoptind];
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (strcmp(argv[myoptind], "--") == 0) {
|
||||
myoptind++;
|
||||
myoptarg = NULL;
|
||||
|
||||
if (myoptind < argc)
|
||||
myoptarg = argv[myoptind];
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
next = argv[myoptind];
|
||||
next++; /* skip - */
|
||||
myoptind++;
|
||||
}
|
||||
|
||||
c = *next++;
|
||||
cp = strchr(optstring, c);
|
||||
|
||||
if (cp == NULL || c == ':')
|
||||
return '?';
|
||||
|
||||
cp++;
|
||||
|
||||
if (*cp == ':') {
|
||||
if (*next != '\0') {
|
||||
myoptarg = next;
|
||||
next = NULL;
|
||||
}
|
||||
else if (myoptind < argc) {
|
||||
myoptarg = argv[myoptind];
|
||||
myoptind++;
|
||||
}
|
||||
else
|
||||
return '?';
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
#ifdef OPENSSL_EXTRA
|
||||
|
||||
static int PasswordCallBack(char* passwd, int sz, int rw, void* userdata)
|
||||
|
@ -25,7 +25,6 @@
|
||||
|
||||
#include <cyassl/ssl.h>
|
||||
#include <cyassl/test.h>
|
||||
#include <sysexits.h>
|
||||
|
||||
/*
|
||||
#define TEST_RESUME
|
||||
@ -73,8 +72,8 @@
|
||||
|
||||
static void Usage(void)
|
||||
{
|
||||
printf("client " VERSION " NOTE: All files relative to CyaSSL home dir"
|
||||
"\n");
|
||||
printf("client " LIBCYASSL_VERSION_STRING
|
||||
" NOTE: All files relative to CyaSSL home dir\n");
|
||||
printf("-? Help, print this usage\n");
|
||||
printf("-h <host> Host to connect to, default %s\n", yasslIP);
|
||||
printf("-p <num> Port to connect on, default %d\n", yasslPort);
|
||||
@ -131,7 +130,7 @@ void client_test(void* args)
|
||||
|
||||
((func_args*)args)->return_code = -1; /* error state */
|
||||
|
||||
while ((ch = getopt(argc, argv, "?gdsh:p:v:l:A:c:k:b:")) != -1) {
|
||||
while ((ch = mygetopt(argc, argv, "?gdsh:p:v:l:A:c:k:b:")) != -1) {
|
||||
switch (ch) {
|
||||
case '?' :
|
||||
Usage();
|
||||
@ -150,54 +149,55 @@ void client_test(void* args)
|
||||
break;
|
||||
|
||||
case 'h' :
|
||||
host = optarg;
|
||||
domain = optarg;
|
||||
host = myoptarg;
|
||||
domain = myoptarg;
|
||||
break;
|
||||
|
||||
case 'p' :
|
||||
port = atoi(optarg);
|
||||
port = atoi(myoptarg);
|
||||
break;
|
||||
|
||||
case 'v' :
|
||||
version = atoi(optarg);
|
||||
version = atoi(myoptarg);
|
||||
if (version < 0 || version > 3) {
|
||||
Usage();
|
||||
exit(EX_USAGE);
|
||||
exit(MY_EX_USAGE);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'l' :
|
||||
cipherList = optarg;
|
||||
cipherList = myoptarg;
|
||||
break;
|
||||
|
||||
case 'A' :
|
||||
verifyCert = optarg;
|
||||
verifyCert = myoptarg;
|
||||
break;
|
||||
|
||||
case 'c' :
|
||||
ourCert = optarg;
|
||||
ourCert = myoptarg;
|
||||
break;
|
||||
|
||||
case 'k' :
|
||||
ourKey = optarg;
|
||||
ourKey = myoptarg;
|
||||
break;
|
||||
|
||||
case 'b' :
|
||||
benchmark = atoi(optarg);
|
||||
benchmark = atoi(myoptarg);
|
||||
if (benchmark < 0 || benchmark > 1000000) {
|
||||
Usage();
|
||||
exit(EX_USAGE);
|
||||
exit(MY_EX_USAGE);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
Usage();
|
||||
exit(EX_USAGE);
|
||||
exit(MY_EX_USAGE);
|
||||
}
|
||||
}
|
||||
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
argc -= myoptind;
|
||||
argv += myoptind;
|
||||
myoptind = 0; /* reset for test cases */
|
||||
|
||||
switch (version) {
|
||||
case 0:
|
||||
@ -442,6 +442,9 @@ void client_test(void* args)
|
||||
return args.return_code;
|
||||
}
|
||||
|
||||
int myoptind = 0;
|
||||
char* myoptarg = NULL;
|
||||
|
||||
#endif /* NO_MAIN_DRIVER */
|
||||
|
||||
|
||||
|
@ -25,7 +25,6 @@
|
||||
|
||||
#include <cyassl/openssl/ssl.h>
|
||||
#include <cyassl/test.h>
|
||||
#include <sysexits.h>
|
||||
|
||||
|
||||
#ifdef CYASSL_CALLBACKS
|
||||
@ -66,8 +65,8 @@
|
||||
|
||||
static void Usage(void)
|
||||
{
|
||||
printf("server " VERSION " NOTE: All files relative to CyaSSL home dir"
|
||||
"\n");
|
||||
printf("server " LIBCYASSL_VERSION_STRING
|
||||
" NOTE: All files relative to CyaSSL home dir\n");
|
||||
printf("-? Help, print this usage\n");
|
||||
printf("-p <num> Port to listen on, default %d\n", yasslPort);
|
||||
printf("-v <num> SSL version [0-3], SSLv3(0) - TLS1.2(3)), default %d\n",
|
||||
@ -109,7 +108,7 @@ THREAD_RETURN CYASSL_THREAD server_test(void* args)
|
||||
|
||||
((func_args*)args)->return_code = -1; /* error state */
|
||||
|
||||
while ((ch = getopt(argc, argv, "?dbsp:v:l:A:c:k:")) != -1) {
|
||||
while ((ch = mygetopt(argc, argv, "?dbsp:v:l:A:c:k:")) != -1) {
|
||||
switch (ch) {
|
||||
case '?' :
|
||||
Usage();
|
||||
@ -128,41 +127,42 @@ THREAD_RETURN CYASSL_THREAD server_test(void* args)
|
||||
break;
|
||||
|
||||
case 'p' :
|
||||
port = atoi(optarg);
|
||||
port = atoi(myoptarg);
|
||||
break;
|
||||
|
||||
case 'v' :
|
||||
version = atoi(optarg);
|
||||
version = atoi(myoptarg);
|
||||
if (version < 0 || version > 3) {
|
||||
Usage();
|
||||
exit(EX_USAGE);
|
||||
exit(MY_EX_USAGE);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'l' :
|
||||
cipherList = optarg;
|
||||
cipherList = myoptarg;
|
||||
break;
|
||||
|
||||
case 'A' :
|
||||
verifyCert = optarg;
|
||||
verifyCert = myoptarg;
|
||||
break;
|
||||
|
||||
case 'c' :
|
||||
ourCert = optarg;
|
||||
ourCert = myoptarg;
|
||||
break;
|
||||
|
||||
case 'k' :
|
||||
ourKey = optarg;
|
||||
ourKey = myoptarg;
|
||||
break;
|
||||
|
||||
default:
|
||||
Usage();
|
||||
exit(EX_USAGE);
|
||||
exit(MY_EX_USAGE);
|
||||
}
|
||||
}
|
||||
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
argc -= myoptind;
|
||||
argv += myoptind;
|
||||
myoptind = 0; /* reset for test cases */
|
||||
|
||||
switch (version) {
|
||||
case 0:
|
||||
@ -319,6 +319,9 @@ THREAD_RETURN CYASSL_THREAD server_test(void* args)
|
||||
return args.return_code;
|
||||
}
|
||||
|
||||
int myoptind = 0;
|
||||
char* myoptarg = NULL;
|
||||
|
||||
#endif /* NO_MAIN_DRIVER */
|
||||
|
||||
|
||||
|
@ -48,6 +48,10 @@ enum {
|
||||
};
|
||||
|
||||
|
||||
int myoptind = 0;
|
||||
char* myoptarg = NULL;
|
||||
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
func_args args;
|
||||
|
Loading…
x
Reference in New Issue
Block a user