mirror of
https://github.com/anope/anope.git
synced 2026-06-23 08:26:38 +02:00
555c7ff856
git-svn-id: svn://svn.anope.org/anope/trunk@1345 31f1291d-b8d6-0310-a050-a5561fc1590b git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1060 5417fbe8-f217-4b02-8779-1006273d7864
48 lines
1.4 KiB
C
48 lines
1.4 KiB
C
/*
|
|
*
|
|
* (C) 2004-2008 Anope Team
|
|
* Contact us at info@anope.org
|
|
*
|
|
* Please read COPYING and README for furhter details.
|
|
*
|
|
* Based on the original code of Epona by Lara.
|
|
* Based on the original code of Services by Andy Church.
|
|
*
|
|
*
|
|
*/
|
|
|
|
#ifndef SOCKETS_H
|
|
#define SOCKETS_H
|
|
|
|
#ifdef _WIN32
|
|
typedef SOCKET ano_socket_t;
|
|
#define ano_sockread(fd, buf, len) recv(fd, buf, len, 0)
|
|
#define ano_sockwrite(fd, buf, len) send(fd, buf, len, 0)
|
|
#define ano_sockclose(fd) closesocket(fd)
|
|
#define ano_sockgeterr() WSAGetLastError()
|
|
#define ano_sockseterr(err) WSASetLastError(err)
|
|
/* ano_sockstrerror in sockutil.c */
|
|
/* ano_socksetnonb in sockutil.c */
|
|
#define ano_sockerrnonb(err) (err == WSAEINPROGRESS || err == WSAEWOULDBLOCK)
|
|
#define SOCKERR_EBADF WSAENOTSOCK
|
|
#define SOCKERR_EINTR WSAEINTR
|
|
#define SOCKERR_EINVAL WSAEINVAL
|
|
#define SOCKERR_EINPROGRESS WSAEINPROGRESS
|
|
#else
|
|
typedef int ano_socket_t;
|
|
#define ano_sockread(fd, buf, len) read(fd, buf, len)
|
|
#define ano_sockwrite(fd, buf, len) write(fd, buf, len)
|
|
#define ano_sockclose(fd) close(fd)
|
|
#define ano_sockgeterr() errno
|
|
#define ano_sockseterr(err) errno = err
|
|
#define ano_sockstrerror(err) strerror(err)
|
|
#define ano_socksetnonb(fd) fcntl(fd, F_SETFL, O_NONBLOCK)
|
|
#define ano_sockerrnonb(err) (err == EINPROGRESS)
|
|
#define SOCKERR_EBADF EBADF
|
|
#define SOCKERR_EINTR EINTR
|
|
#define SOCKERR_EINVAL EINVAL
|
|
#define SOCKERR_EINPROGRESS EINPROGRESS
|
|
#endif
|
|
|
|
#endif
|