It has been pointed out that the wording of the license of this library is not entirely clear. The term "dual licensing" usually refers to a licence choice of two licenses "LICENSE1 _or_ LICENSE2. Instead the license of this library claimed "LICENSE1 _and_ LICENSE2". After an internal discussion with @metajack and @pasis it was made clear that the initial idea was to dual license the library in the usual way. This was also made clear by jack on the ML in the past [0]. As of jack, these licensing terms originated from jquery, which also used the 'and' version in the past and has since been corrected [1]. This patch changes the license terms to 'MIT or GPLv3' and also adds SPDX headers [2]. [0] https://groups.google.com/g/libstrophe/c/JkFgr601JQc [1] https://stackoverflow.com/q/2758409 [2] https://spdx.org Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
71 lines
1.2 KiB
C
71 lines
1.2 KiB
C
/* SPDX-License-Identifier: MIT OR GPL-3.0-only */
|
|
/* test_sock.c
|
|
** libstrophe XMPP client library -- test routines for the socket abstraction
|
|
**
|
|
** Copyright (C) 2005-2009 Collecta, Inc.
|
|
**
|
|
** This software is provided AS-IS with no warranty, either express
|
|
** or implied.
|
|
**
|
|
** This program is dual licensed under the MIT or GPLv3 licenses.
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
#ifndef _WIN32
|
|
#include <sys/select.h>
|
|
#endif
|
|
|
|
#include "sock.h"
|
|
|
|
int wait_for_connect(sock_t sock)
|
|
{
|
|
fd_set wfds, efds;
|
|
int ret;
|
|
|
|
FD_ZERO(&wfds);
|
|
FD_SET(sock, &wfds);
|
|
FD_ZERO(&efds);
|
|
FD_SET(sock, &efds);
|
|
|
|
ret = select(sock + 1, NULL, &wfds, &efds, NULL);
|
|
if (ret <= 0)
|
|
return -1;
|
|
|
|
if (FD_ISSET(sock, &efds))
|
|
return 0;
|
|
if (FD_ISSET(sock, &wfds))
|
|
return 1;
|
|
|
|
return -1;
|
|
}
|
|
|
|
int main()
|
|
{
|
|
sock_t sock;
|
|
int err;
|
|
|
|
sock_initialize();
|
|
|
|
sock = sock_connect("www.google.com", 80);
|
|
|
|
if (sock < 0) {
|
|
sock_shutdown();
|
|
return 1;
|
|
}
|
|
|
|
err = wait_for_connect(sock);
|
|
if (err < 0) {
|
|
sock_close(sock);
|
|
sock_shutdown();
|
|
return 1;
|
|
}
|
|
|
|
sock_close(sock);
|
|
|
|
sock_shutdown();
|
|
|
|
return 0;
|
|
}
|