aria2/src/a2io.h

124 lines
3.8 KiB
C
Raw Normal View History

/* <!-- copyright */
/*
* aria2 - The high speed download utility
*
* Copyright (C) 2006 Tatsuhiro Tsujikawa
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations
* including the two.
* You must obey the GNU General Public License in all respects
* for all of the code used other than OpenSSL. If you modify
* file(s) with this exception, you may extend this exception to your
* version of the file(s), but you are not obligated to do so. If you
* do not wish to do so, delete this exception statement from your
* version. If you delete this exception statement from all source
* files in the program, then also delete it here.
*/
/* copyright --> */
#ifndef _D_A2IO_H_
#define _D_A2IO_H_
#include "common.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#ifdef HAVE_IO_H
# include <io.h>
#endif // HAVE_IO_H
// in some platforms following definitions are missing:
#ifndef EINPROGRESS
# define EINPROGRESS (WSAEINPROGRESS)
#endif // EINPROGRESS
#ifndef O_NONBLOCK
# define O_NONBLOCK (O_NDELAY)
#endif // O_NONBLOCK
#ifndef O_BINARY
# define O_BINARY (0)
#endif // O_BINARY
// st_mode flags
#ifndef S_IRUSR
# define S_IRUSR 0000400 /* read permission, owner */
#endif /* S_IRUSR */
#ifndef S_IWUSR
# define S_IWUSR 0000200 /* write permission, owner */
#endif /* S_IWUSR */
#ifndef S_IXUSR
# define S_IXUSR 0000100/* execute/search permission, owner */
#endif /* S_IXUSR */
#ifndef S_IRWXU
# define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
#endif /* S_IRWXU */
#ifndef S_IRGRP
# define S_IRGRP 0000040 /* read permission, group */
#endif /* S_IRGRP */
#ifndef S_IWGRP
# define S_IWGRP 0000020 /* write permission, grougroup */
#endif /* S_IWGRP */
#ifndef S_IXGRP
# define S_IXGRP 0000010/* execute/search permission, group */
#endif /* S_IXGRP */
#ifndef S_IRWXG
# define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
#endif /* S_IRWXG */
#ifndef S_IROTH
# define S_IROTH 0000004 /* read permission, other */
#endif /* S_IROTH */
#ifndef S_IWOTH
# define S_IWOTH 0000002 /* write permission, other */
#endif /* S_IWOTH */
#ifndef S_IXOTH
# define S_IXOTH 0000001/* execute/search permission, other */
#endif /* S_IXOTH */
#ifndef S_IRWXO
# define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
#endif /* S_IRWXO */
// Use 'null' instead of /dev/null in win32.
#ifdef HAVE_WINSOCK2_H
# define DEV_NULL "nul"
#else
# define DEV_NULL "/dev/null"
#endif // HAVE_WINSOCK2_H
// Use 'con' instead of '/dev/stdout' in win32.
#ifdef HAVE_WINSOCK2_H
# define DEV_STDOUT "con"
#else
# define DEV_STDOUT "/dev/stdout"
#endif // HAVE_WINSOCK2_H
#ifdef __MINGW32__
2007-08-01 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com> Make a2netcompat.h include a2io.h to fix compilation error: * src/a2netcompat.h * src/SocketCore.cc: Removed include of a2io.h * src/Util.cc: Removed include of a2io.h Gather time related functions to a2time.h: * src/a2time.h: New file. * src/DefaultPeerStorage.cc * src/SimpleLogger.cc * src/Util.{h, cc} * src/SimpleRandomizer.h * src/TimeA2.{h,cc} * src/DownloadCommand.cc * src/main.cc Removed #ifdef __MINGW32__ since gai_strerror is included in a2netcompat.h: * src/NameResolver.cc Fixed compilation error without openssl: * src/SocketCore.{h,cc}: Moved include of openssl/err.h to SocketCore.h Added default block to suppress compiler warnings: * src/MetalinkRequestInfo.cc (AccumulateNonP2PUrl::operator()) 2007-07-26 Ross Smith II <aria2spam at smithii dot com> MinGW build enhancements. The following files are added: * src/gai_strerror.{c,h} * src/gettimeofday.{c,h} Changes to support the above new files: * configure.ac * src/Makefile.am * src/a2netcompat.h * src/TimeA2.cc * src/DefaultPeerStorage.cc * src/NameResolver.cc: removed mingw_strerror() function. * src/SocketCore.cc: removed mingw_strerror() function. Miscellaneous MinGW build fixes. * src/a2io.h: Use _lseeki64() instead of lseek() * src/common.h * src/DefaultFileAllocator.cc * src/GlowFileAllocator.cc * src/main.cc: Moved #include "prefs.h" to quiet compile error. * src/NameResolver.cc (callback): Changed int32_t to int. (resolve): Changed int32_t to int. * src/Platform.cc * src/Platform.h * test/MultiDiskWriterTest.cc * test/PeerMessageUtilTest.cc * src/localtime_r.c: Add DeleteCriticalSection() and at exit(). Other enhancements and fixes. * src/HttpRequestCommand.cc (executeInternal) Use non-blocking socket for HTTPS (MinGW only). * src/SocketCore.cc: (error): New function to abstract errno/WSAGetLastError(). (errorMsg): New function to abstract errno/WSAGetLastError(). (initiateSecureConnection): Added more detailed error reporting. * src/SocketCore.h: Added private variable blocking, to allow proper handling of OpenSSL psuedo-errors. * src/message.h (EX_SSL_INIT_FAILURE) (EX_SSL_IO_ERROR) (EX_SSL_PROTOCOL_ERROR) (EX_SSL_UNKNOWN_ERROR) (EX_SSL_CONNECT_ERROR) (EX_SOCKET_BLOCKING) (EX_SOCKET_NONBLOCKING) (EX_SOCKET_UNKNOWN_ERROR) * src/Util.cc (setGlobalSignalHandler): Renamed signal to sig as signal is a reserved name. (httpGMT): Fixed typo.
2007-07-31 16:45:16 +00:00
# define lseek(a, b, c) _lseeki64((a), (b), (c))
# define a2mkdir(path, openMode) mkdir(path)
#else
# define a2mkdir(path, openMode) mkdir(path, openMode)
#endif // __MINGW32__
#if defined HAVE_POSIX_MEMALIGN && O_DIRECT
# define ENABLE_DIRECT_IO 1
#endif // HAVE_POSIX_MEMALIGN && O_DIRECT
#endif // _D_A2IO_H_