1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

Updated test programs to build on Solaris. Some whitespaces cleanup.

This commit is contained in:
Fredrik Skogman 2016-09-09 06:50:41 +08:00 committed by Andy Green
parent 316960b87d
commit 9c04a107c9
5 changed files with 71 additions and 43 deletions

View file

@ -16,7 +16,7 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
* MA 02110-1301 USA
*
*
* fuzxy is designed to go on the client path
@ -66,6 +66,10 @@
#include <netinet/in.h>
#endif
#if defined(__sun)
#include <strings.h> /* bzero */
#endif
#define MAX_FUZZ_BUF (1024 * 1024)
enum types {
@ -394,11 +398,11 @@ static struct option options[] = {
{ "port", required_argument, NULL, 'p' },
{ "ssl", no_argument, NULL, 's' },
{ "allow-non-ssl", no_argument, NULL, 'a' },
{ "interface", required_argument, NULL, 'i' },
{ "closetest", no_argument, NULL, 'c' },
{ "interface", required_argument, NULL, 'i' },
{ "closetest", no_argument, NULL, 'c' },
{ "libev", no_argument, NULL, 'e' },
#ifndef LWS_NO_DAEMONIZE
{ "daemonize", no_argument, NULL, 'D' },
{ "daemonize", no_argument, NULL, 'D' },
#endif
{ "resource_path", required_argument, NULL, 'r' },
{ NULL, 0, 0, 0 }
@ -486,7 +490,7 @@ fuzxy_listen(const char *interface_name, int port, int *sockfd)
if (interface_name[0] &&
lws_interface_to_sa(0, interface_name, (struct sockaddr_in *)
(struct sockaddr *)&serv_addr4,
(struct sockaddr *)&serv_addr4,
sizeof(serv_addr4)) < 0) {
lwsl_err("Unable to find interface %s\n", interface_name);
goto bail2;
@ -756,10 +760,15 @@ main(int argc, char **argv)
int n = 0, m;
#ifndef _WIN32
/* LOG_PERROR is not POSIX standard, and may not be portable */
#ifdef __sun
int syslog_options = LOG_PID;
#else
int syslog_options = LOG_PID | LOG_PERROR;
#endif
#endif
#ifndef LWS_NO_DAEMONIZE
int daemonize = 0;
int daemonize = 0;
#endif
signal(SIGPIPE, sigpipe_handler);
@ -774,7 +783,7 @@ main(int argc, char **argv)
#ifndef LWS_NO_DAEMONIZE
case 'D':
daemonize = 1;
#ifndef _WIN32
#if !defined(_WIN32) && !defined(__sun)
syslog_options &= ~LOG_PERROR;
#endif
break;
@ -913,8 +922,8 @@ main(int argc, char **argv)
/*
* draw down enough of the partner's
* in ring to either exhaust it
* or fill an output buffer
*/
* or fill an output buffer
*/
m = fuzz(n, out, sizeof(out));
if (m < 0) {
lwsl_err("Error on fuzz\n");

View file

@ -14,7 +14,7 @@
* all without asking permission.
*
* The test apps are intended to be adapted for use in your code, which
* may be proprietary. So unlike the library itself, they are licensed
* may be proprietary. So unlike the library itself, they are licensed
* Public Domain.
*/
@ -216,7 +216,7 @@ static struct option options[] = {
{ "help", no_argument, NULL, 'h' },
{ "debug", required_argument, NULL, 'd' },
{ "port", required_argument, NULL, 'p' },
{ "ssl-cert", required_argument, NULL, 'C' },
{ "ssl-cert", required_argument, NULL, 'C' },
{ "ssl-key", required_argument, NULL, 'k' },
#ifndef LWS_NO_CLIENT
{ "client", required_argument, NULL, 'c' },
@ -226,11 +226,11 @@ static struct option options[] = {
{ "versa", no_argument, NULL, 'v' },
{ "uri", required_argument, NULL, 'u' },
{ "passphrase", required_argument, NULL, 'P' },
{ "interface", required_argument, NULL, 'i' },
{ "interface", required_argument, NULL, 'i' },
{ "times", required_argument, NULL, 'n' },
{ "echogen", no_argument, NULL, 'e' },
#ifndef LWS_NO_DAEMONIZE
{ "daemonize", no_argument, NULL, 'D' },
{ "daemonize", no_argument, NULL, 'D' },
#endif
{ NULL, 0, 0, 0 }
};
@ -247,7 +247,12 @@ int main(int argc, char **argv)
char ssl_cert[256] = LOCAL_RESOURCE_PATH"/libwebsockets-test-server.pem";
char ssl_key[256] = LOCAL_RESOURCE_PATH"/libwebsockets-test-server.key.pem";
#ifndef _WIN32
/* LOG_PERROR is not POSIX standard, and may not be portable */
#ifdef __sun
int syslog_options = LOG_PID;
#else
int syslog_options = LOG_PID | LOG_PERROR;
#endif
#endif
int client = 0;
int listen_port = 80;
@ -310,7 +315,7 @@ int main(int argc, char **argv)
#ifndef LWS_NO_DAEMONIZE
case 'D':
daemonize = 1;
#ifndef _WIN32
#if !defined(_WIN32) && !defined(__sun)
syslog_options &= ~LOG_PERROR;
#endif
break;
@ -354,21 +359,21 @@ int main(int argc, char **argv)
case '?':
case 'h':
fprintf(stderr, "Usage: libwebsockets-test-echo\n"
" --debug / -d <debug bitfield>\n"
" --port / -p <port>\n"
" --ssl-cert / -C <cert path>\n"
" --ssl-key / -k <key path>\n"
" --debug / -d <debug bitfield>\n"
" --port / -p <port>\n"
" --ssl-cert / -C <cert path>\n"
" --ssl-key / -k <key path>\n"
#ifndef LWS_NO_CLIENT
" --client / -c <server IP>\n"
" --ratems / -r <rate in ms>\n"
" --client / -c <server IP>\n"
" --ratems / -r <rate in ms>\n"
#endif
" --ssl / -s\n"
" --ssl / -s\n"
" --passphrase / -P <passphrase>\n"
" --interface / -i <interface>\n"
" --uri / -u <uri path>\n"
" --times / -n <-1 unlimited or times to echo>\n"
" --interface / -i <interface>\n"
" --uri / -u <uri path>\n"
" --times / -n <-1 unlimited or times to echo>\n"
#ifndef LWS_NO_DAEMONIZE
" --daemonize / -D\n"
" --daemonize / -D\n"
#endif
);
exit(1);

View file

@ -14,7 +14,7 @@
* all without asking permission.
*
* The test apps are intended to be adapted for use in your code, which
* may be proprietary. So unlike the library itself, they are licensed
* may be proprietary. So unlike the library itself, they are licensed
* Public Domain.
*/
@ -42,6 +42,10 @@
#include <termiosh>
#endif
#ifdef __sun
#include <sys/termios.h>
#endif
/*
* this is specified in the 04 standard, control frames can only have small
* payload length styles

View file

@ -14,7 +14,7 @@
* all without asking permission.
*
* The test apps are intended to be adapted for use in your code, which
* may be proprietary. So unlike the library itself, they are licensed
* may be proprietary. So unlike the library itself, they are licensed
* Public Domain.
*/
@ -45,7 +45,7 @@ char crl_path[1024] = "";
/*
* This mutex lock protects code that changes or relies on wsi list outside of
* the service thread. The service thread will acquire it when changing the
* the service thread. The service thread will acquire it when changing the
* wsi list and other threads should acquire it while dereferencing wsis or
* calling apis like lws_callback_on_writable_all_protocol() which
* use the wsi list and wsis from a different thread context.
@ -176,12 +176,12 @@ static struct option options[] = {
{ "port", required_argument, NULL, 'p' },
{ "ssl", no_argument, NULL, 's' },
{ "allow-non-ssl", no_argument, NULL, 'a' },
{ "interface", required_argument, NULL, 'i' },
{ "closetest", no_argument, NULL, 'c' },
{ "interface", required_argument, NULL, 'i' },
{ "closetest", no_argument, NULL, 'c' },
{ "libev", no_argument, NULL, 'e' },
{ "threads", required_argument, NULL, 'j' },
#ifndef LWS_NO_DAEMONIZE
{ "daemonize", no_argument, NULL, 'D' },
{ "daemonize", no_argument, NULL, 'D' },
#endif
{ "resource_path", required_argument, NULL, 'r' },
{ NULL, 0, 0, 0 }
@ -195,16 +195,21 @@ int main(int argc, char **argv)
pthread_t pthread_dumb, pthread_service[32];
char cert_path[1024];
char key_path[1024];
int threads = 1;
int threads = 1;
int use_ssl = 0;
void *retval;
int opts = 0;
int n = 0;
#ifndef _WIN32
/* LOG_PERROR is not POSIX standard, and may not be portable */
#ifdef __sun
int syslog_options = LOG_PID;
#else
int syslog_options = LOG_PID | LOG_PERROR;
#endif
#endif
#ifndef LWS_NO_DAEMONIZE
int daemonize = 0;
int daemonize = 0;
#endif
/*
@ -235,7 +240,7 @@ int main(int argc, char **argv)
#ifndef LWS_NO_DAEMONIZE
case 'D':
daemonize = 1;
#ifndef _WIN32
#if !defined(_WIN32) && !defined(__sun)
syslog_options &= ~LOG_PERROR;
#endif
break;

View file

@ -14,7 +14,7 @@
* all without asking permission.
*
* The test apps are intended to be adapted for use in your code, which
* may be proprietary. So unlike the library itself, they are licensed
* may be proprietary. So unlike the library itself, they are licensed
* Public Domain.
*/
@ -122,7 +122,7 @@ static struct lws_protocols protocols[] = {
};
/* this shows how to override the lws file operations. You don't need
/* this shows how to override the lws file operations. You don't need
* to do any of this unless you have a reason (eg, want to serve
* compressed files without decompressing the whole archive)
*/
@ -169,20 +169,20 @@ static struct option options[] = {
{ "port", required_argument, NULL, 'p' },
{ "ssl", no_argument, NULL, 's' },
{ "allow-non-ssl", no_argument, NULL, 'a' },
{ "interface", required_argument, NULL, 'i' },
{ "closetest", no_argument, NULL, 'c' },
{ "interface", required_argument, NULL, 'i' },
{ "closetest", no_argument, NULL, 'c' },
{ "ssl-cert", required_argument, NULL, 'C' },
{ "ssl-key", required_argument, NULL, 'K' },
{ "ssl-ca", required_argument, NULL, 'A' },
#if defined(LWS_OPENSSL_SUPPORT)
{ "ssl-verify-client", no_argument, NULL, 'v' },
{ "ssl-verify-client", no_argument, NULL, 'v' },
#if defined(LWS_HAVE_SSL_CTX_set1_param)
{ "ssl-crl", required_argument, NULL, 'R' },
#endif
#endif
{ "libev", no_argument, NULL, 'e' },
#ifndef LWS_NO_DAEMONIZE
{ "daemonize", no_argument, NULL, 'D' },
{ "daemonize", no_argument, NULL, 'D' },
#endif
{ "resource_path", required_argument, NULL, 'r' },
{ NULL, 0, 0, 0 }
@ -202,10 +202,15 @@ int main(int argc, char **argv)
int opts = 0;
int n = 0;
#ifndef _WIN32
/* LOG_PERROR is not POSIX standard, and may not be portable */
#ifdef __sun
int syslog_options = LOG_PID;
#else
int syslog_options = LOG_PID | LOG_PERROR;
#endif
#endif
#ifndef LWS_NO_DAEMONIZE
int daemonize = 0;
int daemonize = 0;
#endif
/*
@ -226,7 +231,7 @@ int main(int argc, char **argv)
#ifndef LWS_NO_DAEMONIZE
case 'D':
daemonize = 1;
#ifndef _WIN32
#if !defined(_WIN32) && !defined(__sun)
syslog_options &= ~LOG_PERROR;
#endif
break;
@ -396,7 +401,7 @@ int main(int argc, char **argv)
return -1;
}
/* this shows how to override the lws file operations. You don't need
/* this shows how to override the lws file operations. You don't need
* to do any of this unless you have a reason (eg, want to serve
* compressed files without decompressing the whole archive)
*/