mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-02 04:04:39 +02:00
make input files [dos] for visual studio
This commit is contained in:
@@ -1,87 +1,87 @@
|
|||||||
/* echoclient.c */
|
/* echoclient.c */
|
||||||
|
|
||||||
#include "openssl/ssl.h"
|
#include "openssl/ssl.h"
|
||||||
#include "../test.h"
|
#include "../test.h"
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
SOCKET_T sockfd = 0;
|
SOCKET_T sockfd = 0;
|
||||||
|
|
||||||
FILE* fin = stdin;
|
FILE* fin = stdin;
|
||||||
FILE* fout = stdout;
|
FILE* fout = stdout;
|
||||||
|
|
||||||
int inCreated = 0;
|
int inCreated = 0;
|
||||||
int outCreated = 0;
|
int outCreated = 0;
|
||||||
|
|
||||||
char send[1024];
|
char send[1024];
|
||||||
char reply[1024];
|
char reply[1024];
|
||||||
|
|
||||||
SSL_METHOD* method = 0;
|
SSL_METHOD* method = 0;
|
||||||
SSL_CTX* ctx = 0;
|
SSL_CTX* ctx = 0;
|
||||||
SSL* ssl = 0;
|
SSL* ssl = 0;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
WSADATA wsd;
|
WSADATA wsd;
|
||||||
WSAStartup(0x0002, &wsd);
|
WSAStartup(0x0002, &wsd);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (argc >= 2) {
|
if (argc >= 2) {
|
||||||
fin = fopen(argv[1], "r");
|
fin = fopen(argv[1], "r");
|
||||||
inCreated = 1;
|
inCreated = 1;
|
||||||
}
|
}
|
||||||
if (argc >= 3) {
|
if (argc >= 3) {
|
||||||
fout = fopen(argv[2], "w");
|
fout = fopen(argv[2], "w");
|
||||||
outCreated = 1;
|
outCreated = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fin) err_sys("can't open input file");
|
if (!fin) err_sys("can't open input file");
|
||||||
if (!fout) err_sys("can't open output file");
|
if (!fout) err_sys("can't open output file");
|
||||||
|
|
||||||
tcp_connect(&sockfd);
|
tcp_connect(&sockfd);
|
||||||
|
|
||||||
method = SSLv3_client_method();
|
method = SSLv3_client_method();
|
||||||
ctx = SSL_CTX_new(method);
|
ctx = SSL_CTX_new(method);
|
||||||
|
|
||||||
if (SSL_CTX_load_verify_locations(ctx, caCert, 0) != SSL_SUCCESS)
|
if (SSL_CTX_load_verify_locations(ctx, caCert, 0) != SSL_SUCCESS)
|
||||||
err_sys("can't load ca file");
|
err_sys("can't load ca file");
|
||||||
|
|
||||||
ssl = SSL_new(ctx);
|
ssl = SSL_new(ctx);
|
||||||
|
|
||||||
SSL_set_fd(ssl, sockfd);
|
SSL_set_fd(ssl, sockfd);
|
||||||
if (SSL_connect(ssl) != SSL_SUCCESS) err_sys("SSL_connect failed");
|
if (SSL_connect(ssl) != SSL_SUCCESS) err_sys("SSL_connect failed");
|
||||||
|
|
||||||
while (fgets(send, sizeof(send), fin)) {
|
while (fgets(send, sizeof(send), fin)) {
|
||||||
|
|
||||||
int sendSz = strlen(send) + 1;
|
int sendSz = strlen(send) + 1;
|
||||||
|
|
||||||
if (SSL_write(ssl, send, sendSz) != sendSz)
|
if (SSL_write(ssl, send, sendSz) != sendSz)
|
||||||
err_sys("SSL_write failed");
|
err_sys("SSL_write failed");
|
||||||
|
|
||||||
if (strncmp(send, "quit", 4) == 0) {
|
if (strncmp(send, "quit", 4) == 0) {
|
||||||
fputs("sending server shutdown command: quit!\n", fout);
|
fputs("sending server shutdown command: quit!\n", fout);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SSL_read(ssl, reply, sizeof(reply)) > 0)
|
if (SSL_read(ssl, reply, sizeof(reply)) > 0)
|
||||||
fputs(reply, fout);
|
fputs(reply, fout);
|
||||||
}
|
}
|
||||||
|
|
||||||
SSL_shutdown(ssl);
|
SSL_shutdown(ssl);
|
||||||
SSL_free(ssl);
|
SSL_free(ssl);
|
||||||
SSL_CTX_free(ctx);
|
SSL_CTX_free(ctx);
|
||||||
|
|
||||||
fflush(fout);
|
fflush(fout);
|
||||||
if (inCreated) fclose(fin);
|
if (inCreated) fclose(fin);
|
||||||
if (outCreated) fclose(fout);
|
if (outCreated) fclose(fout);
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
closesocket(sockfd);
|
closesocket(sockfd);
|
||||||
#else
|
#else
|
||||||
close(sockfd);
|
close(sockfd);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
174
testsuite/input
174
testsuite/input
@@ -1,87 +1,87 @@
|
|||||||
/* echoclient.c */
|
/* echoclient.c */
|
||||||
|
|
||||||
#include "openssl/ssl.h"
|
#include "openssl/ssl.h"
|
||||||
#include "../test.h"
|
#include "../test.h"
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
SOCKET_T sockfd = 0;
|
SOCKET_T sockfd = 0;
|
||||||
|
|
||||||
FILE* fin = stdin;
|
FILE* fin = stdin;
|
||||||
FILE* fout = stdout;
|
FILE* fout = stdout;
|
||||||
|
|
||||||
int inCreated = 0;
|
int inCreated = 0;
|
||||||
int outCreated = 0;
|
int outCreated = 0;
|
||||||
|
|
||||||
char send[1024];
|
char send[1024];
|
||||||
char reply[1024];
|
char reply[1024];
|
||||||
|
|
||||||
SSL_METHOD* method = 0;
|
SSL_METHOD* method = 0;
|
||||||
SSL_CTX* ctx = 0;
|
SSL_CTX* ctx = 0;
|
||||||
SSL* ssl = 0;
|
SSL* ssl = 0;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
WSADATA wsd;
|
WSADATA wsd;
|
||||||
WSAStartup(0x0002, &wsd);
|
WSAStartup(0x0002, &wsd);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (argc >= 2) {
|
if (argc >= 2) {
|
||||||
fin = fopen(argv[1], "r");
|
fin = fopen(argv[1], "r");
|
||||||
inCreated = 1;
|
inCreated = 1;
|
||||||
}
|
}
|
||||||
if (argc >= 3) {
|
if (argc >= 3) {
|
||||||
fout = fopen(argv[2], "w");
|
fout = fopen(argv[2], "w");
|
||||||
outCreated = 1;
|
outCreated = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fin) err_sys("can't open input file");
|
if (!fin) err_sys("can't open input file");
|
||||||
if (!fout) err_sys("can't open output file");
|
if (!fout) err_sys("can't open output file");
|
||||||
|
|
||||||
tcp_connect(&sockfd);
|
tcp_connect(&sockfd);
|
||||||
|
|
||||||
method = SSLv3_client_method();
|
method = SSLv3_client_method();
|
||||||
ctx = SSL_CTX_new(method);
|
ctx = SSL_CTX_new(method);
|
||||||
|
|
||||||
if (SSL_CTX_load_verify_locations(ctx, caCert, 0) != SSL_SUCCESS)
|
if (SSL_CTX_load_verify_locations(ctx, caCert, 0) != SSL_SUCCESS)
|
||||||
err_sys("can't load ca file");
|
err_sys("can't load ca file");
|
||||||
|
|
||||||
ssl = SSL_new(ctx);
|
ssl = SSL_new(ctx);
|
||||||
|
|
||||||
SSL_set_fd(ssl, sockfd);
|
SSL_set_fd(ssl, sockfd);
|
||||||
if (SSL_connect(ssl) != SSL_SUCCESS) err_sys("SSL_connect failed");
|
if (SSL_connect(ssl) != SSL_SUCCESS) err_sys("SSL_connect failed");
|
||||||
|
|
||||||
while (fgets(send, sizeof(send), fin)) {
|
while (fgets(send, sizeof(send), fin)) {
|
||||||
|
|
||||||
int sendSz = strlen(send) + 1;
|
int sendSz = strlen(send) + 1;
|
||||||
|
|
||||||
if (SSL_write(ssl, send, sendSz) != sendSz)
|
if (SSL_write(ssl, send, sendSz) != sendSz)
|
||||||
err_sys("SSL_write failed");
|
err_sys("SSL_write failed");
|
||||||
|
|
||||||
if (strncmp(send, "quit", 4) == 0) {
|
if (strncmp(send, "quit", 4) == 0) {
|
||||||
fputs("sending server shutdown command: quit!\n", fout);
|
fputs("sending server shutdown command: quit!\n", fout);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SSL_read(ssl, reply, sizeof(reply)) > 0)
|
if (SSL_read(ssl, reply, sizeof(reply)) > 0)
|
||||||
fputs(reply, fout);
|
fputs(reply, fout);
|
||||||
}
|
}
|
||||||
|
|
||||||
SSL_shutdown(ssl);
|
SSL_shutdown(ssl);
|
||||||
SSL_free(ssl);
|
SSL_free(ssl);
|
||||||
SSL_CTX_free(ctx);
|
SSL_CTX_free(ctx);
|
||||||
|
|
||||||
fflush(fout);
|
fflush(fout);
|
||||||
if (inCreated) fclose(fin);
|
if (inCreated) fclose(fin);
|
||||||
if (outCreated) fclose(fout);
|
if (outCreated) fclose(fout);
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
closesocket(sockfd);
|
closesocket(sockfd);
|
||||||
#else
|
#else
|
||||||
close(sockfd);
|
close(sockfd);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user