Merge pull request #23 from Tripwire/dev/2435

Open Source Tripwire 2.4.3.5
This commit is contained in:
Brian Cox 2017-04-02 00:18:57 -07:00 committed by GitHub
commit 7af2781a19
167 changed files with 1706 additions and 2459 deletions

1
.gitignore vendored
View File

@ -12,6 +12,7 @@ src/tripwire/tripwire
src/twadmin/twadmin
src/twprint/twprint
src/twtest/twtest
src/test-harness/twtest
**/Makefile
**/*.o
**/*.dylib

View File

@ -1,3 +1,11 @@
2017-03-30 Brian Cox <bcox@tripwire.com>
* Bump version to 2.4.3.5
* Fix install-strip, check, uninstall, and distcheck make targets.
* Fix GCC 7.0.x warnings; use std::unique_ptr instead of deprecated std::auto_ptr where available.
* Add --disable-extrawarnings configure option, for old compilers that dont support the -Wextra compile option.
* Clean up unit tests & enable disabled tests.
* Address more static analyzer warnings, including from CppCheck & Flawfinder
2017-03-05 Brian Cox <bcox@tripwire.com>
* Bump version to 2.4.3.4
* Fix issue with printing level 2 reports, introduced by fixing a Clang static analyzer quibble in 2.4.3.3. Sigh.

View File

@ -6,4 +6,13 @@ install-data-hook:
export INSTALL_STRIP_FLAG
prefix="$(prefix)" sysconfdir="$(sysconfdir)" \
path_to_vi="$(path_to_vi)" path_to_sendmail="$(path_to_sendmail)" \
./installer/install.sh
$(top_srcdir)/installer/install.sh
uninstall-hook:
rm -f ${prefix}/sbin/tripwire $(prefix)/sbin/twadmin $(prefix)/sbin/twprint $(prefix)/sbin/siggen
rm -Rf $(prefix)/doc
check:
rm -Rf $(top_srcdir)/src/test-harness/twtest
cd $(top_srcdir)/src/test-harness && perl ./twtest.pl
$(top_srcdir)/bin/twtest all

View File

@ -774,9 +774,10 @@ ps: ps-recursive
ps-am:
uninstall-am:
@$(NORMAL_INSTALL)
$(MAKE) $(AM_MAKEFLAGS) uninstall-hook
.MAKE: $(am__recursive_targets) all install-am install-data-am \
install-strip
install-strip uninstall-am
.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \
am--refresh check check-am clean clean-cscope clean-generic \
@ -792,7 +793,7 @@ uninstall-am:
install-strip installcheck installcheck-am installdirs \
installdirs-am maintainer-clean maintainer-clean-generic \
mostlyclean mostlyclean-generic pdf pdf-am ps ps-am tags \
tags-am uninstall uninstall-am
tags-am uninstall uninstall-am uninstall-hook
.PRECIOUS: Makefile
@ -801,7 +802,16 @@ install-data-hook:
export INSTALL_STRIP_FLAG
prefix="$(prefix)" sysconfdir="$(sysconfdir)" \
path_to_vi="$(path_to_vi)" path_to_sendmail="$(path_to_sendmail)" \
./installer/install.sh
$(top_srcdir)/installer/install.sh
uninstall-hook:
rm -f ${prefix}/sbin/tripwire $(prefix)/sbin/twadmin $(prefix)/sbin/twprint $(prefix)/sbin/siggen
rm -Rf $(prefix)/doc
check:
rm -Rf $(top_srcdir)/src/test-harness/twtest
cd $(top_srcdir)/src/test-harness && perl ./twtest.pl
$(top_srcdir)/bin/twtest all
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.

View File

@ -1,4 +1,14 @@
What's new in Open Source Tripwire 2.4.3.2:
What's new in Open Source Tripwire 2.4.3.x:
* Useful install-strip, check, uninstall & distcheck make targets as of OST 2.4.3.5. Check target invokes both the test-harness framework and twtest unit tests.
* Verify OST builds without errors w/ GCC 7.0.x; fix new warnings from the new compiler, including deprecation warnings; use std::unique_ptr instead of std::auto_ptr where available.
* Add --disable-extrawarnings configure option, for old compilers that dont support the -Wextra compile option.
* Clean up unit tests, enable various disabled tests, make results more useful.
* Additional cleanup due to static analysis tool results (CppCheck, Flawfinder, Clang analyzer).
* OST now includes optional iconv support when configured with --enable-iconv.
When enabled, binary database & report files store paths as UTF-16, making these files more
@ -29,11 +39,6 @@ specifying a build directory outside the source dir now works as expected.
* Assorted platform tweaks: Add DOS/FreeDOS + DJGPP as a new platform; support Cygwin
//host/share/path syntax for UNC paths; passphrase & tempfile fixes for AROS.
======================================
What was new in earlier 2.4.3 versions:
* This update fixes compilation errors on modern compilers (GCC 4.7+ and LLVM/clang),
as well as some additional errors encountered on various platforms. This is intended
to supersede patches against 2.4.2.x, e.g. http://www.linuxfromscratch.org/blfs/view/svn/postlfs/tripwire.html
@ -66,15 +71,22 @@ defined incorrectly otherwise.
The update has been tested on a variety of platforms:
Linuxes
- CentOS 7 (amd64) + gcc 4.8.5
- Ubuntu 14.0.4 (amd64) + gcc 4.x
- RHEL 3.4 (Itanium) + gcc 3.4.3
- Alpine Linux 3.3.3 + gcc 5.3.0
- Android 6.0 (arm) + gcc 4.9
- Raspbian 7 (wheezy) (armv6l) + gcc 4.6.3
- openSuSE Tumbleweed (20160408) (i586) + gcc 5.3.1
- RHEL 6.0 (powerpc64) + gcc 4.4.4
- Alpine Linux 3.5.1 + gcc 6.2.1
- Arch Linux 232 + gcc 6.3.1
- Amazon Linux AMI 2016.09 + gcc 4.8.3
- Android 6.0 (arm) + gcc 4.9 (NDK)
- CentOS 7 (amd64) + gcc 4.8.5
- Fedora 24 Alpha 7 (amd64) + gcc 6.0.0
- Fedora 27 Rawhide (amd64) + gcc 7.0.1
- Raspbian 7 (wheezy) (armv6l) + gcc 4.6.3
- RHEL 3.4 (Itanium) + gcc 3.4.3
- RHEL 6.0 (powerpc64) + gcc 4.4.4
- openSuSE Tumbleweed (20160408) (i586) + gcc 5.3.1
- Oracle Linux 6.8 + gcc 4.4.7
- Ubuntu 14.0.4 (amd64) + gcc 4.x
- Ubuntu 16.0.4 (amd64) + gcc 5.4.0
- Wind River Pulsar Linux 8 + gcc 5.2.0
OSX
- Mac OS X 10.11 + LLVM 7.0.2 / clang-700.1.81
@ -90,7 +102,7 @@ BSDs
UNIXes
- Solaris 10 SPARC + gcc 3.4.6
- Solaris 10 x86 + gcc 3.4.3
- OpenIndiana 151 + gcc 4.8.5 [an OpenSolaris/illumos distro]
- OpenIndiana 151 + gcc 4.8.5
- AIX 5.2 + gcc 4.3.1
- HP-UX 11.23 + gcc 4.2.3

47
configure vendored
View File

@ -1,7 +1,7 @@
#! /bin/sh
# From configure.ac Revision: 2.4.3.4 .
# From configure.ac Revision: 2.4.3.5 .
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for tripwire 2.4.3.4.
# Generated by GNU Autoconf 2.69 for tripwire 2.4.3.5.
#
# Report bugs to <https://github.com/Tripwire/tripwire-open-source/issues>.
#
@ -584,8 +584,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='tripwire'
PACKAGE_TARNAME='tripwire'
PACKAGE_VERSION='2.4.3.4'
PACKAGE_STRING='tripwire 2.4.3.4'
PACKAGE_VERSION='2.4.3.5'
PACKAGE_STRING='tripwire 2.4.3.5'
PACKAGE_BUGREPORT='https://github.com/Tripwire/tripwire-open-source/issues'
PACKAGE_URL='https://github.com/Tripwire/tripwire-open-source'
@ -748,6 +748,7 @@ ac_subst_files=''
ac_user_opts='
enable_option_checking
enable_silent_rules
enable_extrawarnings
enable_static
enable_debug
enable_dependency_tracking
@ -1321,7 +1322,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures tripwire 2.4.3.4 to adapt to many kinds of systems.
\`configure' configures tripwire 2.4.3.5 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@ -1393,7 +1394,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of tripwire 2.4.3.4:";;
short | recursive ) echo "Configuration of tripwire 2.4.3.5:";;
esac
cat <<\_ACEOF
@ -1403,6 +1404,7 @@ Optional Features:
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--enable-silent-rules less verbose build output (undo: "make V=1")
--disable-silent-rules verbose build output (undo: "make V=0")
—-disable-extrawarnings do not compile with -Wextra warnings enabled
--enable-static compile static binaries
--enable-debug compile with debuging enabled
--enable-dependency-tracking
@ -1504,7 +1506,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
tripwire configure 2.4.3.4
tripwire configure 2.4.3.5
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@ -2391,7 +2393,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by tripwire $as_me 2.4.3.4, which was
It was created by tripwire $as_me 2.4.3.5, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@ -3365,7 +3367,7 @@ fi
# Define the identity of the package.
PACKAGE='tripwire'
VERSION='2.4.3.4'
VERSION='2.4.3.5'
cat >>confdefs.h <<_ACEOF
@ -3460,15 +3462,21 @@ fi
ac_config_headers="$ac_config_headers config.h"
CFLAGS=${CFLAGS:-"-O -pipe -Wall -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"}
CXXFLAGS=${CXXFLAGS:-"-O -pipe -Wall -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"}
# This is primarily to support old compilers that dont understand -Wextra
# Check whether --enable-extrawarnings was given.
if test "${enable_extrawarnings+set}" = set; then :
enableval=$enable_extrawarnings;
fi
rm -f src/tripwire/syslog.h 2> /dev/null
chmod 755 install-sh 2> /dev/null
CFLAGS=${CFLAGS:-"-O -pipe -Wall -Wextra -Wno-unused-parameter -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"}
CXXFLAGS=${CXXFLAGS:-"-O -pipe -Wall -Wextra -Wno-unused-parameter -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"}
if test "x$enable_extrawarnings" != "xno"
then
CFLAGS="${CFLAGS} -Wextra -Wno-unused-parameter"
CXXFLAGS="${CXXFLAGS} -Wextra -Wno-unused-parameter"
fi
# Check whether --enable-static was given.
if test "${enable_static+set}" = set; then :
@ -3478,6 +3486,7 @@ fi
if test "x$enable_static" = xyes
then LDFLAGS="${LDFLAGS} -static"
fi
# Check whether --enable-debug was given.
if test "${enable_debug+set}" = set; then :
enableval=$enable_debug;
@ -4349,7 +4358,7 @@ if test -z "$CXX"; then
CXX=$CCC
else
if test -n "$ac_tool_prefix"; then
for ac_prog in g++ clang++ sunCC aCC xlC_r xlC cl.exe
for ac_prog in g++ c++ clang++ sunCC aCC xlC_r xlC cl.exe
do
# Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
set dummy $ac_tool_prefix$ac_prog; ac_word=$2
@ -4393,7 +4402,7 @@ fi
fi
if test -z "$CXX"; then
ac_ct_CXX=$CXX
for ac_prog in g++ clang++ sunCC aCC xlC_r xlC cl.exe
for ac_prog in g++ c++ clang++ sunCC aCC xlC_r xlC cl.exe
do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
@ -7633,7 +7642,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by tripwire $as_me 2.4.3.4, which was
This file was extended by tripwire $as_me 2.4.3.5, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@ -7700,7 +7709,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
tripwire config.status 2.4.3.4
tripwire config.status 2.4.3.5
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"

View File

@ -2,34 +2,38 @@ dnl Process this file with autoconf to produce a configure script.
dnl
dnl
AC_INIT([tripwire], [2.4.3.4], [https://github.com/Tripwire/tripwire-open-source/issues], [tripwire], [https://github.com/Tripwire/tripwire-open-source])
AC_INIT([tripwire], [2.4.3.5], [https://github.com/Tripwire/tripwire-open-source/issues], [tripwire], [https://github.com/Tripwire/tripwire-open-source])
AC_CONFIG_SRCDIR([src/tw/tw.cpp])
AC_CANONICAL_TARGET([])
AM_INIT_AUTOMAKE
AM_CONFIG_HEADER(config.h)
AC_COPYRIGHT([The developer of the original code and/or files is Tripwire, Inc. Portions created by Tripwire, Inc. are copyright 2000-2017 Tripwire, Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights reserved.])
AC_REVISION([$Revision: 2.4.3.4 $])
dnl #################################
dnl Cleanup Cruft Leftover From Patch
dnl #################################
rm -f src/tripwire/syslog.h 2> /dev/null
chmod 755 install-sh 2> /dev/null
AC_REVISION([$Revision: 2.4.3.5 $])
dnl ###############
dnl Setup defaults
dnl ###############
CFLAGS=${CFLAGS:-"-O -pipe -Wall -Wextra -Wno-unused-parameter -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"}
CXXFLAGS=${CXXFLAGS:-"-O -pipe -Wall -Wextra -Wno-unused-parameter -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"}
CFLAGS=${CFLAGS:-"-O -pipe -Wall -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"}
CXXFLAGS=${CXXFLAGS:-"-O -pipe -Wall -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"}
dnl #####################
dnl Configuration options
dnl #####################
# This is primarily to support old compilers that dont understand -Wextra
AC_ARG_ENABLE(extrawarnings, [ —-disable-extrawarnings do not compile with -Wextra warnings enabled])
if test "x$enable_extrawarnings" != "xno"
then
CFLAGS="${CFLAGS} -Wextra -Wno-unused-parameter"
CXXFLAGS="${CXXFLAGS} -Wextra -Wno-unused-parameter"
fi
AC_ARG_ENABLE(static, [ --enable-static compile static binaries])
if test "x$enable_static" = xyes
then LDFLAGS="${LDFLAGS} -static"
fi
AC_ARG_ENABLE(debug, [ --enable-debug compile with debuging enabled])
if test "x$enable_debug" = xyes
then
@ -42,7 +46,7 @@ dnl ###################
dnl Checks for programs
dnl ###################
AC_PROG_CC([gcc clang suncc aCC xlC_r xlC cl.exe])
AC_PROG_CXX([g++ clang++ sunCC aCC xlC_r xlC cl.exe])
AC_PROG_CXX([g++ c++ clang++ sunCC aCC xlC_r xlC cl.exe])
AC_PROG_RANLIB
AC_PROG_YACC
AC_PROG_LN_S

View File

@ -17,7 +17,7 @@
## from Larry Wall's metaconfig.
##-------------------------------------------------------
PATH='.:/bin:/usr/bin'
PATH=".:/bin:/usr/bin:/usr/local/bin:$PATH"
export PATH || (echo 'You must use sh to run this script'; kill $$)
if [ ! -t 0 ] ; then
echo "Say 'sh install.sh', not 'sh < install.sh'"
@ -42,18 +42,6 @@ else
c=""
fi
##-------------------------------------------------------
## Better have a copy of tar!
## If /bin/sh does not exist or is not readable (seems
## fairly unlikely), then this will fail.
##-------------------------------------------------------
(tar cvf /dev/null /bin/sh) 2> /dev/null 1>&2
if [ $? -ne 0 ]; then
echo "tar command not found -- aborting install."
exit 1
fi
##-------------------------------------------------------
## Can't live without sed.
##-------------------------------------------------------
@ -78,52 +66,24 @@ for p in $awknames; do
fi
done
##-------------------------------------------------------
## Does this system have a copy of grep we can use?
## Some greps don't return status (amazing, huh?),
## so we look for a copy of grep that
## returns 0 status for an exact match
## returns 0 status for a case-insensitive match
## returns 0 status for a wildcard match
## returns non-zero status for a failed match
##-------------------------------------------------------
GREP=""
grepnames="grep egrep"
lcgrepstr="findensiemich" # all lower case
mcgrepstr="FindenSieMich" # mixed case
wcgrepstr="sie.ich$" # wild card match
nogrepstr="WoBistDu" # should not be able to find this
for p in $grepnames; do
(echo "$lcgrepstr" | $p "$lcgrepstr") 2> /dev/null 1>&2
if [ $? -eq 0 ]; then
(echo "$lcgrepstr" | $p -i "$mcgrepstr") 2> /dev/null 1>&2
if [ $? -eq 0 ]; then
(echo "$lcgrepstr" | $p "$wcgrepstr") 2> /dev/null 1>&2
if [ $? -eq 0 ]; then
(echo "$lcgrepstr" | $p "$nogrepstr") 2> /dev/null 1>&2
if [ $? -ne 0 ]; then
GREP=$p
break
fi
fi
fi
fi
done
##-------------------------------------------------------
## Does this system have a pager that we can use?
## Use cat if desperate.
##-------------------------------------------------------
MORE="cat"
morenames="more less cat"
morenames="less more most pg cat"
for p in $morenames; do
($p $0 < /dev/null) 2> /dev/null 1>&2
if [ $? -eq 0 ]; then
MORE=$p
break
fi
pagerpath=`command -v $p`
if [ -z $pagerpath ]; then
continue
fi
if [ -x $pagerpath ]; then
MORE=$pagerpath
break
fi
done
##-------------------------------------------------------
@ -243,9 +203,8 @@ cat << END_OF_TEXT
Installer program for:
Tripwire(R) 2.4 Open Source
Copyright (C) 1998-2000 Tripwire (R) Security Systems, Inc. Tripwire (R)
is a registered trademark of the Purdue Research Foundation and is
licensed exclusively to Tripwire (R) Security Systems, Inc.
Copyright (C) 1998-2017 Tripwire, Inc.
Tripwire is a registered trademark of Tripwire, Inc. All rights reserved.
END_OF_TEXT
@ -417,15 +376,21 @@ else
##-------------------------------------------------------
## Verify that the specified editor program exists
##-------------------------------------------------------
TWEDITOR=${TWEDITOR:-'/bin/vi'}
DEFAULTEDITOR=${EDITOR:-/bin/vi}
TWEDITOR=${TWEDITOR:-$DEFAULTEDITOR}
TWEDITOR_PATH=`command -v $TWEDITOR`
if [ -n ${TWEDITOR_PATH} ]; then
TWEDITOR=$TWEDITOR_PATH
fi
if [ -x ${TWEDITOR} ]; then
echo "${TWEDITOR} exists. Continuing installation."
echo
echo "${TWEDITOR} exists. Continuing installation."
echo
else
echo "${TWEDITOR} does not exist. Exiting."
exit 1
echo "${TWEDITOR} not found. Continuing, but your configuration may need to be edited after installation."
echo
fi
##-------------------------------------------------------
@ -584,9 +549,12 @@ f10=' ff=${POLICYSRC} ; d="/policy" ; dd=$TWPOLICY ; rr=0640 '
#f16=' ff=twadmin.8 ; d="/man/man8" ; dd=$TWMAN/man8 ; rr=0444 '
#f17=' ff=twintro.8 ; d="/man/man8" ; dd=$TWMAN/man8 ; rr=0444 '
#f18=' ff=twprint.8 ; d="/man/man8" ; dd=$TWMAN/man8 ; rr=0444 '
f19=' ff=COMMERCIAL ; d="" ; dd=$TWDOCS ; rr=0444 '
f20=' ff=ReadMe-2.4.3 ; d="" ; dd=$TWDOCS ; rr=0444 '
f21=' ff=ChangeLog ; d="" ; dd=$TWDOCS ; rr=0444 '
# Binaries and manpages are already installed by the install target
loosefiles="f3 f4 f5 f6 f7 f8 f9 f10"
loosefiles="f3 f4 f5 f6 f7 f8 f9 f10 f19 f20 f21"
for i in $loosefiles; do
eval "eval \"\$$i\""
@ -607,7 +575,9 @@ done
if [ -n "$INSTALL_STRIP_FLAG" ] ; then
echo "INSTALL_STRIP_FLAG is set, stripping binaries"
strip "$TWBIN/siggen" "$TWBIN/tripwire" "$TWBIN/twadmin" "$TWBIN/twprint"
chmod u+w "$TWBIN/siggen" "$TWBIN/tripwire" "$TWBIN/twadmin" "$TWBIN/twprint"
strip "$TWBIN/siggen" "$TWBIN/tripwire" "$TWBIN/twadmin" "$TWBIN/twprint"
chmod u-w "$TWBIN/siggen" "$TWBIN/tripwire" "$TWBIN/twadmin" "$TWBIN/twprint"
fi
#Make extra sure we don't install the unit test binary to sbin
@ -923,7 +893,7 @@ cat << END_OF_TEXT
----------------------------------------------
The installation succeeded.
Please refer to $README_LOC
Please refer to documentation in $TWDOCS
for release information and to the printed user documentation
for further instructions on using Tripwire 2.4 Open Source.

View File

@ -12,11 +12,11 @@ libcore_a_SOURCES = \
displayutil.cpp error.cpp errorbucketimpl.cpp errortable.cpp \
errorutil.cpp fileerror.cpp fileheader.cpp fsservices.cpp \
growheap.cpp hashtable.cpp haval.cpp msystem.cpp ntmbs.cpp \
objectpool.cpp refcountobj.cpp serializable.cpp serializer.cpp \
refcountobj.cpp serializable.cpp serializer.cpp \
serializerimpl.cpp serializerutil.cpp serstring.cpp \
srefcountobj.cpp srefcounttbl.cpp stdcore.cpp stringutil.cpp \
timebomb.cpp timeconvert.cpp tw_signal.cpp twlimits.cpp twlocale.cpp \
unixexcept.cpp usernotify.cpp usernotifystdout.cpp utf8.cpp \
unixexcept.cpp usernotify.cpp usernotifystdout.cpp \
wchar16.cpp
libcore_a_HEADERS = archive.h charutil.h cmdlineparser.h codeconvert.h \
@ -24,12 +24,12 @@ libcore_a_HEADERS = archive.h charutil.h cmdlineparser.h codeconvert.h \
displayutil.h error.h errorbucket.h errorbucketimpl.h errorgeneral.h \
errortable.h errorutil.h file.h fileerror.h fileheader.h fixedfilebuf.h \
fsservices.h growheap.h hashtable.h haval.h md5.h msystem.h ntdbs.h \
ntmbs.h objectpool.h package.h platform.h refcountobj.h resources.h \
ntmbs.h package.h platform.h refcountobj.h resources.h \
serializable.h serializer.h serializerimpl.h serializerutil.h serstring.h \
sha.h srefcountobj.h srefcounttbl.h stdcore.h stringutil.h tasktimer.h \
tchar.h timebomb.h timeconvert.h tw_signal.h twlimits.h twlocale.h \
twstringslang.h typed.h types.h unixexcept.h unixfsservices.h upperbound.h \
usernotify.h usernotifystdout.h utf8.h wchar16.h
usernotify.h usernotifystdout.h wchar16.h
libcore_a_LIBADD = @CORE_CRYPT_O@
libcore_a_DEPENDENCIES = @CORE_CRYPT_O@

View File

@ -118,15 +118,14 @@ am_libcore_a_OBJECTS = file_unix.$(OBJEXT) unixfsservices.$(OBJEXT) \
errorutil.$(OBJEXT) fileerror.$(OBJEXT) fileheader.$(OBJEXT) \
fsservices.$(OBJEXT) growheap.$(OBJEXT) hashtable.$(OBJEXT) \
haval.$(OBJEXT) msystem.$(OBJEXT) ntmbs.$(OBJEXT) \
objectpool.$(OBJEXT) refcountobj.$(OBJEXT) \
serializable.$(OBJEXT) serializer.$(OBJEXT) \
serializerimpl.$(OBJEXT) serializerutil.$(OBJEXT) \
serstring.$(OBJEXT) srefcountobj.$(OBJEXT) \
srefcounttbl.$(OBJEXT) stdcore.$(OBJEXT) stringutil.$(OBJEXT) \
timebomb.$(OBJEXT) timeconvert.$(OBJEXT) tw_signal.$(OBJEXT) \
twlimits.$(OBJEXT) twlocale.$(OBJEXT) unixexcept.$(OBJEXT) \
usernotify.$(OBJEXT) usernotifystdout.$(OBJEXT) utf8.$(OBJEXT) \
wchar16.$(OBJEXT)
refcountobj.$(OBJEXT) serializable.$(OBJEXT) \
serializer.$(OBJEXT) serializerimpl.$(OBJEXT) \
serializerutil.$(OBJEXT) serstring.$(OBJEXT) \
srefcountobj.$(OBJEXT) srefcounttbl.$(OBJEXT) \
stdcore.$(OBJEXT) stringutil.$(OBJEXT) timebomb.$(OBJEXT) \
timeconvert.$(OBJEXT) tw_signal.$(OBJEXT) twlimits.$(OBJEXT) \
twlocale.$(OBJEXT) unixexcept.$(OBJEXT) usernotify.$(OBJEXT) \
usernotifystdout.$(OBJEXT) wchar16.$(OBJEXT)
libcore_a_OBJECTS = $(am_libcore_a_OBJECTS)
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
@ -339,11 +338,11 @@ libcore_a_SOURCES = \
displayutil.cpp error.cpp errorbucketimpl.cpp errortable.cpp \
errorutil.cpp fileerror.cpp fileheader.cpp fsservices.cpp \
growheap.cpp hashtable.cpp haval.cpp msystem.cpp ntmbs.cpp \
objectpool.cpp refcountobj.cpp serializable.cpp serializer.cpp \
refcountobj.cpp serializable.cpp serializer.cpp \
serializerimpl.cpp serializerutil.cpp serstring.cpp \
srefcountobj.cpp srefcounttbl.cpp stdcore.cpp stringutil.cpp \
timebomb.cpp timeconvert.cpp tw_signal.cpp twlimits.cpp twlocale.cpp \
unixexcept.cpp usernotify.cpp usernotifystdout.cpp utf8.cpp \
unixexcept.cpp usernotify.cpp usernotifystdout.cpp \
wchar16.cpp
libcore_a_HEADERS = archive.h charutil.h cmdlineparser.h codeconvert.h \
@ -351,12 +350,12 @@ libcore_a_HEADERS = archive.h charutil.h cmdlineparser.h codeconvert.h \
displayutil.h error.h errorbucket.h errorbucketimpl.h errorgeneral.h \
errortable.h errorutil.h file.h fileerror.h fileheader.h fixedfilebuf.h \
fsservices.h growheap.h hashtable.h haval.h md5.h msystem.h ntdbs.h \
ntmbs.h objectpool.h package.h platform.h refcountobj.h resources.h \
ntmbs.h package.h platform.h refcountobj.h resources.h \
serializable.h serializer.h serializerimpl.h serializerutil.h serstring.h \
sha.h srefcountobj.h srefcounttbl.h stdcore.h stringutil.h tasktimer.h \
tchar.h timebomb.h timeconvert.h tw_signal.h twlimits.h twlocale.h \
twstringslang.h typed.h types.h unixexcept.h unixfsservices.h upperbound.h \
usernotify.h usernotifystdout.h utf8.h wchar16.h
usernotify.h usernotifystdout.h wchar16.h
libcore_a_LIBADD = @CORE_CRYPT_O@
libcore_a_DEPENDENCIES = @CORE_CRYPT_O@

View File

@ -324,28 +324,5 @@ private:
};
/*
// TODO: fill these out
///////////////////////////////////////////////////////////////////////////////
// class cMMFileArchive --
///////////////////////////////////////////////////////////////////////////////
class cMMFileArchive : public cMemMappedArchive
{
public:
};
///////////////////////////////////////////////////////////////////////////////
// class cNetArchive --
///////////////////////////////////////////////////////////////////////////////
class cNetArchive : public cArchive
{
public:
};
*/
#endif

View File

@ -1016,7 +1016,7 @@ cDoubleIconvConverter::Convert(
//
size_t nBufBytes = nChars * MB_LEN_MAX;
ntmbs_t pszBuffer = (ntmbs_t)::operator new( nBufBytes + 1 );
std::auto_ptr<mbchar_t> pBuf( pszBuffer );
TW_UNIQUE_PTR<mbchar_t> pBuf( pszBuffer );
//
// do first conversion
@ -1074,7 +1074,7 @@ cDoubleIconvConverter::Convert(
//
size_t nBufBytes = nBytes * MB_LEN_MAX;
ntmbs_t pszBuffer = (ntmbs_t)::operator new( nBufBytes + 1 );
std::auto_ptr<mbchar_t> pBuf( pszBuffer );
TW_UNIQUE_PTR<mbchar_t> pBuf( pszBuffer );
//
// do first conversion

View File

@ -98,11 +98,9 @@ TSS_REGISTER_ERROR( eFileFlush(), _T("File could not be flushed.") )
TSS_REGISTER_ERROR( eFileRewind(), _T("File could not be rewound.") )
/// Win32
#if IS_UNIX
/// General API failures
TSS_REGISTER_ERROR(eUnix(), _T("Unix API failure.") )
#endif
/// FSServices

View File

@ -63,7 +63,7 @@ cDebug::cDebug(const char* label)
cDebug::cDebug(const cDebug &rhs)
{
strcpy(mLabel, rhs.mLabel);
strncpy(mLabel, rhs.mLabel, MAX_LABEL);
}
cDebug::~cDebug()
@ -102,7 +102,7 @@ void cDebug::DoTrace(const char *format, va_list &args)
char out[2048];
size_t guard2 = 0xBABABABA;
vsprintf(out, format, args);
vsnprintf(out, 2048, format, args);
ASSERT(guard1 == 0xBABABABA && guard2 == 0xBABABABA); // string was too long
ASSERT(strlen(out) < 1024);
@ -304,7 +304,7 @@ void cDebug::DebugOut( const char* lpOutputString, ... )
// create the output buffer
va_list args;
va_start(args, lpOutputString);
vsprintf(buf, lpOutputString, args);
vsnprintf(buf, 2048, lpOutputString, args);
va_end(args);
#ifdef _DEBUG

View File

@ -208,16 +208,10 @@ inline void cDebug::DebugOut ( const char*, ... ) {}
// ASSERT macro
//////////////////////////////////////////////////////////////////////////////////
#if IS_UNIX
#define ASSERTMSG( exp, s ) assert( (exp) != 0 )
#define ASSERT( exp ) assert( (exp) != 0 )
// if we are not windows we will just use the standard assert()
#define TSS_DebugBreak() ASSERT( false );
#endif// IS_UNIX
#define ASSERTMSG( exp, s ) assert( (exp) != 0 )
#define ASSERT( exp ) assert( (exp) != 0 )
// if we are not windows we will just use the standard assert()
#define TSS_DebugBreak() ASSERT( false );
#ifndef ASSERT
#error ASSERT did not get defined!!!

View File

@ -81,6 +81,8 @@ inline bool IsSingleTCHAR( TSTRING::const_iterator first,
class iCharEncoder
{
public:
virtual ~iCharEncoder() {};
virtual bool NeedsEncoding( TSTRING::const_iterator first,
TSTRING::const_iterator last ) const = 0;
// Determines if character identified by [first,last) needs encoding.
@ -107,7 +109,7 @@ class iCharEncoder
static TCHAR EscapeChar() { return char_escape; }
protected:
protected:
static TCHAR char_escape;
};
@ -116,6 +118,8 @@ class iCharEncoder
class cNonNarrowableCharEncoder : public iCharEncoder
{
public:
virtual ~cNonNarrowableCharEncoder() {}
virtual bool NeedsEncoding( TSTRING::const_iterator first,
TSTRING::const_iterator last ) const;
@ -141,7 +145,9 @@ class cNonPrintableCharEncoder : public iCharEncoder
cNonPrintableCharEncoder( bool f_allowWS )
: m_allowWS( f_allowWS ) {};
virtual bool NeedsEncoding( TSTRING::const_iterator first,
virtual ~cNonPrintableCharEncoder() {}
virtual bool NeedsEncoding( TSTRING::const_iterator first,
TSTRING::const_iterator last ) const;
virtual TSTRING EncodeRoundtrip(TSTRING::const_iterator first,
@ -164,6 +170,8 @@ class cNonPrintableCharEncoder : public iCharEncoder
class cQuoteCharEncoder : public iCharEncoder
{
public:
virtual ~cQuoteCharEncoder() {}
virtual bool NeedsEncoding( TSTRING::const_iterator first,
TSTRING::const_iterator last ) const;
@ -187,6 +195,8 @@ class cQuoteCharEncoder : public iCharEncoder
class cBackslashCharEncoder : public iCharEncoder
{
public:
virtual ~cBackslashCharEncoder() {}
virtual bool NeedsEncoding( TSTRING::const_iterator first,
TSTRING::const_iterator last ) const;
@ -506,11 +516,8 @@ bool cCharEncoderUtil::IsPrintable( TCHAR ch )
return( ! isprint( ch ) ); // kludge for KAI
#else // USE_CLIB_LOCALE
#if IS_UNIX
return( ! std::isprint<TCHAR>( ch, std::locale() ) );
#endif
return( ! std::isprint<TCHAR>( ch, std::locale() ) );
#endif // USE_CLIB_LOCALE
}

View File

@ -40,18 +40,14 @@
// class eInternal
//=============================================================================
#if IS_UNIX
namespace //unique
{
TCHAR* tw_itot( int value, TCHAR* string, int radix)
TCHAR* tw_itot( int value, TCHAR* string, int radix, int size)
{
_stprintf( string, "%d", value );
snprintf( string, size, "%d", value );
return string;
}
}
#else
#define tw_itot _itot
#endif //IS_UNIX
eInternal::eInternal(TCHAR* sourceFile, int lineNum)
: eError(_T(""))
@ -61,7 +57,7 @@ eInternal::eInternal(TCHAR* sourceFile, int lineNum)
mMsg = _T("File: ");
mMsg += sourceFile;
mMsg += _T(" Line: ");
mMsg += tw_itot(lineNum, buf, 10);
mMsg += tw_itot(lineNum, buf, 10, 256);
}
//=============================================================================

View File

@ -74,12 +74,7 @@ struct cFile_i;
class cFile
{
public:
#if IS_UNIX
typedef off_t File_t;
#else //WIN32
typedef int64 File_t;
#endif // IS_UNIX
enum SeekFrom
{

View File

@ -45,10 +45,7 @@
#define __FIXED_FILEBUF_H
#include <fstream>
#if IS_UNIX
#define fixed_basic_ofstream std::basic_ofstream
#endif // IS_WIN32/IS_UNIX
#endif//__FIXED_FILEBUF_H

View File

@ -65,16 +65,15 @@
// STANDARD LIBRARY INCLUDES
//=========================================================================
#if IS_UNIX
#if HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#if HAVE_SYS_PARAM_H
# include <sys/param.h>
#endif
#if HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
# include <sys/stat.h>
#endif
//=========================================================================
// DEFINES AND MACROS
//=========================================================================
@ -209,13 +208,11 @@ class iFSServices
// maximum path length on platform
////////////////////////////////////////
enum
{
#if IS_UNIX
#ifdef MAXPATHLEN
{
#ifdef MAXPATHLEN
TW_MAX_PATH = MAXPATHLEN
#else
#else
TW_MAX_PATH = 1024
#endif
#endif
};
@ -244,14 +241,14 @@ class iFSServices
////////////////////////////////////////
// major filesystem functions
////////////////////////////////////////
virtual void Stat( const TSTRING& strFileName, cFSStatArgs& pStat ) const throw( eFSServices ) = 0;
virtual void Stat( const TSTRING& strFileName, cFSStatArgs& pStat ) const = 0;
// fills out the cFSStatArgs structure with the stat info for the named file
virtual void GetTempDirName( TSTRING& strName ) const throw( eFSServices ) = 0;
virtual void GetTempDirName( TSTRING& strName ) const = 0;
// makes directory if it doesn't exist already. Dirname will end with a delimiter ( '/' )
virtual void SetTempDirName( TSTRING& tmpName ) = 0;
virtual TSTRING& MakeTempFilename( TSTRING& strName ) const throw( eFSServices ) = 0;
virtual TSTRING& MakeTempFilename( TSTRING& strName ) const = 0;
// create temporary file
// TSTRING must have the form ("baseXXXXXX"), where the X's are replaced with
// characters to make it a unique file. There must be at least 6 Xs.
@ -262,7 +259,7 @@ class iFSServices
////////////////////////////////////////
virtual void GetHostID( TSTRING& name ) const = 0;
virtual void GetMachineName( TSTRING& name ) const throw(eFSServices) = 0;
virtual void GetMachineName( TSTRING& name ) const = 0;
virtual void GetMachineNameFullyQualified( TSTRING& name ) const = 0;
@ -274,11 +271,11 @@ class iFSServices
////////////////////////////////////////
// directory specific functions
////////////////////////////////////////
virtual void ReadDir( const TSTRING& strName, std::vector<TSTRING> &vDirContents, bool bFullPaths = true ) const throw( eFSServices ) = 0;
virtual void ReadDir( const TSTRING& strName, std::vector<TSTRING> &vDirContents, bool bFullPaths = true ) const = 0;
// puts the contents of the specified directory, except for . and .., into the supplied vector.
// if bFullPaths is true, then the vector contains fully qualified path names; otherwise, it only contains the
// short names.
virtual void GetCurrentDir( TSTRING& strCurDir ) const throw( eFSServices ) = 0;
virtual void GetCurrentDir( TSTRING& strCurDir ) const = 0;
// returns the current working directory

View File

@ -66,8 +66,6 @@
#include "stdcore.h"
#if IS_UNIX
/*
* set, reset environment to be passed to mpopem
*/
@ -209,6 +207,7 @@ char *getenv(); /* get variable from environment */
* on some systems, this is a library function, so define STRDUP
* if it is on yours
*/
#if 0
#ifdef STRDUP
# ifndef __STDC__
char *strdup();
@ -226,13 +225,14 @@ char *getenv(); /* get variable from environment */
/*
* allocate space for the string, and copy if successful
*/
if ((p = (char*)malloc((unsigned)((strlen(str)+1)*sizeof(char))))
size_t p_size = (strlen(str)+1)*sizeof(char);
if ((p = (char*)malloc((unsigned)(p_size)))
!= NULL)
(void) strcpy(p, str);
(void) strncpy(p, str, p_size);
return(p);
}
#endif
#endif //0
/*
* allocate space for an array of pointers, OR
@ -382,7 +382,7 @@ char *env;
register int n; /* where a previous definition is */
/*
* seeif youneed to create the environment list
* see if you need to create the environment list
*/
if (sz_envp == 0){
if ((envp = c2alloc((const char**)envp, &sz_envp)) == NULL){
@ -403,21 +403,26 @@ char *env;
* just include it from the current environment
* (if not defined there, don't define it here)
*/
if (strchr(env, '=') == NULL){
if (strchr(env, '=') == NULL) {
q = getenv(env);
/* is it defined locally? */
if ((q = getenv(env)) == NULL){
if (NULL == q) {
/* no -- don't define it here */
return(SE_NONE);
}
else if ((p = (char*)malloc((unsigned) (strlen(env)+strlen(q)+2)))
== NULL){
size_t p_size = strlen(env) + strlen(q) + 2;
if ((p = (char*)malloc((unsigned)(p_size))) == NULL) {
ERMSG("ran out of memory");
return(SE_NOMEM);
}
else{
(void) strcpy(p, env);
(void) strcat(p, "=");
(void) strcat(p, q);
else {
(void) strncpy(p, env, p_size);
(void) strncat(p, "=", p_size);
(void) strncat(p, q, p_size);
}
}
else if ((p = strdup(env)) == NULL){
@ -1038,6 +1043,3 @@ int pid;
*/
return(status);
}
#endif //#if IS_UNIX

View File

@ -58,7 +58,7 @@
// NTMBS Utils -- Definition
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#if 0
/*
* TSS::mbsdec
*
@ -96,7 +96,7 @@ tss::mbsdec( const_ntmbs_t beg, const_ntmbs_t curr )
const_ntmbs_t prev = curr - 1;
for ( ; prev > beg && ::mblen( (char*)prev, curr - prev ) == -1; --prev );
if ( curr - prev > MB_CUR_MAX )
if ( (size_t)(curr - prev) > MB_CUR_MAX )
{
prev = (curr - 1);
@ -117,7 +117,7 @@ tss::mbsdec( const_ntmbs_t beg, const_ntmbs_t curr )
return (ntmbs_t)prev;
}
#endif
/*
* TSS::mbsinc

View File

@ -117,11 +117,12 @@
TSS_EXCEPTION( eCharacter, eError );
TSS_EXCEPTION( eCharacterEncoding, eCharacter );
namespace tss
{
/// Specific Routines (Add as needed)
ntmbs_t mbsdec( const_ntmbs_t, const_ntmbs_t );
//ntmbs_t mbsdec( const_ntmbs_t, const_ntmbs_t );
ntmbs_t mbsinc( const_ntmbs_t );
size_t mbsbytes( const_ntmbs_t, size_t );

View File

@ -1,131 +0,0 @@
//
// The developer of the original code and/or files is Tripwire, Inc.
// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire,
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
// reserved.
//
// This program is free software. The contents of this file are subject
// to the terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2 of the License, or (at your
// option) any later version. You may redistribute it and/or modify it
// only in compliance with the GNU General Public License.
//
// This program is distributed in the hope that it will be useful.
// However, this program is distributed AS-IS WITHOUT ANY
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
//
// Nothing in the GNU General Public License or any other license to use
// the code or files shall permit you to use Tripwire's trademarks,
// service marks, or other intellectual property without Tripwire's
// prior written consent.
//
// If you have any questions, please contact Tripwire, Inc. at either
// info@tripwire.org or www.tripwire.org.
//
// objectpool.cpp
#include "stdcore.h"
#include "objectpool.h"
#include "debug.h"
//-----------------------------------------------------------------------------
// cBlockLink
//-----------------------------------------------------------------------------
class cBlockLink
{
public:
cBlockLink(cBlockLink* pNext) : mpNext(pNext) {}
cBlockLink* Next() { return mpNext; }
private:
cBlockLink* mpNext; // pointer to the next link, or NULL
};
//-----------------------------------------------------------------------------
// cBlockList
//-----------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////
// ctor, dtor
///////////////////////////////////////////////////////////////////////////////
cBlockList::cBlockList() :
mpBlocks(0)
{
}
cBlockList::~cBlockList()
{
Clear();
}
///////////////////////////////////////////////////////////////////////////////
// Allocate
///////////////////////////////////////////////////////////////////////////////
void* cBlockList::Allocate(int size)
{
char* mem = new char[size + sizeof(cBlockLink)];
mpBlocks = new(mem) cBlockLink(mpBlocks);
return mem + sizeof(cBlockLink);
}
///////////////////////////////////////////////////////////////////////////////
// Clear
///////////////////////////////////////////////////////////////////////////////
void cBlockList::Clear()
{
while(mpBlocks)
{
cBlockLink* pLink = mpBlocks;
mpBlocks = mpBlocks->Next();
pLink->~cBlockLink();
delete [] (char*)(pLink);
}
}
//-----------------------------------------------------------------------------
// cObjectPoolBase
//-----------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////
// ctor, dtor
///////////////////////////////////////////////////////////////////////////////
cObjectPoolBase::cObjectPoolBase(int objSize, int chunkSize) :
mObjectSize(objSize),
mChunkSize(chunkSize),
mpNextFree(0)
{
}
cObjectPoolBase::~cObjectPoolBase()
{
//TODO -- assert that the number of instances left are 0.
Clear();
}
///////////////////////////////////////////////////////////////////////////////
// AllocNewChunk
///////////////////////////////////////////////////////////////////////////////
void cObjectPoolBase::AllocNewChunk()
{
ASSERT(mpNextFree == 0);
int size = mObjectSize * mChunkSize;
char* pBlock = (char*)mBlockList.Allocate(size);
char* pLast = pBlock + size - mObjectSize;
for(char* pc = pBlock; pc < pLast; pc += mObjectSize)
{
((cLink*)pc)->mpNext = (cLink*)(pc + mObjectSize);
}
((cLink*)pLast)->mpNext = 0;
mpNextFree = (cLink*)pBlock;
}

View File

@ -1,140 +0,0 @@
//
// The developer of the original code and/or files is Tripwire, Inc.
// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire,
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
// reserved.
//
// This program is free software. The contents of this file are subject
// to the terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2 of the License, or (at your
// option) any later version. You may redistribute it and/or modify it
// only in compliance with the GNU General Public License.
//
// This program is distributed in the hope that it will be useful.
// However, this program is distributed AS-IS WITHOUT ANY
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
//
// Nothing in the GNU General Public License or any other license to use
// the code or files shall permit you to use Tripwire's trademarks,
// service marks, or other intellectual property without Tripwire's
// prior written consent.
//
// If you have any questions, please contact Tripwire, Inc. at either
// info@tripwire.org or www.tripwire.org.
//
///////////////////////////////////////////////////////////////////////////////
// objectpool.h
//
// cBlockList -- a linked list of blocks of memory
// cObjectPoolBase -- a pool of equal-sized objects; constant time allocation
#ifndef __OBJECTPOOL_H
#define __OBJECTPOOL_H
class cBlockLink;
//-----------------------------------------------------------------------------
// cBlockList
//-----------------------------------------------------------------------------
class cBlockList
{
public:
cBlockList();
~cBlockList();
void* Allocate(int size);
void Clear(); // releases everything in the block list
private:
cBlockLink* mpBlocks; // linked list of blocks
};
//-----------------------------------------------------------------------------
// cObjectPoolBase
//-----------------------------------------------------------------------------
class cObjectPoolBase
{
public:
cObjectPoolBase(int objSize, int chunkSize);
~cObjectPoolBase();
// NOTE -- dtor is not virtual; therefore it is potentially dangerous to delete a pointer to
// this class unless you know for sure the dynamic class type has nothing to clean up.
void* Alloc ();
void Free (void* pObj);
void Clear ();
//TODO -- add IsPointerValid()
private:
void AllocNewChunk(); // get another chunk to use...
struct cLink
{
cLink* mpNext;
};
cBlockList mBlockList;
const int mObjectSize; // how big are the objects?
const int mChunkSize; // how big are the chunks we are allocating?
cLink* mpNextFree; // the next free object
//int mInstanceCount; // number of objects that are currently allocated but not freed.
};
//-----------------------------------------------------------------------------
// cObjectPool
// Note -- this template only works for classes that are constructed with their
// default ctor; I don't know how to extend this model to work for non-default
// ctors...
//-----------------------------------------------------------------------------
template <class T>
class cObjectPool : public cObjectPoolBase
{
public:
cObjectPool(int chunkSize) : cObjectPoolBase(sizeof(T), chunkSize) {}
T* New () { return new(cObjectPoolBase::Alloc()) T(); }
void Delete (T* pObj) { pObj->~T(); Free(pObj); }
};
//#############################################################################
// inline implementation
//#############################################################################
///////////////////////////////////////////////////////////////////////////////
// Alloc
///////////////////////////////////////////////////////////////////////////////
inline void* cObjectPoolBase::Alloc()
{
if(! mpNextFree)
AllocNewChunk();
cLink* pRtn = mpNextFree;
mpNextFree = mpNextFree->mpNext;
return pRtn;
}
///////////////////////////////////////////////////////////////////////////////
// Free
///////////////////////////////////////////////////////////////////////////////
inline void cObjectPoolBase::Free(void* pObj)
{
cLink* pNew = (cLink*)pObj;
pNew->mpNext = mpNextFree;
mpNextFree = pNew;
}
///////////////////////////////////////////////////////////////////////////////
// Clear
///////////////////////////////////////////////////////////////////////////////
inline void cObjectPoolBase::Clear()
{
mBlockList.Clear();
mpNextFree = 0;
}
#endif //__OBJECTPOOL_H

View File

@ -144,7 +144,7 @@
#define OS OS_OPENBSD
#define IS_OPENBSD 1
#elif defined(_OSX)
#elif defined(__APPLE__)
#define OS OS_DARWIN
#define IS_DARWIN 1
@ -157,7 +157,7 @@
#define IS_MIDNIGHTBSD 1
#elif defined(_SOLARIS) || defined(__sun)
#elif defined(__sun)
#define OS OS_SOLARIS
#define IS_SOLARIS 1
@ -165,11 +165,11 @@
#define OS OS_AIX
#define IS_AIX 1
#elif defined (_HPUX)
#elif defined (__hpux)
#define OS OS_HPUX
#define IS_HPUX 1
#elif defined(_IRIX)
#elif defined(__sgi)
#define OS OS_IRIX
#define IS_IRIX 1

View File

@ -135,9 +135,6 @@ void cRefCountObj::AddRef() const
void cRefCountObj::Release() const
{
if (this == 0)
return;
if (--mRefCount == 0)
{
Delete();

View File

@ -241,14 +241,9 @@ Resource_Class::Get( ConstKeyRef id ) const
if ( at == m_table.end() )
{
#if IS_UNIX
#ifdef _DEBUG
std::cerr << "*** Error Resource_Class::Get() [" __FILE__ ":" << __LINE__ << "]: Resource not found\n";
#endif
#else
ASSERTMSG( 0, "Resource does not exist!" );
#endif
// TSS_Raise( eInternal, "Resource does not exist!" );
return DefaultValueRef();
}

View File

@ -73,7 +73,6 @@ private:
};
#if IS_UNIX
///////////////////////////////////////////////////////////////////////////////
// cUnixTimeFn -- Unix version, inserts proper function call and overloads
// operator()
@ -98,7 +97,7 @@ private:
typedef cTaskTimer<cUnixTimeFn, cUnixTimeFn::DataType> cUnixTaskTimer;
typedef cUnixTaskTimer cGenericTaskTimer;
#endif // IS_UNIX
//-----------------------------------------------------------------------------
// inline implementation

View File

@ -60,16 +60,12 @@
// A little macro that's useful for finding the number of characters in a TCHAR ARRAY
#define countof( x ) ( sizeof( x ) / sizeof( x[0] ) )
#if IS_UNIX
#include <string.h>
#include <string>
#include <sstream>
#include <iostream>
#define TCHAR char
#define _tmain main
@ -129,7 +125,5 @@ typedef std::ifstream TIFSTREAM;
#define __cdecl
#endif
#endif // WIN32
#endif // __TCHAR_H

View File

@ -38,9 +38,7 @@
static void util_SignalHandler( int sig );
#if IS_UNIX
static void tw_psignal( int sig, const TCHAR* s );
#endif
tw_sighandler_t tw_signal(int sig, tw_sighandler_t pFunc)
{
@ -69,15 +67,10 @@ void util_SignalHandler( int sig )
{
//If we're on unix, let's print out a nice error message telling
//the user which signal we've recieved.
#if IS_UNIX
tw_psignal( sig, (TSS_GetString( cCore, core::STR_SIGNAL).c_str() ) );
#endif
exit( 8 );
}
#if IS_UNIX
/* For the morbidly curious, here's a thread where a POSIX standards committee
wrings its hands about how to define NSIG: http://austingroupbugs.net/view.php?id=741#c1834 */
#ifndef NSIG
@ -126,5 +119,5 @@ void tw_psignal(int sig, const TCHAR *str)
_ftprintf(stderr, _T("%s %s\n"), str, sig < NSIG ? siglist[sig] : siglist[0]);
}
#endif

View File

@ -187,5 +187,16 @@ inline int64 SWAPBYTES64(int64 i)
#endif //WORDS_BIGENDIAN
////////////////////////////////////////////
#if __cplusplus >= 201103L
# define TW_UNIQUE_PTR std::unique_ptr
#else
# define TW_UNIQUE_PTR std::auto_ptr
#endif
#endif // __TYPES_H

View File

@ -41,7 +41,6 @@
eUnix::eUnix( const TCHAR* szFunctionName, const TCHAR* szObjectName, bool fCallGetLastError)
: eError( _T(""))
{
#if IS_UNIX
ASSERT( szFunctionName || szObjectName || fCallGetLastError );
//
// construct the error message:
@ -78,7 +77,6 @@ eUnix::eUnix( const TCHAR* szFunctionName, const TCHAR* szObjectName, bool fCall
mMsg += strErr;
}
}
#endif // IS_UNIX
}
// eof - unixexcept.cpp

View File

@ -183,10 +183,10 @@ TCHAR cUnixFSServices::GetPathSeparator() const
}
#if !USES_DEVICE_PATH
void cUnixFSServices::ReadDir(const TSTRING& strFilename, std::vector<TSTRING> &v, bool bFullPaths) const throw(eFSServices)
void cUnixFSServices::ReadDir(const TSTRING& strFilename, std::vector<TSTRING> &v, bool bFullPaths) const
{
#else
void cUnixFSServices::ReadDir(const TSTRING& strFilenameC, std::vector<TSTRING>& v, bool bFullPaths) const throw(eFSServices)
void cUnixFSServices::ReadDir(const TSTRING& strFilenameC, std::vector<TSTRING>& v, bool bFullPaths) const
{
TSTRING strFilename = cDevicePath::AsNative(strFilenameC);
#endif
@ -237,7 +237,7 @@ void cUnixFSServices::ReadDir(const TSTRING& strFilenameC, std::vector<TSTRING>&
}
/* needs to and with S_IFMT, check EQUALITY with S_*, and return more types
cFSStatArgs::FileType cUnixFSServices::GetFileType(const cFCOName &filename) throw(eFSServices)
cFSStatArgs::FileType cUnixFSServices::GetFileType(const cFCOName &filename)
{
cFSStatArgs stat;
Stat(filename, stat);
@ -245,7 +245,7 @@ cFSStatArgs::FileType cUnixFSServices::GetFileType(const cFCOName &filename) thr
}
*/
void cUnixFSServices::GetCurrentDir( TSTRING& strCurDir ) const throw(eFSServices)
void cUnixFSServices::GetCurrentDir( TSTRING& strCurDir ) const
{
TCHAR pathname[iFSServices::TW_MAX_PATH];
pathname[0] = '\0';
@ -258,13 +258,13 @@ void cUnixFSServices::GetCurrentDir( TSTRING& strCurDir ) const throw(eFSService
}
TSTRING& cUnixFSServices::MakeTempFilename( TSTRING& strName ) const throw(eFSServices)
TSTRING& cUnixFSServices::MakeTempFilename( TSTRING& strName ) const
{
char* pchTempFileName;
char szTemplate[iFSServices::TW_MAX_PATH];
int fd;
strcpy( szTemplate, strName.c_str() );
strncpy( szTemplate, strName.c_str(), iFSServices::TW_MAX_PATH );
#ifdef HAVE_MKSTEMP
// create temp filename and check to see if mkstemp failed
@ -295,7 +295,7 @@ TSTRING& cUnixFSServices::MakeTempFilename( TSTRING& strName ) const throw(eFSSe
return( strName );
}
void cUnixFSServices::GetTempDirName( TSTRING& strName ) const throw(eFSServices)
void cUnixFSServices::GetTempDirName( TSTRING& strName ) const
{
strName = mTempPath;
}
@ -307,10 +307,10 @@ void cUnixFSServices::SetTempDirName(TSTRING& tmpPath) {
#if !USES_DEVICE_PATH
void cUnixFSServices::Stat( const TSTRING& strName, cFSStatArgs &stat ) const throw(eFSServices)
void cUnixFSServices::Stat( const TSTRING& strName, cFSStatArgs &stat ) const
{
#else
void cUnixFSServices::Stat( const TSTRING& strNameC, cFSStatArgs& stat) const throw(eFSServices)
void cUnixFSServices::Stat( const TSTRING& strNameC, cFSStatArgs& stat) const
{
TSTRING strName = cDevicePath::AsNative(strNameC);
#endif
@ -375,7 +375,7 @@ void cUnixFSServices::Stat( const TSTRING& strNameC, cFSStatArgs& stat) const th
else stat.mFileType = cFSStatArgs::TY_INVALID;
}
void cUnixFSServices::GetMachineName( TSTRING& strName ) const throw( eFSServices )
void cUnixFSServices::GetMachineName( TSTRING& strName ) const
{
#if HAVE_SYS_UTSNAME_H
struct utsname namebuf;
@ -604,8 +604,8 @@ bool cUnixFSServices::GetGroupName( gid_t group_id, TSTRING& tstrGroup ) const
//
void cUnixFSServices::ConvertModeToString( uint64 perm, TSTRING& tstrPerm ) const
{
TCHAR szPerm[11]; //10 permission bits plus the NULL
_tcscpy( szPerm, _T("----------") );
TCHAR szPerm[12]; //10 permission bits plus the NULL
strncpy( szPerm, _T("----------"), 11);
ASSERT( sizeof(unsigned short) <= sizeof(uint32) );
// We do this in case an "unsigned short" is ever larger than the
@ -912,7 +912,7 @@ bool util_PathFind( TSTRING& strFullPath, const TSTRING& strFilename )
//
// get the path environment variable
//
TCHAR* pszPathVar = _tgetenv("PATH");
TCHAR* pszPathVar = getenv("PATH");
if( pszPathVar != NULL )
{
//

View File

@ -39,7 +39,7 @@
#define __UNIXFSSERVICES_H
#if !IS_UNIX
#error unixfsservices.h should only be included for instantiating cUnixFSServices objects. If you just want to use iFSServices methods, include fsservices.h. Same goes for cWin32FSServices.
#error unixfsservices.h should only be included for instantiating cUnixFSServices objects. If you just want to use iFSServices methods, include fsservices.h.
#endif
//=========================================================================
@ -83,16 +83,16 @@ class cUnixFSServices : public iFSServices
////////////////////////////////////////
// major filesystem functions
////////////////////////////////////////
virtual void Stat( const TSTRING& strFileName, cFSStatArgs& pStat ) const throw( eFSServices );
virtual void Stat( const TSTRING& strFileName, cFSStatArgs& pStat ) const ;
// fills out the cFSStatArgs structure with the stat info for the named file
virtual void GetTempDirName( TSTRING& strName ) const throw( eFSServices );
virtual void GetTempDirName( TSTRING& strName ) const ;
// makes directory if it doesn't exist already. Dirname will end with a delimiter ( '/' )
virtual void SetTempDirName(TSTRING& tmpName);
// set the default dir name which GetTempDirName will use...
virtual TSTRING& MakeTempFilename( TSTRING& strName ) const throw( eFSServices );
virtual TSTRING& MakeTempFilename( TSTRING& strName ) const ;
// create temporary file
// strName must have the form ("baseXXXXXX"), where the X's are replaced with
// characters to make it a unique file. There must be at least 6 Xs.
@ -103,7 +103,7 @@ class cUnixFSServices : public iFSServices
////////////////////////////////////////
virtual void GetHostID( TSTRING& name ) const;
virtual void GetMachineName( TSTRING& name) const throw(eFSServices);
virtual void GetMachineName( TSTRING& name) const;
virtual void GetMachineNameFullyQualified( TSTRING& name ) const;
@ -115,9 +115,9 @@ class cUnixFSServices : public iFSServices
////////////////////////////////////////
// directory specific functions
////////////////////////////////////////
virtual void ReadDir( const TSTRING& strName, std::vector<TSTRING> &vDirContents, bool bFullPaths = true ) const throw( eFSServices );
virtual void ReadDir( const TSTRING& strName, std::vector<TSTRING> &vDirContents, bool bFullPaths = true ) const;
// puts the contents of the specified directory, except for . and .., into the supplied vector.
virtual void GetCurrentDir( TSTRING& strCurDir ) const throw( eFSServices );
virtual void GetCurrentDir( TSTRING& strCurDir ) const;
// returns the current working directory

View File

@ -1,152 +0,0 @@
//
// The developer of the original code and/or files is Tripwire, Inc.
// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire,
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
// reserved.
//
// This program is free software. The contents of this file are subject
// to the terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2 of the License, or (at your
// option) any later version. You may redistribute it and/or modify it
// only in compliance with the GNU General Public License.
//
// This program is distributed in the hope that it will be useful.
// However, this program is distributed AS-IS WITHOUT ANY
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
//
// Nothing in the GNU General Public License or any other license to use
// the code or files shall permit you to use Tripwire's trademarks,
// service marks, or other intellectual property without Tripwire's
// prior written consent.
//
// If you have any questions, please contact Tripwire, Inc. at either
// info@tripwire.org or www.tripwire.org.
//
///////////////////////////////////////////////////////////////////////////////
// utf8.h
//
#include "stdcore.h"
#include "utf8.h" // Required Deps
#include "tchar.h"
//#include "integ/tss.integ.strings.h"
//#include "integ/tss.integ.strings.inl"
#ifdef _UNICODE
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// CLASS UTF8: Member Definitions
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// NOTES: utf8 uses "lazy evaluation" so that members are only allocated
// if they are used. However, once they are evaluated, the evaluation results
// will be saved so that values may henceforth simply be returned. This
// scheme gives the best time vs. space performance possible as the complexity
// of each operation is at most, linear.
const char* cUTF8::str() const THROW(std::bad_alloc) // UTF8: Get as Narrow UTF8
{
if ( mUTF8Str == 0 ) // If mUTF8Str is NULL mUnicodeStr can't be
mUTF8Str = cUTF8::allocate( mUnicodeStr );
return mUTF8Str;
}
const wchar_t* cUTF8::ustr() const THROW(std::bad_alloc) // UTF8: Get as UNICODE NTWCS
{
if ( mUnicodeStr == 0 )
mUnicodeStr = cUTF8::allocate( mUTF8Str ); // If mUnicodeStr is NULL mUTF8WideStr can't be
return mUnicodeStr;
}
const wchar_t* cUTF8::wstr() const THROW(std::bad_alloc) // UTF8: Get as Wide UTF8
{
if ( mUTF8WideStr == 0 )
{
size_t N = ::strlen( str() ); // WARNING: Get strlen NOT mbcslen!!!
mUTF8WideStr = new wchar_t[ N + 1 ]; // This may throw bad_alloc to client
for ( size_t n = 0; n < N; n++ ) // index ordinal, not pointer
mUTF8WideStr[n] = wchar_t( BYTE(mUTF8Str[n]) ); // WARNING: First convert to "unsigned char"
mUTF8WideStr[N] = 0; // add a final NULL
}
return mUTF8WideStr;
}
/// UTF8: UTF8-Unicode Round-trip Conversions
wchar_t* cUTF8::allocate( const char* in ) THROW( std::bad_alloc )
{
ASSERT( in /* && TSS_IsValidString( in )*/ ); // Verify Input
size_t N = ::MultiByteToWideChar( CP_UTF8, 0, in, -1, 0, 0 );
wchar_t* out = new wchar_t[ N + 1 ]; // Allocate required size
//--Convert
out[0] = 0x00; // NOTE: Just in case we fail
#ifdef _DEBUG
//size_t nWritten =
#endif
::MultiByteToWideChar( CP_UTF8, 0, in, -1, out, N );
out[N] = 0;
#ifdef _INTEG2 // Verify Output
if ( nWritten == 0 )
{
cDebug d( "cUTF8::allocate" );
d.TraceError( "MultiByteToWideChar failed with %x\n", ::GetLastError() );
}
ASSERT( out && TSS_IsValidString( out, nWritten ) );
#endif
return out;
}
char* cUTF8::allocate( const wchar_t* in ) THROW( std::bad_alloc )
{
ASSERT( in /*&& TSS_IsValidString( in ) */); // Verify Input
// Allocate required size
size_t N = ::WideCharToMultiByte( CP_UTF8, 0, in, -1,0,0,0,0 );
char* out = new char[ N + 1 ];
//--Convert
out[0] = 0x00; // NOTE: Just in case we fail
#ifdef _DEBUG
//size_t nWritten =
#endif
::WideCharToMultiByte( CP_UTF8, 0, in, -1, out, N, 0, 0 );
out[N] = 0;
#ifdef _INTEG2 // Verify Output
if ( nWritten == 0 )
{
cDebug d( "cUTF8::allocate" );
d.TraceError( "WideCharToMultiByte failed with %x\n", ::GetLastError() );
}
ASSERT( out /*&& TSS_IsValidString( out, nWritten ) */);
#endif
return out;
}
#endif //_UNICODE

View File

@ -1,187 +0,0 @@
//
// The developer of the original code and/or files is Tripwire, Inc.
// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire,
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
// reserved.
//
// This program is free software. The contents of this file are subject
// to the terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2 of the License, or (at your
// option) any later version. You may redistribute it and/or modify it
// only in compliance with the GNU General Public License.
//
// This program is distributed in the hope that it will be useful.
// However, this program is distributed AS-IS WITHOUT ANY
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
//
// Nothing in the GNU General Public License or any other license to use
// the code or files shall permit you to use Tripwire's trademarks,
// service marks, or other intellectual property without Tripwire's
// prior written consent.
//
// If you have any questions, please contact Tripwire, Inc. at either
// info@tripwire.org or www.tripwire.org.
//
///////////////////////////////////////////////////////////////////////////////
// utf8.h
//
// UTF8 is used to map UNICODE characters to NTBS targets
// that would normally not be able to dealt with. UTF8
// ensures symetrical round-trip conversions. In other
// words an unmapable UNICODE character converted to UTF8
// will always convert back to the same UNICODE value.
//
// For more information, go to:
// mk:@MSITStore:\\SQUID\MSDN%20January%201999\MSDN\kbwindev.chm::/Source/win32sdk/q175392.htm
#ifndef __UTF8_H
#define __UTF8_H
#include <iostream> // operator<<
//#ifndef __TSS_INTEG_STRINGS_H
//#include "integ/tss.integ.strings.h" // IsValidAddress and IsValidString
//#endif
#ifndef __DEBUG_H
#include "debug.h"
#endif
//-----------------------------------------------------------------------------
// convenience macros
//
// use these when printing a string ( TCHAR* ) to stdout, stderr, of printf-style
// function to safely convert the string to something printable
//-----------------------------------------------------------------------------
#ifdef _UNICODE
# define TSS_UTF8( x ) cUTF8( x ).wstr()
#else
# define TSS_UTF8( x ) x
#endif
#ifdef _UNICODE // this class is only needed in unicode builds...
//-----------------------------------------------------------------------------
// Entities Declared in this Module
//-----------------------------------------------------------------------------
class cUTF8;
std::ostream& operator<<( std::ostream&, const cUTF8& );
std::wostream& operator<<( std::wostream&, const cUTF8& );
/// Class Declaration
#ifdef _THROW_SUPPORTED
#define THROW( x ) throw( x )
#define THROW_0 throw()
#else
#define THROW( x )
#define THROW_0
#endif
//=============================================================================
// class cUTF8: Encapsulate UTF8 Encoding
//
// SYNOPSIS:
// Allows unmappable UNICODE characters to be embedded into Narrow strings
// and displayable by narrow display streams.
//
// CONSTRAINTS:
// Cannot default or copy construct or assign UTF8 instances. Each UTF8
// instance is an exclusive owner of its resources for its life-time.
// This cuts down on the amount of redundant allocation and copying that
// is required by the class.
//=============================================================================
class cUTF8
{
/// Interface.
public:
cUTF8( const char* ) THROW( std::bad_alloc );
cUTF8( const wchar_t* ) THROW( std::bad_alloc );
~cUTF8();
const char* str() const THROW( std::bad_alloc ); // Narrow UTF8
const wchar_t* wstr() const THROW( std::bad_alloc ); // Wide UTF8
const wchar_t* ustr() const THROW( std::bad_alloc ); // Unicode
/// Implementation.
protected:
static char* allocate( const wchar_t* ) THROW( std::bad_alloc );
static wchar_t* allocate( const char* ) THROW( std::bad_alloc );
protected:
cUTF8( const cUTF8& ); // Disallow
cUTF8& operator=( const cUTF8& ); // Disallow
private:
mutable wchar_t* mUnicodeStr; // UNICODE String
mutable char* mUTF8Str; // UTF8 Bytes String
mutable wchar_t* mUTF8WideStr; // UTF8 Wide Character String
};
//-----------------------------------------------------------------------------
// UTF8 Inlines: Members and Global Binary Non-Member Operators
//-----------------------------------------------------------------------------
// Create from NTBS UTF8
inline cUTF8::cUTF8( const char* psz ) THROW( std::bad_alloc )
: mUnicodeStr( cUTF8::allocate( psz ) ),
mUTF8Str( 0 ),
mUTF8WideStr( 0 )
{
ASSERT( mUnicodeStr || mUTF8Str );
}
// Create from NTWCS UNICODE
inline cUTF8::cUTF8( const wchar_t* wsz ) THROW( std::bad_alloc )
: mUnicodeStr( 0 ),
mUTF8Str( cUTF8::allocate( wsz ) ),
mUTF8WideStr( 0 )
{
ASSERT( mUnicodeStr || mUTF8Str );
}
inline cUTF8::~cUTF8()
{
delete [] mUnicodeStr; // Delete UNICODE (if exists)
delete [] mUTF8Str; // Delete UTF8 (NTBS)
delete [] mUTF8WideStr; // Delete UTF8 (NTWCS)
}
/// Operators
inline std::ostream& operator<<( std::ostream& out, const cUTF8& str )
{
out << str.str();
return out;
}
inline std::wostream& operator<<( std::wostream& wout, const cUTF8& str )
{
wout << str.wstr(); // CAUTION: Don't send UNICODE string, it won't display!
return wout;
}
#endif //_UNICODE
#endif/*_TSS_UTF8_H*/

View File

@ -5,6 +5,12 @@
#include "queue.h"
#include <memory>
#if __cplusplus >= 201103L
# define TW_UNIQUE_PTR std::unique_ptr
#else
# define TW_UNIQUE_PTR std::auto_ptr
#endif
Filter::Filter(BufferedTransformation *outQ)
: outQueue(outQ ? outQ : new ByteQueue)
{
@ -17,7 +23,7 @@ Filter::Filter(const Filter &source)
void Filter::Detach(BufferedTransformation *newOut)
{
std::auto_ptr<BufferedTransformation> out(newOut ? newOut : new ByteQueue);
TW_UNIQUE_PTR<BufferedTransformation> out(newOut ? newOut : new ByteQueue);
outQueue->Close();
outQueue->TransferTo(*out);
outQueue.reset(out.release());

View File

@ -5,6 +5,12 @@
#include "queue.h"
#include <memory>
#if __cplusplus >= 201103L
# define TW_UNIQUE_PTR std::unique_ptr
#else
# define TW_UNIQUE_PTR std::auto_ptr
#endif
Fork::Fork(int n, BufferedTransformation *const *givenOutPorts)
: numberOfPorts(n), outPorts(n)
{
@ -21,7 +27,7 @@ void Fork::SelectOutPort(int portNumber)
void Fork::Detach(BufferedTransformation *newOut)
{
std::auto_ptr<BufferedTransformation> out(newOut ? newOut : new ByteQueue);
TW_UNIQUE_PTR<BufferedTransformation> out(newOut ? newOut : new ByteQueue);
outPorts[currentPort]->Close();
outPorts[currentPort]->TransferTo(*out);
outPorts[currentPort].reset(out.release());

View File

@ -236,7 +236,7 @@ int Deflator::longest_match(IPos cur_match)
if (prev_length >= good_match) {
chain_length >>= 2;
}
assert(strstart <= (unsigned)WINDOW_SIZE-MIN_LOOKAHEAD);
//assert(strstart <= (unsigned)WINDOW_SIZE-MIN_LOOKAHEAD);
do {
assert(cur_match < strstart);

View File

@ -140,7 +140,7 @@ void cBlockFile::Close()
void cBlockFile::Flush()
{
ASSERT( mpArchive );
for( BlockVector::iterator i = mvPagedBlocks.begin(); i != mvPagedBlocks.end(); i++ )
for( BlockVector::iterator i = mvPagedBlocks.begin(); i != mvPagedBlocks.end(); ++i )
{
FlushBlock( &(*i) );
}
@ -171,7 +171,7 @@ cBlockFile::Block* cBlockFile::GetBlock( int blockNum ) //throw (eArchive)
mTimer++;
if( mTimer == 0 )
{
for( BlockVector::iterator i = mvPagedBlocks.begin(); i != mvPagedBlocks.end(); i++ )
for( BlockVector::iterator i = mvPagedBlocks.begin(); i != mvPagedBlocks.end(); ++i )
{
i->SetTimestamp( 0 );
}
@ -179,7 +179,7 @@ cBlockFile::Block* cBlockFile::GetBlock( int blockNum ) //throw (eArchive)
//
// now, see if the desired block is in memory...
//
for( BlockVector::iterator i = mvPagedBlocks.begin(); i != mvPagedBlocks.end(); i++ )
for( BlockVector::iterator i = mvPagedBlocks.begin(); i != mvPagedBlocks.end(); ++i )
{
if( i->GetBlockNum() == blockNum )
{
@ -201,9 +201,9 @@ cBlockFile::Block* cBlockFile::GetBlock( int blockNum ) //throw (eArchive)
uint32 earliestTime = mvPagedBlocks[0].GetTimestamp();
BlockVector::iterator it = mvPagedBlocks.begin();
BlockVector::iterator earliestIter = it;
it++; // since we don't want to check the first one
++it; // since we don't want to check the first one
ASSERT(it != mvPagedBlocks.end());
for( ; it != mvPagedBlocks.end(); it++ )
for( ; it != mvPagedBlocks.end(); ++it )
{
if( it->GetTimestamp() < earliestTime )
{

View File

@ -277,7 +277,7 @@ int cBlockRecordFile::FindRoomForData( int32 dataSize ) //throw (eArchive)
//
BlockArray::iterator it;
int cnt = 0;
for( it = mvBlocks.begin(); it != mvBlocks.end(); it++, cnt++ )
for( it = mvBlocks.begin(); it != mvBlocks.end(); ++it, ++cnt )
{
util_InitBlockArray( *it );
if( it->GetAvailableSpace() >= dataSize )
@ -310,7 +310,7 @@ void cBlockRecordFile::TraceContents(int dl) const
{
// TODO -- this is probably not what I want to do, but it helps me right now...
//
for( BlockArray::const_iterator i = mvBlocks.begin(); i != mvBlocks.end(); i++ )
for( BlockArray::const_iterator i = mvBlocks.begin(); i != mvBlocks.end(); ++i )
{
i->TraceContents( dl );
}
@ -330,7 +330,7 @@ void cBlockRecordFile::AssertValid() const
///////////////////////////////////////////////////////////////////////////////
void cBlockRecordFile::AssertAllBlocksValid()
{
for( BlockArray::iterator i = mvBlocks.begin(); i != mvBlocks.end(); i++ )
for( BlockArray::iterator i = mvBlocks.begin(); i != mvBlocks.end(); ++i )
{
i->AssertValid();
}

View File

@ -405,7 +405,7 @@ bool cHierDatabaseIter::Done() const
///////////////////////////////////////////////////////////////////////////////
void cHierDatabaseIter::Next()
{
mIter++;
++mIter;
}
///////////////////////////////////////////////////////////////////////////////
@ -552,10 +552,10 @@ void cHierDatabaseIter::CreateEntry( const TSTRING& name ) //throw (eArchive, eH
{
// altering the previous node...
//
mIter--;
--mIter;
mIter->mNext = newAddr;
util_RewriteObject( mpDb, &(*mIter), GetCurrentAddr() );
mIter++;
++mIter;
}
}
@ -672,10 +672,10 @@ void cHierDatabaseIter::DeleteEntry() //throw (eArchive, eHierDatabase)
{
// altering the previous node...
//
mIter--;
--mIter;
mIter->mNext = (mIter+1)->mNext;
util_RewriteObject( mpDb, &(*mIter), GetCurrentAddr() );
mIter++;
++mIter;
}
//
// now, delete the node from the file and from our array...
@ -751,7 +751,7 @@ bool cHierDatabaseIter::CompareForUpperBound( const cHierEntry& he, const TCHAR*
class cHierDatabaseIterCallCompare
{
public:
cHierDatabaseIterCallCompare( const cHierDatabaseIter* pcls )
explicit cHierDatabaseIterCallCompare( const cHierDatabaseIter* pcls )
: pc( pcls ) {};
bool operator()( const cHierEntry& a1, const TCHAR* a2 )

View File

@ -114,7 +114,7 @@ private:
class cHierDatabaseIter
{
public:
cHierDatabaseIter( cHierDatabase* pDb ); //throw (eArchive)
explicit cHierDatabaseIter( cHierDatabase* pDb ); //throw (eArchive)
~cHierDatabaseIter();
//

View File

@ -68,7 +68,7 @@ public:
};
cHierNode( Type type = TYPE_INVALID ) : mType( type ) {}
explicit cHierNode( Type type = TYPE_INVALID ) : mType( type ) {}
virtual ~cHierNode() {}
int32 mType;

View File

@ -53,7 +53,7 @@ public:
};
cFCOCompare();
cFCOCompare( const cFCOPropVector& propsToCompare);
explicit cFCOCompare( const cFCOPropVector& propsToCompare);
virtual ~cFCOCompare();
void SetPropsToCmp(const cFCOPropVector& pv);

View File

@ -46,6 +46,8 @@ public:
enum { CHILDREN_NONE = 0,
CHILDREN_ALL = -1 };
virtual ~iFCODataSource() = 0;
// NOTE -- in the act of creating fcos, there are certain properties that we can obtain "for free" just
// by the act of querying the system we are generating fcos for (for example, a stat() call is required
// to create file system fcos, which also gives us many of the fsfco's property values). Therefore,

View File

@ -52,7 +52,7 @@
//=========================================================================
cFCODataSourceIterImpl::cFCODataSourceIterImpl()
: mFlags(0)
: mpErrorBucket(0), mParentName(), mFlags(0)
{
}
@ -75,7 +75,7 @@ cFCODataSourceIterImpl& cFCODataSourceIterImpl::operator=( const cFCODataSourceI
//
// we need to addref all of the fcos we just got...
//
for( FCOList::const_iterator i = mPeers.begin(); i != mPeers.end(); i++ )
for( FCOList::const_iterator i = mPeers.begin(); i != mPeers.end(); ++i )
{
(*i)->AddRef();
}
@ -191,7 +191,7 @@ bool cFCODataSourceIterImpl::Done() const
///////////////////////////////////////////////////////////////////////////////
void cFCODataSourceIterImpl::Next()
{
mCurPos++;
++mCurPos;
}
///////////////////////////////////////////////////////////////////////////////
@ -265,7 +265,8 @@ void cFCODataSourceIterImpl::SeekToFCO(const cFCOName& name, bool bCreatePeers)
GeneratePeers();
}
SeekToPeerByName( (*mCurPos)->GetName().GetShortName() );
if(mCurPos != mPeers.end() && *mCurPos)
SeekToPeerByName( (*mCurPos)->GetName().GetShortName() );
}
///////////////////////////////////////////////////////////////////////////////
@ -281,7 +282,7 @@ bool cFCODataSourceIterImpl::IsCaseSensitive() const
///////////////////////////////////////////////////////////////////////////////
void cFCODataSourceIterImpl::ClearList()
{
for( mCurPos = mPeers.begin(); mCurPos != mPeers.end(); mCurPos++ )
for( mCurPos = mPeers.begin(); mCurPos != mPeers.end(); ++mCurPos )
{
(*mCurPos)->Release();
}
@ -315,7 +316,7 @@ void cFCODataSourceIterImpl::GeneratePeers()
//
std::vector<TSTRING>::iterator i;
cFCOName curName = mParentName;
for( i = vChildrenNames.begin(); i != vChildrenNames.end(); i++)
for( i = vChildrenNames.begin(); i != vChildrenNames.end(); ++i)
{
curName.Push( *i );
@ -368,7 +369,7 @@ void cFCODataSourceIterImpl::TraceContents(int dl) const
d.Trace( dl, "FCO Iterator; parent = %s\n", mParentName.AsString().c_str() );
d.Trace( dl, "---- Peers ---- (current has a * by it)\n" );
int cnt = 0;
for( FCOList::const_iterator iter = mPeers.begin(); iter != mPeers.end(); iter++, cnt++ )
for( FCOList::const_iterator iter = mPeers.begin(); iter != mPeers.end(); ++iter, ++cnt )
{
d.Trace( dl, "[%d]%c\t:%s\n", cnt, iter == mCurPos ? _T('*') : _T(' '), (*iter)->GetName().AsString().c_str() );
}
@ -439,7 +440,7 @@ bool cFCODataSourceIterImpl::CompareForUpperBound( const iFCO* pFCO, const TCHAR
class cFCODataSourceIterImplCallCompare
{
public:
cFCODataSourceIterImplCallCompare( const cFCODataSourceIterImpl* pcls )
explicit cFCODataSourceIterImplCallCompare( const cFCODataSourceIterImpl* pcls )
: pc( pcls ) {};
bool operator()( const iFCO* a1, const TCHAR* a2 )

View File

@ -177,7 +177,7 @@ void cFCOName::SetNameInfo(iFCONameInfo* pNI)
///////////////////////////////////////////////////////////////////////////////
// operator=
///////////////////////////////////////////////////////////////////////////////
void cFCOName::operator = (const cFCOName& rhs)
cFCOName& cFCOName::operator = (const cFCOName& rhs)
{
mpPathName->Release();
// TODO -- I am sure this won't work (const-ness)
@ -188,16 +188,19 @@ void cFCOName::operator = (const cFCOName& rhs)
#ifdef _DEBUG
mDebugStrName = AsString();
#endif
return *this;
}
void cFCOName::operator = (const TSTRING& rhs)
cFCOName& cFCOName::operator = (const TSTRING& rhs)
{
*this = rhs.c_str();
#ifdef _DEBUG
mDebugStrName = AsString();
#endif
return *this;
}
void cFCOName::operator = (const TCHAR* rhs)
cFCOName& cFCOName::operator = (const TCHAR* rhs)
{
// if I have the only handle on this vector, I can reuse it
// otherwise, I have to release it.
@ -210,6 +213,7 @@ void cFCOName::operator = (const TCHAR* rhs)
#ifdef _DEBUG
mDebugStrName = AsString();
#endif
return *this;
}
void cFCOName::ParseString( const TCHAR* pszin )
@ -284,7 +288,7 @@ TSTRING cFCOName::AsString() const
TSTRING current = (*i)->GetString();
// the loop is constructed in this odd fashion because I don't want a trailing mDelimiter
str += current;
i++;
++i;
if(i != mpPathName->mNames.end() && current != "/")
str += mDelimiter;
@ -339,7 +343,7 @@ cFCOName::Relationship cFCOName::GetRelationship(const cFCOName& rhs) const
for(myIter = mpPathName->mNames.begin(), rhsIter = rhs.mpPathName->mNames.begin();
(myIter != mpPathName->mNames.end() && rhsIter != rhs.mpPathName->mNames.end());
myIter++, rhsIter++)
++myIter, ++rhsIter)
{
if(bCaseSensitive)
bEqual = (*myIter == *rhsIter);
@ -518,7 +522,7 @@ bool cFCOName::operator<(const cFCOName& rhs) const
for(myIter = mpPathName->mNames.begin(), rhsIter = rhs.mpPathName->mNames.begin();
(myIter != mpPathName->mNames.end() && rhsIter != rhs.mpPathName->mNames.end());
myIter++, rhsIter++)
++myIter, ++rhsIter)
{
if(bCaseSensitive)
{
@ -589,7 +593,7 @@ void cFCONameIter::SeekBegin()
///////////////////////////////////////////////////////////////////////////////
void cFCONameIter::Next()
{
mIter++;
++mIter;
}
///////////////////////////////////////////////////////////////////////////////
@ -615,7 +619,7 @@ const TCHAR* cFCONameIter::GetName() const
///////////////////////////////////////////////////////////////////////////////
void cFCONameIter::Prev()
{
mIter--;
--mIter;
}
///////////////////////////////////////////////////////////////////////////////

View File

@ -58,7 +58,7 @@ class cFCOName : public iTypedSerializable
public:
typedef cFCONameIter iterator;
cFCOName(iFCONameInfo* iNI = NULL);
explicit cFCOName(iFCONameInfo* iNI = NULL);
cFCOName(const cFCOName& rhs);
explicit cFCOName(const TSTRING& rhs, iFCONameInfo* iNI = NULL);
@ -67,9 +67,9 @@ public:
// do it unexpectedly
virtual ~cFCOName();
void operator = (const cFCOName& rhs);
void operator = (const TSTRING& rhs);
void operator = (const TCHAR* rhs);
cFCOName& operator = (const cFCOName& rhs);
cFCOName& operator = (const TSTRING& rhs);
cFCOName& operator = (const TCHAR* rhs);
bool operator < (const cFCOName& rhs) const;
// defines an arbitrary order for cFCONames. This is so that names can
@ -165,7 +165,7 @@ class cFCONameIter_i;
class cFCONameIter
{
public:
cFCONameIter(const cFCOName& name);
explicit cFCONameIter(const cFCOName& name);
~cFCONameIter();
int GetSize() const; // returns the number of entries in the fco name

View File

@ -39,8 +39,6 @@
//#############################################################################
// cFCONameTblNode
//#############################################################################
// uncomment this to allocate fconametblnodes from a pool.
//cObjectPoolBase cFCONameTblNode::msAllocator(sizeof(cFCONameTblNode), 1000);
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
@ -112,8 +110,9 @@ void cFCONameTblNode::SetString(const TSTRING& newStr)
mpString = NULL;
}
mpString = (TCHAR*)util_AllocMem( sizeof(TCHAR)*(newStr.length()+1) );
_tcscpy( mpString, newStr.c_str() );
size_t alloc_size = sizeof(TCHAR)*(newStr.length()+1);
mpString = (TCHAR*)util_AllocMem(alloc_size);
strncpy( mpString, newStr.c_str(), alloc_size );
// NOTE -- the lower case pointer is now invalid.
}
@ -188,7 +187,7 @@ cFCONameTblNode* cFCONameTbl::CreateNode(const TSTRING& nodeName)
// TODO:BAM -- does this have any meaning in mb?
for(i = lowStr.begin(); i != lowStr.end(); ++i)
{
*i = _totlower(*i);
*i = tolower(*i);
}
// see if this exists in the table (it could potentially look up itself!)
if(mTable.Lookup(lowStr.c_str(), pLowerNode))

View File

@ -46,15 +46,6 @@
#include "core/hashtable.h"
#endif
// uncomment this to allocate fconametblnodes from a pool.
/*
#ifndef __OBJECTPOOL_H
#include "objectpool.h"
#endif
*/
// end TODO
class cFCONameTbl_i;
///////////////////////////////////////////////////////////////////////////////
@ -119,7 +110,7 @@ private:
class cFCONameTbl
{
public:
cFCONameTbl(int defSize = HASH_VERY_LARGE);
explicit cFCONameTbl(int defSize = HASH_VERY_LARGE);
// defSize is the initial hash table size
~cFCONameTbl();

View File

@ -394,7 +394,6 @@ void cFCOPropVector::Read(iSerializer* pSerializer, int32 version)
if (version > 0)
ThrowAndAssert(eSerializerVersionMismatch(_T("Property Vector Read")));
int i;
int32 newSize;
pSerializer->ReadInt32(newSize);
ASSERT(newSize > 0);
@ -409,7 +408,7 @@ void cFCOPropVector::Read(iSerializer* pSerializer, int32 version)
}
else
{
for (i=0; i <= mSize / msBitlength; ++i)
for (int i=0; i <= mSize / msBitlength; ++i)
{
int32 mask;
pSerializer->ReadInt32(mask);
@ -421,7 +420,6 @@ void cFCOPropVector::Read(iSerializer* pSerializer, int32 version)
void cFCOPropVector::Write(iSerializer* pSerializer) const
{
int i;
pSerializer->WriteInt32(mSize);
if (mpBuf == NULL)
@ -430,7 +428,7 @@ void cFCOPropVector::Write(iSerializer* pSerializer) const
}
else
{
for (i=0; i <= mSize / msBitlength; ++i)
for (int i=0; i <= mSize / msBitlength; ++i)
pSerializer->WriteInt32((*mpBuf)[i]);
}

View File

@ -49,7 +49,7 @@
class cFCOPropVector : public iSerializable // note: this is not iTypedSerializable
{
public:
cFCOPropVector (int size = 32);
explicit cFCOPropVector (int size = 32);
cFCOPropVector (const cFCOPropVector& rhs);
virtual ~cFCOPropVector (void);
bool operator== (const cFCOPropVector& rhs) const;

View File

@ -80,7 +80,7 @@ cFCOSetImpl::cFCOSetImpl(const cFCOSetImpl& rhs) : iFCOSet()
///////////////////////////////////////////////////////////////////////////////
// operator=
///////////////////////////////////////////////////////////////////////////////
void cFCOSetImpl::operator=(const cFCOSetImpl& rhs)
cFCOSetImpl& cFCOSetImpl::operator=(const cFCOSetImpl& rhs)
{
std::set<cFCONode>::const_iterator i;
for(i = rhs.mFCOSet.begin(); i != rhs.mFCOSet.end(); ++i)
@ -88,6 +88,8 @@ void cFCOSetImpl::operator=(const cFCOSetImpl& rhs)
i->mpFCO->AddRef();
mFCOSet.insert(cFCONode(i->mpFCO));
}
return *this;
}
///////////////////////////////////////////////////////////////////////////////
@ -202,7 +204,7 @@ void cFCOSetImpl::Write(iSerializer* pSerializer) const
pSerializer->WriteInt32(mFCOSet.size());
std::set<cFCONode>::const_iterator itr;
for( itr = mFCOSet.begin(); itr != mFCOSet.end(); itr++)
for( itr = mFCOSet.begin(); itr != mFCOSet.end(); ++itr)
{
pSerializer->WriteObjectDynCreate(itr->mpFCO);
}
@ -284,7 +286,7 @@ bool cFCOIterImpl::IsEmpty() const
void cFCOIterImpl::Next() const
{
ASSERT(mpSet != 0);
mIter++;
++mIter;
}

View File

@ -56,7 +56,7 @@ public:
cFCOSetImpl();
cFCOSetImpl(const cFCOSetImpl& rhs);
virtual ~cFCOSetImpl();
void operator=(const cFCOSetImpl& rhs);
cFCOSetImpl& operator=(const cFCOSetImpl& rhs);
virtual const iFCOIter* Lookup(const cFCOName& name) const;
virtual iFCOIter* Lookup(const cFCOName& name);
@ -85,8 +85,9 @@ private:
const cFCOName* mpFCOName;
cFCONode() : mpFCO(0), mpFCOName(0) {}
cFCONode(iFCO* pFCO) : mpFCO(pFCO), mpFCOName(&pFCO->GetName()) {}
cFCONode(const cFCOName& name) : mpFCO(0), mpFCOName(&name) {}
//TODO: make the iFCO* constructor explicit
cFCONode(iFCO* pFCO) : mpFCO(pFCO), mpFCOName(&pFCO->GetName()) {}
explicit cFCONode(const cFCOName& name) : mpFCO(0), mpFCOName(&name) {}
cFCONode(const cFCONode& rhs) : mpFCO(rhs.mpFCO), mpFCOName(rhs.mpFCOName) {}
bool operator < (const cFCONode& rhs) const { if(mpFCOName) return (*mpFCOName < *rhs.mpFCOName); else return false; }
bool operator ==(const cFCONode& rhs) const { if(mpFCOName) return (*mpFCOName == *rhs.mpFCOName); else return false; }
@ -101,8 +102,8 @@ class cFCOIterImpl : public iFCOIter
friend class cFCOSetImpl;
public:
cFCOIterImpl(cFCOSetImpl* pSet);
cFCOIterImpl(const cFCOSetImpl* pSet);
explicit cFCOIterImpl(cFCOSetImpl* pSet);
explicit cFCOIterImpl(const cFCOSetImpl* pSet);
virtual void SeekBegin() const;
virtual bool Done() const;

View File

@ -94,7 +94,7 @@ private:
class cFCOSpecAttrEmailIter
{
public:
cFCOSpecAttrEmailIter(const cFCOSpecAttr& attr);
explicit cFCOSpecAttrEmailIter(const cFCOSpecAttr& attr);
~cFCOSpecAttrEmailIter();
void SeekBegin() const;
@ -171,7 +171,7 @@ inline bool cFCOSpecAttrEmailIter::IsEmpty() const
}
inline void cFCOSpecAttrEmailIter::Next() const
{
mIter++;
++mIter;
}
inline const TSTRING& cFCOSpecAttrEmailIter::EmailAddress() const
{

View File

@ -221,7 +221,7 @@ void cFCOSpecStopPointSet::Add(const cFCOName& name)
break;
default:
i++;
++i;
}
}
@ -306,7 +306,7 @@ iFCOSpecHelper::CompareResult cFCOSpecStopPointSet::Compare(const iFCOSpecHelper
std::set<cFCOName>::const_iterator myIter = mStopPoints.begin(),
rhsIter = pStopPtSet->mStopPoints.begin();
for(; myIter != mStopPoints.end(); myIter++, rhsIter++)
for(; myIter != mStopPoints.end(); ++myIter, ++rhsIter)
{
if(*myIter != *rhsIter)
return ((*myIter < *rhsIter) ? CMP_LT : CMP_GT);

View File

@ -159,7 +159,7 @@ protected:
class cFCOSpecStopPointIter
{
public:
cFCOSpecStopPointIter(cFCOSpecStopPointSet& set);
explicit cFCOSpecStopPointIter(cFCOSpecStopPointSet& set);
void SeekBegin() const;
// seeks to the beginning of the stop point list
@ -257,7 +257,7 @@ inline bool cFCOSpecStopPointIter::IsEmpty() const
inline void cFCOSpecStopPointIter::Next() const
{
mIter++;
++mIter;
}
inline void cFCOSpecStopPointIter::Remove()

View File

@ -100,11 +100,13 @@ IMPLEMENT_SERREFCOUNT(cFCOSpecImpl, _T("cFCOSpecImpl"), 0, 1);
///////////////////////////////////////////////////////////////////////////////
// operator=
///////////////////////////////////////////////////////////////////////////////
void cFCOSpecImpl::operator=(const cFCOSpecImpl& rhs)
cFCOSpecImpl& cFCOSpecImpl::operator=(const cFCOSpecImpl& rhs)
{
mName = rhs.mName;
mPropVector = rhs.mPropVector;
mpHelper = rhs.mpHelper ? rhs.mpHelper->Clone() : 0;
return *this;
}
///////////////////////////////////////////////////////////////////////////////
// Clone -- make a copy of this spec

View File

@ -70,7 +70,7 @@ public:
// the spec will delete whatever helper it contains when it is destroyed
cFCOSpecImpl(const cFCOSpecImpl& rhs);
cFCOSpecImpl();
void operator=(const cFCOSpecImpl& rhs);
cFCOSpecImpl& operator=(const cFCOSpecImpl& rhs);
// from iFCOSpec
virtual bool SpecContainsFCO (const cFCOName& name) const;

View File

@ -61,7 +61,7 @@ void cFCOSpecList::Clear()
{
std::list<PairType>::iterator itr;
for (itr = mAddedList.begin(); itr != mAddedList.end(); itr++)
for (itr = mAddedList.begin(); itr != mAddedList.end(); ++itr)
{
itr->first->Release();
itr->second->Release();
@ -227,7 +227,7 @@ void cFCOSpecListAddedIter::Remove()
// the tricky part is finding the spec in the other list...
std::list<cFCOSpecList::PairType>::iterator i;
for(i = mpSpecList->mCanonicalList.begin(); i != mpSpecList->mCanonicalList.end(); i++)
for(i = mpSpecList->mCanonicalList.begin(); i != mpSpecList->mCanonicalList.end(); ++i)
{
if(i->first == mIter->first)
break;

View File

@ -103,7 +103,7 @@ protected:
class cFCOSpecListAddedIter
{
public:
cFCOSpecListAddedIter(const cFCOSpecList& list);
explicit cFCOSpecListAddedIter(const cFCOSpecList& list);
~cFCOSpecListAddedIter();
void SeekBegin() const;
@ -129,7 +129,7 @@ protected:
class cFCOSpecListCanonicalIter
{
public:
cFCOSpecListCanonicalIter(const cFCOSpecList& list);
explicit cFCOSpecListCanonicalIter(const cFCOSpecList& list);
~cFCOSpecListCanonicalIter();
void SeekBegin() const;

View File

@ -99,14 +99,12 @@ cGenre::Genre cGenreSwitcher::GetDefaultGenre()
void cGenreSwitcher::RegisterGenre( const cGenreInfo* pGI, RegisterFlags flags /* = REGISTER_FLAGS_NONE */ )
{
cDebug d("cGenreSwitcher::RegisterGenre");
d.TraceDebug( _T("ID: %x, long name: %s, short name: %s\n"), pGI->m_ID, pGI->m_sLongName.c_str(), pGI->m_sShortName.c_str() );
//
// validate params
//
ASSERT( NULL != pGI );
ASSERT( pGI->IsValid() );
d.TraceDebug( _T("ID: %x, long name: %s, short name: %s\n"), pGI->m_ID, pGI->m_sLongName.c_str(), pGI->m_sShortName.c_str() );
//
// can only be one of each genre ID
//
@ -145,12 +143,7 @@ bool cGenreSwitcher::IsGenreRegistered( cGenre::Genre g )
bool cGenreSwitcher::IsGenreAppropriate( cGenre::Genre g )
{
#if IS_UNIX
const uint32 platformMask = cGenre::PLATFORM_MASK_UNIX;
#else
#error who am I?
#endif
const uint32 platformMask = cGenre::PLATFORM_MASK_UNIX;
return( ( platformMask & g ) != 0 );
}
@ -230,7 +223,7 @@ cGenre::Genre cGenreSwitcher::StringToGenre( const wchar_t* wsz )
cGenreInfoVec::const_iterator cGenreInfoVec::find( cGenre::Genre g ) const
{
const_iterator i;
for( i = begin(); i != end(); i++ )
for( i = begin(); i != end(); ++i )
{
ASSERT( (*i)->m_ID != cGenre::GENRE_INVALID );
@ -251,7 +244,7 @@ cGenreInfoVec::const_iterator cGenreInfoVec::find( const cGenreInfo* pGI ) const
cGenreInfoVec::const_iterator cGenreInfoVec::find( const TSTRING& sGenre ) const
{
const_iterator i;
for( i = begin(); i != end(); i++ )
for( i = begin(); i != end(); ++i )
{
ASSERT( (*i)->m_ID != cGenre::GENRE_INVALID );

View File

@ -50,6 +50,7 @@ template<class TYPE>
class cIterProxy
{
public:
//TODO: Can these 2 constructors be made explicit?
cIterProxy(TYPE* pIter = NULL) : mpIter(pIter) {};
cIterProxy(const TYPE* pIter) : mpIter((TYPE*)pIter) {};
~cIterProxy() { if (mpIter) mpIter->DestroyIter(); }

View File

@ -550,14 +550,14 @@ TSTRING cMD5Signature::AsStringHex() const
TSTRING ret;
TCHAR stringBuffer[128];
TCHAR sigStringOut[128];
TCHAR sigStringOut[129];
sigStringOut[0] = '\0';
uint8 *dbuf = (uint8 *)md5_digest;
for(int i = 0; i < SIG_BYTE_SIZE; ++i)
{
_stprintf(stringBuffer, _T("%02lx"), (unsigned long)dbuf[i]);
_tcscat(sigStringOut, stringBuffer);
snprintf(stringBuffer, 128, _T("%02lx"), (unsigned long)dbuf[i]);
strncat(sigStringOut, stringBuffer, 128);
}
ret.append(sigStringOut);
@ -673,14 +673,14 @@ TSTRING cSHASignature::AsStringHex() const
TSTRING ret;
TCHAR stringBuffer[128];
TCHAR sigStringOut[128];
TCHAR sigStringOut[129];
sigStringOut[0] = '\0';
uint8 *dbuf = (uint8 *)sha_digest;
for (int i=0; i < SIG_UINT32_SIZE*(int)sizeof(uint32); ++i)
{
_stprintf(stringBuffer, _T("%02x"), dbuf[i]);
_tcscat(sigStringOut, stringBuffer);
snprintf(stringBuffer, 128, _T("%02x"), dbuf[i]);
strncat(sigStringOut, stringBuffer, 128);
}
ret.append(sigStringOut);
@ -749,13 +749,13 @@ TSTRING cSHASignature::AsStringHex() const
TSTRING ret;
TCHAR stringBuffer[128];
TCHAR sigStringOut[128];
TCHAR sigStringOut[129];
sigStringOut[0] = '\0';
for (int i=0; i < SIG_UINT32_SIZE; ++i)
{
_stprintf(stringBuffer, _T("%08x"), mSHAInfo.digest[i]);
_tcscat(sigStringOut, stringBuffer);
snprintf(stringBuffer, 128, _T("%08x"), mSHAInfo.digest[i]);
strncat(sigStringOut, stringBuffer, 128);
}
ret.append(sigStringOut);
@ -851,13 +851,13 @@ TSTRING cHAVALSignature::AsStringHex() const
TSTRING ret;
TCHAR stringBuffer[128];
TCHAR sigStringOut[128];
TCHAR sigStringOut[129];
sigStringOut[0] = _T('\0');
for (int i=0; i < SIG_BYTE_SIZE; ++i)
{
_stprintf(stringBuffer, _T("%02x"), mSignature[i]);
_tcscat(sigStringOut, stringBuffer);
snprintf(stringBuffer, 128, _T("%02x"), mSignature[i]);
strncat(sigStringOut, stringBuffer, 128);
}
ret.append(sigStringOut);

View File

@ -41,9 +41,6 @@
#include "core/error.h"
#include "core/errorutil.h"
//uncomment to allocate fsobjects from a pool
//cObjectPoolBase cFSObject::msAllocator(sizeof(cFSObject), 1000);
// FCO Type information...
IMPLEMENT_SERREFCOUNT(cFSObject, _T("FSObject"), 0, 1)

View File

@ -60,7 +60,7 @@ class cFSObject : public iFCO
DECLARE_SERREFCOUNT()
public:
cFSObject(const cFCOName& name);
explicit cFSObject(const cFCOName& name);
virtual void SetName(const cFCOName& name) ;
virtual const cFCOName& GetName() const ;

View File

@ -131,16 +131,27 @@ void cFSParserUtil::AddSubTypeProps( cFCOPropVector& v ) const
v.AddItemAndGrow( cFSPropSet::PROP_FILETYPE );
}
static inline void trim_leading_whitespace(std::string &str)
{
str.erase(str.begin(), std::find_if(str.begin(), str.end(), std::not1(std::ptr_fun<int, int>(std::isspace))));
}
void cFSParserUtil::InterpretFCOName( const std::list<TSTRING>& l, cFCOName& nameOut ) const
{
TSTRING strT;
for( std::list<TSTRING>::const_iterator i = l.begin(); i != l.end(); i++ )
for( std::list<TSTRING>::const_iterator i = l.begin(); i != l.end(); ++i )
strT += *i;
#if USES_DEVICE_PATH
strT = cDevicePath::AsPosix(strT);
#endif
//Trim any remaining whitespace before actual path, for cases like " /foo",
// otherwise it'll be flagged as a relative path.
//Don't trim trailing whitespace, since that could potentially be a valid path.
if(strT[0] != '/')
trim_leading_whitespace(strT);
// let cFCOName handle interpretation
nameOut = strT;
}

View File

@ -45,10 +45,7 @@
#include "fspropcalc.h"
#include "fsobject.h"
#if IS_UNIX
#include <unistd.h>
#endif
cFSPropCalc::cFSPropCalc() :
@ -93,11 +90,6 @@ static bool NeedsStat(const cFCOPropVector& v)
static bool GetSymLinkStr(const cFCOName& fileName, cArchive& arch)
{
#if !IS_WIN32
#ifdef _UNICODE
#error GetSymLinkStr in fspropcalc.cpp is not unicode compliant
#else // ifdef _UNICODE
char buf[1024];
#if defined(O_PATH)
int fd = open(iTWFactory::GetInstance()->GetNameTranslator()->ToStringAPI( fileName ).c_str(),
@ -116,11 +108,6 @@ static bool GetSymLinkStr(const cFCOName& fileName, cArchive& arch)
arch.WriteBlob(buf, rtn);
return true;
#endif // ifdef _UNICODE
#else // if !IS_WIN32
return false; // TODO: find better way to do this -- just a place holder
#endif // if !IS_WIN32
}

View File

@ -151,7 +151,7 @@ void cFSPropDisplayer::Merge( const iFCOPropDisplayer* const ppd )
// merge mapping info
for( INT64_TO_STRING_MAP::const_iterator iterUID = pfspd->uidToUsername.begin();
iterUID != pfspd->uidToUsername.end();
iterUID++
++iterUID
)
{
AddUsernameMapping( iterUID->first, iterUID->second );
@ -159,7 +159,7 @@ void cFSPropDisplayer::Merge( const iFCOPropDisplayer* const ppd )
for( INT64_TO_STRING_MAP::const_iterator iterGID = pfspd->gidToGroupname.begin();
iterGID != pfspd->gidToGroupname.end();
iterGID++
++iterGID
)
{
AddGroupnameMapping( iterGID->first, iterGID->second );
@ -401,7 +401,7 @@ void cFSPropDisplayer::Write( iSerializer* pSerializer ) const
{
// write UID mapping
pSerializer->WriteInt32( uidToUsername.size() );
for( INT64_TO_STRING_MAP::const_iterator iterUid = uidToUsername.begin(); iterUid != uidToUsername.end(); iterUid++ )
for( INT64_TO_STRING_MAP::const_iterator iterUid = uidToUsername.begin(); iterUid != uidToUsername.end(); ++iterUid )
{
pSerializer->WriteInt64( iterUid->first );
pSerializer->WriteString( iterUid->second );
@ -409,7 +409,7 @@ void cFSPropDisplayer::Write( iSerializer* pSerializer ) const
// write GID mapping
pSerializer->WriteInt32( gidToGroupname.size() );
for( INT64_TO_STRING_MAP::const_iterator iterGid = gidToGroupname.begin(); iterGid != gidToGroupname.end(); iterGid++ )
for( INT64_TO_STRING_MAP::const_iterator iterGid = gidToGroupname.begin(); iterGid != gidToGroupname.end(); ++iterGid )
{
pSerializer->WriteInt64( iterGid->first );
pSerializer->WriteString( iterGid->second );

View File

@ -2,16 +2,16 @@
# parser will echo YES1 through YES9
# there's a problem with the parser if it echoes NO
@@ifhost turd
@@ifhost foo
@@error NO1
@@else
@@echo +YES1;
@@print +YES1
@@endif
@@ifhost crap || your_host||poo
@@ifhost bar || your_host||baz
@@ifhost turd
@@ifhost foo
@@ifhost your_host
@@error +NO2;
@ -23,13 +23,13 @@
@@else
@@ifhost turd
@@ifhost foo
@@error +NO5;
@@else
@@echo +YES2;
@@print +YES2;
@@endif
@@echo +YES3;
@@print +YES3;
@@endif
@ -38,12 +38,12 @@
@@ifhost your_host
@@ifhost your_host
@@echo +YES4;
@@print +YES4;
@@else
@@error +NO6;
@@endif
@@echo +YES5;
@@print +YES5;
@@else
@ -58,34 +58,34 @@
@@endif
@@ifhost your_host
@@echo +YES6;
@@print +YES6;
@@else
@@error +NO10;
@@endif
@@ifhost turd
@@ifhost foo
@@error +NO11;
@@else
@@echo +YES7;
@@print +YES7;
@@endif
@@ifhost your_host || poo
@@echo +YES8;
@@ifhost your_host || baz
@@print +YES8;
@@endif
@@ifhost poo || your_host
@@echo +YES9;
@@ifhost baz || your_host
@@print +YES9;
@@endif
@@ifhost poo
@@ifhost baz
@@error +NO12;
@@endif
@@else
@@ifhost turd
@@ifhost foo
@@ifhost your_host
@@error +NO13;
@ -97,7 +97,7 @@
@@else
@@ifhost turd
@@ifhost foo
@@error +NO16;
@@else
@@error +NO17;
@ -107,7 +107,7 @@
@@endif
@@ifhost turd
@@ifhost foo
@@error +NO19;
@@else
@@error +NO20;
@ -120,16 +120,18 @@
@@endif
@@ifhost turd
@@ifhost foo
@@error +NO23;
@@else
@@error +NO24;
@@endif
@@ifhost poo
@@ifhost baz
@@error +NO25;
@@endif
@@endif
#A token rule at the end to avoid 'no rules in policy file' errors
/asdf -> +a;

View File

@ -14,34 +14,32 @@
/simple -> +ppp;
# variable
$(poo) = pinug;
/simplevar -> $(poo) ;
FOO = pinug;
/simplevar -> $(FOO) ;
$(turd) = /test6;
$(turd) -> $(poo);
BAR = /test6;
$(BAR) -> $(FOO);
# named attributes
/namedattr -> +pinug (name /namedattr ) ;
#/namedattr -> +pinug (name /namedattr ) ;
# multiple attributes
/namedattr2 -> +pinug (emailreport on, emailsendto genek, name /namedattr2, name4 val4, name5 val5 );
#/namedattr2 -> +pinug (emailreport on, emailsendto genek, name /namedattr2, name4 val4, name5 val5 );
# test line continuations
/turd \
/bar \
->\
+p
;
@@EnD
#@@EnD
/test -> +p;
"/te\x73t2" -> +p-p ;
"/te\163t3" -> +pinugs-am ;
"c:\\te\163t3\\" -> +pinugs-am ;
"c:\\te\"as\163t3\\" -> +pinugs-am ;
"/te\163t3" -> +pinugs-am ;
"/te\163t3" -> +pinugs-am ;
/test4 -> +pinugs---am ;
/test5 -> $(ReadOnly)s-+-am ;
/test7 -> +p;
"/te\x73t8" -> +p-p ;
"/te\163t9" -> +pinugs-am ;
"/te\163t12" -> +pinugs-am ;
"/te\163t13" -> +pinugs-am ;
/test14 -> +pinugs---am ;
/test15 -> $(ReadOnly)s-+-am ;
# test weird file names
/lost+found -> +p ;
@ -51,50 +49,51 @@ $(turd) -> $(poo);
;
# simple default policy
/simple -> +ppp;
/simple2 -> +ppp;
# variable
$(poo) = pinug;
/simplevar -> $(poo) ;
$(turd) = /test6;
$(turd) -> $(poo);
FOO = pinug;
/simplevar2 -> $(FOO) ;
BAR = /test16;
$(BAR) -> $(FOO);
# omit with space seperation
! /omit ;
# omit with no space separation
!/omit ;
!/omit2 ;
# named attributes
/namedattr -> +pinug (name1 value1) ;
#/namedattr -> +pinug (name1 value1) ;
# multiple attributes
/namedattr2 -> +pinug (emailreport on; emailsendto genek; name3 val3; name4 val4; name5 val5 ) ;
#/namedattr2 -> +pinug (emailreport on; emailsendto genek; name3 val3; name4 val4; name5 val5 ) ;
# test line continuations
/turd \
/bar2 \
->\
+p
;
@@END
#@@END
# the following isn't implemented yet
#########################################3
# attributes on specifers
/conditions {
xxx: +pinug (inside1 name1 ;) ;
yyy: +pinug ;
zzz: +pinug ;
default: +pinug ;
};
#/conditions2 {
# xxx: +pinug (inside1 name1 ;) ;
# yyy: +pinug ;
# zzz: +pinug ;
# default: +pinug ;
# };
# multiple specmasks
/conditions {
xxx: +pinug ;
yyy: +pinug ;
zzz: +pinug ;
default: +pinug ;
};
#/conditions3 {
# xxx: +pinug ;
# yyy: +pinug ;
# zzz: +pinug ;
# default: +pinug ;
# };
#

View File

@ -1 +1 @@
/etc jj ;
/etc -> $(IgnoreNone);

View File

@ -1,17 +1,16 @@
# test weird file names
/lost+found -> +p ;
/l-o_st+fo/und -> +ping (l-o_st+fo/und2 l-o_st+fo/und3) ;
/l-o_st+fo/und -> +ping;
# test variables
$(ReadOnly) = ping;
/simplevar -> $(ReadOnly) ;
/var -> $(ReadOnly)-p ;
FOO = ping;
/simplevar -> $(FOO) ;
/var -> $(FOO)-p ;
# test line continuations
c:/test -> +p ;
/turd \
/bar \
->\
+p
;
@ -20,25 +19,24 @@ c:/test -> +p ;
"/qfoo" -> +p ;
"/Program Files" -> +p ;
" /lots o' spaces " -> +p ;
" colon: semicolon; quote' " -> +p ;
#" colon: semicolon; quote' " -> +p ;
# test attributes
/namedattr2 -> +p ( name1 value1; name2 value2; ) ;
/namedattr -> +p (name1 value1; ) ;
#/namedattr2 -> +p ( name1 value1; name2 value2; ) ;
#/namedattr -> +p (name1 value1; ) ;
# test propvector
c:/test -> +p ;
/test -> +p ;
/test -> +p-p ;
/test -> +pinugs-am ;
/test -> +pinugs---am ;
/test -> +pinugs-+-am ;
/test1 -> +p ;
/test2 -> +p-p ;
/test3 -> +pinugs-am ;
/test4 -> +pinugs---am ;
/test5 -> +pinugs-+-am ;
# attributes and props
/namedattr3 -> +pinug ( name1 value1; name2 value2; ) ;
/namedattr4 -> +pinug (name1 value1; ) ;
#/namedattr3 -> +pinug ( name1 value1; name2 value2; ) ;
#/namedattr4 -> +pinug (name1 value1; ) ;
# simple default policy
/simple -> +ppp;
@ -48,38 +46,39 @@ c:/test -> +p ;
! /omit ;
# omit with no space separation
!/omit ;
!/omit2 ;
# multiple attributes
/namedattr -> +pinug (emailreport on; emailsendto genek; name3 val3; name4 val4; name5 val5; ) ;
#/namedattr -> +pinug (emailreport on; emailsendto genek; name3 val3; name4 val4; name5 val5; ) ;
@@END
#@@END
# the following isn't implemented yet
#########################################3
# multiple specmasks
/conditions -> {
xxx -> +pinug ;
yyy -> +pinug ;
zzz -> +pinug ;
default -> +pinug ;
};
#/conditions -> {
# xxx -> +pinug ;
# yyy -> +pinug ;
# zzz -> +pinug ;
# default -> +pinug ;
# };
# attributes on specifers
/conditions -> {
xxx -> +pinug (inside1 name1 ;) ;
yyy -> +pinug ;
zzz -> +pinug ;
default -> +pinug ;
};
#/conditions -> {
# xxx -> +pinug (inside1 name1 ;) ;
# yyy -> +pinug ;
# zzz -> +pinug ;
# default -> +pinug ;
# };
# hard ones
/conditions -> {
xxx -> +pinug (inside1 name1 ;) ;
yyy -> $(poo)+pinug ;
zzz -> +pinug ( inside1 name1 ; outside name2);
default -> $(turd)-p ;
};
#/conditions -> {
# xxx -> +pinug (inside1 name1 ;) ;
# yyy -> $(baz)+pinug ;
# zzz -> +pinug ( inside1 name1 ; outside name2);
# default -> $(bar)-p ;
# };

View File

@ -1,4 +1,4 @@
( emailreport on ; )
(emailto=root@localhost)
{
/foo -> +pinugs ;
}
}

View File

@ -46,8 +46,6 @@
#include <fstream> // for the FileExists() stuff
#if IS_UNIX
#include <unistd.h>
#include <fcntl.h>
#if SUPPORTS_TERMIOS
@ -56,7 +54,6 @@
#endif
//#include <signal.h>
int _getch(void);
#endif
using namespace std;
@ -282,7 +279,6 @@ int cSiggenCmdLine::Init(cCmdLineParser& parser)
case HELP:
{
return 0;
break;
}
case CRC32:
{
@ -373,11 +369,6 @@ void PrintHeader( TSTRING filename)
bool util_FileExists(const TSTRING& fileName)
{
#if IS_UNIX
// for unix we may be able to use the same logic as above, but
// it is too close to 2.2.1 release to make that change w/o testing.
// I know the above works for windows.
return _taccess(fileName.c_str(), F_OK) == 0;
#endif
}

View File

@ -55,10 +55,8 @@
#include <iostream>
#include <exception>
#if IS_UNIX
#include "core/unixfsservices.h"
#include <unistd.h>
#endif
///////////////////////////////////////////////////////////////////////////////
// terminate and unexpected handlers
@ -93,9 +91,7 @@ static void SiggenInit()
//
// set up the file system services
//
#if IS_UNIX
static cUnixFSServices fss;
#endif
iFSServices::SetInstance( &fss );
//

View File

@ -100,7 +100,7 @@ static void util_ProcessDir( cDbDataSourceIter dbIter, iFCODataSourceIter* pIter
{
dbIter.AddChildArray();
}
std::auto_ptr<iFCODataSourceIter> pCopy( pIter->CreateCopy() );
TW_UNIQUE_PTR<iFCODataSourceIter> pCopy( pIter->CreateCopy() );
util_ProcessDir( dbIter, pCopy.get(), pSpec, pPC, pPD );
//
// if no files were added, remove the child array...
@ -122,7 +122,7 @@ void cGenerateDb::Execute( const cFCOSpecList& specList, cHierDatabase& db, iFCO
{
// TODO -- assert the db is empty or clear it out myself!
std::auto_ptr<iFCODataSourceIter> pDSIter(iTWFactory::GetInstance()->CreateDataSourceIter());
TW_UNIQUE_PTR<iFCODataSourceIter> pDSIter(iTWFactory::GetInstance()->CreateDataSourceIter());
//
// set up the database's iterator...
@ -139,7 +139,7 @@ void cGenerateDb::Execute( const cFCOSpecList& specList, cHierDatabase& db, iFCO
//
// this is the object that will calculate all of the properties of the fcos.
//
std::auto_ptr<iFCOPropCalc> pPC(iTWFactory::GetInstance()->CreatePropCalc());
TW_UNIQUE_PTR<iFCOPropCalc> pPC(iTWFactory::GetInstance()->CreatePropCalc());
pPC->SetErrorBucket( pBucket );
if( flags & FLAG_ERASE_FOOTPRINTS_GD )
{
@ -193,7 +193,7 @@ void cGenerateDb::Execute( const cFCOSpecList& specList, cHierDatabase& db, iFCO
{
dbIter.AddChildArray();
}
std::auto_ptr<iFCODataSourceIter> pCopy( pDSIter->CreateCopy() );
TW_UNIQUE_PTR<iFCODataSourceIter> pCopy( pDSIter->CreateCopy() );
util_ProcessDir( dbIter, pCopy.get(), specIter.Spec(), pPC.get(), pPD );
//
// if no files were added, remove the child array...

View File

@ -78,7 +78,7 @@ void TestGenerateDb()
// ok, time to integrity check!
//
cGenreSpecListVector::iterator at;
for( at = slv.begin(); at != slv.end(); at++ )
for( at = slv.begin(); at != slv.end(); ++at )
{
cGenerateDb::Execute(
at->GetSpecList(),

View File

@ -90,7 +90,7 @@ void cIntegrityCheck::ProcessAddedFCO( cDbDataSourceIter dbIter, iFCODataSourceI
// to done...
//
while( ! dbIter.Done() ) dbIter.Next();
std::auto_ptr<iFCODataSourceIter> pCopy( pIter->CreateCopy() );
TW_UNIQUE_PTR<iFCODataSourceIter> pCopy( pIter->CreateCopy() );
ProcessDir( dbIter, pCopy.get() );
}
}
@ -231,7 +231,7 @@ void cIntegrityCheck::ProcessChangedFCO( cDbDataSourceIter dbIter, iFCODataSourc
{
if( pIter->CanDescend() || dbIter.CanDescend() )
{
std::auto_ptr<iFCODataSourceIter> pCopy( pIter->CreateCopy() );
TW_UNIQUE_PTR<iFCODataSourceIter> pCopy( pIter->CreateCopy() );
ProcessDir( dbIter, pCopy.get() );
}
}
@ -453,7 +453,7 @@ void cIntegrityCheck::Execute( uint32 flags )
mFlags = flags;
// create the data source iterator
//
std::auto_ptr<iFCODataSourceIter> pDSIter(iTWFactory::GetInstance()->CreateDataSourceIter());
TW_UNIQUE_PTR<iFCODataSourceIter> pDSIter(iTWFactory::GetInstance()->CreateDataSourceIter());
//
// set up the database's iterator...
// I assume the current genre is correct...
@ -560,7 +560,7 @@ void cIntegrityCheck::ExecuteOnObjectList( const std::list<cFCOName>& fcoNames,
//
// create the data source iterator
//
std::auto_ptr<iFCODataSourceIter> pDSIter(iTWFactory::GetInstance()->CreateDataSourceIter());
TW_UNIQUE_PTR<iFCODataSourceIter> pDSIter(iTWFactory::GetInstance()->CreateDataSourceIter());
//
// set up the database's iterator...
// I assume the current genre is correct...
@ -593,7 +593,7 @@ void cIntegrityCheck::ExecuteOnObjectList( const std::list<cFCOName>& fcoNames,
// iterate over all the objects to integrity check..
//
std::list<cFCOName>::const_iterator it;
for( it = fcoNames.begin(); it != fcoNames.end(); it++ )
for( it = fcoNames.begin(); it != fcoNames.end(); ++it )
{
TW_NOTIFY_VERBOSE( _T("%s%s\n"),
TSS_GetString( cTripwire, tripwire::STR_NOTIFY_CHECKING ).c_str(),

View File

@ -80,7 +80,7 @@ void TestIntegrityCheck()
// ok, time to integrity check!
//
cGenreSpecListVector::iterator at;
for( at = slv.begin(); at != slv.end(); at++ )
for( at = slv.begin(); at != slv.end(); ++at )
{
cIntegrityCheck ic( at->GetGenre(), at->GetSpecList(), db, report, &et );
ic.Execute();

View File

@ -130,7 +130,7 @@ bool cMailMessage::GetAttachmentsAsString( std::string& s )
bool allOK = true;
for( std::vector<TSTRING>::const_iterator at = mvstrAttachments.begin();
at != mvstrAttachments.end();
at++ )
++at )
{
s += "\r\n";
@ -231,10 +231,8 @@ bool cMailMessageUtil::ReadDate( TSTRING& strDateBuf )
#if HAVE_STRFTIME
TCHAR szDate[1024];
struct tm *tm = NULL;
time_t current_time = time(NULL);
tm = localtime ( &current_time );
struct tm* tm = localtime ( &current_time );
const TCHAR* szFormat = _T("%a, %d %b %Y %H:%M:%S %z");
@ -349,7 +347,7 @@ cQuotedPrintableEncoding::Encode( const std::string& sIn,
std::string::size_type lineLen = 0;
for( at = sIn.begin();
at != sIn.end();
at++, lineLen += _ENCODED_CHAR_LEN )
++at, lineLen += _ENCODED_CHAR_LEN )
{
if( NeedsEncoding( *at ) )
{
@ -481,7 +479,7 @@ cMailMessageUtil::HasNonAsciiChars( const std::string& s )
{
for( std::string::const_iterator at = s.begin();
at != s.end();
at ++ )
++at )
{
if( (unsigned char)*at > (unsigned char)0x7F )
return true;

View File

@ -36,13 +36,10 @@
#include "core/error.h"
#endif
#if IS_UNIX
# if HAVE_SYS_SOCKET_H
# include <sys/socket.h>
# endif
# define SOCKET int
#if HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#define SOCKET int
///////////////////////////////////////////////////////////////////////////////
@ -250,8 +247,6 @@ private:
};
//#ifdef IS_UNIX
///////////////////////////////////////////////////////////////////////////////
//
// This class implements sending a message through a unix pipe to a program
@ -260,7 +255,7 @@ private:
class cPipedMailMessage : public cMailMessage
{
public:
cPipedMailMessage(TSTRING strSendMailExePath);
explicit cPipedMailMessage(const TSTRING& strSendMailExePath);
virtual ~cPipedMailMessage();
virtual bool Send(); //throw(eMailMessageError)

View File

@ -49,7 +49,7 @@
//
// Constructor. Not much to do beside initialize the handle to the DLL
//
cPipedMailMessage::cPipedMailMessage(TSTRING strSendMailExePath)
cPipedMailMessage::cPipedMailMessage(const TSTRING& strSendMailExePath)
{
mstrSendMailExePath = strSendMailExePath;
mpFile = NULL;

View File

@ -40,8 +40,6 @@
#include "core/msystem.h"
#include "core/file.h"
#if IS_UNIX
#include <time.h>
//All the spleck that it takes to run sockets in Unix...
@ -92,7 +90,7 @@ static int gethostname( char* name, int namelen )
if ( strlen( myname.nodename ) < (unsigned int)namelen )
{
strcpy( name, myname.nodename );
strncpy( name, myname.nodename, namelen );
return 0;
}
else
@ -106,24 +104,24 @@ static int gethostname( char* name, int namelen )
#endif
}
#endif
// Unix does not require us to go though any silly DLL hoops, so we'll
// just #define the pointers to functions needed by Windows to be the
// berkely functions.
#define mPfnSocket socket
#define mPfnInetAddr inet_addr
#define mPfnGethostname gethostname
#define mPfnGethostbyname gethostbyname
#define mPfnConnect connect
#define mPfnCloseSocket close
#define mPfnSend send
#define mPfnRecv recv
#define mPfnSelect select
#define mPfnNtohl ntohl
#define mPfnHtonl htonl
#define mPfnNtohs ntohs
#define mPfnHtons htons
#endif
#endif //HAVE_GETHOSTNAME
// Unix does not require us to go though any silly DLL hoops, so we'll
// just #define the pointers to functions needed by Windows to be the
// berkely functions.
#define mPfnSocket socket
#define mPfnInetAddr inet_addr
#define mPfnGethostname gethostname
#define mPfnGethostbyname gethostbyname
#define mPfnConnect connect
#define mPfnCloseSocket close
#define mPfnSend send
#define mPfnRecv recv
#define mPfnSelect select
#define mPfnNtohl ntohl
#define mPfnHtonl htonl
#define mPfnNtohs ntohs
#define mPfnHtons htons
//
// TODO - maybe convert this SMTP code to non-blocking socket calls, or use
@ -215,9 +213,8 @@ bool cSMTPMailMessage::OpenConnection()
sockAddrIn.sin_port = mPfnHtons(mPortNumber);
uint32 iServerAddress = GetServerAddress();
#if IS_UNIX
sockAddrIn.sin_addr.s_addr = iServerAddress;
#endif
if ( iServerAddress == INADDR_NONE )
{
DecodeError();
@ -494,14 +491,8 @@ bool cSMTPMailMessage::GetAcknowledgement()
// need comment
timeval tv;
#if IS_UNIX
FD_ZERO( &socketSet );
FD_SET( mSocket, &socketSet );
#else
socketSet.fd_count = 1;
socketSet.fd_array[0] = mSocket;
#endif
// set the timeout time to sixty seconds
tv.tv_sec = 60;
@ -567,15 +558,9 @@ void cSMTPMailMessage::SendString( const std::string& str )
void cSMTPMailMessage::DecodeError()
{
#if defined(_DEBUG)
#if IS_UNIX
//
// TODO - Write what ever error reporting will be needed under unix.
//
#endif // IS_UNIX
#endif // defined(_DEBUG)
}

View File

@ -44,7 +44,7 @@
#include "core/errorbucketimpl.h"
#include "core/usernotifystdout.h"
#include "core/timebomb.h"
#include <memory> // for auto_ptr
#include <memory> // for auto_ptr / unique_ptr
#include <iostream>
#include <exception>
@ -55,12 +55,8 @@
#include "fco/fcogenre.h"
#include "fco/genreswitcher.h"
#if IS_UNIX
#include "core/unixfsservices.h"
#include <unistd.h>
#else
#error Who the hell am I?
#endif
static TSTRING util_GetWholeCmdLine( int argc, const TCHAR *argv[] );
@ -137,7 +133,7 @@ int __cdecl _tmain( int argc, const TCHAR* argv[ ], const TCHAR* envp[ ] )
// first, get the right mode...
std::auto_ptr<iTWMode> pMode(cTWCmdLine::GetMode(argc, argv));
TW_UNIQUE_PTR<iTWMode> pMode(cTWCmdLine::GetMode(argc, argv));
if(! pMode.get())
{
// no valid mode passed; GetMode will display an appropriate string (include usage statement)
@ -171,13 +167,11 @@ int __cdecl _tmain( int argc, const TCHAR* argv[ ], const TCHAR* envp[ ] )
TSTRING commandLine = util_GetWholeCmdLine( argc, argv );
#if IS_UNIX
// erase the command line
// TODO: it might be a good idea to move this to cTWUtil
int i;
for (i = 1; i < argc; ++i)
memset((char*)argv[i], 0, strlen(argv[i])*sizeof(TCHAR));
#endif
cCmdLineIter iter(cmdLine);
if (iter.SeekToArg(cTWCmdLine::HELP))
@ -243,7 +237,7 @@ int __cdecl _tmain( int argc, const TCHAR* argv[ ], const TCHAR* envp[ ] )
ret = 8;
}
catch (std::bad_alloc e)
catch (std::bad_alloc& e)
{
// Note: We use fputs rather than TCERR as it will probably require the
// least amount of memory to do its thing. If we ran out of memory we
@ -253,7 +247,7 @@ int __cdecl _tmain( int argc, const TCHAR* argv[ ], const TCHAR* envp[ ] )
ret = 8;
}
catch (std::exception e)
catch (std::exception& e)
{
TCERR << _T("*** Fatal exception: ");
std::cerr << e.what() << std::endl;

View File

@ -78,11 +78,8 @@
#include "tasktimer.h"
#endif
#if IS_UNIX
#include "fs/fsdatasourceiter.h" // for cross file systems flag
#include <unistd.h> // for _exit()
#endif
//-----------------------------------------------------------------------------
// #defines
@ -277,15 +274,10 @@ static void FillOutConfigInfo(cTWModeCommon* pModeInfo, const cConfigFile& cf)
}
if(cf.Lookup(TSTRING(_T("RESETACCESSTIME")), str))
{
#if IS_UNIX
// We do not support reset access time on Unix, so we issue a warning.
// This used to be a fatal error, however this prevents
// cross platform config files.
cTWUtil::PrintErrorMsg(eTWInvalidConfigFileKey(_T("RESETACCESSTIME"), eError::NON_FATAL));
#endif
}
if(cf.Lookup(TSTRING(_T("LOOSEDIRECTORYCHECKING")), str))
{
@ -649,12 +641,9 @@ bool cTWModeDbInit::Init(const cConfigFile& cf, const cCmdLineParser& cmdLine)
if (cTWUtil::VerifyCfgSiteKey( mstrConfigFile, mpData->mSiteKeyFile ) == false)
cTWUtil::PrintErrorMsg(eTWCfgUnencrypted(_T(""), eError::NON_FATAL|eError::SUPRESS_THIRD_MSG));
#if IS_UNIX
// Set the cross file systems flag appropriately.
cFSDataSourceIter::SetFileSystemCrossing(mpData->mbCrossFileSystems);
#endif
return true;
return true;
}
///////////////////////////////////////////////////////////////////////////////
@ -1021,13 +1010,10 @@ bool cTWModeIC::Init(const cConfigFile& cf, const cCmdLineParser& cmdLine)
//
if (cTWUtil::VerifyCfgSiteKey( mstrConfigFile, mpData->mSiteKeyFile ) == false)
cTWUtil::PrintErrorMsg(eTWCfgUnencrypted(_T(""), eError::NON_FATAL|eError::SUPRESS_THIRD_MSG));
#if IS_UNIX
// Set the cross file systems flag appropriately.
cFSDataSourceIter::SetFileSystemCrossing(mpData->mbCrossFileSystems);
#endif
return true;
return true;
}
@ -1137,18 +1123,18 @@ int cTWModeIC::Execute(cErrorQueue* pQueue)
//
// now, we will iterate over the list, performing an integrity check for each genre
//
for( cTWUtil::GenreObjList::iterator genreIter = listOut.begin(); genreIter != listOut.end(); genreIter++ )
for( cTWUtil::GenreObjList::iterator genreIter = listOut.begin(); genreIter != listOut.end(); ++genreIter )
{
dbIter.SeekToGenre( genreIter->first );
if( ! dbIter.Done() )
{
cGenreSwitcher::GetInstance()->SelectGenre( (cGenre::Genre)dbIter.GetGenre() );
std::auto_ptr<iParserGenreUtil> pParseUtil (iTWFactory::GetInstance()->CreateParserGenreUtil());
TW_UNIQUE_PTR<iParserGenreUtil> pParseUtil (iTWFactory::GetInstance()->CreateParserGenreUtil());
//
// I have to turn this into a list of cFCONames
//
std::list<cFCOName> fcoNames;
for(cTWUtil::ObjList::iterator it = genreIter->second.begin(); it != genreIter->second.end(); it++)
for(cTWUtil::ObjList::iterator it = genreIter->second.begin(); it != genreIter->second.end(); ++it)
{
// if this is not an absolute path, warn and continue...
//
@ -1476,7 +1462,7 @@ public:
cFCOReportHeader* mpReportHeader;
// ctor can set up some default values
cTWModeDbUpdate_i() : cTWModeCommon(), mbInteractive(true), mbSecureMode(true), /*mSiteProvided(false),*/ mpReport(0), mpDbFile(0), mpReportHeader(0) {}
cTWModeDbUpdate_i() : cTWModeCommon(), mbInteractive(true), mbSecureMode(true), mbEncryptDb(true), /*mSiteProvided(false),*/ mpReport(0), mpDbFile(0), mpReportHeader(0) {}
};
///////////////////////////////////////////////////////////////////////////////
@ -1586,12 +1572,9 @@ bool cTWModeDbUpdate::Init(const cConfigFile& cf, const cCmdLineParser& cmdLine)
if (cTWUtil::VerifyCfgSiteKey( mstrConfigFile, mpData->mSiteKeyFile ) == false)
cTWUtil::PrintErrorMsg(eTWCfgUnencrypted(_T(""), eError::NON_FATAL|eError::SUPRESS_THIRD_MSG));
#if IS_UNIX
// Set the cross file systems flag appropriately.
cFSDataSourceIter::SetFileSystemCrossing(mpData->mbCrossFileSystems);
#endif
return true;
return true;
}
void cTWModeDbUpdate::Init(const cTWModeIC_i* pICData, cFCODatabaseFile* dbFile, cFCOReportHeader* prh, cFCOReport* pReport, bool bEncryptDb)
@ -1958,12 +1941,9 @@ bool cTWModePolUpdate::Init(const cConfigFile& cf, const cCmdLineParser& cmdLine
if (cTWUtil::VerifyCfgSiteKey( mstrConfigFile, mpData->mSiteKeyFile ) == false)
cTWUtil::PrintErrorMsg(eTWCfgUnencrypted(_T(""), eError::NON_FATAL|eError::SUPRESS_THIRD_MSG));
#if IS_UNIX
// Set the cross file systems flag appropriately.
cFSDataSourceIter::SetFileSystemCrossing(mpData->mbCrossFileSystems);
#endif
return true;
return true;
}
///////////////////////////////////////////////////////////////////////////////

View File

@ -182,14 +182,17 @@ class cTWModeCommon
bool mMailNoViolations; // Email out reports with no violations?
TSTRING mMailFrom;
cTWModeCommon() : mVerbosity(1),
cTWModeCommon() : mVerbosity(1),
mLocalProvided(false),
mbLatePassphrase(false),
mfLooseDirs(false),
mbResetAccessTime(false),
mbLogToSyslog(false),
mbCrossFileSystems(false),
mbDirectIO(false)
mbDirectIO(false),
mMailMethod(cMailMessage::NO_METHOD),
mSmtpPort(25),
mMailNoViolations(true)
{
}
};

View File

@ -531,7 +531,7 @@ static bool EmailReportTo(const TSTRING &toAddress, const cFCOReportHeader& head
const cTWModeCommon *modeCommon,
const bool bForceFullReport)
{
std::auto_ptr<cMailMessage> reportMail;
TW_UNIQUE_PTR<cMailMessage> reportMail;
// allocate the right kind of emailer object based on what came out of the config file.
switch (modeCommon->mMailMethod)
@ -540,10 +540,10 @@ static bool EmailReportTo(const TSTRING &toAddress, const cFCOReportHeader& head
ASSERT(false);
return false;
case cMailMessage::MAIL_BY_SMTP:
reportMail = std::auto_ptr<cMailMessage>(new cSMTPMailMessage(modeCommon->mSmtpHost, modeCommon->mSmtpPort));
reportMail = TW_UNIQUE_PTR<cMailMessage>(new cSMTPMailMessage(modeCommon->mSmtpHost, modeCommon->mSmtpPort));
break;
case cMailMessage::MAIL_BY_PIPE:
reportMail = std::auto_ptr<cMailMessage>(new cPipedMailMessage(modeCommon->mMailProgram));
reportMail = TW_UNIQUE_PTR<cMailMessage>(new cPipedMailMessage(modeCommon->mMailProgram));
break;
}
@ -685,7 +685,7 @@ bool cTWCmdLineUtil::EmailReport(const cFCOReportHeader& header, const cFCORepor
bool cTWCmdLineUtil::SendEmailTestMessage(const TSTRING &mAddress, const cTWModeCommon *modeCommon)
{
std::auto_ptr<cMailMessage> reportMail;
TW_UNIQUE_PTR<cMailMessage> reportMail;
// allocate the right kind of emailer object based on what came out of the config file.
switch (modeCommon->mMailMethod)
@ -694,10 +694,10 @@ bool cTWCmdLineUtil::SendEmailTestMessage(const TSTRING &mAddress, const cTWMode
ASSERT(false);
return false;
case cMailMessage::MAIL_BY_SMTP:
reportMail = std::auto_ptr<cMailMessage>(new cSMTPMailMessage(modeCommon->mSmtpHost, modeCommon->mSmtpPort));
reportMail = TW_UNIQUE_PTR<cMailMessage>(new cSMTPMailMessage(modeCommon->mSmtpHost, modeCommon->mSmtpPort));
break;
case cMailMessage::MAIL_BY_PIPE:
reportMail = std::auto_ptr<cMailMessage>(new cPipedMailMessage(modeCommon->mMailProgram));
reportMail = TW_UNIQUE_PTR<cMailMessage>(new cPipedMailMessage(modeCommon->mMailProgram));
break;
}

View File

@ -293,6 +293,11 @@ bool cConfigFile::Lookup( const TSTRING& sKey, TSTRING& sVal ) const
return( fFound );
}
void cConfigFile::Insert( const TSTRING& sKey, const TSTRING& sVal )
{
mStringHashTable.Insert(sKey, sVal);
}
///////////////////////////////////////////////////////////////////////////////
// GetFileHeaderID()
///////////////////////////////////////////////////////////////////////////////

View File

@ -107,6 +107,10 @@ public:
bool Lookup( const TSTRING& tstrKey, TSTRING& tstrVal ) const;
// returns true if key is found in internal container and returns its value in tstrVal.
void Insert( const TSTRING& tstrKey, const TSTRING& tstrVal );
// add key+value to config data. visible for unit testing.
void WriteString( TSTRING& configText );
// writes all key/value pairs from internal container to filename as "name=value\n"
void ReadString( const TSTRING configText ); // throw( eConfigFile );
@ -140,7 +144,7 @@ private:
class cConfigFileIter
{
public:
cConfigFileIter( cConfigFile& cf);
explicit cConfigFileIter( cConfigFile& cf);
virtual ~cConfigFileIter();
void SeekBegin() const;

View File

@ -98,7 +98,7 @@ public:
// Ctor, Dtor:
~cDebugHierDbIter () {}
cDebugHierDbIter ( cHierDatabase* pDb ) : cHierDatabaseIter( pDb ) {}
explicit cDebugHierDbIter ( cHierDatabase* pDb ) : cHierDatabaseIter( pDb ) {}
//
// Methods for obtaining protected members of cHierDatabaseIter:

View File

@ -179,7 +179,7 @@ static void SplitString( const TSTRING& str, TCHAR c, std::vector<TSTRING>& vStr
vStrings.clear();
TSTRING::const_iterator i, prev;
for( prev = i = str.begin(); i != str.end(); i++ )
for( prev = i = str.begin(); i != str.end(); ++i )
{
if( *i == c )
{
@ -284,7 +284,7 @@ void cDbExplore::Execute( cFCODatabaseFileIter& dbIter )
GetNoun(noun);
std::vector<TSTRING> vDirs;
SplitString( noun, pIter->GetParentName().GetDelimiter(), vDirs );
for( std::vector<TSTRING>::iterator i = vDirs.begin(); i != vDirs.end(); i++ )
for( std::vector<TSTRING>::iterator i = vDirs.begin(); i != vDirs.end(); ++i )
{
if( i->compare( _T("..") ) == 0 )

View File

@ -72,7 +72,7 @@ cFCODatabaseFile::cFCODatabaseFile()
cFCODatabaseFile::~cFCODatabaseFile()
{
for( DbList::iterator i = mDbList.begin(); i != mDbList.end(); i++ )
for( DbList::iterator i = mDbList.begin(); i != mDbList.end(); ++i )
{
delete *i;
}
@ -152,7 +152,7 @@ void cFCODatabaseFile::Write(iSerializer* pSerializer) const //throw( eFCODbFile
//
// TODO -- the database is not really const-correct; therefore I have the sick casts below...
//
for( DbList::iterator i = const_cast<DbList*>(&mDbList)->begin(); i != const_cast<DbList*>(&mDbList)->end(); i++ )
for( DbList::iterator i = const_cast<DbList*>(&mDbList)->begin(); i != const_cast<DbList*>(&mDbList)->end(); ++i )
{
pSerializer->WriteInt32 ( (*i)->mGenre );
pSerializer->WriteObject ( &(*i)->mGenreHeader );
@ -193,7 +193,7 @@ void cFCODatabaseFile::AddGenre( cGenre::Genre genreId, cFCODatabaseFileIter* pI
//
// first, lets make sure this genre doesn't exist...
//
for( DbList::iterator i = mDbList.begin(); i != mDbList.end(); i++ )
for( DbList::iterator i = mDbList.begin(); i != mDbList.end(); ++i )
{
if( (*i)->mGenre == genreId )
{
@ -254,7 +254,7 @@ void cFCODatabaseFileIter::SeekBegin()
void cFCODatabaseFileIter::Next()
{
mIter++;
++mIter;
}
bool cFCODatabaseFileIter::Done() const

View File

@ -112,7 +112,7 @@ public:
//-------------------------------------------------------------------------
struct tEntry
{
tEntry( cGenre::Genre genre );
explicit tEntry( cGenre::Genre genre );
// the ctor will get the appropriate database construction parameters
// based on the genre number.
~tEntry( )
@ -146,7 +146,7 @@ private:
class cFCODatabaseFileIter
{
public:
cFCODatabaseFileIter( cFCODatabaseFile& dbFile );
explicit cFCODatabaseFileIter( cFCODatabaseFile& dbFile );
void SeekBegin();
void Next();

View File

@ -239,10 +239,12 @@ cFCOReportGenreIter::~cFCOReportGenreIter()
delete mpData;
}
void cFCOReportGenreIter::operator=(const cFCOReportGenreIter& rhs)
cFCOReportGenreIter& cFCOReportGenreIter::operator=(const cFCOReportGenreIter& rhs)
{
mpData->mpList = rhs.mpData->mpList;
mpData->mIter = rhs.mpData->mIter;
return *this;
}
// iteration methods
@ -380,13 +382,15 @@ cFCOReportSpecIter::cFCOReportSpecIter(const cFCOReportSpecIter& rhs)
*this = rhs;
}
void cFCOReportSpecIter::operator=(const cFCOReportSpecIter& rhs)
cFCOReportSpecIter& cFCOReportSpecIter::operator=(const cFCOReportSpecIter& rhs)
{
if (mpData == 0)
mpData = new cFCOReportSpecIter_i();
mpData->mpList = rhs.mpData->mpList;
mpData->mIter = rhs.mpData->mIter;
return *this;
}
int cFCOReportSpecIter::GetNumChanged() const
@ -429,7 +433,7 @@ void cFCOReportSpecIter::SeekBegin() const
void cFCOReportSpecIter::Next() const
{
ASSERT(mpData != 0);
mpData->mIter++;
++(mpData->mIter);
}
bool cFCOReportSpecIter::Done() const
@ -446,7 +450,7 @@ const iFCOSpec* cFCOReportSpecIter::GetSpec() const
bool cFCOReportSpecIter::SeekToSpec(const iFCOSpec* pSpec)
{
if (mpData)
for(mpData->mIter = mpData->mpList->begin(); mpData->mIter != mpData->mpList->end(); mpData->mIter++)
for(mpData->mIter = mpData->mpList->begin(); mpData->mIter != mpData->mpList->end(); ++(mpData->mIter))
{
if(iFCOSpecUtil::FCOSpecEqual(*mpData->mIter->mpSpec, *pSpec))
return true;
@ -525,10 +529,12 @@ cFCOReportChangeIter::~cFCOReportChangeIter()
delete mpData;
}
void cFCOReportChangeIter::operator=(const cFCOReportChangeIter& rhs)
cFCOReportChangeIter& cFCOReportChangeIter::operator=(const cFCOReportChangeIter& rhs)
{
mpData->mpList = rhs.mpData->mpList;
mpData->mIter = rhs.mpData->mIter;
return *this;
}
void cFCOReportChangeIter::SetSpecIter(const cFCOReportSpecIter& specIter)
@ -557,7 +563,7 @@ void cFCOReportChangeIter::SeekBegin() const
void cFCOReportChangeIter::Next() const
{
ASSERT(mpData->mpList != 0);
mpData->mIter++;
++(mpData->mIter);
}
bool cFCOReportChangeIter::Done() const
@ -701,7 +707,7 @@ void cFCOReport::AddSpec(cGenre::Genre genre, const iFCOSpec* pSpec, const cFCOS
if (pIter && pIter->mpData && pIter->mpData->mpList == &genreIter->mSpecList)
{
pIter->mpData->mIter = genreIter->mSpecList.end();
pIter->mpData->mIter--;
--(pIter->mpData->mIter);
ASSERT(pIter->GetSpec() == node.mpSpec);
}
}

View File

@ -147,7 +147,7 @@ public:
cFCOReportGenreIter(const cFCOReportGenreIter& rhs);
~cFCOReportGenreIter();
void operator=(const cFCOReportGenreIter& rhs);
cFCOReportGenreIter& operator=(const cFCOReportGenreIter& rhs);
// iteration methods
void SeekBegin() const;
@ -179,13 +179,13 @@ public:
cFCOReportSpecIter(cFCOReport& report, cGenre::Genre genre);
// if genre does not exist in the report, it will be added to the report with
// and empty spec list.
cFCOReportSpecIter(const cFCOReportGenreIter& genreIter);
explicit cFCOReportSpecIter(const cFCOReportGenreIter& genreIter);
// thorws eInternal if genreIter is not at a valid genre or is Done()
cFCOReportSpecIter(const cFCOReportSpecIter& rhs);
~cFCOReportSpecIter();
void operator=(const cFCOReportSpecIter& rhs);
cFCOReportSpecIter& operator=(const cFCOReportSpecIter& rhs);
// iteration methods
void SeekBegin() const;
@ -226,11 +226,11 @@ private:
class cFCOReportChangeIter
{
public:
cFCOReportChangeIter(const cFCOReportSpecIter& specIter);
explicit cFCOReportChangeIter(const cFCOReportSpecIter& specIter);
cFCOReportChangeIter(const cFCOReportChangeIter& rhs);
~cFCOReportChangeIter();
void operator=(const cFCOReportChangeIter& rhs);
cFCOReportChangeIter& operator=(const cFCOReportChangeIter& rhs);
void SetSpecIter(const cFCOReportSpecIter& specIter);
// assocaite this iterator with a different spec. We will assert
// that specIter.Done() is not true.

View File

@ -61,7 +61,8 @@ cFileManipulator::cFileManipulator(const TCHAR* filename)
}
cFileManipulator::cFileManipulator(const cFileManipulator& rhs)
: mFileName(rhs.mFileName),
: mbInit(false),
mFileName(rhs.mFileName),
mFileHeader(rhs.mFileHeader)
{
}

View File

@ -91,7 +91,7 @@ TSS_FILE_EXCEPTION( eFileManipUnrecognizedFileType, eFileManip )
class cFileManipulator
{
public:
cFileManipulator(const TCHAR* filename);
explicit cFileManipulator(const TCHAR* filename);
// throws eArchive if file does not exist
cFileManipulator(const cFileManipulator& rhs);
~cFileManipulator();

Some files were not shown because too many files have changed in this diff Show More