Adding upstream version 1.0.2.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
a04160a00d
commit
36fe29e3d5
464 changed files with 372850 additions and 0 deletions
4
src/pplib/include/.gitignore
vendored
Normal file
4
src/pplib/include/.gitignore
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
/config.h
|
||||
/ppl7-config.h
|
||||
/stamp-h1
|
||||
/stamp-h2
|
174
src/pplib/include/compat.h
Normal file
174
src/pplib/include/compat.h
Normal file
|
@ -0,0 +1,174 @@
|
|||
/*******************************************************************************
|
||||
* This file is part of "Patrick's Programming Library", Version 7 (PPL7).
|
||||
* Web: http://www.pfp.de/ppl/
|
||||
*
|
||||
* $Author$
|
||||
* $Revision$
|
||||
* $Date$
|
||||
* $Id$
|
||||
*
|
||||
*******************************************************************************
|
||||
* Copyright (c) 2013, Patrick Fedick <patrick@pfp.de>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER AND CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef COMPAT_H_
|
||||
#define COMPAT_H_
|
||||
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STDIO_H
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRINGS_H
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
|
||||
#ifdef HAVE_STDARG_H
|
||||
#include <stdarg.h>
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <winsock2.h>
|
||||
#include <Ws2tcpip.h>
|
||||
#include <windows.h>
|
||||
#else
|
||||
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ARPA_INET_H
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
|
||||
#endif // _WIN32
|
||||
|
||||
namespace ppl7 {
|
||||
namespace compat {
|
||||
|
||||
char * trim (char * text);
|
||||
|
||||
#ifndef HAVE_STRTOLOWER
|
||||
char *strtolower (char * text);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRTOUPPER
|
||||
char *strtoupper (char * text);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRCASESTR
|
||||
const char *strcasestr(const char *haystack, const char *needle);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRCASECMP
|
||||
int strcasecmp(const char *s1, const char *s2);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRNCASECMP
|
||||
int strncasecmp(const char *s1, const char *s2, size_t n);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_VASPRINTF
|
||||
int vasprintf(char **buff, const char *fmt, va_list args);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_ASPRINTF
|
||||
int asprintf(char **buff, const char *format, ...);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_HTOL
|
||||
long htol (const char * wert);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_ATOLL
|
||||
long long atoll (const char *wert);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRNDUP
|
||||
char *strndup(const char *str, size_t len);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRNCMP
|
||||
int strncmp(const char *s1, const char *s2, size_t len);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_BCOPY
|
||||
void bcopy(const void *src, void *dst, size_t len);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_BZERO
|
||||
void bzero(void *b, size_t len);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRNLEN
|
||||
size_t strnlen(const char *str, size_t len);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_INET_NTOP
|
||||
const char * inet_ntop(int af, const void *src, char *dst, socklen_t size);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_INET_PTON
|
||||
int inet_pton(int af, const char *src, void *dst);
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* const char *strcasestr(const char *haystack, const char *needle);
|
||||
int strcasecmp(const char *s1, const char *s2);
|
||||
int strncasecmp(const char *s1, const char *s2, size_t n);
|
||||
int vasprintf(char **buff, const char *fmt, va_list args);
|
||||
int asprintf(char **buff, const char *format, ...);
|
||||
long htol (const char * wert);
|
||||
long long atoll (const char * wert);
|
||||
int atoi(const char *wert);
|
||||
long atol(const char *wert);
|
||||
double atof(const char *wert);
|
||||
char *strndup(const char *str, size_t len);
|
||||
int strncmp(const char *s1, const char *s2, size_t len);
|
||||
size_t strnlen(const char *str, size_t len);
|
||||
void bcopy(const void *src, void *dst, size_t len);
|
||||
*
|
||||
*/
|
||||
} // EOF namespace compat
|
||||
|
||||
using namespace compat;
|
||||
|
||||
} // EOF namespace ppl7
|
||||
|
||||
|
||||
#endif /* COMPAT_H_ */
|
466
src/pplib/include/config.h.in
Normal file
466
src/pplib/include/config.h.in
Normal file
|
@ -0,0 +1,466 @@
|
|||
/*******************************************************************************
|
||||
* This file is part of "Patrick's Programming Library", Version 7 (PPL7).
|
||||
* Web: http://www.pfp.de/ppl/
|
||||
*
|
||||
* $Author$
|
||||
* $Revision$
|
||||
* $Date$
|
||||
* $Id$
|
||||
*
|
||||
*******************************************************************************
|
||||
* Copyright (c) 2013, Patrick Fedick <patrick@pfp.de>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER AND CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef _PPL7_CONFIG
|
||||
#define _PPL7_CONFIG
|
||||
|
||||
#undef PACKAGE_VERSION
|
||||
#undef PACKAGE_BUGREPORT
|
||||
#undef PACKAGE_NAME
|
||||
#undef PACKAGE_STRING
|
||||
|
||||
#undef MINGW32
|
||||
#undef MINGW64
|
||||
#undef HAVE_AMD64
|
||||
|
||||
/* Define as 1 if you have unistd.h. */
|
||||
#undef HAVE_UNISTD_H
|
||||
|
||||
/* Define, if we have Thread Local Space */
|
||||
#undef HAVE_TLS
|
||||
|
||||
#undef HAVE_MKTIME
|
||||
#undef size_t
|
||||
#undef wchar_t
|
||||
|
||||
#undef HAVE_ALARM
|
||||
#undef HAVE_BZERO
|
||||
#undef HAVE_FSEEKO
|
||||
#undef HAVE_GETHOSTBYNAME
|
||||
#undef HAVE_GETTIMEOFDAY
|
||||
#undef HAVE_INET_NTOA
|
||||
#undef HAVE_INTTYPES_H
|
||||
#undef HAVE_MALLOC
|
||||
#undef HAVE_MEMMOVE
|
||||
#undef HAVE_MEMORY_H
|
||||
#undef HAVE_MEMSET
|
||||
#undef HAVE_MKDIR
|
||||
#undef HAVE_REALLOC
|
||||
#undef HAVE_SOCKET
|
||||
#undef HAVE_SOCKADDR_SA_LEN
|
||||
#undef HAVE_STDARG_H
|
||||
#undef HAVE_STDDEF_H
|
||||
#undef HAVE_STDBOOL_H
|
||||
#undef HAVE_STDIO_H
|
||||
#undef HAVE_STDINT_H
|
||||
#undef HAVE_STDLIB_H
|
||||
#undef HAVE_LOCALE_H
|
||||
#undef HAVE_WCHAR_H
|
||||
#undef HAVE_WIDEC_H
|
||||
#undef HAVE_WCTYPE_H
|
||||
#undef HAVE_STRDUP
|
||||
#undef HAVE_STRNDUP
|
||||
#undef HAVE_STRNCPY
|
||||
#undef HAVE_STRLCPY
|
||||
#undef HAVE_STRNCAT
|
||||
#undef HAVE_STRLCAT
|
||||
#undef HAVE_MATH_H
|
||||
#undef HAVE_SYSLOG_H
|
||||
|
||||
#undef HAVE_STRERROR
|
||||
#undef HAVE_STRFTIME
|
||||
#undef HAVE_STRINGS_H
|
||||
#undef HAVE_STRING_H
|
||||
#undef HAVE_STRNCASECMP
|
||||
#undef HAVE_STRCASECMP
|
||||
#undef HAVE_STRSTR
|
||||
#undef HAVE_STRCASESTR
|
||||
#undef HAVE_TIME_H
|
||||
#undef HAVE_SYS_TIME_H
|
||||
#undef HAVE_SYS_TYPES_H
|
||||
#undef HAVE_SYS_FILE_H
|
||||
#undef HAVE_FCNTL_H
|
||||
#undef HAVE_UNISTD_H
|
||||
#undef HAVE_ERRNO_H
|
||||
#undef HAVE_TIME_H
|
||||
#undef HAVE_SYS_SOCKET_H
|
||||
#undef HAVE_SYS_POLL_H
|
||||
#undef HAVE_NETINET_IN_H
|
||||
#undef HAVE_NETDB_H
|
||||
#undef HAVE_ARPA_INET_H
|
||||
#undef HAVE_SYS_MMAN_H
|
||||
#undef HAVE_VALGRIND_HELGRIND_H
|
||||
|
||||
#undef HAVE_VPRINTF
|
||||
#undef HAVE_ASPRINTF
|
||||
#undef HAVE_VASPRINTF
|
||||
#undef HAVE___MINGW_VASPRINTF
|
||||
#undef HAVE_WORKING_VSNPRINTF
|
||||
#undef HAVE__BOOL
|
||||
#undef FPOS_T_STRUCT
|
||||
#undef HAVE_PCRE
|
||||
#undef HAVE_FLOCK
|
||||
#undef HAVE_FCNTL
|
||||
#undef HAVE_FPUTS
|
||||
#undef HAVE_FPUTWS
|
||||
#undef HAVE_FGETS
|
||||
#undef HAVE_FGETWS
|
||||
#undef HAVE_FPUTC
|
||||
#undef HAVE_FPUTWC
|
||||
#undef HAVE_FGETC
|
||||
#undef HAVE_FGETWC
|
||||
#undef STRUCT_TM_HAS_GMTOFF
|
||||
#undef HAVE_ATOLL
|
||||
#undef HAVE_STRTOLL
|
||||
#undef HAVE_STRTOULL
|
||||
#undef HAVE_SLEEP
|
||||
#undef HAVE_NAP
|
||||
#undef HAVE_USLEEP
|
||||
#undef HAVE_NANOSLEEP
|
||||
#undef HAVE_STRTOK_R
|
||||
#undef HAVE_SIGNAL
|
||||
#undef HAVE_SIGNAL_H
|
||||
#undef HAVE_DIRENT_H
|
||||
#undef HAVE_FNMATCH_H
|
||||
#undef HAVE_SYS_STAT_H
|
||||
#undef HAVE_LIMITS_H
|
||||
#undef HAVE_STRTOK_R
|
||||
#undef HAVE_GETPID
|
||||
#undef HAVE_GETPPID
|
||||
#undef HAVE_GETUID
|
||||
#undef HAVE_GETEUID
|
||||
#undef HAVE_LOCALTIME
|
||||
#undef HAVE_LOCALTIME_R
|
||||
#undef HAVE_GMTIME
|
||||
#undef HAVE_GMTIME_R
|
||||
#undef HAVE_CTYPE_H
|
||||
#undef HAVE_MKSTEMP
|
||||
#undef HAVE_WCSCASECMP
|
||||
#undef HAVE_WCSNCASECMP
|
||||
#undef HAVE_WCSCMP
|
||||
#undef HAVE_WCSNCMP
|
||||
#undef HAVE_WCSTOL
|
||||
#undef HAVE_WCSTOLL
|
||||
#undef HAVE_WCSLEN
|
||||
#undef HAVE_WCSSTR
|
||||
#undef HAVE_WCSTOUL
|
||||
#undef HAVE_WCSTOULL
|
||||
#undef HAVE_WCSTOMBS
|
||||
#undef HAVE_WCSRTOMBS
|
||||
#undef HAVE_WCSNRTOMBS
|
||||
#undef HAVE_MBSTOWCS
|
||||
#undef HAVE_MBSRTOWCS
|
||||
#undef HAVE_MBSNRTOWCS
|
||||
#undef HAVE_WPRINTF
|
||||
#undef HAVE_FWPRINTF
|
||||
#undef HAVE_SWPRINTF
|
||||
#undef HAVE_VWPRINTF
|
||||
#undef HAVE_VFWPRINTF
|
||||
#undef HAVE_VSWPRINTF
|
||||
#undef HAVE_WCSTOD
|
||||
#undef HAVE_WCSTOF
|
||||
#undef HAVE_WSTOL
|
||||
#undef HAVE_WSTOLL
|
||||
#undef HAVE_WATOI
|
||||
#undef HAVE_WATOLL
|
||||
#undef HAVE_WSTOD
|
||||
#undef HAVE_WATOF
|
||||
#undef HAVE_TRUNCATE
|
||||
#undef HAVE_FTRUNCATE
|
||||
#undef HAVE_STRCMP
|
||||
#undef HAVE_STRNCMP
|
||||
#undef HAVE_STRNLEN
|
||||
#undef HAVE_BCOPY
|
||||
#undef HAVE_SYNC
|
||||
#undef HAVE_FSYNC
|
||||
#undef HAVE_MMAP
|
||||
#undef HAVE_MUNMAP
|
||||
#undef HAVE_PAGESIZE
|
||||
#undef HAVE_SYSCONF
|
||||
#undef HAVE_STAT
|
||||
#undef HAVE_OPENDIR
|
||||
#undef HAVE_CLOSEDIR
|
||||
#undef HAVE_READDIR
|
||||
#undef HAVE_READDIR_R
|
||||
#undef HAVE_HTOL
|
||||
#undef HAVE_HTOLL
|
||||
#undef HAVE_ATOI
|
||||
#undef HAVE_ATOL
|
||||
#undef HAVE_ATOLL
|
||||
#undef HAVE_ATOF
|
||||
#undef HAVE_STRTOLOWER
|
||||
#undef HAVE_STRTOUPPER
|
||||
#undef HAVE_UNLINK
|
||||
#undef HAVE_REMOVE
|
||||
#undef HAVE_SYSLOG
|
||||
#undef HAVE_OPENLOG
|
||||
#undef HAVE_CLOSELOG
|
||||
|
||||
|
||||
|
||||
#undef HAVE_GETHOSTNAME
|
||||
#undef HAVE_SETHOSTNAME
|
||||
#undef HAVE_GETDOMAINNAME
|
||||
#undef HAVE_SETDOMAINNAME
|
||||
#undef HAVE_UNAME
|
||||
#undef HAVE_INET_NTOP
|
||||
#undef HAVE_INET_PTON
|
||||
#undef HAVE_INET_ATON
|
||||
#undef HAVE_INET_NTOA
|
||||
#undef HAVE_INET_NTOA_R
|
||||
#undef HAVE_INET_ADDR
|
||||
#undef HAVE_INET_NETWORK
|
||||
#undef HAVE_INET_MAKEADDR
|
||||
|
||||
#undef HAVE_RESOLV_H
|
||||
#undef HAVE_ARPA_NAMESER_H
|
||||
|
||||
|
||||
|
||||
#undef _FILE_OFFSET_BITS 64
|
||||
|
||||
|
||||
#undef HAVE_LIBLDNS
|
||||
#undef HAVE_LIBBIND
|
||||
#undef HAVE_RES_QUERY
|
||||
#undef HAVE_RES_SEARCH
|
||||
#undef HAVE_RES_QUERYDOMAIN
|
||||
#undef HAVE_RES_MKQUERY
|
||||
#undef HAVE_RES_SEND
|
||||
#undef HAVE_DN_COMP
|
||||
#undef HAVE_DN_EXPAND
|
||||
#undef HAVE_NS_INITPARSE
|
||||
|
||||
#undef HAVE_LIBMICROHTTPD
|
||||
#undef HAVE_LIBIDN
|
||||
#undef HAVE_LIBIDN2
|
||||
#undef HAVE_LIBIDN2_IDN2_NO_TR46
|
||||
|
||||
|
||||
/*
|
||||
* Cryptography
|
||||
*/
|
||||
#undef HAVE_OPENSSL
|
||||
#undef HAVE_TLS_METHOD
|
||||
#undef HAVE_TLS_SERVER_METHOD
|
||||
#undef HAVE_TLS_CLIENT_METHOD
|
||||
#undef HAVE_SSLV23_METHOD
|
||||
#undef HAVE_SSLV23_SERVER_METHOD
|
||||
#undef HAVE_SSLV23_CLIENT_METHOD
|
||||
|
||||
#undef HAVE_LIBMCRYPT
|
||||
#undef HAVE_GCRYPT
|
||||
#undef GCRYPT_WITH_AES
|
||||
#undef GCRYPT_WITH_ARCFOUR
|
||||
#undef GCRYPT_WITH_BLOWFISH
|
||||
#undef GCRYPT_WITH_CAST5
|
||||
#undef GCRYPT_WITH_DES
|
||||
#undef GCRYPT_WITH_IDEA
|
||||
#undef GCRYPT_WITH_RFC2268
|
||||
#undef GCRYPT_WITH_SERPENT
|
||||
#undef GCRYPT_WITH_TWOFISH
|
||||
#undef GCRYPT_WITH_CRC
|
||||
#undef GCRYPT_WITH_HAVAL
|
||||
#undef GCRYPT_WITH_MD2
|
||||
#undef GCRYPT_WITH_MD4
|
||||
#undef GCRYPT_WITH_MD5
|
||||
#undef GCRYPT_WITH_RMD160
|
||||
#undef GCRYPT_WITH_SHA0
|
||||
#undef GCRYPT_WITH_SHA1
|
||||
#undef GCRYPT_WITH_SHA224
|
||||
#undef GCRYPT_WITH_SHA256
|
||||
#undef GCRYPT_WITH_SHA384
|
||||
#undef GCRYPT_WITH_SHA512
|
||||
#undef GCRYPT_WITH_TIGER
|
||||
#undef GCRYPT_WITH_WHIRLPOOL
|
||||
#undef GCRYPT_WITH_DSA
|
||||
#undef GCRYPT_WITH_ELGAMAL
|
||||
#undef GCRYPT_WITH_RSA
|
||||
#undef LIBMCRYPT24
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Assembler
|
||||
*/
|
||||
#undef HAVE_YASM
|
||||
#undef HAVE_NASM
|
||||
#undef HAVE_X86_ASSEMBLER
|
||||
|
||||
/*
|
||||
* Character encoding
|
||||
*/
|
||||
#undef HAVE_ICONV
|
||||
#undef ICONV_CONST
|
||||
|
||||
|
||||
/*
|
||||
* Endianess
|
||||
*/
|
||||
#undef __BIG_ENDIAN__
|
||||
#undef __LITTLE_ENDIAN__
|
||||
|
||||
/*
|
||||
* Compression
|
||||
*/
|
||||
|
||||
#undef HAVE_LIBZ
|
||||
#undef HAVE_BZIP2
|
||||
|
||||
/*
|
||||
* lib curl
|
||||
*/
|
||||
#undef HAVE_LIBCURL
|
||||
#undef LIBCURL_FEATURE_SSL
|
||||
#undef LIBCURL_FEATURE_IPV6
|
||||
#undef LIBCURL_FEATURE_LIBZ
|
||||
#undef LIBCURL_FEATURE_ASYNCHDNS
|
||||
#undef LIBCURL_FEATURE_GSS_API
|
||||
#undef LIBCURL_FEATURE_SPNEGO
|
||||
#undef LIBCURL_FEATURE_NTLM
|
||||
#undef LIBCURL_FEATURE_NTLM_WB
|
||||
#undef LIBCURL_FEATURE_TLS_SRP
|
||||
#undef LIBCURL_PROTOCOL_DICT
|
||||
#undef LIBCURL_PROTOCOL_FILE
|
||||
#undef LIBCURL_PROTOCOL_FTP
|
||||
#undef LIBCURL_PROTOCOL_FTPS
|
||||
#undef LIBCURL_PROTOCOL_GOPHER
|
||||
#undef LIBCURL_PROTOCOL_HTTP
|
||||
#undef LIBCURL_PROTOCOL_HTTPS
|
||||
#undef LIBCURL_PROTOCOL_IMAP
|
||||
#undef LIBCURL_PROTOCOL_IMAPS
|
||||
#undef LIBCURL_PROTOCOL_POP3
|
||||
#undef LIBCURL_PROTOCOL_POP3S
|
||||
#undef LIBCURL_PROTOCOL_RTSP
|
||||
#undef LIBCURL_PROTOCOL_SMTP
|
||||
#undef LIBCURL_PROTOCOL_SMTPS
|
||||
#undef LIBCURL_PROTOCOL_TELNET
|
||||
#undef LIBCURL_PROTOCOL_TFTP
|
||||
|
||||
|
||||
/*
|
||||
* Audio
|
||||
*/
|
||||
#undef HAVE_LAME_LAME_H
|
||||
#undef HAVE_LAME
|
||||
#undef HAVE_LAME_HIP_DECODE
|
||||
#undef HAVE_MAD_H
|
||||
#undef HAVE_LIBMAD
|
||||
#undef HAVE_MPG123
|
||||
#undef HAVE_MPG123_H
|
||||
#undef HAVE_LIBSHOUT
|
||||
#undef HAVE_LIBOGG
|
||||
|
||||
#undef HAVE_LIBCDIO
|
||||
#undef HAVE_LIBCDDB
|
||||
|
||||
|
||||
/*
|
||||
* pthread
|
||||
*/
|
||||
#undef HAVE_PTHREADS
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Grafiklibraries
|
||||
*/
|
||||
#undef HAVE_TIFF
|
||||
#undef HAVE_JPEG
|
||||
#undef HAVE_LIBJPEGTURBO
|
||||
#undef HAVE_PNG
|
||||
#undef HAVE_IMAGEMAGICK
|
||||
#undef HAVE_FREETYPE2
|
||||
#undef HAVE_SDL2
|
||||
#undef HAVE_SDL12
|
||||
#undef HAVE_X11
|
||||
|
||||
/*
|
||||
* Databases
|
||||
*/
|
||||
#undef HAVE_MYSQL
|
||||
#undef HAVE_POSTGRESQL
|
||||
#undef POSTGRESQL_HAVE_PQsetSingleRowMode
|
||||
#undef HAVE_FREETDS
|
||||
#undef HAVE_SYBASE
|
||||
#undef HAVE_SQLITE3
|
||||
|
||||
|
||||
#define ppluint8 undefined
|
||||
#define pplint8 undefined
|
||||
#define ppluint16 undefined
|
||||
#define pplint16 undefined
|
||||
#define ppluint32 undefined
|
||||
#define pplint32 undefined
|
||||
#define ppluint64 undefined
|
||||
#define pplint64 undefined
|
||||
|
||||
#define ppliptr undefined
|
||||
|
||||
#define pplfloat float
|
||||
#define ppldouble double
|
||||
#define pplbool bool
|
||||
#define pplchar char
|
||||
#define ppluchar unsigned char
|
||||
|
||||
#define ICONV_UNICODE undefined
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifdef _M_ALPHA
|
||||
#ifndef __BIG_ENDIAN__
|
||||
#define __BIG_ENDIAN__
|
||||
#endif
|
||||
#else
|
||||
#ifndef __LITTLE_ENDIAN__
|
||||
#define __LITTLE_ENDIAN__
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN // Keine MFCs
|
||||
#define _WIN32_WINNT 0x501
|
||||
// Ab Visual Studio 2005 (Visual C++ 8.0) gibt es einige <20>nderungen
|
||||
#if _MSC_VER >= 1400
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#define _CRT_SECURE_NO_DEPRECATE
|
||||
#define _AFX_SECURE_NO_DEPRECATE
|
||||
#define _ATL_SECURE_NO_DEPRECATE
|
||||
#pragma warning(disable : 4996)
|
||||
#pragma warning(disable : 4800)
|
||||
|
||||
/*
|
||||
#define unlink _unlink
|
||||
#define strdup _strdup
|
||||
#define fileno _fileno
|
||||
#define mkdir _mkdir
|
||||
#define open _open
|
||||
#define close _close
|
||||
#define read _read
|
||||
*/
|
||||
#endif
|
||||
//#define _WINSOCKAPI_ /* Prevent inclusion of winsock.h in windows.h */
|
||||
//#include <windows.h>
|
||||
#endif
|
||||
|
||||
#endif
|
41
src/pplib/include/crypto.h
Normal file
41
src/pplib/include/crypto.h
Normal file
|
@ -0,0 +1,41 @@
|
|||
/*******************************************************************************
|
||||
* This file is part of "Patrick's Programming Library", Version 7 (PPL7).
|
||||
* Web: http://www.pfp.de/ppl/
|
||||
*
|
||||
* $Author$
|
||||
* $Revision$
|
||||
* $Date$
|
||||
* $Id$
|
||||
*
|
||||
*******************************************************************************
|
||||
* Copyright (c) 2013, Patrick Fedick <patrick@pfp.de>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER AND CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*******************************************************************************/
|
||||
|
||||
namespace ppl7 {
|
||||
|
||||
extern bool __OpenSSLDigestAdded;
|
||||
void InitOpenSSLDigest();
|
||||
|
||||
|
||||
}
|
481
src/pplib/include/ppl7-algorithms.h
Normal file
481
src/pplib/include/ppl7-algorithms.h
Normal file
|
@ -0,0 +1,481 @@
|
|||
/*******************************************************************************
|
||||
* This file is part of "Patrick's Programming Library", Version 7 (PPL7).
|
||||
* Web: http://www.pfp.de/ppl/
|
||||
*
|
||||
* $Author$
|
||||
* $Revision$
|
||||
* $Date$
|
||||
* $Id$
|
||||
*
|
||||
*******************************************************************************
|
||||
* Copyright (c) 2013, Patrick Fedick <patrick@pfp.de>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER AND CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*******************************************************************************/
|
||||
|
||||
|
||||
#ifndef PPL7ALGORITHMS_H_
|
||||
#define PPL7ALGORITHMS_H_
|
||||
|
||||
namespace ppl7 {
|
||||
|
||||
// ***************************************************************************
|
||||
// AVL-Trees
|
||||
// ***************************************************************************
|
||||
#ifndef AVL_MAX_HEIGHT
|
||||
#define AVL_MAX_HEIGHT 32
|
||||
#endif
|
||||
|
||||
class AVLTreeAlgorithm
|
||||
{
|
||||
public:
|
||||
class Node
|
||||
{
|
||||
friend class AVLTreeAlgorithm;
|
||||
public:
|
||||
Node *left, *right, *parent;
|
||||
signed char balance;
|
||||
public:
|
||||
Node() {
|
||||
left=right=parent=NULL;
|
||||
balance=0;
|
||||
}
|
||||
virtual ~Node() {};
|
||||
};
|
||||
|
||||
class Iterator
|
||||
{
|
||||
friend class AVLTreeAlgorithm;
|
||||
private:
|
||||
Node *current;
|
||||
Node *stack[AVL_MAX_HEIGHT];
|
||||
size_t stack_height;
|
||||
public:
|
||||
Iterator();
|
||||
};
|
||||
|
||||
private:
|
||||
Node *root;
|
||||
size_t numElements;
|
||||
bool dupes;
|
||||
|
||||
void upInsert(Node *node);
|
||||
void upDelete(Node *node);
|
||||
Node *rotate(Node *kn);
|
||||
void swapNodes(Node *item1, Node *item2);
|
||||
|
||||
public:
|
||||
PPL7EXCEPTION(MissingCompareOperator, Exception);
|
||||
|
||||
AVLTreeAlgorithm();
|
||||
virtual ~AVLTreeAlgorithm();
|
||||
virtual int compare(const Node &value1, const Node &value2) const;
|
||||
void allowDupes(bool allow);
|
||||
size_t num() const;
|
||||
size_t count() const;
|
||||
void clear();
|
||||
void addNode(Node *item);
|
||||
void eraseNode(Node *item);
|
||||
Node *findNode(const Node *value) const;
|
||||
void reset(Iterator &it) const;
|
||||
Node *getFirst(Iterator &it) const;
|
||||
Node *getNext(Iterator &it) const;
|
||||
Node *getLast(Iterator &it) const;
|
||||
Node *getPrevious(Iterator &it) const;
|
||||
Node *getCurrent(Iterator &it) const;
|
||||
Node *getRoot() const;
|
||||
|
||||
};
|
||||
|
||||
template <class K, class T> class AVLTree : private AVLTreeAlgorithm
|
||||
{
|
||||
private:
|
||||
class TreeItem : private AVLTreeAlgorithm::Node {
|
||||
friend class AVLTree;
|
||||
K key;
|
||||
T value;
|
||||
public:
|
||||
void *operator new(size_t, void *p) { return (p);}
|
||||
};
|
||||
MemoryHeap MyHeap;
|
||||
void clearRecursive(TreeItem *item) {
|
||||
if (item->left) clearRecursive(static_cast<TreeItem*>(item->left));
|
||||
item->~TreeItem();
|
||||
if (item->right) clearRecursive(static_cast<TreeItem*>(item->right));
|
||||
}
|
||||
public:
|
||||
class Iterator : public AVLTreeAlgorithm::Iterator
|
||||
{
|
||||
friend class AVLTree;
|
||||
private:
|
||||
const K* Key;
|
||||
T *Value;
|
||||
public:
|
||||
Iterator()
|
||||
{
|
||||
Key=NULL;
|
||||
Value=NULL;
|
||||
}
|
||||
const K& key() const
|
||||
{
|
||||
if (!Key) throw NullPointerException();
|
||||
return (*Key);
|
||||
}
|
||||
T& value() const
|
||||
{
|
||||
if (!Value) throw NullPointerException();
|
||||
return (*Value);
|
||||
}
|
||||
};
|
||||
|
||||
AVLTree() {
|
||||
MyHeap.init(sizeof(TreeItem),0,100);
|
||||
};
|
||||
~AVLTree() {
|
||||
clear();
|
||||
}
|
||||
|
||||
virtual int compare(const Node &value1, const Node &value2) const
|
||||
{
|
||||
const TreeItem &v1=static_cast<const TreeItem&>(value1);
|
||||
const TreeItem &v2=static_cast<const TreeItem&>(value2);
|
||||
if (v1.key<v2.key) return (1);
|
||||
if (v1.key>v2.key) return (-1);
|
||||
return (0);
|
||||
}
|
||||
size_t capacity() const
|
||||
{
|
||||
return (MyHeap.capacity());
|
||||
}
|
||||
size_t itemSize() const
|
||||
{
|
||||
return (sizeof(TreeItem));
|
||||
}
|
||||
void reserve(size_t num)
|
||||
{
|
||||
MyHeap.reserve(num);
|
||||
}
|
||||
|
||||
T& add(const K &key, const T &value)
|
||||
{
|
||||
TreeItem *item=new (MyHeap.malloc())TreeItem;
|
||||
item->key=key;
|
||||
item->value=value;
|
||||
try {
|
||||
AVLTreeAlgorithm::addNode(item);
|
||||
} catch (...) {
|
||||
item->~TreeItem();
|
||||
MyHeap.free(item);
|
||||
throw;
|
||||
}
|
||||
return (item->value);
|
||||
}
|
||||
T& find(const K &key) const
|
||||
{
|
||||
TreeItem search, *found;
|
||||
search.key=key;
|
||||
found=static_cast<TreeItem*>(AVLTreeAlgorithm::findNode(&search));
|
||||
if (!found) throw ItemNotFoundException();
|
||||
return (found->value);
|
||||
}
|
||||
|
||||
bool exists(const K &key) const
|
||||
{
|
||||
TreeItem search, *found;
|
||||
search.key=key;
|
||||
found=static_cast<TreeItem*>(AVLTreeAlgorithm::findNode(&search));
|
||||
if (!found) return (false);
|
||||
return (true);
|
||||
}
|
||||
|
||||
T& operator[](const K &key) const
|
||||
{
|
||||
TreeItem search, *found;
|
||||
search.key=key;
|
||||
found=static_cast<TreeItem*>(AVLTreeAlgorithm::findNode(&search));
|
||||
if (!found) throw ItemNotFoundException();
|
||||
return (found->value);
|
||||
}
|
||||
|
||||
void erase(const K &key)
|
||||
{
|
||||
TreeItem search, *found;
|
||||
search.key=key;
|
||||
found=static_cast<TreeItem*>(AVLTreeAlgorithm::findNode(&search));
|
||||
if (!found) throw ItemNotFoundException();
|
||||
AVLTreeAlgorithm::eraseNode(found);
|
||||
found->~TreeItem();
|
||||
MyHeap.free(found);
|
||||
}
|
||||
void clear()
|
||||
{
|
||||
TreeItem *root=static_cast<TreeItem*>(AVLTreeAlgorithm::getRoot());
|
||||
// Destruktoren der einzelnen Elemente aufrufen
|
||||
if (root) clearRecursive(root);
|
||||
MyHeap.clear(); // kompletten Speicher freigeben
|
||||
AVLTreeAlgorithm::clear();
|
||||
|
||||
}
|
||||
void allowDupes(bool allow)
|
||||
{
|
||||
AVLTreeAlgorithm::allowDupes(allow);
|
||||
}
|
||||
size_t num() const
|
||||
{
|
||||
return (AVLTreeAlgorithm::num());
|
||||
}
|
||||
size_t count() const
|
||||
{
|
||||
return (AVLTreeAlgorithm::count());
|
||||
}
|
||||
|
||||
void reset(Iterator &it) const
|
||||
{
|
||||
AVLTreeAlgorithm::reset(it);
|
||||
}
|
||||
bool getFirst(Iterator &it) const
|
||||
{
|
||||
TreeItem *item=static_cast<TreeItem*>(AVLTreeAlgorithm::getFirst(it));
|
||||
if (!item) return (false);
|
||||
it.Key=&item->key;
|
||||
it.Value=&item->value;
|
||||
return (true);
|
||||
}
|
||||
bool getNext(Iterator &it) const
|
||||
{
|
||||
TreeItem *item=static_cast<TreeItem*>(AVLTreeAlgorithm::getNext(it));
|
||||
if (!item) return (false);
|
||||
it.Key=&item->key;
|
||||
it.Value=&item->value;
|
||||
return (true);
|
||||
}
|
||||
bool getLast(Iterator &it) const
|
||||
{
|
||||
TreeItem *item=static_cast<TreeItem*>(AVLTreeAlgorithm::getLast(it));
|
||||
if (!item) return (false);
|
||||
it.Key=&item->key;
|
||||
it.Value=&item->value;
|
||||
return (true);
|
||||
}
|
||||
bool getPrevious(Iterator &it) const
|
||||
{
|
||||
TreeItem *item=static_cast<TreeItem*>(AVLTreeAlgorithm::getPrevious(it));
|
||||
if (!item) return (false);
|
||||
it.Key=&item->key;
|
||||
it.Value=&item->value;
|
||||
return (true);
|
||||
}
|
||||
bool getCurrent(Iterator &it) const
|
||||
{
|
||||
TreeItem *item=static_cast<TreeItem*>(AVLTreeAlgorithm::getCurrent(it));
|
||||
if (!item) return (false);
|
||||
it.Key=&item->key;
|
||||
it.Value=&item->value;
|
||||
return (true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
template <class K> class List
|
||||
{
|
||||
public:
|
||||
class Iterator;
|
||||
private:
|
||||
MemoryHeap MyHeap;
|
||||
class ListItem {
|
||||
friend class List;
|
||||
friend class List::Iterator;
|
||||
private:
|
||||
K item;
|
||||
ListItem *previous, *next, *original;
|
||||
List *owner;
|
||||
public:
|
||||
ListItem() {
|
||||
previous=next=original=NULL;
|
||||
owner=NULL;
|
||||
}
|
||||
void *operator new(size_t, void *p) { return (p);}
|
||||
};
|
||||
ListItem *first, *last;
|
||||
public:
|
||||
class Iterator
|
||||
{
|
||||
friend class List;
|
||||
private:
|
||||
ListItem* item;
|
||||
bool init;
|
||||
public:
|
||||
Iterator() {item=NULL; init=false;}
|
||||
K& value() const
|
||||
{
|
||||
if (!item) throw NullPointerException();
|
||||
return (item->item);
|
||||
}
|
||||
};
|
||||
|
||||
List() {
|
||||
first=NULL;
|
||||
last=NULL;
|
||||
MyHeap.init(sizeof(ListItem),0,100);
|
||||
}
|
||||
~List() {
|
||||
clear();
|
||||
}
|
||||
|
||||
size_t capacity() const
|
||||
{
|
||||
return (MyHeap.capacity());
|
||||
}
|
||||
size_t itemSize() const
|
||||
{
|
||||
return (sizeof(ListItem));
|
||||
}
|
||||
void reserve(size_t num)
|
||||
{
|
||||
MyHeap.reserve(num);
|
||||
}
|
||||
|
||||
K& add(const K &item)
|
||||
{
|
||||
ListItem *it=new (MyHeap.malloc())ListItem;
|
||||
it->item=item;
|
||||
it->original=it;
|
||||
it->previous=last;
|
||||
it->next=NULL;
|
||||
it->owner=this;
|
||||
if (last) last->next=it;
|
||||
if (!first) first=it;
|
||||
last=it;
|
||||
return (it->item);
|
||||
}
|
||||
|
||||
K& push_front(const K &item)
|
||||
{
|
||||
ListItem *it=new (MyHeap.malloc())ListItem;
|
||||
it->item=item;
|
||||
it->original=it;
|
||||
it->previous=NULL;
|
||||
it->next=first;
|
||||
it->owner=this;
|
||||
if (first) first->previous=it;
|
||||
if (!last) last=it;
|
||||
first=it;
|
||||
return (it->item);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void erase(const K &item)
|
||||
{
|
||||
ListItem *it=first;
|
||||
while (it) {
|
||||
if (it->item==item) {
|
||||
if (it->previous) it->previous->next=it->next;
|
||||
if (it->next) it->next->previous=it->previous;
|
||||
if (it==first) first=it->next;
|
||||
if (it==last) last=it->previous;
|
||||
MyHeap.free(it);
|
||||
return;
|
||||
}
|
||||
it=it->next;
|
||||
}
|
||||
}
|
||||
|
||||
size_t num() const
|
||||
{
|
||||
return (MyHeap.count());
|
||||
}
|
||||
size_t count() const
|
||||
{
|
||||
return (MyHeap.count());
|
||||
}
|
||||
size_t size() const
|
||||
{
|
||||
return (MyHeap.count());
|
||||
}
|
||||
|
||||
void clear()
|
||||
{
|
||||
ListItem *it;
|
||||
while (first) {
|
||||
it=first;
|
||||
first=it->next;
|
||||
it->~ListItem();
|
||||
}
|
||||
last=NULL;
|
||||
MyHeap.clear();
|
||||
}
|
||||
|
||||
void reset(Iterator &it) const throw()
|
||||
{
|
||||
it.item=NULL;
|
||||
it.init=false;
|
||||
}
|
||||
bool getFirst(Iterator &it) const throw()
|
||||
{
|
||||
it.item=first;
|
||||
it.init=true;
|
||||
if (first) return (true);
|
||||
return (false);
|
||||
}
|
||||
bool getNext(Iterator &it) const throw()
|
||||
{
|
||||
if (!it.init) {
|
||||
it.item=first;
|
||||
it.init=true;
|
||||
} else {
|
||||
it.item=it.item->next;
|
||||
}
|
||||
ListItem *item=it.item;
|
||||
if (!item) return (false);
|
||||
return (true);
|
||||
}
|
||||
bool getLast(Iterator &it) const throw()
|
||||
{
|
||||
it.item=last;
|
||||
it.init=true;
|
||||
if (last) return (true);
|
||||
return (false);
|
||||
}
|
||||
bool getPrevious(Iterator &it) const throw()
|
||||
{
|
||||
if (!it.init) {
|
||||
it.item=last;
|
||||
it.init=true;
|
||||
} else {
|
||||
it.item=it.item->previous;
|
||||
}
|
||||
ListItem *item=it.item;
|
||||
if (!item) return (false);
|
||||
return (true);
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
} // EOF namespace ppl7
|
||||
|
||||
|
||||
#endif /* PPL7ALGORITHMS_H_ */
|
686
src/pplib/include/ppl7-audio.h
Normal file
686
src/pplib/include/ppl7-audio.h
Normal file
|
@ -0,0 +1,686 @@
|
|||
/*******************************************************************************
|
||||
* This file is part of "Patrick's Programming Library", Version 7 (PPL7).
|
||||
* Web: http://www.pfp.de/ppl/
|
||||
*
|
||||
* $Author$
|
||||
* $Revision$
|
||||
* $Date$
|
||||
* $Id$
|
||||
*
|
||||
*******************************************************************************
|
||||
* Copyright (c) 2013, Patrick Fedick <patrick@pfp.de>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER AND CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef _PPL7_INCLUDE_AUDIO
|
||||
#define _PPL7_INCLUDE_AUDIO
|
||||
#ifndef _PPL7_INCLUDE
|
||||
#ifdef PPL7LIB
|
||||
#include "ppl7.h"
|
||||
#else
|
||||
#include <ppl7.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef PPL7INET_H_
|
||||
#ifdef PPL7LIB
|
||||
#include "ppl7-inet.h"
|
||||
#else
|
||||
#include <ppl7-inet.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <list>
|
||||
|
||||
|
||||
namespace ppl7 {
|
||||
|
||||
PPL7EXCEPTION(InvalidGenreException,Exception);
|
||||
PPL7EXCEPTION(UnsupportedAudioFormatException,Exception);
|
||||
PPL7EXCEPTION(UnsupportedID3TagVersionException,Exception);
|
||||
PPL7EXCEPTION(FilenameNotSetException,Exception);
|
||||
PPL7EXCEPTION(NoID3TagFoundException,Exception);
|
||||
|
||||
PPL7EXCEPTION(EncoderException,Exception);
|
||||
PPL7EXCEPTION(EncoderAlreadyStartedException,EncoderException);
|
||||
PPL7EXCEPTION(EncoderNotStartedException,EncoderException);
|
||||
PPL7EXCEPTION(EncoderBufferTooSmallException,EncoderException);
|
||||
PPL7EXCEPTION(EncoderPsychoAcousticException,EncoderException);
|
||||
PPL7EXCEPTION(EncoderInitializationException,EncoderException);
|
||||
PPL7EXCEPTION(EncoderAbortedException,EncoderException);
|
||||
PPL7EXCEPTION(EncoderAudioFormatMismatchException,EncoderException);
|
||||
|
||||
PPL7EXCEPTION(DecoderException,Exception);
|
||||
PPL7EXCEPTION(DecoderInitializationException,DecoderException);
|
||||
|
||||
|
||||
//!\brief Struktur zum Speichern eines MP3-Headers
|
||||
typedef struct tagMPEGHeader{
|
||||
ppluint64 start,end; // Beginn und Ende der Daten
|
||||
ppluint64 size,filesize;
|
||||
int version;
|
||||
int layer;
|
||||
int error_protection;
|
||||
int bitrate_index;
|
||||
int bitrate;
|
||||
int frequency_index;
|
||||
int frequency;
|
||||
int padding;
|
||||
int extension;
|
||||
int mode;
|
||||
int mode_ext;
|
||||
int copyright;
|
||||
int original;
|
||||
int emphasis;
|
||||
int stereo;
|
||||
int framesize;
|
||||
int frames;
|
||||
ppluint64 mslength; // Laenge in ms
|
||||
ppluint64 length; // Laenge in s
|
||||
ppluint64 samples;
|
||||
bool vbr;
|
||||
} PPL_MPEG_HEADER;
|
||||
|
||||
//!\brief Identifizieren von MP3-Dateien und Einlesen der Header
|
||||
bool IdentMPEG(FileObject &file, PPL_MPEG_HEADER * mpg);
|
||||
|
||||
void GetMP3Frame(FileObject &file, PPL_MPEG_HEADER &mpg, ByteArray &buffer);
|
||||
|
||||
class AudioInfo
|
||||
{
|
||||
public:
|
||||
AudioInfo();
|
||||
|
||||
enum AudioFormat {
|
||||
UNKNOWN,
|
||||
WAVE,
|
||||
AIFF,
|
||||
MP3,
|
||||
OGG
|
||||
};
|
||||
enum ChannelMode {
|
||||
STEREO,
|
||||
MONO,
|
||||
DUAL_CHANNEL,
|
||||
JOINT_STEREO
|
||||
};
|
||||
|
||||
AudioFormat Format;
|
||||
bool HaveID3v2Tag;
|
||||
bool IsVBR;
|
||||
ppluint32 ID3v2TagStart;
|
||||
ppluint32 FileSize;
|
||||
ppluint32 AudioStart;
|
||||
ppluint32 AudioEnd;
|
||||
ppluint32 AudioSize;
|
||||
ppluint32 Samples;
|
||||
ppluint32 Length; // Length in ms
|
||||
ppluint32 Frequency;
|
||||
ppluint16 Bitrate;
|
||||
ppluint8 BitsPerSample;
|
||||
ppluint8 BytesPerSample;
|
||||
ppluint8 Channels;
|
||||
ChannelMode Mode;
|
||||
};
|
||||
|
||||
bool IdentAudioFile(FileObject &file, AudioInfo &info);
|
||||
AudioInfo::AudioFormat IdentAudioFile(FileObject &file);
|
||||
String GetID3GenreName(int id);
|
||||
|
||||
class ID3Frame
|
||||
{
|
||||
friend class ID3Tag;
|
||||
friend class ID3TagTranscode;
|
||||
private:
|
||||
String ID;
|
||||
int Flags;
|
||||
size_t Size;
|
||||
char *data;
|
||||
ID3Frame *nextFrame, *previousFrame;
|
||||
|
||||
public:
|
||||
ID3Frame();
|
||||
ID3Frame(const String &name);
|
||||
~ID3Frame();
|
||||
|
||||
void setData(const ByteArrayPtr &data);
|
||||
void setFlags(int flags);
|
||||
void hexDump() const;
|
||||
const String& name() const;
|
||||
int flags() const;
|
||||
size_t size() const;
|
||||
void getData(ByteArray &data) const;
|
||||
bool hasData() const;
|
||||
};
|
||||
|
||||
class ID3TagTranscode
|
||||
{
|
||||
public:
|
||||
static void copyAndDecodeText(String &s, const ID3Frame *frame, int offset);
|
||||
static int decode(const ID3Frame *frame, int offset, int encoding, String &target);
|
||||
};
|
||||
|
||||
class ID3Tag
|
||||
{
|
||||
public:
|
||||
enum TextEncoding {
|
||||
ENC_USASCII,
|
||||
ENC_ISO88591,
|
||||
ENC_UTF16,
|
||||
ENC_UTF8
|
||||
};
|
||||
|
||||
enum AudioFormat {
|
||||
AF_UNKNOWN=0,
|
||||
AF_MP3,
|
||||
AF_AIFF
|
||||
};
|
||||
|
||||
enum PictureType {
|
||||
PIC_COVER_FRONT=3,
|
||||
PIC_COVER_BACK=4,
|
||||
};
|
||||
private:
|
||||
String Filename;
|
||||
int Flags;
|
||||
size_t numFrames;
|
||||
int Size;
|
||||
AudioFormat myAudioFormat;
|
||||
ppluint32 PaddingSize, PaddingSpace, MaxPaddingSpace;
|
||||
ID3Frame *firstFrame, *lastFrame;
|
||||
void setTextFrameUtf16(const String &framename, const String &text);
|
||||
void setTextFrameISO88591(const String &framename, const String &text);
|
||||
void setTextFrameUtf8(const String &framename, const String &text);
|
||||
AudioFormat identAudioFormat(FileObject &File);
|
||||
ppluint64 findId3Tag(FileObject &File);
|
||||
void saveMP3();
|
||||
void saveAiff();
|
||||
bool trySaveAiffInExistingFile(FileObject &o, ByteArrayPtr &tagV2);
|
||||
void copyAiffToNewFile(FileObject &o, FileObject &n, ByteArrayPtr &tagV2);
|
||||
|
||||
public:
|
||||
ID3Tag();
|
||||
ID3Tag(const String &File);
|
||||
~ID3Tag();
|
||||
|
||||
void load(const String &filename);
|
||||
void load(FileObject &file);
|
||||
void clearTags();
|
||||
void clear();
|
||||
void save();
|
||||
|
||||
void setPaddingSize(int bytes);
|
||||
void setPaddingSpace(int bytes);
|
||||
void setMaxPaddingSpace(int bytes);
|
||||
|
||||
void addFrame(ID3Frame *Frame);
|
||||
void removeFrame(ID3Frame *frame);
|
||||
void deleteFrame(ID3Frame *frame);
|
||||
ID3Frame *findFrame(const String &name) const;
|
||||
ID3Frame *findUserDefinedText(const String &description) const;
|
||||
void listFrames(bool hexdump=false) const;
|
||||
size_t frameCount() const;
|
||||
|
||||
void setArtist(const String &artist);
|
||||
void setTitle(const String &title);
|
||||
void setGenre(const String &genre);
|
||||
void setRemixer(const String &remixer);
|
||||
void setLabel(const String &label);
|
||||
void setComment(const String &comment);
|
||||
void setComment(const String &description, const String &comment);
|
||||
void setYear(const String &year);
|
||||
void setAlbum(const String &album);
|
||||
void setTrack(const String &track);
|
||||
void setBPM(const String &bpm);
|
||||
void setKey(const String &key);
|
||||
void setEnergyLevel(const String &energy);
|
||||
void setTextFrame(const String &framename, const String &text, TextEncoding enc=ENC_UTF16);
|
||||
void setPicture(int type, const ByteArrayPtr &bin, const String &MimeType);
|
||||
|
||||
void generateId3V2Tag(ByteArray &tag) const;
|
||||
void generateId3V1Tag(ByteArray &tag) const;
|
||||
|
||||
|
||||
String getArtist() const;
|
||||
String getTitle() const;
|
||||
String getGenre() const;
|
||||
String getYear() const;
|
||||
String getComment() const;
|
||||
String getComment(const String &description) const;
|
||||
String getRemixer() const;
|
||||
String getLabel() const;
|
||||
String getAlbum() const;
|
||||
String getTrack() const;
|
||||
String getBPM() const;
|
||||
String getKey() const;
|
||||
String getEnergyLevel() const;
|
||||
ByteArray getPicture(int type) const;
|
||||
bool getPicture(int type, ByteArray &bin) const;
|
||||
bool hasPicture(int type) const;
|
||||
void removePicture(int type);
|
||||
|
||||
bool getPrivateData(ByteArray &bin, const String &identifier) const;
|
||||
ByteArrayPtr getPrivateData(const String &identifier) const;
|
||||
|
||||
};
|
||||
|
||||
class Icecast
|
||||
{
|
||||
private:
|
||||
void *shout;
|
||||
bool bconnected;
|
||||
public:
|
||||
Icecast();
|
||||
~Icecast();
|
||||
String getVersion(int *major=NULL, int *minor=NULL, int *patch=NULL) const;
|
||||
String version() const;
|
||||
bool connected();
|
||||
void setConnection(const String &host, int port, const String &password);
|
||||
String host() const;
|
||||
int port() const;
|
||||
String password() const;
|
||||
void setMount(const String &mount);
|
||||
String mount() const;
|
||||
void setName(const String &name);
|
||||
String name() const;
|
||||
void setUrl(const String &url);
|
||||
String url() const;
|
||||
void setGenre(const String &genre);
|
||||
String genre() const;
|
||||
void setUser(const String &user);
|
||||
String user() const;
|
||||
void setAgent(const String &agent);
|
||||
String agent() const;
|
||||
void setDescription(const String &description);
|
||||
String description() const;
|
||||
void setDumpfile(const String &file);
|
||||
String dumpfile() const;
|
||||
void setAudioInfo(const String &name, const String &value);
|
||||
String audioInfo(const String &name) const;
|
||||
void setPublic(bool makepublic);
|
||||
void setFormatMP3();
|
||||
void setFormatOGG();
|
||||
void setNonBlocking(bool flag);
|
||||
|
||||
void connect();
|
||||
void disconnect();
|
||||
|
||||
void send(const void *buffer, size_t bytes);
|
||||
int delay();
|
||||
void sync();
|
||||
|
||||
void sendMetadata(const String &name, const String &value);
|
||||
void setTitle(const String &title);
|
||||
|
||||
};
|
||||
|
||||
class AudioCD
|
||||
{
|
||||
private:
|
||||
void *cdio;
|
||||
String myDevice;
|
||||
size_t first_track_num;
|
||||
size_t i_tracks;
|
||||
size_t num_audio_tracks;
|
||||
size_t audio_frames;
|
||||
size_t last_lsn;
|
||||
void countAudioTracks();
|
||||
|
||||
public:
|
||||
PPL7EXCEPTION(DeviceOpenFailed,Exception);
|
||||
PPL7EXCEPTION(DeviceNotOpen,Exception);
|
||||
PPL7EXCEPTION(InvalidAudioTrack,Exception);
|
||||
|
||||
class Toc
|
||||
{
|
||||
public:
|
||||
ppluint8 min,sec,frames;
|
||||
};
|
||||
|
||||
class Track
|
||||
{
|
||||
friend class AudioCD;
|
||||
private:
|
||||
int _track;
|
||||
size_t _start, _end;
|
||||
bool _hasPreemphasis, _hasCopyPermit, _isAudioTrack;
|
||||
int _channels;
|
||||
|
||||
public:
|
||||
Track();
|
||||
int track() const;
|
||||
size_t start() const;
|
||||
Toc start_toc() const;
|
||||
size_t end() const;
|
||||
size_t size() const;
|
||||
size_t seconds() const;
|
||||
bool hasPreemphasis() const;
|
||||
bool hasCopyPermit() const;
|
||||
bool isAudioTrack() const;
|
||||
int channels() const;
|
||||
};
|
||||
|
||||
AudioCD();
|
||||
~AudioCD();
|
||||
|
||||
void openDevice(const String &device=String());
|
||||
void closeDevice();
|
||||
const String &deviceName() const;
|
||||
|
||||
size_t firstTrack() const;
|
||||
size_t lastTrack() const;
|
||||
size_t numTotalTracks() const;
|
||||
size_t numAudioTracks() const;
|
||||
size_t totalAudioFrames() const;
|
||||
size_t totalAudioLength() const;
|
||||
size_t lastLsn() const;
|
||||
|
||||
AudioCD::Track getTrack(int track);
|
||||
bool isAudioTrack(int track);
|
||||
|
||||
static bool isSupported();
|
||||
static std::list<String> getDevices();
|
||||
static Toc lsn2toc(size_t lsn);
|
||||
};
|
||||
|
||||
|
||||
class CDDB
|
||||
{
|
||||
public:
|
||||
PPL7EXCEPTION(QueryFailed, Exception);
|
||||
PPL7EXCEPTION(InvalidDiscId, Exception);
|
||||
class Track
|
||||
{
|
||||
public:
|
||||
int number;
|
||||
int frame_offset;
|
||||
int length;
|
||||
String Artist;
|
||||
String Title;
|
||||
String Extra;
|
||||
};
|
||||
class Disc
|
||||
{
|
||||
public:
|
||||
typedef std::list<Track> TrackList;
|
||||
|
||||
unsigned int discId;
|
||||
String category;
|
||||
String genre;
|
||||
int length;
|
||||
int year;
|
||||
String Artist;
|
||||
String Title;
|
||||
String Extra;
|
||||
TrackList Tracks;
|
||||
};
|
||||
|
||||
typedef std::list<Disc> Matches;
|
||||
|
||||
private:
|
||||
ppl7::Curl curl;
|
||||
String QueryPath, Server;
|
||||
String ClientName, ClientVersion;
|
||||
String UserName, Hostname;
|
||||
int port;
|
||||
String buildUri(const String &cmd);
|
||||
|
||||
public:
|
||||
CDDB();
|
||||
~CDDB();
|
||||
|
||||
void setHttpServer(const String &server, int port=80);
|
||||
void setQueryPath(const String &path);
|
||||
void setProxy(const String &hostname, int port);
|
||||
void setClient(const String &name, const String &version);
|
||||
void setUser(const String &username, const String &hostname);
|
||||
|
||||
int query(AudioCD &cd, Matches &list);
|
||||
void getDisc(unsigned int discId, const String &category, Disc &d);
|
||||
|
||||
static bool isSupported();
|
||||
static unsigned int calcDiscId(AudioCD &cd);
|
||||
|
||||
};
|
||||
|
||||
//!\brief Struktur zum Speichern eines WAVE-Headers
|
||||
typedef struct tagWAVEHeader {
|
||||
ppluint32 datastart;
|
||||
ppluint32 numSamples;
|
||||
ppluint32 bytes;
|
||||
ppluint32 frequency;
|
||||
ppluint32 bytespersample;
|
||||
ppluint32 bytespersecond;
|
||||
ppluint32 seconds;
|
||||
ppluint8 channels;
|
||||
ppluint8 bitdepth;
|
||||
} WAVEHEADER;
|
||||
|
||||
typedef pplint16 SAMPLE16;
|
||||
|
||||
//!\brief Struktur zum Speichern eines Stereo-Samples
|
||||
typedef struct tagSTEREOSAMPLE16{
|
||||
SAMPLE16 left;
|
||||
SAMPLE16 right;
|
||||
} STEREOSAMPLE16;
|
||||
|
||||
class AudioDecoder
|
||||
{
|
||||
public:
|
||||
virtual ~AudioDecoder() {};
|
||||
virtual void open(FileObject &file, const AudioInfo *info=NULL)=0;
|
||||
virtual const AudioInfo & getAudioInfo() const=0;
|
||||
virtual void getAudioInfo(AudioInfo &info) const=0;
|
||||
virtual void seekSample(size_t sample)=0;
|
||||
virtual size_t getPosition() const=0;
|
||||
virtual size_t getSamples(size_t num, STEREOSAMPLE16 *buffer)=0;
|
||||
virtual size_t getSamples(size_t num, float *left, float *right)=0;
|
||||
virtual size_t getSamples(size_t num, SAMPLE16 *left, SAMPLE16 *right)=0;
|
||||
};
|
||||
|
||||
AudioDecoder *GetAudioDecoder(FileObject &file);
|
||||
|
||||
class AudioDecoder_Wave: public AudioDecoder
|
||||
{
|
||||
private:
|
||||
FileObject *ff;
|
||||
AudioInfo info;
|
||||
size_t position;
|
||||
size_t samplesize;
|
||||
void readWaveHeader(FileObject &file, WAVEHEADER &header);
|
||||
|
||||
public:
|
||||
AudioDecoder_Wave();
|
||||
~AudioDecoder_Wave();
|
||||
void open(FileObject &file, const AudioInfo *info=NULL);
|
||||
const AudioInfo & getAudioInfo() const;
|
||||
void getAudioInfo(AudioInfo &info) const;
|
||||
void seekSample(size_t sample);
|
||||
size_t getPosition() const;
|
||||
size_t getSamples(size_t num, STEREOSAMPLE16 *buffer);
|
||||
size_t getSamples(size_t num, float *left, float *right);
|
||||
size_t getSamples(size_t num, SAMPLE16 *left, SAMPLE16 *right);
|
||||
};
|
||||
|
||||
class AudioDecoder_Aiff : public AudioDecoder
|
||||
{
|
||||
private:
|
||||
FileObject *ff;
|
||||
AudioInfo info;
|
||||
size_t position;
|
||||
size_t samplesize;
|
||||
|
||||
public:
|
||||
AudioDecoder_Aiff();
|
||||
~AudioDecoder_Aiff();
|
||||
void open(FileObject &file, const AudioInfo *info=NULL);
|
||||
const AudioInfo & getAudioInfo() const;
|
||||
void getAudioInfo(AudioInfo &info) const;
|
||||
void seekSample(size_t sample);
|
||||
size_t getPosition() const;
|
||||
size_t getSamples(size_t num, STEREOSAMPLE16 *buffer);
|
||||
size_t getSamples(size_t num, float *left, float *right);
|
||||
size_t getSamples(size_t num, SAMPLE16 *left, SAMPLE16 *right);
|
||||
};
|
||||
|
||||
class AudioDecoder_MP3 : public AudioDecoder
|
||||
{
|
||||
private:
|
||||
void *decoder;
|
||||
FileObject *ff;
|
||||
ppluint8 *readbuffer;
|
||||
ppluint8 *outbuffer;
|
||||
|
||||
AudioInfo info;
|
||||
size_t position;
|
||||
size_t samplesize;
|
||||
size_t out_offset, out_size;
|
||||
bool isRunning;
|
||||
bool needInput;
|
||||
|
||||
size_t fillDecodeBuffer();
|
||||
|
||||
public:
|
||||
AudioDecoder_MP3();
|
||||
~AudioDecoder_MP3();
|
||||
void open(FileObject &file, const AudioInfo *info=NULL);
|
||||
const AudioInfo & getAudioInfo() const;
|
||||
void getAudioInfo(AudioInfo &info) const;
|
||||
void seekSample(size_t sample);
|
||||
size_t getPosition() const;
|
||||
size_t getSamples(size_t num, STEREOSAMPLE16 *buffer);
|
||||
size_t getSamples(size_t num, float *left, float *right);
|
||||
size_t getSamples(size_t num, SAMPLE16 *left, SAMPLE16 *right);
|
||||
};
|
||||
|
||||
class AudioDecoder_Ogg : public AudioDecoder
|
||||
{
|
||||
private:
|
||||
FileObject *ff;
|
||||
AudioInfo info;
|
||||
size_t position;
|
||||
size_t samplesize;
|
||||
|
||||
public:
|
||||
AudioDecoder_Ogg();
|
||||
~AudioDecoder_Ogg();
|
||||
void open(FileObject &file, const AudioInfo *info=NULL);
|
||||
const AudioInfo & getAudioInfo() const;
|
||||
void getAudioInfo(AudioInfo &info) const;
|
||||
void seekSample(size_t sample);
|
||||
size_t getPosition() const;
|
||||
size_t getSamples(size_t num, STEREOSAMPLE16 *buffer);
|
||||
size_t getSamples(size_t num, float *left, float *right);
|
||||
size_t getSamples(size_t num, SAMPLE16 *left, SAMPLE16 *right);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
class AudioEncoder
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
//!\brief Struktur zum Speichern des Fortschritts bei einem MP3-Encode-Vorgang
|
||||
typedef struct tagSOUNDPROGRESS{
|
||||
double timestarted;
|
||||
double timeend;
|
||||
double now;
|
||||
double past;
|
||||
float percent;
|
||||
float faktor;
|
||||
double eta;
|
||||
ppluint64 position;
|
||||
ppluint64 bytes;
|
||||
ppluint64 position_thisfile;
|
||||
ppluint64 bytes_thisfile;
|
||||
//PPL_WAVEHEADER *wav;
|
||||
//PPL_MPEG_HEADER *mpg;
|
||||
} PPL_SOUNDPROGRESS;
|
||||
|
||||
class AudioEncoder_MP3
|
||||
{
|
||||
private:
|
||||
class FirstAudio
|
||||
{
|
||||
public:
|
||||
int frequency;
|
||||
int channels;
|
||||
};
|
||||
void * gfp;
|
||||
FirstAudio firstAudio;
|
||||
//PPL_SOUNDPROGRESS progress;
|
||||
FileObject *out;
|
||||
char *readcache;
|
||||
int mp3bufsize;
|
||||
unsigned char *mp3buf;
|
||||
|
||||
ppluint32 samples;
|
||||
|
||||
void (*ProgressFunc) (int progress, void *priv);
|
||||
void *ProgressFuncPrivData;
|
||||
|
||||
bool have_firstaudio;
|
||||
bool started;
|
||||
bool bStopEncode;
|
||||
|
||||
void writeEncodedBytes(const char *buffer, size_t bytes);
|
||||
|
||||
public:
|
||||
AudioEncoder_MP3();
|
||||
~AudioEncoder_MP3();
|
||||
void setVBR(int min=32, int max=320, int quality=2);
|
||||
void setCBR(int kbps=320, int quality=2);
|
||||
void setABR(int kbps=192, int quality=2);
|
||||
void setQuality(int quality=2);
|
||||
void setStereoMode(const AudioInfo::ChannelMode mode=AudioInfo::JOINT_STEREO);
|
||||
void setLowpassFreq(int freq=-1); // -1=Disabled
|
||||
void setHighpassFreq(int freq=-1); // -1=Disabled
|
||||
void setProgressFunction(void (*ProgressFunc) (int progress, void *priv), void *priv);
|
||||
void startEncode(FileObject &output);
|
||||
void writeID3v2Tag(const ID3Tag &tag);
|
||||
void writeID3v1Tag(const ID3Tag &tag);
|
||||
void encode(AudioDecoder &decoder);
|
||||
void finish();
|
||||
void stop();
|
||||
|
||||
void startEncode(int frequency, int channels);
|
||||
int encodeBuffer(SAMPLE16 *left, SAMPLE16 *right, int num, void *mp3buf, size_t buffersize);
|
||||
int encodeBuffer(STEREOSAMPLE16 *buffer, int num, void *mp3buf, size_t buffersize);
|
||||
int flushBuffer(void *mp3buf, size_t buffersize);
|
||||
|
||||
static const char *getLameVersion();
|
||||
static const char *getPSYVersion();
|
||||
|
||||
};
|
||||
|
||||
|
||||
} // end of namespace ppl7
|
||||
|
||||
|
||||
#endif // _PPL7_INCLUDE_SOUND
|
||||
|
||||
|
70
src/pplib/include/ppl7-config.h.in
Normal file
70
src/pplib/include/ppl7-config.h.in
Normal file
|
@ -0,0 +1,70 @@
|
|||
/*******************************************************************************
|
||||
* This file is part of "Patrick's Programming Library", Version 7 (PPL7).
|
||||
* Web: http://www.pfp.de/ppl/
|
||||
*
|
||||
* $Author$
|
||||
* $Revision$
|
||||
* $Date$
|
||||
* $Id$
|
||||
*
|
||||
*******************************************************************************
|
||||
* Copyright (c) 2013, Patrick Fedick <patrick@pfp.de>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER AND CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef _PPL7_CONFIG
|
||||
#define _PPL7_CONFIG
|
||||
|
||||
#undef HAVE_SYS_TYPES_H
|
||||
#undef HAVE_STDLIB_H
|
||||
#undef HAVE_STDIO_H
|
||||
#undef HAVE_STRINGS_H
|
||||
#undef HAVE_STDARG_H
|
||||
|
||||
#undef MINGW32
|
||||
|
||||
#undef size_t
|
||||
|
||||
#ifndef _PPL6_CONFIG
|
||||
/*
|
||||
* Type definitions
|
||||
*/
|
||||
|
||||
#define ppluint8 undefined
|
||||
#define pplint8 undefined
|
||||
#define ppluint16 undefined
|
||||
#define pplint16 undefined
|
||||
#define ppluint32 undefined
|
||||
#define pplint32 undefined
|
||||
#define ppluint64 undefined
|
||||
#define pplint64 undefined
|
||||
|
||||
#define pplfloat float
|
||||
#define ppldouble double
|
||||
#define pplbool bool
|
||||
#define pplchar char
|
||||
#define ppluchar unsigned char
|
||||
#define ppliptr undefined
|
||||
#endif // #ifndef _PPL6_CONFIG
|
||||
|
||||
#endif
|
196
src/pplib/include/ppl7-crypto.h
Normal file
196
src/pplib/include/ppl7-crypto.h
Normal file
|
@ -0,0 +1,196 @@
|
|||
/*******************************************************************************
|
||||
* This file is part of "Patrick's Programming Library", Version 7 (PPL7).
|
||||
* Web: http://www.pfp.de/ppl/
|
||||
*
|
||||
* $Author$
|
||||
* $Revision$
|
||||
* $Date$
|
||||
* $Id$
|
||||
*
|
||||
*******************************************************************************
|
||||
* Copyright (c) 2013, Patrick Fedick <patrick@pfp.de>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER AND CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef PPL7CRYPTO_H_
|
||||
#define PPL7CRYPTO_H_
|
||||
|
||||
#ifndef _PPL7_INCLUDE
|
||||
#ifdef PPL7LIB
|
||||
#include "ppl7.h"
|
||||
#else
|
||||
#include <ppl7.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
namespace ppl7 {
|
||||
|
||||
PPL7EXCEPTION (InvalidAlgorithmException, Exception);
|
||||
PPL7EXCEPTION (NoAlgorithmSpecifiedException, Exception);
|
||||
PPL7EXCEPTION (InvalidBlocksizeException, Exception);
|
||||
PPL7EXCEPTION (HashFailedException, OperationFailedException);
|
||||
PPL7EXCEPTION (NoKeySpecifiedException, Exception);
|
||||
PPL7EXCEPTION (NoIVSpecifiedException, Exception);
|
||||
PPL7EXCEPTION (EncryptionFailedException, OperationFailedException);
|
||||
PPL7EXCEPTION (DecryptionFailedException, OperationFailedException);
|
||||
|
||||
class MCrypt
|
||||
{
|
||||
|
||||
private:
|
||||
void *mcrypt;
|
||||
ByteArray IV;
|
||||
ByteArray Key;
|
||||
|
||||
|
||||
public:
|
||||
enum Mode {
|
||||
Mode_STREAM,
|
||||
Mode_ECB,
|
||||
Mode_CBC,
|
||||
Mode_CFB,
|
||||
Mode_OFB,
|
||||
Mode_nOFB,
|
||||
Mode_nCFB,
|
||||
Mode_CTR
|
||||
};
|
||||
|
||||
|
||||
enum Algorithm {
|
||||
Algo_DES,
|
||||
Algo_TRIPLE_DES,
|
||||
Algo_CAST_128,
|
||||
Algo_CAST_256,
|
||||
Algo_xTEA,
|
||||
Algo_THREE_WAY,
|
||||
Algo_SKIPJACK,
|
||||
Algo_BLOWFISH,
|
||||
Algo_TWOFISH,
|
||||
Algo_LOKI97,
|
||||
Algo_RC2,
|
||||
Algo_ARCFOUR,
|
||||
Algo_RC6,
|
||||
Algo_RIJNDAEL_128,
|
||||
Algo_RIJNDAEL_192,
|
||||
Algo_RIJNDAEL_256,
|
||||
Algo_MARS,
|
||||
Algo_PANAMA,
|
||||
Algo_WAKE,
|
||||
Algo_SERPENT,
|
||||
Algo_IDEA,
|
||||
Algo_ENIGMA,
|
||||
Algo_GOST,
|
||||
Algo_SAFER_SK64,
|
||||
Algo_SAFER_SK128,
|
||||
Algo_SAFER_PLUS
|
||||
};
|
||||
|
||||
MCrypt();
|
||||
MCrypt(Algorithm algo, Mode mode);
|
||||
~MCrypt();
|
||||
void setAlgorithm(Algorithm algo=MCrypt::Algo_TWOFISH, Mode mode=MCrypt::Mode_CFB);
|
||||
int getIVSize() const;
|
||||
int getMaxKeySize() const;
|
||||
void setIV(const void *buffer, size_t size);
|
||||
void setIV(const Variant &object);
|
||||
void setKey(const void *buffer, size_t size);
|
||||
void setKey(const Variant &object);
|
||||
bool needIV() const;
|
||||
//int SupportKeySize(size_t size);
|
||||
|
||||
void crypt(void *buffer, size_t size);
|
||||
void crypt(const Variant &in, ByteArray &out);
|
||||
void crypt(ByteArrayPtr &buffer);
|
||||
|
||||
void decrypt(void *buffer, size_t size);
|
||||
void decrypt(const ByteArrayPtr &in, ByteArray &out);
|
||||
void decrypt(ByteArrayPtr &buffer);
|
||||
|
||||
static void crypt(ByteArrayPtr &buffer, const Variant &key, Algorithm algo, Mode mode);
|
||||
static void crypt(ByteArrayPtr &buffer, const Variant &key, const Variant &IV, Algorithm algo, Mode mode);
|
||||
static void decrypt(ByteArrayPtr &buffer, const Variant &key, Algorithm algo, Mode mode);
|
||||
static void decrypt(ByteArrayPtr &buffer, const Variant &key, const Variant &IV, Algorithm algo, Mode mode);
|
||||
|
||||
};
|
||||
|
||||
class Digest
|
||||
{
|
||||
private:
|
||||
const void *m;
|
||||
void *ctx;
|
||||
unsigned char *ret;
|
||||
ppluint64 bytecount;
|
||||
|
||||
public:
|
||||
enum Algorithm {
|
||||
Algo_MD4,
|
||||
Algo_MD5,
|
||||
Algo_SHA1,
|
||||
Algo_SHA224,
|
||||
Algo_SHA256,
|
||||
Algo_SHA384,
|
||||
Algo_SHA512,
|
||||
Algo_WHIRLPOOL,
|
||||
Algo_RIPEMD160
|
||||
};
|
||||
|
||||
|
||||
Digest();
|
||||
Digest(const String &name);
|
||||
Digest(Algorithm algorithm);
|
||||
~Digest();
|
||||
|
||||
void setAlgorithm(Algorithm algorithm);
|
||||
void setAlgorithm(const String &name);
|
||||
void addData(const void *data, size_t size);
|
||||
void addData(const ByteArrayPtr &data);
|
||||
void addData(const String &data);
|
||||
void addData(const WideString &data);
|
||||
void addData(FileObject &file);
|
||||
void addFile(const String &filename);
|
||||
ByteArray getDigest();
|
||||
void saveDigest(ByteArray &result);
|
||||
void saveDigest(String &result);
|
||||
void saveDigest(WideString &result);
|
||||
|
||||
void reset();
|
||||
ppluint64 bytesHashed() const;
|
||||
|
||||
static ByteArray hash(const ByteArrayPtr &data, Algorithm algorithm);
|
||||
static ByteArray hash(const ByteArrayPtr &data, const String &algorithmName);
|
||||
static ByteArray md4(const ByteArrayPtr &data);
|
||||
static ByteArray md5(const ByteArrayPtr &data);
|
||||
static ByteArray sha1(const ByteArrayPtr &data);
|
||||
static ByteArray sha224(const ByteArrayPtr &data);
|
||||
static ByteArray sha256(const ByteArrayPtr &data);
|
||||
static ByteArray sha384(const ByteArrayPtr &data);
|
||||
static ByteArray sha512(const ByteArrayPtr &data);
|
||||
static ppluint32 crc32(const ByteArrayPtr &data);
|
||||
static ppluint32 adler32(const ByteArrayPtr &data);
|
||||
|
||||
};
|
||||
|
||||
|
||||
} // EOF namespace ppl7
|
||||
|
||||
#endif /* PPL7CRYPTO_H_ */
|
338
src/pplib/include/ppl7-db.h
Normal file
338
src/pplib/include/ppl7-db.h
Normal file
|
@ -0,0 +1,338 @@
|
|||
/*******************************************************************************
|
||||
* This file is part of "Patrick's Programming Library", Version 7 (PPL7).
|
||||
* Web: http://www.pfp.de/ppl/
|
||||
*
|
||||
* $Author$
|
||||
* $Revision$
|
||||
* $Date$
|
||||
* $Id$
|
||||
*
|
||||
*******************************************************************************
|
||||
* Copyright (c) 2013, Patrick Fedick <patrick@pfp.de>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER AND CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef PPL7DB_H_
|
||||
#define PPL7DB_H_
|
||||
|
||||
#ifndef _PPL7_INCLUDE
|
||||
#ifdef PPL7LIB
|
||||
#include "ppl7.h"
|
||||
#else
|
||||
#include <ppl7.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <list>
|
||||
|
||||
|
||||
namespace ppl7 {
|
||||
namespace db {
|
||||
|
||||
class SinglePool;
|
||||
class MultiPool;
|
||||
class Database;
|
||||
|
||||
class ResultSet
|
||||
{
|
||||
public:
|
||||
enum FieldType {
|
||||
TYPE_UNKNOWN=0,
|
||||
TYPE_INTEGER,
|
||||
TYPE_LONGINTEGER,
|
||||
TYPE_FLOAT,
|
||||
TYPE_DOUBLE,
|
||||
TYPE_BOOLEAN,
|
||||
TYPE_STRING,
|
||||
TYPE_DATETIME,
|
||||
TYPE_BINARY
|
||||
};
|
||||
virtual ~ResultSet() {};
|
||||
virtual void clear()=0;
|
||||
virtual ppluint64 affected() const=0;
|
||||
virtual int fields() const=0;
|
||||
virtual String getString(const String &fieldname)=0;
|
||||
virtual String getString(int field)=0;
|
||||
virtual int fieldNum(const String &fieldname)=0;
|
||||
virtual String fieldName(int field)=0;
|
||||
virtual FieldType fieldType(int field)=0;
|
||||
virtual FieldType fieldType(const String &fieldname)=0;
|
||||
virtual AssocArray fetchArray()=0;
|
||||
virtual void fetchArray(AssocArray &array)=0;
|
||||
virtual Array fetchFields()=0;
|
||||
virtual void fetchFields(Array &array)=0;
|
||||
virtual void nextRow()=0;
|
||||
virtual bool eof()=0;
|
||||
};
|
||||
|
||||
Database *Connect(const AssocArray ¶ms);
|
||||
void copyResultToAssocArray(ResultSet *res, AssocArray &array);
|
||||
|
||||
class Database
|
||||
{
|
||||
friend class DBPool;
|
||||
friend class DBPoolOfPools;
|
||||
|
||||
private:
|
||||
AssocArray ConnectParam;
|
||||
Logger *Log;
|
||||
ppluint64 lastuse;
|
||||
ppluint64 lastping;
|
||||
|
||||
protected:
|
||||
void logQuery(const String &query, float duration);
|
||||
void updateLastPing();
|
||||
void updateLastUse();
|
||||
void clearLastUse();
|
||||
|
||||
public:
|
||||
Database();
|
||||
virtual ~Database();
|
||||
void setLogger(Logger &logger);
|
||||
void removeLogger();
|
||||
Logger *getLogger();
|
||||
void setParam(const String &name, const String &value);
|
||||
void setParam(const String &name, int value);
|
||||
void setParam(const AssocArray ¶ms);
|
||||
|
||||
void execf(const char *query, ...);
|
||||
ResultSet *queryf(const char *query, ...);
|
||||
|
||||
AssocArray execArrayf(const char *query, ...);
|
||||
AssocArray execArray(const String &query);
|
||||
AssocArray execArrayAllf(const char *query, ...);
|
||||
AssocArray execArrayAll(const String &query);
|
||||
void execArrayf(AssocArray &result, const char *query, ...);
|
||||
void execArray(AssocArray &result, const String &query);
|
||||
void execArrayAllf(AssocArray &result, const char *query, ...);
|
||||
void execArrayAll(AssocArray &result, const String &query);
|
||||
|
||||
ppluint64 count(const String &table, const String &where=String());
|
||||
/*
|
||||
void save(const String &method, const String &table, const AssocArray &a, const String &clause="", const AssocArray &exclude=AssocArray(), const AssocArray &types=AssocArray());
|
||||
String genQuery(const String &method, const String &table, const AssocArray &a, const String &clause="", const AssocArray &exclude=AssocArray(), const AssocArray &types=AssocArray());
|
||||
void readKeyValue(AssocArray &res, const String &query, const String &keyname, const String &valname=String());
|
||||
*/
|
||||
virtual void connect();
|
||||
virtual void connect(const AssocArray ¶ms);
|
||||
virtual void connectCreate(const AssocArray ¶ms);
|
||||
virtual void reconnect();
|
||||
virtual void close();
|
||||
virtual void selectDB(const String &databasename);
|
||||
virtual void exec(const String &query);
|
||||
virtual ResultSet *query(const String &query);
|
||||
virtual bool ping();
|
||||
virtual String escape(const String &str) const;
|
||||
virtual ppluint64 getAffectedRows();
|
||||
virtual void startTransaction();
|
||||
virtual void endTransaction();
|
||||
virtual void cancelTransaction();
|
||||
virtual void cancelTransactionComplete();
|
||||
virtual void createDatabase(const String &name);
|
||||
virtual String databaseType() const;
|
||||
virtual String getQuoted(const String &value, const String &type=String()) const;
|
||||
/*
|
||||
virtual void prepare(const String &preparedStatementName, const String &query);
|
||||
virtual ResultSet *execute(const String &preparedStatementName, const Array ¶ms);
|
||||
virtual void deallocate(const String &preparedStatementName);
|
||||
*/
|
||||
};
|
||||
|
||||
class PostgreSQL: public Database
|
||||
{
|
||||
private:
|
||||
void *conn;
|
||||
ppluint64 affectedrows;
|
||||
int transactiondepth;
|
||||
AssocArray condata;
|
||||
|
||||
void *pgsqlQuery(const String &query);
|
||||
|
||||
public:
|
||||
PostgreSQL();
|
||||
virtual ~PostgreSQL();
|
||||
|
||||
virtual void connect();
|
||||
virtual void connect(const AssocArray ¶ms);
|
||||
virtual void connectCreate(const AssocArray ¶ms);
|
||||
virtual void reconnect();
|
||||
virtual void close();
|
||||
virtual void selectDB(const String &databasename);
|
||||
virtual void exec(const String &query);
|
||||
virtual ResultSet *query(const String &query);
|
||||
virtual bool ping();
|
||||
virtual String escape(const String &str) const;
|
||||
virtual ppluint64 getAffectedRows();
|
||||
virtual void startTransaction();
|
||||
virtual void endTransaction();
|
||||
virtual void cancelTransaction();
|
||||
virtual void cancelTransactionComplete();
|
||||
virtual void createDatabase(const String &name);
|
||||
virtual String databaseType() const;
|
||||
virtual String getQuoted(const String &value, const String &type=String()) const;
|
||||
/*
|
||||
virtual void prepare(const String &preparedStatementName, const String &query);
|
||||
virtual ResultSet *execute(const String &preparedStatementName, const Array ¶ms);
|
||||
virtual void deallocate(const String &preparedStatementName);
|
||||
*/
|
||||
};
|
||||
|
||||
class MySQL: public Database
|
||||
{
|
||||
private:
|
||||
void *conn;
|
||||
ppluint64 affectedrows;
|
||||
int transactiondepth;
|
||||
AssocArray condata;
|
||||
|
||||
void mysqlQuery(const String &query);
|
||||
|
||||
public:
|
||||
MySQL();
|
||||
virtual ~MySQL();
|
||||
virtual void connect();
|
||||
virtual void connect(const AssocArray ¶ms);
|
||||
virtual void connectCreate(const AssocArray ¶ms);
|
||||
virtual void reconnect();
|
||||
virtual void close();
|
||||
virtual void selectDB(const String &databasename);
|
||||
virtual void exec(const String &query);
|
||||
virtual ResultSet *query(const String &query);
|
||||
virtual bool ping();
|
||||
virtual String escape(const String &str) const;
|
||||
virtual ppluint64 getAffectedRows();
|
||||
virtual void startTransaction();
|
||||
virtual void endTransaction();
|
||||
virtual void cancelTransaction();
|
||||
virtual void cancelTransactionComplete();
|
||||
virtual void createDatabase(const String &name);
|
||||
virtual String databaseType() const;
|
||||
virtual String getQuoted(const String &value, const String &type=String()) const;
|
||||
|
||||
static void libraryInit(int argc=0, char **argv=NULL, char **groups=NULL);
|
||||
};
|
||||
|
||||
class SQLite: public Database
|
||||
{
|
||||
private:
|
||||
void *conn;
|
||||
ppluint64 affectedrows;
|
||||
int transactiondepth;
|
||||
AssocArray condata;
|
||||
|
||||
void *sqliteQuery(const String &query);
|
||||
|
||||
public:
|
||||
SQLite();
|
||||
virtual ~SQLite();
|
||||
|
||||
virtual void connect();
|
||||
virtual void connect(const AssocArray ¶ms);
|
||||
virtual void connectCreate(const AssocArray ¶ms);
|
||||
virtual void reconnect();
|
||||
virtual void close();
|
||||
virtual void selectDB(const String &databasename);
|
||||
virtual void exec(const String &query);
|
||||
virtual ResultSet *query(const String &query);
|
||||
virtual bool ping();
|
||||
virtual String escape(const String &str) const;
|
||||
virtual ppluint64 getAffectedRows();
|
||||
virtual void startTransaction();
|
||||
virtual void endTransaction();
|
||||
virtual void cancelTransaction();
|
||||
virtual void cancelTransactionComplete();
|
||||
virtual void createDatabase(const String &name);
|
||||
virtual String databaseType() const;
|
||||
virtual String getQuoted(const String &value, const String &type=String()) const;
|
||||
};
|
||||
|
||||
|
||||
class DBPool
|
||||
{
|
||||
friend class DBPoolOfPools;
|
||||
private:
|
||||
Mutex PoolMutex;
|
||||
std::list<Database *> Used, Free;
|
||||
AssocArray ConnectParam;
|
||||
String Name;
|
||||
Logger *Log;
|
||||
int ConnectParamVersion;
|
||||
int Id;
|
||||
int Min, Max;
|
||||
int MinSpare, MaxSpare;
|
||||
int Grow;
|
||||
int IdleTimeout;
|
||||
int UsedTimeout;
|
||||
int KeepAlive;
|
||||
bool IsInit;
|
||||
double LastCheck;
|
||||
Database *newDB();
|
||||
|
||||
void checkUsedPool();
|
||||
void createMinimum();
|
||||
void createSpare();
|
||||
void releaseSpare();
|
||||
|
||||
public:
|
||||
DBPool();
|
||||
~DBPool();
|
||||
|
||||
void setConnectParams(const AssocArray &connect);
|
||||
void setOptions(const AssocArray &options);
|
||||
void setOption(const String &Name, const String &Value);
|
||||
void setName(const String &Name);
|
||||
void setId(int id);
|
||||
void setMinimumSize(int num);
|
||||
void setMaximumSize(int num);
|
||||
void setMinSpare(int num);
|
||||
void setMaxSpare(int num);
|
||||
void setGrowth(int num);
|
||||
void setIdleTimeout(int seconds);
|
||||
void setUsedTimeout(int seconds);
|
||||
void setKeepAliveIntervall(int seconds);
|
||||
Database *get(bool wait=false, int ms=0);
|
||||
void release(Database *db);
|
||||
void destroy(Database *db);
|
||||
void checkPool();
|
||||
void clearUsedPool();
|
||||
void clearFreePool();
|
||||
void getStatus(AssocArray &status);
|
||||
void setLogger(Logger &logger);
|
||||
};
|
||||
|
||||
class DBPoolOfPools
|
||||
{
|
||||
private:
|
||||
public:
|
||||
DBPoolOfPools();
|
||||
~DBPoolOfPools();
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // EOF namespace db
|
||||
} // EOF namespace ppl7
|
||||
|
||||
#endif /* PPL7INET_H_ */
|
255
src/pplib/include/ppl7-exceptions.h
Normal file
255
src/pplib/include/ppl7-exceptions.h
Normal file
|
@ -0,0 +1,255 @@
|
|||
/*******************************************************************************
|
||||
* This file is part of "Patrick's Programming Library", Version 7 (PPL7).
|
||||
* Web: http://www.pfp.de/ppl/
|
||||
*
|
||||
* $Author$
|
||||
* $Revision$
|
||||
* $Date$
|
||||
* $Id$
|
||||
*
|
||||
*******************************************************************************
|
||||
* Copyright (c) 2013, Patrick Fedick <patrick@pfp.de>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER AND CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef PPL7EXCEPTIONS_H_
|
||||
#define PPL7EXCEPTIONS_H_
|
||||
#include <exception>
|
||||
#include <ostream>
|
||||
|
||||
namespace ppl7 {
|
||||
|
||||
|
||||
|
||||
class String;
|
||||
|
||||
void throwExceptionFromErrno(int e,const String &info);
|
||||
void throwSocketException(int e,const String &info);
|
||||
void throwExceptionFromEaiError(int ecode, const String &info);
|
||||
|
||||
class Exception : std::exception
|
||||
{
|
||||
private:
|
||||
char *ErrorText;
|
||||
public:
|
||||
Exception() throw();
|
||||
Exception(const Exception &other) throw();
|
||||
Exception& operator= (const Exception &other) throw();
|
||||
Exception(const char *msg, ...) throw();
|
||||
virtual ~Exception() throw();
|
||||
virtual const char* what() const throw();
|
||||
const char* text() const throw();
|
||||
String toString() const throw();
|
||||
void print() const;
|
||||
void copyText(const char *str) throw();
|
||||
void copyText(const char *fmt, va_list args) throw();
|
||||
};
|
||||
|
||||
std::ostream& operator<<(std::ostream& s, const Exception &e);
|
||||
|
||||
|
||||
#define STR_VALUE(arg) #arg
|
||||
#define PPL7EXCEPTION(name,inherit) class name : public ppl7::inherit { public: \
|
||||
name() throw() {}; \
|
||||
name(const char *msg, ...) throw() { \
|
||||
va_list args; va_start(args, msg); copyText(msg,args); \
|
||||
va_end(args); } \
|
||||
virtual const char* what() const throw() { return (STR_VALUE(name)); } \
|
||||
};
|
||||
|
||||
PPL7EXCEPTION(UnknownException, Exception);
|
||||
PPL7EXCEPTION(OutOfMemoryException, Exception);
|
||||
PPL7EXCEPTION(NullPointerException, Exception);
|
||||
PPL7EXCEPTION(UnsupportedFeatureException, Exception);
|
||||
PPL7EXCEPTION(CharacterEncodingException, Exception);
|
||||
PPL7EXCEPTION(UnsupportedCharacterEncodingException, Exception);
|
||||
PPL7EXCEPTION(OutOfBoundsEception, Exception);
|
||||
PPL7EXCEPTION(EmptyDataException, Exception);
|
||||
PPL7EXCEPTION(TypeConversionException, Exception);
|
||||
PPL7EXCEPTION(IllegalArgumentException, Exception);
|
||||
PPL7EXCEPTION(MissingArgumentException, Exception);
|
||||
PPL7EXCEPTION(IllegalRegularExpressionException, Exception);
|
||||
PPL7EXCEPTION(OperationFailedException, Exception);
|
||||
PPL7EXCEPTION(OperationAbortedException, Exception);
|
||||
PPL7EXCEPTION(DuplicateInstanceException, Exception);
|
||||
PPL7EXCEPTION(ConnectionFailedException, Exception);
|
||||
PPL7EXCEPTION(SocketException, Exception);
|
||||
PPL7EXCEPTION(LoginRefusedException, Exception);
|
||||
PPL7EXCEPTION(AlreadyConnectedException, Exception);
|
||||
PPL7EXCEPTION(NoConnectionException, Exception);
|
||||
PPL7EXCEPTION(TooManyInstancesException, Exception);
|
||||
PPL7EXCEPTION(InvalidDateException, Exception);
|
||||
PPL7EXCEPTION(DateOutOfRangeException, Exception);
|
||||
PPL7EXCEPTION(NoThreadSupportException, Exception);
|
||||
PPL7EXCEPTION(ThreadStartException, Exception);
|
||||
PPL7EXCEPTION(ThreadAlreadyRunningException, Exception);
|
||||
PPL7EXCEPTION(ThreadOperationFailedException, Exception);
|
||||
PPL7EXCEPTION(ThreadAlreadyInPoolException, Exception);
|
||||
PPL7EXCEPTION(ThreadNotInPoolException, Exception);
|
||||
PPL7EXCEPTION(ItemNotFoundException, Exception);
|
||||
PPL7EXCEPTION(DuplicateItemException, Exception);
|
||||
PPL7EXCEPTION(UnsupportedDataTypeException, Exception);
|
||||
PPL7EXCEPTION(ItemNotFromThisListException, Exception);
|
||||
PPL7EXCEPTION(EndOfListException, Exception);
|
||||
PPL7EXCEPTION(IllegalMemoryAddressException, Exception);
|
||||
PPL7EXCEPTION(UnimplementedVirtualFunctionException, Exception);
|
||||
PPL7EXCEPTION(UnknownCompressionMethodException, Exception);
|
||||
PPL7EXCEPTION(IllegalChunkException, Exception);
|
||||
PPL7EXCEPTION(ChunkNotFoundException, Exception);
|
||||
PPL7EXCEPTION(EmptyFileException, Exception);
|
||||
PPL7EXCEPTION(CompressionFailedException, Exception);
|
||||
PPL7EXCEPTION(DecompressionFailedException, Exception);
|
||||
PPL7EXCEPTION(InvalidFormatException, Exception);
|
||||
PPL7EXCEPTION(AccessDeniedByInstanceException, Exception);
|
||||
PPL7EXCEPTION(BufferTooSmallException, Exception);
|
||||
PPL7EXCEPTION(CorruptedDataException, Exception);
|
||||
PPL7EXCEPTION(FailedToLoadResourceException, Exception);
|
||||
PPL7EXCEPTION(InvalidResourceException, Exception);
|
||||
PPL7EXCEPTION(ResourceNotFoundException, Exception);
|
||||
PPL7EXCEPTION(OperationUnavailableException, Exception);
|
||||
PPL7EXCEPTION(UnavailableException, Exception);
|
||||
PPL7EXCEPTION(InitializationFailedException, Exception);
|
||||
PPL7EXCEPTION(KeyNotFoundException, Exception);
|
||||
PPL7EXCEPTION(InvalidTimezoneException, Exception);
|
||||
PPL7EXCEPTION(CharacterEncodingNotInitializedException, Exception);
|
||||
PPL7EXCEPTION(MutexException, Exception);
|
||||
PPL7EXCEPTION(MutexLockingException, MutexException);
|
||||
PPL7EXCEPTION(MutexNotLockedException, MutexLockingException);
|
||||
PPL7EXCEPTION(UnexpectedEndOfDataException, Exception);
|
||||
PPL7EXCEPTION(InvalidEscapeSequenceException, Exception);
|
||||
PPL7EXCEPTION(UnexpectedCharacterException, Exception);
|
||||
PPL7EXCEPTION(SyntaxException, Exception);
|
||||
|
||||
PPL7EXCEPTION(NoSectionSelectedException, Exception);
|
||||
PPL7EXCEPTION(UnknownSectionException, Exception);
|
||||
|
||||
PPL7EXCEPTION(SSLException, Exception);
|
||||
PPL7EXCEPTION(SSLContextInUseException, Exception);
|
||||
PPL7EXCEPTION(SSLContextUninitializedException, Exception);
|
||||
PPL7EXCEPTION(SSLContextReferenceCounterMismatchException, Exception);
|
||||
PPL7EXCEPTION(InvalidSSLCertificateException, Exception);
|
||||
PPL7EXCEPTION(InvalidSSLCipherException, Exception);
|
||||
PPL7EXCEPTION(SSLPrivatKeyException, Exception);
|
||||
PPL7EXCEPTION(SSLFailedToReadDHParams, Exception);
|
||||
|
||||
|
||||
//! @name IO-Exceptions
|
||||
//@{
|
||||
PPL7EXCEPTION(IOException,Exception);
|
||||
|
||||
PPL7EXCEPTION(FileNotOpenException, IOException);
|
||||
PPL7EXCEPTION(FileSeekException, IOException);
|
||||
PPL7EXCEPTION(ReadException, IOException);
|
||||
PPL7EXCEPTION(WriteException, IOException);
|
||||
PPL7EXCEPTION(EndOfFileException, IOException);
|
||||
PPL7EXCEPTION(FileOpenException, IOException);
|
||||
PPL7EXCEPTION(FileNotFoundException, IOException); // ENOENT
|
||||
PPL7EXCEPTION(InvalidArgumentsException, IOException); // EINVAL
|
||||
PPL7EXCEPTION(InvalidFileNameException, IOException); // ENOTDIR, ENAMETOOLONG, ELOOP
|
||||
PPL7EXCEPTION(PermissionDeniedException, IOException); // EACCESS, EPERM
|
||||
PPL7EXCEPTION(ReadOnlyException, IOException); // EROFS
|
||||
PPL7EXCEPTION(NoRegularFileException, IOException); // EISDIR
|
||||
PPL7EXCEPTION(TooManyOpenFilesException, IOException); // EMFILE
|
||||
PPL7EXCEPTION(UnsupportedFileOperationException, IOException); // EOPNOTSUPP
|
||||
PPL7EXCEPTION(TooManySymbolicLinksException, IOException); // ELOOP
|
||||
PPL7EXCEPTION(FilesystemFullException, IOException); // ENOSPC
|
||||
PPL7EXCEPTION(QuotaExceededException, IOException); // EDQUOT
|
||||
PPL7EXCEPTION(IOErrorException, IOException); // EIO
|
||||
PPL7EXCEPTION(BadFiledescriptorException, IOException); // EABDF
|
||||
PPL7EXCEPTION(BadAddressException, IOException); // EFAULT
|
||||
PPL7EXCEPTION(OverflowException, IOException); // EOVERFLOW
|
||||
PPL7EXCEPTION(FileExistsException, IOException); // EEXIST
|
||||
PPL7EXCEPTION(OperationBlockedException, IOException); // EAGAIN
|
||||
PPL7EXCEPTION(OperationInProgressException, IOException); // EINPROGRESS
|
||||
PPL7EXCEPTION(DeadlockException, IOException); // EDEADLK
|
||||
PPL7EXCEPTION(OperationInterruptedException, IOException); // EINTR
|
||||
PPL7EXCEPTION(TooManyLocksException, IOException); // ENOLCK
|
||||
PPL7EXCEPTION(IllegalOperationOnPipeException, IOException); // ESPIPE
|
||||
PPL7EXCEPTION(NotInitializedException, IOException); // WSANOTINITIALISED
|
||||
PPL7EXCEPTION(SocketOperationOnNonSocketException, IOException); // ENOTSOCK
|
||||
PPL7EXCEPTION(OperationAlreadyInProgressException, IOException); // EALREADY
|
||||
PPL7EXCEPTION(DestinationAddressRequiredException, IOException); // EDESTADDRREQ
|
||||
PPL7EXCEPTION(MessageTooLongException, IOException); // EMSGSIZE
|
||||
PPL7EXCEPTION(ProtocolWrongTypeForSocketException, IOException); // EPROTOTYPE
|
||||
PPL7EXCEPTION(ProtocolNotAvailableException, IOException); // ENOPROTOOPT
|
||||
PPL7EXCEPTION(ProtocolFamilyNotSupportedException, IOException); // EPFNOSUPPORT
|
||||
PPL7EXCEPTION(ProtocolNotSupportedException, IOException); // EPROTONOSUPPORT
|
||||
PPL7EXCEPTION(SocketTypeNotSupportedException, IOException); // ESOCKTNOSUPPORT
|
||||
PPL7EXCEPTION(AddressFamilyNotSupportedException, IOException); // EAFNOSUPPORT
|
||||
PPL7EXCEPTION(AddressAlreadyInUseException, IOException); // EADDRINUSE
|
||||
PPL7EXCEPTION(AddressNotAvailableException, IOException); // EADDRNOTAVAIL
|
||||
PPL7EXCEPTION(NetworkIsDownException, IOException); // ENETDOWN
|
||||
PPL7EXCEPTION(ConnectionAbortedByNetworkException, IOException); // ENETRESET
|
||||
PPL7EXCEPTION(ConnectionAbortedException, IOException); // ECONNABORTED
|
||||
PPL7EXCEPTION(ConnectionResetException, IOException); // ECONNRESET
|
||||
PPL7EXCEPTION(NoBufferSpaceAvailableException, IOException); // ENOBUFS
|
||||
PPL7EXCEPTION(SocketIsConnectedException, IOException); // EISCONN
|
||||
PPL7EXCEPTION(SocketNotConnectedException, IOException); // ENOTCONN
|
||||
PPL7EXCEPTION(TransportEndpointHasShutdownException, IOException); // ESHUTDOWN
|
||||
PPL7EXCEPTION(HostIsUnreachableException, IOException); // EHOSTUNREACH
|
||||
PPL7EXCEPTION(DirectoryNotEmptyException, IOException); // ENOTEMPTY
|
||||
PPL7EXCEPTION(ProcessLimitException, IOException); // EPROCLIM
|
||||
PPL7EXCEPTION(TooManyUsersException, IOException); // EUSERS
|
||||
PPL7EXCEPTION(StaleFileHandleException, IOException); // ESTALE
|
||||
PPL7EXCEPTION(ObjectIsRemoteException, IOException); // EREMOTE
|
||||
PPL7EXCEPTION(NetworkSubsystemUnavailableException, IOException); // WSASYSNOTREADY
|
||||
PPL7EXCEPTION(UnsupportedWinsockVersionException, IOException); // WSAVERNOTSUPPORTED
|
||||
PPL7EXCEPTION(GracefulShutdownInProgressException, IOException); // WSAEDISCON
|
||||
PPL7EXCEPTION(NoMoreResultsException, IOException); // WSAENOMORE, WSA_E_NO_MORE
|
||||
PPL7EXCEPTION(CallHasBeenCanceledException, IOException); // WSAECANCELLED
|
||||
PPL7EXCEPTION(ProcedureCallTableIsInvalidException, IOException); // WSAEINVALIDPROCTABLE
|
||||
PPL7EXCEPTION(ServiceProviderIsInvalidException, IOException); // WSAEINVALIDPROVIDER
|
||||
PPL7EXCEPTION(ServiceProviderFailedToInitializeException, IOException); // WSAEPROVIDERFAILEDINIT
|
||||
PPL7EXCEPTION(SystemCallFailureException, IOException); // WSASYSCALLFAILURE
|
||||
PPL7EXCEPTION(ServiceNotFoundException, IOException); // WSASERVICE_NOT_FOUND
|
||||
PPL7EXCEPTION(ClassTypeNotFoundException, IOException); // WSATYPE_NOT_FOUND
|
||||
PPL7EXCEPTION(CallWasCanceledException, IOException); // WSA_E_CANCELLED
|
||||
PPL7EXCEPTION(QueryRefusedException, IOException); // WSAEREFUSED
|
||||
PPL7EXCEPTION(NonauthoritativeHostNotFound, IOException); // WSATRY_AGAIN
|
||||
PPL7EXCEPTION(UnrecoverableErrorException, IOException); // WSANO_RECOVERY
|
||||
PPL7EXCEPTION(ObjectNotInSignaledStateException, IOException); // WSA_IO_INCOMPLETE
|
||||
PPL7EXCEPTION(OverlappedOperationPendingException, IOException); // WSA_IO_PENDING
|
||||
PPL7EXCEPTION(QoSException, IOException); // Windows WSA_QOS_*
|
||||
|
||||
|
||||
|
||||
|
||||
PPL7EXCEPTION(BufferExceedsLimitException, IOException);
|
||||
|
||||
//@}
|
||||
|
||||
|
||||
PPL7EXCEPTION(HostNotFoundException, Exception); // WSAHOST_NOT_FOUND
|
||||
PPL7EXCEPTION(TryAgainException, Exception);
|
||||
PPL7EXCEPTION(NoResultException, Exception);
|
||||
PPL7EXCEPTION(TimeoutException, Exception);
|
||||
|
||||
PPL7EXCEPTION(QueryFailedException, Exception);
|
||||
PPL7EXCEPTION(EscapeFailedException, Exception);
|
||||
PPL7EXCEPTION(FieldNotInResultSetException, Exception);
|
||||
|
||||
|
||||
|
||||
} // EOF namespace ppl7
|
||||
|
||||
#endif /* PPL7EXCEPTIONS_H_ */
|
1153
src/pplib/include/ppl7-grafix.h
Normal file
1153
src/pplib/include/ppl7-grafix.h
Normal file
File diff suppressed because it is too large
Load diff
770
src/pplib/include/ppl7-inet.h
Normal file
770
src/pplib/include/ppl7-inet.h
Normal file
|
@ -0,0 +1,770 @@
|
|||
/*******************************************************************************
|
||||
* This file is part of "Patrick's Programming Library", Version 7 (PPL7).
|
||||
* Web: http://www.pfp.de/ppl/
|
||||
*
|
||||
* $Author$
|
||||
* $Revision$
|
||||
* $Date$
|
||||
* $Id$
|
||||
*
|
||||
*******************************************************************************
|
||||
* Copyright (c) 2013, Patrick Fedick <patrick@pfp.de>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER AND CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef PPL7INET_H_
|
||||
#define PPL7INET_H_
|
||||
|
||||
#ifndef _PPL7_INCLUDE
|
||||
#ifdef PPL7LIB
|
||||
#include "ppl7.h"
|
||||
#else
|
||||
#include <ppl7.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <list>
|
||||
|
||||
namespace ppl7 {
|
||||
|
||||
PPL7EXCEPTION(NetworkException,Exception);
|
||||
PPL7EXCEPTION(WinsockInitialisationFailed, Exception);
|
||||
PPL7EXCEPTION(IdnConversionException, Exception);
|
||||
|
||||
PPL7EXCEPTION(NotConnectedException,NetworkException);
|
||||
PPL7EXCEPTION(CouldNotOpenSocketException,NetworkException); // 393
|
||||
PPL7EXCEPTION(IllegalPortException,NetworkException); // 393
|
||||
PPL7EXCEPTION(CouldNotBindToInterfaceException,NetworkException); // 394
|
||||
PPL7EXCEPTION(ConnectionRefusedException,NetworkException); // ECONNREFUSED
|
||||
PPL7EXCEPTION(NetworkDownException,NetworkException);
|
||||
PPL7EXCEPTION(NetworkUnreachableException, NetworkException); // ENETUNREACH
|
||||
PPL7EXCEPTION(NetworkDroppedConnectionOnResetException,NetworkException);
|
||||
PPL7EXCEPTION(SoftwareCausedConnectionAbortException,NetworkException);
|
||||
PPL7EXCEPTION(ConnectionResetByPeerException,NetworkException);
|
||||
PPL7EXCEPTION(NoBufferSpaceException,NetworkException);
|
||||
PPL7EXCEPTION(SocketIsAlreadyConnectedException,NetworkException);
|
||||
PPL7EXCEPTION(CantSendAfterSocketShutdownException,NetworkException);
|
||||
PPL7EXCEPTION(TooManyReferencesException, NetworkException); // ETOOMANYREFS
|
||||
PPL7EXCEPTION(HostDownException,NetworkException); // EHOSTDOWN
|
||||
PPL7EXCEPTION(NoRouteToHostException,NetworkException);
|
||||
PPL7EXCEPTION(InvalidSocketException,NetworkException);
|
||||
PPL7EXCEPTION(UnknownOptionException,NetworkException);
|
||||
PPL7EXCEPTION(OutOfBandDataReceivedException,NetworkException);
|
||||
PPL7EXCEPTION(BrokenPipeException,NetworkException);
|
||||
PPL7EXCEPTION(SSLNotStartedException,NetworkException);
|
||||
PPL7EXCEPTION(SSLConnectionFailedException,NetworkException);
|
||||
PPL7EXCEPTION(SettingSocketOptionException,NetworkException);
|
||||
PPL7EXCEPTION(InvalidIpAddressException,NetworkException);
|
||||
PPL7EXCEPTION(InvalidNetworkAddressException,NetworkException);
|
||||
PPL7EXCEPTION(InvalidNetmaskOrPrefixlenException,NetworkException);
|
||||
PPL7EXCEPTION(ConnectionTimeoutException, NetworkException); // ETIMEDOUT
|
||||
|
||||
PPL7EXCEPTION(ResolverException,Exception);
|
||||
PPL7EXCEPTION(UnknownHostException,Exception);
|
||||
|
||||
|
||||
|
||||
|
||||
enum ResolverFlags {
|
||||
af_unspec=0,
|
||||
af_inet=1,
|
||||
af_inet6=2,
|
||||
af_all=3
|
||||
};
|
||||
|
||||
|
||||
class IPAddress
|
||||
{
|
||||
public:
|
||||
enum IP_FAMILY {
|
||||
UNKNOWN=0,
|
||||
IPv4=4,
|
||||
IPv6=6
|
||||
};
|
||||
private:
|
||||
unsigned char _addr[16];
|
||||
IP_FAMILY _family;
|
||||
public:
|
||||
IPAddress();
|
||||
IPAddress(const IPAddress &other);
|
||||
IPAddress(const String &other);
|
||||
IPAddress(IP_FAMILY family, void *addr, size_t addr_len);
|
||||
IPAddress &operator=(const IPAddress &other);
|
||||
IPAddress &operator=(const String &other);
|
||||
void set(const IPAddress &other);
|
||||
void set(const String &address);
|
||||
void set(IP_FAMILY family, void *addr, size_t addr_len);
|
||||
//void setFromSockAddr(const void *sockaddr, size_t sockaddr_len);
|
||||
IPAddress::IP_FAMILY family() const;
|
||||
const void *addr() const;
|
||||
size_t addr_len() const;
|
||||
String toString() const;
|
||||
operator String() const;
|
||||
|
||||
IPAddress mask(int prefixlen) const;
|
||||
|
||||
void toSockAddr(void *sockaddr, size_t sockaddr_len) const;
|
||||
int compare(const IPAddress &other) const;
|
||||
bool operator<(const IPAddress &other) const;
|
||||
bool operator<=(const IPAddress &other) const;
|
||||
bool operator==(const IPAddress &other) const;
|
||||
bool operator!=(const IPAddress &other) const;
|
||||
bool operator>=(const IPAddress &other) const;
|
||||
bool operator>(const IPAddress &other) const;
|
||||
};
|
||||
|
||||
std::ostream& operator<<(std::ostream& s, const IPAddress &addr);
|
||||
|
||||
class IPNetwork
|
||||
{
|
||||
public:
|
||||
private:
|
||||
IPAddress _addr;
|
||||
int _prefixlen;
|
||||
public:
|
||||
IPNetwork();
|
||||
IPNetwork(const IPNetwork &other);
|
||||
IPNetwork(const String &other);
|
||||
IPNetwork &operator=(const IPNetwork &other);
|
||||
IPNetwork &operator=(const String &other);
|
||||
void set(const IPAddress &other, int prefixlen);
|
||||
void set(const IPNetwork &other);
|
||||
void set(const String &network);
|
||||
IPAddress::IP_FAMILY family() const;
|
||||
IPAddress addr() const;
|
||||
IPAddress first() const;
|
||||
IPAddress last() const;
|
||||
IPAddress netmask() const;
|
||||
int prefixlen() const;
|
||||
String toString() const;
|
||||
operator String() const;
|
||||
bool contains(const IPAddress &addr) const;
|
||||
|
||||
|
||||
int compare(const IPNetwork &other) const;
|
||||
bool operator<(const IPNetwork &other) const;
|
||||
bool operator<=(const IPNetwork &other) const;
|
||||
bool operator==(const IPNetwork &other) const;
|
||||
bool operator!=(const IPNetwork &other) const;
|
||||
bool operator>=(const IPNetwork &other) const;
|
||||
bool operator>(const IPNetwork &other) const;
|
||||
|
||||
static int getPrefixlenFromNetmask(const String &netmask);
|
||||
|
||||
};
|
||||
|
||||
std::ostream& operator<<(std::ostream& s, const IPNetwork &net);
|
||||
|
||||
class SockAddr
|
||||
{
|
||||
private:
|
||||
void *saddr;
|
||||
size_t addrlen;
|
||||
public:
|
||||
SockAddr();
|
||||
SockAddr(const SockAddr &other);
|
||||
SockAddr(const void *addr, size_t addrlen);
|
||||
SockAddr(const IPAddress &addr, int port);
|
||||
~SockAddr();
|
||||
SockAddr &operator=(const SockAddr &other);
|
||||
void setAddr(const void *addr, size_t addrlen);
|
||||
void setAddr(const IPAddress &ip, int port);
|
||||
void setAddr(const IPAddress &ip);
|
||||
void setPort(int port);
|
||||
void *addr() const;
|
||||
size_t size() const;
|
||||
int port() const;
|
||||
IPAddress toIPAddress() const;
|
||||
};
|
||||
|
||||
|
||||
void InitSockets();
|
||||
String GetHostname();
|
||||
size_t GetHostByName(const String &name, std::list<IPAddress> &result,ResolverFlags flags=af_unspec);
|
||||
size_t GetHostByAddr(const IPAddress &addr, String &hostname);
|
||||
ppluint32 Ntohl(ppluint32 net);
|
||||
ppluint32 Htonl(ppluint32 host);
|
||||
ppluint16 Ntohs(ppluint16 net);
|
||||
ppluint16 Htons(ppluint16 host);
|
||||
bool IsBigEndian();
|
||||
bool IsLittleEndian();
|
||||
|
||||
|
||||
class Resolver
|
||||
{
|
||||
private:
|
||||
|
||||
public:
|
||||
// Quelle: http://en.wikipedia.org/wiki/List_of_DNS_record_types
|
||||
enum Type {
|
||||
A=1,
|
||||
NS=2,
|
||||
CNAME=5,
|
||||
MX=15,
|
||||
SOA=6,
|
||||
PTR=12,
|
||||
TXT=16,
|
||||
AAAA=28,
|
||||
NAPTR=35,
|
||||
SRV=33,
|
||||
DS=43,
|
||||
DNSKEY=48,
|
||||
NSEC=47,
|
||||
NSEC3=50,
|
||||
RRSIG=46,
|
||||
OPT=41,
|
||||
TSIG=250
|
||||
};
|
||||
|
||||
enum Class {
|
||||
/** the Internet */
|
||||
CLASS_IN = 1,
|
||||
/** Chaos class */
|
||||
CLASS_CH = 3,
|
||||
/** Hesiod (Dyer 87) */
|
||||
CLASS_HS = 4,
|
||||
/** None class, dynamic update */
|
||||
CLASS_NONE = 254,
|
||||
/** Any class */
|
||||
CLASS_ANY = 255,
|
||||
CLASS_FIRST = 0,
|
||||
CLASS_LAST = 65535,
|
||||
CLASS_COUNT = CLASS_LAST - CLASS_FIRST + 1
|
||||
};
|
||||
|
||||
static String typeName(Type t);
|
||||
static String className(Class c);
|
||||
static void query(Array &r, const String &label, Type t=A, Class c=CLASS_IN);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
String Idn2Ace(const String &idn);
|
||||
WideString Idn2Ace(const WideString &idn);
|
||||
String Ace2Idn(const String &ace);
|
||||
WideString Ace2Idn(const WideString &ace);
|
||||
|
||||
String ToQuotedPrintable (const String &source);
|
||||
|
||||
|
||||
class TCPSocket;
|
||||
|
||||
void SSL_Init();
|
||||
void SSL_Exit();
|
||||
|
||||
//! \brief SSL-Verschlüsselung
|
||||
class SSLContext
|
||||
{
|
||||
friend class CTCPSocket;
|
||||
private:
|
||||
Mutex mutex;
|
||||
void *ctx;
|
||||
int references;
|
||||
void clear();
|
||||
public:
|
||||
enum SSL_METHOD {
|
||||
TLS, // Verwendet SSLv23, SSL wird aber disabled, so dass nur TLS unterstuetzt wird
|
||||
TLSclient,
|
||||
TLSserver,
|
||||
};
|
||||
|
||||
SSLContext();
|
||||
SSLContext(SSL_METHOD method);
|
||||
~SSLContext();
|
||||
void init(SSL_METHOD method=TLS);
|
||||
bool isInit();
|
||||
void shutdown();
|
||||
void *newSSL();
|
||||
void releaseSSL(void *ssl);
|
||||
void loadTrustedCAfromFile(const String &filename);
|
||||
void loadTrustedCAfromPath(const String &path);
|
||||
void loadCertificate(const String &certificate, const String &privatekey=String(), const String &password=String());
|
||||
void setCipherList(const String &cipherlist); // "ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH"
|
||||
void setTmpDHParam(const String &dh_param_file);
|
||||
};
|
||||
|
||||
class SSLError
|
||||
{
|
||||
public:
|
||||
SSLError() {
|
||||
Code=0;
|
||||
Line=Flags=0;
|
||||
}
|
||||
String Text;
|
||||
String Filename;
|
||||
String Data;
|
||||
unsigned long Code;
|
||||
int Line;
|
||||
int Flags;
|
||||
};
|
||||
|
||||
int GetSSLError(SSLError &e);
|
||||
int GetSSLErrors(std::list<SSLError> &e);
|
||||
int GetSSLErrors(String &e);
|
||||
void ClearSSLErrorStack();
|
||||
|
||||
|
||||
//! \brief TCP-Socket-Nachrichten
|
||||
class SocketMessage
|
||||
{
|
||||
friend class TCPSocket;
|
||||
private:
|
||||
void *payload;
|
||||
size_t payload_size;
|
||||
int payload_type;
|
||||
int commandId;
|
||||
int Id;
|
||||
int Version;
|
||||
bool UseCompression;
|
||||
bool SupportMsgChannel;
|
||||
|
||||
void compilePacketHeader(char *buffer, size_t *buffer_size, const void *payload, size_t payload_size, bool is_compressed) const;
|
||||
void readFromPacketHeader(const char *msgbuffer, int &flags);
|
||||
|
||||
public:
|
||||
PPL7EXCEPTION(NoDataAvailableException, Exception);
|
||||
PPL7EXCEPTION(DataInOtherFormatException, Exception);
|
||||
PPL7EXCEPTION(InvalidProtocolVersion, Exception);
|
||||
PPL7EXCEPTION(InvalidPacketException, Exception);
|
||||
PPL7EXCEPTION(PayloadTooBigException, Exception);
|
||||
|
||||
|
||||
bool ClientSupportsCompression;
|
||||
|
||||
SocketMessage();
|
||||
SocketMessage(const SocketMessage &other);
|
||||
|
||||
virtual ~SocketMessage();
|
||||
void copy(const SocketMessage &other);
|
||||
|
||||
void clear();
|
||||
|
||||
|
||||
void setCommandId(int id);
|
||||
int getCommandId() const;
|
||||
void setId(int id);
|
||||
int getId() const;
|
||||
void setPayload(const String &msg);
|
||||
void setPayload(const AssocArray &msg);
|
||||
void setPayload(const ByteArrayPtr &msg);
|
||||
void getPayload(String &msg) const;
|
||||
void getPayload(AssocArray &msg) const;
|
||||
void getPayload(ByteArray &msg) const;
|
||||
int getPayloadType();
|
||||
void enableCompression(bool flag=true);
|
||||
void enableMsgChannel(bool flag=true);
|
||||
bool isCompressionSupported() const;
|
||||
bool isMsgChannelSupported() const;
|
||||
};
|
||||
|
||||
|
||||
//! \brief TCP-Socket-Klasse
|
||||
class TCPSocket
|
||||
{
|
||||
private:
|
||||
Mutex mutex;
|
||||
SSLContext *sslcontext;
|
||||
void *socket;
|
||||
void *ssl;
|
||||
bool connected;
|
||||
bool islisten;
|
||||
bool blocking;
|
||||
//int BytesWritten;
|
||||
//int BytesRead;
|
||||
int connect_timeout_sec;
|
||||
int connect_timeout_usec;
|
||||
bool stoplisten;
|
||||
String HostName;
|
||||
int PortNum;
|
||||
String SourceInterface;
|
||||
int SourcePort;
|
||||
|
||||
int SSL_Write(const void *buffer, int size);
|
||||
int SSL_Read(void *buffer, int bytes);
|
||||
|
||||
public:
|
||||
TCPSocket();
|
||||
virtual ~TCPSocket();
|
||||
//! @name TCP-Client functions
|
||||
//@{
|
||||
void setSource(const String &interface_name, int port=0);
|
||||
void connect(const String &host_and_port);
|
||||
void connect(const String &host, int port);
|
||||
void setTimeoutConnect(int seconds, int useconds);
|
||||
bool isConnected() const;
|
||||
int port() const;
|
||||
const String& hostname() const;
|
||||
//@}
|
||||
|
||||
//! @name TCP-Server functions
|
||||
//@{
|
||||
void bind(const String &host, int port);
|
||||
virtual int receiveConnect(TCPSocket *socket, const String &host, int port);
|
||||
bool isListening() const;
|
||||
void stopListen();
|
||||
void signalStopListen();
|
||||
void listen(int backlog=64, int timeout=100);
|
||||
|
||||
//@}
|
||||
|
||||
//! @name Common functions for client and server
|
||||
//@{
|
||||
void setTimeoutRead(int seconds, int useconds);
|
||||
void setTimeoutWrite(int seconds, int useconds);
|
||||
|
||||
void disconnect();
|
||||
void shutdown();
|
||||
size_t write(const String &str, size_t bytes=0);
|
||||
size_t write(const WideString &str, size_t bytes=0);
|
||||
size_t write(const ByteArrayPtr &bin, size_t bytes=0);
|
||||
size_t write(const void *buffer, size_t bytes);
|
||||
size_t writef(const char *fmt, ...);
|
||||
size_t write(const SocketMessage &msg);
|
||||
size_t read(void *buffer, size_t bytes);
|
||||
size_t read(String &buffer, size_t bytes);
|
||||
size_t read(ByteArray &buffer, size_t bytes);
|
||||
|
||||
void readLoop(void *buffer, size_t bytes, int timeout_seconds=0, Thread *watch_thread=NULL);
|
||||
|
||||
int getDescriptor();
|
||||
void setBlocking(bool value);
|
||||
bool isBlocking() const;
|
||||
bool isWriteable();
|
||||
bool isReadable();
|
||||
bool waitForIncomingData(int seconds, int useconds);
|
||||
bool waitForOutgoingData(int seconds, int useconds);
|
||||
SockAddr getSockAddr() const;
|
||||
SockAddr getPeerAddr() const;
|
||||
//@}
|
||||
|
||||
//! @name SSL Encryption
|
||||
//@{
|
||||
void sslStart(SSLContext &context);
|
||||
void sslStop();
|
||||
void sslCheckCertificate(const ppl7::String &name, bool AcceptSelfSignedCert=false);
|
||||
void sslAccept(SSLContext &context);
|
||||
void sslWaitForAccept(SSLContext &context, int timeout_ms=0);
|
||||
bool sslIsEncrypted() const;
|
||||
String sslGetCipherName() const;
|
||||
String sslGetCipherVersion() const;
|
||||
int sslGetCipherBits() const;
|
||||
|
||||
//@}
|
||||
|
||||
|
||||
//! @name TODO
|
||||
//@{
|
||||
bool waitForMessage(SocketMessage &msg, int timeout_seconds=0, Thread *watch_thread=NULL);
|
||||
//@}
|
||||
|
||||
};
|
||||
|
||||
class UDPSocket
|
||||
{
|
||||
private:
|
||||
void *socket;
|
||||
int timeout_sec;
|
||||
int timeout_usec;
|
||||
String SourceInterface;
|
||||
int SourcePort;
|
||||
int connect_timeout_sec;
|
||||
int connect_timeout_usec;
|
||||
bool connected;
|
||||
|
||||
public:
|
||||
UDPSocket();
|
||||
virtual ~UDPSocket();
|
||||
void setTimeoutRead(int seconds, int useconds);
|
||||
void setTimeoutWrite(int seconds, int useconds);
|
||||
|
||||
//! @name Server functions
|
||||
//@{
|
||||
void bind(const String &host, int port);
|
||||
virtual int receiveConnect(UDPSocket *socket, const String &host, int port);
|
||||
bool isListening() const;
|
||||
void stopListen();
|
||||
void signalStopListen();
|
||||
void listen(int timeout=100);
|
||||
//@}
|
||||
|
||||
//! @name Misc
|
||||
int getDescriptor();
|
||||
void setBlocking(bool value);
|
||||
bool isWriteable();
|
||||
bool isReadable();
|
||||
bool waitForIncomingData(int seconds, int useconds);
|
||||
bool waitForOutgoingData(int seconds, int useconds);
|
||||
SockAddr getSockAddr() const;
|
||||
SockAddr getPeerAddr() const;
|
||||
//@}
|
||||
|
||||
//! @name Client functions
|
||||
size_t sendTo(const String &host, int port, const void *buffer, size_t bytes);
|
||||
size_t sendTo(const String &host, int port, const String &buffer);
|
||||
void setTimeoutConnect(int seconds, int useconds);
|
||||
void setSource(const String &interface_name, int port=0);
|
||||
void connect(const String &host_and_port);
|
||||
void connect(const String &host, int port);
|
||||
bool isConnected() const;
|
||||
void disconnect();
|
||||
size_t write(const String &str, size_t bytes=0);
|
||||
size_t write(const WideString &str, size_t bytes=0);
|
||||
size_t write(const ByteArrayPtr &bin, size_t bytes=0);
|
||||
size_t write(const void *buffer, size_t bytes);
|
||||
size_t writef(const char *fmt, ...);
|
||||
//@}
|
||||
|
||||
|
||||
int RecvFrom(void *buffer, int maxlen);
|
||||
int RecvFrom(void *buffer, int maxlen, String &host, int *port);
|
||||
int RecvFrom(String &buffer, int maxlen);
|
||||
int SetReadTimeout(int seconds, int useconds);
|
||||
int Bind(const char *host, int port);
|
||||
int GetDescriptor();
|
||||
|
||||
};
|
||||
|
||||
class Webserver
|
||||
{
|
||||
private:
|
||||
SSLContext SSL;
|
||||
void *daemon;
|
||||
int port;
|
||||
AssocArray res;
|
||||
TCPSocket Socket;
|
||||
bool basicAuthentication;
|
||||
bool SSLEnabled;
|
||||
String realm;
|
||||
String sslkey, sslcert;
|
||||
|
||||
public:
|
||||
class Request {
|
||||
friend class Webserver;
|
||||
private:
|
||||
|
||||
public:
|
||||
void *connection;
|
||||
void *postprocessor;
|
||||
String url;
|
||||
String method;
|
||||
String version;
|
||||
AssocArray header;
|
||||
AssocArray data;
|
||||
AssocArray auth;
|
||||
};
|
||||
Webserver();
|
||||
virtual ~Webserver();
|
||||
void bind(const String &adr, int port);
|
||||
void loadCertificate(const String &certificate, const String &privatekey, const String &password);
|
||||
void enableSSL(bool enable);
|
||||
bool sslEnabled() const;
|
||||
void start();
|
||||
void stop();
|
||||
void requireBasicAuthentication(bool enable, const String &realm);
|
||||
bool useBasicAuthentication() const;
|
||||
int queueResponse(const Request &req, const String &text, int httpStatus=200);
|
||||
int queueBasicAuthFailedResponse(const Request &req);
|
||||
|
||||
virtual int request(Request &req);
|
||||
virtual int authenticate(const String &username, const String &password, Request &req);
|
||||
virtual String getDenyMessage();
|
||||
|
||||
|
||||
|
||||
|
||||
PPL7EXCEPTION(CouldNotBindToSocket, Exception);
|
||||
PPL7EXCEPTION(InvalidSSLCertificate, Exception);
|
||||
PPL7EXCEPTION(NoAddressSpecified, Exception);
|
||||
PPL7EXCEPTION(CouldNotStartDaemon, Exception);
|
||||
PPL7EXCEPTION(SSLInitializationFailed, Exception);
|
||||
|
||||
};
|
||||
|
||||
//! \brief CURL-Klasse
|
||||
class Curl
|
||||
{
|
||||
private:
|
||||
void *handle;
|
||||
void *httppost, *last_httppost;
|
||||
void *headers;
|
||||
char *resultbuffer;
|
||||
Logger *log;
|
||||
size_t resultbuffer_size;
|
||||
String Header;
|
||||
String Browser, Url, UserPassword, Referer, Proxy;
|
||||
String GetCall;
|
||||
char *errorbuffer;
|
||||
bool aboard;
|
||||
void curlResultOk(int ret) const;
|
||||
|
||||
|
||||
|
||||
public:
|
||||
|
||||
PPL7EXCEPTION(InitializationFailedException, Exception);
|
||||
PPL7EXCEPTION(MiscException, Exception);
|
||||
PPL7EXCEPTION(StringEscapeException, Exception);
|
||||
PPL7EXCEPTION(InvalidURLException, Exception);
|
||||
PPL7EXCEPTION(NoResultException, Exception);
|
||||
PPL7EXCEPTION(OperationFailedException, Exception);
|
||||
|
||||
|
||||
enum HTTPVERSION {
|
||||
HTTP_1_0=1,
|
||||
HTTP_1_1,
|
||||
HTTP_2_0,
|
||||
};
|
||||
|
||||
static bool isSupported();
|
||||
|
||||
Curl();
|
||||
Curl(const Curl &other);
|
||||
~Curl();
|
||||
|
||||
//TODO: CNotifyHandler call_receive;
|
||||
//TODO: CNotifyHandler call_send;
|
||||
//TODO: CNotifyHandler call_done;
|
||||
|
||||
void debugHandler(int type, const char *data, size_t size);
|
||||
size_t storeResult(void *ptr, size_t bytes, int type);
|
||||
void setLogger(Logger *log);
|
||||
|
||||
void setBrowser(const String &browser);
|
||||
void setURL(const String &url);
|
||||
void setReferer(const String &url);
|
||||
void setUserPassword(const String &username, const String &password);
|
||||
void setUsername(const String &username);
|
||||
void setPassword(const String &password);
|
||||
void setUserPassword(const String &userpassword); // Format: username:password
|
||||
void setProxy(const String &proxy, int port);
|
||||
void setHttpVersion(Curl::HTTPVERSION version);
|
||||
void setTimeout(int seconds);
|
||||
void setHeader(const String &name, const String &value);
|
||||
void setMaximumPersistantConnects(int value);
|
||||
void enableSignals(bool enable);
|
||||
void reset();
|
||||
void clearHeader();
|
||||
void get();
|
||||
void get(const String ¶meter);
|
||||
void get(const AssocArray ¶m);
|
||||
void getResultBuffer(void **buffer, size_t *size) const;
|
||||
ByteArrayPtr getResultBuffer() const;
|
||||
void copyResultBuffer(ByteArray &bin) const;
|
||||
String getResultBufferAsString() const;
|
||||
String getHeader() const;
|
||||
String getURL() const;
|
||||
String getLastURL() const;
|
||||
void escape(String &target, const AssocArray &source);
|
||||
void escape(String &string);
|
||||
void addPostVar(const String &name, const String &data, const String &contenttype=String());
|
||||
void addPostVar(const String &name, int val, const String &contenttype=String());
|
||||
void addPostVar(const AssocArray ¶m, const String &prefix=String());
|
||||
void post();
|
||||
void post(const AssocArray ¶m);
|
||||
void postFields(const AssocArray ¶m);
|
||||
void clear();
|
||||
|
||||
void addCAFile(const String &filename);
|
||||
void verifyPeer(bool verify);
|
||||
|
||||
void * getCurlHandle() const;
|
||||
|
||||
static String getUri(const String &uri);
|
||||
};
|
||||
|
||||
|
||||
|
||||
class WikiParser
|
||||
{
|
||||
private:
|
||||
int ispre;
|
||||
int ullevel;
|
||||
size_t ollevel;
|
||||
int indexcount;
|
||||
int intable;
|
||||
int inrow;
|
||||
int indentlevel;
|
||||
bool doxyparamsStarted;
|
||||
bool indexenabled;
|
||||
|
||||
AssocArray index;
|
||||
String incol;
|
||||
String ret;
|
||||
String BaseURI;
|
||||
Array nowiki;
|
||||
int nowikicount;
|
||||
bool nobr;
|
||||
|
||||
int precount;
|
||||
AssocArray pre;
|
||||
int sourcecount;
|
||||
Array source;
|
||||
|
||||
Array diagrams;
|
||||
|
||||
|
||||
void init();
|
||||
void renderInternal(const String &Source, String &Html);
|
||||
void extractNoWiki(String &Text);
|
||||
void extractSourcecode(String &Text);
|
||||
void extractDiagrams(String &Text);
|
||||
void parseHeadlines(String &Line);
|
||||
int parseUL(String &Line);
|
||||
int parseOL(String &Line);
|
||||
int parseIndent(String &Line);
|
||||
|
||||
void parseDoxygen(String &Line);
|
||||
void doxygenChapter(String &Line, const String &Name, const Array &Matches);
|
||||
void parseAutoPRE(String &Line);
|
||||
void parseTable(String &Line);
|
||||
void parseLinks(String &Line);
|
||||
void buildIndex(String &Html);
|
||||
void finalize();
|
||||
void finalizeNoWiki();
|
||||
void finalizePRE();
|
||||
void finalizeSource();
|
||||
void finalizeDiagrams();
|
||||
|
||||
protected:
|
||||
virtual void customParseLinks(String &Line);
|
||||
|
||||
public:
|
||||
|
||||
WikiParser();
|
||||
virtual ~WikiParser();
|
||||
void render(const String &Source, String &Html);
|
||||
void renderBody(const String &Source, String &Html);
|
||||
String render(const String &Source);
|
||||
String renderBody(const String &Source);
|
||||
String header();
|
||||
void setIndexEnabled(bool enabled);
|
||||
void setBaseURI(const String &Uri);
|
||||
static String xmlDiagram2HTML(const String &xml);
|
||||
virtual void getHeader(String &Html);
|
||||
};
|
||||
|
||||
|
||||
} // EOF namespace ppl7
|
||||
|
||||
#endif /* PPL7INET_H_ */
|
119
src/pplib/include/ppl7-ppl6compat.h
Normal file
119
src/pplib/include/ppl7-ppl6compat.h
Normal file
|
@ -0,0 +1,119 @@
|
|||
/*******************************************************************************
|
||||
* This file is part of "Patrick's Programming Library", Version 7 (PPL7).
|
||||
* Web: http://www.pfp.de/ppl/
|
||||
*
|
||||
* $Author$
|
||||
* $Revision$
|
||||
* $Date$
|
||||
* $Id$
|
||||
*
|
||||
*******************************************************************************
|
||||
* Copyright (c) 2013, Patrick Fedick <patrick@pfp.de>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER AND CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef PPL7_PPL6COMPAT_H_
|
||||
#define PPL7_PPL6COMPAT_H_
|
||||
|
||||
#ifndef _PPL6_INCLUDE
|
||||
#include <ppl6.h>
|
||||
#endif
|
||||
#ifndef _PPL7_INCLUDE
|
||||
#ifdef PPL7LIB
|
||||
#include "ppl7.h"
|
||||
#else
|
||||
#include <ppl7.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
namespace ppl7 {
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-function"
|
||||
|
||||
static ppl7::String operator+(const ppl7::String &str1, const ppl6::CString& str2)
|
||||
{
|
||||
ppl7::String p7(str2);
|
||||
return str1+p7;
|
||||
}
|
||||
|
||||
static ppl7::String operator+(const ppl6::CString &str1, const ppl7::String& str2)
|
||||
{
|
||||
ppl7::String p7(str1);
|
||||
return p7+str2;
|
||||
}
|
||||
|
||||
static ppl6::CString to6(const ppl7::String &str)
|
||||
{
|
||||
return ppl6::CString(str.c_str(),str.size());
|
||||
}
|
||||
|
||||
static ppl6::CAssocArray to6(const ppl7::AssocArray &arr)
|
||||
{
|
||||
ppl7::ByteArray bin;
|
||||
arr.exportBinary(bin);
|
||||
ppl6::CAssocArray a6;
|
||||
a6.ImportBinary(bin.ptr(),bin.size());
|
||||
return a6;
|
||||
}
|
||||
|
||||
static ppl7::String to7(const ppl6::CString &str)
|
||||
{
|
||||
return ppl7::String(str.GetPtr(),str.Size());
|
||||
}
|
||||
|
||||
static ppl7::DateTime to7(const ppl6::CDateTime &date)
|
||||
{
|
||||
ppl7::DateTime d;
|
||||
d.setLongInt(date.longInt());
|
||||
return d;
|
||||
}
|
||||
|
||||
static ppl6::CDateTime to6(const ppl7::DateTime &date)
|
||||
{
|
||||
ppl6::CDateTime d;
|
||||
d.setLongInt(date.longInt());
|
||||
return d;
|
||||
}
|
||||
|
||||
static ppl7::AssocArray to7(const ppl6::CAssocArray &arr)
|
||||
{
|
||||
ppl6::CBinary *bin=arr.ExportBinary();
|
||||
if (bin) {
|
||||
try {
|
||||
ppl7::AssocArray a7;
|
||||
a7.importBinary(bin->GetPtr(),bin->Size());
|
||||
delete bin;
|
||||
return a7;
|
||||
} catch (...) {
|
||||
}
|
||||
delete bin;
|
||||
}
|
||||
return ppl7::AssocArray();
|
||||
}
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
} // EOF namespace ppl7
|
||||
|
||||
#endif /* PPL7_PPL6COMPAT_H_ */
|
786
src/pplib/include/ppl7-tk.h
Normal file
786
src/pplib/include/ppl7-tk.h
Normal file
|
@ -0,0 +1,786 @@
|
|||
/*******************************************************************************
|
||||
* This file is part of "Patrick's Programming Library", Version 7 (PPL7).
|
||||
* Web: http://www.pfp.de/ppl/
|
||||
*
|
||||
* $Author$
|
||||
* $Revision$
|
||||
* $Date$
|
||||
* $Id$
|
||||
*
|
||||
*******************************************************************************
|
||||
* Copyright (c) 2013, Patrick Fedick <patrick@pfp.de>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER AND CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef _PPL7_INCLUDE_TK
|
||||
#define _PPL7_INCLUDE_TK
|
||||
#ifndef _PPL7_INCLUDE
|
||||
#ifdef PPL7LIB
|
||||
#include "ppl7.h"
|
||||
#else
|
||||
#include <ppl7.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef _PPL7_GRAFIX
|
||||
#ifdef PPL7LIB
|
||||
#include "ppl7-grafix.h"
|
||||
#else
|
||||
#include <ppl7-grafix.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
namespace ppl7 {
|
||||
namespace tk {
|
||||
|
||||
PPL7EXCEPTION(NoWindowManagerException, Exception);
|
||||
PPL7EXCEPTION(DuplicateWindowManagerException, Exception);
|
||||
PPL7EXCEPTION(InitializationException, Exception);
|
||||
PPL7EXCEPTION(ExistingPrimaryWindowException, Exception);
|
||||
PPL7EXCEPTION(WindowCreateException, Exception);
|
||||
PPL7EXCEPTION(WindowAlreadyCreatedException, Exception);
|
||||
PPL7EXCEPTION(SurfaceCreateException, Exception);
|
||||
PPL7EXCEPTION(EventLoopException, Exception);
|
||||
PPL7EXCEPTION(UnknownEventException, Exception);
|
||||
PPL7EXCEPTION(NoWindowException, Exception);
|
||||
|
||||
using namespace ppl7::grafix;
|
||||
|
||||
class WidgetStyle
|
||||
{
|
||||
public:
|
||||
Color windowBackgroundColor;
|
||||
Color frameBackgroundColor;
|
||||
Color frameBorderColor;
|
||||
Color labelFontColor;
|
||||
Font labelFont;
|
||||
Color buttonBackgroundColor;
|
||||
Color buttonFontColor;
|
||||
Font buttonFont;
|
||||
Color surfaceBackgroundColor;
|
||||
Color inputFontColor;
|
||||
Font inputFont;
|
||||
Color inputBackgroundColor;
|
||||
};
|
||||
|
||||
class Widget;
|
||||
|
||||
class Event
|
||||
{
|
||||
friend class EventHandler;
|
||||
public:
|
||||
enum Type {
|
||||
Unknown=0,
|
||||
MouseEnter,
|
||||
MouseMove,
|
||||
MouseLeave,
|
||||
MouseDown,
|
||||
MouseUp,
|
||||
MouseDblClick,
|
||||
MouseWheel,
|
||||
KeyDown,
|
||||
KeyUp,
|
||||
Show,
|
||||
Close,
|
||||
Resize,
|
||||
Move,
|
||||
FocusIn,
|
||||
FocusOut,
|
||||
GeometryChanged,
|
||||
Quit,
|
||||
};
|
||||
private:
|
||||
Type t;
|
||||
bool accepted;
|
||||
bool ignored;
|
||||
Widget *eventWidget;
|
||||
|
||||
public:
|
||||
Event();
|
||||
Event(Type t);
|
||||
virtual ~Event();
|
||||
|
||||
Type type() const;
|
||||
void setType(Type t);
|
||||
void ignore();
|
||||
void accept();
|
||||
bool isIgnored() const;
|
||||
bool isAccepted() const;
|
||||
String name() const;
|
||||
Widget *widget() const;
|
||||
void setWidget(Widget *w);
|
||||
|
||||
|
||||
};
|
||||
|
||||
class MouseState
|
||||
{
|
||||
public:
|
||||
MouseState();
|
||||
enum MouseButton {
|
||||
Left=1,
|
||||
Middle=2,
|
||||
Right=4,
|
||||
WheelUp=8,
|
||||
WheelDown=16,
|
||||
X1=32,
|
||||
X2=64
|
||||
};
|
||||
Point p;
|
||||
MouseButton buttonMask;
|
||||
MouseButton button;
|
||||
};
|
||||
|
||||
class MouseEvent : public Event, public MouseState
|
||||
{
|
||||
private:
|
||||
|
||||
public:
|
||||
};
|
||||
|
||||
|
||||
class KeyEvent : public Event
|
||||
{
|
||||
public:
|
||||
enum keycode {
|
||||
KEY_UNKNOWN = 0,
|
||||
KEY_RETURN = 40,
|
||||
KEY_ESCAPE = 41,
|
||||
KEY_BACKSPACE = 42,
|
||||
KEY_TAB = 43,
|
||||
KEY_SPACE = 44,
|
||||
KEY_CAPSLOCK = 57,
|
||||
KEY_F1 = 58,
|
||||
KEY_F2 = 59,
|
||||
KEY_F3 = 60,
|
||||
KEY_F4 = 61,
|
||||
KEY_F5 = 62,
|
||||
KEY_F6 = 63,
|
||||
KEY_F7 = 64,
|
||||
KEY_F8 = 65,
|
||||
KEY_F9 = 66,
|
||||
KEY_F10 = 67,
|
||||
KEY_F11 = 68,
|
||||
KEY_F12 = 69,
|
||||
KEY_PRINTSCREEN = 70,
|
||||
KEY_SCROLLLOCK = 71,
|
||||
KEY_PAUSE = 72,
|
||||
KEY_INSERT = 73,
|
||||
KEY_HOME = 74,
|
||||
KEY_PAGEUP = 75,
|
||||
KEY_DELETE = 76,
|
||||
KEY_END = 77,
|
||||
KEY_PAGEDOWN = 78,
|
||||
KEY_RIGHT = 79,
|
||||
KEY_LEFT = 80,
|
||||
KEY_DOWN = 81,
|
||||
KEY_UP = 82,
|
||||
KEY_NUMLOCK = 83,
|
||||
KEY_ENTER = 88,
|
||||
KEY_LEFTCTRL = 224,
|
||||
KEY_LEFTSHIFT = 225,
|
||||
KEY_LEFTALT = 226,
|
||||
KEY_LEFTGUI = 227,
|
||||
KEY_RIGHTCTRL = 224,
|
||||
KEY_RIGHTSHIFT = 225,
|
||||
KEY_RIGHTALT = 226,
|
||||
KEY_RIGHTGUI = 227,
|
||||
KEY_MODE = 257,
|
||||
};
|
||||
|
||||
enum keymodifier {
|
||||
KEYMOD_NONE = 0,
|
||||
KEYMOD_LEFTSHIFT = 0x0001,
|
||||
KEYMOD_RIGHTSHIFT = 0x0002,
|
||||
KEYMOD_LEFTCTRL = 0x0004,
|
||||
KEYMOD_RIGHTCTRL = 0x0008,
|
||||
KEYMOD_LEFTALT = 0x0010,
|
||||
KEYMOD_RIGHTALT = 0x0020,
|
||||
KEYMOD_LEFTGUI = 0x0040,
|
||||
KEYMOD_RIGHTGUI = 0x0080,
|
||||
KEYMOD_NUM = 0x0100,
|
||||
KEYMOD_CAPS = 0x0200,
|
||||
KEYMOD_MODE = 0x0400,
|
||||
|
||||
KEYMOD_SHIFT = KEYMOD_LEFTSHIFT|KEYMOD_RIGHTSHIFT,
|
||||
KEYMOD_CTRL = KEYMOD_LEFTCTRL|KEYMOD_RIGHTCTRL,
|
||||
KEYMOD_ALT = KEYMOD_LEFTALT|KEYMOD_RIGHTALT,
|
||||
KEYMOD_GUI = KEYMOD_LEFTGUI|KEYMOD_RIGHTGUI,
|
||||
|
||||
|
||||
};
|
||||
KeyEvent();
|
||||
int key;
|
||||
int modifier;
|
||||
bool repeat;
|
||||
};
|
||||
|
||||
class TextInputEvent : public Event
|
||||
{
|
||||
public:
|
||||
WideString text;
|
||||
};
|
||||
|
||||
class ResizeEvent : public Event
|
||||
{
|
||||
public:
|
||||
ResizeEvent();
|
||||
int width, height;
|
||||
};
|
||||
|
||||
class FocusEvent : public Event
|
||||
{
|
||||
public:
|
||||
|
||||
};
|
||||
|
||||
|
||||
class EventHandler
|
||||
{
|
||||
private:
|
||||
EventHandler *handler;
|
||||
public:
|
||||
EventHandler();
|
||||
virtual ~EventHandler();
|
||||
void setEventHandler(EventHandler *handler);
|
||||
|
||||
virtual void closeEvent(Event *event);
|
||||
virtual void quitEvent(Event *event);
|
||||
|
||||
virtual void mouseMoveEvent(MouseEvent *event);
|
||||
virtual void mouseDownEvent(MouseEvent *event);
|
||||
virtual void mouseUpEvent(MouseEvent *event);
|
||||
virtual void mouseDblClickEvent(MouseEvent *event);
|
||||
virtual void mouseClickEvent(MouseEvent *event);
|
||||
virtual void mouseEnterEvent(MouseEvent *event);
|
||||
virtual void mouseLeaveEvent(MouseEvent *event);
|
||||
virtual void geometryChangedEvent(Event *event);
|
||||
|
||||
virtual void gotFocusEvent(FocusEvent *event);
|
||||
virtual void lostFocusEvent(FocusEvent *event);
|
||||
|
||||
virtual void keyDownEvent(KeyEvent *event);
|
||||
virtual void keyUpEvent(KeyEvent *event);
|
||||
virtual void textInputEvent(TextInputEvent *event);
|
||||
|
||||
virtual void timerEvent(Event *event);
|
||||
|
||||
};
|
||||
|
||||
typedef struct PRIV_SURFACE_FUNCTIONS
|
||||
{
|
||||
void (*lock) (void *privatedata, Drawable &draw);
|
||||
void (*unlock) (void *privatedata);
|
||||
void (*destroy) (void *privatedata);
|
||||
void (*update) (void *privatedata, const Drawable &source);
|
||||
} PRIV_SURFACE_FUNCTIONS;
|
||||
|
||||
class Surface
|
||||
{
|
||||
private:
|
||||
PRIV_SURFACE_FUNCTIONS *fn;
|
||||
void *privatedata;
|
||||
int myFlags;
|
||||
int w,h;
|
||||
RGBFormat myFormat;
|
||||
|
||||
public:
|
||||
enum SurfaceFlags {
|
||||
Hardware = 0x00000001,
|
||||
Lockable = 0x00000002,
|
||||
VideoMemory = 0x00000004,
|
||||
ZBuffer = 0x00000008,
|
||||
StencilBuffer = 0x00000010,
|
||||
SoftwareVertexProcessing = 0x00000020,
|
||||
Multithreaded = 0x00000040,
|
||||
FPUPreserve = 0x00000080,
|
||||
OpenGL = 0x00000100,
|
||||
Texture = 0x00000200,
|
||||
DefaultSurface = Hardware|Lockable|VideoMemory,
|
||||
};
|
||||
Surface();
|
||||
~Surface();
|
||||
bool isLoackable() const;
|
||||
void lock(Drawable &draw);
|
||||
void unlock();
|
||||
void update(const Drawable &source);
|
||||
SurfaceFlags flags() const;
|
||||
const RGBFormat &rgbFormat() const;
|
||||
int width() const;
|
||||
int height() const;
|
||||
|
||||
void setFlags(SurfaceFlags flags);
|
||||
void setRGBFormat(const RGBFormat &format);
|
||||
void setSize(int width, int height);
|
||||
void setPrivateData(void *data, PRIV_SURFACE_FUNCTIONS *fn);
|
||||
void *getPrivateData();
|
||||
};
|
||||
|
||||
|
||||
|
||||
class Widget : public EventHandler
|
||||
{
|
||||
friend class WindowManager;
|
||||
private:
|
||||
Widget *parent;
|
||||
//Surface *surface;
|
||||
RGBFormat format;
|
||||
Point p;
|
||||
Size s;
|
||||
Size MaxSize, MinSize;
|
||||
Rect myClientOffset;
|
||||
List<Widget*> childs;
|
||||
ppluint32 lockcount;
|
||||
bool visible;
|
||||
bool enabled;
|
||||
bool needsredraw;
|
||||
bool child_needsredraw;
|
||||
bool topMost;
|
||||
bool transparent;
|
||||
Size strategy;
|
||||
String myName;
|
||||
|
||||
public:
|
||||
enum SizeStrategy {
|
||||
FIXED=1,
|
||||
MAXIMUM_EXPANDING,
|
||||
MINIMUM_EXPANDING,
|
||||
};
|
||||
|
||||
Widget();
|
||||
virtual ~Widget();
|
||||
size_t numChilds() const;
|
||||
void resetIterator(List<Widget*>::Iterator &it);
|
||||
Widget *getNextChild(List<Widget*>::Iterator &it);
|
||||
|
||||
const Point &pos() const;
|
||||
const Size &size() const;
|
||||
Rect rect() const;
|
||||
Rect clientRect() const;
|
||||
Size clientSize() const;
|
||||
const Size maxSize() const;
|
||||
const Size minSize() const;
|
||||
void setMaxSize(const Size &s);
|
||||
void setMaxSize(int width=65535, int height=65535);
|
||||
void setMinSize(const Size &s);
|
||||
void setMinSize(int width=65535, int height=65535);
|
||||
int width() const;
|
||||
int height() const;
|
||||
int x() const;
|
||||
int y() const;
|
||||
void create(int x, int y, int width, int height);
|
||||
void setX(int x);
|
||||
void setY(int y);
|
||||
void setPos(int x, int y);
|
||||
void setPos(const Point &p);
|
||||
void setWidth(int width);
|
||||
void setHeight(int height);
|
||||
void setSize(int width, int height);
|
||||
void setSize(const Size &s);
|
||||
void setTopmost(bool flag);
|
||||
void setClientOffset(int left, int top, int right, int bottom);
|
||||
void setSizeStrategyWidth(SizeStrategy s);
|
||||
SizeStrategy sizeStrategyWidth() const;
|
||||
void setSizeStrategyHeight(SizeStrategy s);
|
||||
SizeStrategy sizeStrategyHeight() const;
|
||||
|
||||
void setTransparent(bool flag);
|
||||
bool isTransparent() const;
|
||||
void setEnabled(bool flag);
|
||||
bool isEnabed() const;
|
||||
void setVisible(bool flag);
|
||||
bool isVisible() const;
|
||||
|
||||
Drawable drawable(const Drawable &parent) const;
|
||||
Drawable clientDrawable(const Drawable &parent) const;
|
||||
|
||||
void addChild(Widget *w);
|
||||
void removeChild(Widget *w);
|
||||
|
||||
void needsRedraw();
|
||||
void childNeedsRedraw();
|
||||
void parentMustRedraw();
|
||||
void geometryChanged();
|
||||
void toTop(Widget *w=NULL);
|
||||
void toTop(Widget &w);
|
||||
void draw(Drawable &d);
|
||||
void redraw(Drawable &d);
|
||||
bool redrawRequired() const;
|
||||
Size preferedSize() const;
|
||||
void setName(const String &name);
|
||||
String name() const;
|
||||
virtual String widgetType() const;
|
||||
|
||||
virtual void paint(Drawable &draw);
|
||||
virtual Size contentSize() const;
|
||||
};
|
||||
|
||||
class WindowManager;
|
||||
class Window;
|
||||
|
||||
typedef struct PRIV_WINDOW_FUNCTIONS {
|
||||
void (*setWindowTitle) (void *privatedata, const String &Title);
|
||||
void (*setWindowIcon) (void *privatedata, const Drawable &Icon);
|
||||
void (*createSurface) (void *privatedata);
|
||||
void (*createTexture) (void *privatedata);
|
||||
Drawable (*lockWindowSurface) (void *privatedata);
|
||||
void (*unlockWindowSurface) (void *privatedata);
|
||||
void (*drawWindowSurface) (void *privatedata);
|
||||
void *(*getRenderer) (void *privatedata);
|
||||
void (*clearScreen) (void *privatedata);
|
||||
void (*presentScreen) (void *privatedata);
|
||||
} PRIV_WINDOW_FUNCTIONS;
|
||||
|
||||
|
||||
class Window : public Widget
|
||||
{
|
||||
friend class WindowManager;
|
||||
private:
|
||||
void *privateData;
|
||||
PRIV_WINDOW_FUNCTIONS *fn;
|
||||
WindowManager *wm;
|
||||
Widget *keyfocus;
|
||||
ppluint32 windowFlags;
|
||||
String WindowTitle;
|
||||
Image WindowIcon;
|
||||
RGBFormat WindowRGBFormat;
|
||||
Color myBackground;
|
||||
|
||||
MouseState mouseState;
|
||||
|
||||
public:
|
||||
enum WindowFlags {
|
||||
NoBorder = 0x00000001,
|
||||
Resizeable = 0x00000002,
|
||||
Maximized = 0x00000004,
|
||||
Minimized = 0x00000008,
|
||||
TopMost = 0x00000010,
|
||||
Fullscreen = 0x00000020,
|
||||
WaitVsync = 0x00200000,
|
||||
ZBuffer = 0x00400000,
|
||||
StencilBuffer = 0x00800000,
|
||||
SoftwareVertexProcessing = 0x01000000,
|
||||
OpenGL = 0x08000000,
|
||||
DefaultWindow = WaitVsync,
|
||||
DefaultFullscreen = NoBorder|WaitVsync|Fullscreen|TopMost,
|
||||
};
|
||||
Window();
|
||||
~Window();
|
||||
ppluint32 flags() const;
|
||||
void setFlags(ppluint32 flags);
|
||||
const String &windowTitle() const;
|
||||
void setWindowTitle(const String &title);
|
||||
const Drawable &windowIcon() const;
|
||||
void setWindowIcon(const Drawable &icon);
|
||||
const RGBFormat &rgbFormat() const;
|
||||
void setRGBFormat(const RGBFormat &format);
|
||||
|
||||
const Color &backgroundColor() const;
|
||||
void setBackgroundColor(const Color &c);
|
||||
|
||||
void drawWidgets();
|
||||
void redrawWidgets();
|
||||
|
||||
void *getPrivateData();
|
||||
void setPrivateData(void *data, WindowManager *wm, PRIV_WINDOW_FUNCTIONS *fn);
|
||||
|
||||
void *getRenderer();
|
||||
void clearScreen();
|
||||
void presentScreen();
|
||||
MouseState getMouseState();
|
||||
|
||||
virtual String widgetType() const;
|
||||
virtual void paint(Drawable &draw);
|
||||
};
|
||||
|
||||
class WindowManager
|
||||
{
|
||||
private:
|
||||
WidgetStyle Style;
|
||||
Widget *LastMouseDown;
|
||||
Widget *LastMouseEnter;
|
||||
|
||||
MouseEvent clickEvent;
|
||||
int clickCount;
|
||||
int doubleClickIntervall;
|
||||
|
||||
Widget *KeyboardFocus;
|
||||
|
||||
public:
|
||||
WindowManager();
|
||||
virtual ~WindowManager();
|
||||
const WidgetStyle *getWidgetStyle() const;
|
||||
void dispatchEvent(Window *window, Event &event);
|
||||
void dispatchClickEvent(Window *window);
|
||||
void setDoubleClickIntervall(int ms);
|
||||
void setKeyboardFocus(Widget *w);
|
||||
Widget *getKeyboardFocus() const;
|
||||
int getDoubleClickIntervall() const;
|
||||
Widget *findMouseWidget(Widget *window, const Point &p);
|
||||
|
||||
virtual void createWindow(Window &w) = 0;
|
||||
virtual void destroyWindow(Window &w) = 0;
|
||||
|
||||
virtual const Size &desktopResolution() const =0;
|
||||
virtual const RGBFormat &desktopRGBFormat() const =0;
|
||||
|
||||
virtual MouseState getMouseState() const =0;
|
||||
virtual void getMouseState(Point &p, int &buttonMask)=0;
|
||||
virtual void startEventLoop() = 0;
|
||||
virtual void handleEvents() = 0;
|
||||
virtual size_t numWindows() = 0;
|
||||
virtual void startClickEvent(Window *win) = 0;
|
||||
virtual void startTimer(Widget *w, int intervall) =0;
|
||||
//virtual void createSurface(Widget &w, int width, int height, const RGBFormat &format=RGBFormat(), int flags=Surface::DefaultSurface) = 0;
|
||||
|
||||
};
|
||||
|
||||
WindowManager *GetWindowManager();
|
||||
const WidgetStyle *GetWidgetStyle();
|
||||
|
||||
|
||||
class WindowManager_SDL2 : public WindowManager
|
||||
{
|
||||
private:
|
||||
RGBFormat screenRGBFormat;
|
||||
Size screenSize;
|
||||
int screenRefreshRate;
|
||||
|
||||
List<Window*> windows;
|
||||
|
||||
void DispatchSdlActiveEvent(void *e);
|
||||
void DispatchSdlKeyEvent(void *e);
|
||||
void DispatchMouseEvent(void *e);
|
||||
void DispatchKeyEvent(void *e);
|
||||
void DispatchSdlResizeEvent(void *e);
|
||||
void DispatchEvent(void *e);
|
||||
void DispatchQuitEvent(void *e);
|
||||
|
||||
void DispatchWindowEvent(void *e);
|
||||
|
||||
Window *getWindow(ppluint32 id);
|
||||
|
||||
public:
|
||||
WindowManager_SDL2();
|
||||
~WindowManager_SDL2();
|
||||
//virtual void createSurface(Widget &w, int width, int height, const RGBFormat &format=RGBFormat(), int flags=Surface::DefaultSurface);
|
||||
virtual void createWindow(Window &w);
|
||||
virtual void destroyWindow(Window &w);
|
||||
|
||||
virtual const Size &desktopResolution() const;
|
||||
virtual const RGBFormat &desktopRGBFormat() const;
|
||||
virtual MouseState getMouseState() const;
|
||||
virtual void getMouseState(Point &p, int &buttonMask);
|
||||
virtual void startEventLoop();
|
||||
virtual void handleEvents();
|
||||
virtual size_t numWindows();
|
||||
virtual void startClickEvent(Window *win);
|
||||
virtual void startTimer(Widget *w, int intervall);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class Button : public Widget
|
||||
{
|
||||
private:
|
||||
Font myFont;
|
||||
String Text;
|
||||
Image Icon;
|
||||
Color foreground, background;
|
||||
bool isDown;
|
||||
public:
|
||||
Button();
|
||||
Button(int x, int y, int width, int height, const String &text=String(), const Drawable &icon=Drawable());
|
||||
virtual ~Button();
|
||||
const String &text() const;
|
||||
void setText(const String &text);
|
||||
const Drawable &icon() const;
|
||||
void setIcon(const Drawable &icon);
|
||||
int style() const;
|
||||
const Color &color() const;
|
||||
void setColor(const Color &c);
|
||||
const Color &backgroundColor() const;
|
||||
void setBackgroundColor(const Color &c);
|
||||
const Font &font() const;
|
||||
void setFont(const Font &font);
|
||||
|
||||
virtual String widgetType() const;
|
||||
virtual void paint(Drawable &draw);
|
||||
virtual Size contentSize() const;
|
||||
|
||||
virtual void mouseDownEvent(MouseEvent *event);
|
||||
virtual void mouseUpEvent(MouseEvent *event);
|
||||
virtual void mouseLeaveEvent(MouseEvent *event);
|
||||
|
||||
};
|
||||
|
||||
class Frame : public Widget
|
||||
{
|
||||
private:
|
||||
int myBorderStyle;
|
||||
Color myBackground, myBorderColor;
|
||||
public:
|
||||
enum BorderStyle {
|
||||
NoBorder=0,
|
||||
Normal,
|
||||
Upset,
|
||||
Inset
|
||||
};
|
||||
Frame();
|
||||
Frame(int x, int y, int width, int height,BorderStyle style=Upset);
|
||||
~Frame();
|
||||
BorderStyle borderStyle() const;
|
||||
void setBorderStyle(BorderStyle s);
|
||||
const Color &backgroundColor() const;
|
||||
void setBackgroundColor(const Color &c);
|
||||
const Color &borderColor() const;
|
||||
void setBorderColor(const Color &c);
|
||||
|
||||
virtual String widgetType() const;
|
||||
virtual void paint(Drawable &draw);
|
||||
};
|
||||
|
||||
class Label : public Frame
|
||||
{
|
||||
private:
|
||||
String myText;
|
||||
Font myFont;
|
||||
Image myIcon;
|
||||
Color myColor;
|
||||
public:
|
||||
Label();
|
||||
Label(int x, int y, int width, int height, const String &text=String(), BorderStyle style=NoBorder);
|
||||
~Label();
|
||||
const String &text() const;
|
||||
void setText(const String &text);
|
||||
const Drawable &icon() const;
|
||||
void setIcon(const Drawable &icon);
|
||||
const Color &color() const;
|
||||
void setColor(const Color &c);
|
||||
const Font &font() const;
|
||||
void setFont(const Font &font);
|
||||
|
||||
virtual String widgetType() const;
|
||||
virtual void paint(Drawable &draw);
|
||||
virtual Size contentSize() const;
|
||||
};
|
||||
|
||||
class VerticalDivider : public Widget
|
||||
{
|
||||
public:
|
||||
VerticalDivider();
|
||||
VerticalDivider(int x, int y, int width, int height);
|
||||
virtual String widgetType() const;
|
||||
virtual void paint(Drawable &draw);
|
||||
virtual Size contentSize() const;
|
||||
};
|
||||
|
||||
class HorizontalDivider : public Widget
|
||||
{
|
||||
public:
|
||||
HorizontalDivider();
|
||||
HorizontalDivider(int x, int y, int width, int height);
|
||||
virtual String widgetType() const;
|
||||
virtual void paint(Drawable &draw);
|
||||
virtual Size contentSize() const;
|
||||
};
|
||||
|
||||
class HorizontalLayout : public Widget
|
||||
{
|
||||
private:
|
||||
int spacing;
|
||||
int lastTotal;
|
||||
public:
|
||||
HorizontalLayout();
|
||||
virtual ~HorizontalLayout();
|
||||
|
||||
virtual String widgetType() const;
|
||||
virtual void paint(Drawable &draw);
|
||||
virtual void geometryChangedEvent(Event *event);
|
||||
};
|
||||
|
||||
class HorizontalSpacer : public Widget
|
||||
{
|
||||
public:
|
||||
HorizontalSpacer();
|
||||
virtual String widgetType() const;
|
||||
virtual void paint(Drawable &draw);
|
||||
|
||||
};
|
||||
|
||||
class LineInput : public Frame
|
||||
{
|
||||
private:
|
||||
WideString myText;
|
||||
Font myFont;
|
||||
Image myIcon;
|
||||
Color myColor;
|
||||
size_t cursorpos;
|
||||
size_t startpos;
|
||||
int cursorx;
|
||||
int cursorwidth;
|
||||
bool blinker;
|
||||
|
||||
void calcCursorPosition();
|
||||
int calcPosition(int x);
|
||||
public:
|
||||
LineInput();
|
||||
LineInput(int x, int y, int width, int height, const String &text=String());
|
||||
~LineInput();
|
||||
const WideString &text() const;
|
||||
void setText(const String &text);
|
||||
const Color &color() const;
|
||||
void setColor(const Color &c);
|
||||
const Font &font() const;
|
||||
void setFont(const Font &font);
|
||||
|
||||
virtual String widgetType() const;
|
||||
virtual void paint(Drawable &draw);
|
||||
virtual Size contentSize() const;
|
||||
|
||||
virtual void mouseDownEvent(MouseEvent *event);
|
||||
virtual void gotFocusEvent(FocusEvent *event);
|
||||
virtual void lostFocusEvent(FocusEvent *event);
|
||||
virtual void textInputEvent(TextInputEvent *event);
|
||||
virtual void keyDownEvent(KeyEvent *event);
|
||||
virtual void keyUpEvent(KeyEvent *event);
|
||||
virtual void timerEvent(Event *event);
|
||||
|
||||
};
|
||||
|
||||
|
||||
} // EOF namespace tk
|
||||
} // end of namespace ppl7
|
||||
|
||||
|
||||
#endif // _PPL7_INCLUDE_TK
|
||||
|
||||
|
||||
|
1205
src/pplib/include/ppl7-types.h
Normal file
1205
src/pplib/include/ppl7-types.h
Normal file
File diff suppressed because it is too large
Load diff
80
src/pplib/include/ppl7-visualc-config.h
Normal file
80
src/pplib/include/ppl7-visualc-config.h
Normal file
|
@ -0,0 +1,80 @@
|
|||
#pragma once
|
||||
#ifndef PPL7_VISUALC_CONFIG
|
||||
#define PPL7_VISUALC_CONFIG
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
|
||||
// define HAVE_STRING_H 0
|
||||
#define HAVE_STRING_H 1
|
||||
#define HAVE_STDLIB_H 1
|
||||
#define HAVE_STDIO_H 1
|
||||
#define HAVE_STDINT_H 1
|
||||
#define HAVE_STDARG_H 1
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
#define HAVE_CRTDEFS_H 1
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
#define HAVE_LIMITS_H 1
|
||||
#define HAVE_CTYPE_H 1
|
||||
#define HAVE_WCHAR_H 1
|
||||
#define HAVE_WCTYPE_H 1
|
||||
#define HAVE_LOCALE_H 1
|
||||
#define HAVE_ERRNO_H 1
|
||||
//#define HAVE_WIDEC_H 0
|
||||
#define HAVE_TIME_H 1
|
||||
#define HAVE_FCNTL_H 1
|
||||
//#define HAVE_SYS_MMAN_H 0
|
||||
//#define HAVE_UNISTD_H 0
|
||||
//#define HAVE_DIRENT_H 0
|
||||
//#define HAVE_SYS_FILE_H 0
|
||||
#define HAVE_MATH_H
|
||||
#define HAVE_SIGNAL_H
|
||||
|
||||
#define HAVE_STAT
|
||||
|
||||
|
||||
#define HAVE_STRNCPY_S 1
|
||||
#define HAVE_WCSNCPY_S 1
|
||||
#define HAVE_WCSTOMBS_S 1
|
||||
#define HAVE_MBSTOWCS_S 1
|
||||
#define HAVE_STRERROR_S 1
|
||||
|
||||
/*
|
||||
* External Features
|
||||
*/
|
||||
#define HAVE_LIBZ 1
|
||||
#define HAVE_BZIP2 1
|
||||
#define HAVE_X86_ASSEMBLER 1
|
||||
#define HAVE_FREETYPE2 1
|
||||
#define HAVE_JPEG 1
|
||||
#define HAVE_PNG 1
|
||||
#define HAVE_TIFF 1
|
||||
|
||||
|
||||
|
||||
|
||||
#define ppluint8 unsigned char
|
||||
#define pplint8 signed char
|
||||
#define ppluint16 unsigned short
|
||||
#define pplint16 signed short
|
||||
#define ppluint32 unsigned int
|
||||
#define pplint32 signed int
|
||||
#define ppluint64 unsigned long long
|
||||
#define pplint64 signed long long
|
||||
|
||||
#define ppliptr ppluint64
|
||||
|
||||
#define pplfloat float
|
||||
#define ppldouble double
|
||||
#define pplbool bool
|
||||
#define pplchar char
|
||||
#define ppluchar unsigned char
|
||||
|
||||
|
||||
#define ssize_t long long
|
||||
#define mode_t int
|
||||
|
||||
|
||||
#define ICONV_UNICODE "UTF-16LE"
|
||||
|
||||
#endif
|
1330
src/pplib/include/ppl7.h
Normal file
1330
src/pplib/include/ppl7.h
Normal file
File diff suppressed because it is too large
Load diff
53
src/pplib/include/prolog.h
Normal file
53
src/pplib/include/prolog.h
Normal file
|
@ -0,0 +1,53 @@
|
|||
/*******************************************************************************
|
||||
* This file is part of "Patrick's Programming Library", Version 7 (PPL7).
|
||||
* Web: http://www.pfp.de/ppl/
|
||||
*
|
||||
* $Author$
|
||||
* $Revision$
|
||||
* $Date$
|
||||
* $Id$
|
||||
*
|
||||
*******************************************************************************
|
||||
* Copyright (c) 2013, Patrick Fedick <patrick@pfp.de>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER AND CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*******************************************************************************/
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#endif
|
||||
|
||||
#ifndef _PPL7_CONFIG
|
||||
#ifdef PPL7LIB
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#else
|
||||
#ifdef PPLVISUALC
|
||||
#include "ppl7-visualc-config.h"
|
||||
#elif defined _WIN32
|
||||
#include "ppl7-config.h"
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
#include <ppl7-config.h>
|
||||
#endif
|
||||
#endif
|
||||
#include "compat.h"
|
55
src/pplib/include/socket.h
Normal file
55
src/pplib/include/socket.h
Normal file
|
@ -0,0 +1,55 @@
|
|||
/*******************************************************************************
|
||||
* This file is part of "Patrick's Programming Library", Version 7 (PPL7).
|
||||
* Web: http://www.pfp.de/ppl/
|
||||
*
|
||||
* $Author$
|
||||
* $Revision$
|
||||
* $Date$
|
||||
* $Id$
|
||||
*
|
||||
*******************************************************************************
|
||||
* Copyright (c) 2013, Patrick Fedick <patrick@pfp.de>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER AND CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*******************************************************************************/
|
||||
|
||||
namespace ppl7 {
|
||||
|
||||
#ifdef _WIN32
|
||||
int inet_aton(const char *cp, struct in_addr *pin);
|
||||
#endif
|
||||
|
||||
typedef struct tagPPLSocket {
|
||||
#ifdef _WIN32
|
||||
SOCKET sd;
|
||||
#else
|
||||
int sd;
|
||||
#endif
|
||||
int proto;
|
||||
char *ipname;
|
||||
int port;
|
||||
//int addrlen;
|
||||
} PPLSOCKET;
|
||||
|
||||
|
||||
|
||||
}
|
74
src/pplib/include/threads.h
Normal file
74
src/pplib/include/threads.h
Normal file
|
@ -0,0 +1,74 @@
|
|||
/*******************************************************************************
|
||||
* This file is part of "Patrick's Programming Library", Version 7 (PPL7).
|
||||
* Web: http://www.pfp.de/ppl/
|
||||
*
|
||||
* $Author$
|
||||
* $Revision$
|
||||
* $Date$
|
||||
* $Id$
|
||||
*
|
||||
*******************************************************************************
|
||||
* Copyright (c) 2013, Patrick Fedick <patrick@pfp.de>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER AND CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*******************************************************************************/
|
||||
|
||||
#include "prolog.h"
|
||||
#ifdef HAVE_STDIO_H
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
#ifdef HAVE_STDARG_H
|
||||
#include <stdarg.h>
|
||||
#endif
|
||||
|
||||
#include "ppl7.h"
|
||||
|
||||
|
||||
namespace ppl7 {
|
||||
|
||||
|
||||
typedef struct tagThreadData {
|
||||
ppluint64 threadId;
|
||||
#ifdef _WIN32
|
||||
HANDLE thread;
|
||||
DWORD dwThreadID;
|
||||
#elif defined HAVE_PTHREADS
|
||||
pthread_t thread;
|
||||
pthread_attr_t attr;
|
||||
#else
|
||||
int thread;
|
||||
#endif
|
||||
void (*mysql_thread_end)();
|
||||
// Bit 0: Thread hat MySQL benutzt
|
||||
void *clientData;
|
||||
} THREADDATA;
|
||||
|
||||
THREADDATA * GetThreadData();
|
||||
|
||||
|
||||
} // EOF namespace ppl7
|
Loading…
Add table
Add a link
Reference in a new issue