ZenLib/0000775000000000000000000000000012615631146010746 5ustar rootrootZenLib/debian/0000775000000000000000000000000012615631146012170 5ustar rootrootZenLib/debian/libzen-dev.dirs0000664000000000000000000000030012615631146015103 0ustar rootrootusr/lib usr/lib/pkgconfig usr/include/ZenLib usr/include/ZenLib/HTTP_Client usr/include/ZenLib/Format/Html usr/include/ZenLib/Format/Http usr/share/doc/libzen-dev usr/share/doc/libzen-dev/Doc ZenLib/debian/libzen-doc.docs0000664000000000000000000000003012615631146015061 0ustar rootrootDocumentation.html Doc/ ZenLib/debian/libzen0.install0000664000000000000000000000002512615631146015120 0ustar rootroot/usr/lib/*/lib*.so.* ZenLib/debian/compat0000664000000000000000000000000212615631146013366 0ustar rootroot9 ZenLib/debian/autoreconf0000664000000000000000000000002412615631146014254 0ustar rootrootProject/GNU/Library ZenLib/debian/copyright0000664000000000000000000001505112615631146014125 0ustar rootrootFormat: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: libzen Upstream-Contact: MediaArea.net SARL Source: http://zenlib.sf.net Files: * Copyright: 2002-2011, MediaArea.net SARL License: Zlib Files: Source/ZenLib/int128* Copyright: 2005, Jan Ringos 2007-2011, MediaArea.net SARL License: Zlib Files: Source/ZenLib/Base64/base64.h Copyright: 2002, Markus Ewald License: Zlib Files: Source/ZenLib/HTTP_Client/* Copyright: 2006, Eitan Michaelson License: Zlib Files: Source/ZenLib/TinyXml/* Copyright: 2000-2006, Lee Thomason (www.grinninglizard.com) License: Zlib Comment: Bundled copy of TinyXML Files: Source/ZenLib/PreComp.cpp Source/ZenLib/PreComp.h Copyright: 2006-2011, MediaArea.net SARL License: LGPL-3+ Files: Source/MD5/* Copyright: Public Domain License: public-domain Files: Source/ZenLib/HTTP_Client/HTTPClientWrapper.* Copyright: 2005-2006, Eitan Michaelson License: Zlib Files: Source/ZenLib/HTTP_Client/HTTPClientAuth.h Source/ZenLib/HTTP_Client/HTTPClientAuth.c Copyright: 2005, Eitan Michaelson 2009, Internet Society License: Zlib and rfc Comment: Some functions in these files have been lifted from RFC2617 Files: debian/* Copyright: 2009, MediaArea.net SARL 2012, Chow Loong Jin License: GPL-3+ This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. . This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. . You should have received a copy of the GNU General Public License along with this program. If not, see . . On Debian systems, the full text of this license can be found in /usr/share/common-licenses/GPL-3. License: Zlib This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. . Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: . 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. License: rfc By submission of a Contribution, each person actually submitting the Contribution, and each named co-Contributor, is deemed to agree to the following terms and conditions, and to grant the following rights, on his or her own behalf and on behalf of the organization the Contributor represents or is sponsored by (if any) when submitting the Contribution. . a. To the extent that a Contribution or any portion thereof is protected by copyright and other rights of authorship, the Contributor, and each named co-Contributor, and the organization he or she represents or is sponsored by (if any) grant a perpetual, irrevocable, non-exclusive, royalty-free, world-wide right and license to the ISOC and the IETF under all intellectual property rights in the Contribution: . (A) to copy, publish, display, and distribute the Contribution as part of the IETF Standards Process or in an Internet-Draft, . (B) to prepare or allow the preparation of translations of the Contribution into languages other than English, . (C) unless explicitly disallowed in the notices contained in a Contribution [as per Section 5.2 below], to prepare derivative works (other than translations) that are based on or incorporate all or part of the Contribution, or comment upon it, within the IETF Standards Process. The license to such derivative works not granting the ISOC and the IETF any more rights than the license to the original Contribution, . (D) to reproduce any trademarks, service marks or trade names which are included in the Contribution solely in connection with the reproduction, distribution or publication of the Contribution and derivative works thereof as permitted by this paragraph. When reproducing Contributions, the IETF will preserve trademark and service mark identifiers used by the Contributor of the Contribution, including (TM) and (R) where appropriate, and . (E) to extract, copy, publish, display, distribute, modify and incorporate into other works, for any purpose (and not limited to use within the IETF Standards Process) any executable code or code fragments that are included in any IETF Document (such as MIB and PIB modules), subject to the requirements of Section 5 (it also being understood that the licenses granted under this paragraph (E) shall not be deemed to grant any right under any patent, patent application or other similar intellectual property right disclosed by the Contributor under [RFC3979]). License: LGPL-3+ This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version. . This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. . You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . . On Debian systems, the full text of this license can be found in /usr/share/common-licenses/LGPL-3. License: public-domain This code implements the MD5 message-digest algorithm. The algorithm is due to Ron Rivest. This code was written by Colin Plumb in 1993, no copyright is claimed. This code is in the public domain; do with it what you wish. ZenLib/debian/libzen0.docs0000664000000000000000000000001312615631146014377 0ustar rootrootReadMe.txt ZenLib/debian/control0000664000000000000000000000336512615631146013602 0ustar rootrootSource: libzen Priority: optional Maintainer: MediaArea.net SARL Build-Depends: debhelper (>= 9), dh-autoreconf, doxygen, tofrodos Standards-Version: 3.9.6 Section: libs Homepage: http://mediainfo.sourceforge.net Vcs-Git: https://github.com/MediaArea/ZenLib.git Vcs-Browser: https://github.com/MediaArea/ZenLib Package: libzen-dev Section: libdevel Architecture: any Pre-Depends: ${misc:Pre-Depends} Depends: libzen0 (= ${binary:Version}), ${misc:Depends} Description: ZenLib C++ utility library -- development files ZenLib is a C++ utility library. It includes classes for handling strings, configuration, bit streams, threading, translation, and cross-platform operating system functions. . This package contains the headers required for compiling applications/libraries which use this library. Package: libzen0 Architecture: any Multi-Arch: same Pre-Depends: ${misc:Pre-Depends} Depends: ${shlibs:Depends}, ${misc:Depends} Description: ZenLib C++ utility library -- runtime ZenLib is a C++ utility library. It includes classes for handling strings, configuration, bit streams, threading, translation, and cross-platform operating system functions. . This package contains the shared library needed for running applications which use this library. Package: libzen-doc Section: doc Architecture: all Depends: ${shlibs:Depends}, ${misc:Depends} Description: ZenLib C++ utility library -- documentation ZenLib is a C++ utility library. It includes classes for handling strings, configuration, bit streams, threading, translation, and cross-platform operating system functions. . This package contains the Doxygen generated API reference for developing applications/libraries using this library. ZenLib/debian/libzen-dev.links0000664000000000000000000000007512615631146015273 0ustar rootroot/usr/include/tinyxml.h /usr/include/ZenLib/TinyXml/tinyxml.h ZenLib/debian/changelog0000664000000000000000000001236112615631146014045 0ustar rootrootlibzen (0.4.32) experimental; urgency=medium * Upstream version 0.4.32 -- MediaArea Mon, 02 Nov 2015 10:30:00 +0100 libzen (0.4.32) experimental; urgency=medium * [374490a] Imported Upstream version 0.4.32 * [045cf87] Drop zenlib-missed-cmake-files.patch. Applied upstream * [2ae0146] Specify -B when using dh_auto_* Debhelper's cmake subsystem prefers to use out-of-tree building, at obj-${DEB_HOST_GNU_TYPE}, but this is an implementation detail we shouldn't rely on. So, explicitly set the builddir instead so that we know where to find the .pc file. * [1b2b7e9] Patch CMakeLists to use GNUInstallDirs. This gives us automatic multiarch support. * [3e9fa36] Update libzen-dev.install to look for .pc in debian/tmp -- Chow Loong Jin Thu, 16 Apr 2015 12:15:44 +0800 libzen (0.4.30-2) UNRELEASED; urgency=low * [4d65fb4] Use cmake * [8b3e390] Re-add missing cmake files in a patch. Thanks to Ivan Romanov * [a6c4410] Mangle the cmake .pc, not the autofoo one -- Chow Loong Jin Thu, 16 Apr 2015 12:09:44 +0800 libzen (0.4.30-1) experimental; urgency=medium * [0c54249] Update Vcs-* fields libzen resides in pkg-multimedia now, not in collab-maint. Thanks to Thomas Otto * [58c8a65] Imported Upstream version 0.4.30 * [283c9f8] Update symbols file * [3dfbf94] Install .pc file to multiarch directory * [c0f040e] No-change bump of Standard-Version to 3.9.6 -- Chow Loong Jin Sat, 22 Nov 2014 10:46:21 +0800 libzen (0.4.29-1) unstable; urgency=low * [27b1766] Imported Upstream version 0.4.29 * [de7c824] Fix dep5 field name typo -- Chow Loong Jin Wed, 15 May 2013 21:28:44 +0800 libzen (0.4.28-2) experimental; urgency=low * [c0b2e49] Fix unlisted std:: symbol in libzen0.symbols (Closes: #701314) * [32d1a5b] Bump Standards-Version to 3.9.4 -- Chow Loong Jin Sun, 24 Feb 2013 01:05:22 +0800 libzen (0.4.28-1) experimental; urgency=low * [0c202c7] Imported Upstream version 0.4.28 -- Chow Loong Jin Sun, 19 Aug 2012 19:39:18 +0800 libzen (0.4.27-2) unstable; urgency=low * [6704d62] Ignore inline ToZtring symbols. This fixes build failures arising from spurious ToZtring symbols appearing when they get uninlined on certain architectures. * [25a304e] Sort libzen0.symbols -- Chow Loong Jin Sun, 03 Jun 2012 16:49:28 +0800 libzen (0.4.27-1) unstable; urgency=low * [735e67f] Imported Upstream version 0.4.27 * [0816384] Call dpkg-gensymbols with -c4. This ensures the symbols file is always kept up to date. * [4399009] Update optional symbols regex for std:: functions * [cb88073] Add --parallel to dh invocation -- Chow Loong Jin Sun, 03 Jun 2012 13:33:44 +0800 libzen (0.4.26-1) unstable; urgency=low * [192a9e3] Imported Upstream version 0.4.26: - Better support of machines lacking of std::stringstream - Better support of machines requesting explicit stdc++ library link option (e.g. some ARM embedded devices) * [1122615] Bump debhelper build-dep version to 9 * [0ef5511] Bump Standards-Version to 3.9.3 - Update copyright format URL -- Chow Loong Jin Sun, 22 Apr 2012 18:14:20 +0800 libzen (0.4.25-1) UNRELEASED; urgency=low * [5cb095b] Update watch url * [8bc5267] Imported Upstream version 0.4.25: + Fast bitstream parser + Removing Win9X detection on 64-bit CPU + Ztring: integer to text conversion with radix=2 + Updated Linux compilation scripts * [e1dc5fd] Add missing clause to zlib license -- Chow Loong Jin Fri, 30 Mar 2012 00:42:53 +0800 libzen (0.4.24-2) unstable; urgency=low * [15eb4bc] Remove Doxygen-generated files during clean. This fixes issues with the package being built twice. -- Chow Loong Jin Sun, 29 Jan 2012 06:11:26 +0800 libzen (0.4.24-1) unstable; urgency=low * [9fccad3] Imported Upstream version 0.4.24 * [9bbc628] Drop all patches -- applied upstream * [931d09d] Drop removed paths from .install * [586970b] Use download.mediaarea.net in watchfile * [a35bfce] Drop gbp.conf. Use tgz from download.mediaarea.net instead * [003e14d] Use download.mediaarea.net in watchfile -- Chow Loong Jin Wed, 25 Jan 2012 03:42:26 +0800 libzen (0.4.23-4) unstable; urgency=low * [75c6135] Fix NEED_SIZET patch to avoid 32-bit breakage. Thanks to Peter Green (Closes: #656717) * [1ae30af] Install arch-specific libzenconfig.h to libzen-dev -- Chow Loong Jin Sun, 22 Jan 2012 15:26:40 +0800 libzen (0.4.23-3) unstable; urgency=low * [773397c] Add patch to fix libmediainfo FTBFS on s390 -- Chow Loong Jin Fri, 20 Jan 2012 20:09:30 +0800 libzen (0.4.23-2) unstable; urgency=low * [ec1ccfa] Make long double symbols replaceable with __float128b. This fixes build issues with powerpc, sparc and s390(x) -- Chow Loong Jin Fri, 20 Jan 2012 11:53:42 +0800 libzen (0.4.23-1) unstable; urgency=low * Initial release (Closes: #654185) -- Chow Loong Jin Mon, 02 Jan 2012 01:49:36 +0800 ZenLib/debian/libzen-dev.install0000664000000000000000000000046212615631146015621 0ustar rootroot/usr/lib/*/lib*.so Project/GNU/Library/libzen.pc /usr/lib/pkgconfig Source/ZenLib/*.h /usr/include/ZenLib/ Source/ZenLib/HTTP_Client/*.h /usr/include/ZenLib/HTTP_Client Source/ZenLib/Format/Html/*.h /usr/include/ZenLib/Format/Html Source/ZenLib/Format/Http/*.h /usr/include/ZenLib/Format/Http ZenLib/debian/source/0000775000000000000000000000000012615631146013470 5ustar rootrootZenLib/debian/source/format0000664000000000000000000000001512615631146014677 0ustar rootroot3.0 (native) ZenLib/debian/libzen0.dirs0000664000000000000000000000003612615631146014415 0ustar rootrootusr/lib usr/share/doc/libzen0 ZenLib/debian/libzen0.symbols0000664000000000000000000007443012615631146015155 0ustar rootrootlibzen.so.0 libzen0 #MINVER# (c++|regex)"ZenLib::File::Read\(unsigned char\*, unsigned (int|long)\)@Base" 0.4.23 (c++|regex)"ZenLib::File::Write\(unsigned char const\*, unsigned (int|long)\)@Base" 0.4.23 (c++|regex)"ZenLib::InfoMap::Get\(ZenLib::Ztring const&, unsigned (int|long)\) const@Base" 0.4.23 (c++|regex)"ZenLib::InfoMap::Get\(ZenLib::Ztring const&, unsigned (int|long), ZenLib::Ztring const&, unsigned (int|long)\) const@Base" 0.4.23 (c++|regex)"ZenLib::InfoMap::Separator_Set\(unsigned (int|long), ZenLib::Ztring const&\)@Base" 0.4.23 (c++|regex)"ZenLib::int128::int128\((long double|__float128) const&\)@Base" 0.4.23 (c++|regex)"ZenLib::Thread::Sleep\(unsigned (int|long)\)@Base" 0.4.23 (c++|regex)"ZenLib::Translation::Separator_Set\(unsigned (int|long), ZenLib::Ztring const&\)@Base" 0.4.23 (c++|regex)"ZenLib::uint128::uint128\((long double|__float128) const&\)@Base" 0.4.23 (c++|regex)"ZenLib::Ztring::Date_From_String\(char const\*, unsigned (int|long)\)@Base" 0.4.23 (c++|regex)"ZenLib::Ztring::FindAndReplace\(std::basic_string, std::allocator > const&, std::basic_string, std::allocator > const&, unsigned (int|long), ZenLib::ztring_t\)@Base" 0.4.23 (c++|regex)"ZenLib::Ztring::From_ISO_8859_1\(char const\*, unsigned (int|long), unsigned (int|long)\)@Base" 0.4.23 (c++|regex)"ZenLib::Ztring::From_ISO_8859_2\(char const\*, unsigned (int|long), unsigned (int|long)\)@Base" 0.4.23 (c++|regex)"ZenLib::Ztring::From_Local\(char const\*, unsigned (int|long), unsigned (int|long)\)@Base" 0.4.23 (c++|regex)"ZenLib::Ztring::From_Number\((long double|__float128), unsigned char, ZenLib::ztring_t\)@Base" 0.4.23 (c++|regex)"ZenLib::Ztring::From_Unicode\(wchar_t const\*, unsigned (int|long), unsigned (int|long)\)@Base" 0.4.23 (c++|regex)"ZenLib::Ztring::From_UTF16BE\(char const\*, unsigned (int|long), unsigned (int|long)\)@Base" 0.4.23 (c++|regex)"ZenLib::Ztring::From_UTF16\(char const\*, unsigned (int|long), unsigned (int|long)\)@Base" 0.4.23 (c++|regex)"ZenLib::Ztring::From_UTF16LE\(char const\*, unsigned (int|long), unsigned (int|long)\)@Base" 0.4.23 (c++|regex)"ZenLib::Ztring::From_UTF8\(char const\*, unsigned (int|long), unsigned (int|long)\)@Base" 0.4.23 (c++|regex)"ZenLib::ZtringList::Find\(ZenLib::Ztring const&, unsigned (int|long), ZenLib::Ztring const&, ZenLib::ztring_t\) const@Base" 0.4.23 (c++|regex)"ZenLib::ZtringListList::Delete1\(unsigned (int|long)\)@Base" 0.4.23 (c++|regex)"ZenLib::ZtringListList::Delete\(ZenLib::Ztring const&, unsigned (int|long), ZenLib::Ztring const&, ZenLib::ztring_t\)@Base" 0.4.23 (c++|regex)"ZenLib::ZtringListList::Find_Filled\(unsigned (int|long), unsigned (int|long)\) const@Base" 0.4.23 (c++|regex)"ZenLib::ZtringListList::FindValue\(ZenLib::Ztring const&, unsigned (int|long), unsigned (int|long), unsigned (int|long), ZenLib::Ztring const&, ZenLib::ztring_t\) const@Base" 0.4.23 (c++|regex)"ZenLib::ZtringListList::Find\(ZenLib::Ztring const&, unsigned (int|long), unsigned (int|long)\) const@Base" 0.4.23 (c++|regex)"ZenLib::ZtringListList::Find\(ZenLib::Ztring const&, unsigned (int|long), unsigned (int|long), ZenLib::Ztring const&, ZenLib::ztring_t\) const@Base" 0.4.23 (c++|regex)"ZenLib::ZtringListList::Insert1\(ZenLib::Ztring const&, unsigned (int|long)\)@Base" 0.4.23 (c++|regex)"ZenLib::ZtringListList::Max_Set\(unsigned (int|long), unsigned (int|long)\)@Base" 0.4.23 (c++|regex)"ZenLib::ZtringListList::operator\(\)\(unsigned (int|long)\)@Base" 0.4.23 (c++|regex)"ZenLib::ZtringListList::operator\(\)\(unsigned (int|long), unsigned (int|long)\)@Base" 0.4.23 (c++|regex)"ZenLib::ZtringListList::operator\(\)\(ZenLib::Ztring const&, unsigned (int|long), unsigned (int|long)\)@Base" 0.4.23 (c++|regex)"ZenLib::ZtringListList::Read1\(unsigned (int|long)\) const@Base" 0.4.23 (c++|regex)"ZenLib::ZtringListList::Read\(unsigned (int|long)\) const@Base" 0.4.23 (c++|regex)"ZenLib::ZtringListList::Read\(unsigned (int|long), unsigned (int|long)\) const@Base" 0.4.23 (c++|regex)"ZenLib::ZtringListList::Read\(ZenLib::Ztring const&, unsigned (int|long)\) const@Base" 0.4.23 (c++|regex)"ZenLib::ZtringListList::Read\(ZenLib::Ztring const&, unsigned (int|long), unsigned (int|long)\) const@Base" 0.4.23 (c++|regex)"ZenLib::ZtringListList::Read\(ZenLib::Ztring const&, ZenLib::Ztring const&, unsigned (int|long)\) const@Base" 0.4.23 (c++|regex)"ZenLib::ZtringListList::Read\(ZenLib::Ztring const&, ZenLib::Ztring const&, unsigned (int|long), unsigned (int|long)\) const@Base" 0.4.23 (c++|regex)"ZenLib::ZtringListList::Separator_Set\(unsigned (int|long), ZenLib::Ztring const&\)@Base" 0.4.23 (c++|regex)"ZenLib::ZtringListList::Sort\(unsigned (int|long), ZenLib::ztring_t\)@Base" 0.4.23 (c++|regex)"ZenLib::ZtringListList::SubSheet\(ZenLib::Ztring const&, unsigned (int|long), unsigned (int|long), ZenLib::Ztring const&, ZenLib::ztring_t\) const@Base" 0.4.23 (c++|regex)"ZenLib::ZtringListList::Swap1\(unsigned (int|long), unsigned (int|long)\)@Base" 0.4.23 (c++|regex)"ZenLib::ZtringListList::Swap\(unsigned (int|long), unsigned (int|long)\)@Base" 0.4.23 (c++|regex)"ZenLib::ZtringListList::Write\(ZenLib::Ztring const&, unsigned (int|long), unsigned (int|long)\)@Base" 0.4.23 (c++|regex)"ZenLib::ZtringListList::Write\(ZenLib::ZtringList const&, unsigned (int|long)\)@Base" 0.4.23 (c++|regex)"ZenLib::ZtringList::Max_Set\(unsigned (int|long), unsigned (int|long)\)@Base" 0.4.23 (c++|regex)"ZenLib::ZtringList::operator\(\)\(unsigned (int|long)\)@Base" 0.4.23 (c++|regex)"ZenLib::ZtringList::Read\(unsigned (int|long)\) const@Base" 0.4.23 (c++|regex)"ZenLib::ZtringList::Separator_Set\(unsigned (int|long), ZenLib::Ztring const&\)@Base" 0.4.23 (c++|regex)"ZenLib::ZtringList::Swap\(unsigned (int|long), unsigned (int|long)\)@Base" 0.4.23 (c++|regex)"ZenLib::ZtringList::Write\(ZenLib::Ztring const&, unsigned (int|long)\)@Base" 0.4.23 (c++|regex)"ZenLib::Ztring::operator\(\)\(unsigned (int|long)\)@Base" 0.4.23 (c++|regex)"ZenLib::Ztring::SubString\(std::basic_string, std::allocator > const&, std::basic_string, std::allocator > const&, unsigned (int|long), ZenLib::ztring_t\) const@Base" 0.4.23 (c++)"typeinfo for ZenLib::Thread@Base" 0.4.23 (c++)"typeinfo name for ZenLib::Thread@Base" 0.4.23 (c++)"vtable for ZenLib::Thread@Base" 0.4.23 (c++)"ZenLib::BigEndian2float16(char const*)@Base" 0.4.23 (c++)"ZenLib::BigEndian2float32(char const*)@Base" 0.4.23 (c++)"ZenLib::BigEndian2float64(char const*)@Base" 0.4.23 (c++)"ZenLib::BigEndian2float80(char const*)@Base" 0.4.23 (c++)"ZenLib::BigEndian2int128u(char const*)@Base" 0.4.23 (c++)"ZenLib::BigEndian2int16s(char const*)@Base" 0.4.23 (c++)"ZenLib::BigEndian2int16u(char const*)@Base" 0.4.23 (c++)"ZenLib::BigEndian2int24s(char const*)@Base" 0.4.23 (c++)"ZenLib::BigEndian2int24u(char const*)@Base" 0.4.23 (c++)"ZenLib::BigEndian2int32s(char const*)@Base" 0.4.23 (c++)"ZenLib::BigEndian2int32u(char const*)@Base" 0.4.23 (c++)"ZenLib::BigEndian2int40s(char const*)@Base" 0.4.23 (c++)"ZenLib::BigEndian2int40u(char const*)@Base" 0.4.23 (c++)"ZenLib::BigEndian2int48s(char const*)@Base" 0.4.23 (c++)"ZenLib::BigEndian2int48u(char const*)@Base" 0.4.23 (c++)"ZenLib::BigEndian2int56s(char const*)@Base" 0.4.23 (c++)"ZenLib::BigEndian2int56u(char const*)@Base" 0.4.23 (c++)"ZenLib::BigEndian2int64s(char const*)@Base" 0.4.23 (c++)"ZenLib::BigEndian2int64u(char const*)@Base" 0.4.23 (c++)"ZenLib::BigEndian2int8s(char const*)@Base" 0.4.23 (c++)"ZenLib::BigEndian2int8u(char const*)@Base" 0.4.23 (c++)"ZenLib::CriticalSection::~CriticalSection()@Base" 0.4.23 (c++)"ZenLib::CriticalSection::CriticalSection()@Base" 0.4.23 (c++)"ZenLib::CriticalSection::Enter()@Base" 0.4.23 (c++)"ZenLib::CriticalSection::Leave()@Base" 0.4.23 (c++)"ZenLib::Dir::Create(ZenLib::Ztring const&)@Base" 0.4.23 (c++)"ZenLib::Directory_Select_Caption@Base" 0.4.23 (c++)"ZenLib::Dir::Exists(ZenLib::Ztring const&)@Base" 0.4.23 (c++)"ZenLib::Dir::GetAllFileNames(ZenLib::Ztring const&, ZenLib::Dir::dirlist_t)@Base" 0.4.23 (c++)"ZenLib::EmptyZtring@Base" 0.4.23 (c++)"ZenLib::EOL@Base" 0.4.23 (c++)"ZenLib::File::Close()@Base" 0.4.23 (c++)"ZenLib::File::Copy(ZenLib::Ztring const&, ZenLib::Ztring const&, bool)@Base" 0.4.23 (c++)"ZenLib::File::Created_Get()@Base" 0.4.23 (c++)"ZenLib::File::Created_Get(ZenLib::Ztring const&)@Base" 0.4.23 (c++)"ZenLib::File::Created_Local_Get()@Base" 0.4.23 (c++)"ZenLib::File::Create(ZenLib::Ztring const&, bool)@Base" 0.4.23 (c++)"ZenLib::File::Delete(ZenLib::Ztring const&)@Base" 0.4.23 (c++)"ZenLib::File::Exists(ZenLib::Ztring const&)@Base" 0.4.23 (c++)"ZenLib::File::~File()@Base" 0.4.23 (c++)"ZenLib::File::File()@Base" 0.4.23 (c++)"ZenLib::File::File(ZenLib::Ztring, ZenLib::File::access_t)@Base" 0.4.23 (c++)"ZenLib::File::GoTo(long long, ZenLib::File::move_t)@Base" 0.4.23 (c++)"ZenLib::File::Modified_Get()@Base" 0.4.23 (c++)"ZenLib::File::Modified_Get(ZenLib::Ztring const&)@Base" 0.4.23 (c++)"ZenLib::File::Modified_Local_Get()@Base" 0.4.23 (c++)"ZenLib::File::Move(ZenLib::Ztring const&, ZenLib::Ztring const&, bool)@Base" 0.4.23 (c++)"ZenLib::FileName::Extension_Get() const@Base" 0.4.23 (c++)"ZenLib::FileName::Extension_Set(ZenLib::Ztring const&)@Base" 0.4.23 (c++)"ZenLib::FileName::Name_Get() const@Base" 0.4.23 (c++)"ZenLib::FileName::Name_Set(ZenLib::Ztring const&)@Base" 0.4.23 (c++)"ZenLib::FileName::Path_Get() const@Base" 0.4.23 (c++)"ZenLib::FileName_PathSeparator@Base" 0.4.23 (c++)"ZenLib::FileName::Path_Set(ZenLib::Ztring const&)@Base" 0.4.23 (c++)"ZenLib::FileName::TempFileName_Create(ZenLib::Ztring const&)@Base" 0.4.23 (c++)"ZenLib::File::Opened_Get()@Base" 0.4.23 (c++)"ZenLib::File::Open(std::basic_string, std::allocator > const&, ZenLib::File::access_t)@Base" 0.4.23 (c++)"ZenLib::File::Position_Get()@Base" 0.4.23 (c++)"ZenLib::File::Size_Get()@Base" 0.4.23 (c++)"ZenLib::File::Size_Get(ZenLib::Ztring const&)@Base" 0.4.23 (c++)"ZenLib::File::Truncate(unsigned long long)@Base" 0.4.23 (c++)"ZenLib::File::Write(ZenLib::Ztring const&)@Base" 0.4.23 (c++)"ZenLib::float32_int32s(float, bool)@Base" 0.4.23 (c++)"ZenLib::float32_int64s(float, bool)@Base" 0.4.23 (c++)"ZenLib::float64_int32s(double, bool)@Base" 0.4.23 (c++)"ZenLib::float64_int64s(double, bool)@Base" 0.4.23 (c++)"ZenLib::Format::Html::Handler::CleanUp()@Base" 0.4.23 (c++)"ZenLib::Format::Html::Handler::Handler()@Base" 0.4.23 (c++)"ZenLib::Format::Html::Request::~Request()@Base" 0.4.23 (c++)"ZenLib::Format::Html::Request::Request()@Base" 0.4.23 (c++)"ZenLib::Format::Html::Request::Request(ZenLib::Format::Html::Request const&)@Base" 0.4.23 (c++)"ZenLib::Format::Http::Char2Hex(unsigned char)@Base" 0.4.23 (c++)"ZenLib::Format::Http::Char2Hex(wchar_t)@Base" 0.4.23 (c++)"ZenLib::Format::Http::Cookie::~Cookie()@Base" 0.4.23 (c++)"ZenLib::Format::Http::Cookies::Cookies()@Base" 0.4.23 (c++)"ZenLib::Format::Http::Cookies::Create_Lines(std::basic_ostream >&)@Base" 0.4.23 (c++)"ZenLib::Format::Http::Cookies::Set(std::basic_string, std::allocator > const&, std::basic_string, std::allocator > const&, long, std::basic_string, std::allocator > const&, std::basic_string, std::allocator > const&, bool)@Base" 0.4.23 (c++)"ZenLib::Format::Http::EmptyString@Base" 0.4.23 (c++)"ZenLib::Format::Http::Handler::Handler()@Base" 0.4.23 (c++)"ZenLib::Format::Http::Hex2Char(unsigned char)@Base" 0.4.23 (c++)"ZenLib::Format::Http::Hex2Char(wchar_t)@Base" 0.4.23 (c++)"ZenLib::Format::Http::Request::Http_Begin(std::basic_istream >&, std::basic_ostream >&)@Base" 0.4.23 (c++)"ZenLib::Format::Http::Request::Http_End(std::basic_ostream >&)@Base" 0.4.23 (c++)"ZenLib::Format::Http::Request::~Request()@Base" 0.4.23 (c++)"ZenLib::Format::Http::Request::Request()@Base" 0.4.23 (c++)"ZenLib::Format::Http::Request::Request(ZenLib::Format::Http::Request const&)@Base" 0.4.23 (c++)"ZenLib::Format::Http::TrimLeft(std::basic_string, std::allocator >&, char)@Base" 0.4.23 (c++)"ZenLib::Format::Http::URL_Encoded_Decode(std::basic_string, std::allocator > const&)@Base" 0.4.23 (c++)"ZenLib::Format::Http::URL_Encoded_Decode(std::basic_string, std::allocator > const&)@Base" 0.4.23 (c++)"ZenLib::Format::Http::URL_Encoded_Encode(std::basic_string, std::allocator > const&)@Base" 0.4.23 (c++)"ZenLib::Format::Http::URL_Encoded_Encode(std::basic_string, std::allocator > const&)@Base" 0.4.23 (c++)"ZenLib::InfoMap::InfoMap()@Base" 0.4.23 (c++)"ZenLib::InfoMap::InfoMap(char const*)@Base" 0.4.23 (c++)"ZenLib::InfoMap::InfoMap(wchar_t const*)@Base" 0.4.23 (c++)"ZenLib::InfoMap::InfoMap(ZenLib::Ztring const&)@Base" 0.4.23 (c++)"ZenLib::InfoMap::Write(ZenLib::Ztring const&)@Base" 0.4.23 (c++)"ZenLib::int128::bit(unsigned int, bool)@Base" 0.4.23 (c++)"ZenLib::int128::bit(unsigned int) const@Base" 0.4.23 (c++)"ZenLib::int128::div(ZenLib::int128 const&, ZenLib::int128&) const@Base" 0.4.23 (c++)"ZenLib::int128::int128(char const*)@Base" 0.4.23 (c++)"ZenLib::int128::int128(double const&)@Base" 0.4.23 (c++)"ZenLib::int128::int128(float)@Base" 0.4.23 (c++)"ZenLib::int128::operator--()@Base" 0.4.23 (c++)"ZenLib::int128::operator++()@Base" 0.4.23 (c++)"ZenLib::int128::operator~() const@Base" 0.4.23 (c++)"ZenLib::int128::operator-() const@Base" 0.4.23 (c++)"ZenLib::int128::operator!() const@Base" 0.4.23 (c++)"ZenLib::int128::operator--(int)@Base" 0.4.23 (c++)"ZenLib::int128::operator++(int)@Base" 0.4.23 (c++)"ZenLib::int128::operator<<=(unsigned int)@Base" 0.4.23 (c++)"ZenLib::int128::operator>>=(unsigned int)@Base" 0.4.23 (c++)"ZenLib::int128::operator^=(ZenLib::int128 const&)@Base" 0.4.23 (c++)"ZenLib::int128::operator|=(ZenLib::int128 const&)@Base" 0.4.23 (c++)"ZenLib::int128::operator*=(ZenLib::int128 const&)@Base" 0.4.23 (c++)"ZenLib::int128::operator&=(ZenLib::int128 const&)@Base" 0.4.23 (c++)"ZenLib::int128::operator+=(ZenLib::int128 const&)@Base" 0.4.23 (c++)"ZenLib::int128::toDouble() const@Base" 0.4.23 (c++)"ZenLib::int128::toFloat() const@Base" 0.4.23 (c++)"ZenLib::int128::toLongDouble() const@Base" 0.4.23 (c++)"ZenLib::int128::toString(unsigned int) const@Base" 0.4.23 (c++)"ZenLib::int128u2BigEndian(char*, ZenLib::uint128)@Base" 0.4.23 (c++)"ZenLib::int128u2LittleEndian(char*, ZenLib::uint128)@Base" 0.4.23 (c++)"ZenLib::int16s2BigEndian(char*, short)@Base" 0.4.23 (c++)"ZenLib::int16s2LittleEndian(char*, short)@Base" 0.4.23 (c++)"ZenLib::int16u2BigEndian(char*, unsigned short)@Base" 0.4.23 (c++)"ZenLib::int16u2LittleEndian(char*, unsigned short)@Base" 0.4.23 (c++)"ZenLib::int24s2BigEndian(char*, int)@Base" 0.4.23 (c++)"ZenLib::int24s2LittleEndian(char*, int)@Base" 0.4.23 (c++)"ZenLib::int24u2BigEndian(char*, unsigned int)@Base" 0.4.23 (c++)"ZenLib::int24u2LittleEndian(char*, unsigned int)@Base" 0.4.23 (c++)"ZenLib::int32s2BigEndian(char*, int)@Base" 0.4.23 (c++)"ZenLib::int32s2LittleEndian(char*, int)@Base" 0.4.23 (c++)"ZenLib::int32s_int64s(int, unsigned int)@Base" 0.4.23 (c++)"ZenLib::int32s_int64s(long long&, int, unsigned int)@Base" 0.4.23 (c++)"ZenLib::int32u2BigEndian(char*, unsigned int)@Base" 0.4.23 (c++)"ZenLib::int32u2LittleEndian(char*, unsigned int)@Base" 0.4.23 (c++)"ZenLib::int32u_int64u(long long&, unsigned int, unsigned int)@Base" 0.4.23 (c++)"ZenLib::int32u_int64u(unsigned int, unsigned int)@Base" 0.4.23 (c++)"ZenLib::int40s2BigEndian(char*, long long)@Base" 0.4.23 (c++)"ZenLib::int40s2LittleEndian(char*, long long)@Base" 0.4.23 (c++)"ZenLib::int40u2BigEndian(char*, unsigned long long)@Base" 0.4.23 (c++)"ZenLib::int40u2LittleEndian(char*, unsigned long long)@Base" 0.4.23 (c++)"ZenLib::int48s2BigEndian(char*, long long)@Base" 0.4.23 (c++)"ZenLib::int48s2LittleEndian(char*, long long)@Base" 0.4.23 (c++)"ZenLib::int48u2BigEndian(char*, unsigned long long)@Base" 0.4.23 (c++)"ZenLib::int48u2LittleEndian(char*, unsigned long long)@Base" 0.4.23 (c++)"ZenLib::int56s2BigEndian(char*, long long)@Base" 0.4.23 (c++)"ZenLib::int56s2LittleEndian(char*, long long)@Base" 0.4.23 (c++)"ZenLib::int56u2BigEndian(char*, unsigned long long)@Base" 0.4.23 (c++)"ZenLib::int56u2LittleEndian(char*, unsigned long long)@Base" 0.4.23 (c++)"ZenLib::int64s2BigEndian(char*, long long)@Base" 0.4.23 (c++)"ZenLib::int64s2LittleEndian(char*, long long)@Base" 0.4.23 (c++)"ZenLib::int64s_int32s(long long, int&, unsigned int&)@Base" 0.4.23 (c++)"ZenLib::int64u2BigEndian(char*, unsigned long long)@Base" 0.4.23 (c++)"ZenLib::int64u2LittleEndian(char*, unsigned long long)@Base" 0.4.23 (c++)"ZenLib::int64u_int32u(unsigned long long, unsigned int&, unsigned int&)@Base" 0.4.23 (c++)"ZenLib::int8s2BigEndian(char*, signed char)@Base" 0.4.23 (c++)"ZenLib::int8s2LittleEndian(char*, signed char)@Base" 0.4.23 (c++)"ZenLib::int8u2BigEndian(char*, unsigned char)@Base" 0.4.23 (c++)"ZenLib::int8u2LittleEndian(char*, unsigned char)@Base" 0.4.23 (c++)"ZenLib::IsWin9X()@Base" 0.4.23 (c++)"ZenLib::LittleEndian2float16(char const*)@Base" 0.4.23 (c++)"ZenLib::LittleEndian2float32(char const*)@Base" 0.4.23 (c++)"ZenLib::LittleEndian2float64(char const*)@Base" 0.4.23 (c++)"ZenLib::LittleEndian2float80(char const*)@Base" 0.4.23 (c++)"ZenLib::LittleEndian2int128u(char const*)@Base" 0.4.23 (c++)"ZenLib::LittleEndian2int16s(char const*)@Base" 0.4.23 (c++)"ZenLib::LittleEndian2int16u(char const*)@Base" 0.4.23 (c++)"ZenLib::LittleEndian2int24s(char const*)@Base" 0.4.23 (c++)"ZenLib::LittleEndian2int24u(char const*)@Base" 0.4.23 (c++)"ZenLib::LittleEndian2int32s(char const*)@Base" 0.4.23 (c++)"ZenLib::LittleEndian2int32u(char const*)@Base" 0.4.23 (c++)"ZenLib::LittleEndian2int40s(char const*)@Base" 0.4.23 (c++)"ZenLib::LittleEndian2int40u(char const*)@Base" 0.4.23 (c++)"ZenLib::LittleEndian2int48s(char const*)@Base" 0.4.23 (c++)"ZenLib::LittleEndian2int48u(char const*)@Base" 0.4.23 (c++)"ZenLib::LittleEndian2int56s(char const*)@Base" 0.4.23 (c++)"ZenLib::LittleEndian2int56u(char const*)@Base" 0.4.23 (c++)"ZenLib::LittleEndian2int64s(char const*)@Base" 0.4.23 (c++)"ZenLib::LittleEndian2int64u(char const*)@Base" 0.4.23 (c++)"ZenLib::LittleEndian2int8s(char const*)@Base" 0.4.23 (c++)"ZenLib::LittleEndian2int8u(char const*)@Base" 0.4.23 (c++)"ZenLib::operator<(ZenLib::int128 const&, ZenLib::int128 const&)@Base" 0.4.23 (c++)"ZenLib::operator==(ZenLib::int128 const&, ZenLib::int128 const&)@Base" 0.4.23 (c++)"ZenLib::operator||(ZenLib::int128 const&, ZenLib::int128 const&)@Base" 0.4.23 (c++)"ZenLib::operator&&(ZenLib::int128 const&, ZenLib::int128 const&)@Base" 0.4.23 (c++)"ZenLib::operator<(ZenLib::uint128 const&, ZenLib::uint128 const&)@Base" 0.4.23 (c++)"ZenLib::operator==(ZenLib::uint128 const&, ZenLib::uint128 const&)@Base" 0.4.23 (c++)"ZenLib::operator||(ZenLib::uint128 const&, ZenLib::uint128 const&)@Base" 0.4.23 (c++)"ZenLib::operator&&(ZenLib::uint128 const&, ZenLib::uint128 const&)@Base" 0.4.23 (c++)"ZenLib::PathSeparator@Base" 0.4.23 (c++)"ZenLib::Shell_Execute(ZenLib::Ztring const&)@Base" 0.4.23 (c++)"ZenLib::Thread::Entry()@Base" 0.4.23 (c++)"ZenLib::Thread::ForceTerminate()@Base" 0.4.23 (c++)"ZenLib::Thread::Internal_Exit()@Base" 0.4.23 (c++)"ZenLib::Thread::IsExited()@Base" 0.4.23 (c++)"ZenLib::Thread::IsRunning()@Base" 0.4.23 (c++)"ZenLib::Thread::IsTerminating()@Base" 0.4.23 (c++)"ZenLib::Thread::Pause()@Base" 0.4.23 (c++)"ZenLib::Thread::RequestTerminate()@Base" 0.4.23 (c++)"ZenLib::Thread::RunAgain()@Base" 0.4.23 (c++)"ZenLib::Thread::Run()@Base" 0.4.23 (c++)"ZenLib::Thread_Start(void*)@Base" 0.4.23 (c++)"ZenLib::Thread::~Thread()@Base" 0.4.23 (c++)"ZenLib::Thread::Thread()@Base" 0.4.23 (c++)"ZenLib::Thread::Yield()@Base" 0.4.23 (c++)"ZenLib::Translation::Get() const@Base" 0.4.23 (c++)"ZenLib::Translation::Get(ZenLib::Ztring const&)@Base" 0.4.23 (c++)"ZenLib::Translation::Get(ZenLib::Ztring const&, ZenLib::Ztring const&)@Base" 0.4.23 (c++)"ZenLib::Translation::Translation()@Base" 0.4.23 (c++)"ZenLib::Translation::Translation(char const*)@Base" 0.4.23 (c++)"ZenLib::Translation::Translation(wchar_t const*)@Base" 0.4.23 (c++)"ZenLib::Translation::Translation(ZenLib::Ztring const&)@Base" 0.4.23 (c++)"ZenLib::Translation::Write(ZenLib::Ztring const&)@Base" 0.4.23 (c++)"ZenLib::Translation::Write(ZenLib::Ztring const&, ZenLib::Ztring const&)@Base" 0.4.23 (c++)"ZenLib::uint128::bit(unsigned int, bool)@Base" 0.4.23 (c++)"ZenLib::uint128::bit(unsigned int) const@Base" 0.4.23 (c++)"ZenLib::uint128::div(ZenLib::uint128 const&, ZenLib::uint128&) const@Base" 0.4.23 (c++)"ZenLib::uint128::operator--()@Base" 0.4.23 (c++)"ZenLib::uint128::operator++()@Base" 0.4.23 (c++)"ZenLib::uint128::operator~() const@Base" 0.4.23 (c++)"ZenLib::uint128::operator-() const@Base" 0.4.23 (c++)"ZenLib::uint128::operator!() const@Base" 0.4.23 (c++)"ZenLib::uint128::operator--(int)@Base" 0.4.23 (c++)"ZenLib::uint128::operator++(int)@Base" 0.4.23 (c++)"ZenLib::uint128::operator<<=(unsigned int)@Base" 0.4.23 (c++)"ZenLib::uint128::operator>>=(unsigned int)@Base" 0.4.23 (c++)"ZenLib::uint128::operator^=(ZenLib::uint128 const&)@Base" 0.4.23 (c++)"ZenLib::uint128::operator|=(ZenLib::uint128 const&)@Base" 0.4.23 (c++)"ZenLib::uint128::operator*=(ZenLib::uint128 const&)@Base" 0.4.23 (c++)"ZenLib::uint128::operator&=(ZenLib::uint128 const&)@Base" 0.4.23 (c++)"ZenLib::uint128::operator+=(ZenLib::uint128 const&)@Base" 0.4.23 (c++)"ZenLib::uint128::toDouble() const@Base" 0.4.23 (c++)"ZenLib::uint128::toFloat() const@Base" 0.4.23 (c++)"ZenLib::uint128::toLongDouble() const@Base" 0.4.23 (c++)"ZenLib::uint128::toString(unsigned int) const@Base" 0.4.23 (c++)"ZenLib::uint128::uint128(char const*)@Base" 0.4.23 (c++)"ZenLib::uint128::uint128(double const&)@Base" 0.4.23 (c++)"ZenLib::uint128::uint128(float)@Base" 0.4.23 (c++)"ZenLib::Ztring::Assign_FromFile(ZenLib::Ztring const&)@Base" 0.4.23 (c++)"ZenLib::Ztring::Compare(ZenLib::Ztring const&, ZenLib::Ztring const&, ZenLib::ztring_t) const@Base" 0.4.23 (c++)"ZenLib::Ztring::Count(ZenLib::Ztring const&, ZenLib::ztring_t) const@Base" 0.4.23 (c++)"ZenLib::Ztring::Date_From_Milliseconds_1601(unsigned long long)@Base" 0.4.23 (c++)"ZenLib::Ztring::Date_From_Numbers(unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char)@Base" 0.4.23 (c++)"ZenLib::Ztring::Date_From_Seconds_1601(unsigned long long)@Base" 0.4.23 (c++)"ZenLib::Ztring::Date_From_Seconds_1900(long long)@Base" 0.4.30 (c++)"ZenLib::Ztring::Date_From_Seconds_1900(unsigned int)@Base" 0.4.30 (c++)"ZenLib::Ztring::Date_From_Seconds_1904(long long)@Base" 0.4.30 (c++)"ZenLib::Ztring::Date_From_Seconds_1904(unsigned int)@Base" 0.4.30 (c++)"ZenLib::Ztring::Date_From_Seconds_1904(unsigned long long)@Base" 0.4.23 (c++)"ZenLib::Ztring::Date_From_Seconds_1970(int)@Base" 0.4.30 (c++)"ZenLib::Ztring::Date_From_Seconds_1970_Local(unsigned int)@Base" 0.4.23 (c++)"ZenLib::Ztring::Date_From_Seconds_1970(long long)@Base" 0.4.30 (c++)"ZenLib::Ztring::Date_From_Seconds_1970(unsigned int)@Base" 0.4.23 (c++)"ZenLib::Ztring::Duration_From_Milliseconds(long long)@Base" 0.4.23 (c++)"ZenLib::Ztring::Duration_From_Milliseconds(unsigned long long)@Base" 0.4.23 (c++)"ZenLib::Ztring::From_BCD(unsigned char)@Base" 0.4.23 (c++)"ZenLib::Ztring::From_CC1(unsigned char)@Base" 0.4.23 (c++)"ZenLib::Ztring::From_CC2(unsigned short)@Base" 0.4.23 (c++)"ZenLib::Ztring::From_CC3(unsigned int)@Base" 0.4.23 (c++)"ZenLib::Ztring::From_CC4(unsigned int)@Base" 0.4.23 (c++)"ZenLib::Ztring::From_GUID(ZenLib::uint128)@Base" 0.4.23 (c++)"ZenLib::Ztring::From_ISO_8859_1(char const*)@Base" 0.4.23 (c++)"ZenLib::Ztring::From_ISO_8859_2(char const*)@Base" 0.4.23 (c++)"ZenLib::Ztring::From_Local(char const*)@Base" 0.4.23 (c++)"ZenLib::Ztring::From_Number(double, unsigned char, ZenLib::ztring_t)@Base" 0.4.23 (c++)"ZenLib::Ztring::From_Number(float, unsigned char, ZenLib::ztring_t)@Base" 0.4.23 (c++)"ZenLib::Ztring::From_Number(int, unsigned char)@Base" 0.4.23 (c++)"ZenLib::Ztring::From_Number(long long, unsigned char)@Base" 0.4.23 (c++)"ZenLib::Ztring::From_Number(short, unsigned char)@Base" 0.4.23 (c++)"ZenLib::Ztring::From_Number(signed char, unsigned char)@Base" 0.4.23 (c++)"ZenLib::Ztring::From_Number(unsigned char, unsigned char)@Base" 0.4.23 (c++)"ZenLib::Ztring::From_Number(unsigned int, unsigned char)@Base" 0.4.23 (c++)"ZenLib::Ztring::From_Number(unsigned long long, unsigned char)@Base" 0.4.23 (c++)"ZenLib::Ztring::From_Number(unsigned short, unsigned char)@Base" 0.4.23 (c++)"ZenLib::Ztring::From_Number(ZenLib::uint128, unsigned char)@Base" 0.4.23 (c++)"ZenLib::Ztring::From_Unicode(wchar_t)@Base" 0.4.30 (c++)"ZenLib::Ztring::From_Unicode(wchar_t const*)@Base" 0.4.23 (c++)"ZenLib::Ztring::From_UTF16BE(char const*)@Base" 0.4.23 (c++)"ZenLib::Ztring::From_UTF16(char const*)@Base" 0.4.23 (c++)"ZenLib::Ztring::From_UTF16LE(char const*)@Base" 0.4.23 (c++)"ZenLib::Ztring::From_UTF8(char const*)@Base" 0.4.23 (c++)"ZenLib::Ztring::From_UUID(ZenLib::uint128)@Base" 0.4.23 (c++)"ZenLib::Ztring::IsNumber() const@Base" 0.4.23 (c++)"ZenLib::Ztring_ISO_8859_2@Base" 0.4.23 (c++)"ZenLib::ZtringListListF::Backup_Count_Set(unsigned char)@Base" 0.4.23 (c++)"ZenLib::ZtringListListF::Backup_Set(bool)@Base" 0.4.23 (c++)"ZenLib::ZtringListListF::Cancel()@Base" 0.4.23 (c++)"ZenLib::ZtringListListF::CFG_Charger()@Base" 0.4.23 (c++)"ZenLib::ZtringListListF::CFG_Sauvegarder()@Base" 0.4.23 (c++)"ZenLib::ZtringListListF::CSV_Charger()@Base" 0.4.23 (c++)"ZenLib::ZtringListListF::CSV_Sauvegarder()@Base" 0.4.23 (c++)"ZenLib::ZtringListListF::Load(ZenLib::Ztring const&)@Base" 0.4.23 (c++)"ZenLib::ZtringListListF::Local_Set(bool)@Base" 0.4.23 (c++)"ZenLib::ZtringListListF::NettoyerEspaces(ZenLib::Ztring&)@Base" 0.4.23 (c++)"ZenLib::ZtringListListF::Save(ZenLib::Ztring const&)@Base" 0.4.23 (c++)"ZenLib::ZtringListListF::ZtringListListF()@Base" 0.4.23 (c++)"ZenLib::ZtringListListF::ZtringListListF(char const*)@Base" 0.4.23 (c++)"ZenLib::ZtringListListF::ZtringListListF_Common()@Base" 0.4.23 (c++)"ZenLib::ZtringListListF::ZtringListListF(wchar_t const*)@Base" 0.4.23 (c++)"ZenLib::ZtringListListF::ZtringListListF(ZenLib::Ztring const&)@Base" 0.4.23 (c++)"ZenLib::ZtringListListF::ZtringListListF(ZenLib::ZtringListList const&)@Base" 0.4.23 (c++)"ZenLib::ZtringListList::operator=(ZenLib::ZtringListList const&)@Base" 0.4.23 (c++)"ZenLib::ZtringListList::operator+=(ZenLib::ZtringListList const&)@Base" 0.4.23 (c++)"ZenLib::ZtringListList::operator==(ZenLib::ZtringListList const&) const@Base" 0.4.23 (c++)"ZenLib::ZtringListList::operator!=(ZenLib::ZtringListList const&) const@Base" 0.4.23 (c++)"ZenLib::ZtringListList::push_back(ZenLib::Ztring const&)@Base" 0.4.23 (c++)"ZenLib::ZtringListList::push_back(ZenLib::ZtringList const&)@Base" 0.4.23 (c++)"ZenLib::ZtringListList::Quote_Set(ZenLib::Ztring const&)@Base" 0.4.23 (c++)"ZenLib::ZtringListList::Read() const@Base" 0.4.23 (c++)"ZenLib::ZtringListList::Write(ZenLib::Ztring const&)@Base" 0.4.23 (c++)"ZenLib::ZtringListList::~ZtringListList()@Base" 0.4.23 (c++)"ZenLib::ZtringListList::ZtringListList()@Base" 0.4.23 (c++)"ZenLib::ZtringListList::ZtringListList(char const*)@Base" 0.4.23 (c++)"ZenLib::ZtringListList::ZtringListList(wchar_t const*)@Base" 0.4.23 (c++)"ZenLib::ZtringListList::ZtringListList(ZenLib::Ztring const&)@Base" 0.4.23 (c++)"ZenLib::ZtringListList::ZtringListList(ZenLib::ZtringListList const&)@Base" 0.4.23 (c++)"ZenLib::ZtringList::MaxStringLength_Get()@Base" 0.4.23 (c++)"ZenLib::ZtringList::operator=(ZenLib::ZtringList const&)@Base" 0.4.23 (c++)"ZenLib::ZtringList::operator+=(ZenLib::ZtringList const&)@Base" 0.4.23 (c++)"ZenLib::ZtringList::operator==(ZenLib::ZtringList const&) const@Base" 0.4.23 (c++)"ZenLib::ZtringList::operator!=(ZenLib::ZtringList const&) const@Base" 0.4.23 (c++)"ZenLib::ZtringList::Quote_Set(ZenLib::Ztring const&)@Base" 0.4.23 (c++)"ZenLib::ZtringList::Read() const@Base" 0.4.23 (c++)"ZenLib::ZtringList::Sort(ZenLib::ztring_t)@Base" 0.4.23 (c++)"ZenLib::ZtringList::Write(ZenLib::Ztring const&)@Base" 0.4.23 (c++)"ZenLib::ZtringList::~ZtringList()@Base" 0.4.23 (c++)"ZenLib::ZtringList::ZtringList()@Base" 0.4.23 (c++)"ZenLib::ZtringList::ZtringList(char const*)@Base" 0.4.23 (c++)"ZenLib::ZtringList::ZtringList(wchar_t const*)@Base" 0.4.23 (c++)"ZenLib::ZtringList::ZtringList(ZenLib::Ztring const&)@Base" 0.4.23 (c++)"ZenLib::ZtringList::ZtringList(ZenLib::ZtringList const&)@Base" 0.4.23 (c++)"ZenLib::Ztring::MakeLowerCase()@Base" 0.4.23 (c++)"ZenLib::Ztring::MakeUpperCase()@Base" 0.4.23 (c++)"ZenLib::Ztring::Quote(wchar_t)@Base" 0.4.23 (c++)"ZenLib::Ztring::To_CC4() const@Base" 0.4.23 (c++)"ZenLib::Ztring::To_float32(ZenLib::ztring_t) const@Base" 0.4.23 (c++)"ZenLib::Ztring::To_float64(ZenLib::ztring_t) const@Base" 0.4.23 (c++)"ZenLib::Ztring::To_float80(ZenLib::ztring_t) const@Base" 0.4.23 (c++)"ZenLib::Ztring::To_int128u(unsigned char, ZenLib::ztring_t) const@Base" 0.4.23 (c++)"ZenLib::Ztring::To_int16s(unsigned char, ZenLib::ztring_t) const@Base" 0.4.23 (c++)"ZenLib::Ztring::To_int16u(unsigned char, ZenLib::ztring_t) const@Base" 0.4.23 (c++)"ZenLib::Ztring::To_int32s(unsigned char, ZenLib::ztring_t) const@Base" 0.4.23 (c++)"ZenLib::Ztring::To_int32u(unsigned char, ZenLib::ztring_t) const@Base" 0.4.23 (c++)"ZenLib::Ztring::To_int64s(unsigned char, ZenLib::ztring_t) const@Base" 0.4.23 (c++)"ZenLib::Ztring::To_int64u(unsigned char, ZenLib::ztring_t) const@Base" 0.4.23 (c++)"ZenLib::Ztring::To_int8s(unsigned char, ZenLib::ztring_t) const@Base" 0.4.23 (c++)"ZenLib::Ztring::To_int8u(unsigned char, ZenLib::ztring_t) const@Base" 0.4.23 (c++)"ZenLib::Ztring::To_Local() const@Base" 0.4.23 (c++)"ZenLib::Ztring::To_Unicode() const@Base" 0.4.23 (c++)"ZenLib::Ztring::To_UTF8() const@Base" 0.4.23 (c++)"ZenLib::Ztring::To_UUID() const@Base" 0.4.23 (c++)"ZenLib::Ztring::TrimLeft(wchar_t)@Base" 0.4.23 (c++)"ZenLib::Ztring::TrimRight(wchar_t)@Base" 0.4.23 (c++)"ZenLib::Ztring::Trim(wchar_t)@Base" 0.4.23 (c++)"ZenLib::Ztring::~Ztring()@Base" 0.4.23 (optional|c++|regex)"^__gnu_cxx::" 0.4.23 (optional|c++|regex)"^std::" 0.4.23 (optional|c++|regex)"^(void|ZenLib::ZtringList\*|ZenLib::Ztring\*|bool|wchar_t\*) std::" 0.4.23 (optional|c++|regex)"^ZenLib::Ztring::ToZtring" 0.4.23 (optional|c++)"ZenLib::Ztring::From_Number(unsigned long, unsigned char)@Base" 0.4.23 ZenLib/debian/rules0000775000000000000000000000145112615631146013251 0ustar rootroot#!/usr/bin/make -f # -*- makefile -*- version = $(shell dpkg-parsechangelog | sed -nre 's/^Version: (.*)-.*/\1/p') # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 libpath = Project/GNU/Library override_dh_auto_configure: dh_auto_configure -D$(libpath) -- \ --enable-shared \ --disable-static override_dh_auto_build: cd Source/Doc && doxygen Doxyfile cp Source/Doc/*.html ./ sed -i -e 's|Version: |Version: $(version)|g' Project/GNU/Library/libzen.pc dh_auto_build -D$(libpath) override_dh_auto_clean: dh_auto_clean -D$(libpath) rm -rf Doc/ *.html override_dh_auto_install: dh_auto_install -D$(libpath) override_dh_installdocs: dh_installdocs fromdos debian/*/usr/share/doc/*/*.txt override_dh_makeshlibs: dh_makeshlibs -- -c4 %: dh $@ --with=autoreconf --parallel ZenLib/History.txt0000664000000000000000000002670112615631146013156 0ustar rootrootVersion 0.4.32, 2015-11-02 -------------- x Ztring::From_UTF8() was not handling 4 bytes UTF8 codes correctly Version 0.4.31, 2015-04-09 -------------- x BigEndian2float16() was buggy x is possible only with C++ Version 0.4.30, 2014-11-09 -------------- + New MemoryUtils.h functions for SSE2 memcpy + Ztring::From_Unicode(const wchar_t S) + Removed Win9X support + CMake: scripts improvements, thanks to Ivan Romanov + Mac: EOL definitely moved from \r to \n x int128: was not compiling on Cygwin x Windows: file open in append mode has shared read/write Version 0.4.29, 2013-05-13 -------------- + Ztring: Adding some Date_From_Seconds_* methods x Ztring: Ztring_NoZero option was not correctly implemented x File: Write only is not possible with ios_base::out (file is truncated) on Linux x Dir: Include_Dirs only was not working x File: accepts Windows "\\?\" magic value x Thread: Is* methods were not handling all cases Version 0.4.28, 2012-08-06 -------------- + Removing _T() in order to be compatible with LLVM compiler x Ztring: UTF-16 conversion routines crash if the provided string size is odd. x GNU: forcing stdc++ at link Version 0.4.27, 2012-05-22 -------------- + Better support of machines lacking of std::basic_stream x License text corrections Version 0.4.26, 2012-04-09 -------------- + Better support of machines lacking of std::stringstream + Better support of machines requesting explicit stdc++ library link option (e.g. some ARM embedded devices) Version 0.4.25, 2012-03-13 -------------- + Fast bitstream parser + Removing Win9X detection on 64-bit CPU + Ztring: integer to text conversion with radix=2 + Updated Linux compilation scripts Version 0.4.24, 2012-01-24 -------------- + Conversion from ctime style date to ISO date + GNU: more generic test of size_t as a long (e.g. for s390) x Read of text arrays of data was not well done if separator is bigger than 1 character x UTF-8 to UCS4 conversion was buggy with 4-byte characters x LittleEndian2float80() was buggy x Removing TinyXml and Base64 from the package Version 0.4.23, 2011-11-10 -------------- + Loading of CSV or any 2-dimensional array is carriage return mode insensitive + Ztring: ISO_8859_2 support + File: Truncate method x Ztring: UTF-8 load/save using generic code instead of Windows functions (they don't work for all Unicode codes) x File: Crash with some unordered API calls x FileName: Name::Get() wrong behavior in some cases Version 0.4.22, 2011-09-23 -------------- + File size retrieval is dynamic = support of growing files (Windows) x #3412495, Ztring: To_UTF8() was working wrong, corrected thanks to Andrew Jang Version 0.4.21, 2011-08-16 -------------- + File size retrieval is faster (Windows) x #3157308, Ztring::Assign_FromFile(): Memory leak Version 0.4.20, 2011-06-15 -------------- + TinyXml updated + float16 (on disk) support Version 0.4.19, 2011-03-19 -------------- + Ztring: more compatibility with uCLibC x BitStream_LE: wrong result if buffer underrun Version 0.4.18, 2011-03-03 -------------- + HTTP helpers in Unicode version x BitStream Little Endian: count of remaining bits was wrong x ZtringList and ZtringListList :: Read(): do not remove pending delimiters x File Open status: error with Windows return value Version 0.4.17, 2010-12-16 -------------- + uClibc compatibility, thanks to Metin KAYA + BitStream: Skip methods improvements Version 0.4.16, 2010-10-24 ------------- + BitStream: Peek3() x Decimal point issues with some specific compilers/OS x ZtringList: issues with EOL x #3025205, File is not opened if a "?" is in it Version 0.4.15, 2010-05-14 ------------- x Ztring: Solaris compatibility was broken x Solaris: pkgtrans packages, with optional default directory as script parameter Version 0.4.14, 2010-05-02 ------------- + Ztring: better compatibility with std::string + TinyXml import Version 0.4.13, 2010-04-16 ------------- + MSVC2010 project files update + Solaris package creation files update (with relocation) Version 0.4.12, 2010-03-08 ------------- + MSVC2010 project files + Solaris package creation files Version 0.4.11, 2010-02-19 ------------- + Ztring: To_int128u() + Ztring: ISO_8859_1() x File::Open(): no Access_Read_Write (Windows) x BigEndian2int128u() x Ztring::To_UUID(): wrong transformation text to UUID in some cases Version 0.4.10, 2010-01-03 ------------- + Ztring: From a file + Ztring::Duration_From_Milliseconds: handling of negative values x UUID: better validation x ZtringList: better handling of CSV import x File: Write append on Linux/Mac x File: No read/write on Linux/Mac x Dir: No dir test and creation on Mac/Linux x float64_int64s: handling of big integers Version 0.4.9, 2009-11-13 ------------- + File: bug in Open() Version 0.4.8, 2009-10-30 ------------- + Thread: reorganization, better support x File: Support of non-seekable files x ZtringListList: CSV write with quoted strings was wrong (again) Version 0.4.7, 2009-10-15 ------------- + Better universal binary building (Mac OS X) + Linux: Modification date/time (UTC and Local) x ZtringListList: CSV write with quoted strings was wrong x Ztring: GUID to string was wrong x Linux build script were a bit broken x File: file existence test was broken x FindAndReplace was hanging up if ToFind is empty Version 0.4.6, 2009-09-25 ------------- + Thread with Linux (base) + File: ignoring hidden files + Ztring: To_CC4, To_UUID x ZtringListList: better CSV compatibility x File, Open: const input x intxToLittleEndian x Correcting some warnings Version 0.4.5, 2009-09-05 ------------- + libzen.pc correction Version 0.4.4, 2009-09-01 ------------- + Dir::GetAllFileNames() was listing all dir if filename does not exist + Support of more platforms (fmodf) Version 0.4.3, 2009-07-03 ------------- + OpenSolaris support + Path separator + Ztring: handling of another format of date + Ztring: Changed UUID to GUID, Added UUID (in the right order) + Mac OS X: Creation of universal and 10.4 compatible binaries option Version 0.4.2, 2009-04-17 ------------- + File: Local modified/created date Version 0.4.1, 2009-04-03 ------------- + Dir: Option for GetAllFileNames (API incompatible change) Version 0.4.0, 2009-03-20 ------------- + Ztring: Radix option for To_xxx() (API incompatible change) Version 0.3.8, 2009-02-13 ------------- x UTF-8 conversion replacement (was buggy with Debian Lenny, why?) x Big files seeking on Linux x Sometimes memory corruption with Ztring Version 0.3.7 2009-01-30 ------------- + Some additional helpers for Ztring x Managing transformation from Unicode to local with unsupported characters Version 0.3.6 2009-01-19 ------------- + HTML protocol basic stuff + HTTP protocol helpers x Crash in Ztring::Trim() x Code cleanup Version 0.3.5 2008-12-09 ------------- + mipsel CPU support + Better Linux integration + rpm stuff (thanks to oc2pus http://packman.links2linux.org) + deb stuff x Code cleanup Version 0.3.4.0 2008-10-17 --------------- x some size of returned value problems in Ztring x Bug in FileName.cpp Version 0.3.3.9 2008-09-12 --------------- + Sparc compatibility x MacOS X wchar_t stuff Version 0.3.3.8 2008-08-22 --------------- x UTF-16 parsing under Linux Version 0.3.3.7 2008-06-13 --------------- + MinGW compatibility Version 0.3.3.6 2008-05-30 --------------- + MSVC2008 project files Version 0.3.3.5 2008-05-16 --------------- x Ztring: Problem with UTF-8 locale x xxxBSD compatibility Version 0.3.3.4 2008-04-26 --------------- x #1946749, Ztring: From_UTF16BE - endless loop Version 0.3.3.3 2008-04-12 --------------- + Adding some classes for speed improvement Version 0.3.3.2 2008-03-28 --------------- x On some systems, if a string is not a number, the returned number from string-->number conversion is undetermined x Non-unicode version: invalid read with assign() Version 0.3.3.1 2008-03-14 --------------- + Basic support of threads Version 0.3.3.0 2008-02-29 --------------- + Base64 encode/decode + File::Created() and File::Modified() x Trim() problem Version 0.3.2.6 2008-02-09 --------------- x Was not seeking after EOF x Win9X does not support shared reading, do not use it if Win9X Version 0.3.2.5 2008-02-01 --------------- + Linux/MacOS: support of 2GiB+ files x File: Re-enabled shared reading x Better handling of Floating point to string Version 0.3.2.4 2008-01-09 --------------- + Ztring::From_GUID() x small bugfixes Version 0.3.2.3 2007-12-10 --------------- x small bugfixes Version 0.3.2.2 2007-11-02 --------------- x Ztring comparison bug x Memory leaks Version 0.3.2.1 2007-10-07 --------------- + BitStream_LE (Little Endian) class + OpenFolder_Show method for Windows + int128u/s + Win9X support does not request Microsoft unicows.lib anymore x Win9X support was broken, is back now x Several small bug fixes Version 0.3.2.0 2007-08-17 --------------- + WxWidgets is kept out by default x Some minor bug corrections Version 0.3.1.7 2007-07-23 --------------- x .c files were not in source code Version 0.3.1.6 2007-05-14 --------------- x SetFilePointerEx() to SetFilePointer() for win98 support Version 0.3.1.5 2007-04-28 --------------- + Ztring::Date_From_Seconds_1601() added x Some bugfixes and warning corrections, mainly for 64-bit port Version 0.3.1.4 2007-02-05 --------------- x UTF16 with BOM corrupted handling Version 0.3.1.3 2006-12-22 --------------- + UTF16BE Handling + MacIntel adaptation Version 0.3.1.2 2006-12-07 --------------- x Some errors in Ztring x BitStream::Peek() corrected Version 0.3.1.1 2006-11-24 --------------- x BitStream : error with some last bits + ZtringListList and ZtringList : number of element limit added Version 0.3.1.0 2006-08-15 --------------- + Seconds from 1904 to ISO Version 0.3.0.2 2006-07-21 --------------- x Memory leak in Ztring::From_Local(...), (maybe a wxWidgets problem) x Memory leak with some streams methods, using now internal Win32 functions + Some return references in Ztring + Some dates functions Version 0.3.0.1 2006-05-03 --------------- x Big mistake in From_Local(...), Memory corruption Version 0.3.0.0 2006-04-30 --------------- x some Ztring::From_Number returned void + From_Date function + More utils Version 0.2.2.0 2005-12-18 --------------- + Some more utils Version 0.2.1.0 2005-10-14 --------------- + Preparing cross-platform makefiles for GCC, more testing with MinGW + Memory leaks detection in DEBUG mode (with BCC and MSVC only) x Ztring::To_intxx : was adding 1 to big integers if Rouded option set Version 0.2.0.1 2005-05-18 --------------- x MS Visual C++ compilation bug Version 0.2.0.0 2005-03-07 --------------- New + DevCpp (with MinGW) project + GCC project (makefile). Tested with CygWin and Knoppix + FindAndReplaced : Ztring_Recursive is off by default Version 0.1.1.2 2005-01-17 --------------- Bug fixes - Constructors in ZtringLislistF Version 0.1.1.1 2005-01-09 --------------- Bug fixes - minor bugs Version 0.1.1.0 2004-08-03 --------------- Bug fixes - Ztring::int32u was not in compiled files - Visual C++ 6 adaptation (thanks to Jasper van de Gronde) - Visual C++ 7.1 adaptation Version 0.1.0.0 2004-08-02 --------------- New - Conf file - I don't remember :( Bug fixes - Version 0.0.2.0 2003-07-25 --------------- New - Bug fixes - ZenLib/ReadMe.txt0000664000000000000000000000030112615631146012636 0ustar rootrootZenLib - http://zenlib.sourceforge.net Copyright (c) MediaArea.net SARL. All Rights Reserved. This program is freeware under zlib licence conditions. See Licence.txt for more information ZenLib/Source/0000775000000000000000000000000012615631146012206 5ustar rootrootZenLib/Source/Doc/0000775000000000000000000000000012615631146012713 5ustar rootrootZenLib/Source/Doc/Documentation.html0000664000000000000000000000021212615631146016405 0ustar rootroot
(redirecting)
ZenLib/Source/Doc/Doxyfile0000664000000000000000000001655112615631146014431 0ustar rootroot# Doxyfile 1.5.5 #--------------------------------------------------------------------------- # General configuration options #--------------------------------------------------------------------------- PROJECT_NAME = ZenLib PROJECT_NUMBER = OUTPUT_DIRECTORY = ./ OUTPUT_LANGUAGE = English EXTRACT_ALL = YES EXTRACT_PRIVATE = NO EXTRACT_STATIC = NO EXTRACT_LOCAL_CLASSES = YES HIDE_UNDOC_MEMBERS = NO HIDE_UNDOC_CLASSES = NO HIDE_FRIEND_COMPOUNDS = NO HIDE_IN_BODY_DOCS = NO BRIEF_MEMBER_DESC = YES REPEAT_BRIEF = YES ALWAYS_DETAILED_SEC = NO INLINE_INHERITED_MEMB = NO FULL_PATH_NAMES = NO STRIP_FROM_PATH = INTERNAL_DOCS = NO CASE_SENSE_NAMES = YES SHORT_NAMES = NO HIDE_SCOPE_NAMES = NO VERBATIM_HEADERS = YES SHOW_INCLUDE_FILES = YES JAVADOC_AUTOBRIEF = NO MULTILINE_CPP_IS_BRIEF = NO INHERIT_DOCS = YES INLINE_INFO = YES SORT_MEMBER_DOCS = YES DISTRIBUTE_GROUP_DOC = NO TAB_SIZE = 8 GENERATE_TODOLIST = YES GENERATE_TESTLIST = YES GENERATE_BUGLIST = YES GENERATE_DEPRECATEDLIST= YES ALIASES = ENABLED_SECTIONS = MAX_INITIALIZER_LINES = 30 OPTIMIZE_OUTPUT_FOR_C = NO OPTIMIZE_OUTPUT_JAVA = NO SHOW_USED_FILES = YES #--------------------------------------------------------------------------- # configuration options related to warning and progress messages #--------------------------------------------------------------------------- QUIET = YES WARNINGS = NO WARN_IF_UNDOCUMENTED = NO WARN_IF_DOC_ERROR = NO WARN_FORMAT = "$file:$line: $text" WARN_LOGFILE = #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- INPUT = ../ZenLib/ FILE_PATTERNS = *.h RECURSIVE = YES EXCLUDE = EXCLUDE_SYMLINKS = NO EXCLUDE_PATTERNS = EXAMPLE_PATH = EXAMPLE_PATTERNS = EXAMPLE_RECURSIVE = NO IMAGE_PATH = INPUT_FILTER = FILTER_SOURCE_FILES = NO #--------------------------------------------------------------------------- # configuration options related to source browsing #--------------------------------------------------------------------------- SOURCE_BROWSER = NO INLINE_SOURCES = NO STRIP_CODE_COMMENTS = NO REFERENCED_BY_RELATION = YES REFERENCES_RELATION = YES #--------------------------------------------------------------------------- # configuration options related to the alphabetical class index #--------------------------------------------------------------------------- ALPHABETICAL_INDEX = NO COLS_IN_ALPHA_INDEX = 5 IGNORE_PREFIX = #--------------------------------------------------------------------------- # configuration options related to the HTML output #--------------------------------------------------------------------------- GENERATE_HTML = YES HTML_OUTPUT = ../../Doc HTML_FILE_EXTENSION = .html HTML_HEADER = HTML_FOOTER = HTML_STYLESHEET = GENERATE_HTMLHELP = NO CHM_FILE = HHC_LOCATION = GENERATE_CHI = NO BINARY_TOC = NO TOC_EXPAND = NO DISABLE_INDEX = NO ENUM_VALUES_PER_LINE = 4 GENERATE_TREEVIEW = NO TREEVIEW_WIDTH = 250 #--------------------------------------------------------------------------- # configuration options related to the LaTeX output #--------------------------------------------------------------------------- GENERATE_LATEX = NO LATEX_OUTPUT = latex LATEX_CMD_NAME = latex MAKEINDEX_CMD_NAME = makeindex COMPACT_LATEX = NO PAPER_TYPE = a4wide EXTRA_PACKAGES = LATEX_HEADER = PDF_HYPERLINKS = NO USE_PDFLATEX = NO LATEX_BATCHMODE = NO #--------------------------------------------------------------------------- # configuration options related to the RTF output #--------------------------------------------------------------------------- GENERATE_RTF = NO RTF_OUTPUT = rtf COMPACT_RTF = NO RTF_HYPERLINKS = NO RTF_STYLESHEET_FILE = RTF_EXTENSIONS_FILE = #--------------------------------------------------------------------------- # configuration options related to the man page output #--------------------------------------------------------------------------- GENERATE_MAN = NO MAN_OUTPUT = man MAN_EXTENSION = .3 MAN_LINKS = NO #--------------------------------------------------------------------------- # configuration options related to the XML output #--------------------------------------------------------------------------- GENERATE_XML = NO XML_SCHEMA = XML_DTD = #--------------------------------------------------------------------------- # configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- GENERATE_AUTOGEN_DEF = NO #--------------------------------------------------------------------------- # configuration options related to the Perl module output #--------------------------------------------------------------------------- GENERATE_PERLMOD = NO PERLMOD_LATEX = NO PERLMOD_PRETTY = YES PERLMOD_MAKEVAR_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the preprocessor #--------------------------------------------------------------------------- ENABLE_PREPROCESSING = YES MACRO_EXPANSION = NO EXPAND_ONLY_PREDEF = NO SEARCH_INCLUDES = YES INCLUDE_PATH = INCLUDE_FILE_PATTERNS = PREDEFINED = EXPAND_AS_DEFINED = SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- # Configuration::addtions related to external references #--------------------------------------------------------------------------- TAGFILES = GENERATE_TAGFILE = ALLEXTERNALS = NO EXTERNAL_GROUPS = YES PERL_PATH = /usr/bin/perl #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- CLASS_DIAGRAMS = YES HIDE_UNDOC_RELATIONS = YES HAVE_DOT = NO CLASS_GRAPH = YES COLLABORATION_GRAPH = YES TEMPLATE_RELATIONS = YES INCLUDE_GRAPH = YES INCLUDED_BY_GRAPH = YES GRAPHICAL_HIERARCHY = YES DOT_IMAGE_FORMAT = png DOT_PATH = DOTFILE_DIRS = GENERATE_LEGEND = YES DOT_CLEANUP = YES #--------------------------------------------------------------------------- # Configuration::addtions related to the search engine #--------------------------------------------------------------------------- SEARCHENGINE = NO ZenLib/Source/Example/0000775000000000000000000000000012615631146013601 5ustar rootrootZenLib/Source/Example/ZenLib_Test.cpp0000664000000000000000000000247312615631146016475 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a zlib-style license that can * be found in the License.txt file in the root of the source tree. */ #include #include #include #include #include "ZenLib/Conf.h" #include "ZenLib/Ztring.h" #include "ZenLib/ZtringListList.h" #include "ZenLib/MemoryDebug.h" using namespace ZenLib; int main(char /*argc*/, char ** /*argv*/) { //Ztring and Unicode //-How To Use Ztring Z1, Z2; Z1+=Z2.From_Unicode(L"Unicode - \xE0\x01FC\r\n"); Z1+=Z2.From_Local("No Unicode - abc\r\n"); Z1+=Z2.From_Number(0x7FFFFFFFFFFFFFFFULL); //Displaying #if defined(_UNICODE) wprintf (L"%s\r\n", Z1.c_str()); #else printf ("%s\r\n", Z1.c_str()); #endif //ZtringLisList ZtringListList ZLL; ZLL=L"11;12;13\r\n21;22;23\r\n31;32;33"; wprintf (L"\r\nZtringListList\r\n%s\r\n", ZLL.Read().c_str()); wprintf (L"%s\r\n", ZLL.Read(1).c_str()); wprintf (L"%s\r\n", ZLL.Read(1, 1).c_str()); //Debug Mode char* MemoryLeakDetectionTest=new char[50]; //Search for a file Debug_MemoryLeak.txt system("PAUSE"); } //--------------------------------------------------------------------------- ZenLib/Source/ZenLib/0000775000000000000000000000000012615631146013371 5ustar rootrootZenLib/Source/ZenLib/ZtringListList.cpp0000664000000000000000000004114612615631146017050 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a zlib-style license that can * be found in the License.txt file in the root of the source tree. */ //--------------------------------------------------------------------------- #include "ZenLib/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "ZenLib/Conf_Internal.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include #include "ZenLib/ZtringListList.h" using namespace std; #if defined(_MSC_VER) && _MSC_VER <= 1200 using std::vector; //Visual C++ 6 patch #endif //--------------------------------------------------------------------------- namespace ZenLib { //--------------------------------------------------------------------------- extern Ztring EmptyZtring; //--------------------------------------------------------------------------- //*************************************************************************** // Constructors/Destructor //*************************************************************************** //--------------------------------------------------------------------------- // Constructors ZtringListList::ZtringListList() : std::vector > () { Separator[0]=EOL; Separator[1]=__T(";"); Quote=__T("\""); Max[0]=Error; Max[1]=Error; } ZtringListList::ZtringListList(const ZtringListList &Source) : std::vector > () { Separator[0]=Source.Separator[0]; Separator[1]=Source.Separator[1]; Quote=Source.Quote; Max[0]=Source.Max[0]; Max[1]=Source.Max[1]; reserve(Source.size()); for (intu Pos=0; Pos=size()) Write(Ztring(), Pos0); return operator[](Pos0); } Ztring &ZtringListList::operator() (size_type Pos0, size_type Pos1) { //Integrity if (Pos0>=size()) Write(Ztring(), Pos0); return operator[](Pos0).operator()(Pos1); } Ztring &ZtringListList::operator() (const Ztring &Pos0, size_type Pos0_1, size_type Pos1) { size_type Pos=0; size_t Size=size(); for (; PosPos0_1) if (operator[](Pos)[Pos0_1]==Pos0) break; if (Pos>=Size) { Write(Pos0, Size, Pos0_1); Pos=size()-1; } return operator[](Pos).operator()(Pos1); } //*************************************************************************** // In/Out //*************************************************************************** //--------------------------------------------------------------------------- // Read Ztring ZtringListList::Read () const { //Integrity if (size()==0) return Ztring(); Ztring ToReturn; size_type Size=size()-1; for (size_type Pos0=0; Pos00 && Separator[0].size() && ToReturn(ToReturn.size()-1)==Separator[0][Separator[0].size()-1]) //Optimize speed // while (ToReturn.find(Separator[0].c_str(), ToReturn.size()-Separator[0].size())!=std::string::npos) // ToReturn.resize(ToReturn.size()-Separator[0].size()); return ToReturn; } Ztring ZtringListList::Read (size_type Pos0) const { //Integrity if (Pos0>=size()) return Ztring(); return operator[](Pos0).Read(); } const Ztring &ZtringListList::Read (size_type Pos0, size_type Pos1) const { //Integrity if (Pos0>=size()) return EmptyZtring; return operator[](Pos0).Read(Pos1); } const Ztring &ZtringListList::Read (const Ztring &Pos0, size_type Pos1) const { size_type Pos=Find(Pos0); if (Pos==Error) return EmptyZtring; return operator[](Pos).Read(Pos1); } const Ztring &ZtringListList::Read (const Ztring &Pos0, size_type Pos0_1, size_type Pos1) const { size_type Pos=Find(Pos0, Pos0_1); if (Pos==Error) return EmptyZtring; return operator[](Pos).Read(Pos1); } const Ztring &ZtringListList::Read (const Ztring &Pos0, const Ztring &Default, size_type Pos1) const { size_type Pos=Find(Pos0); if (Pos==Error) return Default; return operator[](Pos).Read(Pos1); } const Ztring &ZtringListList::Read (const Ztring &Pos0, const Ztring &Default, size_type Pos0_1, size_type Pos1) const //Lecture d'un champs en position 0 avec une option par defaut { size_type Pos=Find(Pos0, Pos0_1); if (Pos==Error) return Default; return operator[](Pos).Read(Pos1); } Ztring ZtringListList::Read1 (size_type Pos1) const { Ztring ToReturn; size_type Size=size()-1; for (size_type Pos=0; Pos=ToWrite.size()) C1=ToWrite.substr(PosC, string::npos); ZL1.Write(C1); push_back(ZL1); PosC+=C1.size()+WriteSeparator.size(); if (PosC>=ToWrite.size()) Fini=true; } while (!Fini); } void ZtringListList::Write(const ZtringList &ToWrite, size_type Pos) { //Integrity if (Pos==Error) return; //Writing if (Pos>=size()) { //Reservation de ressources if (!capacity()) reserve(1); while (Pos>=capacity()) reserve(capacity()*2); while (Pos>size()) push_back (Ztring()); push_back(ToWrite); } else operator[](Pos)=ToWrite; } void ZtringListList::Write(const Ztring &ToWrite, size_type Pos0, size_type Pos1) { if (Pos0>=size()) Write(Ztring(), Pos0); operator[](Pos0).Write(ToWrite, Pos1); } void ZtringListList::push_back (const ZtringList &ToAdd) { vector::push_back(ToAdd); //Visual C++ 6 patch, should be std::vector operator[](size()-1).Separator_Set(0, Separator[1]); operator[](size()-1).Quote_Set(Quote); operator[](size()-1).Max_Set(0, Max[1]); } void ZtringListList::push_back (const Ztring &ToAdd) { ZtringList ZL1; ZL1.Separator_Set(0, Separator[1]); ZL1.Quote_Set(Quote); ZL1.Max_Set(0, Max[1]); ZL1.Write(ToAdd); push_back(ZL1); } //--------------------------------------------------------------------------- // Insert void ZtringListList::Insert1 (const Ztring &ToInsert, size_type Pos1) { for (size_type Pos0=0; Pos0=size()) Write(Ztring(), Pos_Max); operator [] (Pos0_A).swap(operator [] (Pos0_B)); } void ZtringListList::Swap1 (size_type Pos1_A, size_type Pos1_B) { for (size_type Pos0=0; Pos0Pos1) if (operator[](Pos0)[Pos1]==ToFind) break; if (Pos0>=Size) return Error; return Pos0; } Ztring::size_type ZtringListList::Find_Filled (size_type Pos1, size_type Pos0) const { size_t Size=size(); for (; Pos0Pos1) if (!operator[](Pos0)[Pos1].empty()) break; if (Pos0>=Size) return Error; return Pos0; } Ztring::size_type ZtringListList::Find (const Ztring &ToFind, size_type Pos1, size_type Pos0, const Ztring &Comparator, ztring_t Options) const { while ( Pos0=at(Pos0).size() || !at(Pos0).at(Pos1).Compare(ToFind, Comparator, Options))) Pos0++; if (Pos0>=size()) return Error; return Pos0; } Ztring ZtringListList::FindValue (const Ztring &ToFind, size_type Pos1Value, size_type Pos1, size_type Pos0Begin, const Ztring &Comparator, ztring_t) const { size_type Pos0=Find(ToFind, Pos1, Pos0Begin, Comparator); if (Pos0==Error) return Ztring(); return Read(Pos0, Pos1Value); } ZtringListList ZtringListList::SubSheet (const Ztring &ToFind, size_type Pos1, size_type Pos0, const Ztring &Comparator, ztring_t) const { ZtringListList ToReturn; ToReturn.Separator[0]=Separator[0]; ToReturn.Separator[1]=Separator[1]; ToReturn.Quote=Quote; Pos0--; do { Pos0=Find(ToFind, Pos1, Pos0+1, Comparator); ToReturn.push_back(Read(Pos0)); } while (Pos0!=Error); return ToReturn; } //*************************************************************************** // Configuration //*************************************************************************** //--------------------------------------------------------------------------- // Separator void ZtringListList::Separator_Set (size_type Level, const Ztring &NewSeparator) { if (Level>1) return; Separator[Level]=NewSeparator; if (Level==1) for (size_type Pos0=0; Pos01 || NewMax==0) return; Max[Level]=NewMax; if (Level==1) for (size_type Pos0=0; Pos0 #ifdef ZENLIB_MEMUTILS_SSE2 #include #endif //ZENLIB_MEMUTILS_SSE2 namespace ZenLib { #ifndef ZENLIB_MEMUTILS_SSE2 //----------------------------------------------------------------------- // Memory alloc/free #define malloc_Aligned128 (size) \ malloc (size) #define free_Aligned128 (ptr) \ free (ptr) //----------------------------------------------------------------------- // Arbitrary size - To Unaligned #define memcpy_Unaligned_Unaligned memcpy #define memcpy_Aligned128_Unaligned memcpy //----------------------------------------------------------------------- // Arbitrary size - To Aligned 128 bits (16 bytes) #define memcpy_Unaligned_Aligned128 memcpy #define memcpy_Aligned128_Aligned128 memcpy //----------------------------------------------------------------------- // 128 bits - To Unaligned #define memcpy_Unaligned_Unaligned_Once128 memcpy //----------------------------------------------------------------------- // 128 bits - To Aligned 128 bits (16 bytes) #define memcpy_Aligned128_Aligned128_Once128 memcpy //----------------------------------------------------------------------- // 1024 bits - To Unaligned #define memcpy_Unaligned_Unaligned_Once1024 memcpy //----------------------------------------------------------------------- // 1024 bits - To Aligned 128 bits (16 bytes) #define memcpy_Aligned128_Aligned128_Once1024 memcpy //----------------------------------------------------------------------- // 128-bit multiple - To Aligned 128 bits (16 bytes) #define memcpy_Unaligned_Aligned128_Size128 memcpy #define memcpy_Aligned128_Aligned128_Size128 memcpy #else // ZENLIB_MEMUTILS_SSE2 //----------------------------------------------------------------------- // Memory alloc/free inline void* malloc_Aligned128 (size_t size) { return _aligned_malloc (size, 16); //aligned_alloc in C11 } inline void free_Aligned128 ( void *ptr ) { _aligned_free (ptr); //free in C11 } //----------------------------------------------------------------------- // Arbitrary size - To Unaligned inline void memcpy_Unaligned_Unaligned (void* destination, const void* source, size_t num) { size_t extra=num&0xF; __m128i* destination16=(__m128i*)destination; const __m128i* source16=(const __m128i*)source; num>>=4; while (num--) _mm_storeu_si128 (destination16++, _mm_loadu_si128(source16++)); char* destination1=(char*)destination16; char* source1=(char*)source16; while (extra--) *destination1++=*source1++; } inline void memcpy_Aligned128_Unaligned (void* destination, const void* source, size_t num) { size_t extra=num&0xF; __m128i* destination16=(__m128i*)destination; const __m128i* source16=(const __m128i*)source; num>>=4; while (num--) _mm_storeu_si128 (destination16++, _mm_load_si128(source16++)); char* destination1=(char*)destination16; char* source1=(char*)source16; while (extra--) *destination1++=*source1++; } //----------------------------------------------------------------------- // Arbitrary size - To Aligned 128 bits (16 bytes) inline void memcpy_Unaligned_Aligned128 (void* destination, const void* source, size_t num) { size_t extra=num&0xF; __m128i* destination16=(__m128i*)destination; const __m128i* source16=(const __m128i*)source; num>>=4; while (num--) _mm_stream_si128 (destination16++, _mm_loadu_si128(source16++)); char* destination1=(char*)destination16; char* source1=(char*)source16; while (extra--) *destination1++=*source1++; } //----------------------------------------------------------------------- // 128 bits - To Unaligned inline void memcpy_Unaligned_Unaligned_Once128 (void* destination, const void* source) { _mm_storeu_si128 ((__m128i*)destination, _mm_loadu_si128((const __m128i*)source)); } //----------------------------------------------------------------------- // 128 bits - To Aligned 128 bits (16 bytes) inline void memcpy_Aligned128_Aligned128 (void* destination, const void* source, size_t num) { size_t extra=num&0xF; __m128i* destination16=(__m128i*)destination; const __m128i* source16=(const __m128i*)source; num>>=4; while (num--) _mm_stream_si128 (destination16++, _mm_load_si128(source16++)); char* destination1=(char*)destination16; char* source1=(char*)source16; while (extra--) *destination1++=*source1++; } inline void memcpy_Aligned128_Aligned128_Size128 (void* destination, const void* source, size_t num) { __m128i* destination16=(__m128i*)destination; const __m128i* source16=(__m128i*)source; num>>=4; while (num--) _mm_stream_si128 (destination16++, _mm_load_si128(source16++)); } //----------------------------------------------------------------------- // 1024 bits - To Unaligned inline void memcpy_Unaligned_Unaligned_Once1024 (void* destination, const void* source, size_t) { __m128i* destination16=(__m128i*)destination; const __m128i* source16=(__m128i*)source; size_t num=8; while (num--) _mm_storeu_si128 (destination16++, _mm_loadu_si128(source16++)); } //----------------------------------------------------------------------- // 1024 bits - To Aligned 128 bits (16 bytes) inline void memcpy_Aligned128_Aligned128_Once128 (void* destination, const void* source) { _mm_stream_si128 ((__m128i*)destination, _mm_load_si128((const __m128i*)source)); } //----------------------------------------------------------------------- // 128-bit multiple - To Unaligned (16 bytes) inline void memcpy_Unaligned_Unaligned_Size128 (void* destination, const void* source, size_t num) { __m128i* destination16=(__m128i*)destination; const __m128i* source16=(const __m128i*)source; num>>=4; while (num--) _mm_storeu_si128 (destination16++, _mm_loadu_si128(source16++)); } inline void memcpy_Aligned128_Unaligned_Size128 (void* destination, const void* source, size_t num) { __m128i* destination16=(__m128i*)destination; const __m128i* source16=(__m128i*)source; num>>=4; while (num--) _mm_storeu_si128 (destination16++, _mm_load_si128(source16++)); } //----------------------------------------------------------------------- // 128-bit multiple - To Aligned 128 bits (16 bytes) inline void memcpy_Unaligned_Aligned128_Size128 (void* destination, const void* source, size_t num) { __m128i* destination16=(__m128i*)destination; const __m128i* source16=(__m128i*)source; num>>=4; while (num--) _mm_stream_si128 (destination16++, _mm_loadu_si128(source16++)); } /* Slower inline void memcpy_Aligned128_Aligned128_Once1024 (void* destination, const void* source) { __m128i* destination16=(__m128i*)destination; const __m128i* source16=(__m128i*)source; size_t num=8; while (num--) _mm_stream_si128 (destination16++, _mm_load_si128(source16++)); } */ /* inline void memcpy_Aligned256_Aligned256 (void* destination, const void* source, size_t num) //with AVX, actually slower { size_t extra=num&0x1F; __m256i* destination16=(__m256i*)destination; const __m256i* source16=(const __m256i*)source; num>>=5; while (num--) _mm256_storeu_si256 (destination16++, _mm256_loadu_si256(source16++)); char* destination1=(char*)destination16; char* source1=(char*)source16; while (extra--) *destination1++=*source1++; } */ #endif // ZENLIB_MEMUTILS_SSE2 } //NameSpace #endif ZenLib/Source/ZenLib/HTTP_Client.cpp0000664000000000000000000000636712615631146016166 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a zlib-style license that can * be found in the License.txt file in the root of the source tree. */ //--------------------------------------------------------------------------- #include "ZenLib/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "ZenLib/Conf_Internal.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "ZenLib/HTTP_Client.h" #ifdef WINDOWS #undef __TEXT #include #endif //WINDOWS #include "ZenLib/HTTP_Client/HTTPClient.h" using namespace ZenLib; //--------------------------------------------------------------------------- namespace ZenLib { //*************************************************************************** // Constructor/Destructor //*************************************************************************** //--------------------------------------------------------------------------- HTTP_Client::HTTP_Client () { #ifdef WINDOWS WSADATA WsaData; WSAStartup(MAKEWORD(1, 2), &WsaData); #endif Handle=0; } //--------------------------------------------------------------------------- HTTP_Client::~HTTP_Client () { #ifdef WINDOWS WSACleanup(); #endif } //*************************************************************************** // Open/Close //*************************************************************************** //--------------------------------------------------------------------------- int HTTP_Client::Open (Ztring Url) { if (Handle) Close(); //init Handle=HTTPClientOpenRequest(0); //Mehtod if (HTTPClientSetVerb(Handle, VerbGet)!=0) { Close(); return 0; } //Send request if (HTTPClientSendRequest(Handle, (char*)(Url.To_Local().c_str()), NULL, 0, FALSE, 0, 0)!=0) { Close(); return 0; } //Receive response if (HTTPClientRecvResponse(Handle, 3)!=0) { Close(); return 0; } return 1; } //--------------------------------------------------------------------------- void HTTP_Client::Close () { HTTPClientCloseRequest(&Handle); Handle=0; } //*************************************************************************** // Read //*************************************************************************** //--------------------------------------------------------------------------- Ztring HTTP_Client::Read () { if (Handle==0) return Ztring(); char* Buffer=new char[16384]; int32u Size=0; int32u ReturnValue=HTTPClientReadData(Handle, Buffer, 16384, 0, &Size); if (ReturnValue!=0 && ReturnValue!=1000) //End of stream { Close(); delete[] Buffer; return Ztring(); } Ztring ToReturn; ToReturn.From_Local(Buffer, Size); delete[] Buffer; return ToReturn; } } //namespace ZenLib/Source/ZenLib/ZtringListListF.h0000664000000000000000000000504612615631146016622 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a zlib-style license that can * be found in the License.txt file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // ZtringListList with file load/save // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef ZtringListListFH #define ZtringListListFH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "ZenLib/ZtringListList.h" //--------------------------------------------------------------------------- namespace ZenLib { //*************************************************************************** /// @brief ZtringListList with file management //*************************************************************************** class ZtringListListF : public ZtringListList { public : //Constructors/Destructor ZtringListListF (); ZtringListListF (const ZtringListList &Source); ZtringListListF (const Ztring &Source); ZtringListListF (const Char *Source); #ifdef _UNICODE ZtringListListF (const char *Source); //convert a UTF-8 string into Unicode #endif //File management bool Load (const Ztring &FileName=Ztring()); bool Save (const Ztring &FileName=Ztring()); bool Cancel (); //Configuration // @brief enable or disable backup creation void Backup_Set (bool Save); // @brief Set the count of versions to save void Backup_Count_Set (int8u Count); // @brief Set if the content of file is a localized (=not UTF8) file void Local_Set (bool Local); protected : Ztring Name; //Nom du fichier bool Sauvegarde; //Indicateur si on a le droit de sauvegarder (par defaut) int8u Backup_Nb_Max; //Nombre maxi de sauvegardes int8u Backup_Nb; //Nombre actuel de backups pour cette session bool Local; //if true, this is a local charset, else this is a UTF8 charset //File management bool CSV_Charger (); bool CFG_Charger (); bool CSV_Sauvegarder (); bool CFG_Sauvegarder (); bool File_Load (); //Divers bool NettoyerEspaces (Ztring &ANettoyer); //Enlever les espaces avant et apres private: void ZtringListListF_Common(); }; } //Namespace #endif ZenLib/Source/ZenLib/PreComp.cpp0000664000000000000000000000062212615631146015442 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a zlib-style license that can * be found in the License.txt file in the root of the source tree. */ //--------------------------------------------------------------------------- #include "ZenLib/PreComp.h" //--------------------------------------------------------------------------- ZenLib/Source/ZenLib/Translation.cpp0000664000000000000000000001015512615631146016375 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a zlib-style license that can * be found in the License.txt file in the root of the source tree. */ //--------------------------------------------------------------------------- #include "ZenLib/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "ZenLib/Conf_Internal.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #ifdef ZENLIB_USEWX #include #endif //ZENLIB_USEWX #include #include "ZenLib/Translation.h" using namespace std; //--------------------------------------------------------------------------- namespace ZenLib { //*************************************************************************** // Constructors/Destructor //*************************************************************************** //--------------------------------------------------------------------------- // Constructors Translation::Translation() : std::map () { Separator[0]=EOL; Separator[1]=__T(";"); } Translation::Translation(const Ztring &Source) { Separator[0]=EOL; Separator[1]=__T(";"); Write(Source); } Translation::Translation(const Char *Source) { Separator[0]=EOL; Separator[1]=__T(";"); Write(Source); } #ifdef _UNICODE Translation::Translation (const char* S) { Separator[0]=EOL; Separator[1]=__T(";"); Write(Ztring(S)); } #endif //*************************************************************************** // In/Out //*************************************************************************** //--------------------------------------------------------------------------- // Get Ztring Translation::Get () const { Ztring ToReturn; const_iterator Temp=begin(); while (Temp!=end()) { ToReturn+=Temp->first; ToReturn+=Separator[1]; ToReturn+=Temp->second; ToReturn+=Separator[0]; ++Temp; } return ToReturn; } const Ztring &Translation::Get (const Ztring &Value) { iterator Pos=find(Value); if (Pos==end()) operator[](Value)=Value; return operator[](Value); } Ztring Translation::Get (const Ztring &Value, const Ztring &Default) { iterator Pos=find(Value); if (Pos==end()) operator[](Value)=Default; return operator[](Value); } //--------------------------------------------------------------------------- // Set void Translation::Write(const Ztring &NewLanguage) { clear(); if (NewLanguage.empty()) return; size_t Pos1=0, Pos2_EOL=0, Pos2_Separator=0; while (Pos2_EOL!=(size_t)-1) { Pos2_EOL=NewLanguage.find(__T('\n'), Pos1); Pos2_Separator=NewLanguage.find(__T(';'), Pos1); if (Pos2_Separator1) return; Separator[Level]=NewSeparator; } //*************************************************************************** // C++ //*************************************************************************** } //namespace ZenLib/Source/ZenLib/BitStream_Fast.h0000664000000000000000000002663412615631146016424 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a zlib-style license that can * be found in the License.txt file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Read a stream bit per bit // Can read up to 32 bits at once // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef ZenBitStream_FastH #define ZenBitStream_FastH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "ZenLib/Conf.h" //--------------------------------------------------------------------------- namespace ZenLib { #ifndef MIN #define MIN(a, b) (((a) < (b)) ? (a) : (b)) #endif class BitStream_Fast { public: BitStream_Fast () {Buffer=NULL; Buffer_Size=Buffer_Size_Init=0; BufferUnderRun=false;} BitStream_Fast (const int8u* Buffer_, size_t Size_) {Buffer=Buffer_; Buffer_Size=Buffer_Size_Init=Size_*8; //Size is in bits BufferUnderRun=false;} ~BitStream_Fast () {} void Attach(const int8u* Buffer_, size_t Size_) { Buffer=Buffer_; Buffer_Size=Buffer_Size_Init=Size_*8; //Size is in bits BufferUnderRun=false; } bool GetB () { if (Buffer_Size%8) { Buffer_Size--; return ((LastByte>>(Buffer_Size%8))&0x1)?true:false; } if (!Buffer_Size) { Buffer_Size=0; BufferUnderRun=true; return false; } LastByte=*Buffer; Buffer++; Buffer_Size--; return (LastByte&0x80)?true:false; } int8u Get1 (int8u HowMany) { int8u ToReturn; static const int8u Mask[9]= { 0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff, }; if (HowMany<=(Buffer_Size%8)) { Buffer_Size-=HowMany; return (LastByte>>(Buffer_Size%8))&Mask[HowMany]; } if (HowMany>Buffer_Size) { Buffer_Size=0; BufferUnderRun=true; return 0; } int8u NewBits=HowMany-(Buffer_Size%8); if (NewBits==8) ToReturn=0; else ToReturn=LastByte<>(Buffer_Size%8))&Mask[NewBits]; return ToReturn&Mask[HowMany]; } int16u Get2 (int8u HowMany) { int16u ToReturn; static const int16u Mask[17]= { 0x0000, 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff, 0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff, }; if (HowMany<=(Buffer_Size%8)) { Buffer_Size-=HowMany; return (LastByte>>(Buffer_Size%8))&Mask[HowMany]; } if (HowMany>Buffer_Size) { Buffer_Size=0; BufferUnderRun=true; return 0; } int8u NewBits=HowMany-(Buffer_Size%8); if (NewBits==16) ToReturn=0; else ToReturn=LastByte<>3) { NewBits-=8; ToReturn|=*Buffer<>(Buffer_Size%8))&Mask[NewBits]; return ToReturn&Mask[HowMany]; } int32u Get4 (int8u HowMany) { int32u ToReturn; static const int32u Mask[33]= { 0x00000000, 0x00000001, 0x00000003, 0x00000007, 0x0000000f, 0x0000001f, 0x0000003f, 0x0000007f, 0x000000ff, 0x000001ff, 0x000003ff, 0x000007ff, 0x00000fff, 0x00001fff, 0x00003fff, 0x00007fff, 0x0000ffff, 0x0001ffff, 0x0003ffff, 0x0007ffff, 0x000fffff, 0x001fffff, 0x003fffff, 0x007fffff, 0x00ffffff, 0x01ffffff, 0x03ffffff, 0x07ffffff, 0x0fffffff, 0x1fffffff, 0x3fffffff, 0x7fffffff, 0xffffffff, }; if (HowMany<=(Buffer_Size%8)) { Buffer_Size-=HowMany; return (LastByte>>(Buffer_Size%8))&Mask[HowMany]; } if (HowMany>Buffer_Size) { Buffer_Size=0; BufferUnderRun=true; return 0; } int8u NewBits=HowMany-(Buffer_Size%8); if (NewBits==32) ToReturn=0; else ToReturn=LastByte<>3) { case 3 : NewBits-=8; ToReturn|=*Buffer<>(Buffer_Size%8))&Mask[NewBits]; return ToReturn&Mask[HowMany]; } int64u Get8 (int8u HowMany) { if (HowMany>64) return 0; //Not supported int8u HowMany1, HowMany2; int64u Value1, Value2; if (HowMany>32) HowMany1=HowMany-32; else HowMany1=0; HowMany2=HowMany-HowMany1; Value1=Get4(HowMany1); Value2=Get4(HowMany2); if (BufferUnderRun) return 0; return Value1*0x100000000LL+Value2; } void Skip (size_t HowMany) { if (HowMany<=(Buffer_Size%8)) { Buffer_Size-=HowMany; return; } if (HowMany>Buffer_Size) { Buffer_Size=0; BufferUnderRun=true; return; } Buffer+=(HowMany-(Buffer_Size%8)-1)>>3; LastByte=*Buffer; Buffer++; Buffer_Size-=HowMany; } bool PeekB() { if (Buffer_Size%8) return ((LastByte>>((Buffer_Size-1)%8))&0x1)?true:false; if (!Buffer_Size) { Buffer_Size=0; BufferUnderRun=true; return false; } return ((*Buffer)&0x80)?true:false; } int8u Peek1(int8u HowMany) { int8u ToReturn; static const int8u Mask[9]= { 0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff, }; if (HowMany<=(Buffer_Size%8)) return (LastByte>>((Buffer_Size-HowMany)%8))&Mask[HowMany]; if (HowMany>Buffer_Size) { Buffer_Size=0; BufferUnderRun=true; return 0; } int8u NewBits=HowMany-(Buffer_Size%8); if (NewBits==8) ToReturn=0; else ToReturn=LastByte<>((Buffer_Size-HowMany)%8))&Mask[NewBits]; return ToReturn&Mask[HowMany]; } int16u Peek2(int8u HowMany) { int16u ToReturn; static const int16u Mask[17]= { 0x0000, 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff, 0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff, }; if (HowMany<=(Buffer_Size%8)) return (LastByte>>((Buffer_Size-HowMany)%8))&Mask[HowMany]; if (HowMany>Buffer_Size) { Buffer_Size=0; BufferUnderRun=true; return 0; } const int8u* Buffer_Save=Buffer; int8u NewBits=HowMany-(Buffer_Size%8); if (NewBits==16) ToReturn=0; else ToReturn=LastByte<>3) { NewBits-=8; ToReturn|=*Buffer<>((Buffer_Size-HowMany)%8))&Mask[NewBits]; Buffer=Buffer_Save; return ToReturn&Mask[HowMany]; } int32u Peek4(int8u HowMany) { int32u ToReturn; static const int32u Mask[33]= { 0x00000000, 0x00000001, 0x00000003, 0x00000007, 0x0000000f, 0x0000001f, 0x0000003f, 0x0000007f, 0x000000ff, 0x000001ff, 0x000003ff, 0x000007ff, 0x00000fff, 0x00001fff, 0x00003fff, 0x00007fff, 0x0000ffff, 0x0001ffff, 0x0003ffff, 0x0007ffff, 0x000fffff, 0x001fffff, 0x003fffff, 0x007fffff, 0x00ffffff, 0x01ffffff, 0x03ffffff, 0x07ffffff, 0x0fffffff, 0x1fffffff, 0x3fffffff, 0x7fffffff, 0xffffffff, }; if (HowMany<=(Buffer_Size%8)) return (LastByte>>((Buffer_Size-HowMany)%8))&Mask[HowMany]; if (HowMany>Buffer_Size) { Buffer_Size=0; BufferUnderRun=true; return 0; } const int8u* Buffer_Save=Buffer; int8u NewBits=HowMany-(Buffer_Size%8); if (NewBits==32) ToReturn=0; else ToReturn=LastByte<>3) { case 3 : NewBits-=8; ToReturn|=*Buffer<>((Buffer_Size-HowMany)%8))&Mask[NewBits]; Buffer=Buffer_Save; return ToReturn&Mask[HowMany]; } int64u Peek8(int8u HowMany) { return (int64u)Peek4(HowMany); //Not yet implemented } inline size_t Remain () const //How many bits remain? { return Buffer_Size; } inline void Byte_Align() { Skip (Buffer_Size%8); } inline size_t Offset_Get() const { return (Buffer_Size_Init-Buffer_Size)/8; } inline size_t BitOffset_Get() const { return Buffer_Size%8; } inline size_t OffsetBeforeLastCall_Get() const //No more valid { return Buffer_Size%8; } private : const int8u* Buffer; size_t Buffer_Size; size_t Buffer_Size_Init; int8u LastByte; public : bool BufferUnderRun; }; } //namespace ZenLib #endif ZenLib/Source/ZenLib/Dir.cpp0000664000000000000000000004401212615631146014614 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a zlib-style license that can * be found in the License.txt file in the root of the source tree. */ //--------------------------------------------------------------------------- #include "ZenLib/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "ZenLib/Conf_Internal.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #ifdef ZENLIB_USEWX #include #include #include #include #else //ZENLIB_USEWX #ifdef ZENLIB_STANDARD #undef WINDOWS #endif #ifdef WINDOWS #undef __TEXT #include #else #include #include #undef __TEXT //dirent include windows.h on Windows/Borland #include #include #endif #endif //ZENLIB_USEWX #include "ZenLib/Dir.h" #include "ZenLib/File.h" #include "ZenLib/FileName.h" #include "ZenLib/OS_Utils.h" //--------------------------------------------------------------------------- namespace ZenLib { //--------------------------------------------------------------------------- // Debug #ifdef ZENLIB_DEBUG #include #include namespace ZenLib_Dir_Debug { FILE* F; std::string Debug; SYSTEMTIME st_In; void Debug_Open(bool Out) { F=fopen("C:\\Temp\\ZenLib_Debug.txt", "a+t"); Debug.clear(); SYSTEMTIME st; GetLocalTime( &st ); char Duration[100]; if (Out) { FILETIME ft_In; if (SystemTimeToFileTime(&st_In, &ft_In)) { FILETIME ft_Out; if (SystemTimeToFileTime(&st, &ft_Out)) { ULARGE_INTEGER UI_In; UI_In.HighPart=ft_In.dwHighDateTime; UI_In.LowPart=ft_In.dwLowDateTime; ULARGE_INTEGER UI_Out; UI_Out.HighPart=ft_Out.dwHighDateTime; UI_Out.LowPart=ft_Out.dwLowDateTime; ULARGE_INTEGER UI_Diff; UI_Diff.QuadPart=UI_Out.QuadPart-UI_In.QuadPart; FILETIME ft_Diff; ft_Diff.dwHighDateTime=UI_Diff.HighPart; ft_Diff.dwLowDateTime=UI_Diff.LowPart; SYSTEMTIME st_Diff; if (FileTimeToSystemTime(&ft_Diff, &st_Diff)) { sprintf(Duration, "%02hd:%02hd:%02hd.%03hd", st_Diff.wHour, st_Diff.wMinute, st_Diff.wSecond, st_Diff.wMilliseconds); } else strcpy(Duration, " "); } else strcpy(Duration, " "); } else strcpy(Duration, " "); } else { st_In=st; strcpy(Duration, " "); } fprintf(F," %02hd:%02hd:%02hd.%03hd %s", st.wHour, st.wMinute, st.wSecond, st.wMilliseconds, Duration); } void Debug_Close() { Debug += "\r\n"; fwrite(Debug.c_str(), Debug.size(), 1, F); \ fclose(F); } } using namespace ZenLib_Dir_Debug; #define ZENLIB_DEBUG1(_NAME,_TOAPPEND) \ Debug_Open(false); \ Debug+=", ";Debug+=_NAME; \ _TOAPPEND; \ Debug_Close(); #define ZENLIB_DEBUG2(_NAME,_TOAPPEND) \ Debug_Open(true); \ Debug+=", ";Debug+=_NAME; \ _TOAPPEND; \ Debug_Close(); #else // ZENLIB_DEBUG #define ZENLIB_DEBUG1(_NAME,_TOAPPEND) #define ZENLIB_DEBUG2(_NAME,_TOAPPEND) #endif // ZENLIB_DEBUG //*************************************************************************** // Constructor/Destructor //*************************************************************************** //*************************************************************************** // Open/Close //*************************************************************************** ZtringList Dir::GetAllFileNames(const Ztring &Dir_Name_, dirlist_t Options) { ZENLIB_DEBUG1( "Dir GetAllFileNames", Debug+=", Dir_Name="; Debug+=Ztring(Dir_Name_).To_UTF8(); Debug+=", Options="; Debug +=Ztring::ToZtring(Options).To_UTF8()) ZtringList ToReturn; Ztring Dir_Name=Dir_Name_; #ifdef ZENLIB_USEWX int Flags=wxDIR_FILES | wxDIR_DIRS; //Search for files wxArrayString Liste; wxFileName FullPath; FullPath=Dir_Name.c_str(); //-File if (FullPath.FileExists()) { FullPath.Normalize(); Liste.Add(FullPath.GetFullPath()); } //-Directory else if (FullPath.DirExists()) { FullPath.Normalize(); wxDir::GetAllFiles(FullPath.GetFullPath(), &Liste, Ztring(), Flags); } //-WildCards else { wxString FileName=FullPath.GetFullName(); FullPath.SetFullName(Ztring()); //Supress filename FullPath.Normalize(); if (FullPath.DirExists()) wxDir::GetAllFiles(FullPath.GetPath(), &Liste, FileName, Flags); } //Compatible array ToReturn.reserve(Liste.GetCount()); for (size_t Pos=0; Posd_name); if (File_Name!=__T(".") && File_Name!=__T("..")) //Avoid . an .. { Ztring File_Name_Complete=Dir_Name+File_Name; if (Exists(File_Name_Complete)) { if (Options&Parse_SubDirs) ToReturn+=GetAllFileNames(File_Name_Complete, Options); //A SubDir } else if ((Options&Include_Hidden) || (!File_Name.empty() && File_Name[0]!=__T('.'))) ToReturn.push_back(File_Name_Complete); //A file } } //Close it closedir(Dir); } else { glob_t globbuf; if (glob(Dir_Name.To_Local().c_str(), GLOB_NOSORT, NULL, &globbuf)==0) { for (int Pos=0; PosDir_Name=Dir_Name_; p->Options=Options_; #ifdef WINDOWS //Is a dir? if (Dir::Exists(p->Dir_Name)) p->Dir_Name+=__T("\\*"); //Path p->Path=FileName::Path_Get(p->Dir_Name); if (p->Path.empty()) { DWORD Path_Size=GetFullPathName(p->Dir_Name.c_str(), 0, NULL, NULL); Char* PathTemp=new Char[Path_Size+1]; if (GetFullPathName(p->Dir_Name.c_str(), Path_Size+1, PathTemp, NULL)) p->Path=FileName::Path_Get(PathTemp); delete [] PathTemp; } #else //WINDOWS #endif ZENLIB_DEBUG2( "GetAllFileNames Start", ) } bool GetAllFileNames::Next (Ztring& Name) { if (!p) return false; ZENLIB_DEBUG1( "GetAllFileNames Next", Debug+=", Dir_Name="; Debug+=Ztring(p->Dir_Name).To_UTF8()) #ifdef WINDOWS for (;;) { if (p->hFind==INVALID_HANDLE_VALUE) { #ifdef UNICODE p->hFind=FindFirstFileW(p->Dir_Name.c_str(), &p->FindFileDataW); #else p->hFind=FindFirstFile(p->Dir_Name.c_str(), &p->FindFileData); #endif //UNICODE if (p->hFind==INVALID_HANDLE_VALUE) break; } else { BOOL ReturnValue; #ifdef UNICODE ReturnValue=FindNextFileW(p->hFind, &p->FindFileDataW); #else ReturnValue=FindNextFile(p->hFind, &p->FindFileData); #endif //UNICODE if (!ReturnValue) break; } #ifdef UNICODE Ztring File_Name(p->FindFileDataW.cFileName); #else Ztring File_Name(p->FindFileData.cFileName); #endif //UNICODE if (File_Name!=__T(".") && File_Name!=__T("..")) //Avoid . an .. { bool IsOk=false; #ifdef UNICODE if (p->FindFileDataW.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) #else if (p->FindFileData.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) #endif //UNICODE { if (p->Options&Dir::Include_Dirs) IsOk=true; //A dir } else if ((p->Options&Dir::Include_Files) && ((p->Options&Dir::Include_Hidden) || (!File_Name.empty() && File_Name[0]!=__T('.')))) IsOk=true; //A file if (IsOk) { Name=p->Path+__T("\\")+File_Name; ZENLIB_DEBUG2( "GetAllFileNames Next", Debug+=", File_Name="; Debug +=Name.To_UTF8()) return true; } } } #else //WINDOWS #endif Close(); return false; } void GetAllFileNames::Close () { if (!p) return; ZENLIB_DEBUG1( "GetAllFileNames Close", Debug+=", Dir_Name="; Debug+=Ztring(p->Dir_Name).To_UTF8()) FindClose(p->hFind); p->hFind=INVALID_HANDLE_VALUE; delete p; p=NULL; ZENLIB_DEBUG2( "GetAllFileNames Close", ) } #endif //WINDOWS //*************************************************************************** // //*************************************************************************** } //namespace ZenLib/Source/ZenLib/Utils.h0000664000000000000000000004554012615631146014652 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a zlib-style license that can * be found in the License.txt file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Integer and float manipulation // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef ZenUtilsH #define ZenUtilsH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "ZenLib/int128u.h" //--------------------------------------------------------------------------- namespace ZenLib { //*************************************************************************** // Integer transformations //*************************************************************************** //--------------------------------------------------------------------------- //Little Endians int8s LittleEndian2int8s (const char* List); int8u LittleEndian2int8u (const char* List); int16s LittleEndian2int16s (const char* List); int16u LittleEndian2int16u (const char* List); int32s LittleEndian2int24s (const char* List); int32u LittleEndian2int24u (const char* List); int32s LittleEndian2int32s (const char* List); int32u LittleEndian2int32u (const char* List); #if (MAXTYPE_INT >= 64) int64s LittleEndian2int40s (const char* List); int64u LittleEndian2int40u (const char* List); int64s LittleEndian2int48s (const char* List); int64u LittleEndian2int48u (const char* List); int64s LittleEndian2int56s (const char* List); int64u LittleEndian2int56u (const char* List); int64s LittleEndian2int64s (const char* List); int64u LittleEndian2int64u (const char* List); int128u LittleEndian2int128u (const char* List); #endif float32 LittleEndian2float16 (const char* List); float32 LittleEndian2float32 (const char* List); float64 LittleEndian2float64 (const char* List); float80 LittleEndian2float80 (const char* List); void int8s2LittleEndian (char* List, int8s Value); void int8u2LittleEndian (char* List, int8u Value); void int16s2LittleEndian (char* List, int16s Value); void int16u2LittleEndian (char* List, int16u Value); void int24s2LittleEndian (char* List, int32s Value); void int24u2LittleEndian (char* List, int32u Value); void int32s2LittleEndian (char* List, int32s Value); void int32u2LittleEndian (char* List, int32u Value); #if (MAXTYPE_INT >= 64) void int40s2LittleEndian (char* List, int64s Value); void int40u2LittleEndian (char* List, int64u Value); void int48s2LittleEndian (char* List, int64s Value); void int48u2LittleEndian (char* List, int64u Value); void int56s2LittleEndian (char* List, int64s Value); void int56u2LittleEndian (char* List, int64u Value); void int64s2LittleEndian (char* List, int64s Value); void int64u2LittleEndian (char* List, int64u Value); void int128u2LittleEndian (char* List, int128u Value); #endif void float162LittleEndian (char* List, float32 Value); void float322LittleEndian (char* List, float32 Value); void float642LittleEndian (char* List, float64 Value); void float802LittleEndian (char* List, float80 Value); #ifndef __BORLANDC__ inline int8s LittleEndian2int8s (const int8u* List) {return LittleEndian2int8s ((const char*)List);} inline int8u LittleEndian2int8u (const int8u* List) {return LittleEndian2int8u ((const char*)List);} inline int16s LittleEndian2int16s (const int8u* List) {return LittleEndian2int16s ((const char*)List);} inline int16u LittleEndian2int16u (const int8u* List) {return LittleEndian2int16u ((const char*)List);} inline int32s LittleEndian2int24s (const int8u* List) {return LittleEndian2int24s ((const char*)List);} inline int32u LittleEndian2int24u (const int8u* List) {return LittleEndian2int24u ((const char*)List);} inline int32s LittleEndian2int32s (const int8u* List) {return LittleEndian2int32s ((const char*)List);} inline int32u LittleEndian2int32u (const int8u* List) {return LittleEndian2int32u ((const char*)List);} #if (MAXTYPE_INT >= 64) inline int64s LittleEndian2int40s (const int8u* List) {return LittleEndian2int40s ((const char*)List);} inline int64u LittleEndian2int40u (const int8u* List) {return LittleEndian2int40u ((const char*)List);} inline int64s LittleEndian2int48s (const int8u* List) {return LittleEndian2int48s ((const char*)List);} inline int64u LittleEndian2int48u (const int8u* List) {return LittleEndian2int48u ((const char*)List);} inline int64s LittleEndian2int56s (const int8u* List) {return LittleEndian2int56s ((const char*)List);} inline int64u LittleEndian2int56u (const int8u* List) {return LittleEndian2int56u ((const char*)List);} inline int64s LittleEndian2int64s (const int8u* List) {return LittleEndian2int64s ((const char*)List);} inline int64u LittleEndian2int64u (const int8u* List) {return LittleEndian2int64u ((const char*)List);} inline int128u LittleEndian2int128u (const int8u* List) {return LittleEndian2int64u ((const char*)List);} #endif inline float32 LittleEndian2float16 (const int8u* List) {return LittleEndian2float16 ((const char*)List);} inline float32 LittleEndian2float32 (const int8u* List) {return LittleEndian2float32 ((const char*)List);} inline float64 LittleEndian2float64 (const int8u* List) {return LittleEndian2float64 ((const char*)List);} inline float80 LittleEndian2float80 (const int8u* List) {return LittleEndian2float80 ((const char*)List);} inline void int8s2LittleEndian (int8u* List, int8s Value) {return int8s2LittleEndian ((char*)List, Value);} inline void int8u2LittleEndian (int8u* List, int8u Value) {return int8u2LittleEndian ((char*)List, Value);} inline void int16s2LittleEndian (int8u* List, int16s Value) {return int16s2LittleEndian ((char*)List, Value);} inline void int16u2LittleEndian (int8u* List, int16u Value) {return int16u2LittleEndian ((char*)List, Value);} inline void int24s2LittleEndian (int8u* List, int32s Value) {return int24s2LittleEndian ((char*)List, Value);} inline void int24u2LittleEndian (int8u* List, int32u Value) {return int24u2LittleEndian ((char*)List, Value);} inline void int32s2LittleEndian (int8u* List, int32s Value) {return int32s2LittleEndian ((char*)List, Value);} inline void int32u2LittleEndian (int8u* List, int32u Value) {return int32u2LittleEndian ((char*)List, Value);} #if (MAXTYPE_INT >= 64) inline void int40s2LittleEndian (int8u* List, int64s Value) {return int40s2LittleEndian ((char*)List, Value);} inline void int40u2LittleEndian (int8u* List, int64u Value) {return int40u2LittleEndian ((char*)List, Value);} inline void int48s2LittleEndian (int8u* List, int64s Value) {return int48s2LittleEndian ((char*)List, Value);} inline void int48u2LittleEndian (int8u* List, int64u Value) {return int48u2LittleEndian ((char*)List, Value);} inline void int56s2LittleEndian (int8u* List, int64s Value) {return int56s2LittleEndian ((char*)List, Value);} inline void int56u2LittleEndian (int8u* List, int64u Value) {return int56u2LittleEndian ((char*)List, Value);} inline void int64s2LittleEndian (int8u* List, int64s Value) {return int64s2LittleEndian ((char*)List, Value);} inline void int64u2LittleEndian (int8u* List, int64u Value) {return int64u2LittleEndian ((char*)List, Value);} inline void int128u2LittleEndian (int8u* List, int128u Value) {return int128u2LittleEndian ((char*)List, Value);} #endif inline void float162LittleEndian (int8u* List, float32 Value) {return float162LittleEndian ((char*)List, Value);} inline void float322LittleEndian (int8u* List, float32 Value) {return float322LittleEndian ((char*)List, Value);} inline void float642LittleEndian (int8u* List, float64 Value) {return float642LittleEndian ((char*)List, Value);} inline void float802LittleEndian (int8u* List, float80 Value) {return float802LittleEndian ((char*)List, Value);} #endif //__BORLANDC__ //--------------------------------------------------------------------------- //Big Endians int8s BigEndian2int8s (const char* List); int8u BigEndian2int8u (const char* List); int16s BigEndian2int16s (const char* List); int16u BigEndian2int16u (const char* List); int32s BigEndian2int24s (const char* List); int32u BigEndian2int24u (const char* List); int32s BigEndian2int32s (const char* List); int32u BigEndian2int32u (const char* List); #if (MAXTYPE_INT >= 64) int64s BigEndian2int40s (const char* List); int64u BigEndian2int40u (const char* List); int64s BigEndian2int48s (const char* List); int64u BigEndian2int48u (const char* List); int64s BigEndian2int56s (const char* List); int64u BigEndian2int56u (const char* List); int64s BigEndian2int64s (const char* List); int64u BigEndian2int64u (const char* List); int128u BigEndian2int128u (const char* List); #endif float32 BigEndian2float16 (const char* List); float32 BigEndian2float32 (const char* List); float64 BigEndian2float64 (const char* List); float80 BigEndian2float80 (const char* List); void int8s2BigEndian (char* List, int8s Value); void int8u2BigEndian (char* List, int8u Value); void int16s2BigEndian (char* List, int16s Value); void int16u2BigEndian (char* List, int16u Value); void int24s2BigEndian (char* List, int32s Value); void int24u2BigEndian (char* List, int32u Value); void int32s2BigEndian (char* List, int32s Value); void int32u2BigEndian (char* List, int32u Value); #if (MAXTYPE_INT >= 64) void int40s2BigEndian (char* List, int64s Value); void int40u2BigEndian (char* List, int64u Value); void int48s2BigEndian (char* List, int64s Value); void int48u2BigEndian (char* List, int64u Value); void int56s2BigEndian (char* List, int64s Value); void int56u2BigEndian (char* List, int64u Value); void int64s2BigEndian (char* List, int64s Value); void int64u2BigEndian (char* List, int64u Value); void int128u2BigEndian (char* List, int128u Value); #endif void float162BigEndian (char* List, float32 Value); void float322BigEndian (char* List, float32 Value); void float642BigEndian (char* List, float64 Value); void float802BigEndian (char* List, float80 Value); #ifndef __BORLANDC__ inline int8s BigEndian2int8s (const int8u* List) {return BigEndian2int8s ((const char*)List);} inline int8u BigEndian2int8u (const int8u* List) {return BigEndian2int8u ((const char*)List);} inline int16s BigEndian2int16s (const int8u* List) {return BigEndian2int16s ((const char*)List);} inline int16u BigEndian2int16u (const int8u* List) {return BigEndian2int16u ((const char*)List);} inline int32s BigEndian2int32s (const int8u* List) {return BigEndian2int32s ((const char*)List);} inline int32u BigEndian2int24u (const int8u* List) {return BigEndian2int24u ((const char*)List);} inline int32s BigEndian2int24s (const int8u* List) {return BigEndian2int24s ((const char*)List);} inline int32u BigEndian2int32u (const int8u* List) {return BigEndian2int32u ((const char*)List);} #if (MAXTYPE_INT >= 64) inline int64s BigEndian2int40s (const int8u* List) {return BigEndian2int40s ((const char*)List);} inline int64u BigEndian2int40u (const int8u* List) {return BigEndian2int40u ((const char*)List);} inline int64s BigEndian2int48s (const int8u* List) {return BigEndian2int48s ((const char*)List);} inline int64u BigEndian2int48u (const int8u* List) {return BigEndian2int48u ((const char*)List);} inline int64s BigEndian2int56s (const int8u* List) {return BigEndian2int56s ((const char*)List);} inline int64u BigEndian2int56u (const int8u* List) {return BigEndian2int56u ((const char*)List);} inline int64s BigEndian2int64s (const int8u* List) {return BigEndian2int64s ((const char*)List);} inline int64u BigEndian2int64u (const int8u* List) {return BigEndian2int64u ((const char*)List);} inline int128u BigEndian2int128u (const int8u* List) {return BigEndian2int128u ((const char*)List);} #endif inline float32 BigEndian2float16 (const int8u* List) {return BigEndian2float16 ((const char*)List);} inline float32 BigEndian2float32 (const int8u* List) {return BigEndian2float32 ((const char*)List);} inline float64 BigEndian2float64 (const int8u* List) {return BigEndian2float64 ((const char*)List);} inline float80 BigEndian2float80 (const int8u* List) {return BigEndian2float80 ((const char*)List);} inline void int8s2BigEndian (int8u* List, int8s Value) {return int8s2BigEndian ((char*)List, Value);} inline void int8u2BigEndian (int8u* List, int8u Value) {return int8u2BigEndian ((char*)List, Value);} inline void int16s2BigEndian (int8u* List, int16s Value) {return int16s2BigEndian ((char*)List, Value);} inline void int16u2BigEndian (int8u* List, int16u Value) {return int16u2BigEndian ((char*)List, Value);} inline void int24s2BigEndian (int8u* List, int32s Value) {return int24s2BigEndian ((char*)List, Value);} inline void int24u2BigEndian (int8u* List, int32u Value) {return int24u2BigEndian ((char*)List, Value);} inline void int32s2BigEndian (int8u* List, int32s Value) {return int32s2BigEndian ((char*)List, Value);} inline void int32u2BigEndian (int8u* List, int32u Value) {return int32u2BigEndian ((char*)List, Value);} #if (MAXTYPE_INT >= 64) inline void int40s2BigEndian (int8u* List, int64s Value) {return int40s2BigEndian ((char*)List, Value);} inline void int40u2BigEndian (int8u* List, int64u Value) {return int40u2BigEndian ((char*)List, Value);} inline void int48s2BigEndian (int8u* List, int64s Value) {return int48s2BigEndian ((char*)List, Value);} inline void int48u2BigEndian (int8u* List, int64u Value) {return int48u2BigEndian ((char*)List, Value);} inline void int56s2BigEndian (int8u* List, int64s Value) {return int56s2BigEndian ((char*)List, Value);} inline void int56u2BigEndian (int8u* List, int64u Value) {return int56u2BigEndian ((char*)List, Value);} inline void int64s2BigEndian (int8u* List, int64s Value) {return int64s2BigEndian ((char*)List, Value);} inline void int64u2BigEndian (int8u* List, int64u Value) {return int64u2BigEndian ((char*)List, Value);} inline void int128u2BigEndian (int8u* List, int128u Value) {return int128u2BigEndian ((char*)List, Value);} #endif inline void float162BigEndian (int8u* List, float32 Value) {return float162BigEndian ((char*)List, Value);} inline void float322BigEndian (int8u* List, float32 Value) {return float322BigEndian ((char*)List, Value);} inline void float642BigEndian (int8u* List, float64 Value) {return float642BigEndian ((char*)List, Value);} inline void float802BigEndian (int8u* List, float80 Value) {return float802BigEndian ((char*)List, Value);} #endif //__BORLANDC__ //--------------------------------------------------------------------------- // int32 - int64 int64s int32s_int64s ( int32s High, int32u Low); int64u int32u_int64u ( int32u High, int32u Low); void int32s_int64s (int64s &BigInt, int32s High, int32u Low); void int32u_int64u (int64s &BigInt, int32u High, int32u Low); void int64s_int32s (int64s BigInt, int32s &High, int32u &Low); void int64u_int32u (int64u BigInt, int32u &High, int32u &Low); //--------------------------------------------------------------------------- // Floats and ints int32s float32_int32s (float32 F, bool Rounded=true); int64s float32_int64s (float32 F, bool Rounded=true); int32s float64_int32s (float64 F, bool Rounded=true); int64s float64_int64s (float64 F, bool Rounded=true); // These functions are used because MSVC6 isn't able to convert an unsigned int64 to a floating-point value, and I couldn't think of a cleaner way to handle it. #if defined(_MSC_VER) && _MSC_VER<=1200 inline float32 int64u_float32 (int64u v) {return static_cast(static_cast(v>>1))*2.0f + static_cast(static_cast(v & 1));} inline float64 int64u_float64 (int64u v) {return static_cast(static_cast(v>>1))*2.0f + static_cast(static_cast(v & 1));} #else inline float32 int64u_float32 (int64u v) {return (float32)v;} inline float64 int64u_float64 (int64u v) {return (float64)v;} #endif // defined(_MSC_VER) && _MSC_VER<=1200 //--------------------------------------------------------------------------- // CC (often used in all containers to identify a stream inline int64u CC8(const char* C) {return BigEndian2int64u(C);} inline int64u CC7(const char* C) {return BigEndian2int56u(C);} inline int64u CC6(const char* C) {return BigEndian2int48u(C);} inline int64u CC5(const char* C) {return BigEndian2int40u(C);} inline int32u CC4(const char* C) {return BigEndian2int32u(C);} inline int32u CC3(const char* C) {return BigEndian2int24u(C);} inline int16u CC2(const char* C) {return BigEndian2int16u(C);} inline int8u CC1(const char* C) {return BigEndian2int8u (C);} #ifndef __BORLANDC__ inline int64u CC8(const int8u* C) {return BigEndian2int64u(C);} inline int64u CC7(const int8u* C) {return BigEndian2int56u(C);} inline int64u CC6(const int8u* C) {return BigEndian2int48u(C);} inline int64u CC5(const int8u* C) {return BigEndian2int40u(C);} inline int32u CC4(const int8u* C) {return BigEndian2int32u(C);} inline int32u CC3(const int8u* C) {return BigEndian2int24u(C);} inline int16u CC2(const int8u* C) {return BigEndian2int16u(C);} inline int8u CC1(const int8u* C) {return BigEndian2int8u (C);} #endif // __BORLANDC__ //--------------------------------------------------------------------------- // turn a numeric literal into a hex constant // (avoids problems with leading zeroes) // 8-bit constants max value 0x11111111, always fits in unsigned long #define HEX__(n) 0x##n##LU // 8-bit conversion function #define B8__(x) ((x&0x0000000FLU)?0x01:0) \ +((x&0x000000F0LU)?0x02:0) \ +((x&0x00000F00LU)?0x04:0) \ +((x&0x0000F000LU)?0x08:0) \ +((x&0x000F0000LU)?0x10:0) \ +((x&0x00F00000LU)?0x20:0) \ +((x&0x0F000000LU)?0x40:0) \ +((x&0xF0000000LU)?0x80:0) // for upto 8-bit binary constants #define B8(d) ((int8u)B8__(HEX__(d))) // for upto 16-bit binary constants, MSB first #define B16(dmsb, dlsb) (((int16u)B8(dmsb)<<8) \ + ((int16u)B8(dlsb)<<0)) // for upto 32-bit binary constants, MSB first #define B32(dmsb, db2, db3, dlsb) (((int32u)B8(dmsb)<<24) \ + ((int32u)B8( db2)<<16) \ + ((int32u)B8( db3)<< 8) \ + ((int32u)B8(dlsb)<< 0)) } //namespace ZenLib #endif ZenLib/Source/ZenLib/Conf_Internal.h0000664000000000000000000000145212615631146016265 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a zlib-style license that can * be found in the License.txt file in the root of the source tree. */ //--------------------------------------------------------------------------- #ifndef ZenConf_InternalH #define ZenConf_InternalH //--------------------------------------------------------------------------- #include "ZenLib/Conf.h" //*************************************************************************** // Choice of method //*************************************************************************** #ifndef ZENLIB_USEWX #ifndef WINDOWS #define ZENLIB_STANDARD //We select the C/C++ standard as much as possible #endif #endif //ZENLIB_USEWX #endif ZenLib/Source/ZenLib/CriticalSection.cpp0000664000000000000000000001544212615631146017162 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a zlib-style license that can * be found in the License.txt file in the root of the source tree. */ //--------------------------------------------------------------------------- #include "ZenLib/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "ZenLib/Conf_Internal.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "ZenLib/CriticalSection.h" //--------------------------------------------------------------------------- //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // ZENLIB_USEWX //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #ifdef ZENLIB_USEWX //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #include //--------------------------------------------------------------------------- namespace ZenLib { //*************************************************************************** // Constructor/Destructor //*************************************************************************** //--------------------------------------------------------------------------- CriticalSection::CriticalSection() { CritSect=new wxCriticalSection(); } //--------------------------------------------------------------------------- CriticalSection::~CriticalSection() { delete ((wxCriticalSection*)CritSect); //CritSect=NULL; } //*************************************************************************** // Enter/Leave //*************************************************************************** //--------------------------------------------------------------------------- void CriticalSection::Enter() { ((wxCriticalSection*)CritSect)->Enter(); } //--------------------------------------------------------------------------- void CriticalSection::Leave() { ((wxCriticalSection*)CritSect)->Leave(); } } //Namespace //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // WINDOWS //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #else //ZENLIB_USEWX #ifdef WINDOWS //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #undef __TEXT #include //--------------------------------------------------------------------------- namespace ZenLib { //*************************************************************************** // Constructor/Destructor //*************************************************************************** //--------------------------------------------------------------------------- CriticalSection::CriticalSection() { CritSect=new CRITICAL_SECTION; InitializeCriticalSection((CRITICAL_SECTION*)CritSect); } //--------------------------------------------------------------------------- CriticalSection::~CriticalSection() { DeleteCriticalSection((CRITICAL_SECTION*)CritSect); delete ((CRITICAL_SECTION*)CritSect); //CritSect=NULL; } //*************************************************************************** // Enter/Leave //*************************************************************************** //--------------------------------------------------------------------------- void CriticalSection::Enter() { EnterCriticalSection((CRITICAL_SECTION*)CritSect); } //--------------------------------------------------------------------------- void CriticalSection::Leave() { LeaveCriticalSection((CRITICAL_SECTION*)CritSect); } } //Namespace //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // UNIX //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #else //WINDOWS //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #include //--------------------------------------------------------------------------- namespace ZenLib { //*************************************************************************** // Constructor/Destructor //*************************************************************************** //--------------------------------------------------------------------------- CriticalSection::CriticalSection() { CritSect=new pthread_mutex_t; pthread_mutex_init((pthread_mutex_t*)CritSect, NULL); } //--------------------------------------------------------------------------- CriticalSection::~CriticalSection() { pthread_mutex_destroy((pthread_mutex_t*)CritSect); delete (pthread_mutex_t*)CritSect; } //*************************************************************************** // Enter/Leave //*************************************************************************** //--------------------------------------------------------------------------- void CriticalSection::Enter() { pthread_mutex_lock((pthread_mutex_t*)CritSect); } //--------------------------------------------------------------------------- void CriticalSection::Leave() { pthread_mutex_unlock((pthread_mutex_t*)CritSect); } } //Namespace //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #endif //WINDOWS #endif //ZENLIB_USEWX //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ZenLib/Source/ZenLib/OS_Utils.h0000664000000000000000000000247212615631146015250 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a zlib-style license that can * be found in the License.txt file in the root of the source tree. */ //--------------------------------------------------------------------------- #ifndef ZenOS_UtilsH #define ZenOS_UtilsH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "ZenLib/Ztring.h" //--------------------------------------------------------------------------- namespace ZenLib { //*************************************************************************** // OS Information //*************************************************************************** //--------------------------------------------------------------------------- bool IsWin9X (); // Execute //*************************************************************************** void Shell_Execute(const Ztring &ToExecute); //*************************************************************************** // Directorues //*************************************************************************** Ztring OpenFolder_Show(void* Handle, const Ztring &Title, const Ztring &Caption); } //namespace ZenLib #endif ZenLib/Source/ZenLib/ZtringListListF.cpp0000664000000000000000000002337112615631146017156 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a zlib-style license that can * be found in the License.txt file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // ZtringListList with file load/save // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #include "ZenLib/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "ZenLib/Conf_Internal.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "ZenLib/ZtringListListF.h" #include "ZenLib/File.h" //--------------------------------------------------------------------------- namespace ZenLib { //--------------------------------------------------------------------------- #define READ_SIZE 512*1024 //--------------------------------------------------------------------------- //*************************************************************************** // Constructors/Destructor //*************************************************************************** //--------------------------------------------------------------------------- // Constructors void ZtringListListF::ZtringListListF_Common () { Backup_Nb_Max=0; Backup_Nb=0; Sauvegarde=true; #ifdef _UNICODE Local=false; #else Local=true; #endif } ZtringListListF::ZtringListListF () :ZtringListList () { ZtringListListF_Common(); } ZtringListListF::ZtringListListF (const ZtringListList &Source) :ZtringListList (Source) { ZtringListListF_Common(); } ZtringListListF::ZtringListListF (const Ztring &Source) :ZtringListList (Source) { ZtringListListF_Common(); } ZtringListListF::ZtringListListF (const Char *Source) :ZtringListList (Source) { ZtringListListF_Common(); } #ifdef _UNICODE ZtringListListF::ZtringListListF (const char* Source) :ZtringListList (Source) { ZtringListListF_Common(); } #endif //*************************************************************************** // File management //*************************************************************************** //--------------------------------------------------------------------------- // Load bool ZtringListListF::Load (const Ztring &NewFileName) { clear(); if (!NewFileName.empty()) Name=NewFileName; size_t I1=Error; if (Name.find(__T(".csv"))!=Error) I1=CSV_Charger(); if (Name.find(__T(".cfg"))!=Error) I1=CFG_Charger(); if (I1!=Error) { Backup_Nb=0; //mettre ici le code pour trouver le nb de backup return true; } else return false; } //--------------------------------------------------------------------------- // Load CSV bool ZtringListListF::CSV_Charger () { //Read file File F; if (!F.Open(Name)) return false; int8u* Buffer=new int8u[(size_t)F.Size_Get()+1]; size_t BytesCount=F.Read(Buffer, (size_t)F.Size_Get()); F.Close(); if (BytesCount==Error) { delete[] Buffer; //Buffer=NULL; return false; } Buffer[(int32u)BytesCount]=(int8u)'\0'; //Convert file in UTF-8 or Local Ztring File; if (!Local) { //UTF-8 File.From_UTF8((char*)Buffer, 0, BytesCount); #ifdef _DEBUG if (File.size()==0) File.From_Local((char*)Buffer, 0, BytesCount); #endif //_DEBUG } if (File.size()==0) //Local of UTF-8 failed File.From_Local((char*)Buffer, 0, BytesCount); //Separators if (Separator[0]==__T("(Default)")) Separator[0]=EOL; Ztring SeparatorT=Separator[1]; Separator[1]=__T(";"); //Writing Write(File); //Separators Separator[1]=SeparatorT; delete[] Buffer; //Buffer=NULL; return true; } //--------------------------------------------------------------------------- // Chargement CFG bool ZtringListListF::CFG_Charger () { //Read file File F(Name); int8u* Buffer=new int8u[(size_t)F.Size_Get()+1]; size_t BytesCount=F.Read(Buffer, (size_t)F.Size_Get()); F.Close(); if (BytesCount==Error) { delete[] Buffer; //Buffer=NULL; return false; } Buffer[(int32u)BytesCount]=(int8u)'\0'; //Convert File --> ZtringList ZtringList List; List.Separator_Set(0, EOL); Ztring Z1; Z1.From_UTF8((char*)Buffer, 0, BytesCount); List.Write(Z1); Ztring SeparatorT=Separator[1]; Separator[1]=__T(";"); Ztring Propriete, Valeur, Commentaire; for (size_t Pos=0; Pos0) { //TODO : not tested for (int8u I1=Backup_Nb_Max-1; I1>0; I1--) { Ztring Z1=Name+__T(".sav"); Z1+=Ztring::ToZtring(I1); Ztring Z2=Name+__T(".sav"); Z2+=Ztring::ToZtring(I1+1); File::Delete(Z2.c_str()); I2=File::Move(Z1.c_str(), Z2.c_str()); if (I2 && !Backup_Nb) Backup_Nb=I2; } Ztring Z1=Name+__T(".sav0"); File::Delete(Z1.c_str()); File::Move(Name.c_str(), Z1.c_str()); Backup_Nb++; } I2=0; if (Name.find(__T(".csv"))!=Error) I2=CSV_Sauvegarder(); if (Name.find(__T(".cfg"))!=Error) I2=CFG_Sauvegarder(); if (I2>0) { return true; } else return false; } //--------------------------------------------------------------------------- // Sauvegarde CSV bool ZtringListListF::CSV_Sauvegarder () { //Sauvegarde File F; if (!F.Create(Name, true)) return Error; if (Separator[0]==__T("(Default)")) Separator[0]=EOL; F.Write(Read()); return true; } //--------------------------------------------------------------------------- // Sauvegarde CFG bool ZtringListListF::CFG_Sauvegarder () { File F; if (!F.Create(Name, true)) return Error; Ztring ToWrite; Ztring Propriete, Valeur, Commentaire; ; for (size_t Pos=0; Pos=Debut) ANettoyer=ANettoyer.substr(Debut, Fin-Debut+1); else ANettoyer=Ztring(); return true; } //--------------------------------------------------------------------------- // Backup void ZtringListListF::Backup_Set (bool NewSave) { Sauvegarde=NewSave; Save(); } void ZtringListListF::Backup_Count_Set (int8u NewCount) { Backup_Nb_Max=NewCount; } //--------------------------------------------------------------------------- // Local void ZtringListListF::Local_Set (bool NewLocal) { Local=NewLocal; } } //Namespace ZenLib/Source/ZenLib/FileName.cpp0000664000000000000000000001630412615631146015561 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a zlib-style license that can * be found in the License.txt file in the root of the source tree. */ //--------------------------------------------------------------------------- #include "ZenLib/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "ZenLib/Conf_Internal.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "ZenLib/FileName.h" #ifdef ZENLIB_USEWX #include #else //ZENLIB_USEWX #ifdef ZENLIB_STANDARD #undef WINDOWS #endif #ifdef WINDOWS #undef __TEXT #include #endif #endif //ZENLIB_USEWX //--------------------------------------------------------------------------- #undef ZENLIB_USEWX namespace ZenLib { //*************************************************************************** // Read/Write //*************************************************************************** //--------------------------------------------------------------------------- Ztring FileName::Path_Get() const { #ifdef ZENLIB_USEWX wxFileName FN(c_str()); return FN.GetPath().c_str(); #else //ZENLIB_USEWX //Path limit size_t Pos_Path=rfind(FileName_PathSeparator); if (Pos_Path==Ztring::npos) return Ztring(); //Not found else return Ztring(*this, 0, Pos_Path); #endif //ZENLIB_USEWX } //--------------------------------------------------------------------------- Ztring& FileName::Path_Set(const Ztring &Path) { #ifdef ZENLIB_USEWX wxFileName FN(c_str()); FN.SetPath(Path.c_str()); assign (FN.GetFullPath().c_str()); #else //ZENLIB_USEWX #ifdef WINDOWS //Path limit size_t Pos_Path=rfind(__T('\\')); if (Pos_Path==Ztring::npos) { insert(0, 1, __T('\\')); //Not found Pos_Path=0; } replace(0, Pos_Path, Path, 0, Ztring::npos); #else //Not supported #endif #endif //ZENLIB_USEWX return *this; } //--------------------------------------------------------------------------- Ztring FileName::Name_Get() const { #ifdef ZENLIB_USEWX wxFileName FN(c_str()); if (FN==FN.GetName()) //Bug of WxWidgets? if C:\\dir\\(no name), name is C:\\dir\\(no name) return Ztring(); return FN.GetName().c_str(); #else //ZENLIB_USEWX size_t Pos_Path=rfind(FileName_PathSeparator); //Path limit if (Pos_Path==Ztring::npos) Pos_Path=0; //Not found else Pos_Path+=Ztring(FileName_PathSeparator).size(); //Path separator size //Extension limit size_t Pos_Ext=rfind(__T('.')); if (Pos_Ext==Ztring::npos || Pos_Ext int128u.h // - Namespace // - int128u alias // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #include "ZenLib/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "ZenLib/Conf_Internal.h" //--------------------------------------------------------------------------- #include "int128s.h" /* Name: int128.cpp Copyright: Copyright (C) 2005, Jan Ringos Author: Jan Ringos, http://Tringi.Mx-3.cz Version: 1.1 */ #include #include #include #if defined (__BORLANDC__) || defined (__SUNPRO_CC) #define fmodf fmod #endif #if defined (__NO_LONG_DOUBLE_MATH) || \ defined (__MONTAVISTA__) || defined (__ARMEL__) || \ defined (__FreeBSD__) || defined (__OpenBSD__) || \ defined (__NetBSD__) || defined (__DragonFly__) || \ defined (__sparc__) || defined (__sparc64__) || \ defined (__CYGWIN__) || \ defined (__SUNPRO_CC) #define fmodl fmod #endif using namespace std; namespace ZenLib { // IMPLEMENTATION const char * int128::toString (unsigned int radix) const throw () { if (!*this) return "0"; if (radix < 2 || radix > 37) return "(invalid radix)"; static char sz [256]; memset (sz, 0, 256); int128 r; int128 ii = (*this < 0) ? -*this : *this; int i = 255; while (!!ii && i) { ii = ii.div (radix, r); sz [--i] = (char) (r.toInt () + ((r.toInt () > 9) ? 'A' - 10 : '0')); }; if (*this < 0) sz [--i] = '-'; return &sz [i]; }; int128::int128 (const char * sz) throw () : lo (0u), hi (0) { if (!sz) return; if (!sz [0]) return; unsigned int radix = 10; unsigned int i = 0; bool minus = false; if (sz [i] == '-') { ++i; minus = true; }; if (sz [i] == '0') { radix = 8; ++i; if (sz [i] == 'x') { radix = 16; ++i; }; }; for (; i < strlen (sz); ++i) { unsigned int n = 0; if (sz [i] >= '0' && sz [i] <= (('0' + (int) radix) < '9'?('0' + (int) radix):'9')) //if (sz [i] >= '0' && sz [i] <= (('0' + (int) radix) = 'a' && sz [i] <= 'a' + (int) radix - 10) n = sz [i] - 'a' + 10; else if (sz [i] >= 'A' && sz [i] <= 'A' + (int) radix - 10) n = sz [i] - 'A' + 10; else break; (*this) *= radix; (*this) += n; }; if (minus) *this = 0 - *this; return; }; int128::int128 (const float a) throw () #if defined (__mips__) || defined (__mipsel__) : lo ((int64u) fmodf ((const double)a, 18446744073709551616.0)), #else : lo ((int64u) fmodf (a, 18446744073709551616.0f)), #endif hi ((int64s) (a / 18446744073709551616.0f)) {}; int128::int128 (const double & a) throw () : lo ((int64u) fmod (a, 18446744073709551616.0)), hi ((int64s) (a / 18446744073709551616.0)) {}; int128::int128 (const long double & a) throw () #if defined (__mips__) || defined (__mipsel__) : lo ((int64u) fmod ((const double)a, 18446744073709551616.0)), #else : lo ((int64u) fmodl (a, 18446744073709551616.0l)), #endif hi ((int64s) (a / 18446744073709551616.0l)) {}; float int128::toFloat () const throw () { return (float) this->hi * 18446744073709551616.0f + (float) this->lo; }; double int128::toDouble () const throw () { return (double) this->hi * 18446744073709551616.0 + (double) this->lo; }; long double int128::toLongDouble () const throw () { return (long double) this->hi * 18446744073709551616.0l + (long double) this->lo; }; int128 int128::operator - () const throw () { if (!this->hi && !this->lo) // number is 0, just return 0 return *this; else // non 0 number return int128 (0-this->lo, ~this->hi); }; int128 int128::operator ~ () const throw () { return int128 (~this->lo, ~this->hi); }; int128 & int128::operator ++ () { ++this->lo; if (!this->lo) ++this->hi; return *this; }; int128 & int128::operator -- () { if (!this->lo) --this->hi; --this->lo; return *this; }; int128 int128::operator ++ (int) { int128 b = *this; ++ *this; return b; }; int128 int128::operator -- (int) { int128 b = *this; -- *this; return b; }; int128 & int128::operator += (const int128 & b) throw () { int64u old_lo = this->lo; this->lo += b.lo; this->hi += b.hi + (this->lo < old_lo); return *this; }; int128 & int128::operator *= (const int128 & b) throw () { if (!b) return *this = 0u; if (b == 1u) return *this; int128 a = *this; int128 t = b; this->lo = 0ull; this->hi = 0ll; for (unsigned int i = 0; i < 128; ++i) { if (t.lo & 1) *this += a << i; t >>= 1; }; return *this; }; int128 int128::div (const int128 & divisor, int128 & remainder) const throw () { if (!divisor) return 1u / (unsigned int) divisor.lo; // or RaiseException (EXCEPTION_INT_DIVIDE_BY_ZERO, // EXCEPTION_NONCONTINUABLE, 0, NULL); int128 ds = (divisor < 0) ? -divisor : divisor; int128 dd = (*this < 0) ? -*this : *this; // only remainder if (ds > dd) { remainder = *this; return 0ull; }; int128 r = 0ull; int128 q = 0ull; // while (dd >= ds) { dd -= ds; q += 1; }; // extreme slow version unsigned int b = 127; while (r < ds) { r <<= 1; if (dd.bit (b--)) r.lo |= 1; }; ++b; for (;;) if (r < ds) { if (!(b--)) break; r <<= 1; if (dd.bit (b)) r.lo |= 1; } else { r -= ds; q.bit (b, true); }; // correct if ((divisor < 0) ^ (*this < 0)) q =- q; if (*this < 0) r =- r; remainder = r; return q; }; bool int128::bit (unsigned int n) const throw () { n &= 0x7F; if (n < 64) return (this->lo & (1ull << n))?true:false; else return (this->hi & (1ull << (n - 64)))?true:false; }; void int128::bit (unsigned int n, bool val) throw () { n &= 0x7F; if (val) { if (n < 64) this->lo |= (1ull << n); else this->hi |= (1ull << (n - 64)); } else { if (n < 64) this->lo &= ~(1ull << n); else this->hi &= ~(1ull << (n - 64)); }; }; int128 & int128::operator >>= (unsigned int n) throw () { n &= 0x7F; if (n > 63) { n -= 64; this->lo = this->hi; if (this->hi < 0) this->hi = -1ll; else this->hi = 0ll; }; if (n) { // shift low qword this->lo >>= n; // get lower N bits of high qword int64u mask = 0ull; for (unsigned int i = 0; i < n; ++i) mask |= (1ull << i); // and add them to low qword this->lo |= (this->hi & mask) << (64 - n); // and finally shift also high qword this->hi >>= n; }; return *this; }; int128 & int128::operator <<= (unsigned int n) throw () { n &= 0x7F; if (n > 63) { n -= 64; this->hi = this->lo; this->lo = 0ull; }; if (n) { // shift high qword this->hi <<= n; // get higher N bits of low qword int64u mask = 0ull; for (unsigned int i = 0; i < n; ++i) mask |= (1ull << (63 - i)); // and add them to high qword this->hi |= (this->lo & mask) >> (64 - n); // and finally shift also low qword this->lo <<= n; }; return *this; }; bool int128::operator ! () const throw () { return !(this->hi || this->lo); }; int128 & int128::operator |= (const int128 & b) throw () { this->hi |= b.hi; this->lo |= b.lo; return *this; }; int128 & int128::operator &= (const int128 & b) throw () { this->hi &= b.hi; this->lo &= b.lo; return *this; }; int128 & int128::operator ^= (const int128 & b) throw () { this->hi ^= b.hi; this->lo ^= b.lo; return *this; }; bool operator < (const int128 & a, const int128 & b) throw () { if (a.hi == b.hi) { if (a.hi < 0) return (int64s) a.lo < (int64s) b.lo; else return a.lo < b.lo; } else return a.hi < b.hi; }; bool operator == (const int128 & a, const int128 & b) throw () { return a.hi == b.hi && a.lo == b.lo; }; bool operator && (const int128 & a, const int128 & b) throw () { return (a.hi || a.lo) && (b.hi || b.lo); }; bool operator || (const int128 & a, const int128 & b) throw () { return (a.hi || a.lo) || (b.hi || b.lo); }; } //NameSpace ZenLib/Source/ZenLib/int128s.h0000664000000000000000000001442212615631146014755 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a zlib-style license that can * be found in the License.txt file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // based on http://Tringi.Mx-3.cz // Only adapted for ZenLib: // - .hpp --> .h // - Namespace // - int128s alias // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #ifndef INT128_HPP #define INT128_HPP /* Name: int128.hpp Copyright: Copyright (C) 2005, Jan Ringos Author: Jan Ringos, http://Tringi.Mx-3.cz Version: 1.1 */ #include #include #include #ifdef __cplusplus #include //for size_t #else /* __cplusplus */ #include //for size_t #endif /* __cplusplus */ #include "ZenLib/Conf.h" namespace ZenLib { // CLASS class int128 { private: // Binary correct representation of signed 128bit integer int64u lo; int64s hi; protected: // Some global operator functions must be friends friend bool operator < (const int128 &, const int128 &) throw (); friend bool operator == (const int128 &, const int128 &) throw (); friend bool operator || (const int128 &, const int128 &) throw (); friend bool operator && (const int128 &, const int128 &) throw (); public: // Constructors inline int128 () throw () : lo(0), hi(0) {}; inline int128 (const int128 & a) throw () : lo (a.lo), hi (a.hi) {}; inline int128 (const unsigned int & a) throw () : lo (a), hi (0ll) {}; inline int128 (const signed int & a) throw () : lo (a), hi (0ll) { if (a < 0) this->hi = -1ll; }; inline int128 (const int64u & a) throw () : lo (a), hi (0ll) {}; inline int128 (const int64s & a) throw () : lo (a), hi (0ll) { if (a < 0) this->hi = -1ll; }; int128 (const float a) throw (); int128 (const double & a) throw (); int128 (const long double & a) throw (); int128 (const char * sz) throw (); // TODO: Consider creation of operator= to eliminate // the need of intermediate objects during assignments. private: // Special internal constructors int128 (const int64u & a, const int64s & b) throw () : lo (a), hi (b) {}; public: // Operators bool operator ! () const throw (); int128 operator - () const throw (); int128 operator ~ () const throw (); int128 & operator ++ (); int128 & operator -- (); int128 operator ++ (int); int128 operator -- (int); int128 & operator += (const int128 & b) throw (); int128 & operator *= (const int128 & b) throw (); int128 & operator >>= (unsigned int n) throw (); int128 & operator <<= (unsigned int n) throw (); int128 & operator |= (const int128 & b) throw (); int128 & operator &= (const int128 & b) throw (); int128 & operator ^= (const int128 & b) throw (); // Inline simple operators inline const int128 & operator + () const throw () { return *this; }; // Rest of inline operators inline int128 & operator -= (const int128 & b) throw () { return *this += (-b); }; inline int128 & operator /= (const int128 & b) throw () { int128 dummy; *this = this->div (b, dummy); return *this; }; inline int128 & operator %= (const int128 & b) throw () { this->div (b, *this); return *this; }; // Common methods int toInt () const throw () { return (int) this->lo; }; int64s toInt64 () const throw () { return (int64s) this->lo; }; const char * toString (unsigned int radix = 10) const throw (); float toFloat () const throw (); double toDouble () const throw (); long double toLongDouble () const throw (); // Arithmetic methods int128 div (const int128 &, int128 &) const throw (); // Bit operations bool bit (unsigned int n) const throw (); void bit (unsigned int n, bool val) throw (); } #ifdef __GNUC__ __attribute__ ((__aligned__ (16), __packed__)) #endif ; // GLOBAL OPERATORS bool operator < (const int128 & a, const int128 & b) throw (); bool operator == (const int128 & a, const int128 & b) throw (); bool operator || (const int128 & a, const int128 & b) throw (); bool operator && (const int128 & a, const int128 & b) throw (); // GLOBAL OPERATOR INLINES inline int128 operator + (const int128 & a, const int128 & b) throw () { return int128 (a) += b; }; inline int128 operator - (const int128 & a, const int128 & b) throw () { return int128 (a) -= b; }; inline int128 operator * (const int128 & a, const int128 & b) throw () { return int128 (a) *= b; }; inline int128 operator / (const int128 & a, const int128 & b) throw () { return int128 (a) /= b; }; inline int128 operator % (const int128 & a, const int128 & b) throw () { return int128 (a) %= b; }; inline int128 operator >> (const int128 & a, unsigned int n) throw () { return int128 (a) >>= n; }; inline int128 operator << (const int128 & a, unsigned int n) throw () { return int128 (a) <<= n; }; inline int128 operator & (const int128 & a, const int128 & b) throw () { return int128 (a) &= b; }; inline int128 operator | (const int128 & a, const int128 & b) throw () { return int128 (a) |= b; }; inline int128 operator ^ (const int128 & a, const int128 & b) throw () { return int128 (a) ^= b; }; inline bool operator > (const int128 & a, const int128 & b) throw () { return b < a; }; inline bool operator <= (const int128 & a, const int128 & b) throw () { return !(b < a); }; inline bool operator >= (const int128 & a, const int128 & b) throw () { return !(a < b); }; inline bool operator != (const int128 & a, const int128 & b) throw () { return !(a == b); }; // MISC //typedef int128 __int128; typedef int128 int128s; } //NameSpace #endif ZenLib/Source/ZenLib/int128u.cpp0000664000000000000000000002214112615631146015307 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a zlib-style license that can * be found in the License.txt file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // based on http://Tringi.Mx-3.cz // Only adapted for ZenLib: // - uint128.hpp --> int128u.h // - Namespace // - int128u alias // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #include "ZenLib/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "ZenLib/Conf_Internal.h" //--------------------------------------------------------------------------- #include "int128u.h" /* Name: uint128.cpp Copyright: Copyright (C) 2005, Jan Ringos Author: Jan Ringos, http://Tringi.Mx-3.cz Version: 1.1 */ #include #include #include #if defined (__BORLANDC__) || defined (__SUNPRO_CC) #define fmodf fmod #endif #if defined (__NO_LONG_DOUBLE_MATH) || \ defined (__MONTAVISTA__) || defined (__ARMEL__) || \ defined (__FreeBSD__) || defined (__OpenBSD__) || \ defined (__NetBSD__) || defined (__DragonFly__) || \ defined (__sparc__) || defined (__sparc64__) || \ defined (__CYGWIN__) || \ defined (__SUNPRO_CC) #define fmodl fmod #endif using namespace std; namespace ZenLib { // IMPLEMENTATION const char * uint128::toString (unsigned int radix) const throw () { if (!*this) return "0"; if (radix < 2 || radix > 37) return "(invalid radix)"; static char sz [256]; memset (sz, 0, 256); uint128 r; uint128 ii = *this; int i = 255; while (!!ii && i) { ii = ii.div (radix, r); sz [--i] = (char) (r.toUint () + ((r.toUint () > 9) ? 'A' - 10 : '0')); }; return &sz [i]; }; uint128::uint128 (const char * sz) throw () : lo (0u), hi (0u) { if (!sz) return; if (!sz [0]) return; unsigned int radix = 10; unsigned int i = 0; bool minus = false; if (sz [i] == '-') { ++i; minus = true; }; if (sz [i] == '0') { radix = 8; ++i; if (sz [i] == 'x') { radix = 16; ++i; }; }; for (; i < strlen (sz); ++i) { unsigned int n = 0; if (sz [i] >= '0' && sz [i] <= (('0' + (int) radix) < '9'?('0' + (int) radix):'9')) //if (sz [i] >= '0' && sz [i] <= (('0' + (int) radix) = 'a' && sz [i] <= 'a' + (int) radix - 10) n = sz [i] - 'a' + 10; else if (sz [i] >= 'A' && sz [i] <= 'A' + (int) radix - 10) n = sz [i] - 'A' + 10; else break; (*this) *= radix; (*this) += n; }; if (minus) *this = 0u - *this; return; }; uint128::uint128 (const float a) throw () #if defined (__mips__) || defined (__mipsel__) : lo ((int64u) fmod ((const double)a, 18446744073709551616.0)), #else : lo ((int64u) fmodf (a, 18446744073709551616.0f)), #endif hi ((int64u) (a / 18446744073709551616.0f)) {}; uint128::uint128 (const double & a) throw () : lo ((int64u) fmod (a, 18446744073709551616.0)), hi ((int64u) (a / 18446744073709551616.0)) {}; uint128::uint128 (const long double & a) throw () #if defined (__mips__) || defined (__mipsel__) : lo ((int64u) fmod ((const double)a, 18446744073709551616.0)), #else : lo ((int64u) fmodl (a, 18446744073709551616.0l)), #endif hi ((int64u) (a / 18446744073709551616.0l)) {}; float uint128::toFloat () const throw () { return (float) this->hi * 18446744073709551616.0f + (float) this->lo; }; double uint128::toDouble () const throw () { return (double) this->hi * 18446744073709551616.0 + (double) this->lo; }; long double uint128::toLongDouble () const throw () { return (long double) this->hi * 18446744073709551616.0l + (long double) this->lo; }; uint128 uint128::operator - () const throw () { if (!this->hi && !this->lo) // number is 0, just return 0 return *this; else // non 0 number return uint128 (0-this->lo, ~this->hi); }; uint128 uint128::operator ~ () const throw () { return uint128 (~this->lo, ~this->hi); }; uint128 & uint128::operator ++ () { ++this->lo; if (!this->lo) ++this->hi; return *this; }; uint128 & uint128::operator -- () { if (!this->lo) --this->hi; --this->lo; return *this; }; uint128 uint128::operator ++ (int) { uint128 b = *this; ++ *this; return b; }; uint128 uint128::operator -- (int) { uint128 b = *this; -- *this; return b; }; uint128 & uint128::operator += (const uint128 & b) throw () { int64u old_lo = this->lo; this->lo += b.lo; this->hi += b.hi + (this->lo < old_lo); return *this; }; uint128 & uint128::operator *= (const uint128 & b) throw () { if (!b) return *this = 0u; if (b == 1u) return *this; uint128 a = *this; uint128 t = b; this->lo = 0ull; this->hi = 0ull; for (unsigned int i = 0; i < 128; ++i) { if (t.lo & 1) *this += a << i; t >>= 1; }; return *this; }; uint128 uint128::div (const uint128 & ds, uint128 & remainder) const throw () { if (!ds) return 1u / (unsigned int) ds.lo; uint128 dd = *this; // only remainder if (ds > dd) { remainder = *this; return 0ull; }; uint128 r = 0ull; uint128 q = 0ull; // while (dd >= ds) { dd -= ds; q += 1; }; // extreme slow version unsigned int b = 127; while (r < ds) { r <<= 1; if (dd.bit (b--)) r.lo |= 1; }; ++b; for (;;) if (r < ds) { if (!(b--)) break; r <<= 1; if (dd.bit (b)) r.lo |= 1; } else { r -= ds; q.bit (b, true); }; remainder = r; return q; }; bool uint128::bit (unsigned int n) const throw () { n &= 0x7F; if (n < 64) return (this->lo & (1ull << n))?true:false; else return (this->hi & (1ull << (n - 64)))?true:false; }; void uint128::bit (unsigned int n, bool val) throw () { n &= 0x7F; if (val) { if (n < 64) this->lo |= (1ull << n); else this->hi |= (1ull << (n - 64)); } else { if (n < 64) this->lo &= ~(1ull << n); else this->hi &= ~(1ull << (n - 64)); }; }; uint128 & uint128::operator >>= (unsigned int n) throw () { n &= 0x7F; if (n > 63) { n -= 64; this->lo = this->hi; this->hi = 0ull; }; if (n) { // shift low qword this->lo >>= n; // get lower N bits of high qword int64u mask = 0ull; for (unsigned int i = 0; i < n; ++i) mask |= (1ull << i); // and add them to low qword this->lo |= (this->hi & mask) << (64 - n); // and finally shift also high qword this->hi >>= n; }; return *this; }; uint128 & uint128::operator <<= (unsigned int n) throw () { n &= 0x7F; if (n > 63) { n -= 64; this->hi = this->lo; this->lo = 0ull; }; if (n) { // shift high qword this->hi <<= n; // get higher N bits of low qword int64u mask = 0ull; for (unsigned int i = 0; i < n; ++i) mask |= (1ull << (63 - i)); // and add them to high qword this->hi |= (this->lo & mask) >> (64 - n); // and finally shift also low qword this->lo <<= n; }; return *this; }; bool uint128::operator ! () const throw () { return !(this->hi || this->lo); }; uint128 & uint128::operator |= (const uint128 & b) throw () { this->hi |= b.hi; this->lo |= b.lo; return *this; }; uint128 & uint128::operator &= (const uint128 & b) throw () { this->hi &= b.hi; this->lo &= b.lo; return *this; }; uint128 & uint128::operator ^= (const uint128 & b) throw () { this->hi ^= b.hi; this->lo ^= b.lo; return *this; }; bool operator < (const uint128 & a, const uint128 & b) throw () { return (a.hi == b.hi) ? (a.lo < b.lo) : (a.hi < b.hi); }; bool operator == (const uint128 & a, const uint128 & b) throw () { return a.hi == b.hi && a.lo == b.lo; }; bool operator && (const uint128 & a, const uint128 & b) throw () { return (a.hi || a.lo) && (b.hi || b.lo); }; bool operator || (const uint128 & a, const uint128 & b) throw () { return (a.hi || a.lo) || (b.hi || b.lo); }; } //NameSpace ZenLib/Source/ZenLib/File.h0000664000000000000000000000700212615631146014420 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a zlib-style license that can * be found in the License.txt file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // File functions // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef ZenLib_FileH #define ZenLib_FileH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "ZenLib/Ztring.h" //--------------------------------------------------------------------------- namespace ZenLib { //*************************************************************************** /// @brief File manipulation //*************************************************************************** class File { public : //--------------------------------------------------------------------------- /// @brief Options for Open method enum access_t { Access_Read = 0, ///< Read permission Access_Write = 1, ///< Write permission Access_Read_Write = 2, ///< Read and Write permissions Access_Write_Append = 3, ///< Write permission without deleting old file Access_Write_Excluding = 4 ///< Write permission preventing reading }; //--------------------------------------------------------------------------- /// @brief Options for Move method enum move_t { FromBegin = 0, ///< Begin of file FromCurrent = 1, ///< Current position FromEnd = 2 ///< End of file }; //Constructor/Destructor File (); File (ZenLib::Ztring File_Name, access_t Access=Access_Read); ~File (); //Open/close bool Open (const tstring &File_Name, access_t Access=Access_Read); bool Create(const ZenLib::Ztring &File_Name, bool OverWrite=true); void Close (); //Read/Write size_t Read (int8u* Buffer, size_t Buffer_Size); size_t Write (const int8u* Buffer, size_t Buffer_Size); size_t Write (const Ztring &ToWrite); bool Truncate (int64u Offset=(int64u)-1); //Moving bool GoTo (int64s Position, move_t MoveMethod=FromBegin); int64u Position_Get (); //Attributes int64u Size_Get(); Ztring Created_Get(); Ztring Created_Local_Get(); Ztring Modified_Get(); Ztring Modified_Local_Get(); bool Opened_Get(); //Helpers static int64u Size_Get(const Ztring &File_Name); static Ztring Created_Get(const Ztring &File_Name); static Ztring Modified_Get(const Ztring &File_Name); static bool Exists(const Ztring &File_Name); static bool Copy(const Ztring &Source, const Ztring &Destination, bool OverWrite=false); static bool Move(const Ztring &Source, const Ztring &Destination, bool OverWrite=false); static bool Delete(const Ztring &File_Name); //Temp Ztring File_Name; int64u Position; //Position is saved, may be not good because position may change int64u Size; //Size is saved, may be not good because size may change void* File_Handle; }; } //NameSpace #endif ZenLib/Source/ZenLib/Ztring.h0000664000000000000000000005523712615631146015033 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a zlib-style license that can * be found in the License.txt file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // More methods for std::(w)string // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef ZenLib_ZtringH #define ZenLib_ZtringH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "ZenLib/Utils.h" #include #include //--------------------------------------------------------------------------- namespace ZenLib { //--------------------------------------------------------------------------- typedef std::basic_string, std::allocator > tstring; //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- /// @brief Options for Ztring methods enum ztring_t { Ztring_Nothing, Ztring_Rounded = 1, ///< if >.5, upper, else lower Ztring_CaseSensitive = 2, ///< Case sensitive ("A" and "a" are different) Ztring_AddLastItem = 4, ///< if Begin is found and End is not found, return between Begin and end of string Ztring_Recursive = 8, ///< Do all strings Ztring_NoZero = 16 ///> Doesn't keep Zero in the float number }; //--------------------------------------------------------------------------- //*************************************************************************** /// @brief String manipulation (based on std::(w)string) //*************************************************************************** class Ztring : public tstring //for details about undocumented methods see http://www.sgi.com/tech/stl/basic_string.html { public : //Constructor/destructor Ztring () : tstring(){}; Ztring (const tstring& str) : tstring(str){}; Ztring (const tstring& str, size_type pos, size_type n=npos) : tstring(str, pos, n){}; Ztring (const Char* s, size_type n) : tstring(s, n){}; Ztring (const Char* s) : tstring(s){}; Ztring (size_type n, Char c) : tstring(n, c){}; #ifdef UNICODE Ztring (const char* S) : tstring(){From_UTF8(S);}; Ztring (const char* S, size_type n) : tstring(){From_UTF8(S, 0, n);}; #endif //UNICODE //Operators ///Same as [], but resize the string if Pos doesn't exist yet Char &operator () (size_type Pos); //Assign bool Assign_FromFile (const Ztring &FileName); //Conversions - From #ifndef WSTRING_MISSING /// @brief convert an Unicode encoded string into Ztring Ztring& From_Unicode (const std::wstring &S) {return From_Unicode(S.c_str());}; #endif //WSTRING_MISSING /// @brief convert an Unicode encoded wchar_t into Ztring Ztring& From_Unicode (const wchar_t S); /// @brief convert an Unicode encoded string into Ztring Ztring& From_Unicode (const wchar_t *S); /// @brief convert an Unicode encoded string into Ztring Ztring& From_Unicode (const wchar_t *S, size_type Start, size_type Length); /// @brief convert an Unicode encoded string into Ztring Ztring& From_Unicode (const wchar_t *S, size_type Length) {return From_Unicode(S, 0, Length);}; /// @brief convert an UTF-8 encoded string into Ztring Ztring& From_UTF8 (const std::string &S) {return From_UTF8(S.c_str());}; /// @brief convert an UTF-8 encoded string into Ztring Ztring& From_UTF8 (const char *S); /// @brief convert an UTF-8 encoded string into Ztring Ztring& From_UTF8 (const char *S, size_type Start, size_type Length); /// @brief convert an UTF-8 encoded string into Ztring Ztring& From_UTF8 (const char *S, size_type Length) {return From_UTF8(S, 0, Length);}; /// @brief convert an UTF-16 encoded string into Ztring Ztring& From_UTF16 (const char *S); /// @brief convert an UTF-16 encoded string into Ztring Ztring& From_UTF16 (const char *S, size_type Start, size_type Length); /// @brief convert an UTF-16 encoded string into Ztring Ztring& From_UTF16 (const char *S, size_type Length) {return From_UTF16(S, 0, Length);}; /// @brief convert an UTF-16BE encoded string into Ztring Ztring& From_UTF16BE (const char *S); /// @brief convert an UTF-16BE encoded string into Ztring Ztring& From_UTF16BE (const char *S, size_type Start, size_type Length); /// @brief convert an UTF-16BE encoded string into Ztring Ztring& From_UTF16BE (const char *S, size_type Length) {return From_UTF16BE(S, 0, Length);}; /// @brief convert an UTF-16LE encoded string into Ztring Ztring& From_UTF16LE (const char *S); /// @brief convert an UTF-16LE encoded string into Ztring Ztring& From_UTF16LE (const char *S, size_type Start, size_type Length); /// @brief convert an UTF-16LE encoded string into Ztring Ztring& From_UTF16LE (const char *S, size_type Length) {return From_UTF16LE(S, 0, Length);}; /// @brief convert an Locael encoded string into Ztring Ztring& From_Local (const std::string &S) {return From_Local(S.c_str());}; /// @brief convert an Local encoded string into Ztring Ztring& From_Local (const char *S); /// @brief convert an Local encoded string into Ztring Ztring& From_Local (const char *S, size_type Start, size_type Length); /// @brief convert an Local encoded string into Ztring Ztring& From_Local (const char *S, size_type Length) {return From_Local(S, 0, Length);}; /// @brief convert an ISO-8859-1 encoded string into Ztring Ztring& From_ISO_8859_1 (const char *S); /// @brief convert an ISO-8859-1 encoded string into Ztring Ztring& From_ISO_8859_1 (const char *S, size_type Start, size_type Length); /// @brief convert an ISO-8859-1 encoded string into Ztring Ztring& From_ISO_8859_1 (const char *S, size_type Length) {return From_ISO_8859_1(S, 0, Length);}; /// @brief convert an ISO-8859-2 encoded string into Ztring Ztring& From_ISO_8859_2 (const char *S); /// @brief convert an ISO-8859-1 encoded string into Ztring Ztring& From_ISO_8859_2 (const char *S, size_type Start, size_type Length); /// @brief convert an ISO-8859-1 encoded string into Ztring Ztring& From_ISO_8859_2 (const char *S, size_type Length) {return From_ISO_8859_2(S, 0, Length);}; /// @brief convert an 16 byte GUID into Ztring Ztring& From_GUID (const int128u S); /// @brief convert an 16 byte UUID into Ztring Ztring& From_UUID (const int128u S); /// @brief convert an 4 Character Code into Ztring Ztring& From_CC4 (const char *S) {return From_Local(S, 0, 4);}; /// @brief convert an 4 Character Code into Ztring Ztring& From_CC4 (const int8u *S) {return From_Local((const char*)S, 0, 4);}; /// @brief convert an 4 Character Code into Ztring Ztring& From_CC4 (const int32u S); /// @brief convert an 2 Character Code into Ztring Ztring& From_CC3 (const char *S) {return From_Local(S, 0, 3);}; /// @brief convert an 4 Character Code into Ztring Ztring& From_CC3 (const int8u *S) {return From_Local((const char*)S, 0, 3);}; /// @brief convert an 4 Character Code into Ztring Ztring& From_CC3 (const int32u S); /// @brief convert an 2 Character Code into Ztring Ztring& From_CC2 (const char *S) {return From_CC2(ZenLib::CC2(S));}; /// @brief convert an 2 Character Code into Ztring Ztring& From_CC2 (const int8u *S) {return From_CC2(ZenLib::CC2(S));}; /// @brief convert an 2 Character Code into Ztring Ztring& From_CC2 (const int16u S); /// @brief convert an 1 Character Code into Ztring Ztring& From_CC1 (const char *S) {return From_CC1(ZenLib::CC1(S));}; /// @brief convert an 1 Character Code into Ztring Ztring& From_CC1 (const int8u *S) {return From_CC1(ZenLib::CC1(S));}; /// @brief convert an 1 Character Code into Ztring Ztring& From_CC1 (const int8u S); /// @brief convert number into Ztring Ztring& From_Number (const int8s, int8u Radix=10); /// @brief convert number into Ztring Ztring& From_Number (const int8u, int8u Radix=10); /// @brief convert number into Ztring Ztring& From_Number (const int16s, int8u Radix=10); /// @brief convert number into Ztring Ztring& From_Number (const int16u, int8u Radix=10); /// @brief convert number into Ztring Ztring& From_Number (const int32s, int8u Radix=10); /// @brief convert number into Ztring Ztring& From_Number (const int32u, int8u Radix=10); /// @brief convert number into Ztring Ztring& From_Number (const int64s, int8u Radix=10); /// @brief convert number into Ztring Ztring& From_Number (const int64u, int8u Radix=10); /// @brief convert number into Ztring Ztring& From_Number (const int128u, int8u Radix=10); /// @brief convert number into Ztring Ztring& From_Number (const float32, int8u AfterComma=3, ztring_t Options=Ztring_Nothing); /// @brief convert number into Ztring Ztring& From_Number (const float64, int8u AfterComma=3, ztring_t Options=Ztring_Nothing); /// @brief convert number into Ztring Ztring& From_Number (const float80, int8u AfterComma=3, ztring_t Options=Ztring_Nothing); #ifdef SIZE_T_IS_LONG /// @brief convert number into Ztring Ztring& From_Number (const size_t, int8u Radix=10); #endif //SIZE_T_IS_LONG /// @brief convert number (BCD coded) into Ztring Ztring& From_BCD (const int8u); /// @brief convert count of milliseconds into a readable and sortable string Ztring& Duration_From_Milliseconds (const int64s Milliseconds); /// @deprecated replaced by the int64s version Ztring& Duration_From_Milliseconds (const int64u Milliseconds); /// @brief convert count of seconds since 1601 into a readable and sortable string Ztring& Date_From_Milliseconds_1601 (const int64u Milliseconds); /// @brief convert count of seconds since 1601 into a readable and sortable string Ztring& Date_From_Seconds_1601 (const int64u Seconds); /// @brief convert count of seconds since 1900 into a readable and sortable string Ztring& Date_From_Seconds_1900 (const int32u Seconds); /// @brief convert count of seconds since 1900 into a readable and sortable string Ztring& Date_From_Seconds_1900 (const int64s Seconds); /// @brief convert count of seconds since 1904 into a readable and sortable string Ztring& Date_From_Seconds_1904 (const int32u Seconds); /// @brief convert count of seconds since 1904 into a readable and sortable string Ztring& Date_From_Seconds_1904 (const int64u Seconds); /// @brief convert count of seconds since 1904 into a readable and sortable string Ztring& Date_From_Seconds_1904 (const int64s Seconds); /// @brief convert count of seconds since 1970 into a readable and sortable string Ztring& Date_From_Seconds_1970 (const int32u Seconds); /// @brief convert count of seconds since 1970 into a readable and sortable string Ztring& Date_From_Seconds_1970 (const int32s Seconds); /// @brief convert count of seconds since 1970 into a readable and sortable string Ztring& Date_From_Seconds_1970 (const int64s Seconds); /// @brief convert count of seconds since 1970 into a readable and sortable string (in local time) Ztring& Date_From_Seconds_1970_Local (const int32u Seconds); /// @brief convert a free formated string into a readable and sortable string Ztring& Date_From_String (const char* Date, size_type Value_Size=Error); /// @brief convert numbers into a readable and sortable string Ztring& Date_From_Numbers (const int8u Year, const int8u Month, const int8u Day, const int8u Hour, const int8u Minute, const int8u Second); //Conversions - To #ifndef WSTRING_MISSING /// @brief Convert into Unicode chars /// @return the string corresponding \n std::wstring To_Unicode () const; #endif //WSTRING_MISSING /// @brief Convert into char* (UTF-8 encoded) /// @return the string corresponding \n std::string To_UTF8 () const; /// @brief Convert into char* (Local encoded) /// @return the string corresponding \n std::string To_Local () const; /// @brief Convert into 16 byte UUID number /// @return the value corresponding \n /// 0 if there is a problem int128u To_UUID () const; /// @brief Convert into a 4 Character Code /// @return the value corresponding \n /// 0 if there is a problem int32u To_CC4 () const; /// @brief Convert into Int (8 bits) /// @return the value corresponding \n /// 0 if there is a problem int8s To_int8s (int8u Radix=10, ztring_t Options=Ztring_Rounded) const; /// @brief Convert into unsigned Int (8 bits) /// @return the value corresponding /// 0 if there is a problem int8u To_int8u (int8u Radix=10, ztring_t Options=Ztring_Rounded) const; /// @brief Convert into Int (16 bits) /// @return the value corresponding \n /// 0 if there is a problem int16s To_int16s (int8u Radix=10, ztring_t Options=Ztring_Rounded) const; /// @brief Convert into unsigned Int (16 bits) /// @return the value corresponding /// 0 if there is a problem int16u To_int16u (int8u Radix=10, ztring_t Options=Ztring_Rounded) const; /// @brief Convert into Int (32 bits) /// @return the value corresponding \n /// 0 if there is a problem int32s To_int32s (int8u Radix=10, ztring_t Options=Ztring_Rounded) const; /// @brief Convert into unsigned Int (32 bits) /// @return the value corresponding /// 0 if there is a problem int32u To_int32u (int8u Radix=10, ztring_t Options=Ztring_Rounded) const; /// @brief Convert into Int (64 bits) /// @return the value corresponding \n /// 0 if there is a problem int64s To_int64s (int8u Radix=10, ztring_t Options=Ztring_Rounded) const; /// @brief Convert into unsigned Int (64 bits) /// @return the value corresponding \n /// 0 if there is a problem int64u To_int64u (int8u Radix=10, ztring_t Options=Ztring_Rounded) const; /// @brief Convert into unsigned Int (64 bits) /// @warning only hexadecimal and no rounding are currenlty supported \n /// @return the value corresponding \n /// 0 if there is a problem int128u To_int128u (int8u Radix=10, ztring_t Options=Ztring_Rounded) const; /// @brief Convert into float /// @return the value corresponding \n /// 0 if there is a problem float32 To_float32 (ztring_t Options=Ztring_Nothing) const; float64 To_float64 (ztring_t Options=Ztring_Nothing) const; float80 To_float80 (ztring_t Options=Ztring_Nothing) const; //Static versions static Ztring ToZtring_From_Local(const std::string &S) {return Ztring().From_Local(S);}; static Ztring ToZtring_From_Local(const char *S) {return Ztring().From_Local(S);}; static Ztring ToZtring_From_Local(const char *S, size_type Start, size_type Length) {return Ztring().From_Local(S, Start, Length);}; static Ztring ToZtring_From_Local(const char *S, size_type Length) {return Ztring().From_Local(S, Length);}; static Ztring ToZtring_From_CC4 (const char *S) {return Ztring().From_CC4(S);}; static Ztring ToZtring_From_CC4 (const int8u *S) {return Ztring().From_CC4(S);}; static Ztring ToZtring_From_CC4 (const int32u S) {return Ztring().From_CC4(S);}; static Ztring ToZtring_From_CC3 (const char *S) {return Ztring().From_CC3(S);}; static Ztring ToZtring_From_CC3 (const int8u *S) {return Ztring().From_CC3(S);}; static Ztring ToZtring_From_CC3 (const int32u S) {return Ztring().From_CC3(S);}; static Ztring ToZtring_From_CC2 (const char *S) {return Ztring().From_CC2(S);}; static Ztring ToZtring_From_CC2 (const int8u *S) {return Ztring().From_CC2(S);}; static Ztring ToZtring_From_CC2 (const int16u S) {return Ztring().From_CC2(S);}; static Ztring ToZtring_From_CC1 (const char *S) {return Ztring().From_CC1(S);}; static Ztring ToZtring_From_CC1 (const int8u *S) {return Ztring().From_CC1(S);}; static Ztring ToZtring_From_CC1 (const int8u S) {return Ztring().From_CC1(S);}; static Ztring ToZtring (const int8s I, int8u Radix=10) {return Ztring().From_Number(I, Radix);}; static Ztring ToZtring (const int8u I, int8u Radix=10) {return Ztring().From_Number(I, Radix);}; static Ztring ToZtring (const int16s I, int8u Radix=10) {return Ztring().From_Number(I, Radix);}; static Ztring ToZtring (const int16u I, int8u Radix=10) {return Ztring().From_Number(I, Radix);}; static Ztring ToZtring (const int32s I, int8u Radix=10) {return Ztring().From_Number(I, Radix);}; static Ztring ToZtring (const int32u I, int8u Radix=10) {return Ztring().From_Number(I, Radix);}; static Ztring ToZtring (const int64s I, int8u Radix=10) {return Ztring().From_Number(I, Radix);}; static Ztring ToZtring (const int64u I, int8u Radix=10) {return Ztring().From_Number(I, Radix);}; static Ztring ToZtring (const int128u I, int8u Radix=10) {return Ztring().From_Number(I, Radix);}; static Ztring ToZtring (const float32 F, int8u AfterComma=3) {return Ztring().From_Number(F, AfterComma);}; static Ztring ToZtring (const float64 F, int8u AfterComma=3) {return Ztring().From_Number(F, AfterComma);}; static Ztring ToZtring (const float80 F, int8u AfterComma=3) {return Ztring().From_Number(F, AfterComma);}; #ifdef SIZE_T_IS_LONG static Ztring ToZtring (const size_t I, int8u Radix=10) {return Ztring().From_Number(I, Radix);}; #endif //SIZE_T_IS_LONG //Edition /// @brief test if it is a number bool IsNumber() const; /// @brief convert into lowercase Ztring &MakeLowerCase(); /// @brief convert into uppercase Ztring &MakeUpperCase(); /// @brief Remove leading whitespaces from a string Ztring &TrimLeft(Char ToTrim=__T(' ')); /// @brief Remove trailing whitespaces from a string Ztring &TrimRight(Char ToTrim=__T(' ')); /// @brief Remove leading and trailing whitespaces from a string Ztring &Trim(Char ToTrim=__T(' ')); /// @brief Quotes a string Ztring &Quote(Char ToTrim=__T('\"')); /// @brief return a string between two strings /// @param Begin First string /// @param End Second string /// @param Pos Position to begin to scan string /// @param Options Options for searching \n /// Available : Ztring_CaseSensitive /// @return The substring \n /// "" if not found Ztring SubString (const tstring &Begin, const tstring &End, size_type Pos=0, ztring_t Options=Ztring_Nothing) const; /// @brief replace a string by another one /// @param ToFind string to find /// @param ToReplace string wich replace the string found /// @param Pos Position to begin to scan string /// @param Options Options for searching \n /// Available : Ztring_CaseSensitive, Ztring_Recursive /// @return The count of replacements size_type FindAndReplace (const tstring &ToFind, const tstring &ReplaceBy, size_type Pos=0, ztring_t Options=Ztring_Nothing); //Remplace une chaine par une autre /// @brief Count the number of occurencies of a string in the string /// @param ToCount string to count /// @param Options Options for count \n /// Available : Ztring_CaseSensitive /// @return the count //Information size_type Count (const Ztring &ToCount, ztring_t Options=Ztring_Nothing) const; /// @brief compare with another string /// @param ToCompare string to compare with /// @param Options Options for comaparing \n /// Available : Ztring_CaseSensitive /// @return The result of comparasion bool Compare (const Ztring &ToCompare, const Ztring &Comparator=__T("=="), ztring_t Options=Ztring_Nothing) const; }; } //NameSpace #endif ZenLib/Source/ZenLib/FileName.h0000664000000000000000000000546512615631146015234 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a zlib-style license that can * be found in the License.txt file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // File name related functions // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef ZenLib_FileNameH #define ZenLib_FileNameH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "ZenLib/Ztring.h" //--------------------------------------------------------------------------- namespace ZenLib { //*************************************************************************** /// @brief File name manipulation //*************************************************************************** class FileName : public ZenLib::Ztring { public : //Constructor/Destructor FileName () : Ztring(){}; FileName (const tstring& str) : Ztring(str){}; FileName (const tstring& str, size_type pos, size_type n=npos) : Ztring(str, pos, n){}; FileName (const Char* s, size_type n) : Ztring(s, n){}; FileName (const Char* s) : Ztring(s){}; FileName (size_type n, char c) : Ztring(n, c){}; //Read/Write ZenLib::Ztring Path_Get () const; ZenLib::Ztring Name_Get () const; ZenLib::Ztring Extension_Get () const; ZenLib::Ztring& Path_Set (const Ztring &Path); ZenLib::Ztring& Name_Set (const Ztring &Name); ZenLib::Ztring& Extension_Set (const Ztring &Extension); //Helpers static ZenLib::Ztring Path_Get (const Ztring &File_Name) {return ((FileName&)File_Name).Path_Get();}; static ZenLib::Ztring Name_Get (const Ztring &File_Name) {return ((FileName&)File_Name).Name_Get();}; static ZenLib::Ztring Extension_Get (const Ztring &File_Name) {return ((FileName&)File_Name).Extension_Get();}; static ZenLib::Ztring TempFileName_Create (const Ztring &Prefix); }; //Platform differences extern const Char* FileName_PathSeparator; } //NameSpace //--------------------------------------------------------------------------- #ifdef __BORLANDC__ #pragma warn .8027 #endif //--------------------------------------------------------------------------- #endif ZenLib/Source/ZenLib/InfoMap.h0000664000000000000000000000376312615631146015104 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a zlib-style license that can * be found in the License.txt file in the root of the source tree. */ //--------------------------------------------------------------------------- #ifndef ZenLib_InfoMapH #define ZenLib_InfoMapH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "ZenLib/ZtringList.h" #include //--------------------------------------------------------------------------- namespace ZenLib { //*************************************************************************** /// @brief Helper for InfoMap //*************************************************************************** class InfoMap : public std::multimap { public : //Constructors/Destructor InfoMap (); InfoMap (const Ztring &Source); InfoMap (const Char *Source); #ifdef _UNICODE InfoMap (const char *Source); //convert a UTF-8 string into Unicode #endif //In/Out const Ztring &Get (const Ztring &Value, size_t Pos) const; const Ztring &Get (const Ztring &Value, size_t Pos, const Ztring &WithValue, size_t WithValue_Pos) const; void Write (const Ztring &NewLanguage); //Configuration /// @brief Set the Separator character void Separator_Set (size_type Level, const Ztring &NewSeparator); /// @brief Set the Quote character /// During Read() or Write() method, if Separator is in the sequence, we must quote it void Quote_Set (const Ztring &NewQuote); /// @brief Set the Maximum number of element to read /// During Read() or Write() method, if there is more elements, merge them with the last element void Max_Set (size_type Level, size_type Max); protected : Ztring Separator[2]; Ztring Quote; size_type Max[2]; }; } //namespace #endif ZenLib/Source/ZenLib/MemoryDebug.cpp0000664000000000000000000001365212615631146016323 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a zlib-style license that can * be found in the License.txt file in the root of the source tree. */ //--------------------------------------------------------------------------- #include "ZenLib/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "ZenLib/Conf_Internal.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #if defined(ZENLIB_DEBUG) //--------------------------------------------------------------------------- #include #include #include "ZenLib/MemoryDebug.h" #include "ZenLib/Ztring.h" #ifdef WINDOWS #include #else #include #endif #include #include using namespace std; //--------------------------------------------------------------------------- namespace ZenLib { //*************************************************************************** // Constructors/destructor //*************************************************************************** MemoryDebug::MemoryDebug() { } MemoryDebug::~MemoryDebug() { if (!m_Blocks.empty()) ReportLeaks(); } //*************************************************************************** // Instance //*************************************************************************** MemoryDebug& MemoryDebug::Instance() { static MemoryDebug Inst; return Inst; } //*************************************************************************** // Reports //*************************************************************************** void MemoryDebug::ReportLeaks() { Ztring m_File; //std::ofstream m_File ("Debug_MemoryLeak.txt"); // Fichier de sortie // Détail des fuites std::size_t TotalSize = 0; for (TBlockMap::iterator i = m_Blocks.begin(); i != m_Blocks.end(); ++i) { // Ajout de la taille du bloc au cumul TotalSize += i->second.Size; // Inscription dans le fichier des informations sur le bloc courant /* m_File << "-> 0x" << std::hex << i->first << std::dec << " | " << std::setw(7) << std::setfill(' ') << static_cast(i->second.Size) << " bytes" << " | " << i->second.File.c_str() << " (" << i->second.Line << ")" << std::endl; */ m_File.append(__T("-> 0x")); m_File.append(Ztring::ToZtring((size_t)i->first, 16)); m_File.append(__T(" | ")); Ztring Temp; Temp.From_Number(static_cast(i->second.Size)); while(Temp.size()<7) Temp=__T(" ")+Temp; m_File.append(Temp); m_File.append(__T(" bytes")); m_File.append(__T(" | ")); m_File.append(Ztring().From_Local(i->second.File.c_str())); m_File.append(__T(" (")); m_File.append(Ztring::ToZtring(i->second.Line)); m_File.append(__T(")")); m_File.append(EOL); } // Affichage du cumul des fuites /* m_File << std::endl << std::endl << "-- " << static_cast(m_Blocks.size()) << " non-released blocs, " << static_cast(TotalSize) << " bytes --" << std::endl; */ m_File.append(EOL); m_File.append(EOL); m_File.append(__T("-- ")); m_File.append(Ztring::ToZtring(static_cast(m_Blocks.size()))); m_File.append(__T(" non-released blocs, ")); m_File.append(Ztring::ToZtring(static_cast(TotalSize))); m_File.append(__T(" bytes --")); m_File.append(EOL); std::string ToWrite=m_File.To_Local().c_str(); int m_File_sav=open("Debug_MemoryLeak.txt", O_BINARY|O_RDWR |O_CREAT); // Fichier de sortie write(m_File_sav, (int8u*)ToWrite.c_str(), ToWrite.size()); close(m_File_sav); } //*************************************************************************** // Memory management //*************************************************************************** void* MemoryDebug::Allocate(std::size_t Size, const char* File, int Line, bool Array) { // Allocation de la mémoire void* Ptr = malloc(Size); // Ajout du bloc à la liste des blocs alloués TBlock NewBlock; NewBlock.Size = Size; NewBlock.File = File; NewBlock.Line = Line; NewBlock.Array = Array; m_Blocks[Ptr] = NewBlock; return Ptr; } void MemoryDebug::Free(void* Ptr, bool Array) { // Recherche de l'adresse dans les blocs alloués TBlockMap::iterator It = m_Blocks.find(Ptr); // Si le bloc n'a pas été alloué, on génère une erreur if (It == m_Blocks.end()) { // En fait ça arrive souvent, du fait que le delete surcharge est pris en compte meme la ou on n'inclue pas DebugNew.h, // mais pas la macro pour le new // Dans ce cas on détruit le bloc et on quitte immédiatement free(Ptr); return; } // Si le type d'allocation ne correspond pas, on génère une erreur if (It->second.Array != Array) { //throw CBadDelete(Ptr, It->second.File.c_str(), It->second.Line, !Array); } // Finalement, si tout va bien, on supprime le bloc et on loggiz tout ça m_Blocks.erase(It); m_DeleteStack.pop(); // Libération de la mémoire free(Ptr); } void MemoryDebug::NextDelete(const char* File, int Line) { TBlock Delete; Delete.File = File; Delete.Line = Line; m_DeleteStack.push(Delete); } //*************************************************************************** // //*************************************************************************** } //NameSpace #endif // defined(ZENLIB_DEBUG) ZenLib/Source/ZenLib/Format/0000775000000000000000000000000012615631146014621 5ustar rootrootZenLib/Source/ZenLib/Format/Html/0000775000000000000000000000000012615631146015525 5ustar rootrootZenLib/Source/ZenLib/Format/Html/Html_Handler.cpp0000664000000000000000000000272412615631146020577 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a zlib-style license that can * be found in the License.txt file in the root of the source tree. */ //--------------------------------------------------------------------------- #include "ZenLib/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "ZenLib/Conf_Internal.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "ZenLib/Format/Html/Html_Handler.h" using namespace std; //--------------------------------------------------------------------------- namespace ZenLib { namespace Format { namespace Html { //*************************************************************************** // Constructor/Destructor //*************************************************************************** //--------------------------------------------------------------------------- Handler::Handler() { } //*************************************************************************** // Helpers //*************************************************************************** void Handler::CleanUp() { } } //Namespace } //Namespace } //Namespace ZenLib/Source/ZenLib/Format/Html/Html_Request.h0000664000000000000000000000256512615631146020322 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a zlib-style license that can * be found in the License.txt file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // A HTML Request // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef ZenLib_Server_Html_RequestH #define ZenLib_Server_Html_RequestH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "ZenLib/Format/Html/Html_Handler.h" #include //--------------------------------------------------------------------------- namespace ZenLib { namespace Format { namespace Html { //*************************************************************************** /// @brief //*************************************************************************** class Request { public: //Constructor/Destructor Request(); Request(const Request &Req); ~Request(); //The data ZenLib::Format::Html::Handler *Html; bool IsCopy; }; } //Namespace } //Namespace } //Namespace #endif ZenLib/Source/ZenLib/Format/Html/Html_Request.cpp0000664000000000000000000000323612615631146020651 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a zlib-style license that can * be found in the License.txt file in the root of the source tree. */ //--------------------------------------------------------------------------- #include "ZenLib/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "ZenLib/Conf_Internal.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "ZenLib/Format/Html/Html_Request.h" //--------------------------------------------------------------------------- namespace ZenLib { namespace Format { namespace Html { //*************************************************************************** // Constructor/Destructor //*************************************************************************** //--------------------------------------------------------------------------- Request::Request() { //Config Html=new ZenLib::Format::Html::Handler; IsCopy=false; } //--------------------------------------------------------------------------- Request::Request(const Request &Req) { //Config Html=Req.Html; IsCopy=true; } //--------------------------------------------------------------------------- Request::~Request() { //Config if (!IsCopy) delete Html; //Html=NULL } } //Namespace } //Namespace } //Namespace ZenLib/Source/ZenLib/Format/Html/Html_Handler.h0000664000000000000000000000274512615631146020247 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a zlib-style license that can * be found in the License.txt file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // A HTML Handler // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef ZenLib_Server_Html_HandlerH #define ZenLib_Server_Html_HandlerH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include #include #include #include "ZenLib/Ztring.h" //--------------------------------------------------------------------------- namespace ZenLib { namespace Format { namespace Html { //*************************************************************************** /// @brief //*************************************************************************** struct header { //In Ztring Title; Ztring Language; //Init header() { } }; class Handler { public: //Constructor/Destructor Handler(); //Maintenance void CleanUp(); //The data header Header; }; } //Namespace } //Namespace } //Namespace #define ENDL "\r\n" #define HTML_ENDL "
\r\n" #endif ZenLib/Source/ZenLib/Format/Http/0000775000000000000000000000000012615631146015540 5ustar rootrootZenLib/Source/ZenLib/Format/Http/Http_Request.h0000664000000000000000000000304012615631146020335 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a zlib-style license that can * be found in the License.txt file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // A HTTP Request // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef ZenLib_Server_Http_RequestH #define ZenLib_Server_Http_RequestH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "ZenLib/Format/Http/Http_Handler.h" #include #include #include #include //--------------------------------------------------------------------------- namespace ZenLib { namespace Format { namespace Http { //*************************************************************************** /// @brief //*************************************************************************** class Request { public: //Constructor/Destructor Request(); Request(const Request &Req); ~Request(); //The data ZenLib::Format::Http::Handler *Http; bool IsCopy; //Helpers bool Http_Begin(std::istream &In, std::ostream &Out); void Http_End (std::ostream &Out); }; } //Namespace } //Namespace } //Namespace #endif ZenLib/Source/ZenLib/Format/Http/Http_Cookies.cpp0000664000000000000000000000667512615631146020655 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a zlib-style license that can * be found in the License.txt file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #include "ZenLib/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "ZenLib/Conf_Internal.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "ZenLib/Format/Http/Http_Cookies.h" #include "ZenLib/Format/Http/Http_Utils.h" using namespace std; //--------------------------------------------------------------------------- namespace ZenLib { namespace Format { namespace Http { //*************************************************************************** // Constructor/Destructor //*************************************************************************** //--------------------------------------------------------------------------- Cookies::Cookies() { } //*************************************************************************** // Helpers //*************************************************************************** //--------------------------------------------------------------------------- size_t Cookies::Set(const std::string &Name, const std::string &Value, std::time_t Expires, const std::string &Path, const std::string &Domain, bool Secure) { //Name must not be empty if (Name.empty()) return 1; //Default values handling if (Value.empty()) Expires=time(NULL)-365*24*60*60-1; //minus 1 year //Default value if (Expires==(time_t)-1) Expires=time(NULL)+1*365*24*60*60; //+1 year //Expires can be the count of seconds to handle instead of real time if (Expires>=0 && Expires<3*365*24*60*60) //Les than year 1973, this is not a date, this is a time Expires+=time(NULL); //Registering Cookie Data; Data.Value=Value.empty()?std::string("Deleted"):URL_Encoded_Encode(Value); //If no value, we force a default value for having the cookie understable Data.Expires=Expires; Data.Path=URL_Encoded_Encode(Path.empty()?string("/"):Path); Data.Domain=URL_Encoded_Encode(Domain); Data.Secure=Secure; (*this)[URL_Encoded_Encode(Name)]=Data; return 0; } //--------------------------------------------------------------------------- void Cookies::Create_Lines(std::ostream& Out) { for (Cookies::iterator Cookie=begin(); Cookie!=end(); ++Cookie) { Out << "Set-Cookie: " << Cookie->first << "=" << Cookie->second.Value; if (Cookie->second.Expires!=(time_t)-1) { char Temp[200]; if (strftime(Temp, 200, "%a, %d-%b-%Y %H:%M:%S GMT", gmtime(&Cookie->second.Expires))) Out << "; expires=" << Temp; } if (!Cookie->second.Path.empty()) { Out << "; path=" << Cookie->second.Path; } Out << "\r\n"; } } } //Namespace } //Namespace } //Namespace ZenLib/Source/ZenLib/Format/Http/Http_Utils.cpp0000664000000000000000000001562112615631146020350 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a zlib-style license that can * be found in the License.txt file in the root of the source tree. */ //--------------------------------------------------------------------------- #include "ZenLib/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "ZenLib/Conf_Internal.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "ZenLib/Format/Http/Http_Utils.h" using namespace std; //--------------------------------------------------------------------------- namespace ZenLib { namespace Format { namespace Http { //*************************************************************************** // Global variables //*************************************************************************** std::string EmptyString; //*************************************************************************** // Character manipulation //*************************************************************************** //--------------------------------------------------------------------------- unsigned char Char2Hex (unsigned char Char) { if (Char<='9' && Char>='0') Char-='0'; else if (Char<='f' && Char>='a') Char-='a'-10; else if (Char<='F' && Char>='A') Char-='A'-10; else Char =0; return Char; } //--------------------------------------------------------------------------- wchar_t Char2Hex (wchar_t Char) { if (Char<='9' && Char>='0') Char-='0'; else if (Char<='f' && Char>='a') Char-='a'-10; else if (Char<='F' && Char>='A') Char-='A'-10; else Char =0; return Char; } //--------------------------------------------------------------------------- string Hex2Char (unsigned char Char) { string Result; Result+=(char)((Char/16>=10?'a'-10:'0')+Char/16); Result+=(char)((Char%16>=10?'a'-10:'0')+Char%16); return Result; } //--------------------------------------------------------------------------- #ifndef WSTRING_MISSING wstring Hex2Char (wchar_t Char) { wstring Result; Result+=(Char/16>=10?'a'-10:'0')+Char/16; Result+=(Char%16>=10?'a'-10:'0')+Char%16; return Result; } #endif //WSTRING_MISSING //*************************************************************************** // URL manipulation //*************************************************************************** //--------------------------------------------------------------------------- std::string URL_Encoded_Encode (const std::string& URL) { string Result; string::size_type Pos; for (Pos=0; Pos='\x00' && URL[Pos]<='\x20') || URL[Pos]=='\x7F' || URL[Pos]==' ' || URL[Pos]=='<' || URL[Pos]=='>' || URL[Pos]=='#' || URL[Pos]=='%' || URL[Pos]=='\"' || URL[Pos]=='{' || URL[Pos]=='}' || URL[Pos]=='|' || URL[Pos]=='\\' || URL[Pos]=='^' || URL[Pos]=='[' || URL[Pos]==']' || URL[Pos]=='`' /*|| URL[Pos]==';' || URL[Pos]=='/' || URL[Pos]=='?' || URL[Pos]==':' || URL[Pos]=='@' || URL[Pos]=='&' || URL[Pos]=='=' || URL[Pos]=='+' || URL[Pos]=='$' || URL[Pos]==','*/) Result+='%'+Hex2Char((unsigned char)URL[Pos]); else Result+=URL[Pos]; } return Result; } //--------------------------------------------------------------------------- #ifndef WSTRING_MISSING std::wstring URL_Encoded_Encode (const std::wstring& URL) { wstring Result; wstring::size_type Pos; for (Pos=0; Pos' || URL[Pos]==L'#' || URL[Pos]==L'%' || URL[Pos]==L'\"' || URL[Pos]==L'{' || URL[Pos]==L'}' || URL[Pos]==L'|' || URL[Pos]==L'\\' || URL[Pos]==L'^' || URL[Pos]==L'[' || URL[Pos]==L']' || URL[Pos]==L'`' /*|| URL[Pos]==L';' || URL[Pos]==L'/' || URL[Pos]==L'?' || URL[Pos]==L':' || URL[Pos]==L'@' || URL[Pos]==L'&' || URL[Pos]==L'=L' || URL[Pos]==L'+' || URL[Pos]==L'$' || URL[Pos]==L','*/) Result+=L'%'+Hex2Char(URL[Pos]); else Result+=URL[Pos]; } return Result; } #endif //WSTRING_MISSING //--------------------------------------------------------------------------- std::string URL_Encoded_Decode (const std::string& URL) { string Result; string::size_type Pos; for (Pos=0; Pos using namespace std; //--------------------------------------------------------------------------- namespace ZenLib { namespace Format { namespace Http { //*************************************************************************** // Constructor/Destructor //*************************************************************************** //--------------------------------------------------------------------------- Handler::Handler() { //In Foreign_Port=0; Local_Port=0; HeadersOnly=false; //Out Response_HTTP_Code=200; } } //Namespace } //Namespace } //Namespace ZenLib/Source/ZenLib/Format/Http/Http_Utils.h0000664000000000000000000000405412615631146020013 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a zlib-style license that can * be found in the License.txt file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // HTTP utils // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef ZenLib_Server_Http_UtilsH #define ZenLib_Server_Http_UtilsH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include #include #include #include //--------------------------------------------------------------------------- namespace ZenLib { namespace Format { namespace Http { //*************************************************************************** // //*************************************************************************** //--------------------------------------------------------------------------- // Character manipulation unsigned char Char2Hex (unsigned char Char); wchar_t Char2Hex (wchar_t Char); std::string Hex2Char (unsigned char Char); #ifndef WSTRING_MISSING std::wstring Hex2Char (wchar_t Char); #endif //WSTRING_MISSING //--------------------------------------------------------------------------- // URL manipulation std::string URL_Encoded_Encode (const std::string& URL); #ifndef WSTRING_MISSING std::wstring URL_Encoded_Encode (const std::wstring& URL); #endif //WSTRING_MISSING std::string URL_Encoded_Decode (const std::string& URL); #ifndef WSTRING_MISSING std::wstring URL_Encoded_Decode (const std::wstring& URL); #endif //WSTRING_MISSING //--------------------------------------------------------------------------- // Cleanup void TrimLeft (std::string& String, char ToTrim); } //Namespace } //Namespace } //Namespace #endif //ZENLIB_SERVER_HTTP_UTILS ZenLib/Source/ZenLib/Format/Http/Http_Handler.h0000664000000000000000000000546112615631146020273 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a zlib-style license that can * be found in the License.txt file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // A HTTP Request // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef ZenLib_Format_Http_RequestH #define ZenLib_Format_Http_RequestH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "ZenLib/Format/Http/Http_Cookies.h" #include #include #include #include //--------------------------------------------------------------------------- namespace ZenLib { namespace Format { namespace Http { //*************************************************************************** /// @brief //*************************************************************************** class Handler { public: //Constructor/Destructor Handler(); //In std::string Path; //The path being requested by this request std::map Request_Headers; //All the incoming HTTP headers from the client web browser. std::map Request_Cookies; //The set of cookies that came from the client along with this request std::map Request_Queries; //All the key/value pairs in the query string of this request std::string Foreign_IP; //The foreign ip address for this request std::string Local_IP; //The foreign port number for this request unsigned short Foreign_Port; //The IP of the local interface this request is coming in on unsigned short Local_Port; //The local port number this request is coming in on bool HeadersOnly; //The request requests only the header //Out size_t Response_HTTP_Code; //HTTP code to be sent std::map Response_Headers; //Additional headers you wish to appear in the HTTP response to this request Cookies Response_Cookies; //New cookies to pass back to the client along with the result of this request std::string Response_Body; //To be displayed as the response to this request }; } //Namespace } //Namespace } //Namespace #endif ZenLib/Source/ZenLib/Format/Http/Http_Request.cpp0000664000000000000000000002204112615631146020672 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a zlib-style license that can * be found in the License.txt file in the root of the source tree. */ //--------------------------------------------------------------------------- #include "ZenLib/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "ZenLib/Conf_Internal.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "ZenLib/Format/Http/Http_Request.h" #include "ZenLib/Format/Http/Http_Utils.h" #include "ZenLib/Ztring.h" using namespace std; //--------------------------------------------------------------------------- namespace ZenLib { namespace Format { namespace Http { //*************************************************************************** // Constructor/Destructor //*************************************************************************** //--------------------------------------------------------------------------- Request::Request() { //Config Http=new ZenLib::Format::Http::Handler; IsCopy=false; } //--------------------------------------------------------------------------- Request::Request(const Request &Req) { //Config Http=Req.Http; IsCopy=true; } //--------------------------------------------------------------------------- Request::~Request() { //Config if (!IsCopy) delete Http; //Http=NULL } //*************************************************************************** // //*************************************************************************** //--------------------------------------------------------------------------- bool Request::Http_Begin(std::istream &In, std::ostream &Out) { //First line, "Method Path Norm" //-Method string Method; In>>Method; if (Method.size()==3 && Method[0]=='G' && Method[1]=='E' && Method[2]=='T') ; else if (Method.size()==4 && Method[0]=='P' && Method[1]=='O' && Method[2]=='S' && Method[3]=='T') ; else if (Method.size()==4 && Method[0]=='H' && Method[1]=='E' && Method[2]=='A' && Method[3]=='D') Http->HeadersOnly=true; else { Out << "HTTP/1.0 501\r\n"; Out << "\r\n"; return false; //Unknown request } //-Path In>>Http->Path; if (Http->Path.empty() || Http->Path[0]!='/') { Out << "HTTP/1.0 404\r\n"; Out << "\r\n"; return false; //Problem } if (Http->Path.size()>8096) //Browsers/Servers have a 2K-8K limit, we do same { Out << "HTTP/1.0 414\r\n"; Out << "\r\n"; return false; //Problem } if (Http->Path.find("%")!=string::npos) Http->Path=Format::Http::URL_Encoded_Decode(Http->Path); //-Norm string Line; getline(In, Line); //Drop the first line, no more needed //Headers do { //Getting the line getline(In, Line); if (!Line.empty() && Line[Line.size()-1]=='\r') Line.resize(Line.size()-1); //Remove the \r //Processing the line, form is "aaa: bbb" if (!Line.empty()) { string::size_type Separator_Pos=Line.find(':'); string::size_type Content_Begin=Line.find_first_not_of(' ', Separator_Pos+1); if (Separator_Pos!=string::npos && Content_Begin!=string::npos) { string Command=Line.substr(0, Separator_Pos); if (Command=="Cookie") { string Cookie=Line.substr(Separator_Pos+1, string::npos); while (!Cookie.empty()) { string::size_type Cookie_Pos=Cookie.rfind(';'); if (Cookie_Pos==string::npos) Cookie_Pos=(string::size_type)-1; string Line2=Cookie.substr(Cookie_Pos+1, string::npos); TrimLeft(Line2, ' '); if (Cookie_Pos!=(string::size_type)-1) { Cookie.resize(Cookie_Pos); TrimLeft(Line2, ' '); } else Cookie.clear(); string::size_type Separator_Pos2=Line2.find('='); if (Separator_Pos2!=string::npos) Http->Request_Cookies[Line2.substr(0, Separator_Pos2)]=Format::Http::URL_Encoded_Decode(Line2.substr(Separator_Pos2+1, string::npos)); } } else Http->Request_Headers[Command]=Line.substr(Content_Begin, string::npos); } } } while (!Line.empty()); //Info if ((Method.size()==3 && Method[0]=='G' && Method[1]=='E' && Method[2]=='T') || (Method.size()==4 && Method[0]=='P' && Method[1]=='O' && Method[2]=='S' && Method[3]=='T')) { do { string Content; //Getting the line string::size_type Interogation_Pos=Http->Path.find('?'); if (Interogation_Pos!=string::npos) { Content=Http->Path.substr(Interogation_Pos+1, string::npos); Http->Path.resize(Interogation_Pos); } if (Method.size()==4) //Only for POST { int64u Content_Lengh=0; std::map::iterator Header_Content_Lengh_Element=Http->Request_Headers.find("Content-Length"); if (Header_Content_Lengh_Element==Http->Request_Headers.end()) Header_Content_Lengh_Element=Http->Request_Headers.find("Content-length"); if (Header_Content_Lengh_Element!=Http->Request_Headers.end()) #ifdef UNICODE Content_Lengh=Ztring().From_UTF8(Header_Content_Lengh_Element->second).To_int64u(); #else Content_Lengh=Ztring(Header_Content_Lengh_Element->second).To_int64u(); #endif if (Content_Lengh>1024) //Verifying there is no big element { Out << "HTTP/1.0 501\r\n"; Out << "\r\n"; return false; //Malformed request } size_t Content_Size_Current=Content.size(); if (Content_Size_Current) { Content+='&'; Content_Size_Current++; } Content.resize(Content_Size_Current+(size_t)Content_Lengh+1); In.read(&Content[Content_Size_Current], (streamsize)Content_Lengh); Content[Content_Size_Current+(size_t)Content_Lengh]='\0'; } //Processing the line, form is "aaa=bbb&..." while (!Content.empty()) { string::size_type Content_Pos=Content.rfind('&'); if (Content_Pos==string::npos) Content_Pos=(string::size_type)-1; std::string Line2=Content.substr(Content_Pos+1, string::npos); if (Content_Pos!=(string::size_type)-1) Content.resize(Content_Pos); else Content.clear(); string::size_type Separator_Pos=Line2.find('='); if (Separator_Pos!=string::npos) Http->Request_Queries[Line2.substr(0, Separator_Pos)]=Format::Http::URL_Encoded_Decode(Line2.substr(Separator_Pos+1, string::npos)); } } while (!Line.empty()); } return true; } void Request::Http_End(std::ostream &Out) { Out << "HTTP/1.0 "<< Http->Response_HTTP_Code << "\r\n"; for (std::map::iterator Temp=Http->Response_Headers.begin(); Temp!=Http->Response_Headers.end(); ++Temp) Out << Temp->first << ": " << Temp->second << "\r\n"; Http->Response_Cookies.Create_Lines(Out); std::map::iterator Content_Type_Element=Http->Response_Headers.find("Content-Type"); if (Content_Type_Element!=Http->Response_Headers.end()) Out << "Content-Type: "<< Content_Type_Element->second << "\r\n"; else if (Http->Response_HTTP_Code==200) { if (!Http->Response_Body.empty() && Http->Response_Body[0]=='<') Out << "Content-Type: "<< "text/html; charset=utf-8" << "\r\n"; } if (!Http->Response_Body.empty()) Out << "Content-Length: " << Http->Response_Body.size() << "\r\n"; Out << "\r\n"; if (!Http->HeadersOnly && !Http->Response_Body.empty()) Out << Http->Response_Body.c_str(); } } //Namespace } //Namespace } //Namespace ZenLib/Source/ZenLib/Format/Http/Http_Cookies.h0000664000000000000000000000351512615631146020310 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a zlib-style license that can * be found in the License.txt file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Cookies handling // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef ZenLib_Format_Http_CookiesH #define ZenLib_Format_Http_CookiesH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include #include #include #include //--------------------------------------------------------------------------- namespace ZenLib { namespace Format { namespace Http { //*************************************************************************** /// @brief //*************************************************************************** struct Cookie { std::string Value; std::time_t Expires; std::string Path; std::string Domain; bool Secure; Cookie() { Expires=0; Secure=false; } }; extern std::string EmptyString; //Must not change class Cookies : public std::map { public : //Constructor/Destructor Cookies(); //Helpers size_t Set(const std::string &Name, const std::string &Value=EmptyString, std::time_t Expires=(std::time_t)-1, const std::string &Path=EmptyString, const std::string &Domain=EmptyString, bool Secure=false); Cookie &Get(const std::string &Name); void Create_Lines(std::ostream& Out); }; } //Namespace } //Namespace } //Namespace #endif ZenLib/Source/ZenLib/Dir.h0000664000000000000000000000435212615631146014264 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a zlib-style license that can * be found in the License.txt file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Directories functions // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef ZenLib_DirH #define ZenLib_DirH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "ZenLib/ZtringList.h" //--------------------------------------------------------------------------- namespace ZenLib { //*************************************************************************** /// @brief Directory manipulation //*************************************************************************** class Dir { public : //--------------------------------------------------------------------------- /// @brief Options for Open method enum dirlist_t { Nothing = 0x00, ///< Include_Files = 0x01, ///< Include files Include_Dirs = 0x02, ///< Include directories Include_Hidden = 0x04, ///< Include hidden files Parse_SubDirs = 0x10 ///< Parse subdirectories }; //Constructor/Destructor //Open/close static ZtringList GetAllFileNames(const Ztring &Dir_Name, dirlist_t Options=(dirlist_t)(Include_Files|Parse_SubDirs)); //Helpers static bool Exists(const Ztring &Dir_Name); static bool Create(const Ztring &Dir_Name); }; #ifdef WINDOWS class GetAllFileNames_Private; class GetAllFileNames { public: //Constructor/Destructor GetAllFileNames(); ~GetAllFileNames(); // void Start (const Ztring &Dir_Name, Dir::dirlist_t Options=(Dir::dirlist_t)(Dir::Include_Files|Dir::Parse_SubDirs)); bool Next (Ztring& Name); void Close (); private: GetAllFileNames_Private* p; }; #endif //WINDOWS } //NameSpace #endif ZenLib/Source/ZenLib/OS_Utils.cpp0000664000000000000000000001375412615631146015610 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a zlib-style license that can * be found in the License.txt file in the root of the source tree. */ //--------------------------------------------------------------------------- #include "ZenLib/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "ZenLib/Conf_Internal.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #ifdef ZENLIB_USEWX #else //ZENLIB_USEWX #ifdef WINDOWS #undef __TEXT #include #include #endif #endif //ZENLIB_USEWX #include "ZenLib/OS_Utils.h" //--------------------------------------------------------------------------- namespace ZenLib { //*************************************************************************** // OS info //*************************************************************************** //--------------------------------------------------------------------------- bool IsWin9X () { return false; //Hardcoded value because we don't support Win9x anymore } //*************************************************************************** // Shell //*************************************************************************** void Shell_Execute(const Ztring &ToExecute) { #ifdef ZENLIB_USEWX #else //ZENLIB_USEWX #ifdef WINDOWS ShellExecute(NULL, __T("open"), ToExecute.c_str(), NULL, NULL, 0); #else //Not supported #endif #endif //ZENLIB_USEWX } //*************************************************************************** // Directories //*************************************************************************** //--------------------------------------------------------------------------- // Select directory code // Extracted from TBffolder by Torsten Johann (t-johann@gmx.de) Ztring Directory_Select_Caption; #ifdef WINDOWS #ifdef UNICODE char InitDirA[MAX_PATH]; wchar_t InitDir [MAX_PATH]; int __stdcall ShowOpenFolder_CallbackProc (HWND hwnd, UINT uMsg, LPARAM, LPARAM) { if (uMsg==BFFM_INITIALIZED) { SetWindowText(hwnd, Directory_Select_Caption.c_str()); // Caption SendMessage (hwnd, BFFM_ENABLEOK, 0, TRUE); SendMessage (hwnd, BFFM_SETSELECTION, true, (LPARAM)&InitDir); } return 0; } Ztring OpenFolder_Show(void* Handle, const Ztring &Title, const Ztring &Caption) { //Caption Directory_Select_Caption=Caption; //Values LPMALLOC Malloc; LPSHELLFOLDER ShellFolder; BROWSEINFO BrowseInfo; LPITEMIDLIST ItemIdList; //Initializing the SHBrowseForFolder function if (SHGetMalloc(&Malloc)!=NOERROR) return Ztring(); if (SHGetDesktopFolder(&ShellFolder)!=NOERROR) return Ztring(); ZeroMemory(&BrowseInfo, sizeof(BROWSEINFOW)); BrowseInfo.ulFlags+=BIF_RETURNONLYFSDIRS; BrowseInfo.hwndOwner=(HWND)Handle; BrowseInfo.pszDisplayName=InitDir; BrowseInfo.lpszTitle=Title.c_str(); BrowseInfo.lpfn=ShowOpenFolder_CallbackProc; //Displaying ItemIdList=SHBrowseForFolder(&BrowseInfo); //Releasing ShellFolder->Release(); if (ItemIdList!=NULL) { SHGetPathFromIDList(ItemIdList, InitDir); Malloc->Free(ItemIdList); Malloc->Release(); //The value return InitDir; } else return Ztring(); } #else char InitDirA[MAX_PATH]; int __stdcall ShowOpenFolder_CallbackProc (HWND hwnd, UINT uMsg, LPARAM, LPARAM) { if (uMsg==BFFM_INITIALIZED) { SetWindowText (hwnd, Directory_Select_Caption.c_str()); // Caption SendMessage (hwnd, BFFM_ENABLEOK, 0, TRUE); SendMessage (hwnd, BFFM_SETSELECTION, true, (LPARAM)&InitDirA); } return 0; } Ztring OpenFolder_Show(void* Handle, const Ztring &Title, const Ztring &Caption) { //Caption Directory_Select_Caption=Caption; //Values LPMALLOC Malloc; LPSHELLFOLDER ShellFolder; BROWSEINFO BrowseInfo; LPITEMIDLIST ItemIdList; //Initializing the SHBrowseForFolder function if (SHGetMalloc(&Malloc)!=NOERROR) return Ztring(); if (SHGetDesktopFolder(&ShellFolder)!=NOERROR) return Ztring(); ZeroMemory(&BrowseInfo, sizeof(BROWSEINFO)); BrowseInfo.ulFlags+=BIF_RETURNONLYFSDIRS; BrowseInfo.hwndOwner=(HWND)Handle; BrowseInfo.pszDisplayName=InitDirA; BrowseInfo.lpszTitle=Title.c_str(); BrowseInfo.lpfn=ShowOpenFolder_CallbackProc; //Displaying ItemIdList=SHBrowseForFolder(&BrowseInfo); //Releasing ShellFolder->Release(); if (ItemIdList!=NULL) { SHGetPathFromIDList(ItemIdList, InitDirA); Malloc->Free(ItemIdList); Malloc->Release(); //The value return InitDirA; } else return Ztring(); } #endif //UNICODE #endif //WINDOWS } //namespace ZenLib ZenLib/Source/ZenLib/MemoryDebug.h0000664000000000000000000000724312615631146015767 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a zlib-style license that can * be found in the License.txt file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // MemoryDebug // // Provide "new" and "delete" overloadings to be able to detect memory leaks // Based on http://loulou.developpez.com/tutoriels/moteur3d/partie1/ 2.2.1 // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef ZenMemoryDebugH #define ZenMemoryDebugH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #if defined(ZENLIB_DEBUG) //--------------------------------------------------------------------------- #include "ZenLib/Conf.h" #include #include #include #include //--------------------------------------------------------------------------- namespace ZenLib { //*************************************************************************** // Class //*************************************************************************** class MemoryDebug { public : ~MemoryDebug(); static MemoryDebug& Instance(); void* Allocate(std::size_t Size, const char* File, int Line, bool Array); void Free(void* Ptr, bool Array); void NextDelete(const char*, int Line); //Sauvegarde les infos sur la désallocation courante void ReportLeaks(); private : MemoryDebug(); struct TBlock { std::size_t Size; // Taille allouée std::string File; // Fichier contenant l'allocation int Line; // Ligne de l'allocation bool Array; // Est-ce un objet ou un tableau ? }; typedef std::map TBlockMap; TBlockMap m_Blocks; // Blocs de mémoire alloués std::stack m_DeleteStack; // Pile dont le sommet contient la ligne et le fichier de la prochaine désallocation }; } //NameSpace //*************************************************************************** // operator overloadings //*************************************************************************** inline void* operator new(std::size_t Size, const char* File, int Line) { return ZenLib::MemoryDebug::Instance().Allocate(Size, File, Line, false); } inline void* operator new[](std::size_t Size, const char* File, int Line) { return ZenLib::MemoryDebug::Instance().Allocate(Size, File, Line, true); } inline void operator delete(void* Ptr) { ZenLib::MemoryDebug::Instance().Free(Ptr, false); } inline void operator delete[](void* Ptr) { ZenLib::MemoryDebug::Instance().Free(Ptr, true); } #if !defined(__BORLANDC__) // Borland does not support overloaded delete inline void operator delete(void* Ptr, const char* File, int Line) { ZenLib::MemoryDebug::Instance().NextDelete(File, Line); ZenLib::MemoryDebug::Instance().Free(Ptr, false); } inline void operator delete[](void* Ptr, const char* File, int Line) { ZenLib::MemoryDebug::Instance().NextDelete(File, Line); ZenLib::MemoryDebug::Instance().Free(Ptr, true); } #endif #if !defined(__MINGW32__) //TODO: Does not work on MinGW, don't know why #ifndef new #define new new(__FILE__, __LINE__) #endif #ifndef delete #define delete ZenLib::MemoryDebug::Instance().NextDelete(__FILE__, __LINE__), delete #endif #endif // __MINGW32__ #endif // defined(ZENLIB_DEBUG) #endif // ZenMemoryDebugH ZenLib/Source/ZenLib/Thread.h0000664000000000000000000000461712615631146014761 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a zlib-style license that can * be found in the License.txt file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Thread functions // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef ZenLib_ThreadH #define ZenLib_ThreadH //--------------------------------------------------------------------------- #include "ZenLib/Conf.h" #include "ZenLib/CriticalSection.h" #ifdef _WINDOWS #undef Yield #endif //--------------------------------------------------------------------------- namespace ZenLib { //*************************************************************************** /// @brief Thread manipulation //*************************************************************************** class Thread { public : //Constructor/Destructor Thread (); virtual ~Thread (); //Control enum returnvalue { Ok, IsNotRunning, Incoherent, Resource, }; returnvalue Run(); returnvalue RunAgain(); returnvalue Pause(); returnvalue RequestTerminate(); returnvalue ForceTerminate(); //Status bool IsRunning(); bool IsTerminating(); bool IsExited(); //Configuration void Priority_Set(int8s Priority); //-100 to +100 //Main Entry virtual void Entry(); //Internal returnvalue Internal_Exit(); //Do not use it protected : //Communicating void Sleep(std::size_t Millisecond); void Yield(); private : //Internal void* ThreadPointer; //The possible states of the thread ("-->" shows all possible transitions from this state) enum state { State_New, // didn't start execution yet (--> Running) State_Running, // thread is running (--> Paused, Terminating) State_Paused, // thread is temporarily suspended (--> Running) State_Terminating, // thread should terminate a.s.a.p. (--> Terminated) State_Terminated, // thread is terminated }; state State; CriticalSection C; }; } //NameSpace #endif ZenLib/Source/ZenLib/PreComp.h0000664000000000000000000000223712615631146015113 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a zlib-style license that can * be found in the License.txt file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Helpers for compilers (precompilation) // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef ZenLib_PreCompH #define ZenLib_PreCompH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #if defined(_MSC_VER) || defined(__BORLANDC__) #include #include #include #include #include #include #include #include #include #include "ZenLib/Conf.h" #include "ZenLib/Conf_Internal.h" #endif //defined(_MSC_VER) || defined(__BORLANDC__) //--------------------------------------------------------------------------- #endif ZenLib/Source/ZenLib/HTTP_Client/0000775000000000000000000000000012615631146015446 5ustar rootrootZenLib/Source/ZenLib/HTTP_Client/HTTPClient.h0000664000000000000000000004162412615631146017544 0ustar rootroot #ifndef _HTTP_CLIENT #define _HTTP_CLIENT #include "HTTPClientWrapper.h" #include "HTTPClientCommon.h" #ifdef __cplusplus extern "C" { #endif /////////////////////////////////////////////////////////////////////////////// // // Section : HTTP API global definitions // Last updated : 01/09/2005 // /////////////////////////////////////////////////////////////////////////////// #ifdef _HTTP_BUILD_AMT #define CMSI_HTTPCLIENT_PROTOCOL_GUID {0x471b2c0e, 0x6137, 0x4d55, 0x92, 0x36, 0xdd, 0x0f, 0xdb, 0xc2, 0x52, 0xfb} #endif // Debug hook // #define _HTTP_DEBUGGING_ // Simply dumps more debugging data to the console // API Version #define HTTP_CLIENT_VERSION_MINOR 0 #define HTTP_CLIENT_VERSION_MAJOR 1 // Global default sizes #define HTTP_CLIENT_MAX_SEND_RECV_HEADERS 1024 // Maximum Send and receive buffers size #define HTTP_CLIENT_INIT_SEND_RECV_HEADERS 2048 // If we can resize the buffers this would be the initial size #define HTTP_CLIENT_MAX_USERNAME_LENGTH 16 // Maximum length the user name (host and proxy authentication) #define HTTP_CLIENT_MAX_PASSWORD_LENGTH 16 // Maximum length for the password // Maximum length for the base 64 encoded credentials (twice the size of the user name and password max parameters) #define HTTP_CLIENT_MAX_64_ENCODED_CRED ((HTTP_CLIENT_MAX_USERNAME_LENGTH + HTTP_CLIENT_MAX_PASSWORD_LENGTH) * 2) + 4 #define HTTP_CLIENT_MAX_CHUNK_HEADER 64 // Maximum length for the received chunk header (hex - string) size #define HTTP_CLIENT_MAX_PROXY_HOST_LENGTH 64 // Maximum length for the proxy host name #define HTTP_CLIENT_MAX_TOKEN_LENGTH 512 // Maximum length for an HTTP token data (authentication header elements) #define HTTP_CLIENT_MAX_TOKEN_NAME_LENGTH 32 // Maximum length for an HTTP authorization token name ("qop") #define HTTP_CLIENT_MAX_HEADER_SEARCH_CLUE 1024 // Maximum length for a search clue string (Headers searching) #define HTTP_CLIENT_ALLOW_HEAD_VERB 0 // Can we use the HTTP HEAD verb in our outgoing requests? #define HTTP_CLIENT_MEMORY_RESIZABLE FALSE // Permission to dynamically resize the headers buffer #define HTTP_CLIENT_MEMORY_RESIZE_FACTOR 16 // Factor for memory resizing operation #define HTTP_CLIENT_DEFAULT_PORT 80 // Default HTTP port #define HTTP_CLIENT_DEFAULT_SSL_PORT 443 // Default HTTPS port #define HTTP_CLIENT_DEFAULT_VERB 0 // GET #define HTTP_CLIENT_DEFAULT_VER "HTTP/1.1" // We will send this in the outgoing header #define HTTP_CLIENT_DEFAULT_PROXY_VER "HTTP/1.0" // We will send this in the outgoing header (proxy) #define HTTP_CLIENT_DEFAULT_AGENT "Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)" #define HTTP_CLIENT_DEFAULT_TIMEOUT 30 // Default timeout in seconds #define HTTP_CLIENT_DEFAULT_KEEP_ALIVE 30 // Default Keep-alive value in seconds #define HTTP_CLIENT_DEFAULT_DIGEST_AUTH "MD5" // This is for bypassing a known bug in AMT05.. #define HTTP_CLIENT_DEFAULT_PROXY_AUTH 1 // Basic #define HTTP_CLIENT_CRLF "\r\n" // End of line macro #define HTTP_CLIENT_CRLFX2 "\r\n\r\n" // Double End of line macro // HTTP Session internal API flags // Note: Not intended to be set the by the API user #define HTTP_CLIENT_FLAG_SECURE 0x00000010 // The session is secured using TLS #define HTTP_CLIENT_FLAG_URLANDPORT 0x00000020 // Url has a port within #define HTTP_CLIENT_FLAG_URLHTTPS 0x00000040 // Url has a https prefix #define HTTP_CLIENT_FLAG_USINGPROXY 0x00000080 // Operation will be performed using a proxy server #define HTTP_CLIENT_FLAG_CHUNKED 0x00000100 // The incoming data is chunked // HTTP Status codes #define HTTP_STATUS_OK 200 // The request has succeeded #define HTTP_STATUS_UNAUTHORIZED 401 // The request requires user authentic #define HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED 407 // The client must first authenticate itself with the proxy // Redirection (Note: there are more 30x codes, those are the most popular) #define HTTP_STATUS_OBJECT_MOVED 302 // Page redirection notification #define HTTP_STATUS_OBJECT_MOVED_PERMANENTLY 301 // Page redirection notification #define HTTP_STATUS_CONTINUE 100 // Page continue message // MIN AMX macro #define MIN(a,b) (((a) < (b)) ? (a) : (b)) #define MAX(a,b) (((a) > (b)) ? (a) : (b)) // HTTP timeout macro for selecting the default value if the caller passed 0 (no timeout) to the function #define HTTP_TIMEOUT(nTimeout) (((nTimeout) > (0)) ? (nTimeout) : (HTTP_CLIENT_DEFAULT_TIMEOUT)) // 32 bit alignment macro #define ALIGN(size) ((size & 0xfffffffc) + ((size & 3) ? 4 : 0)) #ifdef _HTTP_DEBUGGING_ typedef VOID _stdcall E_HTTPDebug(const char *,const char*,UINT32,char *,...); // HTTPDebug hook function #endif /////////////////////////////////////////////////////////////////////////////// // // Section : HTTP API internals structures // Last updated : 01/09/2005 // /////////////////////////////////////////////////////////////////////////////// // Generic parameter structure contains a pointer to the buffer and its length typedef struct _HTTP_PARAM { CHAR *pParam; UINT32 nLength; } HTTP_PARAM; // HTTP socket events typedef struct _HTTP_CONNECTION { fd_set FDRead; // socket read event fd_set FDWrite; // socket write event fd_set FDError; // socket error event INT32 HttpSocket; // The underling socket UINT32 HttpStartTime; // Time stamp for the session UINT32 HttpClientPort; // For client side binding BOOL TlsNego; // TLS negotiation flag } HTTP_CONNECTION; // Request URL typedef struct _HTTP_URL { HTTP_PARAM UrlBsee; // a pointer and length to the "http" section of the URL HTTP_PARAM UrlHost; // a pointer and length to the host section of the URL HTTP_PARAM UrlPort; // a pointer and length to the PORT (if was specified section) HTTP_PARAM UrlRequest; // a pointer and length of the request section of the URL UINT16 nPort; // the PORT that we should use (could be default or the one found within the URL) CHAR Url[HTTP_CLIENT_MAX_URL_LENGTH]; // a buffer for the URL }HTTP_URL; // HTTP headers (incoming and outgoing) typedef struct _HTTP_HEADERS { HTTP_PARAM HeadersBuffer; // a pointer and length of the complete Headers (in\out) buffer HTTP_PARAM HeadersOut; // a pointer and length of the outgoing HTTP headers HTTP_PARAM HeadersIn; // a pointer and length of the incoming headers HTTP_PARAM HeaderSearch; // Index and pointer for the header search functions HTTP_VERB HttpVerb; // the HTTP verb that was used in the session HTTP_VERB HttpLastVerb; // the HTTP verb that was last transmited to the server CHAR SearchClue[HTTP_CLIENT_MAX_HEADER_SEARCH_CLUE]; CHAR Verb[16]; // the actual string buffer of the HTTP verb }HTTP_HEADERS; // HTTP headers (parsed headers information) typedef struct _HTTP_HEADERS_INFO { HTTP_PARAM HttpRedirectURL; // Stores the redirection URL if we got a 301 or 303 return code UINT32 nHTTPStatus; // the HTTP status code (200 401 407 act') UINT32 nHTTPContentLength; // the Content length if specified of the returned data UINT32 nHTTPPostContentLength;// the Content-Length of the POSTed data (if known) BOOL Connection; // True = Keep alive or undefined, False = Closed BOOL ValidHeaders; // a flag that indicates if the incoming header ware parsed OK and found to be valid BOOL HaveCredentials; // a flag that indicates if we have credentials for the session CHAR HTTPVersion[16]; // HTTP version string buffer (for example: "HTTP 1.1") }HTTP_HEADERS_INFO; // Authentication parameters that ware extracted from the incoming headers typedef struct _HTTP_AUTH_HEADER { HTTP_PARAM AuthHeader; // the pointer and length of the authentication header UINT32 HTTP_AUTH_SCHEMA; // Its schema (could be any of the supported) }HTTP_AUTH_HEADER; // Proxy related data typedef struct _HTTP_PROXY { CHAR ProxyHost[HTTP_CLIENT_MAX_PROXY_HOST_LENGTH]; CHAR ProxtUser[HTTP_CLIENT_MAX_USERNAME_LENGTH]; CHAR ProxyPassword[HTTP_CLIENT_MAX_PASSWORD_LENGTH]; UINT16 nProxyPort; CHAR AuthSchemaName[16]; // The authentication schema name (for string comperission) HTTP_AUTH_SCHEMA ProxyAuthSchema; }HTTP_PROXY; // HTTP User credentials typedef struct _HTTP_CREDENTIALS { CHAR CredUser[HTTP_CLIENT_MAX_USERNAME_LENGTH]; CHAR CredPassword[HTTP_CLIENT_MAX_PASSWORD_LENGTH]; CHAR AuthSchemaName[16]; // The authentication schema name (for string comperission) HTTP_AUTH_SCHEMA CredAuthSchema; // The schema that calle has selected for the session BOOL Authentication; // a flag that indicates that this session has requested a user authentication }HTTP_CREDENTIALS; // HTTP Counters typedef struct _HTTP_COUNTERS { UINT32 nRecivedHeaderLength; // Bytes count of the incoming header UINT32 nRecivedBodyLength; // Bytes count of the incoming body length UINT32 nRecivedChunkLength; // The next chunk length in bytes UINT32 nBytesToNextChunk; // How many bytes we have to read until we can expect the next chunk UINT32 nActionStartTime; // Operation start time UINT32 nActionTimeout; // Timeout for the session UINT32 nSentChunks; // Count of sent chunks UINT32 nSentBodyBytes; // Count of body bytes that ware sent UINT32 nSentHeaderBytes; // Count of header bytes thhat ware sent }HTTP_COUNTERS; // HTTP Client Session data typedef struct _HTTP_REQUEST { HTTP_URL HttpUrl; HTTP_HEADERS HttpHeaders; HTTP_HEADERS_INFO HttpHeadersInfo; HTTP_AUTH_HEADER HttpAuthHeader; HTTP_PROXY HttpProxy; HTTP_CREDENTIALS HttpCredentials; HTTP_CONNECTION HttpConnection; HTTP_COUNTERS HttpCounters; UINT32 HttpState; UINT32 HttpFlags; #ifdef _HTTP_DEBUGGING_ E_HTTPDebug *pDebug; #endif } HTTP_SESSION, *P_HTTP_SESSION; // HTTP Type Definitions typedef UINT32 HTTP_SESSION_HANDLE; typedef UINT32 HTTP_CLIENT_SESSION_FLAGS; /////////////////////////////////////////////////////////////////////////////// // // Section : HTTP API public interface // Last updated : 01/09/2005 // /////////////////////////////////////////////////////////////////////////////// HTTP_SESSION_HANDLE HTTPClientOpenRequest (HTTP_CLIENT_SESSION_FLAGS Flags); UINT32 HTTPClientCloseRequest (HTTP_SESSION_HANDLE *pSession); UINT32 HTTPClientSetLocalConnection (HTTP_SESSION_HANDLE pSession, UINT32 nPort); UINT32 HTTPClientSetAuth (HTTP_SESSION_HANDLE pSession, HTTP_AUTH_SCHEMA AuthSchema, void *pReserved); UINT32 HTTPClientSetCredentials (HTTP_SESSION_HANDLE pSession, CHAR *pUserName, CHAR *pPassword); UINT32 HTTPClientSetProxy (HTTP_SESSION_HANDLE pSession, CHAR *pProxyName, UINT16 nPort, CHAR *pUserName, CHAR *pPassword); UINT32 HTTPClientSetVerb (HTTP_SESSION_HANDLE pSession, HTTP_VERB HttpVerb); UINT32 HTTPClientAddRequestHeaders (HTTP_SESSION_HANDLE pSession, CHAR *pHeaderName, CHAR *pHeaderData, BOOL nInsert); UINT32 HTTPClientSendRequest (HTTP_SESSION_HANDLE pSession, CHAR *pUrl, VOID *pData, UINT32 nDataLength, BOOL TotalLength, UINT32 nTimeout,UINT32 nClientPort); UINT32 HTTPClientWriteData (HTTP_SESSION_HANDLE pSession, VOID *pBuffer, UINT32 nBufferLength, UINT32 nTimeout); UINT32 HTTPClientRecvResponse (HTTP_SESSION_HANDLE pSession, UINT32 nTimeout); UINT32 HTTPClientReadData (HTTP_SESSION_HANDLE pSession, VOID *pBuffer, UINT32 nBytesToRead, UINT32 nTimeout, UINT32 *nBytesRecived); UINT32 HTTPClientGetInfo (HTTP_SESSION_HANDLE pSession, HTTP_CLIENT *HTTPClient); UINT32 HTTPClientFindFirstHeader (HTTP_SESSION_HANDLE pSession, CHAR *pSearchClue,CHAR *pHeaderBuffer, UINT32 *nLength); UINT32 HTTPClientGetNextHeader (HTTP_SESSION_HANDLE pSession, CHAR *pHeaderBuffer, UINT32 *nLength); UINT32 HTTPClientFindCloseHeader (HTTP_SESSION_HANDLE pSession); #ifdef _HTTP_DEBUGGING_ UINT32 HTTPClientSetDebugHook (HTTP_SESSION_HANDLE pSession,E_HTTPDebug *pDebug); #endif /////////////////////////////////////////////////////////////////////////////// // // Section : HTTP API private function // Last updated : 01/09/2005 // /////////////////////////////////////////////////////////////////////////////// UINT32 HTTPIntrnResizeBuffer (P_HTTP_SESSION pHTTPSession, UINT32 nNewSize); UINT32 HTTPIntrnSetURL (P_HTTP_SESSION pHTTPSession, CHAR *pUrl,UINT32 nUrlLength); UINT32 HTTPIntrnConnectionClose (P_HTTP_SESSION pHTTPSession); UINT32 HTTPIntrnConnectionOpen (P_HTTP_SESSION pHTTPSession); UINT32 HTTPIntrnGetRemoteHeaders (P_HTTP_SESSION pHTTPSession); UINT32 HTTPIntrnGetRemoteChunkLength (P_HTTP_SESSION pHTTPSession); UINT32 HTTPIntrnSend (P_HTTP_SESSION pHTTPSession, CHAR *pData,UINT32 *nLength); UINT32 HTTPIntrnRecv (P_HTTP_SESSION pHTTPSession, CHAR *pData,UINT32 *nLength,BOOL PeekOnly); UINT32 HTTPIntrnParseAuthHeader (P_HTTP_SESSION pHTTPSession); UINT32 HTTPIntrnAuthHandler (P_HTTP_SESSION pHTTPSession); UINT32 HTTPIntrnAuthSendDigest (P_HTTP_SESSION pHTTPSession); UINT32 HTTPIntrnAuthSendBasic (P_HTTP_SESSION pHTTPSession); UINT32 HTTPIntrnAuthenticate (P_HTTP_SESSION pHTTPSession); UINT32 HTTPIntrnHeadersAdd (P_HTTP_SESSION pHTTPSession, CHAR *pHeaderName, UINT32 nNameLength, CHAR *pHeaderData, UINT32 nDataLength); UINT32 HTTPIntrnHeadersRemove (P_HTTP_SESSION pHTTPSession, CHAR *pHeaderName); UINT32 HTTPIntrnHeadersReceive (P_HTTP_SESSION pHTTPSession, UINT32 nTimeout); UINT32 HTTPIntrnHeadersSend (P_HTTP_SESSION pHTTPSession, HTTP_VERB HttpVerb); UINT32 HTTPIntrnHeadersParse (P_HTTP_SESSION pHTTPSession); UINT32 HTTPIntrnHeadersFind (P_HTTP_SESSION pHTTPSession, CHAR *pHeaderName, HTTP_PARAM *pParam,BOOL IncommingHeaders,UINT32 nOffset); UINT32 HTTPIntrnSessionReset (P_HTTP_SESSION pHTTPSession, BOOL EntireSession); UINT32 HTTPIntrnSessionGetUpTime (VOID); BOOL HTTPIntrnSessionEvalTimeout (P_HTTP_SESSION pHTTPSession); #ifdef __cplusplus } #endif #endif //_HTTP_CLIENT ZenLib/Source/ZenLib/HTTP_Client/HTTPClient.c0000664000000000000000000042023612615631146017537 0ustar rootroot /////////////////////////////////////////////////////////////////////////////// // // Module Name: // HTTPClient.c // // Abstract: Partially Implements the client side of the HTTP 1.1 Protocol as // Defined in RFC 2616,2617 // Platform: Any that supports standard C calls and Berkeley sockets // // Author: Eitan Michaelson // Version: 1.0 // Date 7/1/2006 // Opens: HTTP Proxy authentication support (not fully tested). // HTTP Keep Alive not impliamented // HTTPS not implemented // The HTTP counters are not 100% correct (will be fixed) // /////////////////////////////////////////////////////////////////////////////// #include "HTTPClient.h" #include "HTTPClientAuth.h" // Crypto support (Digest, MD5) #include "HTTPClientString.h" // String utilities /////////////////////////////////////////////////////////////////////////////// // // Function : HTTPClientSetLocalConnection // Purpose : TBD // Gets : // Returns : // Last updated : 01/09/2005 // /////////////////////////////////////////////////////////////////////////////// UINT32 HTTPClientSetLocalConnection (HTTP_SESSION_HANDLE pSession, UINT32 nPort) { return 0; } /////////////////////////////////////////////////////////////////////////////// // // Function : HTTPClientOpenRequest // Purpose : Allocate memory for a new HTTP Session // Gets : FLAGS // Returns : HTTP Session handle // Last updated : 01/09/2005 // /////////////////////////////////////////////////////////////////////////////// HTTP_SESSION_HANDLE HTTPClientOpenRequest (HTTP_CLIENT_SESSION_FLAGS Flags) { P_HTTP_SESSION pHTTPSession = NULL; // Handle to the session pointer UINT32 nAllocationSize; // Size of the dynamically allocated buffer // Attempt to allocate the buffer pHTTPSession = (P_HTTP_SESSION)malloc(ALIGN(sizeof(HTTP_SESSION))); // Did we succeed? if(!pHTTPSession) { // Null pointer is returned upon error return 0; } // Reset the allocated space to zeros memset(pHTTPSession,0x00,sizeof(HTTP_SESSION)); // Allocate space for the incoming and outgoing headers // Check if the headers buffer is resizable if(HTTP_CLIENT_MEMORY_RESIZABLE) { // Memory is resizable, so use the init defined size or the maximum buffer size (which ever is smaller) nAllocationSize = MIN(HTTP_CLIENT_MAX_SEND_RECV_HEADERS,HTTP_CLIENT_INIT_SEND_RECV_HEADERS); } else { // Memory is not resizable so simply use the maximum defined size nAllocationSize = HTTP_CLIENT_MAX_SEND_RECV_HEADERS; } // Allocate the headers buffer pHTTPSession->HttpHeaders.HeadersBuffer.pParam = (CHAR*)malloc(ALIGN(nAllocationSize)); // Check the returned pointer if(!pHTTPSession->HttpHeaders.HeadersBuffer.pParam) { // malloc() error, free the containing structure and exit. free(pHTTPSession); return 0; } // Reset the headers allocated memory memset(pHTTPSession->HttpHeaders.HeadersBuffer.pParam ,0x00,nAllocationSize); // Set the buffer length pHTTPSession->HttpHeaders.HeadersBuffer.nLength = nAllocationSize; // Set default values in the session structure HTTPClientSetVerb((UINT32)pHTTPSession,(HTTP_VERB)HTTP_CLIENT_DEFAULT_VERB); // Default HTTP verb pHTTPSession->HttpUrl.nPort = HTTP_CLIENT_DEFAULT_PORT; // Default TCP port pHTTPSession->HttpConnection.HttpSocket = HTTP_INVALID_SOCKET; // Invalidate the socket // Set the outgoing headers pointers pHTTPSession->HttpHeaders.HeadersOut.pParam = pHTTPSession->HttpHeaders.HeadersBuffer.pParam; // Set our state pHTTPSession->HttpState = pHTTPSession->HttpState | HTTP_CLIENT_STATE_INIT; // Save the flags pHTTPSession->HttpFlags = Flags; // Reset the status pHTTPSession->HttpHeadersInfo.nHTTPStatus = 0; // Return an allocated session pointer (cast to UINT32 first) return (HTTP_SESSION_HANDLE)pHTTPSession; } /////////////////////////////////////////////////////////////////////////////// // // Function : HTTPClientReset // Purpose : Reset the HTTP session and make it ready for another call // Gets : FLAGS // Returns : HTTP Session handle // Last updated : 01/09/2005 // /////////////////////////////////////////////////////////////////////////////// UINT32 HTTPClientReset (HTTP_SESSION_HANDLE pSession) { P_HTTP_SESSION pHTTPSession = NULL; // Cast the handle to our internal structure and check the pointers validity pHTTPSession = (P_HTTP_SESSION)pSession; if(!pHTTPSession) { return HTTP_CLIENT_ERROR_INVALID_HANDLE; } return HTTPIntrnSessionReset(pHTTPSession,TRUE); } /////////////////////////////////////////////////////////////////////////////// // Function : HTTPClientCloseRequest // Purpose : Closes any active connection and free any used memory // Gets : a Session handle // Returns : HTTP Status // Last updated : 01/09/2005 // /////////////////////////////////////////////////////////////////////////////// UINT32 HTTPClientCloseRequest (HTTP_SESSION_HANDLE *pSession) { P_HTTP_SESSION pHTTPSession = NULL; // Cast the handle to our internal structure and check the pointers validity pHTTPSession = (P_HTTP_SESSION)*(pSession); if(!pHTTPSession) { // User passed a bad pointer return HTTP_CLIENT_ERROR_INVALID_HANDLE; } // Check for a valid pointer to the HTTP headers if(pHTTPSession->HttpHeaders.HeadersBuffer.pParam) { // Release the used memory free(pHTTPSession->HttpHeaders.HeadersBuffer.pParam); } // Close any active socket connection HTTPIntrnConnectionClose(pHTTPSession); // free the session structure free(pHTTPSession); pHTTPSession = 0; // NULL the pointer *(pSession) = 0; return HTTP_CLIENT_SUCCESS; } #ifdef _HTTP_DEBUGGING_ /////////////////////////////////////////////////////////////////////////////// // // Function : HTTPClientSetDebugHook // Purpose : Sets the HTTP debug function pointer // Returns : HTTP Status // Last updated : 01/09/2005 // /////////////////////////////////////////////////////////////////////////////// UINT32 HTTPClientSetDebugHook (HTTP_SESSION_HANDLE pSession, E_HTTPDebug *pDebug) // [IN] Function pointer to the the caller debugging function) { P_HTTP_SESSION pHTTPSession = NULL; // Cast the handle to our internal structure and check the pointers validity pHTTPSession = (P_HTTP_SESSION)pSession; if(!pHTTPSession) { return HTTP_CLIENT_ERROR_INVALID_HANDLE; } pHTTPSession->pDebug = pDebug; #ifdef _HTTP_DEBUGGING_ if(pHTTPSession->pDebug) { pHTTPSession->pDebug("HTTPClientSetDebugHook",NULL,0,"Debugging hook set, return code is %d",HTTP_CLIENT_SUCCESS); } #endif return HTTP_CLIENT_SUCCESS; } #endif /////////////////////////////////////////////////////////////////////////////// // // Function : HTTPClientSetVerb // Purpose : Sets the HTTP verb for the outgoing request // Returns : HTTP Status // Last updated : 01/09/2005 // /////////////////////////////////////////////////////////////////////////////// UINT32 HTTPClientSetVerb (HTTP_SESSION_HANDLE pSession, HTTP_VERB HttpVerb) // [IN] Http verb (GET POST HEAD act') { P_HTTP_SESSION pHTTPSession = NULL; // Cast the handle to our internal structure and check the pointers validity pHTTPSession = (P_HTTP_SESSION)pSession; if(!pHTTPSession) { return HTTP_CLIENT_ERROR_INVALID_HANDLE; } #ifdef _HTTP_DEBUGGING_ if(pHTTPSession->pDebug) { pHTTPSession->pDebug("HTTPClientSetVerb",NULL,0,"Selected Verb is %d",(INT32)HttpVerb); } #endif // Cache the verb (as integer) for later use pHTTPSession->HttpHeaders.HttpVerb = HttpVerb; // Convert the Verb parameter into its equivalent string representation switch (HttpVerb) { case VerbGet: strcpy(pHTTPSession->HttpHeaders.Verb,"GET"); break; case VerbHead: if(!HTTP_CLIENT_ALLOW_HEAD_VERB) { return HTTP_CLIENT_ERROR_BAD_VERB; } strcpy(pHTTPSession->HttpHeaders.Verb,"HEAD"); break; case VerbPost: strcpy(pHTTPSession->HttpHeaders.Verb,"POST"); break; default: // Unknown verb return HTTP_CLIENT_ERROR_BAD_VERB; }; return HTTP_CLIENT_SUCCESS; } /////////////////////////////////////////////////////////////////////////////// // // Function : HTTPClientSetVerb // Purpose : Sets the HTTP authentication schema // Returns : HTTP Status // Last updated : 01/09/2005 // /////////////////////////////////////////////////////////////////////////////// UINT32 HTTPClientSetAuth (HTTP_SESSION_HANDLE pSession, HTTP_AUTH_SCHEMA AuthSchema, // The type of the authentication to perform void *pReserved) { P_HTTP_SESSION pHTTPSession = NULL; // Cast the handle to our internal structure and check the pointers validity pHTTPSession = (P_HTTP_SESSION)pSession; if(!pHTTPSession) { return HTTP_CLIENT_ERROR_INVALID_HANDLE; } #ifdef _HTTP_DEBUGGING_ if(pHTTPSession->pDebug) { pHTTPSession->pDebug("HTTPClientSetAuth",NULL,0,"Selected authentication is %d",(INT32)AuthSchema); } #endif switch(AuthSchema) { case(AuthSchemaBasic): strcpy(pHTTPSession->HttpCredentials.AuthSchemaName,"basic"); break; case(AuthSchemaDigest): strcpy(pHTTPSession->HttpCredentials.AuthSchemaName,"digest"); break; case(AuthSchemaKerberos): strcpy(pHTTPSession->HttpCredentials.AuthSchemaName,"negotiate"); break; }; if(AuthSchema >= AuthNotSupported) { return HTTP_CLIENT_ERROR_BAD_AUTH; } pHTTPSession->HttpCredentials.CredAuthSchema = AuthSchema; return HTTP_CLIENT_SUCCESS; } /////////////////////////////////////////////////////////////////////////////// // // Function : HTTPClientSetProxy // Purpose : Sets all the proxy related parameters // Returns : HTTP Status // Last updated : 01/09/2005 // /////////////////////////////////////////////////////////////////////////////// UINT32 HTTPClientSetProxy (HTTP_SESSION_HANDLE pSession, CHAR *pProxyHost, // [IN] Null terminated string containing the host name UINT16 nPort, // [IN] The proxy port number CHAR *pUserName, // [IN] User name for proxy authentication (can be null) CHAR *pPassword) // [IN] User password for proxy authentication (can be null) { P_HTTP_SESSION pHTTPSession = NULL; // Cast the handle to our internal structure and check the pointers validity pHTTPSession = (P_HTTP_SESSION)pSession; if(!pHTTPSession) { return HTTP_CLIENT_ERROR_INVALID_HANDLE; } #ifdef _HTTP_DEBUGGING_ if(pHTTPSession->pDebug) { pHTTPSession->pDebug("HTTPClientSetProxy",NULL,0,"Proxy host %s,Port %d, Username %s,Password %s",pProxyHost,nPort,pUserName,pPassword); } #endif // Cache the user supplied information in the internal session structure strncpy(pHTTPSession->HttpProxy.ProxyHost,pProxyHost,HTTP_CLIENT_MAX_PROXY_HOST_LENGTH); if(pUserName) { // Proxy user name (for Proxy server authentication) strncpy(pHTTPSession->HttpProxy.ProxtUser,pUserName,HTTP_CLIENT_MAX_USERNAME_LENGTH); } if(pPassword) { // Proxy password (for proxy server authentication) strncpy(pHTTPSession->HttpProxy.ProxyPassword,pPassword,HTTP_CLIENT_MAX_PASSWORD_LENGTH); } // Proxy TCP port pHTTPSession->HttpProxy.nProxyPort = nPort; // Set the Proxy flag in the connection structure pHTTPSession->HttpFlags = pHTTPSession->HttpFlags | HTTP_CLIENT_FLAG_USINGPROXY; // Set the proxy auyjentication schema if(pPassword && pUserName) { pHTTPSession->HttpProxy.ProxyAuthSchema = HTTP_CLIENT_DEFAULT_PROXY_AUTH; } return HTTP_CLIENT_SUCCESS; } /////////////////////////////////////////////////////////////////////////////// // // Function : HTTPClientSetCredentials // Purpose : Sets credentials for the target host // Returns : HTTP Status // Last updated : 01/09/2005 // /////////////////////////////////////////////////////////////////////////////// UINT32 HTTPClientSetCredentials (HTTP_SESSION_HANDLE pSession, CHAR *pUserName, // [IN] Null terminated string containing the sessions user name CHAR *pPassword) // [IN] Null terminated string containing the sessions password { UINT32 nLength; P_HTTP_SESSION pHTTPSession = NULL; // Cast the handle to our internal structure and check the pointers validity pHTTPSession = (P_HTTP_SESSION)pSession; if(!pHTTPSession) { return HTTP_CLIENT_ERROR_INVALID_HANDLE; } // Get the length of the user name string and see if it's not too long nLength = strlen(pUserName); if(nLength > HTTP_CLIENT_MAX_USERNAME_LENGTH) { return HTTP_CLIENT_ERROR_LONG_INPUT; } // Get the length of the password string and see if it's not too long nLength = strlen(pPassword); if(nLength > HTTP_CLIENT_MAX_PASSWORD_LENGTH) { return HTTP_CLIENT_ERROR_LONG_INPUT; } // Copy them into our internal buffer strcpy(pHTTPSession->HttpCredentials.CredUser ,pUserName); strcpy(pHTTPSession->HttpCredentials.CredPassword ,pPassword); // Set the authentication Boolean flag pHTTPSession->HttpHeadersInfo.HaveCredentials = TRUE; return HTTP_CLIENT_SUCCESS; } /////////////////////////////////////////////////////////////////////////////// // // Function : HTTPClientAddRequestHeaders // Purpose : Add headers to the outgoing request // Gets : // Last updated : 01/09/2005 // /////////////////////////////////////////////////////////////////////////////// UINT32 HTTPClientAddRequestHeaders (HTTP_SESSION_HANDLE pSession, CHAR *pHeaderName, // [IN] The Headers name CHAR *pHeaderData, // [IN] The headers data BOOL nInsert) // [IN] Reserved could be any { UINT32 nRetCode; UINT32 nHeaderLength,nDataLength; P_HTTP_SESSION pHTTPSession = NULL; // Cast the handle to our internal structure and check the pointers validity pHTTPSession = (P_HTTP_SESSION)pSession; if(!pHTTPSession) { return HTTP_CLIENT_ERROR_INVALID_HANDLE; } #ifdef _HTTP_DEBUGGING_ if(pHTTPSession->pDebug) { pHTTPSession->pDebug("HTTPClientAddRequestHeaders",NULL,0,"Adding Header %s: %s",pHeaderName,pHeaderData); } #endif // Get the elements length nHeaderLength = strlen(pHeaderName); nDataLength = strlen(pHeaderData); // Call the internal function to add the headers to our session buffer nRetCode = HTTPIntrnHeadersAdd(pHTTPSession,pHeaderName,nHeaderLength,pHeaderData,nDataLength); return nRetCode; } /////////////////////////////////////////////////////////////////////////////// // // Function : HTTPClientSendRequest // Purpose : This function builds the request headers, performs a DNS resolution , // opens the connection (if it was not opened yet by a previous request or if it has closed) // and sends the request headers. // Returns : HTTP Status // Last updated : 01/09/2005 // /////////////////////////////////////////////////////////////////////////////// UINT32 HTTPClientSendRequest (HTTP_SESSION_HANDLE pSession, CHAR *pUrl, // [IN] The requested URL VOID *pData, // [IN] Data to post to the server UINT32 nDataLength, // [IN] Length of posted data BOOL TotalLength, // [IN] UINT32 nTimeout, // [IN] Operation timeout UINT32 nClientPort) // [IN] Client side port 0 for none { UINT32 nRetCode; // Function call return code UINT32 nBytes; // Bytes counter (socket operations) UINT32 nUrlLength; // Length of the given Url P_HTTP_SESSION pHTTPSession = NULL; // Session pointer CHAR ContentLength[32]; //CHAR *pPtr; // Content length (string conversion) //Jerome/cppcheck: Variable 'pPtr' is assigned a value that is never used. do { // Cast the handle to our internal structure and check the pointers validity pHTTPSession = (P_HTTP_SESSION)pSession; if(!pHTTPSession) { nRetCode = HTTP_CLIENT_ERROR_INVALID_HANDLE; break; } #ifdef _HTTP_DEBUGGING_ if(pHTTPSession->pDebug) { pHTTPSession->pDebug("HTTPClientSendRequest",NULL,0,"Url: %s",pUrl); } #endif // Set the operation timeout counters pHTTPSession->HttpCounters.nActionStartTime = HTTPIntrnSessionGetUpTime(); // 0 makes us use the default defined value pHTTPSession->HttpCounters.nActionTimeout = HTTP_TIMEOUT(nTimeout); // Store the cliebt port for later usage pHTTPSession->HttpConnection.HttpClientPort = nClientPort; // Parse the URL nUrlLength = strlen(pUrl); nRetCode = HTTPIntrnSetURL(pHTTPSession,pUrl,nUrlLength); if(nRetCode != HTTP_CLIENT_SUCCESS) { break; } // Create the default headers // Add the "Host" header. we should handle a special case of port incorporated within the host name. if((pHTTPSession->HttpFlags & HTTP_CLIENT_FLAG_URLANDPORT) != HTTP_CLIENT_FLAG_URLANDPORT) { // The case where we don't have the port if((nRetCode = HTTPIntrnHeadersAdd(pHTTPSession, "Host",4, pHTTPSession->HttpUrl.UrlHost.pParam, pHTTPSession->HttpUrl.UrlHost.nLength)) != HTTP_CLIENT_SUCCESS) { break; } } else { // We have the port so use a deferent element if((nRetCode = HTTPIntrnHeadersAdd(pHTTPSession,"Host",4,pHTTPSession->HttpUrl.UrlHost.pParam, (pHTTPSession->HttpUrl.UrlPort.pParam - pHTTPSession->HttpUrl.UrlHost.pParam) -1 )) != HTTP_CLIENT_SUCCESS) { break; } } // We are in a post request without knowing the total length in advance so return error or use chunking if(pHTTPSession->HttpHeaders.HttpVerb == VerbPost && TotalLength == FALSE) { // If the user specified the chunked flag if((pHTTPSession->HttpFlags & HTTP_CLIENT_FLAG_SEND_CHUNKED) == HTTP_CLIENT_FLAG_SEND_CHUNKED) { // Add the Transfer-Encoding: header if((nRetCode = HTTPIntrnHeadersAdd(pHTTPSession,"Transfer-Encoding",17,"chunked",7))!= HTTP_CLIENT_SUCCESS) { break;; } } else { // Not a supported operation - unknown length nRetCode = HTTP_CLIENT_ERROR_HEADER_NO_LENGTH; break; } } // Add the "User-Agent" header if((nRetCode = HTTPIntrnHeadersAdd(pHTTPSession,"User-Agent",10,HTTP_CLIENT_DEFAULT_AGENT,strlen(HTTP_CLIENT_DEFAULT_AGENT)))!= HTTP_CLIENT_SUCCESS) { break; } // Add the "Keep-Alive" header (if requested by the caller) if((pHTTPSession->HttpFlags & HTTP_CLIENT_FLAG_KEEP_ALIVE) == HTTP_CLIENT_FLAG_KEEP_ALIVE) { if((pHTTPSession->HttpFlags & HTTP_CLIENT_FLAG_USINGPROXY) != HTTP_CLIENT_FLAG_USINGPROXY) { // No proxy keep alive: if((nRetCode = HTTPIntrnHeadersAdd(pHTTPSession,"Connection",10,"Keep-Alive",10))!= HTTP_CLIENT_SUCCESS) { break; } } else // proxy keep alive { if((nRetCode = HTTPIntrnHeadersAdd(pHTTPSession,"Proxy-Connection",15,"Keep-Alive",10))!= HTTP_CLIENT_SUCCESS) { break; } } } // If we know the total length in advance (only when posting) if(pHTTPSession->HttpHeaders.HttpVerb == VerbPost && TotalLength == TRUE) { // set the total content length header pHTTPSession->HttpHeadersInfo.nHTTPPostContentLength = nDataLength; // Store for later usage memset(ContentLength,0,32); //pPtr = IToA(ContentLength,nDataLength); // Convert the buffer length to a string value //Jerome/cppcheck: Variable 'pPtr' is assigned a value that is never used. if((nRetCode = HTTPIntrnHeadersAdd(pHTTPSession,"Content-Length",14,ContentLength,strlen(ContentLength)))!= HTTP_CLIENT_SUCCESS) { break; } } // Add the "Cache control" header (if requested by the caller) if((pHTTPSession->HttpFlags & HTTP_CLIENT_FLAG_NO_CACHE) == HTTP_CLIENT_FLAG_NO_CACHE) { if((nRetCode = HTTPIntrnHeadersAdd(pHTTPSession,"Cache-Control",13,"no-cache",8))!= HTTP_CLIENT_SUCCESS) { break; } } // Now we can connect to the remote server and send the leading request followed by the HTTP headers // Check for timeout if(HTTPIntrnSessionEvalTimeout(pHTTPSession) == TRUE) { nRetCode = HTTP_CLIENT_ERROR_SOCKET_TIME_OUT; break; } // Handle connection close message (reconnect) if(pHTTPSession->HttpHeadersInfo.Connection == FALSE) { // Gracefully close the connection and set the socket as invalid if(pHTTPSession->HttpConnection.HttpSocket != HTTP_INVALID_SOCKET) { HTTPIntrnConnectionClose(pHTTPSession); } // Connect to the remote server (or proxy) nRetCode = HTTPIntrnConnectionOpen(pHTTPSession); if(nRetCode != HTTP_CLIENT_SUCCESS) { break; } } // Send the request along with the rest of the headers if(pHTTPSession->HttpCredentials.CredAuthSchema != AuthSchemaNone || pHTTPSession->HttpProxy.ProxyAuthSchema != AuthSchemaNone) // If we have to authenticate we should use the HEAD verb { if(HTTP_CLIENT_ALLOW_HEAD_VERB) // HEAD should not be ussed if not defined { if((nRetCode = HTTPIntrnHeadersSend(pHTTPSession,VerbHead)) != HTTP_CLIENT_SUCCESS) { break; } // Set the state flag pHTTPSession->HttpState = pHTTPSession->HttpState | HTTP_CLIENT_STATE_HEAD_SENT; } else { // Simply use the verb that was set by the caller without changing to HEAD if((nRetCode = HTTPIntrnHeadersSend(pHTTPSession,pHTTPSession->HttpHeaders.HttpVerb)) != HTTP_CLIENT_SUCCESS) { break; } // This the case where the caller know the total length to receive in advance // and he wishes to send the data right away if(pHTTPSession->HttpHeaders.HttpVerb == VerbPost && TotalLength == TRUE) { // Send the data nBytes = nDataLength; if((nRetCode = HTTPIntrnSend(pHTTPSession,pData,&nBytes)) != HTTP_CLIENT_SUCCESS) { break; } // Set the session state pHTTPSession->HttpState = pHTTPSession->HttpState | HTTP_CLIENT_STATE_POST_SENT; } } // Retrive and analyze the Headers if((nRetCode = HTTPIntrnHeadersReceive(pHTTPSession,nTimeout)) != HTTP_CLIENT_SUCCESS) { break; } if(pHTTPSession->HttpHeadersInfo.nHTTPStatus != 401 && pHTTPSession->HttpHeadersInfo.nHTTPStatus != 407) { nRetCode = HTTP_CLIENT_ERROR_AUTH_MISMATCH; break; } // Authenticate if((nRetCode = HTTPIntrnAuthenticate(pHTTPSession)) != HTTP_CLIENT_SUCCESS) { break; } } else { // No authentication use the verb that was requested by the caller if((nRetCode = HTTPIntrnHeadersSend(pHTTPSession,pHTTPSession->HttpHeaders.HttpVerb)) != HTTP_CLIENT_SUCCESS) { break; } } // This the case where the caller know the total length to receive in advance // and he wishes to send the data right away if(pHTTPSession->HttpHeaders.HttpVerb == VerbPost && TotalLength == TRUE) { // Send the data nBytes = nDataLength; if((nRetCode = HTTPIntrnSend(pHTTPSession,pData,&nBytes)) != HTTP_CLIENT_SUCCESS) { break; } // Set the session state pHTTPSession->HttpState = pHTTPSession->HttpState | HTTP_CLIENT_STATE_POST_SENT; } }while(0); return nRetCode; } /////////////////////////////////////////////////////////////////////////////// // // Function : HTTPClientRecvResponse // Purpose : Receives the response header on the connection and parses it. // Performs any required authentication. // Returns : HTTP Status // Last updated : 01/09/2005 // /////////////////////////////////////////////////////////////////////////////// UINT32 HTTPClientRecvResponse (HTTP_SESSION_HANDLE pSession, UINT32 nTimeout) // [IN] Timeout for the operation { UINT32 nRetCode; // Function return code P_HTTP_SESSION pHTTPSession = NULL; // Session pointer // Cast the handle to our internal structure and check the pointers validity pHTTPSession = (P_HTTP_SESSION)pSession; if(!pHTTPSession) { return HTTP_CLIENT_ERROR_INVALID_HANDLE; } do { if((nRetCode = HTTPIntrnHeadersReceive(pHTTPSession, nTimeout)) != HTTP_CLIENT_SUCCESS) { break; } } while(0); return nRetCode; } /////////////////////////////////////////////////////////////////////////////// // // Function : HTTPClientWriteData // Purpose : Write data to the remote server // Returns : HTTP Status // Last updated : 01/09/2005 // /////////////////////////////////////////////////////////////////////////////// UINT32 HTTPClientWriteData (HTTP_SESSION_HANDLE pSession, VOID *pBuffer, UINT32 nBufferLength, UINT32 nTimeout) { UINT32 nRetCode = HTTP_CLIENT_SUCCESS; UINT32 nBytes; CHAR Chunk[HTTP_CLIENT_MAX_CHUNK_HEADER]; //CHAR *pChunkHeaderPtr; //Jerome/cppcheck: Variable 'pChunkHeaderPtr' is assigned a value that is never used. P_HTTP_SESSION pHTTPSession = NULL; // Cast the handle to our internal structure and check the pointer validity pHTTPSession = (P_HTTP_SESSION)pSession; do { if(!pHTTPSession) { nRetCode = HTTP_CLIENT_ERROR_INVALID_HANDLE; break; } // Set the operation timeout counters pHTTPSession->HttpCounters.nActionStartTime = HTTPIntrnSessionGetUpTime(); pHTTPSession->HttpCounters.nActionTimeout = HTTP_TIMEOUT(nTimeout); // Did the caller specified chunked sending? if((pHTTPSession->HttpFlags & HTTP_CLIENT_FLAG_SEND_CHUNKED) == HTTP_CLIENT_FLAG_SEND_CHUNKED) { // Prep the chunk Header and send it memset(Chunk,0x00,HTTP_CLIENT_MAX_CHUNK_HEADER); HTTPStrLToH(Chunk,nBufferLength); //pChunkHeaderPtr = //Jerome/cppcheck: Variable 'pChunkHeaderPtr' is assigned a value that is never used. strcat(Chunk,HTTP_CLIENT_CRLF); // Send the leading CrLf (only after the first chunk) if(pHTTPSession->HttpCounters.nSentChunks >= 1) { nBytes = 2;; nRetCode = HTTPIntrnSend(pHTTPSession,HTTP_CLIENT_CRLF,&nBytes); if(nRetCode != HTTP_CLIENT_SUCCESS) { break; } } // Send the chunk header nBytes = strlen(Chunk); nRetCode = HTTPIntrnSend(pHTTPSession,Chunk,&nBytes); if(nRetCode != HTTP_CLIENT_SUCCESS) { break; } } // Send the data nBytes = nBufferLength; nRetCode = HTTPIntrnSend(pHTTPSession,pBuffer,&nBytes); if(nRetCode != HTTP_CLIENT_SUCCESS) { break; } // If we are using chunks then.. if((pHTTPSession->HttpFlags & HTTP_CLIENT_FLAG_SEND_CHUNKED) == HTTP_CLIENT_FLAG_SEND_CHUNKED) { // Set the chunks count pHTTPSession->HttpCounters.nSentChunks++; // If it was the last chunk (0) we should re-get the headers from the server reply if(nBufferLength == 0) { // Send the trailing CrLf nBytes = 2;; nRetCode = HTTPIntrnSend(pHTTPSession,HTTP_CLIENT_CRLF,&nBytes); if(nRetCode != HTTP_CLIENT_SUCCESS) { break; } // Get the remote headers (since the last chunk was transmitted we can expect the server to start the reply) if((nRetCode = HTTPIntrnHeadersReceive(pHTTPSession,nTimeout)) != HTTP_CLIENT_SUCCESS) { break; } } } } while(0); return nRetCode; } /////////////////////////////////////////////////////////////////////////////// // // Function : HTTPClientReadData // Purpose : Read data from the server. Parse out the chunks data. // Returns : HTTP Status // Last updated : 01/09/2005 // /////////////////////////////////////////////////////////////////////////////// UINT32 HTTPClientReadData (HTTP_SESSION_HANDLE pSession, VOID *pBuffer, // [IN OUT] a pointer to a buffer that will be filled with the servers response UINT32 nBytesToRead, // [IN] The size of the buffer (numbers of bytes to read) UINT32 nTimeout, // [IN] operation timeout in seconds UINT32 *nBytesRecived) // [OUT] Count of the bytes that ware received in this operation { UINT32 nBytes = 0; UINT32 nRetCode = 0 ; INT32 nProjectedBytes = 0; // Should support negative numbers CHAR *pNullPtr; BOOL EndOfStream = FALSE; P_HTTP_SESSION pHTTPSession = NULL; // Cast the handle to our internal structure and check the pointers validity pHTTPSession = (P_HTTP_SESSION)pSession; if(!pHTTPSession) { return HTTP_CLIENT_ERROR_INVALID_HANDLE; } // If the last verb that was used was HEAD there is no point to get this data (chanses are that we will endup with timeout) if(pHTTPSession->HttpHeaders.HttpVerb == VerbHead) { return HTTP_CLIENT_EOS; } // Set the operation timeout counters pHTTPSession->HttpCounters.nActionStartTime = HTTPIntrnSessionGetUpTime(); pHTTPSession->HttpCounters.nActionTimeout = HTTP_TIMEOUT(nTimeout); nBytes = nBytesToRead - 1; // We will spare 1 byte for the trailing null termination *((CHAR*)pBuffer) = 0; // Null terminate the user supplied buffer *(nBytesRecived) = 0; // Set the return bytes count to 0 // We can read the data only if we got valid headers (and not authentication requests for example) if((pHTTPSession->HttpState & HTTP_CLIENT_STATE_HEADERS_PARSED) != HTTP_CLIENT_STATE_HEADERS_PARSED) { return HTTP_CLIENT_ERROR_BAD_STATE; } // Is it a chunked mode transfer? if((pHTTPSession->HttpFlags & HTTP_CLIENT_FLAG_CHUNKED) == HTTP_CLIENT_FLAG_CHUNKED) { // How many bytes left until the next chunk? if(pHTTPSession->HttpCounters.nBytesToNextChunk == 0) { // Read the chunk header and get its length if(HTTPIntrnGetRemoteChunkLength(pHTTPSession) != HTTP_CLIENT_SUCCESS) { // Could not parse the chunk parameter return HTTP_CLIENT_ERROR_CHUNK; } // 0 Bytes chunk, we should return end of stream if(pHTTPSession->HttpCounters.nRecivedChunkLength == 0) { return HTTP_CLIENT_EOS; } } // If we are about to read pass the next chunk, reduce the read bytes so we will read // non HTML data nProjectedBytes = pHTTPSession->HttpCounters.nBytesToNextChunk - nBytes; if ( nProjectedBytes <= 0) { // Set the correct bytes count we should read nBytes = pHTTPSession->HttpCounters.nBytesToNextChunk; } } // Do we have the content length? if(pHTTPSession->HttpHeadersInfo.nHTTPContentLength > 0) { // Length of the projected buffer nProjectedBytes = pHTTPSession->HttpCounters.nRecivedBodyLength + nBytes; // If we are going to read more then the known content length then.. if(nProjectedBytes >= (INT32)pHTTPSession->HttpHeadersInfo.nHTTPContentLength) { // Reduce the received bytes count to the correct size nBytes = pHTTPSession->HttpHeadersInfo.nHTTPContentLength - pHTTPSession->HttpCounters.nRecivedBodyLength; } } // Receive the data from the socket nRetCode = HTTPIntrnRecv(pHTTPSession,(CHAR*)pBuffer,&nBytes,FALSE); // Set the return bytes count *(nBytesRecived) = nBytes; // + 1; Fixed 11/9/2005 // Pointer to the end of the buffer pNullPtr = (CHAR*)pBuffer + nBytes ; // And null terminate *pNullPtr = 0; // Socket read went OK if(nRetCode == HTTP_CLIENT_SUCCESS) { #ifdef _HTTP_DEBUGGING_ if(pHTTPSession->pDebug) { pHTTPSession->pDebug("HTTPClientReadData",NULL,0,"Reading %d bytes",nBytes); } #endif // Set the HTTP counters pHTTPSession->HttpCounters.nRecivedBodyLength += nBytes; // If we know the total content length and.. if(pHTTPSession->HttpHeadersInfo.nHTTPContentLength > 0) { // If total received body is equal or greater then the known content length then.. if( pHTTPSession->HttpCounters.nRecivedBodyLength >= pHTTPSession->HttpHeadersInfo.nHTTPContentLength) { // Raise a flag to signal end of stream EndOfStream = TRUE; } } // Is it a chunked mode transfer? if((pHTTPSession->HttpFlags & HTTP_CLIENT_FLAG_CHUNKED) == HTTP_CLIENT_FLAG_CHUNKED) { // We are a little closer to the next chunk now pHTTPSession->HttpCounters.nBytesToNextChunk -= nBytes; } // Is it End of stream? if(EndOfStream == TRUE) { // So exit return HTTP_CLIENT_EOS; } } return nRetCode ; } /////////////////////////////////////////////////////////////////////////////// // // Function : HTTPClientGetInfo // Purpose : Fill the users structure with the session information // Returns : HTTP Status // Last updated : 01/09/2005 // /////////////////////////////////////////////////////////////////////////////// UINT32 HTTPClientGetInfo (HTTP_SESSION_HANDLE pSession, HTTP_CLIENT *HTTPClient) { P_HTTP_SESSION pHTTPSession = NULL; // Cast the handle to our internal structure and check the pointers validity pHTTPSession = (P_HTTP_SESSION)pSession; if(!pHTTPSession) { return HTTP_CLIENT_ERROR_INVALID_HANDLE; } // Reset the users info structure memset(HTTPClient,0x00,sizeof(HTTP_CLIENT)); HTTPClient->HTTPStatusCode = pHTTPSession->HttpHeadersInfo.nHTTPStatus; HTTPClient->RequestBodyLengthSent = pHTTPSession->HttpCounters.nSentBodyBytes; HTTPClient->ResponseBodyLengthReceived = pHTTPSession->HttpCounters.nRecivedBodyLength; HTTPClient->TotalResponseBodyLength = pHTTPSession->HttpHeadersInfo.nHTTPContentLength; HTTPClient->HttpState = pHTTPSession->HttpState; return HTTP_CLIENT_SUCCESS; } /////////////////////////////////////////////////////////////////////////////// // // Function : HTTPClientFindFirstHeader // Purpose : Initiate the headr searching functions // Returns : HTTP Status // Last updated : 01/09/2005 // /////////////////////////////////////////////////////////////////////////////// UINT32 HTTPClientFindFirstHeader (HTTP_SESSION_HANDLE pSession, CHAR *pSearchClue,CHAR *pHeaderBuffer, UINT32 *nLength) { P_HTTP_SESSION pHTTPSession = NULL; UINT32 nClueLength; // Cast the handle to our internal structure and check the pointers validity pHTTPSession = (P_HTTP_SESSION)pSession; if(!pHTTPSession) { return HTTP_CLIENT_ERROR_INVALID_HANDLE; } nClueLength = strlen(pSearchClue); // See if we are not to long if(nClueLength >= HTTP_CLIENT_MAX_HEADER_SEARCH_CLUE) { return HTTP_CLIENT_ERROR_HEADER_BIG_CLUE; } else { strcpy(pHTTPSession->HttpHeaders.SearchClue,pSearchClue); pHTTPSession->HttpHeaders.HeaderSearch.nLength = 0; pHTTPSession->HttpHeaders.HeaderSearch.pParam = NULL; } return HTTP_CLIENT_SUCCESS; } /////////////////////////////////////////////////////////////////////////////// // // Function : HTTPClientFindCloseHeader // Purpose : Terminate a headers search session // Returns : HTTP Status // Last updated : 01/09/2005 // /////////////////////////////////////////////////////////////////////////////// UINT32 HTTPClientFindCloseHeader (HTTP_SESSION_HANDLE pSession) { P_HTTP_SESSION pHTTPSession = NULL; // Cast the handle to our internal structure and check the pointers validity pHTTPSession = (P_HTTP_SESSION)pSession; if(!pHTTPSession) { return HTTP_CLIENT_ERROR_INVALID_HANDLE; } pHTTPSession->HttpHeaders.SearchClue[0] = 0; pHTTPSession->HttpHeaders.HeaderSearch.nLength = 0; pHTTPSession->HttpHeaders.HeaderSearch.pParam = NULL; return HTTP_CLIENT_SUCCESS; } /////////////////////////////////////////////////////////////////////////////// // // Function : HTTPClientGetNextHeader // Purpose : Terminate a headers search session // Returns : HTTP Status // Last updated : 01/09/2005 // /////////////////////////////////////////////////////////////////////////////// UINT32 HTTPClientGetNextHeader (HTTP_SESSION_HANDLE pSession, CHAR *pHeaderBuffer, UINT32 *nLength) { P_HTTP_SESSION pHTTPSession = NULL; UINT32 nOffset = 0; UINT32 nRetCode; HTTP_PARAM HttpHeader; CHAR *pPtr; // Cast the handle to our internal structure and check the pointers validity pHTTPSession = (P_HTTP_SESSION)pSession; if(!pHTTPSession) { return HTTP_CLIENT_ERROR_INVALID_HANDLE; } if(pHTTPSession->HttpHeaders.HeaderSearch.nLength > 0) // We must adjust the search offset since it is not the fierst iteration { nOffset = pHTTPSession->HttpHeaders.HeaderSearch.pParam - pHTTPSession->HttpHeaders.HeadersIn.pParam; } // Search for the next header nRetCode = HTTPIntrnHeadersFind(pHTTPSession,pHTTPSession->HttpHeaders.SearchClue,&HttpHeader,TRUE,nOffset); if(nRetCode == HTTP_CLIENT_SUCCESS) { if(HttpHeader.nLength > *(nLength)) // Check for sufficiant length { *(nLength) = HttpHeader.nLength; pHeaderBuffer[0] = 0; // Reset the users buffer return HTTP_CLIENT_ERROR_NO_MEMORY; } pPtr = HttpHeader.pParam; nOffset = 0; if(*pPtr == 0x0d) { nOffset++; pPtr++; } if(*pPtr == 0x0a) { nOffset++; pPtr++; } strncpy(pHeaderBuffer,pPtr,HttpHeader.nLength - nOffset); pHeaderBuffer[HttpHeader.nLength - nOffset] = 0; *(nLength) = HttpHeader.nLength - nOffset; pHTTPSession->HttpHeaders.HeaderSearch.pParam = HttpHeader.pParam + HttpHeader.nLength; pHTTPSession->HttpHeaders.HeaderSearch.nLength++; return HTTP_CLIENT_SUCCESS; } return nRetCode; } /////////////////////////////////////////////////////////////////////////////// // // Function : HTTPIntrnSetURL // Purpose : Parse the user's URL // Returns : HTTP Status // Last updated : 01/09/2005 // /////////////////////////////////////////////////////////////////////////////// static UINT32 HTTPIntrnSetURL (P_HTTP_SESSION pHTTPSession, CHAR *pUrl, // [IN] a null terminated string containing the Url we should retrieve UINT32 nUrlLength) // [IN] The length the Url string { UINT32 nUrlOffset; // Offset in bytes within the Url string HTTP_URL *pUrlPtr; // a Pointer to the Url structure (within the global session structure) CHAR *pPtr; // a Pointer for the Url port (Used in the parsing process) CHAR UrlPort[16]; // a temporary byte array for the Url port conversion operation (string to number) // Check for the session pointer validity if(!pHTTPSession) { return HTTP_CLIENT_ERROR_INVALID_HANDLE; } // Get the length of the Url nUrlLength = strlen(pUrl); // Check if it is not longer than the permitted length if((nUrlLength + 1) > HTTP_CLIENT_MAX_URL_LENGTH) { return HTTP_CLIENT_ERROR_LONG_INPUT; } // Point the local pointer on the global structure pUrlPtr = &pHTTPSession->HttpUrl; // Copy to the internal buffer memcpy(pHTTPSession->HttpUrl.Url,pUrl,nUrlLength); nUrlOffset = 0; // Get the Url base ("http" or "https") if(HTTPStrSearch(pUrlPtr->Url,":",nUrlOffset,nUrlLength,&pUrlPtr->UrlBsee) == FALSE) { return HTTP_CLIENT_ERROR_BAD_URL; } // Increase the offset parameter nUrlOffset += pUrlPtr->UrlBsee.nLength; // If we can parse the string "HTTPS" we can assume a secured session if(HTTPStrInsensitiveCompare(pUrlPtr->UrlBsee.pParam,"https",pUrlPtr->UrlBsee.nLength) == TRUE) { // Set the secured flags on the session pHTTPSession->HttpFlags = pHTTPSession->HttpFlags | HTTP_CLIENT_FLAG_URLHTTPS; pHTTPSession->HttpFlags = pHTTPSession->HttpFlags | HTTP_CLIENT_FLAG_SECURE; // ToDo: Init TLS (GetProtocol) #ifdef _HTTP_BUILD_AMT // OS_GET_CLIENT_SUBSET_PROTOCOL(TRUE,&pHTTPSession->pSecProtocol); #endif #ifdef _HTTP_DEBUGGING_ if(pHTTPSession->pDebug) { pHTTPSession->pDebug("HTTPIntrnSetURL",NULL,0,"SSL Protected Url %s",pUrl); } #endif } else // it should be "http" { if(HTTPStrInsensitiveCompare(pUrlPtr->UrlBsee.pParam,"http",pUrlPtr->UrlBsee.nLength) == FALSE) { return HTTP_CLIENT_ERROR_BAD_URL; // cOULD NOT DETECT http or https prefix } } // Look for standard Url elements if(HTTPStrSearch(pUrlPtr->Url,"://",nUrlOffset,3,0) == FALSE) { return HTTP_CLIENT_ERROR_BAD_URL; // Could not detect "://" } // Increase the offset parameter nUrlOffset += 3; // Get the host name if(HTTPStrSearch(pUrlPtr->Url,"/",nUrlOffset,(nUrlLength - nUrlOffset),&pUrlPtr->UrlHost) == FALSE) { pUrlPtr->Url[nUrlLength] = '/'; nUrlLength++; if(HTTPStrSearch(pUrlPtr->Url,"/",nUrlOffset,(nUrlLength - nUrlOffset),&pUrlPtr->UrlHost) == FALSE) { return HTTP_CLIENT_ERROR_BAD_URL; } } nUrlOffset += pUrlPtr->UrlHost.nLength; // Do we have the port within the hostname? if(HTTPStrSearch(pUrlPtr->Url,":", (nUrlOffset - pUrlPtr->UrlHost.nLength), pUrlPtr->UrlHost.nLength, &pUrlPtr->UrlPort) == TRUE) { if((pUrlPtr->UrlHost.nLength - pUrlPtr->UrlPort.nLength) < 10) { // To-Do: check the actual port length before the memcpy pUrlPtr->UrlPort.pParam += pUrlPtr->UrlPort.nLength + 1; memcpy(UrlPort,pUrlPtr->UrlPort.pParam,15); pUrlPtr->UrlPort.nLength = 0; pPtr = UrlPort; while(*pPtr && pPtr++) { pUrlPtr->UrlPort.nLength++; if(*pPtr == '/') { *pPtr = 0; pUrlPtr->nPort = (UINT16)atol(UrlPort); pHTTPSession->HttpFlags = pHTTPSession->HttpFlags | HTTP_CLIENT_FLAG_URLANDPORT; break; } } } else { // Port too big return HTTP_CLIENT_ERROR_BAD_URL; } } // Get the request body pUrlPtr->UrlRequest.pParam = pUrlPtr->Url + nUrlOffset; pUrlPtr->UrlRequest.nLength = nUrlLength - nUrlOffset; // If we got SSL url with no port we should set the default ssl port if((pHTTPSession->HttpFlags & HTTP_CLIENT_FLAG_URLHTTPS) == HTTP_CLIENT_FLAG_URLHTTPS) { if((pHTTPSession->HttpFlags & HTTP_CLIENT_FLAG_URLANDPORT) != HTTP_CLIENT_FLAG_URLANDPORT) { pHTTPSession->HttpUrl.nPort = HTTP_CLIENT_DEFAULT_SSL_PORT; } } // Set the state flag pHTTPSession->HttpState = pHTTPSession->HttpState | HTTP_CLIENT_STATE_URL_PARSED; return HTTP_CLIENT_SUCCESS; } /////////////////////////////////////////////////////////////////////////////// // // Function : HTTPIntrnResizeBuffer // Purpose : Resize the HTTP headers buffer and reset the pointers // Returns : HTTP Status // Last updated : 01/09/2005 // /////////////////////////////////////////////////////////////////////////////// static UINT32 HTTPIntrnResizeBuffer (P_HTTP_SESSION pHTTPSession, UINT32 nNewBufferSize) // [IN] The new (and larger) buffer size { CHAR *pPtr = NULL; UINT32 nCurrentBufferSize; if(!pHTTPSession) { return HTTP_CLIENT_ERROR_INVALID_HANDLE; } // If the new buffer size is less or equal to the current buffer size then.. if(pHTTPSession->HttpHeaders.HeadersBuffer.nLength >= nNewBufferSize) { // Return an error (bad buffer) return HTTP_CLIENT_ERROR_BUFFER_RSIZE; } // If the new buffer size is bigger then the defined maximum buffer size then.. if(nNewBufferSize > HTTP_CLIENT_MAX_SEND_RECV_HEADERS) { // Return an error (bad buffer) return HTTP_CLIENT_ERROR_BUFFER_RSIZE; } // Current buffer size is the sum of the incoming and outgoing headers strings lengths nCurrentBufferSize = pHTTPSession->HttpHeaders.HeadersOut.nLength + pHTTPSession->HttpHeaders.HeadersIn.nLength; // Allocate a new buffer with the requested buffer size pPtr = (CHAR*)malloc(ALIGN(nNewBufferSize)); if(!pPtr) { // malloc() error return HTTP_CLIENT_ERROR_NO_MEMORY; } // Copy the memory only if there is data to copy if(nCurrentBufferSize > 0) { memcpy(pPtr,pHTTPSession->HttpHeaders.HeadersBuffer.pParam,nCurrentBufferSize); // Reset the rest of the buffer memset(pPtr + nCurrentBufferSize, 0x00,(nNewBufferSize - nCurrentBufferSize)); } else { // Reset the entire buffer (no previous buffer was copied) memset(pPtr,0x00,nNewBufferSize); } free(pHTTPSession->HttpHeaders.HeadersBuffer.pParam); pHTTPSession->HttpHeaders.HeadersBuffer.pParam = pPtr; pHTTPSession->HttpHeaders.HeadersBuffer.nLength = nNewBufferSize; // Refresh the pointers pHTTPSession->HttpHeaders.HeadersOut.pParam = pHTTPSession->HttpHeaders.HeadersBuffer.pParam; if(pHTTPSession->HttpHeaders.HeadersIn.pParam) { pHTTPSession->HttpHeaders.HeadersIn.pParam =pHTTPSession->HttpHeaders.HeadersBuffer.pParam + pHTTPSession->HttpHeaders.HeadersOut.nLength; } return HTTP_CLIENT_SUCCESS; } /////////////////////////////////////////////////////////////////////////////// // // Function : HTTPIntrnRemoveHeader // Purpose : Removes an HTTP headers by its name // Last updated : 01/09/2005 // /////////////////////////////////////////////////////////////////////////////// static UINT32 HTTPIntrnHeadersRemove (P_HTTP_SESSION pHTTPSession, CHAR *pHeaderName) // [IN] The header's name { HTTP_PARAM HttpParam; UINT32 nRetCode = HTTP_CLIENT_SUCCESS; UINT32 nBytes; if(!pHTTPSession) // Pointer validation check { return HTTP_CLIENT_ERROR_INVALID_HANDLE; } // First see if we have that header in our outgoing headers buffer do { if((nRetCode = HTTPIntrnHeadersFind(pHTTPSession,pHeaderName,&HttpParam,FALSE,0)) != HTTP_CLIENT_SUCCESS) { // Could not find this header break; } // Calculate the new headers length nBytes = (HttpParam.pParam - pHTTPSession->HttpHeaders.HeadersOut.pParam); nBytes -= HttpParam.nLength; // Copy the memory memcpy(HttpParam.pParam, HttpParam.pParam + HttpParam.nLength,nBytes); // Set the new length pHTTPSession->HttpHeaders.HeadersOut.nLength -= HttpParam.nLength; // Reset the buffer from it's modified end to it's previous end memset(pHTTPSession->HttpHeaders.HeadersOut.pParam + pHTTPSession->HttpHeaders.HeadersOut.nLength,0x00,HttpParam.nLength); } while(0); #ifdef _HTTP_DEBUGGING_ if(pHTTPSession->pDebug) { pHTTPSession->pDebug("HTTPIntrnHeadersRemove",NULL,0,"Removing Header %",pHeaderName); } #endif return nRetCode; } /////////////////////////////////////////////////////////////////////////////// // // Function : HTTPIntrnHeadersAdd // Purpose : Add HTTP headers to the outgoing headers buffers // Last updated : 01/09/2005 // /////////////////////////////////////////////////////////////////////////////// static UINT32 HTTPIntrnHeadersAdd (P_HTTP_SESSION pHTTPSession, CHAR *pHeaderName, // [IN] The header's name UINT32 nNameLength, // [IN] Name length CHAR *pHeaderData, // [IN] The Header's data UINT32 nDataLength) // [IN] Data length { CHAR *pPtr; UINT32 nProjectedHeaderLength; UINT32 nProjectedBufferLength; INT32 nCurrentfreeSpace; INT32 nProjectedfreeSpace; UINT32 nRetCode; if(!pHTTPSession) // pointer validation check { return HTTP_CLIENT_ERROR_INVALID_HANDLE; } nProjectedHeaderLength = nNameLength + nDataLength + 4; nProjectedBufferLength = nProjectedHeaderLength + pHTTPSession->HttpHeaders.HeadersOut.nLength + pHTTPSession->HttpHeaders.HeadersIn.nLength; nCurrentfreeSpace = pHTTPSession->HttpHeaders.HeadersBuffer.nLength - (pHTTPSession->HttpHeaders.HeadersOut.nLength + pHTTPSession->HttpHeaders.HeadersIn.nLength); nProjectedfreeSpace = nCurrentfreeSpace - nProjectedHeaderLength; // Check total size limit if(nProjectedBufferLength > HTTP_CLIENT_MAX_SEND_RECV_HEADERS) { return HTTP_CLIENT_ERROR_NO_MEMORY; } if((INT32)nProjectedfreeSpace < 0) { if(HTTP_CLIENT_MEMORY_RESIZABLE == FALSE) { // Need more space but we can't grow beyond the current size return HTTP_CLIENT_ERROR_NO_MEMORY; } else { // We can resizes so.. nRetCode = HTTPIntrnResizeBuffer(pHTTPSession,nProjectedBufferLength + HTTP_CLIENT_MEMORY_RESIZE_FACTOR); if(nRetCode != HTTP_CLIENT_SUCCESS) { return nRetCode; } } } // Move the incoming headers data within the buffer so we will have space for the added headers if(pHTTPSession->HttpHeaders.HeadersIn.pParam) { // Move the data and reset the data in the offset. memcpy(pHTTPSession->HttpHeaders.HeadersIn.pParam + nProjectedHeaderLength , pHTTPSession->HttpHeaders.HeadersIn.pParam, pHTTPSession->HttpHeaders.HeadersIn.nLength); // Reset the space created memset(pHTTPSession->HttpHeaders.HeadersOut.pParam + pHTTPSession->HttpHeaders.HeadersOut.nLength, 0x00, nProjectedHeaderLength); } pPtr = pHTTPSession->HttpHeaders.HeadersOut.pParam + pHTTPSession->HttpHeaders.HeadersOut.nLength; // Create the new header memcpy(pPtr,pHeaderName,nNameLength); pPtr += nNameLength; memcpy(pPtr,": ",2); pPtr += 2; memcpy(pPtr,pHeaderData,nDataLength); pPtr += nDataLength; memcpy(pPtr,HTTP_CLIENT_CRLF,2); //pPtr += 2; //Jerome/cppcheck: Variable 'pPtr' is assigned a value that is never used. // Set the new length pHTTPSession->HttpHeaders.HeadersOut.nLength += nProjectedHeaderLength; #ifdef _HTTP_DEBUGGING_ if(pHTTPSession->pDebug) { pHTTPSession->pDebug("HTTPIntrnHeadersAdd",NULL,0,"Adding Header %s: %s",pHeaderName,pHeaderData); } #endif return HTTP_CLIENT_SUCCESS; } /////////////////////////////////////////////////////////////////////////////// // // Function : HTTPIntrnConnectionClose // Purpose : Closes an active socket connection and invalidate the socket handle // Returns : HTTP Status // Last updated : 01/09/2005 // /////////////////////////////////////////////////////////////////////////////// UINT32 HTTPIntrnConnectionClose (P_HTTP_SESSION pHTTPSession) { INT32 nRetCode = HTTP_CLIENT_SUCCESS; do { if(!pHTTPSession) // Validate the session pointer { nRetCode = HTTP_CLIENT_ERROR_INVALID_HANDLE; break; } // If we have a valid socket then.. if(pHTTPSession->HttpConnection.HttpSocket != HTTP_INVALID_SOCKET)// INVALID_SOCKET { if((pHTTPSession->HttpFlags & HTTP_CLIENT_FLAG_SECURE) == HTTP_CLIENT_FLAG_SECURE) { // TLS Close nRetCode = HTTPWrapperSSLClose(pHTTPSession->HttpConnection.HttpSocket); } // Gracefully close it shutdown(pHTTPSession->HttpConnection.HttpSocket,0x01); closesocket(pHTTPSession->HttpConnection.HttpSocket); // And invalidate the socket pHTTPSession->HttpConnection.HttpSocket = HTTP_INVALID_SOCKET; break;; } else { // Not a valid socket error nRetCode = HTTP_CLIENT_ERROR_SOCKET_INVALID; break; } } while(0); #ifdef _HTTP_DEBUGGING_ if(pHTTPSession->pDebug) { pHTTPSession->pDebug("HTTPIntrnConnectionClose",NULL,0,""); } #endif return nRetCode; } /////////////////////////////////////////////////////////////////////////////// // // Function : HTTPIntrnConnectionOpen // Purpose : Opens a socket connection to the remote host or proxy server // Returns : HTTP Status // Last updated : 01/09/2005 // /////////////////////////////////////////////////////////////////////////////// static UINT32 HTTPIntrnConnectionOpen (P_HTTP_SESSION pHTTPSession) { INT32 nRetCode = HTTP_CLIENT_SUCCESS; // a function return code value UINT32 nNullOffset; // a helper value to null terminate a given string int nNonBlocking = 1; // non blocking mode parameter CHAR Backup; // a container for a char value (helps in temporary null termination) // HTTP_HOSTNET *HostEntry; // Socket host entry pointer UINT32 Address = 0; HTTP_SOCKADDR_IN ServerAddress; // Socket address structure HTTP_SOCKADDR_IN LoaclAddress; // Socket address structure (for client binding) do { if(!pHTTPSession) { nRetCode = HTTP_CLIENT_ERROR_INVALID_HANDLE; break; } // Use an existing connection if valid if(pHTTPSession->HttpConnection.HttpSocket != HTTP_INVALID_SOCKET) { // Set the state flag pHTTPSession->HttpState = pHTTPSession->HttpState | HTTP_CLIENT_STATE_HOST_CONNECTED; return HTTP_CLIENT_SUCCESS; } // Zero the socket events FD_ZERO(&pHTTPSession->HttpConnection.FDRead); FD_ZERO(&pHTTPSession->HttpConnection.FDWrite); FD_ZERO(&pHTTPSession->HttpConnection.FDError); if(pHTTPSession->HttpConnection.HttpSocket == HTTP_INVALID_SOCKET) { // Create a TCP/IP stream socket pHTTPSession->HttpConnection.HttpSocket = socket(AF_INET, // Address family SOCK_STREAM, // Socket type IPPROTO_TCP); // Protocol } // Exit if we don't have a valid socket if(pHTTPSession->HttpConnection.HttpSocket == HTTP_INVALID_SOCKET) { nRetCode = HTTP_CLIENT_ERROR_SOCKET_INVALID; break; } // Set non blocking socket nRetCode = ioctlsocket(pHTTPSession->HttpConnection.HttpSocket, FIONBIO, &nNonBlocking); if(nRetCode != 0) { nRetCode = HTTP_CLIENT_ERROR_SOCKET_CANT_SET; break; } // Resolve the target host name if((pHTTPSession->HttpFlags & HTTP_CLIENT_FLAG_USINGPROXY) != HTTP_CLIENT_FLAG_USINGPROXY) { // No proxy, directly resolving the host name // Prep the parameter if((pHTTPSession->HttpFlags & HTTP_CLIENT_FLAG_URLANDPORT) == HTTP_CLIENT_FLAG_URLANDPORT) { nNullOffset = pHTTPSession->HttpUrl.UrlHost.nLength - pHTTPSession->HttpUrl.UrlPort.nLength - 1; } else { nNullOffset = pHTTPSession->HttpUrl.UrlHost.nLength; } Backup = HTTPStrExtract(pHTTPSession->HttpUrl.UrlHost.pParam,nNullOffset,0); // Resolve the host name nRetCode = HostByName(pHTTPSession->HttpUrl.UrlHost.pParam,&Address); // Restore from backup (fix the buffer) HTTPStrExtract(pHTTPSession->HttpUrl.UrlHost.pParam,nNullOffset,Backup); } else { // Using a Proxy server so resolve the proxy host name nRetCode = HostByName(pHTTPSession->HttpProxy.ProxyHost,&Address); } // See if we have a valid response from the net resolve operation /* if(nRetCode) { nRetCode = HTTP_CLIENT_ERROR_SOCKET_RESOLVE; break; } */ // Reset the address structures memset(&ServerAddress, 0, sizeof(HTTP_SOCKADDR_IN)); memset(&LoaclAddress, 0, sizeof(HTTP_SOCKADDR_IN)); // Fill in the address structure ServerAddress.sin_family = AF_INET; #ifdef _HTTP_BUILD_AMT ServerAddress.sin_len = sizeof(HTTP_SOCKADDR_IN); ServerAddress.sin_addr.s_addr = htonl(Address); // Server's address #endif #ifdef _HTTP_BUILD_WIN32 ServerAddress.sin_addr.s_addr = Address; // Server's address #endif if((pHTTPSession->HttpFlags & HTTP_CLIENT_FLAG_USINGPROXY) != HTTP_CLIENT_FLAG_USINGPROXY) { // Use the remote web server port ServerAddress.sin_port = htons(pHTTPSession->HttpUrl.nPort); // Host Port number } else { // Use the proxy port ServerAddress.sin_port = htons(pHTTPSession->HttpProxy.nProxyPort); // Proxy Port number } // Client-side Binding if(pHTTPSession->HttpConnection.HttpClientPort != 0) { LoaclAddress.sin_family = AF_INET; #ifdef _HTTP_BUILD_AMT LoaclAddress.sin_len = sizeof(HTTP_SOCKADDR_IN); #endif LoaclAddress.sin_port = htons((unsigned short)pHTTPSession->HttpConnection.HttpClientPort); nRetCode = bind(pHTTPSession->HttpConnection.HttpSocket, (HTTP_SOCKADDR*)&LoaclAddress, sizeof(HTTP_SOCKADDR_IN)); if(nRetCode != 0) { nRetCode = HTTP_CLIENT_ERROR_SOCKET_BIND; } } // Connect using TLS or otherwise clear connection if((pHTTPSession->HttpFlags & HTTP_CLIENT_FLAG_SECURE) == HTTP_CLIENT_FLAG_SECURE) { // Is it a TLS connection? nRetCode = HTTPWrapperSSLConnect(pHTTPSession->HttpConnection.HttpSocket, // Socket (HTTP_SOCKADDR*)&ServerAddress, // Server address sizeof(HTTP_SOCKADDR), // Length of server address structure "desktop"); // Hostname (ToDo: Fix this) } else // Non TLS so.. { nRetCode = connect(pHTTPSession->HttpConnection.HttpSocket, // Socket (HTTP_SOCKADDR*)&ServerAddress, // Server address sizeof(HTTP_SOCKADDR)); // Length of server address structure } // The socket was set to be asyn so we should check the error being returned from connect() nRetCode = SocketGetErr(pHTTPSession->HttpConnection.HttpSocket); if(nRetCode == 0 || nRetCode == HTTP_EWOULDBLOCK || nRetCode == HTTP_EINPROGRESS) { // Set TLS Nego flag to flase pHTTPSession->HttpConnection.TlsNego = FALSE; // Set the Write fd_sets for a socket connection event FD_SET(pHTTPSession->HttpConnection.HttpSocket, &pHTTPSession->HttpConnection.FDWrite); // Set the state flag pHTTPSession->HttpState = pHTTPSession->HttpState | HTTP_CLIENT_STATE_HOST_CONNECTED; // We have connected so set the return value to success nRetCode = HTTP_CLIENT_SUCCESS; break; } else { // Socket connection problem nRetCode = HTTP_CLIENT_ERROR_SOCKET_CONNECT; break; } }while(0); #ifdef _HTTP_DEBUGGING_ if(pHTTPSession->pDebug) { pHTTPSession->pDebug("HTTPIntrnConnectionOpen",NULL,0,""); } #endif return nRetCode; } /////////////////////////////////////////////////////////////////////////////// // // Function : HTTPIntrnSend // Purpose : Send data to the remote server (Asynchronous sockets) // Returns : HTTP Status // Last updated : 01/09/2005 // /////////////////////////////////////////////////////////////////////////////// static UINT32 HTTPIntrnSend (P_HTTP_SESSION pHTTPSession, CHAR *pData, // [IN] a pointer to the data to be sent UINT32 *nLength) // [IN OUT] Length of data to send and the transmitted bytes count { INT32 nSocketEvents; // Socket events center INT32 nRetCode = HTTP_CLIENT_SUCCESS; // a function return code value HTTP_TIMEVAL Timeval = { 1 , 0 }; // Timeout value for the socket() method HTTP_CONNECTION *pConnection = NULL; // Pointer for the connection structure do { // Validate the session pointer if(!pHTTPSession) { nRetCode = HTTP_CLIENT_ERROR_INVALID_HANDLE; break; } // Have a pointer on the internal connection structure for simplifying code reading pConnection = &pHTTPSession->HttpConnection; while(1) { // Check for timeout if(HTTPIntrnSessionEvalTimeout(pHTTPSession) == TRUE) { nRetCode = HTTP_CLIENT_ERROR_SOCKET_TIME_OUT; break; } // Reset socket events , only Error, since we don't want to get // a repeated Write events (socket is connected) FD_SET(pConnection->HttpSocket, &pConnection->FDError); // See if we got any events on the socket nSocketEvents = select((pConnection->HttpSocket + 1), 0, &pConnection->FDWrite, &pConnection->FDError, &Timeval); if(nSocketEvents < 0) // No events on the socket { *(nLength) = 0; break; // To-Do: This might be an error } if(nSocketEvents == 0) // No new events so { continue; // restart this loop } // Socket is writable (we are connected) so send the data if(FD_ISSET(pConnection->HttpSocket ,&pConnection->FDWrite)) { // Send the data if((pHTTPSession->HttpFlags & HTTP_CLIENT_FLAG_SECURE) == HTTP_CLIENT_FLAG_SECURE) { // TLS Protected connection if(pConnection->TlsNego == FALSE) { nRetCode = HTTPWrapperSSLNegotiate(pConnection->HttpSocket,0,0,"desktop"); if(nRetCode != 0) { // TLS Error nRetCode = HTTP_CLIENT_ERROR_TLS_NEGO; break; } pConnection->TlsNego = TRUE; } nRetCode = HTTPWrapperSSLSend(pConnection->HttpSocket,pData,*(nLength),0); } else { nRetCode = send(pConnection->HttpSocket,pData,*(nLength),0); } if(nRetCode == SOCKET_ERROR) { //nRetCode = SocketGetErr(pHTTPSession->HttpConnection.HttpSocket); //Jerome: is reassigned in the next line nRetCode = HTTP_CLIENT_ERROR_SOCKET_SEND; break; } // The data was sent to the remote server *(nLength) = nRetCode; nRetCode = HTTP_CLIENT_SUCCESS; break; } // We had a socket related error if(FD_ISSET(pConnection->HttpSocket ,&pConnection->FDError)) { FD_CLR((UINT32)pConnection->HttpSocket,&pConnection->FDError); *(nLength) = 0; // To-Do: Handle this case nRetCode = HTTP_CLIENT_ERROR_SOCKET_SEND; break; } } } while(0); #ifdef _HTTP_DEBUGGING_ if(pHTTPSession->pDebug) { pHTTPSession->pDebug("HTTPIntrnSend",pData,*(nLength),""); } #endif return nRetCode; } /////////////////////////////////////////////////////////////////////////////// // // Function : HTTPIntrnRecv // Purpose : Receive data from the connected socket using asynchronous sockets // Returns : HTTP Status // Last updated : 01/09/2005 // /////////////////////////////////////////////////////////////////////////////// static UINT32 HTTPIntrnRecv (P_HTTP_SESSION pHTTPSession, CHAR *pData, // [IN] a pointer for a buffer that receives the data UINT32 *nLength, // [IN OUT] Length of the buffer and the count of the received bytes BOOL PeekOnly) // [IN] State if we should only peek the socket (default is no) { INT32 nSocketEvents; INT32 nRetCode = HTTP_CLIENT_SUCCESS; HTTP_TIMEVAL Timeval = { 0, 50000 }; HTTP_CONNECTION *pConnection = NULL; do { if(!pHTTPSession) { nRetCode = HTTP_CLIENT_ERROR_INVALID_HANDLE; break; } // Set a pointer on the session internal connection structure (simplify code reading) pConnection = &pHTTPSession->HttpConnection; while(1) { // Check for timeout if(HTTPIntrnSessionEvalTimeout(pHTTPSession) == TRUE) { nRetCode = HTTP_CLIENT_ERROR_SOCKET_TIME_OUT; break; } // Reset socket events FD_SET(pConnection->HttpSocket, &pConnection->FDRead); FD_SET(pConnection->HttpSocket, &pConnection->FDError); // See if we got any events on the socket nSocketEvents = select(pConnection->HttpSocket + 1, &pConnection->FDRead, 0, &pConnection->FDError, &Timeval); if(nSocketEvents < 0) // Error or no new socket events { *(nLength) = 0; break; } if(nSocketEvents == 0) { /////////////////////////////////////////////////////////////////////////////////////////////////////////// // This is a simple bypass for the TSL session (for some reason the socket read event is not set so // The pending bytes on the socket are being checked manualy. // TLS hack: if((pHTTPSession->HttpFlags & HTTP_CLIENT_FLAG_SECURE) == HTTP_CLIENT_FLAG_SECURE) { nRetCode = HTTPWrapperSSLRecvPending(pConnection->HttpSocket); if(nRetCode > 0) { // Recive without being notified by the socket event if((nRetCode = HTTPWrapperSSLRecv(pConnection->HttpSocket,pData,*(nLength),0)) == SOCKET_ERROR) { // Socket error nRetCode = HTTP_CLIENT_ERROR_SOCKET_RECV; break; } *(nLength) = nRetCode; // Break on no data or server connection reset if ( nRetCode == 0 || nRetCode == HTTP_ECONNRESET) { // Connection closed, simply break - this is not an error nRetCode = HTTP_CLIENT_EOS; // Signal end of stream break; } // We have successfully got the data from the server nRetCode = HTTP_CLIENT_SUCCESS; break; } } // End Of the TLS bypass section // ///////////////////////////////////////////////////////////////////////////////////////////////// continue; // select() timed out - restart this loop } if(FD_ISSET(pConnection->HttpSocket ,&pConnection->FDRead)) // Are there any read events on the socket ? { // Clear the event FD_CLR((UINT32)pConnection->HttpSocket,&pConnection->FDRead); // Socket is readable so so read the data if(PeekOnly == FALSE) { // Get the data (secuure) if((pHTTPSession->HttpFlags & HTTP_CLIENT_FLAG_SECURE) == HTTP_CLIENT_FLAG_SECURE) { if((nRetCode = HTTPWrapperSSLRecv(pConnection->HttpSocket,pData,*(nLength),0)) == SOCKET_ERROR) { // Socket error nRetCode = HTTP_CLIENT_ERROR_SOCKET_RECV; break; } } else // Get the data (non secuure) { if((nRetCode = recv(pConnection->HttpSocket,pData,*(nLength),0)) == SOCKET_ERROR) { // Socket error nRetCode = HTTP_CLIENT_ERROR_SOCKET_RECV; break; } } } else { // Only peek te socket if((nRetCode = recv(pConnection->HttpSocket,pData,*(nLength),MSG_PEEK)) == SOCKET_ERROR) { // Socket error nRetCode = HTTP_CLIENT_ERROR_SOCKET_RECV; break; } } *(nLength) = nRetCode; // Break on no data or server connection reset // MSDN: If the connection has been gracefully closed, the return value is zero. if ( nRetCode == 0 || nRetCode == HTTP_ECONNRESET) { // Connection closed, simply break - this is not an error nRetCode = HTTP_CLIENT_EOS; // Signal end of stream break; } // We have successfully got the data from the server nRetCode = HTTP_CLIENT_SUCCESS; break; } // We had a socket related error if(FD_ISSET(pConnection->HttpSocket ,&pConnection->FDError)) { FD_CLR((UINT32)pConnection->HttpSocket,&pConnection->FDError); *(nLength) = 0; // To-Do: Handle this case nRetCode = HTTP_CLIENT_ERROR_SOCKET_RECV; break; } } }while(0); return nRetCode; } /////////////////////////////////////////////////////////////////////////////// // // Function : HTTPIntrnGetRemoteChunkLength // Purpose : Receive (byte by byte) the chunk parameter (while in chunk mode receive) and // Convert the HEX string into an integer // Returns : HTTP Status // Last updated : 01/09/2005 // /////////////////////////////////////////////////////////////////////////////// static UINT32 HTTPIntrnGetRemoteChunkLength (P_HTTP_SESSION pHTTPSession) { UINT32 nBytesRead = 1; UINT32 nRetCode = HTTP_CLIENT_SUCCESS; UINT32 nBytesCount = 0; CHAR ChunkHeader[HTTP_CLIENT_MAX_CHUNK_HEADER]; CHAR *pPtr; do { if(!pHTTPSession) { nRetCode = HTTP_CLIENT_ERROR_INVALID_HANDLE; break; } // Read byte by byte until we get a CrLf pPtr = ChunkHeader; // Get a pointer to the received buffer *pPtr = 0; // Terminate with null while(nBytesRead > 0) { // Receive a single byte nRetCode = HTTPIntrnRecv(pHTTPSession,pPtr,&nBytesRead,FALSE); // Did we succeed? if(nRetCode == HTTP_CLIENT_SUCCESS && nBytesRead > 0) { // Increment the bytes count nBytesCount += nBytesRead; if(nBytesRead > HTTP_CLIENT_MAX_CHUNK_HEADER) { // Error chunk buffer is full nRetCode = HTTP_CLIENT_ERROR_CHUNK_TOO_BIG; break; } // Don't Process if the fist 2 bytes are CrLf. if(! ((nBytesCount == 1 && *pPtr == 0x0d) || (nBytesCount == 2 && *pPtr == 0x0a))) { // Advance the pointer by the received data length pPtr += nBytesRead; // Look for CrLf in the last 2 bytes if(memcmp(pPtr - 2,HTTP_CLIENT_CRLF,2) == 0) { // Chunk Header was received *pPtr = 0; // null terminate the chunk parameter pHTTPSession->HttpCounters.nRecivedChunkLength = HTTPStrHToL(ChunkHeader); // Convert to a number // Set the HTTP counters pHTTPSession->HttpCounters.nBytesToNextChunk = pHTTPSession->HttpCounters.nRecivedChunkLength; break; } } } else // Socket Error { nRetCode = 0; break; } } } while(0); #ifdef _HTTP_DEBUGGING_ if(pHTTPSession->pDebug) { pHTTPSession->pDebug("HTTPIntrnGetRemoteChunkLength",NULL,0,"Next chunk is %d bytes",pHTTPSession->HttpCounters.nRecivedChunkLength); } #endif return nRetCode; } /////////////////////////////////////////////////////////////////////////////// // // Function : HTTPIntrnGetRemoteHeaders // Purpose : Perform a socket receive (byte by byte) until all the HTTP headers are received // Returns : HTTP Status // Last updated : 01/09/2005 // /////////////////////////////////////////////////////////////////////////////// static UINT32 HTTPIntrnGetRemoteHeaders (P_HTTP_SESSION pHTTPSession) { UINT32 nBytesRead = 1; UINT32 nRetCode = HTTP_CLIENT_SUCCESS; UINT32 nProjectedHeaderLength; UINT32 nProjectedBufferLength; INT32 nCurrentfreeSpace; INT32 nProjectedfreeSpace; CHAR *pPtr; do { if(!pHTTPSession) { nRetCode = HTTP_CLIENT_ERROR_INVALID_HANDLE; break; } // Read byte by byte until we get CrLf followed by CrLf // Set the incoming headers pointer if(!pHTTPSession->HttpHeaders.HeadersIn.pParam) { /// The incoming headers starts where the outgoing headers ends pHTTPSession->HttpHeaders.HeadersIn.pParam = pHTTPSession->HttpHeaders.HeadersOut.pParam + pHTTPSession->HttpHeaders.HeadersOut.nLength; } // Receive until we get all the headers or any other error event while(nBytesRead > 0) { // Size of the projected buffer we are going to receive nProjectedHeaderLength = nBytesRead; // Size of the projected total incoming buffer nProjectedBufferLength = nProjectedHeaderLength + pHTTPSession->HttpHeaders.HeadersOut.nLength + pHTTPSession->HttpHeaders.HeadersIn.nLength; // Current free space on the incoming headers buffer nCurrentfreeSpace = pHTTPSession->HttpHeaders.HeadersBuffer.nLength - (pHTTPSession->HttpHeaders.HeadersOut.nLength + pHTTPSession->HttpHeaders.HeadersIn.nLength); // Projected free space after the completion of the receive nProjectedfreeSpace = nCurrentfreeSpace - nProjectedHeaderLength; // Check total size limit if(nProjectedBufferLength > HTTP_CLIENT_MAX_SEND_RECV_HEADERS) { return HTTP_CLIENT_ERROR_NO_MEMORY; } if((INT32)nProjectedfreeSpace < 0) { if(HTTP_CLIENT_MEMORY_RESIZABLE == FALSE) { // Need more space but we can't grow beyond the current size nRetCode = HTTP_CLIENT_ERROR_NO_MEMORY; break; } else { // We can resizes so.. nRetCode = HTTPIntrnResizeBuffer(pHTTPSession,nProjectedBufferLength + HTTP_CLIENT_MEMORY_RESIZE_FACTOR); if(nRetCode != HTTP_CLIENT_SUCCESS) { break; } } } // Jump to the beginning of the incoming headers (just after the end of the outgoing headers) pPtr = pHTTPSession->HttpHeaders.HeadersIn.pParam + pHTTPSession->HttpHeaders.HeadersIn.nLength; // Read a single byte nRetCode = HTTPIntrnRecv(pHTTPSession,pPtr,&nBytesRead,FALSE); // ToDo: Break if not getting HTTP on the first 4 bytes if(nRetCode == HTTP_CLIENT_SUCCESS && nBytesRead > 0) { // Advance the pointer by 1 byte pPtr += nBytesRead; // Increase the total receive length pHTTPSession->HttpHeaders.HeadersIn.nLength++; // Set the HTTP counters pHTTPSession->HttpCounters.nRecivedHeaderLength++; if(memcmp(pPtr - 4,HTTP_CLIENT_CRLFX2,4) == 0) { // Headers were received break; } } else { nRetCode = HTTP_CLIENT_ERROR_HEADER_RECV; // This was marked out for some reason break; } } }while(0); #ifdef _HTTP_DEBUGGING_ if(pHTTPSession->pDebug) { pHTTPSession->pDebug("HTTPIntrnGetRemoteHeaders",NULL,0,"Got %d bytes",pHTTPSession->HttpHeaders.HeadersIn.nLength); } #endif return nRetCode; } /////////////////////////////////////////////////////////////////////////////// // // Function : HTTPIntrnHeadersFind // Purpose : Look for a header (insensitive search) by its name // Gets : HTTP Status // Last updated : 01/09/2005 // /////////////////////////////////////////////////////////////////////////////// static UINT32 HTTPIntrnHeadersFind (P_HTTP_SESSION pHTTPSession,CHAR *pHeaderName, HTTP_PARAM *pParam, // [OUT] HTTP parameter structure that holds the search results BOOL IncommingHeaders, // [IN] Indicate if we are to search in the incoming or outgoing headers UINT32 nOffset) // [IN] Optionaly privide an offset to start looking from { CHAR *pHeaderEnd; CHAR Header[HTTP_CLIENT_MAX_HEADER_SEARCH_CLUE]; // To-Do: Use pointers insted of fixed length UINT32 nLength; UINT32 nRetCode = HTTP_CLIENT_ERROR_HEADER_NOT_FOUND; do { if(!pHTTPSession) { nRetCode = HTTP_CLIENT_ERROR_INVALID_HANDLE; break; } // Reset the input parameter structure pParam->pParam = NULL; pParam->nLength = 0; // Get the requested header length nLength = strlen(pHeaderName); if(nLength > (HTTP_CLIENT_MAX_HEADER_SEARCH_CLUE - 3)) { // Error : header search clue too big nRetCode = HTTP_CLIENT_ERROR_HEADER_BIG_CLUE; break; } // Build the searched header name , add a leading CrLf before the header name and trailing ":" memset(Header,0x00,HTTP_CLIENT_MAX_HEADER_SEARCH_CLUE); strcpy(Header,HTTP_CLIENT_CRLF); strcat(Header,pHeaderName); strcat(Header,":"); // Case insensitive search for the header name (search the incoming headers) if(IncommingHeaders == TRUE) { pParam->pParam = HTTPStrCaseStr(pHTTPSession->HttpHeaders.HeadersIn.pParam + nOffset, pHTTPSession->HttpHeaders.HeadersIn.nLength, Header); } else { // Optionally search the outgoing headers pParam->pParam = HTTPStrCaseStr(pHTTPSession->HttpHeaders.HeadersOut.pParam + nOffset, pHTTPSession->HttpHeaders.HeadersOut.nLength, Header); } if(pParam->pParam) // Did we find it? { // Search for the token end (trailing CrLf) pHeaderEnd = strstr(pParam->pParam + 2,HTTP_CLIENT_CRLF); if(pHeaderEnd) { // Get the length (up to the CrLf) pParam->nLength = pHeaderEnd - pParam->pParam; nRetCode = HTTP_CLIENT_SUCCESS; break; } } }while(0); // Could not find the header return nRetCode; } /////////////////////////////////////////////////////////////////////////////// // // Function : HTTPIntrnAuthenticate // Purpose : // Returns : HTTP Status // Last updated : 01/09/2005 // /////////////////////////////////////////////////////////////////////////////// static UINT32 HTTPIntrnAuthenticate(P_HTTP_SESSION pHTTPSession) { UINT32 nRetCode = HTTP_CLIENT_SUCCESS; // Function call return code UINT32 nBytes = 32; UINT32 nTotalBytes = 0; CHAR ErrorPage[32]; BOOL NewConnection = FALSE; do { // Validate the session pointer if(!pHTTPSession) { nRetCode = HTTP_CLIENT_ERROR_INVALID_HANDLE; break; } // Handle connection close message (reconnect) if(pHTTPSession->HttpHeadersInfo.Connection == FALSE) { // Gracefully close the connection and set the socket as invalid if(pHTTPSession->HttpConnection.HttpSocket != HTTP_INVALID_SOCKET) { HTTPIntrnConnectionClose(pHTTPSession); } // Connect to the remote server (or proxy) nRetCode = HTTPIntrnConnectionOpen(pHTTPSession); if(nRetCode != HTTP_CLIENT_SUCCESS) { break; } NewConnection = TRUE; } // Analyze the security headers and optionally build the authentication reply header if((nRetCode = HTTPIntrnParseAuthHeader(pHTTPSession))!= HTTP_CLIENT_SUCCESS) { break; } // We have to recive any HTML data here inorder to "Clear" the socket buffer for later usage // Note: We should skip this when the HEAD verb was used while(NewConnection == FALSE && pHTTPSession->HttpHeaders.HttpLastVerb != VerbHead && pHTTPSession->HttpHeadersInfo.nHTTPContentLength > 0 && nBytes > 0) { ErrorPage[0] = 0; if((nRetCode = HTTPIntrnRecv(pHTTPSession,ErrorPage,&nBytes,FALSE)) != HTTP_CLIENT_SUCCESS) { break; } nTotalBytes += nBytes; if(nTotalBytes >= pHTTPSession->HttpHeadersInfo.nHTTPContentLength) { break; } } // Re-Send the headers after having analyzed the authorizaton headers if((nRetCode = HTTPIntrnHeadersSend(pHTTPSession,pHTTPSession->HttpHeaders.HttpVerb)) != HTTP_CLIENT_SUCCESS) { break; } }while(0); #ifdef _HTTP_DEBUGGING_ if(pHTTPSession->pDebug) { pHTTPSession->pDebug("HTTPIntrnAuthenticate",NULL,0,""); } #endif return nRetCode; } /////////////////////////////////////////////////////////////////////////////// // // Function : HTTPIntrnHeadersParse // Purpose : Parse the HTTP incoming headers. // Returns : HTTP Status // Last updated : 01/09/2005 // /////////////////////////////////////////////////////////////////////////////// static UINT32 HTTPIntrnHeadersParse (P_HTTP_SESSION pHTTPSession) { CHAR *pPtr; // a pointer that points on the incoming headers UINT32 nTokenLength = 0; // Length of the parsed token UINT32 nRetCode = HTTP_CLIENT_SUCCESS; // a function return code value UINT32 nOffset = 0; // Bytes offset (strings comperision) CHAR HTTPToken[HTTP_CLIENT_MAX_TOKEN_LENGTH]; // Buffer for the parsed HTTP token HTTP_PARAM HTTPParam; // A generic pointer\length parameter for parsing BOOL AuthHeaders = FALSE; // While we are searching the authentication methods do { // Validate the session pointer if(!pHTTPSession) { nRetCode = HTTP_CLIENT_ERROR_INVALID_HANDLE; break; } #ifdef _HTTP_DEBUGGING_ if(pHTTPSession->pDebug) { pHTTPSession->pDebug("HTTPIntrnHeadersParse",pHTTPSession->HttpHeaders.HeadersIn.pParam,pHTTPSession->HttpHeaders.HeadersIn.nLength,"[Incomming Headers]"); } #endif // Set a pointer on the incoming headers pPtr = pHTTPSession->HttpHeaders.HeadersIn.pParam; // Detect the leading HTTP string if(HTTPStrInsensitiveCompare(pPtr,"http",4) != TRUE) { nRetCode = HTTP_CLIENT_ERROR_BAD_HEADER; break; } // Get the HTTP Version while ((*pPtr) && (*pPtr != 0x20)) { nTokenLength++; pPtr++; // Move to the first space } strncpy(pHTTPSession->HttpHeadersInfo.HTTPVersion, pPtr - nTokenLength, MIN(15,nTokenLength)); pPtr++; // Get the HTTP status code memset(HTTPToken,0x00,HTTP_CLIENT_MAX_TOKEN_LENGTH); nTokenLength = 0; while ((*pPtr) && (*pPtr != 0x20)) { nTokenLength++; pPtr++; // Move to the next space } strncpy(HTTPToken,(pPtr - nTokenLength),MIN(HTTP_CLIENT_MAX_TOKEN_LENGTH,nTokenLength)); pHTTPSession->HttpHeadersInfo.nHTTPStatus = atol(HTTPToken); // Search for content length pHTTPSession->HttpHeadersInfo.nHTTPContentLength = 0; // Default no unknown length // Look for the token if(HTTPIntrnHeadersFind(pHTTPSession,"content-length",&HTTPParam,TRUE,0) == HTTP_CLIENT_SUCCESS) { memset(HTTPToken,0x00,HTTP_CLIENT_MAX_TOKEN_LENGTH); // Reset the token buffer nTokenLength = HTTP_CLIENT_MAX_TOKEN_LENGTH; // Set the buffer length // Attempt to extract the token if(HTTPStrGetToken(HTTPParam.pParam,HTTPParam.nLength,HTTPToken,&nTokenLength)) { // Convert the content-length into an integer. pHTTPSession->HttpHeadersInfo.nHTTPContentLength = atol(HTTPToken); } } // Search for connection status pHTTPSession->HttpHeadersInfo.Connection = TRUE; // Default status where no server connection header was detected // Look for token (can be standard connection or a proxy connection) if( (HTTPIntrnHeadersFind(pHTTPSession,"connection",&HTTPParam,TRUE,0) == HTTP_CLIENT_SUCCESS) || (HTTPIntrnHeadersFind(pHTTPSession,"proxy-connection",&HTTPParam,TRUE,0) == HTTP_CLIENT_SUCCESS)) { memset(HTTPToken,0x00,HTTP_CLIENT_MAX_TOKEN_LENGTH); nTokenLength = HTTP_CLIENT_MAX_TOKEN_LENGTH; // Attempt to extract the token if(HTTPStrGetToken(HTTPParam.pParam,HTTPParam.nLength,HTTPToken,&nTokenLength)) { // Is this a keep alive session? pHTTPSession->HttpHeadersInfo.Connection = HTTPStrInsensitiveCompare(HTTPToken,"keep-alive",0); // Is it a closed session if(HTTPStrInsensitiveCompare(HTTPToken,"close",0) == TRUE) { pHTTPSession->HttpHeadersInfo.Connection = FALSE; } } } // Search for chunking mode transfer pHTTPSession->HttpFlags = pHTTPSession->HttpFlags &~ HTTP_CLIENT_FLAG_CHUNKED; // Remove the flag if(HTTPIntrnHeadersFind(pHTTPSession,"transfer-encoding",&HTTPParam,TRUE,0) == HTTP_CLIENT_SUCCESS) { memset(HTTPToken,0x00,HTTP_CLIENT_MAX_TOKEN_LENGTH); nTokenLength = HTTP_CLIENT_MAX_TOKEN_LENGTH; if(HTTPStrGetToken(HTTPParam.pParam,HTTPParam.nLength,HTTPToken,&nTokenLength)) { // If the chunks token was find then set the session flag accordingly if(HTTPStrInsensitiveCompare(HTTPToken,"chunked",0) == TRUE) { pHTTPSession->HttpFlags = pHTTPSession->HttpFlags | HTTP_CLIENT_FLAG_CHUNKED; } } } // Look for the authentication header while(AuthHeaders == FALSE) // address multiple authentication methods presented by the server { if(pHTTPSession->HttpHeadersInfo.nHTTPStatus == HTTP_STATUS_UNAUTHORIZED) { // Double check for the "www-authenticate" header token if(HTTPIntrnHeadersFind(pHTTPSession,"www-authenticate",&pHTTPSession->HttpAuthHeader.AuthHeader,TRUE,nOffset) != HTTP_CLIENT_SUCCESS) { if(nOffset > 0) // an authentication header was found but not the right one so adjust the error { nRetCode = HTTP_CLIENT_ERROR_AUTH_MISMATCH; } else { nRetCode = HTTP_CLIENT_ERROR_BAD_HEADER; } break; } // Make sure that we get an authentication header that maches the caller requested schema pPtr = HTTPStrCaseStr(pHTTPSession->HttpAuthHeader.AuthHeader.pParam, pHTTPSession->HttpAuthHeader.AuthHeader.nLength, pHTTPSession->HttpCredentials.AuthSchemaName); if(pPtr) { AuthHeaders = TRUE; } else { // Simply pass the point where the last "www" was found nOffset = (pHTTPSession->HttpAuthHeader.AuthHeader.pParam - pHTTPSession->HttpHeaders.HeadersIn.pParam) + 3; } } else { AuthHeaders = TRUE; } } // Is this a proxy authentication header? if(pHTTPSession->HttpHeadersInfo.nHTTPStatus == HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED) { // Double check for the "Proxy-Authentication" header token if (HTTPIntrnHeadersFind(pHTTPSession,"proxy-authenticate",&pHTTPSession->HttpAuthHeader.AuthHeader,TRUE,0) != HTTP_CLIENT_SUCCESS) { nRetCode = HTTP_CLIENT_ERROR_BAD_HEADER; break; } } // Do we have a redirection response? if( (pHTTPSession->HttpHeadersInfo.nHTTPStatus == HTTP_STATUS_OBJECT_MOVED) || (pHTTPSession->HttpHeadersInfo.nHTTPStatus == HTTP_STATUS_OBJECT_MOVED_PERMANENTLY)) { // Check for the "Location" header token if (HTTPIntrnHeadersFind(pHTTPSession,"location",&pHTTPSession->HttpHeadersInfo.HttpRedirectURL,TRUE,0) != HTTP_CLIENT_SUCCESS) { // Protocol violation, we got a redirect code without the host name to redirect to nRetCode = HTTP_CLIENT_ERROR_BAD_HEADER; break; } // Fix the pointers location (address the "Location: " prefix) pHTTPSession->HttpHeadersInfo.HttpRedirectURL.pParam += 12; pHTTPSession->HttpHeadersInfo.HttpRedirectURL.nLength -= 12; } }while(0); return nRetCode; } /////////////////////////////////////////////////////////////////////////////// // // Function : HTTPIntrnParseAuthHeader // Purpose : Parse the HTTP headers for the required authentication method // Gets : // Returns : HTTP Status // Last updated : 01/09/2005 // /////////////////////////////////////////////////////////////////////////////// static UINT32 HTTPIntrnParseAuthHeader(P_HTTP_SESSION pHTTPSession) { CHAR *pPtrStart, *pPtrEnd; if(!pHTTPSession) { return HTTP_CLIENT_ERROR_INVALID_HANDLE; } if(pHTTPSession->HttpProxy.ProxyAuthSchema != AuthSchemaNone) { // for proxy authentication simply assume basic and exit return HTTP_CLIENT_SUCCESS; } // Advance the pointer in the string and break on the first space pPtrEnd = pHTTPSession->HttpAuthHeader.AuthHeader.pParam + pHTTPSession->HttpAuthHeader.AuthHeader.nLength; pPtrStart = pHTTPSession->HttpAuthHeader.AuthHeader.pParam; // Jump to the first space while ((pPtrEnd - pPtrStart) > 0 && *pPtrStart != 0x20) pPtrStart++; do { if(HTTPStrCaseStr(pPtrStart,8,"basic")) { pHTTPSession->HttpAuthHeader.HTTP_AUTH_SCHEMA = AuthSchemaBasic; break; } if(HTTPStrCaseStr(pPtrStart,8,"digest")) { pHTTPSession->HttpAuthHeader.HTTP_AUTH_SCHEMA = AuthSchemaDigest; break; } if(HTTPStrCaseStr(pPtrStart,8,"negotiate")) // Note that this could be NLM negotiation as well (which is not supported) { pHTTPSession->HttpAuthHeader.HTTP_AUTH_SCHEMA = AuthSchemaKerberos; break; } // To-Do: Add any other supported authentication method } while(0); #ifdef _HTTP_DEBUGGING_ if(pHTTPSession->pDebug) { pHTTPSession->pDebug("HTTPIntrnParseAuthHeader",pHTTPSession->HttpAuthHeader.AuthHeader.pParam, pHTTPSession->HttpAuthHeader.AuthHeader.nLength,"[Incomming Auth Headers: %d]",pHTTPSession->HttpAuthHeader.HTTP_AUTH_SCHEMA); } #endif // If we could not detect the authentication schema return an error if(pHTTPSession->HttpAuthHeader.HTTP_AUTH_SCHEMA == AuthSchemaNone) { return HTTP_CLIENT_ERROR_BAD_AUTH; } //Make sure we are going to authenticate with the method specified by the caller if(pHTTPSession->HttpAuthHeader.HTTP_AUTH_SCHEMA != (UINT32)pHTTPSession->HttpCredentials.CredAuthSchema) { return HTTP_CLIENT_ERROR_AUTH_MISMATCH; } return HTTP_CLIENT_SUCCESS; } /////////////////////////////////////////////////////////////////////////////// // // Function : HTTPIntrnHeadersSend // Purpose : Build and send the HTTP request. this includes the HTTP headers // and any required authentication data // Gets : // Returns : HTTP Status // Last updated : 01/09/2005 // /////////////////////////////////////////////////////////////////////////////// static UINT32 HTTPIntrnHeadersSend(P_HTTP_SESSION pHTTPSession, HTTP_VERB HttpVerb) // [IN] Argument that can bypass the requested verb // Can be used for evaluating a HEAD request { UINT32 nBytes; UINT32 nRetCode = HTTP_CLIENT_SUCCESS; CHAR RequestCmd[16]; CHAR ContentLength[32]; BOOL RestoreHeadersFlag = FALSE; HTTP_VERB HttpCachedVerb; //CHAR *pPtr; // Content length conversion //Jerome/cppcheck: Variable 'pPtr' is assigned a value that is never used. if(!pHTTPSession) { // Bad session pointer error return HTTP_CLIENT_ERROR_INVALID_HANDLE; } #ifdef _HTTP_DEBUGGING_ if(pHTTPSession->pDebug) { pHTTPSession->pDebug("HTTPIntrnHeadersSend",NULL, 0,"Using Verb: %d",(INT32)HttpVerb); } #endif // Cache the original VERB HttpCachedVerb = pHTTPSession->HttpHeaders.HttpVerb; do { // Set the verb (temporarily) if(pHTTPSession->HttpHeaders.HttpVerb != HttpVerb) { if((nRetCode = HTTPClientSetVerb((HTTP_SESSION_HANDLE)pHTTPSession,HttpVerb)) != HTTP_CLIENT_SUCCESS) { break; } } // Remeber this state for later usage pHTTPSession->HttpHeaders.HttpLastVerb = pHTTPSession->HttpHeaders.HttpVerb; // If this is a head request we should temporary remove the chunking header and the content length header if(pHTTPSession->HttpHeaders.HttpVerb == VerbHead) { // If send in chunks flag was set if((pHTTPSession->HttpFlags & HTTP_CLIENT_FLAG_SEND_CHUNKED) == HTTP_CLIENT_FLAG_SEND_CHUNKED) { // Chunking if((nRetCode = HTTPIntrnHeadersRemove(pHTTPSession,"Transfer-Encoding")) != HTTP_CLIENT_SUCCESS) { break; } } // Content-Length if(pHTTPSession->HttpHeadersInfo.nHTTPPostContentLength > 0) // Attempt to remove only if it was previusly set { if((nRetCode = HTTPIntrnHeadersRemove(pHTTPSession,"Content-Length")) != HTTP_CLIENT_SUCCESS) { break; } } RestoreHeadersFlag = TRUE; // So it would be restored later } // Request Verb nBytes = strlen(pHTTPSession->HttpHeaders.Verb) + 1; memset(RequestCmd,0x00,16); strcpy(RequestCmd,pHTTPSession->HttpHeaders.Verb); strcat(RequestCmd," "); if((nRetCode = HTTPIntrnSend(pHTTPSession,RequestCmd,&nBytes)) != HTTP_CLIENT_SUCCESS) { break; } // Set the counters pHTTPSession->HttpCounters.nSentHeaderBytes += nBytes; // Request URI if((pHTTPSession->HttpFlags & HTTP_CLIENT_FLAG_USINGPROXY) != HTTP_CLIENT_FLAG_USINGPROXY) { nBytes = pHTTPSession->HttpUrl.UrlRequest.nLength; if((nRetCode = HTTPIntrnSend(pHTTPSession,pHTTPSession->HttpUrl.UrlRequest.pParam,&nBytes)) != HTTP_CLIENT_SUCCESS) { break; } // Set the counters pHTTPSession->HttpCounters.nSentHeaderBytes += nBytes; } else { nBytes = strlen(pHTTPSession->HttpUrl.Url); if((nRetCode = HTTPIntrnSend(pHTTPSession,pHTTPSession->HttpUrl.Url,&nBytes)) != HTTP_CLIENT_SUCCESS) { break; } // Set the counters pHTTPSession->HttpCounters.nSentHeaderBytes += nBytes; } // Request HTTP Version //memset(RequestCmd+1,0x00,15); //Jerome: memory is overwritten in the next line strcpy(RequestCmd," "); strcat(RequestCmd,HTTP_CLIENT_DEFAULT_VER); strcat(RequestCmd,HTTP_CLIENT_CRLF); nBytes = strlen(RequestCmd); if((nRetCode = HTTPIntrnSend(pHTTPSession,RequestCmd,&nBytes)) != HTTP_CLIENT_SUCCESS) { break; } // Set the counters pHTTPSession->HttpCounters.nSentHeaderBytes += nBytes; // Request headers nBytes = pHTTPSession->HttpHeaders.HeadersOut.nLength; if((nRetCode = HTTPIntrnSend(pHTTPSession,pHTTPSession->HttpHeaders.HeadersOut.pParam,&nBytes)) != HTTP_CLIENT_SUCCESS) { break; } // Set the counters pHTTPSession->HttpCounters.nSentHeaderBytes += nBytes; // Optionally add authentication headers and send them (for host or proxy authentication) if(pHTTPSession->HttpHeadersInfo.nHTTPStatus == HTTP_STATUS_UNAUTHORIZED || pHTTPSession->HttpHeadersInfo.nHTTPStatus == HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED ) { if((nRetCode = HTTPIntrnAuthHandler(pHTTPSession)) != HTTP_CLIENT_SUCCESS) { break; } } // Request terminating CrLf nBytes = strlen(HTTP_CLIENT_CRLF); if((nRetCode = HTTPIntrnSend(pHTTPSession,HTTP_CLIENT_CRLF,&nBytes)) != HTTP_CLIENT_SUCCESS) { break; } // Set the counters pHTTPSession->HttpCounters.nSentHeaderBytes += nBytes; // Restore the verb if(pHTTPSession->HttpHeaders.HttpVerb != HttpCachedVerb) { if((nRetCode = HTTPClientSetVerb((HTTP_SESSION_HANDLE)pHTTPSession,HttpCachedVerb)) != HTTP_CLIENT_SUCCESS) { break; } } if(RestoreHeadersFlag == TRUE) { // Restore chunking header (since it was temporarily removed for the head request // Add the Transfer-Encoding: header if((pHTTPSession->HttpFlags & HTTP_CLIENT_FLAG_SEND_CHUNKED) == HTTP_CLIENT_FLAG_SEND_CHUNKED) { if((nRetCode = HTTPIntrnHeadersAdd(pHTTPSession,"Transfer-Encoding",17,"chunked",7))!= HTTP_CLIENT_SUCCESS) { break; } } // Restore the content length if(pHTTPSession->HttpHeadersInfo.nHTTPPostContentLength > 0) // Attempt to remove only if it was previusly set { IToA(ContentLength,pHTTPSession->HttpHeadersInfo.nHTTPPostContentLength); // Convert the buffer length to a string value //pPtr = //Jerome/cppcheck: Variable 'pPtr' is assigned a value that is never used. if((nRetCode = HTTPIntrnHeadersAdd(pHTTPSession,"Content-Length",14,ContentLength,strlen(ContentLength)))!= HTTP_CLIENT_SUCCESS) { return nRetCode; } } } // Set the session stage pHTTPSession->HttpState = pHTTPSession->HttpState | HTTP_CLIENT_STATE_REQUEST_SENT; } while(0); return nRetCode; // end of HTTPIntrnSendHeaders() } /////////////////////////////////////////////////////////////////////////////// // // Function : HTTPIntrnAuthHandler // Purpose : Differentiate between the authenticate method that we have to implement and perform // the required operation. // Gets : // Returns : HTTP Status // Last updated : 01/09/2005 // /////////////////////////////////////////////////////////////////////////////// static UINT32 HTTPIntrnAuthHandler (P_HTTP_SESSION pHTTPSession) { UINT32 nRetCode = HTTP_CLIENT_SUCCESS; if(!pHTTPSession) { // Bad session pointer error return HTTP_CLIENT_ERROR_INVALID_HANDLE; } if(pHTTPSession->HttpProxy.ProxyAuthSchema != AuthSchemaNone) { // For proxy authentication simply assume basic and exit // Basic authentication nRetCode = HTTPIntrnAuthSendBasic(pHTTPSession); return nRetCode; } #ifdef _HTTP_DEBUGGING_ if(pHTTPSession->pDebug) { pHTTPSession->pDebug("HTTPIntrnAuthHandler",NULL, 0,""); } #endif // Use the correct authentication method as requested by the server switch(pHTTPSession->HttpAuthHeader.HTTP_AUTH_SCHEMA) { case AuthSchemaBasic: { // Basic authentication nRetCode = HTTPIntrnAuthSendBasic(pHTTPSession); break; } case AuthSchemaDigest: { // Digest authentication nRetCode = HTTPIntrnAuthSendDigest(pHTTPSession); break; } case AuthSchemaKerberos: { // ToDo: impliament the Kerberos nego authentication here nRetCode = HTTP_CLIENT_ERROR_NOT_IMPLEMENTED; break; } default: { // Not supported method return HTTP_CLIENT_ERROR_BAD_AUTH; // Not implemented error } }; // This session requested an authentication so.. pHTTPSession->HttpCredentials.Authentication = TRUE; return nRetCode; } /////////////////////////////////////////////////////////////////////////////// // // Function : HTTPIntrnAuthSendBasic // Purpose : Handle basic authentication for direst host connection and proxy authentication // Gets : // Returns : // Last updated : 01/09/2005 // /////////////////////////////////////////////////////////////////////////////// static UINT32 HTTPIntrnAuthSendBasic (P_HTTP_SESSION pHTTPSession) { UINT32 nSegmentLength; UINT32 nRetCode; CHAR Cred[HTTP_CLIENT_MAX_64_ENCODED_CRED /2]; // Credentials (Clear) CHAR Cred64[HTTP_CLIENT_MAX_64_ENCODED_CRED]; // Credentials (64 bit encoded) UINT32 nSrcLength, nDestLength; CHAR* pPtr; CHAR* INITIAL_HDR = "Authorization: Basic "; CHAR* INITIAL_PROXY_HDR = "Proxy-Authorization: Basic "; do { if(!pHTTPSession) { nRetCode = HTTP_CLIENT_ERROR_INVALID_HANDLE; break; } #ifdef _HTTP_DEBUGGING_ if(pHTTPSession->pDebug) { pHTTPSession->pDebug("HTTPIntrnAuthSendBasic",NULL, 0,""); } #endif memset(Cred,0x00,HTTP_CLIENT_MAX_64_ENCODED_CRED /2); memset(Cred64,0x00,HTTP_CLIENT_MAX_64_ENCODED_CRED); switch (pHTTPSession->HttpHeadersInfo.nHTTPStatus) { case( HTTP_STATUS_UNAUTHORIZED): // For host authentication { // Copy the clear text credentials to a format of user:password strcpy(Cred,pHTTPSession->HttpCredentials.CredUser); strcat(Cred,":"); strcat(Cred,pHTTPSession->HttpCredentials.CredPassword); nSrcLength = strlen(Cred); nDestLength = HTTP_CLIENT_MAX_64_ENCODED_CRED; nSegmentLength = strlen(INITIAL_HDR); // Build and send the data first the hard-coded static portion if((nRetCode = HTTPIntrnSend(pHTTPSession,INITIAL_HDR, &nSegmentLength)) != HTTP_CLIENT_SUCCESS) { break; } // Set the counters pHTTPSession->HttpCounters.nSentHeaderBytes += nSegmentLength; // Convert to base 64 HTTPBase64Encoder((unsigned char *)Cred64,(CONST unsigned char *)Cred,nSrcLength); nDestLength = strlen(Cred64); }; break; case (HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED): // For Proxy authentication { // Copy the clear text credentials to a format of user:password strcpy(Cred,pHTTPSession->HttpProxy.ProxtUser); strcat(Cred,":"); strcat(Cred,pHTTPSession->HttpProxy.ProxyPassword); nSrcLength = strlen(Cred); //nDestLength = HTTP_CLIENT_MAX_64_ENCODED_CRED; //Jerome: is reassigned few lines later // Convert to base 64 HTTPBase64Encoder((unsigned char *)Cred64,(unsigned char *)Cred,nSrcLength); nDestLength = strlen(Cred64); nSegmentLength = strlen(INITIAL_PROXY_HDR); // Build and send the data first the hard-coded static portion if((nRetCode = HTTPIntrnSend(pHTTPSession,INITIAL_PROXY_HDR, &nSegmentLength)) != HTTP_CLIENT_SUCCESS) { break; } // Set the counters pHTTPSession->HttpCounters.nSentHeaderBytes += nSegmentLength; }; break; default: { return HTTP_CLIENT_ERROR_BAD_AUTH; // Wrong status for this function }; }; // Send the base 64 encoded data pPtr = Cred64; if((nRetCode = HTTPIntrnSend(pHTTPSession,pPtr, &nDestLength)) != HTTP_CLIENT_SUCCESS) { break; } // Set the counters pHTTPSession->HttpCounters.nSentHeaderBytes += nDestLength; // Terminating CRLF nSegmentLength = strlen(HTTP_CLIENT_CRLF); if((nRetCode = HTTPIntrnSend(pHTTPSession,HTTP_CLIENT_CRLF, &nSegmentLength)) != HTTP_CLIENT_SUCCESS) { break; } // Set the counters pHTTPSession->HttpCounters.nSentHeaderBytes += nSegmentLength; } while (0); return nRetCode; } /////////////////////////////////////////////////////////////////////////////// // // Function : HTTPIntrnAuthSendDigest // Purpose : Handle digest authentication for direct host connection and proxy authentication // Gets : // Returns : HTTP Status // Last updated : 01/09/2005 // /////////////////////////////////////////////////////////////////////////////// static UINT32 HTTPIntrnAuthSendDigest (P_HTTP_SESSION pHTTPSession) { CHAR Cnonce[33]; UINT32 nSegmentLength; UINT32 nRetCode; UINT32 nAlgType = 0; // a flag for the algorithem type (default to MD5) HTTP_PARAM HttpParamOpq,HttpParamRealm,HttpParamNonce,HttpParamQop,HttpParamAlg; // Pointers and lengths of the dynamic sections // of the Digest response. // Fragments of the Digest client response (The hard coded text portion of the response) CHAR* INITIAL_HDR = "Authorization: Digest username=\""; CHAR* INITIAL_PROXY_HDR = "Proxy-Authorization: Digest username=\""; CHAR* REALEM_HDR = "\", realm=\""; CHAR* QOP_HDR = "\", qop=\""; CHAR* ALGO_HDR = "\", algorithm=\""; CHAR* URI_HDR = "\", uri=\""; CHAR* NONCE_HDR = "\", nonce=\""; CHAR* NC_HDR = "\", nc=00000001, cnonce=\""; // To-Do: This should be tested!! CHAR* RSP_HDR = "\", response=\""; CHAR* OPQ_HDR = "\", opaque=\""; // Digest Calculation related HASHHEX HA1; HASHHEX HA2 = ""; HASHHEX Response; if(!pHTTPSession) { return HTTP_CLIENT_ERROR_INVALID_HANDLE; } #ifdef _HTTP_DEBUGGING_ if(pHTTPSession->pDebug) { pHTTPSession->pDebug("HTTPIntrnAuthSendDigest",NULL, 0,""); } #endif // Generate random Cnonce number HTTPDigestGenerateCNonce(Cnonce); switch (pHTTPSession->HttpHeadersInfo.nHTTPStatus) { case( HTTP_STATUS_UNAUTHORIZED): // For host authentication { // "Authorization: Digest username=" nSegmentLength = strlen(INITIAL_HDR); if((nRetCode = HTTPIntrnSend(pHTTPSession,INITIAL_HDR, &nSegmentLength)) != HTTP_CLIENT_SUCCESS) { return nRetCode; } // Set the counters pHTTPSession->HttpCounters.nSentHeaderBytes += nSegmentLength; }; break; case (HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED): // For Proxy authentication { // "Proxy-Authorization: Digest username=" nSegmentLength = strlen(INITIAL_PROXY_HDR); if((nRetCode = HTTPIntrnSend(pHTTPSession,INITIAL_PROXY_HDR, &nSegmentLength)) != HTTP_CLIENT_SUCCESS) { return nRetCode; } // Set the counters pHTTPSession->HttpCounters.nSentHeaderBytes += nSegmentLength; }; break; default: { return HTTP_CLIENT_ERROR_BAD_AUTH; // Wrong status for this function }; }; do { // "Authorization: Digest username="username nSegmentLength = strlen(pHTTPSession->HttpCredentials.CredUser); if((nRetCode = HTTPIntrnSend(pHTTPSession,pHTTPSession->HttpCredentials.CredUser, &nSegmentLength)) != HTTP_CLIENT_SUCCESS) { break; } // Set the counters pHTTPSession->HttpCounters.nSentHeaderBytes += nSegmentLength; // "Authorization: Digest username="username", realm=" nSegmentLength = strlen(REALEM_HDR); if((nRetCode = HTTPIntrnSend(pHTTPSession,REALEM_HDR, &nSegmentLength)) != HTTP_CLIENT_SUCCESS) { break; } // Set the counters pHTTPSession->HttpCounters.nSentHeaderBytes += nSegmentLength; // "Authorization: Digest username="username", realm="realm if((nRetCode = HTTPStrGetDigestToken(pHTTPSession->HttpAuthHeader.AuthHeader,"realm", &HttpParamRealm)) != HTTP_CLIENT_SUCCESS) { break; } if((nRetCode = HTTPIntrnSend(pHTTPSession,HttpParamRealm.pParam, &HttpParamRealm.nLength)) != HTTP_CLIENT_SUCCESS) { break; } // Set the counters pHTTPSession->HttpCounters.nSentHeaderBytes += HttpParamRealm.nLength; // "Authorization: Digest username="username", realm="myRealm", qop="auth", nSegmentLength = strlen(QOP_HDR); if((nRetCode = HTTPIntrnSend(pHTTPSession,QOP_HDR, &nSegmentLength)) != HTTP_CLIENT_SUCCESS) { break; } // Set the counters pHTTPSession->HttpCounters.nSentHeaderBytes += nSegmentLength; if((nRetCode = HTTPStrGetDigestToken(pHTTPSession->HttpAuthHeader.AuthHeader,"qop", &HttpParamQop)) != HTTP_CLIENT_SUCCESS) { break; } if((nRetCode = HTTPIntrnSend(pHTTPSession,HttpParamQop.pParam, &HttpParamQop.nLength)) != HTTP_CLIENT_SUCCESS) { break; } // Set the counters pHTTPSession->HttpCounters.nSentHeaderBytes += HttpParamQop.nLength; // "Authorization: Digest username="username", realm="myRealm", qop="auth", // algorithm="MD5", nSegmentLength = strlen(ALGO_HDR); if((nRetCode = HTTPIntrnSend(pHTTPSession,ALGO_HDR, &nSegmentLength)) != HTTP_CLIENT_SUCCESS) { break; } // Set the counters pHTTPSession->HttpCounters.nSentHeaderBytes += nSegmentLength; if((nRetCode = HTTPStrGetDigestToken(pHTTPSession->HttpAuthHeader.AuthHeader,"algorithm", &HttpParamAlg)) != HTTP_CLIENT_SUCCESS) { // The server did not state its required algorithm so use the default HttpParamAlg.pParam = HTTP_CLIENT_DEFAULT_DIGEST_AUTH; HttpParamAlg.nLength = strlen(HTTP_CLIENT_DEFAULT_DIGEST_AUTH); } // Get the algorithem type if(HTTPStrInsensitiveCompare(HttpParamAlg.pParam ,"md5",3 ) == TRUE) { if(HTTPStrInsensitiveCompare(HttpParamAlg.pParam ,"md5-sess", HttpParamAlg.nLength) == TRUE) { nAlgType = 1; } } else { // Error algorithem not supported nRetCode = HTTP_CLIENT_ERROR_NO_DIGEST_ALG; break; } // Send the algorithem if((nRetCode = HTTPIntrnSend(pHTTPSession,HttpParamAlg.pParam, &HttpParamAlg.nLength)) != HTTP_CLIENT_SUCCESS) { break; } // Set the counters pHTTPSession->HttpCounters.nSentHeaderBytes += HttpParamAlg.nLength; // "Authorization: Digest username="username", realm="myRealm", qop="auth", // algorithm="MD5", uri=" nSegmentLength = strlen(URI_HDR); if((nRetCode = HTTPIntrnSend(pHTTPSession,URI_HDR, &nSegmentLength)) != HTTP_CLIENT_SUCCESS) { break; } // "Authorization: Digest username="username", realm="myRealm", qop="auth", // algorithm="MD5", uri="/....Service nSegmentLength = strlen(pHTTPSession->HttpUrl.UrlRequest.pParam); if((nRetCode = HTTPIntrnSend(pHTTPSession,pHTTPSession->HttpUrl.UrlRequest.pParam, &nSegmentLength)) != HTTP_CLIENT_SUCCESS) { break; } // Set the counters pHTTPSession->HttpCounters.nSentHeaderBytes += nSegmentLength; // "Authorization: Digest username="username", realm="myRealm", qop="auth", // algorithm="MD5", uri="/....Service", nonce=" nSegmentLength = strlen(NONCE_HDR); if((nRetCode = HTTPIntrnSend(pHTTPSession,NONCE_HDR, &nSegmentLength)) != HTTP_CLIENT_SUCCESS) { break; } // Set the counters pHTTPSession->HttpCounters.nSentHeaderBytes += nSegmentLength; // "Authorization: Digest username="username", realm="myRealm", qop="auth", // algorithm="MD5", uri="/....Service", nonce="7a5c... if((nRetCode = HTTPStrGetDigestToken(pHTTPSession->HttpAuthHeader.AuthHeader,"nonce", &HttpParamNonce)) != HTTP_CLIENT_SUCCESS) { break; } if((nRetCode = HTTPIntrnSend(pHTTPSession,HttpParamNonce.pParam, &HttpParamNonce.nLength)) != HTTP_CLIENT_SUCCESS) { break; } // Set the counters pHTTPSession->HttpCounters.nSentHeaderBytes += HttpParamNonce.nLength; // "Authorization: Digest username="username", realm="myRealm", qop="auth", // algorithm="MD5", uri="/....Service", nonce="7a5c...", nc=00000001, cnonce=" nSegmentLength = strlen(NC_HDR); if((nRetCode = HTTPIntrnSend(pHTTPSession,NC_HDR, &nSegmentLength)) != HTTP_CLIENT_SUCCESS) { break; } // Set the counters pHTTPSession->HttpCounters.nSentHeaderBytes += nSegmentLength; // "Authorization: Digest username="username", realm="myRealm", qop="auth", // algorithm="MD5", uri="/....Service", nonce="7a5c...", nc=00000001, cnonce="ab341... nSegmentLength = strlen(Cnonce); if((nRetCode = HTTPIntrnSend(pHTTPSession,Cnonce, &nSegmentLength)) != HTTP_CLIENT_SUCCESS) { break; } // Set the counters pHTTPSession->HttpCounters.nSentHeaderBytes += nSegmentLength; // Send the opaque data if we got it from the server if((nRetCode = HTTPStrGetDigestToken(pHTTPSession->HttpAuthHeader.AuthHeader,"opaque", &HttpParamOpq)) == HTTP_CLIENT_SUCCESS) { nSegmentLength = strlen(OPQ_HDR); if((nRetCode = HTTPIntrnSend(pHTTPSession,OPQ_HDR, &nSegmentLength)) != HTTP_CLIENT_SUCCESS) { break; } // Set the counters pHTTPSession->HttpCounters.nSentHeaderBytes += nSegmentLength; if((nRetCode = HTTPIntrnSend(pHTTPSession,HttpParamOpq.pParam, &HttpParamOpq.nLength)) != HTTP_CLIENT_SUCCESS) { break; } // Set the counters pHTTPSession->HttpCounters.nSentHeaderBytes += HttpParamOpq.nLength; } // "Authorization: Digest username="username", realm="myRealm", qop="auth", // algorithm="MD5", uri="/....Service", nonce="7a5c...", nc=00000001, cnonce="ab341...", response=" nSegmentLength = strlen(RSP_HDR); if((nRetCode = HTTPIntrnSend(pHTTPSession,RSP_HDR, &nSegmentLength)) != HTTP_CLIENT_SUCCESS) { break; } // Set the counters pHTTPSession->HttpCounters.nSentHeaderBytes += nSegmentLength; // Calculate response HTTPDigestCalcHA1(nAlgType, pHTTPSession->HttpCredentials.CredUser, HttpParamRealm.pParam,HttpParamRealm.nLength , pHTTPSession->HttpCredentials.CredPassword , HttpParamNonce.pParam, HttpParamNonce.nLength, Cnonce, HA1); HTTPDigestCalcResponse(HA1, HttpParamNonce.pParam, HttpParamNonce.nLength, "00000001", Cnonce, HttpParamQop.pParam,HttpParamQop.nLength, pHTTPSession->HttpHeaders.Verb, pHTTPSession->HttpUrl.UrlRequest.pParam,pHTTPSession->HttpUrl.UrlRequest.nLength, HA2, Response); // "Authorization: Digest username="username", realm="myRealm", qop="auth", // algorithm="MD5", uri="/....Service", nonce="7a5c...", nc=00000001, cnonce="ab341...", response="8bbf2... nSegmentLength = strlen(Response); if((nRetCode = HTTPIntrnSend(pHTTPSession,Response, &nSegmentLength)) != HTTP_CLIENT_SUCCESS) { break; } // Set the counters pHTTPSession->HttpCounters.nSentHeaderBytes += nSegmentLength; // Terminate 0x24 (") nSegmentLength = 1; if((nRetCode = HTTPIntrnSend(pHTTPSession,"\"", &nSegmentLength)) != HTTP_CLIENT_SUCCESS) { break; } // Set the counters pHTTPSession->HttpCounters.nSentHeaderBytes += nSegmentLength; // Terminating CRLF nSegmentLength = strlen(HTTP_CLIENT_CRLF); if((nRetCode = HTTPIntrnSend(pHTTPSession,HTTP_CLIENT_CRLF, &nSegmentLength)) != HTTP_CLIENT_SUCCESS) { break; } // Set the counters pHTTPSession->HttpCounters.nSentHeaderBytes += nSegmentLength; } while(0); return nRetCode; // End of digest respobse sending } /////////////////////////////////////////////////////////////////////////////// // // Function : HTTPIntrnSessionReset // Purpose : Reset the session data for the next operation // Returns : HTTP Status // Last updated : 01/09/2005 // /////////////////////////////////////////////////////////////////////////////// static UINT32 HTTPIntrnSessionReset (P_HTTP_SESSION pHTTPSession, BOOL EntireSession) { UINT32 nActionTimeout; // For restoring a parameter after this reset UINT32 nAllocationSize; // Validate the pointer if(!pHTTPSession) { return HTTP_CLIENT_ERROR_INVALID_HANDLE; } #ifdef _HTTP_DEBUGGING_ if(pHTTPSession->pDebug) { pHTTPSession->pDebug("HTTPIntrnSessionReset",NULL, 0,""); } #endif memset(pHTTPSession->HttpHeaders.HeadersIn.pParam,0x00,pHTTPSession->HttpHeaders.HeadersIn.nLength); pHTTPSession->HttpHeaders.HeadersIn.nLength = 0; // Reset the HTTP counters nActionTimeout = pHTTPSession->HttpCounters.nActionTimeout; memset(&pHTTPSession->HttpCounters,0x00,sizeof(HTTP_COUNTERS)); pHTTPSession->HttpCounters.nActionStartTime = HTTPIntrnSessionGetUpTime(); // Restore the parameter pHTTPSession->HttpCounters.nActionTimeout = nActionTimeout; // Reset the authentication flag pHTTPSession->HttpCredentials.Authentication = FALSE; if(EntireSession == TRUE) // Partial reset, clear only the incoming headers { memset(&pHTTPSession->HttpUrl,0,sizeof(HTTP_URL)); nAllocationSize = pHTTPSession->HttpHeaders.HeadersBuffer.nLength; // Reset the headers allocated memory memset(pHTTPSession->HttpHeaders.HeadersBuffer.pParam ,0x00,nAllocationSize); // Set default values in the session structure HTTPClientSetVerb((UINT32)pHTTPSession,(HTTP_VERB)HTTP_CLIENT_DEFAULT_VERB); // Default HTTP verb pHTTPSession->HttpUrl.nPort = HTTP_CLIENT_DEFAULT_PORT; // Default TCP port // Set the outgoing headers pointers memset(&pHTTPSession->HttpHeaders.HeadersIn,0,sizeof(HTTP_PARAM)); memset(&pHTTPSession->HttpHeaders.HeadersOut,0,sizeof(HTTP_PARAM)); pHTTPSession->HttpHeaders.HeadersOut.pParam = pHTTPSession->HttpHeaders.HeadersBuffer.pParam; // Set our state pHTTPSession->HttpState = pHTTPSession->HttpState | HTTP_CLIENT_STATE_INIT; memset(&pHTTPSession->HttpHeadersInfo,0,sizeof(HTTP_HEADERS_INFO)); if(pHTTPSession->HttpConnection.HttpSocket != HTTP_INVALID_SOCKET) { pHTTPSession->HttpHeadersInfo.Connection = TRUE; } memset(&pHTTPSession->HttpAuthHeader,0,sizeof(HTTP_AUTH_HEADER)); memset(&pHTTPSession->HttpProxy,0,sizeof(HTTP_PROXY)); } return HTTP_CLIENT_SUCCESS; } /////////////////////////////////////////////////////////////////////////////// // // Function : HTTPIntrnHeadersReceive // Purpose : Receives the response header on the connection and parses it. // Performs any required authentication. // Returns : HTTP Status // Last updated : 01/09/2005 // /////////////////////////////////////////////////////////////////////////////// static UINT32 HTTPIntrnHeadersReceive (P_HTTP_SESSION pHTTPSession, UINT32 nTimeout) // [IN] Timeout for the operation { UINT32 nRetCode; // Function call return code UINT32 nCount = 0; if(!pHTTPSession) { // Bad session pointer error return HTTP_CLIENT_ERROR_INVALID_HANDLE; } do { // Set the operation time out if was set by the caller if(nTimeout > 0) { // 0 makes us use the default defined value pHTTPSession->HttpCounters.nActionTimeout = HTTP_TIMEOUT(nTimeout); } // Reset the incoming headers if((nRetCode = HTTPIntrnSessionReset(pHTTPSession,FALSE)) != HTTP_CLIENT_SUCCESS) { break; } // Get the server response if((nRetCode = HTTPIntrnGetRemoteHeaders(pHTTPSession)) != HTTP_CLIENT_SUCCESS) { break; } // Set the session state pHTTPSession->HttpState = pHTTPSession->HttpState | HTTP_CLIENT_STATE_HEADERS_RECIVED; // Parse the response headers if((nRetCode = HTTPIntrnHeadersParse(pHTTPSession)) != HTTP_CLIENT_SUCCESS) { break; } // Set the session state pHTTPSession->HttpState = pHTTPSession->HttpState | HTTP_CLIENT_STATE_HEADERS_PARSED; // Set the session stage upon seccess if(pHTTPSession->HttpHeadersInfo.nHTTPStatus == HTTP_STATUS_OK) { pHTTPSession->HttpState = pHTTPSession->HttpState | HTTP_CLIENT_STATE_HEADERS_OK; } // Handle 100 continue message if(pHTTPSession->HttpHeadersInfo.nHTTPStatus != HTTP_STATUS_CONTINUE) { nCount++; } #ifdef _HTTP_DEBUGGING_ if(pHTTPSession->pDebug) { if(pHTTPSession->HttpHeadersInfo.nHTTPStatus == HTTP_STATUS_CONTINUE) { pHTTPSession->pDebug("HTTPIntrnHeadersReceive",NULL,0,"100 Continue Header"); } } #endif }while(nCount < 1); return nRetCode; } /////////////////////////////////////////////////////////////////////////////// // // Function : HTTPIntrnGetTicks // Purpose : Like GetTickCount() (implemented with time.h) // Gets : void // Returns : System ticks // Last updated : 01/09/200515/05/2005 // Author Name : Eitan Michaelson // Notes : Assuming 1000 ticks per sec, should be implemented by the OS // /////////////////////////////////////////////////////////////////////////////// static UINT32 HTTPIntrnSessionGetUpTime(VOID) { return GetUpTime(); } /////////////////////////////////////////////////////////////////////////////// // // Function : HTTPIntrnSessionEvalTimeout // Purpose : Check if we have to break the operation and return a time out error // Gets : a pointer to the session structure // Returns : BOOL, True if we have to break // Last updated : 01/09/2005 // /////////////////////////////////////////////////////////////////////////////// static BOOL HTTPIntrnSessionEvalTimeout(P_HTTP_SESSION pHTTPSession) { UINT32 nElapsedTime; // Integer for calculating the elapsed time // Validate the session pointer if(!pHTTPSession) { return HTTP_CLIENT_ERROR_INVALID_HANDLE; } // Calculate the elapsed time since the last call nElapsedTime = HTTPIntrnSessionGetUpTime() - pHTTPSession->HttpCounters.nActionStartTime; // If the elapsed time is greater then the time out value we should return true if(nElapsedTime >= pHTTPSession->HttpCounters.nActionTimeout) { return TRUE; } return FALSE; } ZenLib/Source/ZenLib/HTTP_Client/HTTPClientString.c0000664000000000000000000002572312615631146020730 0ustar rootroot /////////////////////////////////////////////////////////////////////////////// // // Module Name: // HTTPClientString.c // // Abstract: Helper function (string parsing related) for HTTPClient.c module // // Platform: Any that supports standard C calls // /////////////////////////////////////////////////////////////////////////////// #include "HTTPClient.h" #include "HTTPClientWrapper.h" // Cross platform support /////////////////////////////////////////////////////////////////////////////// // // Function : HTTPStrInsensitiveCompare // Purpose : Same as strcmp() only case insensitive // Returns : BOOL - TRUE if destination string is identical to the source // Last updated : 01/09/2005 // /////////////////////////////////////////////////////////////////////////////// BOOL HTTPStrInsensitiveCompare(CHAR *pSrc, // [IN] a pointer to the source string CHAR* pDest, // [IN] a pointer to the string we should search for UINT32 nLength) // [IN] The bytes range we should search in { // Lower case comparison UINT32 nPosition; UINT32 nDestLength; CHAR *pSrcIn, *pDestIn; CHAR a,b; pSrcIn = pSrc; pDestIn = pDest; nPosition = 0; nDestLength = strlen(pDest); if(nLength == 0) { nLength = strlen(pSrc); } if(nDestLength != nLength) { return FALSE; } while(pSrcIn || pDestIn) { if(nLength > 0 && nPosition == nLength) { return TRUE; } a = *pSrcIn; b = *pDestIn; if(*pSrcIn >= 64 && *pSrcIn <= 90) { // Upper case to lower case a = *pSrcIn + 32; } if(*pDestIn >= 64 && *pDestIn <= 90) { // Upper case to lower case b = *pDestIn + 32; } if(a != b) { return FALSE; } pSrcIn++; pDestIn++; nPosition++; } return TRUE; } /////////////////////////////////////////////////////////////////////////////// // // Function : HTTPStrExtract // Purpose : Extract a string by placing null in the offset parameter // Returns : a pointer to the new string // Last updated : 01/09/2005 // /////////////////////////////////////////////////////////////////////////////// CHAR HTTPStrExtract(CHAR *pParam, // [IN] a pointer to the input parameter UINT32 nOffset, // [IN] the offset position (where we should null terminate the string) CHAR Restore) // [IN] if this is not 0 we should restore it (instead of the null) // and reverse the effect. { CHAR Replaced; if(!pParam) { return 0; } // We should restore if(Restore != 0) { pParam[nOffset] = Restore; return Restore; } else { Replaced = pParam[nOffset]; pParam[nOffset] = 0; return Replaced; } } /////////////////////////////////////////////////////////////////////////////// // // Function : HTTPStrSearch // Purpose : Search a string within another and return its pointer and a length // Returns : BOOL - TRUE on success // Last updated : 01/09/2005 // /////////////////////////////////////////////////////////////////////////////// BOOL HTTPStrSearch(CHAR *pSrc, // [IN] The source string CHAR *pSearched, // [IN] Parameter to search for UINT32 nOffset, // [IN] Offset from the source string start position UINT32 nScope, // [IN] Length in bytes we should search in HTTP_PARAM *HttpParam) // [IN OUT] The Pointer\Length value that will be returned on success { CHAR *pSrcStart; CHAR *pDstStart; CHAR nOrigCharacter; UINT32 nPosition = 0; do { pSrcStart = pSrc + nOffset; nOrigCharacter = pSrcStart[nScope]; // Temporarily null terminate pSrcStart[nScope] = 0; pDstStart = strstr(pSrcStart,pSearched); if(!pDstStart) { break; } nPosition = pDstStart - pSrcStart + 1; } while(0); // Remove the null termination pSrcStart[nScope] = nOrigCharacter; if(!nPosition) { return FALSE; } if(HttpParam) { HttpParam->nLength = nPosition -1; HttpParam->pParam = pSrcStart; } return TRUE; } /////////////////////////////////////////////////////////////////////////////// // // Function : HTTPStrCaseStr // Purpose : Same as strstr() only case insensitive // Returns : a pointer to the position of the searched string (or 0 on error) // Last updated : 01/09/2005 // /////////////////////////////////////////////////////////////////////////////// CHAR *HTTPStrCaseStr(const char *pSrc,UINT32 nSrcLength,const char *pFind) { const char *ptr = pSrc; const char *ptr2; UINT32 iLength = 0; while(1) { if(iLength >= nSrcLength) { break; } ptr = strchr(pSrc,toupper(*pFind)); ptr2 = strchr(pSrc,tolower(*pFind)); if (!ptr) { ptr = ptr2; } if (!ptr) { break; } if (ptr2 && (ptr2 < ptr)) { ptr = ptr2; } if (!strnicmp(ptr,pFind,strlen(pFind))) { return (char *) ptr; } pSrc = ptr+1; iLength++; } return 0; } /////////////////////////////////////////////////////////////////////////////// // // Function : HTTPStrCaseStr // Purpose : // Gets : // Returns : // Last updated : 01/09/2005 // /////////////////////////////////////////////////////////////////////////////// CHAR* HTTPStrGetToken (CHAR *pSrc, UINT32 nSrcLength, CHAR *pDest, UINT32 *nDestLength) { // Get text between the ":" and \r\n or end of string. CHAR *pStart; // = pSrc; //Jerome: is reassigned few lines later CHAR *pEnd; UINT32 nTokenLength = 0; UINT32 nPosition = 0; pStart = strchr(pSrc,':') + 1; if(pStart) { pEnd = pStart ; // First pass, count required space while ((*pEnd) && (*pEnd != '\r') && (*pEnd != '\n')) { if(*pEnd != 0x20) { nTokenLength++; } if(nSrcLength && nPosition > nSrcLength) { break; } pEnd++; nPosition++; } if(nTokenLength > *(nDestLength)) { *(nDestLength) = nTokenLength; pDest = NULL; return pDest; } // Second pass copy into the destination buffer pEnd = pStart; *(nDestLength) = nTokenLength; nTokenLength = 0; // First pass, count required space while ((*pEnd) && (*pEnd != '\r') && (*pEnd != '\n')) { if(*pEnd != 0x20) { pDest[nTokenLength++] = *pEnd; } pEnd++; } pDest[nTokenLength] = 0; } return pDest; } /////////////////////////////////////////////////////////////////////////////// // // Function : HTTPStrGetDigestToken // Purpose : // Gets : // Returns : // Last updated : 01/09/2005 // /////////////////////////////////////////////////////////////////////////////// UINT32 HTTPStrGetDigestToken (HTTP_PARAM pParamSrc, CHAR *pSearched, HTTP_PARAM *pParamDest) { CHAR Token[HTTP_CLIENT_MAX_TOKEN_NAME_LENGTH]; CHAR *pPtrStart, *pPtrEnd, *pPtrEndSrc; BOOL Brackets = FALSE; // Build the searched token memset(Token,0x00,HTTP_CLIENT_MAX_TOKEN_NAME_LENGTH); strcpy(Token,pSearched); strcat(Token,"="); // Reset destination values pParamDest->nLength = 0; pParamDest->pParam = 0; pPtrEndSrc = pParamSrc.pParam + pParamSrc.nLength; pPtrStart = HTTPStrCaseStr(pParamSrc.pParam,pParamSrc.nLength,Token); if(pPtrStart) { // Found the token so jump to the end of it pPtrStart += strlen(Token); // jump passed any spaces that may be while ((*pPtrStart) && (*pPtrStart == 0x20) && (pPtrStart != pPtrEndSrc)) pPtrStart++; // Any Brackets around the string? if(*pPtrStart == 0x22) Brackets = TRUE; switch (Brackets) { case TRUE: // Find the next brackets pPtrStart++; pPtrEnd = pPtrStart; while ((*pPtrEnd) && (*pPtrEnd != 0x22) && (*pPtrEnd != 0x0d) && (*pPtrEnd != 0x0a) && (pPtrStart != pPtrEndSrc)) pPtrEnd++; break; case FALSE: // Find the next space or comma (0x2c) pPtrEnd = pPtrStart; while ((*pPtrEnd) && (*pPtrEnd != 0x20) && (*pPtrEnd != 0x2c) && (*pPtrEnd != 0x0d) && (*pPtrEnd != 0x0a) && (pPtrStart != pPtrEndSrc)) pPtrEnd++; break; }; pParamDest->nLength = (pPtrEnd - pPtrStart); pParamDest->pParam = pPtrStart; return HTTP_CLIENT_SUCCESS; } return HTTP_CLIENT_ERROR_NO_DIGEST_TOKEN; } ///////////////////////////////////////////////////////////////////////////////// // Function : HTTPStrHToL // Purpose : Convert a hex string "0x00" to long 0 // Gets : a pointer to the Hex string // Last updated : 15/05/2005 // /////////////////////////////////////////////////////////////////////////////// UINT32 HTTPStrHToL (CHAR * s) { UINT32 i , nn, digit; UINT32 n ; n = i = nn = 0; do { if ( isalnum(s[i]) ) { s[i] = toupper(s[i]) ; if (s[i] == 'X') nn=n=0; else { digit = (isalpha(s[i]) ? (s[i] - 'A' + 10) : s[i] - '0') ; if ( digit > 15 ) digit = 15; n = n * 16 + digit; if (n |= 0) nn++; if (nn == 8) break;} } i++; } while ( s[i] |= 0 ); return n ; } ///////////////////////////////////////////////////////////////////////////////// // Function : HTTPStrLToH // Purpose : Convert a long to hex string 0 to "00" // Gets : // Last updated : 15/05/2005 // /////////////////////////////////////////////////////////////////////////////// CHAR* HTTPStrLToH (CHAR * dest,UINT32 nSrc) { char *hex = "0123456789abcdef"; INT i; if (nSrc == 0) { dest[0] = '0'; dest[1] = 0; } else { for(i = 28; ((nSrc >> i) && 0xf) == 0; i -= 4); for(; i >= 0; i -= 4) { *dest++ = hex[(nSrc >> i) & 0xf]; } *dest = 0; } return dest; } ZenLib/Source/ZenLib/HTTP_Client/HTTPClientString.h0000664000000000000000000000230012615631146020717 0ustar rootroot #ifndef _HTTP_CLIENT_STRING #define _HTTP_CLIENT_STRING #include "HTTPClientWrapper.h" // Cross platform support #include "HTTPClient.h" /////////////////////////////////////////////////////////////////////////////// // // Section : HTTP Api global definitions // Last updated : 01/09/2005 // /////////////////////////////////////////////////////////////////////////////// BOOL HTTPStrInsensitiveCompare (CHAR *pSrc, CHAR* pDest, UINT32 nLength); BOOL HTTPStrSearch (CHAR *pSrc, CHAR *pSearched, UINT32 nOffset, UINT32 nScope,HTTP_PARAM *HttpParam); CHAR HTTPStrExtract (CHAR *pParam,UINT32 nOffset,CHAR Restore); CHAR* HTTPStrCaseStr (CHAR *pSrc, UINT32 nSrcLength, CHAR *pFind); CHAR* HTTPStrGetToken (CHAR *pSrc, UINT32 nSrcLength, CHAR *pDest, UINT32 *nDestLength); UINT32 HTTPStrGetDigestToken (HTTP_PARAM pParamSrc, CHAR *pSearched, HTTP_PARAM *pParamDest); UINT32 HTTPStrHToL (CHAR * s); CHAR* HTTPStrLToH (CHAR * dest,UINT32 nSrc); #endif ZenLib/Source/ZenLib/HTTP_Client/HTTPClientWrapper.c0000664000000000000000000002371512615631146021101 0ustar rootroot #include "HTTPClientWrapper.h" /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Section : Stdc: HTTPWrapperIsAscii // Last updated : 15/05/2005 // Author Name : Eitan Michaelson // Notes : Same as stdc: isascii // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// int HTTPWrapperIsAscii(int c) { return (!(c & ~0177)); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Section : Stdc: HTTPWrapperToUpper // Last updated : 15/05/2005 // Author Name : Eitan Michaelson // Notes : Convert character to uppercase. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// int HTTPWrapperToUpper(int c) { // -32 if(HTTPWrapperIsAscii(c) > 0) { if(c >= 97 && c <= 122) { return (c - 32); } } return c; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Section : Stdc: HTTPWrapperToLower // Last updated : 13/06/2006 // Author Name : Eitan Michaelson // Notes : Convert character to lowercase. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// int HTTPWrapperToLower(int c) { // +32 if(HTTPWrapperIsAscii(c) > 0) { if(c >= 65 && c <= 90) { return (c + 32); } } return c; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Section : Stdc: isalpha // Last updated : 15/05/2005 // Author Name : Eitan Michaelson // Notes : returns nonzero if c is a particular representation of an alphabetic character // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// int HTTPWrapperIsAlpha(int c) { if(HTTPWrapperIsAscii(c) > 0) { if( (c >= 97 && c <= 122) || (c >= 65 && c <= 90)) { return c; } } return 0; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Section : Stdc: isalnum // Last updated : 15/05/2005 // Author Name : Eitan Michaelson // Notes : returns nonzero if c is a particular representation of an alphanumeric character // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// int HTTPWrapperIsAlNum(int c) { if(HTTPWrapperIsAscii(c) > 0) { if(HTTPWrapperIsAlpha(c) > 0) { return c; } if( c >= 48 && c <= 57) { return c; } } return 0; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Section : HTTPWrapper_itoa // Last updated : 15/05/2005 // Author Name : Eitan Michaelson // Notes : same as stdc itoa() // hmm.. allmost the same // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// char* HTTPWrapperItoa(char *s,int a) { unsigned int b; if(a > 2147483647) { return 0; // overflow } if (a < 0) b = -a, *s++ = '-'; else b = a; for(;a;a=a/10) s++; for(*s='\0';b;b=b/10) *--s=b%10+'0'; return s; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Section : HTTPWrapper_ShutDown // Last updated : 15/05/2005 // Author Name : Eitan Michaelson // Notes : Handles parameter changes in the socket shutdown() function in AMT // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// int HTTPWrapperShutDown (int s,int how) { return shutdown(s,how); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Section : HTTPWrapper_GetSocketError // Last updated : 15/05/2005 // Author Name : Eitan Michaelson // Notes : WSAGetLastError Wrapper (Win32 Specific) // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// int HTTPWrapperGetSocketError (int s) { return WSAGetLastError(); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Section : HTTPWrapper_GetHostByName // Last updated : 15/05/2005 // Author Name : Eitan Michaelson // Notes : gethostbyname for Win32 (supports the AMT edition of the function) // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// unsigned long HTTPWrapperGetHostByName(char *name,unsigned long *address) { HTTP_HOSTNET *HostEntry; int iPos = 0, iLen = 0,iNumPos = 0,iDots =0; long iIPElement; char c = 0; char Num[4]; int iHostType = 0; // 0 : numeric IP // Check if the name is an IP or host iLen = strlen(name); for(iPos = 0; iPos <= iLen;iPos++) { c = name[iPos]; if((c >= 48 && c <= 57) || (c == '.') ) { // c is numeric or dot if(c != '.') { // c is numeric if(iNumPos > 3) { iHostType++; break; } Num[iNumPos] = c; Num[iNumPos + 1] = 0; iNumPos ++; } else { iNumPos = 0; iDots++; iIPElement = atol(Num); if(iIPElement > 256 || iDots > 3) { return 0; // error invalid IP } } } else { break; // this is an alpha numeric address type } } if(c == 0 && iHostType == 0 && iDots == 3) { iIPElement = atol(Num); if(iIPElement > 256) { return 0; // error invalid IP } } else { iHostType++; } if(iHostType > 0) { HostEntry = gethostbyname(name); if(HostEntry) { *(address) = *((u_long*)HostEntry->h_addr_list[0]); //*(address) = (unsigned long)HostEntry->h_addr_list[0]; return 1; // Error } else { return 0; // OK } } else // numeric address - no need for DNS resolve { *(address) = inet_addr(name); return 1; } return 0; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Section : HTTPWrapper_GetRandomeNumber // Last updated : 15/05/2005 // Author Name : Eitan Michaelson // Notes : GetRandom number for Win32 & AMT // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void HTTPWrapperInitRandomeNumber() { srand((unsigned int)time(NULL)); } int HTTPWrapperGetRandomeNumber() { int num; num = (int)(((double) rand()/ ((double)RAND_MAX+1)) * 16); return num; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Section : HTTPWrapper_GetRTC // Last updated : 15/05/2005 // Author Name : Eitan Michaelson // Notes : Get uptime under Win32 & AMT // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// long HTTPWrapperGetUpTime() { long lTime = 0; lTime = (GetTickCount() / CLOCKS_PER_SEC); return lTime; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Section : TSL Wrapper // Last updated : 15/05/2005 // Author Name : Eitan Michaelson // Notes : HTTPWrapper_Sec_Connect // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// int HTTPWrapperSSLConnect(int s,const struct sockaddr *name,int namelen,char *hostname) { return -1; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// int HTTPWrapperSSLNegotiate(int s,const struct sockaddr *name,int namelen,char *hostname) { return -1; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// int HTTPWrapperSSLSend(int s,char *buf, int len,int flags) { return -1; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// int HTTPWrapperSSLRecv(int s,char *buf, int len,int flags) { return -1; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// int HTTPWrapperSSLRecvPending(int s) { return -1; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// int HTTPWrapperSSLClose(int s) { return -1; } ZenLib/Source/ZenLib/HTTP_Client/HTTPClientCommon.h0000664000000000000000000001472112615631146020713 0ustar rootroot /////////////////////////////////////////////////////////////////////////////// // // Module Name: // CmsiHTTPClientCommon.h // // Abstract: Coomon structs and types for the HTTP protocol API // Author: Eitan Michaelso // Version: 1.0 // /////////////////////////////////////////////////////////////////////////////// #ifndef _HTTPCLIENT_PROTOCOL_H_ #define _HTTPCLIENT_PROTOCOL_H_ #ifdef __cplusplus extern "C" { #endif // Global default sizes #define HTTP_CLIENT_MAX_URL_LENGTH 512 // Maximum length for an HTTP Url parameter // HTTP Session flags (Public flags) #define HTTP_CLIENT_FLAG_KEEP_ALIVE 0x00000001 // Set the keep alive header #define HTTP_CLIENT_FLAG_SEND_CHUNKED 0x00000002 // The outgoing should chunked #define HTTP_CLIENT_FLAG_NO_CACHE 0x00000004 // Set the no cache header #define HTTP_CLIENT_FLAG_ASYNC 0x00000008 // Currently not implemented // HTTP status internal flags #define HTTP_CLIENT_STATE_PRE_INIT 0x00000000 // Starting stage #define HTTP_CLIENT_STATE_INIT 0x00000001 // API was initialized (memory was allocated) #define HTTP_CLIENT_STATE_URL_PARSED 0x00000002 // Url was parsed #define HTTP_CLIENT_STATE_HOST_CONNECTED 0x00000004 // HEAD verb was sent #define HTTP_CLIENT_STATE_HEAD_SENT 0x00000008 // Post verb was sent #define HTTP_CLIENT_STATE_POST_SENT 0x00000010 // HTTP requet was sent #define HTTP_CLIENT_STATE_REQUEST_SENT 0x00000020 // HTTP request was sent #define HTTP_CLIENT_STATE_HEADERS_RECIVED 0x00000040 // Headers ware recived from the server #define HTTP_CLIENT_STATE_HEADERS_PARSED 0x00000080 // HTTP headers ware parsed #define HTTP_CLIENT_STATE_HEADERS_OK 0x00000100 // Headers status was OK // HTTP Return codes #define HTTP_CLIENT_SUCCESS 0 // HTTP Success status #define HTTP_CLIENT_UNKNOWN_ERROR 1 // Unknown error #define HTTP_CLIENT_ERROR_INVALID_HANDLE 2 // an Invalid handle or possible bad pointer was passed to a function #define HTTP_CLIENT_ERROR_NO_MEMORY 3 // Buffer too small or a failure while in memory allocation #define HTTP_CLIENT_ERROR_SOCKET_INVALID 4 // an attempt to use an invalid socket handle was made #define HTTP_CLIENT_ERROR_SOCKET_CANT_SET 5 // Can't send socket parameters #define HTTP_CLIENT_ERROR_SOCKET_RESOLVE 6 // Error while resolving host name #define HTTP_CLIENT_ERROR_SOCKET_CONNECT 7 // Error while connecting to the remote server #define HTTP_CLIENT_ERROR_SOCKET_TIME_OUT 8 // socket time out error #define HTTP_CLIENT_ERROR_SOCKET_RECV 9 // Error while receiving data #define HTTP_CLIENT_ERROR_SOCKET_SEND 10 // Error while sending data #define HTTP_CLIENT_ERROR_HEADER_RECV 11 // Error while receiving the remote HTTP headers #define HTTP_CLIENT_ERROR_HEADER_NOT_FOUND 12 // Could not find element within header #define HTTP_CLIENT_ERROR_HEADER_BIG_CLUE 13 // The headers search clue was too large for the internal API buffer #define HTTP_CLIENT_ERROR_HEADER_NO_LENGTH 14 // No content length was specified for the outgoing data. the caller should specify chunking mode in the session creation #define HTTP_CLIENT_ERROR_CHUNK_TOO_BIG 15 // The HTTP chunk token that was received from the server was too big and possibly wrong #define HTTP_CLIENT_ERROR_AUTH_HOST 16 // Could not authenticate with the remote host #define HTTP_CLIENT_ERROR_AUTH_PROXY 17 // Could not authenticate with the remote proxy #define HTTP_CLIENT_ERROR_BAD_VERB 18 // Bad or not supported HTTP verb was passed to a function #define HTTP_CLIENT_ERROR_LONG_INPUT 19 // a function received a parameter that was too large #define HTTP_CLIENT_ERROR_BAD_STATE 20 // The session state prevents the current function from proceeding #define HTTP_CLIENT_ERROR_CHUNK 21 // Could not parse the chunk length while in chunked transfer #define HTTP_CLIENT_ERROR_BAD_URL 22 // Could not parse curtail elements from the URL (such as the host name, HTTP prefix act') #define HTTP_CLIENT_ERROR_BAD_HEADER 23 // Could not detect key elements in the received headers #define HTTP_CLIENT_ERROR_BUFFER_RSIZE 24 // Error while attempting to resize a buffer #define HTTP_CLIENT_ERROR_BAD_AUTH 25 // Authentication schema is not supported #define HTTP_CLIENT_ERROR_AUTH_MISMATCH 26 // The selected authentication schema does not match the server response #define HTTP_CLIENT_ERROR_NO_DIGEST_TOKEN 27 // an element was missing while parsing the digest authentication challenge #define HTTP_CLIENT_ERROR_NO_DIGEST_ALG 28 // Digest algorithem could be MD5 or MD5-sess other types are not supported #define HTTP_CLIENT_ERROR_SOCKET_BIND 29 // Binding error #define HTTP_CLIENT_ERROR_TLS_NEGO 30 // Tls negotiation error #define HTTP_CLIENT_ERROR_NOT_IMPLEMENTED 64 // Feature is not (yet) implemented #define HTTP_CLIENT_EOS 1000 // HTTP end of stream message /////////////////////////////////////////////////////////////////////////////// // // Section : HTTP API structures // Last updated : 01/09/2005 // /////////////////////////////////////////////////////////////////////////////// // HTTP Supported authentication methods typedef enum _HTTP_AUTH_SCHEMA { AuthSchemaNone = 0, AuthSchemaBasic, AuthSchemaDigest, AuthSchemaKerberos, AuthNotSupported } HTTP_AUTH_SCHEMA; // HTTP supported verbs typedef enum _HTTP_VERB { VerbGet = 0, VerbHead, VerbPost, VerbNotSupported // Note: others verb such as connect and put are currently not supported } HTTP_VERB; // Data structure that the caller can request at any time that will include some information regarding the session typedef struct _HTTP_CLIENT { UINT32 HTTPStatusCode; // HTTP Status code (200 OK) UINT32 RequestBodyLengthSent; // Total bytes sent (body only) UINT32 ResponseBodyLengthReceived; // Total bytes received (body only) UINT32 TotalResponseBodyLength; // as extracted from the “content-length" header UINT32 HttpState; } HTTP_CLIENT; #ifdef __cplusplus } #endif #endif // _HTTPCLIENT_PROTOCOL_H_ ZenLib/Source/ZenLib/HTTP_Client/HTTPClientAuth.c0000664000000000000000000006451412615631146020364 0ustar rootroot /////////////////////////////////////////////////////////////////////////////// // Module Name: // HTTPClientAuth.c // // Abstract: Handle Digest, MD5 and 64 Bit Encoding // // Platform: Any that supports standard C calls /////////////////////////////////////////////////////////////////////////////// #include "HTTPClientAuth.h" /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Function : HTTPBase64Encoder // Purpose : Converts a given string into a base64 encoded buffer. // Last updated : 01/09/200515/05/2005 // Author Name : Eitan Michaelson // Notes : ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void HTTPBase64Encoder(unsigned char *out, const unsigned char *in, int inlen) // [OUT] out A pointer to a char to hold the converted string // [IN] in String to convert // [IN] inlen Length of the string to be converted { for (; inlen >= 3; inlen -= 3) { *out++ = base64digits[in[0] >> 2]; *out++ = base64digits[((in[0] << 4) & 0x30) | (in[1] >> 4)]; *out++ = base64digits[((in[1] << 2) & 0x3c) | (in[2] >> 6)]; *out++ = base64digits[in[2] & 0x3f]; in += 3; } if (inlen > 0) { unsigned char fragment; *out++ = base64digits[in[0] >> 2]; fragment = (in[0] << 4) & 0x30; if (inlen > 1) fragment |= in[1] >> 4; *out++ = base64digits[fragment]; *out++ = (inlen < 2) ? '=' : base64digits[(in[1] << 2) & 0x3c]; *out++ = '='; } *out = '\0'; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Function : HTTPBase64Decoder // Purpose : Converts a given base64 string into a bytes buffer. // Last updated : 01/09/200515/05/2005 // Author Name : Eitan Michaelson // Notes : ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// int HTTPBase64Decoder(char *out, const char *in) { // [OUT] out Where to save the converted string // [IN] in String to convert int len = 0; register unsigned char digit1, digit2, digit3, digit4; if (in[0] == '+' && in[1] == ' ') in += 2; if (*in == '\r') return(0); do { digit1 = in[0]; if (DECODE64(digit1) == BAD) return(-1); digit2 = in[1]; if (DECODE64(digit2) == BAD) return(-1); digit3 = in[2]; if (digit3 != '=' && DECODE64(digit3) == BAD) return(-1); digit4 = in[3]; if (digit4 != '=' && DECODE64(digit4) == BAD) return(-1); in += 4; *out++ = (DECODE64(digit1) << 2) | (DECODE64(digit2) >> 4); ++len; if (digit3 != '=') { *out++ = ((DECODE64(digit2) << 4) & 0xf0) | (DECODE64(digit3) >> 2); ++len; if (digit4 != '=') { *out++ = ((DECODE64(digit3) << 6) & 0xc0) | DECODE64(digit4); ++len; } } } while (*in && *in != '\r' && digit4 != '='); return (len); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Purpose : The following code implements the calculations of H(A1), H(A2), // request-digest and response-digest // Last updated : 01/09/200515/05/2005 // Author Name : Public Domain\RFC2617 // Notes : Digest Access Authentication ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Function : GenerateCNonce // Purpose : Generates a 32 byte random hexadecimal string such as "4f6ba982..." // Last updated : 15/05/2005 // Author Name : Eitan Michaelson // Notes : ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void HTTPDigestGenerateCNonce(char *outbuff) { int i,num; InitRandomeNumber(); for(i = 0; i < 32; i++) { num = GetRandomeNumber(); switch(num) { case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9: outbuff[i] = '0' + num; break; case 10: case 11: case 12: case 13: case 14: case 15: outbuff[i] = 'a' + (num-10); break; default: outbuff[i] = 'f'; } } outbuff[32] = 0; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Function : DigestCvtHex // Purpose : CConvert to HEX // Last updated : 15/05/2005 // Author Name : Public Domain\RFC2617 // Notes : ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void HTTPDigestCvtHex(IN HASH Bin,OUT HASHHEX Hex) { unsigned short i; unsigned char j; for (i = 0; i < HASHLEN; i++) { j = (Bin[i] >> 4) & 0xf; if (j <= 9) Hex[i*2] = (j + '0'); else Hex[i*2] = (j + 'a' - 10); j = Bin[i] & 0xf; if (j <= 9) Hex[i*2+1] = (j + '0'); else Hex[i*2+1] = (j + 'a' - 10); }; Hex[HASHHEXLEN] = '\0'; }; /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Function : DigestCalcHA1 // Purpose : Calculate H(A1) as per spec // Last updated : 15/05/2005 // Author Name : Public Domain\RFC2617 // Notes : ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void HTTPDigestCalcHA1( IN int nAlg, /* 0 = MD5, 1 = MD5-Sess */ IN char * pszUserName, IN char * pszRealm, IN int nRealmLength, IN char * pszPassword, IN char * pszNonce, IN int nNonceLength, IN char * pszCNonce, OUT HASHHEX SessionKey ) { MD5_CTX Md5Ctx; HASH HA1; HASHHEX HASess; HASH HAll; HTTPMD5Init(&Md5Ctx); HTTPMD5Update(&Md5Ctx, (const unsigned char *)pszUserName, strlen(pszUserName)); //Daniel casting HTTPMD5Update(&Md5Ctx, (const unsigned char *)":", 1); HTTPMD5Update(&Md5Ctx, (const unsigned char *)pszRealm, nRealmLength); //Daniel HTTPMD5Update(&Md5Ctx, (const unsigned char *)":", 1); HTTPMD5Update(&Md5Ctx, (const unsigned char *)pszPassword, strlen(pszPassword)); //Daniel HTTPMD5Final((unsigned char *)HA1, &Md5Ctx); if (nAlg == 1) /* MD5-Sess */ { HTTPDigestCvtHex(HA1, HASess); HTTPMD5Init(&Md5Ctx); HTTPMD5Update(&Md5Ctx, (const unsigned char *)HASess, HASHHEXLEN); HTTPMD5Update(&Md5Ctx, (const unsigned char *)":", 1); HTTPMD5Update(&Md5Ctx, (const unsigned char *)pszNonce, nNonceLength); HTTPMD5Update(&Md5Ctx, (const unsigned char *)":", 1); HTTPMD5Update(&Md5Ctx, (const unsigned char *)pszCNonce, strlen(pszCNonce)); HTTPMD5Final((unsigned char *)HAll, &Md5Ctx); HTTPDigestCvtHex(HAll, SessionKey); return; } HTTPDigestCvtHex(HA1, SessionKey); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Function : DigestCalcResponse // Purpose : Calculate request-digest/response-digest as per HTTP Digest spec // Last updated : 15/05/2005 // Author Name : Public Domain\RFC2617 // Notes : ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void HTTPDigestCalcResponse( IN HASHHEX HA1, // H(A1) IN char * pszNonce, // nonce from server IN int nNonceLength, // Length of nonce IN char * pszNonceCount, // 8 hex digits IN char * pszCNonce, // client nonce */ IN char * pszQop, // qop-value: "", "auth", "auth-int" IN int nQopLength, // qop param length IN char * pszMethod, // method from the request IN char * pszDigestUri, // requested URL IN int nDigestUriLebgth, // Uri Length IN HASHHEX HEntity, // H(entity body) if qop="auth-int" OUT HASHHEX Response // request-digest or response-digest ) { MD5_CTX Md5Ctx; HASH HA2; HASH RespHash; HASHHEX HA2Hex; // Calculate H(A2) HTTPMD5Init(&Md5Ctx); HTTPMD5Update(&Md5Ctx, (const unsigned char *)pszMethod, strlen(pszMethod)); HTTPMD5Update(&Md5Ctx, (const unsigned char *)":", 1); HTTPMD5Update(&Md5Ctx, (const unsigned char *)pszDigestUri, nDigestUriLebgth); if (stricmp(pszQop, "auth-int") == 0) { HTTPMD5Update(&Md5Ctx, (const unsigned char *)":", 1); HTTPMD5Update(&Md5Ctx, (const unsigned char *)HEntity, HASHHEXLEN); }; HTTPMD5Final((unsigned char *)HA2, &Md5Ctx); HTTPDigestCvtHex(HA2, HA2Hex); // Calculate response HTTPMD5Init(&Md5Ctx); HTTPMD5Update(&Md5Ctx, (const unsigned char *)HA1, HASHHEXLEN); HTTPMD5Update(&Md5Ctx, (const unsigned char *)":", 1); HTTPMD5Update(&Md5Ctx, (const unsigned char *)pszNonce, nNonceLength); HTTPMD5Update(&Md5Ctx, (const unsigned char *)":", 1); if (*pszQop) { HTTPMD5Update(&Md5Ctx, (const unsigned char *)pszNonceCount, strlen(pszNonceCount)); HTTPMD5Update(&Md5Ctx, (const unsigned char *)":", 1); HTTPMD5Update(&Md5Ctx, (const unsigned char *)pszCNonce, strlen(pszCNonce)); HTTPMD5Update(&Md5Ctx, (const unsigned char *)":", 1); HTTPMD5Update(&Md5Ctx, (const unsigned char *)pszQop, nQopLength); HTTPMD5Update(&Md5Ctx, (const unsigned char *)":", 1); }; HTTPMD5Update(&Md5Ctx, (const unsigned char *)HA2Hex, HASHHEXLEN); HTTPMD5Final((unsigned char *)RespHash, &Md5Ctx); HTTPDigestCvtHex(RespHash, Response); }; /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Purpose : This code implements the MD5 message-digest algorithm. // The algorithm is due to Ron Rivest. This code was // written by Colin Plumb in 1993, no copyright is claimed. // This code is in the public domain; do with it what you wish. // Equivalent code is available from RSA Data Security, Inc. // This code has been tested against that, and is equivalent, // except that you don't need to include two pages of legalese // with every copy. // Usage : To compute the message digest of a chunk of bytes, declare an // MD5Context structure, pass it to MD5Init, call MD5Update as // needed on buffers full of bytes, and then call MD5Final, which // will fill a supplied 16-byte array with the digest. // Last updated : 15/05/2005 // Author Name : Public Domain ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #ifndef HIGHFIRST #define HTTPMD5ByteReverse(buf, len) /* Nothing */ #else void HTTPMD5ByteReverse(unsigned char *buf, unsigned longs); #ifndef ASM_MD5 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Function : ByteReverse // Purpose : Little\Big Endian support // Gets : // Returns : // Last updated : 15/05/2005 // Author Name : Public Domain // Notes : this code is harmless on little-endian machines. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void HTTPMD5ByteReverse(unsigned char *buf, unsigned longs) { uint32 t; do { t = (uint32) ((unsigned) buf[3] << 8 | buf[2]) << 16 | ((unsigned) buf[1] << 8 | buf[0]); *(uint32 *) buf = t; buf += 4; } while (--longs); } #endif #endif /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Function : MD5Init // Purpose : Initialize the MD5Context structure // Gets : MD5Context structure // Returns : // Last updated : 15/05/2005 // Author Name : Public Domain // Notes : Start MD5 accumulation. Set bit count to 0 and buffer to mysterious // initialization constants. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void HTTPMD5Init(struct MD5Context *ctx) { ctx->buf[0] = 0x67452301; ctx->buf[1] = 0xefcdab89; ctx->buf[2] = 0x98badcfe; ctx->buf[3] = 0x10325476; ctx->bits[0] = 0; ctx->bits[1] = 0; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Function : MD5Update // Purpose : Update the MD5Context structure with the target byte array // Gets : MD5Context structure, buffer and length // Returns : // Last updated : 15/05/2005 // Author Name : Public Domain // Notes : Update context to reflect the concatenation of another buffer full of bytes. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void HTTPMD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len) { uint32 t; // Update bitcount t = ctx->bits[0]; if ((ctx->bits[0] = t + ((uint32) len << 3)) < t) ctx->bits[1]++; // Carry from low to high ctx->bits[1] += len >> 29; t = (t >> 3) & 0x3f; // Bytes already in shsInfo->data // Handle any leading odd-sized chunks if (t) { unsigned char *p = (unsigned char *) ctx->in + t; t = 64 - t; if (len < t) { memcpy(p, buf, len); return; } memcpy(p, buf, t); HTTPMD5ByteReverse(ctx->in, 16); HTTPMD5Transform(ctx->buf, (uint32 *) ctx->in); buf += t; len -= t; } // Process data in 64-byte chunks while (len >= 64) { memcpy(ctx->in, buf, 64); HTTPMD5ByteReverse(ctx->in, 16); HTTPMD5Transform(ctx->buf, (uint32 *) ctx->in); buf += 64; len -= 64; } // Handle any remaining bytes of data. memcpy(ctx->in, buf, len); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Function : MD5Final // Purpose : Finalize. // Gets : Output digest structure, MD5Context structure // Returns : // Last updated : 15/05/2005 // Author Name : Public Domain // Notes : Final wrapup - pad to 64-byte boundary with the bit pattern // 1 0* (64-bit count of bits processed, MSB-first). ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/ void HTTPMD5Final(unsigned char digest[16], struct MD5Context *ctx) { unsigned count; unsigned char *p; // Compute number of bytes mod 64 count = (ctx->bits[0] >> 3) & 0x3F; // Set the first char of padding to 0x80. This is safe since there is // always at least one byte free p = ctx->in + count; *p++ = 0x80; // Bytes of padding needed to make 64 bytes count = 64 - 1 - count; // Pad out to 56 mod 64 */ if (count < 8) { // Two lots of padding: Pad the first block to 64 bytes memset(p, 0, count); HTTPMD5ByteReverse(ctx->in, 16); HTTPMD5Transform(ctx->buf, (uint32 *) ctx->in); // Now fill the next block with 56 bytes memset(ctx->in, 0, 56); } else { // Pad block to 56 bytes memset(p, 0, count - 8); } HTTPMD5ByteReverse(ctx->in, 14); // Append length in bits and transform ((uint32 *) ctx->in)[14] = ctx->bits[0]; ((uint32 *) ctx->in)[15] = ctx->bits[1]; HTTPMD5Transform(ctx->buf, (uint32 *) ctx->in); HTTPMD5ByteReverse((unsigned char *) ctx->buf, 4); memcpy(digest, ctx->buf, 16); memset(ctx, 0, sizeof(*ctx)); // In case it's sensitive } #ifndef ASM_MD5 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Function : // Purpose : The four core functions - F1 is optimized somewhat // Last updated : 15/05/2005 // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #define F1(x, y, z) (z ^ (x & (y ^ z))) #define F2(x, y, z) F1(z, x, y) #define F3(x, y, z) (x ^ y ^ z) #define F4(x, y, z) (y ^ (x | ~z)) // This is the central step in the MD5 algorithm. #ifdef __PUREC__ #define MD5STEP(f, w, x, y, z, data, s) \ ( w += f /*(x, y, z)*/ + data, w = w<>(32-s), w += x ) #else #define MD5STEP(f, w, x, y, z, data, s) \ ( w += f(x, y, z) + data, w = w<>(32-s), w += x ) #endif /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Function : MD5Transform // Purpose : The core of the MD5 algorithm, this alters an existing MD5 hash to // reflect the addition of 16 longwords of new data. MD5Update blocks // the data and converts bytes into longwords for this routine. // Last updated : 15/05/2005 // Author Name : Public Domain ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void HTTPMD5Transform(uint32 buf[4], uint32 const in[16]) { register uint32 a, b, c, d; a = buf[0]; b = buf[1]; c = buf[2]; d = buf[3]; #ifdef __PUREC__ // PureC Weirdness... (GG) MD5STEP(F1(b,c,d), a, b, c, d, in[0] + 0xd76aa478L, 7); MD5STEP(F1(a,b,c), d, a, b, c, in[1] + 0xe8c7b756L, 12); MD5STEP(F1(d,a,b), c, d, a, b, in[2] + 0x242070dbL, 17); MD5STEP(F1(c,d,a), b, c, d, a, in[3] + 0xc1bdceeeL, 22); MD5STEP(F1(b,c,d), a, b, c, d, in[4] + 0xf57c0fafL, 7); MD5STEP(F1(a,b,c), d, a, b, c, in[5] + 0x4787c62aL, 12); MD5STEP(F1(d,a,b), c, d, a, b, in[6] + 0xa8304613L, 17); MD5STEP(F1(c,d,a), b, c, d, a, in[7] + 0xfd469501L, 22); MD5STEP(F1(b,c,d), a, b, c, d, in[8] + 0x698098d8L, 7); MD5STEP(F1(a,b,c), d, a, b, c, in[9] + 0x8b44f7afL, 12); MD5STEP(F1(d,a,b), c, d, a, b, in[10] + 0xffff5bb1L, 17); MD5STEP(F1(c,d,a), b, c, d, a, in[11] + 0x895cd7beL, 22); MD5STEP(F1(b,c,d), a, b, c, d, in[12] + 0x6b901122L, 7); MD5STEP(F1(a,b,c), d, a, b, c, in[13] + 0xfd987193L, 12); MD5STEP(F1(d,a,b), c, d, a, b, in[14] + 0xa679438eL, 17); MD5STEP(F1(c,d,a), b, c, d, a, in[15] + 0x49b40821L, 22); MD5STEP(F2(b,c,d), a, b, c, d, in[1] + 0xf61e2562L, 5); MD5STEP(F2(a,b,c), d, a, b, c, in[6] + 0xc040b340L, 9); MD5STEP(F2(d,a,b), c, d, a, b, in[11] + 0x265e5a51L, 14); MD5STEP(F2(c,d,a), b, c, d, a, in[0] + 0xe9b6c7aaL, 20); MD5STEP(F2(b,c,d), a, b, c, d, in[5] + 0xd62f105dL, 5); MD5STEP(F2(a,b,c), d, a, b, c, in[10] + 0x02441453L, 9); MD5STEP(F2(d,a,b), c, d, a, b, in[15] + 0xd8a1e681L, 14); MD5STEP(F2(c,d,a), b, c, d, a, in[4] + 0xe7d3fbc8L, 20); MD5STEP(F2(b,c,d), a, b, c, d, in[9] + 0x21e1cde6L, 5); MD5STEP(F2(a,b,c), d, a, b, c, in[14] + 0xc33707d6L, 9); MD5STEP(F2(d,a,b), c, d, a, b, in[3] + 0xf4d50d87L, 14); MD5STEP(F2(c,d,a), b, c, d, a, in[8] + 0x455a14edL, 20); MD5STEP(F2(b,c,d), a, b, c, d, in[13] + 0xa9e3e905L, 5); MD5STEP(F2(a,b,c), d, a, b, c, in[2] + 0xfcefa3f8L, 9); MD5STEP(F2(d,a,b), c, d, a, b, in[7] + 0x676f02d9L, 14); MD5STEP(F2(c,d,a), b, c, d, a, in[12] + 0x8d2a4c8aL, 20); MD5STEP(F3(b,c,d), a, b, c, d, in[5] + 0xfffa3942L, 4); MD5STEP(F3(a,b,c), d, a, b, c, in[8] + 0x8771f681L, 11); MD5STEP(F3(d,a,b), c, d, a, b, in[11] + 0x6d9d6122L, 16); MD5STEP(F3(c,d,a), b, c, d, a, in[14] + 0xfde5380cL, 23); MD5STEP(F3(b,c,d), a, b, c, d, in[1] + 0xa4beea44L, 4); MD5STEP(F3(a,b,c), d, a, b, c, in[4] + 0x4bdecfa9L, 11); MD5STEP(F3(d,a,b), c, d, a, b, in[7] + 0xf6bb4b60L, 16); MD5STEP(F3(c,d,a), b, c, d, a, in[10] + 0xbebfbc70L, 23); MD5STEP(F3(b,c,d), a, b, c, d, in[13] + 0x289b7ec6L, 4); MD5STEP(F3(a,b,c), d, a, b, c, in[0] + 0xeaa127faL, 11); MD5STEP(F3(d,a,b), c, d, a, b, in[3] + 0xd4ef3085L, 16); MD5STEP(F3(c,d,a), b, c, d, a, in[6] + 0x04881d05L, 23); MD5STEP(F3(b,c,d), a, b, c, d, in[9] + 0xd9d4d039L, 4); MD5STEP(F3(a,b,c), d, a, b, c, in[12] + 0xe6db99e5L, 11); MD5STEP(F3(d,a,b), c, d, a, b, in[15] + 0x1fa27cf8L, 16); MD5STEP(F3(c,d,a), b, c, d, a, in[2] + 0xc4ac5665L, 23); MD5STEP(F4(b,c,d), a, b, c, d, in[0] + 0xf4292244L, 6); MD5STEP(F4(a,b,c), d, a, b, c, in[7] + 0x432aff97L, 10); MD5STEP(F4(d,a,b), c, d, a, b, in[14] + 0xab9423a7L, 15); MD5STEP(F4(c,d,a), b, c, d, a, in[5] + 0xfc93a039L, 21); MD5STEP(F4(b,c,d), a, b, c, d, in[12] + 0x655b59c3L, 6); MD5STEP(F4(a,b,c), d, a, b, c, in[3] + 0x8f0ccc92L, 10); MD5STEP(F4(d,a,b), c, d, a, b, in[10] + 0xffeff47dL, 15); MD5STEP(F4(c,d,a), b, c, d, a, in[1] + 0x85845dd1L, 21); MD5STEP(F4(b,c,d), a, b, c, d, in[8] + 0x6fa87e4fL, 6); MD5STEP(F4(a,b,c), d, a, b, c, in[15] + 0xfe2ce6e0L, 10); MD5STEP(F4(d,a,b), c, d, a, b, in[6] + 0xa3014314L, 15); MD5STEP(F4(c,d,a), b, c, d, a, in[13] + 0x4e0811a1L, 21); MD5STEP(F4(b,c,d), a, b, c, d, in[4] + 0xf7537e82L, 6); MD5STEP(F4(a,b,c), d, a, b, c, in[11] + 0xbd3af235L, 10); MD5STEP(F4(d,a,b), c, d, a, b, in[2] + 0x2ad7d2bbL, 15); MD5STEP(F4(c,d,a), b, c, d, a, in[9] + 0xeb86d391L, 21); #else MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7); MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12); MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17); MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22); MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7); MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12); MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17); MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22); MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7); MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12); MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17); MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22); MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7); MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12); MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17); MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22); MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5); MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9); MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14); MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20); MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5); MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9); MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14); MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20); MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5); MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9); MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14); MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20); MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5); MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9); MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14); MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20); MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4); MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11); MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16); MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23); MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4); MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11); MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16); MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23); MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4); MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11); MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16); MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23); MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4); MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11); MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16); MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23); MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6); MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10); MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15); MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21); MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6); MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10); MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15); MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21); MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6); MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10); MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15); MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21); MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6); MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10); MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15); MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21); #endif buf[0] += a; buf[1] += b; buf[2] += c; buf[3] += d; } #endif ZenLib/Source/ZenLib/HTTP_Client/HTTPClientAuth.h0000664000000000000000000000657012615631146020367 0ustar rootroot #ifndef HTTP_CLIENT_AUTH_H #define HTTP_CLIENT_AUTH_H #include "HTTPClientWrapper.h" // Cross platform support #define HASHLEN 16 #define HASHHEXLEN 32 #define IN #define OUT typedef char HASH[HASHLEN]; typedef char HASHHEX[HASHHEXLEN+1]; typedef unsigned long uint32; // Base 64 Related #define DECODE64(c) (isascii(c) ? base64val[c] : BAD) #define BAD -1 static const char base64digits[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; static const char base64val[] = { BAD,BAD,BAD,BAD, BAD,BAD,BAD,BAD, BAD,BAD,BAD,BAD, BAD,BAD,BAD,BAD, BAD,BAD,BAD,BAD, BAD,BAD,BAD,BAD, BAD,BAD,BAD,BAD, BAD,BAD,BAD,BAD, BAD,BAD,BAD,BAD, BAD,BAD,BAD,BAD, BAD,BAD,BAD, 62, BAD,BAD,BAD, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,BAD,BAD, BAD,BAD,BAD,BAD, BAD, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,BAD, BAD,BAD,BAD,BAD, BAD, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,BAD, BAD,BAD,BAD,BAD }; void HTTPBase64Encoder(unsigned char *out, const unsigned char *in, int inlen); int HTTPBase64Decoder(char *out, const char *in); // Digest Related // Generates a 32 byte random hexadecimal string such as "4f6ba982..." void HTTPDigestGenerateCNonce(char *outbuff); // Calculate H(A1) as per HTTP Digest spec void HTTPDigestCalcHA1( IN int nAlg, /* 0 = MD5, 1 = MD5-Sess */ IN char * pszUserName, IN char * pszRealm, IN int nRealmLength, IN char * pszPassword, IN char * pszNonce, IN int nNonceLength, IN char * pszCNonce, OUT HASHHEX SessionKey ); // Calculate request-digest/response-digest as per HTTP Digest spec void HTTPDigestCalcResponse( IN HASHHEX HA1, // H(A1) IN char * pszNonce, // nonce from server IN int nNonceLength, // Length of nonce IN char * pszNonceCount, // 8 hex digits IN char * pszCNonce, // client nonce IN char * pszQop, // qop-value: "", "auth", "auth-int" IN int nQopLength, // qop param length IN char * pszMethod, // method from the request IN char * pszDigestUri, // requested URL IN int nDigestUriLebgth, // Uri Length IN HASHHEX HEntity, // H(entity body) if qop="auth-int" OUT HASHHEX Response // request-digest or response-digest ); // MD5 structures and functions struct MD5Context { uint32 buf[4]; uint32 bits[2]; unsigned char in[64]; }; void HTTPMD5Init (struct MD5Context *context); void HTTPMD5Update (struct MD5Context *context, unsigned char const *buf,unsigned len); void HTTPMD5Final (unsigned char digest[16], struct MD5Context *context); void HTTPMD5Transform (uint32 buf[4], uint32 const in[16]); // This is needed to make RSAREF happy on some MS-DOS compilers. typedef struct MD5Context MD5_CTX; #endif ZenLib/Source/ZenLib/HTTP_Client/HTTPClientWrapper.h0000664000000000000000000001142012615631146021074 0ustar rootroot #ifndef HTTP_CLIENT_WRAPPER #define HTTP_CLIENT_WRAPPER // Compilation mode #define _HTTP_BUILD_WIN32 // Set Windows Build flag /////////////////////////////////////////////////////////////////////////////// // // Section : Microsoft Windows Support // Last updated : 01/09/2005 // /////////////////////////////////////////////////////////////////////////////// #ifdef _HTTP_BUILD_WIN32 #if defined(_MSC_VER) #pragma warning (disable: 4996) // 'function': was declared deprecated (VS 2005) #endif #include #include #include #include #include #include #if defined(_WIN32) || defined(WIN32) #include #endif // Generic types typedef unsigned int UINT32; typedef int INT32; // Sockets (Winsock wrapper) #define HTTP_ECONNRESET (WSAECONNRESET) #define HTTP_EINPROGRESS (WSAEINPROGRESS) #define HTTP_EWOULDBLOCK (WSAEWOULDBLOCK) #endif /////////////////////////////////////////////////////////////////////////////// // // Section : Functions that are not supported by the AMT stdc framework // So they had to be specificaly added. // Last updated : 01/09/2005 // /////////////////////////////////////////////////////////////////////////////// #ifdef __cplusplus extern "C" { #endif // STDC Wrapper implimentation int HTTPWrapperIsAscii (int c); int HTTPWrapperToUpper (int c); int HTTPWrapperToLower (int c); int HTTPWrapperIsAlpha (int c); int HTTPWrapperIsAlNum (int c); char* HTTPWrapperItoa (char *buff,int i); void HTTPWrapperInitRandomeNumber (); long HTTPWrapperGetUpTime (); int HTTPWrapperGetRandomeNumber (); int HTTPWrapperGetSocketError (int s); unsigned long HTTPWrapperGetHostByName (char *name,unsigned long *address); int HTTPWrapperShutDown (int s,int in); // SSL Wrapper prototypes int HTTPWrapperSSLConnect (int s,const struct sockaddr *name,int namelen,char *hostname); int HTTPWrapperSSLNegotiate (int s,const struct sockaddr *name,int namelen,char *hostname); int HTTPWrapperSSLSend (int s,char *buf, int len,int flags); int HTTPWrapperSSLRecv (int s,char *buf, int len,int flags); int HTTPWrapperSSLClose (int s); int HTTPWrapperSSLRecvPending (int s); // Global wrapper Functions #define IToA HTTPWrapperItoa #define GetUpTime HTTPWrapperGetUpTime #define SocketGetErr HTTPWrapperGetSocketError #define HostByName HTTPWrapperGetHostByName #define InitRandomeNumber HTTPWrapperInitRandomeNumber #define GetRandomeNumber HTTPWrapperGetRandomeNumber #ifdef __cplusplus } #endif /////////////////////////////////////////////////////////////////////////////// // // Section : Global type definitions // Last updated : 01/09/2005 // /////////////////////////////////////////////////////////////////////////////// #define VOID void #ifndef NULL #define NULL 0 #endif #define TRUE 1 #define FALSE 0 typedef char CHAR; typedef unsigned short UINT16; typedef int BOOL; typedef unsigned long ULONG; // Global socket structures and definitions #define HTTP_INVALID_SOCKET (-1) typedef struct sockaddr_in HTTP_SOCKADDR_IN; typedef struct timeval HTTP_TIMEVAL; typedef struct hostent HTTP_HOSTNET; typedef struct sockaddr HTTP_SOCKADDR; typedef struct in_addr HTTP_INADDR; #endif // HTTP_CLIENT_WRAPPER ZenLib/Source/ZenLib/Trace.h0000664000000000000000000000310112615631146014573 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a zlib-style license that can * be found in the License.txt file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Trace // // Provide a direct to file trace // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef ZenTraceH #define ZenTraceH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include #include "ZenLib/Ztring.h" //--------------------------------------------------------------------------- namespace ZenLib { //*************************************************************************** static std::FILE* Trace_F; static ZenLib::Ztring Trace; static ZenLib::Ztring Trace2; #ifdef TRACE #undef TRACE #endif //TRACE #if 1 #define TRACE(_TOAPPEND) #else #define TRACE(_TOAPPEND) \ Trace.clear(); \ Trace2.clear(); \ _TOAPPEND; \ if (!Trace2.empty()) \ { \ Trace+=__T(" - "); \ Trace+=Trace2; \ } \ Trace+=__T("\r\n"); \ Trace_F=std::fopen("Trace.txt", "a+t"); \ if(Trace_F) \ { \ std::fwrite(Trace.To_Local().c_str(), Trace.size(), 1, Trace_F); \ std::fclose(Trace_F); \ } #endif //*************************************************************************** } //NameSpace #endif // ZenTraceH ZenLib/Source/ZenLib/Thread.cpp0000664000000000000000000004065712615631146015320 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a zlib-style license that can * be found in the License.txt file in the root of the source tree. */ //--------------------------------------------------------------------------- #include "ZenLib/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "ZenLib/Conf_Internal.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "ZenLib/Thread.h" #include #include //--------------------------------------------------------------------------- //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // ZENLIB_USEWX //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #ifdef ZENLIB_USEWX //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #include //--------------------------------------------------------------------------- namespace ZenLib { class ThreadEntry : public wxThread { public : ThreadEntry(Thread* Th_) : wxThread(wxTHREAD_JOINABLE) {Th=Th_;}; void* Entry() {Th->Entry(); return NULL;} private : Thread* Th; }; //*************************************************************************** // Constructor/Destructor //*************************************************************************** //--------------------------------------------------------------------------- Thread::Thread() { ThreadPointer=(void*)new ThreadEntry(this); ((ThreadEntry*)ThreadPointer)->Create(); } //--------------------------------------------------------------------------- Thread::~Thread() { delete (ThreadEntry*)ThreadPointer; } //*************************************************************************** // Main Entry //*************************************************************************** void Thread::Entry() { } //*************************************************************************** // Control //*************************************************************************** void Thread::Run() { ((ThreadEntry*)ThreadPointer)->Resume(); } void Thread::Pause() { ((ThreadEntry*)ThreadPointer)->Pause(); } void Thread::Stop() { ((ThreadEntry*)ThreadPointer)->Delete(); } bool Thread::IsRunning() { return ((ThreadEntry*)ThreadPointer)->IsRunning(); } //*************************************************************************** // Communicating //*************************************************************************** void Thread::Sleep(size_t Millisecond) { ((ThreadEntry*)ThreadPointer)->Sleep((unsigned long)Millisecond); } void Thread::Yield() { ((ThreadEntry*)ThreadPointer)->Yield(); } } //Namespace //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // WINDOWS //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #else //ZENLIB_USEWX #ifdef WINDOWS //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #undef __TEXT #include #undef Yield //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- //Config #ifndef _MT #define _MT //Must have this symbol defined to get _beginthread/_endthread declarations #endif #ifdef __BORLANDC__ #if !defined(__MT__) #define __MT__ //-tWM in the IDE is not always set #endif #if !defined(__MFC_COMPAT__) #define __MFC_COMPAT__ // Needed to know about _beginthreadex etc.. #endif #endif //__BORLANDC__ #if defined(_MSC_VER) || \ (defined(__GNUG__) && defined(__MSVCRT__)) || \ defined(__WATCOMC__) || \ defined(__MWERKS__) //(defined(__BORLANDC__) && (__BORLANDC__ >= 0x500)) #ifndef __WXWINCE__ #define USING_BEGINTHREAD //Using _beginthreadex() instead of CreateThread() if possible (better, because of Win32 API has problems with memory leaks in C library) #endif #endif #ifdef USING_BEGINTHREAD #include typedef unsigned THREAD_RETVAL; //The return type of the thread function entry point #define THREAD_CALLCONV __stdcall //The calling convention of the thread function entry point #else // the settings for CreateThread() typedef DWORD THREAD_RETVAL; #define THREAD_CALLCONV WINAPI #endif //--------------------------------------------------------------------------- namespace ZenLib { //--------------------------------------------------------------------------- THREAD_RETVAL THREAD_CALLCONV Thread_Start(void *param) { ((Thread*)param)->Entry(); ((Thread*)param)->Internal_Exit(); return 1; } //*************************************************************************** // Constructor/Destructor //*************************************************************************** //--------------------------------------------------------------------------- Thread::Thread() { C.Enter(); State=State_New; ThreadPointer=NULL; C.Leave(); } //--------------------------------------------------------------------------- Thread::~Thread() { C.Enter(); if (ThreadPointer!=NULL) CloseHandle((HANDLE)ThreadPointer); //ThreadPointer=NULL C.Leave(); } //*************************************************************************** // Control //*************************************************************************** //--------------------------------------------------------------------------- Thread::returnvalue Thread::Run() { C.Enter(); //Coherency if (State!=State_New || ThreadPointer!=NULL) { C.Leave(); return Incoherent; } //Creating #ifdef USING_BEGINTHREAD #ifdef __WATCOMC__ const unsigned stksize=10240; //Watcom is reported to not like 0 stack size (which means "use default") #else const unsigned stksize=0; //Default #endif //__WATCOMC__ ThreadPointer=(void*)_beginthreadex (NULL, stksize, Thread_Start, this, CREATE_SUSPENDED, NULL); #else ThreadPointer=(void*)CreateThread (NULL, 0, Thread_Start, this, CREATE_SUSPENDED, NULL); #endif //USING_BEGINTHREAD if (ThreadPointer==NULL) { C.Leave(); return Resource; } //Running ResumeThread((HANDLE)ThreadPointer); //Configuring State=State_Running; C.Leave(); return Ok; } //--------------------------------------------------------------------------- Thread::returnvalue Thread::RunAgain() { //Coherency C.Enter(); //Coherency if (State!=State_New && State!=State_Terminated) { C.Leave(); return Incoherent; } //Configuring if (State==State_Terminated) State=State_New; C.Leave(); return Run(); } //--------------------------------------------------------------------------- Thread::returnvalue Thread::Pause() { C.Enter(); //Pausing SuspendThread((HANDLE)ThreadPointer); //Configuring State=State_Paused; C.Leave(); return Ok; } //--------------------------------------------------------------------------- Thread::returnvalue Thread::RequestTerminate() { C.Enter(); //Coherency if (State!=State_Running) { C.Leave(); return IsNotRunning; } //Configuring State=State_Terminating; C.Leave(); return Ok; } //--------------------------------------------------------------------------- Thread::returnvalue Thread::ForceTerminate() { C.Enter(); //Terminating (not clean) TerminateThread((HANDLE)ThreadPointer, 1); ThreadPointer=NULL; //Configuring State=State_Terminated; C.Leave(); return Ok; } //*************************************************************************** // Status //*************************************************************************** bool Thread::IsRunning() { C.Enter(); bool ToReturn=State==State_Running || State==State_Terminating; C.Leave(); return ToReturn; } //--------------------------------------------------------------------------- bool Thread::IsTerminating() { C.Enter(); bool ToReturn=State==State_Terminating; C.Leave(); return ToReturn; } //--------------------------------------------------------------------------- bool Thread::IsExited() { C.Enter(); bool ToReturn=State==State_New || State==State_Terminated; C.Leave(); return ToReturn; } //*************************************************************************** // Main Entry //*************************************************************************** void Thread::Entry() { } //*************************************************************************** // Communicating //*************************************************************************** //--------------------------------------------------------------------------- void Thread::Sleep(size_t Millisecond) { ::Sleep((DWORD)Millisecond); } //--------------------------------------------------------------------------- void Thread::Yield() { ::Sleep(0); } //*************************************************************************** // Internal //*************************************************************************** //--------------------------------------------------------------------------- Thread::returnvalue Thread::Internal_Exit() { C.Enter(); //Coherency if (State!=State_Running && State!=State_Terminating) { C.Leave(); return IsNotRunning; } //Closing old handle CloseHandle((HANDLE)ThreadPointer); ThreadPointer=NULL; //Configuring State=State_Terminated; C.Leave(); return Ok; } } //Namespace //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // UNIX //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #else //WINDOWS //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- //Source: http://www.yolinux.com/TUTORIALS/LinuxTutorialPosixThreads.html //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include #include #ifdef _POSIX_PRIORITY_SCHEDULING #include #endif //_POSIX_PRIORITY_SCHEDULING //--------------------------------------------------------------------------- namespace ZenLib { //--------------------------------------------------------------------------- void *Thread_Start(void *param) { ((Thread*)param)->Entry(); ((Thread*)param)->Internal_Exit(); return NULL; } //*************************************************************************** // Constructor/Destructor //*************************************************************************** //--------------------------------------------------------------------------- Thread::Thread() { C.Enter(); State=State_New; ThreadPointer=NULL; C.Leave(); } //--------------------------------------------------------------------------- Thread::~Thread() { } //*************************************************************************** // Main Entry //*************************************************************************** void Thread::Entry() { } //*************************************************************************** // Control //*************************************************************************** Thread::returnvalue Thread::Run() { C.Enter(); //Coherency if (State!=State_New || ThreadPointer!=NULL) { C.Leave(); return Incoherent; } //Creating pthread_attr_t Attr; pthread_attr_init(&Attr); pthread_attr_setdetachstate(&Attr, PTHREAD_CREATE_DETACHED); //Running pthread_create((pthread_t*)&ThreadPointer, &Attr, Thread_Start, (void*)this); //Configuring State=State_Running; C.Leave(); return Ok; } Thread::returnvalue Thread::RunAgain() { //Coherency C.Enter(); //Coherency if (State!=State_New && State!=State_Terminated) { C.Leave(); return Incoherent; } //Configuring if (State==State_Terminated) State=State_New; C.Leave(); return Run(); } Thread::returnvalue Thread::Pause() { //pthread_cond_wait return Ok; } Thread::returnvalue Thread::RequestTerminate() { C.Enter(); if (State!=State_Running) { C.Leave(); return IsNotRunning; } State=State_Terminating; C.Leave(); return Ok; } Thread::returnvalue Thread::ForceTerminate() { //Terminating (not clean) //Configuring State=State_Terminated; return Ok; } //*************************************************************************** // Status //*************************************************************************** //--------------------------------------------------------------------------- bool Thread::IsRunning() { C.Enter(); bool ToReturn=State==State_Running; C.Leave(); return ToReturn; } //--------------------------------------------------------------------------- bool Thread::IsTerminating() { C.Enter(); bool ToReturn=State==State_Terminating; C.Leave(); return ToReturn; } //--------------------------------------------------------------------------- bool Thread::IsExited() { C.Enter(); bool ToReturn=State==State_New || State==State_Terminating; C.Leave(); return ToReturn; } //*************************************************************************** // Communicating //*************************************************************************** void Thread::Sleep(size_t) { } void Thread::Yield() { #ifdef _POSIX_PRIORITY_SCHEDULING sched_yield(); #endif //_POSIX_PRIORITY_SCHEDULING } //*************************************************************************** // Internal //*************************************************************************** Thread::returnvalue Thread::Internal_Exit() { C.Enter(); //Coherency if (State!=State_Running && State!=State_Terminating) { C.Leave(); return IsNotRunning; } //Closing old handle ; ThreadPointer=NULL; //Configuring State=State_Terminated; C.Leave(); return Ok; } } //Namespace //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #endif //WINDOWS #endif //ZENLIB_USEWX //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ZenLib/Source/ZenLib/Translation.h0000664000000000000000000000413112615631146016037 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a zlib-style license that can * be found in the License.txt file in the root of the source tree. */ //--------------------------------------------------------------------------- #ifndef ZenLib_TranslationH #define ZenLib_TranslationH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "ZenLib/Ztring.h" #include //--------------------------------------------------------------------------- namespace ZenLib { //*************************************************************************** /// @brief Helper for translation //*************************************************************************** class Translation : public std::map { public : //Constructors/Destructor Translation (); Translation (const Ztring &Source); Translation (const Char *Source); #ifdef _UNICODE Translation (const char *Source); //convert a UTF-8 string into Unicode #endif //In/Out Ztring Get () const; const Ztring &Get (const Ztring &Value); Ztring Get (const Ztring &Count, const Ztring &Value); void Write (const Ztring &NewLanguage); //All language in one void Write (const Ztring &Value, const Ztring &NewLanguage); //Per item //Configuration /// @brief Set the Separator character void Separator_Set (size_type Level, const Ztring &NewSeparator); /// @brief Set the Quote character /// During Read() or Write() method, if Separator is in the sequence, we must quote it void Quote_Set (const Ztring &NewQuote); /// @brief Set the Maximum number of element to read /// During Read() or Write() method, if there is more elements, merge them with the last element void Max_Set (size_type Level, size_type Max); protected : Ztring Separator[2]; Ztring Quote; size_type Max[2]; }; } //namespace #endif ZenLib/Source/ZenLib/Conf.h0000664000000000000000000002563312615631146014440 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a zlib-style license that can * be found in the License.txt file in the root of the source tree. */ //--------------------------------------------------------------------------- #ifndef ZenConfH #define ZenConfH //--------------------------------------------------------------------------- //*************************************************************************** // Platforms //*************************************************************************** //--------------------------------------------------------------------------- //Win32 #if defined(__NT__) || defined(_WIN32) || defined(WIN32) #ifndef WIN32 #define WIN32 #endif #ifndef _WIN32 #define _WIN32 #endif #ifndef __WIN32__ #define __WIN32__ 1 #endif #endif //--------------------------------------------------------------------------- //Win64 #if defined(_WIN64) || defined(WIN64) #ifndef WIN64 #define WIN64 #endif #ifndef _WIN64 #define _WIN64 #endif #ifndef __WIN64__ #define __WIN64__ 1 #endif #endif //--------------------------------------------------------------------------- //Windows #if defined(WIN32) || defined(WIN64) #ifndef WINDOWS #define WINDOWS #endif #ifndef _WINDOWS #define _WINDOWS #endif #ifndef __WINDOWS__ #define __WINDOWS__ 1 #endif #endif //--------------------------------------------------------------------------- //Unix (Linux, HP, Sun, BeOS...) #if defined(UNIX) || defined(_UNIX) || defined(__UNIX__) \ || defined(__unix) || defined(__unix__) \ || defined(____SVR4____) || defined(__LINUX__) || defined(__sgi) \ || defined(__hpux) || defined(sun) || defined(__SUN__) || defined(_AIX) \ || defined(__EMX__) || defined(__VMS) || defined(__BEOS__) #ifndef UNIX #define UNIX #endif #ifndef _UNIX #define _UNIX #endif #ifndef __UNIX__ #define __UNIX__ 1 #endif #endif //--------------------------------------------------------------------------- //MacOS Classic #if defined(macintosh) #ifndef MACOS #define MACOS #endif #ifndef _MACOS #define _MACOS #endif #ifndef __MACOS__ #define __MACOS__ 1 #endif #endif //--------------------------------------------------------------------------- //MacOS X #if defined(__APPLE__) && defined(__MACH__) #ifndef MACOSX #define MACOSX #endif #ifndef _MACOSX #define _MACOSX #endif #ifndef __MACOSX__ #define __MACOSX__ 1 #endif #endif //Test of targets #if defined(WINDOWS) && defined(UNIX) && defined(MACOS) && defined(MACOSX) #pragma message Multiple platforms??? #endif #if !defined(WIN32) && !defined(UNIX) && !defined(MACOS) && !defined(MACOSX) #pragma message No known platforms, assume default #endif //*************************************************************************** // Internationnal //*************************************************************************** //--------------------------------------------------------------------------- //Unicode #if defined(_UNICODE) || defined(UNICODE) || defined(__UNICODE__) #ifndef _UNICODE #define _UNICODE #endif #ifndef UNICODE #define UNICODE #endif #ifndef __UNICODE__ #define __UNICODE__ 1 #endif #endif //--------------------------------------------------------------------------- //wchar_t stuff #if defined(MACOS) || defined(MACOSX) #include #endif //*************************************************************************** // Compiler bugs/unuseful warning //*************************************************************************** //MSVC6 : for(int t=0; t<10; ++t) { do something }; for(int t=0; t<10; ++t) { do something } #if defined(_MSC_VER) && _MSC_VER <= 1200 #define for if(true)for #pragma warning(disable:4786) // MSVC6 doesn't like typenames longer than 255 chars (which generates an enormous amount of warnings). #endif //MSVC2005 : "deprecated" warning (replacement functions are not in MinGW32 or Borland!) #if defined(_MSC_VER) && _MSC_VER >= 1400 #pragma warning(disable : 4996) #endif //*************************************************************************** // (Without Namespace) //*************************************************************************** //--------------------------------------------------------------------------- #include //--------------------------------------------------------------------------- #if defined(ZENLIB_DEBUG) && (defined(DEBUG) || defined(_DEBUG)) #include "ZenLib/MemoryDebug.h" #endif // defined(ZENLIB_DEBUG) && (defined(DEBUG) || defined(_DEBUG)) //*************************************************************************** // Compiler helpers //*************************************************************************** //--------------------------------------------------------------------------- //Macro to cut down on compiler warnings #ifndef UNUSED #define UNUSED(Identifier) #endif //--------------------------------------------------------------------------- //If we need size_t specific integer conversion #if !defined(SIZE_T_IS_LONG) && (defined(__LP64__) || defined(MACOSX)) #define SIZE_T_IS_LONG #endif //--------------------------------------------------------------------------- //(-1) is known to be the MAX of an unsigned int but GCC complains about it #ifdef __cplusplus #include //for size_t #else /* __cplusplus */ #include //for size_t #endif /* __cplusplus */ #include //size_t namespace ZenLib { const std::size_t Error=((std::size_t)(-1)); const std::size_t All=((std::size_t)(-1)); const std::size_t Unlimited=((std::size_t)(-1)); } //*************************************************************************** // (With namespace) //*************************************************************************** namespace ZenLib { //*************************************************************************** // International //*************************************************************************** //--------------------------------------------------------------------------- //Char types #if defined(__UNICODE__) #if defined (_MSC_VER) && !defined (_NATIVE_WCHAR_T_DEFINED) #pragma message Native wchar_t is not defined, not tested, you should put /Zc:wchar_t in compiler options #endif typedef wchar_t Char; #undef __T #define __T(__x) L ## __x #else // defined(__UNICODE__) typedef char Char; #undef __T #define __T(__x) __x #endif // defined(__UNICODE__) #ifdef wchar_t typedef wchar_t wchar; #endif // wchar_t //*************************************************************************** // Platform differences //*************************************************************************** //End of line extern const Char* EOL; extern const Char PathSeparator; //*************************************************************************** // Types //*************************************************************************** //--------------------------------------------------------------------------- //int typedef signed int ints; typedef unsigned int intu; //--------------------------------------------------------------------------- //8-bit int #if UCHAR_MAX==0xff #undef MAXTYPE_INT #define MAXTYPE_INT 8 typedef signed char int8s; typedef unsigned char int8u; #else #pragma message This machine has no 8-bit integertype? #endif //--------------------------------------------------------------------------- //16-bit int #if UINT_MAX == 0xffff #undef MAXTYPE_INT #define MAXTYPE_INT 16 typedef signed int int16s; typedef unsigned int int16u; #elif USHRT_MAX == 0xffff #undef MAXTYPE_INT #define MAXTYPE_INT 16 typedef signed short int16s; typedef unsigned short int16u; #else #pragma message This machine has no 16-bit integertype? #endif //--------------------------------------------------------------------------- //32-bit int #if UINT_MAX == 0xfffffffful #undef MAXTYPE_INT #define MAXTYPE_INT 32 typedef signed int int32s; typedef unsigned int int32u; #elif ULONG_MAX == 0xfffffffful #undef MAXTYPE_INT #define MAXTYPE_INT 32 typedef signed long int32s; typedef unsigned long int32u; #elif USHRT_MAX == 0xfffffffful #undef MAXTYPE_INT #define MAXTYPE_INT 32 typedef signed short int32s; typedef unsigned short int32u; #else #pragma message This machine has no 32-bit integer type? #endif //--------------------------------------------------------------------------- //64-bit int #if defined(__MINGW32__) || defined(__CYGWIN32__) || defined(__UNIX__) || defined(__MACOSX__) #undef MAXTYPE_INT #define MAXTYPE_INT 64 typedef signed long long int64s; typedef unsigned long long int64u; #elif defined(__WIN32__) #undef MAXTYPE_INT #define MAXTYPE_INT 64 typedef signed __int64 int64s; typedef unsigned __int64 int64u; #else #pragma message This machine has no 64-bit integer type? #endif //--------------------------------------------------------------------------- //32-bit float #if defined(WINDOWS) || defined(UNIX) || defined(MACOSX) #undef MAXTYPE_FLOAT #define MAXTYPE_FLOAT 32 typedef float float32; #else #pragma message This machine has no 32-bit float type? #endif //--------------------------------------------------------------------------- //64-bit float #if defined(WINDOWS) || defined(UNIX) || defined(MACOSX) #undef MAXTYPE_FLOAT #define MAXTYPE_FLOAT 64 typedef double float64; #else #pragma message This machine has no 64-bit float type? #endif //--------------------------------------------------------------------------- //80-bit float #if defined(WINDOWS) || defined(UNIX) || defined(MACOSX) #undef MAXTYPE_FLOAT #define MAXTYPE_FLOAT 80 typedef long double float80; #else #pragma message This machine has no 80-bit float type? #endif //*************************************************************************** // Nested functions //*************************************************************************** //Unices #if defined (UNIX) #define snwprintf swprintf #endif //Windows - MSVC (before Visual Studio 2015) #if defined (_MSC_VER) && _MSC_VER < 1900 #define snprintf _snprintf #define snwprintf _snwprintf #endif } //namespace #endif ZenLib/Source/ZenLib/Ztring.cpp0000664000000000000000000021641712615631146015365 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a zlib-style license that can * be found in the License.txt file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // More methods for std::(w)string // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #include "ZenLib/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "ZenLib/Conf_Internal.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #ifdef ZENLIB_USEWX #include #include #else //ZENLIB_USEWX #ifdef ZENLIB_STANDARD #undef WINDOWS #endif #ifdef WINDOWS #undef __TEXT #include #include #endif #endif //ZENLIB_USEWX #ifdef __MINGW32__ #include #endif //__MINGW32__ #include #include #include #include #include "ZenLib/OS_Utils.h" #include "ZenLib/File.h" using namespace std; //--------------------------------------------------------------------------- namespace ZenLib { int16u Ztring_ISO_8859_2[96]= { 0x00A0, 0x0104, 0x02D8, 0x0141, 0x00A4, 0x013D, 0x015A, 0x00A7, 0x00A8, 0x0160, 0x015E, 0x0164, 0x0179, 0x00AD, 0x017D, 0x017B, 0x00B0, 0x0105, 0x02DB, 0x0142, 0x00B4, 0x013E, 0x015B, 0x02C7, 0x00B8, 0x0161, 0x015F, 0x0165, 0x017A, 0x02DD, 0x017E, 0x017C, 0x0154, 0x00C1, 0x00C2, 0x0102, 0x00C4, 0x0139, 0x0106, 0x00C7, 0x010C, 0x00C9, 0x0118, 0x00CB, 0x011A, 0x00CD, 0x00CE, 0x010E, 0x0110, 0x0143, 0x0147, 0x00D3, 0x00D4, 0x0150, 0x00D6, 0x00D7, 0x0158, 0x016E, 0x00DA, 0x0170, 0x00DC, 0x00DD, 0x0162, 0x00DF, 0x0155, 0x00E1, 0x00E2, 0x0103, 0x00E4, 0x013A, 0x0107, 0x00E7, 0x010D, 0x00E9, 0x0119, 0x00EB, 0x011B, 0x00ED, 0x00EE, 0x010F, 0x0111, 0x0144, 0x0148, 0x00F3, 0x00F4, 0x0151, 0x00F6, 0x00F7, 0x0159, 0x016F, 0x00FA, 0x0171, 0x00FC, 0x00FD, 0x0163, 0x02D9, }; //--------------------------------------------------------------------------- Ztring EmptyZtring; //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #if defined(STREAM_MISSING) #if defined (_UNICODE) #define _tnprintf snwprintf #else #define _tnprintf snprintf #endif #else typedef basic_stringstream tStringStream; typedef basic_istringstream tiStringStream; typedef basic_ostringstream toStringStream; #endif //--------------------------------------------------------------------------- //*************************************************************************** // Operators //*************************************************************************** Char &Ztring::operator() (size_type Pos) { if (Pos>size()) resize(Pos); return operator[] (Pos); } //*************************************************************************** // Assign //*************************************************************************** bool Ztring::Assign_FromFile (const Ztring &FileName) { File F; if (!F.Open(FileName)) return false; int64u F_Size=F.Size_Get(); if (F_Size>((size_t)-1)-1) return false; //Creating buffer int8u* Buffer=new int8u[(size_t)F_Size+1]; size_t Buffer_Offset=0; //Reading the file while(Buffer_OffsetWC2MB(NULL, S, 0); if (OK!=0 && OK!=Error) assign(wxConvCurrent->cWC2MB(S)); #else //ZENLIB_USEWX #ifdef WINDOWS int Size=WideCharToMultiByte(CP_UTF8, 0, S, -1, NULL, 0, NULL, NULL); if (Size!=0) { char* AnsiString=new char[Size+1]; WideCharToMultiByte(CP_UTF8, 0, S, -1, AnsiString, Size, NULL, NULL); AnsiString[Size]='\0'; assign (AnsiString); delete[] AnsiString; } else clear(); #else //WINDOWS size_t Size=wcstombs(NULL, S, 0); if (Size!=0 && Size!=(size_t)-1) { char* AnsiString=new char[Size+1]; Size=wcstombs(AnsiString, S, wcslen(S)); AnsiString[Size]='\0'; assign (AnsiString); delete[] AnsiString; } else clear(); #endif #endif //ZENLIB_USEWX #endif return *this; } Ztring& Ztring::From_Unicode (const wchar_t *S, size_type Start, size_type Length) { if (S==NULL) return *this; if (Length==Error) Length=wcslen(S+Start); wchar_t* Temp=new wchar_t[Length+1]; wcsncpy (Temp, S+Start, Length); Temp[Length]=__T('\0'); From_Unicode(Temp); delete[] Temp; //Temp=NULL; return *this; } Ztring& Ztring::From_UTF8 (const char* S) { if (S==NULL) return *this; #ifdef ZENLIB_USEWX size_type OK=wxConvUTF8.MB2WC(NULL, S, 0); if (OK!=0 && OK!=Error) #ifdef _UNICODE assign(wxConvUTF8.cMB2WC(S).data()); #else assign(wxConvCurrent->cWC2MB(wxConvUTF8.cMB2WC(S))); #endif #else //ZENLIB_USEWX #ifdef _UNICODE // Don't use MultiByteToWideChar(), some characters are not well decoded clear(); const int8u* Z=(const int8u*)S; while (*Z) //0 is end { //1 byte if (*Z<0x80) { operator += ((wchar_t)(*Z)); Z++; } //2 bytes else if ((*Z&0xE0)==0xC0) { if ((*(Z+1)&0xC0)==0x80) { operator += ((((wchar_t)(*Z&0x1F))<<6)|(*(Z+1)&0x3F)); Z+=2; } else { clear(); return *this; //Bad character } } //3 bytes else if ((*Z&0xF0)==0xE0) { if ((*(Z+1)&0xC0)==0x80 && (*(Z+2)&0xC0)==0x80) { operator += ((((wchar_t)(*Z&0x0F))<<12)|((*(Z+1)&0x3F)<<6)|(*(Z+2)&0x3F)); Z+=3; } else { clear(); return *this; //Bad character } } //4 bytes else if ((*Z&0xF8)==0xF0) { if ((*(Z+1)&0xC0)==0x80 && (*(Z+2)&0xC0)==0x80 && (*(Z+3)&0xC0)==0x80) { #if defined(_MSC_VER) #pragma warning(push) #pragma warning(disable:4127) #endif //defined(_MSC_VER) if (sizeof(wchar_t) == 2) #if defined(_MSC_VER) #pragma warning(pop) #endif //defined(_MSC_VER) { int32u Value = ((((int32u)(*Z&0x0F))<<18)|((*(Z+1)&0x3F)<<12)|((*(Z+2)&0x3F)<<6)|(*(Z+3)&0x3F)); operator += (0xD800|((Value>>10)-0x40)); operator += (0xDC00| (Value&0x3FF)); } else operator += ((((wchar_t)(*Z&0x0F))<<18)|((*(Z+1)&0x3F)<<12)|((*(Z+2)&0x3F)<<6)|(*(Z+3)&0x3F)); Z+=4; } else { clear(); return *this; //Bad character } } else { clear(); return *this; //Bad character } } #else assign(S); //Not implemented #endif #endif //ZENLIB_USEWX return *this; } Ztring& Ztring::From_UTF8 (const char* S, size_type Start, size_type Length) { if (S==NULL) return *this; if (Length==Error) Length=strlen(S+Start); char* Temp=new char[Length+1]; strncpy (Temp, S+Start, Length); Temp[Length]='\0'; From_UTF8(Temp); delete[] Temp; //Temp=NULL; return *this; } Ztring& Ztring::From_UTF16 (const char* S) { if (S==NULL) return *this; if ((unsigned char)S[0]==(unsigned char)0xFF && (unsigned char)S[1]==(unsigned char)0xFE) return From_UTF16LE(S+2); else if ((unsigned char)S[0]==(unsigned char)0xFE && (unsigned char)S[1]==(unsigned char)0xFF) return From_UTF16BE(S+2); else if ((unsigned char)S[0]==(unsigned char)0x00 && (unsigned char)S[1]==(unsigned char)0x00) { clear(); //No begin! return *this; } else return From_UTF16LE(S); //Not sure, default } Ztring& Ztring::From_UTF16 (const char* S, size_type Start, size_type Length) { if (S==NULL) return *this; if (Length<2) return *this; if ((unsigned char)S[0]==(unsigned char)0xFF && (unsigned char)S[1]==(unsigned char)0xFE) return From_UTF16LE(S+2, Start, Length-2); else if ((unsigned char)S[0]==(unsigned char)0xFE && (unsigned char)S[1]==(unsigned char)0xFF) return From_UTF16BE(S+2, Start, Length-2); else if ((unsigned char)S[0]==(unsigned char)0x00 && (unsigned char)S[1]==(unsigned char)0x00) { clear(); //No begin! return *this; } else return From_UTF16LE(S, Start, Length); //Not sure, default } Ztring& Ztring::From_UTF16BE (const char* S) { if (S==NULL) return *this; #ifdef ZENLIB_USEWX //clear(); return *this; wxMBConvUTF16BE wxConvUTF16BE; size_type OK=wxConvUTF16BE.MB2WC(NULL, S, 0); if (OK!=0 && OK!=Error) #ifdef _UNICODE assign(wxConvUTF16BE.cMB2WC(S).data()); #else assign(wxConvCurrent->cWC2MB(wxConvUTF16BE.cMB2WC(S))); #endif #else //ZENLIB_USEWX #ifdef WINDOWS clear(); const wchar_t* SW=(const wchar_t*)S; size_t Pos=0; while (SW[Pos]!=__T('\0')) { Char Temp=(Char)(((SW[Pos]&0xFF00)>>8)+((SW[Pos]&0x00FF)<<8)); append(1, Temp); Pos++; } #else //WINDOWS clear(); while (S[0]!=0 || S[1]!=0) { append(1, (Char)BigEndian2int16u(S)); S+=2; } #endif #endif //ZENLIB_USEWX return *this; } Ztring& Ztring::From_UTF16BE (const char* S, size_type Start, size_type Length) { if (S==NULL) return *this; if (Length==Error) { Length=0; while(S[Length]!=0x0000) Length++; } else Length&=(size_t)-2; //odd number char* Temp=new char[Length+2]; memcpy (Temp, S+Start, Length); Temp[Length+0]=0x00; Temp[Length+1]=0x00; reserve(Length); From_UTF16BE(Temp); delete[] Temp; //Temp=NULL; return *this; } Ztring& Ztring::From_UTF16LE (const char* S) { if (S==NULL) return *this; #ifdef ZENLIB_USEWX //clear(); return *this; wxMBConvUTF16LE wxConvUTF16LE; size_type OK=wxConvUTF16LE.MB2WC(NULL, S, 0); if (OK!=0 && OK!=Error) #ifdef _UNICODE assign(wxConvUTF16LE.cMB2WC(S).data()); #else assign(wxConvCurrent->cWC2MB(wxConvUTF16LE.cMB2WC(S))); #endif #else //ZENLIB_USEWX #ifdef WINDOWS #ifdef UNICODE const wchar_t* SW=(const wchar_t*)S; assign(SW); #else clear(); //Not implemented #endif #else //WINDOWS clear(); while (S[0]!=0 || S[1]!=0) { append(1, (Char)LittleEndian2int16u(S)); S+=2; } #endif #endif //ZENLIB_USEWX return *this; } Ztring& Ztring::From_UTF16LE (const char* S, size_type Start, size_type Length) { if (S==NULL) return *this; if (Length==Error) { Length=0; while(S[Length]!=0x0000) Length+=2; } else Length&=(size_t)-2; //odd number char* Temp=new char[Length+2]; memcpy (Temp, S+Start, Length); Temp[Length+0]=0x00; Temp[Length+1]=0x00; From_UTF16LE(Temp); delete[] Temp; //Temp=NULL; return *this; } Ztring& Ztring::From_Local (const char* S) { if (S==NULL) return *this; #ifdef _UNICODE #ifdef ZENLIB_USEWX size_type OK=wxConvCurrent->MB2WC(NULL, S, 0); if (OK!=0 && OK!=Error) assign(wxConvCurrent->cMB2WC(S).data()); #else //ZENLIB_USEWX #ifdef WINDOWS int Size=MultiByteToWideChar(CP_ACP, 0, S, -1, NULL, 0); if (Size!=0) { wchar_t* WideString=new wchar_t[Size+1]; MultiByteToWideChar(CP_ACP, 0, S, -1, WideString, Size); WideString[Size]=L'\0'; assign (WideString); delete[] WideString; //WideString=NULL; } else clear(); #else //WINDOWS size_t Size=mbstowcs(NULL, S, 0); if (Size!=0 && Size!=(size_t)-1) { wchar_t* WideString=new wchar_t[Size+1]; Size=mbstowcs(WideString, S, Size); WideString[Size]=L'\0'; assign (WideString); delete[] WideString; //WideString=NULL; } else clear(); #endif #endif //ZENLIB_USEWX #else assign(S); #endif return *this; } Ztring& Ztring::From_Local (const char* S, size_type Start, size_type Length) { if (S==NULL) return *this; if (Length==Error) Length=strlen(S+Start); #ifdef _UNICODE char* Temp=new char[Length+1]; strncpy (Temp, S+Start, Length); Temp[Length]='\0'; From_Local(Temp); delete[] Temp; //Temp=NULL; #else assign(S+Start, Length); if (find(__T('\0'))!=std::string::npos) resize(find(__T('\0'))); #endif return *this; } Ztring& Ztring::From_ISO_8859_1(const char* S) { size_t Length = strlen(S); wchar_t* Temp = new wchar_t[Length +1]; for (size_t Pos=0; Pos=0xA0) Temp[Pos]=(wchar_t)Ztring_ISO_8859_2[((int8u)S[Pos])-0xA0]; else Temp[Pos]=(wchar_t)((int8u)S[Pos]); } From_Unicode(Temp); delete[] Temp; return *this; } Ztring& Ztring::From_ISO_8859_2(const char* S, size_type Start, size_type Length) { if (S==NULL) return *this; if (Length==Error) Length=strlen(S+Start); #ifdef _UNICODE char* Temp = new char[Length+1]; strncpy(Temp, S +Start, Length); Temp[Length] = '\0'; From_ISO_8859_2(Temp); delete[] Temp; #else assign(S +Start, Length); if (find(__T('\0')) != std::string::npos) resize(find(__T('\0'))); #endif return *this; } Ztring& Ztring::From_GUID (const int128u S) { Ztring S1; S1.From_CC1((int8u) ((S.hi&0x000000FF00000000LL)>>32)); append(S1); S1.From_CC1((int8u) ((S.hi&0x0000FF0000000000LL)>>40)); append(S1); S1.From_CC1((int8u) ((S.hi&0x00FF000000000000LL)>>48)); append(S1); S1.From_CC1((int8u) ((S.hi&0xFF00000000000000LL)>>56)); append(S1); append(__T("-")); S1.From_CC1((int8u) ((S.hi&0x0000000000FF0000LL)>>16)); append(S1); S1.From_CC1((int8u) ((S.hi&0x00000000FF000000LL)>>24)); append(S1); append(__T("-")); S1.From_CC1((int8u) ( S.hi&0x00000000000000FFLL )); append(S1); S1.From_CC1((int8u) ((S.hi&0x000000000000FF00LL)>> 8)); append(S1); append(__T("-")); S1.From_CC2((int16u)((S.lo&0xFFFF000000000000LL)>>48)); append(S1); append(__T("-")); S1.From_CC2((int16u)((S.lo&0x0000FFFF00000000LL)>>32)); append(S1); S1.From_CC2((int16u)((S.lo&0x00000000FFFF0000LL)>>16)); append(S1); S1.From_CC2((int16u)( S.lo&0x000000000000FFFFLL )); append(S1); return *this; } Ztring& Ztring::From_UUID (const int128u S) { Ztring S1; S1.From_CC2((int16u)((S.hi&0xFFFF000000000000LL)>>48)); assign(S1); S1.From_CC2((int16u)((S.hi&0x0000FFFF00000000LL)>>32)); append(S1); append(__T("-")); S1.From_CC2((int16u)((S.hi&0x00000000FFFF0000LL)>>16)); append(S1); append(__T("-")); S1.From_CC2((int16u)( S.hi&0x000000000000FFFFLL )); append(S1); append(__T("-")); S1.From_CC2((int16u)((S.lo&0xFFFF000000000000LL)>>48)); append(S1); append(__T("-")); S1.From_CC2((int16u)((S.lo&0x0000FFFF00000000LL)>>32)); append(S1); S1.From_CC2((int16u)((S.lo&0x00000000FFFF0000LL)>>16)); append(S1); S1.From_CC2((int16u)( S.lo&0x000000000000FFFFLL )); append(S1); return *this; } Ztring& Ztring::From_CC4 (const int32u S) { std::string S1; S1.append(1, (char)((S&0xFF000000)>>24)); S1.append(1, (char)((S&0x00FF0000)>>16)); S1.append(1, (char)((S&0x0000FF00)>> 8)); S1.append(1, (char)((S&0x000000FF) )); From_Local(S1.c_str()); // Validity Test if ( size()==4 || (size()==3 && (S&0x000000FF)==0x00000000 && at(0)>=0x20 && at(1)>=0x20 && at(2)>=0x20) || (size()==2 && (S&0x0000FFFF)==0x00000000 && at(0)>=0x20 && at(1)>=0x20) || (size()==1 && (S&0x00FFFFFF)==0x00000000 && at(0)>=0x20)) return *this; // Not valid, using 0x as fallback clear(); append(__T("0x")); append(Ztring().From_CC1((int8u)((S&0xFF000000)>>24))); append(Ztring().From_CC1((int8u)((S&0x00FF0000)>>16))); append(Ztring().From_CC1((int8u)((S&0x0000FF00)>> 8))); append(Ztring().From_CC1((int8u)((S&0x000000FF) ))); return *this; } Ztring& Ztring::From_CC3 (const int32u S) { std::string S1; S1.append(1, (char)((S&0x00FF0000)>>16)); S1.append(1, (char)((S&0x0000FF00)>> 8)); S1.append(1, (char)((S&0x000000FF)>> 0)); From_Local(S1.c_str()); //Test if (empty()) assign(__T("(empty)")); return *this; } Ztring& Ztring::From_CC2 (const int16u S) { clear(); Ztring Pos1; Pos1.From_Number(S, 16); resize(4-Pos1.size(), __T('0')); append(Pos1); MakeUpperCase(); return *this; } Ztring& Ztring::From_CC1 (const int8u S) { clear(); Ztring Pos1; Pos1.From_Number(S, 16); resize(2-Pos1.size(), __T('0')); append(Pos1); MakeUpperCase(); return *this; } Ztring& Ztring::From_Number (const int8s I, int8u Radix) { #if defined(STREAM_MISSING) if (Radix==0) { clear(); return *this; } Char* C1=new Char[33]; #ifdef __MINGW32__ _itot (I, C1, Radix); #else _tnprintf(C1, 32, Radix==10?__T("%d"):(Radix==16?__T("%x"):(Radix==8?__T("%o"):__T(""))), I); #endif assign (C1); delete[] C1; //C1=NULL; #else toStringStream Stream; #ifdef UNICODE Stream << setbase(Radix) << I; #else //UNICODE Stream << setbase(Radix) << (size_t)I; //On linux (at least), (un)signed char is detected as a char #endif //UNICODE assign(Stream.str()); #endif MakeUpperCase(); return *this; } Ztring& Ztring::From_Number (const int8u I, int8u Radix) { #if defined(STREAM_MISSING) if (Radix==0) { clear(); return *this; } Char* C1=new Char[33]; #ifdef __MINGW32__ _ultot (I, C1, Radix); #else _tnprintf(C1, 32, Radix==10?__T("%d"):(Radix==16?__T("%x"):(Radix==8?__T("%o"):__T(""))), I); #endif assign (C1); delete[] C1; //C1=NULL; #else if (Radix==2) { clear(); for (int8u Pos=0; Pos<8; Pos++) { if (I<(((int8u)1)<0) && find(__T('.'))!=string::npos) { while (size()>0 && ((*this)[size()-1]==__T('0'))) resize(size()-1); if (size()>0 && (*this)[size()-1]==__T('.')) resize(size()-1); } return *this; } Ztring& Ztring::From_Number (const float64 F, int8u Precision, ztring_t Options) { #if defined(STREAM_MISSING) Char C1[100]; _tnprintf (C1, 99, (Ztring(__T("%."))+Ztring::ToZtring(Precision)+__T("f")).c_str(), F); assign(C1); #else toStringStream Stream; Stream << setprecision(Precision) << fixed << F; assign(Stream.str()); #if defined(__BORLANDC__) FindAndReplace(__T(","), __T(".")); //Borland C++ Builder 2010+Windows Seven put a comma for istringstream, but does not support comma for ostringstream #endif #endif if ((Options & Ztring_NoZero && size()>0) && find(__T('.'))!=string::npos) { while (size()>0 && ((*this)[size()-1]==__T('0'))) resize(size()-1); if (size()>0 && (*this)[size()-1]==__T('.')) resize(size()-1); } return *this; } Ztring& Ztring::From_Number (const float80 F, int8u Precision, ztring_t Options) { #if defined(STREAM_MISSING) Char C1[100]; _tnprintf (C1, 99, (Ztring(__T("%."))+Ztring::ToZtring(Precision)+__T("f")).c_str(), F); assign(C1); #else toStringStream Stream; Stream << setprecision(Precision) << fixed << F; assign(Stream.str()); #if defined(__BORLANDC__) FindAndReplace(__T(","), __T(".")); //Borland C++ Builder 2010+Windows Seven put a comma for istringstream, but does not support comma for ostringstream #endif #endif if ((Options & Ztring_NoZero && size()>0) && find(__T('.'))!=string::npos) { while (size()>0 && ((*this)[size()-1]==__T('0'))) resize(size()-1); if (size()>0 && (*this)[size()-1]==__T('.')) resize(size()-1); } return *this; } #ifdef SIZE_T_IS_LONG Ztring& Ztring::From_Number (const size_t I, int8u Radix) { #if defined(STREAM_MISSING) Char C1[100]; _tnprintf(C1, 64, Radix==10?__T("%zu"):(Radix==16?__T("%zx"):(Radix==8?__T("%zo"):__T(""))), I); assign(C1); #else toStringStream Stream; Stream << setbase(Radix) << I; assign(Stream.str()); #if defined(__BORLANDC__) FindAndReplace(__T(","), __T(".")); //Borland C++ Builder 2010+Windows Seven put a comma for istringstream, but does not support comma for ostringstream #endif #endif MakeUpperCase(); return *this; } #endif //SIZE_T_IS_LONG Ztring& Ztring::From_BCD (const int8u I) { #if defined(STREAM_MISSING) clear(); append(1, __T('0')+I/0x10); append(1, __T('0')+I%0x10); #else toStringStream Stream; Stream << I/0x10; Stream << I%0x10; assign(Stream.str()); #endif return *this; } //--------------------------------------------------------------------------- Ztring& Ztring::Duration_From_Milliseconds (const int64s Value_) { int64s Value=Value_; bool Negative=false; if (Value<0) { Value=-Value; Negative=true; } int64u HH=(int8u)(Value/1000/60/60); int64u MM=Value/1000/60 -((HH*60)); int64u Stream=Value/1000 -((HH*60+MM)*60); int64u MS=Value -((HH*60+MM)*60+Stream)*1000; Ztring DateT; Ztring Date; DateT.From_Number(HH); if (DateT.size()<2){DateT=Ztring(__T("0"))+DateT;} Date+=DateT; Date+=__T(":"); DateT.From_Number(MM); if (DateT.size()<2){DateT=Ztring(__T("0"))+DateT;} Date+=DateT; Date+=__T(":"); DateT.From_Number(Stream); if (DateT.size()<2){DateT=Ztring(__T("0"))+DateT;} Date+=DateT; Date+=__T("."); DateT.From_Number(MS); if (DateT.size()<2){DateT=Ztring(__T("00"))+DateT;} else if (DateT.size()<3){DateT=Ztring(__T("0"))+DateT;} Date+=DateT; if (Negative) { assign(__T("-")); append(Date); } else assign (Date.c_str()); return *this; } //--------------------------------------------------------------------------- Ztring& Ztring::Duration_From_Milliseconds (const int64u Value) { int64u HH=(int8u)(Value/1000/60/60); int64u MM=Value/1000/60 -((HH*60)); int64u Stream=Value/1000 -((HH*60+MM)*60); int64u MS=Value -((HH*60+MM)*60+Stream)*1000; Ztring DateT; Ztring Date; DateT.From_Number(HH); if (DateT.size()<2){DateT=Ztring(__T("0"))+DateT;} Date+=DateT; Date+=__T(":"); DateT.From_Number(MM); if (DateT.size()<2){DateT=Ztring(__T("0"))+DateT;} Date+=DateT; Date+=__T(":"); DateT.From_Number(Stream); if (DateT.size()<2){DateT=Ztring(__T("0"))+DateT;} Date+=DateT; Date+=__T("."); DateT.From_Number(MS); if (DateT.size()<2){DateT=Ztring(__T("00"))+DateT;} else if (DateT.size()<3){DateT=Ztring(__T("0"))+DateT;} Date+=DateT; assign (Date.c_str()); return *this; } Ztring& Ztring::Date_From_Milliseconds_1601 (const int64u Value) { if (Value>=11644473600000LL) //Values <1970 are not supported { Date_From_Seconds_1970((int32u)((Value-11644473600000LL)/1000)); append(__T(".")); Ztring Milliseconds; Milliseconds.From_Number(Value%1000); while (Milliseconds.size()<3) Milliseconds+=__T('0'); append(Milliseconds); } else clear(); //Not supported return *this; } Ztring& Ztring::Date_From_Seconds_1601 (const int64u Value) { return Date_From_Seconds_1970(((int64s)Value)-11644473600LL); } Ztring& Ztring::Date_From_Seconds_1900 (const int32u Value) { if (Value>2208988800) return Date_From_Seconds_1970(((int64s)Value)-2208988800); else return Date_From_Seconds_1970(((int64s)Value)+0x100000000LL-2208988800); //Value is considering to loop e.g. NTP value } Ztring& Ztring::Date_From_Seconds_1900 (const int64s Value) { return Date_From_Seconds_1970(Value-2208988800); } Ztring& Ztring::Date_From_Seconds_1904 (const int32u Value) { return Date_From_Seconds_1970(((int64s)Value)-2082844800); } Ztring& Ztring::Date_From_Seconds_1904 (const int64u Value) { return Date_From_Seconds_1970(((int64s)Value)-2082844800); } Ztring& Ztring::Date_From_Seconds_1904 (const int64s Value) { return Date_From_Seconds_1970(Value-2082844800); } Ztring& Ztring::Date_From_Seconds_1970 (const int32u Value) { return Date_From_Seconds_1970((int64s)Value); } Ztring& Ztring::Date_From_Seconds_1970 (const int32s Value) { return Date_From_Seconds_1970((int64s)Value); } Ztring& Ztring::Date_From_Seconds_1970 (const int64s Value) { time_t Time=(time_t)Value; struct tm *Gmt=gmtime(&Time); if (!Gmt) { clear(); return *this; } Ztring DateT; Ztring Date=__T("UTC "); Date+=Ztring::ToZtring((Gmt->tm_year+1900)); Date+=__T("-"); DateT.From_Number(Gmt->tm_mon+1); if (DateT.size()<2){DateT=Ztring(__T("0"))+Ztring::ToZtring(Gmt->tm_mon+1);} Date+=DateT; Date+=__T("-"); DateT.From_Number(Gmt->tm_mday); if (DateT.size()<2){DateT=Ztring(__T("0"))+Ztring::ToZtring(Gmt->tm_mday);} Date+=DateT; Date+=__T(" "); DateT.From_Number(Gmt->tm_hour); if (DateT.size()<2){DateT=Ztring(__T("0"))+Ztring::ToZtring(Gmt->tm_hour);} Date+=DateT; Date+=__T(":"); DateT=Ztring::ToZtring(Gmt->tm_min); if (DateT.size()<2){DateT=Ztring(__T("0"))+Ztring::ToZtring(Gmt->tm_min);} Date+=DateT; Date+=__T(":"); DateT.From_Number(Gmt->tm_sec); if (DateT.size()<2){DateT=Ztring(__T("0"))+Ztring::ToZtring(Gmt->tm_sec);} Date+=DateT; assign (Date.c_str()); return *this; } Ztring& Ztring::Date_From_Seconds_1970_Local (const int32u Value) { time_t Time=(time_t)Value; struct tm *Gmt=localtime(&Time); Ztring DateT; Ztring Date; Date+=Ztring::ToZtring((Gmt->tm_year+1900)); Date+=__T("-"); DateT.From_Number(Gmt->tm_mon+1); if (DateT.size()<2){DateT=Ztring(__T("0"))+Ztring::ToZtring(Gmt->tm_mon+1);} Date+=DateT; Date+=__T("-"); DateT.From_Number(Gmt->tm_mday); if (DateT.size()<2){DateT=Ztring(__T("0"))+Ztring::ToZtring(Gmt->tm_mday);} Date+=DateT; Date+=__T(" "); DateT.From_Number(Gmt->tm_hour); if (DateT.size()<2){DateT=Ztring(__T("0"))+Ztring::ToZtring(Gmt->tm_hour);} Date+=DateT; Date+=__T(":"); DateT=Ztring::ToZtring(Gmt->tm_min); if (DateT.size()<2){DateT=Ztring(__T("0"))+Ztring::ToZtring(Gmt->tm_min);} Date+=DateT; Date+=__T(":"); DateT.From_Number(Gmt->tm_sec); if (DateT.size()<2){DateT=Ztring(__T("0"))+Ztring::ToZtring(Gmt->tm_sec);} Date+=DateT; assign (Date.c_str()); return *this; } Ztring& Ztring::Date_From_String (const char* Value, size_t Value_Size) { //Only the year if (Value_Size<10) { From_Local(Value, 0, Value_Size); return *this; } #ifdef ZENLIB_USEWX Ztring ToReturn=__T("UTC "); wxDateTime Date; Ztring DateS; DateS.From_Local(Value, Value_Size).c_str(); if (!DateS.empty() && DateS[DateS.size()-1]==__T('\n')) DateS.resize(DateS.size()-1); //Some strange formating : exactly 24 bytes (or 25 with 0x0A at the end) and Year is at the end if (DateS.size()==24 && DateS[23]>=__T('0') && DateS[23]<=__T('9') && DateS[21]>=__T('0') && DateS[21]<=__T('9') && DateS[19]==__T(' ')) Date.ParseFormat(DateS.c_str(), __T("%a %b %d %H:%M:%S %Y")); //ISO date else if (DateS.size()==10 && (DateS[4]<__T('0') || DateS[4]>__T('9')) && (DateS[7]<__T('0') || DateS[7]>__T('9'))) { DateS[4]=__T('-'); DateS[7]=__T('-'); ToReturn+=DateS; } //Default else Date.ParseDateTime(DateS.c_str()); if (ToReturn.size()<5) { ToReturn+=Date.FormatISODate(); ToReturn+=__T(" "); ToReturn+=Date.FormatISOTime(); } else ToReturn+=DateS; assign (ToReturn.c_str()); #else //ZENLIB_USEWX Ztring DateS; DateS.From_Local(Value, 0, Value_Size); //Unix style formating : exactly 24 bytes (or 25 with 0x0A at the end) and Year is at the end if ((DateS.size()==24 || (DateS.size()==25 && DateS[24]==__T('\n'))) && DateS[23]>=__T('0') && DateS[23]<=__T('9') && DateS[21]>=__T('0') && DateS[21]<=__T('9') && DateS[19]==__T(' ')) { clear(); append(1, DateS[20]); append(1, DateS[21]); append(1, DateS[22]); append(1, DateS[23]); append(1, __T('-')); if (DateS[4]==__T('J') && DateS[5]==__T('a') && DateS[6]==__T('n') && DateS[7]==__T(' ')) { append(1, __T('0')); append(1, __T('1')); } else if (DateS[4]==__T('F') && DateS[5]==__T('e') && DateS[6]==__T('b') && DateS[7]==__T(' ')) { append(1, __T('0')); append(1, __T('2')); } else if (DateS[4]==__T('M') && DateS[5]==__T('a') && DateS[6]==__T('r') && DateS[7]==__T(' ')) { append(1, __T('0')); append(1, __T('3')); } else if (DateS[4]==__T('A') && DateS[5]==__T('p') && DateS[6]==__T('r') && DateS[7]==__T(' ')) { append(1, __T('0')); append(1, __T('4')); } else if (DateS[4]==__T('M') && DateS[5]==__T('a') && DateS[6]==__T('y') && DateS[7]==__T(' ')) { append(1, __T('0')); append(1, __T('5')); } else if (DateS[4]==__T('J') && DateS[5]==__T('u') && DateS[6]==__T('n') && DateS[7]==__T(' ')) { append(1, __T('0')); append(1, __T('6')); } else if (DateS[4]==__T('J') && DateS[5]==__T('u') && DateS[6]==__T('l') && DateS[7]==__T(' ')) { append(1, __T('0')); append(1, __T('7')); } else if (DateS[4]==__T('A') && DateS[5]==__T('u') && DateS[6]==__T('g') && DateS[7]==__T(' ')) { append(1, __T('0')); append(1, __T('8')); } else if (DateS[4]==__T('S') && DateS[5]==__T('e') && DateS[6]==__T('p') && DateS[7]==__T(' ')) { append(1, __T('0')); append(1, __T('9')); } else if (DateS[4]==__T('O') && DateS[5]==__T('c') && DateS[6]==__T('t') && DateS[7]==__T(' ')) { append(1, __T('1')); append(1, __T('0')); } else if (DateS[4]==__T('N') && DateS[5]==__T('o') && DateS[6]==__T('v') && DateS[7]==__T(' ')) { append(1, __T('1')); append(1, __T('1')); } else if (DateS[4]==__T('D') && DateS[5]==__T('e') && DateS[6]==__T('c') && DateS[7]==__T(' ')) { append(1, __T('1')); append(1, __T('2')); } else { assign(DateS); return *this; } append(1, __T('-')); append(1, DateS[8]); append(1, DateS[9]); append(1, __T(' ')); append(1, DateS[11]); append(1, DateS[12]); append(1, __T(':')); append(1, DateS[14]); append(1, DateS[15]); append(1, __T(':')); append(1, DateS[17]); append(1, DateS[18]); } else if (DateS.size()==20 && DateS[4]==__T('-') && DateS[7]==__T('-') && DateS[10]==__T('T') && DateS[13]==__T(':') && DateS[16]==__T(':') && DateS[19]==__T('Z')) { DateS.resize(19); DateS[10]=__T(' '); assign(__T("UTC ")); append(DateS); } else if (DateS.size()==23 && DateS[4]==__T('-') && DateS[7]==__T('-') && DateS[10]==__T(' ') && DateS[14]==__T(' ') && DateS[17]==__T(':') && DateS[20]==__T(':')) { DateS.erase(10, 4); //assign(__T("UTC ")); //Is not UTC append(DateS); } else From_Local(Value, 0, Value_Size); //Not implemented #endif //ZENLIB_USEWX return *this; } Ztring& Ztring::Date_From_Numbers (const int8u Year, const int8u Month, const int8u Day, const int8u Hour, const int8u Minute, const int8u Second) { Ztring DateT; Ztring Date=__T("UTC "); DateT.From_Number(Year); if (DateT.size()<2){DateT=Ztring(__T("200"))+Ztring::ToZtring(Year);}; if (DateT.size()<3){DateT=Ztring(__T("20"))+Ztring::ToZtring(Year);} Date+=DateT; Date+=__T("-"); DateT.From_Number(Month); if (DateT.size()<2){DateT=Ztring(__T("0"))+Ztring::ToZtring(Month);} Date+=DateT; Date+=__T("-"); DateT.From_Number(Day); if (DateT.size()<2){DateT=Ztring(__T("0"))+Ztring::ToZtring(Day);} Date+=DateT; Date+=__T(" "); DateT.From_Number(Hour); if (DateT.size()<2){DateT=Ztring(__T("0"))+Ztring::ToZtring(Hour);} Date+=DateT; Date+=__T(":"); DateT=Ztring::ToZtring(Minute); if (DateT.size()<2){DateT=Ztring(__T("0"))+Ztring::ToZtring(Minute);} Date+=DateT; Date+=__T(":"); DateT.From_Number(Second); if (DateT.size()<2){DateT=Ztring(__T("0"))+Ztring::ToZtring(Second);} Date+=DateT; assign (Date.c_str()); return *this; } #ifndef WSTRING_MISSING //--------------------------------------------------------------------------- std::wstring Ztring::To_Unicode () const { #ifdef _UNICODE return c_str(); #else //_UNICODE #ifdef ZENLIB_USEWX return wxConvCurrent->cMB2WC(c_str()).data(); #else //ZENLIB_USEWX return std::wstring(); //Not implemented #endif //ZENLIB_USEWX #endif //_UNICODE } #endif //WSTRING_MISSING std::string Ztring::To_UTF8 () const { #ifdef _UNICODE //Correction thanks to Andrew Jang // Don't use WideCharToMultiByte(), some characters are not well converted std::string ToReturn; ToReturn.reserve(size()); // more efficient const wchar_t* Z=c_str(); while (*Z) { int32u wc; // must be unsigned. #if defined(_MSC_VER) #pragma warning(push) #pragma warning(disable:4127) #endif //defined(_MSC_VER) if (sizeof(wchar_t) == 2) #if defined(_MSC_VER) #pragma warning(pop) #endif //defined(_MSC_VER) { if (((*Z) & 0xFC00) == 0xD800) { //UTF-16 wc =( (((int16u) *Z) & 0x3FF) + 0x40) << 10; Z++; wc |= (((int16u) *Z) & 0x3FF); } else wc = (int16u) *Z; // avoid a cast problem if wchar_t is signed. } else wc = *Z; int count; // refer to http://en.wikipedia.org/wiki/UTF-8#Description if (wc < 0x80) count = 1; else if (wc < 0x800) count = 2; else if (wc < 0x10000) count = 3; else if (wc < 0x200000) count = 4; else if (wc < 0x4000000) count = 5; else if (wc <= 0x7fffffff) count = 6; else break; // bad character int64u utfbuf = 0; // 8 bytes char* utf8chars = (char*) &utfbuf; switch (count) { case 6: utf8chars[5] = 0x80 | (wc & 0x3f); wc = (wc >> 6) | 0x4000000; case 5: utf8chars[4] = 0x80 | (wc & 0x3f); wc = (wc >> 6) | 0x200000; case 4: utf8chars[3] = 0x80 | (wc & 0x3f); wc = (wc >> 6) | 0x10000; case 3: utf8chars[2] = 0x80 | (wc & 0x3f); wc = (wc >> 6) | 0x800; case 2: utf8chars[1] = 0x80 | (wc & 0x3f); wc = (wc >> 6) | 0xc0; case 1: utf8chars[0] = (char) wc; } ToReturn += utf8chars; ++Z; } return ToReturn; #else #ifdef ZENLIB_USEWX return wxConvUTF8.cWC2MB(wxConvCurrent->cMB2WC(c_str())).data(); #else //ZENLIB_USEWX return c_str(); //Not implemented #endif //ZENLIB_USEWX #endif } std::string Ztring::To_Local () const { #ifdef _UNICODE #ifdef ZENLIB_USEWX wxCharBuffer C=wxConvCurrent->cWC2MB(c_str()); if (C.data()) return C.data(); else return std::string(); #else //ZENLIB_USEWX #ifdef WINDOWS int Size=WideCharToMultiByte(CP_ACP, 0, c_str(), -1, NULL, 0, NULL, NULL); if (Size!=0) { char* AnsiString=new char[Size+1]; WideCharToMultiByte(CP_ACP, 0, c_str(), -1, AnsiString, Size, NULL, NULL); AnsiString[Size]='\0'; std::string ToReturn(AnsiString); delete[] AnsiString; //AnsiString=NULL; return ToReturn; } else return std::string(); #else //WINDOWS if (empty()) return std::string(); size_t Size=wcstombs(NULL, c_str(), 0); if (Size!=0 && Size!=(size_t)-1) { char* AnsiString=new char[Size+1]; Size=wcstombs(AnsiString, c_str(), Size); if (Size!=0 && Size!=(size_t)-1) { AnsiString[Size]='\0'; std::string ToReturn(AnsiString); delete[] AnsiString; //AnsiString=NULL; return ToReturn; } //Failed delete[] AnsiString; //AnsiString=NULL; } //Trying with bad chars char* Result=new char[MB_CUR_MAX]; std::string AnsiString; for (size_t Pos=0; Pos=0) AnsiString.append(Result, Result_Size); else AnsiString+='?'; } delete[] Result; //Result=NULL; return AnsiString; #endif #endif //ZENLIB_USEWX #else return c_str(); #endif } //--------------------------------------------------------------------------- int128u Ztring::To_UUID () const { if (size()!=36) return 0; Ztring Temp=*this; for (size_t Pos=0; Pos<36; Pos++) { if ((Temp[Pos]< __T('0') || Temp[Pos]> __T('9')) && (Temp[Pos]< __T('A') || Temp[Pos]> __T('F')) && (Temp[Pos]< __T('a') || Temp[Pos]> __T('f'))) return 0; if (Temp[Pos]>=__T('A') && Temp[Pos]<=__T('F')) { Temp[Pos]-=__T('A'); Temp[Pos]+=__T('9')+1; } if (Temp[Pos]>=__T('a') && Temp[Pos]<=__T('f')) { Temp[Pos]-=__T('a'); Temp[Pos]+=__T('9')+1; } switch(Pos) { case 7 : case 12 : case 17 : case 22 : if (at(Pos+1)!=__T('-')) return 0; Pos++; //Skipping dash in the test } } int128u I; I.hi=((int64u)((int8u)(Temp[ 0]-'0'))<<60) | ((int64u)((int8u)(Temp[ 1]-'0'))<<56) | ((int64u)((int8u)(Temp[ 2]-'0'))<<52) | ((int64u)((int8u)(Temp[ 3]-'0'))<<48) | ((int64u)((int8u)(Temp[ 4]-'0'))<<44) | ((int64u)((int8u)(Temp[ 5]-'0'))<<40) | ((int64u)((int8u)(Temp[ 6]-'0'))<<36) | ((int64u)((int8u)(Temp[ 7]-'0'))<<32) | ((int64u)((int8u)(Temp[ 9]-'0'))<<28) | ((int64u)((int8u)(Temp[10]-'0'))<<24) | ((int64u)((int8u)(Temp[11]-'0'))<<20) | ((int64u)((int8u)(Temp[12]-'0'))<<16) | ((int64u)((int8u)(Temp[14]-'0'))<<12) | ((int64u)((int8u)(Temp[15]-'0'))<< 8) | ((int64u)((int8u)(Temp[16]-'0'))<< 4) | ((int64u)((int8u)(Temp[17]-'0')) ); I.lo=((int64u)((int8u)(Temp[19]-'0'))<<60) | ((int64u)((int8u)(Temp[20]-'0'))<<56) | ((int64u)((int8u)(Temp[21]-'0'))<<52) | ((int64u)((int8u)(Temp[22]-'0'))<<48) | ((int64u)((int8u)(Temp[24]-'0'))<<44) | ((int64u)((int8u)(Temp[25]-'0'))<<40) | ((int64u)((int8u)(Temp[26]-'0'))<<36) | ((int64u)((int8u)(Temp[27]-'0'))<<32) | ((int64u)((int8u)(Temp[28]-'0'))<<28) | ((int64u)((int8u)(Temp[29]-'0'))<<24) | ((int64u)((int8u)(Temp[30]-'0'))<<20) | ((int64u)((int8u)(Temp[31]-'0'))<<16) | ((int64u)((int8u)(Temp[32]-'0'))<<12) | ((int64u)((int8u)(Temp[33]-'0'))<< 8) | ((int64u)((int8u)(Temp[34]-'0'))<< 4) | ((int64u)((int8u)(Temp[35]-'0')) ); return I; } //--------------------------------------------------------------------------- int32u Ztring::To_CC4 () const { int32u I; I =((int32u)((int8u)at(0))<<24) | ((int32u)((int8u)at(1))<<16) | ((int32u)((int8u)at(2))<< 8) | ((int32u)((int8u)at(3)) ); return I; } //--------------------------------------------------------------------------- //Operateur ToInt int8s Ztring::To_int8s (int8u Radix, ztring_t Options) const { //Integrity if (empty()) return 0; //Conversion int I; #if defined(STREAM_MISSING) #ifdef __MINGW32__ I=_ttoi(c_str()); #elif defined(UNICODE) std::string S=To_UTF8(); I=atoi(S.c_str()); #else //UNICODE I=atoi(c_str()); #endif //UNICODE #else tStringStream Stream(*this); Stream >> setbase(Radix) >> I; if (Stream.fail()) return 0; #endif //Rounded if (Options==Ztring_Rounded && find(__T("."))!=Error) { float80 F=To_float80(); F-=I; if (F>=0.5) return (int8s)I+1; } return (int8s)I; } //--------------------------------------------------------------------------- //Operateur ToInt int8u Ztring::To_int8u (int8u Radix, ztring_t Options) const { //Integrity if (empty()) return 0; //Conversion unsigned int I; #if defined(STREAM_MISSING) #ifdef __MINGW32__ I=_ttoi64(c_str()); //TODO : I>0x7FFFFFFF - Replaced by i64 version to support, but not good #elif defined(UNICODE) std::string S=To_UTF8(); I=atoi(S.c_str()); #else //defined(UNICODE) I=atoi(c_str()); #endif //defined(UNICODE) #else tStringStream Stream(*this); Stream >> setbase(Radix) >> I; if (Stream.fail()) return 0; #endif //Rounded if (Options==Ztring_Rounded && find(__T("."))!=std::string::npos) { float32 F=To_float32(); F-=I; if (F>=0.5) return (int8u)I+1; } return (int8u)I; } //--------------------------------------------------------------------------- //Operateur ToInt int16s Ztring::To_int16s (int8u Radix, ztring_t Options) const { //Integrity if (empty()) return 0; //Conversion int I; #if defined(STREAM_MISSING) #ifdef __MINGW32__ I=_ttoi(c_str()); #elif defined(UNICODE) std::string S=To_UTF8(); I=atoi(S.c_str()); #else //defined(UNICODE) I=atoi(c_str()); #endif //defined(UNICODE) #else tStringStream Stream(*this); Stream >> setbase(Radix) >> I; if (Stream.fail()) return 0; #endif //Rounded if (Options==Ztring_Rounded && find(__T("."))!=Error) { float80 F=To_float80(); F-=I; if (F>=0.5) return (int16s)I+1; } return (int16s)I; } //--------------------------------------------------------------------------- //Operateur ToInt int16u Ztring::To_int16u (int8u Radix, ztring_t Options) const { //Integrity if (empty()) return 0; //Conversion unsigned int I; #if defined(STREAM_MISSING) #ifdef __MINGW32__ I=_ttoi64(c_str()); //TODO : I>0x7FFFFFFF - Replaced by i64 version to support, but not good #elif defined(UNICODE) std::string S=To_UTF8(); I=atoi(S.c_str()); #else //defined(UNICODE) I=atoi(c_str()); #endif //defined(UNICODE) #else tStringStream Stream(*this); Stream >> setbase(Radix) >> I; if (Stream.fail()) return 0; #endif //Rounded if (Options==Ztring_Rounded && find(__T("."))!=std::string::npos) { float32 F=To_float32(); F-=I; if (F>=0.5) return (int16u)I+1; } return (int16u)I; } //--------------------------------------------------------------------------- //Operateur ToInt int32s Ztring::To_int32s (int8u Radix, ztring_t Options) const { //Integrity if (empty()) return 0; //Conversion int32s I; #if defined(STREAM_MISSING) #ifdef __MINGW32__ I=_ttoi(c_str()); #elif defined(UNICODE) std::string S=To_UTF8(); I=atol(S.c_str()); #else //defined(UNICODE) I=atol(c_str()); #endif //defined(UNICODE) #else tStringStream Stream(*this); Stream >> setbase(Radix) >> I; if (Stream.fail()) return 0; #endif //Rounded if (Options==Ztring_Rounded && find(__T("."))!=Error) { float80 F=To_float80(); F-=I; if (F>=0.5) return I+1; } return I; } //--------------------------------------------------------------------------- //Operateur ToInt int32u Ztring::To_int32u (int8u Radix, ztring_t Options) const { //Integrity if (empty()) return 0; //Conversion int32u I; #if defined(STREAM_MISSING) #ifdef __MINGW32__ I=_ttoi64(c_str()); //TODO : I>0x7FFFFFFF - Replaced by i64 version to support, but not good #elif defined(UNICODE) std::string S=To_UTF8(); I=atol(S.c_str()); #else //defined(UNICODE) I=atol(c_str()); #endif //defined(UNICODE) #else tStringStream Stream(*this); Stream >> setbase(Radix) >> I; if (Stream.fail()) return 0; #endif //Rounded if (Options==Ztring_Rounded && find(__T("."))!=std::string::npos) { float32 F=To_float32(); F-=I; if (F>=0.5) return I+1; } return I; } //--------------------------------------------------------------------------- //Operateur ToInt int64s Ztring::To_int64s (int8u Radix, ztring_t Options) const { //Integrity if (empty()) return 0; //Conversion int64s I; #if defined(STREAM_MISSING) #ifdef __MINGW32__ I=_ttoi64(c_str()); #elif defined(UNICODE) std::string S=To_UTF8(); I=atoll(S.c_str()); #else //defined(UNICODE) I=atoll(c_str()); #endif //defined(UNICODE) #else tStringStream Stream(*this); Stream >> setbase(Radix) >> I; if (Stream.fail()) return 0; #endif //Rounded if (Options==Ztring_Rounded && find(__T("."))!=std::string::npos) { float32 F=To_float32(); F-=I; if (F>0.5) return I+1; } return I; } //--------------------------------------------------------------------------- //Operateur ToInt int64u Ztring::To_int64u (int8u Radix, ztring_t Options) const { //Integrity if (empty()) return 0; //Conversion int64u I; #if defined(STREAM_MISSING) #ifdef __MINGW32__ I=_ttoi64(c_str()); //TODO : I>0x7FFFFFFFFFFFFFFF #elif defined(UNICODE) std::string S=To_UTF8(); I=atoll(S.c_str()); #else //defined(UNICODE) I=atoll(c_str()); #endif //defined(UNICODE) #else tStringStream Stream(*this); Stream >> setbase(Radix) >> I; if (Stream.fail()) return 0; #endif //Rounded if (Options==Ztring_Rounded && find(__T("."))!=std::string::npos) { float32 F=To_float32(); F-=I; if (F>=0.5) return I+1; } return I; } //--------------------------------------------------------------------------- int128u Ztring::To_int128u (int8u, ztring_t) const { if (size()!=32) return 0; Ztring Temp=*this; for (size_t Pos=0; Pos<32; Pos++) { if ((Temp[Pos]< __T('0') || Temp[Pos]> __T('9')) && (Temp[Pos]< __T('A') || Temp[Pos]> __T('F')) && (Temp[Pos]< __T('a') || Temp[Pos]> __T('f'))) return 0; if (Temp[Pos]>=__T('A') && Temp[Pos]<=__T('F')) { Temp[Pos]-=__T('A'); Temp[Pos]+=__T('9')+1; } if (Temp[Pos]>=__T('a') && Temp[Pos]<=__T('f')) { Temp[Pos]-=__T('a'); Temp[Pos]+=__T('9')+1; } } int128u I; I.hi=((int64u)((int8u)(Temp[ 0]-'0'))<<60) | ((int64u)((int8u)(Temp[ 1]-'0'))<<56) | ((int64u)((int8u)(Temp[ 2]-'0'))<<52) | ((int64u)((int8u)(Temp[ 3]-'0'))<<48) | ((int64u)((int8u)(Temp[ 4]-'0'))<<44) | ((int64u)((int8u)(Temp[ 5]-'0'))<<40) | ((int64u)((int8u)(Temp[ 6]-'0'))<<36) | ((int64u)((int8u)(Temp[ 7]-'0'))<<32) | ((int64u)((int8u)(Temp[ 8]-'0'))<<28) | ((int64u)((int8u)(Temp[ 9]-'0'))<<24) | ((int64u)((int8u)(Temp[10]-'0'))<<20) | ((int64u)((int8u)(Temp[11]-'0'))<<16) | ((int64u)((int8u)(Temp[12]-'0'))<<12) | ((int64u)((int8u)(Temp[13]-'0'))<< 8) | ((int64u)((int8u)(Temp[14]-'0'))<< 4) | ((int64u)((int8u)(Temp[15]-'0')) ); I.lo=((int64u)((int8u)(Temp[16]-'0'))<<60) | ((int64u)((int8u)(Temp[17]-'0'))<<56) | ((int64u)((int8u)(Temp[18]-'0'))<<52) | ((int64u)((int8u)(Temp[19]-'0'))<<48) | ((int64u)((int8u)(Temp[20]-'0'))<<44) | ((int64u)((int8u)(Temp[21]-'0'))<<40) | ((int64u)((int8u)(Temp[22]-'0'))<<36) | ((int64u)((int8u)(Temp[23]-'0'))<<32) | ((int64u)((int8u)(Temp[24]-'0'))<<28) | ((int64u)((int8u)(Temp[25]-'0'))<<24) | ((int64u)((int8u)(Temp[26]-'0'))<<20) | ((int64u)((int8u)(Temp[27]-'0'))<<16) | ((int64u)((int8u)(Temp[28]-'0'))<<12) | ((int64u)((int8u)(Temp[29]-'0'))<< 8) | ((int64u)((int8u)(Temp[30]-'0'))<< 4) | ((int64u)((int8u)(Temp[31]-'0')) ); return I; } //--------------------------------------------------------------------------- //Operateur ToFloat float32 Ztring::To_float32(ztring_t) const { //Integrity if (empty()) return 0; //Conversion #if defined(STREAM_MISSING) #ifdef UNICODE return (wcstod(c_str(),NULL)); #else return (strtod(c_str(),NULL)); #endif #else float32 F; tStringStream Stream(*this); Stream >> F; if (Stream.fail()) return 0; return F; #endif } //--------------------------------------------------------------------------- //Operateur ToFloat float64 Ztring::To_float64(ztring_t) const { //Integrity if (empty()) return 0; //Conversion #if defined(STREAM_MISSING) #ifdef UNICODE return (wcstod(c_str(),NULL)); //TODO verify no wcstold #else return (strtod(c_str(),NULL)); //TODO verify no strtold #endif #else float64 F; tStringStream Stream(*this); Stream >> F; if (Stream.fail()) return 0; return F; #endif } //--------------------------------------------------------------------------- //Operateur ToFloat float80 Ztring::To_float80(ztring_t) const { //Integrity if (empty()) return 0; //Conversion #if defined(STREAM_MISSING) #ifdef UNICODE return (wcstod(c_str(),NULL)); //TODO verify no wcstold #else return (strtod(c_str(),NULL)); //TODO verify no strtold #endif #else float80 F; tStringStream Stream(*this); Stream >> F; if (Stream.fail()) return 0; return F; #endif } //*************************************************************************** // Edition //*************************************************************************** //--------------------------------------------------------------------------- // Retourne une partie de la chaine Ztring Ztring::SubString (const tstring &Begin, const tstring &End, size_type Pos, ztring_t Options) const { //Recherche Debut size_type I_Debut=find(Begin, Pos); if (I_Debut==Error) return Ztring(); I_Debut+=Begin.size(); //gestion fin NULL if (End.empty()) return substr(I_Debut); //Recherche Fin size_type I_Fin=find(End, I_Debut); if (I_Fin==Error) { if (Options & Ztring_AddLastItem) return substr(I_Debut); else return Ztring(); } return substr(I_Debut, I_Fin-I_Debut); } //--------------------------------------------------------------------------- //FindAndReplace Ztring::size_type Ztring::FindAndReplace (const ZenLib::tstring &ToFind, const ZenLib::tstring &ReplaceBy, size_type Pos, ZenLib::ztring_t Options) { if (ToFind.empty()) return 0; size_type Count=0; size_type Middle=Pos; while (!(Count==1 && !(Options&Ztring_Recursive)) && (Middle=find(ToFind, Middle))!=npos) { replace(Middle, ToFind.length(), ReplaceBy); Middle += ReplaceBy.length(); Count++; } return Count; } //--------------------------------------------------------------------------- //test if it is a number bool Ztring::IsNumber() const { if (empty()) return false; bool OK=true; size_t Size=size(); for (size_t Pos=0; Pos__T('9')) { OK=false; break; } return OK; } //--------------------------------------------------------------------------- //Mise en minuscules Ztring &Ztring::MakeLowerCase() { transform(begin(), end(), begin(), (int(*)(int))tolower); //(int(*)(int)) is a patch for unix return *this; } //--------------------------------------------------------------------------- // Mise en majuscules Ztring &Ztring::MakeUpperCase() { transform(begin(), end(), begin(), (int(*)(int))toupper); //(int(*)(int)) is a patch for unix return *this; } //--------------------------------------------------------------------------- // Remove leading whitespaces from a string Ztring &Ztring::TrimLeft(Char ToTrim) { size_type First=0; while (First=")) return (Left>=Right); if (Comparator==__T(">")) return (Left> Right); if (Comparator==__T("!=")) return (Left!=Right); if (Comparator==__T("<>")) return (Left!=Right); return false; } //Case sensitive option if (!(Options & Ztring_CaseSensitive)) { //Need to copy strings and make it lowercase Ztring Left (c_str()); Ztring Right (ToCompare.c_str()); Left.MakeLowerCase(); Right.MakeLowerCase(); //string comparasion if (Comparator==__T("==")) return (Left==Right); if (Comparator==__T("IN")) {if (Left.find(Right)!=string::npos) return true; else return false;} if (Comparator==__T("<")) return (Left< Right); if (Comparator==__T("<=")) return (Left<=Right); if (Comparator==__T(">=")) return (Left>=Right); if (Comparator==__T(">")) return (Left> Right); if (Comparator==__T("!=")) return (Left!=Right); if (Comparator==__T("<>")) return (Left!=Right); return false; } else { //string comparasion if (Comparator==__T("==")) return (*this==ToCompare); if (Comparator==__T("IN")) {if (this->find(ToCompare)!=string::npos) return true; else return false;} if (Comparator==__T("<")) return (*this< ToCompare); if (Comparator==__T("<=")) return (*this<=ToCompare); if (Comparator==__T(">=")) return (*this>=ToCompare); if (Comparator==__T(">")) return (*this> ToCompare); if (Comparator==__T("!=")) return (*this!=ToCompare); if (Comparator==__T("<>")) return (*this!=ToCompare); return false; } } } //namespace ZenLib/Source/ZenLib/BitStream.h0000664000000000000000000002401312615631146015434 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a zlib-style license that can * be found in the License.txt file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Read a stream bit per bit // Can read up to 32 bits at once // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef ZenBitStreamH #define ZenBitStreamH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "ZenLib/Conf.h" //--------------------------------------------------------------------------- namespace ZenLib { #ifndef MIN #define MIN(a, b) (((a) < (b)) ? (a) : (b)) #endif class BitStream { public: BitStream () {Buffer=NULL; Buffer_Size=Buffer_Size_Init=Buffer_Size_BeforeLastCall=0; LastByte_Size=0; BufferUnderRun=true; BookMark=false;} BitStream (const int8u* Buffer_, size_t Size_) {Buffer=Buffer_; Buffer_Size=Buffer_Size_Init=Buffer_Size_BeforeLastCall=Size_*8; //Size is in bits LastByte_Size=0; BufferUnderRun=Buffer_Size?false:true; BookMark=false;} virtual ~BitStream () {}; virtual void Attach(const int8u* Buffer_, size_t Size_) { if (Buffer_==Buffer) return; //Nothing to do Buffer=Buffer_; Buffer_Size=Buffer_Size_Init=Buffer_Size_BeforeLastCall=Size_*8; //Size is in bits LastByte_Size=0; BufferUnderRun=Buffer_Size?false:true; BookMark=false; }; virtual int32u Get (size_t HowMany) { size_t ToReturn; static const int32u Mask[33]={ 0x00000000, 0x00000001, 0x00000003, 0x00000007, 0x0000000f, 0x0000001f, 0x0000003f, 0x0000007f, 0x000000ff, 0x000001ff, 0x000003ff, 0x000007ff, 0x00000fff, 0x00001fff, 0x00003fff, 0x00007fff, 0x0000ffff, 0x0001ffff, 0x0003ffff, 0x0007ffff, 0x000fffff, 0x001fffff, 0x003fffff, 0x007fffff, 0x00ffffff, 0x01ffffff, 0x03ffffff, 0x07ffffff, 0x0fffffff, 0x1fffffff, 0x3fffffff, 0x7fffffff, 0xffffffff, }; if (HowMany==0 || HowMany>32) return 0; if ((size_t)HowMany>Buffer_Size+LastByte_Size) { Buffer_Size=0; LastByte_Size=0; BufferUnderRun=true; return 0; } Buffer_Size_BeforeLastCall=Buffer_Size+LastByte_Size; if (HowMany<=LastByte_Size) { LastByte_Size-=HowMany; ToReturn=LastByte>>LastByte_Size; } else { size_t NewBits=HowMany-LastByte_Size; if (NewBits==32) ToReturn=0; else ToReturn=LastByte<>LastByte_Size)&Mask[NewBits]; } return (int32u)(ToReturn&Mask[HowMany]); }; bool GetB () { return Get(1)?true:false; } int8u Get1 (size_t HowMany) { return (int8u )Get(HowMany); } int16u Get2 (size_t HowMany) { return (int16u)Get(HowMany); } int32u Get4 (size_t HowMany) { return (int32u)Get(HowMany); } int64u Get8 (size_t HowMany) { if (HowMany>64) return 0; //Not supported size_t HowMany1, HowMany2; int64u Value1, Value2; if (HowMany>32) HowMany1=HowMany-32; else HowMany1=0; HowMany2=HowMany-HowMany1; Value1=Get(HowMany1); Value2=Get(HowMany2); if (BufferUnderRun) return 0; return Value1*0x100000000LL+Value2; } virtual void Skip (size_t HowMany) { if (HowMany==0) return; if (HowMany>32) //Algorithm is only for <=32 bits { do { Skip(32); HowMany-=32; } while(HowMany>32); if (HowMany) Skip(HowMany); return; } if ((size_t)HowMany>Buffer_Size+LastByte_Size) { Buffer_Size=0; LastByte_Size=0; BufferUnderRun=true; return; } Buffer_Size_BeforeLastCall=Buffer_Size+LastByte_Size; if (HowMany<=LastByte_Size) LastByte_Size-=HowMany; else { size_t NewBits=HowMany-LastByte_Size; switch ((NewBits-1)/8) { case 3 : NewBits-=8; Buffer++; Buffer_Size-=8; case 2 : NewBits-=8; Buffer++; Buffer_Size-=8; case 1 : NewBits-=8; Buffer++; Buffer_Size-=8; case 0 : LastByte=*Buffer; Buffer++; } LastByte_Size=MIN(8, Buffer_Size)-NewBits; Buffer_Size -=MIN(8, Buffer_Size); } }; void SkipB () { Skip(1); } void Skip1 (size_t HowMany) { Skip(HowMany); } void Skip2 (size_t HowMany) { Skip(HowMany); } void Skip4 (size_t HowMany) { Skip(HowMany); } void Skip8 (size_t HowMany) { if (HowMany>64) return; //Not supported size_t HowMany1, HowMany2; if (HowMany>32) HowMany1=HowMany-32; else HowMany1=0; HowMany2=HowMany-HowMany1; Skip(HowMany1); Skip(HowMany2); } int32u Peek(size_t HowMany) { BookMarkPos(true); int32u ToReturn=Get(HowMany); BookMarkPos(false); return ToReturn; } bool PeekB() { return Peek(1)?true:false; } int8u Peek1(size_t HowMany) { return (int8u )Peek(HowMany); } int16u Peek2(size_t HowMany) { return (int16u)Peek(HowMany); } int32u Peek4(size_t HowMany) { return (int32u)Peek(HowMany); } int32u Peek3(size_t HowMany) { return (int32u)Peek(HowMany); } int64u Peek8(size_t HowMany) { return (int64u)Peek(HowMany); } void BookMarkPos(bool ToSet) { if (ToSet) { BookMark=1; Buffer_BookMark=Buffer; Buffer_Size_BookMark=Buffer_Size; LastByte_BookMark=LastByte; LastByte_Size_BookMark=LastByte_Size; BufferUnderRun_BookMark=BufferUnderRun; } else { BookMark=0; Buffer=Buffer_BookMark; Buffer_Size=Buffer_Size_BookMark; LastByte=LastByte_BookMark; LastByte_Size=LastByte_Size_BookMark; BufferUnderRun=BufferUnderRun_BookMark; } }; virtual int32u Remain () //How many bits remain? { return (int32u)(Buffer_Size+LastByte_Size); }; virtual void Byte_Align() { Get(LastByte_Size); }; virtual size_t Offset_Get() { if (BufferUnderRun) return 0; return (Buffer_Size_Init-Buffer_Size)/8; }; virtual size_t BitOffset_Get() { if (BufferUnderRun) return 0; return LastByte_Size; }; virtual size_t OffsetBeforeLastCall_Get() { if (BufferUnderRun) return 0; return (Buffer_Size_Init-Buffer_Size_BeforeLastCall)/8; }; private : const int8u* Buffer; size_t Buffer_Size; size_t Buffer_Size_Init; size_t Buffer_Size_BeforeLastCall; size_t LastByte; size_t LastByte_Size; bool BufferUnderRun; bool BookMark; const int8u* Buffer_BookMark; size_t Buffer_Size_BookMark; size_t LastByte_BookMark; size_t LastByte_Size_BookMark; bool BufferUnderRun_BookMark; }; } //namespace ZenLib #endif ZenLib/Source/ZenLib/ZtringListList.h0000664000000000000000000001556012615631146016516 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a zlib-style license that can * be found in the License.txt file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // More methods for std::vector> // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef ZenLib_ZtringListListH #define ZenLib_ZtringListListH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "ZenLib/ZtringList.h" //--------------------------------------------------------------------------- namespace ZenLib { //*************************************************************************** /// @brief Vector of vectors of strings manipulation (based on std::vector>) //*************************************************************************** class ZtringListList : public std::vector { public : //Constructors/Destructor ZtringListList (); ZtringListList (const ZtringListList &Source); ZtringListList (const Ztring &Source); ZtringListList (const Char *Source); #ifdef _UNICODE ZtringListList (const char *Source); //convert a UTF-8 string into Unicode #endif //Operateurs bool operator == (const ZtringListList &Source) const; bool operator != (const ZtringListList &Source) const; ZtringListList &operator += (const ZtringListList &Source); ZtringListList &operator = (const ZtringListList &Source); ZtringList &operator () (size_type Pos0); ///< Same as [], but write a empty string if Pos doesn't exist yet Ztring &operator () (size_type Pos0, size_type Pos1); /// @brief Return [Pos][Pos1], Pos=First occurency of Pos0 in [xxx][0] Ztring &operator () (const Ztring &Pos0, size_type Pos1=1) {return operator() (Pos0, 0 , Pos1);}; /// @brief Return [Pos][Pos1], Pos=First occurency of Pos0 in [xxx][Pos0_1] Ztring &operator () (const Ztring &Pos0, size_type Pos0_1, size_type Pos1); //In/Out /// @brief Read all Ztring Read () const; /// @brief Read a vector of string Ztring Read (size_type Pos0) const; /// @brief Read a string const Ztring &Read (size_type Pos0, size_type Pos1) const; /// @brief Return [Pos][Pos1], Pos=First occurency of Pos0 in [xxx][0] const Ztring &Read (const Ztring &Pos0, size_type Pos1=1) const; /// @brief Return [Pos][Pos1], Pos=First occurency of Pos0 in [xxx][Pos0_1] const Ztring &Read (const Ztring &Pos0, size_type Pos0_1, size_type Pos1) const; /// @brief Return [Pos][Pos1], Pos=First occurency of Pos0 in [xxx][0], with default value const Ztring &Read (const Ztring &Pos0, const Ztring &Default, size_type Pos1=1) const; /// @brief Return [Pos][Pos1], Pos=First occurency of Pos0 in [xxx][Pos0_1], with default value const Ztring &Read (const Ztring &Pos0, const Ztring &Default, size_type Pos0_1, size_type Pos1) const; /// @brief Read all strings at position Pos1 Ztring Read1 (size_type Pos1) const; /// @brief Write all void Write (const Ztring &ToWrite); /// @brief Write a vector of string void Write (const ZtringList &ToWrite, size_type Pos0); /// @brief Write a vector of string void Write (const Ztring &ToWrite, size_type Pos0, size_type Pos1); /// @brief Add a vector of string void push_back (const ZtringList &ToAdd); /// @brief Add a vector of string (with separator is ZtringListList Separator) void push_back (const Ztring &ToAdd); /// @brief Add a vector of string (Char version) void push_back (const Char* ToAdd) {push_back(Ztring(ToAdd));}; /// @brief Insert a vector of string at position Pos0 void Insert (const ZtringList &ToInsert, size_type Pos0) {insert(begin()+Pos0, ToInsert);}; /// @brief Insert a string at all positions Pos1 void Insert1 (const Ztring &ToInsert, size_type Pos1); /// @brief Delete a vector of string at position Pos0 void Delete (size_type Pos0) {erase(begin()+Pos0);}; /// @brief Delete all vectors of string, with [xxx][Pos1] == ToFind void Delete (const Ztring &ToFind, size_type Pos1=0, const Ztring &Comparator=__T("=="), ztring_t Options=Ztring_Nothing); /// @brief Delete a string at all positions Pos1 void Delete1 (size_type Pos1); //Edition /// @brief Swap 2 positions void Swap (size_type Pos0_A, size_type Pos0_B); /// @brief Swap 2 columns for each line void Swap1 (size_type Pos1_A, size_type Pos1_B); /// @brief Sort void Sort (size_type Pos1, ztring_t Options=Ztring_Nothing); //Information /// @brief Find the first position of the string in the vector of vector, in a specific column size_type Find (const Ztring &ToFind, size_type Pos1=0, size_type Pos0Begin=0) const; /// @brief Find the first position of the string in the vector of vector, in a specific column, which is not empty size_type Find_Filled (size_type Pos1=0, size_type Pos0Begin=0) const; /// @brief Find the first position of the string in the vector of vector, in a specific column size_type Find (const Ztring &ToFind, size_type Pos1, size_type Pos0Begin, const Ztring &Comparator, ztring_t Options=Ztring_Nothing) const; /// @brief Return [xxx][Pos1Value] when founded the first position of the string in the vector of vector, in a specific column Ztring FindValue (const Ztring &ToFind, size_type Pos1Value=1, size_type Pos1=0, size_type Pos0Begin=0, const Ztring &Comparator=__T("=="), ztring_t Options=Ztring_Nothing) const; /// @brief Return a subsheet, with all lines with position of the string in the vector of vector, in a specific column ZtringListList SubSheet (const Ztring &ToFind, size_type Pos1=0, size_type Pos0Begin=0, const Ztring &Comparator=__T("=="), ztring_t Options=Ztring_Nothing) const; //Configuration /// @brief Set the Separator character void Separator_Set (size_type Level, const Ztring &NewSeparator); /// @brief Set the Quote character /// During Read() or Write() method, if Separator is in the sequence, we must quote it void Quote_Set (const Ztring &NewQuote); /// @brief Set the Maximum number of element to read /// During Read() or Write() method, if there is more elements, merge them with the last element void Max_Set (size_type Level, size_type Max); protected : Ztring Separator[2]; Ztring Quote; size_type Max[2]; }; } //namespace #endif ZenLib/Source/ZenLib/ZtringList.h0000664000000000000000000000675212615631146015665 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a zlib-style license that can * be found in the License.txt file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // More methods for std::vector // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef ZenLib_ZtringListH #define ZenLib_ZtringListH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "ZenLib/Ztring.h" #include //--------------------------------------------------------------------------- namespace ZenLib { //*************************************************************************** /// @brief Vector of strings manipulation (based on std::vector) //*************************************************************************** class ZtringList : public std::vector { public : //Constructors/destructor ZtringList (); ZtringList (const ZtringList &Source); ZtringList (const Ztring &Source); ZtringList (const Char *Source); #ifdef _UNICODE ZtringList (const char *Source); //convert a UTF-8 string into Unicode #endif //Operators bool operator == (const ZtringList &Source) const; bool operator != (const ZtringList &Source) const; ZtringList &operator += (const ZtringList &Source); ZtringList &operator = (const ZtringList &Source); Ztring &operator () (size_type Pos); ///< Same as [], but write a empty string if Pos doesn't exist yet //In/out Ztring Read () const; /// Read all const Ztring &Read (size_type Pos) const; /// Read a string void Write (const Ztring &ToWrite); /// Write all void Write (const Ztring &ToWrite, size_type Pos); /// Write a string /// @brief Insert a string at position Pos0 void Insert (const Ztring &ToInsert, size_type Pos0) {insert(begin()+Pos0, ToInsert);}; /// @brief Delete a string at position Pos0 void Delete (size_type Pos0) {erase(begin()+Pos0);}; //Edition /// @brief Swap 2 positions void Swap (size_type Pos0_A, size_type Pos0_B); /// @brief Sort void Sort (ztring_t Options=Ztring_Nothing); //Information /// @brief Find the position of the string in the vector size_type Find (const Ztring &ToFind, size_type PosBegin=0, const Ztring &Comparator=__T("=="), ztring_t Options=Ztring_Nothing) const; /// @brief Return the length of the longest string in the list. size_type MaxStringLength_Get (); //Configuration /// @brief Set the Separator character void Separator_Set (size_type Level, const Ztring &NewSeparator); /// @brief Set the Quote character /// During Read() or Write() method, if Separator is in the sequence, we must quote it void Quote_Set (const Ztring &NewQuote); /// @brief Set the Maximum number of element to read /// During Read() or Write() method, if there is more elements, merge them with the last element void Max_Set (size_type Level, size_type Max_New); protected : Ztring Separator[1]; Ztring Quote; size_type Max[1]; }; } //namespace #endif ZenLib/Source/ZenLib/int128u.h0000664000000000000000000001415612615631146014763 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a zlib-style license that can * be found in the License.txt file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // based on http://Tringi.Mx-3.cz // Only adapted for ZenLib: // - .hpp --> .h // - Namespace // - int128u alias // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #ifndef UINT128_HPP #define UINT128_HPP /* Name: uint128.hpp Copyright: Copyright (C) 2005, Jan Ringos Author: Jan Ringos, http://Tringi.Mx-3.cz Version: 1.1 */ #include #include #include #include "ZenLib/Conf.h" // CLASS namespace ZenLib { class uint128 { public://private: // Binary correct representation of signed 128bit integer int64u lo; int64u hi; protected: // Some global operator functions must be friends friend bool operator < (const uint128 &, const uint128 &) throw (); friend bool operator == (const uint128 &, const uint128 &) throw (); friend bool operator || (const uint128 &, const uint128 &) throw (); friend bool operator && (const uint128 &, const uint128 &) throw (); public: // Constructors inline uint128 () throw () : lo(0), hi(0) {}; inline uint128 (const uint128 & a) throw () : lo (a.lo), hi (a.hi) {}; inline uint128 (const int & a) throw () : lo (a), hi (0ull) {}; inline uint128 (const unsigned int & a) throw () : lo (a), hi (0ull) {}; inline uint128 (const int64u & a) throw () : lo (a), hi (0ull) {}; uint128 (const float a) throw (); uint128 (const double & a) throw (); uint128 (const long double & a) throw (); uint128 (const char * sz) throw (); // TODO: Consider creation of operator= to eliminate // the need of intermediate objects during assignments. private: // Special internal constructors uint128 (const int64u & a, const int64u & b) throw () : lo (a), hi (b) {}; public: // Operators bool operator ! () const throw (); uint128 operator - () const throw (); uint128 operator ~ () const throw (); uint128 & operator ++ (); uint128 & operator -- (); uint128 operator ++ (int); uint128 operator -- (int); uint128 & operator += (const uint128 & b) throw (); uint128 & operator *= (const uint128 & b) throw (); uint128 & operator >>= (unsigned int n) throw (); uint128 & operator <<= (unsigned int n) throw (); uint128 & operator |= (const uint128 & b) throw (); uint128 & operator &= (const uint128 & b) throw (); uint128 & operator ^= (const uint128 & b) throw (); // Inline simple operators inline const uint128 & operator + () const throw () { return *this; }; // Rest of inline operators inline uint128 & operator -= (const uint128 & b) throw () { return *this += (-b); }; inline uint128 & operator /= (const uint128 & b) throw () { uint128 dummy; *this = this->div (b, dummy); return *this; }; inline uint128 & operator %= (const uint128 & b) throw () { this->div (b, *this); return *this; }; // Common methods unsigned int toUint () const throw () { return (unsigned int) this->lo; }; int64u toUint64 () const throw () { return (int64u) this->lo; }; const char * toString (unsigned int radix = 10) const throw (); float toFloat () const throw (); double toDouble () const throw (); long double toLongDouble () const throw (); // Arithmetic methods uint128 div (const uint128 &, uint128 &) const throw (); // Bit operations bool bit (unsigned int n) const throw (); void bit (unsigned int n, bool val) throw (); } #ifdef __GNUC__ __attribute__ ((__aligned__ (16), __packed__)) #endif ; // GLOBAL OPERATORS bool operator < (const uint128 & a, const uint128 & b) throw (); bool operator == (const uint128 & a, const uint128 & b) throw (); bool operator || (const uint128 & a, const uint128 & b) throw (); bool operator && (const uint128 & a, const uint128 & b) throw (); // GLOBAL OPERATOR INLINES inline uint128 operator + (const uint128 & a, const uint128 & b) throw () { return uint128 (a) += b; }; inline uint128 operator - (const uint128 & a, const uint128 & b) throw () { return uint128 (a) -= b; }; inline uint128 operator * (const uint128 & a, const uint128 & b) throw () { return uint128 (a) *= b; }; inline uint128 operator / (const uint128 & a, const uint128 & b) throw () { return uint128 (a) /= b; }; inline uint128 operator % (const uint128 & a, const uint128 & b) throw () { return uint128 (a) %= b; }; inline uint128 operator >> (const uint128 & a, unsigned int n) throw () { return uint128 (a) >>= n; }; inline uint128 operator << (const uint128 & a, unsigned int n) throw () { return uint128 (a) <<= n; }; inline uint128 operator & (const uint128 & a, const uint128 & b) throw () { return uint128 (a) &= b; }; inline uint128 operator | (const uint128 & a, const uint128 & b) throw () { return uint128 (a) |= b; }; inline uint128 operator ^ (const uint128 & a, const uint128 & b) throw () { return uint128 (a) ^= b; }; inline bool operator > (const uint128 & a, const uint128 & b) throw () { return b < a; }; inline bool operator <= (const uint128 & a, const uint128 & b) throw () { return !(b < a); }; inline bool operator >= (const uint128 & a, const uint128 & b) throw () { return !(a < b); }; inline bool operator != (const uint128 & a, const uint128 & b) throw () { return !(a == b); }; // MISC typedef uint128 __uint128; typedef uint128 int128u; } //NameSpace #endif ZenLib/Source/ZenLib/File.cpp0000664000000000000000000011527212615631146014764 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a zlib-style license that can * be found in the License.txt file in the root of the source tree. */ //--------------------------------------------------------------------------- #include "ZenLib/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "ZenLib/Conf_Internal.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #ifdef ZENLIB_USEWX #include #include #include #else //ZENLIB_USEWX #ifdef ZENLIB_STANDARD #ifdef WINDOWS #else #include #endif #include #if !defined(WINDOWS) #include #endif //!defined(WINDOWS) #include using namespace std; #ifndef S_ISDIR #define S_ISDIR(mode) (((mode)&S_IFMT) == S_IFDIR) #endif #ifndef S_ISREG #define S_ISREG(mode) (((mode)&S_IFMT) == S_IFREG) #endif #elif defined WINDOWS #undef __TEXT #include #endif #endif //ZENLIB_USEWX #include "ZenLib/File.h" #include "ZenLib/OS_Utils.h" #include //--------------------------------------------------------------------------- namespace ZenLib { //--------------------------------------------------------------------------- // Debug #ifdef ZENLIB_DEBUG #include #include namespace ZenLib_File_Debug { FILE* F; std::string Debug; SYSTEMTIME st_In; void Debug_Open(bool Out) { F=fopen("C:\\Temp\\ZenLib_Debug.txt", "a+t"); Debug.clear(); SYSTEMTIME st; GetLocalTime( &st ); char Duration[100]; if (Out) { FILETIME ft_In; if (SystemTimeToFileTime(&st_In, &ft_In)) { FILETIME ft_Out; if (SystemTimeToFileTime(&st, &ft_Out)) { ULARGE_INTEGER UI_In; UI_In.HighPart=ft_In.dwHighDateTime; UI_In.LowPart=ft_In.dwLowDateTime; ULARGE_INTEGER UI_Out; UI_Out.HighPart=ft_Out.dwHighDateTime; UI_Out.LowPart=ft_Out.dwLowDateTime; ULARGE_INTEGER UI_Diff; UI_Diff.QuadPart=UI_Out.QuadPart-UI_In.QuadPart; FILETIME ft_Diff; ft_Diff.dwHighDateTime=UI_Diff.HighPart; ft_Diff.dwLowDateTime=UI_Diff.LowPart; SYSTEMTIME st_Diff; if (FileTimeToSystemTime(&ft_Diff, &st_Diff)) { sprintf(Duration, "%02hd:%02hd:%02hd.%03hd", st_Diff.wHour, st_Diff.wMinute, st_Diff.wSecond, st_Diff.wMilliseconds); } else strcpy(Duration, " "); } else strcpy(Duration, " "); } else strcpy(Duration, " "); } else { st_In=st; strcpy(Duration, " "); } fprintf(F," %02hd:%02hd:%02hd.%03hd %s", st.wHour, st.wMinute, st.wSecond, st.wMilliseconds, Duration); } void Debug_Close() { Debug += "\r\n"; fwrite(Debug.c_str(), Debug.size(), 1, F); \ fclose(F); } } using namespace ZenLib_File_Debug; #define ZENLIB_DEBUG1(_NAME,_TOAPPEND) \ Debug_Open(false); \ Debug+=", ";Debug+=_NAME; \ _TOAPPEND; \ Debug_Close(); #define ZENLIB_DEBUG2(_NAME,_TOAPPEND) \ Debug_Open(true); \ Debug+=", ";Debug+=_NAME; \ _TOAPPEND; \ Debug_Close(); #else // ZENLIB_DEBUG #define ZENLIB_DEBUG1(_NAME,_TOAPPEND) #define ZENLIB_DEBUG2(_NAME,_TOAPPEND) #endif // ZENLIB_DEBUG //*************************************************************************** // Constructor/Destructor //*************************************************************************** //--------------------------------------------------------------------------- File::File() { #ifdef ZENLIB_USEWX File_Handle=NULL; #else //ZENLIB_USEWX #ifdef ZENLIB_STANDARD File_Handle=NULL; #elif defined WINDOWS File_Handle=INVALID_HANDLE_VALUE; #endif #endif //ZENLIB_USEWX Position=(int64u)-1; Size=(int64u)-1; } File::File(Ztring File_Name, access_t Access) { #ifdef ZENLIB_USEWX File_Handle=NULL; #else //ZENLIB_USEWX #ifdef ZENLIB_STANDARD File_Handle=NULL; #elif defined WINDOWS File_Handle=INVALID_HANDLE_VALUE; #endif #endif //ZENLIB_USEWX Position=(int64u)-1; Size=(int64u)-1; Open(File_Name, Access); } //--------------------------------------------------------------------------- File::~File() { Close(); } //*************************************************************************** // Open/Close //*************************************************************************** //--------------------------------------------------------------------------- bool File::Open (const tstring &File_Name_, access_t Access) { Close(); ZENLIB_DEBUG1( "File Open", Debug+=", File_Name="; Debug +=Ztring(File_Name_).To_UTF8();) File_Name=File_Name_; #ifdef ZENLIB_USEWX File_Handle=(void*)new wxFile(); if (((wxFile*)File_Handle)->Open(File_Name.c_str(), (wxFile::OpenMode)Access)==0) { //Sometime the file is locked for few milliseconds, we try again later wxMilliSleep(1000); if (((wxFile*)File_Handle)->Open(File_Name.c_str(), (wxFile::OpenMode)Access)==0) //File is not openable return false; } return true; #else //ZENLIB_USEWX #ifdef ZENLIB_STANDARD /* int access; switch (Access) { case Access_Read : access=O_BINARY|O_RDONLY ; break; case Access_Write : access=O_BINARY|O_WRONLY|O_CREAT|O_TRUNC ; break; case Access_Read_Write : access=O_BINARY|O_RDWR |O_CREAT ; break; case Access_Write_Append : access=O_BINARY|O_WRONLY|O_CREAT|O_APPEND ; break; default : access=0 ; break; } #ifdef UNICODE File_Handle=open(File_Name.To_Local().c_str(), access); #else File_Handle=open(File_Name.c_str(), access); #endif //UNICODE return File_Handle!=-1; */ ios_base::openmode mode; switch (Access) { case Access_Read : mode=ios_base::binary|ios_base::in; break; case Access_Write : mode=ios_base::binary|ios_base::in|ios_base::out; break; case Access_Read_Write : mode=ios_base::binary|ios_base::in|ios_base::out; break; case Access_Write_Append : if (!Exists(File_Name)) mode=ios_base::binary|ios_base::out; else mode=ios_base::binary|ios_base::out|ios_base::app; break; default : ; } #ifdef UNICODE File_Handle=new fstream(File_Name.To_Local().c_str(), mode); #else File_Handle=new fstream(File_Name.c_str(), mode); #endif //UNICODE if (!((fstream*)File_Handle)->is_open()) { delete (fstream*)File_Handle; File_Handle=NULL; return false; } return true; #elif defined WINDOWS DWORD dwDesiredAccess, dwShareMode, dwCreationDisposition; switch (Access) { case Access_Read : dwDesiredAccess=FILE_READ_DATA; dwShareMode=FILE_SHARE_READ|FILE_SHARE_WRITE; dwCreationDisposition=OPEN_EXISTING; break; case Access_Write : dwDesiredAccess=GENERIC_WRITE; dwShareMode=0; dwCreationDisposition=OPEN_ALWAYS; break; case Access_Read_Write : dwDesiredAccess=FILE_READ_DATA|GENERIC_WRITE; dwShareMode=0; dwCreationDisposition=OPEN_ALWAYS; break; case Access_Write_Append : dwDesiredAccess=GENERIC_WRITE; dwShareMode=FILE_SHARE_READ|FILE_SHARE_WRITE; dwCreationDisposition=OPEN_ALWAYS; break; default : dwDesiredAccess=0; dwShareMode=0; dwCreationDisposition=0; break; } #ifdef UNICODE File_Handle=CreateFileW(File_Name.c_str(), dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, 0, NULL); #else File_Handle=CreateFile(File_Name.c_str(), dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, 0, NULL); #endif //UNICODE #if 0 //Disabled if (File_Handle==INVALID_HANDLE_VALUE) { //Sometimes the file is locked for few milliseconds, we try again later DWORD dw = GetLastError(); if (dw!=ERROR_FILE_NOT_FOUND) { /* char lpMsgBuf[1000]; FormatMessageA( FORMAT_MESSAGE_FROM_SYSTEM, NULL, dw, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), lpMsgBuf, 1000, NULL ); */ Sleep(1000); #ifdef UNICODE File_Handle=CreateFileW(File_Name.c_str(), dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, 0, NULL); #else File_Handle=CreateFile(File_Name.c_str(), dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, 0, NULL); #endif //UNICODE } } #endif //0 if (File_Handle==INVALID_HANDLE_VALUE) { ZENLIB_DEBUG2( "File Open", Debug+=", returns 0";) //File is not openable return false; } ZENLIB_DEBUG2( "File Open", Debug+=", returns 1";) //Append if (Access==Access_Write_Append) GoTo(0, FromEnd); return true; #endif #endif //ZENLIB_USEWX } //--------------------------------------------------------------------------- bool File::Create (const Ztring &File_Name_, bool OverWrite) { Close(); ZENLIB_DEBUG1( "File Create", Debug+=", File_Name="; Debug +=Ztring(File_Name_).To_UTF8();) File_Name=File_Name_; #ifdef ZENLIB_USEWX File_Handle=(void*)new wxFile(); if (((wxFile*)File_Handle)->Create(File_Name.c_str(), OverWrite)==0) { //Sometime the file is locked for few milliseconds, we try again later wxMilliSleep(3000); if (((wxFile*)File_Handle)->Create(File_Name.c_str(), OverWrite)==0) //File is not openable return false; } return true; #else //ZENLIB_USEWX #ifdef ZENLIB_STANDARD /* int access; switch (OverWrite) { case false : access=O_BINARY|O_CREAT|O_WRONLY|O_EXCL ; break; default : access=O_BINARY|O_CREAT|O_WRONLY|O_TRUNC; break; } #ifdef UNICODE File_Handle=open(File_Name.To_Local().c_str(), access); #else File_Handle=open(File_Name.c_str(), access); #endif //UNICODE return File_Handle!=-1; */ /*ios_base::openmode mode; switch (OverWrite) { //case false : mode= ; break; default : mode=0 ; break; }*/ ios_base::openmode access; switch (OverWrite) { case false : if (Exists(File_Name)) return false; default : access=ios_base::binary|ios_base::in|ios_base::out|ios_base::trunc; break; } #ifdef UNICODE File_Handle=new fstream(File_Name.To_Local().c_str(), access); #else File_Handle=new fstream(File_Name.c_str(), access); #endif //UNICODE return ((fstream*)File_Handle)->is_open(); #elif defined WINDOWS DWORD dwDesiredAccess, dwShareMode, dwCreationDisposition; switch (OverWrite) { case false : dwDesiredAccess=GENERIC_WRITE; dwShareMode=0; dwCreationDisposition=CREATE_NEW; break; default : dwDesiredAccess=GENERIC_WRITE; dwShareMode=0; dwCreationDisposition=CREATE_ALWAYS; break; } #ifdef UNICODE File_Handle=CreateFileW(File_Name.c_str(), dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, 0, NULL); #else File_Handle=CreateFile(File_Name.c_str(), dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, 0, NULL); #endif //UNICODE #if 0 //Disabled if (File_Handle==INVALID_HANDLE_VALUE) { //Sometime the file is locked for few milliseconds, we try again later Sleep(3000); #ifdef UNICODE File_Handle=CreateFileW(File_Name.c_str(), dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, 0, NULL); #else File_Handle=CreateFile(File_Name.c_str(), dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, 0, NULL); #endif //UNICODE } #endif //0 if (File_Handle==INVALID_HANDLE_VALUE) { ZENLIB_DEBUG2( "File Create", Debug+=", returns 0";) //File is not openable return false; } ZENLIB_DEBUG2( "File Create", Debug+=", returns 1";) return true; #endif #endif //ZENLIB_USEWX } //--------------------------------------------------------------------------- void File::Close () { #ifdef ZENLIB_DEBUG bool isOpen=false; #ifdef ZENLIB_USEWX if (File_Handle!=NULL) #else //ZENLIB_USEWX #ifdef ZENLIB_STANDARD if (File_Handle!=NULL) #elif defined WINDOWS if (File_Handle!=INVALID_HANDLE_VALUE) #endif #endif //ZENLIB_USEWX { ZENLIB_DEBUG1( "File Close", Debug+=", File_Name="; Debug+=Ztring(File_Name).To_UTF8();) isOpen=true; } #endif #ifdef ZENLIB_USEWX delete (wxFile*)File_Handle; File_Handle=NULL; #else //ZENLIB_USEWX #ifdef ZENLIB_STANDARD //close(File_Handle); File_Handle=-1; delete (fstream*)File_Handle; File_Handle=NULL; #elif defined WINDOWS CloseHandle(File_Handle); File_Handle=INVALID_HANDLE_VALUE; #endif #endif //ZENLIB_USEWX Position=(int64u)-1; Size=(int64u)-1; #ifdef ZENLIB_DEBUG if (isOpen) { ZENLIB_DEBUG2( "File Close", ) } #endif } //*************************************************************************** // Read/Write //*************************************************************************** //--------------------------------------------------------------------------- size_t File::Read (int8u* Buffer, size_t Buffer_Size_Max) { ZENLIB_DEBUG1( "File Read", Debug+=", File_Name="; Debug+=Ztring(File_Name).To_UTF8(); Debug+=", MaxSize="; Debug +=Ztring::ToZtring(Buffer_Size_Max).To_UTF8()) #ifdef ZENLIB_USEWX if (File_Handle==NULL) #else //ZENLIB_USEWX #ifdef ZENLIB_STANDARD if (File_Handle==NULL) #elif defined WINDOWS if (File_Handle==INVALID_HANDLE_VALUE) #endif #endif //ZENLIB_USEWX return 0; #ifdef ZENLIB_USEWX size_t ByteRead=((wxFile*)File_Handle)->Read(Buffer, Buffer_Size_Max); Position+=ByteRead; return ByteRead; #else //ZENLIB_USEWX #ifdef ZENLIB_STANDARD //return read((int)File_Handle, Buffer, Buffer_Size_Max); if (Position==(int64u)-1) Position_Get(); if (Size==(int64u)-1) Size_Get(); if (Position!=(int64u)-1 && Position+Buffer_Size_Max>Size) Buffer_Size_Max=(size_t)(Size-Position); //We don't want to enable eofbit (impossible to seek after) ((fstream*)File_Handle)->read((char*)Buffer, Buffer_Size_Max); size_t ByteRead=((fstream*)File_Handle)->gcount(); Position+=ByteRead; return ByteRead; #elif defined WINDOWS DWORD Buffer_Size; if (ReadFile(File_Handle, Buffer, (DWORD)Buffer_Size_Max, &Buffer_Size, NULL)) { Position+=Buffer_Size; ZENLIB_DEBUG2( "File Read", Debug+=", new position ";Debug+=Ztring::ToZtring(Position).To_UTF8();;Debug+=", returns ";Debug+=Ztring::ToZtring((int64u)Buffer_Size).To_UTF8();) return Buffer_Size; } else { ZENLIB_DEBUG2( "File Read", Debug+=", returns 0";) return 0; } #endif #endif //ZENLIB_USEWX } //--------------------------------------------------------------------------- size_t File::Write (const int8u* Buffer, size_t Buffer_Size) { #ifdef ZENLIB_USEWX if (File_Handle==NULL) #else //ZENLIB_USEWX #ifdef ZENLIB_STANDARD if (File_Handle==NULL) #elif defined WINDOWS if (File_Handle==INVALID_HANDLE_VALUE) #endif #endif //ZENLIB_USEWX return 0; #ifdef ZENLIB_USEWX return ((wxFile*)File_Handle)->Write(Buffer, Buffer_Size); #else //ZENLIB_USEWX #ifdef ZENLIB_STANDARD //return write(File_Handle, Buffer, Buffer_Size); ((fstream*)File_Handle)->write((char*)Buffer, Buffer_Size); if (((fstream*)File_Handle)->bad()) { Position=(int64u)-1; return 0; } else { if (Position!=(int64u)-1) Position+=Buffer_Size; return Buffer_Size; } #elif defined WINDOWS DWORD Buffer_Size_Written; if (WriteFile(File_Handle, Buffer, (DWORD)Buffer_Size, &Buffer_Size_Written, NULL)) { if (Position!=(int64u)-1) Position+=Buffer_Size_Written; return Buffer_Size_Written; } else { Position=(int64u)-1; return 0; } #endif #endif //ZENLIB_USEWX } //--------------------------------------------------------------------------- bool File::Truncate (int64u Offset) { if (File_Handle==NULL) return false; #ifdef ZENLIB_USEWX return false; //Not supported #else //ZENLIB_USEWX #ifdef ZENLIB_STANDARD #if defined(WINDOWS) return false; //Not supported #else //defined(WINDOWS) //Need to close the file, use truncate, reopen it if (Offset==(int64u)-1) Offset=Position_Get(); Ztring File_Name_Sav=File_Name; Close(); truncate(File_Name_Sav.To_Local().c_str(), Offset); if (!Open(File_Name_Sav, Access_Read_Write)) return false; GoTo(0, FromEnd); return true; #endif //!defined(WINDOWS) #elif defined WINDOWS if(Offset!=(int64u)-1 && Offset!=Position_Get()) if (!GoTo(Offset)) return false; SetEndOfFile(File_Handle); return true; #endif #endif //ZENLIB_USEWX } //--------------------------------------------------------------------------- size_t File::Write (const Ztring &ToWrite) { std::string AnsiString=ToWrite.To_UTF8(); return Write((const int8u*)AnsiString.c_str(), AnsiString.size()); } //*************************************************************************** // Moving //*************************************************************************** //--------------------------------------------------------------------------- bool File::GoTo (int64s Position_ToMove, move_t MoveMethod) { ZENLIB_DEBUG1( "File GoTo", Debug+=", File_Name="; Debug+=Ztring(File_Name).To_UTF8(); Debug+="File GoTo: "; Debug +=Ztring(File_Name).To_UTF8(); Debug+=", MoveMethod="; Debug +=Ztring::ToZtring(MoveMethod).To_UTF8(); Debug+=", MaxSize="; Debug +=Ztring::ToZtring(Position_ToMove).To_UTF8()) #ifdef ZENLIB_USEWX if (File_Handle==NULL) #else //ZENLIB_USEWX #ifdef ZENLIB_STANDARD if (File_Handle==NULL) #elif defined WINDOWS if (File_Handle==INVALID_HANDLE_VALUE) #endif #endif //ZENLIB_USEWX return false; Position=(int64u)-1; //Disabling memory #ifdef ZENLIB_USEWX return ((wxFile*)File_Handle)->Seek(Position, (wxSeekMode)MoveMethod)!=wxInvalidOffset; //move_t and wxSeekMode are same #else //ZENLIB_USEWX #ifdef ZENLIB_STANDARD /* int fromwhere; switch (MoveMethod) { case FromBegin : fromwhere=SEEK_SET; break; case FromCurrent : fromwhere=SEEK_CUR; break; case FromEnd : fromwhere=SEEK_END; break; default : fromwhere=SEEK_CUR; break; } return lseek(File_Handle, Position, fromwhere)!=-1; */ ios_base::seekdir dir; switch (MoveMethod) { case FromBegin : dir=ios_base::beg; break; case FromCurrent : dir=ios_base::cur; break; case FromEnd : dir=ios_base::end; break; default : dir=ios_base::beg; } ((fstream*)File_Handle)->seekg((streamoff)Position_ToMove, dir); return !((fstream*)File_Handle)->fail(); #elif defined WINDOWS LARGE_INTEGER GoTo; GoTo.QuadPart=Position_ToMove; BOOL i=SetFilePointerEx(File_Handle, GoTo, NULL, MoveMethod); #ifdef ZENLIB_DEBUG LARGE_INTEGER Temp; Temp.QuadPart=0; SetFilePointerEx(File_Handle, Temp, &Temp, FILE_CURRENT); ZENLIB_DEBUG2( "File GoTo", Debug+=", new position ";Debug+=Ztring::ToZtring(Temp.QuadPart).To_UTF8();Debug+=", returns ";Debug+=i?'1':'0';) #endif //ZENLIB_DEBUG return i?true:false; #endif #endif //ZENLIB_USEWX } //--------------------------------------------------------------------------- int64u File::Position_Get () { if (Position!=(int64u)-1) return Position; ZENLIB_DEBUG1( "File Position_Get", Debug+=", File_Name="; Debug+=Ztring(File_Name).To_UTF8()) #ifdef ZENLIB_USEWX if (File_Handle==NULL) #else //ZENLIB_USEWX #ifdef ZENLIB_STANDARD if (File_Handle==NULL) #elif defined WINDOWS if (File_Handle==INVALID_HANDLE_VALUE) #endif #endif //ZENLIB_USEWX return (int64u)-1; #ifdef ZENLIB_USEWX return (int64u)-1; #else //ZENLIB_USEWX #ifdef ZENLIB_STANDARD Position=((fstream*)File_Handle)->tellg(); return Position; #elif defined WINDOWS LARGE_INTEGER GoTo; GoTo.QuadPart=0; GoTo.LowPart=SetFilePointer(File_Handle, GoTo.LowPart, &GoTo.HighPart, FILE_CURRENT); Position=GoTo.QuadPart; ZENLIB_DEBUG2( "File GoTo", Debug+=", new position ";Debug+=Ztring::ToZtring(GoTo.QuadPart).To_UTF8();Debug+=", returns 1";) return Position; #endif #endif //ZENLIB_USEWX } //*************************************************************************** // Attributes //*************************************************************************** //--------------------------------------------------------------------------- int64u File::Size_Get() { #ifdef ZENLIB_USEWX if (File_Handle==NULL) #else //ZENLIB_USEWX #ifdef ZENLIB_STANDARD if (File_Handle==NULL) #elif defined WINDOWS if (File_Handle==INVALID_HANDLE_VALUE) #endif #endif //ZENLIB_USEWX return 0; #ifdef ZENLIB_USEWX return ((wxFile*)File_Handle)->Length(); #else //ZENLIB_USEWX #ifdef ZENLIB_STANDARD /* int CurrentPos=lseek(File_Handle, 0, SEEK_CUR); int64u File_Size; File_Size=lseek(File_Handle, 0, SEEK_END); lseek(File_Handle, CurrentPos, SEEK_SET); */ fstream::pos_type CurrentPos=((fstream*)File_Handle)->tellg(); if (CurrentPos!=(fstream::pos_type)-1) { ((fstream*)File_Handle)->seekg(0, ios_base::end); Size=((fstream*)File_Handle)->tellg(); ((fstream*)File_Handle)->seekg(CurrentPos); } else Size=(int64u)-1; #elif defined WINDOWS LARGE_INTEGER x = {0}; BOOL bRet = ::GetFileSizeEx(File_Handle, &x); if (bRet == FALSE) return (int64u)-1; Size=x.QuadPart; #endif return Size; #endif //ZENLIB_USEWX } //--------------------------------------------------------------------------- Ztring File::Created_Get() { #ifdef ZENLIB_USEWX if (File_Handle==NULL) #else //ZENLIB_USEWX #ifdef ZENLIB_STANDARD if (File_Handle==NULL) #elif defined WINDOWS if (File_Handle==INVALID_HANDLE_VALUE) #endif #endif //ZENLIB_USEWX return Ztring(); #ifdef ZENLIB_USEWX return __T(""); //Not implemented #else //ZENLIB_USEWX #ifdef ZENLIB_STANDARD return __T(""); //Not implemented #elif defined WINDOWS FILETIME TimeFT; if (GetFileTime(File_Handle, &TimeFT, NULL, NULL)) { int64u Time64=0x100000000ULL*TimeFT.dwHighDateTime+TimeFT.dwLowDateTime; Ztring Time; Time.Date_From_Milliseconds_1601(Time64/10000); return Time; } else return __T(""); //There was a problem #endif #endif //ZENLIB_USEWX } //--------------------------------------------------------------------------- Ztring File::Created_Local_Get() { #ifdef ZENLIB_USEWX if (File_Handle==NULL) #else //ZENLIB_USEWX #ifdef ZENLIB_STANDARD if (File_Handle==NULL) #elif defined WINDOWS if (File_Handle==INVALID_HANDLE_VALUE) #endif #endif //ZENLIB_USEWX return Ztring(); #ifdef ZENLIB_USEWX return __T(""); //Not implemented #else //ZENLIB_USEWX #ifdef ZENLIB_STANDARD return __T(""); //Not implemented #elif defined WINDOWS FILETIME TimeFT; if (GetFileTime(File_Handle, &TimeFT, NULL, NULL)) { int64u Time64=0x100000000ULL*TimeFT.dwHighDateTime+TimeFT.dwLowDateTime; TIME_ZONE_INFORMATION Info; DWORD Result=GetTimeZoneInformation(&Info); if (Result!=TIME_ZONE_ID_INVALID) { Time64-=((int64s)Info.Bias)*60*1000*1000*10; if (Result==TIME_ZONE_ID_DAYLIGHT) Time64-=((int64s)Info.DaylightBias)*60*1000*1000*10; else Time64-=((int64s)Info.StandardBias)*60*1000*1000*10; } Ztring Time; Time.Date_From_Milliseconds_1601(Time64/10000); Time.FindAndReplace(__T("UTC "), __T("")); return Time; } else return __T(""); //There was a problem #endif #endif //ZENLIB_USEWX } //--------------------------------------------------------------------------- Ztring File::Modified_Get() { #ifdef ZENLIB_USEWX if (File_Handle==NULL) #else //ZENLIB_USEWX #ifdef ZENLIB_STANDARD if (File_Handle==NULL) #elif defined WINDOWS if (File_Handle==INVALID_HANDLE_VALUE) #endif #endif //ZENLIB_USEWX return Ztring(); #ifdef ZENLIB_USEWX return __T(""); //Not implemented #else //ZENLIB_USEWX #ifdef ZENLIB_STANDARD struct stat Stat; int Result=stat(File_Name.To_Local().c_str(), &Stat); if (Result<0) return __T(""); //Error Ztring Time; Time.Date_From_Seconds_1970((int64s)Stat.st_mtime); return Time; #elif defined WINDOWS FILETIME TimeFT; if (GetFileTime(File_Handle, NULL, NULL, &TimeFT)) { int64u Time64=0x100000000ULL*TimeFT.dwHighDateTime+TimeFT.dwLowDateTime; Ztring Time; Time.Date_From_Milliseconds_1601(Time64/10000); return Time; } else return __T(""); //There was a problem #endif #endif //ZENLIB_USEWX } //--------------------------------------------------------------------------- Ztring File::Modified_Local_Get() { #ifdef ZENLIB_USEWX if (File_Handle==NULL) #else //ZENLIB_USEWX #ifdef ZENLIB_STANDARD if (File_Handle==NULL) #elif defined WINDOWS if (File_Handle==INVALID_HANDLE_VALUE) #endif #endif //ZENLIB_USEWX return Ztring(); #ifdef ZENLIB_USEWX return __T(""); //Not implemented #else //ZENLIB_USEWX #ifdef ZENLIB_STANDARD struct stat Stat; int Result=stat(File_Name.To_Local().c_str(), &Stat); if (Result<0) return __T(""); //Error Ztring Time; Time.Date_From_Seconds_1970_Local(Stat.st_mtime); return Time; #elif defined WINDOWS FILETIME TimeFT; if (GetFileTime(File_Handle, NULL, NULL, &TimeFT)) { int64u Time64=0x100000000ULL*TimeFT.dwHighDateTime+TimeFT.dwLowDateTime; //100-ns TIME_ZONE_INFORMATION Info; DWORD Result=GetTimeZoneInformation(&Info); if (Result!=TIME_ZONE_ID_INVALID) { Time64-=((int64s)Info.Bias)*60*1000*1000*10; if (Result==TIME_ZONE_ID_DAYLIGHT) Time64-=((int64s)Info.DaylightBias)*60*1000*1000*10; else Time64-=((int64s)Info.StandardBias)*60*1000*1000*10; } Ztring Time; Time.Date_From_Milliseconds_1601(Time64/10000); Time.FindAndReplace(__T("UTC "), __T("")); return Time; } else return __T(""); //There was a problem #endif #endif //ZENLIB_USEWX } //--------------------------------------------------------------------------- bool File::Opened_Get() { #ifdef ZENLIB_USEWX return File_Handle!=NULL; #else //ZENLIB_USEWX #ifdef ZENLIB_STANDARD //return File_Handle!=-1; return File_Handle!=NULL && ((fstream*)File_Handle)->is_open(); #elif defined WINDOWS return File_Handle!=INVALID_HANDLE_VALUE; #endif #endif //ZENLIB_USEWX } //*************************************************************************** // Helpers //*************************************************************************** //--------------------------------------------------------------------------- int64u File::Size_Get(const Ztring &File_Name) { File F(File_Name); return F.Size_Get(); } //--------------------------------------------------------------------------- Ztring File::Created_Get(const Ztring &File_Name) { File F(File_Name); return F.Created_Get(); } //--------------------------------------------------------------------------- Ztring File::Modified_Get(const Ztring &File_Name) { File F(File_Name); return F.Modified_Get(); } //--------------------------------------------------------------------------- bool File::Exists(const Ztring &File_Name) { ZENLIB_DEBUG1( "File Exists", Debug+=", File_Name="; Debug+=Ztring(File_Name).To_UTF8()) #ifdef ZENLIB_USEWX wxFileName FN(File_Name.c_str()); return FN.FileExists(); #else //ZENLIB_USEWX #ifdef ZENLIB_STANDARD if (File_Name.find(__T('*'))!=std::string::npos || File_Name.find(__T('?'))!=std::string::npos) return false; struct stat buffer; int status; #ifdef UNICODE status=stat(File_Name.To_Local().c_str(), &buffer); #else status=stat(File_Name.c_str(), &buffer); #endif //UNICODE return status==0 && S_ISREG(buffer.st_mode); #elif defined WINDOWS if (File_Name.find(__T('*'))!=std::string::npos || (File_Name.find(__T("\\\\?\\"))!=0 && File_Name.find(__T('?'))!=std::string::npos) || (File_Name.find(__T("\\\\?\\"))==0 && File_Name.find(__T('?'), 4)!=std::string::npos)) return false; #ifdef UNICODE DWORD FileAttributes=GetFileAttributesW(File_Name.c_str()); #else DWORD FileAttributes=GetFileAttributes(File_Name.c_str()); #endif //UNICODE ZENLIB_DEBUG2( "File Exists", Debug+=", File_Name="; Debug+=Ztring::ToZtring(((FileAttributes!=INVALID_FILE_ATTRIBUTES) && !(FileAttributes&FILE_ATTRIBUTE_DIRECTORY))?1:0).To_UTF8()) return ((FileAttributes!=INVALID_FILE_ATTRIBUTES) && !(FileAttributes&FILE_ATTRIBUTE_DIRECTORY)); #endif #endif //ZENLIB_USEWX } //--------------------------------------------------------------------------- bool File::Copy(const Ztring &Source, const Ztring &Destination, bool OverWrite) { #ifdef ZENLIB_USEWX return wxCopyFile(Source.c_str(), Destination.c_str(), OverWrite); #else //ZENLIB_USEWX #ifdef ZENLIB_STANDARD return false; #elif defined WINDOWS #ifdef UNICODE return CopyFileW(Source.c_str(), Destination.c_str(), !OverWrite)!=0; #else return CopyFile(Source.c_str(), Destination.c_str(), !OverWrite)!=0; #endif //UNICODE #endif #endif //ZENLIB_USEWX } //--------------------------------------------------------------------------- bool File::Move(const Ztring &Source, const Ztring &Destination, bool OverWrite) { if (OverWrite && Exists(Source)) Delete(Destination); #ifdef ZENLIB_USEWX if (OverWrite && Exists(Destination)) wxRemoveFile(Destination.c_str()); return wxRenameFile(Source.c_str(), Destination.c_str()); #else //ZENLIB_USEWX #ifdef ZENLIB_STANDARD return !std::rename(Source.To_Local().c_str(), Destination.To_Local().c_str()); #elif defined WINDOWS #ifdef UNICODE return MoveFileW(Source.c_str(), Destination.c_str())!=0; #else return MoveFile(Source.c_str(), Destination.c_str())!=0; #endif //UNICODE #endif #endif //ZENLIB_USEWX } //--------------------------------------------------------------------------- bool File::Delete(const Ztring &File_Name) { #ifdef ZENLIB_USEWX return wxRemoveFile(File_Name.c_str()); #else //ZENLIB_USEWX #ifdef ZENLIB_STANDARD #ifdef UNICODE return unlink(File_Name.To_Local().c_str())==0; #else return unlink(File_Name.c_str())==0; #endif //UNICODE #elif defined WINDOWS #ifdef UNICODE return DeleteFileW(File_Name.c_str())!=0; #else return DeleteFile(File_Name.c_str())!=0; #endif //UNICODE #endif #endif //ZENLIB_USEWX } //*************************************************************************** // //*************************************************************************** } //namespace ZenLib/Source/ZenLib/CriticalSection.h0000664000000000000000000000344212615631146016624 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a zlib-style license that can * be found in the License.txt file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // CriticalSection functions // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef ZenLib_CriticalSectionH #define ZenLib_CriticalSectionH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #ifdef CS #undef CS //Solaris defines this somewhere #endif //--------------------------------------------------------------------------- namespace ZenLib { //*************************************************************************** /// @brief CriticalSection manipulation //*************************************************************************** class CriticalSection { public : //Constructor/Destructor CriticalSection (); ~CriticalSection (); //Enter/Leave void Enter(); void Leave(); private : void* CritSect; }; //*************************************************************************** /// @brief CriticalSectionLocker helper //*************************************************************************** class CriticalSectionLocker { public: CriticalSectionLocker (ZenLib::CriticalSection &CS) { CritSec=&CS; CritSec->Enter(); } ~CriticalSectionLocker () { CritSec->Leave(); } private: ZenLib::CriticalSection *CritSec; }; } //NameSpace #endif ZenLib/Source/ZenLib/ZtringList.cpp0000664000000000000000000002407312615631146016214 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a zlib-style license that can * be found in the License.txt file in the root of the source tree. */ //--------------------------------------------------------------------------- #include "ZenLib/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "ZenLib/Conf_Internal.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include #include #include "ZenLib/ZtringList.h" using namespace std; #if defined(_MSC_VER) && _MSC_VER <= 1200 using std::vector; //Visual C++ 6 patch #endif //--------------------------------------------------------------------------- namespace ZenLib { //--------------------------------------------------------------------------- extern Ztring EmptyZtring; //--------------------------------------------------------------------------- //*************************************************************************** // Constructors/Destructor //*************************************************************************** //--------------------------------------------------------------------------- // Constructors ZtringList::ZtringList () : std::vector > () { Separator[0]=__T(";"); Quote=__T("\""); Max[0]=Error; } ZtringList::ZtringList(const ZtringList &Source) : std::vector > () { Separator[0]=Source.Separator[0]; Quote=Source.Quote; reserve(Source.size()); for (intu Pos=0; Pos=size()) Write(Ztring(), Pos); return operator[](Pos); } //*************************************************************************** // In/Out //*************************************************************************** //--------------------------------------------------------------------------- // Read Ztring ZtringList::Read () const { //Integrity if (size()==0) return Ztring(); Ztring Retour; Ztring ToFind=Separator[0]+Quote[0]+__T("\r\n"); for (size_type Pos=0; Pos=size()) return EmptyZtring; return operator[](Pos); } //--------------------------------------------------------------------------- // Write void ZtringList::Write(const Ztring &ToWrite) { clear(); if (ToWrite.empty()) return; size_type PosC=0; bool Fini=false; Ztring C1; Ztring DelimiterL; Ztring DelimiterR; do { //Searching quotes if (ToWrite[PosC]==Quote[0]) { size_t Pos_End=PosC+1; while (Pos_End0 && C1[C1.size()-1]==Quote[0]) { C1.resize(C1.size()-1); PosC+=Quote.size(); } } else //Normal { C1=ToWrite.SubString(tstring(), Separator[0], PosC, Ztring_AddLastItem); PosC+=C1.size()+Separator[0].size(); } C1.FindAndReplace(Quote+Quote, Quote, 0, Ztring_Recursive); if (size()=ToWrite.size()) Fini=true; } while (!Fini); return; } void ZtringList::Write(const Ztring &ToWrite, size_type Pos) { if (Pos==Error) return; if (Pos>=size()) { //Resource reservation size_t ToReserve=1; while (ToReservesize()) push_back(Ztring()); push_back(ToWrite); } else operator[](Pos)=ToWrite; return; } //*************************************************************************** // Edition //*************************************************************************** //--------------------------------------------------------------------------- // Swap void ZtringList::Swap (size_type Pos0_A, size_type Pos0_B) { //Integrity size_type Pos_Max; if (Pos0_A=size()) Write(Ztring(), Pos_Max); operator [] (Pos0_A).swap(operator [] (Pos0_B)); } //--------------------------------------------------------------------------- // Sort void ZtringList::Sort(ztring_t) { std::stable_sort(begin(), end()); return; } //*************************************************************************** // Information //*************************************************************************** //--------------------------------------------------------------------------- // Find Ztring::size_type ZtringList::Find (const Ztring &ToFind, size_type Pos, const Ztring &Comparator, ztring_t Options) const { while (Pos=size()) return Error; return Pos; } //--------------------------------------------------------------------------- // Return the length of the longest string in the list. Ztring::size_type ZtringList::MaxStringLength_Get () { size_type Max = 0; for (ZtringList::const_iterator it=begin(); it!=end(); ++it) if (it->size()>Max) Max=it->size(); return Max; } //*************************************************************************** // Configuration //*************************************************************************** //--------------------------------------------------------------------------- // Separator void ZtringList::Separator_Set (size_type Level, const Ztring &NewSeparator) { if (Level>0) return; Separator[Level]=NewSeparator; } //--------------------------------------------------------------------------- // Quote void ZtringList::Quote_Set (const Ztring &NewQuote) { Quote=NewQuote; } //--------------------------------------------------------------------------- // Separator void ZtringList::Max_Set (size_type Level, size_type Max_New) { if (Level>0 || Max_New==0) return; Max[Level]=Max_New; } } //namespace ZenLib/Source/ZenLib/InfoMap.cpp0000664000000000000000000001177212615631146015436 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a zlib-style license that can * be found in the License.txt file in the root of the source tree. */ //--------------------------------------------------------------------------- #include "ZenLib/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "ZenLib/Conf_Internal.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #ifdef ZENLIB_USEWX #include #endif //ZENLIB_USEWX #include #include "ZenLib/InfoMap.h" using namespace std; //--------------------------------------------------------------------------- namespace ZenLib { //--------------------------------------------------------------------------- const Ztring InfoMap_EmptyZtring_Const; //Use it when we can't return a reference to a true Ztring, const version //--------------------------------------------------------------------------- //*************************************************************************** // Constructors/Destructor //*************************************************************************** //--------------------------------------------------------------------------- // Constructors InfoMap::InfoMap() : std::multimap () { Separator[0]=EOL; Separator[1]=__T(";"); } InfoMap::InfoMap(const Ztring &Source) : std::multimap () { Separator[0]=EOL; Separator[1]=__T(";"); Write(Source); } InfoMap::InfoMap(const Char *Source) : std::multimap () { Separator[0]=EOL; Separator[1]=__T(";"); Write(Source); } #ifdef _UNICODE InfoMap::InfoMap (const char* S) : std::multimap () { Separator[0]=EOL; Separator[1]=__T(";"); Write(Ztring(S)); } #endif //*************************************************************************** // In/Out //*************************************************************************** //--------------------------------------------------------------------------- const Ztring &InfoMap::Get (const Ztring &Value, size_t Pos) const { InfoMap::const_iterator List=find(Value); if (List==end()) return InfoMap_EmptyZtring_Const; //Not found if (Possecond.size()) return List->second[Pos]; else return InfoMap_EmptyZtring_Const; //Not found } //--------------------------------------------------------------------------- const Ztring &InfoMap::Get (const Ztring &Value, size_t Pos, const Ztring &WithValue, size_t WithValue_Pos) const { InfoMap::const_iterator List=find(Value); if (List==end()) return InfoMap_EmptyZtring_Const; //Not found if (Possecond.size()) { if (List->second[WithValue_Pos]==WithValue) return List->second[Pos]; else { ++List; //The second one, this is a stupid hack for a 2 value, should be changed later... if (Possecond.size()) { if (List->second[WithValue_Pos]==WithValue) return List->second[Pos]; else return InfoMap_EmptyZtring_Const; //Not found } else return InfoMap_EmptyZtring_Const; //Not found } } else return InfoMap_EmptyZtring_Const; //Not found } //--------------------------------------------------------------------------- // Set void InfoMap::Write(const Ztring &NewInfoMap) { clear(); if (NewInfoMap.empty()) return; size_t Pos1=0, Pos2_EOL=0, Pos2_Separator=0; while (Pos2_EOL!=(size_t)-1) { Pos2_EOL=NewInfoMap.find(__T('\n'), Pos1); Pos2_Separator=NewInfoMap.find(__T(';'), Pos1); if (Pos2_Separator(NewInfoMap.substr(Pos1, Pos2_Separator-Pos1), List)); } Pos1=Pos2_EOL+1; } } //*************************************************************************** // Configuration //*************************************************************************** //--------------------------------------------------------------------------- // Separator void InfoMap::Separator_Set (size_type Level, const Ztring &NewSeparator) { if (Level>1) return; Separator[Level]=NewSeparator; } //*************************************************************************** // C++ //*************************************************************************** } //namespace ZenLib/Source/ZenLib/Utils.cpp0000664000000000000000000007270312615631146015206 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a zlib-style license that can * be found in the License.txt file in the root of the source tree. */ //--------------------------------------------------------------------------- #include "ZenLib/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "ZenLib/Conf_Internal.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "ZenLib/Utils.h" #include #include //--------------------------------------------------------------------------- namespace ZenLib { //*************************************************************************** // Transformations - Little Endian to something //*************************************************************************** //--------------------------------------------------------------------------- // Little Endian - 8 bits int8s LittleEndian2int8s (const char* Liste) { return (int8s)Liste[0]; } int8u LittleEndian2int8u (const char* Liste) { return (int8u)Liste[0]; } //--------------------------------------------------------------------------- // Little Endian - 16 bits int16s LittleEndian2int16s (const char* Liste) { int16s Retour= (int8s)Liste[1]; Retour=(Retour<<8)|(int8u)Liste[0]; return Retour; } int16u LittleEndian2int16u (const char* Liste) { int16u Retour= (int8u)Liste[1]; Retour=(Retour<<8)|(int8u)Liste[0]; return Retour; } //--------------------------------------------------------------------------- // Little Endian - 24 bits int32s LittleEndian2int24s (const char* Liste) { int32s Retour= (int8s)Liste[2]; Retour=(Retour<<8)|(int8u)Liste[1]; Retour=(Retour<<8)|(int8u)Liste[0]; return Retour; } int32u LittleEndian2int24u (const char* Liste) { int32u Retour= (int8u)Liste[2]; Retour=(Retour<<8)|(int8u)Liste[1]; Retour=(Retour<<8)|(int8u)Liste[0]; return Retour; } //--------------------------------------------------------------------------- // Little Endian - 32 bits int32s LittleEndian2int32s (const char* Liste) { int32s Retour= (int8s)Liste[3]; Retour=(Retour<<8)|(int8u)Liste[2]; Retour=(Retour<<8)|(int8u)Liste[1]; Retour=(Retour<<8)|(int8u)Liste[0]; return Retour; } int32u LittleEndian2int32u (const char* Liste) { int32u Retour= (int8u)Liste[3]; Retour=(Retour<<8)|(int8u)Liste[2]; Retour=(Retour<<8)|(int8u)Liste[1]; Retour=(Retour<<8)|(int8u)Liste[0]; return Retour; } //--------------------------------------------------------------------------- // Little Endian - 40 bits int64s LittleEndian2int40s (const char* Liste) { int64s Retour= (int8u)Liste[4]; Retour=(Retour<<8)|(int8u)Liste[3]; Retour=(Retour<<8)|(int8u)Liste[2]; Retour=(Retour<<8)|(int8u)Liste[1]; Retour=(Retour<<8)|(int8u)Liste[0]; return Retour; } int64u LittleEndian2int40u (const char* Liste) { int64u Retour= (int8u)Liste[4]; Retour=(Retour<<8)|(int8u)Liste[3]; Retour=(Retour<<8)|(int8u)Liste[2]; Retour=(Retour<<8)|(int8u)Liste[1]; Retour=(Retour<<8)|(int8u)Liste[0]; return Retour; } //--------------------------------------------------------------------------- // Little Endian - 48 bits int64s LittleEndian2int48s (const char* Liste) { int64s Retour= (int8u)Liste[5]; Retour=(Retour<<8)|(int8u)Liste[4]; Retour=(Retour<<8)|(int8u)Liste[3]; Retour=(Retour<<8)|(int8u)Liste[2]; Retour=(Retour<<8)|(int8u)Liste[1]; Retour=(Retour<<8)|(int8u)Liste[0]; return Retour; } int64u LittleEndian2int48u (const char* Liste) { int64u Retour= (int8u)Liste[5]; Retour=(Retour<<8)|(int8u)Liste[4]; Retour=(Retour<<8)|(int8u)Liste[3]; Retour=(Retour<<8)|(int8u)Liste[2]; Retour=(Retour<<8)|(int8u)Liste[1]; Retour=(Retour<<8)|(int8u)Liste[0]; return Retour; } //--------------------------------------------------------------------------- // Little Endian - 56 bits int64s LittleEndian2int56s (const char* Liste) { int64s Retour= (int8u)Liste[6]; Retour=(Retour<<8)|(int8u)Liste[5]; Retour=(Retour<<8)|(int8u)Liste[4]; Retour=(Retour<<8)|(int8u)Liste[3]; Retour=(Retour<<8)|(int8u)Liste[2]; Retour=(Retour<<8)|(int8u)Liste[1]; Retour=(Retour<<8)|(int8u)Liste[0]; return Retour; } int64u LittleEndian2int56u (const char* Liste) { int64u Retour= (int8u)Liste[6]; Retour=(Retour<<8)|(int8u)Liste[5]; Retour=(Retour<<8)|(int8u)Liste[4]; Retour=(Retour<<8)|(int8u)Liste[3]; Retour=(Retour<<8)|(int8u)Liste[2]; Retour=(Retour<<8)|(int8u)Liste[1]; Retour=(Retour<<8)|(int8u)Liste[0]; return Retour; } //--------------------------------------------------------------------------- // Little Endian - 64 bits int64s LittleEndian2int64s (const char* Liste) { int64s Retour= (int8s)Liste[7]; Retour=(Retour<<8)|(int8u)Liste[6]; Retour=(Retour<<8)|(int8u)Liste[5]; Retour=(Retour<<8)|(int8u)Liste[4]; Retour=(Retour<<8)|(int8u)Liste[3]; Retour=(Retour<<8)|(int8u)Liste[2]; Retour=(Retour<<8)|(int8u)Liste[1]; Retour=(Retour<<8)|(int8u)Liste[0]; return Retour; } int64u LittleEndian2int64u (const char* Liste) { int64u Retour= (int8u)Liste[7]; Retour=(Retour<<8)|(int8u)Liste[6]; Retour=(Retour<<8)|(int8u)Liste[5]; Retour=(Retour<<8)|(int8u)Liste[4]; Retour=(Retour<<8)|(int8u)Liste[3]; Retour=(Retour<<8)|(int8u)Liste[2]; Retour=(Retour<<8)|(int8u)Liste[1]; Retour=(Retour<<8)|(int8u)Liste[0]; return Retour; } //--------------------------------------------------------------------------- // Little Endian - 128 bits int128u LittleEndian2int128u(const char* Liste) { int128u Retour; Retour.lo=LittleEndian2int64u(Liste); Retour.hi=LittleEndian2int64u(Liste+8); return Retour; } //--------------------------------------------------------------------------- // Little Endian - float 16 bits float32 LittleEndian2float16(const char* Liste) { //sign 1 bit //exponent 5 bit //significand 10 bit //Retrieving data int32u Integer=LittleEndian2int32u(Liste); //Retrieving elements bool Sign =(Integer&0x8000)?true:false; int32u Exponent=(Integer>>10)&0xFF; int32u Mantissa= Integer&0x03FF; //Some computing if (Exponent==0 || Exponent==0xFF) return 0; //These are denormalised numbers, NANs, and other horrible things Exponent-=0x7F; //Bias float64 Answer=(((float64)Mantissa)/8388608+1.0)*std::pow((float64)2, (int)Exponent); //(1+Mantissa) * 2^Exponent if (Sign) Answer=-Answer; return (float32)Answer; } //--------------------------------------------------------------------------- // Little Endian - float 32 bits float32 LittleEndian2float32(const char* Liste) { //sign 1 bit //exponent 8 bit //significand 23 bit //Retrieving data int32u Integer=LittleEndian2int32u(Liste); //Retrieving elements bool Sign =(Integer&0x80000000)?true:false; int32u Exponent=(Integer>>23)&0xFF; int32u Mantissa= Integer&0x007FFFFF; //Some computing if (Exponent==0 || Exponent==0xFF) return 0; //These are denormalised numbers, NANs, and other horrible things Exponent-=0x7F; //Bias float64 Answer=(((float64)Mantissa)/8388608+1.0)*std::pow((float64)2, (int)Exponent); //(1+Mantissa) * 2^Exponent if (Sign) Answer=-Answer; return (float32)Answer; } //--------------------------------------------------------------------------- // Little Endian - float 64 bits float64 LittleEndian2float64(const char* Liste) { //sign 1 bit //exponent 11 bit //significand 52 bit //Retrieving data int64u Integer=LittleEndian2int64u(Liste); //Retrieving elements bool Sign =(Integer&0x8000000000000000LL)?true:false; int64u Exponent=(Integer>>52)&0x7FF; int64u Mantissa= Integer&0xFFFFFFFFFFFFFLL; //Some computing if (Exponent==0 || Exponent==0x7FF) return 0; //These are denormalised numbers, NANs, and other horrible things Exponent-=0x3FF; //Bias float64 Answer=(((float64)Mantissa)/4503599627370496.0+1.0)*std::pow((float64)2, (int)Exponent); //(1+Mantissa) * 2^Exponent if (Sign) Answer=-Answer; return (float64)Answer; } //--------------------------------------------------------------------------- // Little Endian - float 80 bits float80 LittleEndian2float80(const char* Liste) { //sign 1 bit //exponent 15 bit //integer? 1 bit //significand 63 bit //Retrieving data int16u Integer1=LittleEndian2int16u(Liste); int64u Integer2=LittleEndian2int64u(Liste+2); //Retrieving elements bool Sign =(Integer1&0x8000)?true:false; int16u Exponent= Integer1&0x7FFF; int64u Mantissa= Integer2&0x7FFFFFFFFFFFFFFFLL; //Only 63 bits, 1 most significant bit is explicit //Some computing if (Exponent==0 || Exponent==0x7FFF) return 0; //These are denormalised numbers, NANs, and other horrible things Exponent-=0x3FFF; //Bias float80 Answer=(((float80)Mantissa)/9223372036854775808.0+1.0)*std::pow((float)2, (int)Exponent); //(1+Mantissa) * 2^Exponent if (Sign) Answer=-Answer; return (float80)Answer; } //*************************************************************************** // Transformations - Something to Little Endian //*************************************************************************** //--------------------------------------------------------------------------- // Little Endian - 8 bits void int8s2LittleEndian (char* List, int8s Value) { List[0]=(char)Value; } void int8u2LittleEndian (char* List, int8u Value) { List[0]=(char)Value; } //--------------------------------------------------------------------------- // Little Endian - 16 bits void int16s2LittleEndian (char* List, int16s Value) { List[0]=(char) Value; List[1]=(char)(Value>> 8); } void int16u2LittleEndian (char* List, int16u Value) { List[0]=(char) Value; List[1]=(char)(Value>> 8); } //--------------------------------------------------------------------------- // Little Endian - 24 bits void int24s2LittleEndian (char* List, int32s Value) { List[0]=(char) Value; List[1]=(char)(Value>> 8); List[2]=(char)(Value>>16); } void int24u2LittleEndian (char* List, int32u Value) { List[0]=(char) Value; List[1]=(char)(Value>> 8); List[2]=(char)(Value>>16); } //--------------------------------------------------------------------------- // Little Endian - 32 bits void int32s2LittleEndian (char* List, int32s Value) { List[0]=(char) Value; List[1]=(char)(Value>> 8); List[2]=(char)(Value>>16); List[3]=(char)(Value>>24); } void int32u2LittleEndian (char* List, int32u Value) { List[0]=(char) Value; List[1]=(char)(Value>> 8); List[2]=(char)(Value>>16); List[3]=(char)(Value>>24); } //--------------------------------------------------------------------------- // Little Endian - 40 bits void int40s2LittleEndian (char* List, int64s Value) { List[0]=(char) Value; List[1]=(char)(Value>> 8); List[2]=(char)(Value>>16); List[3]=(char)(Value>>24); List[4]=(char)(Value>>32); } void int40u2LittleEndian (char* List, int64u Value) { List[0]=(char) Value; List[1]=(char)(Value>> 8); List[2]=(char)(Value>>16); List[3]=(char)(Value>>24); List[4]=(char)(Value>>32); } //--------------------------------------------------------------------------- // Little Endian - 48 bits void int48s2LittleEndian (char* List, int64s Value) { List[0]=(char) Value; List[1]=(char)(Value>> 8); List[2]=(char)(Value>>16); List[3]=(char)(Value>>24); List[4]=(char)(Value>>32); List[5]=(char)(Value>>40); } void int48u2LittleEndian (char* List, int64u Value) { List[0]=(char) Value; List[1]=(char)(Value>> 8); List[2]=(char)(Value>>16); List[3]=(char)(Value>>24); List[4]=(char)(Value>>32); List[5]=(char)(Value>>40); } //--------------------------------------------------------------------------- // Little Endian - 56 bits void int56s2LittleEndian (char* List, int64s Value) { List[0]=(char) Value; List[1]=(char)(Value>> 8); List[2]=(char)(Value>>16); List[3]=(char)(Value>>24); List[4]=(char)(Value>>32); List[5]=(char)(Value>>40); List[6]=(char)(Value>>48); } void int56u2LittleEndian (char* List, int64u Value) { List[0]=(char) Value; List[1]=(char)(Value>> 8); List[2]=(char)(Value>>16); List[3]=(char)(Value>>24); List[4]=(char)(Value>>32); List[5]=(char)(Value>>40); List[6]=(char)(Value>>48); } //--------------------------------------------------------------------------- // Little Endian - 64 bits void int64s2LittleEndian (char* List, int64s Value) { List[0]=(char) Value; List[1]=(char)(Value>> 8); List[2]=(char)(Value>>16); List[3]=(char)(Value>>24); List[4]=(char)(Value>>32); List[5]=(char)(Value>>40); List[6]=(char)(Value>>48); List[7]=(char)(Value>>56); } void int64u2LittleEndian (char* List, int64u Value) { List[0]=(char) Value; List[1]=(char)(Value>> 8); List[2]=(char)(Value>>16); List[3]=(char)(Value>>24); List[4]=(char)(Value>>32); List[5]=(char)(Value>>40); List[6]=(char)(Value>>48); List[7]=(char)(Value>>56); } //--------------------------------------------------------------------------- // Little Endian - 128 bits void int128u2LittleEndian(char* List, int128u Value) { int64u2LittleEndian(List+8, Value.lo); int64u2LittleEndian(List , Value.hi); } //*************************************************************************** // Transformations - Big Endian to something //*************************************************************************** //--------------------------------------------------------------------------- // Big Endian - 8 bits int8s BigEndian2int8s (const char* Liste) { return (int8s)Liste[0]; } int8u BigEndian2int8u (const char* Liste) { return (int8u)Liste[0]; } //--------------------------------------------------------------------------- // Big Endian - 16 bits int16s BigEndian2int16s (const char* Liste) { int16s Retour= (int8s)Liste[0]; Retour=(Retour<<8)|(int8u)Liste[1]; return Retour; } int16u BigEndian2int16u (const char* Liste) { int16u Retour= (int8u)Liste[0]; Retour=(Retour<<8)|(int8u)Liste[1]; return Retour; } //--------------------------------------------------------------------------- // Big Endian - 24 bits int32s BigEndian2int24s (const char* Liste) { int32s Retour= (int8s)Liste[0]; Retour=(Retour<<8)|(int8u)Liste[1]; Retour=(Retour<<8)|(int8u)Liste[2]; return Retour; } int32u BigEndian2int24u (const char* Liste) { int32u Retour= (int8u)Liste[0]; Retour=(Retour<<8)|(int8u)Liste[1]; Retour=(Retour<<8)|(int8u)Liste[2]; return Retour; } //--------------------------------------------------------------------------- // Big Endian - 32 bits int32s BigEndian2int32s (const char* Liste) { int32s Retour= (int8s)Liste[0]; Retour=(Retour<<8)|(int8u)Liste[1]; Retour=(Retour<<8)|(int8u)Liste[2]; Retour=(Retour<<8)|(int8u)Liste[3]; return Retour; } int32u BigEndian2int32u (const char* Liste) { int32u Retour= (int8u)Liste[0]; Retour=(Retour<<8)|(int8u)Liste[1]; Retour=(Retour<<8)|(int8u)Liste[2]; Retour=(Retour<<8)|(int8u)Liste[3]; return Retour; } //--------------------------------------------------------------------------- // Big Endian - 40 bits int64s BigEndian2int40s (const char* Liste) { int64s Retour= (int8s)Liste[0]; Retour=(Retour<<8)|(int8u)Liste[1]; Retour=(Retour<<8)|(int8u)Liste[2]; Retour=(Retour<<8)|(int8u)Liste[3]; Retour=(Retour<<8)|(int8u)Liste[4]; return Retour; } int64u BigEndian2int40u (const char* Liste) { int64u Retour= (int8u)Liste[0]; Retour=(Retour<<8)|(int8u)Liste[1]; Retour=(Retour<<8)|(int8u)Liste[2]; Retour=(Retour<<8)|(int8u)Liste[3]; Retour=(Retour<<8)|(int8u)Liste[4]; return Retour; } //--------------------------------------------------------------------------- // Big Endian - 48 bits int64s BigEndian2int48s (const char* Liste) { int64s Retour= (int8s)Liste[0]; Retour=(Retour<<8)|(int8u)Liste[1]; Retour=(Retour<<8)|(int8u)Liste[2]; Retour=(Retour<<8)|(int8u)Liste[3]; Retour=(Retour<<8)|(int8u)Liste[4]; Retour=(Retour<<8)|(int8u)Liste[5]; return Retour; } int64u BigEndian2int48u (const char* Liste) { int64u Retour= (int8u)Liste[0]; Retour=(Retour<<8)|(int8u)Liste[1]; Retour=(Retour<<8)|(int8u)Liste[2]; Retour=(Retour<<8)|(int8u)Liste[3]; Retour=(Retour<<8)|(int8u)Liste[4]; Retour=(Retour<<8)|(int8u)Liste[5]; return Retour; } //--------------------------------------------------------------------------- // Big Endian - 56 bits int64s BigEndian2int56s (const char* Liste) { int64s Retour= (int8s)Liste[0]; Retour=(Retour<<8)|(int8u)Liste[1]; Retour=(Retour<<8)|(int8u)Liste[2]; Retour=(Retour<<8)|(int8u)Liste[3]; Retour=(Retour<<8)|(int8u)Liste[4]; Retour=(Retour<<8)|(int8u)Liste[5]; Retour=(Retour<<8)|(int8u)Liste[6]; return Retour; } int64u BigEndian2int56u (const char* Liste) { int64u Retour= (int8u)Liste[0]; Retour=(Retour<<8)|(int8u)Liste[1]; Retour=(Retour<<8)|(int8u)Liste[2]; Retour=(Retour<<8)|(int8u)Liste[3]; Retour=(Retour<<8)|(int8u)Liste[4]; Retour=(Retour<<8)|(int8u)Liste[5]; Retour=(Retour<<8)|(int8u)Liste[6]; return Retour; } //--------------------------------------------------------------------------- // Big Endian - 64 bits int64s BigEndian2int64s (const char* Liste) { int64s Retour=(int8s)Liste[0]; Retour=(Retour<<8)|(int8u)Liste[1]; Retour=(Retour<<8)|(int8u)Liste[2]; Retour=(Retour<<8)|(int8u)Liste[3]; Retour=(Retour<<8)|(int8u)Liste[4]; Retour=(Retour<<8)|(int8u)Liste[5]; Retour=(Retour<<8)|(int8u)Liste[6]; Retour=(Retour<<8)|(int8u)Liste[7]; return Retour; } int64u BigEndian2int64u (const char* Liste) { int64u Retour=(int8u)Liste[0]; Retour=(Retour<<8)|(int8u)Liste[1]; Retour=(Retour<<8)|(int8u)Liste[2]; Retour=(Retour<<8)|(int8u)Liste[3]; Retour=(Retour<<8)|(int8u)Liste[4]; Retour=(Retour<<8)|(int8u)Liste[5]; Retour=(Retour<<8)|(int8u)Liste[6]; Retour=(Retour<<8)|(int8u)Liste[7]; return Retour; } //--------------------------------------------------------------------------- // Big Endian - 128 bits int128u BigEndian2int128u(const char* Liste) { int128u Retour; Retour.hi=BigEndian2int64u(Liste); Retour.lo=BigEndian2int64u(Liste+8); return Retour; } //--------------------------------------------------------------------------- // Big Endian - float 16 bits float32 BigEndian2float16(const char* Liste) { //sign 1 bit //exponent 5 bit //significand 10 bit //Retrieving data int16u Integer=BigEndian2int16u(Liste); //Retrieving elements bool Sign =(Integer&0x8000)?true:false; int32u Exponent=(Integer>>10)&0xFF; int32u Mantissa= Integer&0x03FF; //Some computing if (Exponent==0 || Exponent==0xFF) return 0; //These are denormalised numbers, NANs, and other horrible things Exponent-=0x0F; //Bias float64 Answer=(((float64)Mantissa)/8388608+1.0)*std::pow((float64)2, (int)Exponent); //(1+Mantissa) * 2^Exponent if (Sign) Answer=-Answer; return (float32)Answer; } //--------------------------------------------------------------------------- // Big Endian - float 32 bits float32 BigEndian2float32(const char* Liste) { //sign 1 bit //exponent 8 bit //significand 23 bit //Retrieving data int32u Integer=BigEndian2int32u(Liste); //Retrieving elements bool Sign =(Integer&0x80000000)?true:false; int32u Exponent=(Integer>>23)&0xFF; int32u Mantissa= Integer&0x007FFFFF; //Some computing if (Exponent==0 || Exponent==0xFF) return 0; //These are denormalised numbers, NANs, and other horrible things Exponent-=0x7F; //Bias float64 Answer=(((float64)Mantissa)/8388608+1.0)*std::pow((float64)2, (int)Exponent); //(1+Mantissa) * 2^Exponent if (Sign) Answer=-Answer; return (float32)Answer; } //--------------------------------------------------------------------------- // Big Endian - float 64 bits float64 BigEndian2float64(const char* Liste) { //sign 1 bit //exponent 11 bit //significand 52 bit //Retrieving data int64u Integer=BigEndian2int64u(Liste); //Retrieving elements bool Sign =(Integer&0x8000000000000000LL)?true:false; int64u Exponent=(Integer>>52)&0x7FF; int64u Mantissa= Integer&0xFFFFFFFFFFFFFLL; //Some computing if (Exponent==0 || Exponent==0x7FF) return 0; //These are denormalised numbers, NANs, and other horrible things Exponent-=0x3FF; //Bias float64 Answer=(((float64)Mantissa)/4503599627370496.0+1.0)*std::pow((float64)2, (int)Exponent); //(1+Mantissa) * 2^Exponent if (Sign) Answer=-Answer; return (float64)Answer; } //--------------------------------------------------------------------------- // Big Endian - float 80 bits float80 BigEndian2float80(const char* Liste) { //sign 1 bit //exponent 15 bit //integer? 1 bit //significand 63 bit //Retrieving data int16u Integer1=BigEndian2int16u(Liste); int64u Integer2=BigEndian2int64u(Liste+2); //Retrieving elements bool Sign =(Integer1&0x8000)?true:false; int16u Exponent= Integer1&0x7FFF; int64u Mantissa= Integer2&0x7FFFFFFFFFFFFFFFLL; //Only 63 bits, 1 most significant bit is explicit //Some computing if (Exponent==0 || Exponent==0x7FFF) return 0; //These are denormalised numbers, NANs, and other horrible things Exponent-=0x3FFF; //Bias float80 Answer=(((float80)Mantissa)/9223372036854775808.0+1.0)*std::pow((float)2, (int)Exponent); //(1+Mantissa) * 2^Exponent if (Sign) Answer=-Answer; return (float80)Answer; } //*************************************************************************** // Transformations - Something to Big Endian //*************************************************************************** //--------------------------------------------------------------------------- // Big Endian - 8 bits void int8s2BigEndian (char* List, int8s Value) { List[0]=(char)Value; } void int8u2BigEndian (char* List, int8u Value) { List[0]=(char)Value; } //--------------------------------------------------------------------------- // Big Endian - 16 bits void int16s2BigEndian (char* List, int16s Value) { List[0]=(char)(Value>> 8); List[1]=(char) Value; } void int16u2BigEndian (char* List, int16u Value) { List[0]=(char)(Value>> 8); List[1]=(char) Value; } //--------------------------------------------------------------------------- // Big Endian - 24 bits void int24s2BigEndian (char* List, int32s Value) { List[0]=(char)(Value>>16); List[1]=(char)(Value>> 8); List[2]=(char) Value; } void int24u2BigEndian (char* List, int32u Value) { List[0]=(char)(Value>>16); List[1]=(char)(Value>> 8); List[2]=(char) Value; } //--------------------------------------------------------------------------- // Big Endian - 32 bits void int32s2BigEndian (char* List, int32s Value) { List[0]=(char)(Value>>24); List[1]=(char)(Value>>16); List[2]=(char)(Value>> 8); List[3]=(char) Value; } void int32u2BigEndian (char* List, int32u Value) { List[0]=(char)(Value>>24); List[1]=(char)(Value>>16); List[2]=(char)(Value>> 8); List[3]=(char) Value; } //--------------------------------------------------------------------------- // Big Endian - 40 bits void int40s2BigEndian (char* List, int64s Value) { List[0]=(char)(Value>>32); List[1]=(char)(Value>>24); List[2]=(char)(Value>>16); List[3]=(char)(Value>> 8); List[4]=(char) Value; } void int40u2BigEndian (char* List, int64u Value) { List[0]=(char)(Value>>32); List[1]=(char)(Value>>24); List[2]=(char)(Value>>16); List[3]=(char)(Value>> 8); List[4]=(char) Value; } //--------------------------------------------------------------------------- // Big Endian - 48 bits void int48s2BigEndian (char* List, int64s Value) { List[0]=(char)(Value>>40); List[1]=(char)(Value>>32); List[2]=(char)(Value>>24); List[3]=(char)(Value>>16); List[4]=(char)(Value>> 8); List[5]=(char) Value; } void int48u2BigEndian (char* List, int64u Value) { List[0]=(char)(Value>>40); List[1]=(char)(Value>>32); List[2]=(char)(Value>>24); List[3]=(char)(Value>>16); List[4]=(char)(Value>> 8); List[5]=(char) Value; } //--------------------------------------------------------------------------- // Big Endian - 56 bits void int56s2BigEndian (char* List, int64s Value) { List[0]=(char)(Value>>48); List[1]=(char)(Value>>40); List[2]=(char)(Value>>32); List[3]=(char)(Value>>24); List[4]=(char)(Value>>16); List[5]=(char)(Value>> 8); List[6]=(char) Value; } void int56u2BigEndian (char* List, int64u Value) { List[0]=(char)(Value>>48); List[1]=(char)(Value>>40); List[2]=(char)(Value>>32); List[3]=(char)(Value>>24); List[4]=(char)(Value>>16); List[5]=(char)(Value>> 8); List[6]=(char) Value; } //--------------------------------------------------------------------------- // Big Endian - 64 bits void int64s2BigEndian (char* List, int64s Value) { List[0]=(char)(Value>>56); List[1]=(char)(Value>>48); List[2]=(char)(Value>>40); List[3]=(char)(Value>>32); List[4]=(char)(Value>>24); List[5]=(char)(Value>>16); List[6]=(char)(Value>> 8); List[7]=(char) Value; } void int64u2BigEndian (char* List, int64u Value) { List[0]=(char)(Value>>56); List[1]=(char)(Value>>48); List[2]=(char)(Value>>40); List[3]=(char)(Value>>32); List[4]=(char)(Value>>24); List[5]=(char)(Value>>16); List[6]=(char)(Value>> 8); List[7]=(char) Value; } //--------------------------------------------------------------------------- // Big Endian - 128 bits void int128u2BigEndian(char* List, int128u Value) { int64u2BigEndian(List, Value.hi); int64u2BigEndian(List+8, Value.lo); } //*************************************************************************** // Int to Int //*************************************************************************** //--------------------------------------------------------------------------- // int32 - int64 int64s int32s_int64s (int32s High, int32u Low) { return ((((int64s)High)<<32) | Low); } int64u int32u_int64u (int32u High, int32u Low) { return ((((int64s)High)<<32) | Low); } void int32s_int64s (int64s &BigInt, int32s High, int32u Low) { BigInt= ((((int64s)High)<<32) | Low); } void int32u_int64u (int64s &BigInt, int32u High, int32u Low) { BigInt= ((((int64s)High)<<32) | Low); } void int64s_int32s (int64s BigInt, int32s &High, int32u &Low) { High = (int32s) ((BigInt & 0xFFFFFFFF00000000LL)>>32); Low = (int32u) ( BigInt & 0x00000000FFFFFFFF); } void int64u_int32u (int64u BigInt, int32u &High, int32u &Low) { High = (int32u) ((BigInt & 0xFFFFFFFF00000000LL)>>32); Low = (int32u) ( BigInt & 0x00000000FFFFFFFF); } //--------------------------------------------------------------------------- // Floats and ints int32s float32_int32s (float32 F, bool Rounded) { //Not rounded if (!Rounded) return (int32s)F; //Rounded int I1=(int)F; if (F-I1>=0.5) return I1+1; else return I1; } int64s float32_int64s (float32 F, bool Rounded) { //Not rounded if (!Rounded) return (int64s)F; //Rounded int I1=(int)F; if (F-I1>=0.5) return I1+1; else return I1; } int32s float64_int32s (float64 F, bool Rounded) { //Not rounded if (!Rounded) return (int32s)F; //Rounded int32s I1=(int32s)F; if (F-I1>=0.5) return I1+1; else return I1; } int64s float64_int64s (float64 F, bool Rounded) { //Not rounded if (!Rounded) return (int64s)F; //Rounded int64s I1=(int64s)F; if (F-I1>=0.5) return I1+1; else return I1; } } //namespace ZenLib ZenLib/Source/ZenLib/BitStream_LE.h0000664000000000000000000000655612615631146016030 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a zlib-style license that can * be found in the License.txt file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Read a stream bit per bit, Little Endian version (rarely used!!!) // Can read up to 32 bits at once // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef ZenBitStream_LEH #define ZenBitStream_LEH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "ZenLib/BitStream.h" //--------------------------------------------------------------------------- namespace ZenLib { class BitStream_LE : public BitStream { public: BitStream_LE () :BitStream() {}; BitStream_LE (const int8u* Buffer_, size_t Size_) :BitStream(Buffer_, Size_) {}; void Attach(const int8u* Buffer_, size_t Size_) { endbyte=0; endbit=0; buffer=Buffer_; ptr=Buffer_; storage=(long)Size_; }; int32u Get (size_t HowMany) { ptr_BeforeLastCall=ptr; long ret; static const int32u Mask[33]={ 0x00000000, 0x00000001, 0x00000003, 0x00000007, 0x0000000f, 0x0000001f, 0x0000003f, 0x0000007f, 0x000000ff, 0x000001ff, 0x000003ff, 0x000007ff, 0x00000fff, 0x00001fff, 0x00003fff, 0x00007fff, 0x0000ffff, 0x0001ffff, 0x0003ffff, 0x0007ffff, 0x000fffff, 0x001fffff, 0x003fffff, 0x007fffff, 0x00ffffff, 0x01ffffff, 0x03ffffff, 0x07ffffff, 0x0fffffff, 0x1fffffff, 0x3fffffff, 0x7fffffff, 0xffffffff, }; unsigned long m=Mask[HowMany]; HowMany+=endbit; if(endbyte+4>=storage){ ret=-1L; if(endbyte*8+(long)HowMany>storage*8){ Attach(NULL, 0); goto overflow; } } ret=ptr[0]>>endbit; if(HowMany>8){ ret|=ptr[1]<<(8-endbit); if(HowMany>16){ ret|=ptr[2]<<(16-endbit); if(HowMany>24){ ret|=ptr[3]<<(24-endbit); if(HowMany>32 && endbit){ ret|=ptr[4]<<(32-endbit); } } } } ret&=m; ptr+=HowMany/8; endbyte+=(long)HowMany/8; endbit=(long)HowMany&7; overflow: return(ret); }; void Skip(size_t bits) { Get(bits); } int32u Remain () //How many bits remain? { return storage*8-(endbyte*8+endbit); }; void Byte_Align() { }; size_t Offset_Get() { return ptr-buffer; }; size_t BitOffset_Get() { return endbit; }; size_t OffsetBeforeLastCall_Get() { return ptr_BeforeLastCall-buffer; }; private : long endbyte; int endbit; const unsigned char *buffer; const unsigned char *ptr; const unsigned char *ptr_BeforeLastCall; long storage; }; } //namespace ZenLib #endif ZenLib/Source/ZenLib/HTTP_Client.h0000664000000000000000000000242012615631146015615 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a zlib-style license that can * be found in the License.txt file in the root of the source tree. */ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // Basic HTTP client // //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //--------------------------------------------------------------------------- #ifndef ZenLib_HTTPClientH #define ZenLib_HTTPClientH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "ZenLib/Ztring.h" //--------------------------------------------------------------------------- namespace ZenLib { //*************************************************************************** /// @brief Basic HTTP client //*************************************************************************** class HTTP_Client { public : //Constructor/Destructor HTTP_Client (); ~HTTP_Client (); //Open/Close int Open (Ztring URL); void Close (); //Read Ztring Read(); private : int32u Handle; }; } //NameSpace #endif ZenLib/Source/ZenLib/Conf.cpp0000664000000000000000000000253112615631146014763 0ustar rootroot/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a zlib-style license that can * be found in the License.txt file in the root of the source tree. */ //--------------------------------------------------------------------------- #include "ZenLib/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "ZenLib/Conf_Internal.h" //--------------------------------------------------------------------------- namespace ZenLib { //*************************************************************************** // Platform differences //*************************************************************************** //End of line #ifdef WINDOWS const Char* EOL=__T("\r\n"); const Char PathSeparator=__T('\\'); #endif #ifdef UNIX const Char* EOL=__T("\n"); const Char PathSeparator=__T('/'); #endif #if defined (MACOS) || defined (MACOSX) const Char* EOL=__T("\n"); const Char PathSeparator=__T('/'); #endif //*************************************************************************** // //*************************************************************************** } //namespace ZenLib/License.txt0000664000000000000000000000160612615631146013074 0ustar rootrootCopyright (c) 2002-2014 MediaArea.net SARL. All rights reserved. This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. ZenLib/Release/0000775000000000000000000000000012615631146012326 5ustar rootrootZenLib/Release/Release_Source.bat0000664000000000000000000000630212615631146015717 0ustar rootroot@echo off rem --- Clean up --- if exist ZenLib_Source del ZenLib_Source.7z if exist ZenLib_Source rmdir ZenLib_Source /S /Q mkdir ZenLib_Source rem --- Copying : Sources --- xcopy ..\Source\*.c ZenLib_Source\Source\ /S xcopy ..\Source\*.cpp ZenLib_Source\Source\ /S xcopy ..\Source\*.h ZenLib_Source\Source\ /S xcopy ..\Source\Doc\* ZenLib_Source\Source\Doc\ /S rem --- Copying : debian --- xcopy ..\debian\* ZenLib_Source\debian\ /S rem --- Copying : Projects --- xcopy ..\Project\*.bdsgroup ZenLib_Source\Project\ /S xcopy ..\Project\*.bdsproj ZenLib_Source\Project\ /S xcopy ..\Project\*.bpf ZenLib_Source\Project\ /S xcopy ..\Project\*.bpg ZenLib_Source\Project\ /S xcopy ..\Project\*.bpr ZenLib_Source\Project\ /S xcopy ..\Project\*.c ZenLib_Source\Project\ /S xcopy ..\Project\*.cbp ZenLib_Source\Project\ /S xcopy ..\Project\*.cpp ZenLib_Source\Project\ /S xcopy ..\Project\*.cs ZenLib_Source\Project\ /S xcopy ..\Project\*.csproj ZenLib_Source\Project\ /S xcopy ..\Project\*.dev ZenLib_Source\Project\ /S xcopy ..\Project\*.dfm ZenLib_Source\Project\ /S xcopy ..\Project\*.dof ZenLib_Source\Project\ /S xcopy ..\Project\*.dpr ZenLib_Source\Project\ /S xcopy ..\Project\*.ico ZenLib_Source\Project\ /S xcopy ..\Project\*.jsl ZenLib_Source\Project\ /S xcopy ..\Project\*.pas ZenLib_Source\Project\ /S xcopy ..\Project\*.res* ZenLib_Source\Project\ /S xcopy ..\Project\*.sln ZenLib_Source\Project\ /S xcopy ..\Project\*.vb ZenLib_Source\Project\ /S xcopy ..\Project\*.vbproj ZenLib_Source\Project\ /S xcopy ..\Project\*.vc ZenLib_Source\Project\ /S xcopy ..\Project\*.vcproj ZenLib_Source\Project\ /S xcopy ..\Project\*.vcxproj ZenLib_Source\Project\ /S xcopy ..\Project\*.vcxproj.filters ZenLib_Source\Project\ /S xcopy ..\Project\*.vjsproj ZenLib_Source\Project\ /S xcopy ..\Project\*.workspace ZenLib_Source\Project\ /S xcopy ..\Project\BCB\*.h ZenLib_Source\Project\BCB\ /S xcopy ..\Project\CMake\* ZenLib_Source\Project\CMake\ /S /Y xcopy ..\Project\GNU\* ZenLib_Source\Project\GNU\ /S xcopy ..\Project\MSVC\*.h ZenLib_Source\Project\MSVC\ /S xcopy ..\Project\MSVC\*.rc ZenLib_Source\Project\MSVC\ /S xcopy ..\Project\Solaris\* ZenLib_Source\Project\Solaris\ /S rem --- Copying : Release --- xcopy *.bat ZenLib_Source\Release\ xcopy *.txt ZenLib_Source\Release\ xcopy BCB\*.txt ZenLib_Source\Release\BCB\ /S xcopy GCC_Linux_i386\*.txt ZenLib_Source\Release\GCC_Linux_i386\ /S xcopy GCC_MinGW32\*.txt ZenLib_Source\Release\GCC_MinGW32\ /S xcopy MSVC\*.txt ZenLib_Source\Release\MSVC\ /S rem --- Copying : Information files --- copy ..\*.txt ZenLib_Source\ rem --- Copying : CVS files --- copy ..\*.cvsignore ZenLib_Source\ rem --- Compressing Archive --- if "%2"=="SkipCompression" goto SkipCompression move ZenLib_Source ZenLib ..\..\Shared\Binary\Windows_i386\7-Zip\7z a -r -ttar -mx9 ZenLib_Source.tar ZenLib\* ..\..\Shared\Binary\Windows_i386\7-Zip\7z a -r -tbzip2 -mx9 libzen_.tar.bz2 ZenLib_Source.tar ..\..\Shared\Binary\Windows_i386\7-Zip\7z a -r -tgzip -mx9 libzen_-1.tar.gz ZenLib_Source.tar del ZenLib_Source.tar move ZenLib ZenLib_Source :SkipCompression rem --- Clean up --- if "%1"=="SkipCleanUp" goto SkipCleanUp rmdir ZenLib_Source /S /Q :SkipCleanUp ZenLib/Release/CleanUp.bat0000664000000000000000000000145412615631146014351 0ustar rootroot@echo off rem --- General --- pushd .. del /Q /S *.~* *.obj *.o *.tds *.dcu *.ddp *.opt *.ncb *.suo *.ilk *.idb *.pdb *.pch *.plg *.aps *.user *.win *.layout *.local *.depend *.identcache *.tgs *.tgw *.sdf del /AH /Q /S *.~* *.obj *.o *.tds *.dcu *.ddp *.opt *.ncb *.suo *.ilk *.idb *.pdb *.pch *.plg *.aps *.user *.win *.layout *.local *.depend *.identcache *.tgs *.tgw *.sdf popd rem Borland Developper Studio --- pushd ..\Project\BCB call CleanUp popd rem Code::Blocks --- pushd ..\Project\CodeBlocks call CleanUp popd rem MS Visual Studio --- pushd ..\Project\MSVC2012 call CleanUp popd pushd ..\Project\MSVC2010 call CleanUp popd pushd ..\Project\MSVC2008 call CleanUp popd pushd ..\Project\MSVC2005 call CleanUp popd rem Release --- del /Q /S *.zip *.gz *.bz2 *.7z ZenLib/Release/Release_BCB.bat0000664000000000000000000000137512615631146015052 0ustar rootroot@echo off rem --- Clean up --- if exist ZenLib_BCB.7z del ZenLib_BCB.7z rmdir ZenLib_BCB /S /Q mkdir ZenLib_BCB rem --- Copying : Include --- xcopy ..\Source\ZenLib\*.h ZenLib_BCB\Include\ZenLib\ rem --- Copying : Documentation --- mkdir Doc pushd ..\Source\Doc ..\..\..\Shared\Binary\Doxygen Doxygen popd mkdir ZenLib_BCB\Doc\ xcopy Doc\*.* ZenLib_BCB\Doc\ rmdir Doc /S /Q xcopy ..\Source\Doc\*.html ZenLib_BCB\ /S rem --- Copying : Library --- copy BCB\Library\ZenLib.lib ZenLib_BCB\ rem --- Copying : Information files --- copy ..\*.txt ZenLib_BCB\ rem --- Compressing Archive --- pushd ZenLib_BCB ..\..\..\Shared\Binary\Win32\7-Zip\7z a -r -t7z -mx9 ..\ZenLib_BCB.7z * popd rem --- Clean up --- rmdir ZenLib_BCB /S /QZenLib/Release/Release_GNU_FromSource.sh0000775000000000000000000000750012615631146017124 0ustar rootroot#! /bin/sh #----------------------------------------------------------------------- # Clean up test -e ZenLib_GNU_FromSource.tar && rm ZenLib_GNU_FromSource.tar test -e ZenLib_GNU_FromSource.tar.bz2 && rm ZenLib_GNU_FromSource.tar.bz2 test -d ZenLib_GNU_FromSource && rm -r ZenLib_GNU_FromSource mkdir ZenLib_GNU_FromSource #----------------------------------------------------------------------- # Preparing : Project cd ../Project/GNU/Library chmod u+x autogen.sh ./autogen.sh cd ../../../Release #----------------------------------------------------------------------- # Copying : License files cp ../License.txt ZenLib_GNU_FromSource/ #----------------------------------------------------------------------- # Copying : History cp ../History.txt ZenLib_GNU_FromSource/ #----------------------------------------------------------------------- # Copying : Information file cp ../ReadMe.txt ZenLib_GNU_FromSource/ #----------------------------------------------------------------------- # Copying : Sources mkdir -p ZenLib_GNU_FromSource/Source/ZenLib cp -r ../Source/ZenLib/*.h ZenLib_GNU_FromSource/Source/ZenLib/ cp -r ../Source/ZenLib/*.cpp ZenLib_GNU_FromSource/Source/ZenLib/ mkdir ZenLib_GNU_FromSource/Source/ZenLib/HTTP_Client cp -r ../Source/ZenLib/HTTP_Client/*.h ZenLib_GNU_FromSource/Source/ZenLib/HTTP_Client cp -r ../Source/ZenLib/HTTP_Client/*.c ZenLib_GNU_FromSource/Source/ZenLib/HTTP_Client mkdir ZenLib_GNU_FromSource/Source/ZenLib/Base64 cp -r ../Source/ZenLib/Base64/*.h ZenLib_GNU_FromSource/Source/ZenLib/Base64 mkdir ZenLib_GNU_FromSource/Source/ZenLib/Format mkdir ZenLib_GNU_FromSource/Source/ZenLib/Format/Html cp -r ../Source/ZenLib/Format/Html/*.h ZenLib_GNU_FromSource/Source/ZenLib/Format/Html cp -r ../Source/ZenLib/Format/Html/*.cpp ZenLib_GNU_FromSource/Source/ZenLib/Format/Html mkdir ZenLib_GNU_FromSource/Source/ZenLib/Format/Http cp -r ../Source/ZenLib/Format/Http/*.h ZenLib_GNU_FromSource/Source/ZenLib/Format/Http cp -r ../Source/ZenLib/Format/Http/*.cpp ZenLib_GNU_FromSource/Source/ZenLib/Format/Http mkdir ZenLib_GNU_FromSource/Source/ZenLib/TinyXml cp -r ../Source/ZenLib/TinyXml/*.h ZenLib_GNU_FromSource/Source/ZenLib/TinyXml cp -r ../Source/ZenLib/TinyXml/*.cpp ZenLib_GNU_FromSource/Source/ZenLib/TinyXml #----------------------------------------------------------------------- # Copying : Projects mkdir -p ZenLib_GNU_FromSource/Project/GNU/Library cp ../Project/GNU/Library/aclocal.m4 ZenLib_GNU_FromSource/Project/GNU/Library/ cp ../Project/GNU/Library/autogen.sh ZenLib_GNU_FromSource/Project/GNU/Library/ cp ../Project/GNU/Library/config.guess ZenLib_GNU_FromSource/Project/GNU/Library/ cp ../Project/GNU/Library/config.sub ZenLib_GNU_FromSource/Project/GNU/Library/ cp ../Project/GNU/Library/configure ZenLib_GNU_FromSource/Project/GNU/Library/ cp ../Project/GNU/Library/configure.ac ZenLib_GNU_FromSource/Project/GNU/Library/ cp ../Project/GNU/Library/depcomp ZenLib_GNU_FromSource/Project/GNU/Library/ cp ../Project/GNU/Library/install-sh ZenLib_GNU_FromSource/Project/GNU/Library/ cp ../Project/GNU/Library/ltmain.sh ZenLib_GNU_FromSource/Project/GNU/Library/ cp ../Project/GNU/Library/Makefile.am ZenLib_GNU_FromSource/Project/GNU/Library/ cp ../Project/GNU/Library/Makefile.in ZenLib_GNU_FromSource/Project/GNU/Library/ cp ../Project/GNU/Library/missing ZenLib_GNU_FromSource/Project/GNU/Library/ cp ../Project/GNU/Library/wxwin.m4 ZenLib_GNU_FromSource/Project/GNU/Library/ cp ../Project/GNU/Library/libzen.pc.in ZenLib_GNU_FromSource/Project/GNU/Library/ cp ../Project/GNU/Library/libzen-config.in ZenLib_GNU_FromSource/Project/GNU/Library/ #----------------------------------------------------------------------- # Compressing Archive tar jchf ZenLib_GNU_FromSource.tar.bz2 ZenLib_GNU_FromSource/* #----------------------------------------------------------------------- # Clean up rm -r ZenLib_GNU_FromSource ZenLib/Release/UpgradeVersion.sh0000664000000000000000000000326712615631146015627 0ustar rootroot# Upgrade the version number of ZenLib function btask.UpgradeVersion.run () { if [ $(b.opt.get_opt --source-path) ]; then ZL_source=$(sanitize_arg $(b.opt.get_opt --source-path)) else if [ $(b.opt.get_opt --repo-url) ]; then RepoURL=$(sanitize_arg $(b.opt.get_opt --repo-url)) else RepoURL="git://github.com/MediaArea/ZenLib/" fi getSource /tmp $RepoURL ZL_source=/tmp/ZenLib fi echo echo "Passage for version with dots..." index=0 ZL_files[((index++))]="Project/GNU/libzen.dsc" ZL_files[((index++))]="Project/GNU/libzen.spec" ZL_files[((index++))]="Project/Solaris/mkpkg" ZL_files[((index++))]="debian/changelog" ZL_files[((index++))]="debian/control" ZL_files[((index++))]="Project/GNU/Library/configure.ac" # Replace old version by new version for ZL_file in ${ZL_files[@]} do echo "${ZL_source}/${ZL_file}" updateFile $Version_old_dot $Version_new "${ZL_source}/${ZL_file}" done echo echo "Replace major/minor/patch in ${ZL_source}/Project/CMake/CMakeLists.txt" updateFile "set(ZenLib_MAJOR_VERSION \"$Version_old_major\")" \ "set(ZenLib_MAJOR_VERSION \"$Version_new_major\")" \ "${ZL_source}/Project/CMake/CMakeLists.txt" updateFile "set(ZenLib_MINOR_VERSION \"$Version_old_minor\")" \ "set(ZenLib_MINOR_VERSION \"$Version_new_minor\")" \ "${ZL_source}/Project/CMake/CMakeLists.txt" updateFile "set(ZenLib_PATCH_VERSION \"$Version_old_patch\")" \ "set(ZenLib_PATCH_VERSION \"$Version_new_patch\")" \ "${ZL_source}/Project/CMake/CMakeLists.txt" unset -v ZL_files index ZL_source } ZenLib/Release/Release_GNU_Prepare.bat0000664000000000000000000000176312615631146016574 0ustar rootroot@echo off rem --- Clean up --- if exist ZenLib_GNU_Prepare.7z del ZenLib_GNU_Prepare.7z if exist ZenLib_GNU_Prepare rmdir ZenLib_GNU_Prepare /S /Q mkdir ZenLib_GNU_Prepare rem --- Copying : Sources --- xcopy ..\Source\ZenLib\*.c ZenLib_GNU_Prepare\Source\ZenLib\ /S xcopy ..\Source\ZenLib\*.cpp ZenLib_GNU_Prepare\Source\ZenLib\ /S xcopy ..\Source\ZenLib\*.h ZenLib_GNU_Prepare\Source\ZenLib\ /S rem --- Copying : Projects --- xcopy ..\Project\GNU\* ZenLib_GNU_Prepare\Project\GNU\ /S rem --- Copying : Release --- xcopy *.sh ZenLib_GNU_Prepare\Release\ xcopy *.txt ZenLib_GNU_Prepare\Release\ rem --- Copying : Information files --- copy ..\*.txt ZenLib_GNU_Prepare\ rem --- Compressing Archive --- if "%2"=="SkipCompression" goto SkipCompression ..\..\Shared\Binary\Win32\7-Zip\7z a -r -t7z -mx9 ZenLib_GNU_Prepare.7z ZenLib_GNU_Prepare\* :SkipCompression rem --- Clean up --- if "%1"=="SkipCleanUp" goto SkipCleanUp rmdir ZenLib_GNU_Prepare /S /Q :SkipCleanUp ZenLib/Project/0000775000000000000000000000000012615631146012354 5ustar rootrootZenLib/Project/MSVC2010/0000775000000000000000000000000012615631146013427 5ustar rootrootZenLib/Project/MSVC2010/CleanUp.bat0000664000000000000000000000116012615631146015444 0ustar rootroot@echo off rem MS Visual Studio specific --- if exist *.opensdf del *.opensdf if exist *.sdf del *.sdf pushd Example if exist Debug rmdir Debug /Q /S if exist Release rmdir Release /Q /S if exist Win32 rmdir Win32 /Q /S if exist x64 rmdir x64 /Q /S if exist *.ncb del *.ncb if exist *.user del *.user if exist *.suo del *.suo /AH popd pushd Library if exist Debug rmdir Debug /Q /S if exist Release rmdir Release /Q /S if exist Win32 rmdir Win32 /Q /S if exist x64 rmdir x64 /Q /S if exist *.ncb del *.ncb if exist *.user del *.user if exist *.suo del *.suo /AH popd ZenLib/Project/MSVC2010/ZenLib_MSVC.sln0000664000000000000000000000370712615631146016167 0ustar rootrootMicrosoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ZenLib", "Library\ZenLib.vcxproj", "{0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Debug|x64 = Debug|x64 DebugA|Win32 = DebugA|Win32 DebugA|x64 = DebugA|x64 Release|Win32 = Release|Win32 Release|x64 = Release|x64 ReleaseA|Win32 = ReleaseA|Win32 ReleaseA|x64 = ReleaseA|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.Debug|Win32.ActiveCfg = Debug|Win32 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.Debug|Win32.Build.0 = Debug|Win32 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.Debug|x64.ActiveCfg = Debug|x64 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.Debug|x64.Build.0 = Debug|x64 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.DebugA|Win32.ActiveCfg = DebugA|Win32 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.DebugA|Win32.Build.0 = DebugA|Win32 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.DebugA|x64.ActiveCfg = DebugA|x64 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.DebugA|x64.Build.0 = DebugA|x64 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.Release|Win32.ActiveCfg = Release|Win32 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.Release|Win32.Build.0 = Release|Win32 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.Release|x64.ActiveCfg = Release|x64 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.Release|x64.Build.0 = Release|x64 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.ReleaseA|Win32.ActiveCfg = ReleaseA|Win32 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.ReleaseA|Win32.Build.0 = ReleaseA|Win32 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.ReleaseA|x64.ActiveCfg = ReleaseA|x64 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.ReleaseA|x64.Build.0 = ReleaseA|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal ZenLib/Project/MSVC2010/Library/0000775000000000000000000000000012615631146015033 5ustar rootrootZenLib/Project/MSVC2010/Library/ZenLib.vcxproj0000664000000000000000000004724512615631146017647 0ustar rootroot DebugA Win32 DebugA x64 Debug Win32 Debug x64 ReleaseA Win32 ReleaseA x64 Release Win32 Release x64 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94} ZenLib Win32Proj StaticLibrary MultiByte StaticLibrary MultiByte true StaticLibrary Unicode true StaticLibrary Unicode StaticLibrary MultiByte StaticLibrary MultiByte true StaticLibrary Unicode true StaticLibrary Unicode <_ProjectFileVersion>10.0.30128.1 $(Platform)\$(Configuration)\ $(Platform)\$(Configuration)\Intermediate\ $(Platform)\$(Configuration)\ $(Platform)\$(Configuration)\Intermediate\ $(Platform)\$(Configuration)\ $(Platform)\$(Configuration)\Intermediate\ $(Platform)\$(Configuration)\ $(Platform)\$(Configuration)\Intermediate\ $(Platform)\$(Configuration)\ $(Platform)\$(Configuration)\Intermediate\ $(Platform)\$(Configuration)\ $(Platform)\$(Configuration)\Intermediate\ $(Platform)\$(Configuration)\ $(Platform)\$(Configuration)\Intermediate\ $(Platform)\$(Configuration)\ $(Platform)\$(Configuration)\Intermediate\ Disabled ../../../Source;../../../../zlib;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebug Level4 EditAndContinue true Use ZenLib/PreComp.h MachineX86 Disabled ../../../Source;../../../../zlib;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) MultiThreadedDebug Level4 ProgramDatabase EnableFastChecks true Use ZenLib/PreComp.h MachineX64 MaxSpeed ../../../Source;../../../../zlib;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) MultiThreaded Level4 true Use ZenLib/PreComp.h MachineX86 MaxSpeed ../../../Source;../../../../zlib;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) MultiThreaded Level4 true Use ZenLib/PreComp.h MachineX64 MaxSpeed ../../../Source;../../../../zlib;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) MultiThreaded Level4 true Use ZenLib/PreComp.h MachineX86 MaxSpeed ../../../Source;../../../../zlib;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) MultiThreaded Level4 true Use ZenLib/PreComp.h MachineX64 Disabled ../../../Source;../../../../zlib;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebug Level4 EditAndContinue true Use ZenLib/PreComp.h MachineX86 Disabled ../../../Source;../../../../zlib;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebug Level4 ProgramDatabase true Use ZenLib/PreComp.h MachineX64 Create Create Create Create Create Create Create Create ZenLib/Project/MSVC2010/Library/ZenLib.vcxproj.filters0000664000000000000000000002014712615631146021306 0ustar rootroot {4FC737F1-C7A5-4376-A066-2A32D752A2FF} cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx {b0e0820a-9895-4fee-8a01-7583d157cda3} {a987454d-645c-4a63-bc84-ffc79ae4679d} {e2876701-1853-42b5-a385-15d45b825a88} {93995380-89BD-4b04-88EB-625FBE52EBFB} h;hpp;hxx;hm;inl;inc;xsd {14855e7b-4367-4780-9bdb-48a7e942fd23} {5cfba4eb-2f03-4a6b-8f8a-a8a0dbfb4802} {16c53209-3c96-4ded-b925-c5cd36c4858f} Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files\Format\Http Source Files\Format\Http Source Files\Format\Http Source Files\Format\Http Source Files\Format\Html Source Files\Format\Html Source Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files\Format\Html Header Files\Format\Html Header Files\Format\Http Header Files\Format\Http Header Files\Format\Http Header Files\Format\Http Header Files Header Files Header Files ZenLib/Project/MSVC2010/Example/0000775000000000000000000000000012615631146015022 5ustar rootrootZenLib/Project/MSVC2010/Example/ZenLib_Test.vcxproj.filters0000664000000000000000000000102012615631146022261 0ustar rootroot {5fc02ff6-0eab-4a4f-a754-256dd82d27af} cpp;c;cxx;def;odl;idl;hpj;bat;asm Source Files ZenLib/Project/MSVC2010/Example/ZenLib_Test.vcxproj0000664000000000000000000001013712615631146020623 0ustar rootroot Release_Ansi Win32 Release Win32 {425F07FD-D7F7-467F-B213-8B60635582F2} Win32Proj Application MultiByte Application Unicode <_ProjectFileVersion>10.0.40219.1 Release\ Release\ Release_Ansi\ Release_Ansi\ ../../../Source;%(AdditionalIncludeDirectories) WIN32;NDEBUG;%(PreprocessorDefinitions) Level4 comctl32.lib;WxJpeg.lib;WxPng.lib;WxTiff.lib;WxWidgets.lib;ZenLib.lib;%(AdditionalDependencies) ../../../Release/MSVC/Library;../../../../Shared/Library/MSVC comctl32.lib;ZenLib.lib;%(AdditionalDependencies) ../../../Source;%(AdditionalIncludeDirectories) WIN32;NDEBUG;%(PreprocessorDefinitions) Level4 ZenLibA.lib;WxBaseA.lib;%(AdditionalDependencies) ../../../ReleaseA/MSVC/Library;../../../../Shared/Library/MSVC ZenLib/Project/MSVC2010/Example/ZenLib_Test.sln0000664000000000000000000000164212615631146017725 0ustar rootroot Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ZenLib_Test", "ZenLib_Test.vcxproj", "{425F07FD-D7F7-467F-B213-8B60635582F2}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Release_Ansi|Win32 = Release_Ansi|Win32 Release|Win32 = Release|Win32 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {425F07FD-D7F7-467F-B213-8B60635582F2}.Release_Ansi|Win32.ActiveCfg = Release_Ansi|Win32 {425F07FD-D7F7-467F-B213-8B60635582F2}.Release_Ansi|Win32.Build.0 = Release_Ansi|Win32 {425F07FD-D7F7-467F-B213-8B60635582F2}.Release|Win32.ActiveCfg = Release|Win32 {425F07FD-D7F7-467F-B213-8B60635582F2}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal ZenLib/Project/GNU/0000775000000000000000000000000012615631146013005 5ustar rootrootZenLib/Project/GNU/libzen.dsc0000664000000000000000000000143412615631146014765 0ustar rootrootFormat: 3.0 (native) Source: libzen Binary: libzen-dev, libzen0, libzen-doc Architecture: any all Version: 0.4.32 Maintainer: MediaArea.net SARL Homepage: http://mediainfo.sourceforge.net Standards-Version: 3.9.6 Vcs-Browser: https://github.com/MediaArea/ZenLib Vcs-Git: https://github.com/MediaArea/ZenLib.git Build-Depends: debhelper (>= 9), dh-autoreconf, doxygen, tofrodos Package-List: libzen-dev deb libdevel optional arch=any libzen-doc deb doc optional arch=all libzen0 deb libs optional arch=any Checksums-Sha1: 0000000000000000000000000000000000000000 000000 libzen_0.4.32.tar.xz Checksums-Sha256: 0000000000000000000000000000000000000000000000000000000000000000 000000 libzen_0.4.32.tar.xz Files: 00000000000000000000000000000000 000000 libzen_0.4.32.tar.xz ZenLib/Project/GNU/libzen.spec0000664000000000000000000000771612615631146015157 0ustar rootroot%define libzen_version 0.4.32 Name: libzen Version: %{libzen_version} Release: 1 Summary: C++ utility library License: Zlib Group: System/Libraries URL: http://sourceforge.net/projects/zenlib Packager: MediaArea.net SARL Source: %{name}_%{version}.tar.gz BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root BuildRequires: gcc-c++ BuildRequires: pkgconfig BuildRequires: glibc-devel BuildRequires: doxygen BuildRequires: libtool BuildRequires: automake BuildRequires: autoconf %description ZenLib is a C++ utility library. It includes classes for handling strings, configuration, bit streams, threading, translation, and cross-platform operating system functions. %package -n %{name}0 Summary: C++ utility library -- runtime Group: System/Libraries Requires: glibc %description -n %{name}0 ZenLib is a C++ utility library. It includes classes for handling strings, configuration, bit streams, threading, translation, and cross-platform operating system functions. This package contains the headers required for compiling applications/libraries which use this library. %package doc Summary: C++ utility library -- documentation Group: Development/Libraries Requires: %{name}0 = %{version} %description doc ZenLib is a C++ utility library. It includes classes for handling strings, configuration, bit streams, threading, translation, and cross-platform operating system functions. This package contains the documentation %package devel Summary: C++ utility library -- development Group: Development/Libraries Requires: %{name}0%{?_isa} = %{version} Requires: glibc-devel %description devel ZenLib is a C++ utility library. It includes classes for handling strings, configuration, bit streams, threading, translation, and cross-platform operating system functions. This package contains the include files and mandatory libraries for development. %prep %setup -q -n ZenLib #Correct documentation encoding and permissions sed -i 's/.$//' *.txt chmod 644 *.txt Source/Doc/Documentation.html chmod 644 Source/ZenLib/*.h Source/ZenLib/*.cpp \ Source/ZenLib/Format/Html/*.h Source/ZenLib/Format/Html/*.cpp \ Source/ZenLib/Format/Http/*.h Source/ZenLib/Format/Http/*.cpp pushd Project/GNU/Library autoreconf -i popd %build export CFLAGS="%{optflags}" export CPPFLAGS="%{optflags}" export CXXFLAGS="%{optflags}" #Make documentation pushd Source/Doc/ doxygen Doxyfile popd cp Source/Doc/*.html ./ pushd Project/GNU/Library %configure --disable-static --enable-shared make clean make %{?_smp_mflags} popd %install pushd Project/GNU/Library make install DESTDIR=%{buildroot} popd #Install headers and ZenLib-config install -dm 755 %{buildroot}%{_includedir}/ZenLib install -m 644 Source/ZenLib/*.h \ %{buildroot}%{_includedir}/ZenLib for i in HTTP_Client Format/Html Format/Http; do install -dm 755 %{buildroot}%{_includedir}/ZenLib/$i install -m 644 Source/ZenLib/$i/*.h \ %{buildroot}%{_includedir}/ZenLib/$i done sed -i -e 's|Version: |Version: %{version}|g' \ Project/GNU/Library/%{name}.pc install -dm 755 %{buildroot}%{_libdir}/pkgconfig install -m 644 Project/GNU/Library/%{name}.pc \ %{buildroot}%{_libdir}/pkgconfig %post -n %{name}0 -p /sbin/ldconfig %postun -n %{name}0 -p /sbin/ldconfig %files -n %{name}0 %defattr(-,root,root,-) %doc History.txt License.txt ReadMe.txt %{_libdir}/%{name}.so.* %files doc %defattr(-,root,root,-) %doc Documentation.html %doc Doc %files devel %defattr(-,root,root,-) %{_bindir}/%{name}-config %{_includedir}/ZenLib %{_libdir}/%{name}.so %{_libdir}/%{name}.la %{_libdir}/pkgconfig/*.pc %changelog * Tue Jan 01 2009 MediaArea.net SARL - 0.4.32-0 - See History.txt for more info and real dates - Previous packages made by Toni Graffy - Fedora style made by Vasiliy N. Glazov ZenLib/Project/GNU/Library/0000775000000000000000000000000012615631146014411 5ustar rootrootZenLib/Project/GNU/Library/autogen.sh0000775000000000000000000000104112615631146016406 0ustar rootroot#libtoolize if test "$(uname)" = "Darwin" ; then #Darwin based Systems like Mac OS X: libtoolize is called glibtoolize. glibtoolize --automake else libtoolize --automake fi #aclocal if test -e /usr/bin/aclocal-1.11 ; then #OpenSolaris: no aclocal aclocal-1.11 elif test -e /usr/bin/aclocal-1.10 ; then aclocal-1.10 else aclocal fi #automake if test -e /usr/bin/automake-1.11 ; then #OpenSolaris: no automake automake-1.11 -a elif test -e /usr/bin/automake-1.10 ; then automake-1.10 -a else automake -a fi autoreconf -fiZenLib/Project/GNU/Library/libzen-config.in0000664000000000000000000000054212615631146017470 0ustar rootroot#!/bin/bash if test "$1" = "CXXFLAGS"; then echo @ZenLib_CXXFLAGS@ fi if test "$1" = "LIBS"; then echo @ZenLib_LIBS@ fi if test "$1" = "LIBS_Static"; then echo @ZenLib_LIBS_Static@ fi if test "$1" = "Unicode"; then echo @ZenLib_Unicode@ fi if test "$1" = "WstringMissing"; then echo @ZenLib_wstring_missing@ fi if test "$1" = "Exists"; then echo yes fi ZenLib/Project/GNU/Library/libzen.pc.in0000664000000000000000000000051412615631146016625 0ustar rootrootprefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ includedir=@includedir@ Unicode=@ZenLib_Unicode@ WstringMissing=@ZenLib_wstring_missing@ Libs_Static=@libdir@/libzen.a -lpthread Name: libzen Version: @PACKAGE_VERSION@ Description: ZenLib Libs: -L@libdir@ -lzen -lpthread -lstdc++ Cflags: -I${includedir} @ZenLib_CXXFLAGS@ ZenLib/Project/GNU/Library/configure.ac0000664000000000000000000002330212615631146016677 0ustar rootrootdnl ######################################################################### dnl ### Init dnl ######################################################################### dnl ------------------------------------------------------------------------- dnl Name and version dnl AC_INIT([libzen], [0.4.32]) dnl ------------------------------------------------------------------------- dnl Test if we are at the good place dnl AC_CONFIG_SRCDIR([../../../Source/ZenLib/Ztring.cpp]) dnl ------------------------------------------------------------------------- dnl sets build, host, target variables and the same with _alias dnl AC_CANONICAL_BUILD AM_INIT_AUTOMAKE([foreign -Wall]) dnl ------------------------------------------------------------------------- dnl Autotools init dnl AC_PROG_CC AC_PROG_CXX AC_PROG_CPP AC_DISABLE_SHARED AC_LIBTOOL_WIN32_DLL AC_PROG_LIBTOOL AC_PROG_INSTALL dnl ######################################################################### dnl ### Options dnl ######################################################################### dnl ------------------------------------------------------------------------- dnl Enable dnl AC_ARG_ENABLE([debug], [AS_HELP_STRING([--enable-debug], [Enable full debug])], , [enable_debug=no]) AC_ARG_ENABLE([gprof], [AS_HELP_STRING([--enable-gprof], [Enable gprof log])], , [enable_gprof=no]) AC_ARG_ENABLE([universal_binary], [AS_HELP_STRING([--enable-universal_binary], [Create Mac PPC/i386 Universal binary])], , [enable_universal_binary=no]) AC_ARG_ENABLE([arch-ppc], [AS_HELP_STRING(([--enable-arch-ppc], [Create Mac PPC architecture]))], , [enable_arch_ppc=no]) AC_ARG_ENABLE([arch-ppc64], [AS_HELP_STRING(([--enable-arch-ppc64], [Create Mac PPC64 architecture]))], , [enable_arch_ppc64=no]) AC_ARG_ENABLE([arch-i386], [AS_HELP_STRING(([--enable-arch-i386], [Create Mac i386 architecture]))], , [enable_arch_i386=no]) AC_ARG_ENABLE([arch-x86_64], [AS_HELP_STRING(([--enable-arch-x86_64], [Create Mac x86_64 architecture]))], , [enable_arch_x86_64=no]) AC_ARG_ENABLE([unicode], [AS_HELP_STRING(([--disable-unicode], [Disable unicode]))], , [enable_unicode=yes]) AC_ARG_ENABLE([wstring_missing], [AS_HELP_STRING(([--enable-wstring_missing], [Disable wstring support (old compilers)]))], , [enable_wstring_missing=no]) AC_ARG_ENABLE([stream_missing], [AS_HELP_STRING(([--enable-stream_missing], [Disable stream support (old compilers)]))], , [enable_stream_missing=no]) AC_ARG_ENABLE([large_files], [AS_HELP_STRING(([--disable-large_files], [Disable large files support]))], , [enable_large_files=yes]) dnl AC_ARG_ENABLE([threads], [AS_HELP_STRING(([--disable-threads], [Disable threads support]))], , [enable_threads=yes]) dnl ------------------------------------------------------------------------- dnl With dnl AC_ARG_WITH([macosx-sdk], [AS_HELP_STRING(([--with-macosx-sdk], [Force the Mac SDK]))], , [with_macosx_sdk=no]) AC_ARG_WITH([macosx-version-min], [AS_HELP_STRING(([--with-macosx-version-min], [Force the Mac Version]))], , [with_macosx_version_min=no]) dnl ######################################################################### dnl ### Compiler specific dnl ######################################################################### dnl ------------------------------------------------------------------------- case "${build}" in powerpc-montavista* ) CFLAGS="$CFLAGS -D__MONTAVISTA__" CXXFLAGS="$CXXFLAGS -D__MONTAVISTA__" ;; esac dnl ------------------------------------------------------------------------- dnl Mac Architecture and SDK dnl if test "$enable_universal_binary" = "yes"; then enable_arch_ppc=yes enable_arch_i386=yes if test "$with_macosx_sdk" = no ; then with_macosx_sdk="/Developer/SDKs/MacOSX10.4u.sdk" fi if test "$with_macosx_version_min" = no ; then with_macosx_version_min="10.4" fi fi if test "$enable_arch_ppc" = "yes"; then CXXFLAGS="$CXXFLAGS -arch ppc" CFLAGS="$CFLAGS -arch ppc" LDFLAGS="$LDFLAGS -arch ppc" fi if test "$enable_arch_ppc64" = "yes"; then CXXFLAGS="$CXXFLAGS -arch ppc64" CFLAGS="$CFLAGS -arch ppc64" LDFLAGS="$LDFLAGS -arch ppc64" fi if test "$enable_arch_i386" = "yes"; then CXXFLAGS="$CXXFLAGS -arch i386" CFLAGS="$CFLAGS -arch i386" LDFLAGS="$LDFLAGS -arch i386" fi if test "$enable_arch_x86_64" = "yes"; then CXXFLAGS="$CXXFLAGS -arch x86_64" CFLAGS="$CFLAGS -arch x86_64" LDFLAGS="$LDFLAGS -arch x86_64" fi if test "$with_macosx_sdk" = "yes" ; then CXXFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk $CXXFLAGS" CFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk $CFLAGS" LDFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk $LDFLAGS" elif test "x$with_macosx_sdk" != xno ; then CXXFLAGS="-isysroot $with_macosx_sdk $CXXFLAGS" CFLAGS="-isysroot $with_macosx_sdk $CFLAGS" LDFLAGS="-isysroot $with_macosx_sdk $LDFLAGS" fi if test "x$with_macosx_version_min" != xno ; then CXXFLAGS="-mmacosx-version-min=$with_macosx_version_min $CXXFLAGS" CFLAGS="-mmacosx-version-min=$with_macosx_version_min $CFLAGS" LDFLAGS="-mmacosx-version-min=$with_macosx_version_min $LDFLAGS" fi dnl ######################################################################### dnl ### ZenLib flags dnl ######################################################################### dnl ------------------------------------------------------------------------- dnl Common dnl ZenLib_LIBS="-L$(pwd) -lzen -lpthread -lstdc++ $ZenLib_LIBS" ZenLib_LIBS_Static="$(pwd)/.libs/libzen.a -lpthread -lstdc++ $ZenLib_LIBS_Static" dnl ######################################################################### dnl ### C/C++ compiler options used to compile dnl ######################################################################### dnl ------------------------------------------------------------------------- dnl wstring dnl if test "$enable_wstring_missing" = "yes"; then CXXFLAGS="$CXXFLAGS -DWSTRING_MISSING" ZenLib_CXXFLAGS="$ZenLib_CXXFLAGS -DWSTRING_MISSING" ZenLib_wstring_missing="yes" enable_unicode="no" else ZenLib_wstring_missing="no" fi dnl ------------------------------------------------------------------------- dnl Unicode dnl if test "$enable_unicode" = "yes"; then CXXFLAGS="$CXXFLAGS -DUNICODE" ZenLib_CXXFLAGS="$ZenLib_CXXFLAGS -DUNICODE" ZenLib_Unicode="yes" else ZenLib_Unicode="no" fi dnl ------------------------------------------------------------------------- dnl Large files dnl if test "$enable_large_files" = "yes"; then CXXFLAGS="$CXXFLAGS -D_LARGE_FILES -D_FILE_OFFSET_BITS=64" ZenLib_LargeFiles="yes" else ZenLib_LargeFiles="no" fi dnl ------------------------------------------------------------------------- dnl Threads dnl dnl ------------------------------------------------------------------------- dnl Check if size_t is long dnl AC_LANG([C++]) AC_COMPILE_IFELSE([ #include void foo(signed int) {} void foo(unsigned int) {} int main () {foo(size_t(0)); return 0;}], [size_t_is_long="no"], [size_t_is_long="yes"]) if test "$size_t_is_long" = "yes"; then CXXFLAGS="$CXXFLAGS -DSIZE_T_IS_LONG" ZenLib_CXXFLAGS="$ZenLib_CXXFLAGS -DSIZE_T_IS_LONG" fi dnl ------------------------------------------------------------------------- dnl Check if stream is available dnl AC_LANG([C++]) if test "$enable_unicode" = "yes"; then AC_COMPILE_IFELSE([ #include int main () {std::wstringstream message; message<<1.0; return 0;}], , [enable_stream_missing="yes"]) else AC_COMPILE_IFELSE([ #include int main () {std::stringstream message; message<<1.0; return 0;}], , [enable_stream_missing="yes"]) fi if test "$enable_stream_missing" = "yes"; then CXXFLAGS="$CXXFLAGS -DSTREAM_MISSING" fi dnl ------------------------------------------------------------------------- dnl GNU compiler dnl if test "$GXX" = yes ; then CFLAGS="$CFLAGS -fPIC" CXXFLAGS="$CXXFLAGS -fPIC" if test "$enable_debug" = "yes"; then CFLAGS="$CFLAGS -O0 -g -Wall -Wundef" CXXFLAGS="$CXXFLAGS -O0 -g -Wall -W -Wundef -Wcast-qual -Wno-ctor-dtor-privacy" else CFLAGS="$CFLAGS -O2" CXXFLAGS="$CXXFLAGS -O2" fi if test "$enable_gprof" = "yes"; then CFLAGS="$CFLAGS -pg -g" CXXFLAGS="$CXXFLAGS -pg -g" fi fi dnl ------------------------------------------------------------------------- dnl External libs dnl LDFLAGS="$LDFLAGS -lpthread -lstdc++" dnl ######################################################################### dnl ### Output dnl ######################################################################### AC_SUBST(ZenLib_CXXFLAGS) AC_SUBST(ZenLib_LIBS) AC_SUBST(ZenLib_LIBS_Static) AC_SUBST(ZenLib_Unicode) AC_SUBST(ZenLib_wstring_missing) AC_SUBST(ZenLib_LargeFiles) AC_CONFIG_FILES(libzen-config, [chmod u+x libzen-config]) AC_CONFIG_FILES(libzen.pc) AC_OUTPUT(Makefile) dnl ######################################################################### dnl ### Report how we have been configured dnl ######################################################################### echo "" echo "Configured ZenLib for '$build'" echo "" echo " Unicode? $enable_unicode" echo " Large files support? $enable_large_files" echo " wstring missing support? $enable_wstring_missing" echo " stream missing support? $enable_stream_missing" echo "" echo " Create static lib? $enable_static" echo " Create shared lib? $enable_shared" echo "" echo " CXXFLAGS: $CXXFLAGS" echo " LIBS: $LIBS" ZenLib/Project/GNU/Library/Makefile.am0000664000000000000000000000674012615631146016454 0ustar rootrootAUTOMAKE_OPTIONS = foreign lib_LTLIBRARIES = libzen.la libzen_la_SOURCES = \ ../../../Source/ZenLib/Conf.cpp \ ../../../Source/ZenLib/CriticalSection.cpp \ ../../../Source/ZenLib/Dir.cpp \ ../../../Source/ZenLib/File.cpp \ ../../../Source/ZenLib/FileName.cpp \ ../../../Source/ZenLib/InfoMap.cpp \ ../../../Source/ZenLib/int128s.cpp \ ../../../Source/ZenLib/int128u.cpp \ ../../../Source/ZenLib/MemoryDebug.cpp \ ../../../Source/ZenLib/OS_Utils.cpp \ ../../../Source/ZenLib/Translation.cpp \ ../../../Source/ZenLib/Thread.cpp \ ../../../Source/ZenLib/Utils.cpp \ ../../../Source/ZenLib/Ztring.cpp \ ../../../Source/ZenLib/ZtringList.cpp \ ../../../Source/ZenLib/ZtringListList.cpp \ ../../../Source/ZenLib/ZtringListListF.cpp \ ../../../Source/ZenLib/Format/Html/Html_Handler.cpp \ ../../../Source/ZenLib/Format/Html/Html_Request.cpp \ ../../../Source/ZenLib/Format/Http/Http_Cookies.cpp \ ../../../Source/ZenLib/Format/Http/Http_Handler.cpp \ ../../../Source/ZenLib/Format/Http/Http_Request.cpp \ ../../../Source/ZenLib/Format/Http/Http_Utils.cpp libzen_la_LDFLAGS = -no-undefined -version-info 0:0:0 zenincludedir = $(includedir)/ZenLib zeninclude_HEADERS = \ ../../../Source/ZenLib/BitStream.h \ ../../../Source/ZenLib/BitStream_Fast.h \ ../../../Source/ZenLib/BitStream_LE.h \ ../../../Source/ZenLib/Conf.h \ ../../../Source/ZenLib/Conf_Internal.h \ ../../../Source/ZenLib/CriticalSection.h \ ../../../Source/ZenLib/Dir.h \ ../../../Source/ZenLib/File.h \ ../../../Source/ZenLib/FileName.h \ ../../../Source/ZenLib/HTTP_Client.h \ ../../../Source/ZenLib/InfoMap.h \ ../../../Source/ZenLib/int128s.h \ ../../../Source/ZenLib/int128u.h \ ../../../Source/ZenLib/MemoryDebug.h \ ../../../Source/ZenLib/OS_Utils.h \ ../../../Source/ZenLib/PreComp.h \ ../../../Source/ZenLib/Thread.h \ ../../../Source/ZenLib/Trace.h \ ../../../Source/ZenLib/Translation.h \ ../../../Source/ZenLib/Utils.h \ ../../../Source/ZenLib/Ztring.h \ ../../../Source/ZenLib/ZtringList.h \ ../../../Source/ZenLib/ZtringListListF.h \ ../../../Source/ZenLib/ZtringListList.h zen_httpclientdir = $(zenincludedir)/HTTP_Client zen_httpclient_HEADERS = \ ../../../Source/ZenLib/HTTP_Client/HTTPClient.h \ ../../../Source/ZenLib/HTTP_Client/HTTPClientCommon.h \ ../../../Source/ZenLib/HTTP_Client/HTTPClientString.h \ ../../../Source/ZenLib/HTTP_Client/HTTPClientAuth.h \ ../../../Source/ZenLib/HTTP_Client/HTTPClientWrapper.h zen_format_htmldir = $(zenincludedir)/Format/Html zen_format_html_HEADERS = \ ../../../Source/ZenLib/Format/Html/Html_Handler.h \ ../../../Source/ZenLib/Format/Html/Html_Request.h zen_format_httpdir = $(zenincludedir)/Format/Http zen_format_http_HEADERS = \ ../../../Source/ZenLib/Format/Http/Http_Utils.h \ ../../../Source/ZenLib/Format/Http/Http_Request.h \ ../../../Source/ZenLib/Format/Http/Http_Handler.h \ ../../../Source/ZenLib/Format/Http/Http_Cookies.h bin_SCRIPTS = libzen-config pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = libzen.pc AM_CPPFLAGS = -I../../../Source ZenLib/Project/CMake/0000775000000000000000000000000012615631146013334 5ustar rootrootZenLib/Project/CMake/ZenLibConfig.cmake.in0000664000000000000000000000020412615631146017250 0ustar rootroot@PACKAGE_INIT@ if(NOT TARGET zen) include(${CMAKE_CURRENT_LIST_DIR}/ZenLibTargets.cmake) endif() set(ZenLib_LIBRARY zen) ZenLib/Project/CMake/size_t_is_long_check.cpp0000664000000000000000000000020112615631146020175 0ustar rootroot#include void foo(signed int) {} void foo(unsigned int) {} int main () { foo(size_t(0)); return 0; } ZenLib/Project/CMake/libzen.pc.in0000664000000000000000000000047212615631146015553 0ustar rootrootprefix=@CMAKE_INSTALL_PREFIX@ exec_prefix=${prefix} libdir=@LIB_INSTALL_DIR@ includedir=@INCLUDE_INSTALL_DIR@ Unicode=@ZenLib_Unicode@ Name: libzen Version: @ZenLib_VERSION_STRING@ Description: ZenLib Libs: -L${libdir} -lzen -lpthread -lstdc++ Cflags: -I${includedir} @ZenLib_CXXFLAGS@ Requires: zlib ZenLib/Project/CMake/CMakeLists.txt0000664000000000000000000001506612615631146016104 0ustar rootrootproject(ZenLib) cmake_minimum_required(VERSION 2.8.11) if(WIN32) option(BUILD_SHARED_LIBS "Build shared libs" OFF) else() option(BUILD_SHARED_LIBS "Build shared libs" ON) endif() option(ENABLE_UNICODE "Enable unicode support" ON) set(ZenLib_SOURCES_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../Source) set(ZenLib_MAJOR_VERSION "0") set(ZenLib_MINOR_VERSION "4") set(ZenLib_PATCH_VERSION "32") set(ZenLib_VERSION_STRING "${ZenLib_MAJOR_VERSION}.${ZenLib_MINOR_VERSION}.${ZenLib_PATCH_VERSION}") # On Windows debug library should have 'd' postfix. if(WIN32) set(CMAKE_DEBUG_POSTFIX "d") elseif(APPLE) set(CMAKE_DEBUG_POSTFIX "_debug") endif() include(GNUInstallDirs) set(LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)" ) set(BIN_INSTALL_DIR "${CMAKE_INSTALL_FULL_BINDIR}" CACHE STRING "Directory where binary will install") set(LIB_INSTALL_DIR "${CMAKE_INSTALL_FULL_LIBDIR}" CACHE STRING "Directory where library will install") set(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_FULL_INCLUDEDIR}" CACHE PATH "The directory the headers are installed in") if(NOT MSVC) set(ZenLib_CONFIG_INSTALL_DIR "${LIB_INSTALL_DIR}/cmake/zenlib") else() set(ZenLib_CONFIG_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/cmake/") endif() set(ZenLib_HDRS ${ZenLib_SOURCES_PATH}/ZenLib/BitStream.h ${ZenLib_SOURCES_PATH}/ZenLib/BitStream_Fast.h ${ZenLib_SOURCES_PATH}/ZenLib/BitStream_LE.h ${ZenLib_SOURCES_PATH}/ZenLib/Conf.h ${ZenLib_SOURCES_PATH}/ZenLib/Conf_Internal.h ${ZenLib_SOURCES_PATH}/ZenLib/CriticalSection.h ${ZenLib_SOURCES_PATH}/ZenLib/Dir.h ${ZenLib_SOURCES_PATH}/ZenLib/File.h ${ZenLib_SOURCES_PATH}/ZenLib/FileName.h ${ZenLib_SOURCES_PATH}/ZenLib/Format/Html/Html_Handler.h ${ZenLib_SOURCES_PATH}/ZenLib/Format/Html/Html_Request.h ${ZenLib_SOURCES_PATH}/ZenLib/Format/Http/Http_Cookies.h ${ZenLib_SOURCES_PATH}/ZenLib/Format/Http/Http_Handler.h ${ZenLib_SOURCES_PATH}/ZenLib/Format/Http/Http_Request.h ${ZenLib_SOURCES_PATH}/ZenLib/Format/Http/Http_Utils.h ${ZenLib_SOURCES_PATH}/ZenLib/InfoMap.h ${ZenLib_SOURCES_PATH}/ZenLib/MemoryDebug.h ${ZenLib_SOURCES_PATH}/ZenLib/OS_Utils.h ${ZenLib_SOURCES_PATH}/ZenLib/PreComp.h ${ZenLib_SOURCES_PATH}/ZenLib/Thread.h ${ZenLib_SOURCES_PATH}/ZenLib/Trace.h ${ZenLib_SOURCES_PATH}/ZenLib/Translation.h ${ZenLib_SOURCES_PATH}/ZenLib/Utils.h ${ZenLib_SOURCES_PATH}/ZenLib/Ztring.h ${ZenLib_SOURCES_PATH}/ZenLib/ZtringList.h ${ZenLib_SOURCES_PATH}/ZenLib/ZtringListList.h ${ZenLib_SOURCES_PATH}/ZenLib/ZtringListListF.h ${ZenLib_SOURCES_PATH}/ZenLib/int128s.h ${ZenLib_SOURCES_PATH}/ZenLib/int128u.h ) set(ZenLib_SRCS ${ZenLib_SOURCES_PATH}/ZenLib/Conf.cpp ${ZenLib_SOURCES_PATH}/ZenLib/CriticalSection.cpp ${ZenLib_SOURCES_PATH}/ZenLib/Dir.cpp ${ZenLib_SOURCES_PATH}/ZenLib/File.cpp ${ZenLib_SOURCES_PATH}/ZenLib/FileName.cpp ${ZenLib_SOURCES_PATH}/ZenLib/InfoMap.cpp ${ZenLib_SOURCES_PATH}/ZenLib/int128s.cpp ${ZenLib_SOURCES_PATH}/ZenLib/int128u.cpp ${ZenLib_SOURCES_PATH}/ZenLib/MemoryDebug.cpp ${ZenLib_SOURCES_PATH}/ZenLib/OS_Utils.cpp ${ZenLib_SOURCES_PATH}/ZenLib/Translation.cpp ${ZenLib_SOURCES_PATH}/ZenLib/Thread.cpp ${ZenLib_SOURCES_PATH}/ZenLib/Utils.cpp ${ZenLib_SOURCES_PATH}/ZenLib/Ztring.cpp ${ZenLib_SOURCES_PATH}/ZenLib/ZtringList.cpp ${ZenLib_SOURCES_PATH}/ZenLib/ZtringListList.cpp ${ZenLib_SOURCES_PATH}/ZenLib/ZtringListListF.cpp ${ZenLib_SOURCES_PATH}/ZenLib/Format/Html/Html_Handler.cpp ${ZenLib_SOURCES_PATH}/ZenLib/Format/Html/Html_Request.cpp ${ZenLib_SOURCES_PATH}/ZenLib/Format/Http/Http_Cookies.cpp ${ZenLib_SOURCES_PATH}/ZenLib/Format/Http/Http_Handler.cpp ${ZenLib_SOURCES_PATH}/ZenLib/Format/Http/Http_Request.cpp ${ZenLib_SOURCES_PATH}/ZenLib/Format/Http/Http_Utils.cpp ) add_library(zen ${ZenLib_SRCS} ${ZenLib_HDRS}) if(ENABLE_UNICODE) set(ZenLib_Unicode "yes") set(ZenLib_CXXFLAGS -DUNICODE) target_compile_definitions(zen PUBLIC UNICODE) else() set(ZenLib_Unicode "no") endif() try_compile(SIZE_T_IS_NOT_LONG ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/size_t_is_long_check.cpp) if(NOT SIZE_T_IS_NOT_LONG) target_compile_definitions(zen PUBLIC SIZE_T_IS_LONG) endif() target_include_directories(zen INTERFACE ${INCLUDE_INSTALL_DIR}) target_include_directories(zen PRIVATE ${ZenLib_SOURCES_PATH}) set_target_properties(zen PROPERTIES VERSION ${ZenLib_MAJOR_VERSION}.${ZenLib_MINOR_VERSION}.${ZenLib_PATCH_VERSION} SOVERSION ${ZenLib_MAJOR_VERSION} ) if(MSVC) get_target_property(LOCATION zen LOCATION_DEBUG) string(REGEX REPLACE "\\.[^.]*$" ".pdb" LOCATION "${LOCATION}") install(FILES ${LOCATION} DESTINATION ${BIN_INSTALL_DIR} CONFIGURATIONS Debug) get_target_property(LOCATION zen LOCATION_RELWITHDEBINFO) string(REGEX REPLACE "\\.[^.]*$" ".pdb" LOCATION "${LOCATION}") install(FILES ${LOCATION} DESTINATION ${BIN_INSTALL_DIR} CONFIGURATIONS RelWithDebInfo) endif() install(TARGETS zen EXPORT zen-export RUNTIME DESTINATION ${BIN_INSTALL_DIR} ARCHIVE DESTINATION ${LIB_INSTALL_DIR} LIBRARY DESTINATION ${LIB_INSTALL_DIR}) install(EXPORT zen-export DESTINATION ${ZenLib_CONFIG_INSTALL_DIR} FILE ZenLibTargets.cmake) foreach(HEADER ${ZenLib_HDRS}) string(REPLACE ${ZenLib_SOURCES_PATH} "" DIR ${HEADER}) string(REGEX REPLACE "/[^/]*$" "" DIR ${DIR}) install(FILES ${HEADER} DESTINATION include/${DIR}) endforeach() configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY) # pkg-config if(NOT WIN32) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libzen.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libzen.pc @ONLY) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libzen.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) endif() # cmake-modules include(CMakePackageConfigHelpers) configure_package_config_file( ZenLibConfig.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/ZenLibConfig.cmake" INSTALL_DESTINATION ${ZenLib_CONFIG_INSTALL_DIR} PATH_VARS BIN_INSTALL_DIR LIB_INSTALL_DIR INCLUDE_INSTALL_DIR) write_basic_config_version_file(ZenLibConfigVersion.cmake VERSION ${ZenLib_VERSION_STRING} COMPATIBILITY AnyNewerVersion) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ZenLibConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/ZenLibConfigVersion.cmake DESTINATION ${ZenLib_CONFIG_INSTALL_DIR}) if(NOT TARGET uninstall) add_custom_target(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake") endif() ZenLib/Project/CMake/cmake_uninstall.cmake.in0000664000000000000000000000137012615631146020115 0ustar rootrootif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") message(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"") endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) string(REGEX REPLACE "\n" ";" files "${files}") foreach(file ${files}) message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"") exec_program( "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" OUTPUT_VARIABLE rm_out RETURN_VALUE rm_retval ) if(NOT "${rm_retval}" STREQUAL 0) message(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"") endif(NOT "${rm_retval}" STREQUAL 0) endforeach(file) ZenLib/Project/MSVC2013/0000775000000000000000000000000012615631146013432 5ustar rootrootZenLib/Project/MSVC2013/CleanUp.bat0000664000000000000000000000116012615631146015447 0ustar rootroot@echo off rem MS Visual Studio specific --- if exist *.opensdf del *.opensdf if exist *.sdf del *.sdf pushd Example if exist Debug rmdir Debug /Q /S if exist Release rmdir Release /Q /S if exist Win32 rmdir Win32 /Q /S if exist x64 rmdir x64 /Q /S if exist *.ncb del *.ncb if exist *.user del *.user if exist *.suo del *.suo /AH popd pushd Library if exist Debug rmdir Debug /Q /S if exist Release rmdir Release /Q /S if exist Win32 rmdir Win32 /Q /S if exist x64 rmdir x64 /Q /S if exist *.ncb del *.ncb if exist *.user del *.user if exist *.suo del *.suo /AH popd ZenLib/Project/MSVC2013/ZenLib_MSVC.sln0000664000000000000000000000402612615631146016165 0ustar rootrootMicrosoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2013 VisualStudioVersion = 12.0.20827.3 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ZenLib", "Library\ZenLib.vcxproj", "{0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Debug|x64 = Debug|x64 DebugA|Win32 = DebugA|Win32 DebugA|x64 = DebugA|x64 Release|Win32 = Release|Win32 Release|x64 = Release|x64 ReleaseA|Win32 = ReleaseA|Win32 ReleaseA|x64 = ReleaseA|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.Debug|Win32.ActiveCfg = Debug|Win32 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.Debug|Win32.Build.0 = Debug|Win32 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.Debug|x64.ActiveCfg = Debug|x64 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.Debug|x64.Build.0 = Debug|x64 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.DebugA|Win32.ActiveCfg = DebugA|Win32 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.DebugA|Win32.Build.0 = DebugA|Win32 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.DebugA|x64.ActiveCfg = DebugA|x64 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.DebugA|x64.Build.0 = DebugA|x64 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.Release|Win32.ActiveCfg = Release|Win32 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.Release|Win32.Build.0 = Release|Win32 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.Release|x64.ActiveCfg = Release|x64 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.Release|x64.Build.0 = Release|x64 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.ReleaseA|Win32.ActiveCfg = ReleaseA|Win32 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.ReleaseA|Win32.Build.0 = ReleaseA|Win32 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.ReleaseA|x64.ActiveCfg = ReleaseA|x64 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.ReleaseA|x64.Build.0 = ReleaseA|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal ZenLib/Project/MSVC2013/Library/0000775000000000000000000000000012615631146015036 5ustar rootrootZenLib/Project/MSVC2013/Library/ZenLib.vcxproj0000664000000000000000000007275212615631146017653 0ustar rootroot DebugA ARM DebugA Win32 DebugA x64 Debug ARM Debug Win32 Debug x64 ReleaseA ARM ReleaseA Win32 ReleaseA x64 Release ARM Release Win32 Release x64 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94} ZenLib Win32Proj StaticLibrary MultiByte v120_xp true StaticLibrary MultiByte v120 true true StaticLibrary MultiByte true v120_xp StaticLibrary MultiByte true v120 true StaticLibrary Unicode true v120_xp StaticLibrary Unicode true v120 true StaticLibrary v120_xp Unicode true StaticLibrary v120 Unicode true true StaticLibrary MultiByte v120_xp true StaticLibrary MultiByte true v120_xp StaticLibrary Unicode true v120_xp StaticLibrary Unicode v120_xp true <_ProjectFileVersion>10.0.30128.1 $(Platform)\$(Configuration)\ $(Platform)\$(Configuration)\ $(Platform)\$(Configuration)\Intermediate\ $(Platform)\$(Configuration)\Intermediate\ $(Platform)\$(Configuration)\ $(Platform)\$(Configuration)\Intermediate\ $(Platform)\$(Configuration)\ $(Platform)\$(Configuration)\ $(Platform)\$(Configuration)\Intermediate\ $(Platform)\$(Configuration)\Intermediate\ $(Platform)\$(Configuration)\ $(Platform)\$(Configuration)\Intermediate\ $(Platform)\$(Configuration)\ $(Platform)\$(Configuration)\ $(Platform)\$(Configuration)\Intermediate\ $(Platform)\$(Configuration)\Intermediate\ $(Platform)\$(Configuration)\ $(Platform)\$(Configuration)\Intermediate\ $(Platform)\$(Configuration)\ $(Platform)\$(Configuration)\ $(Platform)\$(Configuration)\Intermediate\ $(Platform)\$(Configuration)\Intermediate\ $(Platform)\$(Configuration)\ $(Platform)\$(Configuration)\Intermediate\ Disabled ../../../Source;../../../../zlib;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebug Use ZenLib/PreComp.h true Level4 4100;4996;4127;%(DisableSpecificWarnings) StreamingSIMDExtensions MachineX86 Disabled ../../../Source;../../../../zlib;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebug Use ZenLib/PreComp.h true Level4 4100;4996;4127;%(DisableSpecificWarnings) MachineX86 Disabled ../../../Source;../../../../zlib;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) MultiThreadedDebug Level4 EnableFastChecks true Use ZenLib/PreComp.h 4100;4996;4127;%(DisableSpecificWarnings) MachineX64 MaxSpeed ../../../Source;../../../../zlib;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) MultiThreaded Level4 true Use ZenLib/PreComp.h 4100;4996;4127;%(DisableSpecificWarnings) StreamingSIMDExtensions MachineX86 MaxSpeed ../../../Source;../../../../zlib;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) MultiThreaded Level4 true Use ZenLib/PreComp.h 4100;4996;4127;%(DisableSpecificWarnings) MachineX86 MaxSpeed ../../../Source;../../../../zlib;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) MultiThreaded Level4 true Use ZenLib/PreComp.h 4100;4996;4127;%(DisableSpecificWarnings) MachineX64 MaxSpeed ../../../Source;../../../../zlib;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) MultiThreaded Level4 true Use ZenLib/PreComp.h 4100;4996;4127;%(DisableSpecificWarnings) StreamingSIMDExtensions MachineX86 MaxSpeed ../../../Source;../../../../zlib;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) MultiThreaded Level4 true Use ZenLib/PreComp.h 4100;4996;4127;%(DisableSpecificWarnings) MachineX86 MaxSpeed ../../../Source;../../../../zlib;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) MultiThreaded Level4 true Use ZenLib/PreComp.h 4100;4996;4127;%(DisableSpecificWarnings) MachineX64 Disabled ../../../Source;../../../../zlib;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebug Level4 true Use ZenLib/PreComp.h 4100;4996;4127;%(DisableSpecificWarnings) StreamingSIMDExtensions MachineX86 Disabled ../../../Source;../../../../zlib;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebug Level4 true Use ZenLib/PreComp.h 4100;4996;4127;%(DisableSpecificWarnings) MachineX86 Disabled ../../../Source;../../../../zlib;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebug Level4 ProgramDatabase true Use ZenLib/PreComp.h 4100;4996;4127;%(DisableSpecificWarnings) MachineX64 Create Create Create Create Create Create Create Create Create Create Create Create ZenLib/Project/MSVC2013/Library/ZenLib.vcxproj.filters0000664000000000000000000002014712615631146021311 0ustar rootroot {4FC737F1-C7A5-4376-A066-2A32D752A2FF} cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx {b0e0820a-9895-4fee-8a01-7583d157cda3} {a987454d-645c-4a63-bc84-ffc79ae4679d} {e2876701-1853-42b5-a385-15d45b825a88} {93995380-89BD-4b04-88EB-625FBE52EBFB} h;hpp;hxx;hm;inl;inc;xsd {14855e7b-4367-4780-9bdb-48a7e942fd23} {5cfba4eb-2f03-4a6b-8f8a-a8a0dbfb4802} {16c53209-3c96-4ded-b925-c5cd36c4858f} Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files\Format\Http Source Files\Format\Http Source Files\Format\Http Source Files\Format\Http Source Files\Format\Html Source Files\Format\Html Source Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files\Format\Html Header Files\Format\Html Header Files\Format\Http Header Files\Format\Http Header Files\Format\Http Header Files\Format\Http Header Files Header Files Header Files ZenLib/Project/MSVC2013/Example/0000775000000000000000000000000012615631146015025 5ustar rootrootZenLib/Project/MSVC2013/Example/ZenLib_Test.vcxproj.filters0000664000000000000000000000102012615631146022264 0ustar rootroot {5fc02ff6-0eab-4a4f-a754-256dd82d27af} cpp;c;cxx;def;odl;idl;hpj;bat;asm Source Files ZenLib/Project/MSVC2013/Example/ZenLib_Test.vcxproj0000664000000000000000000001021512615631146020623 0ustar rootroot Release_Ansi Win32 Release Win32 {425F07FD-D7F7-467F-B213-8B60635582F2} Win32Proj Application MultiByte Application Unicode <_ProjectFileVersion>10.0.40219.1 Release\ Release\ Release_Ansi\ Release_Ansi\ ../../../Source;%(AdditionalIncludeDirectories) WIN32;NDEBUG;%(PreprocessorDefinitions) Level4 comctl32.lib;WxJpeg.lib;WxPng.lib;WxTiff.lib;WxWidgets.lib;ZenLib.lib;%(AdditionalDependencies) ../../../Release/MSVC/Library;../../../../Shared/Library/MSVC comctl32.lib;WxJpeg.lib;WxPng.lib;WxTiff.lib;WxWidgets.lib;ZenLib.lib;%(AdditionalDependencies) ../../../Source;%(AdditionalIncludeDirectories) WIN32;NDEBUG;%(PreprocessorDefinitions) Level4 ZenLibA.lib;WxBaseA.lib;%(AdditionalDependencies) ../../../ReleaseA/MSVC/Library;../../../../Shared/Library/MSVC ZenLib/Project/MSVC2013/Example/ZenLib_Test.sln0000664000000000000000000000164012615631146017726 0ustar rootrootMicrosoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2012 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ZenLib_Test", "ZenLib_Test.vcxproj", "{425F07FD-D7F7-467F-B213-8B60635582F2}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Release_Ansi|Win32 = Release_Ansi|Win32 Release|Win32 = Release|Win32 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {425F07FD-D7F7-467F-B213-8B60635582F2}.Release_Ansi|Win32.ActiveCfg = Release_Ansi|Win32 {425F07FD-D7F7-467F-B213-8B60635582F2}.Release_Ansi|Win32.Build.0 = Release_Ansi|Win32 {425F07FD-D7F7-467F-B213-8B60635582F2}.Release|Win32.ActiveCfg = Release|Win32 {425F07FD-D7F7-467F-B213-8B60635582F2}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal ZenLib/Project/CodeBlocks/0000775000000000000000000000000012615631146014364 5ustar rootrootZenLib/Project/CodeBlocks/ZenLib.workspace0000664000000000000000000000033312615631146017466 0ustar rootroot ZenLib/Project/CodeBlocks/CleanUp.bat0000664000000000000000000000012712615631146016403 0ustar rootroot@rem echo off @rem Code::Blocks specific --- cd Library rmdir .objs /Q /S cd .. ZenLib/Project/CodeBlocks/Library/0000775000000000000000000000000012615631146015770 5ustar rootrootZenLib/Project/CodeBlocks/Library/ZenLib.cbp0000664000000000000000000000526212615631146017646 0ustar rootroot ZenLib/Project/Coverity/0000775000000000000000000000000012615631146014160 5ustar rootrootZenLib/Project/Coverity/coverity.bat0000664000000000000000000000406312615631146016517 0ustar rootroot@ECHO OFF REM Script taken from MPC-HC, https://github.com/mpc-hc/mpc-hc SETLOCAL PUSHD %~dp0 IF NOT DEFINED COVDIR SET "COVDIR=H:\progs\thirdparty\cov-analysis-win64" IF DEFINED COVDIR IF NOT EXIST "%COVDIR%" ( ECHO. ECHO ERROR: Coverity not found in "%COVDIR%" GOTO End ) CALL "%VS120COMNTOOLS%..\..\VC\vcvarsall.bat" x86 IF %ERRORLEVEL% NEQ 0 ( ECHO vcvarsall.bat call failed. GOTO End ) :Cleanup IF EXIST "cov-int" RD /q /s "cov-int" IF EXIST "ZenLib.lzma" DEL "ZenLib.lzma" IF EXIST "ZenLib.tar" DEL "ZenLib.tar" IF EXIST "ZenLib.tgz" DEL "ZenLib.tgz" :Main SET MSBUILD_SWITCHES=/nologo /consoleloggerparameters:Verbosity=minimal /maxcpucount^ /nodeReuse:true /target:ZenLib:Rebuild /property:Configuration="Release";Platform=%1 "%COVDIR%\bin\cov-build.exe" --dir cov-int MSBuild "..\MSVC2013\ZenLib_MSVC.sln" %MSBUILD_SWITCHES%Win32 "%COVDIR%\bin\cov-build.exe" --dir cov-int MSBuild "..\MSVC2013\ZenLib_MSVC.sln" %MSBUILD_SWITCHES%x64 :tar tar --version 1>&2 2>NUL || (ECHO. & ECHO ERROR: tar not found & GOTO SevenZip) tar caf "ZenLib.lzma" "cov-int" GOTO End :SevenZip CALL :SubDetectSevenzipPath rem Coverity is totally bogus with lzma... rem And since I cannot replicate the arguments with 7-Zip, just use tar/gzip. IF EXIST "%SEVENZIP%" ( "%SEVENZIP%" a -ttar "ZenLib.tar" "cov-int" "%SEVENZIP%" a -tgzip "ZenLib.tgz" "ZenLib.tar" IF EXIST "ZenLib.tar" DEL "ZenLib.tar" GOTO End ) :SubDetectSevenzipPath FOR %%G IN (7z.exe) DO (SET "SEVENZIP_PATH=%%~$PATH:G") IF EXIST "%SEVENZIP_PATH%" (SET "SEVENZIP=%SEVENZIP_PATH%" & EXIT /B) FOR %%G IN (7za.exe) DO (SET "SEVENZIP_PATH=%%~$PATH:G") IF EXIST "%SEVENZIP_PATH%" (SET "SEVENZIP=%SEVENZIP_PATH%" & EXIT /B) FOR /F "tokens=2*" %%A IN ( 'REG QUERY "HKLM\SOFTWARE\7-Zip" /v "Path" 2^>NUL ^| FIND "REG_SZ" ^|^| REG QUERY "HKLM\SOFTWARE\Wow6432Node\7-Zip" /v "Path" 2^>NUL ^| FIND "REG_SZ"') DO SET "SEVENZIP=%%B\7z.exe" EXIT /B :End POPD ECHO. & ECHO Press any key to close this window... PAUSE >NUL ENDLOCAL EXIT /B ZenLib/Project/OBS/0000775000000000000000000000000012615631146012777 5ustar rootrootZenLib/Project/OBS/deb6.dsc0000664000000000000000000000054712615631146014320 0ustar rootrootFormat: 1.0 Source: libzen Binary: libzen-dev, libzen0 Architecture: any Version: 0.4.32 Maintainer: MediaArea.net SARL Homepage: http://mediainfo.sourceforge.net Standards-Version: 3.7.3 Build-Depends: debhelper (>= 5), doxygen, tofrodos, automake, autoconf, libtool Files: 00000000000000000000000000000000 000000 libzen_0.4.32.tar.gz ZenLib/Project/OBS/deb6.debian/0000775000000000000000000000000012615631146015040 5ustar rootrootZenLib/Project/OBS/deb6.debian/libzen-dev.dirs0000664000000000000000000000030012615631146017753 0ustar rootrootusr/lib usr/lib/pkgconfig usr/include/ZenLib usr/include/ZenLib/HTTP_Client usr/include/ZenLib/Format/Html usr/include/ZenLib/Format/Http usr/share/doc/libzen-dev usr/share/doc/libzen-dev/Doc ZenLib/Project/OBS/deb6.debian/libzen0.install0000664000000000000000000000016712615631146017777 0ustar rootrootusr/lib/lib*.so.* usr/share/doc/libzen0/History.txt usr/share/doc/libzen0/License.txt usr/share/doc/libzen0/ReadMe.txt ZenLib/Project/OBS/deb6.debian/compat0000664000000000000000000000000212615631146016236 0ustar rootroot5 ZenLib/Project/OBS/deb6.debian/copyright0000664000000000000000000000104112615631146016767 0ustar rootrootThis package was debianized by MediaArea.net SARL on Wed, 26 Nov 2008 20:19:43 +0100. It was downloaded from Upstream Author(s): MediaArea.net SARL Copyright: License: Zlib The Debian packaging is (C) 2009, MediaArea.net SARL and is licensed under the Zlib license. # Please also look if there are files or directories which have a # different copyright/license attached and list them here. ZenLib/Project/OBS/deb6.debian/control0000664000000000000000000000134312615631146016444 0ustar rootrootSource: libzen Priority: optional Maintainer: MediaArea.net SARL Build-Depends: debhelper (>= 5), doxygen, tofrodos, automake, autoconf, libtool Standards-Version: 3.7.3 Section: libs Homepage: http://mediainfo.sourceforge.net Vcs-Svn: https://zenlib.svn.sourceforge.net/svnroot/zenlib/ZenLib/ Vcs-Browser: http://zenlib.svn.sourceforge.net/viewvc/zenlib/ZenLib/ Package: libzen-dev Section: libdevel Architecture: any Depends: libzen0 (>=0.4.32) Description: libmediainfo mandatory library (dev) This package includes the development support files Package: libzen0 Section: libs Architecture: any Depends: Replaces: libzen0-dev Description: libmediainfo mandatory library This package includes the shared library ZenLib/Project/OBS/deb6.debian/changelog0000664000000000000000000000024612615631146016714 0ustar rootrootlibzen (0.4.32) unstable; urgency=low * See History.txt for more info and real dates -- MediaArea.net SARL Thu, 01 Jan 2009 00:04:32 +0000 ZenLib/Project/OBS/deb6.debian/libzen-dev.install0000664000000000000000000000036412615631146020472 0ustar rootrootusr/lib/lib*.so usr/lib/*.la usr/lib/pkgconfig/* usr/include/ZenLib/* usr/include/ZenLib/HTTP_Client/* usr/include/ZenLib/Format/Html/* usr/include/ZenLib/Format/Http/* usr/share/doc/libzen-dev/Documentation.html usr/share/doc/libzen-dev/Doc/* ZenLib/Project/OBS/deb6.debian/libzen0.dirs0000664000000000000000000000003612615631146017265 0ustar rootrootusr/lib usr/share/doc/libzen0 ZenLib/Project/OBS/deb6.debian/rules0000664000000000000000000000664312615631146016126 0ustar rootroot#!/usr/bin/make -f # -*- makefile -*- # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 # shared library versions version=`ls src/.libs/lib*.so.* | \ awk '{if (match($$0,/[0-9]+\.[0-9]+\.[0-9]+$$/)) print substr($$0,RSTART)}'` major=`ls src/.libs/lib*.so.* | \ awk '{if (match($$0,/\.so\.[0-9]+$$/)) print substr($$0,RSTART+4)}'` configure: configure-stamp configure-stamp: dh_testdir # Add here commands to configure the package. fromdos *.txt Source/Doc/*.html chmod 644 *.txt Source/Doc/*.html cd Source/Doc && doxygen Doxyfile cp Source/Doc/*.html ./ cd Project/GNU/Library && chmod u+x autogen.sh cd Project/GNU/Library && ./autogen.sh cd Project/GNU/Library && ./configure --disable-static --enable-shared --prefix=/usr touch $@ build: build-stamp build-stamp: configure-stamp dh_testdir # Add here commands to compile the package. cd Project/GNU/Library && $(MAKE) touch $@ clean: dh_testdir dh_testroot # Add here commands to clean up after the build process. # $(MAKE) clean dh_clean install: build dh_testdir dh_testroot dh_clean -k dh_installdirs # Add here commands to install the package into debian/tmp cd Project/GNU/Library && $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install install -dm 755 $(CURDIR)/debian/tmp/usr/include/ZenLib install -m 644 Source/ZenLib/*.h $(CURDIR)/debian/tmp/usr/include/ZenLib install -dm 755 $(CURDIR)/debian/tmp/usr/include/ZenLib/HTTP_Client install -m 644 Source/ZenLib/HTTP_Client/*.h $(CURDIR)/debian/tmp/usr/include/ZenLib/HTTP_Client install -dm 755 $(CURDIR)/debian/tmp/usr/include/ZenLib/Format/Html install -m 644 Source/ZenLib/Format/Html/*.h $(CURDIR)/debian/tmp/usr/include/ZenLib/Format/Html install -dm 755 $(CURDIR)/debian/tmp/usr/include/ZenLib/Format/Http install -m 644 Source/ZenLib/Format/Http/*.h $(CURDIR)/debian/tmp/usr/include/ZenLib/Format/Http sed -i -e 's|Version: |Version: %{version}|g' Project/GNU/Library/libzen.pc install -dm 755 $(CURDIR)/debian/tmp/usr/lib/pkgconfig install -m 644 Project/GNU/Library/libzen.pc $(CURDIR)/debian/tmp/usr/lib/pkgconfig install -dm 755 $(CURDIR)/debian/tmp/usr/share/doc/libzen0 install -m 644 *.txt $(CURDIR)/debian/tmp/usr/share/doc/libzen0 install -dm 755 $(CURDIR)/debian/tmp/usr/share/doc/libzen-dev install -m 644 Documentation.html $(CURDIR)/debian/tmp/usr/share/doc/libzen-dev install -dm 755 $(CURDIR)/debian/tmp/usr/share/doc/libzen-dev/Doc install -m 644 Doc/*.* $(CURDIR)/debian/tmp/usr/share/doc/libzen-dev/Doc if test -d Doc/search/ ; then install -dm 755 $(CURDIR)/debian/tmp/usr/share/doc/libzen-dev/Doc/search ; fi if test -d Doc/search/ ; then install -m 644 Doc/search/*.* $(CURDIR)/debian/tmp/usr/share/doc/libzen-dev/Doc/search ; fi # Build architecture-independent files here. binary-indep: build install # We have nothing to do by default. # Build architecture-dependent files here. binary-arch: build install dh_testdir dh_testroot dh_install --sourcedir=debian/tmp dh_installchangelogs dh_installdocs dh_installexamples # dh_install # dh_installmenu # dh_installdebconf # dh_installlogrotate # dh_installemacsen # dh_installpam # dh_installmime # dh_installinit # dh_installcron # dh_installinfo dh_installman dh_link dh_strip dh_compress dh_fixperms # dh_perl # dh_python dh_makeshlibs dh_installdeb dh_shlibdeps dh_gencontrol dh_md5sums dh_builddeb binary: binary-indep binary-arch .PHONY: build clean binary-indep binary-arch binary install configure ZenLib/Project/BCB/0000775000000000000000000000000012615631146012742 5ustar rootrootZenLib/Project/BCB/CleanUp.bat0000664000000000000000000000123512615631146014762 0ustar rootroot@rem echo off @rem Borland Developper Studio specific --- cd Example del *.local cd Debug_Build del *.* /Q cd .. cd Release_Build del *.* /Q cd .. cd .. cd Library del *.local cd Debug_Build del *.* /Q cd .. cd Release_Build del *.* /Q cd .. cd .. @rem Borland __history files --- rmdir Example\__history /Q /S rmdir Library\__history/Q /S rmdir ..\..\Source\ZenLib\__history/Q /S rmdir ..\..\Source\ZenLib\Base64\__history/Q /S rmdir ..\..\Source\ZenLib\Format\__history/Q /S rmdir ..\..\Source\ZenLib\Format\Html\__history/Q /S rmdir ..\..\Source\ZenLib\Format\Http\__history/Q /S rmdir ..\..\Source\ZenLib\HTTP_Client\__history/Q /S ZenLib/Project/BCB/Library/0000775000000000000000000000000012615631146014346 5ustar rootrootZenLib/Project/BCB/Library/ZenLib.res0000664000000000000000000000014012615631146016237 0ustar rootroot ÿÿÿÿ<ÿÿ PLATFORMTARGETS0 ZenLib/Project/BCB/Library/ZenLib.cbproj0000664000000000000000000002640212615631146016736 0ustar rootroot {D690CA39-4FB9-4C60-A530-FB757CC20EE7} 13.4 None True Release Win32 1 StaticLibrary true true Base true true Base true true Base true true Cfg_2 true true ..\..\..\Source\ZenLib\HTTP_Client\;..\..\..\Source\ZenLib\Format\Http\;..\..\..\Source\ZenLib\Format\Html\;..\..\..\Source\;..\..\..\Source\ZenLib\;$(IncludePath) None CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0 1036 rtl.lib IPIndyImpl;bindcompfmx;fmx;rtl;dbrtl;IndySystem;DbxClientDriver;bindcomp;inetdb;DBXInterBaseDriver;DataSnapCommon;DataSnapClient;DataSnapServer;DataSnapProviderClient;xmlrtl;DbxCommonDriver;IndyProtocols;DBXMySQLDriver;dbxcds;bindengine;soaprtl;DBXOracleDriver;dsnap;DBXInformixDriver;IndyCore;fmxase;DBXFirebirdDriver;inet;fmxobj;inetdbxpress;DBXSybaseASADriver;fmxdae;dbexpress;DataSnapIndy10ServerTransport;$(PackageImports) true System;Xml;Data;Datasnap;Web;Soap;$(DCC_Namespace) CppStaticLibrary <_TCHARMapping>wchar_t JPHNE .\$(Platform)\$(Config) .\$(Platform)\$(Config) false true true $(BDSLIB)\$(PLATFORM)\release\$(LANGDIR);$(ILINK_TranslatedLibraryPath) Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) vcldbx;frx16;TeeDB;Rave100VCL;vclib;Tee;inetdbbde;DBXOdbcDriver;DBXSybaseASEDriver;ibxpress;vclimg;frxDB16;intrawebdb_120_160;fs16;TeeUI;FMXTee;vclactnband;vcldb;vcldsnap;bindcompvcl;vclie;vcltouch;Intraweb_120_160;DBXDb2Driver;bcbsmp;websnap;vclribbon;frxe16;VclSmp;fsDB16;vcl;DataSnapConnectors;CloudService;DBXMSSQLDriver;FmxTeeUI;dsnapcon;vclx;webdsnap;bdertl;adortl;bcbie;$(PackageImports) false true false true _DEBUG;$(Defines) false None DEBUG true true true true Full true $(BDSLIB)\$(PLATFORM)\debug;$(ILINK_LibraryPath) $(BDSLIB)\$(PLATFORM)\debug\$(LANGDIR);$(ILINK_TranslatedLibraryPath) NDEBUG;$(Defines) None CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0 None 1036 2 3 4 0 5 18 19 20 21 22 23 28 24 25 26 27 6 7 8 9 10 11 12 13 14 1 15 16 ..\..\..\Source\ZenLib\ZtringListListF.h 17 Cfg_2 Base Base Cfg_1 Base CPlusPlusBuilder.Personality.12 CppStaticLibrary False False 1 0 0 0 False False False False False 1036 1252 1.0.0.0 1.0.0.0 False True True False True 12 ZenLib/Project/BCB/Example/0000775000000000000000000000000012615631146014335 5ustar rootrootZenLib/Project/BCB/Example/ZenLib_Test.cbproj0000664000000000000000000002105412615631146017722 0ustar rootroot {8F106A80-C83E-442B-9D3C-EAE4467DCB6C} 13.4 None True Release Win32 1 Console true true Base true true Base true true Base true true Cfg_2 true true IPIndyImpl;bindcompfmx;fmx;rtl;dbrtl;IndySystem;DbxClientDriver;bindcomp;inetdb;DBXInterBaseDriver;DataSnapCommon;DataSnapClient;DataSnapServer;DataSnapProviderClient;xmlrtl;DbxCommonDriver;IndyProtocols;DBXMySQLDriver;dbxcds;bindengine;soaprtl;DBXOracleDriver;dsnap;DBXInformixDriver;IndyCore;fmxase;DBXFirebirdDriver;inet;fmxobj;inetdbxpress;DBXSybaseASADriver;fmxdae;dbexpress;DataSnapIndy10ServerTransport;$(PackageImports) ..\..\..\Source\Example\;D:\Programmation\ZenLib\Source\Example\;$(ILINK_LibraryPath) <_TCHARMapping>char System;Xml;Data;Datasnap;Web;Soap;$(DCC_Namespace) ..\..\..\Source\Example\;..\..\..\Source;$(IncludePath) CppConsoleApplication CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= None 1036 JPHNE true .\$(Platform)\$(Config) .\$(Platform)\$(Config) false true true $(BDSLIB)\$(PLATFORM)\release\$(LANGDIR);$(ILINK_TranslatedLibraryPath) vcldbx;frx16;TeeDB;Rave100VCL;vclib;Tee;inetdbbde;DBXOdbcDriver;DBXSybaseASEDriver;ibxpress;vclimg;frxDB16;intrawebdb_120_160;fs16;TeeUI;FMXTee;vclactnband;vcldb;vcldsnap;bindcompvcl;vclie;vcltouch;Intraweb_120_160;DBXDb2Driver;bcbsmp;websnap;vclribbon;frxe16;VclSmp;fsDB16;vcl;DataSnapConnectors;CloudService;DBXMSSQLDriver;FmxTeeUI;dsnapcon;vclx;webdsnap;bdertl;adortl;bcbie;$(PackageImports) Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) 1033 CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= false true false true _DEBUG;$(Defines) false None DEBUG true true true true Full true $(BDSLIB)\$(PLATFORM)\debug;$(ILINK_LibraryPath) $(BDSLIB)\$(PLATFORM)\debug\$(LANGDIR);$(ILINK_TranslatedLibraryPath) NDEBUG;$(Defines) None None 1033 0 Cfg_2 Base Base Cfg_1 Base CPlusPlusBuilder.Personality.12 CppConsoleApplication False False 1 0 0 0 False False False False False 1036 1252 1.0.0.0 1.0.0.0 False True True Embarcadero C++Builder Office 2000 Servers Package Embarcadero C++Builder Office XP Servers Package Microsoft Office 2000 Sample Automation Server Wrapper Components Microsoft Office XP Sample Automation Server Wrapper Components False True 12 ZenLib/Project/BCB/Example/ZenLib_Test.res0000664000000000000000000000014012615631146017225 0ustar rootroot ÿÿÿÿ<ÿÿ PLATFORMTARGETS0 ZenLib/Project/BCB/ZenLib_Proj.groupproj0000664000000000000000000000315112615631146017070 0ustar rootroot {DE2BA2E9-6347-4E7C-926C-C6F9BA01C65F} Default.Personality.12 ZenLib/Project/MSVC2012/0000775000000000000000000000000012615631146013431 5ustar rootrootZenLib/Project/MSVC2012/CleanUp.bat0000664000000000000000000000116012615631146015446 0ustar rootroot@echo off rem MS Visual Studio specific --- if exist *.opensdf del *.opensdf if exist *.sdf del *.sdf pushd Example if exist Debug rmdir Debug /Q /S if exist Release rmdir Release /Q /S if exist Win32 rmdir Win32 /Q /S if exist x64 rmdir x64 /Q /S if exist *.ncb del *.ncb if exist *.user del *.user if exist *.suo del *.suo /AH popd pushd Library if exist Debug rmdir Debug /Q /S if exist Release rmdir Release /Q /S if exist Win32 rmdir Win32 /Q /S if exist x64 rmdir x64 /Q /S if exist *.ncb del *.ncb if exist *.user del *.user if exist *.suo del *.suo /AH popd ZenLib/Project/MSVC2012/ZenLib_MSVC.sln0000664000000000000000000000370712615631146016171 0ustar rootrootMicrosoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2012 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ZenLib", "Library\ZenLib.vcxproj", "{0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Debug|x64 = Debug|x64 DebugA|Win32 = DebugA|Win32 DebugA|x64 = DebugA|x64 Release|Win32 = Release|Win32 Release|x64 = Release|x64 ReleaseA|Win32 = ReleaseA|Win32 ReleaseA|x64 = ReleaseA|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.Debug|Win32.ActiveCfg = Debug|Win32 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.Debug|Win32.Build.0 = Debug|Win32 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.Debug|x64.ActiveCfg = Debug|x64 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.Debug|x64.Build.0 = Debug|x64 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.DebugA|Win32.ActiveCfg = DebugA|Win32 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.DebugA|Win32.Build.0 = DebugA|Win32 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.DebugA|x64.ActiveCfg = DebugA|x64 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.DebugA|x64.Build.0 = DebugA|x64 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.Release|Win32.ActiveCfg = Release|Win32 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.Release|Win32.Build.0 = Release|Win32 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.Release|x64.ActiveCfg = Release|x64 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.Release|x64.Build.0 = Release|x64 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.ReleaseA|Win32.ActiveCfg = ReleaseA|Win32 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.ReleaseA|Win32.Build.0 = ReleaseA|Win32 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.ReleaseA|x64.ActiveCfg = ReleaseA|x64 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.ReleaseA|x64.Build.0 = ReleaseA|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal ZenLib/Project/MSVC2012/Library/0000775000000000000000000000000012615631146015035 5ustar rootrootZenLib/Project/MSVC2012/Library/ZenLib.vcxproj0000664000000000000000000006667212615631146017656 0ustar rootroot DebugA ARM DebugA Win32 DebugA x64 Debug ARM Debug Win32 Debug x64 ReleaseA ARM ReleaseA Win32 ReleaseA x64 Release ARM Release Win32 Release x64 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94} ZenLib Win32Proj StaticLibrary MultiByte v110_xp StaticLibrary Unicode v110 true StaticLibrary MultiByte true v110_xp StaticLibrary MultiByte true v110_xp StaticLibrary Unicode true v110_xp StaticLibrary Unicode true v110_xp StaticLibrary Unicode v110_xp StaticLibrary Unicode v110_xp StaticLibrary MultiByte v110_xp StaticLibrary MultiByte true v110_xp StaticLibrary Unicode true v110_xp StaticLibrary Unicode v110_xp <_ProjectFileVersion>10.0.30128.1 $(Platform)\$(Configuration)\ $(Platform)\$(Configuration)\ $(Platform)\$(Configuration)\Intermediate\ $(Platform)\$(Configuration)\Intermediate\ $(Platform)\$(Configuration)\ $(Platform)\$(Configuration)\Intermediate\ $(Platform)\$(Configuration)\ $(Platform)\$(Configuration)\ $(Platform)\$(Configuration)\Intermediate\ $(Platform)\$(Configuration)\Intermediate\ $(Platform)\$(Configuration)\ $(Platform)\$(Configuration)\Intermediate\ $(Platform)\$(Configuration)\ $(Platform)\$(Configuration)\ $(Platform)\$(Configuration)\Intermediate\ $(Platform)\$(Configuration)\Intermediate\ $(Platform)\$(Configuration)\ $(Platform)\$(Configuration)\Intermediate\ $(Platform)\$(Configuration)\ $(Platform)\$(Configuration)\ $(Platform)\$(Configuration)\Intermediate\ $(Platform)\$(Configuration)\Intermediate\ $(Platform)\$(Configuration)\ $(Platform)\$(Configuration)\Intermediate\ Disabled ../../../Source;../../../../zlib;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebug Use ZenLib/PreComp.h true Level4 MachineX86 Disabled ../../../Source;../../../../zlib;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebug Use ZenLib/PreComp.h true Level4 MachineX86 Disabled ../../../Source;../../../../zlib;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) MultiThreadedDebug Level4 EnableFastChecks true Use ZenLib/PreComp.h MachineX64 MaxSpeed ../../../Source;../../../../zlib;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) MultiThreaded Level4 true Use ZenLib/PreComp.h MachineX86 MaxSpeed ../../../Source;../../../../zlib;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) MultiThreaded Level4 true Use ZenLib/PreComp.h MachineX86 MaxSpeed ../../../Source;../../../../zlib;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) MultiThreaded Level4 true Use ZenLib/PreComp.h MachineX64 MaxSpeed ../../../Source;../../../../zlib;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) MultiThreaded Level4 true Use ZenLib/PreComp.h MachineX86 MaxSpeed ../../../Source;../../../../zlib;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) MultiThreaded Level4 true Use ZenLib/PreComp.h MachineX86 MaxSpeed ../../../Source;../../../../zlib;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) MultiThreaded Level4 true Use ZenLib/PreComp.h MachineX64 Disabled ../../../Source;../../../../zlib;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebug Level4 true Use ZenLib/PreComp.h MachineX86 Disabled ../../../Source;../../../../zlib;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebugDLL Level4 true Use ZenLib/PreComp.h MachineARM Disabled ../../../Source;../../../../zlib;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebug Level4 ProgramDatabase true Use ZenLib/PreComp.h MachineX64 Create Create Create Create Create Create Create Create Create Create Create Create ZenLib/Project/MSVC2012/Library/ZenLib.vcxproj.filters0000664000000000000000000002014712615631146021310 0ustar rootroot {4FC737F1-C7A5-4376-A066-2A32D752A2FF} cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx {b0e0820a-9895-4fee-8a01-7583d157cda3} {a987454d-645c-4a63-bc84-ffc79ae4679d} {e2876701-1853-42b5-a385-15d45b825a88} {93995380-89BD-4b04-88EB-625FBE52EBFB} h;hpp;hxx;hm;inl;inc;xsd {14855e7b-4367-4780-9bdb-48a7e942fd23} {5cfba4eb-2f03-4a6b-8f8a-a8a0dbfb4802} {16c53209-3c96-4ded-b925-c5cd36c4858f} Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files\Format\Http Source Files\Format\Http Source Files\Format\Http Source Files\Format\Http Source Files\Format\Html Source Files\Format\Html Source Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files\Format\Html Header Files\Format\Html Header Files\Format\Http Header Files\Format\Http Header Files\Format\Http Header Files\Format\Http Header Files Header Files Header Files ZenLib/Project/MSVC2012/Example/0000775000000000000000000000000012615631146015024 5ustar rootrootZenLib/Project/MSVC2012/Example/ZenLib_Test.vcxproj.filters0000664000000000000000000000102012615631146022263 0ustar rootroot {5fc02ff6-0eab-4a4f-a754-256dd82d27af} cpp;c;cxx;def;odl;idl;hpj;bat;asm Source Files ZenLib/Project/MSVC2012/Example/ZenLib_Test.vcxproj0000664000000000000000000001021512615631146020622 0ustar rootroot Release_Ansi Win32 Release Win32 {425F07FD-D7F7-467F-B213-8B60635582F2} Win32Proj Application MultiByte Application Unicode <_ProjectFileVersion>10.0.40219.1 Release\ Release\ Release_Ansi\ Release_Ansi\ ../../../Source;%(AdditionalIncludeDirectories) WIN32;NDEBUG;%(PreprocessorDefinitions) Level4 comctl32.lib;WxJpeg.lib;WxPng.lib;WxTiff.lib;WxWidgets.lib;ZenLib.lib;%(AdditionalDependencies) ../../../Release/MSVC/Library;../../../../Shared/Library/MSVC comctl32.lib;WxJpeg.lib;WxPng.lib;WxTiff.lib;WxWidgets.lib;ZenLib.lib;%(AdditionalDependencies) ../../../Source;%(AdditionalIncludeDirectories) WIN32;NDEBUG;%(PreprocessorDefinitions) Level4 ZenLibA.lib;WxBaseA.lib;%(AdditionalDependencies) ../../../ReleaseA/MSVC/Library;../../../../Shared/Library/MSVC ZenLib/Project/MSVC2012/Example/ZenLib_Test.sln0000664000000000000000000000164012615631146017725 0ustar rootrootMicrosoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2012 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ZenLib_Test", "ZenLib_Test.vcxproj", "{425F07FD-D7F7-467F-B213-8B60635582F2}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Release_Ansi|Win32 = Release_Ansi|Win32 Release|Win32 = Release|Win32 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {425F07FD-D7F7-467F-B213-8B60635582F2}.Release_Ansi|Win32.ActiveCfg = Release_Ansi|Win32 {425F07FD-D7F7-467F-B213-8B60635582F2}.Release_Ansi|Win32.Build.0 = Release_Ansi|Win32 {425F07FD-D7F7-467F-B213-8B60635582F2}.Release|Win32.ActiveCfg = Release|Win32 {425F07FD-D7F7-467F-B213-8B60635582F2}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal ZenLib/Project/MSVC2008/0000775000000000000000000000000012615631146013436 5ustar rootrootZenLib/Project/MSVC2008/CleanUp.bat0000664000000000000000000000116012615631146015453 0ustar rootroot@echo off rem MS Visual Studio specific --- if exist *.opensdf del *.opensdf if exist *.sdf del *.sdf pushd Example if exist Debug rmdir Debug /Q /S if exist Release rmdir Release /Q /S if exist Win32 rmdir Win32 /Q /S if exist x64 rmdir x64 /Q /S if exist *.ncb del *.ncb if exist *.user del *.user if exist *.suo del *.suo /AH popd pushd Library if exist Debug rmdir Debug /Q /S if exist Release rmdir Release /Q /S if exist Win32 rmdir Win32 /Q /S if exist x64 rmdir x64 /Q /S if exist *.ncb del *.ncb if exist *.user del *.user if exist *.suo del *.suo /AH popd ZenLib/Project/MSVC2008/ZenLib_MSVC.sln0000664000000000000000000000370612615631146016175 0ustar rootrootMicrosoft Visual Studio Solution File, Format Version 10.00 # Visual Studio 2008 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ZenLib", "Library\ZenLib.vcproj", "{0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Debug|x64 = Debug|x64 DebugA|Win32 = DebugA|Win32 DebugA|x64 = DebugA|x64 Release|Win32 = Release|Win32 Release|x64 = Release|x64 ReleaseA|Win32 = ReleaseA|Win32 ReleaseA|x64 = ReleaseA|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.Debug|Win32.ActiveCfg = Debug|Win32 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.Debug|Win32.Build.0 = Debug|Win32 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.Debug|x64.ActiveCfg = Debug|x64 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.Debug|x64.Build.0 = Debug|x64 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.DebugA|Win32.ActiveCfg = DebugA|Win32 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.DebugA|Win32.Build.0 = DebugA|Win32 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.DebugA|x64.ActiveCfg = DebugA|x64 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.DebugA|x64.Build.0 = DebugA|x64 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.Release|Win32.ActiveCfg = Release|Win32 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.Release|Win32.Build.0 = Release|Win32 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.Release|x64.ActiveCfg = Release|x64 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.Release|x64.Build.0 = Release|x64 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.ReleaseA|Win32.ActiveCfg = ReleaseA|Win32 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.ReleaseA|Win32.Build.0 = ReleaseA|Win32 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.ReleaseA|x64.ActiveCfg = ReleaseA|x64 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.ReleaseA|x64.Build.0 = ReleaseA|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal ZenLib/Project/MSVC2008/Library/0000775000000000000000000000000012615631146015042 5ustar rootrootZenLib/Project/MSVC2008/Library/ZenLib.vcproj0000664000000000000000000005166012615631146017462 0ustar rootroot ZenLib/Project/MSVC2008/Example/0000775000000000000000000000000012615631146015031 5ustar rootrootZenLib/Project/MSVC2008/Example/ZenLib_Test.vcproj0000664000000000000000000000646312615631146020451 0ustar rootroot ZenLib/Project/Solaris/0000775000000000000000000000000012615631146013770 5ustar rootrootZenLib/Project/Solaris/mkpkg.sub0000664000000000000000000000630212615631146015615 0ustar rootroot#!/bin/bash PackageCreate() { mkdir -p ${packagecreation_prefix} #checkinstall echo -e "#!/bin/sh" > ${packagecreation_prefix}/checkinstall echo -e "" >> ${packagecreation_prefix}/checkinstall echo -e "expected_platform=\042${processor}\042" >> ${packagecreation_prefix}/checkinstall echo -e "" >> ${packagecreation_prefix}/checkinstall echo -e "platform=\0140uname -p\0140" >> ${packagecreation_prefix}/checkinstall echo -e "" >> ${packagecreation_prefix}/checkinstall echo -e "if [ \044{platform} != \044{expected_platform} ]; then" >> ${packagecreation_prefix}/checkinstall echo -e " echo \042\0134n\0134n\0134n\0134tThis package must be installer on a \044{expected_platform} architecture\0134n\042" >> ${packagecreation_prefix}/checkinstall echo -e " echo \042\0134tAbording intallation.\0134n\0134n\0134n\042" >> ${packagecreation_prefix}/checkinstall echo -e " exit 1" >> ${packagecreation_prefix}/checkinstall echo -e "fi" >> ${packagecreation_prefix}/checkinstall echo -e "" >> ${packagecreation_prefix}/checkinstall echo -e "exit 0" >> ${packagecreation_prefix}/checkinstall #prototype file echo "i pkginfo" > ${packagecreation_prefix}/prototype echo "!default 0755 root bin" >> ${packagecreation_prefix}/prototype echo "i checkinstall" >> ${packagecreation_prefix}/prototype if test -e ${packagecreation_prefix}/depend; then echo "i depend" >> ${packagecreation_prefix}/prototype fi cd ${install_prefix} find . -print > ${packagecreation_prefix}/files cat ${packagecreation_prefix}/files | pkgproto | sed "s/ bin bin/ ? /g" | sed "s/ ${user} / ? /g" | sed "s/ ${group}/ ?/g" >> ${packagecreation_prefix}/prototype #pkginfo file echo "PKG=${pkgname}" > ${packagecreation_prefix}/pkginfo echo "VERSION=${version}" >> ${packagecreation_prefix}/pkginfo echo "ARCH=${processor}" >> ${packagecreation_prefix}/pkginfo echo "NAME=${pkgname} ${version} ${kernel} ${release} ${processor}" >> ${packagecreation_prefix}/pkginfo echo "DESC=Base library for some other projects" >> ${packagecreation_prefix}/pkginfo echo "CLASSES=none" >> ${packagecreation_prefix}/pkginfo echo "CATEGORY=utility" >> ${packagecreation_prefix}/pkginfo echo "VENDOR=MediaArea.net" >> ${packagecreation_prefix}/pkginfo echo "EMAIL=Info@MediaArea.net" >> ${packagecreation_prefix}/pkginfo echo "BASEDIR=${basedir}" >> ${packagecreation_prefix}/pkginfo cd ${packagecreation_prefix} pkgmk -o -b ${install_prefix} -d . -f prototype echo tar -cf - $pkgname | gzip -9 -c >${Home}/${pkgname}-${version}-${processor}.${kernel}_${release}.tar.gz tar -cf - $pkgname | gzip -9 -c >${Home}/${pkgname}-${version}-${processor}.${kernel}_${release}.tar.gz echo pkgtrans ${packagecreation_prefix} ${Home}/${pkgname}-${version}-${processor}.${kernel}_${release}.pkg ${pkgname} pkgtrans ${packagecreation_prefix} ${Home}/${pkgname}-${version}-${processor}.${kernel}_${release}.pkg ${pkgname} echo gzip -9 -cf ${Home}/${pkgname}-${version}-${processor}.${kernel}_${release}.pkg >${Home}/${pkgname}-${version}-${processor}.${kernel}_${release}.pkg.gz gzip -9 -cf ${Home}/${pkgname}-${version}-${processor}.${kernel}_${release}.pkg >${Home}/${pkgname}-${version}-${processor}.${kernel}_${release}.pkg.gz #Removing files cd ${home} rm -rf ${install_prefix} rm -rf ${packagecreation_prefix} } ZenLib/Project/Solaris/mkpkg0000775000000000000000000000547412615631146015041 0ustar rootroot#!/bin/bash #Config user=`id -un` group=`id -gn` processor=`uname -p` kernel=`uname -s` release=`uname -r` #Creation of known directories and filenames name="libzen0" version="0.4.32" Home=`pwd` install_prefix=${Home}/mk_package packagecreation_prefix=${Home}/create_package if test -z ${basedir}; then basedir="/" fi #Common code . ./mkpkg.sub #Compile and install cd ../GNU/Library ./autogen.sh ./configure --prefix=${install_prefix} --enable-shared --disable-static $* make if test -e .libs/libzen.so; then echo "Compilation OK" else echo "Compilation problem" exit 1 fi #**************************************************************************** # Release #**************************************************************************** cd ${Home} mkdir -p ${install_prefix} #Copying useful files install -d -m 755 ${install_prefix}/lib cp -rP ../GNU/Library/.libs/*.so* ${install_prefix}/lib install -d -m 755 ${install_prefix}/share/doc/${name} cp ../../*.txt ${install_prefix}/share/doc/${name} chmod 644 ${install_prefix}/share/doc/${name}/*.txt #Creation of package pkgname="${name}" PackageCreate #**************************************************************************** # Devel #**************************************************************************** cd ${Home} mkdir -p ${install_prefix} #include install -d -m 755 ${install_prefix}/include/ZenLib cp ../../Source/ZenLib/*.h ${install_prefix}/include/ZenLib/ chmod 644 ${install_prefix}/include/ZenLib/*.h install -d -m 755 ${install_prefix}/include/ZenLib/Base64 cp ../../Source/ZenLib/Base64/*.h ${install_prefix}/include/ZenLib/Base64 chmod 644 ${install_prefix}/include/ZenLib/Base64/*.h install -d -m 755 ${install_prefix}/include/ZenLib/HTTP_Client cp ../../Source/ZenLib/HTTP_Client/*.h ${install_prefix}/include/ZenLib/HTTP_Client chmod 644 ${install_prefix}/include/ZenLib/HTTP_Client/*.h install -d -m 755 ${install_prefix}/include/ZenLib/Format/Html cp ../../Source/ZenLib/Format/Html/*.h ${install_prefix}/include/ZenLib/Format/Html chmod 644 ${install_prefix}/include/ZenLib/Format/Html/*.h install -d -m 755 ${install_prefix}/include/ZenLib/Format/Http cp ../../Source/ZenLib/Format/Http/*.h ${install_prefix}/include/ZenLib/Format/Http chmod 644 ${install_prefix}/include/ZenLib/Format/Http/*.h install -d -m 755 ${install_prefix}/include/ZenLib/TinyXml cp ../../Source/ZenLib/TinyXml/*.h ${install_prefix}/include/ZenLib/TinyXml chmod 644 ${install_prefix}/include/ZenLib/TinyXml/*.h install -d -m 755 ${install_prefix}/bin cp ../GNU/Library/libzen-config ${install_prefix}/bin chmod 755 ${install_prefix}/bin/* #depend file mkdir -p ${packagecreation_prefix} echo "P ${name}" > ${packagecreation_prefix}/depend pkgname="${name}-devel" PackageCreate exit 0 #hints #install: pkgadd -R /opt/libzen0 -d./ libzen0 #remove: pkgrm libzen0, remove /var/spool/name/libzen0 ZenLib/Project/MSVC2005/0000775000000000000000000000000012615631146013433 5ustar rootrootZenLib/Project/MSVC2005/CleanUp.bat0000664000000000000000000000116012615631146015450 0ustar rootroot@echo off rem MS Visual Studio specific --- if exist *.opensdf del *.opensdf if exist *.sdf del *.sdf pushd Example if exist Debug rmdir Debug /Q /S if exist Release rmdir Release /Q /S if exist Win32 rmdir Win32 /Q /S if exist x64 rmdir x64 /Q /S if exist *.ncb del *.ncb if exist *.user del *.user if exist *.suo del *.suo /AH popd pushd Library if exist Debug rmdir Debug /Q /S if exist Release rmdir Release /Q /S if exist Win32 rmdir Win32 /Q /S if exist x64 rmdir x64 /Q /S if exist *.ncb del *.ncb if exist *.user del *.user if exist *.suo del *.suo /AH popd ZenLib/Project/MSVC2005/ZenLib_MSVC.sln0000664000000000000000000000127012615631146016164 0ustar rootrootMicrosoft Visual Studio Solution File, Format Version 9.00 # Visual Studio 2005 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ZenLib", "Library\ZenLib.vcproj", "{0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Release|Win32 = Release|Win32 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.Release|Win32.ActiveCfg = Release|Win32 {0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal ZenLib/Project/MSVC2005/Library/0000775000000000000000000000000012615631146015037 5ustar rootrootZenLib/Project/MSVC2005/Library/ZenLib.vcproj0000664000000000000000000001647612615631146017465 0ustar rootroot ZenLib/Project/MSVC2005/Example/0000775000000000000000000000000012615631146015026 5ustar rootrootZenLib/Project/MSVC2005/Example/ZenLib_Test.vcproj0000664000000000000000000000646312615631146020446 0ustar rootroot