Merge pull request #29 from Tripwire/dev/q1-2018
Open Source Tripwire 2.4.3.7
This commit is contained in:
commit
6e64a9e5b7
|
@ -0,0 +1,115 @@
|
||||||
|
---
|
||||||
|
Language: Cpp
|
||||||
|
|
||||||
|
AccessModifierOffset: -4
|
||||||
|
AlignAfterOpenBracket: Align
|
||||||
|
AlignConsecutiveAssignments: true
|
||||||
|
AlignConsecutiveDeclarations: true
|
||||||
|
AlignEscapedNewlines: Left
|
||||||
|
AlignOperands: true
|
||||||
|
AlignTrailingComments: true
|
||||||
|
AllowAllParametersOfDeclarationOnNextLine: true
|
||||||
|
AllowShortBlocksOnASingleLine: false
|
||||||
|
AllowShortCaseLabelsOnASingleLine: false
|
||||||
|
AllowShortFunctionsOnASingleLine: None
|
||||||
|
AllowShortIfStatementsOnASingleLine: false
|
||||||
|
AllowShortLoopsOnASingleLine: false
|
||||||
|
AlwaysBreakAfterDefinitionReturnType: None
|
||||||
|
AlwaysBreakAfterReturnType: None
|
||||||
|
AlwaysBreakBeforeMultilineStrings: false
|
||||||
|
AlwaysBreakTemplateDeclarations: false
|
||||||
|
BinPackArguments: false
|
||||||
|
BinPackParameters: false
|
||||||
|
BraceWrapping:
|
||||||
|
AfterClass: true
|
||||||
|
AfterControlStatement: true
|
||||||
|
AfterEnum: true
|
||||||
|
AfterFunction: true
|
||||||
|
AfterNamespace: true
|
||||||
|
AfterObjCDeclaration: true
|
||||||
|
AfterStruct: true
|
||||||
|
AfterUnion: true
|
||||||
|
AfterExternBlock: true
|
||||||
|
BeforeCatch: true
|
||||||
|
BeforeElse: true
|
||||||
|
IndentBraces: false
|
||||||
|
SplitEmptyFunction: true
|
||||||
|
SplitEmptyRecord: true
|
||||||
|
SplitEmptyNamespace: true
|
||||||
|
BreakBeforeBinaryOperators: None
|
||||||
|
BreakBeforeBraces: Custom
|
||||||
|
BreakBeforeInheritanceComma: false
|
||||||
|
BreakBeforeTernaryOperators: false
|
||||||
|
BreakConstructorInitializersBeforeComma: false
|
||||||
|
BreakConstructorInitializers: BeforeColon
|
||||||
|
BreakAfterJavaFieldAnnotations: false
|
||||||
|
BreakStringLiterals: true
|
||||||
|
ColumnLimit: 120
|
||||||
|
CommentPragmas: '^ IWYU pragma:'
|
||||||
|
CompactNamespaces: false
|
||||||
|
ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
||||||
|
ConstructorInitializerIndentWidth: 4
|
||||||
|
ContinuationIndentWidth: 4
|
||||||
|
Cpp11BracedListStyle: true
|
||||||
|
DerivePointerAlignment: false
|
||||||
|
DisableFormat: false
|
||||||
|
ExperimentalAutoDetectBinPacking: false
|
||||||
|
FixNamespaceComments: true
|
||||||
|
ForEachMacros:
|
||||||
|
- foreach
|
||||||
|
- Q_FOREACH
|
||||||
|
- BOOST_FOREACH
|
||||||
|
IncludeBlocks: Preserve
|
||||||
|
IncludeCategories:
|
||||||
|
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
|
||||||
|
Priority: 2
|
||||||
|
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
|
||||||
|
Priority: 3
|
||||||
|
- Regex: '.*'
|
||||||
|
Priority: 1
|
||||||
|
IncludeIsMainRegex: '(Test)?$'
|
||||||
|
IndentCaseLabels: false
|
||||||
|
IndentPPDirectives: AfterHash
|
||||||
|
IndentWidth: 4
|
||||||
|
IndentWrappedFunctionNames: false
|
||||||
|
JavaScriptQuotes: Leave
|
||||||
|
JavaScriptWrapImports: true
|
||||||
|
KeepEmptyLinesAtTheStartOfBlocks: true
|
||||||
|
MacroBlockBegin: ''
|
||||||
|
MacroBlockEnd: ''
|
||||||
|
MaxEmptyLinesToKeep: 2
|
||||||
|
NamespaceIndentation: None
|
||||||
|
ObjCBlockIndentWidth: 2
|
||||||
|
ObjCSpaceAfterProperty: false
|
||||||
|
ObjCSpaceBeforeProtocolList: true
|
||||||
|
PenaltyBreakAssignment: 2
|
||||||
|
PenaltyBreakBeforeFirstCallParameter: 19
|
||||||
|
PenaltyBreakComment: 300
|
||||||
|
PenaltyBreakFirstLessLess: 120
|
||||||
|
PenaltyBreakString: 1000
|
||||||
|
PenaltyExcessCharacter: 1000000
|
||||||
|
PenaltyReturnTypeOnItsOwnLine: 60
|
||||||
|
PointerAlignment: Left
|
||||||
|
RawStringFormats:
|
||||||
|
- Delimiter: pb
|
||||||
|
Language: TextProto
|
||||||
|
BasedOnStyle: google
|
||||||
|
ReflowComments: false
|
||||||
|
SortIncludes: false
|
||||||
|
SortUsingDeclarations: true
|
||||||
|
SpaceAfterCStyleCast: false
|
||||||
|
SpaceAfterTemplateKeyword: false
|
||||||
|
SpaceBeforeAssignmentOperators: true
|
||||||
|
SpaceBeforeParens: ControlStatements
|
||||||
|
SpaceInEmptyParentheses: false
|
||||||
|
SpacesBeforeTrailingComments: 1
|
||||||
|
SpacesInAngles: false
|
||||||
|
SpacesInContainerLiterals: true
|
||||||
|
SpacesInCStyleCastParentheses: false
|
||||||
|
SpacesInParentheses: false
|
||||||
|
SpacesInSquareBrackets: false
|
||||||
|
Standard: Auto
|
||||||
|
TabWidth: 4
|
||||||
|
UseTab: Never
|
||||||
|
...
|
||||||
|
|
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
||||||
|
2018-03-24 Brian Cox <bcox@tripwire.com>
|
||||||
|
* Update version to 2.4.3.7
|
||||||
|
* Provide a useful README.md (Github issue #17).
|
||||||
|
* Document return codes in man pages (Github issue #28).
|
||||||
|
* Update install script after testing on additional platforms.
|
||||||
|
* Provide default policies for more operating systems, and update some existing policies
|
||||||
|
* Usability tweaks to twtest.
|
||||||
|
* Fix email reporting on Syllable
|
||||||
|
* Update copyright dates to 2018
|
||||||
|
* Clean up code style with clang-format, & add a custom style that approximates existing OST usage.
|
||||||
|
* Add -t / --output-level option to print-db mode, for consistency w/ print-report mode.
|
||||||
|
* Add object list support to print-report mode, for consistency w/ print-db mode.
|
||||||
|
|
||||||
2017-10-01 Brian Cox <bcox@tripwire.com>
|
2017-10-01 Brian Cox <bcox@tripwire.com>
|
||||||
* Update version to 2.4.3.6
|
* Update version to 2.4.3.6
|
||||||
* Fix & expand tests in Perl acceptance test framework
|
* Fix & expand tests in Perl acceptance test framework
|
||||||
|
|
|
@ -3,10 +3,10 @@ SUBDIRS = man src
|
||||||
EXTRA_DIST = COMMERCIAL MAINTAINERS TRADEMARK LICENSE Packaging ReadMe-2.4.3 README.md autogen.sh autogen.sh.README touchconfig.sh contrib policy installer
|
EXTRA_DIST = COMMERCIAL MAINTAINERS TRADEMARK LICENSE Packaging ReadMe-2.4.3 README.md autogen.sh autogen.sh.README touchconfig.sh contrib policy installer
|
||||||
|
|
||||||
install-data-hook:
|
install-data-hook:
|
||||||
export INSTALL_STRIP_FLAG
|
INSTALL_STRIP_FLAG="$(INSTALL_STRIP_FLAG)" \
|
||||||
prefix="$(prefix)" sysconfdir="$(sysconfdir)" \
|
prefix="$(prefix)" sysconfdir="$(sysconfdir)" \
|
||||||
path_to_vi="$(path_to_vi)" path_to_sendmail="$(path_to_sendmail)" \
|
path_to_vi="$(path_to_vi)" path_to_sendmail="$(path_to_sendmail)" \
|
||||||
$(top_srcdir)/installer/install.sh
|
$(top_srcdir)/installer/install.sh
|
||||||
|
|
||||||
uninstall-hook:
|
uninstall-hook:
|
||||||
rm -f ${prefix}/sbin/tripwire $(prefix)/sbin/twadmin $(prefix)/sbin/twprint $(prefix)/sbin/siggen
|
rm -f ${prefix}/sbin/tripwire $(prefix)/sbin/twadmin $(prefix)/sbin/twprint $(prefix)/sbin/siggen
|
||||||
|
|
|
@ -798,10 +798,10 @@ uninstall-am:
|
||||||
|
|
||||||
|
|
||||||
install-data-hook:
|
install-data-hook:
|
||||||
export INSTALL_STRIP_FLAG
|
INSTALL_STRIP_FLAG="$(INSTALL_STRIP_FLAG)" \
|
||||||
prefix="$(prefix)" sysconfdir="$(sysconfdir)" \
|
prefix="$(prefix)" sysconfdir="$(sysconfdir)" \
|
||||||
path_to_vi="$(path_to_vi)" path_to_sendmail="$(path_to_sendmail)" \
|
path_to_vi="$(path_to_vi)" path_to_sendmail="$(path_to_sendmail)" \
|
||||||
$(top_srcdir)/installer/install.sh
|
$(top_srcdir)/installer/install.sh
|
||||||
|
|
||||||
uninstall-hook:
|
uninstall-hook:
|
||||||
rm -f ${prefix}/sbin/tripwire $(prefix)/sbin/twadmin $(prefix)/sbin/twprint $(prefix)/sbin/siggen
|
rm -f ${prefix}/sbin/tripwire $(prefix)/sbin/twadmin $(prefix)/sbin/twprint $(prefix)/sbin/siggen
|
||||||
|
|
|
@ -9,10 +9,6 @@ Packaging for Open Source Tripwire is maintained by various third parties:
|
||||||
* Debian: https://tracker.debian.org/pkg/tripwire
|
* Debian: https://tracker.debian.org/pkg/tripwire
|
||||||
|
|
||||||
* Gentoo: https://packages.gentoo.org/packages/app-admin/tripwire
|
* Gentoo: https://packages.gentoo.org/packages/app-admin/tripwire
|
||||||
Gentoo also has an SELinux policy for OST:
|
|
||||||
https://packages.gentoo.org/packages/sec-policy/selinux-tripwire
|
|
||||||
|
|
||||||
* Chef cookbook: https://github.com/rackspace-cookbooks/rackspace_tripwire
|
|
||||||
|
|
||||||
* FreeBSD Ports: http://svnweb.freebsd.org/ports/head/security/tripwire/
|
* FreeBSD Ports: http://svnweb.freebsd.org/ports/head/security/tripwire/
|
||||||
|
|
||||||
|
@ -23,5 +19,19 @@ Packaging for Open Source Tripwire is maintained by various third parties:
|
||||||
* NetBSD pkgsrc: http://ftp.netbsd.org/pub/pkgsrc/current/pkgsrc/security/tripwire/README.html
|
* NetBSD pkgsrc: http://ftp.netbsd.org/pub/pkgsrc/current/pkgsrc/security/tripwire/README.html
|
||||||
NOTE: At present (April 2016) pkgsrc only provides the obsolete Tripwire 1.2, from the mid-1990s.
|
NOTE: At present (April 2016) pkgsrc only provides the obsolete Tripwire 1.2, from the mid-1990s.
|
||||||
That version lacks contemporary hash algorithms, and you probably don't want to use it.
|
That version lacks contemporary hash algorithms, and you probably don't want to use it.
|
||||||
|
There's an unfinished pkgsrc port for OST 2.3+ here, if someone who understands pkgsrc
|
||||||
|
is looking for a fun(?) project: http://pkgsrc.se/wip/tripwire2
|
||||||
|
|
||||||
|
|
||||||
|
A few third party projects that might be useful with OST
|
||||||
|
|
||||||
|
* Chef cookbook: https://github.com/rackspace-cookbooks/rackspace_tripwire
|
||||||
|
|
||||||
|
* Puppet module: https://github.com/razorsedge/puppet-tripwire
|
||||||
|
|
||||||
|
* SELinux policies from Tresys: https://github.com/TresysTechnology/refpolicy-contrib/blob/master/tripwire.te
|
||||||
|
(and related .fc and .if files in the same repo)
|
||||||
|
|
||||||
|
* A Gentoo SELinux policy, different from the one above: https://packages.gentoo.org/packages/sec-policy/selinux-tripwire
|
||||||
|
|
||||||
|
* An experimental(?) Dockerfile for CentOS: https://hub.docker.com/r/prateeknischal/tripwire-play/
|
||||||
|
|
181
README.md
181
README.md
|
@ -1,5 +1,180 @@
|
||||||
#Open Source Tripwire<sup>®</sup>
|
# Open Source Tripwire<sup>®</sup>
|
||||||
|
|
||||||
Open Source Tripwire<sup>®</sup> software is a security and data integrity tool useful for monitoring and alerting on specific file change(s) on a range of systems. The project is based on code originally contributed by [Tripwire, Inc.](http://www.tripwire.com) in 2000.
|
Open Source Tripwire<sup>®</sup> is a security and data integrity tool for monitoring and alerting on file & directory changes. This project is based on code originally contributed by [Tripwire, Inc.](http://www.tripwire.com) in 2000.
|
||||||
|
|
||||||
Open Source Tripwire is suitable for monitoring a small number of Linux servers, where centralized control and reporting is not needed and professional support or system automation is not a requirement.
|
## Overview
|
||||||
|
A Tripwire check compares the current filesystem state against a known baseline state, and alerts on any changes it detects. The baseline and check behavior are controlled by a policy file, which specifies which files or directories to monitor, and which attributes to monitor on them, such as hashes, file permissions, and ownership.
|
||||||
|
|
||||||
|
When an expected change occurs, such as upgrading a package, the baseline database can be updated to the new known-good state. The policy can also be updated, for example to reduce noise or cover a newly installed package.
|
||||||
|
|
||||||
|
## Getting Started
|
||||||
|
|
||||||
|
This section covers manual setup of Open Source Tripwire. If installing via an RPM or Debian package, or via **make install**, a setup script will walk the user through the initial setup steps (key generation thru policy creation) and these will not need to be done by hand.
|
||||||
|
|
||||||
|
### Generating Keys
|
||||||
|
The first step is to generate site and local key files. This is necessary because Tripwire policy, configuration, and database files are signed by default, and report files may also be signed. The site key is used to sign config and policy files, while databases and reports are signed with the local key. The idea here is that multiple machines can share a site key, but each will have its own local key. The policy and config files can then be created once and distributed across these machines.
|
||||||
|
|
||||||
|
A common practice is to include the hostname in the local key filename, as follows:
|
||||||
|
|
||||||
|
```
|
||||||
|
./twadmin --generate-keys -L /etc/tripwire/${HOSTNAME}-local.key
|
||||||
|
./twadmin --generate-keys -S /etc/tripwire/site.key
|
||||||
|
```
|
||||||
|
|
||||||
|
### Creating a configuration file
|
||||||
|
The next step is to create a Tripwire config file. The config file contains a variety of settings including the locations of Tripwire binaries and key files, email report settings, and parameters that control baseline/check behavior. These settings are explained in detail in the **twconfig(4)** manual page.
|
||||||
|
|
||||||
|
This command line reads and validates the config text in /path/to/twcfg.txt, writes the results to tw.cfg, and signs the resulting file with the provided site key:
|
||||||
|
|
||||||
|
```
|
||||||
|
./twadmin --create-cfgfile -S /path/to/site.key /path/to/twcfg.txt
|
||||||
|
```
|
||||||
|
### Generating a policy file
|
||||||
|
|
||||||
|
Now it's time to configure which files & directories OST will monitor. A few simple examples of policy rules:
|
||||||
|
|
||||||
|
```
|
||||||
|
/start/point -> $(IgnoreNone); # Get all attributes for this dir tree
|
||||||
|
/another/start -> +pinugS; # Get selected attributes for this dir tree
|
||||||
|
!/start/point/subdir/to/ignore; # Don't monitor this dir tree
|
||||||
|
```
|
||||||
|
The Tripwire policy language is documented in detail in the **twpolicy(4)** manual page, and default policies for most common operating systems are available in the OST project's policy subdirectory.
|
||||||
|
|
||||||
|
```
|
||||||
|
./twadmin --create-polfile -S /etc/tripwire/twpol.txt
|
||||||
|
```
|
||||||
|
|
||||||
|
### Creating a baseline
|
||||||
|
|
||||||
|
The next step is to baseline the system for the first time. This step is necessary even if the previous steps are handled by a setup/install script.
|
||||||
|
|
||||||
|
```
|
||||||
|
./tripwire --init
|
||||||
|
```
|
||||||
|
This creates a database file in the configured directory, typically a file with a .twd extension in /var/lib/tripwire. The optional **--verbose** argument to init mode lists files and directories as they're being scanned.
|
||||||
|
|
||||||
|
### Running a check
|
||||||
|
```
|
||||||
|
./tripwire --check
|
||||||
|
```
|
||||||
|
This runs a check, again with an optional **--verbose** option that displays what it's doing. Scan results are written to standard out, as well as a report file, which typically has a .twr extension and lives in /var/lib/tripwire/report. If email reporting is enabled, emails will be sent at the end of the check.
|
||||||
|
|
||||||
|
A common way to use OST is to set up a cron job to run checks periodically, emailing results to an administrative account. Note that the OST install script currently does not create any cron jobs, and this will need to be done by hand.
|
||||||
|
|
||||||
|
### Printing a report
|
||||||
|
```
|
||||||
|
./twprint -m r -t [0-4] -r /path/to/reportfile.twr
|
||||||
|
```
|
||||||
|
The -t argument specifies the level of report verbosity, where 0 is a single line summary of the report contents, and 4 displays all gathered attributes on all changed objects. The report level defaults to 3 if not specified on the command line or via the REPORTLEVEL config file option.
|
||||||
|
|
||||||
|
Databases can be also printed with:
|
||||||
|
|
||||||
|
```
|
||||||
|
./twprint -m d -d /path/to/database.twd
|
||||||
|
```
|
||||||
|
|
||||||
|
### Updating a database
|
||||||
|
The simplest form of update updates the database with all the changes in a report file:
|
||||||
|
|
||||||
|
```
|
||||||
|
./tripwire --update --accept-all
|
||||||
|
```
|
||||||
|
|
||||||
|
While a
|
||||||
|
```
|
||||||
|
./tripwire --update
|
||||||
|
```
|
||||||
|
brings up a text report in the user's preferred editor (as configured in the config file's EDITOR option), with a checkbox next to each detected change. After saving and exiting the editor, the database will only be updated for those objects that remain selected with an **[x]**.
|
||||||
|
|
||||||
|
### Updating a policy
|
||||||
|
Policy update mode modifies the current Tripwire policy without losing existing baselines.
|
||||||
|
|
||||||
|
```
|
||||||
|
./tripwire --update-policy updated-policy.txt
|
||||||
|
```
|
||||||
|
|
||||||
|
A check is run with the new policy as part of the update process. If this check detects changes, the default behavior is to display the changes and exit without updating the policy or database. To accept the changes and continue with the policy update, use the **-Z low** / **--secure-mode low** command line option.
|
||||||
|
|
||||||
|
### Testing the email configuration
|
||||||
|
To test email configuration:
|
||||||
|
|
||||||
|
```
|
||||||
|
./tripwire --test --email user@domain.tld
|
||||||
|
```
|
||||||
|
This sends a test email to the specified address, using the email settings specified in the config file.
|
||||||
|
|
||||||
|
## Building OST
|
||||||
|
|
||||||
|
### Prerequisites
|
||||||
|
|
||||||
|
A C++ compiler. It's known to build with gcc and clang; OST should work with gcc versions as old as 2.95.2, although gcc older than version 3.1 will need an external STLPort package.
|
||||||
|
|
||||||
|
A POSIX-like operating system, including Linux, macOS, various BSDs, Solaris, AIX, HP-UX, Minix, Haiku, GNU/Hurd, and others. Windows users can build OST under Cygwin, although this does not provide support for monitoring the Registry or any Windows-specific file attributes.
|
||||||
|
|
||||||
|
Perl 5+ is needed to run the project's test suite.
|
||||||
|
|
||||||
|
### Configuring & Building
|
||||||
|
|
||||||
|
OST uses a standard automake build, so the first configuration step will generally be:
|
||||||
|
```
|
||||||
|
./configure
|
||||||
|
```
|
||||||
|
|
||||||
|
Additional compiler arguments (such as Debian hardening options), non-default paths, and other options can be set up in this step. A ```./configure --help``` lists the available configuration options.
|
||||||
|
|
||||||
|
The ```--prefix=/some/path``` option controls where a subsequent ```make install``` will install to, and where Tripwire binaries will look for a configuration file.
|
||||||
|
|
||||||
|
The ```--enable-static``` option causes the build to create statically linked binaries. This is often used as a security enhancement, so that Tripwire will not rely on the shared libraries on the machine. This is not possible on all platforms, as some (like macOS and Solaris) don't provide the necessary static libraries to link against.
|
||||||
|
|
||||||
|
Note that Linux systems that use NSS for name lookups will still employ shared libraries behind the scenes even when the OST binaries are statically linked. There have been occasional reports of segfaults when trying to do a name lookup in these circumstances, particularly when the binary was built on a different machine or it's trying to do an LDAP or NIS name lookup. If this occurs, there are two ways to work around it: Either switch to dynamic binaries, or set the Tripwire config file option ```RESOLVE_IDS_TO_NAMES=false```, which tells OST to just watch numeric user & group IDs and not perform name lookups.
|
||||||
|
|
||||||
|
If the configure or make step fails with errors about the automake/autoconf version, it may be necessary to run the script
|
||||||
|
```
|
||||||
|
./touchconfig.sh```
|
||||||
|
before building the project. This script simply touches files in the correct order such that their last change times are not all identical, and that they're different in the right order.
|
||||||
|
|
||||||
|
Then just
|
||||||
|
```make```
|
||||||
|
to build the project.
|
||||||
|
|
||||||
|
## Running the test suites
|
||||||
|
|
||||||
|
the ```make check``` make target runs two things: The acceptance test suite in the src/test-harness directory, and unit tests by running twtest, which is built in the bin directory along with other Tripwire binaries. These tests can also be run separately:
|
||||||
|
```./twtest``` runs all unit tests, while ```./twtest list``` lists all available tests.
|
||||||
|
```./twtest Groupname``` runs all tests in a group, and
|
||||||
|
```./twtest Groupname/Testname``` just runs the specified test.
|
||||||
|
|
||||||
|
|
||||||
|
To run the acceptance tests manually, cd to the src/test-harness directory and run ```perl ./twtest.pl```.
|
||||||
|
|
||||||
|
|
||||||
|
## Deployment
|
||||||
|
|
||||||
|
The ```make install``` target installs OST to the configured location, and ```make install-strip``` installs and removes symbols from the Tripwire binaries. A ```make dist``` creates a gzipped source bundle.
|
||||||
|
|
||||||
|
## Authors
|
||||||
|
|
||||||
|
* [Tripwire, Inc.](http://www.tripwire.com)
|
||||||
|
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
The developer of the original code and/or files is Tripwire, Inc.
|
||||||
|
Portions created by Tripwire, Inc. are copyright 2000-2018 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.
|
||||||
|
|
|
@ -2,7 +2,7 @@ TRIPWIRE COPYRIGHT & TRADEMARK NOTICE
|
||||||
|
|
||||||
COPYRIGHT
|
COPYRIGHT
|
||||||
The developer of the original code and/or files is Tripwire, Inc. Portions
|
The developer of the original code and/or files is Tripwire, Inc. Portions
|
||||||
created by Tripwire, Inc. are copyright 2000-2017 Tripwire, Inc.
|
created by Tripwire, Inc. are copyright 2000-2018 Tripwire, Inc.
|
||||||
|
|
||||||
TRADEMARK
|
TRADEMARK
|
||||||
Tripwire is a registered trademark (the "Trademark") of Tripwire, Inc. All
|
Tripwire is a registered trademark (the "Trademark") of Tripwire, Inc. All
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
# From configure.ac Revision: 2.4.3.6 .
|
# From configure.ac Revision: 2.4.3.7 .
|
||||||
# Guess values for system-dependent variables and create Makefiles.
|
# Guess values for system-dependent variables and create Makefiles.
|
||||||
# Generated by GNU Autoconf 2.69 for tripwire 2.4.3.6.
|
# Generated by GNU Autoconf 2.69 for tripwire 2.4.3.7.
|
||||||
#
|
#
|
||||||
# Report bugs to <https://github.com/Tripwire/tripwire-open-source/issues>.
|
# Report bugs to <https://github.com/Tripwire/tripwire-open-source/issues>.
|
||||||
#
|
#
|
||||||
|
@ -12,7 +12,7 @@
|
||||||
# This configure script is free software; the Free Software Foundation
|
# This configure script is free software; the Free Software Foundation
|
||||||
# gives unlimited permission to copy, distribute and modify it.
|
# gives unlimited permission to copy, distribute and modify it.
|
||||||
#
|
#
|
||||||
# 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.
|
# The developer of the original code and/or files is Tripwire, Inc. Portions created by Tripwire, Inc. are copyright 2000-2018 Tripwire, Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights reserved.
|
||||||
## -------------------- ##
|
## -------------------- ##
|
||||||
## M4sh Initialization. ##
|
## M4sh Initialization. ##
|
||||||
## -------------------- ##
|
## -------------------- ##
|
||||||
|
@ -584,8 +584,8 @@ MAKEFLAGS=
|
||||||
# Identity of this package.
|
# Identity of this package.
|
||||||
PACKAGE_NAME='tripwire'
|
PACKAGE_NAME='tripwire'
|
||||||
PACKAGE_TARNAME='tripwire'
|
PACKAGE_TARNAME='tripwire'
|
||||||
PACKAGE_VERSION='2.4.3.6'
|
PACKAGE_VERSION='2.4.3.7'
|
||||||
PACKAGE_STRING='tripwire 2.4.3.6'
|
PACKAGE_STRING='tripwire 2.4.3.7'
|
||||||
PACKAGE_BUGREPORT='https://github.com/Tripwire/tripwire-open-source/issues'
|
PACKAGE_BUGREPORT='https://github.com/Tripwire/tripwire-open-source/issues'
|
||||||
PACKAGE_URL='https://github.com/Tripwire/tripwire-open-source'
|
PACKAGE_URL='https://github.com/Tripwire/tripwire-open-source'
|
||||||
|
|
||||||
|
@ -1314,7 +1314,7 @@ if test "$ac_init_help" = "long"; then
|
||||||
# Omit some internal or obsolete options to make the list less imposing.
|
# 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.
|
# This message is too long to be a string in the A/UX 3.1 sh.
|
||||||
cat <<_ACEOF
|
cat <<_ACEOF
|
||||||
\`configure' configures tripwire 2.4.3.6 to adapt to many kinds of systems.
|
\`configure' configures tripwire 2.4.3.7 to adapt to many kinds of systems.
|
||||||
|
|
||||||
Usage: $0 [OPTION]... [VAR=VALUE]...
|
Usage: $0 [OPTION]... [VAR=VALUE]...
|
||||||
|
|
||||||
|
@ -1385,7 +1385,7 @@ fi
|
||||||
|
|
||||||
if test -n "$ac_init_help"; then
|
if test -n "$ac_init_help"; then
|
||||||
case $ac_init_help in
|
case $ac_init_help in
|
||||||
short | recursive ) echo "Configuration of tripwire 2.4.3.6:";;
|
short | recursive ) echo "Configuration of tripwire 2.4.3.7:";;
|
||||||
esac
|
esac
|
||||||
cat <<\_ACEOF
|
cat <<\_ACEOF
|
||||||
|
|
||||||
|
@ -1500,14 +1500,14 @@ fi
|
||||||
test -n "$ac_init_help" && exit $ac_status
|
test -n "$ac_init_help" && exit $ac_status
|
||||||
if $ac_init_version; then
|
if $ac_init_version; then
|
||||||
cat <<\_ACEOF
|
cat <<\_ACEOF
|
||||||
tripwire configure 2.4.3.6
|
tripwire configure 2.4.3.7
|
||||||
generated by GNU Autoconf 2.69
|
generated by GNU Autoconf 2.69
|
||||||
|
|
||||||
Copyright (C) 2012 Free Software Foundation, Inc.
|
Copyright (C) 2012 Free Software Foundation, Inc.
|
||||||
This configure script is free software; the Free Software Foundation
|
This configure script is free software; the Free Software Foundation
|
||||||
gives unlimited permission to copy, distribute and modify it.
|
gives unlimited permission to copy, distribute and modify it.
|
||||||
|
|
||||||
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.
|
The developer of the original code and/or files is Tripwire, Inc. Portions created by Tripwire, Inc. are copyright 2000-2018 Tripwire, Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights reserved.
|
||||||
_ACEOF
|
_ACEOF
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
@ -2444,7 +2444,7 @@ cat >config.log <<_ACEOF
|
||||||
This file contains any messages produced by compilers while
|
This file contains any messages produced by compilers while
|
||||||
running configure, to aid debugging if configure makes a mistake.
|
running configure, to aid debugging if configure makes a mistake.
|
||||||
|
|
||||||
It was created by tripwire $as_me 2.4.3.6, which was
|
It was created by tripwire $as_me 2.4.3.7, which was
|
||||||
generated by GNU Autoconf 2.69. Invocation command line was
|
generated by GNU Autoconf 2.69. Invocation command line was
|
||||||
|
|
||||||
$ $0 $@
|
$ $0 $@
|
||||||
|
@ -3418,7 +3418,7 @@ fi
|
||||||
|
|
||||||
# Define the identity of the package.
|
# Define the identity of the package.
|
||||||
PACKAGE='tripwire'
|
PACKAGE='tripwire'
|
||||||
VERSION='2.4.3.6'
|
VERSION='2.4.3.7'
|
||||||
|
|
||||||
|
|
||||||
cat >>confdefs.h <<_ACEOF
|
cat >>confdefs.h <<_ACEOF
|
||||||
|
@ -7889,7 +7889,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
|
||||||
# report actual input values of CONFIG_FILES etc. instead of their
|
# report actual input values of CONFIG_FILES etc. instead of their
|
||||||
# values after options handling.
|
# values after options handling.
|
||||||
ac_log="
|
ac_log="
|
||||||
This file was extended by tripwire $as_me 2.4.3.6, which was
|
This file was extended by tripwire $as_me 2.4.3.7, which was
|
||||||
generated by GNU Autoconf 2.69. Invocation command line was
|
generated by GNU Autoconf 2.69. Invocation command line was
|
||||||
|
|
||||||
CONFIG_FILES = $CONFIG_FILES
|
CONFIG_FILES = $CONFIG_FILES
|
||||||
|
@ -7956,7 +7956,7 @@ _ACEOF
|
||||||
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
|
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
|
||||||
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
|
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
|
||||||
ac_cs_version="\\
|
ac_cs_version="\\
|
||||||
tripwire config.status 2.4.3.6
|
tripwire config.status 2.4.3.7
|
||||||
configured by $0, generated by GNU Autoconf 2.69,
|
configured by $0, generated by GNU Autoconf 2.69,
|
||||||
with options \\"\$ac_cs_config\\"
|
with options \\"\$ac_cs_config\\"
|
||||||
|
|
||||||
|
|
|
@ -2,14 +2,14 @@ dnl Process this file with autoconf to produce a configure script.
|
||||||
dnl
|
dnl
|
||||||
dnl
|
dnl
|
||||||
|
|
||||||
AC_INIT([tripwire], [2.4.3.6], [https://github.com/Tripwire/tripwire-open-source/issues], [tripwire], [https://github.com/Tripwire/tripwire-open-source])
|
AC_INIT([tripwire], [2.4.3.7], [https://github.com/Tripwire/tripwire-open-source/issues], [tripwire], [https://github.com/Tripwire/tripwire-open-source])
|
||||||
AC_CONFIG_SRCDIR([src/tw/tw.cpp])
|
AC_CONFIG_SRCDIR([src/tw/tw.cpp])
|
||||||
AC_CANONICAL_TARGET([])
|
AC_CANONICAL_TARGET([])
|
||||||
AM_INIT_AUTOMAKE
|
AM_INIT_AUTOMAKE
|
||||||
AM_CONFIG_HEADER(config.h)
|
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_COPYRIGHT([The developer of the original code and/or files is Tripwire, Inc. Portions created by Tripwire, Inc. are copyright 2000-2018 Tripwire, Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights reserved.])
|
||||||
AC_REVISION([$Revision: 2.4.3.6 $])
|
AC_REVISION([$Revision: 2.4.3.7 $])
|
||||||
|
|
||||||
dnl ###############
|
dnl ###############
|
||||||
dnl Setup defaults
|
dnl Setup defaults
|
||||||
|
|
|
@ -154,10 +154,16 @@ TAR_DIR=${TAR_DIR:-${START_DIR}}
|
||||||
|
|
||||||
OS=`uname -s`
|
OS=`uname -s`
|
||||||
POLICYSRC="twpol-${OS:=GENERIC}.txt"
|
POLICYSRC="twpol-${OS:=GENERIC}.txt"
|
||||||
if [ ! -r ${TAR_DIR}/policy/${POLICYSRC} ]
|
if [ ! -r ${TAR_DIR}/policy/${POLICYSRC} ]; then
|
||||||
then POLICYSRC="twpol-GENERIC.txt"
|
OS=`uname -o`
|
||||||
|
POLICYSRC="twpol-${OS:=GENERIC}.txt"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ ! -r ${TAR_DIR}/policy/${POLICYSRC} ]; then
|
||||||
|
POLICYSRC="twpol-GENERIC.txt"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
##-------------------------------------------------------
|
##-------------------------------------------------------
|
||||||
## Parse the command line.
|
## Parse the command line.
|
||||||
##-------------------------------------------------------
|
##-------------------------------------------------------
|
||||||
|
@ -386,9 +392,37 @@ else
|
||||||
## Verify that the specified editor program exists
|
## Verify that the specified editor program exists
|
||||||
##-------------------------------------------------------
|
##-------------------------------------------------------
|
||||||
|
|
||||||
DEFAULTEDITOR=${EDITOR:-‘/bin/vi’}
|
# If user specified an editor in $path_to_vi or $TWEDITOR, try that first.
|
||||||
TWEDITOR=${TWEDITOR:-$DEFAULTEDITOR}
|
# $path_to_vi defaults to /usr/bin/vi, so we usually succeed here.
|
||||||
TWEDITOR_PATH=`command -v $TWEDITOR`
|
#
|
||||||
|
if [ -n ${TWEDITOR} ]; then
|
||||||
|
TWEDITOR_PATH=`command -v $TWEDITOR`
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If user's environment includes $EDITOR, try that next
|
||||||
|
if [ -n ${EDITOR} ] && [ -z ${TWEDITOR_PATH} ]; then
|
||||||
|
TWEDITOR_PATH=`command -v $EDITOR`
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Ok, now search path for vi
|
||||||
|
if [ -z ${TWEDITOR_PATH} ]; then
|
||||||
|
TWEDITOR_PATH=`command -v vi`
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Try vim in case there isn't a link named vi
|
||||||
|
if [ -z ${TWEDITOR_PATH} ]; then
|
||||||
|
TWEDITOR_PATH=`command -v vim`
|
||||||
|
fi
|
||||||
|
|
||||||
|
# No vi/vim? See if nano is present
|
||||||
|
if [ -z ${TWEDITOR_PATH} ]; then
|
||||||
|
TWEDITOR_PATH=`command -v nano`
|
||||||
|
fi
|
||||||
|
|
||||||
|
# No vi or nano? See if emacs is available
|
||||||
|
if [ -z ${TWEDITOR_PATH} ]; then
|
||||||
|
TWEDITOR_PATH=`command -v emacs`
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -n ${TWEDITOR_PATH} ]; then
|
if [ -n ${TWEDITOR_PATH} ]; then
|
||||||
TWEDITOR=$TWEDITOR_PATH
|
TWEDITOR=$TWEDITOR_PATH
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
..
|
..
|
||||||
.nh
|
.nh
|
||||||
.ad l
|
.ad l
|
||||||
.TH TWCONFIG 4 "1 July 2000"
|
.TH TWCONFIG 4 "04 Jan 2018" "Open Source Tripwire 2.4"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
twconfig \- \fITripwire\fP configuration file reference
|
twconfig \- \fITripwire\fP configuration file reference
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
|
@ -215,6 +215,15 @@ parameter; reports displayed by other modes and other commands
|
||||||
are not affected.
|
are not affected.
|
||||||
.br
|
.br
|
||||||
Initial value: \fI3\fP
|
Initial value: \fI3\fP
|
||||||
|
.IP \f(CWDBPRINTLEVEL\fP
|
||||||
|
Specifies the default level of report produced by the \fBtwprint
|
||||||
|
\(hy\(hyprint\(hydbfile\fP mode. Valid values for this option are 0 to
|
||||||
|
2. The output
|
||||||
|
level specified by this option can be overridden with the (\fB\(hyt\fP\ or\ \fB\(hy\(hyoutput\(hylevel\fP) option on the command line. If
|
||||||
|
this variable is not included in the configuration file, the default
|
||||||
|
output level is 2.
|
||||||
|
.br
|
||||||
|
Initial value: \fI2\fP
|
||||||
.IP \f(CWHASH_DIRECT_IO\fP
|
.IP \f(CWHASH_DIRECT_IO\fP
|
||||||
Use direct i/o when hashing files. (Linux-only as of OST 2.4.3.2)
|
Use direct i/o when hashing files. (Linux-only as of OST 2.4.3.2)
|
||||||
.br
|
.br
|
||||||
|
@ -302,7 +311,7 @@ Permission is granted to copy and distribute modified versions of this man page
|
||||||
.PP
|
.PP
|
||||||
Permission is granted to copy and distribute translations of this man page into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by Tripwire, Inc.
|
Permission is granted to copy and distribute translations of this man page into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by Tripwire, Inc.
|
||||||
.PP
|
.PP
|
||||||
Copyright 2000-2017 Tripwire, Inc. Tripwire is a registered trademark of Tripwire, Inc. in the United States and other countries. All rights reserved.
|
Copyright 2000-2018 Tripwire, Inc. Tripwire is a registered trademark of Tripwire, Inc. in the United States and other countries. All rights reserved.
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
.BR twintro (8),
|
.BR twintro (8),
|
||||||
.BR tripwire (8),
|
.BR tripwire (8),
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
.\"
|
.\"
|
||||||
.nh
|
.nh
|
||||||
.ad l
|
.ad l
|
||||||
.TH TWPOLICY 4 "1 July 2000"
|
.TH TWPOLICY 4 "04 Jan 2018" "Open Source Tripwire 2.4"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
twpolicy \- \fITripwire\fP policy file reference
|
twpolicy \- \fITripwire\fP policy file reference
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
|
@ -537,7 +537,7 @@ Permission is granted to copy and distribute modified versions of this man page
|
||||||
.PP
|
.PP
|
||||||
Permission is granted to copy and distribute translations of this man page into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by Tripwire, Inc.
|
Permission is granted to copy and distribute translations of this man page into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by Tripwire, Inc.
|
||||||
.PP
|
.PP
|
||||||
Copyright 2000-2017 Tripwire, Inc. Tripwire is a registered trademark of Tripwire, Inc. in the United States and other countries. All rights reserved.
|
Copyright 2000-2018 Tripwire, Inc. Tripwire is a registered trademark of Tripwire, Inc. in the United States and other countries. All rights reserved.
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
.BR twintro (8),
|
.BR twintro (8),
|
||||||
.BR tripwire (8),
|
.BR tripwire (8),
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
.\"
|
.\"
|
||||||
.nh
|
.nh
|
||||||
.ad l
|
.ad l
|
||||||
.TH TWFILES 5 "1 July 2000"
|
.TH TWFILES 5 "04 Jan 2018" "Open Source Tripwire 2.4"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
twfiles \- overview of files used by \fITripwire\fR and file backup process
|
twfiles \- overview of files used by \fITripwire\fR and file backup process
|
||||||
.\"
|
.\"
|
||||||
|
@ -112,7 +112,7 @@ Permission is granted to copy and distribute modified versions of this man page
|
||||||
.PP
|
.PP
|
||||||
Permission is granted to copy and distribute translations of this man page into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by Tripwire, Inc.
|
Permission is granted to copy and distribute translations of this man page into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by Tripwire, Inc.
|
||||||
.PP
|
.PP
|
||||||
Copyright 2000-2017 Tripwire, Inc. Tripwire is a registered trademark of Tripwire, Inc. in the United States and other countries. All rights reserved.
|
Copyright 2000-2018 Tripwire, Inc. Tripwire is a registered trademark of Tripwire, Inc. in the United States and other countries. All rights reserved.
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
.BR twintro (8),
|
.BR twintro (8),
|
||||||
.BR tripwire (8),
|
.BR tripwire (8),
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
.\" Do not move or remove previous line.
|
.\" Do not move or remove previous line.
|
||||||
.\" Used by some man commands to know that tbl should be used.
|
.\" Used by some man commands to know that tbl should be used.
|
||||||
.nh
|
.nh
|
||||||
.TH SIGGEN 8 "19 Feb 2004"
|
.TH SIGGEN 8 "04 Jan 2018" "Open Source Tripwire 2.4"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
siggen \- signature gathering routine for Tripwire
|
siggen \- signature gathering utility for Tripwire
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.B siggen
|
.B siggen
|
||||||
[
|
[
|
||||||
|
@ -54,6 +54,8 @@ Display Haval value, a 128-bit hash code.
|
||||||
.TP
|
.TP
|
||||||
.IR file1 " [ " "file2... " ]
|
.IR file1 " [ " "file2... " ]
|
||||||
List of filesystem objects for which to display values.
|
List of filesystem objects for which to display values.
|
||||||
|
.SH EXIT STATUS
|
||||||
|
\fBsiggen\fP exits 0 on success, 1 on error.
|
||||||
.SH VERSION INFORMATION
|
.SH VERSION INFORMATION
|
||||||
This man page describes
|
This man page describes
|
||||||
.B siggen
|
.B siggen
|
||||||
|
@ -67,7 +69,7 @@ Permission is granted to copy and distribute modified versions of this man page
|
||||||
.PP
|
.PP
|
||||||
Permission is granted to copy and distribute translations of this man page into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by Tripwire, Inc.
|
Permission is granted to copy and distribute translations of this man page into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by Tripwire, Inc.
|
||||||
.PP
|
.PP
|
||||||
Copyright 2000-2017 Tripwire, Inc. Tripwire is a registered trademark of Tripwire, Inc. in the United States and other countries. All rights reserved.
|
Copyright 2000-2018 Tripwire, Inc. Tripwire is a registered trademark of Tripwire, Inc. in the United States and other countries. All rights reserved.
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
.BR twintro (8),
|
.BR twintro (8),
|
||||||
.BR tripwire (8),
|
.BR tripwire (8),
|
||||||
|
|
|
@ -36,9 +36,9 @@
|
||||||
.\"
|
.\"
|
||||||
.nh
|
.nh
|
||||||
.ad l
|
.ad l
|
||||||
.TH TRIPWIRE 8 "1 July 2000"
|
.TH TRIPWIRE 8 "04 Jan 2018" "Open Source Tripwire 2.4"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
tripwire \- a file integrity checker for \s-1UNIX\s0 systems
|
tripwire \- a file integrity checker for \s-1UNIX-like\s0 systems
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.B tripwire
|
.B tripwire
|
||||||
.RB "{ " "-m i" " | " "--init" " } "
|
.RB "{ " "-m i" " | " "--init" " } "
|
||||||
|
@ -554,6 +554,19 @@ Mode selector.
|
||||||
Use the specified email address. This parameter must
|
Use the specified email address. This parameter must
|
||||||
be supplied when test mode is used. Only one address
|
be supplied when test mode is used. Only one address
|
||||||
may be specified.
|
may be specified.
|
||||||
|
.SH EXIT STATUS
|
||||||
|
.SS Integrity Checking Mode
|
||||||
|
\fBtripwire\fP exits 0 if no changes are detected. Otherwise the exit value is a bit mask:
|
||||||
|
.TP
|
||||||
|
\fB1\fP At least one file or directory has been added.
|
||||||
|
.TP
|
||||||
|
\fB2\fP At least one file or directory has been modified.
|
||||||
|
.TP
|
||||||
|
\fB4\fP At least one file or directory has been modified.
|
||||||
|
.TP
|
||||||
|
\fB8\fP Error(s) occurred during the check.
|
||||||
|
.SS All Other Modes
|
||||||
|
\fBtripwire\fP exits 0 on success, 8 on error.
|
||||||
.SH VERSION INFORMATION
|
.SH VERSION INFORMATION
|
||||||
This man page describes
|
This man page describes
|
||||||
.B tripwire
|
.B tripwire
|
||||||
|
@ -567,7 +580,7 @@ Permission is granted to copy and distribute modified versions of this man page
|
||||||
.PP
|
.PP
|
||||||
Permission is granted to copy and distribute translations of this man page into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by Tripwire, Inc.
|
Permission is granted to copy and distribute translations of this man page into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by Tripwire, Inc.
|
||||||
.PP
|
.PP
|
||||||
Copyright 2000-2017 Tripwire, Inc. Tripwire is a registered trademark of Tripwire, Inc. in the United States and other countries. All rights reserved.
|
Copyright 2000-2018 Tripwire, Inc. Tripwire is a registered trademark of Tripwire, Inc. in the United States and other countries. All rights reserved.
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
.BR twintro (8),
|
.BR twintro (8),
|
||||||
.BR twadmin (8),
|
.BR twadmin (8),
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
.in \\n(.iu
|
.in \\n(.iu
|
||||||
..
|
..
|
||||||
.ad l
|
.ad l
|
||||||
.TH TWADMIN 8 "1 July 2000"
|
.TH TWADMIN 8 "04 Jan 2018" "Open Source Tripwire 2.4"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
twadmin \- Tripwire administrative and utility tool
|
twadmin \- Tripwire administrative and utility tool
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
|
@ -538,6 +538,8 @@ file.
|
||||||
Specify passphrase used to decrypt the private key in the specified sitekey
|
Specify passphrase used to decrypt the private key in the specified sitekey
|
||||||
file.
|
file.
|
||||||
.\" *****************************************
|
.\" *****************************************
|
||||||
|
.SH EXIT STATUS
|
||||||
|
\fBtwadmin\fP exits 0 on success, 1 on error.
|
||||||
.SH VERSION INFORMATION
|
.SH VERSION INFORMATION
|
||||||
This man page describes
|
This man page describes
|
||||||
.B twadmin
|
.B twadmin
|
||||||
|
@ -551,7 +553,7 @@ Permission is granted to copy and distribute modified versions of this man page
|
||||||
.PP
|
.PP
|
||||||
Permission is granted to copy and distribute translations of this man page into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by Tripwire, Inc.
|
Permission is granted to copy and distribute translations of this man page into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by Tripwire, Inc.
|
||||||
.PP
|
.PP
|
||||||
Copyright 2000-2017 Tripwire, Inc. Tripwire is a registered trademark of Tripwire, Inc. in the United States and other countries. All rights reserved.
|
Copyright 2000-2018 Tripwire, Inc. Tripwire is a registered trademark of Tripwire, Inc. in the United States and other countries. All rights reserved.
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
.BR twintro (8),
|
.BR twintro (8),
|
||||||
.BR tripwire (8),
|
.BR tripwire (8),
|
||||||
|
|
|
@ -16,12 +16,12 @@
|
||||||
.\"
|
.\"
|
||||||
.nh
|
.nh
|
||||||
.ad l
|
.ad l
|
||||||
.TH TWINTRO 8 "1 July 2000"
|
.TH TWINTRO 8 "04 Jan 2018" "Open Source Tripwire 2.4"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
twintro \- introduction to \fITripwire\fP software
|
twintro \- introduction to \fITripwire\fP software
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
.PP
|
.PP
|
||||||
\fITripwire 2.4\fP is a file integrity assessment product for Linux networks. Rather than preventing an intruder or virus
|
\fITripwire 2.4\fP is a file integrity assessment tool for UNIX-like systems. Rather than preventing an intruder or virus
|
||||||
from attacking system files, \fITripwire\fP detects intrusions when
|
from attacking system files, \fITripwire\fP detects intrusions when
|
||||||
they do occur. By comparing system files and directories against a
|
they do occur. By comparing system files and directories against a
|
||||||
previously stored "baseline" database, \fITripwire\fP finds any
|
previously stored "baseline" database, \fITripwire\fP finds any
|
||||||
|
@ -99,7 +99,7 @@ Permission is granted to copy and distribute modified versions of this man page
|
||||||
.PP
|
.PP
|
||||||
Permission is granted to copy and distribute translations of this man page into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by Tripwire, Inc.
|
Permission is granted to copy and distribute translations of this man page into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by Tripwire, Inc.
|
||||||
.PP
|
.PP
|
||||||
Copyright 2000-2017 Tripwire, Inc. Tripwire is a registered trademark of Tripwire, Inc. in the United States and other countries. All rights reserved.
|
Copyright 2000-2018 Tripwire, Inc. Tripwire is a registered trademark of Tripwire, Inc. in the United States and other countries. All rights reserved.
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
.BR tripwire (8),
|
.BR tripwire (8),
|
||||||
.BR twadmin (8),
|
.BR twadmin (8),
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
.\" Do not move or remove previous line.
|
.\" Do not move or remove previous line.
|
||||||
.\" Used by some man commands to know that tbl should be used.
|
.\" Used by some man commands to know that tbl should be used.
|
||||||
.ad l
|
.ad l
|
||||||
.TH TWPRINT 8 "1 July 2000"
|
.TH TWPRINT 8 "04 Jan 2018" "Open Source Tripwire 2.4"
|
||||||
.nh
|
.nh
|
||||||
.SH NAME
|
.SH NAME
|
||||||
twprint \- Tripwire database and report printer
|
twprint \- Tripwire database and report printer
|
||||||
|
@ -10,6 +10,9 @@ twprint \- Tripwire database and report printer
|
||||||
.B twprint
|
.B twprint
|
||||||
.RB "{ " "-m r" " | " "--print-report" " } "
|
.RB "{ " "-m r" " | " "--print-report" " } "
|
||||||
.RI "[ " options... " ]"
|
.RI "[ " options... " ]"
|
||||||
|
.if n .br
|
||||||
|
.if n .ti +.5i
|
||||||
|
.RI " [ " "object1" " [ " "object2..." " ]]"
|
||||||
.br
|
.br
|
||||||
.B twprint
|
.B twprint
|
||||||
.RB "{ " "-m d" " | " "--print-dbfile" " } "
|
.RB "{ " "-m d" " | " "--print-dbfile" " } "
|
||||||
|
@ -59,6 +62,7 @@ lbw(1.2i) lb.
|
||||||
-L \fIlocalkey\fP --local-keyfile \fIlocalkey\fP
|
-L \fIlocalkey\fP --local-keyfile \fIlocalkey\fP
|
||||||
-t \fR{ 0|1|2|3|4 }\fP --report-level \fR{ 0|1|2|3|4 }\fP
|
-t \fR{ 0|1|2|3|4 }\fP --report-level \fR{ 0|1|2|3|4 }\fP
|
||||||
.TE
|
.TE
|
||||||
|
.RI "[ " "object1" " [ " "object2..." " ]]"
|
||||||
.RE
|
.RE
|
||||||
.TP
|
.TP
|
||||||
.BR "\(hym r" ", " --print-report
|
.BR "\(hym r" ", " --print-report
|
||||||
|
@ -83,10 +87,15 @@ Print the specified report file.
|
||||||
Use the specified local key file to perform verification
|
Use the specified local key file to perform verification
|
||||||
with reports which are signed.
|
with reports which are signed.
|
||||||
.TP
|
.TP
|
||||||
.BI \(hyt " level\fR, " --report-level " level
|
.BI \(hyt " level\fR, " --report-level " level"
|
||||||
Specifies the detail level of the printed report, overriding the
|
Specifies the detail level of the printed report, overriding the
|
||||||
\f(CWREPORTLEVEL\fP variable in the configuration
|
\f(CWREPORTLEVEL\fP variable in the configuration
|
||||||
file. \fIlevel\fR must be a number from 0\ to\ 4.
|
file. \fIlevel\fR must be a number from 0\ to\ 4.
|
||||||
|
.TP
|
||||||
|
.RI "[ " "object1" " [ " "object2..." " ]]"
|
||||||
|
List of filesystem objects in the report to print. If no
|
||||||
|
objects are specified, every object in the report will
|
||||||
|
be printed.
|
||||||
.\" *****************************************
|
.\" *****************************************
|
||||||
.SS Database printing mode:
|
.SS Database printing mode:
|
||||||
.RS 0.4i
|
.RS 0.4i
|
||||||
|
@ -100,6 +109,7 @@ lbw(1.2i) lb.
|
||||||
-c \fIcfgfile\fP --cfgfile \fIcfgfile\fP
|
-c \fIcfgfile\fP --cfgfile \fIcfgfile\fP
|
||||||
-d \fIdatabase\fP --dbfile \fIdatabase\fP
|
-d \fIdatabase\fP --dbfile \fIdatabase\fP
|
||||||
-L \fIlocalkey\fP --local-keyfile \fIlocalkey\fP
|
-L \fIlocalkey\fP --local-keyfile \fIlocalkey\fP
|
||||||
|
-t \fR{ 0|1|2 }\fP --output-level \fR{ 0|1|2 }\fP
|
||||||
.TE
|
.TE
|
||||||
.RI "[ " "object1" " [ " "object2..." " ]]"
|
.RI "[ " "object1" " [ " "object2..." " ]]"
|
||||||
.RE
|
.RE
|
||||||
|
@ -125,6 +135,11 @@ Print the specified database file.
|
||||||
.BI \(hyL " localkey\fR, " --local-keyfile " localkey"
|
.BI \(hyL " localkey\fR, " --local-keyfile " localkey"
|
||||||
Use the specified local key file to read the database.
|
Use the specified local key file to read the database.
|
||||||
.TP
|
.TP
|
||||||
|
.BI \(hyt " level\fR, " --output-level " level"
|
||||||
|
Specifies the detail level of the printed database, overriding the
|
||||||
|
\f(CWDBPRINTLEVEL\fP variable in the configuration
|
||||||
|
file. \fIlevel\fR must be a number from 0\ to\ 2.
|
||||||
|
.TP
|
||||||
.RI "[ " "object1" " [ " "object2..." " ]]"
|
.RI "[ " "object1" " [ " "object2..." " ]]"
|
||||||
List of filesystem objects in the database to print. If no
|
List of filesystem objects in the database to print. If no
|
||||||
objects are specified, every object in the database will
|
objects are specified, every object in the database will
|
||||||
|
@ -132,6 +147,8 @@ be printed. The format for a list of objects is:
|
||||||
.if n .I "section: objname objname... section: objname..."
|
.if n .I "section: objname objname... section: objname..."
|
||||||
.if t .br
|
.if t .br
|
||||||
.if t .I "section: objectname objectname... section: objectname..."
|
.if t .I "section: objectname objectname... section: objectname..."
|
||||||
|
.SH EXIT STATUS
|
||||||
|
\fBtwprint\fP exits 0 on success, 1 on error.
|
||||||
.SH VERSION INFORMATION
|
.SH VERSION INFORMATION
|
||||||
This man page describes
|
This man page describes
|
||||||
.B twprint
|
.B twprint
|
||||||
|
@ -145,7 +162,7 @@ Permission is granted to copy and distribute modified versions of this man page
|
||||||
.PP
|
.PP
|
||||||
Permission is granted to copy and distribute translations of this man page into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by Tripwire, Inc.
|
Permission is granted to copy and distribute translations of this man page into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by Tripwire, Inc.
|
||||||
.PP
|
.PP
|
||||||
Copyright 2000-2017 Tripwire, Inc. Tripwire is a registered trademark of Tripwire, Inc. in the United States and other countries. All rights reserved.
|
Copyright 2000-2018 Tripwire, Inc. Tripwire is a registered trademark of Tripwire, Inc. in the United States and other countries. All rights reserved.
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
.BR twintro (8),
|
.BR twintro (8),
|
||||||
.BR tripwire (8),
|
.BR tripwire (8),
|
||||||
|
|
|
@ -191,7 +191,7 @@ $(DIR1) -> $(param1); # It is also possible to do a
|
||||||
|
|
||||||
#=============================================================================
|
#=============================================================================
|
||||||
#
|
#
|
||||||
# Copyright 2000-2017 Tripwire, Inc. Tripwire is a registered trademark of Tripwire,
|
# Copyright 2000-2018 Tripwire, Inc. Tripwire is a registered trademark of Tripwire,
|
||||||
# Inc. All rights reserved.
|
# Inc. All rights reserved.
|
||||||
#
|
#
|
||||||
# Linux is a registered trademark of Linus Torvalds.
|
# Linux is a registered trademark of Linus Torvalds.
|
||||||
|
|
|
@ -60,13 +60,14 @@ HOSTNAME=;
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
Device = +pugsdr-intlbamcCMSH ;
|
SEC_DEVICE = +pugsdr-intlbamcCMSH ;
|
||||||
Dynamic = +pinugtd-srlbamcCMSH ;
|
SEC_DYNAMIC = +pinugtd-srlbamcCMSH ;
|
||||||
Growing = +pinugtdl-srbamcCMSH ;
|
SEC_GROWING = +pinugtdl-srbamcCMSH ;
|
||||||
IgnoreAll = -pinugtsdrlbamcCMSH ;
|
SEC_IGNORE_ALL = -pinugtsdrlbamcCMSH ;
|
||||||
IgnoreNone = +pinugtsdrbamcCMSH-l ;
|
SEC_IGNORE_NONE = +pinugtsdrbamcCMSH-l ;
|
||||||
ReadOnly = +pinugtsdbmCM-rlacSH ;
|
SEC_READONLY = +pinugtsdbmCM-rlacSH ;
|
||||||
Temporary = +pugt ;
|
SEC_TEMPORARY = +pugt ;
|
||||||
|
|
||||||
|
|
||||||
@@section FS
|
@@section FS
|
||||||
|
|
||||||
|
@ -83,10 +84,10 @@ Temporary = +pugt ;
|
||||||
rulename = "Tripwire Binaries",
|
rulename = "Tripwire Binaries",
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
$(TWBIN)/siggen -> $(ReadOnly) ;
|
$(TWBIN)/siggen -> $(SEC_READONLY) ;
|
||||||
$(TWBIN)/tripwire -> $(ReadOnly) ;
|
$(TWBIN)/tripwire -> $(SEC_READONLY) ;
|
||||||
$(TWBIN)/twadmin -> $(ReadOnly) ;
|
$(TWBIN)/twadmin -> $(SEC_READONLY) ;
|
||||||
$(TWBIN)/twprint -> $(ReadOnly) ;
|
$(TWBIN)/twprint -> $(SEC_READONLY) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Tripwire Data Files - Configuration Files, Policy Files, Keys, Reports, Databases
|
# Tripwire Data Files - Configuration Files, Policy Files, Keys, Reports, Databases
|
||||||
|
@ -103,14 +104,14 @@ Temporary = +pugt ;
|
||||||
# afterward triggers this rule until a database update is run, since the
|
# afterward triggers this rule until a database update is run, since the
|
||||||
# database file does not exist before that point.
|
# database file does not exist before that point.
|
||||||
|
|
||||||
$(TWDB) -> $(Dynamic) -i ;
|
$(TWDB) -> $(SEC_DYNAMIC) -i ;
|
||||||
$(TWPOL)/tw.pol -> $(ReadOnly) -i ;
|
$(TWPOL)/tw.pol -> $(SEC_READONLY) -i ;
|
||||||
$(TWPOL)/tw.cfg -> $(ReadOnly) -i ;
|
$(TWPOL)/tw.cfg -> $(SEC_READONLY) -i ;
|
||||||
$(TWLKEY)/$(HOSTNAME)-local.key -> $(ReadOnly) ;
|
$(TWLKEY)/$(HOSTNAME)-local.key -> $(SEC_READONLY) ;
|
||||||
$(TWSKEY)/site.key -> $(ReadOnly) ;
|
$(TWSKEY)/site.key -> $(SEC_READONLY) ;
|
||||||
|
|
||||||
# don't scan the individual reports
|
# don't scan the individual reports
|
||||||
$(TWREPORT) -> $(Dynamic) (recurse=0) ;
|
$(TWREPORT) -> $(SEC_DYNAMIC) (recurse=0) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
################################################
|
################################################
|
||||||
|
@ -124,7 +125,7 @@ Temporary = +pugt ;
|
||||||
rulename = "OS Boot and Configuration Files",
|
rulename = "OS Boot and Configuration Files",
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/etc -> $(IgnoreNone) -SHa ;
|
/etc -> $(SEC_IGNORE_NONE) -SHa ;
|
||||||
}
|
}
|
||||||
|
|
||||||
###################################################
|
###################################################
|
||||||
|
@ -138,9 +139,9 @@ Temporary = +pugt ;
|
||||||
rulename = "Mount Points",
|
rulename = "Mount Points",
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/ -> $(ReadOnly) ;
|
/ -> $(SEC_READONLY) ;
|
||||||
/usr -> $(ReadOnly) ;
|
/usr -> $(SEC_READONLY) ;
|
||||||
/var -> $(ReadOnly) ;
|
/var -> $(SEC_READONLY) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
###################################################
|
###################################################
|
||||||
|
@ -154,10 +155,10 @@ Temporary = +pugt ;
|
||||||
rulename = "Misc Top-Level Directories",
|
rulename = "Misc Top-Level Directories",
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/lost+found -> $(ReadOnly) ;
|
/lost+found -> $(SEC_READONLY) ;
|
||||||
/hacmplocal -> $(ReadOnly) ;
|
/hacmplocal -> $(SEC_READONLY) ;
|
||||||
/homelocal -> $(ReadOnly) ;
|
/homelocal -> $(SEC_READONLY) ;
|
||||||
/opt -> $(ReadOnly) ;
|
/opt -> $(SEC_READONLY) ;
|
||||||
!/var/adm/csd ;
|
!/var/adm/csd ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,7 +173,7 @@ Temporary = +pugt ;
|
||||||
rulename = "System Devices",
|
rulename = "System Devices",
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/dev -> $(Device) ;
|
/dev -> $(SEC_DEVICE) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
################################################
|
################################################
|
||||||
|
@ -186,10 +187,10 @@ Temporary = +pugt ;
|
||||||
rulename = "OS Binaries and Libraries",
|
rulename = "OS Binaries and Libraries",
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/sbin -> $(ReadOnly) ;
|
/sbin -> $(SEC_READONLY) ;
|
||||||
/usr/bin -> $(ReadOnly) ;
|
/usr/bin -> $(SEC_READONLY) ;
|
||||||
/usr/lib -> $(ReadOnly) ;
|
/usr/lib -> $(SEC_READONLY) ;
|
||||||
/usr/sbin -> $(ReadOnly) ;
|
/usr/sbin -> $(SEC_READONLY) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
################################################
|
################################################
|
||||||
|
@ -203,11 +204,11 @@ Temporary = +pugt ;
|
||||||
rulename = "Root Directory and Files",
|
rulename = "Root Directory and Files",
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
#/.dtprofile -> $(Dynamic) ;
|
#/.dtprofile -> $(SEC_DYNAMIC) ;
|
||||||
! /.netscape/cache ;
|
! /.netscape/cache ;
|
||||||
/.netscape/history.dat -> $(Dynamic) ;
|
/.netscape/history.dat -> $(SEC_DYNAMIC) ;
|
||||||
/.sh_history -> $(Dynamic) ;
|
/.sh_history -> $(SEC_DYNAMIC) ;
|
||||||
#/.Xauthority -> $(ReadOnly) ;
|
#/.Xauthority -> $(SEC_READONLY) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
################################################
|
################################################
|
||||||
|
@ -221,8 +222,8 @@ Temporary = +pugt ;
|
||||||
rulename = "Temporary Directories",
|
rulename = "Temporary Directories",
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/tmp -> $(Temporary) ;
|
/tmp -> $(SEC_TEMPORARY) ;
|
||||||
/var/tmp -> $(Temporary) ;
|
/var/tmp -> $(SEC_TEMPORARY) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
################################################
|
################################################
|
||||||
|
@ -251,31 +252,31 @@ Temporary = +pugt ;
|
||||||
rulename = "System and Boot Changes",
|
rulename = "System and Boot Changes",
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/etc/es/objrepos -> $(ReadOnly) -SHacm ;
|
/etc/es/objrepos -> $(SEC_READONLY) -SHacm ;
|
||||||
/etc/es/objrepos/HACMPresource -> $(ReadOnly) -SHCMcm ;
|
/etc/es/objrepos/HACMPresource -> $(SEC_READONLY) -SHCMcm ;
|
||||||
/etc/lpp/diagnostics/data -> $(ReadOnly) -SHCMacm ;
|
/etc/lpp/diagnostics/data -> $(SEC_READONLY) -SHCMacm ;
|
||||||
/etc/ntp.drift -> $(ReadOnly) -SHiacm ;
|
/etc/ntp.drift -> $(SEC_READONLY) -SHiacm ;
|
||||||
!/etc/objrepos ;
|
!/etc/objrepos ;
|
||||||
/etc/security -> $(ReadOnly) -SHacm ;
|
/etc/security -> $(SEC_READONLY) -SHacm ;
|
||||||
/usr/es/adm/cluster.log -> $(ReadOnly) -SHCMsbm ;
|
/usr/es/adm/cluster.log -> $(SEC_READONLY) -SHCMsbm ;
|
||||||
/usr/es/sbin/cluster/etc/objrepos/active -> $(ReadOnly) -SHim ;
|
/usr/es/sbin/cluster/etc/objrepos/active -> $(SEC_READONLY) -SHim ;
|
||||||
!/usr/etc/sbin/cluster/history ;
|
!/usr/etc/sbin/cluster/history ;
|
||||||
/usr/share/lib/objrepos -> $(ReadOnly) -m ;
|
/usr/share/lib/objrepos -> $(SEC_READONLY) -m ;
|
||||||
/usr/lib/objrepos -> $(ReadOnly) -m ;
|
/usr/lib/objrepos -> $(SEC_READONLY) -m ;
|
||||||
!/var/adm/SPlogs ;
|
!/var/adm/SPlogs ;
|
||||||
/var/ha/log -> $(Growing) -i ;
|
/var/ha/log -> $(SEC_GROWING) -i ;
|
||||||
!/var/adm ;
|
!/var/adm ;
|
||||||
!/var/ct ;
|
!/var/ct ;
|
||||||
|
|
||||||
#/var/backups -> $(Dynamic) -i ;
|
#/var/backups -> $(SEC_DYNAMIC) -i ;
|
||||||
#/var/db/host.random -> $(ReadOnly) -mCM ;
|
#/var/db/host.random -> $(SEC_READONLY) -mCM ;
|
||||||
#/var/db/locate.database -> $(ReadOnly) -misCM ;
|
#/var/db/locate.database -> $(SEC_READONLY) -misCM ;
|
||||||
#/var/cron -> $(Growing) -i ;
|
#/var/cron -> $(SEC_GROWING) -i ;
|
||||||
#/var/log -> $(Growing) -i ;
|
#/var/log -> $(SEC_GROWING) -i ;
|
||||||
#/var/run -> $(Dynamic) -i ;
|
#/var/run -> $(SEC_DYNAMIC) -i ;
|
||||||
#/var/mail -> $(Growing) ;
|
#/var/mail -> $(SEC_GROWING) ;
|
||||||
#/var/msgs/bounds -> $(ReadOnly) -smbCM ;
|
#/var/msgs/bounds -> $(SEC_READONLY) -smbCM ;
|
||||||
#/var/spool/clientmqueue -> $(Temporary) ;
|
#/var/spool/clientmqueue -> $(SEC_TEMPORARY) ;
|
||||||
#/var/spool/mqueue -> $(Temporary) ;
|
#/var/spool/mqueue -> $(SEC_TEMPORARY) ;
|
||||||
#!/var/tmp/vi.recover ; # perl script periodically removes this
|
#!/var/tmp/vi.recover ; # perl script periodically removes this
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,132 @@
|
||||||
|
###############################################################################
|
||||||
|
# ##
|
||||||
|
# Default Tripwire 2.4 Policy file for AROS ##
|
||||||
|
# ##
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# ##
|
||||||
|
# Global Variable Definitions ##
|
||||||
|
# ##
|
||||||
|
# These are defined at install time by the installation script. You may ##
|
||||||
|
# Manually edit these if you are using this file directly and not from the ##
|
||||||
|
# installation script itself. ##
|
||||||
|
# ##
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
@@section GLOBAL
|
||||||
|
TWROOT=;
|
||||||
|
TWBIN=;
|
||||||
|
TWPOL=;
|
||||||
|
TWDB=;
|
||||||
|
TWSKEY=;
|
||||||
|
TWLKEY=;
|
||||||
|
TWREPORT=;
|
||||||
|
HOSTNAME=;
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
# Predefined Variables #
|
||||||
|
##############################################################################
|
||||||
|
#
|
||||||
|
# Property Masks
|
||||||
|
#
|
||||||
|
# - ignore the following properties
|
||||||
|
# + check the following properties
|
||||||
|
#
|
||||||
|
# a access timestamp (mutually exclusive with +CMSH)
|
||||||
|
# b number of blocks allocated
|
||||||
|
# c inode creation/modification timestamp
|
||||||
|
# d ID of device on which inode resides
|
||||||
|
# g group id of owner
|
||||||
|
# i inode number
|
||||||
|
# l growing files (logfiles for example)
|
||||||
|
# m modification timestamp
|
||||||
|
# n number of links
|
||||||
|
# p permission and file mode bits
|
||||||
|
# r ID of device pointed to by inode (valid only for device objects)
|
||||||
|
# s file size
|
||||||
|
# t file type
|
||||||
|
# u user id of owner
|
||||||
|
#
|
||||||
|
# C CRC-32 hash
|
||||||
|
# H HAVAL hash
|
||||||
|
# M MD5 hash
|
||||||
|
# S SHA hash
|
||||||
|
#
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
SEC_DEVICE = +pugsdr-intlbamcCMSH ;
|
||||||
|
SEC_DYNAMIC = +pinugtd-srlbamcCMSH ;
|
||||||
|
SEC_GROWING = +pinugtdl-srbamcCMSH ;
|
||||||
|
SEC_IGNORE_ALL = -pinugtsdrlbamcCMSH ;
|
||||||
|
SEC_IGNORE_NONE = +pinugtsdrbamcCMSH-l ;
|
||||||
|
SEC_READONLY = +pinugtsdbmCM-rlacSH ;
|
||||||
|
SEC_TEMPORARY = +pugt ;
|
||||||
|
|
||||||
|
@@section FS
|
||||||
|
|
||||||
|
#########################################
|
||||||
|
# ##
|
||||||
|
# Tripwire Binaries and Data Files ##
|
||||||
|
# ##
|
||||||
|
#########################################
|
||||||
|
|
||||||
|
# Tripwire Binaries
|
||||||
|
(
|
||||||
|
rulename = "Tripwire Binaries",
|
||||||
|
)
|
||||||
|
{
|
||||||
|
$(TWBIN)/siggen -> $(SEC_READONLY) ;
|
||||||
|
$(TWBIN)/tripwire -> $(SEC_READONLY) ;
|
||||||
|
$(TWBIN)/twadmin -> $(SEC_READONLY) ;
|
||||||
|
$(TWBIN)/twprint -> $(SEC_READONLY) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Tripwire Data Files - Configuration Files, Policy Files, Keys, Reports, Databases
|
||||||
|
(
|
||||||
|
rulename = "Tripwire Data Files",
|
||||||
|
)
|
||||||
|
{
|
||||||
|
# NOTE: We remove the inode attribute because when Tripwire creates a backup,
|
||||||
|
# it does so by renaming the old file and creating a new one (which will
|
||||||
|
# have a new inode number). Inode is left turned on for keys, which shouldn't
|
||||||
|
# ever change.
|
||||||
|
|
||||||
|
# NOTE: The first integrity check triggers this rule and each integrity check
|
||||||
|
# afterward triggers this rule until a database update is run, since the
|
||||||
|
# database file does not exist before that point.
|
||||||
|
|
||||||
|
$(TWDB) -> $(SEC_DYNAMIC) -i ;
|
||||||
|
$(TWPOL)/tw.pol -> $(SEC_READONLY) -i ;
|
||||||
|
$(TWPOL)/tw.cfg -> $(SEC_READONLY) -i ;
|
||||||
|
$(TWLKEY)/$(HOSTNAME)-local.key -> $(SEC_READONLY) ;
|
||||||
|
$(TWSKEY)/site.key -> $(SEC_READONLY) ;
|
||||||
|
|
||||||
|
# don't scan the individual reports
|
||||||
|
$(TWREPORT) -> $(SEC_DYNAMIC) (recurse=0) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
(rulename="OS Files",)
|
||||||
|
{
|
||||||
|
AROS:System -> $(SEC_READONLY);
|
||||||
|
AROS:Devs -> $(SEC_READONLY);
|
||||||
|
AROS:Libs -> $(SEC_READONLY);
|
||||||
|
AROS:Tools-> $(SEC_READONLY);
|
||||||
|
AROS:Prefs -> $(SEC_READONLY);
|
||||||
|
AROS:Utilities -> $(SEC_READONLY);
|
||||||
|
AROS:WBStartup -> $(SEC_READONLY);
|
||||||
|
}
|
||||||
|
|
||||||
|
(rulename="Development Tools",)
|
||||||
|
{
|
||||||
|
Work:Development -> $(SEC_READONLY);
|
||||||
|
}
|
||||||
|
|
||||||
|
(rulename="Extras",)
|
||||||
|
{
|
||||||
|
Work:Extras -> $(SEC_READONLY);
|
||||||
|
}
|
|
@ -2,8 +2,8 @@
|
||||||
# ##
|
# ##
|
||||||
############################################################################## #
|
############################################################################## #
|
||||||
# # #
|
# # #
|
||||||
# Policy file for Bitrig 1.x # #
|
# Tripwire 2.4 policy for Bitrig # #
|
||||||
# (adapted from OpenBSD policy) # #
|
# updated March 2018 # #
|
||||||
# ##
|
# ##
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
|
@ -60,13 +60,13 @@ HOSTNAME=;
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
Device = +pugsdr-intlbamcCMSH ;
|
SEC_DEVICE = +pugsdr-intlbamcCMSH ;
|
||||||
Dynamic = +pinugtd-srlbamcCMSH ;
|
SEC_DYNAMIC = +pinugtd-srlbamcCMSH ;
|
||||||
Growing = +pinugtdl-srbamcCMSH ;
|
SEC_GROWING = +pinugtdl-srbamcCMSH ;
|
||||||
IgnoreAll = -pinugtsdrlbamcCMSH ;
|
SEC_IGNORE_ALL = -pinugtsdrlbamcCMSH ;
|
||||||
IgnoreNone = +pinugtsdrbamcCMSH-l ;
|
SEC_IGNORE_NONE = +pinugtsdrbamcCMSH-l ;
|
||||||
ReadOnly = +pinugtsdbmCM-rlacSH ;
|
SEC_READONLY = +pinugtsdbmCM-rlacSH ;
|
||||||
Temporary = +pugt ;
|
SEC_TEMPORARY = +pugt ;
|
||||||
|
|
||||||
@@section FS
|
@@section FS
|
||||||
|
|
||||||
|
@ -83,10 +83,10 @@ Temporary = +pugt ;
|
||||||
rulename = "Tripwire Binaries",
|
rulename = "Tripwire Binaries",
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
$(TWBIN)/siggen -> $(ReadOnly) ;
|
$(TWBIN)/siggen -> $(SEC_READONLY) ;
|
||||||
$(TWBIN)/tripwire -> $(ReadOnly) ;
|
$(TWBIN)/tripwire -> $(SEC_READONLY) ;
|
||||||
$(TWBIN)/twadmin -> $(ReadOnly) ;
|
$(TWBIN)/twadmin -> $(SEC_READONLY) ;
|
||||||
$(TWBIN)/twprint -> $(ReadOnly) ;
|
$(TWBIN)/twprint -> $(SEC_READONLY) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Tripwire Data Files - Configuration Files, Policy Files, Keys, Reports, Databases
|
# Tripwire Data Files - Configuration Files, Policy Files, Keys, Reports, Databases
|
||||||
|
@ -103,14 +103,14 @@ Temporary = +pugt ;
|
||||||
# afterward triggers this rule until a database update is run, since the
|
# afterward triggers this rule until a database update is run, since the
|
||||||
# database file does not exist before that point.
|
# database file does not exist before that point.
|
||||||
|
|
||||||
$(TWDB) -> $(Dynamic) -i ;
|
$(TWDB) -> $(SEC_DYNAMIC) -i ;
|
||||||
$(TWPOL)/tw.pol -> $(ReadOnly) -i ;
|
$(TWPOL)/tw.pol -> $(SEC_READONLY) -i ;
|
||||||
$(TWPOL)/tw.cfg -> $(ReadOnly) -i ;
|
$(TWPOL)/tw.cfg -> $(SEC_READONLY) -i ;
|
||||||
$(TWLKEY)/$(HOSTNAME)-local.key -> $(ReadOnly) ;
|
$(TWLKEY)/$(HOSTNAME)-local.key -> $(SEC_READONLY) ;
|
||||||
$(TWSKEY)/site.key -> $(ReadOnly) ;
|
$(TWSKEY)/site.key -> $(SEC_READONLY) ;
|
||||||
|
|
||||||
# don't scan the individual reports
|
# don't scan the individual reports
|
||||||
$(TWREPORT) -> $(Dynamic) (recurse=0) ;
|
$(TWREPORT) -> $(SEC_DYNAMIC) (recurse=0) ;
|
||||||
|
|
||||||
# In this configuration /usr/local is a symbolic link to /home/local.
|
# In this configuration /usr/local is a symbolic link to /home/local.
|
||||||
# We want to ignore the following directories since they are already
|
# We want to ignore the following directories since they are already
|
||||||
|
@ -131,9 +131,9 @@ Temporary = +pugt ;
|
||||||
rulename = "OS Boot and Configuration Files",
|
rulename = "OS Boot and Configuration Files",
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/boot -> $(ReadOnly) ;
|
/boot -> $(SEC_READONLY) ;
|
||||||
/bsd -> $(ReadOnly) ;
|
/bsd -> $(SEC_READONLY) ;
|
||||||
/etc -> $(IgnoreNone) -SHa ;
|
/etc -> $(SEC_IGNORE_NONE) -SHa ;
|
||||||
}
|
}
|
||||||
|
|
||||||
###################################################
|
###################################################
|
||||||
|
@ -147,13 +147,13 @@ Temporary = +pugt ;
|
||||||
rulename = "Mount Points",
|
rulename = "Mount Points",
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/ -> $(ReadOnly) ;
|
/ -> $(SEC_READONLY) ;
|
||||||
/cdrom -> $(Dynamic) ;
|
/cdrom -> $(SEC_DYNAMIC) ;
|
||||||
/floppy -> $(Dynamic) ;
|
/floppy -> $(SEC_DYNAMIC) ;
|
||||||
/home -> $(ReadOnly) ; # Modify as needed
|
/home -> $(SEC_READONLY) ; # Modify as needed
|
||||||
/mnt -> $(Dynamic) ;
|
/mnt -> $(SEC_DYNAMIC) ;
|
||||||
/usr -> $(ReadOnly) ;
|
/usr -> $(SEC_READONLY) ;
|
||||||
/var -> $(ReadOnly) ;
|
/var -> $(SEC_READONLY) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
###################################################
|
###################################################
|
||||||
|
@ -167,8 +167,8 @@ Temporary = +pugt ;
|
||||||
rulename = "Misc Top-Level Directories",
|
rulename = "Misc Top-Level Directories",
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/altroot -> $(Dynamic) ;
|
/altroot -> $(SEC_DYNAMIC) ;
|
||||||
/stand -> $(Dynamic) ;
|
/stand -> $(SEC_DYNAMIC) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
################################################
|
################################################
|
||||||
|
@ -182,10 +182,10 @@ Temporary = +pugt ;
|
||||||
rulename = "System Devices",
|
rulename = "System Devices",
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/dev -> $(Device) ;
|
/dev -> $(SEC_DEVICE) ;
|
||||||
/dev/fd -> $(Device) ;
|
/dev/fd -> $(SEC_DEVICE) ;
|
||||||
/var/cron/tabs/.sock -> $(Device) ;
|
/var/cron/tabs/.sock -> $(SEC_DEVICE) ;
|
||||||
/var/empty/dev/log -> $(Device) ;
|
/var/empty/dev/log -> $(SEC_DEVICE) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
################################################
|
################################################
|
||||||
|
@ -199,14 +199,14 @@ Temporary = +pugt ;
|
||||||
rulename = "OS Binaries and Libraries",
|
rulename = "OS Binaries and Libraries",
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/bin -> $(ReadOnly) ;
|
/bin -> $(SEC_READONLY) ;
|
||||||
/sbin -> $(ReadOnly) ;
|
/sbin -> $(SEC_READONLY) ;
|
||||||
/usr/bin -> $(ReadOnly) ;
|
/usr/bin -> $(SEC_READONLY) ;
|
||||||
/usr/lib -> $(ReadOnly) ;
|
/usr/lib -> $(SEC_READONLY) ;
|
||||||
/usr/libexec -> $(ReadOnly) ;
|
/usr/libexec -> $(SEC_READONLY) ;
|
||||||
/usr/sbin -> $(ReadOnly) ;
|
/usr/sbin -> $(SEC_READONLY) ;
|
||||||
/usr/X11R6/bin -> $(ReadOnly) ;
|
/usr/X11R6/bin -> $(SEC_READONLY) ;
|
||||||
/usr/X11R6/lib -> $(ReadOnly) ;
|
/usr/X11R6/lib -> $(SEC_READONLY) ;
|
||||||
}
|
}
|
||||||
################################################
|
################################################
|
||||||
# ##
|
# ##
|
||||||
|
@ -219,19 +219,19 @@ Temporary = +pugt ;
|
||||||
#OKrulename = "Usr Local Files",
|
#OKrulename = "Usr Local Files",
|
||||||
#OK)
|
#OK)
|
||||||
#OK{
|
#OK{
|
||||||
#OK/usr/local -> $(ReadOnly) ;
|
#OK/usr/local -> $(SEC_READONLY) ;
|
||||||
#OK/usr/local/bin -> $(ReadOnly) ;
|
#OK/usr/local/bin -> $(SEC_READONLY) ;
|
||||||
#OK/usr/local/doc -> $(ReadOnly) ;
|
#OK/usr/local/doc -> $(SEC_READONLY) ;
|
||||||
#OK/usr/local/etc -> $(ReadOnly) ;
|
#OK/usr/local/etc -> $(SEC_READONLY) ;
|
||||||
#OK/usr/local/include -> $(ReadOnly) ;
|
#OK/usr/local/include -> $(SEC_READONLY) ;
|
||||||
#OK/usr/local/info -> $(ReadOnly) ;
|
#OK/usr/local/info -> $(SEC_READONLY) ;
|
||||||
#OK/usr/local/lib -> $(ReadOnly) ;
|
#OK/usr/local/lib -> $(SEC_READONLY) ;
|
||||||
#OK/usr/local/libdata -> $(ReadOnly) ;
|
#OK/usr/local/libdata -> $(SEC_READONLY) ;
|
||||||
#OK/usr/local/libexec -> $(ReadOnly) ;
|
#OK/usr/local/libexec -> $(SEC_READONLY) ;
|
||||||
#OK/usr/local/man -> $(ReadOnly) ;
|
#OK/usr/local/man -> $(SEC_READONLY) ;
|
||||||
#OK/usr/local/sbin -> $(ReadOnly) ;
|
#OK/usr/local/sbin -> $(SEC_READONLY) ;
|
||||||
#OK/usr/local/share -> $(ReadOnly) ;
|
#OK/usr/local/share -> $(SEC_READONLY) ;
|
||||||
#OK/usr/local/src -> $(ReadOnly) ;
|
#OK/usr/local/src -> $(SEC_READONLY) ;
|
||||||
#OK}
|
#OK}
|
||||||
|
|
||||||
################################################
|
################################################
|
||||||
|
@ -245,9 +245,9 @@ Temporary = +pugt ;
|
||||||
rulename = "Root Directory and Files",
|
rulename = "Root Directory and Files",
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/root -> $(IgnoreNone) -SHa ;
|
/root -> $(SEC_IGNORE_NONE) -SHa ;
|
||||||
/root/.cshrc -> $(Dynamic) ;
|
/root/.cshrc -> $(SEC_DYNAMIC) ;
|
||||||
/root/.profile -> $(Dynamic) ;
|
/root/.profile -> $(SEC_DYNAMIC) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
################################################
|
################################################
|
||||||
|
@ -261,8 +261,8 @@ Temporary = +pugt ;
|
||||||
rulename = "Temporary Directories",
|
rulename = "Temporary Directories",
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/tmp -> $(Temporary) ;
|
/tmp -> $(SEC_TEMPORARY) ;
|
||||||
/var/tmp -> $(Temporary) ;
|
/var/tmp -> $(SEC_TEMPORARY) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
################################################
|
################################################
|
||||||
|
@ -276,15 +276,15 @@ Temporary = +pugt ;
|
||||||
rulename = "System and Boot Changes",
|
rulename = "System and Boot Changes",
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/var/backups -> $(Dynamic) -i ;
|
/var/backups -> $(SEC_DYNAMIC) -i ;
|
||||||
/var/db/host.random -> $(ReadOnly) -mCM ;
|
/var/db/host.random -> $(SEC_READONLY) -mCM ;
|
||||||
/var/cron -> $(Growing) -i ;
|
/var/cron -> $(SEC_GROWING) -i ;
|
||||||
/var/log -> $(Growing) -i ;
|
/var/log -> $(SEC_GROWING) -i ;
|
||||||
/var/run -> $(Dynamic) -i ;
|
/var/run -> $(SEC_DYNAMIC) -i ;
|
||||||
/var/mail -> $(Growing) ;
|
/var/mail -> $(SEC_GROWING) ;
|
||||||
/var/msgs/bounds -> $(ReadOnly) -smbCM ;
|
/var/msgs/bounds -> $(SEC_READONLY) -smbCM ;
|
||||||
/var/spool/clientmqueue -> $(Temporary) ;
|
/var/spool/clientmqueue -> $(SEC_TEMPORARY) ;
|
||||||
/var/spool/mqueue -> $(Temporary) ;
|
/var/spool/mqueue -> $(SEC_TEMPORARY) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
|
@ -0,0 +1,163 @@
|
||||||
|
###############################################################################
|
||||||
|
# ##
|
||||||
|
# Default Tripwire 2.4 Policy file for Cygwin ##
|
||||||
|
# ##
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# ##
|
||||||
|
# Global Variable Definitions ##
|
||||||
|
# ##
|
||||||
|
# These are defined at install time by the installation script. You may ##
|
||||||
|
# Manually edit these if you are using this file directly and not from the ##
|
||||||
|
# installation script itself. ##
|
||||||
|
# ##
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
@@section GLOBAL
|
||||||
|
TWROOT=;
|
||||||
|
TWBIN=;
|
||||||
|
TWPOL=;
|
||||||
|
TWDB=;
|
||||||
|
TWSKEY=;
|
||||||
|
TWLKEY=;
|
||||||
|
TWREPORT=;
|
||||||
|
HOSTNAME=;
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
# Predefined Variables #
|
||||||
|
##############################################################################
|
||||||
|
#
|
||||||
|
# Property Masks
|
||||||
|
#
|
||||||
|
# - ignore the following properties
|
||||||
|
# + check the following properties
|
||||||
|
#
|
||||||
|
# a access timestamp (mutually exclusive with +CMSH)
|
||||||
|
# b number of blocks allocated
|
||||||
|
# c inode creation/modification timestamp
|
||||||
|
# d ID of device on which inode resides
|
||||||
|
# g group id of owner
|
||||||
|
# i inode number
|
||||||
|
# l growing files (logfiles for example)
|
||||||
|
# m modification timestamp
|
||||||
|
# n number of links
|
||||||
|
# p permission and file mode bits
|
||||||
|
# r ID of device pointed to by inode (valid only for device objects)
|
||||||
|
# s file size
|
||||||
|
# t file type
|
||||||
|
# u user id of owner
|
||||||
|
#
|
||||||
|
# C CRC-32 hash
|
||||||
|
# H HAVAL hash
|
||||||
|
# M MD5 hash
|
||||||
|
# S SHA hash
|
||||||
|
#
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
SEC_DEVICE = +pugsdr-intlbamcCMSH ;
|
||||||
|
SEC_DYNAMIC = +pinugtd-srlbamcCMSH ;
|
||||||
|
SEC_GROWING = +pinugtdl-srbamcCMSH ;
|
||||||
|
SEC_IGNORE_ALL = -pinugtsdrlbamcCMSH ;
|
||||||
|
SEC_IGNORE_NONE = +pinugtsdrbamcCMSH-l ;
|
||||||
|
SEC_READONLY = +pinugtsdbmCM-rlacSH ;
|
||||||
|
SEC_TEMPORARY = +pugt ;
|
||||||
|
|
||||||
|
@@section FS
|
||||||
|
|
||||||
|
#########################################
|
||||||
|
# ##
|
||||||
|
# Tripwire Binaries and Data Files ##
|
||||||
|
# ##
|
||||||
|
#########################################
|
||||||
|
|
||||||
|
# Tripwire Binaries
|
||||||
|
(
|
||||||
|
rulename = "Tripwire Binaries",
|
||||||
|
)
|
||||||
|
{
|
||||||
|
$(TWBIN)/siggen -> $(SEC_READONLY) ;
|
||||||
|
$(TWBIN)/tripwire -> $(SEC_READONLY) ;
|
||||||
|
$(TWBIN)/twadmin -> $(SEC_READONLY) ;
|
||||||
|
$(TWBIN)/twprint -> $(SEC_READONLY) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Tripwire Data Files - Configuration Files, Policy Files, Keys, Reports, Databases
|
||||||
|
(
|
||||||
|
rulename = "Tripwire Data Files",
|
||||||
|
)
|
||||||
|
{
|
||||||
|
# NOTE: We remove the inode attribute because when Tripwire creates a backup,
|
||||||
|
# it does so by renaming the old file and creating a new one (which will
|
||||||
|
# have a new inode number). Inode is left turned on for keys, which shouldn't
|
||||||
|
# ever change.
|
||||||
|
|
||||||
|
# NOTE: The first integrity check triggers this rule and each integrity check
|
||||||
|
# afterward triggers this rule until a database update is run, since the
|
||||||
|
# database file does not exist before that point.
|
||||||
|
|
||||||
|
$(TWDB) -> $(SEC_DYNAMIC) -i ;
|
||||||
|
$(TWPOL)/tw.pol -> $(SEC_READONLY) -i ;
|
||||||
|
$(TWPOL)/tw.cfg -> $(SEC_READONLY) -i ;
|
||||||
|
$(TWLKEY)/$(HOSTNAME)-local.key -> $(SEC_READONLY) ;
|
||||||
|
$(TWSKEY)/site.key -> $(SEC_READONLY) ;
|
||||||
|
|
||||||
|
# don't scan the individual reports
|
||||||
|
$(TWREPORT) -> $(SEC_DYNAMIC) (recurse=0) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
(rulename="Binary files",)
|
||||||
|
{
|
||||||
|
/bin -> $(SEC_READONLY) -a;
|
||||||
|
/usr/bin -> $(SEC_READONLY) -a;
|
||||||
|
/usr/local/bin -> $(SEC_READONLY) -a;
|
||||||
|
}
|
||||||
|
|
||||||
|
(rulename="Development",)
|
||||||
|
{
|
||||||
|
/usr/x86_64-pc-cygwin -> $(SEC_READONLY) -a;
|
||||||
|
}
|
||||||
|
|
||||||
|
(rulename="Libexec",)
|
||||||
|
{
|
||||||
|
/usr/libexec -> $(SEC_READONLY) -a;
|
||||||
|
}
|
||||||
|
|
||||||
|
(rulename="Admin binaries",)
|
||||||
|
{
|
||||||
|
/sbin -> $(SEC_READONLY) -a;
|
||||||
|
/usr/sbin -> $(SEC_READONLY) -a;
|
||||||
|
}
|
||||||
|
|
||||||
|
(rulename="Libraries",)
|
||||||
|
{
|
||||||
|
/lib -> $(SEC_READONLY) -a;
|
||||||
|
/usr/lib -> $(SEC_READONLY) -a;
|
||||||
|
/usr/local/lib -> $(SEC_READONLY) -a;
|
||||||
|
}
|
||||||
|
|
||||||
|
(rulename="Etc",)
|
||||||
|
{
|
||||||
|
/etc -> $(SEC_READONLY) -a;
|
||||||
|
/usr/local/etc -> $(SEC_READONLY) -a;
|
||||||
|
}
|
||||||
|
|
||||||
|
(rulename="Dev",)
|
||||||
|
{
|
||||||
|
/dev -> $(SEC_DEVICE);
|
||||||
|
}
|
||||||
|
|
||||||
|
(rulename="Tmp",)
|
||||||
|
{
|
||||||
|
/tmp -> $(SEC_TEMPORARY);
|
||||||
|
/var/tmp -> $(SEC_TEMPORARY);
|
||||||
|
/usr/tmp -> $(SEC_TEMPORARY);
|
||||||
|
}
|
||||||
|
|
||||||
|
(rulename="Log",)
|
||||||
|
{
|
||||||
|
/var/log -> $(SEC_GROWING);
|
||||||
|
}
|
|
@ -2,8 +2,8 @@
|
||||||
# ##
|
# ##
|
||||||
############################################################################## #
|
############################################################################## #
|
||||||
# # #
|
# # #
|
||||||
# Policy file for Mac OS X # #
|
# Tripwire 2.4 policy for Mac OS X # #
|
||||||
# September 3, 2003 # #
|
# updated March 2018 # #
|
||||||
# ##
|
# ##
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ TWDB=;
|
||||||
TWSKEY=;
|
TWSKEY=;
|
||||||
TWLKEY=;
|
TWLKEY=;
|
||||||
TWREPORT=;
|
TWREPORT=;
|
||||||
#USER1=frodo ;
|
HOSTNAME=;
|
||||||
|
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
@ -67,9 +67,10 @@ SEC_DYNAMIC = +pinugt-dsrlbamcCMSH ;
|
||||||
SEC_READONLY = +pinugtsbmCM-drlacSH ;
|
SEC_READONLY = +pinugtsbmCM-drlacSH ;
|
||||||
SEC_GROWING = +pinugtl-dsrbamcCMSH ;
|
SEC_GROWING = +pinugtl-dsrbamcCMSH ;
|
||||||
|
|
||||||
IgnoreAll = -pinugtsdrlbamcCMSH ;
|
SEC_IGNORE_ALL = -pinugtsdrlbamcCMSH ;
|
||||||
IgnoreNone = +pinugtsdrbamcCMSH-l ;
|
SEC_IGNORE_NONE = +pinugtsdrbamcCMSH-l ;
|
||||||
Temporary = +pugt ;
|
SEC_TEMPORARY = +pugt ;
|
||||||
|
|
||||||
|
|
||||||
@@section FS
|
@@section FS
|
||||||
|
|
||||||
|
@ -109,7 +110,7 @@ Temporary = +pugt ;
|
||||||
$(TWDB) -> $(SEC_DYNAMIC) -i ;
|
$(TWDB) -> $(SEC_DYNAMIC) -i ;
|
||||||
$(TWPOL)/tw.pol -> $(SEC_READONLY) -i ;
|
$(TWPOL)/tw.pol -> $(SEC_READONLY) -i ;
|
||||||
$(TWPOL)/tw.cfg -> $(SEC_READONLY) -i ;
|
$(TWPOL)/tw.cfg -> $(SEC_READONLY) -i ;
|
||||||
$(TWLKEY)/local.key -> $(SEC_READONLY) ;
|
$(TWLKEY)/$(HOSTNAME)-local.key -> $(SEC_READONLY) ;
|
||||||
$(TWSKEY)/site.key -> $(SEC_READONLY) ;
|
$(TWSKEY)/site.key -> $(SEC_READONLY) ;
|
||||||
|
|
||||||
# don't scan the individual reports
|
# don't scan the individual reports
|
||||||
|
@ -129,14 +130,14 @@ Temporary = +pugt ;
|
||||||
rulename = "OS Boot and Configuration Files", severity=100
|
rulename = "OS Boot and Configuration Files", severity=100
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/mach.sym -> $(SEC_READONLY)-im ;
|
#/mach.sym -> $(SEC_READONLY)-im ;
|
||||||
/mach_kernel -> $(SEC_READONLY) ;
|
/mach_kernel -> $(SEC_READONLY) ;
|
||||||
/private/etc -> $(SEC_READONLY)-m ;
|
/private/etc -> $(SEC_READONLY)-m ;
|
||||||
|
|
||||||
#/private/etc/appletalk.cfg -> $(SEC_READONLY)-im ;
|
#/private/etc/appletalk.cfg -> $(SEC_READONLY)-im ;
|
||||||
#/private/etc/appletalk.nvram.en0 -> $(SEC_DYNAMIC) ;
|
#/private/etc/appletalk.nvram.en0 -> $(SEC_DYNAMIC) ;
|
||||||
/private/etc/cups/certs -> $(SEC_DYNAMIC) -i(recurse=0) ;
|
/private/etc/cups/certs -> $(SEC_DYNAMIC) -i(recurse=0) ;
|
||||||
/private/etc/smb.conf -> $(SEC_READONLY)-im ;
|
#/private/etc/smb.conf -> $(SEC_READONLY)-im ;
|
||||||
|
|
||||||
/Library -> $(SEC_READONLY) ;
|
/Library -> $(SEC_READONLY) ;
|
||||||
/System -> $(SEC_READONLY) ;
|
/System -> $(SEC_READONLY) ;
|
||||||
|
@ -182,8 +183,6 @@ Temporary = +pugt ;
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/dev -> $(SEC_DEVICE)(recurse=0) ;
|
/dev -> $(SEC_DEVICE)(recurse=0) ;
|
||||||
#/private/var/cron/tabs/.sock -> $(SEC_DEVICE) ;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
################################################
|
################################################
|
||||||
|
@ -203,8 +202,8 @@ Temporary = +pugt ;
|
||||||
/usr/lib -> $(SEC_READONLY) ;
|
/usr/lib -> $(SEC_READONLY) ;
|
||||||
/usr/libexec -> $(SEC_READONLY) ;
|
/usr/libexec -> $(SEC_READONLY) ;
|
||||||
/usr/sbin -> $(SEC_READONLY) ;
|
/usr/sbin -> $(SEC_READONLY) ;
|
||||||
#/usr/X11R6 -> $(SEC_READONLY)(recurse=2) ; # May not be present
|
/usr/X11 -> $(SEC_READONLY)(recurse=2) ; # May not be present
|
||||||
#/usr/X11R6/man -> $(SEC_DYNAMIC)-i(recurse=1) ; # May not be present
|
#/usr/X11/man -> $(SEC_DYNAMIC)-i(recurse=1) ; # May not be present
|
||||||
/usr/share -> $(SEC_READONLY) ;
|
/usr/share -> $(SEC_READONLY) ;
|
||||||
/usr/share/man -> $(SEC_DYNAMIC)-i(recurse=1) ;
|
/usr/share/man -> $(SEC_DYNAMIC)-i(recurse=1) ;
|
||||||
|
|
||||||
|
@ -223,12 +222,6 @@ Temporary = +pugt ;
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/Applications -> $(SEC_READONLY)-im(recurse=2) ;
|
/Applications -> $(SEC_READONLY)-im(recurse=2) ;
|
||||||
"/Applications (Mac OS 9)" -> $(SEC_READONLY) ;
|
|
||||||
|
|
||||||
|
|
||||||
!/Applications/Internet/P2P/Downloads ;
|
|
||||||
!/Applications/Games/"Warcraft III Folder"/Save ;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
################################################
|
################################################
|
||||||
|
@ -243,10 +236,19 @@ Temporary = +pugt ;
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/usr/local -> $(SEC_READONLY) ;
|
/usr/local -> $(SEC_READONLY) ;
|
||||||
#/usr/local/bin -> $(SEC_READONLY) ;
|
/usr/local/sbin -> $(SEC_READONLY) ;
|
||||||
|
/usr/local/bin -> $(SEC_READONLY) ;
|
||||||
|
/usr/local/include -> $(SEC_READONLY) ;
|
||||||
|
/usr/local/opt -> $(SEC_READONLY) ;
|
||||||
|
/usr/local/libexec -> $(SEC_READONLY) ;
|
||||||
|
/usr/local/lib -> $(SEC_READONLY) ;
|
||||||
/usr/local/etc -> $(SEC_READONLY) ;
|
/usr/local/etc -> $(SEC_READONLY) ;
|
||||||
#/usr/local/sbin -> $(SEC_READONLY) ;
|
/usr/local/share -> $(SEC_READONLY) ;
|
||||||
#/usr/local/share -> $(SEC_READONLY) ;
|
/usr/local/man -> $(SEC_READONLY) ;
|
||||||
|
/usr/local/Frameworks -> $(SEC_READONLY) ;
|
||||||
|
# Homebrew
|
||||||
|
/usr/local/.git -> $(SEC_READONLY) ;
|
||||||
|
/usr/local/Cellar -> $(SEC_READONLY) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -263,24 +265,26 @@ Temporary = +pugt ;
|
||||||
{
|
{
|
||||||
/private/tmp -> $(SEC_DYNAMIC)-in(recurse=0) ;
|
/private/tmp -> $(SEC_DYNAMIC)-in(recurse=0) ;
|
||||||
|
|
||||||
|
/private/tftpboot -> $(SEC_READONLY)-i ;
|
||||||
|
|
||||||
/private/var -> $(SEC_READONLY)-i ;
|
/private/var -> $(SEC_READONLY)-i ;
|
||||||
/private/var/backups -> $(SEC_READONLY)-imc(severity=100) ;
|
/private/var/backups -> $(SEC_READONLY)-imc(severity=100) ;
|
||||||
#/private/var/backups/local.nidump -> $(SEC_DYNAMIC) -i(severity=100) ;
|
#/private/var/backups/local.nidump -> $(SEC_DYNAMIC) -i(severity=100) ;
|
||||||
#/private/var/cron -> $(SEC_DYNAMIC) -i ;
|
#/private/var/cron -> $(SEC_DYNAMIC) -i ;
|
||||||
/private/var/db -> $(SEC_READONLY)-im ;
|
/private/var/db -> $(SEC_READONLY)-im ;
|
||||||
/private/var/db/BootCache.playlist -> $(SEC_DYNAMIC) -i ;
|
/private/var/db/BootCache.playlist -> $(SEC_DYNAMIC) -i ;
|
||||||
/private/var/db/netinfo/local.nidb/Store.384 -> $(SEC_READONLY)-imc(severity=100) ;
|
#/private/var/db/netinfo/local.nidb/Store.384 -> $(SEC_READONLY)-imc(severity=100) ;
|
||||||
#/private/var/db/netinfo/local.nidb/Store.672 -> $(SEC_READONLY)-imc(severity=100) ;
|
#/private/var/db/netinfo/local.nidb/Store.672 -> $(SEC_READONLY)-imc(severity=100) ;
|
||||||
/private/var/db/prebindOnDemandBadFiles -> $(SEC_DYNAMIC) -i ;
|
#/private/var/db/prebindOnDemandBadFiles -> $(SEC_DYNAMIC) -i ;
|
||||||
/private/var/log -> $(SEC_DYNAMIC) -i ;
|
/private/var/log -> $(SEC_DYNAMIC) -i ;
|
||||||
#/private/var/mail -> $(SEC_DYNAMIC) ;
|
#/private/var/mail -> $(SEC_DYNAMIC) ;
|
||||||
/private/var/msgs/bounds -> $(SEC_READONLY)-smbCM ;
|
/private/var/msgs/bounds -> $(SEC_READONLY)-smbCM ;
|
||||||
/private/var/root/Library/Caches -> $(SEC_DYNAMIC) -i ;
|
/private/var/root/Library/Caches -> $(SEC_DYNAMIC) -i ;
|
||||||
/private/var/run -> $(SEC_DYNAMIC) -i(rulename="Running Services") ;
|
/private/var/run -> $(SEC_DYNAMIC) -i(rulename="Running Services") ;
|
||||||
#/private/var/slp.regfile -> $(SEC_READONLY)-im ;
|
#/private/var/slp.regfile -> $(SEC_READONLY)-im ;
|
||||||
/private/var/spool/clientmqueue -> $(SEC_DYNAMIC)(recurse=0) ;
|
#/private/var/spool/clientmqueue -> $(SEC_DYNAMIC)(recurse=0) ;
|
||||||
/private/var/spool/mqueue -> $(SEC_DYNAMIC)(recurse=0) ;
|
/private/var/spool/mqueue -> $(SEC_DYNAMIC)(recurse=0) ;
|
||||||
/private/var/spool/lock -> $(SEC_DYNAMIC) -i(recurse=1) ;
|
#/private/var/spool/lock -> $(SEC_DYNAMIC) -i(recurse=1) ;
|
||||||
/private/var/spool/cups -> $(SEC_DYNAMIC) -i(recurse=0) ;
|
/private/var/spool/cups -> $(SEC_DYNAMIC) -i(recurse=0) ;
|
||||||
/private/var/tmp -> $(SEC_DYNAMIC) -i(recurse=0) ;
|
/private/var/tmp -> $(SEC_DYNAMIC) -i(recurse=0) ;
|
||||||
/private/var/vm -> $(SEC_DYNAMIC)(recurse=0) ;
|
/private/var/vm -> $(SEC_DYNAMIC)(recurse=0) ;
|
||||||
|
@ -294,37 +298,19 @@ Temporary = +pugt ;
|
||||||
!/private/var/db/dhcpd_leases ;
|
!/private/var/db/dhcpd_leases ;
|
||||||
!/private/var/db/locate.database ;
|
!/private/var/db/locate.database ;
|
||||||
!/private/var/db/SystemEntropyCache ;
|
!/private/var/db/SystemEntropyCache ;
|
||||||
|
!/private/var/db/mds/messages/se_SecurityMessages ;
|
||||||
!/private/var/db/samba/secrets.tdb ;
|
!/private/var/db/samba/secrets.tdb ;
|
||||||
|
!/private/var/db/ntp.drift ;
|
||||||
|
!/private/var/folders ;
|
||||||
|
!/private/var/vm/sleepimage ;
|
||||||
|
!/private/var/vm/swap0 ;
|
||||||
|
!/private/var/vm/swap[1-9][0-9]* ;
|
||||||
|
# Sophos
|
||||||
|
!/Library/Caches/com.sophos.sau ;
|
||||||
|
!/Library/Caches/com.sophos.sxld ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
################################################
|
|
||||||
# ##
|
|
||||||
################################################ #
|
|
||||||
# # #
|
|
||||||
# Classic Environment # #
|
|
||||||
# ##
|
|
||||||
################################################
|
|
||||||
(
|
|
||||||
rulename = "Classic Environment", severity=100
|
|
||||||
)
|
|
||||||
{
|
|
||||||
|
|
||||||
/"System Folder" -> $(SEC_READONLY) ;
|
|
||||||
/"System Folder"/Preferences -> $(SEC_DYNAMIC)-i(recurse=0) ;
|
|
||||||
/"System Folder"/Extensions -> $(SEC_READONLY)-im ;
|
|
||||||
/"System Folder/Apple Menu Items" -> $(SEC_READONLY)-im(recurse=0) ;
|
|
||||||
/"System Folder"/Clipboard -> $(SEC_DYNAMIC) ;
|
|
||||||
|
|
||||||
!/"System Folder"/VolumeNameIconPict ;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
###################################################
|
###################################################
|
||||||
# ##
|
# ##
|
||||||
################################################### #
|
################################################### #
|
||||||
|
@ -375,7 +361,3 @@ Temporary = +pugt ;
|
||||||
#!"/Users/$(USER1)/.lpoptions" ;
|
#!"/Users/$(USER1)/.lpoptions" ;
|
||||||
#!"/Users/$(USER1)/.Trash" ;
|
#!"/Users/$(USER1)/.Trash" ;
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
|
||||||
# JTI
|
|
||||||
#
|
|
||||||
|
|
|
@ -54,16 +54,24 @@ TWREPORT=;
|
||||||
HOSTNAME=;
|
HOSTNAME=;
|
||||||
|
|
||||||
@@section FS
|
@@section FS
|
||||||
SEC_CRIT = $(IgnoreNone)-SHa ; # Critical files that cannot change
|
SEC_DEVICE = +pugsdr-intlbamcCMSH ;
|
||||||
SEC_SUID = $(IgnoreNone)-SHa ; # Binaries with the SUID or SGID flags set
|
SEC_DYNAMIC = +pinugtd-srlbamcCMSH ;
|
||||||
SEC_BIN = $(ReadOnly) ; # Binaries that should not change
|
SEC_GROWING = +pinugtdl-srbamcCMSH ;
|
||||||
SEC_CONFIG = $(Dynamic) ; # Config files that are changed infrequently but accessed often
|
SEC_IGNORE_ALL = -pinugtsdrlbamcCMSH ;
|
||||||
SEC_TTY = $(Dynamic)-ugp ; # Tty files that change ownership at login
|
SEC_IGNORE_NONE = +pinugtsdrbamcCMSH-l ;
|
||||||
SEC_LOG = $(Growing) ; # Files that grow, but that should never change ownership
|
SEC_READONLY = +pinugtsdbmCM-rlacSH ;
|
||||||
SEC_INVARIANT = +tpug ; # Directories that should never change permission or ownership
|
SEC_TEMPORARY = +pugt ;
|
||||||
SIG_LOW = 33 ; # Non-critical files that are of minimal security impact
|
|
||||||
SIG_MED = 66 ; # Non-critical files that are of significant security impact
|
SEC_CRIT = $(SEC_IGNORE_NONE)-SHa ; # Critical files that cannot change
|
||||||
SIG_HI = 100 ; # Critical files that are significant points of vulnerability
|
SEC_SUID = $(SEC_IGNORE_NONE)-SHa ; # Binaries with the SUID or SGID flags set
|
||||||
|
SEC_BIN = $(SEC_READONLY) ; # Binaries that should not change
|
||||||
|
SEC_CONFIG = $(SEC_DYNAMIC) ; # Config files that are changed infrequently but accessed often
|
||||||
|
SEC_TTY = $(SEC_DYNAMIC)-ugp ; # Tty files that change ownership at login
|
||||||
|
SEC_LOG = $(SEC_GROWING) ; # Files that grow, but that should never change ownership
|
||||||
|
SEC_INVARIANT = $(SEC_TEMPORARY) ; # Directories that should never change permission or ownership
|
||||||
|
SIG_LOW = 33 ; # Non-critical files that are of minimal security impact
|
||||||
|
SIG_MED = 66 ; # Non-critical files that are of significant security impact
|
||||||
|
SIG_HI = 100 ; # Critical files that are significant points of vulnerability
|
||||||
|
|
||||||
|
|
||||||
# Tripwire Binaries
|
# Tripwire Binaries
|
||||||
|
@ -630,7 +638,7 @@ SIG_HI = 100 ; # Critical files that are significant point
|
||||||
|
|
||||||
#=============================================================================
|
#=============================================================================
|
||||||
#
|
#
|
||||||
# Copyright 2000-2017 Tripwire, Inc. Tripwire is a registered trademark of Tripwire,
|
# Copyright 2000-2018 Tripwire, Inc. Tripwire is a registered trademark of Tripwire,
|
||||||
# Inc. in the United States and other countries. All rights reserved.
|
# Inc. in the United States and other countries. All rights reserved.
|
||||||
#
|
#
|
||||||
# FreeBSD is a registered trademark of the FreeBSD Project Inc.
|
# FreeBSD is a registered trademark of the FreeBSD Project Inc.
|
||||||
|
|
|
@ -53,16 +53,24 @@ TWREPORT=;
|
||||||
HOSTNAME=;
|
HOSTNAME=;
|
||||||
|
|
||||||
@@section FS
|
@@section FS
|
||||||
SEC_CRIT = $(IgnoreNone)-SHa ; # Critical files that cannot change
|
SEC_DEVICE = +pugsdr-intlbamcCMSH ;
|
||||||
SEC_SUID = $(IgnoreNone)-SHa ; # Binaries with the SUID or SGID flags set
|
SEC_DYNAMIC = +pinugtd-srlbamcCMSH ;
|
||||||
SEC_BIN = $(ReadOnly) ; # Binaries that should not change
|
SEC_GROWING = +pinugtdl-srbamcCMSH ;
|
||||||
SEC_CONFIG = $(Dynamic) ; # Config files that are changed infrequently but accessed often
|
SEC_IGNORE_ALL = -pinugtsdrlbamcCMSH ;
|
||||||
SEC_TTY = $(Dynamic)-ugp ; # Tty files that change ownership at login
|
SEC_IGNORE_NONE = +pinugtsdrbamcCMSH-l ;
|
||||||
SEC_LOG = $(Growing) ; # Files that grow, but that should never change ownership
|
SEC_READONLY = +pinugtsdbmCM-rlacSH ;
|
||||||
SEC_INVARIANT = +tpug ; # Directories that should never change permission or ownership
|
SEC_TEMPORARY = +pugt ;
|
||||||
SIG_LOW = 33 ; # Non-critical files that are of minimal security impact
|
|
||||||
SIG_MED = 66 ; # Non-critical files that are of significant security impact
|
SEC_CRIT = $(SEC_IGNORE_NONE)-SHa ; # Critical files that cannot change
|
||||||
SIG_HI = 100 ; # Critical files that are significant points of vulnerability
|
SEC_SUID = $(SEC_IGNORE_NONE)-SHa ; # Binaries with the SUID or SGID flags set
|
||||||
|
SEC_BIN = $(SEC_READONLY) ; # Binaries that should not change
|
||||||
|
SEC_CONFIG = $(SEC_DYNAMIC) ; # Config files that are changed infrequently but accessed often
|
||||||
|
SEC_TTY = $(SEC_DYNAMIC)-ugp ; # Tty files that change ownership at login
|
||||||
|
SEC_LOG = $(SEC_GROWING) ; # Files that grow, but that should never change ownership
|
||||||
|
SEC_INVARIANT = $(SEC_TEMPORARY) ; # Directories that should never change permission or ownership
|
||||||
|
SIG_LOW = 33 ; # Non-critical files that are of minimal security impact
|
||||||
|
SIG_MED = 66 ; # Non-critical files that are of significant security impact
|
||||||
|
SIG_HI = 100 ; # Critical files that are significant points of vulnerability
|
||||||
|
|
||||||
|
|
||||||
# Tripwire Binaries
|
# Tripwire Binaries
|
||||||
|
@ -629,7 +637,7 @@ SIG_HI = 100 ; # Critical files that are significant point
|
||||||
|
|
||||||
#=============================================================================
|
#=============================================================================
|
||||||
#
|
#
|
||||||
# Copyright 2000-2017 Tripwire, Inc. Tripwire is a registered trademark of Tripwire,
|
# Copyright 2000-2018 Tripwire, Inc. Tripwire is a registered trademark of Tripwire,
|
||||||
# Inc. in the United States and other countries. All rights reserved.
|
# Inc. in the United States and other countries. All rights reserved.
|
||||||
#
|
#
|
||||||
# FreeBSD is a registered trademark of the FreeBSD Project Inc.
|
# FreeBSD is a registered trademark of the FreeBSD Project Inc.
|
||||||
|
|
|
@ -65,15 +65,24 @@ TWREPORT=;
|
||||||
HOSTNAME=;
|
HOSTNAME=;
|
||||||
|
|
||||||
@@section FS
|
@@section FS
|
||||||
SEC_CRIT = $(IgnoreNone)-SHa ; # Critical files that cannot change
|
SEC_DEVICE = +pugsdr-intlbamcCMSH ;
|
||||||
SEC_SUID = $(IgnoreNone)-SHa ; # Binaries with the SUID or SGID flags set
|
SEC_DYNAMIC = +pinugtd-srlbamcCMSH ;
|
||||||
SEC_BIN = $(ReadOnly) ; # Binaries that should not change
|
SEC_GROWING = +pinugtdl-srbamcCMSH ;
|
||||||
SEC_CONFIG = $(Dynamic) ; # Config files that are changed infrequently but accessed often
|
SEC_IGNORE_ALL = -pinugtsdrlbamcCMSH ;
|
||||||
SEC_LOG = $(Growing) ; # Files that grow, but that should never change ownership
|
SEC_IGNORE_NONE = +pinugtsdrbamcCMSH-l ;
|
||||||
SEC_INVARIANT = +tpug ; # Directories that should never change permission or ownership
|
SEC_READONLY = +pinugtsdbmCM-rlacSH ;
|
||||||
SIG_LOW = 33 ; # Non-critical files that are of minimal security impact
|
SEC_TEMPORARY = +pugt ;
|
||||||
SIG_MED = 66 ; # Non-critical files that are of significant security impact
|
|
||||||
SIG_HI = 100 ; # Critical files that are significant points of vulnerability
|
SEC_CRIT = $(SEC_IGNORE_NONE)-SHa ; # Critical files that cannot change
|
||||||
|
SEC_SUID = $(SEC_IGNORE_NONE)-SHa ; # Binaries with the SUID or SGID flags set
|
||||||
|
SEC_BIN = $(SEC_READONLY) ; # Binaries that should not change
|
||||||
|
SEC_CONFIG = $(SEC_DYNAMIC) ; # Config files that are changed infrequently but accessed often
|
||||||
|
SEC_TTY = $(SEC_DYNAMIC)-ugp ; # Tty files that change ownership at login
|
||||||
|
SEC_LOG = $(SEC_GROWING) ; # Files that grow, but that should never change ownership
|
||||||
|
SEC_INVARIANT = $(SEC_TEMPORARY) ; # Directories that should never change permission or ownership
|
||||||
|
SIG_LOW = 33 ; # Non-critical files that are of minimal security impact
|
||||||
|
SIG_MED = 66 ; # Non-critical files that are of significant security impact
|
||||||
|
SIG_HI = 100 ; # Critical files that are significant points of vulnerability
|
||||||
|
|
||||||
|
|
||||||
# Tripwire Binaries
|
# Tripwire Binaries
|
||||||
|
@ -114,56 +123,6 @@ SIG_HI = 100 ; # Critical files that are significant point
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Tripwire HQ Connector Binaries
|
|
||||||
#(
|
|
||||||
# rulename = "Tripwire HQ Connector Binaries",
|
|
||||||
# severity = $(SIG_HI)
|
|
||||||
#)
|
|
||||||
#{
|
|
||||||
# $(TWBIN)/hqagent -> $(SEC_BIN) ;
|
|
||||||
#}
|
|
||||||
#
|
|
||||||
# Tripwire HQ Connector - Configuration Files, Keys, and Logs
|
|
||||||
|
|
||||||
##############################################################################
|
|
||||||
# ##
|
|
||||||
############################################################################## #
|
|
||||||
# # #
|
|
||||||
# Note: File locations here are different than in a stock HQ Connector # #
|
|
||||||
# installation. This is because Tripwire 2.3 uses a different path # #
|
|
||||||
# structure than Tripwire 2.2.1. # #
|
|
||||||
# # #
|
|
||||||
# You may need to update your HQ Agent configuation file (or this policy # #
|
|
||||||
# file) to correct the paths. We have attempted to support the FHS standard # #
|
|
||||||
# here by placing the HQ Agent files similarly to the way Tripwire 2.3 # #
|
|
||||||
# places them. # #
|
|
||||||
# ##
|
|
||||||
##############################################################################
|
|
||||||
|
|
||||||
#(
|
|
||||||
# rulename = "Tripwire HQ Connector Data Files",
|
|
||||||
# severity = $(SIG_HI)
|
|
||||||
#)
|
|
||||||
#{
|
|
||||||
# #############################################################################
|
|
||||||
# ##############################################################################
|
|
||||||
# # NOTE: Removing the inode attribute because when Tripwire creates a backup ##
|
|
||||||
# # it does so by renaming the old file and creating a new one (which will ##
|
|
||||||
# # have a new inode number). Leaving inode turned on for keys, which ##
|
|
||||||
# # shouldn't ever change. ##
|
|
||||||
# #############################################################################
|
|
||||||
#
|
|
||||||
# $(TWBIN)/agent.cfg -> $(SEC_BIN) -i ;
|
|
||||||
# $(TWLKEY)/authentication.key -> $(SEC_BIN) ;
|
|
||||||
# $(TWDB)/tasks.dat -> $(SEC_CONFIG) ;
|
|
||||||
# $(TWDB)/schedule.dat -> $(SEC_CONFIG) ;
|
|
||||||
#
|
|
||||||
# # Uncomment if you have agent logging enabled.
|
|
||||||
# #/var/log/tripwire/agent.log -> $(SEC_LOG) ;
|
|
||||||
#}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Commonly accessed directories that should remain static with regards to owner and group
|
# Commonly accessed directories that should remain static with regards to owner and group
|
||||||
(
|
(
|
||||||
rulename = "Invariant Directories",
|
rulename = "Invariant Directories",
|
||||||
|
@ -1078,7 +1037,7 @@ SIG_HI = 100 ; # Critical files that are significant point
|
||||||
|
|
||||||
#=============================================================================
|
#=============================================================================
|
||||||
#
|
#
|
||||||
# Copyright 2000-2017 Tripwire, Inc. Tripwire is a registered trademark of Tripwire,
|
# Copyright 2000-2018 Tripwire, Inc. Tripwire is a registered trademark of Tripwire,
|
||||||
# Inc. in the United States and other countries. All rights reserved.
|
# Inc. in the United States and other countries. All rights reserved.
|
||||||
#
|
#
|
||||||
# Linux is a registered trademark of Linus Torvalds.
|
# Linux is a registered trademark of Linus Torvalds.
|
||||||
|
|
|
@ -0,0 +1,159 @@
|
||||||
|
###############################################################################
|
||||||
|
# ##
|
||||||
|
# Default Tripwire 2.4 Policy file for GNU/Hurd ##
|
||||||
|
# ##
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# ##
|
||||||
|
# Global Variable Definitions ##
|
||||||
|
# ##
|
||||||
|
# These are defined at install time by the installation script. You may ##
|
||||||
|
# Manually edit these if you are using this file directly and not from the ##
|
||||||
|
# installation script itself. ##
|
||||||
|
# ##
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
@@section GLOBAL
|
||||||
|
TWROOT=;
|
||||||
|
TWBIN=;
|
||||||
|
TWPOL=;
|
||||||
|
TWDB=;
|
||||||
|
TWSKEY=;
|
||||||
|
TWLKEY=;
|
||||||
|
TWREPORT=;
|
||||||
|
HOSTNAME=;
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
# Predefined Variables #
|
||||||
|
##############################################################################
|
||||||
|
#
|
||||||
|
# Property Masks
|
||||||
|
#
|
||||||
|
# - ignore the following properties
|
||||||
|
# + check the following properties
|
||||||
|
#
|
||||||
|
# a access timestamp (mutually exclusive with +CMSH)
|
||||||
|
# b number of blocks allocated
|
||||||
|
# c inode creation/modification timestamp
|
||||||
|
# d ID of device on which inode resides
|
||||||
|
# g group id of owner
|
||||||
|
# i inode number
|
||||||
|
# l growing files (logfiles for example)
|
||||||
|
# m modification timestamp
|
||||||
|
# n number of links
|
||||||
|
# p permission and file mode bits
|
||||||
|
# r ID of device pointed to by inode (valid only for device objects)
|
||||||
|
# s file size
|
||||||
|
# t file type
|
||||||
|
# u user id of owner
|
||||||
|
#
|
||||||
|
# C CRC-32 hash
|
||||||
|
# H HAVAL hash
|
||||||
|
# M MD5 hash
|
||||||
|
# S SHA hash
|
||||||
|
#
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
SEC_DEVICE = +pugsdr-intlbamcCMSH ;
|
||||||
|
SEC_DYNAMIC = +pinugtd-srlbamcCMSH ;
|
||||||
|
SEC_GROWING = +pinugtdl-srbamcCMSH ;
|
||||||
|
SEC_IGNORE_ALL = -pinugtsdrlbamcCMSH ;
|
||||||
|
SEC_IGNORE_NONE = +pinugtsdrbamcCMSH-l ;
|
||||||
|
SEC_READONLY = +pinugtsdbmCM-rlacSH ;
|
||||||
|
SEC_TEMPORARY = +pugt ;
|
||||||
|
|
||||||
|
@@section FS
|
||||||
|
|
||||||
|
#########################################
|
||||||
|
# ##
|
||||||
|
# Tripwire Binaries and Data Files ##
|
||||||
|
# ##
|
||||||
|
#########################################
|
||||||
|
|
||||||
|
# Tripwire Binaries
|
||||||
|
(
|
||||||
|
rulename = "Tripwire Binaries",
|
||||||
|
)
|
||||||
|
{
|
||||||
|
$(TWBIN)/siggen -> $(SEC_READONLY) ;
|
||||||
|
$(TWBIN)/tripwire -> $(SEC_READONLY) ;
|
||||||
|
$(TWBIN)/twadmin -> $(SEC_READONLY) ;
|
||||||
|
$(TWBIN)/twprint -> $(SEC_READONLY) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Tripwire Data Files - Configuration Files, Policy Files, Keys, Reports, Databases
|
||||||
|
(
|
||||||
|
rulename = "Tripwire Data Files",
|
||||||
|
)
|
||||||
|
{
|
||||||
|
# NOTE: We remove the inode attribute because when Tripwire creates a backup,
|
||||||
|
# it does so by renaming the old file and creating a new one (which will
|
||||||
|
# have a new inode number). Inode is left turned on for keys, which shouldn't
|
||||||
|
# ever change.
|
||||||
|
|
||||||
|
# NOTE: The first integrity check triggers this rule and each integrity check
|
||||||
|
# afterward triggers this rule until a database update is run, since the
|
||||||
|
# database file does not exist before that point.
|
||||||
|
|
||||||
|
$(TWDB) -> $(SEC_DYNAMIC) -i ;
|
||||||
|
$(TWPOL)/tw.pol -> $(SEC_READONLY) -i ;
|
||||||
|
$(TWPOL)/tw.cfg -> $(SEC_READONLY) -i ;
|
||||||
|
$(TWLKEY)/$(HOSTNAME)-local.key -> $(SEC_READONLY) ;
|
||||||
|
$(TWSKEY)/site.key -> $(SEC_READONLY) ;
|
||||||
|
|
||||||
|
# don't scan the individual reports
|
||||||
|
$(TWREPORT) -> $(SEC_DYNAMIC) (recurse=0) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
(rulename="Boot files",)
|
||||||
|
{
|
||||||
|
/boot -> $(SEC_READONLY) -a;
|
||||||
|
}
|
||||||
|
|
||||||
|
(rulename="Binary files",)
|
||||||
|
{
|
||||||
|
/bin -> $(SEC_READONLY) -a;
|
||||||
|
/usr/bin -> $(SEC_READONLY) -a;
|
||||||
|
/usr/local/bin -> $(SEC_READONLY) -a;
|
||||||
|
}
|
||||||
|
|
||||||
|
(rulename="Admin binaries",)
|
||||||
|
{
|
||||||
|
/servers -> $(SEC_READONLY) -a;
|
||||||
|
/sbin -> $(SEC_READONLY) -a;
|
||||||
|
/usr/sbin -> $(SEC_READONLY) -a;
|
||||||
|
/hurd -> $(SEC_READONLY) -a;
|
||||||
|
}
|
||||||
|
|
||||||
|
(rulename="Libraries",)
|
||||||
|
{
|
||||||
|
/lib -> $(SEC_READONLY) -a;
|
||||||
|
/usr/lib -> $(SEC_READONLY) -a;
|
||||||
|
/usr/local/lib -> $(SEC_READONLY) -a;
|
||||||
|
}
|
||||||
|
|
||||||
|
(rulename="Etc",)
|
||||||
|
{
|
||||||
|
/etc -> $(SEC_READONLY) -a;
|
||||||
|
/usr/local/etc -> $(SEC_READONLY) -a;
|
||||||
|
}
|
||||||
|
|
||||||
|
(rulename="Dev",)
|
||||||
|
{
|
||||||
|
/dev -> $(SEC_DEVICE);
|
||||||
|
}
|
||||||
|
|
||||||
|
(rulename="Tmp",)
|
||||||
|
{
|
||||||
|
/tmp -> $(SEC_TEMPORARY);
|
||||||
|
/var/tmp -> $(SEC_TEMPORARY);
|
||||||
|
}
|
||||||
|
|
||||||
|
(rulename="Log",)
|
||||||
|
{
|
||||||
|
/var/log -> $(SEC_GROWING);
|
||||||
|
}
|
|
@ -1077,7 +1077,7 @@ SIG_HI = 100 ; # Critical files that are significant point
|
||||||
|
|
||||||
#=============================================================================
|
#=============================================================================
|
||||||
#
|
#
|
||||||
# Copyright 2000-2017 Tripwire, Inc. Tripwire is a registered trademark of Tripwire,
|
# Copyright 2000-2018 Tripwire, Inc. Tripwire is a registered trademark of Tripwire,
|
||||||
# Inc. in the United States and other countries. All rights reserved.
|
# Inc. in the United States and other countries. All rights reserved.
|
||||||
#
|
#
|
||||||
# Linux is a registered trademark of Linus Torvalds.
|
# Linux is a registered trademark of Linus Torvalds.
|
||||||
|
|
|
@ -0,0 +1,178 @@
|
||||||
|
###############################################################################
|
||||||
|
# ##
|
||||||
|
# Default Tripwire 2.4 Policy file for Haiku ##
|
||||||
|
# ##
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# ##
|
||||||
|
# Global Variable Definitions ##
|
||||||
|
# ##
|
||||||
|
# These are defined at install time by the installation script. You may ##
|
||||||
|
# Manually edit these if you are using this file directly and not from the ##
|
||||||
|
# installation script itself. ##
|
||||||
|
# ##
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
@@section GLOBAL
|
||||||
|
TWROOT=;
|
||||||
|
TWBIN=;
|
||||||
|
TWPOL=;
|
||||||
|
TWDB=;
|
||||||
|
TWSKEY=;
|
||||||
|
TWLKEY=;
|
||||||
|
TWREPORT=;
|
||||||
|
HOSTNAME=;
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
# Predefined Variables #
|
||||||
|
##############################################################################
|
||||||
|
#
|
||||||
|
# Property Masks
|
||||||
|
#
|
||||||
|
# - ignore the following properties
|
||||||
|
# + check the following properties
|
||||||
|
#
|
||||||
|
# a access timestamp (mutually exclusive with +CMSH)
|
||||||
|
# b number of blocks allocated
|
||||||
|
# c inode creation/modification timestamp
|
||||||
|
# d ID of device on which inode resides
|
||||||
|
# g group id of owner
|
||||||
|
# i inode number
|
||||||
|
# l growing files (logfiles for example)
|
||||||
|
# m modification timestamp
|
||||||
|
# n number of links
|
||||||
|
# p permission and file mode bits
|
||||||
|
# r ID of device pointed to by inode (valid only for device objects)
|
||||||
|
# s file size
|
||||||
|
# t file type
|
||||||
|
# u user id of owner
|
||||||
|
#
|
||||||
|
# C CRC-32 hash
|
||||||
|
# H HAVAL hash
|
||||||
|
# M MD5 hash
|
||||||
|
# S SHA hash
|
||||||
|
#
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
SEC_DEVICE = +pugsdr-intlbamcCMSH ;
|
||||||
|
SEC_DYNAMIC = +pinugtd-srlbamcCMSH ;
|
||||||
|
SEC_GROWING = +pinugtdl-srbamcCMSH ;
|
||||||
|
SEC_IGNORE_ALL = -pinugtsdrlbamcCMSH ;
|
||||||
|
SEC_IGNORE_NONE = +pinugtsdrbamcCMSH-l ;
|
||||||
|
SEC_READONLY = +pinugtsdbmCM-rlacSH ;
|
||||||
|
SEC_TEMPORARY = +pugt ;
|
||||||
|
|
||||||
|
@@section FS
|
||||||
|
|
||||||
|
#########################################
|
||||||
|
# ##
|
||||||
|
# Tripwire Binaries and Data Files ##
|
||||||
|
# ##
|
||||||
|
#########################################
|
||||||
|
|
||||||
|
# Tripwire Binaries
|
||||||
|
(
|
||||||
|
rulename = "Tripwire Binaries",
|
||||||
|
)
|
||||||
|
{
|
||||||
|
$(TWBIN)/siggen -> $(SEC_READONLY) ;
|
||||||
|
$(TWBIN)/tripwire -> $(SEC_READONLY) ;
|
||||||
|
$(TWBIN)/twadmin -> $(SEC_READONLY) ;
|
||||||
|
$(TWBIN)/twprint -> $(SEC_READONLY) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Tripwire Data Files - Configuration Files, Policy Files, Keys, Reports, Databases
|
||||||
|
(
|
||||||
|
rulename = "Tripwire Data Files",
|
||||||
|
)
|
||||||
|
{
|
||||||
|
# NOTE: We remove the inode attribute because when Tripwire creates a backup,
|
||||||
|
# it does so by renaming the old file and creating a new one (which will
|
||||||
|
# have a new inode number). Inode is left turned on for keys, which shouldn't
|
||||||
|
# ever change.
|
||||||
|
|
||||||
|
# NOTE: The first integrity check triggers this rule and each integrity check
|
||||||
|
# afterward triggers this rule until a database update is run, since the
|
||||||
|
# database file does not exist before that point.
|
||||||
|
|
||||||
|
$(TWDB) -> $(SEC_DYNAMIC) -i ;
|
||||||
|
$(TWPOL)/tw.pol -> $(SEC_READONLY) -i ;
|
||||||
|
$(TWPOL)/tw.cfg -> $(SEC_READONLY) -i ;
|
||||||
|
$(TWLKEY)/$(HOSTNAME)-local.key -> $(SEC_READONLY) ;
|
||||||
|
$(TWSKEY)/site.key -> $(SEC_READONLY) ;
|
||||||
|
|
||||||
|
# don't scan the individual reports
|
||||||
|
$(TWREPORT) -> $(SEC_DYNAMIC) (recurse=0) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
|
||||||
|
### System dir ###############################################################
|
||||||
|
#
|
||||||
|
(rulename = "System Directory",)
|
||||||
|
{
|
||||||
|
/boot/system -> $(SEC_READONLY) -a;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
### Other bin dirs ############################################################
|
||||||
|
#
|
||||||
|
(rulename = "Binary Directories",)
|
||||||
|
{
|
||||||
|
/boot/home/config/bin -> $(SEC_READONLY) -a;
|
||||||
|
/boot/common/bin -> $(SEC_READONLY) -a;
|
||||||
|
/boot/apps -> $(SEC_READONLY) -a;
|
||||||
|
# /boot/develop/tools/gnupro/bin -> $(SEC_READONLY) -a; #uncomment to monitor dev tools if present
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
### Other lib dirs ############################################################
|
||||||
|
#
|
||||||
|
(rulename = "Library Directories",)
|
||||||
|
{
|
||||||
|
/boot/common/lib -> $(SEC_READONLY) -a;
|
||||||
|
/boot/home/config/lib -> $(SEC_READONLY) -a;
|
||||||
|
}
|
||||||
|
|
||||||
|
### Other boot dirs ###########################################################
|
||||||
|
#
|
||||||
|
(rulename = "Boot Directories",)
|
||||||
|
{
|
||||||
|
/boot/common/boot -> $(SEC_READONLY) -a;
|
||||||
|
/boot/home/config/boot -> $(SEC_READONLY) -a;
|
||||||
|
}
|
||||||
|
|
||||||
|
### Settings ##################################################################
|
||||||
|
#
|
||||||
|
(rulename = "Settings",)
|
||||||
|
{
|
||||||
|
/boot/common/settings -> $(SEC_READONLY) -a;
|
||||||
|
/boot/common/data -> $(SEC_READONLY) -a;
|
||||||
|
/boot/common/etc -> $(SEC_READONLY) -a;
|
||||||
|
/boot/home/config/settings -> $(SEC_READONLY) -a;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Logs ########################################################################
|
||||||
|
#
|
||||||
|
(rulename = "Logs",)
|
||||||
|
{
|
||||||
|
/boot/common/var/log -> $(SEC_GROWING) -a;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Dev #########################################################################
|
||||||
|
#
|
||||||
|
(rulename = "Devices",)
|
||||||
|
{
|
||||||
|
/dev -> $(SEC_DEVICE) -a;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Temp dirs #########################
|
||||||
|
#
|
||||||
|
(rulename = "Temp Directories",)
|
||||||
|
{
|
||||||
|
/boot/common/cache/tmp -> $(SEC_TEMPORARY) -a;
|
||||||
|
}
|
|
@ -0,0 +1,292 @@
|
||||||
|
##############################################################################
|
||||||
|
# ##
|
||||||
|
############################################################################## #
|
||||||
|
# # #
|
||||||
|
# Tripwire 2.4 policy for LibertyBSD # #
|
||||||
|
# updated March 2018 # #
|
||||||
|
# ##
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
# ##
|
||||||
|
############################################################################## #
|
||||||
|
# # #
|
||||||
|
# Global Variable Definitions # #
|
||||||
|
# # #
|
||||||
|
# These are defined at install time by the installation script. You may # #
|
||||||
|
# manually edit these if you are using this file directly and not from the # #
|
||||||
|
# installation script itself. # #
|
||||||
|
# ##
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
@@section GLOBAL
|
||||||
|
TWROOT=;
|
||||||
|
TWBIN=;
|
||||||
|
TWPOL=;
|
||||||
|
TWDB=;
|
||||||
|
TWSKEY=;
|
||||||
|
TWLKEY=;
|
||||||
|
TWREPORT=;
|
||||||
|
HOSTNAME=;
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
# Predefined Variables #
|
||||||
|
##############################################################################
|
||||||
|
#
|
||||||
|
# Property Masks
|
||||||
|
#
|
||||||
|
# - ignore the following properties
|
||||||
|
# + check the following properties
|
||||||
|
#
|
||||||
|
# a access timestamp (mutually exclusive with +CMSH)
|
||||||
|
# b number of blocks allocated
|
||||||
|
# c inode creation/modification timestamp
|
||||||
|
# d ID of device on which inode resides
|
||||||
|
# g group id of owner
|
||||||
|
# i inode number
|
||||||
|
# l growing files (logfiles for example)
|
||||||
|
# m modification timestamp
|
||||||
|
# n number of links
|
||||||
|
# p permission and file mode bits
|
||||||
|
# r ID of device pointed to by inode (valid only for device objects)
|
||||||
|
# s file size
|
||||||
|
# t file type
|
||||||
|
# u user id of owner
|
||||||
|
#
|
||||||
|
# C CRC-32 hash
|
||||||
|
# H HAVAL hash
|
||||||
|
# M MD5 hash
|
||||||
|
# S SHA hash
|
||||||
|
#
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
SEC_DEVICE = +pugsdr-intlbamcCMSH ;
|
||||||
|
SEC_DYNAMIC = +pinugtd-srlbamcCMSH ;
|
||||||
|
SEC_GROWING = +pinugtdl-srbamcCMSH ;
|
||||||
|
SEC_IGNORE_ALL = -pinugtsdrlbamcCMSH ;
|
||||||
|
SEC_IGNORE_NONE = +pinugtsdrbamcCMSH-l ;
|
||||||
|
SEC_READONLY = +pinugtsdbmCM-rlacSH ;
|
||||||
|
SEC_TEMPORARY = +pugt ;
|
||||||
|
|
||||||
|
@@section FS
|
||||||
|
|
||||||
|
########################################
|
||||||
|
# ##
|
||||||
|
######################################## #
|
||||||
|
# # #
|
||||||
|
# Tripwire Binaries and Data Files # #
|
||||||
|
# ##
|
||||||
|
########################################
|
||||||
|
|
||||||
|
# Tripwire Binaries
|
||||||
|
(
|
||||||
|
rulename = "Tripwire Binaries",
|
||||||
|
)
|
||||||
|
{
|
||||||
|
$(TWBIN)/siggen -> $(SEC_READONLY) ;
|
||||||
|
$(TWBIN)/tripwire -> $(SEC_READONLY) ;
|
||||||
|
$(TWBIN)/twadmin -> $(SEC_READONLY) ;
|
||||||
|
$(TWBIN)/twprint -> $(SEC_READONLY) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Tripwire Data Files - Configuration Files, Policy Files, Keys, Reports, Databases
|
||||||
|
(
|
||||||
|
rulename = "Tripwire Data Files",
|
||||||
|
)
|
||||||
|
{
|
||||||
|
# NOTE: We remove the inode attribute because when Tripwire creates a backup,
|
||||||
|
# it does so by renaming the old file and creating a new one (which will
|
||||||
|
# have a new inode number). Inode is left turned on for keys, which shouldn't
|
||||||
|
# ever change.
|
||||||
|
|
||||||
|
# NOTE: The first integrity check triggers this rule and each integrity check
|
||||||
|
# afterward triggers this rule until a database update is run, since the
|
||||||
|
# database file does not exist before that point.
|
||||||
|
|
||||||
|
$(TWDB) -> $(SEC_DYNAMIC) -i ;
|
||||||
|
$(TWPOL)/tw.pol -> $(SEC_READONLY) -i ;
|
||||||
|
$(TWPOL)/tw.cfg -> $(SEC_READONLY) -i ;
|
||||||
|
$(TWLKEY)/$(HOSTNAME)-local.key -> $(SEC_READONLY) ;
|
||||||
|
$(TWSKEY)/site.key -> $(SEC_READONLY) ;
|
||||||
|
|
||||||
|
# don't scan the individual reports
|
||||||
|
$(TWREPORT) -> $(SEC_DYNAMIC) (recurse=0) ;
|
||||||
|
|
||||||
|
# In this configuration /usr/local is a symbolic link to /home/local.
|
||||||
|
# We want to ignore the following directories since they are already
|
||||||
|
# scanned using the real directory or mount point. Otherwise we see
|
||||||
|
# duplicates in the reports.
|
||||||
|
|
||||||
|
!/home/local ;
|
||||||
|
}
|
||||||
|
|
||||||
|
################################################
|
||||||
|
# ##
|
||||||
|
################################################ #
|
||||||
|
# # #
|
||||||
|
# OS Boot and Configuration Files # #
|
||||||
|
# ##
|
||||||
|
################################################
|
||||||
|
(
|
||||||
|
rulename = "OS Boot and Configuration Files",
|
||||||
|
)
|
||||||
|
{
|
||||||
|
/boot -> $(SEC_READONLY) ;
|
||||||
|
/bsd -> $(SEC_READONLY) ;
|
||||||
|
/etc -> $(SEC_IGNORE_NONE) -SHa ;
|
||||||
|
}
|
||||||
|
|
||||||
|
###################################################
|
||||||
|
# ##
|
||||||
|
################################################### #
|
||||||
|
# # #
|
||||||
|
# Mount Points # #
|
||||||
|
# ##
|
||||||
|
###################################################
|
||||||
|
(
|
||||||
|
rulename = "Mount Points",
|
||||||
|
)
|
||||||
|
{
|
||||||
|
/ -> $(SEC_READONLY) ;
|
||||||
|
/cdrom -> $(SEC_DYNAMIC) ;
|
||||||
|
/floppy -> $(SEC_DYNAMIC) ;
|
||||||
|
/home -> $(SEC_READONLY) ; # Modify as needed
|
||||||
|
/mnt -> $(SEC_DYNAMIC) ;
|
||||||
|
/usr -> $(SEC_READONLY) ;
|
||||||
|
/var -> $(SEC_READONLY) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
###################################################
|
||||||
|
# ##
|
||||||
|
################################################### #
|
||||||
|
# # #
|
||||||
|
# Misc Top-Level Directories # #
|
||||||
|
# ##
|
||||||
|
###################################################
|
||||||
|
(
|
||||||
|
rulename = "Misc Top-Level Directories",
|
||||||
|
)
|
||||||
|
{
|
||||||
|
/altroot -> $(SEC_DYNAMIC) ;
|
||||||
|
/stand -> $(SEC_DYNAMIC) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
################################################
|
||||||
|
# ##
|
||||||
|
################################################ #
|
||||||
|
# # #
|
||||||
|
# System Devices # #
|
||||||
|
# ##
|
||||||
|
################################################
|
||||||
|
(
|
||||||
|
rulename = "System Devices",
|
||||||
|
)
|
||||||
|
{
|
||||||
|
/dev -> $(SEC_DEVICE) ;
|
||||||
|
/dev/fd -> $(SEC_DEVICE) ;
|
||||||
|
/var/cron/tabs/.sock -> $(SEC_DEVICE) ;
|
||||||
|
/var/empty/dev/log -> $(SEC_DEVICE) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
################################################
|
||||||
|
# ##
|
||||||
|
################################################ #
|
||||||
|
# # #
|
||||||
|
# OS Binaries and Libraries # #
|
||||||
|
# ##
|
||||||
|
################################################
|
||||||
|
(
|
||||||
|
rulename = "OS Binaries and Libraries",
|
||||||
|
)
|
||||||
|
{
|
||||||
|
/bin -> $(SEC_READONLY) ;
|
||||||
|
/sbin -> $(SEC_READONLY) ;
|
||||||
|
/usr/bin -> $(SEC_READONLY) ;
|
||||||
|
/usr/lib -> $(SEC_READONLY) ;
|
||||||
|
/usr/libexec -> $(SEC_READONLY) ;
|
||||||
|
/usr/sbin -> $(SEC_READONLY) ;
|
||||||
|
/usr/X11R6/bin -> $(SEC_READONLY) ;
|
||||||
|
/usr/X11R6/lib -> $(SEC_READONLY) ;
|
||||||
|
}
|
||||||
|
################################################
|
||||||
|
# ##
|
||||||
|
################################################ #
|
||||||
|
# # #
|
||||||
|
# Usr Local Files # #
|
||||||
|
# ##
|
||||||
|
################################################
|
||||||
|
#OK(
|
||||||
|
#OKrulename = "Usr Local Files",
|
||||||
|
#OK)
|
||||||
|
#OK{
|
||||||
|
#OK/usr/local -> $(SEC_READONLY) ;
|
||||||
|
#OK/usr/local/bin -> $(SEC_READONLY) ;
|
||||||
|
#OK/usr/local/doc -> $(SEC_READONLY) ;
|
||||||
|
#OK/usr/local/etc -> $(SEC_READONLY) ;
|
||||||
|
#OK/usr/local/include -> $(SEC_READONLY) ;
|
||||||
|
#OK/usr/local/info -> $(SEC_READONLY) ;
|
||||||
|
#OK/usr/local/lib -> $(SEC_READONLY) ;
|
||||||
|
#OK/usr/local/libdata -> $(SEC_READONLY) ;
|
||||||
|
#OK/usr/local/libexec -> $(SEC_READONLY) ;
|
||||||
|
#OK/usr/local/man -> $(SEC_READONLY) ;
|
||||||
|
#OK/usr/local/sbin -> $(SEC_READONLY) ;
|
||||||
|
#OK/usr/local/share -> $(SEC_READONLY) ;
|
||||||
|
#OK/usr/local/src -> $(SEC_READONLY) ;
|
||||||
|
#OK}
|
||||||
|
|
||||||
|
################################################
|
||||||
|
# ##
|
||||||
|
################################################ #
|
||||||
|
# # #
|
||||||
|
# Root Directory and Files # #
|
||||||
|
# ##
|
||||||
|
################################################
|
||||||
|
(
|
||||||
|
rulename = "Root Directory and Files",
|
||||||
|
)
|
||||||
|
{
|
||||||
|
/root -> $(SEC_IGNORE_NONE) -SHa ;
|
||||||
|
/root/.cshrc -> $(SEC_DYNAMIC) ;
|
||||||
|
/root/.profile -> $(SEC_DYNAMIC) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
################################################
|
||||||
|
# ##
|
||||||
|
################################################ #
|
||||||
|
# # #
|
||||||
|
# Temporary Directories # #
|
||||||
|
# ##
|
||||||
|
################################################
|
||||||
|
(
|
||||||
|
rulename = "Temporary Directories",
|
||||||
|
)
|
||||||
|
{
|
||||||
|
/tmp -> $(SEC_TEMPORARY) ;
|
||||||
|
/var/tmp -> $(SEC_TEMPORARY) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
################################################
|
||||||
|
# ##
|
||||||
|
################################################ #
|
||||||
|
# # #
|
||||||
|
# System and Boot Changes # #
|
||||||
|
# ##
|
||||||
|
################################################
|
||||||
|
(
|
||||||
|
rulename = "System and Boot Changes",
|
||||||
|
)
|
||||||
|
{
|
||||||
|
/var/backups -> $(SEC_DYNAMIC) -i ;
|
||||||
|
/var/db/host.random -> $(SEC_READONLY) -mCM ;
|
||||||
|
/var/cron -> $(SEC_GROWING) -i ;
|
||||||
|
/var/log -> $(SEC_GROWING) -i ;
|
||||||
|
/var/run -> $(SEC_DYNAMIC) -i ;
|
||||||
|
/var/mail -> $(SEC_GROWING) ;
|
||||||
|
/var/msgs/bounds -> $(SEC_READONLY) -smbCM ;
|
||||||
|
/var/spool/clientmqueue -> $(SEC_TEMPORARY) ;
|
||||||
|
/var/spool/mqueue -> $(SEC_TEMPORARY) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# $Id: twpol-OpenBSD.txt,v 1.2 2004/05/14 21:56:21 pherman Exp $
|
||||||
|
#
|
|
@ -2,7 +2,8 @@
|
||||||
# ##
|
# ##
|
||||||
############################################################################## #
|
############################################################################## #
|
||||||
# # #
|
# # #
|
||||||
# Policy file for Red Hat Linux # #
|
# Tripwire 2.4 policy for Linux (RPM) # #
|
||||||
|
# updated March 2018 # #
|
||||||
# ##
|
# ##
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
|
@ -59,13 +60,13 @@ HOSTNAME=;
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
Device = +pugsdr-intlbamcCMSH ;
|
SEC_DEVICE = +pugsdr-intlbamcCMSH ;
|
||||||
Dynamic = +pinugtd-srlbamcCMSH ;
|
SEC_DYNAMIC = +pinugtd-srlbamcCMSH ;
|
||||||
Growing = +pinugtdl-srbamcCMSH ;
|
SEC_GROWING = +pinugtdl-srbamcCMSH ;
|
||||||
IgnoreAll = -pinugtsdrlbamcCMSH ;
|
SEC_IGNORE_ALL = -pinugtsdrlbamcCMSH ;
|
||||||
IgnoreNone = +pinugtsdrbamcCMSH-l ;
|
SEC_IGNORE_NONE = +pinugtsdrbamcCMSH-l ;
|
||||||
ReadOnly = +pinugtsdbmCM-rlacSH ;
|
SEC_READONLY = +pinugtsdbmCM-rlacSH ;
|
||||||
Temporary = +pugt ;
|
SEC_TEMPORARY = +pugt ;
|
||||||
|
|
||||||
@@section FS
|
@@section FS
|
||||||
|
|
||||||
|
@ -82,10 +83,10 @@ Temporary = +pugt ;
|
||||||
rulename = "Tripwire Binaries",
|
rulename = "Tripwire Binaries",
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
$(TWBIN)/siggen -> $(ReadOnly) ;
|
$(TWBIN)/siggen -> $(SEC_READONLY) ;
|
||||||
$(TWBIN)/tripwire -> $(ReadOnly) ;
|
$(TWBIN)/tripwire -> $(SEC_READONLY) ;
|
||||||
$(TWBIN)/twadmin -> $(ReadOnly) ;
|
$(TWBIN)/twadmin -> $(SEC_READONLY) ;
|
||||||
$(TWBIN)/twprint -> $(ReadOnly) ;
|
$(TWBIN)/twprint -> $(SEC_READONLY) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Tripwire Data Files - Configuration Files, Policy Files, Keys, Reports, Databases
|
# Tripwire Data Files - Configuration Files, Policy Files, Keys, Reports, Databases
|
||||||
|
@ -102,14 +103,14 @@ Temporary = +pugt ;
|
||||||
# afterward triggers this rule until a database update is run, since the
|
# afterward triggers this rule until a database update is run, since the
|
||||||
# database file does not exist before that point.
|
# database file does not exist before that point.
|
||||||
|
|
||||||
$(TWDB) -> $(Dynamic) -i ;
|
$(TWDB) -> $(SEC_DYNAMIC) -i ;
|
||||||
$(TWPOL)/tw.pol -> $(ReadOnly) -i ;
|
$(TWPOL)/tw.pol -> $(SEC_READONLY) -i ;
|
||||||
$(TWPOL)/tw.cfg -> $(ReadOnly) -i ;
|
$(TWPOL)/tw.cfg -> $(SEC_READONLY) -i ;
|
||||||
$(TWLKEY)/$(HOSTNAME)-local.key -> $(ReadOnly) ;
|
$(TWLKEY)/$(HOSTNAME)-local.key -> $(SEC_READONLY) ;
|
||||||
$(TWSKEY)/site.key -> $(ReadOnly) ;
|
$(TWSKEY)/site.key -> $(SEC_READONLY) ;
|
||||||
|
|
||||||
# don't scan the individual reports
|
# don't scan the individual reports
|
||||||
$(TWREPORT) -> $(Dynamic) (recurse=0) ;
|
$(TWREPORT) -> $(SEC_DYNAMIC) (recurse=0) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
################################################
|
################################################
|
||||||
|
@ -123,10 +124,10 @@ Temporary = +pugt ;
|
||||||
rulename = "RPM Checksum Files",
|
rulename = "RPM Checksum Files",
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/var/lib/rpm -> $(ReadOnly);
|
/var/lib/rpm -> $(SEC_READONLY);
|
||||||
/var/lib/rpm/__db.001 -> $(Dynamic) ;
|
/var/lib/rpm/__db.001 -> $(SEC_DYNAMIC) ;
|
||||||
/var/lib/rpm/__db.002 -> $(Dynamic) ;
|
/var/lib/rpm/__db.002 -> $(SEC_DYNAMIC) ;
|
||||||
/var/lib/rpm/__db.003 -> $(Dynamic) ;
|
/var/lib/rpm/__db.003 -> $(SEC_DYNAMIC) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
################################################
|
################################################
|
||||||
|
@ -140,18 +141,18 @@ Temporary = +pugt ;
|
||||||
rulename = "Global Configuration Files",
|
rulename = "Global Configuration Files",
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/etc -> $(IgnoreNone) -SHa ;
|
/etc -> $(SEC_IGNORE_NONE) -SHa ;
|
||||||
/etc/adjtime -> $(Dynamic) ;
|
/etc/adjtime -> $(SEC_DYNAMIC) ;
|
||||||
/etc/aliases.db -> $(Dynamic) ;
|
/etc/aliases.db -> $(SEC_DYNAMIC) ;
|
||||||
/etc/bashrc -> $(Dynamic) ;
|
/etc/bashrc -> $(SEC_DYNAMIC) ;
|
||||||
/etc/csh.cshrc -> $(Dynamic) ;
|
/etc/csh.cshrc -> $(SEC_DYNAMIC) ;
|
||||||
/etc/csh.login -> $(Dynamic) ;
|
/etc/csh.login -> $(SEC_DYNAMIC) ;
|
||||||
/etc/mail/statistics -> $(Growing) ;
|
/etc/mail/statistics -> $(SEC_GROWING) ;
|
||||||
/etc/profile -> $(Dynamic) -i ;
|
/etc/profile -> $(SEC_DYNAMIC) -i ;
|
||||||
/etc/mtab -> $(Dynamic) -i ;
|
/etc/mtab -> $(SEC_DYNAMIC) -i ;
|
||||||
/etc/rc.d -> $(IgnoreNone) -SHa ;
|
/etc/rc.d -> $(SEC_IGNORE_NONE) -SHa ;
|
||||||
/etc/sysconfig -> $(IgnoreNone) -SHa ;
|
/etc/sysconfig -> $(SEC_IGNORE_NONE) -SHa ;
|
||||||
/etc/sysconfig/hwconf -> $(Dynamic) -m ;
|
/etc/sysconfig/hwconf -> $(SEC_DYNAMIC) -m ;
|
||||||
}
|
}
|
||||||
|
|
||||||
################################################
|
################################################
|
||||||
|
@ -165,10 +166,10 @@ Temporary = +pugt ;
|
||||||
rulename = "OS Boot Files and Mount Points",
|
rulename = "OS Boot Files and Mount Points",
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/boot -> $(ReadOnly) ;
|
/boot -> $(SEC_READONLY) ;
|
||||||
/cdrom -> $(Dynamic) ;
|
/cdrom -> $(SEC_DYNAMIC) ;
|
||||||
/floppy -> $(Dynamic) ;
|
/floppy -> $(SEC_DYNAMIC) ;
|
||||||
/mnt -> $(Dynamic) ;
|
/mnt -> $(SEC_DYNAMIC) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
################################################
|
################################################
|
||||||
|
@ -182,12 +183,12 @@ Temporary = +pugt ;
|
||||||
rulename = "OS Devices and Misc Directories",
|
rulename = "OS Devices and Misc Directories",
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/dev -> $(Device) ;
|
/dev -> $(SEC_DEVICE) ;
|
||||||
/initrd -> $(Dynamic) ;
|
/initrd -> $(SEC_DYNAMIC) ;
|
||||||
/opt -> $(Dynamic) ;
|
/opt -> $(SEC_DYNAMIC) ;
|
||||||
/lost+found -> $(Dynamic) ;
|
/lost+found -> $(SEC_DYNAMIC) ;
|
||||||
/var/lost+found -> $(Dynamic) ;
|
/var/lost+found -> $(SEC_DYNAMIC) ;
|
||||||
/home/lost+found -> $(Dynamic) ;
|
/home/lost+found -> $(SEC_DYNAMIC) ;
|
||||||
!/dev/pts ; # Ignore this file
|
!/dev/pts ; # Ignore this file
|
||||||
!/dev/shm ; # Ignore this file
|
!/dev/shm ; # Ignore this file
|
||||||
}
|
}
|
||||||
|
@ -203,14 +204,14 @@ Temporary = +pugt ;
|
||||||
rulename = "OS Binaries and Libraries",
|
rulename = "OS Binaries and Libraries",
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/bin -> $(ReadOnly) ;
|
/bin -> $(SEC_READONLY) ;
|
||||||
/lib -> $(ReadOnly) ;
|
/lib -> $(SEC_READONLY) ;
|
||||||
/sbin -> $(ReadOnly) ;
|
/sbin -> $(SEC_READONLY) ;
|
||||||
/usr/bin -> $(ReadOnly) ;
|
/usr/bin -> $(SEC_READONLY) ;
|
||||||
/usr/lib -> $(ReadOnly) ;
|
/usr/lib -> $(SEC_READONLY) ;
|
||||||
/usr/libexec -> $(ReadOnly) ;
|
/usr/libexec -> $(SEC_READONLY) ;
|
||||||
/usr/sbin -> $(ReadOnly) ;
|
/usr/sbin -> $(SEC_READONLY) ;
|
||||||
/usr/X11R6/lib -> $(ReadOnly) ;
|
/usr/X11R6/lib -> $(SEC_READONLY) ;
|
||||||
}
|
}
|
||||||
################################################
|
################################################
|
||||||
# ##
|
# ##
|
||||||
|
@ -224,19 +225,19 @@ Temporary = +pugt ;
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
!/home/local;
|
!/home/local;
|
||||||
/usr/local -> $(ReadOnly) ;
|
/usr/local -> $(SEC_READONLY) ;
|
||||||
/usr/local/bin -> $(ReadOnly) ;
|
/usr/local/bin -> $(SEC_READONLY) ;
|
||||||
/usr/local/doc -> $(ReadOnly) ;
|
/usr/local/doc -> $(SEC_READONLY) ;
|
||||||
/usr/local/etc -> $(ReadOnly) ;
|
/usr/local/etc -> $(SEC_READONLY) ;
|
||||||
/usr/local/games -> $(ReadOnly) ;
|
/usr/local/games -> $(SEC_READONLY) ;
|
||||||
/usr/local/include -> $(ReadOnly) ;
|
/usr/local/include -> $(SEC_READONLY) ;
|
||||||
/usr/local/lib -> $(ReadOnly) ;
|
/usr/local/lib -> $(SEC_READONLY) ;
|
||||||
/usr/local/libexec -> $(ReadOnly) ;
|
/usr/local/libexec -> $(SEC_READONLY) ;
|
||||||
/usr/local/man -> $(ReadOnly) ;
|
/usr/local/man -> $(SEC_READONLY) ;
|
||||||
/usr/local/sbin -> $(ReadOnly) ;
|
/usr/local/sbin -> $(SEC_READONLY) ;
|
||||||
/usr/local/share -> $(ReadOnly) ;
|
/usr/local/share -> $(SEC_READONLY) ;
|
||||||
/usr/local/src -> $(ReadOnly) ;
|
/usr/local/src -> $(SEC_READONLY) ;
|
||||||
/usr/local/sysinfo -> $(ReadOnly) ;
|
/usr/local/sysinfo -> $(SEC_READONLY) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
################################################
|
################################################
|
||||||
|
@ -250,29 +251,29 @@ Temporary = +pugt ;
|
||||||
rulename = "Root Directory and Files",
|
rulename = "Root Directory and Files",
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/root -> $(IgnoreNone) -SHa ;
|
/root -> $(SEC_IGNORE_NONE) -SHa ;
|
||||||
/root/.bashrc -> $(Dynamic) ;
|
/root/.bashrc -> $(SEC_DYNAMIC) ;
|
||||||
/root/.bash_history -> $(Dynamic) ;
|
/root/.bash_history -> $(SEC_DYNAMIC) ;
|
||||||
#/root/.bash_logout -> $(Dynamic) ;
|
#/root/.bash_logout -> $(SEC_DYNAMIC) ;
|
||||||
/root/.bash_profile -> $(Dynamic) ;
|
/root/.bash_profile -> $(SEC_DYNAMIC) ;
|
||||||
/root/.cshrc -> $(Dynamic) ;
|
/root/.cshrc -> $(SEC_DYNAMIC) ;
|
||||||
#/root/.enlightenment -> $(Dynamic) ;
|
#/root/.enlightenment -> $(SEC_DYNAMIC) ;
|
||||||
#/root/.esd-auth -> $(Dynamic) ;
|
#/root/.esd-auth -> $(SEC_DYNAMIC) ;
|
||||||
!/root/.gconf ;
|
!/root/.gconf ;
|
||||||
!/root/.gconfd ;
|
!/root/.gconfd ;
|
||||||
#/root/.gnome -> $(Dynamic) ;
|
#/root/.gnome -> $(SEC_DYNAMIC) ;
|
||||||
#/root/.gnome-desktop -> $(Dynamic) ;
|
#/root/.gnome-desktop -> $(SEC_DYNAMIC) ;
|
||||||
#/root/.gnome2 -> $(Dynamic) ;
|
#/root/.gnome2 -> $(SEC_DYNAMIC) ;
|
||||||
#/root/.gtkrc -> $(Dynamic) ;
|
#/root/.gtkrc -> $(SEC_DYNAMIC) ;
|
||||||
#/root/.gtkrc-1.2-gnome2 -> $(Dynamic) ;
|
#/root/.gtkrc-1.2-gnome2 -> $(SEC_DYNAMIC) ;
|
||||||
#/root/.metacity -> $(Dynamic) ;
|
#/root/.metacity -> $(SEC_DYNAMIC) ;
|
||||||
#/root/.nautilus -> $(Dynamic) ;
|
#/root/.nautilus -> $(SEC_DYNAMIC) ;
|
||||||
#/root/.rhn-applet.conf -> $(Dynamic) ;
|
#/root/.rhn-applet.conf -> $(SEC_DYNAMIC) ;
|
||||||
#/root/.tcshrc -> $(Dynamic) ;
|
#/root/.tcshrc -> $(SEC_DYNAMIC) ;
|
||||||
#/root/.xauth -> $(Dynamic) ;
|
#/root/.xauth -> $(SEC_DYNAMIC) ;
|
||||||
#/root/.ICEauthority -> $(Dynamic) ;
|
#/root/.ICEauthority -> $(SEC_DYNAMIC) ;
|
||||||
#/root/.Xauthority -> $(Dynamic) -i ;
|
#/root/.Xauthority -> $(SEC_DYNAMIC) -i ;
|
||||||
#/root/.Xresources -> $(Dynamic) ;
|
#/root/.Xresources -> $(SEC_DYNAMIC) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
################################################
|
################################################
|
||||||
|
@ -286,12 +287,12 @@ Temporary = +pugt ;
|
||||||
rulename = "Temporary Directories",
|
rulename = "Temporary Directories",
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/usr/tmp -> $(Temporary) ;
|
/usr/tmp -> $(SEC_TEMPORARY) ;
|
||||||
/var/tmp -> $(Temporary) ;
|
/var/tmp -> $(SEC_TEMPORARY) ;
|
||||||
/tmp -> $(Temporary) ;
|
/tmp -> $(SEC_TEMPORARY) ;
|
||||||
#/tmp/.fam-socket -> $(Temporary) ;
|
#/tmp/.fam-socket -> $(SEC_TEMPORARY) ;
|
||||||
#/tmp/.ICE-unix -> $(Temporary) ;
|
#/tmp/.ICE-unix -> $(SEC_TEMPORARY) ;
|
||||||
#/tmp/.X11-unix -> $(Temporary) ;
|
#/tmp/.X11-unix -> $(SEC_TEMPORARY) ;
|
||||||
!/tmp/orbit-root ;
|
!/tmp/orbit-root ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -306,21 +307,21 @@ Temporary = +pugt ;
|
||||||
rulename = "System Boot Changes",
|
rulename = "System Boot Changes",
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/.autofsck -> $(Dynamic) -m ;
|
/.autofsck -> $(SEC_DYNAMIC) -m ;
|
||||||
/var/cache/man/whatis -> $(Growing) ;
|
/var/cache/man/whatis -> $(SEC_GROWING) ;
|
||||||
/var/lib/logrotate.status -> $(Growing) ;
|
/var/lib/logrotate.status -> $(SEC_GROWING) ;
|
||||||
#/var/lib/nfs/statd -> $(Growing) ;
|
#/var/lib/nfs/statd -> $(SEC_GROWING) ;
|
||||||
!/var/lib/random-seed ;
|
!/var/lib/random-seed ;
|
||||||
#/var/lib/slocate/slocate.db -> $(Growing) -is ;
|
#/var/lib/slocate/slocate.db -> $(SEC_GROWING) -is ;
|
||||||
/var/lock/subsys -> $(Dynamic) -i ;
|
/var/lock/subsys -> $(SEC_DYNAMIC) -i ;
|
||||||
/var/log -> $(Growing) -i ;
|
/var/log -> $(SEC_GROWING) -i ;
|
||||||
!/var/log/sa;
|
!/var/log/sa;
|
||||||
!/var/log/cisco;
|
!/var/log/cisco;
|
||||||
/var/run -> $(Dynamic) -i ;
|
/var/run -> $(SEC_DYNAMIC) -i ;
|
||||||
/etc/cron.daily -> $(Growing);
|
/etc/cron.daily -> $(SEC_GROWING);
|
||||||
/etc/cron.weekly -> $(Growing);
|
/etc/cron.weekly -> $(SEC_GROWING);
|
||||||
/etc/cron.monthly -> $(Growing);
|
/etc/cron.monthly -> $(SEC_GROWING);
|
||||||
/var/spool/mail -> $(Growing);
|
/var/spool/mail -> $(SEC_GROWING);
|
||||||
}
|
}
|
||||||
|
|
||||||
################################################
|
################################################
|
||||||
|
@ -334,10 +335,10 @@ Temporary = +pugt ;
|
||||||
rulename = "Monitor Filesystems",
|
rulename = "Monitor Filesystems",
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/ -> $(ReadOnly) ;
|
/ -> $(SEC_READONLY) ;
|
||||||
/home -> $(ReadOnly) ; # Modify as needed
|
/home -> $(SEC_READONLY) ; # Modify as needed
|
||||||
/usr -> $(ReadOnly) ;
|
/usr -> $(SEC_READONLY) ;
|
||||||
/var -> $(ReadOnly) ;
|
/var -> $(SEC_READONLY) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
################################################
|
################################################
|
||||||
|
|
|
@ -54,16 +54,24 @@ TWREPORT=;
|
||||||
HOSTNAME=;
|
HOSTNAME=;
|
||||||
|
|
||||||
@@section FS
|
@@section FS
|
||||||
SEC_CRIT = $(IgnoreNone)-SHa ; # Critical files that cannot change
|
SEC_DEVICE = +pugsdr-intlbamcCMSH ;
|
||||||
SEC_SUID = $(IgnoreNone)-SHa ; # Binaries with the SUID or SGID flags set
|
SEC_DYNAMIC = +pinugtd-srlbamcCMSH ;
|
||||||
SEC_BIN = $(ReadOnly) ; # Binaries that should not change
|
SEC_GROWING = +pinugtdl-srbamcCMSH ;
|
||||||
SEC_CONFIG = $(Dynamic) ; # Config files that are changed infrequently but accessed often
|
SEC_IGNORE_ALL = -pinugtsdrlbamcCMSH ;
|
||||||
SEC_TTY = $(Dynamic)-ugp ; # Tty files that change ownership at login
|
SEC_IGNORE_NONE = +pinugtsdrbamcCMSH-l ;
|
||||||
SEC_LOG = $(Growing) ; # Files that grow, but that should never change ownership
|
SEC_READONLY = +pinugtsdbmCM-rlacSH ;
|
||||||
SEC_INVARIANT = +tpug ; # Directories that should never change permission or ownership
|
SEC_TEMPORARY = +pugt ;
|
||||||
SIG_LOW = 33 ; # Non-critical files that are of minimal security impact
|
|
||||||
SIG_MED = 66 ; # Non-critical files that are of significant security impact
|
SEC_CRIT = $(SEC_IGNORE_NONE)-SHa ; # Critical files that cannot change
|
||||||
SIG_HI = 100 ; # Critical files that are significant points of vulnerability
|
SEC_SUID = $(SEC_IGNORE_NONE)-SHa ; # Binaries with the SUID or SGID flags set
|
||||||
|
SEC_BIN = $(SEC_READONLY) ; # Binaries that should not change
|
||||||
|
SEC_CONFIG = $(SEC_DYNAMIC) ; # Config files that are changed infrequently but accessed often
|
||||||
|
SEC_TTY = $(SEC_DYNAMIC)-ugp ; # Tty files that change ownership at login
|
||||||
|
SEC_LOG = $(SEC_GROWING) ; # Files that grow, but that should never change ownership
|
||||||
|
SEC_INVARIANT = $(SEC_TEMPORARY) ; # Directories that should never change permission or ownership
|
||||||
|
SIG_LOW = 33 ; # Non-critical files that are of minimal security impact
|
||||||
|
SIG_MED = 66 ; # Non-critical files that are of significant security impact
|
||||||
|
SIG_HI = 100 ; # Critical files that are significant points of vulnerability
|
||||||
|
|
||||||
|
|
||||||
# Tripwire Binaries
|
# Tripwire Binaries
|
||||||
|
@ -630,7 +638,7 @@ SIG_HI = 100 ; # Critical files that are significant point
|
||||||
|
|
||||||
#=============================================================================
|
#=============================================================================
|
||||||
#
|
#
|
||||||
# Copyright 2000-2017 Tripwire, Inc. Tripwire is a registered trademark of Tripwire,
|
# Copyright 2000-2018 Tripwire, Inc. Tripwire is a registered trademark of Tripwire,
|
||||||
# Inc. in the United States and other countries. All rights reserved.
|
# Inc. in the United States and other countries. All rights reserved.
|
||||||
#
|
#
|
||||||
# FreeBSD is a registered trademark of the FreeBSD Project Inc.
|
# FreeBSD is a registered trademark of the FreeBSD Project Inc.
|
||||||
|
|
|
@ -0,0 +1,176 @@
|
||||||
|
###############################################################################
|
||||||
|
# ##
|
||||||
|
# Default Tripwire 2.4 Policy file for Minix ##
|
||||||
|
# ##
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# ##
|
||||||
|
# Global Variable Definitions ##
|
||||||
|
# ##
|
||||||
|
# These are defined at install time by the installation script. You may ##
|
||||||
|
# Manually edit these if you are using this file directly and not from the ##
|
||||||
|
# installation script itself. ##
|
||||||
|
# ##
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
@@section GLOBAL
|
||||||
|
TWROOT=;
|
||||||
|
TWBIN=;
|
||||||
|
TWPOL=;
|
||||||
|
TWDB=;
|
||||||
|
TWSKEY=;
|
||||||
|
TWLKEY=;
|
||||||
|
TWREPORT=;
|
||||||
|
HOSTNAME=;
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
# Predefined Variables #
|
||||||
|
##############################################################################
|
||||||
|
#
|
||||||
|
# Property Masks
|
||||||
|
#
|
||||||
|
# - ignore the following properties
|
||||||
|
# + check the following properties
|
||||||
|
#
|
||||||
|
# a access timestamp (mutually exclusive with +CMSH)
|
||||||
|
# b number of blocks allocated
|
||||||
|
# c inode creation/modification timestamp
|
||||||
|
# d ID of device on which inode resides
|
||||||
|
# g group id of owner
|
||||||
|
# i inode number
|
||||||
|
# l growing files (logfiles for example)
|
||||||
|
# m modification timestamp
|
||||||
|
# n number of links
|
||||||
|
# p permission and file mode bits
|
||||||
|
# r ID of device pointed to by inode (valid only for device objects)
|
||||||
|
# s file size
|
||||||
|
# t file type
|
||||||
|
# u user id of owner
|
||||||
|
#
|
||||||
|
# C CRC-32 hash
|
||||||
|
# H HAVAL hash
|
||||||
|
# M MD5 hash
|
||||||
|
# S SHA hash
|
||||||
|
#
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
SEC_DEVICE = +pugsdr-intlbamcCMSH ;
|
||||||
|
SEC_DYNAMIC = +pinugtd-srlbamcCMSH ;
|
||||||
|
SEC_GROWING = +pinugtdl-srbamcCMSH ;
|
||||||
|
SEC_IGNORE_ALL = -pinugtsdrlbamcCMSH ;
|
||||||
|
SEC_IGNORE_NONE = +pinugtsdrbamcCMSH-l ;
|
||||||
|
SEC_READONLY = +pinugtsdbmCM-rlacSH ;
|
||||||
|
SEC_TEMPORARY = +pugt ;
|
||||||
|
|
||||||
|
@@section FS
|
||||||
|
|
||||||
|
#########################################
|
||||||
|
# ##
|
||||||
|
# Tripwire Binaries and Data Files ##
|
||||||
|
# ##
|
||||||
|
#########################################
|
||||||
|
|
||||||
|
# Tripwire Binaries
|
||||||
|
(
|
||||||
|
rulename = "Tripwire Binaries",
|
||||||
|
)
|
||||||
|
{
|
||||||
|
$(TWBIN)/siggen -> $(SEC_READONLY) ;
|
||||||
|
$(TWBIN)/tripwire -> $(SEC_READONLY) ;
|
||||||
|
$(TWBIN)/twadmin -> $(SEC_READONLY) ;
|
||||||
|
$(TWBIN)/twprint -> $(SEC_READONLY) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Tripwire Data Files - Configuration Files, Policy Files, Keys, Reports, Databases
|
||||||
|
(
|
||||||
|
rulename = "Tripwire Data Files",
|
||||||
|
)
|
||||||
|
{
|
||||||
|
# NOTE: We remove the inode attribute because when Tripwire creates a backup,
|
||||||
|
# it does so by renaming the old file and creating a new one (which will
|
||||||
|
# have a new inode number). Inode is left turned on for keys, which shouldn't
|
||||||
|
# ever change.
|
||||||
|
|
||||||
|
# NOTE: The first integrity check triggers this rule and each integrity check
|
||||||
|
# afterward triggers this rule until a database update is run, since the
|
||||||
|
# database file does not exist before that point.
|
||||||
|
|
||||||
|
$(TWDB) -> $(SEC_DYNAMIC) -i ;
|
||||||
|
$(TWPOL)/tw.pol -> $(SEC_READONLY) -i ;
|
||||||
|
$(TWPOL)/tw.cfg -> $(SEC_READONLY) -i ;
|
||||||
|
$(TWLKEY)/$(HOSTNAME)-local.key -> $(SEC_READONLY) ;
|
||||||
|
$(TWSKEY)/site.key -> $(SEC_READONLY) ;
|
||||||
|
|
||||||
|
# don't scan the individual reports
|
||||||
|
$(TWREPORT) -> $(SEC_DYNAMIC) (recurse=0) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
(rulename="Boot files",)
|
||||||
|
{
|
||||||
|
/boot -> $(SEC_READONLY) -a;
|
||||||
|
/boot_monitor -> $(SEC_READONLY) -a;
|
||||||
|
/boot.cfg -> $(SEC_READONLY) -a;
|
||||||
|
}
|
||||||
|
|
||||||
|
(rulename="Binary files",)
|
||||||
|
{
|
||||||
|
/bin -> $(SEC_READONLY) -a;
|
||||||
|
/usr/bin -> $(SEC_READONLY) -a;
|
||||||
|
/usr/local/bin -> $(SEC_READONLY) -a;
|
||||||
|
/usr/pkg/bin -> $(SEC_READONLY) -a;
|
||||||
|
}
|
||||||
|
|
||||||
|
(rulename="Development",)
|
||||||
|
{
|
||||||
|
/usr/pkg/gnu/bin -> $(SEC_READONLY) -a;
|
||||||
|
/usr/pkg/i386-elf32-minix/bin -> $(SEC_READONLY) -a;
|
||||||
|
}
|
||||||
|
|
||||||
|
(rulename="Libexec",)
|
||||||
|
{
|
||||||
|
/usr/libexec -> $(SEC_READONLY) -a;
|
||||||
|
/usr/pkg/libexec -> $(SEC_READONLY) -a;
|
||||||
|
}
|
||||||
|
|
||||||
|
(rulename="Admin binaries",)
|
||||||
|
{
|
||||||
|
/service -> $(SEC_READONLY) -a;
|
||||||
|
/sbin -> $(SEC_READONLY) -a;
|
||||||
|
/usr/sbin -> $(SEC_READONLY) -a;
|
||||||
|
/usr/pkg/sbin -> $(SEC_READONLY) -a;
|
||||||
|
}
|
||||||
|
|
||||||
|
(rulename="Libraries",)
|
||||||
|
{
|
||||||
|
/lib -> $(SEC_READONLY) -a;
|
||||||
|
/usr/lib -> $(SEC_READONLY) -a;
|
||||||
|
/usr/pkg/lib -> $(SEC_READONLY) -a;
|
||||||
|
}
|
||||||
|
|
||||||
|
(rulename="Etc",)
|
||||||
|
{
|
||||||
|
/etc -> $(SEC_READONLY) -a;
|
||||||
|
/usr/etc -> $(SEC_READONLY) -a;
|
||||||
|
/usr/pkg/etc -> $(SEC_READONLY) -a;
|
||||||
|
}
|
||||||
|
|
||||||
|
(rulename="Dev",)
|
||||||
|
{
|
||||||
|
/dev -> $(SEC_DEVICE);
|
||||||
|
}
|
||||||
|
|
||||||
|
(rulename="Tmp",)
|
||||||
|
{
|
||||||
|
/tmp -> $(SEC_TEMPORARY);
|
||||||
|
/var/tmp -> $(SEC_TEMPORARY);
|
||||||
|
/usr/tmp -> $(SEC_TEMPORARY);
|
||||||
|
}
|
||||||
|
|
||||||
|
(rulename="Log",)
|
||||||
|
{
|
||||||
|
/var/log -> $(SEC_GROWING);
|
||||||
|
}
|
|
@ -2,8 +2,8 @@
|
||||||
# ##
|
# ##
|
||||||
############################################################################## #
|
############################################################################## #
|
||||||
# # #
|
# # #
|
||||||
# Policy file for MirOS BSD # #
|
# Tripwire 2.4 policy for MirOS BSD # #
|
||||||
# (adapted from OpenBSD policy) # #
|
# updated March 2018 # #
|
||||||
# ##
|
# ##
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
|
@ -60,13 +60,13 @@ HOSTNAME=;
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
Device = +pugsdr-intlbamcCMSH ;
|
SEC_DEVICE = +pugsdr-intlbamcCMSH ;
|
||||||
Dynamic = +pinugtd-srlbamcCMSH ;
|
SEC_DYNAMIC = +pinugtd-srlbamcCMSH ;
|
||||||
Growing = +pinugtdl-srbamcCMSH ;
|
SEC_GROWING = +pinugtdl-srbamcCMSH ;
|
||||||
IgnoreAll = -pinugtsdrlbamcCMSH ;
|
SEC_IGNORE_ALL = -pinugtsdrlbamcCMSH ;
|
||||||
IgnoreNone = +pinugtsdrbamcCMSH-l ;
|
SEC_IGNORE_NONE = +pinugtsdrbamcCMSH-l ;
|
||||||
ReadOnly = +pinugtsdbmCM-rlacSH ;
|
SEC_READONLY = +pinugtsdbmCM-rlacSH ;
|
||||||
Temporary = +pugt ;
|
SEC_TEMPORARY = +pugt ;
|
||||||
|
|
||||||
@@section FS
|
@@section FS
|
||||||
|
|
||||||
|
@ -83,10 +83,10 @@ Temporary = +pugt ;
|
||||||
rulename = "Tripwire Binaries",
|
rulename = "Tripwire Binaries",
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
$(TWBIN)/siggen -> $(ReadOnly) ;
|
$(TWBIN)/siggen -> $(SEC_READONLY) ;
|
||||||
$(TWBIN)/tripwire -> $(ReadOnly) ;
|
$(TWBIN)/tripwire -> $(SEC_READONLY) ;
|
||||||
$(TWBIN)/twadmin -> $(ReadOnly) ;
|
$(TWBIN)/twadmin -> $(SEC_READONLY) ;
|
||||||
$(TWBIN)/twprint -> $(ReadOnly) ;
|
$(TWBIN)/twprint -> $(SEC_READONLY) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Tripwire Data Files - Configuration Files, Policy Files, Keys, Reports, Databases
|
# Tripwire Data Files - Configuration Files, Policy Files, Keys, Reports, Databases
|
||||||
|
@ -103,14 +103,14 @@ Temporary = +pugt ;
|
||||||
# afterward triggers this rule until a database update is run, since the
|
# afterward triggers this rule until a database update is run, since the
|
||||||
# database file does not exist before that point.
|
# database file does not exist before that point.
|
||||||
|
|
||||||
$(TWDB) -> $(Dynamic) -i ;
|
$(TWDB) -> $(SEC_DYNAMIC) -i ;
|
||||||
$(TWPOL)/tw.pol -> $(ReadOnly) -i ;
|
$(TWPOL)/tw.pol -> $(SEC_READONLY) -i ;
|
||||||
$(TWPOL)/tw.cfg -> $(ReadOnly) -i ;
|
$(TWPOL)/tw.cfg -> $(SEC_READONLY) -i ;
|
||||||
$(TWLKEY)/$(HOSTNAME)-local.key -> $(ReadOnly) ;
|
$(TWLKEY)/$(HOSTNAME)-local.key -> $(SEC_READONLY) ;
|
||||||
$(TWSKEY)/site.key -> $(ReadOnly) ;
|
$(TWSKEY)/site.key -> $(SEC_READONLY) ;
|
||||||
|
|
||||||
# don't scan the individual reports
|
# don't scan the individual reports
|
||||||
$(TWREPORT) -> $(Dynamic) (recurse=0) ;
|
$(TWREPORT) -> $(SEC_DYNAMIC) (recurse=0) ;
|
||||||
|
|
||||||
# In this configuration /usr/local is a symbolic link to /home/local.
|
# In this configuration /usr/local is a symbolic link to /home/local.
|
||||||
# We want to ignore the following directories since they are already
|
# We want to ignore the following directories since they are already
|
||||||
|
@ -131,9 +131,9 @@ Temporary = +pugt ;
|
||||||
rulename = "OS Boot and Configuration Files",
|
rulename = "OS Boot and Configuration Files",
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/boot -> $(ReadOnly) ;
|
/boot -> $(SEC_READONLY) ;
|
||||||
/bsd -> $(ReadOnly) ;
|
/bsd -> $(SEC_READONLY) ;
|
||||||
/etc -> $(IgnoreNone) -SHa ;
|
/etc -> $(SEC_IGNORE_NONE) -SHa ;
|
||||||
}
|
}
|
||||||
|
|
||||||
###################################################
|
###################################################
|
||||||
|
@ -147,13 +147,13 @@ Temporary = +pugt ;
|
||||||
rulename = "Mount Points",
|
rulename = "Mount Points",
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/ -> $(ReadOnly) ;
|
/ -> $(SEC_READONLY) ;
|
||||||
/cdrom -> $(Dynamic) ;
|
/cdrom -> $(SEC_DYNAMIC) ;
|
||||||
/floppy -> $(Dynamic) ;
|
/floppy -> $(SEC_DYNAMIC) ;
|
||||||
/home -> $(ReadOnly) ; # Modify as needed
|
/home -> $(SEC_READONLY) ; # Modify as needed
|
||||||
/mnt -> $(Dynamic) ;
|
/mnt -> $(SEC_DYNAMIC) ;
|
||||||
/usr -> $(ReadOnly) ;
|
/usr -> $(SEC_READONLY) ;
|
||||||
/var -> $(ReadOnly) ;
|
/var -> $(SEC_READONLY) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
###################################################
|
###################################################
|
||||||
|
@ -167,8 +167,8 @@ Temporary = +pugt ;
|
||||||
rulename = "Misc Top-Level Directories",
|
rulename = "Misc Top-Level Directories",
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/altroot -> $(Dynamic) ;
|
/altroot -> $(SEC_DYNAMIC) ;
|
||||||
/stand -> $(Dynamic) ;
|
/stand -> $(SEC_DYNAMIC) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
################################################
|
################################################
|
||||||
|
@ -182,10 +182,10 @@ Temporary = +pugt ;
|
||||||
rulename = "System Devices",
|
rulename = "System Devices",
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/dev -> $(Device) ;
|
/dev -> $(SEC_DEVICE) ;
|
||||||
/dev/fd -> $(Device) ;
|
/dev/fd -> $(SEC_DEVICE) ;
|
||||||
/var/cron/tabs/.sock -> $(Device) ;
|
/var/cron/tabs/.sock -> $(SEC_DEVICE) ;
|
||||||
/var/empty/dev/log -> $(Device) ;
|
/var/empty/dev/log -> $(SEC_DEVICE) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
################################################
|
################################################
|
||||||
|
@ -199,14 +199,14 @@ Temporary = +pugt ;
|
||||||
rulename = "OS Binaries and Libraries",
|
rulename = "OS Binaries and Libraries",
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/bin -> $(ReadOnly) ;
|
/bin -> $(SEC_READONLY) ;
|
||||||
/sbin -> $(ReadOnly) ;
|
/sbin -> $(SEC_READONLY) ;
|
||||||
/usr/bin -> $(ReadOnly) ;
|
/usr/bin -> $(SEC_READONLY) ;
|
||||||
/usr/lib -> $(ReadOnly) ;
|
/usr/lib -> $(SEC_READONLY) ;
|
||||||
/usr/libexec -> $(ReadOnly) ;
|
/usr/libexec -> $(SEC_READONLY) ;
|
||||||
/usr/sbin -> $(ReadOnly) ;
|
/usr/sbin -> $(SEC_READONLY) ;
|
||||||
/usr/X11R6/bin -> $(ReadOnly) ;
|
/usr/X11R6/bin -> $(SEC_READONLY) ;
|
||||||
/usr/X11R6/lib -> $(ReadOnly) ;
|
/usr/X11R6/lib -> $(SEC_READONLY) ;
|
||||||
}
|
}
|
||||||
################################################
|
################################################
|
||||||
# ##
|
# ##
|
||||||
|
@ -219,19 +219,19 @@ Temporary = +pugt ;
|
||||||
#OKrulename = "Usr Local Files",
|
#OKrulename = "Usr Local Files",
|
||||||
#OK)
|
#OK)
|
||||||
#OK{
|
#OK{
|
||||||
#OK/usr/local -> $(ReadOnly) ;
|
#OK/usr/local -> $(SEC_READONLY) ;
|
||||||
#OK/usr/local/bin -> $(ReadOnly) ;
|
#OK/usr/local/bin -> $(SEC_READONLY) ;
|
||||||
#OK/usr/local/doc -> $(ReadOnly) ;
|
#OK/usr/local/doc -> $(SEC_READONLY) ;
|
||||||
#OK/usr/local/etc -> $(ReadOnly) ;
|
#OK/usr/local/etc -> $(SEC_READONLY) ;
|
||||||
#OK/usr/local/include -> $(ReadOnly) ;
|
#OK/usr/local/include -> $(SEC_READONLY) ;
|
||||||
#OK/usr/local/info -> $(ReadOnly) ;
|
#OK/usr/local/info -> $(SEC_READONLY) ;
|
||||||
#OK/usr/local/lib -> $(ReadOnly) ;
|
#OK/usr/local/lib -> $(SEC_READONLY) ;
|
||||||
#OK/usr/local/libdata -> $(ReadOnly) ;
|
#OK/usr/local/libdata -> $(SEC_READONLY) ;
|
||||||
#OK/usr/local/libexec -> $(ReadOnly) ;
|
#OK/usr/local/libexec -> $(SEC_READONLY) ;
|
||||||
#OK/usr/local/man -> $(ReadOnly) ;
|
#OK/usr/local/man -> $(SEC_READONLY) ;
|
||||||
#OK/usr/local/sbin -> $(ReadOnly) ;
|
#OK/usr/local/sbin -> $(SEC_READONLY) ;
|
||||||
#OK/usr/local/share -> $(ReadOnly) ;
|
#OK/usr/local/share -> $(SEC_READONLY) ;
|
||||||
#OK/usr/local/src -> $(ReadOnly) ;
|
#OK/usr/local/src -> $(SEC_READONLY) ;
|
||||||
#OK}
|
#OK}
|
||||||
|
|
||||||
################################################
|
################################################
|
||||||
|
@ -245,9 +245,9 @@ Temporary = +pugt ;
|
||||||
rulename = "Root Directory and Files",
|
rulename = "Root Directory and Files",
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/root -> $(IgnoreNone) -SHa ;
|
/root -> $(SEC_IGNORE_NONE) -SHa ;
|
||||||
/root/.cshrc -> $(Dynamic) ;
|
/root/.cshrc -> $(SEC_DYNAMIC) ;
|
||||||
/root/.profile -> $(Dynamic) ;
|
/root/.profile -> $(SEC_DYNAMIC) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
################################################
|
################################################
|
||||||
|
@ -261,8 +261,8 @@ Temporary = +pugt ;
|
||||||
rulename = "Temporary Directories",
|
rulename = "Temporary Directories",
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/tmp -> $(Temporary) ;
|
/tmp -> $(SEC_TEMPORARY) ;
|
||||||
/var/tmp -> $(Temporary) ;
|
/var/tmp -> $(SEC_TEMPORARY) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
################################################
|
################################################
|
||||||
|
@ -276,15 +276,15 @@ Temporary = +pugt ;
|
||||||
rulename = "System and Boot Changes",
|
rulename = "System and Boot Changes",
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/var/backups -> $(Dynamic) -i ;
|
/var/backups -> $(SEC_DYNAMIC) -i ;
|
||||||
/var/db/host.random -> $(ReadOnly) -mCM ;
|
/var/db/host.random -> $(SEC_READONLY) -mCM ;
|
||||||
/var/cron -> $(Growing) -i ;
|
/var/cron -> $(SEC_GROWING) -i ;
|
||||||
/var/log -> $(Growing) -i ;
|
/var/log -> $(SEC_GROWING) -i ;
|
||||||
/var/run -> $(Dynamic) -i ;
|
/var/run -> $(SEC_DYNAMIC) -i ;
|
||||||
/var/mail -> $(Growing) ;
|
/var/mail -> $(SEC_GROWING) ;
|
||||||
/var/msgs/bounds -> $(ReadOnly) -smbCM ;
|
/var/msgs/bounds -> $(SEC_READONLY) -smbCM ;
|
||||||
/var/spool/clientmqueue -> $(Temporary) ;
|
/var/spool/clientmqueue -> $(SEC_TEMPORARY) ;
|
||||||
/var/spool/mqueue -> $(Temporary) ;
|
/var/spool/mqueue -> $(SEC_TEMPORARY) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
|
@ -54,16 +54,24 @@ TWREPORT=;
|
||||||
HOSTNAME=;
|
HOSTNAME=;
|
||||||
|
|
||||||
@@section FS
|
@@section FS
|
||||||
SEC_CRIT = $(IgnoreNone)-SHa ; # Critical files that cannot change
|
SEC_DEVICE = +pugsdr-intlbamcCMSH ;
|
||||||
SEC_SUID = $(IgnoreNone)-SHa ; # Binaries with the SUID or SGID flags set
|
SEC_DYNAMIC = +pinugtd-srlbamcCMSH ;
|
||||||
SEC_BIN = $(ReadOnly) ; # Binaries that should not change
|
SEC_GROWING = +pinugtdl-srbamcCMSH ;
|
||||||
SEC_CONFIG = $(Dynamic) ; # Config files that are changed infrequently but accessed often
|
SEC_IGNORE_ALL = -pinugtsdrlbamcCMSH ;
|
||||||
SEC_TTY = $(Dynamic)-ugp ; # Tty files that change ownership at login
|
SEC_IGNORE_NONE = +pinugtsdrbamcCMSH-l ;
|
||||||
SEC_LOG = $(Growing) ; # Files that grow, but that should never change ownership
|
SEC_READONLY = +pinugtsdbmCM-rlacSH ;
|
||||||
SEC_INVARIANT = +tpug ; # Directories that should never change permission or ownership
|
SEC_TEMPORARY = +pugt ;
|
||||||
SIG_LOW = 33 ; # Non-critical files that are of minimal security impact
|
|
||||||
SIG_MED = 66 ; # Non-critical files that are of significant security impact
|
SEC_CRIT = $(SEC_IGNORE_NONE)-SHa ; # Critical files that cannot change
|
||||||
SIG_HI = 100 ; # Critical files that are significant points of vulnerability
|
SEC_SUID = $(SEC_IGNORE_NONE)-SHa ; # Binaries with the SUID or SGID flags set
|
||||||
|
SEC_BIN = $(SEC_READONLY) ; # Binaries that should not change
|
||||||
|
SEC_CONFIG = $(SEC_DYNAMIC) ; # Config files that are changed infrequently but accessed often
|
||||||
|
SEC_TTY = $(SEC_DYNAMIC)-ugp ; # Tty files that change ownership at login
|
||||||
|
SEC_LOG = $(SEC_GROWING) ; # Files that grow, but that should never change ownership
|
||||||
|
SEC_INVARIANT = $(SEC_TEMPORARY) ; # Directories that should never change permission or ownership
|
||||||
|
SIG_LOW = 33 ; # Non-critical files that are of minimal security impact
|
||||||
|
SIG_MED = 66 ; # Non-critical files that are of significant security impact
|
||||||
|
SIG_HI = 100 ; # Critical files that are significant points of vulnerability
|
||||||
|
|
||||||
|
|
||||||
# Tripwire Binaries
|
# Tripwire Binaries
|
||||||
|
@ -630,7 +638,7 @@ SIG_HI = 100 ; # Critical files that are significant point
|
||||||
|
|
||||||
#=============================================================================
|
#=============================================================================
|
||||||
#
|
#
|
||||||
# Copyright 2000-2017 Tripwire, Inc. Tripwire is a registered trademark of Tripwire,
|
# Copyright 2000-2018 Tripwire, Inc. Tripwire is a registered trademark of Tripwire,
|
||||||
# Inc. in the United States and other countries. All rights reserved.
|
# Inc. in the United States and other countries. All rights reserved.
|
||||||
#
|
#
|
||||||
# FreeBSD is a registered trademark of the FreeBSD Project Inc.
|
# FreeBSD is a registered trademark of the FreeBSD Project Inc.
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
# ##
|
# ##
|
||||||
############################################################################## #
|
############################################################################## #
|
||||||
# # #
|
# # #
|
||||||
# Policy file for OpenBSD 3.5 # #
|
# Tripwire 2.4 policy for OpenBSD # #
|
||||||
# May 20, 2003 # #
|
# updated March 2018 # #
|
||||||
# ##
|
# ##
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
|
@ -60,13 +60,13 @@ HOSTNAME=;
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
Device = +pugsdr-intlbamcCMSH ;
|
SEC_DEVICE = +pugsdr-intlbamcCMSH ;
|
||||||
Dynamic = +pinugtd-srlbamcCMSH ;
|
SEC_DYNAMIC = +pinugtd-srlbamcCMSH ;
|
||||||
Growing = +pinugtdl-srbamcCMSH ;
|
SEC_GROWING = +pinugtdl-srbamcCMSH ;
|
||||||
IgnoreAll = -pinugtsdrlbamcCMSH ;
|
SEC_IGNORE_ALL = -pinugtsdrlbamcCMSH ;
|
||||||
IgnoreNone = +pinugtsdrbamcCMSH-l ;
|
SEC_IGNORE_NONE = +pinugtsdrbamcCMSH-l ;
|
||||||
ReadOnly = +pinugtsdbmCM-rlacSH ;
|
SEC_READONLY = +pinugtsdbmCM-rlacSH ;
|
||||||
Temporary = +pugt ;
|
SEC_TEMPORARY = +pugt ;
|
||||||
|
|
||||||
@@section FS
|
@@section FS
|
||||||
|
|
||||||
|
@ -83,10 +83,10 @@ Temporary = +pugt ;
|
||||||
rulename = "Tripwire Binaries",
|
rulename = "Tripwire Binaries",
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
$(TWBIN)/siggen -> $(ReadOnly) ;
|
$(TWBIN)/siggen -> $(SEC_READONLY) ;
|
||||||
$(TWBIN)/tripwire -> $(ReadOnly) ;
|
$(TWBIN)/tripwire -> $(SEC_READONLY) ;
|
||||||
$(TWBIN)/twadmin -> $(ReadOnly) ;
|
$(TWBIN)/twadmin -> $(SEC_READONLY) ;
|
||||||
$(TWBIN)/twprint -> $(ReadOnly) ;
|
$(TWBIN)/twprint -> $(SEC_READONLY) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Tripwire Data Files - Configuration Files, Policy Files, Keys, Reports, Databases
|
# Tripwire Data Files - Configuration Files, Policy Files, Keys, Reports, Databases
|
||||||
|
@ -103,14 +103,14 @@ Temporary = +pugt ;
|
||||||
# afterward triggers this rule until a database update is run, since the
|
# afterward triggers this rule until a database update is run, since the
|
||||||
# database file does not exist before that point.
|
# database file does not exist before that point.
|
||||||
|
|
||||||
$(TWDB) -> $(Dynamic) -i ;
|
$(TWDB) -> $(SEC_DYNAMIC) -i ;
|
||||||
$(TWPOL)/tw.pol -> $(ReadOnly) -i ;
|
$(TWPOL)/tw.pol -> $(SEC_READONLY) -i ;
|
||||||
$(TWPOL)/tw.cfg -> $(ReadOnly) -i ;
|
$(TWPOL)/tw.cfg -> $(SEC_READONLY) -i ;
|
||||||
$(TWLKEY)/$(HOSTNAME)-local.key -> $(ReadOnly) ;
|
$(TWLKEY)/$(HOSTNAME)-local.key -> $(SEC_READONLY) ;
|
||||||
$(TWSKEY)/site.key -> $(ReadOnly) ;
|
$(TWSKEY)/site.key -> $(SEC_READONLY) ;
|
||||||
|
|
||||||
# don't scan the individual reports
|
# don't scan the individual reports
|
||||||
$(TWREPORT) -> $(Dynamic) (recurse=0) ;
|
$(TWREPORT) -> $(SEC_DYNAMIC) (recurse=0) ;
|
||||||
|
|
||||||
# In this configuration /usr/local is a symbolic link to /home/local.
|
# In this configuration /usr/local is a symbolic link to /home/local.
|
||||||
# We want to ignore the following directories since they are already
|
# We want to ignore the following directories since they are already
|
||||||
|
@ -131,9 +131,9 @@ Temporary = +pugt ;
|
||||||
rulename = "OS Boot and Configuration Files",
|
rulename = "OS Boot and Configuration Files",
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/boot -> $(ReadOnly) ;
|
/boot -> $(SEC_READONLY) ;
|
||||||
/bsd -> $(ReadOnly) ;
|
/bsd -> $(SEC_READONLY) ;
|
||||||
/etc -> $(IgnoreNone) -SHa ;
|
/etc -> $(SEC_IGNORE_NONE) -SHa ;
|
||||||
}
|
}
|
||||||
|
|
||||||
###################################################
|
###################################################
|
||||||
|
@ -147,13 +147,13 @@ Temporary = +pugt ;
|
||||||
rulename = "Mount Points",
|
rulename = "Mount Points",
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/ -> $(ReadOnly) ;
|
/ -> $(SEC_READONLY) ;
|
||||||
/cdrom -> $(Dynamic) ;
|
/cdrom -> $(SEC_DYNAMIC) ;
|
||||||
/floppy -> $(Dynamic) ;
|
/floppy -> $(SEC_DYNAMIC) ;
|
||||||
/home -> $(ReadOnly) ; # Modify as needed
|
/home -> $(SEC_READONLY) ; # Modify as needed
|
||||||
/mnt -> $(Dynamic) ;
|
/mnt -> $(SEC_DYNAMIC) ;
|
||||||
/usr -> $(ReadOnly) ;
|
/usr -> $(SEC_READONLY) ;
|
||||||
/var -> $(ReadOnly) ;
|
/var -> $(SEC_READONLY) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
###################################################
|
###################################################
|
||||||
|
@ -167,8 +167,8 @@ Temporary = +pugt ;
|
||||||
rulename = "Misc Top-Level Directories",
|
rulename = "Misc Top-Level Directories",
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/altroot -> $(Dynamic) ;
|
/altroot -> $(SEC_DYNAMIC) ;
|
||||||
/stand -> $(Dynamic) ;
|
/stand -> $(SEC_DYNAMIC) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
################################################
|
################################################
|
||||||
|
@ -182,10 +182,10 @@ Temporary = +pugt ;
|
||||||
rulename = "System Devices",
|
rulename = "System Devices",
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/dev -> $(Device) ;
|
/dev -> $(SEC_DEVICE) ;
|
||||||
/dev/fd -> $(Device) ;
|
/dev/fd -> $(SEC_DEVICE) ;
|
||||||
/var/cron/tabs/.sock -> $(Device) ;
|
/var/cron/tabs/.sock -> $(SEC_DEVICE) ;
|
||||||
/var/empty/dev/log -> $(Device) ;
|
/var/empty/dev/log -> $(SEC_DEVICE) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
################################################
|
################################################
|
||||||
|
@ -199,14 +199,14 @@ Temporary = +pugt ;
|
||||||
rulename = "OS Binaries and Libraries",
|
rulename = "OS Binaries and Libraries",
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/bin -> $(ReadOnly) ;
|
/bin -> $(SEC_READONLY) ;
|
||||||
/sbin -> $(ReadOnly) ;
|
/sbin -> $(SEC_READONLY) ;
|
||||||
/usr/bin -> $(ReadOnly) ;
|
/usr/bin -> $(SEC_READONLY) ;
|
||||||
/usr/lib -> $(ReadOnly) ;
|
/usr/lib -> $(SEC_READONLY) ;
|
||||||
/usr/libexec -> $(ReadOnly) ;
|
/usr/libexec -> $(SEC_READONLY) ;
|
||||||
/usr/sbin -> $(ReadOnly) ;
|
/usr/sbin -> $(SEC_READONLY) ;
|
||||||
/usr/X11R6/bin -> $(ReadOnly) ;
|
/usr/X11R6/bin -> $(SEC_READONLY) ;
|
||||||
/usr/X11R6/lib -> $(ReadOnly) ;
|
/usr/X11R6/lib -> $(SEC_READONLY) ;
|
||||||
}
|
}
|
||||||
################################################
|
################################################
|
||||||
# ##
|
# ##
|
||||||
|
@ -219,19 +219,19 @@ Temporary = +pugt ;
|
||||||
#OKrulename = "Usr Local Files",
|
#OKrulename = "Usr Local Files",
|
||||||
#OK)
|
#OK)
|
||||||
#OK{
|
#OK{
|
||||||
#OK/usr/local -> $(ReadOnly) ;
|
#OK/usr/local -> $(SEC_READONLY) ;
|
||||||
#OK/usr/local/bin -> $(ReadOnly) ;
|
#OK/usr/local/bin -> $(SEC_READONLY) ;
|
||||||
#OK/usr/local/doc -> $(ReadOnly) ;
|
#OK/usr/local/doc -> $(SEC_READONLY) ;
|
||||||
#OK/usr/local/etc -> $(ReadOnly) ;
|
#OK/usr/local/etc -> $(SEC_READONLY) ;
|
||||||
#OK/usr/local/include -> $(ReadOnly) ;
|
#OK/usr/local/include -> $(SEC_READONLY) ;
|
||||||
#OK/usr/local/info -> $(ReadOnly) ;
|
#OK/usr/local/info -> $(SEC_READONLY) ;
|
||||||
#OK/usr/local/lib -> $(ReadOnly) ;
|
#OK/usr/local/lib -> $(SEC_READONLY) ;
|
||||||
#OK/usr/local/libdata -> $(ReadOnly) ;
|
#OK/usr/local/libdata -> $(SEC_READONLY) ;
|
||||||
#OK/usr/local/libexec -> $(ReadOnly) ;
|
#OK/usr/local/libexec -> $(SEC_READONLY) ;
|
||||||
#OK/usr/local/man -> $(ReadOnly) ;
|
#OK/usr/local/man -> $(SEC_READONLY) ;
|
||||||
#OK/usr/local/sbin -> $(ReadOnly) ;
|
#OK/usr/local/sbin -> $(SEC_READONLY) ;
|
||||||
#OK/usr/local/share -> $(ReadOnly) ;
|
#OK/usr/local/share -> $(SEC_READONLY) ;
|
||||||
#OK/usr/local/src -> $(ReadOnly) ;
|
#OK/usr/local/src -> $(SEC_READONLY) ;
|
||||||
#OK}
|
#OK}
|
||||||
|
|
||||||
################################################
|
################################################
|
||||||
|
@ -245,9 +245,9 @@ Temporary = +pugt ;
|
||||||
rulename = "Root Directory and Files",
|
rulename = "Root Directory and Files",
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/root -> $(IgnoreNone) -SHa ;
|
/root -> $(SEC_IGNORE_NONE) -SHa ;
|
||||||
/root/.cshrc -> $(Dynamic) ;
|
/root/.cshrc -> $(SEC_DYNAMIC) ;
|
||||||
/root/.profile -> $(Dynamic) ;
|
/root/.profile -> $(SEC_DYNAMIC) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
################################################
|
################################################
|
||||||
|
@ -261,8 +261,8 @@ Temporary = +pugt ;
|
||||||
rulename = "Temporary Directories",
|
rulename = "Temporary Directories",
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/tmp -> $(Temporary) ;
|
/tmp -> $(SEC_TEMPORARY) ;
|
||||||
/var/tmp -> $(Temporary) ;
|
/var/tmp -> $(SEC_TEMPORARY) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
################################################
|
################################################
|
||||||
|
@ -276,15 +276,15 @@ Temporary = +pugt ;
|
||||||
rulename = "System and Boot Changes",
|
rulename = "System and Boot Changes",
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/var/backups -> $(Dynamic) -i ;
|
/var/backups -> $(SEC_DYNAMIC) -i ;
|
||||||
/var/db/host.random -> $(ReadOnly) -mCM ;
|
/var/db/host.random -> $(SEC_READONLY) -mCM ;
|
||||||
/var/cron -> $(Growing) -i ;
|
/var/cron -> $(SEC_GROWING) -i ;
|
||||||
/var/log -> $(Growing) -i ;
|
/var/log -> $(SEC_GROWING) -i ;
|
||||||
/var/run -> $(Dynamic) -i ;
|
/var/run -> $(SEC_DYNAMIC) -i ;
|
||||||
/var/mail -> $(Growing) ;
|
/var/mail -> $(SEC_GROWING) ;
|
||||||
/var/msgs/bounds -> $(ReadOnly) -smbCM ;
|
/var/msgs/bounds -> $(SEC_READONLY) -smbCM ;
|
||||||
/var/spool/clientmqueue -> $(Temporary) ;
|
/var/spool/clientmqueue -> $(SEC_TEMPORARY) ;
|
||||||
/var/spool/mqueue -> $(Temporary) ;
|
/var/spool/mqueue -> $(SEC_TEMPORARY) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
# ##
|
# ##
|
||||||
############################################################################## #
|
############################################################################## #
|
||||||
# # #
|
# # #
|
||||||
# Policy file for Solaris 8 # #
|
# Tripwire 2.4 policy for Solaris # #
|
||||||
|
# updated March 2018 # #
|
||||||
# ##
|
# ##
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
|
@ -61,13 +62,13 @@ HOSTNAME=;
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
Device = +pugsdr-intlbamcCMSH ;
|
SEC_DEVICE = +pugsdr-intlbamcCMSH ;
|
||||||
Dynamic = +pinugtd-srlbamcCMSH ;
|
SEC_DYNAMIC = +pinugtd-srlbamcCMSH ;
|
||||||
Growing = +pinugtdl-srbamcCMSH ;
|
SEC_GROWING = +pinugtdl-srbamcCMSH ;
|
||||||
IgnoreAll = -pinugtsdrlbamcCMSH ;
|
SEC_IGNORE_ALL = -pinugtsdrlbamcCMSH ;
|
||||||
IgnoreNone = +pinugtsdrbamcCMSH-l ;
|
SEC_IGNORE_NONE = +pinugtsdrbamcCMSH-l ;
|
||||||
ReadOnly = +pinugtsdbmCM-rlacSH ;
|
SEC_READONLY = +pinugtsdbmCM-rlacSH ;
|
||||||
Temporary = +pugt ;
|
SEC_TEMPORARY = +pugt ;
|
||||||
|
|
||||||
@@section FS
|
@@section FS
|
||||||
|
|
||||||
|
@ -84,10 +85,10 @@ Temporary = +pugt ;
|
||||||
rulename = "Tripwire Binaries",
|
rulename = "Tripwire Binaries",
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
$(TWBIN)/siggen -> $(ReadOnly) ;
|
$(TWBIN)/siggen -> $(SEC_READONLY) ;
|
||||||
$(TWBIN)/tripwire -> $(ReadOnly) ;
|
$(TWBIN)/tripwire -> $(SEC_READONLY) ;
|
||||||
$(TWBIN)/twadmin -> $(ReadOnly) ;
|
$(TWBIN)/twadmin -> $(SEC_READONLY) ;
|
||||||
$(TWBIN)/twprint -> $(ReadOnly) ;
|
$(TWBIN)/twprint -> $(SEC_READONLY) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Tripwire Data Files - Configuration Files, Policy Files, Keys, Reports, Databases
|
# Tripwire Data Files - Configuration Files, Policy Files, Keys, Reports, Databases
|
||||||
|
@ -104,14 +105,14 @@ Temporary = +pugt ;
|
||||||
# afterward triggers this rule until a database update is run, since the
|
# afterward triggers this rule until a database update is run, since the
|
||||||
# database file does not exist before that point.
|
# database file does not exist before that point.
|
||||||
|
|
||||||
$(TWDB) -> $(Dynamic) -i ;
|
$(TWDB) -> $(SEC_DYNAMIC) -i ;
|
||||||
$(TWPOL)/tw.pol -> $(ReadOnly) -i ;
|
$(TWPOL)/tw.pol -> $(SEC_READONLY) -i ;
|
||||||
$(TWPOL)/tw.cfg -> $(ReadOnly) -i ;
|
$(TWPOL)/tw.cfg -> $(SEC_READONLY) -i ;
|
||||||
$(TWLKEY)/$(HOSTNAME)-local.key -> $(ReadOnly) ;
|
$(TWLKEY)/$(HOSTNAME)-local.key -> $(SEC_READONLY) ;
|
||||||
$(TWSKEY)/site.key -> $(ReadOnly) ;
|
$(TWSKEY)/site.key -> $(SEC_READONLY) ;
|
||||||
|
|
||||||
# don't scan the individual reports
|
# don't scan the individual reports
|
||||||
$(TWREPORT) -> $(Dynamic) (recurse=0) ;
|
$(TWREPORT) -> $(SEC_DYNAMIC) (recurse=0) ;
|
||||||
|
|
||||||
# In this configuration /usr/local is a symbolic link to /home/local.
|
# In this configuration /usr/local is a symbolic link to /home/local.
|
||||||
# We want to ignore the following directories since they are already
|
# We want to ignore the following directories since they are already
|
||||||
|
@ -132,8 +133,8 @@ Temporary = +pugt ;
|
||||||
rulename = "OS Boot and Configuration Files",
|
rulename = "OS Boot and Configuration Files",
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/etc -> $(IgnoreNone) -SHa ;
|
/etc -> $(SEC_IGNORE_NONE) -SHa ;
|
||||||
/kernel -> $(ReadOnly) ;
|
/kernel -> $(SEC_READONLY) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
###################################################
|
###################################################
|
||||||
|
@ -147,13 +148,13 @@ Temporary = +pugt ;
|
||||||
rulename = "Mount Points",
|
rulename = "Mount Points",
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/ -> $(ReadOnly) ;
|
/ -> $(SEC_READONLY) ;
|
||||||
/cdrom -> $(Dynamic) ;
|
/cdrom -> $(SEC_DYNAMIC) ;
|
||||||
/home -> $(ReadOnly) ;
|
/home -> $(SEC_READONLY) ;
|
||||||
/mnt -> $(Dynamic) ;
|
/mnt -> $(SEC_DYNAMIC) ;
|
||||||
/usr -> $(ReadOnly) ;
|
/usr -> $(SEC_READONLY) ;
|
||||||
/var -> $(ReadOnly) ;
|
/var -> $(SEC_READONLY) ;
|
||||||
/opt -> $(ReadOnly) ;
|
/opt -> $(SEC_READONLY) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
###################################################
|
###################################################
|
||||||
|
@ -167,7 +168,7 @@ Temporary = +pugt ;
|
||||||
rulename = "Misc Top-Level Directories",
|
rulename = "Misc Top-Level Directories",
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/lost+found -> $(ReadOnly) ;
|
/lost+found -> $(SEC_READONLY) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
################################################
|
################################################
|
||||||
|
@ -181,8 +182,8 @@ Temporary = +pugt ;
|
||||||
rulename = "System Devices",
|
rulename = "System Devices",
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/dev -> $(Device) ;
|
/dev -> $(SEC_DEVICE) ;
|
||||||
/devices -> $(Device) ;
|
/devices -> $(SEC_DEVICE) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
################################################
|
################################################
|
||||||
|
@ -196,12 +197,12 @@ Temporary = +pugt ;
|
||||||
rulename = "OS Binaries and Libraries",
|
rulename = "OS Binaries and Libraries",
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/sbin -> $(ReadOnly) ;
|
/sbin -> $(SEC_READONLY) ;
|
||||||
/usr/bin -> $(ReadOnly) ;
|
/usr/bin -> $(SEC_READONLY) ;
|
||||||
/usr/lib -> $(ReadOnly) ;
|
/usr/lib -> $(SEC_READONLY) ;
|
||||||
/usr/sbin -> $(ReadOnly) ;
|
/usr/sbin -> $(SEC_READONLY) ;
|
||||||
/usr/openwin/bin -> $(ReadOnly) ;
|
/usr/openwin/bin -> $(SEC_READONLY) ;
|
||||||
/usr/openwin/lib -> $(ReadOnly) ;
|
/usr/openwin/lib -> $(SEC_READONLY) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
################################################
|
################################################
|
||||||
|
@ -216,9 +217,9 @@ Temporary = +pugt ;
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
! /.netscape/cache ;
|
! /.netscape/cache ;
|
||||||
/.bash_history -> $(ReadOnly) -smbCM;
|
/.bash_history -> $(SEC_READONLY) -smbCM;
|
||||||
/.sh_history -> $(Dynamic) ;
|
/.sh_history -> $(SEC_DYNAMIC) ;
|
||||||
/.Xauthority -> $(ReadOnly) ;
|
/.Xauthority -> $(SEC_READONLY) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
################################################
|
################################################
|
||||||
|
@ -232,8 +233,8 @@ Temporary = +pugt ;
|
||||||
rulename = "Temporary Directories",
|
rulename = "Temporary Directories",
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/tmp -> $(Temporary) ;
|
/tmp -> $(SEC_TEMPORARY) ;
|
||||||
/var/tmp -> $(Temporary) ;
|
/var/tmp -> $(SEC_TEMPORARY) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
################################################
|
################################################
|
||||||
|
@ -295,17 +296,17 @@ Temporary = +pugt ;
|
||||||
rulename = "System and Boot Changes",
|
rulename = "System and Boot Changes",
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/etc/.pwd.lock -> $(ReadOnly) -cm;
|
/etc/.pwd.lock -> $(SEC_READONLY) -cm;
|
||||||
/etc/coreadm.conf -> $(ReadOnly) -cm;
|
/etc/coreadm.conf -> $(SEC_READONLY) -cm;
|
||||||
/var/adm -> $(Growing) -i;
|
/var/adm -> $(SEC_GROWING) -i;
|
||||||
#/var/backups -> $(Dynamic) -i ;
|
#/var/backups -> $(SEC_DYNAMIC) -i ;
|
||||||
/var/cron/log -> $(Growing) -i ;
|
/var/cron/log -> $(SEC_GROWING) -i ;
|
||||||
#/var/db/host.random -> $(ReadOnly) -mCM ;
|
#/var/db/host.random -> $(SEC_READONLY) -mCM ;
|
||||||
#/var/db/locate.database -> $(ReadOnly) -misCM ;
|
#/var/db/locate.database -> $(SEC_READONLY) -misCM ;
|
||||||
/var/log -> $(Growing) -i ;
|
/var/log -> $(SEC_GROWING) -i ;
|
||||||
#/var/run -> $(Dynamic) -i ;
|
#/var/run -> $(SEC_DYNAMIC) -i ;
|
||||||
#/var/mail -> $(Growing) ;
|
#/var/mail -> $(SEC_GROWING) ;
|
||||||
#/var/msgs/bounds -> $(ReadOnly) -smbCM ;
|
#/var/msgs/bounds -> $(SEC_READONLY) -smbCM ;
|
||||||
!/var/sendmail ;
|
!/var/sendmail ;
|
||||||
!/var/spool/clientmqueue ;
|
!/var/spool/clientmqueue ;
|
||||||
!/var/spool/mqueue ;
|
!/var/spool/mqueue ;
|
||||||
|
|
|
@ -0,0 +1,184 @@
|
||||||
|
###############################################################################
|
||||||
|
# ##
|
||||||
|
# Default Tripwire 2.4 Policy file for Syllable ##
|
||||||
|
# ##
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# ##
|
||||||
|
# Global Variable Definitions ##
|
||||||
|
# ##
|
||||||
|
# These are defined at install time by the installation script. You may ##
|
||||||
|
# Manually edit these if you are using this file directly and not from the ##
|
||||||
|
# installation script itself. ##
|
||||||
|
# ##
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
@@section GLOBAL
|
||||||
|
TWROOT=;
|
||||||
|
TWBIN=;
|
||||||
|
TWPOL=;
|
||||||
|
TWDB=;
|
||||||
|
TWSKEY=;
|
||||||
|
TWLKEY=;
|
||||||
|
TWREPORT=;
|
||||||
|
HOSTNAME=;
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
# Predefined Variables #
|
||||||
|
##############################################################################
|
||||||
|
#
|
||||||
|
# Property Masks
|
||||||
|
#
|
||||||
|
# - ignore the following properties
|
||||||
|
# + check the following properties
|
||||||
|
#
|
||||||
|
# a access timestamp (mutually exclusive with +CMSH)
|
||||||
|
# b number of blocks allocated
|
||||||
|
# c inode creation/modification timestamp
|
||||||
|
# d ID of device on which inode resides
|
||||||
|
# g group id of owner
|
||||||
|
# i inode number
|
||||||
|
# l growing files (logfiles for example)
|
||||||
|
# m modification timestamp
|
||||||
|
# n number of links
|
||||||
|
# p permission and file mode bits
|
||||||
|
# r ID of device pointed to by inode (valid only for device objects)
|
||||||
|
# s file size
|
||||||
|
# t file type
|
||||||
|
# u user id of owner
|
||||||
|
#
|
||||||
|
# C CRC-32 hash
|
||||||
|
# H HAVAL hash
|
||||||
|
# M MD5 hash
|
||||||
|
# S SHA hash
|
||||||
|
#
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
SEC_DEVICE = +pugsdr-intlbamcCMSH ;
|
||||||
|
SEC_DYNAMIC = +pinugtd-srlbamcCMSH ;
|
||||||
|
SEC_GROWING = +pinugtdl-srbamcCMSH ;
|
||||||
|
SEC_IGNORE_ALL = -pinugtsdrlbamcCMSH ;
|
||||||
|
SEC_IGNORE_NONE = +pinugtsdrbamcCMSH-l ;
|
||||||
|
SEC_READONLY = +pinugtsdbmCM-rlacSH ;
|
||||||
|
SEC_TEMPORARY = +pugt ;
|
||||||
|
|
||||||
|
@@section FS
|
||||||
|
|
||||||
|
#########################################
|
||||||
|
# ##
|
||||||
|
# Tripwire Binaries and Data Files ##
|
||||||
|
# ##
|
||||||
|
#########################################
|
||||||
|
|
||||||
|
# Tripwire Binaries
|
||||||
|
(
|
||||||
|
rulename = "Tripwire Binaries",
|
||||||
|
)
|
||||||
|
{
|
||||||
|
$(TWBIN)/siggen -> $(SEC_READONLY) ;
|
||||||
|
$(TWBIN)/tripwire -> $(SEC_READONLY) ;
|
||||||
|
$(TWBIN)/twadmin -> $(SEC_READONLY) ;
|
||||||
|
$(TWBIN)/twprint -> $(SEC_READONLY) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Tripwire Data Files - Configuration Files, Policy Files, Keys, Reports, Databases
|
||||||
|
(
|
||||||
|
rulename = "Tripwire Data Files",
|
||||||
|
)
|
||||||
|
{
|
||||||
|
# NOTE: We remove the inode attribute because when Tripwire creates a backup,
|
||||||
|
# it does so by renaming the old file and creating a new one (which will
|
||||||
|
# have a new inode number). Inode is left turned on for keys, which shouldn't
|
||||||
|
# ever change.
|
||||||
|
|
||||||
|
# NOTE: The first integrity check triggers this rule and each integrity check
|
||||||
|
# afterward triggers this rule until a database update is run, since the
|
||||||
|
# database file does not exist before that point.
|
||||||
|
|
||||||
|
$(TWDB) -> $(SEC_DYNAMIC) -i ;
|
||||||
|
$(TWPOL)/tw.pol -> $(SEC_READONLY) -i ;
|
||||||
|
$(TWPOL)/tw.cfg -> $(SEC_READONLY) -i ;
|
||||||
|
$(TWLKEY)/$(HOSTNAME)-local.key -> $(SEC_READONLY) ;
|
||||||
|
$(TWSKEY)/site.key -> $(SEC_READONLY) ;
|
||||||
|
|
||||||
|
# don't scan the individual reports
|
||||||
|
$(TWREPORT) -> $(SEC_DYNAMIC) (recurse=0) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
|
||||||
|
### System dir ###############################################################
|
||||||
|
#
|
||||||
|
(rulename = "System Directory",)
|
||||||
|
{
|
||||||
|
/boot/system -> $(SEC_READONLY) -a;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
### Other bin dirs ############################################################
|
||||||
|
#
|
||||||
|
(rulename = "Binary Directories",)
|
||||||
|
{
|
||||||
|
/boot/bin -> $(SEC_READONLY) -a;
|
||||||
|
/usr/bin -> $(SEC_READONLY) -a;
|
||||||
|
/usr/local/bin -> $(SEC_READONLY) -a;
|
||||||
|
/boot/Applications -> $(SEC_READONLY) -a;
|
||||||
|
/resources/index/bin -> $(SEC_READONLY) -a;
|
||||||
|
}
|
||||||
|
|
||||||
|
(rulename = "Admin Binary Directories",)
|
||||||
|
{
|
||||||
|
/usr/local/sbin -> $(SEC_READONLY) -a;
|
||||||
|
/resources/index/sbin -> $(SEC_READONLY) -a;
|
||||||
|
/usr/local/libexec -> $(SEC_READONLY) -a;
|
||||||
|
/resources/index/libexec -> $(SEC_READONLY) -a;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
### Other lib dirs ############################################################
|
||||||
|
#
|
||||||
|
(rulename = "Library Directories",)
|
||||||
|
{
|
||||||
|
/usr/local/lib -> $(SEC_READONLY) -a;
|
||||||
|
/resources/index/lib -> $(SEC_READONLY) -a;
|
||||||
|
}
|
||||||
|
|
||||||
|
### Other boot dirs ###########################################################
|
||||||
|
#
|
||||||
|
(rulename = "Boot Directories",)
|
||||||
|
{
|
||||||
|
/boot/boot/grub -> $(SEC_READONLY) -a;
|
||||||
|
}
|
||||||
|
|
||||||
|
### Settings ##################################################################
|
||||||
|
#
|
||||||
|
(rulename = "Settings",)
|
||||||
|
{
|
||||||
|
/boot/etc -> $(SEC_READONLY) -a;
|
||||||
|
/usr/local/etc -> $(SEC_READONLY) -a;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Logs ########################################################################
|
||||||
|
#
|
||||||
|
(rulename = "Logs",)
|
||||||
|
{
|
||||||
|
/var/log -> $(SEC_GROWING) -a;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Dev #########################################################################
|
||||||
|
#
|
||||||
|
(rulename = "Devices",)
|
||||||
|
{
|
||||||
|
/dev -> $(SEC_DEVICE) -a;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Temp dirs #########################
|
||||||
|
#
|
||||||
|
(rulename = "Temp Directories",)
|
||||||
|
{
|
||||||
|
/boot/tmp -> $(SEC_TEMPORARY) -a;
|
||||||
|
}
|
|
@ -0,0 +1,183 @@
|
||||||
|
###############################################################################
|
||||||
|
# ##
|
||||||
|
# Default Tripwire 2.4 Policy file for SkyOS ##
|
||||||
|
# ##
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# ##
|
||||||
|
# Global Variable Definitions ##
|
||||||
|
# ##
|
||||||
|
# These are defined at install time by the installation script. You may ##
|
||||||
|
# Manually edit these if you are using this file directly and not from the ##
|
||||||
|
# installation script itself. ##
|
||||||
|
# ##
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
@@section GLOBAL
|
||||||
|
TWROOT=;
|
||||||
|
TWBIN=;
|
||||||
|
TWPOL=;
|
||||||
|
TWDB=;
|
||||||
|
TWSKEY=;
|
||||||
|
TWLKEY=;
|
||||||
|
TWREPORT=;
|
||||||
|
HOSTNAME=;
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
# Predefined Variables #
|
||||||
|
##############################################################################
|
||||||
|
#
|
||||||
|
# Property Masks
|
||||||
|
#
|
||||||
|
# - ignore the following properties
|
||||||
|
# + check the following properties
|
||||||
|
#
|
||||||
|
# a access timestamp (mutually exclusive with +CMSH)
|
||||||
|
# b number of blocks allocated
|
||||||
|
# c inode creation/modification timestamp
|
||||||
|
# d ID of device on which inode resides
|
||||||
|
# g group id of owner
|
||||||
|
# i inode number
|
||||||
|
# l growing files (logfiles for example)
|
||||||
|
# m modification timestamp
|
||||||
|
# n number of links
|
||||||
|
# p permission and file mode bits
|
||||||
|
# r ID of device pointed to by inode (valid only for device objects)
|
||||||
|
# s file size
|
||||||
|
# t file type
|
||||||
|
# u user id of owner
|
||||||
|
#
|
||||||
|
# C CRC-32 hash
|
||||||
|
# H HAVAL hash
|
||||||
|
# M MD5 hash
|
||||||
|
# S SHA hash
|
||||||
|
#
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
SEC_DEVICE = +pugsdr-intlbamcCMSH ;
|
||||||
|
SEC_DYNAMIC = +pinugtd-srlbamcCMSH ;
|
||||||
|
SEC_GROWING = +pinugtdl-srbamcCMSH ;
|
||||||
|
SEC_IGNORE_ALL = -pinugtsdrlbamcCMSH ;
|
||||||
|
SEC_IGNORE_NONE = +pinugtsdrbamcCMSH-l ;
|
||||||
|
SEC_READONLY = +pinugtsdbmCM-rlacSH ;
|
||||||
|
SEC_TEMPORARY = +pugt ;
|
||||||
|
|
||||||
|
@@section FS
|
||||||
|
|
||||||
|
#########################################
|
||||||
|
# ##
|
||||||
|
# Tripwire Binaries and Data Files ##
|
||||||
|
# ##
|
||||||
|
#########################################
|
||||||
|
|
||||||
|
# Tripwire Binaries
|
||||||
|
(
|
||||||
|
rulename = "Tripwire Binaries",
|
||||||
|
)
|
||||||
|
{
|
||||||
|
$(TWBIN)/siggen -> $(SEC_READONLY) ;
|
||||||
|
$(TWBIN)/tripwire -> $(SEC_READONLY) ;
|
||||||
|
$(TWBIN)/twadmin -> $(SEC_READONLY) ;
|
||||||
|
$(TWBIN)/twprint -> $(SEC_READONLY) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Tripwire Data Files - Configuration Files, Policy Files, Keys, Reports, Databases
|
||||||
|
(
|
||||||
|
rulename = "Tripwire Data Files",
|
||||||
|
)
|
||||||
|
{
|
||||||
|
# NOTE: We remove the inode attribute because when Tripwire creates a backup,
|
||||||
|
# it does so by renaming the old file and creating a new one (which will
|
||||||
|
# have a new inode number). Inode is left turned on for keys, which shouldn't
|
||||||
|
# ever change.
|
||||||
|
|
||||||
|
# NOTE: The first integrity check triggers this rule and each integrity check
|
||||||
|
# afterward triggers this rule until a database update is run, since the
|
||||||
|
# database file does not exist before that point.
|
||||||
|
|
||||||
|
$(TWDB) -> $(SEC_DYNAMIC) -i ;
|
||||||
|
$(TWPOL)/tw.pol -> $(SEC_READONLY) -i ;
|
||||||
|
$(TWPOL)/tw.cfg -> $(SEC_READONLY) -i ;
|
||||||
|
$(TWLKEY)/$(HOSTNAME)-local.key -> $(SEC_READONLY) ;
|
||||||
|
$(TWSKEY)/site.key -> $(SEC_READONLY) ;
|
||||||
|
|
||||||
|
# don't scan the individual reports
|
||||||
|
$(TWREPORT) -> $(SEC_DYNAMIC) (recurse=0) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
|
||||||
|
### System dir ###############################################################
|
||||||
|
#
|
||||||
|
(rulename = "System Directory",)
|
||||||
|
{
|
||||||
|
/boot/system -> $(SEC_READONLY) -a;
|
||||||
|
/boot/system/registry.rsm -> $(SEC_READONLY) -am;
|
||||||
|
}
|
||||||
|
|
||||||
|
(rulename = "System Files",)
|
||||||
|
{
|
||||||
|
/boot/kernel.sys -> $(SEC_READONLY) -a;
|
||||||
|
/boot/kernel.dbg -> $(SEC_READONLY) -a;
|
||||||
|
/boot/init.scr -> $(SEC_READONLY) -a;
|
||||||
|
/boot/install.sif -> $(SEC_READONLY) -a;
|
||||||
|
}
|
||||||
|
|
||||||
|
### Other bin dirs ############################################################
|
||||||
|
#
|
||||||
|
(rulename = "Binary Directories",)
|
||||||
|
{
|
||||||
|
/boot/programs -> $(SEC_READONLY) -a;
|
||||||
|
}
|
||||||
|
|
||||||
|
### Other lib dirs ############################################################
|
||||||
|
#
|
||||||
|
(rulename = "Library Directories",)
|
||||||
|
{
|
||||||
|
/usr/lib -> $(SEC_READONLY) -a;
|
||||||
|
/usr/local/lib -> $(SEC_READONLY) -a;
|
||||||
|
}
|
||||||
|
|
||||||
|
### Other boot dirs ###########################################################
|
||||||
|
#
|
||||||
|
(rulename = "Boot Directories",)
|
||||||
|
{
|
||||||
|
/boot/boot/grub -> $(SEC_READONLY) -a;
|
||||||
|
}
|
||||||
|
|
||||||
|
### Settings ##################################################################
|
||||||
|
#
|
||||||
|
(rulename = "Settings",)
|
||||||
|
{
|
||||||
|
/boot/programs/unix/etc -> $(SEC_READONLY) -a;
|
||||||
|
/usr/local/etc -> $(SEC_READONLY) -a;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Logs ########################################################################
|
||||||
|
#
|
||||||
|
(rulename = "Logs",)
|
||||||
|
{
|
||||||
|
/var/log -> $(SEC_GROWING) -a;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Dev #########################################################################
|
||||||
|
#
|
||||||
|
(rulename = "Devices",)
|
||||||
|
{
|
||||||
|
/dev -> $(SEC_DEVICE) -a;
|
||||||
|
/fifo -> $(SEC_DEVICE) -a;
|
||||||
|
/pty -> $(SEC_DEVICE) -as;
|
||||||
|
/systeminterface -> $(SEC_DEVICE) -a;
|
||||||
|
/umfs -> $(SEC_DEVICE) -a;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Temp dirs #########################
|
||||||
|
#
|
||||||
|
(rulename = "Temp Directories",)
|
||||||
|
{
|
||||||
|
/boot/temp -> $(SEC_TEMPORARY) -a;
|
||||||
|
}
|
|
@ -1,2 +1 @@
|
||||||
#define BUILD_NUM _T("0")
|
#define BUILD_NUM _T("0")
|
||||||
|
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
//
|
//
|
||||||
// The developer of the original code and/or files is Tripwire, Inc.
|
// The developer of the original code and/or files is Tripwire, Inc.
|
||||||
// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire,
|
// Portions created by Tripwire, Inc. are copyright (C) 2000-2018 Tripwire,
|
||||||
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
||||||
// reserved.
|
// reserved.
|
||||||
//
|
//
|
||||||
// This program is free software. The contents of this file are subject
|
// 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
|
// 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
|
// Free Software Foundation; either version 2 of the License, or (at your
|
||||||
// option) any later version. You may redistribute it and/or modify it
|
// option) any later version. You may redistribute it and/or modify it
|
||||||
// only in compliance with the GNU General Public License.
|
// only in compliance with the GNU General Public License.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful.
|
// This program is distributed in the hope that it will be useful.
|
||||||
// However, this program is distributed AS-IS WITHOUT ANY
|
// However, this program is distributed AS-IS WITHOUT ANY
|
||||||
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
||||||
// for more details.
|
// for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
// USA.
|
// USA.
|
||||||
//
|
//
|
||||||
// Nothing in the GNU General Public License or any other license to use
|
// 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,
|
// the code or files shall permit you to use Tripwire's trademarks,
|
||||||
// service marks, or other intellectual property without Tripwire's
|
// service marks, or other intellectual property without Tripwire's
|
||||||
// prior written consent.
|
// prior written consent.
|
||||||
//
|
//
|
||||||
// If you have any questions, please contact Tripwire, Inc. at either
|
// If you have any questions, please contact Tripwire, Inc. at either
|
||||||
// info@tripwire.org or www.tripwire.org.
|
// info@tripwire.org or www.tripwire.org.
|
||||||
//
|
//
|
||||||
|
@ -49,34 +49,34 @@
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
#include "stringutil.h"
|
#include "stringutil.h"
|
||||||
|
|
||||||
#include "corestrings.h" // for: STR_ERR2_ARCH_CRYPTO_ERR
|
#include "corestrings.h" // for: STR_ERR2_ARCH_CRYPTO_ERR
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
// eArchiveCrypto
|
// eArchiveCrypto
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
TSTRING eArchiveCrypto::GetMsg( ) const
|
TSTRING eArchiveCrypto::GetMsg() const
|
||||||
{
|
{
|
||||||
// RAD: Updated this to use new stringtable
|
// RAD: Updated this to use new stringtable
|
||||||
return ( mMsg + TSS_GetString( cCore, core::STR_ERR2_ARCH_CRYPTO_ERR ) );
|
return (mMsg + TSS_GetString(cCore, core::STR_ERR2_ARCH_CRYPTO_ERR));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
// cArchive
|
// cArchive
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
|
|
||||||
// convenience methods
|
// convenience methods
|
||||||
//
|
//
|
||||||
// Specific Read functions throw eArchive if EOF is reached because
|
// Specific Read functions throw eArchive if EOF is reached because
|
||||||
// if the caller is requesting a certain amount of data to be present,
|
// if the caller is requesting a certain amount of data to be present,
|
||||||
// reaching EOF is unexpected
|
// reaching EOF is unexpected
|
||||||
//
|
//
|
||||||
// ReadBlob and WriteBlob return number of bytes read or written. Notice
|
// ReadBlob and WriteBlob return number of bytes read or written. Notice
|
||||||
// that ReadBlob does not throw an exception since eventually EOF is expected.
|
// that ReadBlob does not throw an exception since eventually EOF is expected.
|
||||||
//
|
//
|
||||||
// ReadBlob can take NULL as a destination pointer
|
// ReadBlob can take NULL as a destination pointer
|
||||||
//
|
//
|
||||||
// All write functions throw exceptions for unexpected events like
|
// All write functions throw exceptions for unexpected events like
|
||||||
// running out of memory or disk space.
|
// running out of memory or disk space.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ void cArchive::ReadInt64(int64& ret) // throw(eArchive)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE:BAM 10/11/99 -- we store unsigned size, but it really only works with
|
// NOTE:BAM 10/11/99 -- we store unsigned size, but it really only works with
|
||||||
// lengths < INT16_MAX due to sign extension in integral promotion during the
|
// lengths < INT16_MAX due to sign extension in integral promotion during the
|
||||||
// resize() in ReadString().
|
// resize() in ReadString().
|
||||||
// format for written string: 16-bit unsigned size, then a list of 16-bit UCS2 (Unicode) characters
|
// format for written string: 16-bit unsigned size, then a list of 16-bit UCS2 (Unicode) characters
|
||||||
// not including terminating NULL
|
// not including terminating NULL
|
||||||
|
@ -113,25 +113,25 @@ void cArchive::ReadString(TSTRING& ret) // throw(eArchive)
|
||||||
{
|
{
|
||||||
// read in size of string
|
// read in size of string
|
||||||
int16 size;
|
int16 size;
|
||||||
ReadInt16( size );
|
ReadInt16(size);
|
||||||
|
|
||||||
// create buffer for WCHAR16 string
|
// create buffer for WCHAR16 string
|
||||||
wc16_string ws;
|
wc16_string ws;
|
||||||
ws.resize( size );
|
ws.resize(size);
|
||||||
WCHAR16* pwc = (WCHAR16*)ws.data();
|
WCHAR16* pwc = (WCHAR16*)ws.data();
|
||||||
|
|
||||||
for( int n = 0; n < size; n++ )
|
for (int n = 0; n < size; n++)
|
||||||
{
|
{
|
||||||
int16 i16;
|
int16 i16;
|
||||||
ReadInt16( i16 );
|
ReadInt16(i16);
|
||||||
*pwc++ = i16;
|
*pwc++ = i16;
|
||||||
}
|
}
|
||||||
|
|
||||||
// convert WCHAR16 string to a TSTRING
|
// convert WCHAR16 string to a TSTRING
|
||||||
ret = cStringUtil::WstrToTstr( ws );
|
ret = cStringUtil::WstrToTstr(ws);
|
||||||
}
|
}
|
||||||
|
|
||||||
int cArchive::ReadBlob(void* pBlob, int count)
|
int cArchive::ReadBlob(void* pBlob, int count)
|
||||||
{
|
{
|
||||||
return Read(pBlob, count);
|
return Read(pBlob, count);
|
||||||
}
|
}
|
||||||
|
@ -155,7 +155,7 @@ void cArchive::WriteInt64(int64 i) // throw(eArchive)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE:BAM 10/11/99 -- we store unsigned size, but it really only works with
|
// NOTE:BAM 10/11/99 -- we store unsigned size, but it really only works with
|
||||||
// lengths < INT16_MAX due to sign extension in integral promotion during the
|
// lengths < INT16_MAX due to sign extension in integral promotion during the
|
||||||
// resize() in ReadString().
|
// resize() in ReadString().
|
||||||
// format for written string: 16-bit unsigned size, then a list of 16-bit UCS2 (Unicode) characters
|
// format for written string: 16-bit unsigned size, then a list of 16-bit UCS2 (Unicode) characters
|
||||||
// not including terminating NULL
|
// not including terminating NULL
|
||||||
|
@ -163,20 +163,20 @@ void cArchive::WriteString(TSTRING s) // throw(eArchive)
|
||||||
{
|
{
|
||||||
// convert string to a UCS2 string
|
// convert string to a UCS2 string
|
||||||
wc16_string ws;
|
wc16_string ws;
|
||||||
cStringUtil::Convert( ws, s ); // Make convert "type-dispatched"
|
cStringUtil::Convert(ws, s); // Make convert "type-dispatched"
|
||||||
|
|
||||||
// we assume that we can represent the size as a unsigned 16-bit number
|
// we assume that we can represent the size as a unsigned 16-bit number
|
||||||
// (we actually write it as a signed number, but we cast it)
|
// (we actually write it as a signed number, but we cast it)
|
||||||
if( ws.length() > TSS_INT16_MAX )
|
if (ws.length() > TSS_INT16_MAX)
|
||||||
ThrowAndAssert( eArchiveStringTooLong() );
|
ThrowAndAssert(eArchiveStringTooLong());
|
||||||
|
|
||||||
WriteInt16( static_cast<int16>( ws.length() ) );
|
WriteInt16(static_cast<int16>(ws.length()));
|
||||||
|
|
||||||
// write out each 16 bit character
|
// write out each 16 bit character
|
||||||
// RAD:09/03/99 -- Optimized for performance with "const"
|
// RAD:09/03/99 -- Optimized for performance with "const"
|
||||||
wc16_string::const_iterator at = ws.begin();
|
wc16_string::const_iterator at = ws.begin();
|
||||||
while ( at != ws.end() )
|
while (at != ws.end())
|
||||||
WriteInt16( *at++ );
|
WriteInt16(*at++);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -190,27 +190,30 @@ int32 cArchive::GetStorageSize(const TSTRING& str)
|
||||||
{
|
{
|
||||||
int32 size = sizeof(int32); // the length is always stored
|
int32 size = sizeof(int32); // the length is always stored
|
||||||
//
|
//
|
||||||
// after the length, all of the characters in the string are written as 16-bit values,
|
// after the length, all of the characters in the string are written as 16-bit values,
|
||||||
// except for the null character
|
// except for the null character
|
||||||
//
|
//
|
||||||
size += ( str.length() * 2 );
|
size += (str.length() * 2);
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64 cArchive::Copy(cArchive* pFrom, int64 amt)
|
int64 cArchive::Copy(cArchive* pFrom, int64 amt)
|
||||||
{
|
{
|
||||||
enum { BUF_SIZE = 2048 };
|
enum
|
||||||
int8 buf[BUF_SIZE];
|
{
|
||||||
int64 amtLeft = amt;
|
BUF_SIZE = 2048
|
||||||
|
};
|
||||||
|
int8 buf[BUF_SIZE];
|
||||||
|
int64 amtLeft = amt;
|
||||||
|
|
||||||
while(amtLeft > 0)
|
while (amtLeft > 0)
|
||||||
{
|
{
|
||||||
int64 amtToRead = amtLeft > (int64)BUF_SIZE ? (int64)BUF_SIZE : amtLeft;
|
int64 amtToRead = amtLeft > (int64)BUF_SIZE ? (int64)BUF_SIZE : amtLeft;
|
||||||
int64 amtRead = pFrom->ReadBlob(buf, static_cast<int>( amtToRead ) );
|
int64 amtRead = pFrom->ReadBlob(buf, static_cast<int>(amtToRead));
|
||||||
amtLeft -= amtRead;
|
amtLeft -= amtRead;
|
||||||
WriteBlob(buf, static_cast<int>( amtRead ) );
|
WriteBlob(buf, static_cast<int>(amtRead));
|
||||||
if(amtRead < amtToRead)
|
if (amtRead < amtToRead)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,7 +227,7 @@ int64 cArchive::Copy(cArchive* pFrom, int64 amt)
|
||||||
|
|
||||||
cMemMappedArchive::cMemMappedArchive()
|
cMemMappedArchive::cMemMappedArchive()
|
||||||
{
|
{
|
||||||
mpMappedMem = 0;
|
mpMappedMem = 0;
|
||||||
mMappedOffset = 0;
|
mMappedOffset = 0;
|
||||||
mMappedLength = 0;
|
mMappedLength = 0;
|
||||||
}
|
}
|
||||||
|
@ -269,13 +272,13 @@ void cMemMappedArchive::SetNewMap(void* pMap, int64 offset, int64 length) const
|
||||||
{
|
{
|
||||||
if (pMap == 0)
|
if (pMap == 0)
|
||||||
{
|
{
|
||||||
mpMappedMem = 0;
|
mpMappedMem = 0;
|
||||||
mMappedOffset = 0;
|
mMappedOffset = 0;
|
||||||
mMappedLength = 0;
|
mMappedLength = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mpMappedMem = pMap;
|
mpMappedMem = pMap;
|
||||||
mMappedOffset = offset;
|
mMappedOffset = offset;
|
||||||
mMappedLength = length;
|
mMappedLength = length;
|
||||||
}
|
}
|
||||||
|
@ -288,14 +291,13 @@ void cMemMappedArchive::SetNewMap(void* pMap, int64 offset, int64 length) const
|
||||||
// mapped.
|
// mapped.
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
cMemoryArchive::cMemoryArchive(int maxSize)
|
cMemoryArchive::cMemoryArchive(int maxSize) : mMaxAllocatedLen(maxSize)
|
||||||
: mMaxAllocatedLen(maxSize)
|
|
||||||
{
|
{
|
||||||
ASSERT(maxSize > 0);
|
ASSERT(maxSize > 0);
|
||||||
mpMemory = 0;
|
mpMemory = 0;
|
||||||
mAllocatedLen = 0;
|
mAllocatedLen = 0;
|
||||||
mLogicalSize = 0;
|
mLogicalSize = 0;
|
||||||
mReadHead = 0;
|
mReadHead = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
cMemoryArchive::~cMemoryArchive()
|
cMemoryArchive::~cMemoryArchive()
|
||||||
|
@ -321,13 +323,15 @@ void cMemoryArchive::Seek(int64 offset, SeekFrom from) // throw(eArchive)
|
||||||
offset = mLogicalSize + (int)offset;
|
offset = mLogicalSize + (int)offset;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ThrowAndAssert(eArchiveSeek(TSS_GetString( cCore, core::STR_MEMARCHIVE_FILENAME), TSS_GetString( cCore, core::STR_MEMARCHIVE_ERRSTR)));
|
ThrowAndAssert(eArchiveSeek(TSS_GetString(cCore, core::STR_MEMARCHIVE_FILENAME),
|
||||||
|
TSS_GetString(cCore, core::STR_MEMARCHIVE_ERRSTR)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (offset > mLogicalSize)
|
if (offset > mLogicalSize)
|
||||||
ThrowAndAssert(eArchiveSeek(TSS_GetString( cCore, core::STR_MEMARCHIVE_FILENAME), TSS_GetString( cCore, core::STR_MEMARCHIVE_ERRSTR)));
|
ThrowAndAssert(eArchiveSeek(TSS_GetString(cCore, core::STR_MEMARCHIVE_FILENAME),
|
||||||
|
TSS_GetString(cCore, core::STR_MEMARCHIVE_ERRSTR)));
|
||||||
|
|
||||||
mReadHead = static_cast<int>( offset );
|
mReadHead = static_cast<int>(offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
int64 cMemoryArchive::CurrentPos() const
|
int64 cMemoryArchive::CurrentPos() const
|
||||||
|
@ -350,8 +354,8 @@ void cMemoryArchive::Truncate()
|
||||||
|
|
||||||
void cMemoryArchive::MapArchive(int64 offset, int64 len) // throw(eArchive)
|
void cMemoryArchive::MapArchive(int64 offset, int64 len) // throw(eArchive)
|
||||||
{
|
{
|
||||||
if ( offset + (int)len > mLogicalSize )
|
if (offset + (int)len > mLogicalSize)
|
||||||
AllocateMemory( static_cast<int>( offset + len ) );
|
AllocateMemory(static_cast<int>(offset + len));
|
||||||
|
|
||||||
SetNewMap(mpMemory + offset, offset, len);
|
SetNewMap(mpMemory + offset, offset, len);
|
||||||
}
|
}
|
||||||
|
@ -404,9 +408,9 @@ void cMemoryArchive::AllocateMemory(int len) // throw(eArchive)
|
||||||
ThrowAndAssert(eArchiveOutOfMem());
|
ThrowAndAssert(eArchiveOutOfMem());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if( 0 == mAllocatedLen )
|
if (0 == mAllocatedLen)
|
||||||
mAllocatedLen = MIN_ALLOCATED_SIZE;
|
mAllocatedLen = MIN_ALLOCATED_SIZE;
|
||||||
|
|
||||||
while (mAllocatedLen < len)
|
while (mAllocatedLen < len)
|
||||||
mAllocatedLen *= 2;
|
mAllocatedLen *= 2;
|
||||||
|
|
||||||
|
@ -416,7 +420,7 @@ void cMemoryArchive::AllocateMemory(int len) // throw(eArchive)
|
||||||
memcpy(pNewMem, mpMemory, mLogicalSize);
|
memcpy(pNewMem, mpMemory, mLogicalSize);
|
||||||
delete [] mpMemory;
|
delete [] mpMemory;
|
||||||
}
|
}
|
||||||
mpMemory = pNewMem;
|
mpMemory = pNewMem;
|
||||||
mLogicalSize = len;
|
mLogicalSize = len;
|
||||||
|
|
||||||
// update memory map if there is one
|
// update memory map if there is one
|
||||||
|
@ -436,7 +440,7 @@ void cMemoryArchive::AllocateMemory(int len) // throw(eArchive)
|
||||||
ASSERT(mpMemory);
|
ASSERT(mpMemory);
|
||||||
memcpy(pNewMem, mpMemory, len);
|
memcpy(pNewMem, mpMemory, len);
|
||||||
delete [] mpMemory;
|
delete [] mpMemory;
|
||||||
mpMemory = pNewMem;
|
mpMemory = pNewMem;
|
||||||
mLogicalSize = len;
|
mLogicalSize = len;
|
||||||
|
|
||||||
// update memory map if there is one
|
// update memory map if there is one
|
||||||
|
@ -464,33 +468,27 @@ public:
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// cFixedMemArchive
|
// cFixedMemArchive
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
cFixedMemArchive::cFixedMemArchive()
|
cFixedMemArchive::cFixedMemArchive() : mpMemory(0), mSize(0), mReadHead(0)
|
||||||
: mpMemory (0),
|
|
||||||
mSize (0),
|
|
||||||
mReadHead (0)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
cFixedMemArchive::cFixedMemArchive( int8* pMem, int32 size )
|
cFixedMemArchive::cFixedMemArchive(int8* pMem, int32 size) : mpMemory(0), mSize(0), mReadHead(0)
|
||||||
: mpMemory (0),
|
|
||||||
mSize (0),
|
|
||||||
mReadHead (0)
|
|
||||||
{
|
{
|
||||||
Attach( pMem, size );
|
Attach(pMem, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
cFixedMemArchive::~cFixedMemArchive()
|
cFixedMemArchive::~cFixedMemArchive()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void cFixedMemArchive::Attach( int8* pMem, int32 size )
|
void cFixedMemArchive::Attach(int8* pMem, int32 size)
|
||||||
{
|
{
|
||||||
mpMemory = pMem;
|
mpMemory = pMem;
|
||||||
mSize = size;
|
mSize = size;
|
||||||
mReadHead = 0;
|
mReadHead = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cFixedMemArchive::Seek(int64 offset, SeekFrom from) // throw(eArchive)
|
void cFixedMemArchive::Seek(int64 offset, SeekFrom from) // throw(eArchive)
|
||||||
{
|
{
|
||||||
switch (from)
|
switch (from)
|
||||||
{
|
{
|
||||||
|
@ -503,21 +501,23 @@ void cFixedMemArchive::Seek(int64 offset, SeekFrom from) // throw(eArchive)
|
||||||
offset = mSize + (int)offset;
|
offset = mSize + (int)offset;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ThrowAndAssert(eArchiveSeek(TSS_GetString( cCore, core::STR_MEMARCHIVE_FILENAME), TSS_GetString( cCore, core::STR_MEMARCHIVE_ERRSTR)));
|
ThrowAndAssert(eArchiveSeek(TSS_GetString(cCore, core::STR_MEMARCHIVE_FILENAME),
|
||||||
|
TSS_GetString(cCore, core::STR_MEMARCHIVE_ERRSTR)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (offset > mSize)
|
if (offset > mSize)
|
||||||
ThrowAndAssert(eArchiveSeek(TSS_GetString( cCore, core::STR_MEMARCHIVE_FILENAME), TSS_GetString( cCore, core::STR_MEMARCHIVE_ERRSTR)));
|
ThrowAndAssert(eArchiveSeek(TSS_GetString(cCore, core::STR_MEMARCHIVE_FILENAME),
|
||||||
|
TSS_GetString(cCore, core::STR_MEMARCHIVE_ERRSTR)));
|
||||||
|
|
||||||
mReadHead = static_cast<int32>( offset );
|
mReadHead = static_cast<int32>(offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
int64 cFixedMemArchive::CurrentPos() const
|
int64 cFixedMemArchive::CurrentPos() const
|
||||||
{
|
{
|
||||||
return mReadHead;
|
return mReadHead;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64 cFixedMemArchive::Length() const
|
int64 cFixedMemArchive::Length() const
|
||||||
{
|
{
|
||||||
return mSize;
|
return mSize;
|
||||||
}
|
}
|
||||||
|
@ -527,12 +527,12 @@ bool cFixedMemArchive::EndOfFile()
|
||||||
return (mReadHead >= mSize);
|
return (mReadHead >= mSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
int cFixedMemArchive::Read(void* pDest, int count) // throw(eArchive)
|
int cFixedMemArchive::Read(void* pDest, int count) // throw(eArchive)
|
||||||
{
|
{
|
||||||
ASSERT( pDest );
|
ASSERT(pDest);
|
||||||
if (mReadHead + count > mSize)
|
if (mReadHead + count > mSize)
|
||||||
{
|
{
|
||||||
count = static_cast<int>( mSize - mReadHead );
|
count = static_cast<int>(mSize - mReadHead);
|
||||||
if (count <= 0)
|
if (count <= 0)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -545,11 +545,11 @@ int cFixedMemArchive::Read(void* pDest, int count) // throw(eArchive)
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
int cFixedMemArchive::Write(const void* pDest, int count) // throw(eArchive)
|
int cFixedMemArchive::Write(const void* pDest, int count) // throw(eArchive)
|
||||||
{
|
{
|
||||||
if (mReadHead + count > mSize)
|
if (mReadHead + count > mSize)
|
||||||
{
|
{
|
||||||
ASSERT( false );
|
ASSERT(false);
|
||||||
throw eArchiveWrite();
|
throw eArchiveWrite();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -566,11 +566,9 @@ int cFixedMemArchive::Write(const void* pDest, int count) // throw(eArchive)
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
//Ctor -- Initialize member variables to 0 or NULL equivalents.
|
//Ctor -- Initialize member variables to 0 or NULL equivalents.
|
||||||
cFileArchive::cFileArchive() :
|
cFileArchive::cFileArchive() : mFileSize(0), mReadHead(0), isWritable(false)
|
||||||
mFileSize(0),
|
{
|
||||||
mReadHead(0),
|
}
|
||||||
isWritable(false)
|
|
||||||
{}
|
|
||||||
|
|
||||||
cFileArchive::~cFileArchive()
|
cFileArchive::~cFileArchive()
|
||||||
{
|
{
|
||||||
|
@ -578,16 +576,16 @@ cFileArchive::~cFileArchive()
|
||||||
|
|
||||||
bool cFileArchive::EndOfFile()
|
bool cFileArchive::EndOfFile()
|
||||||
{
|
{
|
||||||
return ( mReadHead >= mFileSize );
|
return (mReadHead >= mFileSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// Seek -- This is where the actual offset is performed. The default
|
// Seek -- This is where the actual offset is performed. The default
|
||||||
// for each archive will be 0.
|
// for each archive will be 0.
|
||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
void cFileArchive::Seek( int64 offset, SeekFrom from) // throw(eArchive)
|
void cFileArchive::Seek(int64 offset, SeekFrom from) // throw(eArchive)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
switch (from)
|
switch (from)
|
||||||
{
|
{
|
||||||
|
@ -600,19 +598,19 @@ void cFileArchive::Seek( int64 offset, SeekFrom from) // throw(eArchive)
|
||||||
offset = mFileSize + offset;
|
offset = mFileSize + offset;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw eArchiveSeek( mCurrentFilename, iFSServices::GetInstance()->GetErrString() ) ;
|
throw eArchiveSeek(mCurrentFilename, iFSServices::GetInstance()->GetErrString());
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( offset > mFileSize )
|
if (offset > mFileSize)
|
||||||
throw eArchiveSeek( mCurrentFilename, iFSServices::GetInstance()->GetErrString() ) ;
|
throw eArchiveSeek(mCurrentFilename, iFSServices::GetInstance()->GetErrString());
|
||||||
mReadHead = offset;
|
mReadHead = offset;
|
||||||
|
|
||||||
mCurrentFile.Seek(mReadHead, cFile::SEEK_BEGIN);
|
mCurrentFile.Seek(mReadHead, cFile::SEEK_BEGIN);
|
||||||
//This is where the actual read/writehead is set!!
|
//This is where the actual read/writehead is set!!
|
||||||
}//try
|
} //try
|
||||||
catch( eFile& fileError )
|
catch (eFile& fileError)
|
||||||
{
|
{
|
||||||
throw( eArchiveSeek( mCurrentFilename, fileError.GetDescription() ) );
|
throw(eArchiveSeek(mCurrentFilename, fileError.GetDescription()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -626,13 +624,13 @@ int64 cFileArchive::CurrentPos(void) const
|
||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
int64 cFileArchive::Length(void) const
|
int64 cFileArchive::Length(void) const
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return mCurrentFile.GetSize();
|
return mCurrentFile.GetSize();
|
||||||
}
|
}
|
||||||
catch(eFile& fileError)
|
catch (eFile& fileError)
|
||||||
{
|
{
|
||||||
throw( eArchiveSeek( mCurrentFilename, fileError.GetDescription() ) );
|
throw(eArchiveSeek(mCurrentFilename, fileError.GetDescription()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -641,26 +639,26 @@ int64 cFileArchive::Length(void) const
|
||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
void cFileArchive::OpenRead(const TCHAR* filename, uint32 openFlags)
|
void cFileArchive::OpenRead(const TCHAR* filename, uint32 openFlags)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// set up open flags
|
// set up open flags
|
||||||
uint32 flags = cFile::OPEN_READ;
|
uint32 flags = cFile::OPEN_READ;
|
||||||
flags |= ( ( openFlags & FA_OPEN_TRUNCATE ) ? cFile::OPEN_TRUNCATE : 0 );
|
flags |= ((openFlags & FA_OPEN_TRUNCATE) ? cFile::OPEN_TRUNCATE : 0);
|
||||||
flags |= ( ( openFlags & FA_OPEN_TEXT ) ? cFile::OPEN_TEXT : 0 );
|
flags |= ((openFlags & FA_OPEN_TEXT) ? cFile::OPEN_TEXT : 0);
|
||||||
flags |= ( ( openFlags & FA_SCANNING ) ? cFile::OPEN_SCANNING : 0 );
|
flags |= ((openFlags & FA_SCANNING) ? cFile::OPEN_SCANNING : 0);
|
||||||
flags |= ( ( openFlags & FA_DIRECT ) ? cFile::OPEN_DIRECT : 0 );
|
flags |= ((openFlags & FA_DIRECT) ? cFile::OPEN_DIRECT : 0);
|
||||||
|
|
||||||
mOpenFlags = openFlags;
|
mOpenFlags = openFlags;
|
||||||
mCurrentFilename = filename;
|
mCurrentFilename = filename;
|
||||||
mCurrentFile.Open( filename, flags );
|
mCurrentFile.Open(filename, flags);
|
||||||
isWritable = false;
|
isWritable = false;
|
||||||
|
|
||||||
mFileSize = mCurrentFile.GetSize();
|
mFileSize = mCurrentFile.GetSize();
|
||||||
mReadHead = mCurrentFile.Seek( 0, cFile::SEEK_BEGIN );
|
mReadHead = mCurrentFile.Seek(0, cFile::SEEK_BEGIN);
|
||||||
}
|
}
|
||||||
catch(eFile& fileError)
|
catch (eFile& fileError)
|
||||||
{
|
{
|
||||||
throw(eArchiveOpen( mCurrentFilename, fileError.GetDescription() ) );
|
throw(eArchiveOpen(mCurrentFilename, fileError.GetDescription()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -669,26 +667,26 @@ void cFileArchive::OpenRead(const TCHAR* filename, uint32 openFlags)
|
||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
void cFileArchive::OpenReadWrite(const TCHAR* filename, uint32 openFlags)
|
void cFileArchive::OpenReadWrite(const TCHAR* filename, uint32 openFlags)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// set up open flags
|
// set up open flags
|
||||||
uint32 flags = cFile::OPEN_WRITE;
|
uint32 flags = cFile::OPEN_WRITE;
|
||||||
flags |= ( ( openFlags & FA_OPEN_TRUNCATE ) ? cFile::OPEN_TRUNCATE : 0 );
|
flags |= ((openFlags & FA_OPEN_TRUNCATE) ? cFile::OPEN_TRUNCATE : 0);
|
||||||
flags |= ( ( openFlags & FA_OPEN_TEXT ) ? cFile::OPEN_TEXT : 0 );
|
flags |= ((openFlags & FA_OPEN_TEXT) ? cFile::OPEN_TEXT : 0);
|
||||||
flags |= ( ( openFlags & FA_SCANNING ) ? cFile::OPEN_SCANNING : 0 );
|
flags |= ((openFlags & FA_SCANNING) ? cFile::OPEN_SCANNING : 0);
|
||||||
flags |= ( ( openFlags & FA_DIRECT ) ? cFile::OPEN_DIRECT : 0 );
|
flags |= ((openFlags & FA_DIRECT) ? cFile::OPEN_DIRECT : 0);
|
||||||
|
|
||||||
mOpenFlags = openFlags;
|
mOpenFlags = openFlags;
|
||||||
mCurrentFilename = filename;
|
mCurrentFilename = filename;
|
||||||
mCurrentFile.Open( filename, flags );
|
mCurrentFile.Open(filename, flags);
|
||||||
isWritable = true;
|
isWritable = true;
|
||||||
|
|
||||||
mFileSize = mCurrentFile.GetSize();
|
mFileSize = mCurrentFile.GetSize();
|
||||||
mReadHead = mCurrentFile.Seek( 0, cFile::SEEK_BEGIN );
|
mReadHead = mCurrentFile.Seek(0, cFile::SEEK_BEGIN);
|
||||||
}
|
}
|
||||||
catch(eFile& fileError)
|
catch (eFile& fileError)
|
||||||
{
|
{
|
||||||
throw( eArchiveOpen( mCurrentFilename, fileError.GetDescription() ) );
|
throw(eArchiveOpen(mCurrentFilename, fileError.GetDescription()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -706,66 +704,65 @@ TSTRING cFileArchive::GetCurrentFilename(void) const
|
||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
void cFileArchive::Close()
|
void cFileArchive::Close()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
mCurrentFile.Close();
|
mCurrentFile.Close();
|
||||||
mFileSize = 0;
|
mFileSize = 0;
|
||||||
mReadHead = 0;
|
mReadHead = 0;
|
||||||
|
|
||||||
mCurrentFilename = _T("");
|
mCurrentFilename = _T("");
|
||||||
}
|
}
|
||||||
catch(eFile& fileError)
|
catch (eFile& fileError)
|
||||||
{
|
{
|
||||||
throw( eArchive( mCurrentFilename, fileError.GetDescription() ) );
|
throw(eArchive(mCurrentFilename, fileError.GetDescription()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
// Read -- Read places bytes in location designated by pDest. Returns
|
// Read -- Read places bytes in location designated by pDest. Returns
|
||||||
// The actual amount read into *pDest.
|
// The actual amount read into *pDest.
|
||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
int cFileArchive::Read(void* pDest, int count)
|
int cFileArchive::Read(void* pDest, int count)
|
||||||
{
|
{
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if ( mReadHead + count > mFileSize && !(mOpenFlags & FA_DIRECT))
|
if (mReadHead + count > mFileSize && !(mOpenFlags & FA_DIRECT))
|
||||||
count = static_cast<int>( mFileSize - mReadHead );
|
count = static_cast<int>(mFileSize - mReadHead);
|
||||||
|
|
||||||
if ( pDest != NULL )
|
if (pDest != NULL)
|
||||||
{
|
{
|
||||||
int nbRead =
|
int nbRead = static_cast<int>(mCurrentFile.Read(pDest, count));
|
||||||
static_cast<int>( mCurrentFile.Read( pDest, count ) );
|
|
||||||
|
|
||||||
// 'count' may not be equal to 'nbRead' if the file is open in
|
// 'count' may not be equal to 'nbRead' if the file is open in
|
||||||
// text mode.
|
// text mode.
|
||||||
count = nbRead;
|
count = nbRead;
|
||||||
if(count < 0) count = 0;
|
if (count < 0)
|
||||||
|
count = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int32 dummy;
|
int32 dummy;
|
||||||
for (i = count; ; i -= sizeof(int32))
|
for (i = count;; i -= sizeof(int32))
|
||||||
{
|
{
|
||||||
if (i < (int)sizeof(int32))
|
if (i < (int)sizeof(int32))
|
||||||
{
|
{
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
mCurrentFile.Read( &dummy, i );
|
mCurrentFile.Read(&dummy, i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
mCurrentFile.Read( &dummy, i );
|
mCurrentFile.Read(&dummy, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mReadHead += count;
|
mReadHead += count;
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
catch( eFile& fileError )
|
catch (eFile& fileError)
|
||||||
{
|
{
|
||||||
throw( eArchiveRead( mCurrentFilename, fileError.GetDescription() ) );
|
throw(eArchiveRead(mCurrentFilename, fileError.GetDescription()));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -774,38 +771,38 @@ int cFileArchive::Read(void* pDest, int count)
|
||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
int cFileArchive::Write(const void* pDest, int count) // throw(eArchive)
|
int cFileArchive::Write(const void* pDest, int count) // throw(eArchive)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
int64 actual_count = 0;
|
int64 actual_count = 0;
|
||||||
ASSERT( mCurrentFile.isWritable );
|
ASSERT(mCurrentFile.isWritable);
|
||||||
|
|
||||||
actual_count = mCurrentFile.Write( pDest, count );
|
actual_count = mCurrentFile.Write(pDest, count);
|
||||||
|
|
||||||
if ( actual_count < count )
|
if (actual_count < count)
|
||||||
{
|
{
|
||||||
//Disk full??
|
//Disk full??
|
||||||
throw eArchiveWrite( mCurrentFilename, iFSServices::GetInstance()->GetErrString() ) ;
|
throw eArchiveWrite(mCurrentFilename, iFSServices::GetInstance()->GetErrString());
|
||||||
}
|
}
|
||||||
|
|
||||||
// increment the read/write head
|
// increment the read/write head
|
||||||
mReadHead += actual_count;
|
mReadHead += actual_count;
|
||||||
|
|
||||||
// increase the size, if needed
|
// increase the size, if needed
|
||||||
if( mReadHead > mFileSize )
|
if (mReadHead > mFileSize)
|
||||||
{
|
{
|
||||||
#if 0 // IS_SUNPRO
|
#if 0 // IS_SUNPRO \
|
||||||
// These two lines seem to be all there is between code that crashes and code that works for sunpro
|
// These two lines seem to be all there is between code that crashes and code that works for sunpro
|
||||||
cDebug d("cFileArchive::Write()");
|
cDebug d("cFileArchive::Write()");
|
||||||
d.TraceDebug(_T("file(%s) adjusted mFileSize = %d mReadHead = %d\n"), mCurrentFilename.c_str(), (int)mFileSize, (int)mReadHead);
|
d.TraceDebug(_T("file(%s) adjusted mFileSize = %d mReadHead = %d\n"), mCurrentFilename.c_str(), (int)mFileSize, (int)mReadHead);
|
||||||
#endif
|
#endif
|
||||||
mFileSize = mReadHead;
|
mFileSize = mReadHead;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (int)actual_count;
|
return (int)actual_count;
|
||||||
}
|
}
|
||||||
catch( eFile& fileError )
|
catch (eFile& fileError)
|
||||||
{
|
{
|
||||||
throw( eArchiveWrite( mCurrentFilename, fileError.GetDescription() ) );
|
throw(eArchiveWrite(mCurrentFilename, fileError.GetDescription()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -813,91 +810,92 @@ int cFileArchive::Write(const void* pDest, int count) // throw(eArchive)
|
||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
// Truncate
|
// Truncate
|
||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
void cFileArchive::Truncate() // throw(eArchive)
|
void cFileArchive::Truncate() // throw(eArchive)
|
||||||
{
|
{
|
||||||
ASSERT( mCurrentFile.IsOpen() );
|
ASSERT(mCurrentFile.IsOpen());
|
||||||
ASSERT( mCurrentFile.isWritable );
|
ASSERT(mCurrentFile.isWritable);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
mCurrentFile.Truncate ( mReadHead );
|
mCurrentFile.Truncate(mReadHead);
|
||||||
}
|
}
|
||||||
catch( eFile& fileError )
|
catch (eFile& fileError)
|
||||||
{
|
{
|
||||||
//TODO: create an error number for truncate...
|
//TODO: create an error number for truncate...
|
||||||
throw( eArchiveWrite( mCurrentFilename, fileError.GetDescription() ) );
|
throw(eArchiveWrite(mCurrentFilename, fileError.GetDescription()));
|
||||||
}
|
}
|
||||||
|
|
||||||
mFileSize = mReadHead;
|
mFileSize = mReadHead;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
// OpenReadWrite -- Opens the file to be read or written to
|
// OpenReadWrite -- Opens the file to be read or written to
|
||||||
//
|
//
|
||||||
// since we'll never open an existing file, the truncateFile flag is unnecessary.
|
// since we'll never open an existing file, the truncateFile flag is unnecessary.
|
||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
void cLockedTemporaryFileArchive::OpenReadWrite( const TCHAR* filename, uint32 openFlags )
|
void cLockedTemporaryFileArchive::OpenReadWrite(const TCHAR* filename, uint32 openFlags)
|
||||||
{
|
{
|
||||||
TSTRING strTempFile;
|
TSTRING strTempFile;
|
||||||
|
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
|
|
||||||
ASSERT( !mCurrentFile.IsOpen() ); // shouldn't be able to create a new file when we're already open
|
ASSERT(!mCurrentFile.IsOpen()); // shouldn't be able to create a new file when we're already open
|
||||||
if ( mCurrentFile.IsOpen() )
|
if (mCurrentFile.IsOpen())
|
||||||
throw( eArchive( mCurrentFilename, _T("Internal Error") ) );
|
throw(eArchive(mCurrentFilename, _T("Internal Error")));
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// if filename is NULL, create a temp file for the caller
|
// if filename is NULL, create a temp file for the caller
|
||||||
if( filename == NULL )
|
if (filename == NULL)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
iFSServices::GetInstance()->GetTempDirName( strTempFile );
|
iFSServices::GetInstance()->GetTempDirName(strTempFile);
|
||||||
strTempFile += _T("twtempXXXXXX");
|
strTempFile += _T("twtempXXXXXX");
|
||||||
iFSServices::GetInstance()->MakeTempFilename( strTempFile );
|
iFSServices::GetInstance()->MakeTempFilename(strTempFile);
|
||||||
}
|
}
|
||||||
catch( eFSServices& fileError)
|
catch (eFSServices& fileError)
|
||||||
{
|
{
|
||||||
TSTRING errStr = TSS_GetString( cCore, core::STR_BAD_TEMPDIRECTORY );
|
TSTRING errStr = TSS_GetString(cCore, core::STR_BAD_TEMPDIRECTORY);
|
||||||
throw eArchiveOpen(strTempFile, errStr);
|
throw eArchiveOpen(strTempFile, errStr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// create file
|
// create file
|
||||||
|
|
||||||
// set up flags
|
// set up flags
|
||||||
uint32 flags = cFile::OPEN_WRITE | cFile::OPEN_LOCKED_TEMP | cFile::OPEN_CREATE | cFile::OPEN_EXCLUSIVE;
|
uint32 flags = cFile::OPEN_WRITE | cFile::OPEN_LOCKED_TEMP | cFile::OPEN_CREATE | cFile::OPEN_EXCLUSIVE;
|
||||||
if ( openFlags & FA_OPEN_TRUNCATE )
|
if (openFlags & FA_OPEN_TRUNCATE)
|
||||||
flags |= cFile::OPEN_TRUNCATE;
|
flags |= cFile::OPEN_TRUNCATE;
|
||||||
if ( openFlags & FA_OPEN_TEXT )
|
if (openFlags & FA_OPEN_TEXT)
|
||||||
flags |= cFile::OPEN_TEXT;
|
flags |= cFile::OPEN_TEXT;
|
||||||
|
|
||||||
// open file
|
// open file
|
||||||
mCurrentFilename = filename ? filename : strTempFile.c_str();
|
mCurrentFilename = filename ? filename : strTempFile.c_str();
|
||||||
mCurrentFile.Open( mCurrentFilename, flags );
|
mCurrentFile.Open(mCurrentFilename, flags);
|
||||||
|
|
||||||
isWritable = true;
|
isWritable = true;
|
||||||
mFileSize = mCurrentFile.GetSize();
|
mFileSize = mCurrentFile.GetSize();
|
||||||
mReadHead = mCurrentFile.Seek( 0, cFile::SEEK_BEGIN );
|
mReadHead = mCurrentFile.Seek(0, cFile::SEEK_BEGIN);
|
||||||
|
|
||||||
#if 0 // IS_SUNPRO
|
#if 0 // IS_SUNPRO
|
||||||
cDebug d("cLockedTemporaryFileArchive::OpenReadWrite()");
|
cDebug d("cLockedTemporaryFileArchive::OpenReadWrite()");
|
||||||
d.TraceDebug(_T("file(%s) set mFileSize to %d mReadHead to %d\n"), mCurrentFilename.c_str(), (int)mFileSize, (int)mReadHead);
|
d.TraceDebug(_T("file(%s) set mFileSize to %d mReadHead to %d\n"), mCurrentFilename.c_str(), (int)mFileSize, (int)mReadHead);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}//try
|
} //try
|
||||||
catch (eFile& fileError) {
|
catch (eFile& fileError)
|
||||||
TSTRING errStr = TSS_GetString( cCore, core::STR_BAD_TEMPDIRECTORY );
|
{
|
||||||
eArchiveOpen e(strTempFile, errStr);
|
TSTRING errStr = TSS_GetString(cCore, core::STR_BAD_TEMPDIRECTORY);
|
||||||
throw e;
|
eArchiveOpen e(strTempFile, errStr);
|
||||||
}
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -907,4 +905,3 @@ void cLockedTemporaryFileArchive::Close()
|
||||||
// Note: this deletes the file as well
|
// Note: this deletes the file as well
|
||||||
cFileArchive::Close();
|
cFileArchive::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
//
|
//
|
||||||
// The developer of the original code and/or files is Tripwire, Inc.
|
// The developer of the original code and/or files is Tripwire, Inc.
|
||||||
// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire,
|
// Portions created by Tripwire, Inc. are copyright (C) 2000-2018 Tripwire,
|
||||||
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
||||||
// reserved.
|
// reserved.
|
||||||
//
|
//
|
||||||
// This program is free software. The contents of this file are subject
|
// 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
|
// 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
|
// Free Software Foundation; either version 2 of the License, or (at your
|
||||||
// option) any later version. You may redistribute it and/or modify it
|
// option) any later version. You may redistribute it and/or modify it
|
||||||
// only in compliance with the GNU General Public License.
|
// only in compliance with the GNU General Public License.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful.
|
// This program is distributed in the hope that it will be useful.
|
||||||
// However, this program is distributed AS-IS WITHOUT ANY
|
// However, this program is distributed AS-IS WITHOUT ANY
|
||||||
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
||||||
// for more details.
|
// for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
// USA.
|
// USA.
|
||||||
//
|
//
|
||||||
// Nothing in the GNU General Public License or any other license to use
|
// 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,
|
// the code or files shall permit you to use Tripwire's trademarks,
|
||||||
// service marks, or other intellectual property without Tripwire's
|
// service marks, or other intellectual property without Tripwire's
|
||||||
// prior written consent.
|
// prior written consent.
|
||||||
//
|
//
|
||||||
// If you have any questions, please contact Tripwire, Inc. at either
|
// If you have any questions, please contact Tripwire, Inc. at either
|
||||||
// info@tripwire.org or www.tripwire.org.
|
// info@tripwire.org or www.tripwire.org.
|
||||||
//
|
//
|
||||||
|
@ -56,69 +56,71 @@
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
// eArchive exception classes
|
// eArchive exception classes
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
TSS_FILE_EXCEPTION( eArchive, eFileError );
|
TSS_FILE_EXCEPTION(eArchive, eFileError);
|
||||||
TSS_FILE_EXCEPTION( eArchiveOpen, eArchive );
|
TSS_FILE_EXCEPTION(eArchiveOpen, eArchive);
|
||||||
TSS_FILE_EXCEPTION( eArchiveWrite, eArchive );
|
TSS_FILE_EXCEPTION(eArchiveWrite, eArchive);
|
||||||
TSS_FILE_EXCEPTION( eArchiveRead, eArchive );
|
TSS_FILE_EXCEPTION(eArchiveRead, eArchive);
|
||||||
TSS_FILE_EXCEPTION( eArchiveEOF, eArchive );
|
TSS_FILE_EXCEPTION(eArchiveEOF, eArchive);
|
||||||
TSS_FILE_EXCEPTION( eArchiveSeek, eArchive );
|
TSS_FILE_EXCEPTION(eArchiveSeek, eArchive);
|
||||||
TSS_FILE_EXCEPTION( eArchiveMemmap, eArchive );
|
TSS_FILE_EXCEPTION(eArchiveMemmap, eArchive);
|
||||||
TSS_FILE_EXCEPTION( eArchiveOutOfMem, eArchive );
|
TSS_FILE_EXCEPTION(eArchiveOutOfMem, eArchive);
|
||||||
TSS_FILE_EXCEPTION( eArchiveInvalidOp, eArchive );
|
TSS_FILE_EXCEPTION(eArchiveInvalidOp, eArchive);
|
||||||
TSS_FILE_EXCEPTION( eArchiveFormat, eArchive );
|
TSS_FILE_EXCEPTION(eArchiveFormat, eArchive);
|
||||||
TSS_FILE_EXCEPTION( eArchiveNotRegularFile, eArchive );
|
TSS_FILE_EXCEPTION(eArchiveNotRegularFile, eArchive);
|
||||||
TSS_BEGIN_EXCEPTION( eArchiveCrypto, eArchive )
|
TSS_BEGIN_EXCEPTION(eArchiveCrypto, eArchive)
|
||||||
|
|
||||||
virtual TSTRING GetMsg() const;
|
virtual TSTRING GetMsg() const;
|
||||||
// eCryptoArchive appends a special string to the end of
|
// eCryptoArchive appends a special string to the end of
|
||||||
// all exception messages
|
// all exception messages
|
||||||
TSS_END_EXCEPTION()
|
TSS_END_EXCEPTION()
|
||||||
TSS_EXCEPTION( eArchiveStringTooLong, eArchive );
|
TSS_EXCEPTION(eArchiveStringTooLong, eArchive);
|
||||||
|
|
||||||
// throw( eArchiveOpen( cErrorUtil::MakeFileError( fileError.GetMsg(), strTempFile ) ) );
|
// throw( eArchiveOpen( cErrorUtil::MakeFileError( fileError.GetMsg(), strTempFile ) ) );
|
||||||
|
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
// cArchive
|
// cArchive
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
|
|
||||||
class cArchive
|
class cArchive
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~cArchive() {}
|
virtual ~cArchive()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
// convenience methods
|
// convenience methods
|
||||||
//
|
//
|
||||||
// Specific Read functions throw(eArchive) if EOF is reached because
|
// Specific Read functions throw(eArchive) if EOF is reached because
|
||||||
// if the caller is requesting a certain amount of data to be present,
|
// if the caller is requesting a certain amount of data to be present,
|
||||||
// reaching EOF is unexpected
|
// reaching EOF is unexpected
|
||||||
//
|
//
|
||||||
// ReadBlob and WriteBlob return number of bytes read or written. Notice
|
// ReadBlob and WriteBlob return number of bytes read or written. Notice
|
||||||
// that ReadBlob does not throw an exception since eventually EOF is expected.
|
// that ReadBlob does not throw an exception since eventually EOF is expected.
|
||||||
//
|
//
|
||||||
// ReadBlob can take NULL as a destination pointer
|
// ReadBlob can take NULL as a destination pointer
|
||||||
//
|
//
|
||||||
// All write functions throw exceptions for unexpected events like
|
// All write functions throw exceptions for unexpected events like
|
||||||
// running out of memory or disk space.
|
// running out of memory or disk space.
|
||||||
//
|
//
|
||||||
void ReadInt16(int16& ret); // throw(eArchive)
|
void ReadInt16(int16& ret); // throw(eArchive)
|
||||||
void ReadInt32(int32& ret); // throw(eArchive)
|
void ReadInt32(int32& ret); // throw(eArchive)
|
||||||
void ReadInt64(int64& ret); // throw(eArchive)
|
void ReadInt64(int64& ret); // throw(eArchive)
|
||||||
void ReadString(TSTRING& ret); // throw(eArchive)
|
void ReadString(TSTRING& ret); // throw(eArchive)
|
||||||
int ReadBlob(void* pBlob, int count);
|
int ReadBlob(void* pBlob, int count);
|
||||||
void WriteInt16(int16 i); // throw(eArchive)
|
void WriteInt16(int16 i); // throw(eArchive)
|
||||||
void WriteInt32(int32 i); // throw(eArchive)
|
void WriteInt32(int32 i); // throw(eArchive)
|
||||||
void WriteInt64(int64 i); // throw(eArchive)
|
void WriteInt64(int64 i); // throw(eArchive)
|
||||||
void WriteString(TSTRING s); // throw(eArchive)
|
void WriteString(TSTRING s); // throw(eArchive)
|
||||||
void WriteBlob(const void* pBlob, int count); // throw(eArchive)
|
void WriteBlob(const void* pBlob, int count); // throw(eArchive)
|
||||||
|
|
||||||
static int32 GetStorageSize(const TSTRING& str);
|
static int32 GetStorageSize(const TSTRING& str);
|
||||||
// this method calculates how many bytes the given string will take up in the archive and returns
|
// this method calculates how many bytes the given string will take up in the archive and returns
|
||||||
// that value
|
// that value
|
||||||
// NOTE -- if the implementation of ReadString() or WriteString() ever changes, this method will also
|
// NOTE -- if the implementation of ReadString() or WriteString() ever changes, this method will also
|
||||||
// need to change.
|
// need to change.
|
||||||
|
|
||||||
int64 Copy(cArchive* pFrom, int64 amt); // throw(eArchive)
|
int64 Copy(cArchive* pFrom, int64 amt); // throw(eArchive)
|
||||||
// this method copies amt bytes from pFrom to itself, throwing an eArchive if anything goes wrong.
|
// this method copies amt bytes from pFrom to itself, throwing an eArchive if anything goes wrong.
|
||||||
|
|
||||||
// only makes sense to call for reading archives
|
// only makes sense to call for reading archives
|
||||||
|
@ -126,7 +128,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// overrides
|
// overrides
|
||||||
virtual int Read(void* pDest, int count) = 0;
|
virtual int Read(void* pDest, int count) = 0;
|
||||||
virtual int Write(const void* pDest, int count) = 0; // throw(eArchive);
|
virtual int Write(const void* pDest, int count) = 0; // throw(eArchive);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -137,15 +139,16 @@ protected:
|
||||||
class cBidirArchive : public cArchive
|
class cBidirArchive : public cArchive
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum SeekFrom {
|
enum SeekFrom
|
||||||
|
{
|
||||||
BEGINNING = 0,
|
BEGINNING = 0,
|
||||||
CURRENT = 1,
|
CURRENT = 1,
|
||||||
END = -1
|
END = -1
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual void Seek(int64 offset, SeekFrom from) = 0; // throw(eArchive);
|
virtual void Seek(int64 offset, SeekFrom from) = 0; // throw(eArchive);
|
||||||
virtual int64 CurrentPos() const = 0;
|
virtual int64 CurrentPos() const = 0;
|
||||||
virtual int64 Length() const = 0;
|
virtual int64 Length() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -155,29 +158,30 @@ public:
|
||||||
class cMemMappedArchive : public cBidirArchive
|
class cMemMappedArchive : public cBidirArchive
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum {
|
enum
|
||||||
|
{
|
||||||
MAP_TO_EOF = -1
|
MAP_TO_EOF = -1
|
||||||
};
|
};
|
||||||
|
|
||||||
cMemMappedArchive();
|
cMemMappedArchive();
|
||||||
virtual ~cMemMappedArchive();
|
virtual ~cMemMappedArchive();
|
||||||
|
|
||||||
virtual void MapArchive(int64 offset, int64 len) = 0; // throw(eArchive);
|
virtual void MapArchive(int64 offset, int64 len) = 0; // throw(eArchive);
|
||||||
virtual void MapArchive(int64 offset, int64 len) const = 0; // throw(eArchive);
|
virtual void MapArchive(int64 offset, int64 len) const = 0; // throw(eArchive);
|
||||||
// the const version of MapArchive() does not allow the archive to grow in size
|
// the const version of MapArchive() does not allow the archive to grow in size
|
||||||
|
|
||||||
int64 GetMappedOffset() const; // throw(eArchive)
|
int64 GetMappedOffset() const; // throw(eArchive)
|
||||||
int64 GetMappedLength() const; // throw(eArchive)
|
int64 GetMappedLength() const; // throw(eArchive)
|
||||||
void* GetMap(); // throw(eArchive)
|
void* GetMap(); // throw(eArchive)
|
||||||
const void* GetMap() const;
|
const void* GetMap() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
mutable void* mpMappedMem;
|
mutable void* mpMappedMem;
|
||||||
mutable int64 mMappedOffset;
|
mutable int64 mMappedOffset;
|
||||||
mutable int64 mMappedLength;
|
mutable int64 mMappedLength;
|
||||||
|
|
||||||
// call in derived class to set above vars
|
// call in derived class to set above vars
|
||||||
void SetNewMap(void* pMap, int64 offset, int64 length) const;
|
void SetNewMap(void* pMap, int64 offset, int64 length) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -193,27 +197,30 @@ public:
|
||||||
cMemoryArchive(int maxSize = 0x8000000); // default max size == 128MB
|
cMemoryArchive(int maxSize = 0x8000000); // default max size == 128MB
|
||||||
~cMemoryArchive();
|
~cMemoryArchive();
|
||||||
|
|
||||||
virtual bool EndOfFile();
|
virtual bool EndOfFile();
|
||||||
virtual void Seek(int64 offset, SeekFrom from); // throw(eArchive)
|
virtual void Seek(int64 offset, SeekFrom from); // throw(eArchive)
|
||||||
virtual int64 CurrentPos() const;
|
virtual int64 CurrentPos() const;
|
||||||
virtual int64 Length() const;
|
virtual int64 Length() const;
|
||||||
virtual void MapArchive(int64 offset, int64 len); // throw(eArchive)
|
virtual void MapArchive(int64 offset, int64 len); // throw(eArchive)
|
||||||
virtual void MapArchive(int64 offset, int64 len) const; // throw(eArchive)
|
virtual void MapArchive(int64 offset, int64 len) const; // throw(eArchive)
|
||||||
|
|
||||||
void Truncate(); // set the length to the current pos
|
void Truncate(); // set the length to the current pos
|
||||||
|
|
||||||
int8* GetMemory() const { return mpMemory; }
|
int8* GetMemory() const
|
||||||
|
{
|
||||||
|
return mpMemory;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int8* mpMemory;
|
int8* mpMemory;
|
||||||
int mAllocatedLen;
|
int mAllocatedLen;
|
||||||
int mMaxAllocatedLen;
|
int mMaxAllocatedLen;
|
||||||
int mLogicalSize;
|
int mLogicalSize;
|
||||||
int mReadHead;
|
int mReadHead;
|
||||||
|
|
||||||
virtual int Read(void* pDest, int count);
|
virtual int Read(void* pDest, int count);
|
||||||
virtual int Write(const void* pDest, int count); // throw(eArchive)
|
virtual int Write(const void* pDest, int count); // throw(eArchive)
|
||||||
virtual void AllocateMemory(int len); // throw(eArchive)
|
virtual void AllocateMemory(int len); // throw(eArchive)
|
||||||
};
|
};
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -224,30 +231,31 @@ class cFixedMemArchive : public cBidirArchive
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
cFixedMemArchive();
|
cFixedMemArchive();
|
||||||
cFixedMemArchive( int8* pMem, int32 size );
|
cFixedMemArchive(int8* pMem, int32 size);
|
||||||
virtual ~cFixedMemArchive();
|
virtual ~cFixedMemArchive();
|
||||||
|
|
||||||
void Attach( int8* pMem, int32 size );
|
void Attach(int8* pMem, int32 size);
|
||||||
// this method associates the archive with pMem and sets the size of the
|
// this method associates the archive with pMem and sets the size of the
|
||||||
// archive. Unlike cMemoryArchive, this may never grow or shrink in size.
|
// archive. Unlike cMemoryArchive, this may never grow or shrink in size.
|
||||||
|
|
||||||
//-----------------------------------
|
//-----------------------------------
|
||||||
// cBidirArchive interface
|
// cBidirArchive interface
|
||||||
//-----------------------------------
|
//-----------------------------------
|
||||||
virtual void Seek (int64 offset, SeekFrom from) ; // throw(eArchive);
|
virtual void Seek(int64 offset, SeekFrom from); // throw(eArchive);
|
||||||
virtual int64 CurrentPos () const ;
|
virtual int64 CurrentPos() const;
|
||||||
virtual int64 Length () const ;
|
virtual int64 Length() const;
|
||||||
virtual bool EndOfFile();
|
virtual bool EndOfFile();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//-----------------------------------
|
//-----------------------------------
|
||||||
// cArchive interface
|
// cArchive interface
|
||||||
//-----------------------------------
|
//-----------------------------------
|
||||||
virtual int Read(void* pDest, int count); // throw(eArchive)
|
virtual int Read(void* pDest, int count); // throw(eArchive)
|
||||||
virtual int Write(const void* pDest, int count); // throw(eArchive)
|
virtual int Write(const void* pDest, int count); // throw(eArchive)
|
||||||
|
|
||||||
int8* mpMemory;
|
int8* mpMemory;
|
||||||
int32 mSize;
|
int32 mSize;
|
||||||
int32 mReadHead;
|
int32 mReadHead;
|
||||||
};
|
};
|
||||||
|
|
||||||
class cFileArchive : public cBidirArchive
|
class cFileArchive : public cBidirArchive
|
||||||
|
@ -258,71 +266,74 @@ public:
|
||||||
|
|
||||||
enum OpenFlags
|
enum OpenFlags
|
||||||
{
|
{
|
||||||
FA_OPEN_TEXT = 0x1,
|
FA_OPEN_TEXT = 0x1,
|
||||||
FA_OPEN_TRUNCATE = 0x2,
|
FA_OPEN_TRUNCATE = 0x2,
|
||||||
FA_SCANNING = 0x4,
|
FA_SCANNING = 0x4,
|
||||||
FA_DIRECT = 0x8
|
FA_DIRECT = 0x8
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: Open should throw
|
// TODO: Open should throw
|
||||||
virtual void OpenRead(const TCHAR* filename, uint32 openFlags = 0 );
|
virtual void OpenRead(const TCHAR* filename, uint32 openFlags = 0);
|
||||||
virtual void OpenReadWrite(const TCHAR* filename, uint32 openFlags = FA_OPEN_TRUNCATE );
|
virtual void OpenReadWrite(const TCHAR* filename, uint32 openFlags = FA_OPEN_TRUNCATE);
|
||||||
// opens a file for reading or writing; the file is always created if it doesn't exist,
|
// opens a file for reading or writing; the file is always created if it doesn't exist,
|
||||||
// and is truncated to zero length if truncateFile is set to true;
|
// and is truncated to zero length if truncateFile is set to true;
|
||||||
TSTRING GetCurrentFilename(void) const;
|
TSTRING GetCurrentFilename(void) const;
|
||||||
virtual void Close(void);
|
virtual void Close(void);
|
||||||
void Truncate(); // throw(eArchive) // set the length to the current pos
|
void Truncate(); // throw(eArchive) // set the length to the current pos
|
||||||
|
|
||||||
//-----------------------------------
|
//-----------------------------------
|
||||||
// cBidirArchive interface
|
// cBidirArchive interface
|
||||||
//-----------------------------------
|
//-----------------------------------
|
||||||
virtual bool EndOfFile();
|
virtual bool EndOfFile();
|
||||||
virtual void Seek(int64 offset, SeekFrom from); // throw(eArchive)
|
virtual void Seek(int64 offset, SeekFrom from); // throw(eArchive)
|
||||||
virtual int64 CurrentPos() const;
|
virtual int64 CurrentPos() const;
|
||||||
virtual int64 Length() const;
|
virtual int64 Length() const;
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int64 mFileSize; //Size of FileArchive
|
int64 mFileSize; //Size of FileArchive
|
||||||
int64 mReadHead; //Current position of read/write head
|
int64 mReadHead; //Current position of read/write head
|
||||||
//-----------------------------------
|
//-----------------------------------
|
||||||
// cArchive interface
|
// cArchive interface
|
||||||
//-----------------------------------
|
//-----------------------------------
|
||||||
virtual int Read(void* pDest, int count);
|
virtual int Read(void* pDest, int count);
|
||||||
virtual int Write(const void* pDest, int count); //throw(eArchive)
|
virtual int Write(const void* pDest, int count); //throw(eArchive)
|
||||||
bool isWritable;
|
bool isWritable;
|
||||||
cFile mCurrentFile;
|
cFile mCurrentFile;
|
||||||
TSTRING mCurrentFilename; //current file
|
TSTRING mCurrentFilename; //current file
|
||||||
uint32 mOpenFlags;
|
uint32 mOpenFlags;
|
||||||
};
|
};
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// cLockedTemporaryFileArchive -- this class uses as an archive a file
|
// cLockedTemporaryFileArchive -- this class uses as an archive a file
|
||||||
// that is not accessable to any other process besides the calling one.
|
// that is not accessable to any other process besides the calling one.
|
||||||
// the file will be deleted from the filesystem on Close();
|
// the file will be deleted from the filesystem on Close();
|
||||||
//
|
//
|
||||||
// implemented by using cFileArchive and overwriting open and close
|
// implemented by using cFileArchive and overwriting open and close
|
||||||
// functions
|
// functions
|
||||||
//
|
//
|
||||||
class cLockedTemporaryFileArchive : public cFileArchive
|
class cLockedTemporaryFileArchive : public cFileArchive
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual void OpenReadWrite ( const TCHAR* filename = NULL, uint32 openFlags = FA_OPEN_TRUNCATE );
|
virtual void OpenReadWrite(const TCHAR* filename = NULL, uint32 openFlags = FA_OPEN_TRUNCATE);
|
||||||
// creates the file. filename must not exist on the file system.
|
// creates the file. filename must not exist on the file system.
|
||||||
// if filename is NULL, the class will create and use a temporary file.
|
// if filename is NULL, the class will create and use a temporary file.
|
||||||
// truncateFile has no meaning
|
// truncateFile has no meaning
|
||||||
//virtual void OpenReadWriteThrow ( const TCHAR* filename = NULL, bool truncateFile = true ) throw (eArchive);
|
//virtual void OpenReadWriteThrow ( const TCHAR* filename = NULL, bool truncateFile = true ) throw (eArchive);
|
||||||
// this is the same as OpenReadWrite, except an exception is thrown on error (of type
|
// this is the same as OpenReadWrite, except an exception is thrown on error (of type
|
||||||
// cArchive::ERR_OPEN_FAILED)
|
// cArchive::ERR_OPEN_FAILED)
|
||||||
|
|
||||||
virtual void Close();
|
virtual void Close();
|
||||||
// close and delete the file
|
// close and delete the file
|
||||||
private:
|
private:
|
||||||
// open for read only makes no sense if we're always creating the file,
|
// open for read only makes no sense if we're always creating the file,
|
||||||
// so disallow read only file opens
|
// so disallow read only file opens
|
||||||
virtual void OpenRead( const TCHAR*, uint32 openFlags = 0 ) { ASSERT( false ); THROW_INTERNAL("archive.h"); }
|
virtual void OpenRead(const TCHAR*, uint32 openFlags = 0)
|
||||||
|
{
|
||||||
|
ASSERT(false);
|
||||||
|
THROW_INTERNAL("archive.h");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
//
|
//
|
||||||
// The developer of the original code and/or files is Tripwire, Inc.
|
// The developer of the original code and/or files is Tripwire, Inc.
|
||||||
// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire,
|
// Portions created by Tripwire, Inc. are copyright (C) 2000-2018 Tripwire,
|
||||||
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
||||||
// reserved.
|
// reserved.
|
||||||
//
|
//
|
||||||
// This program is free software. The contents of this file are subject
|
// 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
|
// 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
|
// Free Software Foundation; either version 2 of the License, or (at your
|
||||||
// option) any later version. You may redistribute it and/or modify it
|
// option) any later version. You may redistribute it and/or modify it
|
||||||
// only in compliance with the GNU General Public License.
|
// only in compliance with the GNU General Public License.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful.
|
// This program is distributed in the hope that it will be useful.
|
||||||
// However, this program is distributed AS-IS WITHOUT ANY
|
// However, this program is distributed AS-IS WITHOUT ANY
|
||||||
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
||||||
// for more details.
|
// for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
// USA.
|
// USA.
|
||||||
//
|
//
|
||||||
// Nothing in the GNU General Public License or any other license to use
|
// 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,
|
// the code or files shall permit you to use Tripwire's trademarks,
|
||||||
// service marks, or other intellectual property without Tripwire's
|
// service marks, or other intellectual property without Tripwire's
|
||||||
// prior written consent.
|
// prior written consent.
|
||||||
//
|
//
|
||||||
// If you have any questions, please contact Tripwire, Inc. at either
|
// If you have any questions, please contact Tripwire, Inc. at either
|
||||||
// info@tripwire.org or www.tripwire.org.
|
// info@tripwire.org or www.tripwire.org.
|
||||||
//
|
//
|
||||||
|
@ -42,48 +42,48 @@
|
||||||
#include "ntmbs.h"
|
#include "ntmbs.h"
|
||||||
|
|
||||||
#if IS_ANDROID
|
#if IS_ANDROID
|
||||||
int mblen(const char *s, size_t n)
|
int mblen(const char* s, size_t n)
|
||||||
{
|
{
|
||||||
return mbtowc(0, s, n);
|
return mbtowc(0, s, n);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//
|
//
|
||||||
// finds the next whole character in string identified by ['cur'-'end')
|
// finds the next whole character in string identified by ['cur'-'end')
|
||||||
// identifies beginning of char in 'first', then end of character in 'last'
|
// identifies beginning of char in 'first', then end of character in 'last'
|
||||||
// returns number of TCHARs that make up the next character
|
// returns number of TCHARs that make up the next character
|
||||||
// if there are no more characters, will return 0 and first = last = end
|
// if there are no more characters, will return 0 and first = last = end
|
||||||
// POSTCONDITIONS:
|
// POSTCONDITIONS:
|
||||||
//
|
//
|
||||||
// RETURNS:
|
// RETURNS:
|
||||||
//
|
//
|
||||||
// THROWS:
|
// THROWS:
|
||||||
//
|
//
|
||||||
// COMPLEXITY:
|
// COMPLEXITY:
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
|
||||||
/* static */
|
/* static */
|
||||||
bool cCharUtil::PeekNextChar( const TSTRING::const_iterator& cur,
|
bool cCharUtil::PeekNextChar(const TSTRING::const_iterator& cur,
|
||||||
const TSTRING::const_iterator& end,
|
const TSTRING::const_iterator& end,
|
||||||
TSTRING::const_iterator& first,
|
TSTRING::const_iterator& first,
|
||||||
TSTRING::const_iterator& last )
|
TSTRING::const_iterator& last)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// do we have a valid string here?
|
// do we have a valid string here?
|
||||||
//
|
//
|
||||||
if( cur > end )
|
if (cur > end)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( cur == end )
|
if (cur == end)
|
||||||
{
|
{
|
||||||
first = last = end;
|
first = last = end;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( *cur == _T('\0') )
|
if (*cur == _T('\0'))
|
||||||
{
|
{
|
||||||
first = last = cur;
|
first = last = cur;
|
||||||
return false;
|
return false;
|
||||||
|
@ -93,19 +93,19 @@ bool cCharUtil::PeekNextChar( const TSTRING::const_iterator& cur,
|
||||||
|
|
||||||
if (!(*cur))
|
if (!(*cur))
|
||||||
{
|
{
|
||||||
last = cur;
|
last = cur;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if !IS_AROS
|
#if !IS_AROS
|
||||||
mblen (NULL, 0);
|
mblen(NULL, 0);
|
||||||
int len = mblen(&*cur, MB_CUR_MAX);
|
int len = mblen(&*cur, MB_CUR_MAX);
|
||||||
if (len < 0) //invalid multibyte sequence, but let's not blow up.
|
if (len < 0) //invalid multibyte sequence, but let's not blow up.
|
||||||
len = 1;
|
len = 1;
|
||||||
|
|
||||||
last = cur + len;
|
last = cur + len;
|
||||||
#else // AROS mblen() seems broken (as of 6/2016) so don't use it.
|
#else // AROS mblen() seems broken (as of 6/2016) so don't use it.
|
||||||
last = cur + 1;
|
last = cur + 1;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,40 +114,38 @@ bool cCharUtil::PeekNextChar( const TSTRING::const_iterator& cur,
|
||||||
|
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
//
|
//
|
||||||
// /* static */
|
// /* static */
|
||||||
// bool cCharUtil::PopNextChar( TSTRING::const_iterator& cur,
|
// bool cCharUtil::PopNextChar( TSTRING::const_iterator& cur,
|
||||||
// const TSTRING::const_iterator& end,
|
// const TSTRING::const_iterator& end,
|
||||||
// TSTRING::const_iterator& first,
|
// TSTRING::const_iterator& first,
|
||||||
// TSTRING::const_iterator& last )
|
// TSTRING::const_iterator& last )
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// REQUIRES:
|
// REQUIRES:
|
||||||
//
|
//
|
||||||
// EFFECTS:
|
// EFFECTS:
|
||||||
//
|
//
|
||||||
// same as PeekNextChar but increments 'cur' to 'last'
|
// same as PeekNextChar but increments 'cur' to 'last'
|
||||||
//
|
//
|
||||||
// POSTCONDITIONS:
|
// POSTCONDITIONS:
|
||||||
//
|
//
|
||||||
// RETURNS:
|
// RETURNS:
|
||||||
//
|
//
|
||||||
// THROWS:
|
// THROWS:
|
||||||
//
|
//
|
||||||
// COMPLEXITY:
|
// COMPLEXITY:
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
|
||||||
/* static */
|
/* static */
|
||||||
bool cCharUtil::PopNextChar( TSTRING::const_iterator& cur,
|
bool cCharUtil::PopNextChar(TSTRING::const_iterator& cur,
|
||||||
const TSTRING::const_iterator& end,
|
const TSTRING::const_iterator& end,
|
||||||
TSTRING::const_iterator& first,
|
TSTRING::const_iterator& first,
|
||||||
TSTRING::const_iterator& last )
|
TSTRING::const_iterator& last)
|
||||||
{
|
{
|
||||||
bool f = PeekNextChar( cur, end, first, last );
|
bool f = PeekNextChar(cur, end, first, last);
|
||||||
|
|
||||||
cur = last; // pop causes 'cur' to move to just beyond character ('last')
|
cur = last; // pop causes 'cur' to move to just beyond character ('last')
|
||||||
|
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
//
|
//
|
||||||
// The developer of the original code and/or files is Tripwire, Inc.
|
// The developer of the original code and/or files is Tripwire, Inc.
|
||||||
// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire,
|
// Portions created by Tripwire, Inc. are copyright (C) 2000-2018 Tripwire,
|
||||||
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
||||||
// reserved.
|
// reserved.
|
||||||
//
|
//
|
||||||
// This program is free software. The contents of this file are subject
|
// 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
|
// 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
|
// Free Software Foundation; either version 2 of the License, or (at your
|
||||||
// option) any later version. You may redistribute it and/or modify it
|
// option) any later version. You may redistribute it and/or modify it
|
||||||
// only in compliance with the GNU General Public License.
|
// only in compliance with the GNU General Public License.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful.
|
// This program is distributed in the hope that it will be useful.
|
||||||
// However, this program is distributed AS-IS WITHOUT ANY
|
// However, this program is distributed AS-IS WITHOUT ANY
|
||||||
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
||||||
// for more details.
|
// for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
// USA.
|
// USA.
|
||||||
//
|
//
|
||||||
// Nothing in the GNU General Public License or any other license to use
|
// 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,
|
// the code or files shall permit you to use Tripwire's trademarks,
|
||||||
// service marks, or other intellectual property without Tripwire's
|
// service marks, or other intellectual property without Tripwire's
|
||||||
// prior written consent.
|
// prior written consent.
|
||||||
//
|
//
|
||||||
// If you have any questions, please contact Tripwire, Inc. at either
|
// If you have any questions, please contact Tripwire, Inc. at either
|
||||||
// info@tripwire.org or www.tripwire.org.
|
// info@tripwire.org or www.tripwire.org.
|
||||||
//
|
//
|
||||||
|
@ -44,23 +44,20 @@
|
||||||
class cCharUtil
|
class cCharUtil
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
||||||
// finds the next whole character in string identified by ['cur'-'end')
|
// finds the next whole character in string identified by ['cur'-'end')
|
||||||
// identifies beginning of char in 'first', then end of character in 'last'
|
// identifies beginning of char in 'first', then end of character in 'last'
|
||||||
// returns 'are there more characters in string?'
|
// returns 'are there more characters in string?'
|
||||||
// if there are no more characters, will return 0 and first = last = end
|
// if there are no more characters, will return 0 and first = last = end
|
||||||
static bool PeekNextChar( const TSTRING::const_iterator& cur,
|
static bool PeekNextChar(const TSTRING::const_iterator& cur,
|
||||||
const TSTRING::const_iterator& end,
|
const TSTRING::const_iterator& end,
|
||||||
TSTRING::const_iterator& first,
|
TSTRING::const_iterator& first,
|
||||||
TSTRING::const_iterator& last );
|
TSTRING::const_iterator& last);
|
||||||
|
|
||||||
// same as PeekNextChar but increments 'cur' to 'last'
|
// same as PeekNextChar but increments 'cur' to 'last'
|
||||||
static bool PopNextChar( TSTRING::const_iterator& cur,
|
static bool PopNextChar(TSTRING::const_iterator& cur,
|
||||||
const TSTRING::const_iterator& end,
|
const TSTRING::const_iterator& end,
|
||||||
TSTRING::const_iterator& first,
|
TSTRING::const_iterator& first,
|
||||||
TSTRING::const_iterator& last );
|
TSTRING::const_iterator& last);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif//__CHARUTIL_H
|
#endif //__CHARUTIL_H
|
||||||
|
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
//
|
//
|
||||||
// The developer of the original code and/or files is Tripwire, Inc.
|
// The developer of the original code and/or files is Tripwire, Inc.
|
||||||
// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire,
|
// Portions created by Tripwire, Inc. are copyright (C) 2000-2018 Tripwire,
|
||||||
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
||||||
// reserved.
|
// reserved.
|
||||||
//
|
//
|
||||||
// This program is free software. The contents of this file are subject
|
// 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
|
// 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
|
// Free Software Foundation; either version 2 of the License, or (at your
|
||||||
// option) any later version. You may redistribute it and/or modify it
|
// option) any later version. You may redistribute it and/or modify it
|
||||||
// only in compliance with the GNU General Public License.
|
// only in compliance with the GNU General Public License.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful.
|
// This program is distributed in the hope that it will be useful.
|
||||||
// However, this program is distributed AS-IS WITHOUT ANY
|
// However, this program is distributed AS-IS WITHOUT ANY
|
||||||
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
||||||
// for more details.
|
// for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
// USA.
|
// USA.
|
||||||
//
|
//
|
||||||
// Nothing in the GNU General Public License or any other license to use
|
// 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,
|
// the code or files shall permit you to use Tripwire's trademarks,
|
||||||
// service marks, or other intellectual property without Tripwire's
|
// service marks, or other intellectual property without Tripwire's
|
||||||
// prior written consent.
|
// prior written consent.
|
||||||
//
|
//
|
||||||
// If you have any questions, please contact Tripwire, Inc. at either
|
// If you have any questions, please contact Tripwire, Inc. at either
|
||||||
// info@tripwire.org or www.tripwire.org.
|
// info@tripwire.org or www.tripwire.org.
|
||||||
//
|
//
|
||||||
|
@ -38,9 +38,7 @@
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// ctor, dotr
|
// ctor, dotr
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
cCmdLineParser::cCmdLineParser() :
|
cCmdLineParser::cCmdLineParser() : mArgTable(HASH_VERY_SMALL), mLastArgInfo(-1, PARAM_NONE)
|
||||||
mArgTable(HASH_VERY_SMALL),
|
|
||||||
mLastArgInfo(-1, PARAM_NONE)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,19 +49,20 @@ cCmdLineParser::~cCmdLineParser()
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// AddArg
|
// AddArg
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
void cCmdLineParser::AddArg(int argId, const TSTRING& arg, const TSTRING& alias, ParamCount numParams, bool multipleAllowed)
|
void cCmdLineParser::AddArg(
|
||||||
|
int argId, const TSTRING& arg, const TSTRING& alias, ParamCount numParams, bool multipleAllowed)
|
||||||
{
|
{
|
||||||
if(arg.empty() && alias.empty())
|
if (arg.empty() && alias.empty())
|
||||||
{
|
{
|
||||||
// this refers to the list of parameters that comes after all the cmd line switches
|
// this refers to the list of parameters that comes after all the cmd line switches
|
||||||
mLastArgInfo.mId = argId;
|
mLastArgInfo.mId = argId;
|
||||||
mLastArgInfo.mNumParams = numParams;
|
mLastArgInfo.mNumParams = numParams;
|
||||||
return ;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(! arg.empty())
|
if (!arg.empty())
|
||||||
mArgTable.Insert(arg, cArgInfo(argId, numParams));
|
mArgTable.Insert(arg, cArgInfo(argId, numParams));
|
||||||
if(! alias.empty())
|
if (!alias.empty())
|
||||||
{
|
{
|
||||||
// put the alias in the table with a '-' prepended to it so it matches '--'
|
// put the alias in the table with a '-' prepended to it so it matches '--'
|
||||||
TSTRING str(_T("-"));
|
TSTRING str(_T("-"));
|
||||||
|
@ -71,8 +70,8 @@ void cCmdLineParser::AddArg(int argId, const TSTRING& arg, const TSTRING& alias,
|
||||||
mArgTable.Insert(str, cArgInfo(argId, numParams));
|
mArgTable.Insert(str, cArgInfo(argId, numParams));
|
||||||
}
|
}
|
||||||
// This argument can appear more than once on the command line.
|
// This argument can appear more than once on the command line.
|
||||||
if( multipleAllowed )
|
if (multipleAllowed)
|
||||||
mMultipleAllowed.insert( argId );
|
mMultipleAllowed.insert(argId);
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -90,43 +89,39 @@ void cCmdLineParser::AddArg(int argId, const TSTRING& arg, const TSTRING& alias,
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// Parse
|
// Parse
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
void cCmdLineParser::Parse(int argc, const TCHAR *const * argv)
|
void cCmdLineParser::Parse(int argc, const TCHAR* const* argv)
|
||||||
{
|
{
|
||||||
// clear out any existing data
|
// clear out any existing data
|
||||||
mArgData.clear();
|
mArgData.clear();
|
||||||
|
|
||||||
const TCHAR* pCurArg = 0;
|
const TCHAR* pCurArg = 0;
|
||||||
bool bProcessedFinalParams = false; // gets set to true when the parameters to the command line are processed
|
bool bProcessedFinalParams = false; // gets set to true when the parameters to the command line are processed
|
||||||
|
|
||||||
// I assume argv[0] is the executable name...
|
// I assume argv[0] is the executable name...
|
||||||
for(int i=1; i < argc; i++)
|
for (int i = 1; i < argc; i++)
|
||||||
{
|
{
|
||||||
if(argv[i][0] == _T('-'))
|
if (argv[i][0] == _T('-'))
|
||||||
{
|
{
|
||||||
pCurArg = argv[i];
|
pCurArg = argv[i];
|
||||||
|
|
||||||
// this is a switch; find it in the table...
|
// this is a switch; find it in the table...
|
||||||
cArgInfo argInfo;
|
cArgInfo argInfo;
|
||||||
if ( !mArgTable.Lookup( TSTRING(&argv[i][1] ), argInfo ) )
|
if (!mArgTable.Lookup(TSTRING(&argv[i][1]), argInfo))
|
||||||
{
|
{
|
||||||
// unknown switch!
|
// unknown switch!
|
||||||
throw eCmdLineInvalidArg(
|
throw eCmdLineInvalidArg(TSS_GetString(cCore, core::STR_ERR2_BAD_ARG_PARAMS) + pCurArg);
|
||||||
TSS_GetString( cCore, core::STR_ERR2_BAD_ARG_PARAMS )
|
|
||||||
+ pCurArg );
|
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
// make sure this hasn't been specified yet...
|
// make sure this hasn't been specified yet...
|
||||||
//
|
//
|
||||||
if( ArgInList( argInfo.mId ) )
|
if (ArgInList(argInfo.mId))
|
||||||
{
|
{
|
||||||
// Make sure it isn't okay for this one to appear more than once...
|
// Make sure it isn't okay for this one to appear more than once...
|
||||||
std::set<int>::iterator it = mMultipleAllowed.find( argInfo.mId );
|
std::set<int>::iterator it = mMultipleAllowed.find(argInfo.mId);
|
||||||
if( it == mMultipleAllowed.end() )
|
if (it == mMultipleAllowed.end())
|
||||||
{
|
{
|
||||||
// It wasn't in our list of allowed params, so error.
|
// It wasn't in our list of allowed params, so error.
|
||||||
throw eCmdLineMultiArg(
|
throw eCmdLineMultiArg(TSS_GetString(cCore, core::STR_ERR2_BAD_ARG_PARAMS) + argv[i]);
|
||||||
TSS_GetString( cCore, core::STR_ERR2_BAD_ARG_PARAMS )
|
|
||||||
+ argv[i] );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
|
@ -134,24 +129,22 @@ void cCmdLineParser::Parse(int argc, const TCHAR *const * argv)
|
||||||
//
|
//
|
||||||
mArgData.push_back(cArgData(argInfo.mId, TSTRING(argv[i])));
|
mArgData.push_back(cArgData(argInfo.mId, TSTRING(argv[i])));
|
||||||
cArgData& curArg = mArgData.back();
|
cArgData& curArg = mArgData.back();
|
||||||
switch( argInfo.mNumParams )
|
switch (argInfo.mNumParams)
|
||||||
{
|
{
|
||||||
case PARAM_NONE:
|
case PARAM_NONE:
|
||||||
// make sure there are no parameters to this, but be careful because
|
// make sure there are no parameters to this, but be careful because
|
||||||
// it is legal to start the parameters to the executable here.
|
// it is legal to start the parameters to the executable here.
|
||||||
if((i+1 < argc) && (argv[i+1][0] != _T('-')))
|
if ((i + 1 < argc) && (argv[i + 1][0] != _T('-')))
|
||||||
{
|
{
|
||||||
// search for any more parameters
|
// search for any more parameters
|
||||||
// TODO: In the future we may want to support a '--' switch that specifies the start
|
// TODO: In the future we may want to support a '--' switch that specifies the start
|
||||||
// of parameters to the executable.
|
// of parameters to the executable.
|
||||||
for (int j = i + 2; j < argc; ++j )
|
for (int j = i + 2; j < argc; ++j)
|
||||||
{
|
{
|
||||||
if (argv[j][0] == _T('-'))
|
if (argv[j][0] == _T('-'))
|
||||||
{
|
{
|
||||||
// >0 parameter passed !
|
// >0 parameter passed !
|
||||||
throw eCmdLineBadParam(
|
throw eCmdLineBadParam(TSS_GetString(cCore, core::STR_ERR2_BAD_ARG_PARAMS) + pCurArg);
|
||||||
TSS_GetString( cCore, core::STR_ERR2_BAD_ARG_PARAMS )
|
|
||||||
+ pCurArg );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -160,29 +153,27 @@ void cCmdLineParser::Parse(int argc, const TCHAR *const * argv)
|
||||||
case PARAM_ONE:
|
case PARAM_ONE:
|
||||||
// get the next parameter...
|
// get the next parameter...
|
||||||
i++;
|
i++;
|
||||||
if ( (i >= argc) || (argv[i][0] == _T('-')) )
|
if ((i >= argc) || (argv[i][0] == _T('-')))
|
||||||
{
|
{
|
||||||
// zero parameters passed to something that needed one param
|
// zero parameters passed to something that needed one param
|
||||||
throw eCmdLineBadParam(
|
throw eCmdLineBadParam(TSS_GetString(cCore, core::STR_ERR2_BAD_ARG_PARAMS) + pCurArg);
|
||||||
TSS_GetString( cCore, core::STR_ERR2_BAD_ARG_PARAMS )
|
|
||||||
+ pCurArg );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
curArg.mParams.push_back( TSTRING(argv[i]) );
|
curArg.mParams.push_back(TSTRING(argv[i]));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PARAM_MANY:
|
case PARAM_MANY:
|
||||||
i++;
|
i++;
|
||||||
while((i < argc) && (argv[i][0] != _T('-')))
|
while ((i < argc) && (argv[i][0] != _T('-')))
|
||||||
{
|
{
|
||||||
curArg.mParams.push_back(TSTRING(argv[i]));
|
curArg.mParams.push_back(TSTRING(argv[i]));
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
i--; // since we have gone too far at this point
|
i--; // since we have gone too far at this point
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
ASSERTMSG( false, "Unknown number of arguments to parser" );
|
ASSERTMSG(false, "Unknown number of arguments to parser");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -191,14 +182,14 @@ void cCmdLineParser::Parse(int argc, const TCHAR *const * argv)
|
||||||
// this must be the final "unnamed" arg
|
// this must be the final "unnamed" arg
|
||||||
// first, make sure it is consistent with the current info...
|
// first, make sure it is consistent with the current info...
|
||||||
bool bResult = true;
|
bool bResult = true;
|
||||||
switch(mLastArgInfo.mNumParams)
|
switch (mLastArgInfo.mNumParams)
|
||||||
{
|
{
|
||||||
case PARAM_NONE:
|
case PARAM_NONE:
|
||||||
// this is an error; they didn't want any command line parameters...
|
// this is an error; they didn't want any command line parameters...
|
||||||
bResult = false;
|
bResult = false;
|
||||||
break;
|
break;
|
||||||
case PARAM_ONE:
|
case PARAM_ONE:
|
||||||
if(i+1 != argc)
|
if (i + 1 != argc)
|
||||||
// there is >1 final parameter; it is an error
|
// there is >1 final parameter; it is an error
|
||||||
bResult = false;
|
bResult = false;
|
||||||
break;
|
break;
|
||||||
|
@ -207,33 +198,28 @@ void cCmdLineParser::Parse(int argc, const TCHAR *const * argv)
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ASSERT(false);
|
ASSERT(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
if(! bResult)
|
if (!bResult)
|
||||||
{
|
{
|
||||||
throw eCmdLineBadParam( );
|
throw eCmdLineBadParam();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ok, we can push the final parameter info onto the list...
|
// ok, we can push the final parameter info onto the list...
|
||||||
mArgData.push_back(cArgData(mLastArgInfo.mId));
|
mArgData.push_back(cArgData(mLastArgInfo.mId));
|
||||||
cArgData& curArg = mArgData.back();
|
cArgData& curArg = mArgData.back();
|
||||||
|
|
||||||
while ( i < argc )
|
while (i < argc)
|
||||||
{
|
{
|
||||||
if ( argv[i][0] == _T('-') )
|
if (argv[i][0] == _T('-'))
|
||||||
{
|
{
|
||||||
if ( ! pCurArg )
|
if (!pCurArg)
|
||||||
{
|
{
|
||||||
throw eCmdLineBadSwitchPos(
|
throw eCmdLineBadSwitchPos(TSS_GetString(cCore, core::STR_ERR2_BAD_ARG_PARAMS) + argv[i]);
|
||||||
TSS_GetString( cCore, core::STR_ERR2_BAD_ARG_PARAMS )
|
|
||||||
+ argv[i] );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// there was an extra parameter passed somewhere!
|
// there was an extra parameter passed somewhere!
|
||||||
throw eCmdLineBadArgParam(
|
throw eCmdLineBadArgParam(TSS_GetString(cCore, core::STR_ERR2_BAD_ARG_PARAMS) + pCurArg);
|
||||||
TSS_GetString( cCore, core::STR_ERR2_BAD_ARG_PARAMS )
|
|
||||||
+ pCurArg );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -241,21 +227,18 @@ void cCmdLineParser::Parse(int argc, const TCHAR *const * argv)
|
||||||
curArg.mParams.push_back(TSTRING(argv[i]));
|
curArg.mParams.push_back(TSTRING(argv[i]));
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// it is possible not to process the final command line parameters in the "else" case above
|
// it is possible not to process the final command line parameters in the "else" case above
|
||||||
// (this only occurs if there are no command line parameters specified) so let's make sure that
|
// (this only occurs if there are no command line parameters specified) so let's make sure that
|
||||||
// is consistent with what we are configured with...
|
// is consistent with what we are configured with...
|
||||||
// NOTE -- it is ok to have no cmd line parameters if they specified PARAM_NONE or PARAM_MANY
|
// NOTE -- it is ok to have no cmd line parameters if they specified PARAM_NONE or PARAM_MANY
|
||||||
if(! bProcessedFinalParams)
|
if (!bProcessedFinalParams)
|
||||||
{
|
{
|
||||||
if(mLastArgInfo.mNumParams == PARAM_ONE)
|
if (mLastArgInfo.mNumParams == PARAM_ONE)
|
||||||
{
|
{
|
||||||
throw eCmdLineBadParam( );
|
throw eCmdLineBadParam();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -269,28 +252,24 @@ void cCmdLineParser::Parse(int argc, const TCHAR *const * argv)
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
void cCmdLineParser::TestMutEx()
|
void cCmdLineParser::TestMutEx()
|
||||||
{
|
{
|
||||||
std::list<std::pair<int,int> >::const_iterator i;
|
std::list<std::pair<int, int> >::const_iterator i;
|
||||||
cCmdLineIter iter1(*this), iter2(*this);
|
cCmdLineIter iter1(*this), iter2(*this);
|
||||||
for(i = mMutExList.begin(); i != mMutExList.end(); i++)
|
for (i = mMutExList.begin(); i != mMutExList.end(); i++)
|
||||||
{
|
{
|
||||||
//TODO -- there is a much more efficent way to do this (using cFCOPropVector, for example)
|
//TODO -- there is a much more efficent way to do this (using cFCOPropVector, for example)
|
||||||
// the command line is presumably small enough, tho, that it probably isn't a big
|
// the command line is presumably small enough, tho, that it probably isn't a big
|
||||||
// deal to do it this way.
|
// deal to do it this way.
|
||||||
iter1.SeekToArg(i->first);
|
iter1.SeekToArg(i->first);
|
||||||
if(! iter1.Done())
|
if (!iter1.Done())
|
||||||
{
|
{
|
||||||
iter2.SeekToArg(i->second);
|
iter2.SeekToArg(i->second);
|
||||||
if(! iter2.Done())
|
if (!iter2.Done())
|
||||||
{
|
{
|
||||||
// we have a mutual exclusion violation!
|
// we have a mutual exclusion violation!
|
||||||
throw eCmdLineMutEx(
|
throw eCmdLineMutEx(iter1.ActualParam() + _T(", ") + iter2.ActualParam());
|
||||||
iter1.ActualParam()
|
|
||||||
+ _T(", ")
|
|
||||||
+ iter2.ActualParam() );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -298,51 +277,51 @@ void cCmdLineParser::TestMutEx()
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
void cCmdLineParser::TestDependency()
|
void cCmdLineParser::TestDependency()
|
||||||
{
|
{
|
||||||
std::list< std::pair< std::pair< int, int>, bool > >::const_iterator i;
|
std::list<std::pair<std::pair<int, int>, bool> >::const_iterator i;
|
||||||
cCmdLineIter iter1(*this), iter2(*this);
|
cCmdLineIter iter1(*this), iter2(*this);
|
||||||
|
|
||||||
for( i = mDependencyList.begin(); i != mDependencyList.end(); ++i)
|
for (i = mDependencyList.begin(); i != mDependencyList.end(); ++i)
|
||||||
{
|
{
|
||||||
iter1.SeekToArg( i->first.first );
|
iter1.SeekToArg(i->first.first);
|
||||||
// was it on the command line?
|
// was it on the command line?
|
||||||
if( !iter1.Done() )
|
if (!iter1.Done())
|
||||||
{
|
{
|
||||||
// it was, is the corresponding arg on the command line?
|
// it was, is the corresponding arg on the command line?
|
||||||
iter2.SeekToArg( i->first.second );
|
iter2.SeekToArg(i->first.second);
|
||||||
if( iter2.Done() ) // it wasn't, dependency error
|
if (iter2.Done()) // it wasn't, dependency error
|
||||||
{
|
{
|
||||||
TSTRING arg1, arg2, alias1, alias2;
|
TSTRING arg1, arg2, alias1, alias2;
|
||||||
cCmdLineParser::LookupArgInfo( i->first.first, arg1, alias1 );
|
cCmdLineParser::LookupArgInfo(i->first.first, arg1, alias1);
|
||||||
cCmdLineParser::LookupArgInfo( i->first.second, arg2, alias2 );
|
cCmdLineParser::LookupArgInfo(i->first.second, arg2, alias2);
|
||||||
|
|
||||||
// determine in which form the user passed the arguments,
|
// determine in which form the user passed the arguments,
|
||||||
// and construct the error message in the same form
|
// and construct the error message in the same form
|
||||||
if ( iter1.ActualParam().length() == 2 )
|
if (iter1.ActualParam().length() == 2)
|
||||||
throw eCmdLineDependency( _T("The switch -") + arg1 + _T(" requires -") + arg2 +_T(".") );
|
throw eCmdLineDependency(_T("The switch -") + arg1 + _T(" requires -") + arg2 + _T("."));
|
||||||
else
|
else
|
||||||
throw eCmdLineDependency( _T("The switch --") + alias1 + _T(" requires --") + alias2 + _T(".") );
|
throw eCmdLineDependency(_T("The switch --") + alias1 + _T(" requires --") + alias2 + _T("."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if( i->second )
|
else if (i->second)
|
||||||
// only make this second check if the dependencies are MUTUAL,
|
// only make this second check if the dependencies are MUTUAL,
|
||||||
// as indicated (or not) by the bool value.
|
// as indicated (or not) by the bool value.
|
||||||
{
|
{
|
||||||
iter2.SeekToArg( i->first.second );
|
iter2.SeekToArg(i->first.second);
|
||||||
// the first arg in the pair was not on the command line,
|
// the first arg in the pair was not on the command line,
|
||||||
// so just make sure the second isn't there...
|
// so just make sure the second isn't there...
|
||||||
if( !iter2.Done() )
|
if (!iter2.Done())
|
||||||
{
|
{
|
||||||
// arg2 appeared without arg1, so dependency error.
|
// arg2 appeared without arg1, so dependency error.
|
||||||
TSTRING arg1, arg2, alias1, alias2;
|
TSTRING arg1, arg2, alias1, alias2;
|
||||||
cCmdLineParser::LookupArgInfo( i->first.first, arg1, alias1 );
|
cCmdLineParser::LookupArgInfo(i->first.first, arg1, alias1);
|
||||||
cCmdLineParser::LookupArgInfo( i->first.second, arg2, alias2 );
|
cCmdLineParser::LookupArgInfo(i->first.second, arg2, alias2);
|
||||||
|
|
||||||
// determine in which form the user passed the arguments,
|
// determine in which form the user passed the arguments,
|
||||||
// and construct the error message in the same form
|
// and construct the error message in the same form
|
||||||
if ( iter1.ActualParam().length() == 2 )
|
if (iter1.ActualParam().length() == 2)
|
||||||
throw eCmdLineDependency( _T("The switch -") + arg2 + _T(" requires -") + arg1 +_T(".") );
|
throw eCmdLineDependency(_T("The switch -") + arg2 + _T(" requires -") + arg1 + _T("."));
|
||||||
else
|
else
|
||||||
throw eCmdLineDependency( _T("The switch --") + alias2 + _T(" requires --") + alias1 + _T(".") );
|
throw eCmdLineDependency(_T("The switch --") + alias2 + _T(" requires --") + alias1 + _T("."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -364,32 +343,32 @@ void cCmdLineParser::AddMutEx(int argId1, int argId2)
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// AddDependency
|
// AddDependency
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
void cCmdLineParser::AddDependency(int argId1, int argId2, bool mutual )
|
void cCmdLineParser::AddDependency(int argId1, int argId2, bool mutual)
|
||||||
{
|
{
|
||||||
// again, no checking for duplicates... would a set
|
// again, no checking for duplicates... would a set
|
||||||
// prove to be a better container for this operation?
|
// prove to be a better container for this operation?
|
||||||
std::pair< int, int > Args( argId1, argId2 );
|
std::pair<int, int> Args(argId1, argId2);
|
||||||
std::pair< std::pair< int, int >, bool > Dep( Args, mutual );
|
std::pair<std::pair<int, int>, bool> Dep(Args, mutual);
|
||||||
|
|
||||||
ASSERT(argId1 != argId2);
|
ASSERT(argId1 != argId2);
|
||||||
mDependencyList.push_back( Dep);
|
mDependencyList.push_back(Dep);
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// TraceContents
|
// TraceContents
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
void cCmdLineParser::TraceContents(int dl)
|
void cCmdLineParser::TraceContents(int dl)
|
||||||
{
|
{
|
||||||
cDebug d("cCmdLineParser::TraceContents");
|
cDebug d("cCmdLineParser::TraceContents");
|
||||||
if(dl == -1)
|
if (dl == -1)
|
||||||
dl = cDebug::D_DEBUG;
|
dl = cDebug::D_DEBUG;
|
||||||
|
|
||||||
std::list<cArgData>::const_iterator i;
|
std::list<cArgData>::const_iterator i;
|
||||||
for(i = mArgData.begin(); i != mArgData.end(); i++)
|
for (i = mArgData.begin(); i != mArgData.end(); i++)
|
||||||
{
|
{
|
||||||
d.Trace(dl, "* Item id:%d\n", i->mId);
|
d.Trace(dl, "* Item id:%d\n", i->mId);
|
||||||
for(std::vector<TSTRING>::const_iterator vi = i->mParams.begin(); vi != i->mParams.end(); vi++)
|
for (std::vector<TSTRING>::const_iterator vi = i->mParams.begin(); vi != i->mParams.end(); vi++)
|
||||||
{
|
{
|
||||||
d.Trace(dl, "\t%s\n", vi->c_str());
|
d.Trace(dl, "\t%s\n", vi->c_str());
|
||||||
}
|
}
|
||||||
|
@ -398,7 +377,7 @@ void cCmdLineParser::TraceContents(int dl)
|
||||||
d.Trace(dl, "--- Switch id table ---\n");
|
d.Trace(dl, "--- Switch id table ---\n");
|
||||||
|
|
||||||
cHashTableIter<TSTRING, cArgInfo> iter(mArgTable);
|
cHashTableIter<TSTRING, cArgInfo> iter(mArgTable);
|
||||||
for(iter.SeekBegin(); ! iter.Done(); iter.Next())
|
for (iter.SeekBegin(); !iter.Done(); iter.Next())
|
||||||
{
|
{
|
||||||
d.Trace(dl, "[%d] %s\n", iter.Val().mId, iter.Key().c_str());
|
d.Trace(dl, "[%d] %s\n", iter.Val().mId, iter.Key().c_str());
|
||||||
}
|
}
|
||||||
|
@ -412,16 +391,16 @@ void cCmdLineParser::TraceContents(int dl)
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
bool cCmdLineParser::LookupArgInfo(int argId, TSTRING& arg, TSTRING& alias) const
|
bool cCmdLineParser::LookupArgInfo(int argId, TSTRING& arg, TSTRING& alias) const
|
||||||
{
|
{
|
||||||
arg = _T("");
|
arg = _T("");
|
||||||
alias = _T("");
|
alias = _T("");
|
||||||
|
|
||||||
cHashTableIter<TSTRING, cArgInfo> iter(mArgTable);
|
cHashTableIter<TSTRING, cArgInfo> iter(mArgTable);
|
||||||
for(iter.SeekBegin(); ! iter.Done(); iter.Next())
|
for (iter.SeekBegin(); !iter.Done(); iter.Next())
|
||||||
{
|
{
|
||||||
if(iter.Val().mId == argId)
|
if (iter.Val().mId == argId)
|
||||||
{
|
{
|
||||||
TSTRING str = iter.Key();
|
TSTRING str = iter.Key();
|
||||||
if((str.length() > 0) && (str[0] == _T('-')))
|
if ((str.length() > 0) && (str[0] == _T('-')))
|
||||||
{
|
{
|
||||||
// this is the alias!
|
// this is the alias!
|
||||||
alias = (str.c_str() + 1);
|
alias = (str.c_str() + 1);
|
||||||
|
@ -433,7 +412,7 @@ bool cCmdLineParser::LookupArgInfo(int argId, TSTRING& arg, TSTRING& alias) cons
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ((! arg.empty()) || (! alias.empty()));
|
return ((!arg.empty()) || (!alias.empty()));
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -442,9 +421,9 @@ bool cCmdLineParser::LookupArgInfo(int argId, TSTRING& arg, TSTRING& alias) cons
|
||||||
bool cCmdLineParser::ArgInList(int argId)
|
bool cCmdLineParser::ArgInList(int argId)
|
||||||
{
|
{
|
||||||
std::list<cArgData>::iterator i;
|
std::list<cArgData>::iterator i;
|
||||||
for( i = mArgData.begin(); i != mArgData.end(); i++ )
|
for (i = mArgData.begin(); i != mArgData.end(); i++)
|
||||||
{
|
{
|
||||||
if( i->mId == argId )
|
if (i->mId == argId)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -458,15 +437,13 @@ bool cCmdLineParser::ArgInList(int argId)
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// SeekToArg
|
// SeekToArg
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
bool cCmdLineIter::SeekToArg(int argId) const
|
bool cCmdLineIter::SeekToArg(int argId) const
|
||||||
{
|
{
|
||||||
for(SeekBegin(); ! Done(); Next())
|
for (SeekBegin(); !Done(); Next())
|
||||||
{
|
{
|
||||||
if(ArgId() == argId)
|
if (ArgId() == argId)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,38 +1,38 @@
|
||||||
//
|
//
|
||||||
// The developer of the original code and/or files is Tripwire, Inc.
|
// The developer of the original code and/or files is Tripwire, Inc.
|
||||||
// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire,
|
// Portions created by Tripwire, Inc. are copyright (C) 2000-2018 Tripwire,
|
||||||
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
||||||
// reserved.
|
// reserved.
|
||||||
//
|
//
|
||||||
// This program is free software. The contents of this file are subject
|
// 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
|
// 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
|
// Free Software Foundation; either version 2 of the License, or (at your
|
||||||
// option) any later version. You may redistribute it and/or modify it
|
// option) any later version. You may redistribute it and/or modify it
|
||||||
// only in compliance with the GNU General Public License.
|
// only in compliance with the GNU General Public License.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful.
|
// This program is distributed in the hope that it will be useful.
|
||||||
// However, this program is distributed AS-IS WITHOUT ANY
|
// However, this program is distributed AS-IS WITHOUT ANY
|
||||||
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
||||||
// for more details.
|
// for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
// USA.
|
// USA.
|
||||||
//
|
//
|
||||||
// Nothing in the GNU General Public License or any other license to use
|
// 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,
|
// the code or files shall permit you to use Tripwire's trademarks,
|
||||||
// service marks, or other intellectual property without Tripwire's
|
// service marks, or other intellectual property without Tripwire's
|
||||||
// prior written consent.
|
// prior written consent.
|
||||||
//
|
//
|
||||||
// If you have any questions, please contact Tripwire, Inc. at either
|
// If you have any questions, please contact Tripwire, Inc. at either
|
||||||
// info@tripwire.org or www.tripwire.org.
|
// info@tripwire.org or www.tripwire.org.
|
||||||
//
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// cmdlineparser.h
|
// cmdlineparser.h
|
||||||
//
|
//
|
||||||
// cCmdLineParser.h -- class that tokenizes the command line
|
// cCmdLineParser.h -- class that tokenizes the command line
|
||||||
#ifndef __CMDLINEPARSER_H
|
#ifndef __CMDLINEPARSER_H
|
||||||
#define __CMDLINEPARSER_H
|
#define __CMDLINEPARSER_H
|
||||||
|
|
||||||
|
@ -49,14 +49,15 @@
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
// eCmdLine
|
// eCmdLine
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
TSS_EXCEPTION( eCmdLine, eError )
|
TSS_EXCEPTION(eCmdLine, eError)
|
||||||
TSS_EXCEPTION( eCmdLineInvalidArg, eCmdLine ) // an arg on the command line is not recognized
|
TSS_EXCEPTION(eCmdLineInvalidArg, eCmdLine) // an arg on the command line is not recognized
|
||||||
TSS_EXCEPTION( eCmdLineBadArgParam, eCmdLine ) // wrong number of parameters to an argument
|
TSS_EXCEPTION(eCmdLineBadArgParam, eCmdLine) // wrong number of parameters to an argument
|
||||||
TSS_EXCEPTION( eCmdLineBadParam, eCmdLine ) // wrong number of paramters to the executable (not associated with any arguments)
|
TSS_EXCEPTION(eCmdLineBadParam,
|
||||||
TSS_EXCEPTION( eCmdLineBadSwitchPos,eCmdLine ) // a '-' arg appeared after the final parameter list
|
eCmdLine) // wrong number of paramters to the executable (not associated with any arguments)
|
||||||
TSS_EXCEPTION( eCmdLineMutEx, eCmdLine ) // a mutual exclusion error has occured
|
TSS_EXCEPTION(eCmdLineBadSwitchPos, eCmdLine) // a '-' arg appeared after the final parameter list
|
||||||
TSS_EXCEPTION( eCmdLineDependency, eCmdLine ) // a dependency error has occurred.
|
TSS_EXCEPTION(eCmdLineMutEx, eCmdLine) // a mutual exclusion error has occured
|
||||||
TSS_EXCEPTION( eCmdLineMultiArg, eCmdLine ) // an arg was found twice in the command line
|
TSS_EXCEPTION(eCmdLineDependency, eCmdLine) // a dependency error has occurred.
|
||||||
|
TSS_EXCEPTION(eCmdLineMultiArg, eCmdLine) // an arg was found twice in the command line
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -95,93 +96,99 @@ public:
|
||||||
|
|
||||||
enum ParamCount
|
enum ParamCount
|
||||||
{
|
{
|
||||||
PARAM_NONE, // no parameters to arg
|
PARAM_NONE, // no parameters to arg
|
||||||
PARAM_ONE, // one parameter to arg
|
PARAM_ONE, // one parameter to arg
|
||||||
PARAM_MANY, // zero or more paramters to arg
|
PARAM_MANY, // zero or more paramters to arg
|
||||||
|
|
||||||
PARAM_INVALID // top of enum
|
PARAM_INVALID // top of enum
|
||||||
};
|
};
|
||||||
|
|
||||||
void AddArg(int argId, const TSTRING& arg, const TSTRING& alias, ParamCount numParams, bool multipleAllowed = false);
|
void
|
||||||
// this method should be called for each argument that can appear on the
|
AddArg(int argId, const TSTRING& arg, const TSTRING& alias, ParamCount numParams, bool multipleAllowed = false);
|
||||||
// command line.
|
// this method should be called for each argument that can appear on the
|
||||||
// argId -- a number that uniquely identifies the argument; no two arguments
|
// command line.
|
||||||
// may have the same id (ASSERT-enforced)
|
// argId -- a number that uniquely identifies the argument; no two arguments
|
||||||
// arg -- string that comes after the '-'. can be _T("") if there is only
|
// may have the same id (ASSERT-enforced)
|
||||||
// a string representation
|
// arg -- string that comes after the '-'. can be _T("") if there is only
|
||||||
// alias -- string that comes after '--' which has the same meaning. Can be _T("")
|
// a string representation
|
||||||
// if there is no alias. If both arg and alias are empty strings, then this arg
|
// alias -- string that comes after '--' which has the same meaning. Can be _T("")
|
||||||
// represents the list of arguments that comes at the end of the command line
|
// if there is no alias. If both arg and alias are empty strings, then this arg
|
||||||
// numParams -- number of parameters that this argument needs
|
// represents the list of arguments that comes at the end of the command line
|
||||||
|
// numParams -- number of parameters that this argument needs
|
||||||
|
|
||||||
void AddMutEx(int argId1, int argId2);
|
void AddMutEx(int argId1, int argId2);
|
||||||
// this adds a mutual exclusion constraint. When Parse() is called, if argId1 and
|
// this adds a mutual exclusion constraint. When Parse() is called, if argId1 and
|
||||||
// argId2 both exist on the command line, then the parse will fail and the error
|
// argId2 both exist on the command line, then the parse will fail and the error
|
||||||
// value ERR_MUTUAL_EXCLUSION will be set.
|
// value ERR_MUTUAL_EXCLUSION will be set.
|
||||||
|
|
||||||
void AddDependency(int argId1, int argId2, bool mutual = false );
|
void AddDependency(int argId1, int argId2, bool mutual = false);
|
||||||
// This adds a dependency constraint. When Parse() is called, if argId1
|
// This adds a dependency constraint. When Parse() is called, if argId1
|
||||||
// exists on the command line independent from argId2, then the parse will fail.
|
// exists on the command line independent from argId2, then the parse will fail.
|
||||||
// If the default param mutual is true, then the command parser will check for
|
// If the default param mutual is true, then the command parser will check for
|
||||||
// argId1 if argId2 is passed. We do this, since it is possible for one arg to
|
// argId1 if argId2 is passed. We do this, since it is possible for one arg to
|
||||||
// depend on another, but have the other arg alone on the command line, legally.
|
// depend on another, but have the other arg alone on the command line, legally.
|
||||||
|
|
||||||
void Parse(int argc, const TCHAR *const * argv); // throw eCmdLine
|
void Parse(int argc, const TCHAR* const* argv); // throw eCmdLine
|
||||||
// after AddArg() has been called for every argument that could be processed by the
|
// after AddArg() has been called for every argument that could be processed by the
|
||||||
// command line, call this to tokenize argv. If the return value is false, then
|
// command line, call this to tokenize argv. If the return value is false, then
|
||||||
// the input was invalid in some way; the actual error can be determined by calling
|
// the input was invalid in some way; the actual error can be determined by calling
|
||||||
// GetErrorInfo() below.
|
// GetErrorInfo() below.
|
||||||
|
|
||||||
// void Clear();
|
// void Clear();
|
||||||
// clear out all information that this class contains
|
// clear out all information that this class contains
|
||||||
|
|
||||||
bool LookupArgInfo(int argId, TSTRING& arg, TSTRING& alias) const;
|
bool LookupArgInfo(int argId, TSTRING& arg, TSTRING& alias) const;
|
||||||
// given an argId, fill out the strings with the argument and alias strings. Returns false
|
// given an argId, fill out the strings with the argument and alias strings. Returns false
|
||||||
// if the argId cannot be found. This method is not very fast, so don't use it often.
|
// if the argId cannot be found. This method is not very fast, so don't use it often.
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
void TraceContents(int dl = -1) ;
|
void TraceContents(int dl = -1);
|
||||||
#endif
|
#endif
|
||||||
private:
|
private:
|
||||||
void TestMutEx();
|
void TestMutEx();
|
||||||
// tests for mutual exclusion violations; if it fails, the current error is set and false
|
// tests for mutual exclusion violations; if it fails, the current error is set and false
|
||||||
// is returned.
|
// is returned.
|
||||||
void TestDependency();
|
void TestDependency();
|
||||||
// tests for all dependency violations.
|
// tests for all dependency violations.
|
||||||
bool ArgInList(int argId);
|
bool ArgInList(int argId);
|
||||||
// returns true if an argument with the specified id already exists in the list; this is used
|
// returns true if an argument with the specified id already exists in the list; this is used
|
||||||
// to make sure the same arg doesn't appear >1 time on the command line
|
// to make sure the same arg doesn't appear >1 time on the command line
|
||||||
|
|
||||||
// for storing information on paramers
|
// for storing information on paramers
|
||||||
struct cArgInfo
|
struct cArgInfo
|
||||||
{
|
{
|
||||||
int mId;
|
int mId;
|
||||||
ParamCount mNumParams;
|
ParamCount mNumParams;
|
||||||
|
|
||||||
cArgInfo(int i = -1, ParamCount p = PARAM_INVALID) : mId(i), mNumParams(p) {}
|
cArgInfo(int i = -1, ParamCount p = PARAM_INVALID) : mId(i), mNumParams(p)
|
||||||
|
{
|
||||||
|
}
|
||||||
};
|
};
|
||||||
// for storing parsed argv information
|
// for storing parsed argv information
|
||||||
struct cArgData
|
struct cArgData
|
||||||
{
|
{
|
||||||
int mId;
|
int mId;
|
||||||
std::vector<TSTRING> mParams;
|
std::vector<TSTRING> mParams;
|
||||||
TSTRING mActualParam; // a string representation of what was actually on the command line
|
TSTRING mActualParam; // a string representation of what was actually on the command line
|
||||||
|
|
||||||
cArgData(int id = -1, const TSTRING& actualParam = TSTRING(_T(""))) : mId(id), mActualParam(actualParam) {}
|
cArgData(int id = -1, const TSTRING& actualParam = TSTRING(_T(""))) : mId(id), mActualParam(actualParam)
|
||||||
|
{
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
cHashTable<TSTRING, cArgInfo> mArgTable;
|
cHashTable<TSTRING, cArgInfo> mArgTable;
|
||||||
cArgInfo mLastArgInfo; // info on the argument that comes at the end of the command line (with no associated '-x' or '--x')
|
cArgInfo
|
||||||
std::list<cArgData> mArgData;
|
mLastArgInfo; // info on the argument that comes at the end of the command line (with no associated '-x' or '--x')
|
||||||
std::list<std::pair<int,int> > mMutExList; // all of the mutual exclusions
|
std::list<cArgData> mArgData;
|
||||||
std::list< std::pair < std::pair<int,int>, bool > > mDependencyList; // all of the dependencies
|
std::list<std::pair<int, int> > mMutExList; // all of the mutual exclusions
|
||||||
std::set< int > mMultipleAllowed;
|
std::list<std::pair<std::pair<int, int>, bool> > mDependencyList; // all of the dependencies
|
||||||
|
std::set<int> mMultipleAllowed;
|
||||||
|
|
||||||
friend class cCmdLineIter;
|
friend class cCmdLineIter;
|
||||||
};
|
};
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// cCmdLineIter -- used to iterate over the tokenized command line parameters;
|
// cCmdLineIter -- used to iterate over the tokenized command line parameters;
|
||||||
// is only useful after cCmdLineParser::Parse() has been called.
|
// is only useful after cCmdLineParser::Parse() has been called.
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
class cCmdLineIter
|
class cCmdLineIter
|
||||||
|
@ -190,36 +197,35 @@ public:
|
||||||
cCmdLineIter(const cCmdLineParser& parser);
|
cCmdLineIter(const cCmdLineParser& parser);
|
||||||
|
|
||||||
// iteration
|
// iteration
|
||||||
void SeekBegin() const;
|
void SeekBegin() const;
|
||||||
bool Done() const;
|
bool Done() const;
|
||||||
bool IsEmpty() const;
|
bool IsEmpty() const;
|
||||||
void Next() const;
|
void Next() const;
|
||||||
|
|
||||||
bool SeekToArg(int argId) const;
|
bool SeekToArg(int argId) const;
|
||||||
// seeks to the argument with the given argId. returns
|
// seeks to the argument with the given argId. returns
|
||||||
// false and Done() == true if it couldn't find it.
|
// false and Done() == true if it couldn't find it.
|
||||||
|
|
||||||
// access to the argument data
|
// access to the argument data
|
||||||
int ArgId() const;
|
int ArgId() const;
|
||||||
// returns the id of this arg; ASSERTs if Done() == true
|
// returns the id of this arg; ASSERTs if Done() == true
|
||||||
int NumParams() const;
|
int NumParams() const;
|
||||||
// returns the number of parameters this argument has
|
// returns the number of parameters this argument has
|
||||||
const TSTRING& ActualParam() const;
|
const TSTRING& ActualParam() const;
|
||||||
// returns exactly what was passed on the command line (ie -- what the user typed)
|
// returns exactly what was passed on the command line (ie -- what the user typed)
|
||||||
const TSTRING& ParamAt(int index) const;
|
const TSTRING& ParamAt(int index) const;
|
||||||
// returns the parameter at the specified index. ASSERTs if
|
// returns the parameter at the specified index. ASSERTs if
|
||||||
// the index is out of range.
|
// the index is out of range.
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const std::list<cCmdLineParser::cArgData>& mList;
|
const std::list<cCmdLineParser::cArgData>& mList;
|
||||||
mutable std::list<cCmdLineParser::cArgData>::const_iterator mIter;
|
mutable std::list<cCmdLineParser::cArgData>::const_iterator mIter;
|
||||||
};
|
};
|
||||||
|
|
||||||
//#############################################################################
|
//#############################################################################
|
||||||
// inline implementation
|
// inline implementation
|
||||||
//#############################################################################
|
//#############################################################################
|
||||||
inline cCmdLineIter::cCmdLineIter(const cCmdLineParser& parser) :
|
inline cCmdLineIter::cCmdLineIter(const cCmdLineParser& parser) : mList(parser.mArgData)
|
||||||
mList(parser.mArgData)
|
|
||||||
{
|
{
|
||||||
SeekBegin();
|
SeekBegin();
|
||||||
}
|
}
|
||||||
|
@ -241,22 +247,22 @@ inline void cCmdLineIter::Next() const
|
||||||
}
|
}
|
||||||
inline int cCmdLineIter::ArgId() const
|
inline int cCmdLineIter::ArgId() const
|
||||||
{
|
{
|
||||||
ASSERT(! Done());
|
ASSERT(!Done());
|
||||||
return mIter->mId;
|
return mIter->mId;
|
||||||
}
|
}
|
||||||
inline int cCmdLineIter::NumParams() const
|
inline int cCmdLineIter::NumParams() const
|
||||||
{
|
{
|
||||||
ASSERT(! Done());
|
ASSERT(!Done());
|
||||||
return mIter->mParams.size();
|
return mIter->mParams.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const TSTRING& cCmdLineIter::ActualParam() const
|
inline const TSTRING& cCmdLineIter::ActualParam() const
|
||||||
{
|
{
|
||||||
ASSERT(! Done());
|
ASSERT(!Done());
|
||||||
return mIter->mActualParam;
|
return mIter->mActualParam;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const TSTRING& cCmdLineIter::ParamAt(int index) const
|
inline const TSTRING& cCmdLineIter::ParamAt(int index) const
|
||||||
{
|
{
|
||||||
ASSERT((index >= 0) && (index < NumParams()));
|
ASSERT((index >= 0) && (index < NumParams()));
|
||||||
return mIter->mParams[index];
|
return mIter->mParams[index];
|
||||||
|
@ -264,4 +270,3 @@ inline const TSTRING& cCmdLineIter::ParamAt(int index) const
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,31 +1,31 @@
|
||||||
//
|
//
|
||||||
// The developer of the original code and/or files is Tripwire, Inc.
|
// The developer of the original code and/or files is Tripwire, Inc.
|
||||||
// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire,
|
// Portions created by Tripwire, Inc. are copyright (C) 2000-2018 Tripwire,
|
||||||
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
||||||
// reserved.
|
// reserved.
|
||||||
//
|
//
|
||||||
// This program is free software. The contents of this file are subject
|
// 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
|
// 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
|
// Free Software Foundation; either version 2 of the License, or (at your
|
||||||
// option) any later version. You may redistribute it and/or modify it
|
// option) any later version. You may redistribute it and/or modify it
|
||||||
// only in compliance with the GNU General Public License.
|
// only in compliance with the GNU General Public License.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful.
|
// This program is distributed in the hope that it will be useful.
|
||||||
// However, this program is distributed AS-IS WITHOUT ANY
|
// However, this program is distributed AS-IS WITHOUT ANY
|
||||||
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
||||||
// for more details.
|
// for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
// USA.
|
// USA.
|
||||||
//
|
//
|
||||||
// Nothing in the GNU General Public License or any other license to use
|
// 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,
|
// the code or files shall permit you to use Tripwire's trademarks,
|
||||||
// service marks, or other intellectual property without Tripwire's
|
// service marks, or other intellectual property without Tripwire's
|
||||||
// prior written consent.
|
// prior written consent.
|
||||||
//
|
//
|
||||||
// If you have any questions, please contact Tripwire, Inc. at either
|
// If you have any questions, please contact Tripwire, Inc. at either
|
||||||
// info@tripwire.org or www.tripwire.org.
|
// info@tripwire.org or www.tripwire.org.
|
||||||
//
|
//
|
||||||
|
@ -60,17 +60,17 @@
|
||||||
|
|
||||||
/// Requirements
|
/// Requirements
|
||||||
|
|
||||||
#include "platform.h" // for: Platform specific code
|
#include "platform.h" // for: Platform specific code
|
||||||
#include "ntmbs.h" // for: NTBS, NTMBS, NTWCS, and NTDBS types
|
#include "ntmbs.h" // for: NTBS, NTMBS, NTWCS, and NTDBS types
|
||||||
|
|
||||||
|
|
||||||
/// Exceptions
|
/// Exceptions
|
||||||
|
|
||||||
TSS_EXCEPTION( eConverter, eError );
|
TSS_EXCEPTION(eConverter, eError);
|
||||||
TSS_EXCEPTION( eConverterReset, eConverter );
|
TSS_EXCEPTION(eConverterReset, eConverter);
|
||||||
TSS_EXCEPTION( eConverterFatal, eConverter );
|
TSS_EXCEPTION(eConverterFatal, eConverter);
|
||||||
TSS_EXCEPTION( eConverterUnsupportedConversion, eConverter );
|
TSS_EXCEPTION(eConverterUnsupportedConversion, eConverter);
|
||||||
TSS_EXCEPTION( eConverterUnknownCodepage, eConverter );
|
TSS_EXCEPTION(eConverterUnknownCodepage, eConverter);
|
||||||
|
|
||||||
|
|
||||||
/// Classes
|
/// Classes
|
||||||
|
@ -90,45 +90,38 @@ TSS_EXCEPTION( eConverterUnknownCodepage, eConverter );
|
||||||
*/
|
*/
|
||||||
class iCodeConverter
|
class iCodeConverter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
static iCodeConverter* GetInstance(); // Singleton
|
||||||
static iCodeConverter* GetInstance(); // Singleton
|
static void Finit();
|
||||||
static void Finit();
|
|
||||||
|
|
||||||
|
|
||||||
|
/// Subclass Responsibilities
|
||||||
|
virtual int Convert(ntmbs_t, // NTMBS buffer
|
||||||
|
size_t, // Capacity in mbchar_t's (bytes)
|
||||||
|
const_ntdbs_t, // null terminated two-byte wide character (UCS2 rep)
|
||||||
|
size_t nCount) = 0; // Amount to convert in dbchar_t's
|
||||||
|
// returns number of buffer items converted, -1 on error
|
||||||
|
|
||||||
/// Subclass Responsibilities
|
|
||||||
virtual
|
|
||||||
int
|
|
||||||
Convert(
|
|
||||||
ntmbs_t, // NTMBS buffer
|
|
||||||
size_t, // Capacity in mbchar_t's (bytes)
|
|
||||||
const_ntdbs_t, // null terminated two-byte wide character (UCS2 rep)
|
|
||||||
size_t nCount ) = 0; // Amount to convert in dbchar_t's
|
|
||||||
// returns number of buffer items converted, -1 on error
|
|
||||||
|
|
||||||
|
|
||||||
virtual
|
virtual int Convert(ntdbs_t, // NTDBS (Null-terminated two byte sequence) buf
|
||||||
int
|
size_t, // Capacity in dbchar_t's
|
||||||
Convert(
|
const_ntmbs_t, // Null-terminated multi-byte sequence
|
||||||
ntdbs_t, // NTDBS (Null-terminated two byte sequence) buf
|
size_t) = 0; // Capacity in mbchar_t's (bytes)
|
||||||
size_t, // Capacity in dbchar_t's
|
// returns number of buffer items converted, -1 on error
|
||||||
const_ntmbs_t, // Null-terminated multi-byte sequence
|
|
||||||
size_t ) = 0; // Capacity in mbchar_t's (bytes)
|
|
||||||
// returns number of buffer items converted, -1 on error
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
iCodeConverter()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
virtual ~iCodeConverter()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
iCodeConverter() {}
|
private:
|
||||||
virtual ~iCodeConverter() {}
|
static iCodeConverter* CreateConverter();
|
||||||
|
static iCodeConverter* CreateGoodEnoughConverter();
|
||||||
private:
|
|
||||||
|
|
||||||
static iCodeConverter* CreateConverter();
|
|
||||||
static iCodeConverter* CreateGoodEnoughConverter();
|
|
||||||
|
|
||||||
static iCodeConverter* m_pInst;
|
|
||||||
|
|
||||||
|
static iCodeConverter* m_pInst;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -139,74 +132,70 @@ class iCodeConverter
|
||||||
#ifdef HAVE_ICONV_H
|
#ifdef HAVE_ICONV_H
|
||||||
#include <iconv.h>
|
#include <iconv.h>
|
||||||
|
|
||||||
#ifdef HAVE_LANGINFO_H
|
# ifdef HAVE_LANGINFO_H
|
||||||
#ifndef __USE_XOPEN
|
# ifndef __USE_XOPEN
|
||||||
#define __USE_XOPEN 1
|
# define __USE_XOPEN 1
|
||||||
#endif
|
# endif
|
||||||
#include <langinfo.h>
|
# include <langinfo.h>
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
class cIconvUtil
|
class cIconvUtil
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
static const char* GetCodePageID(); // gets code page id for current locale, throws if error
|
||||||
static const char* GetCodePageID(); // gets code page id for current locale, throws if error
|
static bool GetCodePageID(const char** ppCP);
|
||||||
static bool GetCodePageID( const char** ppCP );
|
static const char* GetIconvDbIdentifier();
|
||||||
static const char* GetIconvDbIdentifier();
|
static const char* GetMiddleIdentifier();
|
||||||
static const char* GetMiddleIdentifier();
|
static void ResetConverter(iconv_t);
|
||||||
static void ResetConverter( iconv_t );
|
static bool TestConverter(const char* pTo, const char* pFrom);
|
||||||
static bool TestConverter( const char* pTo, const char* pFrom );
|
static iconv_t OpenHandle(const char* pTo, const char* pFrom); // throws
|
||||||
static iconv_t OpenHandle( const char* pTo, const char* pFrom ); // throws
|
static void CloseHandle(iconv_t ic);
|
||||||
static void CloseHandle( iconv_t ic );
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class cIconvConverter : public iCodeConverter
|
class cIconvConverter : public iCodeConverter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
static bool Test(); // is there a conversion for the current codepage?
|
||||||
|
|
||||||
static bool Test(); // is there a conversion for the current codepage?
|
virtual int Convert(ntmbs_t, size_t, const_ntdbs_t, size_t);
|
||||||
|
virtual int Convert(ntdbs_t, size_t, const_ntmbs_t, size_t);
|
||||||
|
|
||||||
virtual int Convert( ntmbs_t, size_t, const_ntdbs_t, size_t );
|
cIconvConverter();
|
||||||
virtual int Convert( ntdbs_t, size_t, const_ntmbs_t, size_t );
|
virtual ~cIconvConverter();
|
||||||
|
|
||||||
cIconvConverter();
|
private:
|
||||||
virtual ~cIconvConverter();
|
void Init();
|
||||||
|
|
||||||
private:
|
iconv_t icToDb;
|
||||||
void Init();
|
iconv_t icFromDb;
|
||||||
|
|
||||||
iconv_t icToDb;
|
|
||||||
iconv_t icFromDb;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class cDoubleIconvConverter : public iCodeConverter
|
class cDoubleIconvConverter : public iCodeConverter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
static bool Test(); // is there a conversion for the current codepage?
|
||||||
|
|
||||||
static bool Test(); // is there a conversion for the current codepage?
|
virtual int Convert(ntmbs_t, size_t, const_ntdbs_t, size_t);
|
||||||
|
virtual int Convert(ntdbs_t, size_t, const_ntmbs_t, size_t);
|
||||||
|
|
||||||
virtual int Convert( ntmbs_t, size_t, const_ntdbs_t, size_t );
|
cDoubleIconvConverter();
|
||||||
virtual int Convert( ntdbs_t, size_t, const_ntmbs_t, size_t );
|
virtual ~cDoubleIconvConverter();
|
||||||
|
|
||||||
cDoubleIconvConverter();
|
private:
|
||||||
virtual ~cDoubleIconvConverter();
|
void Init();
|
||||||
|
|
||||||
private:
|
iconv_t icMbToUTF8;
|
||||||
|
iconv_t icUTF8ToDb;
|
||||||
|
|
||||||
void Init();
|
iconv_t icDbToUTF8;
|
||||||
|
iconv_t icUTF8ToMb;
|
||||||
iconv_t icMbToUTF8;
|
|
||||||
iconv_t icUTF8ToDb;
|
|
||||||
|
|
||||||
iconv_t icDbToUTF8;
|
|
||||||
iconv_t icUTF8ToMb;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // HAVE_ICONV_H
|
#endif // HAVE_ICONV_H
|
||||||
|
|
||||||
|
|
||||||
/// QUESTION:RAD -- Why not just have one platform-specific of the below
|
/// QUESTION:RAD -- Why not just have one platform-specific of the below
|
||||||
|
|
||||||
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
// cWcharIs32BitUcs2Converterer
|
// cWcharIs32BitUcs2Converterer
|
||||||
|
@ -214,16 +203,18 @@ class cDoubleIconvConverter : public iCodeConverter
|
||||||
|
|
||||||
#if WCHAR_IS_32_BITS
|
#if WCHAR_IS_32_BITS
|
||||||
|
|
||||||
// TODO:BAM -- this is not really correct! Convert will not honor nSource!!
|
// TODO:BAM -- this is not really correct! Convert will not honor nSource!!
|
||||||
// it looks for the first null char!
|
// it looks for the first null char!
|
||||||
|
|
||||||
class cWcharIs32BitUcs2Converterer : public iCodeConverter
|
class cWcharIs32BitUcs2Converterer : public iCodeConverter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual int Convert( ntmbs_t, size_t, const_ntdbs_t, size_t );
|
virtual int Convert(ntmbs_t, size_t, const_ntdbs_t, size_t);
|
||||||
virtual int Convert( ntdbs_t, size_t, const_ntmbs_t, size_t );
|
virtual int Convert(ntdbs_t, size_t, const_ntmbs_t, size_t);
|
||||||
|
|
||||||
virtual ~cWcharIs32BitUcs2Converterer() {}
|
virtual ~cWcharIs32BitUcs2Converterer()
|
||||||
|
{
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // WCHAR_IS_32_BITS
|
#endif // WCHAR_IS_32_BITS
|
||||||
|
@ -234,16 +225,18 @@ public:
|
||||||
|
|
||||||
#if WCHAR_IS_16_BITS
|
#if WCHAR_IS_16_BITS
|
||||||
|
|
||||||
// TODO:BAM -- this is not really correct! Convert will not honor nSource!!
|
// TODO:BAM -- this is not really correct! Convert will not honor nSource!!
|
||||||
// it looks for the first null char!
|
// it looks for the first null char!
|
||||||
|
|
||||||
class cWcharIs16BitUcs2Converterer : public iCodeConverter
|
class cWcharIs16BitUcs2Converterer : public iCodeConverter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual int Convert( ntmbs_t, size_t, const_ntdbs_t, size_t );
|
virtual int Convert(ntmbs_t, size_t, const_ntdbs_t, size_t);
|
||||||
virtual int Convert( ntdbs_t, size_t, const_ntmbs_t, size_t );
|
virtual int Convert(ntdbs_t, size_t, const_ntmbs_t, size_t);
|
||||||
|
|
||||||
virtual ~cWcharIs16BitUcs2Converterer() {}
|
virtual ~cWcharIs16BitUcs2Converterer()
|
||||||
|
{
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // WCHAR_IS_16_BITS
|
#endif // WCHAR_IS_16_BITS
|
||||||
|
@ -252,31 +245,33 @@ public:
|
||||||
// converts mbchars > 0x7F to our reserved space
|
// converts mbchars > 0x7F to our reserved space
|
||||||
class cGoodEnoughConverterer : public iCodeConverter
|
class cGoodEnoughConverterer : public iCodeConverter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual int Convert( ntmbs_t, size_t, const_ntdbs_t, size_t );
|
virtual int Convert(ntmbs_t, size_t, const_ntdbs_t, size_t);
|
||||||
virtual int Convert( ntdbs_t, size_t, const_ntmbs_t, size_t );
|
virtual int Convert(ntdbs_t, size_t, const_ntmbs_t, size_t);
|
||||||
|
|
||||||
virtual ~cGoodEnoughConverterer() {}
|
virtual ~cGoodEnoughConverterer()
|
||||||
|
{
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class cConvertUtil
|
class cConvertUtil
|
||||||
{
|
{
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
TSS_UCS2_RESERVED_START = 0xE800u, // E000-E8FF is private use range, but
|
TSS_UCS2_RESERVED_START = 0xE800u, // E000-E8FF is private use range, but
|
||||||
TSS_UCS2_RESERVED_END = 0xE8FFu, // SJIS and EUC use E000-E757
|
TSS_UCS2_RESERVED_END = 0xE8FFu, // SJIS and EUC use E000-E757
|
||||||
TSS_HIGH_ASCII_START = 0x0080u,
|
TSS_HIGH_ASCII_START = 0x0080u,
|
||||||
TSS_HIGH_ASCII_END = 0x00FFu
|
TSS_HIGH_ASCII_END = 0x00FFu
|
||||||
};
|
};
|
||||||
public:
|
|
||||||
static dbchar_t ConvertNonChar( mbchar_t ch );
|
|
||||||
static mbchar_t ConvertNonChar( dbchar_t ch );
|
|
||||||
|
|
||||||
static bool ValueInReservedRange( mbchar_t ch );
|
public:
|
||||||
static bool ValueInReservedRange( dbchar_t ch );
|
static dbchar_t ConvertNonChar(mbchar_t ch);
|
||||||
|
static mbchar_t ConvertNonChar(dbchar_t ch);
|
||||||
|
|
||||||
|
static bool ValueInReservedRange(mbchar_t ch);
|
||||||
|
static bool ValueInReservedRange(dbchar_t ch);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif //__CODECONVERT_H
|
#endif //__CODECONVERT_H
|
||||||
|
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
//
|
//
|
||||||
// The developer of the original code and/or files is Tripwire, Inc.
|
// The developer of the original code and/or files is Tripwire, Inc.
|
||||||
// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire,
|
// Portions created by Tripwire, Inc. are copyright (C) 2000-2018 Tripwire,
|
||||||
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
||||||
// reserved.
|
// reserved.
|
||||||
//
|
//
|
||||||
// This program is free software. The contents of this file are subject
|
// 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
|
// 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
|
// Free Software Foundation; either version 2 of the License, or (at your
|
||||||
// option) any later version. You may redistribute it and/or modify it
|
// option) any later version. You may redistribute it and/or modify it
|
||||||
// only in compliance with the GNU General Public License.
|
// only in compliance with the GNU General Public License.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful.
|
// This program is distributed in the hope that it will be useful.
|
||||||
// However, this program is distributed AS-IS WITHOUT ANY
|
// However, this program is distributed AS-IS WITHOUT ANY
|
||||||
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
||||||
// for more details.
|
// for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
// USA.
|
// USA.
|
||||||
//
|
//
|
||||||
// Nothing in the GNU General Public License or any other license to use
|
// 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,
|
// the code or files shall permit you to use Tripwire's trademarks,
|
||||||
// service marks, or other intellectual property without Tripwire's
|
// service marks, or other intellectual property without Tripwire's
|
||||||
// prior written consent.
|
// prior written consent.
|
||||||
//
|
//
|
||||||
// If you have any questions, please contact Tripwire, Inc. at either
|
// If you have any questions, please contact Tripwire, Inc. at either
|
||||||
// info@tripwire.org or www.tripwire.org.
|
// info@tripwire.org or www.tripwire.org.
|
||||||
//
|
//
|
||||||
|
@ -39,21 +39,21 @@
|
||||||
#include "core.h"
|
#include "core.h"
|
||||||
#include "coreerrors.h"
|
#include "coreerrors.h"
|
||||||
|
|
||||||
#include "codeconvert.h" // for: iCodeConverter::GetInstance
|
#include "codeconvert.h" // for: iCodeConverter::GetInstance
|
||||||
#include "twlocale.h" // for: cTWLocale::InitGlobalLocale
|
#include "twlocale.h" // for: cTWLocale::InitGlobalLocale
|
||||||
|
|
||||||
TSS_ImplementPackage( cCore )
|
TSS_ImplementPackage(cCore)
|
||||||
|
|
||||||
cCore::cCore()
|
cCore::cCore()
|
||||||
{
|
{
|
||||||
TSS_REGISTER_PKG_ERRORS( core );
|
TSS_REGISTER_PKG_ERRORS(core);
|
||||||
|
|
||||||
// NOTE: Initialize code converter when cCore is a dependency
|
// NOTE: Initialize code converter when cCore is a dependency
|
||||||
// of another package (created on first call to GetInstance(),
|
// of another package (created on first call to GetInstance(),
|
||||||
// forcing creation here to hasten the display of any errors)
|
// forcing creation here to hasten the display of any errors)
|
||||||
|
|
||||||
cDebug::SetDebugLevel( cDebug::D_DEBUG );
|
cDebug::SetDebugLevel(cDebug::D_DEBUG);
|
||||||
cDebug::AddOutTarget( cDebug::OUT_STDOUT );
|
cDebug::AddOutTarget(cDebug::OUT_STDOUT);
|
||||||
|
|
||||||
cTWLocale::InitGlobalLocale();
|
cTWLocale::InitGlobalLocale();
|
||||||
|
|
||||||
|
@ -64,4 +64,3 @@ cCore::~cCore()
|
||||||
{
|
{
|
||||||
iCodeConverter::Finit();
|
iCodeConverter::Finit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
//
|
//
|
||||||
// The developer of the original code and/or files is Tripwire, Inc.
|
// The developer of the original code and/or files is Tripwire, Inc.
|
||||||
// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire,
|
// Portions created by Tripwire, Inc. are copyright (C) 2000-2018 Tripwire,
|
||||||
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
||||||
// reserved.
|
// reserved.
|
||||||
//
|
//
|
||||||
// This program is free software. The contents of this file are subject
|
// 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
|
// 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
|
// Free Software Foundation; either version 2 of the License, or (at your
|
||||||
// option) any later version. You may redistribute it and/or modify it
|
// option) any later version. You may redistribute it and/or modify it
|
||||||
// only in compliance with the GNU General Public License.
|
// only in compliance with the GNU General Public License.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful.
|
// This program is distributed in the hope that it will be useful.
|
||||||
// However, this program is distributed AS-IS WITHOUT ANY
|
// However, this program is distributed AS-IS WITHOUT ANY
|
||||||
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
||||||
// for more details.
|
// for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
// USA.
|
// USA.
|
||||||
//
|
//
|
||||||
// Nothing in the GNU General Public License or any other license to use
|
// 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,
|
// the code or files shall permit you to use Tripwire's trademarks,
|
||||||
// service marks, or other intellectual property without Tripwire's
|
// service marks, or other intellectual property without Tripwire's
|
||||||
// prior written consent.
|
// prior written consent.
|
||||||
//
|
//
|
||||||
// If you have any questions, please contact Tripwire, Inc. at either
|
// If you have any questions, please contact Tripwire, Inc. at either
|
||||||
// info@tripwire.org or www.tripwire.org.
|
// info@tripwire.org or www.tripwire.org.
|
||||||
//
|
//
|
||||||
|
@ -43,20 +43,18 @@
|
||||||
|
|
||||||
//--Requirements
|
//--Requirements
|
||||||
|
|
||||||
#include "package.h" // for: Packaging Abstraction
|
#include "package.h" // for: Packaging Abstraction
|
||||||
|
|
||||||
//--Classes
|
//--Classes
|
||||||
|
|
||||||
TSS_BeginPackage( cCore )
|
TSS_BeginPackage(cCore)
|
||||||
|
|
||||||
TSS_DECLARE_STRINGTABLE;
|
TSS_DECLARE_STRINGTABLE;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
cCore();
|
||||||
|
~cCore();
|
||||||
|
|
||||||
cCore();
|
TSS_EndPackage(cCore)
|
||||||
~cCore();
|
|
||||||
|
|
||||||
TSS_EndPackage( cCore )
|
|
||||||
|
|
||||||
#endif //__CORE_H
|
#endif //__CORE_H
|
||||||
|
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
//
|
//
|
||||||
// The developer of the original code and/or files is Tripwire, Inc.
|
// The developer of the original code and/or files is Tripwire, Inc.
|
||||||
// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire,
|
// Portions created by Tripwire, Inc. are copyright (C) 2000-2018 Tripwire,
|
||||||
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
||||||
// reserved.
|
// reserved.
|
||||||
//
|
//
|
||||||
// This program is free software. The contents of this file are subject
|
// 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
|
// 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
|
// Free Software Foundation; either version 2 of the License, or (at your
|
||||||
// option) any later version. You may redistribute it and/or modify it
|
// option) any later version. You may redistribute it and/or modify it
|
||||||
// only in compliance with the GNU General Public License.
|
// only in compliance with the GNU General Public License.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful.
|
// This program is distributed in the hope that it will be useful.
|
||||||
// However, this program is distributed AS-IS WITHOUT ANY
|
// However, this program is distributed AS-IS WITHOUT ANY
|
||||||
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
||||||
// for more details.
|
// for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
// USA.
|
// USA.
|
||||||
//
|
//
|
||||||
// Nothing in the GNU General Public License or any other license to use
|
// 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,
|
// the code or files shall permit you to use Tripwire's trademarks,
|
||||||
// service marks, or other intellectual property without Tripwire's
|
// service marks, or other intellectual property without Tripwire's
|
||||||
// prior written consent.
|
// prior written consent.
|
||||||
//
|
//
|
||||||
// If you have any questions, please contact Tripwire, Inc. at either
|
// If you have any questions, please contact Tripwire, Inc. at either
|
||||||
// info@tripwire.org or www.tripwire.org.
|
// info@tripwire.org or www.tripwire.org.
|
||||||
//
|
//
|
||||||
|
@ -49,118 +49,118 @@
|
||||||
#include "ntmbs.h"
|
#include "ntmbs.h"
|
||||||
#include "displayencoder.h"
|
#include "displayencoder.h"
|
||||||
|
|
||||||
TSS_BEGIN_ERROR_REGISTRATION( core )
|
TSS_BEGIN_ERROR_REGISTRATION(core)
|
||||||
|
|
||||||
/// Internal
|
/// Internal
|
||||||
|
|
||||||
TSS_REGISTER_ERROR( eInternal(), _T("Internal error.") )
|
TSS_REGISTER_ERROR(eInternal(), _T("Internal error."))
|
||||||
|
|
||||||
|
|
||||||
/// General
|
/// General
|
||||||
|
|
||||||
TSS_REGISTER_ERROR( eErrorGeneral(), _T("General Error") );
|
TSS_REGISTER_ERROR(eErrorGeneral(), _T("General Error"));
|
||||||
TSS_REGISTER_ERROR( eOpen(), _T("File could not be opened.") );
|
TSS_REGISTER_ERROR(eOpen(), _T("File could not be opened."));
|
||||||
TSS_REGISTER_ERROR( eOpenRead(), _T("File could not be opened for reading.") );
|
TSS_REGISTER_ERROR(eOpenRead(), _T("File could not be opened for reading."));
|
||||||
TSS_REGISTER_ERROR( eOpenWrite(), _T("File could not be opened for writing.") );
|
TSS_REGISTER_ERROR(eOpenWrite(), _T("File could not be opened for writing."));
|
||||||
TSS_REGISTER_ERROR( eBadModeSwitch(), _T("Unknown mode specified.") );
|
TSS_REGISTER_ERROR(eBadModeSwitch(), _T("Unknown mode specified."));
|
||||||
TSS_REGISTER_ERROR( eBadCmdLine(), _T("Command line error.") );
|
TSS_REGISTER_ERROR(eBadCmdLine(), _T("Command line error."));
|
||||||
|
|
||||||
|
|
||||||
/// Archive
|
/// Archive
|
||||||
|
|
||||||
TSS_REGISTER_ERROR( eArchive(), _T("Archive error.") )
|
TSS_REGISTER_ERROR(eArchive(), _T("Archive error."))
|
||||||
TSS_REGISTER_ERROR( eArchiveOpen(), _T("File could not be opened.") )
|
TSS_REGISTER_ERROR(eArchiveOpen(), _T("File could not be opened."))
|
||||||
TSS_REGISTER_ERROR( eArchiveWrite(), _T("File could not be written.") )
|
TSS_REGISTER_ERROR(eArchiveWrite(), _T("File could not be written."))
|
||||||
TSS_REGISTER_ERROR( eArchiveRead(), _T("File could not be read.") )
|
TSS_REGISTER_ERROR(eArchiveRead(), _T("File could not be read."))
|
||||||
TSS_REGISTER_ERROR( eArchiveEOF(), _T("End of file reached.") )
|
TSS_REGISTER_ERROR(eArchiveEOF(), _T("End of file reached."))
|
||||||
TSS_REGISTER_ERROR( eArchiveSeek(), _T("File seek failed.") )
|
TSS_REGISTER_ERROR(eArchiveSeek(), _T("File seek failed."))
|
||||||
TSS_REGISTER_ERROR( eArchiveMemmap(), _T("Memory mapped archive file invalid.") )
|
TSS_REGISTER_ERROR(eArchiveMemmap(), _T("Memory mapped archive file invalid."))
|
||||||
TSS_REGISTER_ERROR( eArchiveOutOfMem(), _T("Archive ran out of memory.") )
|
TSS_REGISTER_ERROR(eArchiveOutOfMem(), _T("Archive ran out of memory."))
|
||||||
TSS_REGISTER_ERROR( eArchiveInvalidOp(),_T("Archive logic error.") )
|
TSS_REGISTER_ERROR(eArchiveInvalidOp(), _T("Archive logic error."))
|
||||||
TSS_REGISTER_ERROR( eArchiveFormat(), _T("Archive file format invalid.") )
|
TSS_REGISTER_ERROR(eArchiveFormat(), _T("Archive file format invalid."))
|
||||||
TSS_REGISTER_ERROR( eArchiveNotRegularFile(), _T("File is not a regular file.") )
|
TSS_REGISTER_ERROR(eArchiveNotRegularFile(), _T("File is not a regular file."))
|
||||||
TSS_REGISTER_ERROR( eArchiveCrypto(), _T("File could not be decrypted.") )
|
TSS_REGISTER_ERROR(eArchiveCrypto(), _T("File could not be decrypted."))
|
||||||
TSS_REGISTER_ERROR( eArchiveStringTooLong(), _T("String was too long.") )
|
TSS_REGISTER_ERROR(eArchiveStringTooLong(), _T("String was too long."))
|
||||||
|
|
||||||
|
|
||||||
/// File
|
/// File
|
||||||
|
|
||||||
TSS_REGISTER_ERROR( eFile(), _T("File error.") )
|
TSS_REGISTER_ERROR(eFile(), _T("File error."))
|
||||||
TSS_REGISTER_ERROR( eFileOpen(), _T("File could not be opened.") )
|
TSS_REGISTER_ERROR(eFileOpen(), _T("File could not be opened."))
|
||||||
TSS_REGISTER_ERROR( eFileWrite(), _T("File could not be written.") )
|
TSS_REGISTER_ERROR(eFileWrite(), _T("File could not be written."))
|
||||||
TSS_REGISTER_ERROR( eFileRead(), _T("File could not be read.") )
|
TSS_REGISTER_ERROR(eFileRead(), _T("File could not be read."))
|
||||||
TSS_REGISTER_ERROR( eFileEOF(), _T("End of file reached.") )
|
TSS_REGISTER_ERROR(eFileEOF(), _T("End of file reached."))
|
||||||
TSS_REGISTER_ERROR( eFileSeek(), _T("File seek failed.") )
|
TSS_REGISTER_ERROR(eFileSeek(), _T("File seek failed."))
|
||||||
TSS_REGISTER_ERROR( eFileInvalidOp(), _T("File logic error.") )
|
TSS_REGISTER_ERROR(eFileInvalidOp(), _T("File logic error."))
|
||||||
TSS_REGISTER_ERROR( eFileTrunc(), _T("File could not be truncated.") )
|
TSS_REGISTER_ERROR(eFileTrunc(), _T("File could not be truncated."))
|
||||||
TSS_REGISTER_ERROR( eFileClose(), _T("File could not be closed.") )
|
TSS_REGISTER_ERROR(eFileClose(), _T("File could not be closed."))
|
||||||
TSS_REGISTER_ERROR( eFileFlush(), _T("File could not be flushed.") )
|
TSS_REGISTER_ERROR(eFileFlush(), _T("File could not be flushed."))
|
||||||
TSS_REGISTER_ERROR( eFileRewind(), _T("File could not be rewound.") )
|
TSS_REGISTER_ERROR(eFileRewind(), _T("File could not be rewound."))
|
||||||
|
|
||||||
|
|
||||||
/// General API failures
|
/// General API failures
|
||||||
TSS_REGISTER_ERROR(eUnix(), _T("Unix API failure.") )
|
TSS_REGISTER_ERROR(eUnix(), _T("Unix API failure."))
|
||||||
|
|
||||||
|
|
||||||
/// FSServices
|
/// FSServices
|
||||||
|
|
||||||
TSS_REGISTER_ERROR( eFSServices(), _T("File system error.") )
|
TSS_REGISTER_ERROR(eFSServices(), _T("File system error."))
|
||||||
TSS_REGISTER_ERROR( eFSServicesGeneric(),_T("File system error.") )
|
TSS_REGISTER_ERROR(eFSServicesGeneric(), _T("File system error."))
|
||||||
|
|
||||||
|
|
||||||
/// Serializer
|
/// Serializer
|
||||||
|
|
||||||
TSS_REGISTER_ERROR( eSerializerUnknownType(), _T("Unknown type encountered in file.\nFile format may not be valid for this platform.") )
|
TSS_REGISTER_ERROR(eSerializerUnknownType(),
|
||||||
TSS_REGISTER_ERROR( eSerializerInputStreamFmt(), _T("Invalid input stream format.") )
|
_T("Unknown type encountered in file.\nFile format may not be valid for this platform."))
|
||||||
TSS_REGISTER_ERROR( eSerializerOutputStreamFmt(), _T("Invalid output stream format.") )
|
TSS_REGISTER_ERROR(eSerializerInputStreamFmt(), _T("Invalid input stream format."))
|
||||||
TSS_REGISTER_ERROR( eSerializerInputStremTypeArray(), _T("A bad index was encountered in file.") )
|
TSS_REGISTER_ERROR(eSerializerOutputStreamFmt(), _T("Invalid output stream format."))
|
||||||
TSS_REGISTER_ERROR( eSerializerArchive(), _T("File read encountered an archive error.") )
|
TSS_REGISTER_ERROR(eSerializerInputStremTypeArray(), _T("A bad index was encountered in file."))
|
||||||
TSS_REGISTER_ERROR( eSerializerVersionMismatch(), _T("File version mismatch.") )
|
TSS_REGISTER_ERROR(eSerializerArchive(), _T("File read encountered an archive error."))
|
||||||
TSS_REGISTER_ERROR( eSerializerEncryption(), _T("File encryption error.") )
|
TSS_REGISTER_ERROR(eSerializerVersionMismatch(), _T("File version mismatch."))
|
||||||
TSS_REGISTER_ERROR( eSerializer(), _T("File format error.") )
|
TSS_REGISTER_ERROR(eSerializerEncryption(), _T("File encryption error."))
|
||||||
|
TSS_REGISTER_ERROR(eSerializer(), _T("File format error."))
|
||||||
|
|
||||||
|
|
||||||
/// Command Line
|
/// Command Line
|
||||||
|
|
||||||
TSS_REGISTER_ERROR( eCmdLine(), _T("Command line parsing error.") )
|
TSS_REGISTER_ERROR(eCmdLine(), _T("Command line parsing error."))
|
||||||
TSS_REGISTER_ERROR( eCmdLineInvalidArg(), _T("Invalid argument passed on command line.") )
|
TSS_REGISTER_ERROR(eCmdLineInvalidArg(), _T("Invalid argument passed on command line."))
|
||||||
TSS_REGISTER_ERROR( eCmdLineBadArgParam(), _T("Incorrect number of parameters to a command line argument.") )
|
TSS_REGISTER_ERROR(eCmdLineBadArgParam(), _T("Incorrect number of parameters to a command line argument."))
|
||||||
TSS_REGISTER_ERROR( eCmdLineBadParam(), _T("Incorrect number of parameters on command line.") )
|
TSS_REGISTER_ERROR(eCmdLineBadParam(), _T("Incorrect number of parameters on command line."))
|
||||||
TSS_REGISTER_ERROR( eCmdLineBadSwitchPos(), _T("Switch appears after final command line parameter.") )
|
TSS_REGISTER_ERROR(eCmdLineBadSwitchPos(), _T("Switch appears after final command line parameter."))
|
||||||
TSS_REGISTER_ERROR( eCmdLineMutEx(), _T("Specified command line switches are mutually exclusive.") )
|
TSS_REGISTER_ERROR(eCmdLineMutEx(), _T("Specified command line switches are mutually exclusive."))
|
||||||
TSS_REGISTER_ERROR( eCmdLineDependency(), _T("Command line parameter missing.") )
|
TSS_REGISTER_ERROR(eCmdLineDependency(), _T("Command line parameter missing."))
|
||||||
TSS_REGISTER_ERROR( eCmdLineMultiArg(), _T("Command line argument specified more than once.") )
|
TSS_REGISTER_ERROR(eCmdLineMultiArg(), _T("Command line argument specified more than once."))
|
||||||
|
|
||||||
|
|
||||||
/// TWLocale
|
/// TWLocale
|
||||||
|
|
||||||
TSS_REGISTER_ERROR( eTWLocale(), _T("Localization error.") )
|
TSS_REGISTER_ERROR(eTWLocale(), _T("Localization error."))
|
||||||
TSS_REGISTER_ERROR( eTWLocaleBadNumFormat(),_T("Bad number format.") )
|
TSS_REGISTER_ERROR(eTWLocaleBadNumFormat(), _T("Bad number format."))
|
||||||
|
|
||||||
|
|
||||||
/// Character Handling (defined in ntmbs.h)
|
/// Character Handling (defined in ntmbs.h)
|
||||||
|
|
||||||
TSS_REGISTER_ERROR( eCharacter(), _T("General Character Handling Error.") )
|
TSS_REGISTER_ERROR(eCharacter(), _T("General Character Handling Error."))
|
||||||
TSS_REGISTER_ERROR( eCharacterEncoding(), _T("Character Encoding Error.") )
|
TSS_REGISTER_ERROR(eCharacterEncoding(), _T("Character Encoding Error."))
|
||||||
|
|
||||||
|
|
||||||
/// Character Conversion Handling (defined in <codeconvert.h>)
|
/// Character Conversion Handling (defined in <codeconvert.h>)
|
||||||
|
|
||||||
TSS_REGISTER_ERROR( eConverter(), _T("General conversion error.") )
|
TSS_REGISTER_ERROR(eConverter(), _T("General conversion error."))
|
||||||
TSS_REGISTER_ERROR( eConverterReset(), _T("Converter handle could not be reset.") )
|
TSS_REGISTER_ERROR(eConverterReset(), _T("Converter handle could not be reset."))
|
||||||
TSS_REGISTER_ERROR( eConverterFatal(), _T("Catastrophic conversion error.") )
|
TSS_REGISTER_ERROR(eConverterFatal(), _T("Catastrophic conversion error."))
|
||||||
TSS_REGISTER_ERROR( eConverterUnsupportedConversion(), _T("Unsupported character conversion.") )
|
TSS_REGISTER_ERROR(eConverterUnsupportedConversion(), _T("Unsupported character conversion."))
|
||||||
TSS_REGISTER_ERROR( eConverterUnknownCodepage(), _T("Could not identify code page.") )
|
TSS_REGISTER_ERROR(eConverterUnknownCodepage(), _T("Could not identify code page."))
|
||||||
|
|
||||||
//
|
//
|
||||||
// Display Encoder
|
// Display Encoder
|
||||||
//
|
//
|
||||||
|
|
||||||
TSS_REGISTER_ERROR( eEncoder(), _T("Display encoder error.") )
|
TSS_REGISTER_ERROR(eEncoder(), _T("Display encoder error."))
|
||||||
TSS_REGISTER_ERROR( eBadDecoderInput(), _T("Bad input to display encoder.") )
|
TSS_REGISTER_ERROR(eBadDecoderInput(), _T("Bad input to display encoder."))
|
||||||
TSS_REGISTER_ERROR( eBadHexConversion(), _T("Bad hex conversion in display encoder.") )
|
TSS_REGISTER_ERROR(eBadHexConversion(), _T("Bad hex conversion in display encoder."))
|
||||||
TSS_REGISTER_ERROR( eUnknownEscapeEncoding(), _T("Unknown encoding in display encoder input.") )
|
TSS_REGISTER_ERROR(eUnknownEscapeEncoding(), _T("Unknown encoding in display encoder input."))
|
||||||
|
|
||||||
|
|
||||||
TSS_END_ERROR_REGISTRATION()
|
TSS_END_ERROR_REGISTRATION()
|
||||||
|
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
//
|
//
|
||||||
// The developer of the original code and/or files is Tripwire, Inc.
|
// The developer of the original code and/or files is Tripwire, Inc.
|
||||||
// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire,
|
// Portions created by Tripwire, Inc. are copyright (C) 2000-2018 Tripwire,
|
||||||
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
||||||
// reserved.
|
// reserved.
|
||||||
//
|
//
|
||||||
// This program is free software. The contents of this file are subject
|
// 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
|
// 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
|
// Free Software Foundation; either version 2 of the License, or (at your
|
||||||
// option) any later version. You may redistribute it and/or modify it
|
// option) any later version. You may redistribute it and/or modify it
|
||||||
// only in compliance with the GNU General Public License.
|
// only in compliance with the GNU General Public License.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful.
|
// This program is distributed in the hope that it will be useful.
|
||||||
// However, this program is distributed AS-IS WITHOUT ANY
|
// However, this program is distributed AS-IS WITHOUT ANY
|
||||||
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
||||||
// for more details.
|
// for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
// USA.
|
// USA.
|
||||||
//
|
//
|
||||||
// Nothing in the GNU General Public License or any other license to use
|
// 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,
|
// the code or files shall permit you to use Tripwire's trademarks,
|
||||||
// service marks, or other intellectual property without Tripwire's
|
// service marks, or other intellectual property without Tripwire's
|
||||||
// prior written consent.
|
// prior written consent.
|
||||||
//
|
//
|
||||||
// If you have any questions, please contact Tripwire, Inc. at either
|
// If you have any questions, please contact Tripwire, Inc. at either
|
||||||
// info@tripwire.org or www.tripwire.org.
|
// info@tripwire.org or www.tripwire.org.
|
||||||
//
|
//
|
||||||
|
@ -41,8 +41,7 @@
|
||||||
|
|
||||||
#include "core/errortable.h"
|
#include "core/errortable.h"
|
||||||
|
|
||||||
TSS_DECLARE_ERROR_REGISTRATION( core )
|
TSS_DECLARE_ERROR_REGISTRATION(core)
|
||||||
|
|
||||||
|
|
||||||
#endif//__COREERRORS_H
|
|
||||||
|
|
||||||
|
#endif //__COREERRORS_H
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
//
|
//
|
||||||
// The developer of the original code and/or files is Tripwire, Inc.
|
// The developer of the original code and/or files is Tripwire, Inc.
|
||||||
// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire,
|
// Portions created by Tripwire, Inc. are copyright (C) 2000-2018 Tripwire,
|
||||||
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
||||||
// reserved.
|
// reserved.
|
||||||
//
|
//
|
||||||
// This program is free software. The contents of this file are subject
|
// 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
|
// 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
|
// Free Software Foundation; either version 2 of the License, or (at your
|
||||||
// option) any later version. You may redistribute it and/or modify it
|
// option) any later version. You may redistribute it and/or modify it
|
||||||
// only in compliance with the GNU General Public License.
|
// only in compliance with the GNU General Public License.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful.
|
// This program is distributed in the hope that it will be useful.
|
||||||
// However, this program is distributed AS-IS WITHOUT ANY
|
// However, this program is distributed AS-IS WITHOUT ANY
|
||||||
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
||||||
// for more details.
|
// for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
// USA.
|
// USA.
|
||||||
//
|
//
|
||||||
// Nothing in the GNU General Public License or any other license to use
|
// 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,
|
// the code or files shall permit you to use Tripwire's trademarks,
|
||||||
// service marks, or other intellectual property without Tripwire's
|
// service marks, or other intellectual property without Tripwire's
|
||||||
// prior written consent.
|
// prior written consent.
|
||||||
//
|
//
|
||||||
// If you have any questions, please contact Tripwire, Inc. at either
|
// If you have any questions, please contact Tripwire, Inc. at either
|
||||||
// info@tripwire.org or www.tripwire.org.
|
// info@tripwire.org or www.tripwire.org.
|
||||||
//
|
//
|
||||||
|
@ -35,39 +35,35 @@
|
||||||
// Creator.: Robert DiFalco (rdifalco)
|
// Creator.: Robert DiFalco (rdifalco)
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "stdcore.h" // for: pch (required by all core source modules)
|
#include "stdcore.h" // for: pch (required by all core source modules)
|
||||||
#include "corestrings.h" // for: cCore and core::STR_IDS
|
#include "corestrings.h" // for: cCore and core::STR_IDS
|
||||||
|
|
||||||
|
|
||||||
TSS_BeginStringtable( cCore )
|
TSS_BeginStringtable(cCore)
|
||||||
|
|
||||||
TSS_StringEntry( core::STR_ERR2_ARCH_CRYPTO_ERR, _T("File could not be decrypted.") ),
|
TSS_StringEntry(core::STR_ERR2_ARCH_CRYPTO_ERR, _T("File could not be decrypted.")),
|
||||||
TSS_StringEntry( core::STR_ERR2_BAD_ARG_PARAMS, _T("Argument: ") ),
|
TSS_StringEntry(core::STR_ERR2_BAD_ARG_PARAMS, _T("Argument: ")),
|
||||||
TSS_StringEntry( core::STR_ERROR_ERROR, _T("### Error") ),
|
TSS_StringEntry(core::STR_ERROR_ERROR, _T("### Error")),
|
||||||
TSS_StringEntry( core::STR_ERROR_WARNING, _T("### Warning") ),
|
TSS_StringEntry(core::STR_ERROR_WARNING, _T("### Warning")), TSS_StringEntry(core::STR_ERROR_COLON, _T(":")),
|
||||||
TSS_StringEntry( core::STR_ERROR_COLON, _T(":") ),
|
TSS_StringEntry(core::STR_ERROR_HEADER, _T("### ")), TSS_StringEntry(core::STR_ERROR_EXITING, _T("Exiting...")),
|
||||||
TSS_StringEntry( core::STR_ERROR_HEADER, _T("### ") ),
|
TSS_StringEntry(core::STR_ERROR_CONTINUING, _T("Continuing...")),
|
||||||
TSS_StringEntry( core::STR_ERROR_EXITING, _T("Exiting...") ),
|
TSS_StringEntry(core::STR_ERR2_FILENAME, _T("Filename: ")),
|
||||||
TSS_StringEntry( core::STR_ERROR_CONTINUING, _T("Continuing...") ),
|
TSS_StringEntry(core::STR_ERROR_FILENAME, _T("Filename: ")), TSS_StringEntry(core::STR_UNKNOWN, _T("Unknown")),
|
||||||
TSS_StringEntry( core::STR_ERR2_FILENAME, _T("Filename: ") ),
|
TSS_StringEntry(core::STR_NUMBER_TOO_BIG, _T("Number too big")),
|
||||||
TSS_StringEntry( core::STR_ERROR_FILENAME, _T("Filename: ") ),
|
TSS_StringEntry(core::STR_SIGNAL, _T("Software interrupt forced exit:")),
|
||||||
TSS_StringEntry( core::STR_UNKNOWN, _T("Unknown") ),
|
TSS_StringEntry(core::STR_NEWLINE, _T("\n")),
|
||||||
TSS_StringEntry( core::STR_NUMBER_TOO_BIG, _T("Number too big") ),
|
TSS_StringEntry(core::STR_MEMARCHIVE_FILENAME, _T("Error occured in internal memory file")),
|
||||||
TSS_StringEntry( core::STR_SIGNAL, _T("Software interrupt forced exit:") ),
|
TSS_StringEntry(core::STR_MEMARCHIVE_ERRSTR, _T("")),
|
||||||
TSS_StringEntry( core::STR_NEWLINE, _T("\n") ),
|
TSS_StringEntry(core::STR_ENDOFTIME, _T("Tripwire is not designed to run past the year 2038.\nNow exiting...")),
|
||||||
TSS_StringEntry( core::STR_MEMARCHIVE_FILENAME, _T("Error occured in internal memory file") ),
|
TSS_StringEntry(core::STR_UNKNOWN_TIME, _T("Unknown time")),
|
||||||
TSS_StringEntry( core::STR_MEMARCHIVE_ERRSTR, _T("") ),
|
TSS_StringEntry(
|
||||||
TSS_StringEntry( core::STR_ENDOFTIME, _T("Tripwire is not designed to run past the year 2038.\nNow exiting...") ),
|
core::STR_BAD_TEMPDIRECTORY,
|
||||||
TSS_StringEntry( core::STR_UNKNOWN_TIME, _T("Unknown time") ),
|
_T("Solution: Check existence/permissions for directory specified by TEMPDIRECTORY in config file")),
|
||||||
TSS_StringEntry( core::STR_BAD_TEMPDIRECTORY, _T("Solution: Check existence/permissions for directory specified by TEMPDIRECTORY in config file") ),
|
|
||||||
/// Particularly useful for eCharacter and eCharacterEncoding
|
/// Particularly useful for eCharacter and eCharacterEncoding
|
||||||
|
|
||||||
TSS_StringEntry( core::STR_ERR_ISNULL, _T("Argument cannot be null.") ),
|
TSS_StringEntry(core::STR_ERR_ISNULL, _T("Argument cannot be null.")),
|
||||||
TSS_StringEntry( core::STR_ERR_OVERFLOW, _T("An overflow has been detected.") ),
|
TSS_StringEntry(core::STR_ERR_OVERFLOW, _T("An overflow has been detected.")),
|
||||||
TSS_StringEntry( core::STR_ERR_UNDERFLOW, _T("An underflow has been detected.") ),
|
TSS_StringEntry(core::STR_ERR_UNDERFLOW, _T("An underflow has been detected.")),
|
||||||
TSS_StringEntry( core::STR_ERR_BADCHAR, _T("Input contained an invalid character.") )
|
TSS_StringEntry(core::STR_ERR_BADCHAR, _T("Input contained an invalid character."))
|
||||||
|
|
||||||
TSS_EndStringtable( cCore )
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
TSS_EndStringtable(cCore)
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
//
|
//
|
||||||
// The developer of the original code and/or files is Tripwire, Inc.
|
// The developer of the original code and/or files is Tripwire, Inc.
|
||||||
// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire,
|
// Portions created by Tripwire, Inc. are copyright (C) 2000-2018 Tripwire,
|
||||||
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
||||||
// reserved.
|
// reserved.
|
||||||
//
|
//
|
||||||
// This program is free software. The contents of this file are subject
|
// 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
|
// 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
|
// Free Software Foundation; either version 2 of the License, or (at your
|
||||||
// option) any later version. You may redistribute it and/or modify it
|
// option) any later version. You may redistribute it and/or modify it
|
||||||
// only in compliance with the GNU General Public License.
|
// only in compliance with the GNU General Public License.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful.
|
// This program is distributed in the hope that it will be useful.
|
||||||
// However, this program is distributed AS-IS WITHOUT ANY
|
// However, this program is distributed AS-IS WITHOUT ANY
|
||||||
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
||||||
// for more details.
|
// for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
// USA.
|
// USA.
|
||||||
//
|
//
|
||||||
// Nothing in the GNU General Public License or any other license to use
|
// 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,
|
// the code or files shall permit you to use Tripwire's trademarks,
|
||||||
// service marks, or other intellectual property without Tripwire's
|
// service marks, or other intellectual property without Tripwire's
|
||||||
// prior written consent.
|
// prior written consent.
|
||||||
//
|
//
|
||||||
// If you have any questions, please contact Tripwire, Inc. at either
|
// If you have any questions, please contact Tripwire, Inc. at either
|
||||||
// info@tripwire.org or www.tripwire.org.
|
// info@tripwire.org or www.tripwire.org.
|
||||||
//
|
//
|
||||||
|
@ -40,42 +40,24 @@
|
||||||
#define __CORESTRINGS_H
|
#define __CORESTRINGS_H
|
||||||
|
|
||||||
|
|
||||||
#include "core.h" // for: STRINGTABLE syntax
|
#include "core.h" // for: STRINGTABLE syntax
|
||||||
|
|
||||||
|
|
||||||
//--Message Keys
|
//--Message Keys
|
||||||
|
|
||||||
TSS_BeginStringIds( core )
|
TSS_BeginStringIds(core)
|
||||||
|
|
||||||
STR_ERR2_ARCH_CRYPTO_ERR,
|
STR_ERR2_ARCH_CRYPTO_ERR,
|
||||||
STR_ERR2_BAD_ARG_PARAMS,
|
STR_ERR2_BAD_ARG_PARAMS, STR_ERROR_ERROR, STR_ERROR_WARNING, STR_ERROR_COLON, STR_ERROR_HEADER, STR_ERROR_EXITING,
|
||||||
STR_ERROR_ERROR,
|
STR_ERROR_CONTINUING, STR_ERR2_FILENAME, STR_ERROR_FILENAME, STR_NUMBER_TOO_BIG, STR_UNKNOWN, STR_SIGNAL,
|
||||||
STR_ERROR_WARNING,
|
STR_NEWLINE, STR_MEMARCHIVE_FILENAME, STR_MEMARCHIVE_ERRSTR, STR_ENDOFTIME, STR_UNKNOWN_TIME, STR_BAD_TEMPDIRECTORY,
|
||||||
STR_ERROR_COLON,
|
|
||||||
STR_ERROR_HEADER,
|
|
||||||
STR_ERROR_EXITING,
|
|
||||||
STR_ERROR_CONTINUING,
|
|
||||||
STR_ERR2_FILENAME,
|
|
||||||
STR_ERROR_FILENAME,
|
|
||||||
STR_NUMBER_TOO_BIG,
|
|
||||||
STR_UNKNOWN,
|
|
||||||
STR_SIGNAL,
|
|
||||||
STR_NEWLINE,
|
|
||||||
STR_MEMARCHIVE_FILENAME,
|
|
||||||
STR_MEMARCHIVE_ERRSTR,
|
|
||||||
STR_ENDOFTIME,
|
|
||||||
STR_UNKNOWN_TIME,
|
|
||||||
STR_BAD_TEMPDIRECTORY,
|
|
||||||
|
|
||||||
/// Particularly useful for eCharacterSet and eCharacterEncoding
|
/// Particularly useful for eCharacterSet and eCharacterEncoding
|
||||||
|
|
||||||
STR_ERR_ISNULL,
|
STR_ERR_ISNULL, STR_ERR_OVERFLOW, STR_ERR_UNDERFLOW,
|
||||||
STR_ERR_OVERFLOW,
|
|
||||||
STR_ERR_UNDERFLOW,
|
|
||||||
STR_ERR_BADCHAR
|
STR_ERR_BADCHAR
|
||||||
|
|
||||||
TSS_EndStringIds( core )
|
TSS_EndStringIds(core)
|
||||||
|
|
||||||
|
|
||||||
#endif //__CORESTRINGS_H
|
#endif //__CORESTRINGS_H
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
//
|
//
|
||||||
// The developer of the original code and/or files is Tripwire, Inc.
|
// The developer of the original code and/or files is Tripwire, Inc.
|
||||||
// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire,
|
// Portions created by Tripwire, Inc. are copyright (C) 2000-2018 Tripwire,
|
||||||
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
||||||
// reserved.
|
// reserved.
|
||||||
//
|
//
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
//
|
//
|
||||||
// The developer of the original code and/or files is Tripwire, Inc.
|
// The developer of the original code and/or files is Tripwire, Inc.
|
||||||
// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire,
|
// Portions created by Tripwire, Inc. are copyright (C) 2000-2018 Tripwire,
|
||||||
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
||||||
// reserved.
|
// reserved.
|
||||||
//
|
//
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
//
|
//
|
||||||
// The developer of the original code and/or files is Tripwire, Inc.
|
// The developer of the original code and/or files is Tripwire, Inc.
|
||||||
// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire,
|
// Portions created by Tripwire, Inc. are copyright (C) 2000-2018 Tripwire,
|
||||||
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
||||||
// reserved.
|
// reserved.
|
||||||
//
|
//
|
||||||
// This program is free software. The contents of this file are subject
|
// 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
|
// 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
|
// Free Software Foundation; either version 2 of the License, or (at your
|
||||||
// option) any later version. You may redistribute it and/or modify it
|
// option) any later version. You may redistribute it and/or modify it
|
||||||
// only in compliance with the GNU General Public License.
|
// only in compliance with the GNU General Public License.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful.
|
// This program is distributed in the hope that it will be useful.
|
||||||
// However, this program is distributed AS-IS WITHOUT ANY
|
// However, this program is distributed AS-IS WITHOUT ANY
|
||||||
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
||||||
// for more details.
|
// for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
// USA.
|
// USA.
|
||||||
//
|
//
|
||||||
// Nothing in the GNU General Public License or any other license to use
|
// 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,
|
// the code or files shall permit you to use Tripwire's trademarks,
|
||||||
// service marks, or other intellectual property without Tripwire's
|
// service marks, or other intellectual property without Tripwire's
|
||||||
// prior written consent.
|
// prior written consent.
|
||||||
//
|
//
|
||||||
// If you have any questions, please contact Tripwire, Inc. at either
|
// If you have any questions, please contact Tripwire, Inc. at either
|
||||||
// info@tripwire.org or www.tripwire.org.
|
// info@tripwire.org or www.tripwire.org.
|
||||||
//
|
//
|
||||||
|
@ -37,17 +37,17 @@
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
|
||||||
#ifndef va_start
|
# ifndef va_start
|
||||||
#include <cstdarg>
|
# include <cstdarg>
|
||||||
#endif
|
# endif
|
||||||
#include <cwchar>
|
#include <cwchar>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
int cDebug::mDebugLevel(10);
|
int cDebug::mDebugLevel(10);
|
||||||
uint32 cDebug::mOutMask(cDebug::OUT_TRACE);
|
uint32 cDebug::mOutMask(cDebug::OUT_TRACE);
|
||||||
std::ofstream cDebug::logfile;
|
std::ofstream cDebug::logfile;
|
||||||
//mDebugLevel default == 10, mOutMask default == OUT_TRACE.
|
//mDebugLevel default == 10, mOutMask default == OUT_TRACE.
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// Constructors and Destructor
|
// Constructors and Destructor
|
||||||
|
@ -61,32 +61,31 @@ cDebug::cDebug(const char* label)
|
||||||
mLabel[cnt] = '\0';
|
mLabel[cnt] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
cDebug::cDebug(const cDebug &rhs)
|
cDebug::cDebug(const cDebug& rhs)
|
||||||
{
|
{
|
||||||
strncpy(mLabel, rhs.mLabel, MAX_LABEL);
|
strncpy(mLabel, rhs.mLabel, MAX_LABEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
cDebug::~cDebug()
|
cDebug::~cDebug()
|
||||||
{
|
{
|
||||||
if(logfile)
|
if (logfile)
|
||||||
logfile.close();
|
logfile.close();
|
||||||
}
|
}
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// Trace -- Outputs a format string only if the passed integer value is <=
|
// Trace -- Outputs a format string only if the passed integer value is <=
|
||||||
// the "global debug level" (indicated by mDebugLevel).
|
// the "global debug level" (indicated by mDebugLevel).
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
void cDebug::Trace(int levelNum, const char* format, ...)
|
void cDebug::Trace(int levelNum, const char* format, ...)
|
||||||
{
|
{
|
||||||
if (levelNum > mDebugLevel)
|
if (levelNum > mDebugLevel)
|
||||||
return;
|
return;
|
||||||
// create the output buffer
|
// create the output buffer
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
DoTrace(format, args);
|
DoTrace(format, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -96,10 +95,10 @@ void cDebug::Trace(int levelNum, const char* format, ...)
|
||||||
// console, etc...
|
// console, etc...
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void cDebug::DoTrace(const char *format, va_list &args)
|
void cDebug::DoTrace(const char* format, va_list& args)
|
||||||
{
|
{
|
||||||
size_t guard1 = 0xBABABABA;
|
size_t guard1 = 0xBABABABA;
|
||||||
char out[2048];
|
char out[2048];
|
||||||
size_t guard2 = 0xBABABABA;
|
size_t guard2 = 0xBABABABA;
|
||||||
|
|
||||||
vsnprintf(out, 2048, format, args);
|
vsnprintf(out, 2048, format, args);
|
||||||
|
@ -135,14 +134,14 @@ void cDebug::DoTrace(const char *format, va_list &args)
|
||||||
logfile.flush();
|
logfile.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef DEBUG
|
# ifdef DEBUG
|
||||||
|
|
||||||
//
|
//
|
||||||
// wrappers around Trace() that requires less typing
|
// wrappers around Trace() that requires less typing
|
||||||
// TODO: this is quick and dirty, but lets me check in all these files right away. --ghk
|
// TODO: this is quick and dirty, but lets me check in all these files right away. --ghk
|
||||||
//
|
//
|
||||||
|
|
||||||
void cDebug::TraceAlways(const char *format, ...)
|
void cDebug::TraceAlways(const char* format, ...)
|
||||||
{
|
{
|
||||||
if (D_ALWAYS > mDebugLevel)
|
if (D_ALWAYS > mDebugLevel)
|
||||||
return;
|
return;
|
||||||
|
@ -154,7 +153,7 @@ void cDebug::TraceAlways(const char *format, ...)
|
||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cDebug::TraceError(const char *format, ...)
|
void cDebug::TraceError(const char* format, ...)
|
||||||
{
|
{
|
||||||
if (D_ERROR > mDebugLevel)
|
if (D_ERROR > mDebugLevel)
|
||||||
return;
|
return;
|
||||||
|
@ -166,7 +165,7 @@ void cDebug::TraceError(const char *format, ...)
|
||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cDebug::TraceWarning(const char *format, ...)
|
void cDebug::TraceWarning(const char* format, ...)
|
||||||
{
|
{
|
||||||
if (D_WARNING > mDebugLevel)
|
if (D_WARNING > mDebugLevel)
|
||||||
return;
|
return;
|
||||||
|
@ -178,7 +177,7 @@ void cDebug::TraceWarning(const char *format, ...)
|
||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cDebug::TraceDebug(const char *format, ...)
|
void cDebug::TraceDebug(const char* format, ...)
|
||||||
{
|
{
|
||||||
if (D_DEBUG > mDebugLevel)
|
if (D_DEBUG > mDebugLevel)
|
||||||
return;
|
return;
|
||||||
|
@ -190,7 +189,7 @@ void cDebug::TraceDebug(const char *format, ...)
|
||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cDebug::TraceDetail(const char *format, ...)
|
void cDebug::TraceDetail(const char* format, ...)
|
||||||
{
|
{
|
||||||
if (D_DETAIL > mDebugLevel)
|
if (D_DETAIL > mDebugLevel)
|
||||||
return;
|
return;
|
||||||
|
@ -202,7 +201,7 @@ void cDebug::TraceDetail(const char *format, ...)
|
||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cDebug::TraceNever(const char *format, ...)
|
void cDebug::TraceNever(const char* format, ...)
|
||||||
{
|
{
|
||||||
if (D_NEVER > mDebugLevel)
|
if (D_NEVER > mDebugLevel)
|
||||||
return;
|
return;
|
||||||
|
@ -214,15 +213,15 @@ void cDebug::TraceNever(const char *format, ...)
|
||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cDebug::TraceVaArgs( int iDebugLevel, const char *format, va_list &args )
|
void cDebug::TraceVaArgs(int iDebugLevel, const char* format, va_list& args)
|
||||||
{
|
{
|
||||||
if ( iDebugLevel <= mDebugLevel )
|
if (iDebugLevel <= mDebugLevel)
|
||||||
DoTrace( format, args);
|
DoTrace(format, args);
|
||||||
}
|
}
|
||||||
#endif // DEBUG
|
# endif // DEBUG
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// AddOutTarget -- Attempts to add a new target for trace/debug output.
|
// AddOutTarget -- Attempts to add a new target for trace/debug output.
|
||||||
// FAILS ONLY IF caller attempts to SET OUT_FILE via this function.
|
// FAILS ONLY IF caller attempts to SET OUT_FILE via this function.
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
bool cDebug::AddOutTarget(OutTarget target)
|
bool cDebug::AddOutTarget(OutTarget target)
|
||||||
|
@ -231,7 +230,8 @@ bool cDebug::AddOutTarget(OutTarget target)
|
||||||
mOutMask |= OUT_STDOUT;
|
mOutMask |= OUT_STDOUT;
|
||||||
if (target == OUT_TRACE)
|
if (target == OUT_TRACE)
|
||||||
mOutMask |= OUT_TRACE;
|
mOutMask |= OUT_TRACE;
|
||||||
if (target == OUT_FILE) {
|
if (target == OUT_FILE)
|
||||||
|
{
|
||||||
mOutMask |= OUT_FILE;
|
mOutMask |= OUT_FILE;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -259,7 +259,7 @@ bool cDebug::RemoveOutTarget(OutTarget target)
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
bool cDebug::HasOutTarget(OutTarget target)
|
bool cDebug::HasOutTarget(OutTarget target)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (target == OUT_STDOUT)
|
if (target == OUT_STDOUT)
|
||||||
return ((mOutMask & OUT_STDOUT) != 0);
|
return ((mOutMask & OUT_STDOUT) != 0);
|
||||||
else if (target == OUT_TRACE)
|
else if (target == OUT_TRACE)
|
||||||
|
@ -271,25 +271,27 @@ bool cDebug::HasOutTarget(OutTarget target)
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// SetOutputFile -- Attempts to set the output file for Logfile member to
|
// SetOutputFile -- Attempts to set the output file for Logfile member to
|
||||||
// the string passed in.
|
// the string passed in.
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
bool cDebug::SetOutputFile(const char* filename)
|
bool cDebug::SetOutputFile(const char* filename)
|
||||||
{
|
{
|
||||||
// TODO -- make sure this does the right thing if a log file is
|
// TODO -- make sure this does the right thing if a log file is
|
||||||
// already open!
|
// already open!
|
||||||
// TODO -- make this work with wide chars
|
// TODO -- make this work with wide chars
|
||||||
if (!logfile)
|
if (!logfile)
|
||||||
logfile.open(filename, std::ios_base::out | std::ios_base::ate | std::ios_base::app);
|
logfile.open(filename, std::ios_base::out | std::ios_base::ate | std::ios_base::app);
|
||||||
else
|
else
|
||||||
logfile.setf(std::ios_base::hex, std::ios_base::basefield);
|
logfile.setf(std::ios_base::hex, std::ios_base::basefield);
|
||||||
//make sure info. will not be clobbered.
|
//make sure info. will not be clobbered.
|
||||||
|
|
||||||
//Should be open now- if not, abort.
|
//Should be open now- if not, abort.
|
||||||
if (!logfile) {
|
if (!logfile)
|
||||||
|
{
|
||||||
mOutMask ^= OUT_FILE;
|
mOutMask ^= OUT_FILE;
|
||||||
return false;
|
return false;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
mOutMask |= OUT_FILE;
|
mOutMask |= OUT_FILE;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -298,18 +300,18 @@ bool cDebug::SetOutputFile(const char* filename)
|
||||||
// DebugOut -- Works just like TRACE. note: there is an internal buffer size
|
// DebugOut -- Works just like TRACE. note: there is an internal buffer size
|
||||||
// of 1024; traces larger than that will have unpredictable results.
|
// of 1024; traces larger than that will have unpredictable results.
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
void cDebug::DebugOut( const char* lpOutputString, ... )
|
void cDebug::DebugOut(const char* lpOutputString, ...)
|
||||||
{
|
{
|
||||||
char buf[2048];
|
char buf[2048];
|
||||||
// create the output buffer
|
// create the output buffer
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, lpOutputString);
|
va_start(args, lpOutputString);
|
||||||
vsnprintf(buf, 2048, lpOutputString, args);
|
vsnprintf(buf, 2048, lpOutputString, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
#ifdef DEBUG
|
# ifdef DEBUG
|
||||||
TCERR << buf;
|
TCERR << buf;
|
||||||
#endif //_DEBUG
|
# endif //_DEBUG
|
||||||
|
|
||||||
TCOUT.flush();
|
TCOUT.flush();
|
||||||
}
|
}
|
||||||
|
@ -318,4 +320,3 @@ void cDebug::DebugOut( const char* lpOutputString, ... )
|
||||||
//////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////
|
||||||
// ASSERT macro support function
|
// ASSERT macro support function
|
||||||
//////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
217
src/core/debug.h
217
src/core/debug.h
|
@ -1,31 +1,31 @@
|
||||||
//
|
//
|
||||||
// The developer of the original code and/or files is Tripwire, Inc.
|
// The developer of the original code and/or files is Tripwire, Inc.
|
||||||
// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire,
|
// Portions created by Tripwire, Inc. are copyright (C) 2000-2018 Tripwire,
|
||||||
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
||||||
// reserved.
|
// reserved.
|
||||||
//
|
//
|
||||||
// This program is free software. The contents of this file are subject
|
// 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
|
// 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
|
// Free Software Foundation; either version 2 of the License, or (at your
|
||||||
// option) any later version. You may redistribute it and/or modify it
|
// option) any later version. You may redistribute it and/or modify it
|
||||||
// only in compliance with the GNU General Public License.
|
// only in compliance with the GNU General Public License.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful.
|
// This program is distributed in the hope that it will be useful.
|
||||||
// However, this program is distributed AS-IS WITHOUT ANY
|
// However, this program is distributed AS-IS WITHOUT ANY
|
||||||
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
||||||
// for more details.
|
// for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
// USA.
|
// USA.
|
||||||
//
|
//
|
||||||
// Nothing in the GNU General Public License or any other license to use
|
// 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,
|
// the code or files shall permit you to use Tripwire's trademarks,
|
||||||
// service marks, or other intellectual property without Tripwire's
|
// service marks, or other intellectual property without Tripwire's
|
||||||
// prior written consent.
|
// prior written consent.
|
||||||
//
|
//
|
||||||
// If you have any questions, please contact Tripwire, Inc. at either
|
// If you have any questions, please contact Tripwire, Inc. at either
|
||||||
// info@tripwire.org or www.tripwire.org.
|
// info@tripwire.org or www.tripwire.org.
|
||||||
//
|
//
|
||||||
|
@ -40,19 +40,17 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
/* Do it in this order, because autoconf checks for <stdarg.h>
|
/* Do it in this order, because autoconf checks for <stdarg.h>
|
||||||
* first i.e. if HAVE_VARARGS_H is defined, it is only because
|
* first i.e. if HAVE_VARARGS_H is defined, it is only because
|
||||||
* <stdarg.h> couldn't be found.
|
* <stdarg.h> couldn't be found.
|
||||||
*/
|
*/
|
||||||
#ifdef HAVE_VARARGS_H
|
#ifdef HAVE_VARARGS_H
|
||||||
# include <varargs.h>
|
#include <varargs.h>
|
||||||
#else
|
#else
|
||||||
# ifdef HAVE_STDARG_H
|
# ifdef HAVE_STDARG_H
|
||||||
# include <stdarg.h>
|
# include <stdarg.h>
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
|
@ -69,8 +67,8 @@
|
||||||
//
|
//
|
||||||
// IMPORTANT:
|
// IMPORTANT:
|
||||||
//
|
//
|
||||||
// strings outputted as trace statements are printed as narrow characters.
|
// strings outputted as trace statements are printed as narrow characters.
|
||||||
// passing trace messages with wide characters will have odd results, since
|
// passing trace messages with wide characters will have odd results, since
|
||||||
// they will be used as arugments to sprintf(), etc...
|
// they will be used as arugments to sprintf(), etc...
|
||||||
//
|
//
|
||||||
|
|
||||||
|
@ -80,19 +78,19 @@ class cDebug
|
||||||
public:
|
public:
|
||||||
enum OutTarget
|
enum OutTarget
|
||||||
{
|
{
|
||||||
OUT_STDOUT = 1,
|
OUT_STDOUT = 1,
|
||||||
OUT_TRACE = 2,
|
OUT_TRACE = 2,
|
||||||
OUT_FILE = 4
|
OUT_FILE = 4
|
||||||
};
|
};
|
||||||
|
|
||||||
enum DebugLevel
|
enum DebugLevel
|
||||||
{
|
{
|
||||||
D_ALWAYS = 0,
|
D_ALWAYS = 0,
|
||||||
D_ERROR = 1,
|
D_ERROR = 1,
|
||||||
D_WARNING = 4,
|
D_WARNING = 4,
|
||||||
D_DEBUG = 8,
|
D_DEBUG = 8,
|
||||||
D_DETAIL = 16,
|
D_DETAIL = 16,
|
||||||
D_NEVER = 1000
|
D_NEVER = 1000
|
||||||
};
|
};
|
||||||
|
|
||||||
cDebug(const char* pLabel);
|
cDebug(const char* pLabel);
|
||||||
|
@ -101,65 +99,67 @@ public:
|
||||||
|
|
||||||
// These are the preferred tracing interfaces, because you don't need to know
|
// These are the preferred tracing interfaces, because you don't need to know
|
||||||
// the DebugLevel enums.
|
// the DebugLevel enums.
|
||||||
// Wide/Narrow Chars Issues: If you include a %s in your format string and you
|
// Wide/Narrow Chars Issues: If you include a %s in your format string and you
|
||||||
// wish to print out a TCHAR (which might be a natural thing to do) you should
|
// wish to print out a TCHAR (which might be a natural thing to do) you should
|
||||||
// encompas the format string with a _T("") macro, i.e. make it a TSTRING.
|
// encompas the format string with a _T("") macro, i.e. make it a TSTRING.
|
||||||
// The wide character overloads of these functions will expect wide strings
|
// The wide character overloads of these functions will expect wide strings
|
||||||
// for %s options.
|
// for %s options.
|
||||||
//
|
//
|
||||||
void TraceAlways (const char *format, ...);
|
void TraceAlways(const char* format, ...);
|
||||||
void TraceError (const char *format, ...);
|
void TraceError(const char* format, ...);
|
||||||
void TraceWarning (const char *format, ...);
|
void TraceWarning(const char* format, ...);
|
||||||
void TraceDebug (const char *format, ...);
|
void TraceDebug(const char* format, ...);
|
||||||
void TraceDetail (const char *format, ...);
|
void TraceDetail(const char* format, ...);
|
||||||
void TraceNever (const char *format, ...);
|
void TraceNever(const char* format, ...);
|
||||||
|
|
||||||
|
|
||||||
// these are of use if you are inside a function with a "..." as an argument
|
// these are of use if you are inside a function with a "..." as an argument
|
||||||
// and you want to trace those args
|
// and you want to trace those args
|
||||||
void TraceVaArgs (int iDebugLevel, const char *format, va_list &args);
|
void TraceVaArgs(int iDebugLevel, const char* format, va_list& args);
|
||||||
|
|
||||||
// ...but you can still choose to use this interface...
|
// ...but you can still choose to use this interface...
|
||||||
|
|
||||||
void Trace(int levelNum, const char* format, ...);
|
void Trace(int levelNum, const char* format, ...);
|
||||||
// Outputs based on levelnum. If levelnum <= global debug, print.
|
// Outputs based on levelnum. If levelnum <= global debug, print.
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
static bool AddOutTarget(OutTarget target);
|
||||||
static bool AddOutTarget (OutTarget target);
|
static bool RemoveOutTarget(OutTarget target);
|
||||||
static bool RemoveOutTarget (OutTarget target);
|
// used to specify the out target....
|
||||||
// used to specify the out target....
|
static bool HasOutTarget(OutTarget target);
|
||||||
static bool HasOutTarget (OutTarget target);
|
|
||||||
|
|
||||||
static bool SetOutputFile (const char* filename);
|
static bool SetOutputFile(const char* filename);
|
||||||
// specifies the output file name used when OUT_FILE is set
|
// specifies the output file name used when OUT_FILE is set
|
||||||
static void SetDebugLevel (int level);
|
static void SetDebugLevel(int level);
|
||||||
static int GetDebugLevel (void);
|
static int GetDebugLevel(void);
|
||||||
// gets and sets the global debug level. Trace output at or below this
|
// gets and sets the global debug level. Trace output at or below this
|
||||||
// level will be output.
|
// level will be output.
|
||||||
|
|
||||||
static void DebugOut ( const char* lpOutputString, ... );
|
static void DebugOut(const char* lpOutputString, ...);
|
||||||
// Works just like TRACE
|
// Works just like TRACE
|
||||||
// note: there is an internal buffer size of 1024; traces larger
|
// note: there is an internal buffer size of 1024; traces larger
|
||||||
// than that will have unpredictable and probably bad results
|
// than that will have unpredictable and probably bad results
|
||||||
private:
|
private:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
enum { MAX_LABEL = 128 };
|
enum
|
||||||
|
{
|
||||||
|
MAX_LABEL = 128
|
||||||
|
};
|
||||||
|
|
||||||
static int mDebugLevel;
|
static int mDebugLevel;
|
||||||
static uint32 mOutMask;
|
static uint32 mOutMask;
|
||||||
static std::ofstream logfile;
|
static std::ofstream logfile;
|
||||||
char mLabel[MAX_LABEL];
|
char mLabel[MAX_LABEL];
|
||||||
|
|
||||||
// helper functions
|
// helper functions
|
||||||
void DoTrace(const char *format, va_list &args);
|
void DoTrace(const char* format, va_list& args);
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
#define TRACE cDebug::DebugOut
|
# define TRACE cDebug::DebugOut
|
||||||
#else
|
#else
|
||||||
#define TRACE 1 ? (void)0 : cDebug::DebugOut
|
# define TRACE 1 ? (void)0 : cDebug::DebugOut
|
||||||
#endif // DEBUG
|
#endif // DEBUG
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -179,51 +179,90 @@ inline int cDebug::GetDebugLevel()
|
||||||
return mDebugLevel;
|
return mDebugLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else // DEBUG
|
# else // DEBUG
|
||||||
|
|
||||||
inline cDebug::cDebug (const char *) {}
|
inline cDebug::cDebug(const char*)
|
||||||
inline cDebug::~cDebug () {}
|
{
|
||||||
inline cDebug::cDebug (const cDebug&) {}
|
}
|
||||||
inline void cDebug::TraceAlways (const char *, ...) {}
|
inline cDebug::~cDebug()
|
||||||
inline void cDebug::TraceError (const char *, ...) {}
|
{
|
||||||
inline void cDebug::TraceWarning (const char *, ...) {}
|
}
|
||||||
inline void cDebug::TraceDebug (const char *, ...) {}
|
inline cDebug::cDebug(const cDebug&)
|
||||||
inline void cDebug::TraceDetail (const char *, ...) {}
|
{
|
||||||
inline void cDebug::TraceNever (const char *, ...) {}
|
}
|
||||||
inline void cDebug::TraceVaArgs (int, const char *, va_list &) {}
|
inline void cDebug::TraceAlways(const char*, ...)
|
||||||
inline void cDebug::Trace (int, const char*, ...) {}
|
{
|
||||||
inline bool cDebug::AddOutTarget (OutTarget) { return false; }
|
}
|
||||||
inline bool cDebug::RemoveOutTarget (OutTarget) { return false; }
|
inline void cDebug::TraceError(const char*, ...)
|
||||||
inline bool cDebug::HasOutTarget (OutTarget) { return false; }
|
{
|
||||||
inline bool cDebug::SetOutputFile (const char*) { return false; }
|
}
|
||||||
inline void cDebug::SetDebugLevel (int) {}
|
inline void cDebug::TraceWarning(const char*, ...)
|
||||||
inline int cDebug::GetDebugLevel (void) { return 0; }
|
{
|
||||||
inline void cDebug::DebugOut ( const char*, ... ) {}
|
}
|
||||||
|
inline void cDebug::TraceDebug(const char*, ...)
|
||||||
#endif // DEBUG
|
{
|
||||||
|
}
|
||||||
|
inline void cDebug::TraceDetail(const char*, ...)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
inline void cDebug::TraceNever(const char*, ...)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
inline void cDebug::TraceVaArgs(int, const char*, va_list&)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
inline void cDebug::Trace(int, const char*, ...)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
inline bool cDebug::AddOutTarget(OutTarget)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
inline bool cDebug::RemoveOutTarget(OutTarget)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
inline bool cDebug::HasOutTarget(OutTarget)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
inline bool cDebug::SetOutputFile(const char*)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
inline void cDebug::SetDebugLevel(int)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
inline int cDebug::GetDebugLevel(void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
inline void cDebug::DebugOut(const char*, ...)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
# endif // DEBUG
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////
|
||||||
// ASSERT macro
|
// ASSERT macro
|
||||||
//////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#define ASSERTMSG( exp, s ) assert( (exp) != 0 )
|
# define ASSERTMSG(exp, s) assert((exp) != 0)
|
||||||
#define ASSERT( exp ) assert( (exp) != 0 )
|
# define ASSERT(exp) assert((exp) != 0)
|
||||||
// if we are not windows we will just use the standard assert()
|
// if we are not windows we will just use the standard assert()
|
||||||
#define TSS_DebugBreak() ASSERT( false );
|
# define TSS_DebugBreak() ASSERT(false);
|
||||||
|
|
||||||
#ifndef ASSERT
|
# ifndef ASSERT
|
||||||
#error ASSERT did not get defined!!!
|
# error ASSERT did not get defined!!!
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
#ifndef ASSERTMSG
|
# ifndef ASSERTMSG
|
||||||
#error ASSERTMSG did not get defined!!!
|
# error ASSERTMSG did not get defined!!!
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
#ifndef TSS_DebugBreak
|
# ifndef TSS_DebugBreak
|
||||||
#error TSS_DebugBreak did not get defined!!!
|
# error TSS_DebugBreak did not get defined!!!
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
#endif //__DEBUG_H
|
#endif //__DEBUG_H
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,31 +1,31 @@
|
||||||
//
|
//
|
||||||
// The developer of the original code and/or files is Tripwire, Inc.
|
// The developer of the original code and/or files is Tripwire, Inc.
|
||||||
// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire,
|
// Portions created by Tripwire, Inc. are copyright (C) 2000-2018 Tripwire,
|
||||||
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
||||||
// reserved.
|
// reserved.
|
||||||
//
|
//
|
||||||
// This program is free software. The contents of this file are subject
|
// 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
|
// 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
|
// Free Software Foundation; either version 2 of the License, or (at your
|
||||||
// option) any later version. You may redistribute it and/or modify it
|
// option) any later version. You may redistribute it and/or modify it
|
||||||
// only in compliance with the GNU General Public License.
|
// only in compliance with the GNU General Public License.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful.
|
// This program is distributed in the hope that it will be useful.
|
||||||
// However, this program is distributed AS-IS WITHOUT ANY
|
// However, this program is distributed AS-IS WITHOUT ANY
|
||||||
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
||||||
// for more details.
|
// for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
// USA.
|
// USA.
|
||||||
//
|
//
|
||||||
// Nothing in the GNU General Public License or any other license to use
|
// 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,
|
// the code or files shall permit you to use Tripwire's trademarks,
|
||||||
// service marks, or other intellectual property without Tripwire's
|
// service marks, or other intellectual property without Tripwire's
|
||||||
// prior written consent.
|
// prior written consent.
|
||||||
//
|
//
|
||||||
// If you have any questions, please contact Tripwire, Inc. at either
|
// If you have any questions, please contact Tripwire, Inc. at either
|
||||||
// info@tripwire.org or www.tripwire.org.
|
// info@tripwire.org or www.tripwire.org.
|
||||||
//
|
//
|
||||||
|
@ -40,10 +40,10 @@
|
||||||
// EXCEPTION DECLARATION
|
// EXCEPTION DECLARATION
|
||||||
//=========================================================================
|
//=========================================================================
|
||||||
|
|
||||||
TSS_EXCEPTION( eEncoder, eError );
|
TSS_EXCEPTION(eEncoder, eError);
|
||||||
TSS_EXCEPTION( eBadDecoderInput, eEncoder );
|
TSS_EXCEPTION(eBadDecoderInput, eEncoder);
|
||||||
TSS_EXCEPTION( eBadHexConversion, eEncoder );
|
TSS_EXCEPTION(eBadHexConversion, eEncoder);
|
||||||
TSS_EXCEPTION( eUnknownEscapeEncoding, eEncoder );
|
TSS_EXCEPTION(eUnknownEscapeEncoding, eEncoder);
|
||||||
|
|
||||||
//=========================================================================
|
//=========================================================================
|
||||||
// DECLARATION OF CLASSES
|
// DECLARATION OF CLASSES
|
||||||
|
@ -55,106 +55,101 @@ TSS_EXCEPTION( eUnknownEscapeEncoding, eEncoder );
|
||||||
|
|
||||||
class iCharEncoder;
|
class iCharEncoder;
|
||||||
|
|
||||||
// TODO:BAM -- i don't think that the order of encodings is important
|
// TODO:BAM -- i don't think that the order of encodings is important
|
||||||
// as long as AllIdentifiersUnique and OnlyOneCatagoryPerChar are true
|
// as long as AllIdentifiersUnique and OnlyOneCatagoryPerChar are true
|
||||||
class cEncoder
|
class cEncoder
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum Encodings
|
enum Encodings
|
||||||
{
|
{
|
||||||
NON_NARROWABLE = 0x01, // WC -> MB, MB alway narrowable:
|
NON_NARROWABLE = 0x01, // WC -> MB, MB alway narrowable:
|
||||||
NON_PRINTABLE = 0x02,
|
NON_PRINTABLE = 0x02,
|
||||||
BACKSLASH = 0x04,
|
BACKSLASH = 0x04,
|
||||||
DBL_QUOTE = 0x08
|
DBL_QUOTE = 0x08
|
||||||
};
|
};
|
||||||
|
|
||||||
enum Flags
|
|
||||||
{
|
|
||||||
ROUNDTRIP = 0x01,
|
|
||||||
NON_ROUNDTRIP = 0x02,
|
|
||||||
ALLOW_WHITESPACE = 0x04
|
|
||||||
};
|
|
||||||
|
|
||||||
cEncoder( int e, int f ); // mask of Encodings
|
enum Flags
|
||||||
virtual ~cEncoder();
|
{
|
||||||
|
ROUNDTRIP = 0x01,
|
||||||
|
NON_ROUNDTRIP = 0x02,
|
||||||
|
ALLOW_WHITESPACE = 0x04
|
||||||
|
};
|
||||||
|
|
||||||
void Encode( TSTRING& str ) const;
|
cEncoder(int e, int f); // mask of Encodings
|
||||||
void Decode( TSTRING& str ) const; // TODO:BAM -- throw error!
|
virtual ~cEncoder();
|
||||||
|
|
||||||
void ValidateSchema() const;
|
void Encode(TSTRING& str) const;
|
||||||
bool OnlyOneCatagoryPerChar() const;
|
void Decode(TSTRING& str) const; // TODO:BAM -- throw error!
|
||||||
bool AllIdentifiersUnique() const;
|
|
||||||
bool AllTestsRunOnEncodedString( const TSTRING& str ) const;
|
|
||||||
|
|
||||||
private:
|
void ValidateSchema() const;
|
||||||
typedef std::vector< iCharEncoder* > sack_type;
|
bool OnlyOneCatagoryPerChar() const;
|
||||||
|
bool AllIdentifiersUnique() const;
|
||||||
TSTRING Encode( TSTRING::const_iterator first,
|
bool AllTestsRunOnEncodedString(const TSTRING& str) const;
|
||||||
TSTRING::const_iterator last,
|
|
||||||
sack_type::const_iterator encoding ) const;
|
|
||||||
|
|
||||||
bool RoundTrip() const;
|
|
||||||
bool AllowWhiteSpace() const;
|
|
||||||
|
|
||||||
sack_type m_encodings;
|
private:
|
||||||
int m_fFlags;
|
typedef std::vector<iCharEncoder*> sack_type;
|
||||||
|
|
||||||
|
TSTRING
|
||||||
|
Encode(TSTRING::const_iterator first, TSTRING::const_iterator last, sack_type::const_iterator encoding) const;
|
||||||
|
|
||||||
|
bool RoundTrip() const;
|
||||||
|
bool AllowWhiteSpace() const;
|
||||||
|
|
||||||
|
sack_type m_encodings;
|
||||||
|
int m_fFlags;
|
||||||
};
|
};
|
||||||
|
|
||||||
// encodes ( BACKSLASH | DBL_QUOTE | NON_NARROWABLE | NON_PRINTABLE )
|
// encodes ( BACKSLASH | DBL_QUOTE | NON_NARROWABLE | NON_PRINTABLE )
|
||||||
|
|
||||||
class cDisplayEncoder : public cEncoder
|
class cDisplayEncoder : public cEncoder
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
cDisplayEncoder( Flags f = NON_ROUNDTRIP );
|
cDisplayEncoder(Flags f = NON_ROUNDTRIP);
|
||||||
|
|
||||||
void Encode( TSTRING& str ) const;
|
|
||||||
bool Decode( TSTRING& str ) const;
|
|
||||||
|
|
||||||
static TSTRING EncodeInline( const TSTRING& sIn )
|
void Encode(TSTRING& str) const;
|
||||||
{
|
bool Decode(TSTRING& str) const;
|
||||||
TSTRING sOut = sIn;
|
|
||||||
cDisplayEncoder e;
|
static TSTRING EncodeInline(const TSTRING& sIn)
|
||||||
e.Encode( sOut );
|
{
|
||||||
return sOut;
|
TSTRING sOut = sIn;
|
||||||
}
|
cDisplayEncoder e;
|
||||||
|
e.Encode(sOut);
|
||||||
static TSTRING EncodeInlineAllowWS( const TSTRING& sIn )
|
return sOut;
|
||||||
{
|
}
|
||||||
TSTRING sOut = sIn;
|
|
||||||
cDisplayEncoder e( (Flags)( NON_ROUNDTRIP | ALLOW_WHITESPACE ) );
|
static TSTRING EncodeInlineAllowWS(const TSTRING& sIn)
|
||||||
e.Encode( sOut );
|
{
|
||||||
return sOut;
|
TSTRING sOut = sIn;
|
||||||
}
|
cDisplayEncoder e((Flags)(NON_ROUNDTRIP | ALLOW_WHITESPACE));
|
||||||
|
e.Encode(sOut);
|
||||||
|
return sOut;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class cCharEncoderUtil
|
class cCharEncoderUtil
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
static bool IsPrintable(TCHAR ch);
|
||||||
|
static bool IsWhiteSpace(TCHAR ch);
|
||||||
|
|
||||||
static bool IsPrintable( TCHAR ch );
|
static TSTRING CharStringToHexValue(const TSTRING& str);
|
||||||
static bool IsWhiteSpace( TCHAR ch );
|
|
||||||
|
|
||||||
static TSTRING CharStringToHexValue( const TSTRING& str );
|
static TSTRING HexValueToCharString(const TSTRING& str);
|
||||||
|
|
||||||
static TSTRING HexValueToCharString( const TSTRING& str );
|
static TCHAR hex_to_char(TSTRING::const_iterator first, TSTRING::const_iterator last);
|
||||||
|
|
||||||
static TCHAR hex_to_char( TSTRING::const_iterator first,
|
static TSTRING char_to_hex(TCHAR ch);
|
||||||
TSTRING::const_iterator last );
|
|
||||||
|
|
||||||
static TSTRING char_to_hex( TCHAR ch );
|
static TSTRING DecodeHexToChar(TSTRING::const_iterator* pcur, const TSTRING::const_iterator end);
|
||||||
|
|
||||||
static TSTRING DecodeHexToChar( TSTRING::const_iterator* pcur,
|
|
||||||
const TSTRING::const_iterator end );
|
|
||||||
|
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
BYTE_AS_HEX__IN_TCHARS = 2,
|
BYTE_AS_HEX__IN_TCHARS = 2,
|
||||||
BYTES_PER_TCHAR = sizeof( TCHAR ),
|
BYTES_PER_TCHAR = sizeof(TCHAR),
|
||||||
TCHAR_AS_HEX__IN_TCHARS = BYTE_AS_HEX__IN_TCHARS * BYTES_PER_TCHAR
|
TCHAR_AS_HEX__IN_TCHARS = BYTE_AS_HEX__IN_TCHARS * BYTES_PER_TCHAR
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //__DISPLAYENCODER_H
|
#endif //__DISPLAYENCODER_H
|
||||||
|
@ -241,4 +236,3 @@ typedef cDisplayEncoder_<TCHAR> cDisplayEncoder;
|
||||||
#endif //__DISPLAYENCODER_H
|
#endif //__DISPLAYENCODER_H
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
//
|
//
|
||||||
// The developer of the original code and/or files is Tripwire, Inc.
|
// The developer of the original code and/or files is Tripwire, Inc.
|
||||||
// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire,
|
// Portions created by Tripwire, Inc. are copyright (C) 2000-2018 Tripwire,
|
||||||
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
||||||
// reserved.
|
// reserved.
|
||||||
//
|
//
|
||||||
// This program is free software. The contents of this file are subject
|
// 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
|
// 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
|
// Free Software Foundation; either version 2 of the License, or (at your
|
||||||
// option) any later version. You may redistribute it and/or modify it
|
// option) any later version. You may redistribute it and/or modify it
|
||||||
// only in compliance with the GNU General Public License.
|
// only in compliance with the GNU General Public License.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful.
|
// This program is distributed in the hope that it will be useful.
|
||||||
// However, this program is distributed AS-IS WITHOUT ANY
|
// However, this program is distributed AS-IS WITHOUT ANY
|
||||||
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
||||||
// for more details.
|
// for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
// USA.
|
// USA.
|
||||||
//
|
//
|
||||||
// Nothing in the GNU General Public License or any other license to use
|
// 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,
|
// the code or files shall permit you to use Tripwire's trademarks,
|
||||||
// service marks, or other intellectual property without Tripwire's
|
// service marks, or other intellectual property without Tripwire's
|
||||||
// prior written consent.
|
// prior written consent.
|
||||||
//
|
//
|
||||||
// If you have any questions, please contact Tripwire, Inc. at either
|
// If you have any questions, please contact Tripwire, Inc. at either
|
||||||
// info@tripwire.org or www.tripwire.org.
|
// info@tripwire.org or www.tripwire.org.
|
||||||
//
|
//
|
||||||
|
@ -40,29 +40,29 @@
|
||||||
#include "ntmbs.h"
|
#include "ntmbs.h"
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
|
||||||
TSTRING cDisplayUtil::FormatMultiLineString( const TSTRING& str, int nOffset, int nWidth )
|
TSTRING cDisplayUtil::FormatMultiLineString(const TSTRING& str, int nOffset, int nWidth)
|
||||||
{
|
{
|
||||||
TOSTRINGSTREAM sstr;
|
TOSTRINGSTREAM sstr;
|
||||||
TSTRING strT;
|
TSTRING strT;
|
||||||
bool fFirstLine = true;
|
bool fFirstLine = true;
|
||||||
for( TSTRING::const_iterator i = str.begin(); i != str.end(); i = *i ? i + 1 : i )
|
for (TSTRING::const_iterator i = str.begin(); i != str.end(); i = *i ? i + 1 : i)
|
||||||
{
|
{
|
||||||
// return found -- add line to output string
|
// return found -- add line to output string
|
||||||
if( _T('\n') == *i )
|
if (_T('\n') == *i)
|
||||||
{
|
{
|
||||||
// only do offset for strings after the first
|
// only do offset for strings after the first
|
||||||
if( fFirstLine )
|
if (fFirstLine)
|
||||||
{
|
{
|
||||||
fFirstLine = false;
|
fFirstLine = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// add offset
|
// add offset
|
||||||
for( int j = 0; j < nOffset; j++ )
|
for (int j = 0; j < nOffset; j++)
|
||||||
sstr << _T(" ");
|
sstr << _T(" ");
|
||||||
|
|
||||||
// set width
|
// set width
|
||||||
sstr << std::setw( nWidth );
|
sstr << std::setw(nWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
// add to stringstream
|
// add to stringstream
|
||||||
|
@ -73,28 +73,26 @@ TSTRING cDisplayUtil::FormatMultiLineString( const TSTRING& str, int nOffset, in
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// add char to string
|
// add char to string
|
||||||
strT.append( i, (TSTRING::const_iterator)(*i ? i + 1 : i) );
|
strT.append(i, (TSTRING::const_iterator)(*i ? i + 1 : i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// add last portion -- no endl
|
// add last portion -- no endl
|
||||||
// we want our client to be able to say "out << PropAsString() << endl;"
|
// we want our client to be able to say "out << PropAsString() << endl;"
|
||||||
|
|
||||||
// add offset
|
// add offset
|
||||||
if( ! fFirstLine )
|
if (!fFirstLine)
|
||||||
{
|
{
|
||||||
for( int j = 0; j < nOffset; j++ )
|
for (int j = 0; j < nOffset; j++)
|
||||||
sstr << _T(" ");
|
sstr << _T(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
// set width
|
// set width
|
||||||
sstr << std::setw( nWidth );
|
sstr << std::setw(nWidth);
|
||||||
|
|
||||||
// now add last string
|
// now add last string
|
||||||
sstr << strT;
|
sstr << strT;
|
||||||
|
|
||||||
return( sstr.str() );
|
return (sstr.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
//
|
//
|
||||||
// The developer of the original code and/or files is Tripwire, Inc.
|
// The developer of the original code and/or files is Tripwire, Inc.
|
||||||
// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire,
|
// Portions created by Tripwire, Inc. are copyright (C) 2000-2018 Tripwire,
|
||||||
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
||||||
// reserved.
|
// reserved.
|
||||||
//
|
//
|
||||||
// This program is free software. The contents of this file are subject
|
// 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
|
// 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
|
// Free Software Foundation; either version 2 of the License, or (at your
|
||||||
// option) any later version. You may redistribute it and/or modify it
|
// option) any later version. You may redistribute it and/or modify it
|
||||||
// only in compliance with the GNU General Public License.
|
// only in compliance with the GNU General Public License.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful.
|
// This program is distributed in the hope that it will be useful.
|
||||||
// However, this program is distributed AS-IS WITHOUT ANY
|
// However, this program is distributed AS-IS WITHOUT ANY
|
||||||
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
||||||
// for more details.
|
// for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
// USA.
|
// USA.
|
||||||
//
|
//
|
||||||
// Nothing in the GNU General Public License or any other license to use
|
// 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,
|
// the code or files shall permit you to use Tripwire's trademarks,
|
||||||
// service marks, or other intellectual property without Tripwire's
|
// service marks, or other intellectual property without Tripwire's
|
||||||
// prior written consent.
|
// prior written consent.
|
||||||
//
|
//
|
||||||
// If you have any questions, please contact Tripwire, Inc. at either
|
// If you have any questions, please contact Tripwire, Inc. at either
|
||||||
// info@tripwire.org or www.tripwire.org.
|
// info@tripwire.org or www.tripwire.org.
|
||||||
//
|
//
|
||||||
|
@ -41,7 +41,7 @@
|
||||||
class cDisplayUtil
|
class cDisplayUtil
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static TSTRING FormatMultiLineString( const TSTRING& str, int nOffset, int nWidth );
|
static TSTRING FormatMultiLineString(const TSTRING& str, int nOffset, int nWidth);
|
||||||
};
|
};
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -61,18 +61,18 @@ public:
|
||||||
//
|
//
|
||||||
// What happens is that you get output like:
|
// What happens is that you get output like:
|
||||||
// " First Line"
|
// " First Line"
|
||||||
// ^ ^^ ^
|
// ^ ^^ ^
|
||||||
// |--10 sp-||---15 width--|
|
// |--10 sp-||---15 width--|
|
||||||
// "Second Line"
|
// "Second Line"
|
||||||
// ^
|
// ^
|
||||||
// | 0 sp, 0 width
|
// | 0 sp, 0 width
|
||||||
//
|
//
|
||||||
// When you really wanted:
|
// When you really wanted:
|
||||||
// " First Line"
|
// " First Line"
|
||||||
// ^ ^^ ^
|
// ^ ^^ ^
|
||||||
// |--10 sp-||---15 width--|
|
// |--10 sp-||---15 width--|
|
||||||
// " Second Line"
|
// " Second Line"
|
||||||
// ^ ^^ ^
|
// ^ ^^ ^
|
||||||
// |--10 sp-||---15 width--|
|
// |--10 sp-||---15 width--|
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
@ -84,13 +84,13 @@ public:
|
||||||
// So you can output a multiline string and have each line be formatted
|
// So you can output a multiline string and have each line be formatted
|
||||||
// like the first one was.
|
// like the first one was.
|
||||||
//
|
//
|
||||||
// So, for the preceeding example,
|
// So, for the preceeding example,
|
||||||
//
|
//
|
||||||
// change:
|
// change:
|
||||||
// TCOUT << szTenSpaceMargin << setw(15) << szMessage;
|
// TCOUT << szTenSpaceMargin << setw(15) << szMessage;
|
||||||
//
|
//
|
||||||
// to:
|
// to:
|
||||||
// TCOUT << szTenSpaceMargin << setw(15)
|
// TCOUT << szTenSpaceMargin << setw(15)
|
||||||
// << cDisplayUtil::FormatMultiLineString( szMessage, 10, 15 );
|
// << cDisplayUtil::FormatMultiLineString( szMessage, 10, 15 );
|
||||||
//
|
//
|
||||||
// Comprende? It's crazy but it works.
|
// Comprende? It's crazy but it works.
|
||||||
|
@ -98,4 +98,3 @@ public:
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
||||||
#endif // #ifndef __DISPLAYUTIL_H
|
#endif // #ifndef __DISPLAYUTIL_H
|
||||||
|
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
//
|
//
|
||||||
// The developer of the original code and/or files is Tripwire, Inc.
|
// The developer of the original code and/or files is Tripwire, Inc.
|
||||||
// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire,
|
// Portions created by Tripwire, Inc. are copyright (C) 2000-2018 Tripwire,
|
||||||
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
||||||
// reserved.
|
// reserved.
|
||||||
//
|
//
|
||||||
// This program is free software. The contents of this file are subject
|
// 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
|
// 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
|
// Free Software Foundation; either version 2 of the License, or (at your
|
||||||
// option) any later version. You may redistribute it and/or modify it
|
// option) any later version. You may redistribute it and/or modify it
|
||||||
// only in compliance with the GNU General Public License.
|
// only in compliance with the GNU General Public License.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful.
|
// This program is distributed in the hope that it will be useful.
|
||||||
// However, this program is distributed AS-IS WITHOUT ANY
|
// However, this program is distributed AS-IS WITHOUT ANY
|
||||||
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
||||||
// for more details.
|
// for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
// USA.
|
// USA.
|
||||||
//
|
//
|
||||||
// Nothing in the GNU General Public License or any other license to use
|
// 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,
|
// the code or files shall permit you to use Tripwire's trademarks,
|
||||||
// service marks, or other intellectual property without Tripwire's
|
// service marks, or other intellectual property without Tripwire's
|
||||||
// prior written consent.
|
// prior written consent.
|
||||||
//
|
//
|
||||||
// If you have any questions, please contact Tripwire, Inc. at either
|
// If you have any questions, please contact Tripwire, Inc. at either
|
||||||
// info@tripwire.org or www.tripwire.org.
|
// info@tripwire.org or www.tripwire.org.
|
||||||
//
|
//
|
||||||
|
@ -49,9 +49,9 @@ bool CheckEpoch()
|
||||||
// Rather than crashing, we will exit with a nice message
|
// Rather than crashing, we will exit with a nice message
|
||||||
memset(&time_struct, 0, sizeof(time_struct));
|
memset(&time_struct, 0, sizeof(time_struct));
|
||||||
time_struct.tm_mday = 1;
|
time_struct.tm_mday = 1;
|
||||||
time_struct.tm_mon = 0;
|
time_struct.tm_mon = 0;
|
||||||
time_struct.tm_year = 138;
|
time_struct.tm_year = 138;
|
||||||
int64 endoftime = cTimeUtil::DateToTime( &time_struct );
|
int64 endoftime = cTimeUtil::DateToTime(&time_struct);
|
||||||
|
|
||||||
if (time(0) > endoftime)
|
if (time(0) > endoftime)
|
||||||
{
|
{
|
||||||
|
@ -64,4 +64,3 @@ bool CheckEpoch()
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
//
|
//
|
||||||
// The developer of the original code and/or files is Tripwire, Inc.
|
// The developer of the original code and/or files is Tripwire, Inc.
|
||||||
// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire,
|
// Portions created by Tripwire, Inc. are copyright (C) 2000-2018 Tripwire,
|
||||||
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
||||||
// reserved.
|
// reserved.
|
||||||
//
|
//
|
||||||
// This program is free software. The contents of this file are subject
|
// 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
|
// 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
|
// Free Software Foundation; either version 2 of the License, or (at your
|
||||||
// option) any later version. You may redistribute it and/or modify it
|
// option) any later version. You may redistribute it and/or modify it
|
||||||
// only in compliance with the GNU General Public License.
|
// only in compliance with the GNU General Public License.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful.
|
// This program is distributed in the hope that it will be useful.
|
||||||
// However, this program is distributed AS-IS WITHOUT ANY
|
// However, this program is distributed AS-IS WITHOUT ANY
|
||||||
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
||||||
// for more details.
|
// for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
// USA.
|
// USA.
|
||||||
//
|
//
|
||||||
// Nothing in the GNU General Public License or any other license to use
|
// 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,
|
// the code or files shall permit you to use Tripwire's trademarks,
|
||||||
// service marks, or other intellectual property without Tripwire's
|
// service marks, or other intellectual property without Tripwire's
|
||||||
// prior written consent.
|
// prior written consent.
|
||||||
//
|
//
|
||||||
// If you have any questions, please contact Tripwire, Inc. at either
|
// If you have any questions, please contact Tripwire, Inc. at either
|
||||||
// info@tripwire.org or www.tripwire.org.
|
// info@tripwire.org or www.tripwire.org.
|
||||||
//
|
//
|
||||||
|
@ -42,4 +42,3 @@
|
||||||
bool CheckEpoch();
|
bool CheckEpoch();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
//
|
//
|
||||||
// The developer of the original code and/or files is Tripwire, Inc.
|
// The developer of the original code and/or files is Tripwire, Inc.
|
||||||
// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire,
|
// Portions created by Tripwire, Inc. are copyright (C) 2000-2018 Tripwire,
|
||||||
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
||||||
// reserved.
|
// reserved.
|
||||||
//
|
//
|
||||||
// This program is free software. The contents of this file are subject
|
// 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
|
// 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
|
// Free Software Foundation; either version 2 of the License, or (at your
|
||||||
// option) any later version. You may redistribute it and/or modify it
|
// option) any later version. You may redistribute it and/or modify it
|
||||||
// only in compliance with the GNU General Public License.
|
// only in compliance with the GNU General Public License.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful.
|
// This program is distributed in the hope that it will be useful.
|
||||||
// However, this program is distributed AS-IS WITHOUT ANY
|
// However, this program is distributed AS-IS WITHOUT ANY
|
||||||
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
||||||
// for more details.
|
// for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
// USA.
|
// USA.
|
||||||
//
|
//
|
||||||
// Nothing in the GNU General Public License or any other license to use
|
// 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,
|
// the code or files shall permit you to use Tripwire's trademarks,
|
||||||
// service marks, or other intellectual property without Tripwire's
|
// service marks, or other intellectual property without Tripwire's
|
||||||
// prior written consent.
|
// prior written consent.
|
||||||
//
|
//
|
||||||
// If you have any questions, please contact Tripwire, Inc. at either
|
// If you have any questions, please contact Tripwire, Inc. at either
|
||||||
// info@tripwire.org or www.tripwire.org.
|
// info@tripwire.org or www.tripwire.org.
|
||||||
//
|
//
|
||||||
|
@ -39,13 +39,11 @@
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// CalcHash
|
// CalcHash
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
uint32 eError::CalcHash( const char* name )
|
uint32 eError::CalcHash(const char* name)
|
||||||
{
|
{
|
||||||
CRC_INFO crc;
|
CRC_INFO crc;
|
||||||
crcInit( crc );
|
crcInit(crc);
|
||||||
crcUpdate( crc, (const uint8*)name, strlen( name ) );
|
crcUpdate(crc, (const uint8*)name, strlen(name));
|
||||||
crcFinit( crc );
|
crcFinit(crc);
|
||||||
return crc.crc;
|
return crc.crc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
183
src/core/error.h
183
src/core/error.h
|
@ -1,31 +1,31 @@
|
||||||
//
|
//
|
||||||
// The developer of the original code and/or files is Tripwire, Inc.
|
// The developer of the original code and/or files is Tripwire, Inc.
|
||||||
// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire,
|
// Portions created by Tripwire, Inc. are copyright (C) 2000-2018 Tripwire,
|
||||||
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
||||||
// reserved.
|
// reserved.
|
||||||
//
|
//
|
||||||
// This program is free software. The contents of this file are subject
|
// 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
|
// 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
|
// Free Software Foundation; either version 2 of the License, or (at your
|
||||||
// option) any later version. You may redistribute it and/or modify it
|
// option) any later version. You may redistribute it and/or modify it
|
||||||
// only in compliance with the GNU General Public License.
|
// only in compliance with the GNU General Public License.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful.
|
// This program is distributed in the hope that it will be useful.
|
||||||
// However, this program is distributed AS-IS WITHOUT ANY
|
// However, this program is distributed AS-IS WITHOUT ANY
|
||||||
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
||||||
// for more details.
|
// for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
// USA.
|
// USA.
|
||||||
//
|
//
|
||||||
// Nothing in the GNU General Public License or any other license to use
|
// 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,
|
// the code or files shall permit you to use Tripwire's trademarks,
|
||||||
// service marks, or other intellectual property without Tripwire's
|
// service marks, or other intellectual property without Tripwire's
|
||||||
// prior written consent.
|
// prior written consent.
|
||||||
//
|
//
|
||||||
// If you have any questions, please contact Tripwire, Inc. at either
|
// If you have any questions, please contact Tripwire, Inc. at either
|
||||||
// info@tripwire.org or www.tripwire.org.
|
// info@tripwire.org or www.tripwire.org.
|
||||||
//
|
//
|
||||||
|
@ -42,14 +42,13 @@
|
||||||
class eError
|
class eError
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
// Construction and Assignment
|
// Construction and Assignment
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
eError( const TSTRING& msg, uint32 flags = 0 );
|
eError(const TSTRING& msg, uint32 flags = 0);
|
||||||
explicit eError( const eError& rhs );
|
explicit eError(const eError& rhs);
|
||||||
explicit eError();
|
explicit eError();
|
||||||
void operator=( const eError& rhs );
|
void operator=(const eError& rhs);
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
// Destruction
|
// Destruction
|
||||||
|
@ -60,54 +59,54 @@ public:
|
||||||
// Data Access
|
// Data Access
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
virtual uint32 GetID() const = 0;
|
virtual uint32 GetID() const = 0;
|
||||||
// returns a system wide unique identifier for this exception. See the
|
// returns a system wide unique identifier for this exception. See the
|
||||||
// macro below for the typical implementation of this method.
|
// macro below for the typical implementation of this method.
|
||||||
// This is used to associate the error with a string description of the
|
// This is used to associate the error with a string description of the
|
||||||
// error via the global error table.
|
// error via the global error table.
|
||||||
|
|
||||||
virtual TSTRING GetMsg() const;
|
virtual TSTRING GetMsg() const;
|
||||||
// returns specific information about the error that occured. Provides
|
// returns specific information about the error that occured. Provides
|
||||||
// additional information about the error described by GetID(). It should
|
// additional information about the error described by GetID(). It should
|
||||||
// not provide any information redundant with GetID().
|
// not provide any information redundant with GetID().
|
||||||
//
|
//
|
||||||
// The string passed to the constructor should be formated properly to
|
// The string passed to the constructor should be formated properly to
|
||||||
// be displayed as the "Second" part of an error message, or the derived
|
// be displayed as the "Second" part of an error message, or the derived
|
||||||
// class should override GetMsg() and return a string appropriate for display.
|
// class should override GetMsg() and return a string appropriate for display.
|
||||||
|
|
||||||
uint32 GetFlags() const;
|
uint32 GetFlags() const;
|
||||||
// Flags are defined below. Currently, these only have an impact on how errors are
|
// Flags are defined below. Currently, these only have an impact on how errors are
|
||||||
// displayed.
|
// displayed.
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
// Flags
|
// Flags
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
enum Flag
|
enum Flag
|
||||||
{
|
{
|
||||||
NON_FATAL = 0x00000001, // displays "Error" or "Warning" ?
|
NON_FATAL = 0x00000001, // displays "Error" or "Warning" ?
|
||||||
SUPRESS_THIRD_MSG = 0x00000002 // supresses the "continuing" or "exiting" message
|
SUPRESS_THIRD_MSG = 0x00000002 // supresses the "continuing" or "exiting" message
|
||||||
};
|
};
|
||||||
|
|
||||||
void SetFlags( uint32 flags );
|
void SetFlags(uint32 flags);
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
// Flag Convenience Methods
|
// Flag Convenience Methods
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
void SetFatality(bool fatal);
|
void SetFatality(bool fatal);
|
||||||
bool IsFatal() const;
|
bool IsFatal() const;
|
||||||
// Fatality is set to true by default when eError is constructed. But when an error
|
// Fatality is set to true by default when eError is constructed. But when an error
|
||||||
// it is put in an cErrorBucket chain it the code doing so may wish to set the fatality
|
// it is put in an cErrorBucket chain it the code doing so may wish to set the fatality
|
||||||
// to non-fatal to indicate that the error is actually a warning and program flow
|
// to non-fatal to indicate that the error is actually a warning and program flow
|
||||||
// is going to continue.
|
// is going to continue.
|
||||||
void SetSupressThird(bool supressThird);
|
void SetSupressThird(bool supressThird);
|
||||||
bool SupressThird() const;
|
bool SupressThird() const;
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
// Utility Methods
|
// Utility Methods
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
static uint32 CalcHash( const char* name );
|
static uint32 CalcHash(const char* name);
|
||||||
// calculates the CRC32 of the string passed in as name. This methods
|
// calculates the CRC32 of the string passed in as name. This methods
|
||||||
// asserts that name is non null. This is used to generate unique IDs
|
// asserts that name is non null. This is used to generate unique IDs
|
||||||
// for errors.
|
// for errors.
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
// Private Implementation
|
// Private Implementation
|
||||||
|
@ -124,62 +123,69 @@ protected:
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// TSS_BEGIN_EXCEPTION / TSS_END_EXCEPTION
|
// TSS_BEGIN_EXCEPTION / TSS_END_EXCEPTION
|
||||||
//
|
//
|
||||||
// Serves the same purpose as TSS_EXCEPTION but allows custom data and methods
|
// Serves the same purpose as TSS_EXCEPTION but allows custom data and methods
|
||||||
// to be added to the exception class.
|
// to be added to the exception class.
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#if HAVE_GCC
|
#if HAVE_GCC
|
||||||
#define TSS_BEGIN_EXCEPTION_EXPLICIT
|
# define TSS_BEGIN_EXCEPTION_EXPLICIT
|
||||||
#else
|
#else
|
||||||
#define TSS_BEGIN_EXCEPTION_EXPLICIT explicit
|
# define TSS_BEGIN_EXCEPTION_EXPLICIT explicit
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define TSS_BEGIN_EXCEPTION( except, base ) \
|
#define TSS_BEGIN_EXCEPTION(except, base) \
|
||||||
class except : public base \
|
class except : public base \
|
||||||
{\
|
{ \
|
||||||
public:\
|
public: \
|
||||||
except( const TSTRING& msg, uint32 flags = 0 ) \
|
except(const TSTRING& msg, uint32 flags = 0) : base(msg, flags) \
|
||||||
: base( msg, flags ) {} \
|
{ \
|
||||||
TSS_BEGIN_EXCEPTION_EXPLICIT except( const except& rhs ) \
|
} \
|
||||||
: base( rhs ) {} \
|
TSS_BEGIN_EXCEPTION_EXPLICIT except(const except& rhs) : base(rhs) \
|
||||||
explicit except() : base() {} \
|
{ \
|
||||||
\
|
} \
|
||||||
virtual uint32 GetID() const \
|
explicit except() : base() \
|
||||||
{\
|
{ \
|
||||||
return CalcHash( #except ); \
|
} \
|
||||||
}\
|
\
|
||||||
|
virtual uint32 GetID() const \
|
||||||
|
{ \
|
||||||
|
return CalcHash(#except); \
|
||||||
|
}
|
||||||
|
|
||||||
#define TSS_END_EXCEPTION( ) \
|
#define TSS_END_EXCEPTION() \
|
||||||
};
|
} \
|
||||||
|
;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// TSS_BEGIN_EXCEPTION_NO_CTOR
|
// TSS_BEGIN_EXCEPTION_NO_CTOR
|
||||||
//
|
//
|
||||||
// Same as TSS_BEGIN_EXCEPTION, but doesn't define any ctors.
|
// Same as TSS_BEGIN_EXCEPTION, but doesn't define any ctors.
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
#define TSS_BEGIN_EXCEPTION_NO_CTOR( except, base ) \
|
#define TSS_BEGIN_EXCEPTION_NO_CTOR(except, base) \
|
||||||
class except : public base \
|
class except : public base \
|
||||||
{\
|
{ \
|
||||||
public:\
|
public: \
|
||||||
explicit except() : base() {} \
|
explicit except() : base() \
|
||||||
\
|
{ \
|
||||||
virtual uint32 GetID() const \
|
} \
|
||||||
{\
|
\
|
||||||
return CalcHash( #except ); \
|
virtual uint32 GetID() const \
|
||||||
}\
|
{ \
|
||||||
|
return CalcHash(#except); \
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// TSS_EXCEPTION
|
// TSS_EXCEPTION
|
||||||
//
|
//
|
||||||
// This is a convenience define for quickly defining an exception class. After
|
// This is a convenience define for quickly defining an exception class. After
|
||||||
// defining a new exception, don't forget to add it to the package's error
|
// defining a new exception, don't forget to add it to the package's error
|
||||||
// string file!
|
// string file!
|
||||||
//
|
//
|
||||||
// TODO (mdb) -- do we want to cache the CRC? if we store it in a class static
|
// TODO (mdb) -- do we want to cache the CRC? if we store it in a class static
|
||||||
// variable, then we will need to define it in the cpp file as well ...
|
// variable, then we will need to define it in the cpp file as well ...
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
#define TSS_EXCEPTION( except, base ) \
|
#define TSS_EXCEPTION(except, base) \
|
||||||
TSS_BEGIN_EXCEPTION( except, base ) \
|
TSS_BEGIN_EXCEPTION(except, base) \
|
||||||
TSS_END_EXCEPTION()
|
TSS_END_EXCEPTION()
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -189,41 +195,32 @@ protected:
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// eError
|
// eError
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
inline eError::eError( const TSTRING& msg, uint32 flags )
|
inline eError::eError(const TSTRING& msg, uint32 flags) : mMsg(msg), mFlags(flags)
|
||||||
: mMsg ( msg ),
|
|
||||||
mFlags ( flags )
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// eError
|
// eError
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
inline eError::eError( const eError& rhs )
|
inline eError::eError(const eError& rhs) : mMsg(rhs.mMsg), mFlags(rhs.mFlags)
|
||||||
: mMsg ( rhs.mMsg ),
|
|
||||||
mFlags ( rhs.mFlags )
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// eError
|
// eError
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
inline eError::eError( )
|
inline eError::eError() : mMsg(_T("")), mFlags(0)
|
||||||
: mMsg ( _T("") ),
|
|
||||||
mFlags ( 0 )
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// operator=
|
// operator=
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
inline void eError::operator=( const eError& rhs )
|
inline void eError::operator=(const eError& rhs)
|
||||||
{
|
{
|
||||||
mMsg = rhs.mMsg;
|
mMsg = rhs.mMsg;
|
||||||
mFlags = rhs.mFlags;
|
mFlags = rhs.mFlags;
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -231,7 +228,6 @@ inline void eError::operator=( const eError& rhs )
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
inline eError::~eError()
|
inline eError::~eError()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -239,7 +235,7 @@ inline eError::~eError()
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
inline TSTRING eError::GetMsg() const
|
inline TSTRING eError::GetMsg() const
|
||||||
{
|
{
|
||||||
return mMsg;
|
return mMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -253,9 +249,9 @@ inline uint32 eError::GetFlags() const
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// SetFlags
|
// SetFlags
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
inline void eError::SetFlags( uint32 flags )
|
inline void eError::SetFlags(uint32 flags)
|
||||||
{
|
{
|
||||||
mFlags = flags;
|
mFlags = flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -275,7 +271,6 @@ inline void eError::SetFatality(bool fatal)
|
||||||
inline bool eError::IsFatal() const
|
inline bool eError::IsFatal() const
|
||||||
{
|
{
|
||||||
return (mFlags & (uint32)NON_FATAL) == 0;
|
return (mFlags & (uint32)NON_FATAL) == 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -298,6 +293,4 @@ inline bool eError::SupressThird() const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif //__ERROR_H
|
#endif //__ERROR_H
|
||||||
|
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
//
|
//
|
||||||
// The developer of the original code and/or files is Tripwire, Inc.
|
// The developer of the original code and/or files is Tripwire, Inc.
|
||||||
// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire,
|
// Portions created by Tripwire, Inc. are copyright (C) 2000-2018 Tripwire,
|
||||||
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
||||||
// reserved.
|
// reserved.
|
||||||
//
|
//
|
||||||
// This program is free software. The contents of this file are subject
|
// 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
|
// 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
|
// Free Software Foundation; either version 2 of the License, or (at your
|
||||||
// option) any later version. You may redistribute it and/or modify it
|
// option) any later version. You may redistribute it and/or modify it
|
||||||
// only in compliance with the GNU General Public License.
|
// only in compliance with the GNU General Public License.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful.
|
// This program is distributed in the hope that it will be useful.
|
||||||
// However, this program is distributed AS-IS WITHOUT ANY
|
// However, this program is distributed AS-IS WITHOUT ANY
|
||||||
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
||||||
// for more details.
|
// for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
// USA.
|
// USA.
|
||||||
//
|
//
|
||||||
// Nothing in the GNU General Public License or any other license to use
|
// 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,
|
// the code or files shall permit you to use Tripwire's trademarks,
|
||||||
// service marks, or other intellectual property without Tripwire's
|
// service marks, or other intellectual property without Tripwire's
|
||||||
// prior written consent.
|
// prior written consent.
|
||||||
//
|
//
|
||||||
// If you have any questions, please contact Tripwire, Inc. at either
|
// If you have any questions, please contact Tripwire, Inc. at either
|
||||||
// info@tripwire.org or www.tripwire.org.
|
// info@tripwire.org or www.tripwire.org.
|
||||||
//
|
//
|
||||||
|
@ -46,32 +46,34 @@
|
||||||
class eError;
|
class eError;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// cErrorBucket -- contains an interface that handles error reporting, and
|
// cErrorBucket -- contains an interface that handles error reporting, and
|
||||||
// contains a link to a child bucket. Each concrete implementation of the
|
// contains a link to a child bucket. Each concrete implementation of the
|
||||||
// cErrorBucket interface will perform its own specific task related to the
|
// cErrorBucket interface will perform its own specific task related to the
|
||||||
// error's occurence (print to stderr, store in a queue, etc) and then forward
|
// error's occurence (print to stderr, store in a queue, etc) and then forward
|
||||||
// the error on to its child link. The parent bucket does not own the destruction
|
// the error on to its child link. The parent bucket does not own the destruction
|
||||||
// of the pointer to the child bucket.
|
// of the pointer to the child bucket.
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
class cErrorBucket
|
class cErrorBucket
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
cErrorBucket();
|
cErrorBucket();
|
||||||
virtual ~cErrorBucket() {}
|
virtual ~cErrorBucket()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
virtual void AddError(const eError& error);
|
virtual void AddError(const eError& error);
|
||||||
// add an error to the bucket
|
// add an error to the bucket
|
||||||
|
|
||||||
cErrorBucket* GetChild();
|
cErrorBucket* GetChild();
|
||||||
// returns the bucket that the current bucket is chained to, or
|
// returns the bucket that the current bucket is chained to, or
|
||||||
// NULL if nothing is attached to it.
|
// NULL if nothing is attached to it.
|
||||||
cErrorBucket* SetChild(cErrorBucket* pNewChild);
|
cErrorBucket* SetChild(cErrorBucket* pNewChild);
|
||||||
// sets the child link of this bucket; returns the old link value
|
// sets the child link of this bucket; returns the old link value
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void HandleError(const eError& error) = 0;
|
virtual void HandleError(const eError& error) = 0;
|
||||||
// override this to implement error handling functionality specific to
|
// override this to implement error handling functionality specific to
|
||||||
// the derived class
|
// the derived class
|
||||||
cErrorBucket* mpChild;
|
cErrorBucket* mpChild;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -81,8 +83,7 @@ protected:
|
||||||
///////////////////
|
///////////////////
|
||||||
// cErrorBucket
|
// cErrorBucket
|
||||||
///////////////////
|
///////////////////
|
||||||
inline cErrorBucket::cErrorBucket() :
|
inline cErrorBucket::cErrorBucket() : mpChild(0)
|
||||||
mpChild(0)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,9 +95,8 @@ inline cErrorBucket* cErrorBucket::GetChild()
|
||||||
inline cErrorBucket* cErrorBucket::SetChild(cErrorBucket* pNewChild)
|
inline cErrorBucket* cErrorBucket::SetChild(cErrorBucket* pNewChild)
|
||||||
{
|
{
|
||||||
cErrorBucket* pOldChild = mpChild;
|
cErrorBucket* pOldChild = mpChild;
|
||||||
mpChild = pNewChild;
|
mpChild = pNewChild;
|
||||||
return pOldChild;
|
return pOldChild;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
//
|
//
|
||||||
// The developer of the original code and/or files is Tripwire, Inc.
|
// The developer of the original code and/or files is Tripwire, Inc.
|
||||||
// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire,
|
// Portions created by Tripwire, Inc. are copyright (C) 2000-2018 Tripwire,
|
||||||
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
||||||
// reserved.
|
// reserved.
|
||||||
//
|
//
|
||||||
// This program is free software. The contents of this file are subject
|
// 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
|
// 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
|
// Free Software Foundation; either version 2 of the License, or (at your
|
||||||
// option) any later version. You may redistribute it and/or modify it
|
// option) any later version. You may redistribute it and/or modify it
|
||||||
// only in compliance with the GNU General Public License.
|
// only in compliance with the GNU General Public License.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful.
|
// This program is distributed in the hope that it will be useful.
|
||||||
// However, this program is distributed AS-IS WITHOUT ANY
|
// However, this program is distributed AS-IS WITHOUT ANY
|
||||||
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
||||||
// for more details.
|
// for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
// USA.
|
// USA.
|
||||||
//
|
//
|
||||||
// Nothing in the GNU General Public License or any other license to use
|
// 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,
|
// the code or files shall permit you to use Tripwire's trademarks,
|
||||||
// service marks, or other intellectual property without Tripwire's
|
// service marks, or other intellectual property without Tripwire's
|
||||||
// prior written consent.
|
// prior written consent.
|
||||||
//
|
//
|
||||||
// If you have any questions, please contact Tripwire, Inc. at either
|
// If you have any questions, please contact Tripwire, Inc. at either
|
||||||
// info@tripwire.org or www.tripwire.org.
|
// info@tripwire.org or www.tripwire.org.
|
||||||
//
|
//
|
||||||
|
@ -43,7 +43,7 @@
|
||||||
void cErrorBucket::AddError(const eError& error)
|
void cErrorBucket::AddError(const eError& error)
|
||||||
{
|
{
|
||||||
HandleError(error);
|
HandleError(error);
|
||||||
if(mpChild)
|
if (mpChild)
|
||||||
mpChild->AddError(error);
|
mpChild->AddError(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,10 +52,8 @@ void cErrorBucket::AddError(const eError& error)
|
||||||
//#############################################################################
|
//#############################################################################
|
||||||
void cErrorReporter::PrintErrorMsg(const eError& error, const TSTRING& strExtra)
|
void cErrorReporter::PrintErrorMsg(const eError& error, const TSTRING& strExtra)
|
||||||
{
|
{
|
||||||
cDisplayEncoder e(
|
cDisplayEncoder e((cDisplayEncoder::Flags)(cDisplayEncoder::NON_ROUNDTRIP | cDisplayEncoder::ALLOW_WHITESPACE));
|
||||||
(cDisplayEncoder::Flags) ( cDisplayEncoder::NON_ROUNDTRIP |
|
TSTRING errStr;
|
||||||
cDisplayEncoder::ALLOW_WHITESPACE ) );
|
|
||||||
TSTRING errStr;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// if the ID is zero, just return.
|
// if the ID is zero, just return.
|
||||||
|
@ -68,19 +66,18 @@ void cErrorReporter::PrintErrorMsg(const eError& error, const TSTRING& strExtra)
|
||||||
// point is when we throw ePoly() with no constructor arguments. At some point we want
|
// point is when we throw ePoly() with no constructor arguments. At some point we want
|
||||||
// to stop using the mechanism have non-printing errors, thus we leave in the ASSERT below.
|
// to stop using the mechanism have non-printing errors, thus we leave in the ASSERT below.
|
||||||
// But we don't want to break any release code, thus we return on the next line - June 2, 1999 DMB.
|
// But we don't want to break any release code, thus we return on the next line - June 2, 1999 DMB.
|
||||||
ASSERT( error.GetID() != 0 );
|
ASSERT(error.GetID() != 0);
|
||||||
|
|
||||||
if( error.GetID() == 0 )
|
if (error.GetID() == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// "First Part" header
|
// "First Part" header
|
||||||
errStr = TSS_GetString( cCore, error.IsFatal() ? core::STR_ERROR_ERROR
|
errStr = TSS_GetString(cCore, error.IsFatal() ? core::STR_ERROR_ERROR : core::STR_ERROR_WARNING);
|
||||||
: core::STR_ERROR_WARNING );
|
|
||||||
|
|
||||||
if (errStr.empty())
|
if (errStr.empty())
|
||||||
{
|
{
|
||||||
TOSTRINGSTREAM strm;
|
TOSTRINGSTREAM strm;
|
||||||
ASSERT( sizeof( uint32 ) == sizeof(unsigned int) ); // for cast on next line
|
ASSERT(sizeof(uint32) == sizeof(unsigned int)); // for cast on next line
|
||||||
strm << _T("Unknown Error ID ") << (unsigned int)error.GetID();
|
strm << _T("Unknown Error ID ") << (unsigned int)error.GetID();
|
||||||
errStr = strm.str();
|
errStr = strm.str();
|
||||||
}
|
}
|
||||||
|
@ -91,10 +88,10 @@ void cErrorReporter::PrintErrorMsg(const eError& error, const TSTRING& strExtra)
|
||||||
// "First Part" error string
|
// "First Part" error string
|
||||||
TSTRING prependToSecond;
|
TSTRING prependToSecond;
|
||||||
|
|
||||||
// #pragma message("errorbucketimpl.cpp needs a little help in the mb arena, with the findfirst/last and such")
|
// #pragma message("errorbucketimpl.cpp needs a little help in the mb arena, with the findfirst/last and such")
|
||||||
|
|
||||||
errStr = cErrorTable::GetInstance()->Get( error.GetID() );
|
errStr = cErrorTable::GetInstance()->Get(error.GetID());
|
||||||
if(! errStr.empty())
|
if (!errStr.empty())
|
||||||
{
|
{
|
||||||
// If the first part has a '\n' in it, we take everything following and prepend it to the
|
// If the first part has a '\n' in it, we take everything following and prepend it to the
|
||||||
// second part. This was added to allow specifing a verbose string as the second part
|
// second part. This was added to allow specifing a verbose string as the second part
|
||||||
|
@ -108,7 +105,7 @@ void cErrorReporter::PrintErrorMsg(const eError& error, const TSTRING& strExtra)
|
||||||
|
|
||||||
ASSERT(errStr.length() + len + 6 < 80); // line too big for terminal?
|
ASSERT(errStr.length() + len + 6 < 80); // line too big for terminal?
|
||||||
// Add 6 to account for "### ' and ': '
|
// Add 6 to account for "### ' and ': '
|
||||||
TCERR << TSS_GetString( cCore, core::STR_ERROR_COLON ) << _T(" ") << errStr;
|
TCERR << TSS_GetString(cCore, core::STR_ERROR_COLON) << _T(" ") << errStr;
|
||||||
TCERR << std::endl;
|
TCERR << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,14 +114,14 @@ void cErrorReporter::PrintErrorMsg(const eError& error, const TSTRING& strExtra)
|
||||||
const TCHAR SPACE = _T(' ');
|
const TCHAR SPACE = _T(' ');
|
||||||
|
|
||||||
errStr = prependToSecond + error.GetMsg() + strExtra;
|
errStr = prependToSecond + error.GetMsg() + strExtra;
|
||||||
e.Encode( errStr );
|
e.Encode(errStr);
|
||||||
if (! errStr.empty())
|
if (!errStr.empty())
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
// look for newline chars
|
// look for newline chars
|
||||||
TSTRING::size_type firstNewLine;
|
TSTRING::size_type firstNewLine;
|
||||||
TSTRING currentStr = errStr.substr(0, (firstNewLine = errStr.find_first_of(_T('\n'))));
|
TSTRING currentStr = errStr.substr(0, (firstNewLine = errStr.find_first_of(_T('\n'))));
|
||||||
errStr.erase(0, (firstNewLine < errStr.length() ? firstNewLine + 1 : firstNewLine));
|
errStr.erase(0, (firstNewLine < errStr.length() ? firstNewLine + 1 : firstNewLine));
|
||||||
|
|
||||||
// break up the error string in case it is larger than screen width
|
// break up the error string in case it is larger than screen width
|
||||||
|
@ -132,11 +129,12 @@ void cErrorReporter::PrintErrorMsg(const eError& error, const TSTRING& strExtra)
|
||||||
{
|
{
|
||||||
if (currentStr.length() <= (unsigned int)WIDTH)
|
if (currentStr.length() <= (unsigned int)WIDTH)
|
||||||
{
|
{
|
||||||
TCERR << TSS_GetString( cCore, core::STR_ERROR_HEADER ) << currentStr << std::endl;
|
TCERR << TSS_GetString(cCore, core::STR_ERROR_HEADER) << currentStr << std::endl;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
TSTRING::size_type lastSpace = currentStr.find_last_of(SPACE, currentStr.length() >= WIDTH - 1 ? WIDTH - 1 : TSTRING::npos);
|
TSTRING::size_type lastSpace =
|
||||||
|
currentStr.find_last_of(SPACE, currentStr.length() >= WIDTH - 1 ? WIDTH - 1 : TSTRING::npos);
|
||||||
if (lastSpace == TSTRING::npos)
|
if (lastSpace == TSTRING::npos)
|
||||||
{
|
{
|
||||||
// can't find space to break at so this string will just have to be longer than screen width.
|
// can't find space to break at so this string will just have to be longer than screen width.
|
||||||
|
@ -148,28 +146,21 @@ void cErrorReporter::PrintErrorMsg(const eError& error, const TSTRING& strExtra)
|
||||||
lastSpace = currentStr.length();
|
lastSpace = currentStr.length();
|
||||||
}
|
}
|
||||||
|
|
||||||
TCERR << TSS_GetString( cCore, core::STR_ERROR_HEADER )
|
TCERR << TSS_GetString(cCore, core::STR_ERROR_HEADER) << currentStr.substr(0, lastSpace) << std::endl;
|
||||||
<< currentStr.substr( 0, lastSpace )
|
|
||||||
<< std::endl;
|
|
||||||
|
|
||||||
currentStr.erase( 0, lastSpace + 1 );
|
currentStr.erase(0, lastSpace + 1);
|
||||||
}
|
} while (!currentStr.empty());
|
||||||
while ( !currentStr.empty() );
|
} while (!errStr.empty());
|
||||||
}
|
|
||||||
while ( !errStr.empty() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// "Third Part" print 'exiting' or 'continuing'
|
// "Third Part" print 'exiting' or 'continuing'
|
||||||
// note that we supress this part if the appropriate flag is set...
|
// note that we supress this part if the appropriate flag is set...
|
||||||
//
|
//
|
||||||
if( (error.GetFlags() & eError::SUPRESS_THIRD_MSG) == 0 )
|
if ((error.GetFlags() & eError::SUPRESS_THIRD_MSG) == 0)
|
||||||
{
|
{
|
||||||
TCERR << TSS_GetString( cCore, core::STR_ERROR_HEADER)
|
TCERR << TSS_GetString(cCore, core::STR_ERROR_HEADER)
|
||||||
<< TSS_GetString(
|
<< TSS_GetString(cCore, error.IsFatal() ? core::STR_ERROR_EXITING : core::STR_ERROR_CONTINUING)
|
||||||
cCore,
|
<< std::endl;
|
||||||
error.IsFatal()
|
|
||||||
? core::STR_ERROR_EXITING
|
|
||||||
: core::STR_ERROR_CONTINUING ) << std::endl;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,9 +176,7 @@ void cErrorTracer::HandleError(const eError& error)
|
||||||
{
|
{
|
||||||
cDebug d("cErrorTracer::HandleError");
|
cDebug d("cErrorTracer::HandleError");
|
||||||
|
|
||||||
d.TraceError( _T("%s : %s\n"),
|
d.TraceError(_T("%s : %s\n"), cErrorTable::GetInstance()->Get(error.GetID()).c_str(), error.GetMsg().c_str());
|
||||||
cErrorTable::GetInstance()->Get( error.GetID() ).c_str(),
|
|
||||||
error.GetMsg().c_str() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//#############################################################################
|
//#############################################################################
|
||||||
|
@ -207,17 +196,15 @@ int cErrorQueue::GetNumErrors() const
|
||||||
|
|
||||||
void cErrorQueue::HandleError(const eError& error)
|
void cErrorQueue::HandleError(const eError& error)
|
||||||
{
|
{
|
||||||
mList.push_back( ePoly( error ) );
|
mList.push_back(ePoly(error));
|
||||||
}
|
}
|
||||||
|
|
||||||
cErrorQueueIter::cErrorQueueIter(cErrorQueue& queue) :
|
cErrorQueueIter::cErrorQueueIter(cErrorQueue& queue) : mList(queue.mList)
|
||||||
mList(queue.mList)
|
|
||||||
{
|
{
|
||||||
SeekBegin();
|
SeekBegin();
|
||||||
}
|
}
|
||||||
|
|
||||||
cErrorQueueIter::cErrorQueueIter(const cErrorQueue& queue)
|
cErrorQueueIter::cErrorQueueIter(const cErrorQueue& queue) : mList(((cErrorQueue*)&queue)->mList)
|
||||||
: mList( ((cErrorQueue*)&queue)->mList )
|
|
||||||
{
|
{
|
||||||
SeekBegin();
|
SeekBegin();
|
||||||
}
|
}
|
||||||
|
@ -240,7 +227,7 @@ bool cErrorQueueIter::Done() const
|
||||||
|
|
||||||
const ePoly& cErrorQueueIter::GetError() const
|
const ePoly& cErrorQueueIter::GetError() const
|
||||||
{
|
{
|
||||||
ASSERT(! Done());
|
ASSERT(!Done());
|
||||||
return (*mIter);
|
return (*mIter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -255,19 +242,18 @@ void cErrorQueue::Read(iSerializer* pSerializer, int32 version)
|
||||||
int32 size;
|
int32 size;
|
||||||
mList.clear();
|
mList.clear();
|
||||||
pSerializer->ReadInt32(size);
|
pSerializer->ReadInt32(size);
|
||||||
for(int i = 0; i < size; ++i)
|
for (int i = 0; i < size; ++i)
|
||||||
{
|
{
|
||||||
int32 errorNumber;
|
int32 errorNumber;
|
||||||
TSTRING errorString;
|
TSTRING errorString;
|
||||||
int32 flags;
|
int32 flags;
|
||||||
|
|
||||||
pSerializer->ReadInt32 (errorNumber);
|
pSerializer->ReadInt32(errorNumber);
|
||||||
pSerializer->ReadString (errorString);
|
pSerializer->ReadString(errorString);
|
||||||
pSerializer->ReadInt32 (flags);
|
pSerializer->ReadInt32(flags);
|
||||||
|
|
||||||
mList.push_back( ePoly( errorNumber, errorString, flags ) );
|
mList.push_back(ePoly(errorNumber, errorString, flags));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -277,13 +263,12 @@ void cErrorQueue::Write(iSerializer* pSerializer) const
|
||||||
{
|
{
|
||||||
pSerializer->WriteInt32(mList.size());
|
pSerializer->WriteInt32(mList.size());
|
||||||
ListType::const_iterator i;
|
ListType::const_iterator i;
|
||||||
for( i = mList.begin(); i != mList.end(); ++i)
|
for (i = mList.begin(); i != mList.end(); ++i)
|
||||||
{
|
{
|
||||||
pSerializer->WriteInt32 ((*i).GetID());
|
pSerializer->WriteInt32((*i).GetID());
|
||||||
pSerializer->WriteString((*i).GetMsg());
|
pSerializer->WriteString((*i).GetMsg());
|
||||||
pSerializer->WriteInt32 ((*i).GetFlags());
|
pSerializer->WriteInt32((*i).GetFlags());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -292,15 +277,14 @@ void cErrorQueue::Write(iSerializer* pSerializer) const
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
void cErrorQueue::TraceContents(int dl) const
|
void cErrorQueue::TraceContents(int dl) const
|
||||||
{
|
{
|
||||||
if(dl < 0)
|
if (dl < 0)
|
||||||
dl = cDebug::D_DEBUG;
|
dl = cDebug::D_DEBUG;
|
||||||
|
|
||||||
cDebug d("cFCOErrorQueue::TraceContents");
|
cDebug d("cFCOErrorQueue::TraceContents");
|
||||||
ListType::const_iterator i;
|
ListType::const_iterator i;
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
for(i = mList.begin(); i != mList.end(); i++, counter++)
|
for (i = mList.begin(); i != mList.end(); i++, counter++)
|
||||||
{
|
{
|
||||||
d.Trace(dl, _T("Error[%d]: num = %x string = %s\n") , counter, (*i).GetID(), (*i).GetMsg().c_str());
|
d.Trace(dl, _T("Error[%d]: num = %x string = %s\n"), counter, (*i).GetID(), (*i).GetMsg().c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,37 +1,37 @@
|
||||||
//
|
//
|
||||||
// The developer of the original code and/or files is Tripwire, Inc.
|
// The developer of the original code and/or files is Tripwire, Inc.
|
||||||
// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire,
|
// Portions created by Tripwire, Inc. are copyright (C) 2000-2018 Tripwire,
|
||||||
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
||||||
// reserved.
|
// reserved.
|
||||||
//
|
//
|
||||||
// This program is free software. The contents of this file are subject
|
// 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
|
// 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
|
// Free Software Foundation; either version 2 of the License, or (at your
|
||||||
// option) any later version. You may redistribute it and/or modify it
|
// option) any later version. You may redistribute it and/or modify it
|
||||||
// only in compliance with the GNU General Public License.
|
// only in compliance with the GNU General Public License.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful.
|
// This program is distributed in the hope that it will be useful.
|
||||||
// However, this program is distributed AS-IS WITHOUT ANY
|
// However, this program is distributed AS-IS WITHOUT ANY
|
||||||
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
||||||
// for more details.
|
// for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
// USA.
|
// USA.
|
||||||
//
|
//
|
||||||
// Nothing in the GNU General Public License or any other license to use
|
// 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,
|
// the code or files shall permit you to use Tripwire's trademarks,
|
||||||
// service marks, or other intellectual property without Tripwire's
|
// service marks, or other intellectual property without Tripwire's
|
||||||
// prior written consent.
|
// prior written consent.
|
||||||
//
|
//
|
||||||
// If you have any questions, please contact Tripwire, Inc. at either
|
// If you have any questions, please contact Tripwire, Inc. at either
|
||||||
// info@tripwire.org or www.tripwire.org.
|
// info@tripwire.org or www.tripwire.org.
|
||||||
//
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// errorbucketimpl.h
|
// errorbucketimpl.h
|
||||||
//
|
//
|
||||||
// This component contains classes derived from cErrorBucket and helper classes.
|
// This component contains classes derived from cErrorBucket and helper classes.
|
||||||
// They were broken out of errorbucket.h becuase many components will only need to
|
// They were broken out of errorbucket.h becuase many components will only need to
|
||||||
// know about cErrorBucket, so we reduce system dependencies by keeping these classes
|
// know about cErrorBucket, so we reduce system dependencies by keeping these classes
|
||||||
|
@ -60,22 +60,22 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////
|
||||||
// cErrorReporter -- sends all error messages to
|
// cErrorReporter -- sends all error messages to
|
||||||
// stderr
|
// stderr
|
||||||
//////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////
|
||||||
class cErrorReporter : public cErrorBucket
|
class cErrorReporter : public cErrorBucket
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void PrintErrorMsg(const eError& error, const TSTRING& strExtra = _T(""));
|
static void PrintErrorMsg(const eError& error, const TSTRING& strExtra = _T(""));
|
||||||
// function that HandleError() uses to print the error messages to stderr.
|
// function that HandleError() uses to print the error messages to stderr.
|
||||||
// this function uses the current authoritative format for error reporting, so
|
// this function uses the current authoritative format for error reporting, so
|
||||||
// other functions needing to display errors to the user should use this.
|
// other functions needing to display errors to the user should use this.
|
||||||
//
|
//
|
||||||
|
|
||||||
// NOTE:bam 5/7/99 -- I don't think the below is true anymore?
|
// NOTE:bam 5/7/99 -- I don't think the below is true anymore?
|
||||||
// NOTE:mdb -- if the error has an ID of zero, nothing will be printed. This
|
// NOTE:mdb -- if the error has an ID of zero, nothing will be printed. This
|
||||||
// is a way to throw a fatal error where the error reporting has already
|
// is a way to throw a fatal error where the error reporting has already
|
||||||
// occurred.
|
// occurred.
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void HandleError(const eError& error);
|
virtual void HandleError(const eError& error);
|
||||||
|
@ -100,17 +100,18 @@ protected:
|
||||||
class cErrorQueue : public cErrorBucket, public iTypedSerializable
|
class cErrorQueue : public cErrorBucket, public iTypedSerializable
|
||||||
{
|
{
|
||||||
friend class cErrorQueueIter;
|
friend class cErrorQueueIter;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void Clear();
|
void Clear();
|
||||||
// remove all errors from the queue
|
// remove all errors from the queue
|
||||||
int GetNumErrors() const;
|
int GetNumErrors() const;
|
||||||
// returns how many errors are in the queue
|
// returns how many errors are in the queue
|
||||||
|
|
||||||
//
|
//
|
||||||
// iSerializable interface
|
// iSerializable interface
|
||||||
//
|
//
|
||||||
virtual void Read (iSerializer* pSerializer, int32 version = 0); // throw (eSerializer, eArchive)
|
virtual void Read(iSerializer* pSerializer, int32 version = 0); // throw (eSerializer, eArchive)
|
||||||
virtual void Write(iSerializer* pSerializer) const; // throw (eSerializer, eArchive)
|
virtual void Write(iSerializer* pSerializer) const; // throw (eSerializer, eArchive)
|
||||||
|
|
||||||
//
|
//
|
||||||
// Debugging
|
// Debugging
|
||||||
|
@ -119,9 +120,10 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void HandleError(const eError& error);
|
virtual void HandleError(const eError& error);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef std::list<ePoly> ListType;
|
typedef std::list<ePoly> ListType;
|
||||||
ListType mList;
|
ListType mList;
|
||||||
|
|
||||||
DECLARE_TYPEDSERIALIZABLE()
|
DECLARE_TYPEDSERIALIZABLE()
|
||||||
};
|
};
|
||||||
|
@ -131,7 +133,9 @@ class cErrorQueueIter
|
||||||
public:
|
public:
|
||||||
cErrorQueueIter(cErrorQueue& queue);
|
cErrorQueueIter(cErrorQueue& queue);
|
||||||
cErrorQueueIter(const cErrorQueue& queue);
|
cErrorQueueIter(const cErrorQueue& queue);
|
||||||
~cErrorQueueIter() {}
|
~cErrorQueueIter()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
// iteration methods
|
// iteration methods
|
||||||
void SeekBegin();
|
void SeekBegin();
|
||||||
|
@ -139,9 +143,9 @@ public:
|
||||||
bool Done() const;
|
bool Done() const;
|
||||||
|
|
||||||
// access to the error
|
// access to the error
|
||||||
const ePoly& GetError() const;
|
const ePoly& GetError() const;
|
||||||
// both of these return results are undefined if the iterator
|
// both of these return results are undefined if the iterator
|
||||||
// is not valid (ie - IsDone() == true)
|
// is not valid (ie - IsDone() == true)
|
||||||
private:
|
private:
|
||||||
cErrorQueue::ListType& mList;
|
cErrorQueue::ListType& mList;
|
||||||
cErrorQueue::ListType::iterator mIter;
|
cErrorQueue::ListType::iterator mIter;
|
||||||
|
@ -153,9 +157,14 @@ private:
|
||||||
//////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////
|
||||||
class cErrorBucketNull : public cErrorBucket
|
class cErrorBucketNull : public cErrorBucket
|
||||||
{
|
{
|
||||||
virtual void AddError(const eError& ) {}
|
virtual void AddError(const eError&)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void HandleError(const eError& ) {}
|
virtual void HandleError(const eError&)
|
||||||
|
{
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////
|
||||||
|
@ -165,10 +174,10 @@ protected:
|
||||||
class cErrorBucketPassThru : public cErrorBucket
|
class cErrorBucketPassThru : public cErrorBucket
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
virtual void HandleError(const eError& ) {}
|
virtual void HandleError(const eError&)
|
||||||
|
{
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1,36 +1,36 @@
|
||||||
//
|
//
|
||||||
// The developer of the original code and/or files is Tripwire, Inc.
|
// The developer of the original code and/or files is Tripwire, Inc.
|
||||||
// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire,
|
// Portions created by Tripwire, Inc. are copyright (C) 2000-2018 Tripwire,
|
||||||
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
||||||
// reserved.
|
// reserved.
|
||||||
//
|
//
|
||||||
// This program is free software. The contents of this file are subject
|
// 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
|
// 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
|
// Free Software Foundation; either version 2 of the License, or (at your
|
||||||
// option) any later version. You may redistribute it and/or modify it
|
// option) any later version. You may redistribute it and/or modify it
|
||||||
// only in compliance with the GNU General Public License.
|
// only in compliance with the GNU General Public License.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful.
|
// This program is distributed in the hope that it will be useful.
|
||||||
// However, this program is distributed AS-IS WITHOUT ANY
|
// However, this program is distributed AS-IS WITHOUT ANY
|
||||||
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
||||||
// for more details.
|
// for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
// USA.
|
// USA.
|
||||||
//
|
//
|
||||||
// Nothing in the GNU General Public License or any other license to use
|
// 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,
|
// the code or files shall permit you to use Tripwire's trademarks,
|
||||||
// service marks, or other intellectual property without Tripwire's
|
// service marks, or other intellectual property without Tripwire's
|
||||||
// prior written consent.
|
// prior written consent.
|
||||||
//
|
//
|
||||||
// If you have any questions, please contact Tripwire, Inc. at either
|
// If you have any questions, please contact Tripwire, Inc. at either
|
||||||
// info@tripwire.org or www.tripwire.org.
|
// info@tripwire.org or www.tripwire.org.
|
||||||
//
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// errorgeneral.h --
|
// errorgeneral.h --
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef __ERRORGENERAL_H
|
#ifndef __ERRORGENERAL_H
|
||||||
|
@ -38,12 +38,11 @@
|
||||||
|
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
|
||||||
TSS_EXCEPTION( eErrorGeneral, eError );
|
TSS_EXCEPTION(eErrorGeneral, eError);
|
||||||
TSS_EXCEPTION( eOpen, eErrorGeneral );
|
TSS_EXCEPTION(eOpen, eErrorGeneral);
|
||||||
TSS_EXCEPTION( eOpenRead, eErrorGeneral );
|
TSS_EXCEPTION(eOpenRead, eErrorGeneral);
|
||||||
TSS_EXCEPTION( eOpenWrite, eErrorGeneral );
|
TSS_EXCEPTION(eOpenWrite, eErrorGeneral);
|
||||||
TSS_EXCEPTION( eBadCmdLine, eErrorGeneral );
|
TSS_EXCEPTION(eBadCmdLine, eErrorGeneral);
|
||||||
TSS_EXCEPTION( eBadModeSwitch, eErrorGeneral );
|
TSS_EXCEPTION(eBadModeSwitch, eErrorGeneral);
|
||||||
|
|
||||||
#endif //#ifndef __ERRORGENERAL_H
|
#endif //#ifndef __ERRORGENERAL_H
|
||||||
|
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
//
|
//
|
||||||
// The developer of the original code and/or files is Tripwire, Inc.
|
// The developer of the original code and/or files is Tripwire, Inc.
|
||||||
// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire,
|
// Portions created by Tripwire, Inc. are copyright (C) 2000-2018 Tripwire,
|
||||||
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
||||||
// reserved.
|
// reserved.
|
||||||
//
|
//
|
||||||
// This program is free software. The contents of this file are subject
|
// 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
|
// 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
|
// Free Software Foundation; either version 2 of the License, or (at your
|
||||||
// option) any later version. You may redistribute it and/or modify it
|
// option) any later version. You may redistribute it and/or modify it
|
||||||
// only in compliance with the GNU General Public License.
|
// only in compliance with the GNU General Public License.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful.
|
// This program is distributed in the hope that it will be useful.
|
||||||
// However, this program is distributed AS-IS WITHOUT ANY
|
// However, this program is distributed AS-IS WITHOUT ANY
|
||||||
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
||||||
// for more details.
|
// for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
// USA.
|
// USA.
|
||||||
//
|
//
|
||||||
// Nothing in the GNU General Public License or any other license to use
|
// 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,
|
// the code or files shall permit you to use Tripwire's trademarks,
|
||||||
// service marks, or other intellectual property without Tripwire's
|
// service marks, or other intellectual property without Tripwire's
|
||||||
// prior written consent.
|
// prior written consent.
|
||||||
//
|
//
|
||||||
// If you have any questions, please contact Tripwire, Inc. at either
|
// If you have any questions, please contact Tripwire, Inc. at either
|
||||||
// info@tripwire.org or www.tripwire.org.
|
// info@tripwire.org or www.tripwire.org.
|
||||||
//
|
//
|
||||||
|
@ -64,18 +64,18 @@ void cErrorTable::AssertMsgValidity(const TCHAR* msg)
|
||||||
if (errSize == TSTRING::npos)
|
if (errSize == TSTRING::npos)
|
||||||
errSize = errStr.length();
|
errSize = errStr.length();
|
||||||
|
|
||||||
#if 0 //TODO: Figure out how to do this properly.
|
# if 0 //TODO: Figure out how to do this properly.
|
||||||
TSTRING::size_type errorSize = TSS_GetString( cCore, core::STR_ERROR_ERROR ).length();
|
TSTRING::size_type errorSize = TSS_GetString( cCore, core::STR_ERROR_ERROR ).length();
|
||||||
TSTRING::size_type warningSize = TSS_GetString( cCore, core::STR_ERROR_WARNING ).length();
|
TSTRING::size_type warningSize = TSS_GetString( cCore, core::STR_ERROR_WARNING ).length();
|
||||||
TSTRING::size_type maxHeaderSize = (errorSize > warningSize ? errorSize : warningSize) + 6; // Add 6 to account for "### ' and ': '
|
TSTRING::size_type maxHeaderSize = (errorSize > warningSize ? errorSize : warningSize) + 6; // Add 6 to account for "### ' and ': '
|
||||||
#else
|
# else
|
||||||
// Sunpro got stuck in an infinite loop when we called GetString from this func;
|
// Sunpro got stuck in an infinite loop when we called GetString from this func;
|
||||||
TSTRING::size_type errorSize = 9;
|
TSTRING::size_type errorSize = 9;
|
||||||
TSTRING::size_type warningSize = 10;
|
TSTRING::size_type warningSize = 10;
|
||||||
TSTRING::size_type maxHeaderSize = (errorSize > warningSize ? errorSize : warningSize) + 6; // Add 6 to account for "### ' and ': '
|
TSTRING::size_type maxHeaderSize =
|
||||||
#endif
|
(errorSize > warningSize ? errorSize : warningSize) + 6; // Add 6 to account for "### ' and ': '
|
||||||
|
# endif
|
||||||
|
|
||||||
ASSERT(maxHeaderSize + errSize < 80);
|
ASSERT(maxHeaderSize + errSize < 80);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
//
|
//
|
||||||
// The developer of the original code and/or files is Tripwire, Inc.
|
// The developer of the original code and/or files is Tripwire, Inc.
|
||||||
// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire,
|
// Portions created by Tripwire, Inc. are copyright (C) 2000-2018 Tripwire,
|
||||||
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
||||||
// reserved.
|
// reserved.
|
||||||
//
|
//
|
||||||
// This program is free software. The contents of this file are subject
|
// 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
|
// 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
|
// Free Software Foundation; either version 2 of the License, or (at your
|
||||||
// option) any later version. You may redistribute it and/or modify it
|
// option) any later version. You may redistribute it and/or modify it
|
||||||
// only in compliance with the GNU General Public License.
|
// only in compliance with the GNU General Public License.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful.
|
// This program is distributed in the hope that it will be useful.
|
||||||
// However, this program is distributed AS-IS WITHOUT ANY
|
// However, this program is distributed AS-IS WITHOUT ANY
|
||||||
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
||||||
// for more details.
|
// for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
// USA.
|
// USA.
|
||||||
//
|
//
|
||||||
// Nothing in the GNU General Public License or any other license to use
|
// 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,
|
// the code or files shall permit you to use Tripwire's trademarks,
|
||||||
// service marks, or other intellectual property without Tripwire's
|
// service marks, or other intellectual property without Tripwire's
|
||||||
// prior written consent.
|
// prior written consent.
|
||||||
//
|
//
|
||||||
// If you have any questions, please contact Tripwire, Inc. at either
|
// If you have any questions, please contact Tripwire, Inc. at either
|
||||||
// info@tripwire.org or www.tripwire.org.
|
// info@tripwire.org or www.tripwire.org.
|
||||||
//
|
//
|
||||||
|
@ -34,7 +34,7 @@
|
||||||
// Date: 30 April 99
|
// Date: 30 April 99
|
||||||
// Creator: mdb
|
// Creator: mdb
|
||||||
//
|
//
|
||||||
// cErrorTable -- singleton derived from Resource_<> that serves as the global
|
// cErrorTable -- singleton derived from Resource_<> that serves as the global
|
||||||
// error id to string mapping
|
// error id to string mapping
|
||||||
//
|
//
|
||||||
#ifndef __ERRORTABLE_H
|
#ifndef __ERRORTABLE_H
|
||||||
|
@ -59,36 +59,36 @@ public:
|
||||||
//
|
//
|
||||||
// Convenience Methods
|
// Convenience Methods
|
||||||
//
|
//
|
||||||
void Put( const eError& e, const TCHAR* msg );
|
void Put(const eError& e, const TCHAR* msg);
|
||||||
//
|
//
|
||||||
// Singleton Interface
|
// Singleton Interface
|
||||||
//
|
//
|
||||||
static cErrorTable* GetInstance();
|
static cErrorTable* GetInstance();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
static void AssertMsgValidity(const TCHAR* msg);
|
static void AssertMsgValidity(const TCHAR* msg);
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void cErrorTable::Put( const eError& e, const TCHAR* msg )
|
inline void cErrorTable::Put(const eError& e, const TCHAR* msg)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
AssertMsgValidity(msg);
|
AssertMsgValidity(msg);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
inherited::Put( e.GetID(), msg );
|
inherited::Put(e.GetID(), msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Convenience Macros
|
// Convenience Macros
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// These macros make it easy for a module to register errors with the global
|
// These macros make it easy for a module to register errors with the global
|
||||||
// error table. Them like this:
|
// error table. Them like this:
|
||||||
//
|
//
|
||||||
// // animalerrors.h
|
// // animalerrors.h
|
||||||
// //
|
// //
|
||||||
// TSS_DECLARE_ERROR_REGISTRATION( animal )
|
// TSS_DECLARE_ERROR_REGISTRATION( animal )
|
||||||
//
|
//
|
||||||
// // animalerrors.cpp
|
// // animalerrors.cpp
|
||||||
|
@ -109,32 +109,27 @@ inline void cErrorTable::Put( const eError& e, const TCHAR* msg )
|
||||||
//===================
|
//===================
|
||||||
// cpp file macros
|
// cpp file macros
|
||||||
//===================
|
//===================
|
||||||
#define TSS_BEGIN_ERROR_REGISTRATION( pkgName ) \
|
# define TSS_BEGIN_ERROR_REGISTRATION(pkgName) \
|
||||||
RegisterErrors##pkgName::RegisterErrors##pkgName() \
|
RegisterErrors##pkgName::RegisterErrors##pkgName() \
|
||||||
{
|
{
|
||||||
|
|
||||||
#define TSS_REGISTER_ERROR( err, str ) \
|
# define TSS_REGISTER_ERROR(err, str) cErrorTable::GetInstance()->Put(err, str);
|
||||||
cErrorTable::GetInstance()->Put \
|
|
||||||
( err, str );
|
|
||||||
|
|
||||||
#define TSS_END_ERROR_REGISTRATION() \
|
# define TSS_END_ERROR_REGISTRATION() }
|
||||||
}
|
|
||||||
|
|
||||||
//===================
|
//===================
|
||||||
// h file macros
|
// h file macros
|
||||||
//===================
|
//===================
|
||||||
#define TSS_DECLARE_ERROR_REGISTRATION( pkgName ) \
|
# define TSS_DECLARE_ERROR_REGISTRATION(pkgName) \
|
||||||
struct RegisterErrors##pkgName \
|
struct RegisterErrors##pkgName \
|
||||||
{\
|
{ \
|
||||||
RegisterErrors##pkgName(); \
|
RegisterErrors##pkgName(); \
|
||||||
};
|
};
|
||||||
|
|
||||||
//===================
|
//===================
|
||||||
// package init macros
|
// package init macros
|
||||||
//===================
|
//===================
|
||||||
#define TSS_REGISTER_PKG_ERRORS( pkgName ) \
|
# define TSS_REGISTER_PKG_ERRORS(pkgName) RegisterErrors##pkgName register##pkgName;
|
||||||
RegisterErrors##pkgName register##pkgName;
|
|
||||||
|
|
||||||
|
|
||||||
#endif //__ERRORTABLE_H
|
#endif //__ERRORTABLE_H
|
||||||
|
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
//
|
//
|
||||||
// The developer of the original code and/or files is Tripwire, Inc.
|
// The developer of the original code and/or files is Tripwire, Inc.
|
||||||
// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire,
|
// Portions created by Tripwire, Inc. are copyright (C) 2000-2018 Tripwire,
|
||||||
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
||||||
// reserved.
|
// reserved.
|
||||||
//
|
//
|
||||||
// This program is free software. The contents of this file are subject
|
// 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
|
// 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
|
// Free Software Foundation; either version 2 of the License, or (at your
|
||||||
// option) any later version. You may redistribute it and/or modify it
|
// option) any later version. You may redistribute it and/or modify it
|
||||||
// only in compliance with the GNU General Public License.
|
// only in compliance with the GNU General Public License.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful.
|
// This program is distributed in the hope that it will be useful.
|
||||||
// However, this program is distributed AS-IS WITHOUT ANY
|
// However, this program is distributed AS-IS WITHOUT ANY
|
||||||
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
||||||
// for more details.
|
// for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
// USA.
|
// USA.
|
||||||
//
|
//
|
||||||
// Nothing in the GNU General Public License or any other license to use
|
// 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,
|
// the code or files shall permit you to use Tripwire's trademarks,
|
||||||
// service marks, or other intellectual property without Tripwire's
|
// service marks, or other intellectual property without Tripwire's
|
||||||
// prior written consent.
|
// prior written consent.
|
||||||
//
|
//
|
||||||
// If you have any questions, please contact Tripwire, Inc. at either
|
// If you have any questions, please contact Tripwire, Inc. at either
|
||||||
// info@tripwire.org or www.tripwire.org.
|
// info@tripwire.org or www.tripwire.org.
|
||||||
//
|
//
|
||||||
|
@ -37,20 +37,19 @@
|
||||||
#include "corestrings.h"
|
#include "corestrings.h"
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
// class eInternal
|
// class eInternal
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
|
|
||||||
namespace //unique
|
namespace //unique
|
||||||
{
|
{
|
||||||
TCHAR* tw_itot( int value, TCHAR* string, int radix, int size)
|
TCHAR* tw_itot(int value, TCHAR* string, int radix, int size)
|
||||||
{
|
{
|
||||||
snprintf( string, size, "%d", value );
|
snprintf(string, size, "%d", value);
|
||||||
return string;
|
return string;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
} // namespace
|
||||||
|
|
||||||
eInternal::eInternal(TCHAR* sourceFile, int lineNum)
|
eInternal::eInternal(TCHAR* sourceFile, int lineNum) : eError(_T(""))
|
||||||
: eError(_T(""))
|
|
||||||
{
|
{
|
||||||
TCHAR buf[256];
|
TCHAR buf[256];
|
||||||
|
|
||||||
|
@ -67,18 +66,17 @@ eInternal::eInternal(TCHAR* sourceFile, int lineNum)
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// MakeFileError
|
// MakeFileError
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
TSTRING cErrorUtil::MakeFileError( const TSTRING& msg, const TSTRING& fileName )
|
TSTRING cErrorUtil::MakeFileError(const TSTRING& msg, const TSTRING& fileName)
|
||||||
{
|
{
|
||||||
TSTRING ret;
|
TSTRING ret;
|
||||||
ret = TSS_GetString( cCore, core::STR_ERR2_FILENAME );
|
ret = TSS_GetString(cCore, core::STR_ERR2_FILENAME);
|
||||||
ret.append( fileName );
|
ret.append(fileName);
|
||||||
ret.append( 1, _T('\n') );
|
ret.append(1, _T('\n'));
|
||||||
|
|
||||||
if ( msg.length() > 0 )
|
if (msg.length() > 0)
|
||||||
{
|
{
|
||||||
ret.append(msg);
|
ret.append(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
//
|
//
|
||||||
// The developer of the original code and/or files is Tripwire, Inc.
|
// The developer of the original code and/or files is Tripwire, Inc.
|
||||||
// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire,
|
// Portions created by Tripwire, Inc. are copyright (C) 2000-2018 Tripwire,
|
||||||
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
||||||
// reserved.
|
// reserved.
|
||||||
//
|
//
|
||||||
// This program is free software. The contents of this file are subject
|
// 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
|
// 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
|
// Free Software Foundation; either version 2 of the License, or (at your
|
||||||
// option) any later version. You may redistribute it and/or modify it
|
// option) any later version. You may redistribute it and/or modify it
|
||||||
// only in compliance with the GNU General Public License.
|
// only in compliance with the GNU General Public License.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful.
|
// This program is distributed in the hope that it will be useful.
|
||||||
// However, this program is distributed AS-IS WITHOUT ANY
|
// However, this program is distributed AS-IS WITHOUT ANY
|
||||||
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
||||||
// for more details.
|
// for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
// USA.
|
// USA.
|
||||||
//
|
//
|
||||||
// Nothing in the GNU General Public License or any other license to use
|
// 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,
|
// the code or files shall permit you to use Tripwire's trademarks,
|
||||||
// service marks, or other intellectual property without Tripwire's
|
// service marks, or other intellectual property without Tripwire's
|
||||||
// prior written consent.
|
// prior written consent.
|
||||||
//
|
//
|
||||||
// If you have any questions, please contact Tripwire, Inc. at either
|
// If you have any questions, please contact Tripwire, Inc. at either
|
||||||
// info@tripwire.org or www.tripwire.org.
|
// info@tripwire.org or www.tripwire.org.
|
||||||
//
|
//
|
||||||
|
@ -39,7 +39,7 @@
|
||||||
// eInternal -- internal logic errors ( ie -- programming mistakes )
|
// eInternal -- internal logic errors ( ie -- programming mistakes )
|
||||||
// ePoly -- "polymorphic" error that takes its ID as input instead
|
// ePoly -- "polymorphic" error that takes its ID as input instead
|
||||||
// of from its class name
|
// of from its class name
|
||||||
// ThrowAndAssert -- asserts false and throws the specified exception
|
// ThrowAndAssert -- asserts false and throws the specified exception
|
||||||
//
|
//
|
||||||
#ifndef __ERRORUTIL_H
|
#ifndef __ERRORUTIL_H
|
||||||
#define __ERRORUTIL_H
|
#define __ERRORUTIL_H
|
||||||
|
@ -58,27 +58,27 @@ public:
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
// Construction and Assignment
|
// Construction and Assignment
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
ePoly( uint32 id, const TSTRING& msg, uint32 flags = 0 );
|
ePoly(uint32 id, const TSTRING& msg, uint32 flags = 0);
|
||||||
explicit ePoly( const eError& rhs );
|
explicit ePoly(const eError& rhs);
|
||||||
explicit ePoly();
|
explicit ePoly();
|
||||||
void operator=( const eError& rhs );
|
void operator=(const eError& rhs);
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
// ID manipulation
|
// ID manipulation
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
virtual uint32 GetID() const;
|
virtual uint32 GetID() const;
|
||||||
void SetID( uint32 id );
|
void SetID(uint32 id);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint32 mID;
|
uint32 mID;
|
||||||
};
|
};
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// eInternal
|
// eInternal
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
TSS_BEGIN_EXCEPTION( eInternal, eError )
|
TSS_BEGIN_EXCEPTION(eInternal, eError)
|
||||||
public:
|
public:
|
||||||
eInternal( TCHAR* file, int lineNum );
|
eInternal(TCHAR* file, int lineNum);
|
||||||
TSS_END_EXCEPTION()
|
TSS_END_EXCEPTION()
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -87,28 +87,32 @@ TSS_END_EXCEPTION()
|
||||||
class cErrorUtil
|
class cErrorUtil
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static TSTRING MakeFileError( const TSTRING& msg, const TSTRING& fileName );
|
static TSTRING MakeFileError(const TSTRING& msg, const TSTRING& fileName);
|
||||||
// constructs an error message of the form:
|
// constructs an error message of the form:
|
||||||
// File: <fileName> \n <msg>
|
// File: <fileName> \n <msg>
|
||||||
// This is useful for constructing strings to pass as the msg parameter
|
// This is useful for constructing strings to pass as the msg parameter
|
||||||
// to eError constructors.
|
// to eError constructors.
|
||||||
};
|
};
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Convenience Macros
|
// Convenience Macros
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// NOTE -- we require the developer to supply the file name instead of using
|
// NOTE -- we require the developer to supply the file name instead of using
|
||||||
// __FILE__ because that includes the full path to the file, which we
|
// __FILE__ because that includes the full path to the file, which we
|
||||||
// would not like to display to the user.
|
// would not like to display to the user.
|
||||||
//
|
//
|
||||||
#define INTERNAL_ERROR(filename) eInternal((TCHAR*)_T(filename), __LINE__)
|
#define INTERNAL_ERROR(filename) eInternal((TCHAR*)_T(filename), __LINE__)
|
||||||
#define THROW_INTERNAL(filename) throw eInternal((TCHAR*)_T(filename), __LINE__)
|
#define THROW_INTERNAL(filename) throw eInternal((TCHAR*)_T(filename), __LINE__)
|
||||||
|
|
||||||
|
|
||||||
// TODO: ASSERT is always fatal in Unix, perhaps we could #ifdef the ASSERT
|
// TODO: ASSERT is always fatal in Unix, perhaps we could #ifdef the ASSERT
|
||||||
// to echo to cout the line number the exception occured at?
|
// to echo to cout the line number the exception occured at?
|
||||||
#define ThrowAndAssert(exception) { ASSERT(false); throw exception; }
|
#define ThrowAndAssert(exception) \
|
||||||
|
{ \
|
||||||
|
ASSERT(false); \
|
||||||
|
throw exception; \
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -118,17 +122,14 @@ public:
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// ePoly
|
// ePoly
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
inline ePoly::ePoly( uint32 id, const TSTRING& msg, uint32 flags )
|
inline ePoly::ePoly(uint32 id, const TSTRING& msg, uint32 flags) : eError(msg, flags), mID(id)
|
||||||
: eError( msg, flags ),
|
|
||||||
mID( id )
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// ePoly
|
// ePoly
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
inline ePoly::ePoly( const eError& rhs )
|
inline ePoly::ePoly(const eError& rhs)
|
||||||
{
|
{
|
||||||
*this = rhs;
|
*this = rhs;
|
||||||
}
|
}
|
||||||
|
@ -136,21 +137,18 @@ inline ePoly::ePoly( const eError& rhs )
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// ePoly
|
// ePoly
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
inline ePoly::ePoly()
|
inline ePoly::ePoly() : eError(_T("")), mID(0)
|
||||||
: eError( _T("") ),
|
|
||||||
mID( 0 )
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// operator=
|
// operator=
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
inline void ePoly::operator=( const eError& rhs )
|
inline void ePoly::operator=(const eError& rhs)
|
||||||
{
|
{
|
||||||
mMsg = rhs.GetMsg();
|
mMsg = rhs.GetMsg();
|
||||||
mFlags = rhs.GetFlags();
|
mFlags = rhs.GetFlags();
|
||||||
mID = rhs.GetID();
|
mID = rhs.GetID();
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -164,10 +162,9 @@ inline uint32 ePoly::GetID() const
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// SetID
|
// SetID
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
inline void ePoly::SetID( uint32 id )
|
inline void ePoly::SetID(uint32 id)
|
||||||
{
|
{
|
||||||
mID = id;
|
mID = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //__ERRORUTIL_H
|
#endif //__ERRORUTIL_H
|
||||||
|
|
||||||
|
|
131
src/core/file.h
131
src/core/file.h
|
@ -1,31 +1,31 @@
|
||||||
//
|
//
|
||||||
// The developer of the original code and/or files is Tripwire, Inc.
|
// The developer of the original code and/or files is Tripwire, Inc.
|
||||||
// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire,
|
// Portions created by Tripwire, Inc. are copyright (C) 2000-2018 Tripwire,
|
||||||
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
||||||
// reserved.
|
// reserved.
|
||||||
//
|
//
|
||||||
// This program is free software. The contents of this file are subject
|
// 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
|
// 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
|
// Free Software Foundation; either version 2 of the License, or (at your
|
||||||
// option) any later version. You may redistribute it and/or modify it
|
// option) any later version. You may redistribute it and/or modify it
|
||||||
// only in compliance with the GNU General Public License.
|
// only in compliance with the GNU General Public License.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful.
|
// This program is distributed in the hope that it will be useful.
|
||||||
// However, this program is distributed AS-IS WITHOUT ANY
|
// However, this program is distributed AS-IS WITHOUT ANY
|
||||||
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
||||||
// for more details.
|
// for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
// USA.
|
// USA.
|
||||||
//
|
//
|
||||||
// Nothing in the GNU General Public License or any other license to use
|
// 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,
|
// the code or files shall permit you to use Tripwire's trademarks,
|
||||||
// service marks, or other intellectual property without Tripwire's
|
// service marks, or other intellectual property without Tripwire's
|
||||||
// prior written consent.
|
// prior written consent.
|
||||||
//
|
//
|
||||||
// If you have any questions, please contact Tripwire, Inc. at either
|
// If you have any questions, please contact Tripwire, Inc. at either
|
||||||
// info@tripwire.org or www.tripwire.org.
|
// info@tripwire.org or www.tripwire.org.
|
||||||
//
|
//
|
||||||
|
@ -55,86 +55,88 @@
|
||||||
// eFile exception class
|
// eFile exception class
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
|
|
||||||
TSS_FILE_EXCEPTION( eFile, eFileError );
|
TSS_FILE_EXCEPTION(eFile, eFileError);
|
||||||
TSS_FILE_EXCEPTION( eFileOpen, eFile );
|
TSS_FILE_EXCEPTION(eFileOpen, eFile);
|
||||||
TSS_FILE_EXCEPTION( eFileWrite, eFile );
|
TSS_FILE_EXCEPTION(eFileWrite, eFile);
|
||||||
TSS_FILE_EXCEPTION( eFileRead, eFile );
|
TSS_FILE_EXCEPTION(eFileRead, eFile);
|
||||||
TSS_FILE_EXCEPTION( eFileEOF, eFile ); // never used!
|
TSS_FILE_EXCEPTION(eFileEOF, eFile); // never used!
|
||||||
TSS_FILE_EXCEPTION( eFileSeek, eFile );
|
TSS_FILE_EXCEPTION(eFileSeek, eFile);
|
||||||
TSS_FILE_EXCEPTION( eFileInvalidOp, eFile ); // never used!
|
TSS_FILE_EXCEPTION(eFileInvalidOp, eFile); // never used!
|
||||||
TSS_FILE_EXCEPTION( eFileTrunc, eFile );
|
TSS_FILE_EXCEPTION(eFileTrunc, eFile);
|
||||||
TSS_FILE_EXCEPTION( eFileClose, eFile ); // never used!
|
TSS_FILE_EXCEPTION(eFileClose, eFile); // never used!
|
||||||
TSS_FILE_EXCEPTION( eFileFlush, eFile );
|
TSS_FILE_EXCEPTION(eFileFlush, eFile);
|
||||||
TSS_FILE_EXCEPTION( eFileRewind, eFile );
|
TSS_FILE_EXCEPTION(eFileRewind, eFile);
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
// cFile
|
// cFile
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
struct cFile_i;
|
struct cFile_i;
|
||||||
class cFile
|
class cFile
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef off_t File_t;
|
typedef off_t File_t;
|
||||||
|
|
||||||
enum SeekFrom
|
enum SeekFrom
|
||||||
{
|
{
|
||||||
SEEK_BEGIN = 0,
|
SEEK_BEGIN = 0,
|
||||||
SEEK_CURRENT,
|
SEEK_CURRENT,
|
||||||
SEEK_EOF
|
SEEK_EOF
|
||||||
};
|
};
|
||||||
|
|
||||||
enum OpenFlags
|
enum OpenFlags
|
||||||
{
|
{
|
||||||
// note that reading from the file is implicit
|
// note that reading from the file is implicit
|
||||||
OPEN_READ = 0x00000001, // not needed, but makes calls nice...
|
OPEN_READ = 0x00000001, // not needed, but makes calls nice...
|
||||||
OPEN_WRITE = 0x00000002, // we will be writing to the file
|
OPEN_WRITE = 0x00000002, // we will be writing to the file
|
||||||
OPEN_LOCKED_TEMP = 0x00000004, // the file should not be readable by other processes and should be removed when closed
|
OPEN_LOCKED_TEMP =
|
||||||
OPEN_TRUNCATE = 0x00000008, // opens an empty file. creates it if it doesn't exist. Doesn't make much sense without OF_WRITE
|
0x00000004, // the file should not be readable by other processes and should be removed when closed
|
||||||
OPEN_CREATE = 0x00000010, // create the file if it doesn't exist; this is implicit if OF_TRUNCATE is set
|
OPEN_TRUNCATE =
|
||||||
OPEN_TEXT = 0x00000020,
|
0x00000008, // opens an empty file. creates it if it doesn't exist. Doesn't make much sense without OF_WRITE
|
||||||
OPEN_EXCLUSIVE = 0x00000040, // Use O_CREAT | O_EXCL
|
OPEN_CREATE = 0x00000010, // create the file if it doesn't exist; this is implicit if OF_TRUNCATE is set
|
||||||
OPEN_SCANNING = 0x00000080, // Open for scanning; set nonblocking & caching accordingly, where available
|
OPEN_TEXT = 0x00000020,
|
||||||
OPEN_DIRECT = 0x00000100 // Use O_DIRECT or platform equivalent
|
OPEN_EXCLUSIVE = 0x00000040, // Use O_CREAT | O_EXCL
|
||||||
|
OPEN_SCANNING = 0x00000080, // Open for scanning; set nonblocking & caching accordingly, where available
|
||||||
|
OPEN_DIRECT = 0x00000100 // Use O_DIRECT or platform equivalent
|
||||||
};
|
};
|
||||||
|
|
||||||
//Ctor, Dtor, CpyCtor, Operator=:
|
//Ctor, Dtor, CpyCtor, Operator=:
|
||||||
cFile ( void );
|
cFile(void);
|
||||||
~cFile ( void );
|
~cFile(void);
|
||||||
|
|
||||||
/************ User Interface **************************/
|
/************ User Interface **************************/
|
||||||
|
|
||||||
// Both Open methods ALWAYS open files in BINARY mode!
|
// Both Open methods ALWAYS open files in BINARY mode!
|
||||||
void Open ( const TSTRING& sFileName, uint32 flags = OPEN_READ ); //throw(eFile)
|
void Open(const TSTRING& sFileName, uint32 flags = OPEN_READ); //throw(eFile)
|
||||||
void Close ( void ); //throw(eFile)
|
void Close(void); //throw(eFile)
|
||||||
bool IsOpen ( void ) const;
|
bool IsOpen(void) const;
|
||||||
|
|
||||||
File_t Seek ( File_t offset, SeekFrom From ) const; //throw(eFile)
|
File_t Seek(File_t offset, SeekFrom From) const; //throw(eFile)
|
||||||
// Seek returns the current offset after completion
|
// Seek returns the current offset after completion
|
||||||
File_t Read ( void* buffer, File_t nBytes ) const; //throw(eFile)
|
File_t Read(void* buffer, File_t nBytes) const; //throw(eFile)
|
||||||
// Read returns the number of bytes that are actually read. If the nBytes
|
// Read returns the number of bytes that are actually read. If the nBytes
|
||||||
// parameter is 0, 0 bytes will be read and buffer will remain untouched.
|
// parameter is 0, 0 bytes will be read and buffer will remain untouched.
|
||||||
// If the read head is at EOF, no bytes will be read and 0 will be returned.
|
// If the read head is at EOF, no bytes will be read and 0 will be returned.
|
||||||
File_t Write ( const void* buffer, File_t nBytes ); //throw(eFile)
|
File_t Write(const void* buffer, File_t nBytes); //throw(eFile)
|
||||||
// Write returns the number of bytes that are actually written.
|
// Write returns the number of bytes that are actually written.
|
||||||
File_t Tell ( void ) const;
|
File_t Tell(void) const;
|
||||||
// Tell returns the current offset.
|
// Tell returns the current offset.
|
||||||
bool Flush ( void ); //throw(eFile)
|
bool Flush(void); //throw(eFile)
|
||||||
// Flush returns 0 if the currently defined stream is successfully flushed.
|
// Flush returns 0 if the currently defined stream is successfully flushed.
|
||||||
void Rewind ( void ) const; //throw(eFile)
|
void Rewind(void) const; //throw(eFile)
|
||||||
// Sets the offset to 0.
|
// Sets the offset to 0.
|
||||||
File_t GetSize ( void ) const;
|
File_t GetSize(void) const;
|
||||||
// Returns the size of the current file in bytes. Returns -1 if no file is defined.
|
// Returns the size of the current file in bytes. Returns -1 if no file is defined.
|
||||||
void Truncate ( File_t offset ); // throw(eFile)
|
void Truncate(File_t offset); // throw(eFile)
|
||||||
|
|
||||||
private:
|
private:
|
||||||
cFile ( const cFile& rhs ); //not impl.
|
cFile(const cFile& rhs); //not impl.
|
||||||
cFile& operator= ( const cFile& rhs); //not impl.
|
cFile& operator=(const cFile& rhs); //not impl.
|
||||||
|
|
||||||
//Pointer to the insulated implementation
|
//Pointer to the insulated implementation
|
||||||
cFile_i* mpData;
|
cFile_i* mpData;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool isWritable;
|
bool isWritable;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -143,7 +145,7 @@ class cDosPath
|
||||||
public:
|
public:
|
||||||
static TSTRING AsPosix(const TSTRING& in);
|
static TSTRING AsPosix(const TSTRING& in);
|
||||||
static TSTRING AsNative(const TSTRING& in);
|
static TSTRING AsNative(const TSTRING& in);
|
||||||
static bool IsAbsolutePath(const TSTRING& in);
|
static bool IsAbsolutePath(const TSTRING& in);
|
||||||
static TSTRING BackupName(const TSTRING& in);
|
static TSTRING BackupName(const TSTRING& in);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -152,7 +154,7 @@ class cArosPath
|
||||||
public:
|
public:
|
||||||
static TSTRING AsPosix(const TSTRING& in);
|
static TSTRING AsPosix(const TSTRING& in);
|
||||||
static TSTRING AsNative(const TSTRING& in);
|
static TSTRING AsNative(const TSTRING& in);
|
||||||
static bool IsAbsolutePath(const TSTRING& in);
|
static bool IsAbsolutePath(const TSTRING& in);
|
||||||
};
|
};
|
||||||
|
|
||||||
class cRiscosPath
|
class cRiscosPath
|
||||||
|
@ -160,7 +162,7 @@ class cRiscosPath
|
||||||
public:
|
public:
|
||||||
static TSTRING AsPosix(const TSTRING& in);
|
static TSTRING AsPosix(const TSTRING& in);
|
||||||
static TSTRING AsNative(const TSTRING& in);
|
static TSTRING AsNative(const TSTRING& in);
|
||||||
static bool IsAbsolutePath(const TSTRING& in);
|
static bool IsAbsolutePath(const TSTRING& in);
|
||||||
};
|
};
|
||||||
|
|
||||||
class cRedoxPath
|
class cRedoxPath
|
||||||
|
@ -168,19 +170,18 @@ class cRedoxPath
|
||||||
public:
|
public:
|
||||||
static TSTRING AsPosix(const TSTRING& in);
|
static TSTRING AsPosix(const TSTRING& in);
|
||||||
static TSTRING AsNative(const TSTRING& in);
|
static TSTRING AsNative(const TSTRING& in);
|
||||||
static bool IsAbsolutePath(const TSTRING& in);
|
static bool IsAbsolutePath(const TSTRING& in);
|
||||||
};
|
};
|
||||||
|
|
||||||
#if IS_DOS_DJGPP
|
# if IS_DOS_DJGPP
|
||||||
#define cDevicePath cDosPath
|
# define cDevicePath cDosPath
|
||||||
#elif IS_AROS
|
# elif IS_AROS
|
||||||
#define cDevicePath cArosPath
|
# define cDevicePath cArosPath
|
||||||
#elif IS_RISCOS
|
# elif IS_RISCOS
|
||||||
#define cDevicePath cRiscosPath
|
# define cDevicePath cRiscosPath
|
||||||
#elif IS_REDOX
|
# elif IS_REDOX
|
||||||
#define cDevicePath cRedoxPath
|
# define cDevicePath cRedoxPath
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
|
|
||||||
#endif //__FILE_H
|
#endif //__FILE_H
|
||||||
|
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
|
|
||||||
// The developer of the original code and/or files is Tripwire, Inc.
|
// The developer of the original code and/or files is Tripwire, Inc.
|
||||||
// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire,
|
// Portions created by Tripwire, Inc. are copyright (C) 2000-2018 Tripwire,
|
||||||
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
||||||
// reserved.
|
// reserved.
|
||||||
//
|
//
|
||||||
// This program is free software. The contents of this file are subject
|
// 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
|
// 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
|
// Free Software Foundation; either version 2 of the License, or (at your
|
||||||
// option) any later version. You may redistribute it and/or modify it
|
// option) any later version. You may redistribute it and/or modify it
|
||||||
// only in compliance with the GNU General Public License.
|
// only in compliance with the GNU General Public License.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful.
|
// This program is distributed in the hope that it will be useful.
|
||||||
// However, this program is distributed AS-IS WITHOUT ANY
|
// However, this program is distributed AS-IS WITHOUT ANY
|
||||||
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
||||||
// for more details.
|
// for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
// USA.
|
// USA.
|
||||||
//
|
//
|
||||||
// Nothing in the GNU General Public License or any other license to use
|
// 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,
|
// the code or files shall permit you to use Tripwire's trademarks,
|
||||||
// service marks, or other intellectual property without Tripwire's
|
// service marks, or other intellectual property without Tripwire's
|
||||||
// prior written consent.
|
// prior written consent.
|
||||||
//
|
//
|
||||||
// If you have any questions, please contact Tripwire, Inc. at either
|
// If you have any questions, please contact Tripwire, Inc. at either
|
||||||
// info@tripwire.org or www.tripwire.org.
|
// info@tripwire.org or www.tripwire.org.
|
||||||
//
|
//
|
||||||
|
@ -35,13 +35,13 @@
|
||||||
/* On GNU/Hurd, need to define _GNU_SOURCE in order to use O_NOATIME
|
/* On GNU/Hurd, need to define _GNU_SOURCE in order to use O_NOATIME
|
||||||
which technically is still a nonstandard extension to open() */
|
which technically is still a nonstandard extension to open() */
|
||||||
#if IS_HURD
|
#if IS_HURD
|
||||||
# define _GNU_SOURCE
|
# define _GNU_SOURCE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "core/stdcore.h"
|
#include "core/stdcore.h"
|
||||||
|
|
||||||
#if !IS_UNIX
|
#if !IS_UNIX
|
||||||
#error Need to be unix to use unixfsservices
|
# error Need to be unix to use unixfsservices
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "core/file.h"
|
#include "core/file.h"
|
||||||
|
@ -54,7 +54,7 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#if HAVE_SYS_FS_VX_IOCTL_H
|
#if HAVE_SYS_FS_VX_IOCTL_H
|
||||||
# include <sys/fs/vx_ioctl.h>
|
#include <sys/fs/vx_ioctl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "core/debug.h"
|
#include "core/debug.h"
|
||||||
|
@ -75,32 +75,32 @@ struct cFile_i
|
||||||
cFile_i();
|
cFile_i();
|
||||||
~cFile_i();
|
~cFile_i();
|
||||||
|
|
||||||
int m_fd; //underlying file descriptor
|
int m_fd; //underlying file descriptor
|
||||||
FILE* mpCurrStream; //currently defined file stream
|
FILE* mpCurrStream; //currently defined file stream
|
||||||
TSTRING mFileName; //the name of the file we are currently referencing.
|
TSTRING mFileName; //the name of the file we are currently referencing.
|
||||||
uint32 mFlags; //Flags used to open the file
|
uint32 mFlags; //Flags used to open the file
|
||||||
};
|
};
|
||||||
|
|
||||||
//Ctor
|
//Ctor
|
||||||
cFile_i::cFile_i() :
|
cFile_i::cFile_i() : m_fd(-1), mpCurrStream(NULL), mFlags(0)
|
||||||
m_fd(-1), mpCurrStream(NULL), mFlags(0)
|
{
|
||||||
{}
|
}
|
||||||
|
|
||||||
//Dtor
|
//Dtor
|
||||||
cFile_i::~cFile_i()
|
cFile_i::~cFile_i()
|
||||||
{
|
{
|
||||||
if (mpCurrStream != NULL)
|
if (mpCurrStream != NULL)
|
||||||
{
|
{
|
||||||
fclose( mpCurrStream );
|
fclose(mpCurrStream);
|
||||||
mpCurrStream = NULL;
|
mpCurrStream = NULL;
|
||||||
|
|
||||||
#if !CAN_UNLINK_WHILE_OPEN // so unlink after close instead
|
#if !CAN_UNLINK_WHILE_OPEN // so unlink after close instead
|
||||||
if( mFlags & cFile::OPEN_LOCKED_TEMP )
|
if (mFlags & cFile::OPEN_LOCKED_TEMP)
|
||||||
{
|
{
|
||||||
// unlink this file
|
// unlink this file
|
||||||
if( 0 != unlink(mFileName.c_str()))
|
if (0 != unlink(mFileName.c_str()))
|
||||||
{
|
{
|
||||||
throw( eFileOpen( mFileName, iFSServices::GetInstance()->GetErrString() ) );
|
throw(eFileOpen(mFileName, iFSServices::GetInstance()->GetErrString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -113,15 +113,14 @@ cFile_i::~cFile_i()
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
cFile::cFile() :
|
cFile::cFile() : mpData(NULL), isWritable(false)
|
||||||
mpData(NULL), isWritable(false)
|
|
||||||
{
|
{
|
||||||
mpData = new cFile_i;
|
mpData = new cFile_i;
|
||||||
}
|
}
|
||||||
|
|
||||||
cFile::~cFile()
|
cFile::~cFile()
|
||||||
{
|
{
|
||||||
if( mpData != NULL)
|
if (mpData != NULL)
|
||||||
{
|
{
|
||||||
delete mpData;
|
delete mpData;
|
||||||
mpData = NULL;
|
mpData = NULL;
|
||||||
|
@ -133,19 +132,19 @@ cFile::~cFile()
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#if !USES_DEVICE_PATH
|
#if !USES_DEVICE_PATH
|
||||||
void cFile::Open( const TSTRING& sFileName, uint32 flags )
|
void cFile::Open(const TSTRING& sFileName, uint32 flags)
|
||||||
{
|
{
|
||||||
#else
|
#else
|
||||||
void cFile::Open( const TSTRING& sFileNameC, uint32 flags )
|
void cFile::Open(const TSTRING& sFileNameC, uint32 flags)
|
||||||
{
|
{
|
||||||
TSTRING sFileName = cDevicePath::AsNative(sFileNameC);
|
TSTRING sFileName = cDevicePath::AsNative(sFileNameC);
|
||||||
#endif
|
#endif
|
||||||
mode_t openmode = 0664;
|
mode_t openmode = 0664;
|
||||||
if (mpData->mpCurrStream != NULL)
|
if (mpData->mpCurrStream != NULL)
|
||||||
Close();
|
Close();
|
||||||
|
|
||||||
mpData->mFlags = flags;
|
mpData->mFlags = flags;
|
||||||
|
|
||||||
//
|
//
|
||||||
// set up the open permissions
|
// set up the open permissions
|
||||||
//
|
//
|
||||||
|
@ -155,9 +154,9 @@ void cFile::Open( const TSTRING& sFileNameC, uint32 flags )
|
||||||
|
|
||||||
if (flags & OPEN_WRITE)
|
if (flags & OPEN_WRITE)
|
||||||
{
|
{
|
||||||
perm |= O_RDWR;
|
perm |= O_RDWR;
|
||||||
isWritable = true;
|
isWritable = true;
|
||||||
mode = _T("rb");
|
mode = _T("rb");
|
||||||
if (flags & OPEN_TRUNCATE)
|
if (flags & OPEN_TRUNCATE)
|
||||||
{
|
{
|
||||||
perm |= O_TRUNC;
|
perm |= O_TRUNC;
|
||||||
|
@ -169,14 +168,15 @@ void cFile::Open( const TSTRING& sFileNameC, uint32 flags )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
perm |= O_RDONLY;
|
perm |= O_RDONLY;
|
||||||
isWritable = false;
|
isWritable = false;
|
||||||
mode = _T("rb");
|
mode = _T("rb");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & OPEN_EXCLUSIVE) {
|
if (flags & OPEN_EXCLUSIVE)
|
||||||
|
{
|
||||||
perm |= O_CREAT | O_EXCL;
|
perm |= O_CREAT | O_EXCL;
|
||||||
openmode = (mode_t) 0600; // Make sure only root can read the file
|
openmode = (mode_t)0600; // Make sure only root can read the file
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & OPEN_CREATE)
|
if (flags & OPEN_CREATE)
|
||||||
|
@ -196,28 +196,28 @@ void cFile::Open( const TSTRING& sFileNameC, uint32 flags )
|
||||||
//Only use O_DIRECT for scanning, since cfg/policy/report reads
|
//Only use O_DIRECT for scanning, since cfg/policy/report reads
|
||||||
// don't happen w/ a nice round block size.
|
// don't happen w/ a nice round block size.
|
||||||
if ((flags & OPEN_DIRECT) && (flags & OPEN_SCANNING))
|
if ((flags & OPEN_DIRECT) && (flags & OPEN_SCANNING))
|
||||||
perm |= O_DIRECT;
|
perm |= O_DIRECT;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//
|
//
|
||||||
// actually open the file
|
// actually open the file
|
||||||
//
|
//
|
||||||
int fh = _topen( sFileName.c_str(), perm, openmode );
|
int fh = _topen(sFileName.c_str(), perm, openmode);
|
||||||
if( fh == -1 )
|
if (fh == -1)
|
||||||
{
|
{
|
||||||
throw( eFileOpen( sFileName, iFSServices::GetInstance()->GetErrString() ) );
|
throw(eFileOpen(sFileName, iFSServices::GetInstance()->GetErrString()));
|
||||||
}
|
}
|
||||||
mpData->m_fd = fh;
|
mpData->m_fd = fh;
|
||||||
|
|
||||||
#if CAN_UNLINK_WHILE_OPEN
|
#if CAN_UNLINK_WHILE_OPEN
|
||||||
if( flags & OPEN_LOCKED_TEMP )
|
if (flags & OPEN_LOCKED_TEMP)
|
||||||
{
|
{
|
||||||
// unlink this file
|
// unlink this file
|
||||||
if( 0 != unlink( sFileName.c_str() ) )
|
if (0 != unlink(sFileName.c_str()))
|
||||||
{
|
{
|
||||||
// we weren't able to unlink file, so close handle and fail
|
// we weren't able to unlink file, so close handle and fail
|
||||||
close( fh );
|
close(fh);
|
||||||
throw( eFileOpen( sFileName, iFSServices::GetInstance()->GetErrString() ) );
|
throw(eFileOpen(sFileName, iFSServices::GetInstance()->GetErrString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -227,27 +227,27 @@ void cFile::Open( const TSTRING& sFileNameC, uint32 flags )
|
||||||
//
|
//
|
||||||
mpData->mpCurrStream = _tfdopen(fh, mode.c_str());
|
mpData->mpCurrStream = _tfdopen(fh, mode.c_str());
|
||||||
|
|
||||||
mpData->mFileName = sFileName; //Set mFileName to the newly opened file.
|
mpData->mFileName = sFileName; //Set mFileName to the newly opened file.
|
||||||
|
|
||||||
cFile::Rewind();
|
cFile::Rewind();
|
||||||
|
|
||||||
#ifdef F_NOCACHE //OSX
|
#ifdef F_NOCACHE //OSX
|
||||||
if ((flags & OPEN_DIRECT) && (flags & OPEN_SCANNING))
|
if ((flags & OPEN_DIRECT) && (flags & OPEN_SCANNING))
|
||||||
fcntl(fh, F_NOCACHE, 1);
|
fcntl(fh, F_NOCACHE, 1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if IS_SOLARIS
|
#if IS_SOLARIS
|
||||||
if ((flags & OPEN_DIRECT) && (flags & OPEN_SCANNING))
|
if ((flags & OPEN_DIRECT) && (flags & OPEN_SCANNING))
|
||||||
directio(fh, DIRECTIO_ON);
|
directio(fh, DIRECTIO_ON);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if HAVE_POSIX_FADVISE
|
#if HAVE_POSIX_FADVISE
|
||||||
if (flags & OPEN_SCANNING && !(flags & OPEN_DIRECT))
|
if (flags & OPEN_SCANNING && !(flags & OPEN_DIRECT))
|
||||||
{
|
{
|
||||||
posix_fadvise(fh,0,0, POSIX_FADV_SEQUENTIAL);
|
posix_fadvise(fh, 0, 0, POSIX_FADV_SEQUENTIAL);
|
||||||
posix_fadvise(fh,0,0, POSIX_FADV_NOREUSE);
|
posix_fadvise(fh, 0, 0, POSIX_FADV_NOREUSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif HAVE_SYS_FS_VX_IOCTL_H
|
#elif HAVE_SYS_FS_VX_IOCTL_H
|
||||||
if (flags & OPEN_SCANNING)
|
if (flags & OPEN_SCANNING)
|
||||||
{
|
{
|
||||||
|
@ -257,7 +257,6 @@ void cFile::Open( const TSTRING& sFileNameC, uint32 flags )
|
||||||
ioctl(fh, VX_SETCACHE, VX_SEQ | VX_NOREUSE);
|
ioctl(fh, VX_SETCACHE, VX_SEQ | VX_NOREUSE);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -266,37 +265,37 @@ void cFile::Open( const TSTRING& sFileNameC, uint32 flags )
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
void cFile::Close() //throw(eFile)
|
void cFile::Close() //throw(eFile)
|
||||||
{
|
{
|
||||||
if(mpData->mpCurrStream != NULL)
|
if (mpData->mpCurrStream != NULL)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_POSIX_FADVISE
|
#ifdef HAVE_POSIX_FADVISE
|
||||||
posix_fadvise(fileno(mpData->mpCurrStream),0,0, POSIX_FADV_DONTNEED);
|
posix_fadvise(fileno(mpData->mpCurrStream), 0, 0, POSIX_FADV_DONTNEED);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
fclose( mpData->mpCurrStream );
|
fclose(mpData->mpCurrStream);
|
||||||
mpData->mpCurrStream = NULL;
|
mpData->mpCurrStream = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
mpData->mFileName.empty();
|
mpData->mFileName.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cFile::IsOpen( void ) const
|
bool cFile::IsOpen(void) const
|
||||||
{
|
{
|
||||||
return( mpData->mpCurrStream != NULL );
|
return (mpData->mpCurrStream != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// Seek -- Positions the read/write offset in mpCurrStream. Returns the
|
// Seek -- Positions the read/write offset in mpCurrStream. Returns the
|
||||||
// current offset upon completion. Returns 0 if no stream is defined.
|
// current offset upon completion. Returns 0 if no stream is defined.
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
cFile::File_t cFile::Seek( File_t offset, SeekFrom From) const //throw(eFile)
|
cFile::File_t cFile::Seek(File_t offset, SeekFrom From) const //throw(eFile)
|
||||||
{
|
{
|
||||||
//Check to see if a file as been opened yet...
|
//Check to see if a file as been opened yet...
|
||||||
ASSERT( mpData->mpCurrStream != 0);
|
ASSERT(mpData->mpCurrStream != 0);
|
||||||
|
|
||||||
int apiFrom;
|
int apiFrom;
|
||||||
|
|
||||||
switch( From )
|
switch (From)
|
||||||
{
|
{
|
||||||
case cFile::SEEK_BEGIN:
|
case cFile::SEEK_BEGIN:
|
||||||
apiFrom = SEEK_SET;
|
apiFrom = SEEK_SET;
|
||||||
|
@ -309,11 +308,11 @@ cFile::File_t cFile::Seek( File_t offset, SeekFrom From) const //throw(eFile)
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
//An invalid SeekFrom parameter was passed.
|
//An invalid SeekFrom parameter was passed.
|
||||||
throw( eInternal( _T("file_unix") ) );
|
throw(eInternal(_T("file_unix")));
|
||||||
}
|
}
|
||||||
|
|
||||||
// this is a hack to simulate running out of disk space
|
// this is a hack to simulate running out of disk space
|
||||||
#if 0
|
#if 0
|
||||||
static int blowupCount = 1;
|
static int blowupCount = 1;
|
||||||
if (++blowupCount == 1075)
|
if (++blowupCount == 1075)
|
||||||
{
|
{
|
||||||
|
@ -322,14 +321,14 @@ cFile::File_t cFile::Seek( File_t offset, SeekFrom From) const //throw(eFile)
|
||||||
throw std::bad_alloc();
|
throw std::bad_alloc();
|
||||||
}
|
}
|
||||||
fprintf(stderr, "%d\n", blowupCount);
|
fprintf(stderr, "%d\n", blowupCount);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (fseeko( mpData->mpCurrStream, offset, apiFrom ) != 0)
|
if (fseeko(mpData->mpCurrStream, offset, apiFrom) != 0)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
cDebug d("cFile::Seek");
|
cDebug d("cFile::Seek");
|
||||||
d.TraceDebug("Seek failed!\n");
|
d.TraceDebug("Seek failed!\n");
|
||||||
#endif
|
#endif
|
||||||
throw eFileSeek();
|
throw eFileSeek();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -340,26 +339,31 @@ cFile::File_t cFile::Seek( File_t offset, SeekFrom From) const //throw(eFile)
|
||||||
// Read -- Returns the actual bytes read from mpCurrStream. Returns 0 if
|
// Read -- Returns the actual bytes read from mpCurrStream. Returns 0 if
|
||||||
// mpCurrStream is undefined.
|
// mpCurrStream is undefined.
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
cFile::File_t cFile::Read( void* buffer, File_t nBytes ) const //throw(eFile)
|
cFile::File_t cFile::Read(void* buffer, File_t nBytes) const //throw(eFile)
|
||||||
{
|
{
|
||||||
File_t iBytesRead;
|
File_t iBytesRead;
|
||||||
|
|
||||||
// Has a file been opened?
|
// Has a file been opened?
|
||||||
ASSERT( mpData->mpCurrStream != NULL );
|
ASSERT(mpData->mpCurrStream != NULL);
|
||||||
|
|
||||||
// Is the nBytes parameter 0? If so, return without touching buffer:
|
// Is the nBytes parameter 0? If so, return without touching buffer:
|
||||||
if( nBytes == 0 )
|
if (nBytes == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (mpData->mFlags & OPEN_DIRECT) {
|
if (mpData->mFlags & OPEN_DIRECT)
|
||||||
|
{
|
||||||
iBytesRead = read(mpData->m_fd, buffer, nBytes);
|
iBytesRead = read(mpData->m_fd, buffer, nBytes);
|
||||||
if (iBytesRead<0) {
|
if (iBytesRead < 0)
|
||||||
throw eFileRead(mpData->mFileName, iFSServices::GetInstance()->GetErrString());
|
{
|
||||||
|
throw eFileRead(mpData->mFileName, iFSServices::GetInstance()->GetErrString());
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
iBytesRead = fread( buffer, sizeof(byte), nBytes, mpData->mpCurrStream );
|
else
|
||||||
if( ferror( mpData->mpCurrStream ) != 0 ) {
|
{
|
||||||
throw eFileRead( mpData->mFileName, iFSServices::GetInstance()->GetErrString() ) ;
|
iBytesRead = fread(buffer, sizeof(byte), nBytes, mpData->mpCurrStream);
|
||||||
|
if (ferror(mpData->mpCurrStream) != 0)
|
||||||
|
{
|
||||||
|
throw eFileRead(mpData->mFileName, iFSServices::GetInstance()->GetErrString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -370,16 +374,16 @@ cFile::File_t cFile::Read( void* buffer, File_t nBytes ) const //throw(eFile)
|
||||||
// Write -- Returns the actual number of bytes written to mpCurrStream
|
// Write -- Returns the actual number of bytes written to mpCurrStream
|
||||||
// Returns 0 if no file has been opened.
|
// Returns 0 if no file has been opened.
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
cFile::File_t cFile::Write( const void* buffer, File_t nBytes ) //throw(eFile)
|
cFile::File_t cFile::Write(const void* buffer, File_t nBytes) //throw(eFile)
|
||||||
{
|
{
|
||||||
File_t actual_count = 0;
|
File_t actual_count = 0;
|
||||||
|
|
||||||
// Has a file been opened? Is it writable?
|
// Has a file been opened? Is it writable?
|
||||||
ASSERT( mpData->mpCurrStream != NULL );
|
ASSERT(mpData->mpCurrStream != NULL);
|
||||||
ASSERT( isWritable );
|
ASSERT(isWritable);
|
||||||
|
|
||||||
if( ( actual_count = fwrite( buffer, sizeof(byte), nBytes, mpData->mpCurrStream ) ) < nBytes )
|
if ((actual_count = fwrite(buffer, sizeof(byte), nBytes, mpData->mpCurrStream)) < nBytes)
|
||||||
throw eFileWrite( mpData->mFileName, iFSServices::GetInstance()->GetErrString() );
|
throw eFileWrite(mpData->mFileName, iFSServices::GetInstance()->GetErrString());
|
||||||
else
|
else
|
||||||
return actual_count;
|
return actual_count;
|
||||||
}
|
}
|
||||||
|
@ -390,9 +394,9 @@ cFile::File_t cFile::Write( const void* buffer, File_t nBytes ) //throw(eFil
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
cFile::File_t cFile::Tell() const
|
cFile::File_t cFile::Tell() const
|
||||||
{
|
{
|
||||||
ASSERT( mpData->mpCurrStream != 0);
|
ASSERT(mpData->mpCurrStream != 0);
|
||||||
|
|
||||||
return ftell( mpData->mpCurrStream );
|
return ftell(mpData->mpCurrStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -400,23 +404,23 @@ cFile::File_t cFile::Tell() const
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
bool cFile::Flush() //throw(eFile)
|
bool cFile::Flush() //throw(eFile)
|
||||||
{
|
{
|
||||||
if ( mpData->mpCurrStream == NULL )
|
if (mpData->mpCurrStream == NULL)
|
||||||
throw eFileFlush( mpData->mFileName, iFSServices::GetInstance()->GetErrString() );
|
throw eFileFlush(mpData->mFileName, iFSServices::GetInstance()->GetErrString());
|
||||||
|
|
||||||
return ( fflush( mpData->mpCurrStream) == 0 );
|
return (fflush(mpData->mpCurrStream) == 0);
|
||||||
}
|
}
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// Rewind -- Sets the offset to the beginning of the file. If mpCurrStream
|
// Rewind -- Sets the offset to the beginning of the file. If mpCurrStream
|
||||||
// is NULL, this method returns false. If the rewind operation fails,
|
// is NULL, this method returns false. If the rewind operation fails,
|
||||||
// an exception is thrown.
|
// an exception is thrown.
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
void cFile::Rewind() const //throw(eFile)
|
void cFile::Rewind() const //throw(eFile)
|
||||||
{
|
{
|
||||||
ASSERT( mpData->mpCurrStream != 0);
|
ASSERT(mpData->mpCurrStream != 0);
|
||||||
|
|
||||||
rewind( mpData->mpCurrStream );
|
rewind(mpData->mpCurrStream);
|
||||||
if( ftell( mpData->mpCurrStream ) != 0 )
|
if (ftell(mpData->mpCurrStream) != 0)
|
||||||
throw( eFileRewind( mpData->mFileName, iFSServices::GetInstance()->GetErrString() ) );
|
throw(eFileRewind(mpData->mFileName, iFSServices::GetInstance()->GetErrString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -429,12 +433,12 @@ cFile::File_t cFile::GetSize() const
|
||||||
File_t ret;
|
File_t ret;
|
||||||
|
|
||||||
//Has a file been opened? If not, return -1
|
//Has a file been opened? If not, return -1
|
||||||
if( mpData->mpCurrStream == NULL )
|
if (mpData->mpCurrStream == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
ret = Seek( 0, cFile::SEEK_EOF );
|
ret = Seek(0, cFile::SEEK_EOF);
|
||||||
Seek( vCurrentOffset, cFile::SEEK_BEGIN );
|
Seek(vCurrentOffset, cFile::SEEK_BEGIN);
|
||||||
//return the offset to it's position prior to GetSize call.
|
//return the offset to it's position prior to GetSize call.
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -442,14 +446,14 @@ cFile::File_t cFile::GetSize() const
|
||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
// Truncate
|
// Truncate
|
||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
void cFile::Truncate( File_t offset ) // throw(eFile)
|
void cFile::Truncate(File_t offset) // throw(eFile)
|
||||||
{
|
{
|
||||||
ASSERT( mpData->mpCurrStream != 0);
|
ASSERT(mpData->mpCurrStream != 0);
|
||||||
ASSERT( isWritable );
|
ASSERT(isWritable);
|
||||||
|
|
||||||
ftruncate( fileno(mpData->mpCurrStream), offset );
|
ftruncate(fileno(mpData->mpCurrStream), offset);
|
||||||
if( GetSize() != offset )
|
if (GetSize() != offset)
|
||||||
throw( eFileTrunc( mpData->mFileName, iFSServices::GetInstance()->GetErrString() ) );
|
throw(eFileTrunc(mpData->mFileName, iFSServices::GetInstance()->GetErrString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -472,7 +476,7 @@ bool cDosPath::IsAbsolutePath(const TSTRING& in)
|
||||||
}
|
}
|
||||||
|
|
||||||
// For paths of type C:\DOS
|
// For paths of type C:\DOS
|
||||||
TSTRING cDosPath::AsPosix( const TSTRING& in )
|
TSTRING cDosPath::AsPosix(const TSTRING& in)
|
||||||
{
|
{
|
||||||
if (in[0] == '/')
|
if (in[0] == '/')
|
||||||
{
|
{
|
||||||
|
@ -481,12 +485,12 @@ TSTRING cDosPath::AsPosix( const TSTRING& in )
|
||||||
|
|
||||||
TSTRING out = (cDosPath::IsAbsolutePath(in)) ? ("/dev/" + in) : in;
|
TSTRING out = (cDosPath::IsAbsolutePath(in)) ? ("/dev/" + in) : in;
|
||||||
std::replace(out.begin(), out.end(), '\\', '/');
|
std::replace(out.begin(), out.end(), '\\', '/');
|
||||||
out.erase( std::remove(out.begin(), out.end(), ':'), out.end());
|
out.erase(std::remove(out.begin(), out.end(), ':'), out.end());
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
TSTRING cDosPath::AsNative( const TSTRING& in )
|
TSTRING cDosPath::AsNative(const TSTRING& in)
|
||||||
{
|
{
|
||||||
if (in[0] != '/')
|
if (in[0] != '/')
|
||||||
{
|
{
|
||||||
|
@ -495,10 +499,10 @@ TSTRING cDosPath::AsNative( const TSTRING& in )
|
||||||
|
|
||||||
if (in.find("/dev") != 0 || in.length() < 6)
|
if (in.find("/dev") != 0 || in.length() < 6)
|
||||||
return in;
|
return in;
|
||||||
|
|
||||||
TSTRING out = "?:/";
|
TSTRING out = "?:/";
|
||||||
out[0] = in[5];
|
out[0] = in[5];
|
||||||
|
|
||||||
if (in.length() >= 8)
|
if (in.length() >= 8)
|
||||||
out.append(in.substr(7));
|
out.append(in.substr(7));
|
||||||
|
|
||||||
|
@ -507,15 +511,15 @@ TSTRING cDosPath::AsNative( const TSTRING& in )
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
TSTRING cDosPath::BackupName( const TSTRING& in )
|
TSTRING cDosPath::BackupName(const TSTRING& in)
|
||||||
{
|
{
|
||||||
TSTRING out = in;
|
TSTRING out = in;
|
||||||
std::string::size_type pos = out.find_last_of("\\");
|
std::string::size_type pos = out.find_last_of("\\");
|
||||||
if( std::string::npos == pos)
|
if (std::string::npos == pos)
|
||||||
return in;
|
return in;
|
||||||
|
|
||||||
TSTRING path = in.substr(0, pos);
|
TSTRING path = in.substr(0, pos);
|
||||||
TSTRING name = in.substr(pos,9);
|
TSTRING name = in.substr(pos, 9);
|
||||||
std::replace(name.begin(), name.end(), '.', '_');
|
std::replace(name.begin(), name.end(), '.', '_');
|
||||||
path.append(name);
|
path.append(name);
|
||||||
|
|
||||||
|
@ -527,7 +531,7 @@ bool cArosPath::IsAbsolutePath(const TSTRING& in)
|
||||||
{
|
{
|
||||||
if (in.empty())
|
if (in.empty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (in[0] == '/')
|
if (in[0] == '/')
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
@ -538,7 +542,7 @@ bool cArosPath::IsAbsolutePath(const TSTRING& in)
|
||||||
}
|
}
|
||||||
|
|
||||||
// For paths of type DH0:dir/file
|
// For paths of type DH0:dir/file
|
||||||
TSTRING cArosPath::AsPosix( const TSTRING& in )
|
TSTRING cArosPath::AsPosix(const TSTRING& in)
|
||||||
{
|
{
|
||||||
if (in[0] == '/')
|
if (in[0] == '/')
|
||||||
{
|
{
|
||||||
|
@ -551,7 +555,7 @@ TSTRING cArosPath::AsPosix( const TSTRING& in )
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
TSTRING cArosPath::AsNative( const TSTRING& in )
|
TSTRING cArosPath::AsNative(const TSTRING& in)
|
||||||
{
|
{
|
||||||
if (in[0] != '/')
|
if (in[0] != '/')
|
||||||
{
|
{
|
||||||
|
@ -559,9 +563,9 @@ TSTRING cArosPath::AsNative( const TSTRING& in )
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string::size_type drive = in.find_first_not_of("/");
|
std::string::size_type drive = in.find_first_not_of("/");
|
||||||
TSTRING out = (drive != std::string::npos) ? in.substr(drive) : in;
|
TSTRING out = (drive != std::string::npos) ? in.substr(drive) : in;
|
||||||
TSTRING::size_type t = out.find_first_of('/');
|
TSTRING::size_type t = out.find_first_of('/');
|
||||||
if(t != std::string::npos)
|
if (t != std::string::npos)
|
||||||
out[t] = ':';
|
out[t] = ':';
|
||||||
else
|
else
|
||||||
out.append(":");
|
out.append(":");
|
||||||
|
@ -574,7 +578,7 @@ bool cRiscosPath::IsAbsolutePath(const TSTRING& in)
|
||||||
{
|
{
|
||||||
if (in.empty())
|
if (in.empty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (in[0] == '/')
|
if (in[0] == '/')
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
@ -585,7 +589,7 @@ bool cRiscosPath::IsAbsolutePath(const TSTRING& in)
|
||||||
}
|
}
|
||||||
|
|
||||||
// For paths of type SDFS::Volume.$.dir.file
|
// For paths of type SDFS::Volume.$.dir.file
|
||||||
TSTRING cRiscosPath::AsPosix( const TSTRING& in )
|
TSTRING cRiscosPath::AsPosix(const TSTRING& in)
|
||||||
{
|
{
|
||||||
#if IS_RISCOS
|
#if IS_RISCOS
|
||||||
if (in[0] == '/')
|
if (in[0] == '/')
|
||||||
|
@ -594,8 +598,8 @@ TSTRING cRiscosPath::AsPosix( const TSTRING& in )
|
||||||
}
|
}
|
||||||
|
|
||||||
TSTRING out;
|
TSTRING out;
|
||||||
char* unixified = __unixify(in.c_str(), 0,0,0,0);
|
char* unixified = __unixify(in.c_str(), 0, 0, 0, 0);
|
||||||
if(unixified)
|
if (unixified)
|
||||||
{
|
{
|
||||||
out.assign(unixified);
|
out.assign(unixified);
|
||||||
free(unixified);
|
free(unixified);
|
||||||
|
@ -608,7 +612,7 @@ TSTRING cRiscosPath::AsPosix( const TSTRING& in )
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
TSTRING cRiscosPath::AsNative( const TSTRING& in )
|
TSTRING cRiscosPath::AsNative(const TSTRING& in)
|
||||||
{
|
{
|
||||||
#if IS_RISCOS
|
#if IS_RISCOS
|
||||||
if (in[0] != '/')
|
if (in[0] != '/')
|
||||||
|
@ -616,11 +620,11 @@ TSTRING cRiscosPath::AsNative( const TSTRING& in )
|
||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
TSTRING out;
|
TSTRING out;
|
||||||
int buf_size = in.length() + 100; // examples pad by 100
|
int buf_size = in.length() + 100; // examples pad by 100
|
||||||
std::vector<char> buf(buf_size);
|
std::vector<char> buf(buf_size);
|
||||||
__riscosify(in.c_str(), 0,0, &buf[0], buf_size, 0);
|
__riscosify(in.c_str(), 0, 0, &buf[0], buf_size, 0);
|
||||||
if(buf[0])
|
if (buf[0])
|
||||||
{
|
{
|
||||||
out.assign(&buf[0]);
|
out.assign(&buf[0]);
|
||||||
return out;
|
return out;
|
||||||
|
@ -637,7 +641,7 @@ bool cRedoxPath::IsAbsolutePath(const TSTRING& in)
|
||||||
{
|
{
|
||||||
if (in.empty())
|
if (in.empty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (in[0] == '/')
|
if (in[0] == '/')
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
@ -648,21 +652,21 @@ bool cRedoxPath::IsAbsolutePath(const TSTRING& in)
|
||||||
}
|
}
|
||||||
|
|
||||||
// For paths of type file:/dir/file
|
// For paths of type file:/dir/file
|
||||||
TSTRING cRedoxPath::AsPosix( const TSTRING& in )
|
TSTRING cRedoxPath::AsPosix(const TSTRING& in)
|
||||||
{
|
{
|
||||||
if (in[0] == '/')
|
if (in[0] == '/')
|
||||||
{
|
{
|
||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
TSTRING out = IsAbsolutePath(in) ? '/' + in : in;
|
TSTRING out = IsAbsolutePath(in) ? '/' + in : in;
|
||||||
std::string::size_type colon = out.find_first_of(":");
|
std::string::size_type colon = out.find_first_of(":");
|
||||||
if( colon != std::string::npos )
|
if (colon != std::string::npos)
|
||||||
out.erase(colon, 1);
|
out.erase(colon, 1);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
TSTRING cRedoxPath::AsNative( const TSTRING& in )
|
TSTRING cRedoxPath::AsNative(const TSTRING& in)
|
||||||
{
|
{
|
||||||
if (in[0] != '/')
|
if (in[0] != '/')
|
||||||
{
|
{
|
||||||
|
@ -670,9 +674,9 @@ TSTRING cRedoxPath::AsNative( const TSTRING& in )
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string::size_type drive = in.find_first_not_of("/");
|
std::string::size_type drive = in.find_first_not_of("/");
|
||||||
TSTRING out = (drive != std::string::npos) ? in.substr(drive) : in;
|
TSTRING out = (drive != std::string::npos) ? in.substr(drive) : in;
|
||||||
TSTRING::size_type slash = out.find_first_of('/');
|
TSTRING::size_type slash = out.find_first_of('/');
|
||||||
if(slash != std::string::npos)
|
if (slash != std::string::npos)
|
||||||
out.insert(slash, ":");
|
out.insert(slash, ":");
|
||||||
else
|
else
|
||||||
out.append(":/");
|
out.append(":/");
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
//
|
//
|
||||||
// The developer of the original code and/or files is Tripwire, Inc.
|
// The developer of the original code and/or files is Tripwire, Inc.
|
||||||
// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire,
|
// Portions created by Tripwire, Inc. are copyright (C) 2000-2018 Tripwire,
|
||||||
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
||||||
// reserved.
|
// reserved.
|
||||||
//
|
//
|
||||||
// This program is free software. The contents of this file are subject
|
// 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
|
// 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
|
// Free Software Foundation; either version 2 of the License, or (at your
|
||||||
// option) any later version. You may redistribute it and/or modify it
|
// option) any later version. You may redistribute it and/or modify it
|
||||||
// only in compliance with the GNU General Public License.
|
// only in compliance with the GNU General Public License.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful.
|
// This program is distributed in the hope that it will be useful.
|
||||||
// However, this program is distributed AS-IS WITHOUT ANY
|
// However, this program is distributed AS-IS WITHOUT ANY
|
||||||
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
||||||
// for more details.
|
// for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
// USA.
|
// USA.
|
||||||
//
|
//
|
||||||
// Nothing in the GNU General Public License or any other license to use
|
// 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,
|
// the code or files shall permit you to use Tripwire's trademarks,
|
||||||
// service marks, or other intellectual property without Tripwire's
|
// service marks, or other intellectual property without Tripwire's
|
||||||
// prior written consent.
|
// prior written consent.
|
||||||
//
|
//
|
||||||
// If you have any questions, please contact Tripwire, Inc. at either
|
// If you have any questions, please contact Tripwire, Inc. at either
|
||||||
// info@tripwire.org or www.tripwire.org.
|
// info@tripwire.org or www.tripwire.org.
|
||||||
//
|
//
|
||||||
|
@ -37,11 +37,10 @@
|
||||||
#include "corestrings.h"
|
#include "corestrings.h"
|
||||||
|
|
||||||
// TODO: Make this use MakeFileError() for consistency
|
// TODO: Make this use MakeFileError() for consistency
|
||||||
eFileError::eFileError( const TSTRING& filename, const TSTRING& description, uint32 flags )
|
eFileError::eFileError(const TSTRING& filename, const TSTRING& description, uint32 flags) : eError(_T(""), flags)
|
||||||
: eError( _T(""), flags )
|
|
||||||
{
|
{
|
||||||
mFilename = filename;
|
mFilename = filename;
|
||||||
mMsg = description;
|
mMsg = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
TSTRING eFileError::GetFilename() const
|
TSTRING eFileError::GetFilename() const
|
||||||
|
@ -58,14 +57,14 @@ TSTRING eFileError::GetDescription() const
|
||||||
{
|
{
|
||||||
TSTRING ret;
|
TSTRING ret;
|
||||||
|
|
||||||
if( ! mFilename.empty() )
|
if (!mFilename.empty())
|
||||||
{
|
{
|
||||||
ret = TSS_GetString( cCore, core::STR_ERROR_FILENAME ) + mFilename;
|
ret = TSS_GetString(cCore, core::STR_ERROR_FILENAME) + mFilename;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ! mMsg.empty() )
|
if (!mMsg.empty())
|
||||||
{
|
{
|
||||||
if ( ! mFilename.empty() )
|
if (!mFilename.empty())
|
||||||
ret += _T("\n");
|
ret += _T("\n");
|
||||||
|
|
||||||
ret += mMsg;
|
ret += mMsg;
|
||||||
|
@ -73,4 +72,3 @@ TSTRING eFileError::GetDescription() const
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
//
|
//
|
||||||
// The developer of the original code and/or files is Tripwire, Inc.
|
// The developer of the original code and/or files is Tripwire, Inc.
|
||||||
// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire,
|
// Portions created by Tripwire, Inc. are copyright (C) 2000-2018 Tripwire,
|
||||||
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
||||||
// reserved.
|
// reserved.
|
||||||
//
|
//
|
||||||
// This program is free software. The contents of this file are subject
|
// 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
|
// 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
|
// Free Software Foundation; either version 2 of the License, or (at your
|
||||||
// option) any later version. You may redistribute it and/or modify it
|
// option) any later version. You may redistribute it and/or modify it
|
||||||
// only in compliance with the GNU General Public License.
|
// only in compliance with the GNU General Public License.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful.
|
// This program is distributed in the hope that it will be useful.
|
||||||
// However, this program is distributed AS-IS WITHOUT ANY
|
// However, this program is distributed AS-IS WITHOUT ANY
|
||||||
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
||||||
// for more details.
|
// for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
// USA.
|
// USA.
|
||||||
//
|
//
|
||||||
// Nothing in the GNU General Public License or any other license to use
|
// 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,
|
// the code or files shall permit you to use Tripwire's trademarks,
|
||||||
// service marks, or other intellectual property without Tripwire's
|
// service marks, or other intellectual property without Tripwire's
|
||||||
// prior written consent.
|
// prior written consent.
|
||||||
//
|
//
|
||||||
// If you have any questions, please contact Tripwire, Inc. at either
|
// If you have any questions, please contact Tripwire, Inc. at either
|
||||||
// info@tripwire.org or www.tripwire.org.
|
// info@tripwire.org or www.tripwire.org.
|
||||||
//
|
//
|
||||||
|
@ -51,30 +51,33 @@
|
||||||
// ### Insufficient permission to open file. <-- constructor parameter "msg"
|
// ### Insufficient permission to open file. <-- constructor parameter "msg"
|
||||||
// ### Exiting... <-- appropriate third message
|
// ### Exiting... <-- appropriate third message
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
TSS_BEGIN_EXCEPTION_NO_CTOR( eFileError, eError )
|
TSS_BEGIN_EXCEPTION_NO_CTOR(eFileError, eError)
|
||||||
private:
|
private:
|
||||||
TSTRING mFilename;
|
TSTRING mFilename;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
eFileError( const TSTRING& filename, const TSTRING& description, uint32 flags = 0 );
|
eFileError(const TSTRING& filename, const TSTRING& description, uint32 flags = 0);
|
||||||
|
|
||||||
explicit eFileError( const eFileError& rhs )
|
explicit eFileError(const eFileError& rhs) : eError(rhs)
|
||||||
: eError( rhs ) { mFilename = rhs.mFilename; }
|
{
|
||||||
eFileError( const TSTRING& msg, uint32 flags = 0 )
|
mFilename = rhs.mFilename;
|
||||||
: eError( msg, flags ) {}
|
}
|
||||||
|
eFileError(const TSTRING& msg, uint32 flags = 0) : eError(msg, flags)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
TSTRING GetFilename() const;
|
TSTRING GetFilename() const;
|
||||||
TSTRING GetDescription() const;
|
TSTRING GetDescription() const;
|
||||||
virtual TSTRING GetMsg() const;
|
virtual TSTRING GetMsg() const;
|
||||||
|
|
||||||
TSS_END_EXCEPTION()
|
TSS_END_EXCEPTION()
|
||||||
|
|
||||||
#define TSS_FILE_EXCEPTION( except, base ) \
|
# define TSS_FILE_EXCEPTION(except, base) \
|
||||||
TSS_BEGIN_EXCEPTION( except, base ) \
|
TSS_BEGIN_EXCEPTION(except, base) \
|
||||||
except( const TSTRING& filename, const TSTRING& msg, uint32 flags = 0 ) \
|
except(const TSTRING& filename, const TSTRING& msg, uint32 flags = 0) : base(filename, msg, flags) \
|
||||||
: base( filename, msg, flags ) {} \
|
{ \
|
||||||
TSS_END_EXCEPTION()
|
} \
|
||||||
|
TSS_END_EXCEPTION()
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
//
|
//
|
||||||
// The developer of the original code and/or files is Tripwire, Inc.
|
// The developer of the original code and/or files is Tripwire, Inc.
|
||||||
// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire,
|
// Portions created by Tripwire, Inc. are copyright (C) 2000-2018 Tripwire,
|
||||||
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
||||||
// reserved.
|
// reserved.
|
||||||
//
|
//
|
||||||
// This program is free software. The contents of this file are subject
|
// 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
|
// 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
|
// Free Software Foundation; either version 2 of the License, or (at your
|
||||||
// option) any later version. You may redistribute it and/or modify it
|
// option) any later version. You may redistribute it and/or modify it
|
||||||
// only in compliance with the GNU General Public License.
|
// only in compliance with the GNU General Public License.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful.
|
// This program is distributed in the hope that it will be useful.
|
||||||
// However, this program is distributed AS-IS WITHOUT ANY
|
// However, this program is distributed AS-IS WITHOUT ANY
|
||||||
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
||||||
// for more details.
|
// for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
// USA.
|
// USA.
|
||||||
//
|
//
|
||||||
// Nothing in the GNU General Public License or any other license to use
|
// 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,
|
// the code or files shall permit you to use Tripwire's trademarks,
|
||||||
// service marks, or other intellectual property without Tripwire's
|
// service marks, or other intellectual property without Tripwire's
|
||||||
// prior written consent.
|
// prior written consent.
|
||||||
//
|
//
|
||||||
// If you have any questions, please contact Tripwire, Inc. at either
|
// If you have any questions, please contact Tripwire, Inc. at either
|
||||||
// info@tripwire.org or www.tripwire.org.
|
// info@tripwire.org or www.tripwire.org.
|
||||||
//
|
//
|
||||||
|
@ -38,10 +38,10 @@
|
||||||
#include "ntmbs.h"
|
#include "ntmbs.h"
|
||||||
|
|
||||||
// A magic number to put at top of file headers
|
// A magic number to put at top of file headers
|
||||||
// I changed this magic number in 2.1 since we now support versioning in the file header.
|
// I changed this magic number in 2.1 since we now support versioning in the file header.
|
||||||
// (the old magic number was 0x00202039)
|
// (the old magic number was 0x00202039)
|
||||||
// I generated the random number using the random.org web site.
|
// I generated the random number using the random.org web site.
|
||||||
const uint32 FILE_HEADER_MAGIC_NUMBER = 0x78f9beb3;
|
const uint32 FILE_HEADER_MAGIC_NUMBER = 0x78f9beb3;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// class cFileHeaderID
|
// class cFileHeaderID
|
||||||
|
@ -50,48 +50,46 @@ cFileHeaderID::~cFileHeaderID()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void cFileHeaderID::operator=( const TCHAR* pszId )
|
void cFileHeaderID::operator=(const TCHAR* pszId)
|
||||||
{
|
{
|
||||||
// RAD:10/1/99 -- Not Needed
|
// RAD:10/1/99 -- Not Needed
|
||||||
// TODO:BAM -- I'm pretty sure that there's a bug hiding here...
|
// TODO:BAM -- I'm pretty sure that there's a bug hiding here...
|
||||||
//size_t len = _tcslen(id);
|
//size_t len = _tcslen(id);
|
||||||
//if (len >= 256)
|
//if (len >= 256)
|
||||||
//{
|
//{
|
||||||
// ASSERT(false);
|
// ASSERT(false);
|
||||||
// mIDLen = 0;
|
// mIDLen = 0;
|
||||||
// return;
|
// return;
|
||||||
//}
|
//}
|
||||||
|
|
||||||
size_t N = ::strlen( pszId );
|
|
||||||
if ( !(N < cFileHeaderID::MAXBYTES) )
|
|
||||||
throw eCharacter( TSS_GetString( cCore, core::STR_ERR_OVERFLOW ) );
|
|
||||||
|
|
||||||
mIDLen = static_cast<int16>( N ); // know len is less than MAXBYTES
|
size_t N = ::strlen(pszId);
|
||||||
::memcpy( mID, pszId, N * sizeof(char) );
|
if (!(N < cFileHeaderID::MAXBYTES))
|
||||||
|
throw eCharacter(TSS_GetString(cCore, core::STR_ERR_OVERFLOW));
|
||||||
|
|
||||||
|
mIDLen = static_cast<int16>(N); // know len is less than MAXBYTES
|
||||||
|
::memcpy(mID, pszId, N * sizeof(char));
|
||||||
}
|
}
|
||||||
|
|
||||||
void cFileHeaderID::operator=( const cFileHeaderID& rhs )
|
void cFileHeaderID::operator=(const cFileHeaderID& rhs)
|
||||||
{
|
{
|
||||||
ASSERT( rhs.mIDLen < cFileHeaderID::MAXBYTES );
|
ASSERT(rhs.mIDLen < cFileHeaderID::MAXBYTES);
|
||||||
mIDLen = rhs.mIDLen;
|
mIDLen = rhs.mIDLen;
|
||||||
memcpy(mID, rhs.mID, mIDLen * sizeof(char));
|
memcpy(mID, rhs.mID, mIDLen * sizeof(char));
|
||||||
}
|
}
|
||||||
|
|
||||||
int cFileHeaderID::operator==( const cFileHeaderID& rhs ) const
|
int cFileHeaderID::operator==(const cFileHeaderID& rhs) const
|
||||||
{
|
{
|
||||||
return
|
return (mIDLen == rhs.mIDLen) && (::memcmp(mID, rhs.mID, mIDLen * sizeof(char)) == 0);
|
||||||
( mIDLen == rhs.mIDLen ) &&
|
|
||||||
( ::memcmp( mID, rhs.mID, mIDLen * sizeof(char) ) == 0 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cFileHeaderID::Read(iSerializer* pSerializer, int32 /*version*/ ) // throw (eSerializer, eArchive)
|
void cFileHeaderID::Read(iSerializer* pSerializer, int32 /*version*/) // throw (eSerializer, eArchive)
|
||||||
{
|
{
|
||||||
int16 len;
|
int16 len;
|
||||||
pSerializer->ReadInt16( len );
|
pSerializer->ReadInt16(len);
|
||||||
if ( (len < 0) || (len >= cFileHeaderID::MAXBYTES ))
|
if ((len < 0) || (len >= cFileHeaderID::MAXBYTES))
|
||||||
{
|
{
|
||||||
// this is invalid!
|
// this is invalid!
|
||||||
throw eSerializerInputStreamFmt( _T("File Header ID invalid") );
|
throw eSerializerInputStreamFmt(_T("File Header ID invalid"));
|
||||||
}
|
}
|
||||||
pSerializer->ReadBlob(mID, len * sizeof(char));
|
pSerializer->ReadBlob(mID, len * sizeof(char));
|
||||||
mIDLen = len;
|
mIDLen = len;
|
||||||
|
@ -99,17 +97,16 @@ void cFileHeaderID::Read(iSerializer* pSerializer, int32 /*version*/ ) // throw
|
||||||
|
|
||||||
void cFileHeaderID::Write(iSerializer* pSerializer) const // throw (eSerializer, eArchive)
|
void cFileHeaderID::Write(iSerializer* pSerializer) const // throw (eSerializer, eArchive)
|
||||||
{
|
{
|
||||||
ASSERT( mIDLen >= 0 && mIDLen < cFileHeaderID::MAXBYTES );
|
ASSERT(mIDLen >= 0 && mIDLen < cFileHeaderID::MAXBYTES);
|
||||||
|
|
||||||
pSerializer->WriteInt16( mIDLen );
|
pSerializer->WriteInt16(mIDLen);
|
||||||
pSerializer->WriteBlob( mID, mIDLen * sizeof(char) );
|
pSerializer->WriteBlob(mID, mIDLen * sizeof(char));
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// class cFileHeader
|
// class cFileHeader
|
||||||
|
|
||||||
cFileHeader::cFileHeader()
|
cFileHeader::cFileHeader() : mVersion(0)
|
||||||
: mVersion(0)
|
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
mEncoding = LAST_ENCODING; // set to invalid value so we can assert on write
|
mEncoding = LAST_ENCODING; // set to invalid value so we can assert on write
|
||||||
|
@ -119,20 +116,14 @@ cFileHeader::cFileHeader()
|
||||||
}
|
}
|
||||||
|
|
||||||
cFileHeader::cFileHeader(const cFileHeader& rhs)
|
cFileHeader::cFileHeader(const cFileHeader& rhs)
|
||||||
: iSerializable(),
|
: iSerializable(), mID(rhs.mID), mVersion(rhs.mVersion), mEncoding(rhs.mEncoding)
|
||||||
mID(rhs.mID),
|
|
||||||
mVersion(rhs.mVersion),
|
|
||||||
mEncoding(rhs.mEncoding)
|
|
||||||
{
|
{
|
||||||
if (rhs.mBaggage.Length() > 0)
|
if (rhs.mBaggage.Length() > 0)
|
||||||
{
|
{
|
||||||
mBaggage.MapArchive(0, rhs.mBaggage.Length());
|
mBaggage.MapArchive(0, rhs.mBaggage.Length());
|
||||||
rhs.mBaggage.MapArchive(0, rhs.mBaggage.Length());
|
rhs.mBaggage.MapArchive(0, rhs.mBaggage.Length());
|
||||||
|
|
||||||
::memcpy(
|
::memcpy(mBaggage.GetMap(), rhs.mBaggage.GetMap(), static_cast<size_t>(rhs.mBaggage.Length()));
|
||||||
mBaggage.GetMap(),
|
|
||||||
rhs.mBaggage.GetMap(),
|
|
||||||
static_cast<size_t>( rhs.mBaggage.Length() ) );
|
|
||||||
|
|
||||||
mBaggage.MapArchive(0, 0);
|
mBaggage.MapArchive(0, 0);
|
||||||
rhs.mBaggage.MapArchive(0, 0);
|
rhs.mBaggage.MapArchive(0, 0);
|
||||||
|
@ -171,18 +162,18 @@ void cFileHeader::Read(iSerializer* pSerializer, int32 /*version*/) // throw (eS
|
||||||
if ((unsigned int)magicNumber != FILE_HEADER_MAGIC_NUMBER)
|
if ((unsigned int)magicNumber != FILE_HEADER_MAGIC_NUMBER)
|
||||||
{
|
{
|
||||||
d.TraceDebug("Bad magic number");
|
d.TraceDebug("Bad magic number");
|
||||||
throw eSerializerInputStreamFmt(pSerializer->GetFileName() );
|
throw eSerializerInputStreamFmt(pSerializer->GetFileName());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note this version refers to the format of this data structure in the
|
// Note this version refers to the format of this data structure in the
|
||||||
// file image. mVersion refers to the version of data that accompanies
|
// file image. mVersion refers to the version of data that accompanies
|
||||||
// this cFileHeader, for example the database or report format.
|
// this cFileHeader, for example the database or report format.
|
||||||
pSerializer->ReadInt32(version);
|
pSerializer->ReadInt32(version);
|
||||||
if (version > 1)
|
if (version > 1)
|
||||||
{
|
{
|
||||||
// don't understand the version
|
// don't understand the version
|
||||||
d.TraceDebug("Bad version");
|
d.TraceDebug("Bad version");
|
||||||
throw eSerializerInputStreamFmt(pSerializer->GetFileName() );
|
throw eSerializerInputStreamFmt(pSerializer->GetFileName());
|
||||||
}
|
}
|
||||||
|
|
||||||
mID.Read(pSerializer);
|
mID.Read(pSerializer);
|
||||||
|
@ -196,7 +187,7 @@ void cFileHeader::Read(iSerializer* pSerializer, int32 /*version*/) // throw (eS
|
||||||
pSerializer->ReadInt32(len);
|
pSerializer->ReadInt32(len);
|
||||||
|
|
||||||
if (len < 0 || len > 0xffff)
|
if (len < 0 || len > 0xffff)
|
||||||
throw eSerializerInputStreamFmt(pSerializer->GetFileName() );
|
throw eSerializerInputStreamFmt(pSerializer->GetFileName());
|
||||||
|
|
||||||
mBaggage.MapArchive(0, len);
|
mBaggage.MapArchive(0, len);
|
||||||
|
|
||||||
|
@ -220,12 +211,12 @@ void cFileHeader::Write(iSerializer* pSerializer) const // throw (eSerializer, e
|
||||||
ASSERT(mEncoding != LAST_ENCODING);
|
ASSERT(mEncoding != LAST_ENCODING);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// we need to have our own versioning since we are not
|
// we need to have our own versioning since we are not
|
||||||
// a iTypedSerializable object.
|
// a iTypedSerializable object.
|
||||||
pSerializer->WriteInt32(FILE_HEADER_MAGIC_NUMBER);
|
pSerializer->WriteInt32(FILE_HEADER_MAGIC_NUMBER);
|
||||||
|
|
||||||
// Note this version refers to the format of this data structure in the
|
// Note this version refers to the format of this data structure in the
|
||||||
// file image. mVersion refers to the version of data that accompanies
|
// file image. mVersion refers to the version of data that accompanies
|
||||||
// this cFileHeader, for example the database or report format.
|
// this cFileHeader, for example the database or report format.
|
||||||
pSerializer->WriteInt32(1); // version
|
pSerializer->WriteInt32(1); // version
|
||||||
|
|
||||||
|
@ -233,21 +224,20 @@ void cFileHeader::Write(iSerializer* pSerializer) const // throw (eSerializer, e
|
||||||
|
|
||||||
pSerializer->WriteInt32(mVersion);
|
pSerializer->WriteInt32(mVersion);
|
||||||
|
|
||||||
pSerializer->WriteInt16( static_cast<int16>(mEncoding) );
|
pSerializer->WriteInt16(static_cast<int16>(mEncoding));
|
||||||
|
|
||||||
int32 len = static_cast<int32>( mBaggage.Length() );
|
int32 len = static_cast<int32>(mBaggage.Length());
|
||||||
|
|
||||||
ASSERT(len >= 0);
|
ASSERT(len >= 0);
|
||||||
ASSERT(len <= 0xFFFF);
|
ASSERT(len <= 0xFFFF);
|
||||||
|
|
||||||
if ( len < 0 || len > 0xFFFF )
|
if (len < 0 || len > 0xFFFF)
|
||||||
throw eSerializerOutputStreamFmt();
|
throw eSerializerOutputStreamFmt();
|
||||||
|
|
||||||
pSerializer->WriteInt32(len);
|
pSerializer->WriteInt32(len);
|
||||||
if (len > 0)
|
if (len > 0)
|
||||||
{
|
{
|
||||||
mBaggage.MapArchive(0, len);
|
mBaggage.MapArchive(0, len);
|
||||||
pSerializer->WriteBlob(mBaggage.GetMap(), len);
|
pSerializer->WriteBlob(mBaggage.GetMap(), len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
//
|
//
|
||||||
// The developer of the original code and/or files is Tripwire, Inc.
|
// The developer of the original code and/or files is Tripwire, Inc.
|
||||||
// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire,
|
// Portions created by Tripwire, Inc. are copyright (C) 2000-2018 Tripwire,
|
||||||
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
||||||
// reserved.
|
// reserved.
|
||||||
//
|
//
|
||||||
// This program is free software. The contents of this file are subject
|
// 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
|
// 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
|
// Free Software Foundation; either version 2 of the License, or (at your
|
||||||
// option) any later version. You may redistribute it and/or modify it
|
// option) any later version. You may redistribute it and/or modify it
|
||||||
// only in compliance with the GNU General Public License.
|
// only in compliance with the GNU General Public License.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful.
|
// This program is distributed in the hope that it will be useful.
|
||||||
// However, this program is distributed AS-IS WITHOUT ANY
|
// However, this program is distributed AS-IS WITHOUT ANY
|
||||||
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
||||||
// for more details.
|
// for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
// USA.
|
// USA.
|
||||||
//
|
//
|
||||||
// Nothing in the GNU General Public License or any other license to use
|
// 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,
|
// the code or files shall permit you to use Tripwire's trademarks,
|
||||||
// service marks, or other intellectual property without Tripwire's
|
// service marks, or other intellectual property without Tripwire's
|
||||||
// prior written consent.
|
// prior written consent.
|
||||||
//
|
//
|
||||||
// If you have any questions, please contact Tripwire, Inc. at either
|
// If you have any questions, please contact Tripwire, Inc. at either
|
||||||
// info@tripwire.org or www.tripwire.org.
|
// info@tripwire.org or www.tripwire.org.
|
||||||
//
|
//
|
||||||
|
@ -54,13 +54,13 @@ public:
|
||||||
cFileHeaderID(const cFileHeaderID& rhs);
|
cFileHeaderID(const cFileHeaderID& rhs);
|
||||||
virtual ~cFileHeaderID();
|
virtual ~cFileHeaderID();
|
||||||
|
|
||||||
void operator = (const TCHAR* id);
|
void operator=(const TCHAR* id);
|
||||||
void operator = (const cFileHeaderID& rhs);
|
void operator=(const cFileHeaderID& rhs);
|
||||||
int operator == (const cFileHeaderID& rhs) const;
|
int operator==(const cFileHeaderID& rhs) const;
|
||||||
int operator != (const cFileHeaderID& rhs) const;
|
int operator!=(const cFileHeaderID& rhs) const;
|
||||||
|
|
||||||
virtual void Read (iSerializer* pSerializer, int32 version = 0); // throw (eSerializer, eArchive)
|
virtual void Read(iSerializer* pSerializer, int32 version = 0); // throw (eSerializer, eArchive)
|
||||||
virtual void Write(iSerializer* pSerializer) const; // throw (eSerializer, eArchive)
|
virtual void Write(iSerializer* pSerializer) const; // throw (eSerializer, eArchive)
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// For now we will store the id as a string.
|
// For now we will store the id as a string.
|
||||||
|
@ -68,10 +68,13 @@ private:
|
||||||
// the way we implemented cFCONames.
|
// the way we implemented cFCONames.
|
||||||
// Note: We store the string as narrow chars, since
|
// Note: We store the string as narrow chars, since
|
||||||
// the program is the only person who will see them.
|
// the program is the only person who will see them.
|
||||||
int16 mIDLen;
|
int16 mIDLen;
|
||||||
|
|
||||||
enum { MAXBYTES = 256 };
|
enum
|
||||||
char mID[ MAXBYTES ];
|
{
|
||||||
|
MAXBYTES = 256
|
||||||
|
};
|
||||||
|
char mID[MAXBYTES];
|
||||||
};
|
};
|
||||||
|
|
||||||
inline cFileHeaderID::cFileHeaderID()
|
inline cFileHeaderID::cFileHeaderID()
|
||||||
|
@ -84,14 +87,12 @@ inline cFileHeaderID::cFileHeaderID(const TCHAR* id)
|
||||||
*this = id;
|
*this = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
inline cFileHeaderID::cFileHeaderID(const cFileHeaderID& rhs) : iSerializable(), mIDLen(rhs.mIDLen)
|
||||||
cFileHeaderID::cFileHeaderID( const cFileHeaderID& rhs ) :
|
|
||||||
iSerializable(), mIDLen( rhs.mIDLen )
|
|
||||||
{
|
{
|
||||||
memcpy( mID, rhs.mID, MAXBYTES );
|
memcpy(mID, rhs.mID, MAXBYTES);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int cFileHeaderID::operator != (const cFileHeaderID& rhs) const
|
inline int cFileHeaderID::operator!=(const cFileHeaderID& rhs) const
|
||||||
{
|
{
|
||||||
return !(*this == rhs);
|
return !(*this == rhs);
|
||||||
}
|
}
|
||||||
|
@ -115,26 +116,26 @@ public:
|
||||||
LAST_ENCODING
|
LAST_ENCODING
|
||||||
};
|
};
|
||||||
|
|
||||||
void SetID(const cFileHeaderID& id);
|
void SetID(const cFileHeaderID& id);
|
||||||
const cFileHeaderID& GetID() const;
|
const cFileHeaderID& GetID() const;
|
||||||
|
|
||||||
void SetVersion(uint32 v);
|
void SetVersion(uint32 v);
|
||||||
uint32 GetVersion() const;
|
uint32 GetVersion() const;
|
||||||
|
|
||||||
void SetEncoding(Encoding e);
|
void SetEncoding(Encoding e);
|
||||||
Encoding GetEncoding() const;
|
Encoding GetEncoding() const;
|
||||||
|
|
||||||
cMemoryArchive& GetBaggage();
|
cMemoryArchive& GetBaggage();
|
||||||
const cMemoryArchive& GetBaggage() const;
|
const cMemoryArchive& GetBaggage() const;
|
||||||
|
|
||||||
virtual void Read (iSerializer* pSerializer, int32 version = 0); // throw (eSerializer, eArchive)
|
virtual void Read(iSerializer* pSerializer, int32 version = 0); // throw (eSerializer, eArchive)
|
||||||
virtual void Write(iSerializer* pSerializer) const; // throw (eSerializer, eArchive)
|
virtual void Write(iSerializer* pSerializer) const; // throw (eSerializer, eArchive)
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
cFileHeaderID mID;
|
cFileHeaderID mID;
|
||||||
uint32 mVersion;
|
uint32 mVersion;
|
||||||
Encoding mEncoding;
|
Encoding mEncoding;
|
||||||
cMemoryArchive mBaggage; // items that have been serialized to this object
|
cMemoryArchive mBaggage; // items that have been serialized to this object
|
||||||
};
|
};
|
||||||
|
|
||||||
inline const cFileHeaderID& cFileHeader::GetID() const
|
inline const cFileHeaderID& cFileHeader::GetID() const
|
||||||
|
@ -163,4 +164,3 @@ inline const cMemoryArchive& cFileHeader::GetBaggage() const
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
//
|
//
|
||||||
// The developer of the original code and/or files is Tripwire, Inc.
|
// The developer of the original code and/or files is Tripwire, Inc.
|
||||||
// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire,
|
// Portions created by Tripwire, Inc. are copyright (C) 2000-2018 Tripwire,
|
||||||
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
||||||
// reserved.
|
// reserved.
|
||||||
//
|
//
|
||||||
// This program is free software. The contents of this file are subject
|
// 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
|
// 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
|
// Free Software Foundation; either version 2 of the License, or (at your
|
||||||
// option) any later version. You may redistribute it and/or modify it
|
// option) any later version. You may redistribute it and/or modify it
|
||||||
// only in compliance with the GNU General Public License.
|
// only in compliance with the GNU General Public License.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful.
|
// This program is distributed in the hope that it will be useful.
|
||||||
// However, this program is distributed AS-IS WITHOUT ANY
|
// However, this program is distributed AS-IS WITHOUT ANY
|
||||||
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
||||||
// for more details.
|
// for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
// USA.
|
// USA.
|
||||||
//
|
//
|
||||||
// Nothing in the GNU General Public License or any other license to use
|
// 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,
|
// the code or files shall permit you to use Tripwire's trademarks,
|
||||||
// service marks, or other intellectual property without Tripwire's
|
// service marks, or other intellectual property without Tripwire's
|
||||||
// prior written consent.
|
// prior written consent.
|
||||||
//
|
//
|
||||||
// If you have any questions, please contact Tripwire, Inc. at either
|
// If you have any questions, please contact Tripwire, Inc. at either
|
||||||
// info@tripwire.org or www.tripwire.org.
|
// info@tripwire.org or www.tripwire.org.
|
||||||
//
|
//
|
||||||
|
@ -34,8 +34,8 @@
|
||||||
// Date....: 8/12/99
|
// Date....: 8/12/99
|
||||||
// Creator.: Brian McFeely (bmcfeely)
|
// Creator.: Brian McFeely (bmcfeely)
|
||||||
//
|
//
|
||||||
// Plauger's 'basic_filebuf::overflow' had a bug,
|
// Plauger's 'basic_filebuf::overflow' had a bug,
|
||||||
// so I had to reimplement the entire class.
|
// so I had to reimplement the entire class.
|
||||||
//
|
//
|
||||||
// Plauger had a line: "fwrite(_Str->begin(), _N, 1, _File)"
|
// Plauger had a line: "fwrite(_Str->begin(), _N, 1, _File)"
|
||||||
// that should have been: "fwrite(_Str->begin(), 1, _N, _File)"
|
// that should have been: "fwrite(_Str->begin(), 1, _N, _File)"
|
||||||
|
@ -47,5 +47,4 @@
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#define fixed_basic_ofstream std::basic_ofstream
|
#define fixed_basic_ofstream std::basic_ofstream
|
||||||
|
|
||||||
#endif//__FIXED_FILEBUF_H
|
#endif //__FIXED_FILEBUF_H
|
||||||
|
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
//
|
//
|
||||||
// The developer of the original code and/or files is Tripwire, Inc.
|
// The developer of the original code and/or files is Tripwire, Inc.
|
||||||
// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire,
|
// Portions created by Tripwire, Inc. are copyright (C) 2000-2018 Tripwire,
|
||||||
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
||||||
// reserved.
|
// reserved.
|
||||||
//
|
//
|
||||||
// This program is free software. The contents of this file are subject
|
// 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
|
// 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
|
// Free Software Foundation; either version 2 of the License, or (at your
|
||||||
// option) any later version. You may redistribute it and/or modify it
|
// option) any later version. You may redistribute it and/or modify it
|
||||||
// only in compliance with the GNU General Public License.
|
// only in compliance with the GNU General Public License.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful.
|
// This program is distributed in the hope that it will be useful.
|
||||||
// However, this program is distributed AS-IS WITHOUT ANY
|
// However, this program is distributed AS-IS WITHOUT ANY
|
||||||
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
||||||
// for more details.
|
// for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
// USA.
|
// USA.
|
||||||
//
|
//
|
||||||
// Nothing in the GNU General Public License or any other license to use
|
// 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,
|
// the code or files shall permit you to use Tripwire's trademarks,
|
||||||
// service marks, or other intellectual property without Tripwire's
|
// service marks, or other intellectual property without Tripwire's
|
||||||
// prior written consent.
|
// prior written consent.
|
||||||
//
|
//
|
||||||
// If you have any questions, please contact Tripwire, Inc. at either
|
// If you have any questions, please contact Tripwire, Inc. at either
|
||||||
// info@tripwire.org or www.tripwire.org.
|
// info@tripwire.org or www.tripwire.org.
|
||||||
//
|
//
|
||||||
|
@ -43,5 +43,3 @@ iFSServices* iFSServices::mpInstance = 0;
|
||||||
//#############################################################################
|
//#############################################################################
|
||||||
// eFSServices
|
// eFSServices
|
||||||
//#############################################################################
|
//#############################################################################
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
//
|
//
|
||||||
// The developer of the original code and/or files is Tripwire, Inc.
|
// The developer of the original code and/or files is Tripwire, Inc.
|
||||||
// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire,
|
// Portions created by Tripwire, Inc. are copyright (C) 2000-2018 Tripwire,
|
||||||
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
||||||
// reserved.
|
// reserved.
|
||||||
//
|
//
|
||||||
// This program is free software. The contents of this file are subject
|
// 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
|
// 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
|
// Free Software Foundation; either version 2 of the License, or (at your
|
||||||
// option) any later version. You may redistribute it and/or modify it
|
// option) any later version. You may redistribute it and/or modify it
|
||||||
// only in compliance with the GNU General Public License.
|
// only in compliance with the GNU General Public License.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful.
|
// This program is distributed in the hope that it will be useful.
|
||||||
// However, this program is distributed AS-IS WITHOUT ANY
|
// However, this program is distributed AS-IS WITHOUT ANY
|
||||||
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
||||||
// for more details.
|
// for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
// USA.
|
// USA.
|
||||||
//
|
//
|
||||||
// Nothing in the GNU General Public License or any other license to use
|
// 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,
|
// the code or files shall permit you to use Tripwire's trademarks,
|
||||||
// service marks, or other intellectual property without Tripwire's
|
// service marks, or other intellectual property without Tripwire's
|
||||||
// prior written consent.
|
// prior written consent.
|
||||||
//
|
//
|
||||||
// If you have any questions, please contact Tripwire, Inc. at either
|
// If you have any questions, please contact Tripwire, Inc. at either
|
||||||
// info@tripwire.org or www.tripwire.org.
|
// info@tripwire.org or www.tripwire.org.
|
||||||
//
|
//
|
||||||
|
@ -36,7 +36,7 @@
|
||||||
//
|
//
|
||||||
// objective:
|
// objective:
|
||||||
// abstract all file system calls, except for reading/writing
|
// abstract all file system calls, except for reading/writing
|
||||||
// to elaborate: this class does not handle any file I/O -- we
|
// to elaborate: this class does not handle any file I/O -- we
|
||||||
// intend to use streams to abstract out file I/O
|
// intend to use streams to abstract out file I/O
|
||||||
// abstract case sensitivity of underlying file system
|
// abstract case sensitivity of underlying file system
|
||||||
//
|
//
|
||||||
|
@ -66,11 +66,11 @@
|
||||||
//=========================================================================
|
//=========================================================================
|
||||||
|
|
||||||
#if HAVE_SYS_PARAM_H
|
#if HAVE_SYS_PARAM_H
|
||||||
# include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if HAVE_SYS_STAT_H
|
#if HAVE_SYS_STAT_H
|
||||||
# include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -78,28 +78,28 @@
|
||||||
// DEFINES AND MACROS
|
// DEFINES AND MACROS
|
||||||
//=========================================================================
|
//=========================================================================
|
||||||
|
|
||||||
// macros for extracting the major and minor portions of int64's:
|
// macros for extracting the major and minor portions of int64's:
|
||||||
#if !defined(major)
|
#if !defined(major)
|
||||||
#if !USES_GLIBC
|
# if !USES_GLIBC
|
||||||
#define major(x) ((int)((x) >> 8) & 0xff)
|
# define major(x) ((int)((x) >> 8) & 0xff)
|
||||||
#define minor(x) ((int)((x) & 0xff))
|
# define minor(x) ((int)((x)&0xff))
|
||||||
#else
|
# else
|
||||||
#ifdef WORDS_BIGENDIAN
|
# ifdef WORDS_BIGENDIAN
|
||||||
#define major(x) (int)(((char*)&(x))[2])
|
# define major(x) (int)(((char*)&(x))[2])
|
||||||
#define minor(x) (int)(((char*)&(x))[3])
|
# define minor(x) (int)(((char*)&(x))[3])
|
||||||
#else
|
# else
|
||||||
#define major(x) (int)(((char*)&(x))[1])
|
# define major(x) (int)(((char*)&(x))[1])
|
||||||
#define minor(x) (int)(((char*)&(x))[0])
|
# define minor(x) (int)(((char*)&(x))[0])
|
||||||
#endif
|
# endif
|
||||||
#endif
|
# endif
|
||||||
#endif /* !major */
|
#endif /* !major */
|
||||||
|
|
||||||
//=========================================================================
|
//=========================================================================
|
||||||
// TYPEDEFS
|
// TYPEDEFS
|
||||||
//=========================================================================
|
//=========================================================================
|
||||||
|
|
||||||
typedef int64 cFSTime;
|
typedef int64 cFSTime;
|
||||||
typedef int64 cFSType;
|
typedef int64 cFSType;
|
||||||
|
|
||||||
//=========================================================================
|
//=========================================================================
|
||||||
// GLOBALS
|
// GLOBALS
|
||||||
|
@ -114,229 +114,232 @@ typedef int64 cFSType;
|
||||||
//=========================================================================
|
//=========================================================================
|
||||||
|
|
||||||
// filesystem access control lists
|
// filesystem access control lists
|
||||||
// it is the union of MAX(elem) for all the file systems that we support
|
// it is the union of MAX(elem) for all the file systems that we support
|
||||||
/*class cACLElem {
|
/*class cACLElem {
|
||||||
// TODO this is just a place holder
|
// TODO this is just a place holder
|
||||||
// uint32 mUid;
|
// uint32 mUid;
|
||||||
};*/
|
};*/
|
||||||
|
|
||||||
// this class is used only to pass arguments to iFSServices
|
// this class is used only to pass arguments to iFSServices
|
||||||
// it is the union of MAX(elem) for all the file systems that we support
|
// it is the union of MAX(elem) for all the file systems that we support
|
||||||
struct cFSStatArgs {
|
struct cFSStatArgs
|
||||||
enum FileType {
|
{
|
||||||
TY_INVALID, // lazy evaluation
|
enum FileType
|
||||||
TY_FILE,
|
{
|
||||||
TY_DIR,
|
TY_INVALID, // lazy evaluation
|
||||||
TY_BLOCKDEV,
|
TY_FILE,
|
||||||
TY_CHARDEV,
|
TY_DIR,
|
||||||
TY_SYMLINK,
|
TY_BLOCKDEV,
|
||||||
TY_FIFO,
|
TY_CHARDEV,
|
||||||
TY_SOCK,
|
TY_SYMLINK,
|
||||||
TY_DOOR,
|
TY_FIFO,
|
||||||
TY_PORT,
|
TY_SOCK,
|
||||||
TY_NAMED
|
TY_DOOR,
|
||||||
};
|
TY_PORT,
|
||||||
|
TY_NAMED
|
||||||
|
};
|
||||||
|
|
||||||
// attr is fs dependent?
|
// attr is fs dependent?
|
||||||
uint64 dev; // dep
|
uint64 dev; // dep
|
||||||
int64 ino; // dep
|
int64 ino; // dep
|
||||||
int64 mode; // dep
|
int64 mode; // dep
|
||||||
int64 nlink; // indep
|
int64 nlink; // indep
|
||||||
int64 uid; // dep
|
int64 uid; // dep
|
||||||
int64 gid; // dep
|
int64 gid; // dep
|
||||||
uint64 rdev; // dep
|
uint64 rdev; // dep
|
||||||
int64 size; // indep
|
int64 size; // indep
|
||||||
cFSTime atime; // indep
|
cFSTime atime; // indep
|
||||||
cFSTime mtime; // indep
|
cFSTime mtime; // indep
|
||||||
cFSTime ctime; // indep
|
cFSTime ctime; // indep
|
||||||
int64 blksize; // indep
|
int64 blksize; // indep
|
||||||
int64 blocks; // dep
|
int64 blocks; // dep
|
||||||
int64 fstype; // dep
|
int64 fstype; // dep
|
||||||
TSTRING usid; // dep
|
TSTRING usid; // dep
|
||||||
TSTRING gsid; // dep
|
TSTRING gsid; // dep
|
||||||
// int64 mFileType; // Matt's addition...
|
// int64 mFileType; // Matt's addition...
|
||||||
|
|
||||||
FileType mFileType; // redundant with other information in this struct, but
|
FileType mFileType; // redundant with other information in this struct, but
|
||||||
// broken out for convenience
|
// broken out for convenience
|
||||||
|
|
||||||
//TODO: access control list should go here, too
|
//TODO: access control list should go here, too
|
||||||
//std::list <cACLElem> mACL; // indep
|
//std::list <cACLElem> mACL; // indep
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//=========================================================================
|
//=========================================================================
|
||||||
//
|
//
|
||||||
// eFSServices -- exception class
|
// eFSServices -- exception class
|
||||||
//
|
//
|
||||||
//=========================================================================
|
//=========================================================================
|
||||||
|
|
||||||
TSS_FILE_EXCEPTION( eFSServices, eFileError );
|
TSS_FILE_EXCEPTION(eFSServices, eFileError);
|
||||||
TSS_FILE_EXCEPTION( eFSServicesGeneric, eFSServices );
|
TSS_FILE_EXCEPTION(eFSServicesGeneric, eFSServices);
|
||||||
|
|
||||||
//=========================================================================
|
//=========================================================================
|
||||||
//
|
//
|
||||||
// iFSServices -- abstracts all file system calls, except for opening, reading,
|
// iFSServices -- abstracts all file system calls, except for opening, reading,
|
||||||
// and writing, which will be handled by standard c++.
|
// and writing, which will be handled by standard c++.
|
||||||
// NOTE -- all paths returned from this class will be delimited with a '/'
|
// NOTE -- all paths returned from this class will be delimited with a '/'
|
||||||
//
|
//
|
||||||
//=========================================================================
|
//=========================================================================
|
||||||
|
|
||||||
class iFSServices
|
class iFSServices
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~iFSServices() {}
|
virtual ~iFSServices()
|
||||||
///////////////////////////////////////////////////////////////
|
{
|
||||||
// ENUMS
|
}
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
|
// ENUMS
|
||||||
|
///////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
////////////////////////////////////////
|
////////////////////////////////////////
|
||||||
// file creation modes
|
// file creation modes
|
||||||
////////////////////////////////////////
|
////////////////////////////////////////
|
||||||
enum Mode
|
enum Mode
|
||||||
{
|
{
|
||||||
MODE_DEFAULT = 0,
|
MODE_DEFAULT = 0,
|
||||||
MODE_READ = 1,
|
MODE_READ = 1,
|
||||||
MODE_WRITE = 2,
|
MODE_WRITE = 2,
|
||||||
MODE_SHARE_DELETE = 4,
|
MODE_SHARE_DELETE = 4,
|
||||||
MODE_SHARE_READ = 8,
|
MODE_SHARE_READ = 8,
|
||||||
MODE_SHARE_WRITE = 16,
|
MODE_SHARE_WRITE = 16,
|
||||||
MODE_CREATE_EXCL = 32,
|
MODE_CREATE_EXCL = 32,
|
||||||
MODE_CREATE_TRUNCATE = 64
|
MODE_CREATE_TRUNCATE = 64
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////////////
|
////////////////////////////////////////
|
||||||
// maximum path length on platform
|
// maximum path length on platform
|
||||||
////////////////////////////////////////
|
////////////////////////////////////////
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
#ifdef MAXPATHLEN
|
#ifdef MAXPATHLEN
|
||||||
TW_MAX_PATH = MAXPATHLEN
|
TW_MAX_PATH = MAXPATHLEN
|
||||||
#else
|
#else
|
||||||
TW_MAX_PATH = 1024
|
TW_MAX_PATH = 1024
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// MEMBER FUNCTIONS
|
// MEMBER FUNCTIONS
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////
|
|
||||||
// platform specific functions
|
|
||||||
////////////////////////////////////////
|
|
||||||
virtual bool IsCaseSensitive() const = 0;
|
|
||||||
// returns true if the file system is case sensitive
|
|
||||||
virtual TCHAR GetPathSeparator() const = 0;
|
|
||||||
// returns "/" for unix and "\\" for win32
|
|
||||||
virtual const TCHAR* GetStandardBackupExtension() const = 0;
|
|
||||||
// returns normal string to append to backup files for this os.
|
|
||||||
|
|
||||||
////////////////////////////////////////
|
|
||||||
// process functions
|
|
||||||
////////////////////////////////////////
|
|
||||||
virtual void Sleep( int nSeconds ) const = 0;
|
|
||||||
// makes the current process sleep for the specified number of seconds
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////
|
|
||||||
// major filesystem functions
|
|
||||||
////////////////////////////////////////
|
|
||||||
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 = 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 = 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.
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////
|
////////////////////////////////////////
|
||||||
// minor filesystem functions
|
// platform specific functions
|
||||||
////////////////////////////////////////
|
////////////////////////////////////////
|
||||||
virtual void GetHostID( TSTRING& name ) const = 0;
|
virtual bool IsCaseSensitive() const = 0;
|
||||||
|
// returns true if the file system is case sensitive
|
||||||
|
virtual TCHAR GetPathSeparator() const = 0;
|
||||||
|
// returns "/" for unix and "\\" for win32
|
||||||
|
virtual const TCHAR* GetStandardBackupExtension() const = 0;
|
||||||
|
// returns normal string to append to backup files for this os.
|
||||||
|
|
||||||
virtual void GetMachineName( TSTRING& name ) const = 0;
|
////////////////////////////////////////
|
||||||
|
// process functions
|
||||||
virtual void GetMachineNameFullyQualified( TSTRING& name ) const = 0;
|
////////////////////////////////////////
|
||||||
|
virtual void Sleep(int nSeconds) const = 0;
|
||||||
virtual bool GetCurrentUserName( TSTRING& tstrName ) const = 0;
|
// makes the current process sleep for the specified number of seconds
|
||||||
|
|
||||||
virtual bool GetIPAddress( uint32& uiIPAddress ) = 0;
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////
|
////////////////////////////////////////
|
||||||
// directory specific functions
|
// major filesystem functions
|
||||||
////////////////////////////////////////
|
////////////////////////////////////////
|
||||||
virtual void ReadDir( const TSTRING& strName, std::vector<TSTRING> &vDirContents, bool bFullPaths = true ) const = 0;
|
virtual void Stat(const TSTRING& strFileName, cFSStatArgs& pStat) const = 0;
|
||||||
// puts the contents of the specified directory, except for . and .., into the supplied vector.
|
// fills out the cFSStatArgs structure with the stat info for the named file
|
||||||
// if bFullPaths is true, then the vector contains fully qualified path names; otherwise, it only contains the
|
virtual void GetTempDirName(TSTRING& strName) const = 0;
|
||||||
// short names.
|
// makes directory if it doesn't exist already. Dirname will end with a delimiter ( '/' )
|
||||||
virtual void GetCurrentDir( TSTRING& strCurDir ) const = 0;
|
|
||||||
// returns the current working directory
|
virtual void SetTempDirName(TSTRING& tmpName) = 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.
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////
|
////////////////////////////////////////
|
||||||
// file specific functions
|
// minor filesystem functions
|
||||||
////////////////////////////////////////
|
////////////////////////////////////////
|
||||||
virtual bool FileDelete( const TSTRING& name ) const = 0;
|
virtual void GetHostID(TSTRING& name) const = 0;
|
||||||
|
|
||||||
////////////////////////////////////////
|
|
||||||
// directory and file functions
|
|
||||||
////////////////////////////////////////
|
|
||||||
virtual bool Rename( const TSTRING& strOldName, const TSTRING& strNewName, bool fOverWrite = true ) const = 0;
|
|
||||||
// rename a file
|
|
||||||
|
|
||||||
virtual bool GetUserName( uid_t user_id, TSTRING& tstrUser ) const = 0;
|
|
||||||
virtual bool GetGroupName( gid_t group_id, TSTRING& tstrGroup ) const = 0;
|
|
||||||
|
|
||||||
//Set whether we try to resolve uid/gid to a name, since Linux static binaries can
|
virtual void GetMachineName(TSTRING& name) const = 0;
|
||||||
//have trouble (read: segfaulting) with name resolution given the right nsswitch.conf setup.
|
|
||||||
//This defaults to true if not specified.
|
virtual void GetMachineNameFullyQualified(TSTRING& name) const = 0;
|
||||||
virtual void SetResolveNames(bool resolve)=0;
|
|
||||||
|
virtual bool GetCurrentUserName(TSTRING& tstrName) const = 0;
|
||||||
////////////////////////////////////////
|
|
||||||
// miscellaneous utility functions
|
virtual bool GetIPAddress(uint32& uiIPAddress) = 0;
|
||||||
////////////////////////////////////////
|
|
||||||
virtual void ConvertModeToString( uint64 perm, TSTRING& tstrPerm ) const = 0;
|
|
||||||
// takes a int64 permission (from stat) and changes it to look like UNIX's 'ls -l' (e.g. drwxrwxrwx)
|
|
||||||
virtual bool FullPath( TSTRING& fullPath, const TSTRING& relPath, const TSTRING& pathRelFrom = _T("") ) const = 0;
|
|
||||||
// converts relPath into a fully qualified path, storing it in FullPath. If this
|
|
||||||
// fails, false is returned. if the path to which relPath is relative is not CWD, put it in pathRelFrom.
|
|
||||||
// TODO: In some places we have depended on the behaviour that if relPath.empty() == true then we
|
|
||||||
// fail or return an empty string. Should we add this behaviour to the interface?
|
|
||||||
virtual bool GetExecutableFilename( TSTRING& strFullPath, const TSTRING& strFilename ) const = 0;
|
|
||||||
// get the path to the current executable file
|
|
||||||
virtual bool IsRoot( const TSTRING& strPath ) const = 0;
|
|
||||||
// returns true if strPath denotes a root path
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////
|
////////////////////////////////////////
|
||||||
// error functions
|
// directory specific functions
|
||||||
////////////////////////////////////////
|
////////////////////////////////////////
|
||||||
virtual TSTRING GetErrString() const = 0;
|
virtual void ReadDir(const TSTRING& strName, std::vector<TSTRING>& vDirContents, bool bFullPaths = true) const = 0;
|
||||||
// Returns an error string that is appropriate for the system, (e.g. errorstr(errno)
|
// puts the contents of the specified directory, except for . and .., into the supplied vector.
|
||||||
// on UNIX and FormatError( ..., GetLastError(), ...) in Win32
|
// if bFullPaths is true, then the vector contains fully qualified path names; otherwise, it only contains the
|
||||||
// Call this immediately after a failed system call to get a string
|
// short names.
|
||||||
// representation of the error event.
|
virtual void GetCurrentDir(TSTRING& strCurDir) const = 0;
|
||||||
|
// returns the current working directory
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////
|
////////////////////////////////////////
|
||||||
// singleton manipulation
|
// file specific functions
|
||||||
////////////////////////////////////////
|
////////////////////////////////////////
|
||||||
static iFSServices* GetInstance();
|
virtual bool FileDelete(const TSTRING& name) const = 0;
|
||||||
static void SetInstance( iFSServices* pInst );
|
|
||||||
|
|
||||||
|
////////////////////////////////////////
|
||||||
///////////////////////////////////////////////////////////////
|
// directory and file functions
|
||||||
// PRIVATE DATA
|
////////////////////////////////////////
|
||||||
///////////////////////////////////////////////////////////////
|
virtual bool Rename(const TSTRING& strOldName, const TSTRING& strNewName, bool fOverWrite = true) const = 0;
|
||||||
private:
|
// rename a file
|
||||||
static iFSServices* mpInstance;
|
|
||||||
|
virtual bool GetUserName(uid_t user_id, TSTRING& tstrUser) const = 0;
|
||||||
|
virtual bool GetGroupName(gid_t group_id, TSTRING& tstrGroup) const = 0;
|
||||||
|
|
||||||
|
//Set whether we try to resolve uid/gid to a name, since Linux static binaries can
|
||||||
|
//have trouble (read: segfaulting) with name resolution given the right nsswitch.conf setup.
|
||||||
|
//This defaults to true if not specified.
|
||||||
|
virtual void SetResolveNames(bool resolve) = 0;
|
||||||
|
|
||||||
|
////////////////////////////////////////
|
||||||
|
// miscellaneous utility functions
|
||||||
|
////////////////////////////////////////
|
||||||
|
virtual void ConvertModeToString(uint64 perm, TSTRING& tstrPerm) const = 0;
|
||||||
|
// takes a int64 permission (from stat) and changes it to look like UNIX's 'ls -l' (e.g. drwxrwxrwx)
|
||||||
|
virtual bool FullPath(TSTRING& fullPath, const TSTRING& relPath, const TSTRING& pathRelFrom = _T("")) const = 0;
|
||||||
|
// converts relPath into a fully qualified path, storing it in FullPath. If this
|
||||||
|
// fails, false is returned. if the path to which relPath is relative is not CWD, put it in pathRelFrom.
|
||||||
|
// TODO: In some places we have depended on the behaviour that if relPath.empty() == true then we
|
||||||
|
// fail or return an empty string. Should we add this behaviour to the interface?
|
||||||
|
virtual bool GetExecutableFilename(TSTRING& strFullPath, const TSTRING& strFilename) const = 0;
|
||||||
|
// get the path to the current executable file
|
||||||
|
virtual bool IsRoot(const TSTRING& strPath) const = 0;
|
||||||
|
// returns true if strPath denotes a root path
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////
|
||||||
|
// error functions
|
||||||
|
////////////////////////////////////////
|
||||||
|
virtual TSTRING GetErrString() const = 0;
|
||||||
|
// Returns an error string that is appropriate for the system, (e.g. errorstr(errno)
|
||||||
|
// on UNIX and FormatError( ..., GetLastError(), ...) in Win32
|
||||||
|
// Call this immediately after a failed system call to get a string
|
||||||
|
// representation of the error event.
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////
|
||||||
|
// singleton manipulation
|
||||||
|
////////////////////////////////////////
|
||||||
|
static iFSServices* GetInstance();
|
||||||
|
static void SetInstance(iFSServices* pInst);
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////
|
||||||
|
// PRIVATE DATA
|
||||||
|
///////////////////////////////////////////////////////////////
|
||||||
|
private:
|
||||||
|
static iFSServices* mpInstance;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -345,16 +348,15 @@ class iFSServices
|
||||||
//=========================================================================
|
//=========================================================================
|
||||||
inline iFSServices* iFSServices::GetInstance()
|
inline iFSServices* iFSServices::GetInstance()
|
||||||
{
|
{
|
||||||
ASSERT(mpInstance != 0);
|
ASSERT(mpInstance != 0);
|
||||||
|
|
||||||
return mpInstance;
|
return mpInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void iFSServices::SetInstance( iFSServices* pInst )
|
inline void iFSServices::SetInstance(iFSServices* pInst)
|
||||||
{
|
{
|
||||||
mpInstance = pInst;
|
mpInstance = pInst;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
//
|
//
|
||||||
// The developer of the original code and/or files is Tripwire, Inc.
|
// The developer of the original code and/or files is Tripwire, Inc.
|
||||||
// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire,
|
// Portions created by Tripwire, Inc. are copyright (C) 2000-2018 Tripwire,
|
||||||
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
||||||
// reserved.
|
// reserved.
|
||||||
//
|
//
|
||||||
// This program is free software. The contents of this file are subject
|
// 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
|
// 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
|
// Free Software Foundation; either version 2 of the License, or (at your
|
||||||
// option) any later version. You may redistribute it and/or modify it
|
// option) any later version. You may redistribute it and/or modify it
|
||||||
// only in compliance with the GNU General Public License.
|
// only in compliance with the GNU General Public License.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful.
|
// This program is distributed in the hope that it will be useful.
|
||||||
// However, this program is distributed AS-IS WITHOUT ANY
|
// However, this program is distributed AS-IS WITHOUT ANY
|
||||||
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
||||||
// for more details.
|
// for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
// USA.
|
// USA.
|
||||||
//
|
//
|
||||||
// Nothing in the GNU General Public License or any other license to use
|
// 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,
|
// the code or files shall permit you to use Tripwire's trademarks,
|
||||||
// service marks, or other intellectual property without Tripwire's
|
// service marks, or other intellectual property without Tripwire's
|
||||||
// prior written consent.
|
// prior written consent.
|
||||||
//
|
//
|
||||||
// If you have any questions, please contact Tripwire, Inc. at either
|
// If you have any questions, please contact Tripwire, Inc. at either
|
||||||
// info@tripwire.org or www.tripwire.org.
|
// info@tripwire.org or www.tripwire.org.
|
||||||
//
|
//
|
||||||
|
@ -44,48 +44,51 @@ public:
|
||||||
class cHeap
|
class cHeap
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
size_t mSize;
|
size_t mSize;
|
||||||
int8* mpData;
|
int8* mpData;
|
||||||
|
|
||||||
cHeap( size_t size ) : mSize( size ), mpData( new int8[size] ) { ASSERT(mpData != 0); }
|
cHeap(size_t size) : mSize(size), mpData(new int8[size])
|
||||||
// Note: The above ASSERT should never occur! If the new failed we should have thrown a bad_alloc().
|
{
|
||||||
|
ASSERT(mpData != 0);
|
||||||
|
}
|
||||||
|
// Note: The above ASSERT should never occur! If the new failed we should have thrown a bad_alloc().
|
||||||
};
|
};
|
||||||
typedef std::vector<cHeap> HeapList;
|
typedef std::vector<cHeap> HeapList;
|
||||||
|
|
||||||
size_t mInitialSize;
|
size_t mInitialSize;
|
||||||
size_t mGrowBy;
|
size_t mGrowBy;
|
||||||
HeapList mHeaps;
|
HeapList mHeaps;
|
||||||
TSTRING mName;
|
TSTRING mName;
|
||||||
size_t mCurOff;
|
size_t mCurOff;
|
||||||
|
|
||||||
cGrowHeap_i( size_t initialSize, size_t growBy, const TCHAR* name );
|
|
||||||
~cGrowHeap_i() { Clear(); }
|
|
||||||
|
|
||||||
size_t AlignSizeRequest( size_t size, size_t alignSize );
|
cGrowHeap_i(size_t initialSize, size_t growBy, const TCHAR* name);
|
||||||
void* Malloc( size_t size );
|
~cGrowHeap_i()
|
||||||
void Clear();
|
{
|
||||||
|
Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t AlignSizeRequest(size_t size, size_t alignSize);
|
||||||
|
void* Malloc(size_t size);
|
||||||
|
void Clear();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
cGrowHeap_i::cGrowHeap_i( size_t initialSize, size_t growBy, const TCHAR* name )
|
cGrowHeap_i::cGrowHeap_i(size_t initialSize, size_t growBy, const TCHAR* name)
|
||||||
: mInitialSize( initialSize ),
|
: mInitialSize(initialSize), mGrowBy(growBy), mName(name), mCurOff(0)
|
||||||
mGrowBy ( growBy ),
|
|
||||||
mName ( name ),
|
|
||||||
mCurOff ( 0 )
|
|
||||||
{
|
{
|
||||||
// assure that initial size and growby are aligned
|
// assure that initial size and growby are aligned
|
||||||
ASSERT( 0 == ( initialSize % BYTE_ALIGN ) );
|
ASSERT(0 == (initialSize % BYTE_ALIGN));
|
||||||
ASSERT( 0 == ( growBy % BYTE_ALIGN ) );
|
ASSERT(0 == (growBy % BYTE_ALIGN));
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t cGrowHeap::TotalMemUsage() const
|
size_t cGrowHeap::TotalMemUsage() const
|
||||||
{
|
{
|
||||||
size_t usage = 0;
|
size_t usage = 0;
|
||||||
for( cGrowHeap_i::HeapList::const_iterator i = mpData->mHeaps.begin(); i != mpData->mHeaps.end(); i++ )
|
for (cGrowHeap_i::HeapList::const_iterator i = mpData->mHeaps.begin(); i != mpData->mHeaps.end(); i++)
|
||||||
{
|
{
|
||||||
usage += i->mSize;
|
usage += i->mSize;
|
||||||
}
|
}
|
||||||
if( ! mpData->mHeaps.empty() )
|
if (!mpData->mHeaps.empty())
|
||||||
{
|
{
|
||||||
// take off the unused portion...
|
// take off the unused portion...
|
||||||
usage -= (mpData->mHeaps.back().mSize - mpData->mCurOff);
|
usage -= (mpData->mHeaps.back().mSize - mpData->mCurOff);
|
||||||
|
@ -94,23 +97,23 @@ size_t cGrowHeap::TotalMemUsage() const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void* cGrowHeap_i::Malloc( size_t size )
|
void* cGrowHeap_i::Malloc(size_t size)
|
||||||
{
|
{
|
||||||
size = AlignSizeRequest( size, BYTE_ALIGN );
|
size = AlignSizeRequest(size, BYTE_ALIGN);
|
||||||
|
|
||||||
ASSERT( ( size > 0 ) && ( size < mGrowBy ) );
|
ASSERT((size > 0) && (size < mGrowBy));
|
||||||
|
|
||||||
if( size >= mGrowBy )
|
if (size >= mGrowBy)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if( mHeaps.empty() )
|
if (mHeaps.empty())
|
||||||
{
|
{
|
||||||
mHeaps.push_back( cHeap( mInitialSize ) );
|
mHeaps.push_back(cHeap(mInitialSize));
|
||||||
ASSERT(mHeaps.back().mpData != 0);
|
ASSERT(mHeaps.back().mpData != 0);
|
||||||
mCurOff = 0;
|
mCurOff = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( mCurOff + size < mHeaps.back().mSize )
|
if (mCurOff + size < mHeaps.back().mSize)
|
||||||
{
|
{
|
||||||
// we have room to add this to the current heap.
|
// we have room to add this to the current heap.
|
||||||
//
|
//
|
||||||
|
@ -122,43 +125,43 @@ void* cGrowHeap_i::Malloc( size_t size )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mHeaps.push_back( cHeap( mGrowBy ) );
|
mHeaps.push_back(cHeap(mGrowBy));
|
||||||
ASSERT(mHeaps.back().mpData != 0);
|
ASSERT(mHeaps.back().mpData != 0);
|
||||||
mCurOff = 0;
|
mCurOff = 0;
|
||||||
|
|
||||||
#ifdef _DEUBG
|
#ifdef _DEUBG
|
||||||
void* ret = Malloc( size );
|
void* ret = Malloc(size);
|
||||||
ASSERT(ret != 0);
|
ASSERT(ret != 0);
|
||||||
return ret;
|
return ret;
|
||||||
#else
|
#else
|
||||||
return Malloc( size );
|
return Malloc(size);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t cGrowHeap_i::AlignSizeRequest( size_t size, size_t alignSize )
|
size_t cGrowHeap_i::AlignSizeRequest(size_t size, size_t alignSize)
|
||||||
{
|
{
|
||||||
// The two's complement algorithm requires a non-zero size request size,
|
// The two's complement algorithm requires a non-zero size request size,
|
||||||
// so make make all requests require it so that this function
|
// so make make all requests require it so that this function
|
||||||
// acts the same no matter what the integer representation
|
// acts the same no matter what the integer representation
|
||||||
if( 0 == size )
|
if (0 == size)
|
||||||
size = 1;
|
size = 1;
|
||||||
|
|
||||||
#if USES_2S_COMPLEMENT
|
#if USES_2S_COMPLEMENT
|
||||||
// This efficient algorithm assumes alignSize is power of two AND a
|
// This efficient algorithm assumes alignSize is power of two AND a
|
||||||
// 2's complement representation. Requires non-zero size request
|
// 2's complement representation. Requires non-zero size request
|
||||||
ASSERT( 0 == ( alignSize % 2 ) );
|
ASSERT(0 == (alignSize % 2));
|
||||||
ASSERT( size > 0 );
|
ASSERT(size > 0);
|
||||||
return( ( size + alignSize - 1 ) & ~( alignSize - 1 ) );
|
return ((size + alignSize - 1) & ~(alignSize - 1));
|
||||||
#else
|
#else
|
||||||
// this makes no assumption about BYTE_ALIGN or hardware integer representation
|
// this makes no assumption about BYTE_ALIGN or hardware integer representation
|
||||||
return( ( ( size / alignSize ) + ( ( size % alignSize ) ? 1 : 0 ) ) * alignSize );
|
return (((size / alignSize) + ((size % alignSize) ? 1 : 0)) * alignSize);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void cGrowHeap_i::Clear()
|
void cGrowHeap_i::Clear()
|
||||||
{
|
{
|
||||||
for( HeapList::iterator i = mHeaps.begin(); i != mHeaps.end(); i++ )
|
for (HeapList::iterator i = mHeaps.begin(); i != mHeaps.end(); i++)
|
||||||
{
|
{
|
||||||
delete [] i->mpData;
|
delete [] i->mpData;
|
||||||
}
|
}
|
||||||
|
@ -168,27 +171,25 @@ void cGrowHeap_i::Clear()
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// cGrowHeap
|
// cGrowHeap
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
cGrowHeap::cGrowHeap( size_t initialSize, size_t growBy, const TCHAR* name ) :
|
cGrowHeap::cGrowHeap(size_t initialSize, size_t growBy, const TCHAR* name)
|
||||||
mpData( new cGrowHeap_i( initialSize, growBy, name ) )
|
: mpData(new cGrowHeap_i(initialSize, growBy, name))
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cGrowHeap::~cGrowHeap()
|
cGrowHeap::~cGrowHeap()
|
||||||
{
|
{
|
||||||
cDebug d("FCO name heap stats");
|
cDebug d("FCO name heap stats");
|
||||||
d.TraceDebug( _T("Total heap memory usage for %s: %d\n"), mpData->mName.c_str(), TotalMemUsage() );
|
d.TraceDebug(_T("Total heap memory usage for %s: %d\n"), mpData->mName.c_str(), TotalMemUsage());
|
||||||
|
|
||||||
delete mpData;
|
delete mpData;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* cGrowHeap::Malloc( size_t size )
|
void* cGrowHeap::Malloc(size_t size)
|
||||||
{
|
{
|
||||||
return mpData->Malloc( size );
|
return mpData->Malloc(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cGrowHeap::Clear()
|
void cGrowHeap::Clear()
|
||||||
{
|
{
|
||||||
mpData->Clear();
|
mpData->Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
//
|
//
|
||||||
// The developer of the original code and/or files is Tripwire, Inc.
|
// The developer of the original code and/or files is Tripwire, Inc.
|
||||||
// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire,
|
// Portions created by Tripwire, Inc. are copyright (C) 2000-2018 Tripwire,
|
||||||
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
||||||
// reserved.
|
// reserved.
|
||||||
//
|
//
|
||||||
// This program is free software. The contents of this file are subject
|
// 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
|
// 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
|
// Free Software Foundation; either version 2 of the License, or (at your
|
||||||
// option) any later version. You may redistribute it and/or modify it
|
// option) any later version. You may redistribute it and/or modify it
|
||||||
// only in compliance with the GNU General Public License.
|
// only in compliance with the GNU General Public License.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful.
|
// This program is distributed in the hope that it will be useful.
|
||||||
// However, this program is distributed AS-IS WITHOUT ANY
|
// However, this program is distributed AS-IS WITHOUT ANY
|
||||||
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
||||||
// for more details.
|
// for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
// USA.
|
// USA.
|
||||||
//
|
//
|
||||||
// Nothing in the GNU General Public License or any other license to use
|
// 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,
|
// the code or files shall permit you to use Tripwire's trademarks,
|
||||||
// service marks, or other intellectual property without Tripwire's
|
// service marks, or other intellectual property without Tripwire's
|
||||||
// prior written consent.
|
// prior written consent.
|
||||||
//
|
//
|
||||||
// If you have any questions, please contact Tripwire, Inc. at either
|
// If you have any questions, please contact Tripwire, Inc. at either
|
||||||
// info@tripwire.org or www.tripwire.org.
|
// info@tripwire.org or www.tripwire.org.
|
||||||
//
|
//
|
||||||
|
@ -49,24 +49,23 @@
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
class cGrowHeap_i;
|
class cGrowHeap_i;
|
||||||
|
|
||||||
class cGrowHeap
|
class cGrowHeap
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
cGrowHeap( size_t initialSize, size_t growby, const TCHAR* name );
|
cGrowHeap(size_t initialSize, size_t growby, const TCHAR* name);
|
||||||
// creates a heap that is initially initialSize big, and increases the
|
// creates a heap that is initially initialSize big, and increases the
|
||||||
// size by growBy every time there is no more room.
|
// size by growBy every time there is no more room.
|
||||||
// initialSize and growby must be a multiple of BYTE_ALIGN
|
// initialSize and growby must be a multiple of BYTE_ALIGN
|
||||||
~cGrowHeap();
|
~cGrowHeap();
|
||||||
|
|
||||||
void* Malloc( size_t size );
|
void* Malloc(size_t size);
|
||||||
void Clear();
|
void Clear();
|
||||||
// resets the grow heap's state.
|
// resets the grow heap's state.
|
||||||
size_t TotalMemUsage() const;
|
size_t TotalMemUsage() const;
|
||||||
// returns the total memory usage of this heap
|
// returns the total memory usage of this heap
|
||||||
private:
|
private:
|
||||||
cGrowHeap_i* mpData;
|
cGrowHeap_i* mpData;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1,36 +1,34 @@
|
||||||
//
|
//
|
||||||
// The developer of the original code and/or files is Tripwire, Inc.
|
// The developer of the original code and/or files is Tripwire, Inc.
|
||||||
// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire,
|
// Portions created by Tripwire, Inc. are copyright (C) 2000-2018 Tripwire,
|
||||||
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
||||||
// reserved.
|
// reserved.
|
||||||
//
|
//
|
||||||
// This program is free software. The contents of this file are subject
|
// 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
|
// 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
|
// Free Software Foundation; either version 2 of the License, or (at your
|
||||||
// option) any later version. You may redistribute it and/or modify it
|
// option) any later version. You may redistribute it and/or modify it
|
||||||
// only in compliance with the GNU General Public License.
|
// only in compliance with the GNU General Public License.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful.
|
// This program is distributed in the hope that it will be useful.
|
||||||
// However, this program is distributed AS-IS WITHOUT ANY
|
// However, this program is distributed AS-IS WITHOUT ANY
|
||||||
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
||||||
// for more details.
|
// for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
// USA.
|
// USA.
|
||||||
//
|
//
|
||||||
// Nothing in the GNU General Public License or any other license to use
|
// 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,
|
// the code or files shall permit you to use Tripwire's trademarks,
|
||||||
// service marks, or other intellectual property without Tripwire's
|
// service marks, or other intellectual property without Tripwire's
|
||||||
// prior written consent.
|
// prior written consent.
|
||||||
//
|
//
|
||||||
// If you have any questions, please contact Tripwire, Inc. at either
|
// If you have any questions, please contact Tripwire, Inc. at either
|
||||||
// info@tripwire.org or www.tripwire.org.
|
// info@tripwire.org or www.tripwire.org.
|
||||||
//
|
//
|
||||||
//hashtable.cpp : implementation for hashtable which maps const TCHAR*'s to void*'s
|
//hashtable.cpp : implementation for hashtable which maps const TCHAR*'s to void*'s
|
||||||
#include "stdcore.h"
|
#include "stdcore.h"
|
||||||
#include "hashtable.h"
|
#include "hashtable.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
//
|
//
|
||||||
// The developer of the original code and/or files is Tripwire, Inc.
|
// The developer of the original code and/or files is Tripwire, Inc.
|
||||||
// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire,
|
// Portions created by Tripwire, Inc. are copyright (C) 2000-2018 Tripwire,
|
||||||
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
||||||
// reserved.
|
// reserved.
|
||||||
//
|
//
|
||||||
// This program is free software. The contents of this file are subject
|
// 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
|
// 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
|
// Free Software Foundation; either version 2 of the License, or (at your
|
||||||
// option) any later version. You may redistribute it and/or modify it
|
// option) any later version. You may redistribute it and/or modify it
|
||||||
// only in compliance with the GNU General Public License.
|
// only in compliance with the GNU General Public License.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful.
|
// This program is distributed in the hope that it will be useful.
|
||||||
// However, this program is distributed AS-IS WITHOUT ANY
|
// However, this program is distributed AS-IS WITHOUT ANY
|
||||||
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
||||||
// for more details.
|
// for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
// USA.
|
// USA.
|
||||||
//
|
//
|
||||||
// Nothing in the GNU General Public License or any other license to use
|
// 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,
|
// the code or files shall permit you to use Tripwire's trademarks,
|
||||||
// service marks, or other intellectual property without Tripwire's
|
// service marks, or other intellectual property without Tripwire's
|
||||||
// prior written consent.
|
// prior written consent.
|
||||||
//
|
//
|
||||||
// If you have any questions, please contact Tripwire, Inc. at either
|
// If you have any questions, please contact Tripwire, Inc. at either
|
||||||
// info@tripwire.org or www.tripwire.org.
|
// info@tripwire.org or www.tripwire.org.
|
||||||
//
|
//
|
||||||
|
@ -34,9 +34,9 @@
|
||||||
// implements cHashTable, which maps a key of arbitrary type to a value
|
// implements cHashTable, which maps a key of arbitrary type to a value
|
||||||
// of arbitrary type. The key data type MUST have the const byte*()
|
// of arbitrary type. The key data type MUST have the const byte*()
|
||||||
// operator overloaded in order for this to work. TSTRINGS will always
|
// operator overloaded in order for this to work. TSTRINGS will always
|
||||||
// work as the key value because of the overloaded-template-function
|
// work as the key value because of the overloaded-template-function
|
||||||
//
|
//
|
||||||
// Note: Any overloaded const byte*() operator must return an
|
// Note: Any overloaded const byte*() operator must return an
|
||||||
// length of key as well. see cDefaultConvert
|
// length of key as well. see cDefaultConvert
|
||||||
//
|
//
|
||||||
// IMPORTANT -- cDefaultConvert only works for pointers to objects
|
// IMPORTANT -- cDefaultConvert only works for pointers to objects
|
||||||
|
@ -63,12 +63,11 @@
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// Comparison function objects ... these are used by the hash table to determine
|
// Comparison function objects ... these are used by the hash table to determine
|
||||||
// equality. The one defined should work for objects that use op== to define
|
// equality. The one defined should work for objects that use op== to define
|
||||||
// equality. There is also a specialization for TSTRINGS. If neither of these
|
// equality. There is also a specialization for TSTRINGS. If neither of these
|
||||||
// fit your needs, you must pass the hash table your own fn pointer or class
|
// fit your needs, you must pass the hash table your own fn pointer or class
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
template<class T>
|
template<class T> class cDefaultCompare
|
||||||
class cDefaultCompare
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
bool operator()(const T& lhs, const T& rhs)
|
bool operator()(const T& lhs, const T& rhs)
|
||||||
|
@ -79,19 +78,17 @@ public:
|
||||||
/////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////
|
||||||
// specialization for TSTRINGS
|
// specialization for TSTRINGS
|
||||||
/////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////
|
||||||
template<>
|
template<> inline bool cDefaultCompare<TSTRING>::operator()(const TSTRING& lhs, const TSTRING& rhs)
|
||||||
inline bool cDefaultCompare<TSTRING>::operator()(const TSTRING& lhs, const TSTRING& rhs)
|
|
||||||
{
|
{
|
||||||
return (lhs.compare(rhs) == 0);
|
return (lhs.compare(rhs) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// Conversion function objects ... used by the hash table to locate the key in KEY_TYPE
|
// Conversion function objects ... used by the hash table to locate the key in KEY_TYPE
|
||||||
// into a byte* and a key length (for hashing purposes). The default implementation
|
// into a byte* and a key length (for hashing purposes). The default implementation
|
||||||
// just does a cast. A specialization is also provided for TSTRINGs.
|
// just does a cast. A specialization is also provided for TSTRINGs.
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
template<class T>
|
template<class T> class cDefaultConvert
|
||||||
class cDefaultConvert
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
const byte* operator()(const T& obj, int* const pcbKeyLen)
|
const byte* operator()(const T& obj, int* const pcbKeyLen)
|
||||||
|
@ -104,8 +101,7 @@ public:
|
||||||
/////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////
|
||||||
// specialization for TSTRINGS
|
// specialization for TSTRINGS
|
||||||
/////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////
|
||||||
template<>
|
template<> inline const byte* cDefaultConvert<TSTRING>::operator()(const TSTRING& obj, int* const pcbKeyLen)
|
||||||
inline const byte* cDefaultConvert<TSTRING>::operator()(const TSTRING& obj, int* const pcbKeyLen )
|
|
||||||
{
|
{
|
||||||
*pcbKeyLen = sizeof(TCHAR) * obj.length();
|
*pcbKeyLen = sizeof(TCHAR) * obj.length();
|
||||||
return (byte*)obj.c_str();
|
return (byte*)obj.c_str();
|
||||||
|
@ -113,7 +109,7 @@ inline const byte* cDefaultConvert<TSTRING>::operator()(const TSTRING& obj, int*
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// cHashTable<KEY, VAL, CMP, CONVERTER>
|
// cHashTable<KEY, VAL, CMP, CONVERTER>
|
||||||
// KEY -- the key you are hashing on
|
// KEY -- the key you are hashing on
|
||||||
// VAL -- the value you want associated with that key
|
// VAL -- the value you want associated with that key
|
||||||
// CMP -- a function object that takes (KEY, KEY) and returns true if they
|
// CMP -- a function object that takes (KEY, KEY) and returns true if they
|
||||||
// are equal.
|
// are equal.
|
||||||
|
@ -123,7 +119,8 @@ inline const byte* cDefaultConvert<TSTRING>::operator()(const TSTRING& obj, int*
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// these were moved outside of the class because it sucks to have to name the class with template parameters
|
// these were moved outside of the class because it sucks to have to name the class with template parameters
|
||||||
// ie -- mTable(cHashTable<TSTRING, int>::MEDIUM
|
// ie -- mTable(cHashTable<TSTRING, int>::MEDIUM
|
||||||
enum cHashTable_TableSize {
|
enum cHashTable_TableSize
|
||||||
|
{
|
||||||
HASH_VERY_SMALL = 17,
|
HASH_VERY_SMALL = 17,
|
||||||
HASH_SMALL = 2007,
|
HASH_SMALL = 2007,
|
||||||
HASH_MEDIUM = 6007,
|
HASH_MEDIUM = 6007,
|
||||||
|
@ -132,155 +129,165 @@ enum cHashTable_TableSize {
|
||||||
};
|
};
|
||||||
|
|
||||||
// forward declaration
|
// forward declaration
|
||||||
template <class KEY_TYPE, class VAL_TYPE, class COMPARE_OP = cDefaultCompare<KEY_TYPE>, class CONVERTER = cDefaultConvert<KEY_TYPE> >
|
template<class KEY_TYPE,
|
||||||
|
class VAL_TYPE,
|
||||||
|
class COMPARE_OP = cDefaultCompare<KEY_TYPE>,
|
||||||
|
class CONVERTER = cDefaultConvert<KEY_TYPE> >
|
||||||
class cHashTableIter;
|
class cHashTableIter;
|
||||||
|
|
||||||
//General version of cHashTable template:
|
//General version of cHashTable template:
|
||||||
template <class KEY_TYPE, class VAL_TYPE, class COMPARE_OP = cDefaultCompare<KEY_TYPE>, class CONVERTER = cDefaultConvert<KEY_TYPE> >
|
template<class KEY_TYPE,
|
||||||
class cHashTable
|
class VAL_TYPE,
|
||||||
|
class COMPARE_OP = cDefaultCompare<KEY_TYPE>,
|
||||||
|
class CONVERTER = cDefaultConvert<KEY_TYPE> >
|
||||||
|
class cHashTable
|
||||||
{
|
{
|
||||||
friend class cHashTableIter<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>;
|
friend class cHashTableIter<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//structure for hash table nodes.
|
//structure for hash table nodes.
|
||||||
struct node {
|
struct node
|
||||||
|
{
|
||||||
KEY_TYPE nKey;
|
KEY_TYPE nKey;
|
||||||
VAL_TYPE nData;
|
VAL_TYPE nData;
|
||||||
node* next;
|
node* next;
|
||||||
};
|
};
|
||||||
|
|
||||||
cHashTable(int tblSize = HASH_MEDIUM);
|
cHashTable(int tblSize = HASH_MEDIUM);
|
||||||
~cHashTable();
|
~cHashTable();
|
||||||
|
|
||||||
bool Insert(KEY_TYPE key, VAL_TYPE data_in);
|
bool Insert(KEY_TYPE key, VAL_TYPE data_in);
|
||||||
// The pointer, data_in, is stored in a node based on string_in's hashing.
|
// The pointer, data_in, is stored in a node based on string_in's hashing.
|
||||||
//
|
//
|
||||||
// if (key) already exists in the table, then it's value is replaced by (data_in)
|
// if (key) already exists in the table, then it's value is replaced by (data_in)
|
||||||
// returns true if (key) already existed in table. otherwise, returns false
|
// returns true if (key) already existed in table. otherwise, returns false
|
||||||
|
|
||||||
bool Lookup(KEY_TYPE key, VAL_TYPE& data_out) const;
|
bool Lookup(KEY_TYPE key, VAL_TYPE& data_out) const;
|
||||||
//bool Lookup(TSTRING key, VAL_TYPE& data_out) const;
|
//bool Lookup(TSTRING key, VAL_TYPE& data_out) const;
|
||||||
//Lookup returns true if a match is found for string_check. A reference
|
//Lookup returns true if a match is found for string_check. A reference
|
||||||
//to the node in the table that matches string_check is passed back (by ref).
|
//to the node in the table that matches string_check is passed back (by ref).
|
||||||
bool Remove(KEY_TYPE key);
|
bool Remove(KEY_TYPE key);
|
||||||
//The node that matches string_out is de-allocated.
|
//The node that matches string_out is de-allocated.
|
||||||
|
|
||||||
bool Clear(void);
|
bool Clear(void);
|
||||||
//Clears the entire table and sets all node pointers to NULL
|
//Clears the entire table and sets all node pointers to NULL
|
||||||
bool IsEmpty(void) const;
|
bool IsEmpty(void) const;
|
||||||
uint32 Hash( const KEY_TYPE& key ) const;
|
uint32 Hash(const KEY_TYPE& key) const;
|
||||||
//The hashing function, taken from old Tripwire
|
//The hashing function, taken from old Tripwire
|
||||||
int32 GetNumValues() const { return mValuesInTable; };
|
int32 GetNumValues() const
|
||||||
|
{
|
||||||
|
return mValuesInTable;
|
||||||
|
};
|
||||||
// returns number of table entries filled
|
// returns number of table entries filled
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
void TraceDiagnostics() const;
|
void TraceDiagnostics() const;
|
||||||
// traces hash table statistics
|
// traces hash table statistics
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
cHashTable(const cHashTable& rhs); // not impl
|
cHashTable(const cHashTable& rhs); // not impl
|
||||||
void operator=(const cHashTable& rhs); // not impl
|
void operator=(const cHashTable& rhs); // not impl
|
||||||
|
|
||||||
node** mTable;
|
node** mTable;
|
||||||
int mTableSize;
|
int mTableSize;
|
||||||
int32 mValuesInTable;
|
int32 mValuesInTable;
|
||||||
};
|
};
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// cHashTableIter
|
// cHashTableIter
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
template <class KEY_TYPE, class VAL_TYPE, class COMPARE_OP, class CONVERTER>
|
template<class KEY_TYPE, class VAL_TYPE, class COMPARE_OP, class CONVERTER> class cHashTableIter
|
||||||
class cHashTableIter
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
cHashTableIter(const cHashTable<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>& hashTbl);
|
cHashTableIter(const cHashTable<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>& hashTbl);
|
||||||
|
|
||||||
void SeekBegin() const;
|
void SeekBegin() const;
|
||||||
bool Done() const;
|
bool Done() const;
|
||||||
void Next() const;
|
void Next() const;
|
||||||
|
|
||||||
const KEY_TYPE& Key() const;
|
const KEY_TYPE& Key() const;
|
||||||
const VAL_TYPE& Val() const;
|
const VAL_TYPE& Val() const;
|
||||||
VAL_TYPE& Val();
|
VAL_TYPE& Val();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
mutable int mCurIndex;
|
mutable int mCurIndex;
|
||||||
mutable typename cHashTable<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>::node* mpCurNode;
|
mutable typename cHashTable<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>::node* mpCurNode;
|
||||||
const cHashTable<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>& mHashTable;
|
const cHashTable<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>& mHashTable;
|
||||||
|
|
||||||
// helper function
|
// helper function
|
||||||
void SeekNextValid() const;
|
void SeekNextValid() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//#############################################################################
|
//#############################################################################
|
||||||
// implementation
|
// implementation
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// iterator
|
// iterator
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
template <class KEY_TYPE, class VAL_TYPE, class COMPARE_OP, class CONVERTER>
|
template<class KEY_TYPE, class VAL_TYPE, class COMPARE_OP, class CONVERTER>
|
||||||
inline cHashTableIter<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>::cHashTableIter( const cHashTable<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>& hashTbl) :
|
inline cHashTableIter<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>::cHashTableIter(
|
||||||
mHashTable(hashTbl)
|
const cHashTable<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>& hashTbl)
|
||||||
|
: mHashTable(hashTbl)
|
||||||
{
|
{
|
||||||
SeekBegin();
|
SeekBegin();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class KEY_TYPE, class VAL_TYPE, class COMPARE_OP, class CONVERTER>
|
template<class KEY_TYPE, class VAL_TYPE, class COMPARE_OP, class CONVERTER>
|
||||||
inline void cHashTableIter<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>::SeekBegin() const
|
inline void cHashTableIter<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>::SeekBegin() const
|
||||||
{
|
{
|
||||||
mCurIndex = 0;
|
mCurIndex = 0;
|
||||||
mpCurNode = mHashTable.mTable[0];
|
mpCurNode = mHashTable.mTable[0];
|
||||||
if(! mpCurNode)
|
if (!mpCurNode)
|
||||||
SeekNextValid();
|
SeekNextValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class KEY_TYPE, class VAL_TYPE, class COMPARE_OP, class CONVERTER>
|
template<class KEY_TYPE, class VAL_TYPE, class COMPARE_OP, class CONVERTER>
|
||||||
inline bool cHashTableIter<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>::Done() const
|
inline bool cHashTableIter<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>::Done() const
|
||||||
{
|
{
|
||||||
return ((mCurIndex < 0) || (mCurIndex >= mHashTable.mTableSize));
|
return ((mCurIndex < 0) || (mCurIndex >= mHashTable.mTableSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class KEY_TYPE, class VAL_TYPE, class COMPARE_OP, class CONVERTER>
|
template<class KEY_TYPE, class VAL_TYPE, class COMPARE_OP, class CONVERTER>
|
||||||
inline void cHashTableIter<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>::Next() const
|
inline void cHashTableIter<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>::Next() const
|
||||||
{
|
{
|
||||||
SeekNextValid();
|
SeekNextValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class KEY_TYPE, class VAL_TYPE, class COMPARE_OP, class CONVERTER>
|
template<class KEY_TYPE, class VAL_TYPE, class COMPARE_OP, class CONVERTER>
|
||||||
inline void cHashTableIter<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>::SeekNextValid() const
|
inline void cHashTableIter<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>::SeekNextValid() const
|
||||||
{
|
{
|
||||||
if(mpCurNode)
|
if (mpCurNode)
|
||||||
mpCurNode = mpCurNode->next;
|
mpCurNode = mpCurNode->next;
|
||||||
|
|
||||||
// if we're out of range, bail out w/o incrementing index
|
// if we're out of range, bail out w/o incrementing index
|
||||||
if(mCurIndex >= mHashTable.mTableSize)
|
if (mCurIndex >= mHashTable.mTableSize)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
while((! mpCurNode) && (++mCurIndex < mHashTable.mTableSize))
|
while ((!mpCurNode) && (++mCurIndex < mHashTable.mTableSize))
|
||||||
{
|
{
|
||||||
mpCurNode = mHashTable.mTable[mCurIndex];
|
mpCurNode = mHashTable.mTable[mCurIndex];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class KEY_TYPE, class VAL_TYPE, class COMPARE_OP, class CONVERTER>
|
template<class KEY_TYPE, class VAL_TYPE, class COMPARE_OP, class CONVERTER>
|
||||||
inline const KEY_TYPE& cHashTableIter<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>::Key() const
|
inline const KEY_TYPE& cHashTableIter<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>::Key() const
|
||||||
{
|
{
|
||||||
ASSERT(! Done());
|
ASSERT(!Done());
|
||||||
return mpCurNode->nKey;
|
return mpCurNode->nKey;
|
||||||
}
|
}
|
||||||
template <class KEY_TYPE, class VAL_TYPE, class COMPARE_OP, class CONVERTER>
|
template<class KEY_TYPE, class VAL_TYPE, class COMPARE_OP, class CONVERTER>
|
||||||
inline const VAL_TYPE& cHashTableIter<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>::Val() const
|
inline const VAL_TYPE& cHashTableIter<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>::Val() const
|
||||||
{
|
{
|
||||||
ASSERT(! Done());
|
ASSERT(!Done());
|
||||||
return mpCurNode->nData;
|
return mpCurNode->nData;
|
||||||
}
|
}
|
||||||
template <class KEY_TYPE, class VAL_TYPE, class COMPARE_OP, class CONVERTER>
|
template<class KEY_TYPE, class VAL_TYPE, class COMPARE_OP, class CONVERTER>
|
||||||
inline VAL_TYPE& cHashTableIter<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>::Val()
|
inline VAL_TYPE& cHashTableIter<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>::Val()
|
||||||
{
|
{
|
||||||
ASSERT(! Done());
|
ASSERT(!Done());
|
||||||
return mpCurNode->nData;
|
return mpCurNode->nData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -289,32 +296,32 @@ inline VAL_TYPE& cHashTableIter<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>::Val(
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
//Default value for tblSize == 6007
|
//Default value for tblSize == 6007
|
||||||
template <class KEY_TYPE, class VAL_TYPE, class COMPARE_OP, class CONVERTER>
|
template<class KEY_TYPE, class VAL_TYPE, class COMPARE_OP, class CONVERTER>
|
||||||
cHashTable<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>::cHashTable(int tblSize)
|
cHashTable<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>::cHashTable(int tblSize)
|
||||||
{
|
{
|
||||||
mValuesInTable = 0;
|
mValuesInTable = 0;
|
||||||
mTableSize = tblSize;
|
mTableSize = tblSize;
|
||||||
mTable = new node*[mTableSize];
|
mTable = new node*[mTableSize];
|
||||||
|
|
||||||
for (int i=0; i < mTableSize; ++i)
|
for (int i = 0; i < mTableSize; ++i)
|
||||||
mTable[i] = NULL;
|
mTable[i] = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Destructor steps through table and deallocates all dynamic memory
|
//Destructor steps through table and deallocates all dynamic memory
|
||||||
template <class KEY_TYPE, class VAL_TYPE, class COMPARE_OP, class CONVERTER>
|
template<class KEY_TYPE, class VAL_TYPE, class COMPARE_OP, class CONVERTER>
|
||||||
cHashTable<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>::~cHashTable()
|
cHashTable<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>::~cHashTable()
|
||||||
{
|
{
|
||||||
for (int i=0; i<mTableSize; ++i)
|
for (int i = 0; i < mTableSize; ++i)
|
||||||
{
|
{
|
||||||
if (mTable[i] != NULL)
|
if (mTable[i] != NULL)
|
||||||
{
|
{
|
||||||
//delete the entire chain:
|
//delete the entire chain:
|
||||||
node* curr = mTable[i];
|
node* curr = mTable[i];
|
||||||
node* del;
|
node* del;
|
||||||
while(curr != NULL)
|
while (curr != NULL)
|
||||||
{
|
{
|
||||||
del = curr;
|
del = curr;
|
||||||
curr=curr->next;
|
curr = curr->next;
|
||||||
|
|
||||||
delete del;
|
delete del;
|
||||||
}
|
}
|
||||||
|
@ -328,17 +335,18 @@ cHashTable<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>::~cHashTable()
|
||||||
// using seperate chaining (link lists).
|
// using seperate chaining (link lists).
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// General Version:
|
// General Version:
|
||||||
template <class KEY_TYPE, class VAL_TYPE, class COMPARE_OP, class CONVERTER>
|
template<class KEY_TYPE, class VAL_TYPE, class COMPARE_OP, class CONVERTER>
|
||||||
bool cHashTable<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>::Insert(KEY_TYPE key, VAL_TYPE d_in)
|
bool cHashTable<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>::Insert(KEY_TYPE key, VAL_TYPE d_in)
|
||||||
{
|
{
|
||||||
COMPARE_OP compare;
|
COMPARE_OP compare;
|
||||||
|
|
||||||
int hindex = Hash( key );
|
int hindex = Hash(key);
|
||||||
if (mTable[hindex] == NULL) {
|
if (mTable[hindex] == NULL)
|
||||||
|
{
|
||||||
//open index, perform insert
|
//open index, perform insert
|
||||||
mTable[hindex] = new node;
|
mTable[hindex] = new node;
|
||||||
(mTable[hindex])->nKey = key;
|
(mTable[hindex])->nKey = key;
|
||||||
(mTable[hindex])->next = NULL;
|
(mTable[hindex])->next = NULL;
|
||||||
(mTable[hindex])->nData = d_in;
|
(mTable[hindex])->nData = d_in;
|
||||||
mValuesInTable++;
|
mValuesInTable++;
|
||||||
|
|
||||||
|
@ -348,13 +356,13 @@ bool cHashTable<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>::Insert(KEY_TYPE key,
|
||||||
{
|
{
|
||||||
// case 1: key already exists in list -- replace existing one
|
// case 1: key already exists in list -- replace existing one
|
||||||
// case 2: key does not exist -- add to end of list
|
// case 2: key does not exist -- add to end of list
|
||||||
|
|
||||||
node* nodeptr = mTable[hindex];
|
node* nodeptr = mTable[hindex];
|
||||||
|
|
||||||
bool found = false;
|
bool found = false;
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
if ( compare(nodeptr->nKey, key))
|
if (compare(nodeptr->nKey, key))
|
||||||
{
|
{
|
||||||
// we found a duplicate!
|
// we found a duplicate!
|
||||||
found = true;
|
found = true;
|
||||||
|
@ -362,24 +370,24 @@ bool cHashTable<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>::Insert(KEY_TYPE key,
|
||||||
}
|
}
|
||||||
|
|
||||||
// break if this is the last node in the list
|
// break if this is the last node in the list
|
||||||
if(! nodeptr->next)
|
if (!nodeptr->next)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// otherwise, keep traversing
|
// otherwise, keep traversing
|
||||||
nodeptr = nodeptr->next;
|
nodeptr = nodeptr->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
// add a node if the key was not found
|
// add a node if the key was not found
|
||||||
if (! found)
|
if (!found)
|
||||||
{
|
{
|
||||||
node *prev = nodeptr;
|
node* prev = nodeptr;
|
||||||
nodeptr = new node;
|
nodeptr = new node;
|
||||||
nodeptr->nKey = key;
|
nodeptr->nKey = key;
|
||||||
nodeptr->next = NULL;
|
nodeptr->next = NULL;
|
||||||
prev->next = nodeptr;
|
prev->next = nodeptr;
|
||||||
|
|
||||||
mValuesInTable++;
|
mValuesInTable++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// whether it is a new node or not, set the data to this new value
|
// whether it is a new node or not, set the data to this new value
|
||||||
nodeptr->nData = d_in;
|
nodeptr->nData = d_in;
|
||||||
|
@ -392,52 +400,55 @@ bool cHashTable<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>::Insert(KEY_TYPE key,
|
||||||
// Lookup -- Attempts to find 'string' in the hash table.
|
// Lookup -- Attempts to find 'string' in the hash table.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// General Version:
|
// General Version:
|
||||||
template <class KEY_TYPE, class VAL_TYPE, class COMPARE_OP, class CONVERTER>
|
template<class KEY_TYPE, class VAL_TYPE, class COMPARE_OP, class CONVERTER>
|
||||||
bool
|
bool cHashTable<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>::Lookup(KEY_TYPE key, VAL_TYPE& d_out) const
|
||||||
cHashTable<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>::Lookup(KEY_TYPE key, VAL_TYPE& d_out) const
|
|
||||||
{
|
{
|
||||||
COMPARE_OP compare;
|
COMPARE_OP compare;
|
||||||
|
|
||||||
int hindex = Hash( key );
|
int hindex = Hash(key);
|
||||||
if (mTable[hindex] == NULL)
|
if (mTable[hindex] == NULL)
|
||||||
return false;
|
return false;
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
node* nodeptr = mTable[hindex];
|
node* nodeptr = mTable[hindex];
|
||||||
while (nodeptr != NULL)
|
while (nodeptr != NULL)
|
||||||
{
|
{
|
||||||
if( compare(nodeptr->nKey, key)) {
|
if (compare(nodeptr->nKey, key))
|
||||||
|
{
|
||||||
d_out = nodeptr->nData;
|
d_out = nodeptr->nData;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
nodeptr = nodeptr->next;
|
nodeptr = nodeptr->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false; //mTable entries exhausted without a match
|
return false; //mTable entries exhausted without a match
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Remove -- Removes a single entry from the hash table. Returns false if
|
// Remove -- Removes a single entry from the hash table. Returns false if
|
||||||
// the nKey is not found in the table.
|
// the nKey is not found in the table.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// General Version -
|
// General Version -
|
||||||
template <class KEY_TYPE, class VAL_TYPE, class COMPARE_OP, class CONVERTER>
|
template<class KEY_TYPE, class VAL_TYPE, class COMPARE_OP, class CONVERTER>
|
||||||
bool
|
bool cHashTable<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>::Remove(KEY_TYPE key)
|
||||||
cHashTable<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>::Remove(KEY_TYPE key)
|
|
||||||
{
|
{
|
||||||
COMPARE_OP compare;
|
COMPARE_OP compare;
|
||||||
|
|
||||||
int hindex = Hash( key );
|
int hindex = Hash(key);
|
||||||
if (mTable[hindex] == NULL) {
|
if (mTable[hindex] == NULL)
|
||||||
|
{
|
||||||
delete (mTable[hindex]);
|
delete (mTable[hindex]);
|
||||||
mTable[hindex] = NULL;
|
mTable[hindex] = NULL;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
node* nodeptr = mTable[hindex];
|
node* nodeptr = mTable[hindex];
|
||||||
node* prev;
|
node* prev;
|
||||||
while(nodeptr != NULL) {
|
while (nodeptr != NULL)
|
||||||
|
{
|
||||||
prev = nodeptr;
|
prev = nodeptr;
|
||||||
if(compare(mTable[hindex]->nKey, key))
|
if (compare(mTable[hindex]->nKey, key))
|
||||||
{
|
{
|
||||||
prev->next = nodeptr->next;
|
prev->next = nodeptr->next;
|
||||||
delete nodeptr;
|
delete nodeptr;
|
||||||
|
@ -445,48 +456,48 @@ cHashTable<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>::Remove(KEY_TYPE key)
|
||||||
mTable[hindex] = NULL;
|
mTable[hindex] = NULL;
|
||||||
nodeptr = NULL;
|
nodeptr = NULL;
|
||||||
return true;
|
return true;
|
||||||
}//end if
|
} //end if
|
||||||
nodeptr = nodeptr->next;
|
nodeptr = nodeptr->next;
|
||||||
}//end while
|
} //end while
|
||||||
}//end else
|
} //end else
|
||||||
return false; //match was not found, no node deleted
|
return false; //match was not found, no node deleted
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Clear -- Clears entire hash table so that all indices are NULL
|
// Clear -- Clears entire hash table so that all indices are NULL
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
template <class KEY_TYPE, class VAL_TYPE, class COMPARE_OP, class CONVERTER>
|
template<class KEY_TYPE, class VAL_TYPE, class COMPARE_OP, class CONVERTER>
|
||||||
bool
|
bool cHashTable<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>::Clear(void)
|
||||||
cHashTable<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>::Clear(void)
|
|
||||||
{
|
{
|
||||||
for (int i=0; i<mTableSize; ++i)
|
for (int i = 0; i < mTableSize; ++i)
|
||||||
{
|
{
|
||||||
if (mTable[i] != NULL) {
|
if (mTable[i] != NULL)
|
||||||
|
{
|
||||||
node* curr = mTable[i];
|
node* curr = mTable[i];
|
||||||
node* del;
|
node* del;
|
||||||
while(curr != NULL) {
|
while (curr != NULL)
|
||||||
del = curr;
|
{
|
||||||
curr=curr->next;
|
del = curr;
|
||||||
|
curr = curr->next;
|
||||||
delete del;
|
delete del;
|
||||||
if (del == mTable[i])
|
if (del == mTable[i])
|
||||||
mTable[i] = NULL;
|
mTable[i] = NULL;
|
||||||
del = NULL;
|
del = NULL;
|
||||||
|
|
||||||
}//end delete chain loop
|
} //end delete chain loop
|
||||||
}//end if mTable[i]!= NULL
|
} //end if mTable[i]!= NULL
|
||||||
}//end for
|
} //end for
|
||||||
return (IsEmpty());
|
return (IsEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// IsEmpty --
|
// IsEmpty --
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
template <class KEY_TYPE, class VAL_TYPE, class COMPARE_OP, class CONVERTER>
|
template<class KEY_TYPE, class VAL_TYPE, class COMPARE_OP, class CONVERTER>
|
||||||
bool
|
bool cHashTable<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>::IsEmpty(void) const
|
||||||
cHashTable<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>::IsEmpty(void) const
|
|
||||||
{
|
{
|
||||||
bool ret = true;
|
bool ret = true;
|
||||||
for(int i=0; i< mTableSize; ++i)
|
for (int i = 0; i < mTableSize; ++i)
|
||||||
ret &= (mTable[i] == NULL);
|
ret &= (mTable[i] == NULL);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -494,13 +505,13 @@ cHashTable<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>::IsEmpty(void) const
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Hash -- performs hashing on key, returns an integer index val.
|
// Hash -- performs hashing on key, returns an integer index val.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
template <class KEY_TYPE, class VAL_TYPE, class COMPARE_OP, class CONVERTER>
|
template<class KEY_TYPE, class VAL_TYPE, class COMPARE_OP, class CONVERTER>
|
||||||
uint32 cHashTable<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>::Hash( const KEY_TYPE& key ) const
|
uint32 cHashTable<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>::Hash(const KEY_TYPE& key) const
|
||||||
{
|
{
|
||||||
CONVERTER converter;
|
CONVERTER converter;
|
||||||
int len;
|
int len;
|
||||||
const byte* pb = converter( key, &len ); //locates key
|
const byte* pb = converter(key, &len); //locates key
|
||||||
uint32 hindex;
|
uint32 hindex;
|
||||||
|
|
||||||
hindex = *pb;
|
hindex = *pb;
|
||||||
while (len-- > 0)
|
while (len-- > 0)
|
||||||
|
@ -510,24 +521,24 @@ uint32 cHashTable<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>::Hash( const KEY_TY
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
|
||||||
template <class KEY_TYPE, class VAL_TYPE, class COMPARE_OP, class CONVERTER>
|
template<class KEY_TYPE, class VAL_TYPE, class COMPARE_OP, class CONVERTER>
|
||||||
void cHashTable<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>::TraceDiagnostics() const
|
void cHashTable<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>::TraceDiagnostics() const
|
||||||
{
|
{
|
||||||
cDebug d("cHashTable::Diagnostics");
|
cDebug d("cHashTable::Diagnostics");
|
||||||
|
|
||||||
int slotsFilled = 0, numItems = 0, numMultiSlot = 0;
|
int slotsFilled = 0, numItems = 0, numMultiSlot = 0;
|
||||||
node* pNode;
|
node* pNode;
|
||||||
|
|
||||||
for(int i=0; i < mTableSize; i++)
|
for (int i = 0; i < mTableSize; i++)
|
||||||
{
|
{
|
||||||
if(mTable[i] != NULL)
|
if (mTable[i] != NULL)
|
||||||
{
|
{
|
||||||
slotsFilled++;
|
slotsFilled++;
|
||||||
numItems++;
|
numItems++;
|
||||||
pNode = (mTable[i])->next;
|
pNode = (mTable[i])->next;
|
||||||
if(pNode != NULL)
|
if (pNode != NULL)
|
||||||
numMultiSlot++;
|
numMultiSlot++;
|
||||||
while(pNode)
|
while (pNode)
|
||||||
{
|
{
|
||||||
numItems++;
|
numItems++;
|
||||||
pNode = pNode->next;
|
pNode = pNode->next;
|
||||||
|
@ -536,14 +547,17 @@ void cHashTable<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>::TraceDiagnostics() c
|
||||||
}
|
}
|
||||||
|
|
||||||
d.TraceDebug("---------------Hash Table Statisics---------------\n");
|
d.TraceDebug("---------------Hash Table Statisics---------------\n");
|
||||||
d.TraceDebug("-- Number of slots: %d\n", mTableSize);
|
d.TraceDebug("-- Number of slots: %d\n", mTableSize);
|
||||||
d.TraceDebug("-- Number of items: %d\n", numItems);
|
d.TraceDebug("-- Number of items: %d\n", numItems);
|
||||||
d.TraceDebug("-- Slots filled: %d (%lf %%)\n",slotsFilled, ((double)slotsFilled / (double)mTableSize) * 100.0);
|
d.TraceDebug("-- Slots filled: %d (%lf %%)\n",
|
||||||
d.TraceDebug("-- Slots with >1 item: %d (%lf %%)\n",numMultiSlot, ((double)numMultiSlot / (double)slotsFilled) * 100.0);
|
slotsFilled,
|
||||||
|
((double)slotsFilled / (double)mTableSize) * 100.0);
|
||||||
|
d.TraceDebug("-- Slots with >1 item: %d (%lf %%)\n",
|
||||||
|
numMultiSlot,
|
||||||
|
((double)numMultiSlot / (double)slotsFilled) * 100.0);
|
||||||
d.TraceDebug("--------------------------------------------------\n");
|
d.TraceDebug("--------------------------------------------------\n");
|
||||||
}
|
}
|
||||||
#endif // DEBUG
|
# endif // DEBUG
|
||||||
|
|
||||||
|
|
||||||
#endif //__HASHTABLE_H
|
#endif //__HASHTABLE_H
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
//
|
//
|
||||||
// The developer of the original code and/or files is Tripwire, Inc.
|
// The developer of the original code and/or files is Tripwire, Inc.
|
||||||
// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire,
|
// Portions created by Tripwire, Inc. are copyright (C) 2000-2018 Tripwire,
|
||||||
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
||||||
// reserved.
|
// reserved.
|
||||||
//
|
//
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
//
|
//
|
||||||
// The developer of the original code and/or files is Tripwire, Inc.
|
// The developer of the original code and/or files is Tripwire, Inc.
|
||||||
// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire,
|
// Portions created by Tripwire, Inc. are copyright (C) 2000-2018 Tripwire,
|
||||||
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
||||||
// reserved.
|
// reserved.
|
||||||
//
|
//
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
//
|
//
|
||||||
// The developer of the original code and/or files is Tripwire, Inc.
|
// The developer of the original code and/or files is Tripwire, Inc.
|
||||||
// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire,
|
// Portions created by Tripwire, Inc. are copyright (C) 2000-2018 Tripwire,
|
||||||
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
||||||
// reserved.
|
// reserved.
|
||||||
//
|
//
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
//
|
//
|
||||||
// The developer of the original code and/or files is Tripwire, Inc.
|
// The developer of the original code and/or files is Tripwire, Inc.
|
||||||
// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire,
|
// Portions created by Tripwire, Inc. are copyright (C) 2000-2018 Tripwire,
|
||||||
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
||||||
// reserved.
|
// reserved.
|
||||||
//
|
//
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
//
|
//
|
||||||
// The developer of the original code and/or files is Tripwire, Inc.
|
// The developer of the original code and/or files is Tripwire, Inc.
|
||||||
// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire,
|
// Portions created by Tripwire, Inc. are copyright (C) 2000-2018 Tripwire,
|
||||||
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
||||||
// reserved.
|
// reserved.
|
||||||
//
|
//
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
//
|
//
|
||||||
// The developer of the original code and/or files is Tripwire, Inc.
|
// The developer of the original code and/or files is Tripwire, Inc.
|
||||||
// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire,
|
// Portions created by Tripwire, Inc. are copyright (C) 2000-2018 Tripwire,
|
||||||
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
||||||
// reserved.
|
// reserved.
|
||||||
//
|
//
|
||||||
|
|
184
src/core/ntdbs.h
184
src/core/ntdbs.h
|
@ -1,31 +1,31 @@
|
||||||
//
|
//
|
||||||
// The developer of the original code and/or files is Tripwire, Inc.
|
// The developer of the original code and/or files is Tripwire, Inc.
|
||||||
// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire,
|
// Portions created by Tripwire, Inc. are copyright (C) 2000-2018 Tripwire,
|
||||||
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
||||||
// reserved.
|
// reserved.
|
||||||
//
|
//
|
||||||
// This program is free software. The contents of this file are subject
|
// 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
|
// 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
|
// Free Software Foundation; either version 2 of the License, or (at your
|
||||||
// option) any later version. You may redistribute it and/or modify it
|
// option) any later version. You may redistribute it and/or modify it
|
||||||
// only in compliance with the GNU General Public License.
|
// only in compliance with the GNU General Public License.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful.
|
// This program is distributed in the hope that it will be useful.
|
||||||
// However, this program is distributed AS-IS WITHOUT ANY
|
// However, this program is distributed AS-IS WITHOUT ANY
|
||||||
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
||||||
// for more details.
|
// for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
// USA.
|
// USA.
|
||||||
//
|
//
|
||||||
// Nothing in the GNU General Public License or any other license to use
|
// 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,
|
// the code or files shall permit you to use Tripwire's trademarks,
|
||||||
// service marks, or other intellectual property without Tripwire's
|
// service marks, or other intellectual property without Tripwire's
|
||||||
// prior written consent.
|
// prior written consent.
|
||||||
//
|
//
|
||||||
// If you have any questions, please contact Tripwire, Inc. at either
|
// If you have any questions, please contact Tripwire, Inc. at either
|
||||||
// info@tripwire.org or www.tripwire.org.
|
// info@tripwire.org or www.tripwire.org.
|
||||||
//
|
//
|
||||||
|
@ -51,13 +51,13 @@
|
||||||
#include "ntmbs.h"
|
#include "ntmbs.h"
|
||||||
|
|
||||||
#if IS_KAI
|
#if IS_KAI
|
||||||
#define IS_STDLIB_MODENA 1 // Has special char_traits req's!
|
# define IS_STDLIB_MODENA 1 // Has special char_traits req's!
|
||||||
#ifdef MSIPL_WCHART
|
# ifdef MSIPL_WCHART
|
||||||
#define MBSTATE_T_DEFINED
|
# define MBSTATE_T_DEFINED
|
||||||
#endif
|
# endif
|
||||||
#else
|
#else
|
||||||
#define IS_STDLIB_MODENA 0
|
# define IS_STDLIB_MODENA 0
|
||||||
#define MBSTATE_T_DEFINED
|
# define MBSTATE_T_DEFINED
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -65,15 +65,24 @@
|
||||||
// Char traits for WCHAR16 (aka dbchar_t) and NTMBCS (mctype_t)
|
// Char traits for WCHAR16 (aka dbchar_t) and NTMBCS (mctype_t)
|
||||||
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
||||||
#if ( WCHAR_IS_16_BITS )
|
#if (WCHAR_IS_16_BITS)
|
||||||
namespace tss { typedef std::wstring dbstring; }
|
namespace tss
|
||||||
|
{
|
||||||
|
typedef std::wstring dbstring;
|
||||||
|
}
|
||||||
|
|
||||||
#elif ( WCHAR_IS_32_BITS )
|
#elif (WCHAR_IS_32_BITS)
|
||||||
namespace std { template <> struct char_traits< dbchar_t >; }
|
namespace std
|
||||||
namespace tss { typedef std::basic_string<dbchar_t> dbstring; }
|
{
|
||||||
|
template<> struct char_traits<dbchar_t>;
|
||||||
|
}
|
||||||
|
namespace tss
|
||||||
|
{
|
||||||
|
typedef std::basic_string<dbchar_t> dbstring;
|
||||||
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#error "wchar_t is not correctly factored!"
|
# error "wchar_t is not correctly factored!"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -84,151 +93,140 @@
|
||||||
|
|
||||||
// specialize *std*::char_traits!!!
|
// specialize *std*::char_traits!!!
|
||||||
|
|
||||||
template<>
|
template<> struct std::char_traits<dbchar_t>
|
||||||
struct std::char_traits< dbchar_t >
|
|
||||||
{
|
{
|
||||||
typedef dbchar_t char_type;
|
typedef dbchar_t char_type;
|
||||||
typedef wint_t int_type;
|
typedef wint_t int_type;
|
||||||
typedef streampos pos_type;
|
typedef streampos pos_type;
|
||||||
typedef streamoff off_type;
|
typedef streamoff off_type;
|
||||||
|
|
||||||
#ifdef MBSTATE_T_DEFINED
|
# ifdef MBSTATE_T_DEFINED
|
||||||
typedef mbstate_t state_type;
|
typedef mbstate_t state_type;
|
||||||
#else
|
# else
|
||||||
typedef int state_type; // Shame on you KAI! This is ANSI-C!
|
typedef int state_type; // Shame on you KAI! This is ANSI-C!
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
static
|
static void assign(char_type& lhs, const char_type& rhs)
|
||||||
void assign( char_type& lhs, const char_type& rhs ) {
|
{
|
||||||
lhs = rhs;
|
lhs = rhs;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static bool eq(const char_type& lhs, const char_type& rhs)
|
||||||
bool eq( const char_type& lhs, const char_type& rhs ) {
|
{
|
||||||
return lhs == rhs;
|
return lhs == rhs;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static bool lt(const char_type& lhs, const char_type& rhs)
|
||||||
bool lt( const char_type& lhs, const char_type& rhs ) {
|
{
|
||||||
return lhs < rhs;
|
return lhs < rhs;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static int compare(const char_type* lhs, const char_type* rhs, size_t N)
|
||||||
int compare( const char_type* lhs, const char_type* rhs, size_t N )
|
|
||||||
{
|
{
|
||||||
for ( ; N; ++lhs, ++rhs, --N )
|
for (; N; ++lhs, ++rhs, --N)
|
||||||
if ( *lhs != *rhs )
|
if (*lhs != *rhs)
|
||||||
return ( *lhs < *rhs ) ? -1 : +1;
|
return (*lhs < *rhs) ? -1 : +1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static size_t length(const char_type* psz)
|
||||||
size_t length( const char_type* psz )
|
|
||||||
{
|
{
|
||||||
if ( psz == 0 )
|
if (psz == 0)
|
||||||
return 0;
|
return 0;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const char_type* end;
|
const char_type* end;
|
||||||
for ( end = psz; *end; end++ );
|
for (end = psz; *end; end++)
|
||||||
return (size_t)( end - psz );
|
;
|
||||||
|
return (size_t)(end - psz);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static char_type* copy(char_type* lhs, const char_type* rhs, size_t N)
|
||||||
char_type* copy( char_type* lhs, const char_type* rhs, size_t N )
|
|
||||||
{
|
{
|
||||||
for ( char_type* at = lhs; N; ++at, ++rhs, --N )
|
for (char_type* at = lhs; N; ++at, ++rhs, --N)
|
||||||
*at = *rhs;
|
*at = *rhs;
|
||||||
|
|
||||||
return lhs;
|
return lhs;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static const char_type* find(const char_type* psz, size_t N, const char_type& ch)
|
||||||
const char_type*
|
|
||||||
find( const char_type* psz, size_t N, const char_type& ch )
|
|
||||||
{
|
{
|
||||||
for ( ; N; ++psz, --N )
|
for (; N; ++psz, --N)
|
||||||
if ( *psz == ch )
|
if (*psz == ch)
|
||||||
return psz;
|
return psz;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static char_type* move(char_type* lhs, const char_type* rhs, size_t N)
|
||||||
char_type* move( char_type* lhs, const char_type* rhs, size_t N ) {
|
{
|
||||||
return (char_type*)memmove( lhs, rhs, N * sizeof(char_type) );
|
return (char_type*)memmove(lhs, rhs, N * sizeof(char_type));
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static char_type* assign(char_type* lhs, size_t N, char_type ch)
|
||||||
char_type* assign( char_type* lhs, size_t N, char_type ch )
|
|
||||||
{
|
{
|
||||||
for ( char_type* at = lhs; N; ++at, --N )
|
for (char_type* at = lhs; N; ++at, --N)
|
||||||
*at = ch;
|
*at = ch;
|
||||||
return lhs;
|
return lhs;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static int_type not_eof(const int_type& ch)
|
||||||
int_type not_eof( const int_type& ch ) {
|
|
||||||
return int_type( !eq( ch, eof() ) ? ch : ~ch );
|
|
||||||
}
|
|
||||||
|
|
||||||
static
|
|
||||||
char_type to_char_type( const int_type& ch )
|
|
||||||
{
|
{
|
||||||
return
|
return int_type(!eq(ch, eof()) ? ch : ~ch);
|
||||||
eq_int_type( ch, to_int_type( ch ) )
|
|
||||||
? ch
|
|
||||||
: char_type(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static char_type to_char_type(const int_type& ch)
|
||||||
int_type to_int_type( const char_type& ch ) {
|
{
|
||||||
|
return eq_int_type(ch, to_int_type(ch)) ? ch : char_type(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int_type to_int_type(const char_type& ch)
|
||||||
|
{
|
||||||
return (int_type)ch;
|
return (int_type)ch;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static bool eq_int_type(const int_type& lhs, const int_type& rhs)
|
||||||
bool eq_int_type( const int_type& lhs, const int_type& rhs ) {
|
{
|
||||||
return lhs == rhs;
|
return lhs == rhs;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if IS_STDLIB_MODENA
|
# if IS_STDLIB_MODENA
|
||||||
|
|
||||||
// CAUTION:RAD -- Extra members required by Modena!!
|
// CAUTION:RAD -- Extra members required by Modena!!
|
||||||
|
|
||||||
#ifdef MBSTATE_T_DEFINED // This is ANSI-C *not* ANSI-C++!!
|
# ifdef MBSTATE_T_DEFINED // This is ANSI-C *not* ANSI-C++!!
|
||||||
static
|
static state_type get_state(pos_type pos)
|
||||||
state_type get_state( pos_type pos ) {
|
{
|
||||||
return pos.state();
|
return pos.state();
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static pos_type get_pos(pos_type pos, state_type state)
|
||||||
pos_type get_pos( pos_type pos, state_type state ) {
|
{
|
||||||
return pos_type( pos.offset(), state );
|
return pos_type(pos.offset(), state);
|
||||||
}
|
}
|
||||||
#endif//MBSTATE_T_DEFINED
|
# endif //MBSTATE_T_DEFINED
|
||||||
|
|
||||||
static
|
static char_type newline()
|
||||||
char_type newline() {
|
{
|
||||||
return L'\n';
|
return L'\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static char_type eos()
|
||||||
char_type eos() {
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif//IS_STDLIB_MODENA
|
# endif //IS_STDLIB_MODENA
|
||||||
|
|
||||||
static
|
static int_type eof()
|
||||||
int_type eof() {
|
{
|
||||||
return (wint_t)(0xFFFF);
|
return (wint_t)(0xFFFF);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif//WCHAR_IS_16_BITS // We already have a dbstring implicitly in wstring!!!
|
# endif //WCHAR_IS_16_BITS // We already have a dbstring implicitly in wstring!!!
|
||||||
|
|
||||||
|
|
||||||
#endif//__NTDBS_H
|
#endif //__NTDBS_H
|
||||||
|
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
//
|
//
|
||||||
// The developer of the original code and/or files is Tripwire, Inc.
|
// The developer of the original code and/or files is Tripwire, Inc.
|
||||||
// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire,
|
// Portions created by Tripwire, Inc. are copyright (C) 2000-2018 Tripwire,
|
||||||
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
||||||
// reserved.
|
// reserved.
|
||||||
//
|
//
|
||||||
// This program is free software. The contents of this file are subject
|
// 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
|
// 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
|
// Free Software Foundation; either version 2 of the License, or (at your
|
||||||
// option) any later version. You may redistribute it and/or modify it
|
// option) any later version. You may redistribute it and/or modify it
|
||||||
// only in compliance with the GNU General Public License.
|
// only in compliance with the GNU General Public License.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful.
|
// This program is distributed in the hope that it will be useful.
|
||||||
// However, this program is distributed AS-IS WITHOUT ANY
|
// However, this program is distributed AS-IS WITHOUT ANY
|
||||||
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
||||||
// for more details.
|
// for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
// USA.
|
// USA.
|
||||||
//
|
//
|
||||||
// Nothing in the GNU General Public License or any other license to use
|
// 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,
|
// the code or files shall permit you to use Tripwire's trademarks,
|
||||||
// service marks, or other intellectual property without Tripwire's
|
// service marks, or other intellectual property without Tripwire's
|
||||||
// prior written consent.
|
// prior written consent.
|
||||||
//
|
//
|
||||||
// If you have any questions, please contact Tripwire, Inc. at either
|
// If you have any questions, please contact Tripwire, Inc. at either
|
||||||
// info@tripwire.org or www.tripwire.org.
|
// info@tripwire.org or www.tripwire.org.
|
||||||
//
|
//
|
||||||
|
@ -38,20 +38,18 @@
|
||||||
* Routines to make NTMBS processing easier.
|
* Routines to make NTMBS processing easier.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "stdcore.h" // for: pch
|
#include "stdcore.h" // for: pch
|
||||||
#include "ntmbs.h" // for: These Declarations
|
#include "ntmbs.h" // for: These Declarations
|
||||||
|
|
||||||
|
|
||||||
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
// Module-wide Helpers
|
// Module-wide Helpers
|
||||||
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
||||||
#ifndef TSS_Raise // Should add file and line info in DEBUG mode!!!!
|
#ifndef TSS_Raise // Should add file and line info in DEBUG mode!!!!
|
||||||
#define TSS_Raise( Xcpt, pkg, ids ) \
|
# define TSS_Raise(Xcpt, pkg, ids) throw Xcpt(TSS_GetString(pkg, ids))
|
||||||
throw Xcpt( TSS_GetString( pkg, ids ) )
|
|
||||||
|
|
||||||
#endif//TSS_Raise
|
|
||||||
|
|
||||||
|
#endif //TSS_Raise
|
||||||
|
|
||||||
|
|
||||||
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -134,32 +132,28 @@ tss::mbsdec( const_ntmbs_t beg, const_ntmbs_t curr )
|
||||||
* POSTCONDITIONS:
|
* POSTCONDITIONS:
|
||||||
* Returns non-const pointer after moving it.
|
* Returns non-const pointer after moving it.
|
||||||
*/
|
*/
|
||||||
ntmbs_t
|
ntmbs_t tss::mbsinc(const_ntmbs_t psz)
|
||||||
tss::mbsinc( const_ntmbs_t psz )
|
|
||||||
{
|
{
|
||||||
cDebug dbg( "tss::mbsinc -" );
|
cDebug dbg("tss::mbsinc -");
|
||||||
|
|
||||||
if ( psz == 0 )
|
if (psz == 0)
|
||||||
throw eCharacter( TSS_GetString( cCore, core::STR_ERR_ISNULL ) );
|
throw eCharacter(TSS_GetString(cCore, core::STR_ERR_ISNULL));
|
||||||
|
|
||||||
int nBytes = ::mblen( (char*)psz, MB_CUR_MAX );
|
int nBytes = ::mblen((char*)psz, MB_CUR_MAX);
|
||||||
if ( nBytes == -1 )
|
if (nBytes == -1)
|
||||||
{
|
{
|
||||||
dbg.TraceDebug( "Character Fault: %c\n", *psz );
|
dbg.TraceDebug("Character Fault: %c\n", *psz);
|
||||||
if ( (unsigned char)*psz > 0x7F )
|
if ((unsigned char)*psz > 0x7F)
|
||||||
{
|
{
|
||||||
dbg.TraceDebug( "Normalizing.\n" );
|
dbg.TraceDebug("Normalizing.\n");
|
||||||
return (((ntmbs_t)psz) + 1 );
|
return (((ntmbs_t)psz) + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
dbg.TraceDebug( "Incorrectly Formed, Cannot Normalize!\n" );
|
dbg.TraceDebug("Incorrectly Formed, Cannot Normalize!\n");
|
||||||
TSS_Raise(
|
TSS_Raise(eCharacterEncoding, cCore, core::STR_ERR_BADCHAR);
|
||||||
eCharacterEncoding,
|
|
||||||
cCore,
|
|
||||||
core::STR_ERR_BADCHAR );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ( ((ntmbs_t)psz) + nBytes );
|
return (((ntmbs_t)psz) + nBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -180,33 +174,30 @@ tss::mbsinc( const_ntmbs_t psz )
|
||||||
* POSTCONDITIONS:
|
* POSTCONDITIONS:
|
||||||
* Returns size_t value indicating bytes in the range of [0,nCount).
|
* Returns size_t value indicating bytes in the range of [0,nCount).
|
||||||
*/
|
*/
|
||||||
size_t
|
size_t tss::mbsbytes(const_ntmbs_t psz, size_t nCount)
|
||||||
tss::mbsbytes( const_ntmbs_t psz, size_t nCount )
|
|
||||||
{
|
{
|
||||||
const_ntmbs_t at = psz;
|
const_ntmbs_t at = psz;
|
||||||
while ( nCount-- )
|
while (nCount--)
|
||||||
at = tss::mbsinc( at );
|
at = tss::mbsinc(at);
|
||||||
|
|
||||||
return (size_t)((char*)at - (char*)psz);
|
return (size_t)((char*)at - (char*)psz);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// To Null terminator
|
/// To Null terminator
|
||||||
|
|
||||||
size_t
|
size_t tss::mbsbytes(const_ntmbs_t psz)
|
||||||
tss::mbsbytes( const_ntmbs_t psz )
|
|
||||||
{
|
{
|
||||||
if ( psz == 0 )
|
if (psz == 0)
|
||||||
throw eCharacter( TSS_GetString( cCore, core::STR_ERR_ISNULL ) );
|
throw eCharacter(TSS_GetString(cCore, core::STR_ERR_ISNULL));
|
||||||
|
|
||||||
|
|
||||||
const_ntmbs_t at;
|
const_ntmbs_t at;
|
||||||
for ( at = psz; *at; ++at );
|
for (at = psz; *at; ++at)
|
||||||
|
;
|
||||||
return (size_t)((char*)at - (char*)psz);
|
return (size_t)((char*)at - (char*)psz);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TSS::mbscount
|
* TSS::mbscount
|
||||||
*
|
*
|
||||||
|
@ -224,25 +215,22 @@ tss::mbsbytes( const_ntmbs_t psz )
|
||||||
* POSTCONDITIONS:
|
* POSTCONDITIONS:
|
||||||
* Returns size_t value indicating characters in the range of [psz + 0, psz + nBytes).
|
* Returns size_t value indicating characters in the range of [psz + 0, psz + nBytes).
|
||||||
*/
|
*/
|
||||||
size_t
|
size_t tss_mbscount(const_ntmbs_t psz, size_t nBytes)
|
||||||
tss_mbscount( const_ntmbs_t psz, size_t nBytes )
|
|
||||||
{
|
{
|
||||||
size_t nCount = 0;
|
size_t nCount = 0;
|
||||||
const_ntmbs_t at = psz;
|
const_ntmbs_t at = psz;
|
||||||
const_ntmbs_t end = psz + nBytes;
|
const_ntmbs_t end = psz + nBytes;
|
||||||
for ( ; at < end; nCount++, at = tss::mbsinc( at ) );
|
for (; at < end; nCount++, at = tss::mbsinc(at))
|
||||||
|
;
|
||||||
return nCount;
|
return nCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// To Null terminator
|
/// To Null terminator
|
||||||
|
|
||||||
size_t
|
size_t tss::mbscount(const_ntmbs_t psz)
|
||||||
tss::mbscount( const_ntmbs_t psz )
|
|
||||||
{
|
{
|
||||||
size_t nCount = 0;
|
size_t nCount = 0;
|
||||||
for ( ; *psz; psz = tss::mbsinc( psz ), nCount++ );
|
for (; *psz; psz = tss::mbsinc(psz), nCount++)
|
||||||
|
;
|
||||||
return nCount;
|
return nCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
648
src/core/ntmbs.h
648
src/core/ntmbs.h
|
@ -1,31 +1,31 @@
|
||||||
//
|
//
|
||||||
// The developer of the original code and/or files is Tripwire, Inc.
|
// The developer of the original code and/or files is Tripwire, Inc.
|
||||||
// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire,
|
// Portions created by Tripwire, Inc. are copyright (C) 2000-2018 Tripwire,
|
||||||
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
||||||
// reserved.
|
// reserved.
|
||||||
//
|
//
|
||||||
// This program is free software. The contents of this file are subject
|
// 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
|
// 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
|
// Free Software Foundation; either version 2 of the License, or (at your
|
||||||
// option) any later version. You may redistribute it and/or modify it
|
// option) any later version. You may redistribute it and/or modify it
|
||||||
// only in compliance with the GNU General Public License.
|
// only in compliance with the GNU General Public License.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful.
|
// This program is distributed in the hope that it will be useful.
|
||||||
// However, this program is distributed AS-IS WITHOUT ANY
|
// However, this program is distributed AS-IS WITHOUT ANY
|
||||||
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
||||||
// for more details.
|
// for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
// USA.
|
// USA.
|
||||||
//
|
//
|
||||||
// Nothing in the GNU General Public License or any other license to use
|
// 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,
|
// the code or files shall permit you to use Tripwire's trademarks,
|
||||||
// service marks, or other intellectual property without Tripwire's
|
// service marks, or other intellectual property without Tripwire's
|
||||||
// prior written consent.
|
// prior written consent.
|
||||||
//
|
//
|
||||||
// If you have any questions, please contact Tripwire, Inc. at either
|
// If you have any questions, please contact Tripwire, Inc. at either
|
||||||
// info@tripwire.org or www.tripwire.org.
|
// info@tripwire.org or www.tripwire.org.
|
||||||
//
|
//
|
||||||
|
@ -45,9 +45,9 @@
|
||||||
|
|
||||||
/// Requirements.
|
/// Requirements.
|
||||||
|
|
||||||
#include "error.h" // for: TSS_EXCEPTION
|
#include "error.h" // for: TSS_EXCEPTION
|
||||||
#include "package.h" // for: TSS_GetString
|
#include "package.h" // for: TSS_GetString
|
||||||
#include "corestrings.h" // for: Utility Strings
|
#include "corestrings.h" // for: Utility Strings
|
||||||
|
|
||||||
|
|
||||||
/// Type Definitions for Multiple (?), Double (16), and Wide Characters (32)
|
/// Type Definitions for Multiple (?), Double (16), and Wide Characters (32)
|
||||||
|
@ -55,28 +55,27 @@
|
||||||
//--Null-terminated Multibyte Character Sequence
|
//--Null-terminated Multibyte Character Sequence
|
||||||
|
|
||||||
#ifndef NTMBS_T_DEFINED
|
#ifndef NTMBS_T_DEFINED
|
||||||
#define NTMBS_T_DEFINED
|
# define NTMBS_T_DEFINED
|
||||||
#ifdef TSS_NTMBS_IS_UNSIGNED // Natural-sign by default
|
# ifdef TSS_NTMBS_IS_UNSIGNED // Natural-sign by default
|
||||||
typedef unsigned char mbchar_t;
|
typedef unsigned char mbchar_t;
|
||||||
typedef unsigned char* ntmbs_t;
|
typedef unsigned char* ntmbs_t;
|
||||||
typedef const unsigned char* const_ntmbs_t;
|
typedef const unsigned char* const_ntmbs_t;
|
||||||
#else //TSS_NTMBS_IS_UNSIGNED
|
# else //TSS_NTMBS_IS_UNSIGNED
|
||||||
typedef char mbchar_t;
|
typedef char mbchar_t;
|
||||||
typedef char* ntmbs_t;
|
typedef char* ntmbs_t;
|
||||||
typedef const char* const_ntmbs_t;
|
typedef const char* const_ntmbs_t;
|
||||||
#endif//TSS_NTMBS_IS_UNSIGNED
|
# endif //TSS_NTMBS_IS_UNSIGNED
|
||||||
#endif//NTMBS_T_DEFINED
|
#endif //NTMBS_T_DEFINED
|
||||||
|
|
||||||
|
|
||||||
//--Null-terminated Wide Character Sequence (Could be double or quad byte)
|
//--Null-terminated Wide Character Sequence (Could be double or quad byte)
|
||||||
|
|
||||||
#ifndef NTWCS_T_DEFINED
|
#ifndef NTWCS_T_DEFINED
|
||||||
#define NTWCS_T_DEFINED
|
# define NTWCS_T_DEFINED
|
||||||
//typedef wchar_t wchar_t;
|
//typedef wchar_t wchar_t;
|
||||||
typedef wchar_t* ntwcs_t;
|
typedef wchar_t* ntwcs_t;
|
||||||
typedef const wchar_t* const_ntwcs_t;
|
typedef const wchar_t* const_ntwcs_t;
|
||||||
#endif//NTWCS_T_DEFINED
|
#endif //NTWCS_T_DEFINED
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// NOTE: Size Specific (2 [double] or 4 [quad] byte wide characters)
|
/// NOTE: Size Specific (2 [double] or 4 [quad] byte wide characters)
|
||||||
|
@ -84,57 +83,57 @@
|
||||||
//--Null-terminated double(2)-byte Character Sequence
|
//--Null-terminated double(2)-byte Character Sequence
|
||||||
|
|
||||||
#ifndef NTDBS_T_DEFINED
|
#ifndef NTDBS_T_DEFINED
|
||||||
#define NTDBS_T_DEFINED
|
# define NTDBS_T_DEFINED
|
||||||
#if WCHAR_IS_16_BITS
|
# if WCHAR_IS_16_BITS
|
||||||
typedef wchar_t dbchar_t; // Same size but use NT's type
|
typedef wchar_t dbchar_t; // Same size but use NT's type
|
||||||
#else
|
# else
|
||||||
typedef uint16 dbchar_t;
|
typedef uint16 dbchar_t;
|
||||||
#endif
|
# endif
|
||||||
typedef dbchar_t* ntdbs_t;
|
typedef dbchar_t* ntdbs_t;
|
||||||
typedef const dbchar_t* const_ntdbs_t;
|
typedef const dbchar_t* const_ntdbs_t;
|
||||||
#endif//NTDBS_T_DEFINED
|
#endif //NTDBS_T_DEFINED
|
||||||
|
|
||||||
|
|
||||||
//--Internal, "size-specific" types for type dispatched specializations
|
//--Internal, "size-specific" types for type dispatched specializations
|
||||||
|
|
||||||
#ifndef NTQBS_T_DEFINED
|
#ifndef NTQBS_T_DEFINED
|
||||||
#define NTQBS_T_DEFINED
|
# define NTQBS_T_DEFINED
|
||||||
#if WCHAR_IS_32_BITS
|
# if WCHAR_IS_32_BITS
|
||||||
typedef wchar_t qbchar_t; // Same size but use NT's type
|
typedef wchar_t qbchar_t; // Same size but use NT's type
|
||||||
#else
|
# else
|
||||||
typedef uint32 qbchar_t;
|
typedef uint32 qbchar_t;
|
||||||
#endif
|
# endif
|
||||||
typedef qbchar_t* ntqbs_t;
|
typedef qbchar_t* ntqbs_t;
|
||||||
typedef const qbchar_t* const_ntqbs_t;
|
typedef const qbchar_t* const_ntqbs_t;
|
||||||
#endif//NTQBS_T_DEFINED
|
#endif //NTQBS_T_DEFINED
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
// NTMBS Manipulators
|
// NTMBS Manipulators
|
||||||
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
||||||
TSS_EXCEPTION( eCharacter, eError );
|
TSS_EXCEPTION(eCharacter, eError);
|
||||||
TSS_EXCEPTION( eCharacterEncoding, eCharacter );
|
TSS_EXCEPTION(eCharacterEncoding, eCharacter);
|
||||||
|
|
||||||
|
|
||||||
namespace tss
|
namespace tss
|
||||||
{
|
{
|
||||||
/// Specific Routines (Add as needed)
|
/// 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 );
|
ntmbs_t mbsinc(const_ntmbs_t);
|
||||||
|
|
||||||
size_t mbsbytes( const_ntmbs_t, size_t );
|
size_t mbsbytes(const_ntmbs_t, size_t);
|
||||||
size_t mbscount( const_ntmbs_t, size_t );
|
size_t mbscount(const_ntmbs_t, size_t);
|
||||||
|
|
||||||
size_t mbsbytes( const_ntmbs_t );
|
size_t mbsbytes(const_ntmbs_t);
|
||||||
size_t mbscount( const_ntmbs_t );
|
size_t mbscount(const_ntmbs_t);
|
||||||
|
|
||||||
inline size_t mbslen( const_ntmbs_t psz ) { // RAD: Yeesh!
|
inline size_t mbslen(const_ntmbs_t psz)
|
||||||
return tss::mbscount( psz );
|
{ // RAD: Yeesh!
|
||||||
}
|
return tss::mbscount(psz);
|
||||||
}//tss::
|
}
|
||||||
|
} // namespace tss
|
||||||
|
|
||||||
|
|
||||||
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -145,15 +144,14 @@ namespace tss
|
||||||
|
|
||||||
namespace tss
|
namespace tss
|
||||||
{
|
{
|
||||||
/// Increment and Decrement Pointers by (N)
|
/// Increment and Decrement Pointers by (N)
|
||||||
|
|
||||||
//--DEC
|
//--DEC
|
||||||
|
|
||||||
template< class CT >
|
template<class CT> inline CT* strdec(const CT*, const CT* psz)
|
||||||
inline
|
{
|
||||||
CT* strdec( const CT*, const CT* psz ) {
|
return const_cast<CT*>(psz - 1);
|
||||||
return const_cast<CT*>( psz - 1 );
|
}
|
||||||
}
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
template<>
|
template<>
|
||||||
|
@ -164,96 +162,86 @@ namespace tss
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
//--INC
|
//--INC
|
||||||
|
|
||||||
template< class CT >
|
template<class CT> inline CT* strinc(const CT* psz)
|
||||||
inline
|
{
|
||||||
CT* strinc( const CT* psz )
|
ASSERT(psz);
|
||||||
{
|
return const_cast<CT*>((*psz ? psz + 1 : psz));
|
||||||
ASSERT( psz );
|
}
|
||||||
return const_cast<CT*>( ( *psz ? psz + 1 : psz ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
template< class CT, class SIZET >
|
template<class CT, class SIZET> inline CT* strinc(const CT* psz, SIZET N)
|
||||||
inline
|
{
|
||||||
CT* strinc( const CT* psz, SIZET N )
|
ASSERT(psz);
|
||||||
{
|
return const_cast<CT*>((*psz ? psz + N : psz));
|
||||||
ASSERT( psz );
|
}
|
||||||
return const_cast<CT*>( ( *psz ? psz + N : psz ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<>
|
|
||||||
inline
|
|
||||||
ntmbs_t strinc( const_ntmbs_t psz )
|
|
||||||
{
|
|
||||||
return tss::mbsinc( psz );
|
|
||||||
}
|
|
||||||
|
|
||||||
template<>
|
|
||||||
inline
|
|
||||||
ntmbs_t strinc( const_ntmbs_t psz, size_t N )
|
|
||||||
{
|
|
||||||
ntmbs_t at = const_cast<ntmbs_t>( psz );
|
|
||||||
while ( N-- )
|
|
||||||
at = tss::mbsinc( at );
|
|
||||||
return at;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// Byte and Character Count Mappings
|
template<> inline ntmbs_t strinc(const_ntmbs_t psz)
|
||||||
|
{
|
||||||
|
return tss::mbsinc(psz);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<> inline ntmbs_t strinc(const_ntmbs_t psz, size_t N)
|
||||||
|
{
|
||||||
|
ntmbs_t at = const_cast<ntmbs_t>(psz);
|
||||||
|
while (N--)
|
||||||
|
at = tss::mbsinc(at);
|
||||||
|
return at;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//--BYTES
|
/// Byte and Character Count Mappings
|
||||||
|
|
||||||
template< class CT >
|
|
||||||
size_t strsize( const CT* psz )
|
|
||||||
{
|
|
||||||
const CT* at = psz;
|
|
||||||
while ( *at ) at++;
|
|
||||||
return (size_t)((char*)at - (char*)psz);
|
|
||||||
}
|
|
||||||
|
|
||||||
template< class CT >
|
|
||||||
size_t strsize( const CT*, size_t N )
|
|
||||||
{
|
|
||||||
return N * sizeof(CT);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<>
|
|
||||||
inline size_t strsize( const_ntmbs_t psz ) {
|
|
||||||
return mbsbytes( psz );
|
|
||||||
}
|
|
||||||
template<>
|
|
||||||
inline size_t strsize( const_ntmbs_t psz, size_t N ) {
|
|
||||||
return mbsbytes( psz, N );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//--COUNT
|
//--BYTES
|
||||||
|
|
||||||
template< class CT >
|
template<class CT> size_t strsize(const CT* psz)
|
||||||
size_t strcount( const CT* psz )
|
{
|
||||||
{
|
const CT* at = psz;
|
||||||
const CT* at = psz;
|
while (*at)
|
||||||
while ( *at ) at++;
|
at++;
|
||||||
return (size_t)(at - psz);
|
return (size_t)((char*)at - (char*)psz);
|
||||||
}
|
}
|
||||||
|
|
||||||
template< class CT >
|
template<class CT> size_t strsize(const CT*, size_t N)
|
||||||
size_t strcount( const CT*, size_t N )
|
{
|
||||||
{
|
return N * sizeof(CT);
|
||||||
return N;
|
}
|
||||||
}
|
|
||||||
|
template<> inline size_t strsize(const_ntmbs_t psz)
|
||||||
template<>
|
{
|
||||||
inline size_t strcount( const_ntmbs_t psz ) {
|
return mbsbytes(psz);
|
||||||
return mbscount( psz );
|
}
|
||||||
}
|
template<> inline size_t strsize(const_ntmbs_t psz, size_t N)
|
||||||
template<>
|
{
|
||||||
inline size_t strcount( const_ntmbs_t psz, size_t N ) {
|
return mbsbytes(psz, N);
|
||||||
return mbscount( psz, N );
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
//--COUNT
|
||||||
|
|
||||||
|
template<class CT> size_t strcount(const CT* psz)
|
||||||
|
{
|
||||||
|
const CT* at = psz;
|
||||||
|
while (*at)
|
||||||
|
at++;
|
||||||
|
return (size_t)(at - psz);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class CT> size_t strcount(const CT*, size_t N)
|
||||||
|
{
|
||||||
|
return N;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<> inline size_t strcount(const_ntmbs_t psz)
|
||||||
|
{
|
||||||
|
return mbscount(psz);
|
||||||
|
}
|
||||||
|
template<> inline size_t strcount(const_ntmbs_t psz, size_t N)
|
||||||
|
{
|
||||||
|
return mbscount(psz, N);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* These are needed! However, it would be better to just create
|
/* These are needed! However, it would be better to just create
|
||||||
|
@ -262,7 +250,7 @@ done with it */
|
||||||
|
|
||||||
#ifdef TSS_NTMBS_AWARE_SEACH_COMPLETE
|
#ifdef TSS_NTMBS_AWARE_SEACH_COMPLETE
|
||||||
|
|
||||||
/* CAUTION:RAD -- I changed the traversal logic from "!=" to
|
/* CAUTION:RAD -- I changed the traversal logic from "!=" to
|
||||||
"<" to accomodate a basic_string whose end() member does not
|
"<" to accomodate a basic_string whose end() member does not
|
||||||
correctly point after the last valid trail-byte in a string.
|
correctly point after the last valid trail-byte in a string.
|
||||||
Really, at != end should be correct, but I don't want to leave
|
Really, at != end should be correct, but I don't want to leave
|
||||||
|
@ -270,243 +258,209 @@ done with it */
|
||||||
under unit test and have all occurances of "at < end" changed
|
under unit test and have all occurances of "at < end" changed
|
||||||
to the "more on-purpose" "at != end". */
|
to the "more on-purpose" "at != end". */
|
||||||
|
|
||||||
/// Various MULTIBYTE aware string searching routines..
|
/// Various MULTIBYTE aware string searching routines..
|
||||||
|
|
||||||
//--FIND_FIRST: ITER
|
//--FIND_FIRST: ITER
|
||||||
|
|
||||||
template< class InputT, class E >
|
template<class InputT, class E> InputT find_first(InputT beg, InputT end, const E& item)
|
||||||
InputT
|
{
|
||||||
find_first( InputT beg, InputT end, const E& item )
|
for (; beg < end && *beg != item; beg = (InputT)tss::strinc(beg))
|
||||||
{
|
;
|
||||||
for ( ; beg < end && *beg != item; beg = (InputT)tss::strinc( beg ) );
|
return beg;
|
||||||
return beg;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//--FIND_LAST: ITER
|
|
||||||
|
|
||||||
template< class InputT, class E >
|
|
||||||
InputT
|
|
||||||
find_last( InputT beg, InputT end, const E& item )
|
|
||||||
{
|
|
||||||
InputT at = end;
|
|
||||||
for ( ; beg < end ; beg = (InputT)tss::strinc( beg ) );
|
|
||||||
if ( *beg == item )
|
|
||||||
at = beg;
|
|
||||||
|
|
||||||
return at;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//--FIND_FIRST: STRING
|
//--FIND_LAST: ITER
|
||||||
|
|
||||||
template< class StrT >
|
template<class InputT, class E> InputT find_last(InputT beg, InputT end, const E& item)
|
||||||
StrT::size_type
|
{
|
||||||
find_first( const StrT& sin, StrT::const_reference item )
|
InputT at = end;
|
||||||
{
|
for (; beg < end; beg = (InputT)tss::strinc(beg))
|
||||||
StrT::const_iterator
|
;
|
||||||
beg = sin.begin();
|
if (*beg == item)
|
||||||
end = sin.end();
|
at = beg;
|
||||||
|
|
||||||
StrT::size_type N;
|
return at;
|
||||||
for ( N = 0; beg < end; ++N, beg = (InputT)tss::strinc( beg ) )
|
}
|
||||||
if ( *beg == item )
|
|
||||||
|
|
||||||
|
//--FIND_FIRST: STRING
|
||||||
|
|
||||||
|
template<class StrT> StrT::size_type find_first(const StrT& sin, StrT::const_reference item)
|
||||||
|
{
|
||||||
|
StrT::const_iterator beg = sin.begin();
|
||||||
|
end = sin.end();
|
||||||
|
|
||||||
|
StrT::size_type N;
|
||||||
|
for (N = 0; beg < end; ++N, beg = (InputT)tss::strinc(beg))
|
||||||
|
if (*beg == item)
|
||||||
|
return N;
|
||||||
|
|
||||||
|
return StrT::npos;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--FIND_LAST: STRING
|
||||||
|
|
||||||
|
template<class StrT> StrT::size_type find_last(const StrT& sin, StrT::const_reference item)
|
||||||
|
{
|
||||||
|
StrT::size_type N = 0;
|
||||||
|
StrT::size_type nResult = StrT::npos;
|
||||||
|
StrT::const_iterator beg = sin.begin();
|
||||||
|
end = sin.end();
|
||||||
|
|
||||||
|
for (; beg < end; beg = (InputT)tss::strinc(beg))
|
||||||
|
;
|
||||||
|
if (*beg == item)
|
||||||
|
nResult = N;
|
||||||
|
|
||||||
|
return N;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--FIND_FIRST_OF: ITER
|
||||||
|
|
||||||
|
template<class InputT> InputT find_first_of(InputT beg, InputT end, InputT setbeg, InputT setend)
|
||||||
|
{
|
||||||
|
InputT at;
|
||||||
|
for (; beg < end; beg = (InputT)tss::strinc(beg))
|
||||||
|
;
|
||||||
|
for (at = setbeg; setbeg < setend; at = (InputT)tss::strinc(at))
|
||||||
|
if (*beg == *at)
|
||||||
|
return beg;
|
||||||
|
|
||||||
|
return end;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--FIND_FIRST_OF: STRING (SAFE!!!)
|
||||||
|
|
||||||
|
template<class StrT> StrT::size_type find_first_of(const StrT& sin, StrT::const_iterator set)
|
||||||
|
{
|
||||||
|
// Point to beg of input
|
||||||
|
StrT::iterator beg = sin.begin();
|
||||||
|
|
||||||
|
// Start Search
|
||||||
|
StrT::size_type N = 0;
|
||||||
|
for (; beg < sin.end(); ++N, beg = tss::strinc(beg))
|
||||||
|
for (StrT::const_iterator at = set; *at; at = tss::strinc(at))
|
||||||
|
if (*beg == *at)
|
||||||
return N;
|
return N;
|
||||||
|
|
||||||
return StrT::npos;
|
return StrT::npos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//--FIND_LAST: STRING
|
|
||||||
|
|
||||||
template< class StrT >
|
|
||||||
StrT::size_type
|
|
||||||
find_last( const StrT& sin, StrT::const_reference item )
|
|
||||||
{
|
|
||||||
StrT::size_type N = 0;
|
|
||||||
StrT::size_type nResult = StrT::npos;
|
|
||||||
StrT::const_iterator
|
|
||||||
beg = sin.begin();
|
|
||||||
end = sin.end();
|
|
||||||
|
|
||||||
for ( ; beg < end ; beg = (InputT)tss::strinc( beg ) );
|
|
||||||
if ( *beg == item )
|
|
||||||
nResult = N;
|
|
||||||
|
|
||||||
return N;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//--FIND_FIRST_OF: ITER
|
//--FIND_FIRST_OF: STRING (NOT SAFE!!!)
|
||||||
|
|
||||||
template< class InputT >
|
template<class StrT>
|
||||||
InputT
|
StrT::size_type find_first_of(const StrT& sin, StrT::const_iterator set, StrT::size_type nPos, StrT::size_type nCount)
|
||||||
find_first_of(
|
{
|
||||||
InputT beg,
|
|
||||||
InputT end,
|
|
||||||
InputT setbeg,
|
|
||||||
InputT setend )
|
|
||||||
{
|
|
||||||
InputT at;
|
|
||||||
for ( ; beg < end; beg = (InputT)tss::strinc( beg ) );
|
|
||||||
for ( at = setbeg; setbeg < setend; at = (InputT)tss::strinc( at ) )
|
|
||||||
if ( *beg == *at )
|
|
||||||
return beg;
|
|
||||||
|
|
||||||
return end;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//--FIND_FIRST_OF: STRING (SAFE!!!)
|
|
||||||
|
|
||||||
template< class StrT >
|
|
||||||
StrT::size_type
|
|
||||||
find_first_of( const StrT& sin, StrT::const_iterator set )
|
|
||||||
{
|
|
||||||
// Point to beg of input
|
|
||||||
StrT::iterator beg = sin.begin();
|
|
||||||
|
|
||||||
// Start Search
|
|
||||||
StrT::size_type N = 0;
|
|
||||||
for ( ; beg < sin.end(); ++N, beg = tss::strinc( beg ) )
|
|
||||||
for ( StrT::const_iterator at = set; *at; at = tss::strinc( at ) )
|
|
||||||
if ( *beg == *at )
|
|
||||||
return N;
|
|
||||||
|
|
||||||
return StrT::npos;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//--FIND_FIRST_OF: STRING (NOT SAFE!!!)
|
|
||||||
|
|
||||||
template< class StrT >
|
|
||||||
StrT::size_type
|
|
||||||
find_first_of(
|
|
||||||
const StrT& sin,
|
|
||||||
StrT::const_iterator set,
|
|
||||||
StrT::size_type nPos,
|
|
||||||
StrT::size_type nCount )
|
|
||||||
{
|
|
||||||
ASSERT( nPos < tss::strcount( sin.begin() );
|
ASSERT( nPos < tss::strcount( sin.begin() );
|
||||||
|
|
||||||
if ( nCount > 0 && nPos < sin.size() )
|
if ( nCount > 0 && nPos < sin.size() )
|
||||||
{
|
{
|
||||||
ASSERT( nCount > tss::strcount( set ) );
|
ASSERT(nCount > tss::strcount(set));
|
||||||
StrT::const_iterator endset; // Get end of set
|
StrT::const_iterator endset; // Get end of set
|
||||||
while ( nCount-- ) endset++;
|
while (nCount--)
|
||||||
|
endset++;
|
||||||
|
|
||||||
// Advance to nPos
|
// Advance to nPos
|
||||||
StrT::const_iterator at = tss::strinc( sin.begin(), nPos );
|
StrT::const_iterator at = tss::strinc(sin.begin(), nPos);
|
||||||
StrT::const_iterator end = sin.end();
|
StrT::const_iterator end = sin.end();
|
||||||
|
|
||||||
// Start Search
|
// Start Search
|
||||||
StrT::size_type N = 0;
|
StrT::size_type N = 0;
|
||||||
for ( ; at < end; ++N, at = tss::strinc( at ) )
|
for (; at < end; ++N, at = tss::strinc(at))
|
||||||
{
|
{
|
||||||
if ( tss::find( set, endset, *at ) != 0 )
|
if (tss::find(set, endset, *at) != 0)
|
||||||
return N;
|
return N;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return StrT::npos;
|
return StrT::npos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//--FIND_LAST_OF: ITER
|
//--FIND_LAST_OF: ITER
|
||||||
|
|
||||||
template< class InputT1, class InputT2 >
|
template<class InputT1, class InputT2>
|
||||||
InputT
|
InputT find_last_of(const InputT1 beg, const InputT1 end, const InputT2 setbeg, const InputT2 setend)
|
||||||
find_last_of(
|
{
|
||||||
const InputT1 beg, const InputT1 end,
|
const InputT1 ans = end;
|
||||||
const InputT2 setbeg, const InputT2 setend )
|
for (; beg < end; beg = tss::strinc(beg))
|
||||||
|
;
|
||||||
|
for (InputT2 at = setbeg; setbeg != setend; at = tss::strinc(at))
|
||||||
|
if (*beg == *at)
|
||||||
|
ans = beg;
|
||||||
|
|
||||||
|
return ans;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--FIND_LAST_OF: STRING (SAFE!!!)
|
||||||
|
|
||||||
|
template<class StrT> StrT::size_type find_last_of(const StrT& sin, StrT::const_iterator set)
|
||||||
|
{
|
||||||
|
StrT::size_type nResult = StrT::npos;
|
||||||
|
StrT::size_type N = 0;
|
||||||
|
for (; at < end; ++N, at = tss::strinc(at))
|
||||||
{
|
{
|
||||||
const InputT1 ans = end;
|
for (StrT::const_iterator at = set; *at; at = tss::strinc(at))
|
||||||
for ( ; beg < end; beg = tss::strinc( beg ) );
|
if (*beg == *at)
|
||||||
for ( InputT2 at = setbeg; setbeg != setend; at = tss::strinc( at ) )
|
nResult = N;
|
||||||
if ( *beg == *at )
|
|
||||||
ans = beg;
|
|
||||||
|
|
||||||
return ans;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return nResult;
|
||||||
|
}
|
||||||
|
|
||||||
//--FIND_LAST_OF: STRING (SAFE!!!)
|
|
||||||
|
|
||||||
template< class StrT >
|
template<class StrT>
|
||||||
StrT::size_type
|
StrT::size_type find_last_of(const StrT& sin, StrT::const_iterator set, StrT::size_type nStart, StrT::size_type nCount)
|
||||||
find_last_of( const StrT& sin, StrT::const_iterator set )
|
{
|
||||||
|
if (nCount > 0 && sin.size())
|
||||||
{
|
{
|
||||||
StrT::size_type nResult = StrT::npos;
|
for (StrT::const_iterator at = sin.begin() + (nStart < _Len ? nStart : _Len - 1);; --_U)
|
||||||
StrT::size_type N = 0;
|
if (_Tr::find(set, nCount, *_U) != 0)
|
||||||
for ( ; at < end; ++N, at = tss::strinc( at ) )
|
return (_U - _Ptr);
|
||||||
{
|
else if (_U == _Ptr)
|
||||||
for ( StrT::const_iterator at = set; *at; at = tss::strinc( at ) )
|
break;
|
||||||
if ( *beg == *at )
|
|
||||||
nResult = N;
|
|
||||||
}
|
|
||||||
|
|
||||||
return nResult;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return StrT::npos;
|
||||||
|
}
|
||||||
|
|
||||||
template< class StrT >
|
// TODO:RAD -- find_first_not_of;
|
||||||
StrT::size_type
|
// TODO:RAD -- find_last_not_of;
|
||||||
find_last_of(
|
|
||||||
const StrT& sin,
|
|
||||||
StrT::const_iterator set,
|
|
||||||
StrT::size_type nStart,
|
|
||||||
StrT::size_type nCount )
|
|
||||||
{
|
|
||||||
if ( nCount > 0 && sin.size() )
|
|
||||||
{
|
|
||||||
for ( StrT::const_iterator at = sin.begin()
|
|
||||||
+ (nStart < _Len ? nStart : _Len - 1); ; --_U)
|
|
||||||
if (_Tr::find(set, nCount, *_U) != 0)
|
|
||||||
return (_U - _Ptr);
|
|
||||||
else if (_U == _Ptr)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return StrT::npos;
|
#endif //TSS_NTMBS_AWARE_SEACH_COMPLETE
|
||||||
}
|
|
||||||
|
|
||||||
// TODO:RAD -- find_first_not_of;
|
namespace util
|
||||||
// TODO:RAD -- find_last_not_of;
|
{
|
||||||
|
// Preserves bit values when enlarging a type to a size_t
|
||||||
|
// Good for preventing sign extension
|
||||||
|
template<class E> inline size_t char_to_size(E ch)
|
||||||
|
{
|
||||||
|
// if this fails, 'ch' can't be cast to a
|
||||||
|
// size_t and preserve bit values
|
||||||
|
// if this fails, then you must find another way
|
||||||
|
ASSERT(sizeof(size_t) >= sizeof(E));
|
||||||
|
|
||||||
#endif//TSS_NTMBS_AWARE_SEACH_COMPLETE
|
// assert that either 'ch' is an unsigned value (no sign extension possible)
|
||||||
|
// or that 'ch' is the same size as a size_t (no sign extension is possible as well)
|
||||||
|
// if this fails, then you must specialize this function like we did for 'char'
|
||||||
|
ASSERT((int)(E)-1 > (int)0 || sizeof(size_t) == sizeof(E));
|
||||||
|
|
||||||
namespace util
|
return (size_t)ch;
|
||||||
{
|
}
|
||||||
// Preserves bit values when enlarging a type to a size_t
|
|
||||||
// Good for preventing sign extension
|
|
||||||
template< class E >
|
|
||||||
inline
|
|
||||||
size_t
|
|
||||||
char_to_size( E ch )
|
|
||||||
{
|
|
||||||
// if this fails, 'ch' can't be cast to a
|
|
||||||
// size_t and preserve bit values
|
|
||||||
// if this fails, then you must find another way
|
|
||||||
ASSERT( sizeof( size_t ) >= sizeof( E ) );
|
|
||||||
|
|
||||||
// assert that either 'ch' is an unsigned value (no sign extension possible)
|
|
||||||
// or that 'ch' is the same size as a size_t (no sign extension is possible as well)
|
|
||||||
// if this fails, then you must specialize this function like we did for 'char'
|
|
||||||
ASSERT( (int)(E)-1 > (int)0 || sizeof( size_t ) == sizeof( E ) );
|
|
||||||
|
|
||||||
return (size_t)ch;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline
|
|
||||||
size_t
|
|
||||||
char_to_size( char ch )
|
|
||||||
{
|
|
||||||
return (size_t)(unsigned char)ch;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}//tss::
|
|
||||||
|
|
||||||
|
|
||||||
#endif//__NTMBS_H
|
inline size_t char_to_size(char ch)
|
||||||
|
{
|
||||||
|
return (size_t)(unsigned char)ch;
|
||||||
|
}
|
||||||
|
} // namespace util
|
||||||
|
} // namespace tss
|
||||||
|
|
||||||
|
|
||||||
|
#endif //__NTMBS_H
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
//
|
//
|
||||||
// The developer of the original code and/or files is Tripwire, Inc.
|
// The developer of the original code and/or files is Tripwire, Inc.
|
||||||
// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire,
|
// Portions created by Tripwire, Inc. are copyright (C) 2000-2018 Tripwire,
|
||||||
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
||||||
// reserved.
|
// reserved.
|
||||||
//
|
//
|
||||||
// This program is free software. The contents of this file are subject
|
// 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
|
// 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
|
// Free Software Foundation; either version 2 of the License, or (at your
|
||||||
// option) any later version. You may redistribute it and/or modify it
|
// option) any later version. You may redistribute it and/or modify it
|
||||||
// only in compliance with the GNU General Public License.
|
// only in compliance with the GNU General Public License.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful.
|
// This program is distributed in the hope that it will be useful.
|
||||||
// However, this program is distributed AS-IS WITHOUT ANY
|
// However, this program is distributed AS-IS WITHOUT ANY
|
||||||
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
||||||
// for more details.
|
// for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
// USA.
|
// USA.
|
||||||
//
|
//
|
||||||
// Nothing in the GNU General Public License or any other license to use
|
// 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,
|
// the code or files shall permit you to use Tripwire's trademarks,
|
||||||
// service marks, or other intellectual property without Tripwire's
|
// service marks, or other intellectual property without Tripwire's
|
||||||
// prior written consent.
|
// prior written consent.
|
||||||
//
|
//
|
||||||
// If you have any questions, please contact Tripwire, Inc. at either
|
// If you have any questions, please contact Tripwire, Inc. at either
|
||||||
// info@tripwire.org or www.tripwire.org.
|
// info@tripwire.org or www.tripwire.org.
|
||||||
//
|
//
|
||||||
|
@ -52,7 +52,7 @@
|
||||||
// themselves singletons or shared. Using the package interface
|
// themselves singletons or shared. Using the package interface
|
||||||
// guarantees that all shared resources will be properely
|
// guarantees that all shared resources will be properely
|
||||||
// initialized before they are used. When creating a package
|
// initialized before they are used. When creating a package
|
||||||
// representation you can declare other packages that your
|
// representation you can declare other packages that your
|
||||||
// package depends on, ensuring that predicate packages and their
|
// package depends on, ensuring that predicate packages and their
|
||||||
// resources will be initialized before the package that uses
|
// resources will be initialized before the package that uses
|
||||||
// those resources.
|
// those resources.
|
||||||
|
@ -60,8 +60,8 @@
|
||||||
// Contents of this File
|
// Contents of this File
|
||||||
//
|
//
|
||||||
// TSS_Package( cPackage )
|
// TSS_Package( cPackage )
|
||||||
// TSS_BeginPackage( cPackage )
|
// TSS_BeginPackage( cPackage )
|
||||||
// TSS_EndPackage( cPackage )
|
// TSS_EndPackage( cPackage )
|
||||||
// TSS_ImplementPackage( cPackage )
|
// TSS_ImplementPackage( cPackage )
|
||||||
// TSS_Dependency( cPackage )
|
// TSS_Dependency( cPackage )
|
||||||
//
|
//
|
||||||
|
@ -71,7 +71,7 @@
|
||||||
// TSS_BeginStringtable( cPackage )
|
// TSS_BeginStringtable( cPackage )
|
||||||
// TSS_StringEntry( IDS, "message" )
|
// TSS_StringEntry( IDS, "message" )
|
||||||
// TSS_EndStringtable( cPackage )
|
// TSS_EndStringtable( cPackage )
|
||||||
//
|
//
|
||||||
// TSS_BeginStringIds( package_namespace )
|
// TSS_BeginStringIds( package_namespace )
|
||||||
// TSS_EndStringIds( package_namespace )
|
// TSS_EndStringIds( package_namespace )
|
||||||
//
|
//
|
||||||
|
@ -82,7 +82,7 @@
|
||||||
#ifndef __PACKAGE_H
|
#ifndef __PACKAGE_H
|
||||||
#define __PACKAGE_H
|
#define __PACKAGE_H
|
||||||
|
|
||||||
#include "resources.h" // for: cMessage_<KEY,CHAR>
|
#include "resources.h" // for: cMessage_<KEY,CHAR>
|
||||||
|
|
||||||
|
|
||||||
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -91,90 +91,92 @@
|
||||||
|
|
||||||
//--PACKAGE Helpers
|
//--PACKAGE Helpers
|
||||||
|
|
||||||
#define TSS_Package( pkg ) \
|
#define TSS_Package(pkg) pkg::GetInstance() // Access "the" Package obj
|
||||||
pkg::GetInstance() // Access "the" Package obj
|
|
||||||
|
|
||||||
#define TSS_Dependency( pkg ) \
|
#define TSS_Dependency(pkg) TSS_Package(pkg) // Declare a Package Depend.
|
||||||
TSS_Package( pkg ) // Declare a Package Depend.
|
|
||||||
|
|
||||||
|
|
||||||
|
#define TSS_BeginPackage(pkg) \
|
||||||
#define TSS_BeginPackage( pkg ) \
|
class pkg : public cPackageBase_<TCHAR> \
|
||||||
class pkg : public cPackageBase_< TCHAR > \
|
{ \
|
||||||
{ \
|
public: \
|
||||||
public: \
|
|
||||||
static pkg& GetInstance();
|
static pkg& GetInstance();
|
||||||
|
|
||||||
|
|
||||||
#define TSS_EndPackage( pkg ) \
|
#define TSS_EndPackage(pkg) \
|
||||||
};
|
} \
|
||||||
|
;
|
||||||
|
|
||||||
#define TSS_ImplementPackage( pkg ) \
|
#define TSS_ImplementPackage(pkg) \
|
||||||
pkg& pkg::GetInstance() \
|
pkg& pkg::GetInstance() \
|
||||||
{ \
|
{ \
|
||||||
static bool bConstructed = false; \
|
static bool bConstructed = false; \
|
||||||
static pkg x; \
|
static pkg x; \
|
||||||
if ( !bConstructed ) \
|
if (!bConstructed) \
|
||||||
{ \
|
{ \
|
||||||
bConstructed = true; \
|
bConstructed = true; \
|
||||||
x.LoadStrings(); \
|
x.LoadStrings(); \
|
||||||
} \
|
} \
|
||||||
return x; \
|
return x; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//--STRINGTABLE Helperfs
|
//--STRINGTABLE Helperfs
|
||||||
|
|
||||||
#define TSS_GetString( pkg, id ) \
|
#define TSS_GetString(pkg, id) TSS_Package(pkg).GetString(id) // Access the Message String
|
||||||
TSS_Package( pkg ).GetString( id ) // Access the Message String
|
|
||||||
|
|
||||||
|
|
||||||
#define TSS_DECLARE_STRINGTABLE \
|
#define TSS_DECLARE_STRINGTABLE \
|
||||||
public: \
|
public: \
|
||||||
Messages::String \
|
Messages::String GetString(Messages::ConstKeyRef id) const \
|
||||||
GetString( \
|
{ \
|
||||||
Messages::ConstKeyRef id ) const { \
|
return m_messages.Get(id); \
|
||||||
return m_messages.Get( id ); } \
|
} \
|
||||||
void LoadStrings(); \
|
void LoadStrings(); \
|
||||||
private: \
|
\
|
||||||
Messages m_messages // Decare a Stringtable
|
private: \
|
||||||
|
Messages m_messages // Decare a Stringtable
|
||||||
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
#define TSS_BeginStringtable( pkg ) \
|
# define TSS_BeginStringtable(pkg) \
|
||||||
void pkg::LoadStrings() \
|
void pkg::LoadStrings() \
|
||||||
{ cDebug d( #pkg "::LoadStrings()" ); \
|
{ \
|
||||||
d.TraceDebug("Loading strings for " #pkg " package.\n"); \
|
cDebug d(#pkg "::LoadStrings()"); \
|
||||||
Messages::Pair astr[] = { // Define a Stringtable
|
d.TraceDebug("Loading strings for " #pkg " package.\n"); \
|
||||||
#else // DEBUG
|
Messages::Pair astr[] = { // Define a Stringtable
|
||||||
#define TSS_BeginStringtable( pkg ) \
|
#else // DEBUG
|
||||||
void pkg::LoadStrings() \
|
# define TSS_BeginStringtable(pkg) \
|
||||||
{ Messages::Pair astr[] = { // Define a Stringtable
|
void pkg::LoadStrings() \
|
||||||
#endif // DEBUG
|
{ \
|
||||||
|
Messages::Pair astr[] = { // Define a Stringtable
|
||||||
|
#endif // DEBUG
|
||||||
|
|
||||||
#define TSS_EndStringtable( pkg ) \
|
#define TSS_EndStringtable(pkg) \
|
||||||
}; m_messages.Put( \
|
} \
|
||||||
astr, astr + countof(astr) ); } // End define Strintable
|
; \
|
||||||
|
m_messages.Put(astr, astr + countof(astr)); \
|
||||||
|
} // End define Strintable
|
||||||
|
|
||||||
|
|
||||||
#define TSS_StringEntry( id, s ) \
|
#define TSS_StringEntry(id, s) Messages::Pair(id, s) // Stringtable Entry
|
||||||
Messages::Pair( id, s ) // Stringtable Entry
|
|
||||||
|
|
||||||
#define TSS_BeginStringIds( pns ) \
|
#define TSS_BeginStringIds(pns) \
|
||||||
namespace pns { \
|
namespace pns \
|
||||||
enum { // Define String IDs
|
{ \
|
||||||
|
enum \
|
||||||
#define TSS_EndStringIds( pns ) \
|
{ // Define String IDs
|
||||||
}; } // End define String IDs
|
|
||||||
|
|
||||||
|
#define TSS_EndStringIds(pns) \
|
||||||
|
} \
|
||||||
|
; \
|
||||||
|
} // End define String IDs
|
||||||
|
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
// cPackageBase_<CharT> -- Base class for all Package Resources
|
// cPackageBase_<CharT> -- Base class for all Package Resources
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// SYNOPSIS:
|
// SYNOPSIS:
|
||||||
// This class is the base class for all package representations
|
// This class is the base class for all package representations
|
||||||
// and, thus, establishes the package contract. It's interface
|
// and, thus, establishes the package contract. It's interface
|
||||||
// is relied on by the Package singleton wrapper, TSS_Package.
|
// is relied on by the Package singleton wrapper, TSS_Package.
|
||||||
|
@ -184,28 +186,25 @@
|
||||||
// be called once.
|
// be called once.
|
||||||
//
|
//
|
||||||
// CONSTRAINTS:
|
// CONSTRAINTS:
|
||||||
// A Package representation template must be instantiated with a
|
// A Package representation template must be instantiated with a
|
||||||
// "character concept" that is a valid STDCPP NTCTS.
|
// "character concept" that is a valid STDCPP NTCTS.
|
||||||
// This will most often be char (for NTBS), wchar_t (for NTWCS),
|
// This will most often be char (for NTBS), wchar_t (for NTWCS),
|
||||||
// but may also be unsigned char (for NTMBCS).
|
// but may also be unsigned char (for NTMBCS).
|
||||||
//
|
//
|
||||||
// INVARIANTS:
|
// INVARIANTS:
|
||||||
// m_nInstances <= 1
|
// m_nInstances <= 1
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
|
||||||
template< class CharT >
|
template<class CharT> class cPackageBase_
|
||||||
class cPackageBase_
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
typedef cMessages_<int, CharT> Messages;
|
||||||
|
|
||||||
typedef cMessages_< int, CharT > Messages;
|
void LoadStrings()
|
||||||
|
{
|
||||||
void LoadStrings()
|
}
|
||||||
{
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif//__PACKAGE_H
|
#endif //__PACKAGE_H
|
||||||
|
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
//
|
//
|
||||||
// The developer of the original code and/or files is Tripwire, Inc.
|
// The developer of the original code and/or files is Tripwire, Inc.
|
||||||
// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire,
|
// Portions created by Tripwire, Inc. are copyright (C) 2000-2018 Tripwire,
|
||||||
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
||||||
// reserved.
|
// reserved.
|
||||||
//
|
//
|
||||||
// This program is free software. The contents of this file are subject
|
// 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
|
// 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
|
// Free Software Foundation; either version 2 of the License, or (at your
|
||||||
// option) any later version. You may redistribute it and/or modify it
|
// option) any later version. You may redistribute it and/or modify it
|
||||||
// only in compliance with the GNU General Public License.
|
// only in compliance with the GNU General Public License.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful.
|
// This program is distributed in the hope that it will be useful.
|
||||||
// However, this program is distributed AS-IS WITHOUT ANY
|
// However, this program is distributed AS-IS WITHOUT ANY
|
||||||
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
||||||
// for more details.
|
// for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
// USA.
|
// USA.
|
||||||
//
|
//
|
||||||
// Nothing in the GNU General Public License or any other license to use
|
// 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,
|
// the code or files shall permit you to use Tripwire's trademarks,
|
||||||
// service marks, or other intellectual property without Tripwire's
|
// service marks, or other intellectual property without Tripwire's
|
||||||
// prior written consent.
|
// prior written consent.
|
||||||
//
|
//
|
||||||
// If you have any questions, please contact Tripwire, Inc. at either
|
// If you have any questions, please contact Tripwire, Inc. at either
|
||||||
// info@tripwire.org or www.tripwire.org.
|
// info@tripwire.org or www.tripwire.org.
|
||||||
//
|
//
|
||||||
|
@ -34,72 +34,72 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
# include <config.h>
|
#include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef __PLATFORM_H
|
#ifndef __PLATFORM_H
|
||||||
#define __PLATFORM_H
|
# define __PLATFORM_H
|
||||||
|
|
||||||
//NOTE: Autoconf is strongly preferred as the Right Way to detect platform-specific features/behaviors.
|
//NOTE: Autoconf is strongly preferred as the Right Way to detect platform-specific features/behaviors.
|
||||||
// These macros should really only be used when autoconf can't get the job done.
|
// These macros should really only be used when autoconf can't get the job done.
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
// Enumerations
|
// Enumerations
|
||||||
//
|
//
|
||||||
// For each of these "enumerations" we create unique integers identifying each
|
// For each of these "enumerations" we create unique integers identifying each
|
||||||
// variation. We group similar items together, such as OS_REDHAT and OS_SLACKWARE
|
// variation. We group similar items together, such as OS_REDHAT and OS_SLACKWARE
|
||||||
|
|
||||||
#define OS_UNKNOWN 0
|
# define OS_UNKNOWN 0
|
||||||
|
|
||||||
#define OS_WIN32 0x0101
|
# define OS_WIN32 0x0101
|
||||||
#define OS_CYGWIN 0x0102
|
# define OS_CYGWIN 0x0102
|
||||||
#define OS_DOS_DJGPP 0x0103
|
# define OS_DOS_DJGPP 0x0103
|
||||||
|
|
||||||
#define OS_LINUX 0x0201
|
# define OS_LINUX 0x0201
|
||||||
#define OS_ANDROID 0x0202
|
# define OS_ANDROID 0x0202
|
||||||
|
|
||||||
#define OS_FREEBSD 0x0301
|
# define OS_FREEBSD 0x0301
|
||||||
#define OS_NETBSD 0x0302
|
# define OS_NETBSD 0x0302
|
||||||
#define OS_OPENBSD 0x0303
|
# define OS_OPENBSD 0x0303
|
||||||
#define OS_DARWIN 0x0304
|
# define OS_DARWIN 0x0304
|
||||||
#define OS_DRAGONFLYBSD 0x0305
|
# define OS_DRAGONFLYBSD 0x0305
|
||||||
#define OS_MIDNIGHTBSD 0x0306
|
# define OS_MIDNIGHTBSD 0x0306
|
||||||
#define OS_MIRBSD 0x0307
|
# define OS_MIRBSD 0x0307
|
||||||
#define OS_BITRIG 0x0308
|
# define OS_BITRIG 0x0308
|
||||||
#define OS_LIBERTYBSD 0x0309
|
# define OS_LIBERTYBSD 0x0309
|
||||||
|
|
||||||
#define OS_SOLARIS 0x0400
|
# define OS_SOLARIS 0x0400
|
||||||
#define OS_AIX 0x0401
|
# define OS_AIX 0x0401
|
||||||
#define OS_HPUX 0x0402
|
# define OS_HPUX 0x0402
|
||||||
#define OS_IRIX 0x0403
|
# define OS_IRIX 0x0403
|
||||||
#define OS_OSF1 0x0404
|
# define OS_OSF1 0x0404
|
||||||
|
|
||||||
#define OS_MINIX 0x0501
|
# define OS_MINIX 0x0501
|
||||||
#define OS_HURD 0x0502
|
# define OS_HURD 0x0502
|
||||||
#define OS_HAIKU 0x0503
|
# define OS_HAIKU 0x0503
|
||||||
#define OS_SYLLABLE 0x0504
|
# define OS_SYLLABLE 0x0504
|
||||||
#define OS_SKYOS 0x0505
|
# define OS_SKYOS 0x0505
|
||||||
#define OS_SORTIX 0x0506
|
# define OS_SORTIX 0x0506
|
||||||
#define OS_MINT 0x0507
|
# define OS_MINT 0x0507
|
||||||
#define OS_AROS 0x0508
|
# define OS_AROS 0x0508
|
||||||
#define OS_RTEMS 0x0509
|
# define OS_RTEMS 0x0509
|
||||||
#define OS_RISCOS 0x050A
|
# define OS_RISCOS 0x050A
|
||||||
#define OS_REDOX 0x050B
|
# define OS_REDOX 0x050B
|
||||||
#define OS_QNX 0x050C
|
# define OS_QNX 0x050C
|
||||||
|
|
||||||
#define COMP_UNKNOWN 0
|
# define COMP_UNKNOWN 0
|
||||||
#define COMP_GCC 0x0001
|
# define COMP_GCC 0x0001
|
||||||
#define COMP_CLANG 0x0002
|
# define COMP_CLANG 0x0002
|
||||||
|
|
||||||
#define COMP_MSVC 0x0101
|
# define COMP_MSVC 0x0101
|
||||||
#define COMP_KAI_GCC 0x0201
|
# define COMP_KAI_GCC 0x0201
|
||||||
#define COMP_KAI_SUNPRO 0x0202
|
# define COMP_KAI_SUNPRO 0x0202
|
||||||
#define COMP_KAI_GLIBC 0x0203
|
# define COMP_KAI_GLIBC 0x0203
|
||||||
#define COMP_KAI_VISUALAGE 0x0204
|
# define COMP_KAI_VISUALAGE 0x0204
|
||||||
#define COMP_KAI_HPANSIC 0x0205
|
# define COMP_KAI_HPANSIC 0x0205
|
||||||
#define COMP_KAI_IRIX 0x0206
|
# define COMP_KAI_IRIX 0x0206
|
||||||
#define COMP_KAI_OSF1ALPHA 0x0207
|
# define COMP_KAI_OSF1ALPHA 0x0207
|
||||||
#define COMP_SUNPRO 0x0301
|
# define COMP_SUNPRO 0x0301
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
// Platform detection
|
// Platform detection
|
||||||
|
@ -112,143 +112,142 @@
|
||||||
// OS The OS
|
// OS The OS
|
||||||
// COMP The compiler
|
// COMP The compiler
|
||||||
//
|
//
|
||||||
// PLEASE NOTE: Do not set any preprocessor variable other than the above three in this
|
// PLEASE NOTE: Do not set any preprocessor variable other than the above three in this
|
||||||
// section. Use the following sections for anything that does not fall into
|
// section. Use the following sections for anything that does not fall into
|
||||||
// the above catagories.
|
// the above catagories.
|
||||||
|
|
||||||
#if defined(_WIN32)
|
# if defined(_WIN32)
|
||||||
#define OS OS_WIN32
|
# define OS OS_WIN32
|
||||||
#define IS_WIN32 1
|
# define IS_WIN32 1
|
||||||
|
|
||||||
#elif defined(__CYGWIN__)
|
# elif defined(__CYGWIN__)
|
||||||
#define OS OS_CYGWIN
|
# define OS OS_CYGWIN
|
||||||
#define IS_CYGWIN 1
|
# define IS_CYGWIN 1
|
||||||
|
|
||||||
|
# elif defined(__DJGPP__)
|
||||||
|
# define OS OS_DOS_DJGPP
|
||||||
|
# define IS_DOS_DJGPP 1
|
||||||
|
|
||||||
|
|
||||||
|
# elif defined(__ANDROID__)
|
||||||
|
# define OS OS_ANDROID
|
||||||
|
# define IS_ANDROID 1
|
||||||
|
|
||||||
|
# elif defined(__linux__)
|
||||||
|
# define OS OS_LINUX
|
||||||
|
# define IS_LINUX 1
|
||||||
|
|
||||||
#elif defined(__DJGPP__)
|
|
||||||
#define OS OS_DOS_DJGPP
|
|
||||||
#define IS_DOS_DJGPP 1
|
|
||||||
|
|
||||||
|
|
||||||
#elif defined(__ANDROID__)
|
|
||||||
#define OS OS_ANDROID
|
|
||||||
#define IS_ANDROID 1
|
|
||||||
|
|
||||||
#elif defined(__linux__)
|
|
||||||
#define OS OS_LINUX
|
|
||||||
#define IS_LINUX 1
|
|
||||||
|
|
||||||
|
|
||||||
// A herd of BSDs. Have to detect MidnightBSD before FreeBSD, and MirOS & Bitrig before OpenBSD
|
// A herd of BSDs. Have to detect MidnightBSD before FreeBSD, and MirOS & Bitrig before OpenBSD
|
||||||
// because they also define symbols for their ancestor BSDs.
|
// because they also define symbols for their ancestor BSDs.
|
||||||
#elif defined(__DragonFly__)
|
# elif defined(__DragonFly__)
|
||||||
#define OS OS_DRAGONFLYBSD
|
# define OS OS_DRAGONFLYBSD
|
||||||
#define IS_DRAGONFLYBSD 1
|
# define IS_DRAGONFLYBSD 1
|
||||||
|
|
||||||
#elif defined(__MidnightBSD__)
|
# elif defined(__MidnightBSD__)
|
||||||
#define OS OS_MIDNIGHTBSD
|
# define OS OS_MIDNIGHTBSD
|
||||||
#define IS_MIDNIGHTBSD 1
|
# define IS_MIDNIGHTBSD 1
|
||||||
|
|
||||||
#elif defined(__FreeBSD__)
|
# elif defined(__FreeBSD__)
|
||||||
#define OS OS_FREEBSD
|
# define OS OS_FREEBSD
|
||||||
#define IS_FREEBSD 1
|
# define IS_FREEBSD 1
|
||||||
|
|
||||||
#elif defined(__NetBSD__)
|
# elif defined(__NetBSD__)
|
||||||
#define OS OS_NETBSD
|
# define OS OS_NETBSD
|
||||||
#define IS_NETBSD 1
|
# define IS_NETBSD 1
|
||||||
|
|
||||||
#elif defined(__MirBSD__)
|
# elif defined(__MirBSD__)
|
||||||
#define OS OS_MIRBSD
|
# define OS OS_MIRBSD
|
||||||
#define IS_MIRBSD 1
|
# define IS_MIRBSD 1
|
||||||
|
|
||||||
#elif defined(__Bitrig__)
|
# elif defined(__Bitrig__)
|
||||||
#define OS OS_BITRIG
|
# define OS OS_BITRIG
|
||||||
#define IS_BITRIG 1
|
# define IS_BITRIG 1
|
||||||
|
|
||||||
#elif defined(TW_LibertyBSD)
|
# elif defined(TW_LibertyBSD)
|
||||||
#define OS OS_LIBERTYBSD
|
# define OS OS_LIBERTYBSD
|
||||||
#define IS_LIBERTYBSD 1
|
# define IS_LIBERTYBSD 1
|
||||||
|
|
||||||
#elif defined(__OpenBSD__)
|
# elif defined(__OpenBSD__)
|
||||||
#define OS OS_OPENBSD
|
# define OS OS_OPENBSD
|
||||||
#define IS_OPENBSD 1
|
# define IS_OPENBSD 1
|
||||||
|
|
||||||
#elif defined(__APPLE__)
|
# elif defined(__APPLE__)
|
||||||
#define OS OS_DARWIN
|
# define OS OS_DARWIN
|
||||||
#define IS_DARWIN 1
|
# define IS_DARWIN 1
|
||||||
|
|
||||||
|
|
||||||
#elif defined(__sun)
|
# elif defined(__sun)
|
||||||
#define OS OS_SOLARIS
|
# define OS OS_SOLARIS
|
||||||
#define IS_SOLARIS 1
|
# define IS_SOLARIS 1
|
||||||
|
|
||||||
#elif defined(_AIX)
|
|
||||||
#define OS OS_AIX
|
|
||||||
#define IS_AIX 1
|
|
||||||
|
|
||||||
#elif defined (__hpux)
|
|
||||||
#define OS OS_HPUX
|
|
||||||
#define IS_HPUX 1
|
|
||||||
|
|
||||||
#elif defined(__sgi)
|
|
||||||
#define OS OS_IRIX
|
|
||||||
#define IS_IRIX 1
|
|
||||||
|
|
||||||
#elif defined(TRU64) || defined(__OSF1__)
|
|
||||||
#define OS OS_OSF1
|
|
||||||
#define IS_OSF1 1
|
|
||||||
|
|
||||||
|
|
||||||
#elif defined(__minix__)
|
# elif defined(_AIX)
|
||||||
#define OS OS_MINIX
|
# define OS OS_AIX
|
||||||
#define IS_MINIX 1
|
# define IS_AIX 1
|
||||||
|
|
||||||
#elif defined(__gnu_hurd__)
|
# elif defined(__hpux)
|
||||||
#define OS OS_HURD
|
# define OS OS_HPUX
|
||||||
#define IS_HURD 1
|
# define IS_HPUX 1
|
||||||
|
|
||||||
#elif defined(__HAIKU__)
|
# elif defined(__sgi)
|
||||||
#define OS OS_HAIKU
|
# define OS OS_IRIX
|
||||||
#define IS_HAIKU 1
|
# define IS_IRIX 1
|
||||||
|
|
||||||
#elif defined(__SYLLABLE__)
|
# elif defined(TRU64) || defined(__OSF1__)
|
||||||
#define OS OS_SYLLABLE
|
# define OS OS_OSF1
|
||||||
#define IS_SYLLABLE 1
|
# define IS_OSF1 1
|
||||||
|
|
||||||
#elif defined(SKYOS)
|
|
||||||
#define OS OS_SKYOS
|
|
||||||
#define IS_SKYOS 1
|
|
||||||
|
|
||||||
#elif defined(_SORTIX_SOURCE)
|
|
||||||
#define OS OS_SORTIX
|
|
||||||
#define IS_SORTIX 1
|
|
||||||
|
|
||||||
#elif defined(__MINT__)
|
|
||||||
#define OS OS_MINT
|
|
||||||
#define IS_MINT 1
|
|
||||||
|
|
||||||
#elif defined(__AROS__)
|
|
||||||
#define OS OS_AROS
|
|
||||||
#define IS_AROS 1
|
|
||||||
|
|
||||||
#elif defined(__rtems__)
|
|
||||||
#define OS OS_RTEMS
|
|
||||||
#define IS_RTEMS 1
|
|
||||||
|
|
||||||
#elif defined(__riscos__)
|
|
||||||
#define OS OS_RISCOS
|
|
||||||
#define IS_RISCOS 1
|
|
||||||
|
|
||||||
#elif defined(__redox__)
|
# elif defined(__minix__)
|
||||||
#define OS OS_REDOX
|
# define OS OS_MINIX
|
||||||
#define IS_REDOX 1
|
# define IS_MINIX 1
|
||||||
|
|
||||||
#elif defined(__QNX__)
|
# elif defined(__gnu_hurd__)
|
||||||
#define OS OS_QNX
|
# define OS OS_HURD
|
||||||
#define IS_QNX 1
|
# define IS_HURD 1
|
||||||
|
|
||||||
|
# elif defined(__HAIKU__)
|
||||||
|
# define OS OS_HAIKU
|
||||||
|
# define IS_HAIKU 1
|
||||||
|
|
||||||
|
# elif defined(__SYLLABLE__)
|
||||||
|
# define OS OS_SYLLABLE
|
||||||
|
# define IS_SYLLABLE 1
|
||||||
|
|
||||||
|
# elif defined(SKYOS)
|
||||||
|
# define OS OS_SKYOS
|
||||||
|
# define IS_SKYOS 1
|
||||||
|
|
||||||
|
# elif defined(_SORTIX_SOURCE)
|
||||||
|
# define OS OS_SORTIX
|
||||||
|
# define IS_SORTIX 1
|
||||||
|
|
||||||
|
# elif defined(__MINT__)
|
||||||
|
# define OS OS_MINT
|
||||||
|
# define IS_MINT 1
|
||||||
|
|
||||||
|
# elif defined(__AROS__)
|
||||||
|
# define OS OS_AROS
|
||||||
|
# define IS_AROS 1
|
||||||
|
|
||||||
|
# elif defined(__rtems__)
|
||||||
|
# define OS OS_RTEMS
|
||||||
|
# define IS_RTEMS 1
|
||||||
|
|
||||||
|
# elif defined(__riscos__)
|
||||||
|
# define OS OS_RISCOS
|
||||||
|
# define IS_RISCOS 1
|
||||||
|
|
||||||
|
# elif defined(__redox__)
|
||||||
|
# define OS OS_REDOX
|
||||||
|
# define IS_REDOX 1
|
||||||
|
|
||||||
|
# elif defined(__QNX__)
|
||||||
|
# define OS OS_QNX
|
||||||
|
# define IS_QNX 1
|
||||||
|
|
||||||
|
# endif
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* XXX: COMP may now not resolve, because autoconf may
|
/* XXX: COMP may now not resolve, because autoconf may
|
||||||
* detect GCC. This is done in the hopes that all
|
* detect GCC. This is done in the hopes that all
|
||||||
|
@ -262,9 +261,9 @@
|
||||||
*
|
*
|
||||||
* PH - 20010311
|
* PH - 20010311
|
||||||
*/
|
*/
|
||||||
#if !defined(COMP) && !defined(HAVE_GCC)
|
# if !defined(COMP) && !defined(HAVE_GCC)
|
||||||
#error COMP definition did not resolve. Check "platform.h".
|
# error COMP definition did not resolve. Check "platform.h".
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
// Platform Macros (a.k.a. "IS_" macros)
|
// Platform Macros (a.k.a. "IS_" macros)
|
||||||
|
@ -273,7 +272,7 @@
|
||||||
// these macros rather than comparing PLATFORM to the unique IDs by hand.
|
// these macros rather than comparing PLATFORM to the unique IDs by hand.
|
||||||
//
|
//
|
||||||
// NB: Programmers are STRONGLY ENCOURAGED not to use the OS detection macros
|
// NB: Programmers are STRONGLY ENCOURAGED not to use the OS detection macros
|
||||||
// or compiler detection marcros directly. Instead they should create
|
// or compiler detection marcros directly. Instead they should create
|
||||||
// macros specific to the task at hand. For example Win32 and Solaris support
|
// macros specific to the task at hand. For example Win32 and Solaris support
|
||||||
// extended permissions for their files. Rather than check IS_WIN32 || IS_SOLARIS,
|
// extended permissions for their files. Rather than check IS_WIN32 || IS_SOLARIS,
|
||||||
// create a new macro called "HAS_EXTENDED_FILE_PERMISSIONS" and use that.
|
// create a new macro called "HAS_EXTENDED_FILE_PERMISSIONS" and use that.
|
||||||
|
@ -289,90 +288,95 @@
|
||||||
// int network_order = swap(machine_order);
|
// int network_order = swap(machine_order);
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
||||||
|
|
||||||
// complier detection
|
// complier detection
|
||||||
#define IS_KAI (COMP == COMP_KAI_GCC || COMP == COMP_KAI_SUNPRO || COMP == COMP_KAI_GLIBC || COMP == COMP_KAI_VISUALAGE || COMP == COMP_KAI_HPANSIC || COMP == COMP_KAI_IRIX || COMP == COMP_KAI_OSF1ALPHA)
|
# define IS_KAI \
|
||||||
#define IS_MSVC (COMP == COMP_MSVC)
|
(COMP == COMP_KAI_GCC || COMP == COMP_KAI_SUNPRO || COMP == COMP_KAI_GLIBC || COMP == COMP_KAI_VISUALAGE || \
|
||||||
#define IS_SUNPRO (COMP == COMP_SUNPRO)
|
COMP == COMP_KAI_HPANSIC || COMP == COMP_KAI_IRIX || COMP == COMP_KAI_OSF1ALPHA)
|
||||||
|
# define IS_MSVC (COMP == COMP_MSVC)
|
||||||
|
# define IS_SUNPRO (COMP == COMP_SUNPRO)
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
||||||
// Unicode
|
// Unicode
|
||||||
#define SUPPORTS_UNICODE IS_WIN32 // The OS supports Unicode
|
# define SUPPORTS_UNICODE IS_WIN32 // The OS supports Unicode
|
||||||
|
|
||||||
// KAI 3.4 uses a much improved stl
|
// KAI 3.4 uses a much improved stl
|
||||||
#define IS_KAI_3_4 (IS_KAI && (COMP == COMP_KAI_IRIX || COMP == COMP_KAI_OSF1ALPHA || COMP == COMP_KAI_GLIBC))
|
# define IS_KAI_3_4 (IS_KAI && (COMP == COMP_KAI_IRIX || COMP == COMP_KAI_OSF1ALPHA || COMP == COMP_KAI_GLIBC))
|
||||||
|
|
||||||
// Used in twlocale
|
// Used in twlocale
|
||||||
#define USE_STD_CPP_LOCALE_WORKAROUND (IS_SUNPRO || (IS_KAI && !IS_KAI_3_4)) // TODO:BAM -- name this something more general.
|
# define USE_STD_CPP_LOCALE_WORKAROUND \
|
||||||
#define USE_CLIB_LOCALE IS_KAI || HAVE_GCC
|
(IS_SUNPRO || (IS_KAI && !IS_KAI_3_4)) // TODO:BAM -- name this something more general.
|
||||||
#define USES_CLIB_DATE_FUNCTION ( USE_CLIB_LOCALE || IS_SUNPRO || IS_MSVC ) // if we use clib, can't use C++ time_put, and SUNPRO and MSVC add characters
|
# define USE_CLIB_LOCALE IS_KAI || HAVE_GCC
|
||||||
|
# define USES_CLIB_DATE_FUNCTION \
|
||||||
|
(USE_CLIB_LOCALE || IS_SUNPRO || \
|
||||||
|
IS_MSVC) // if we use clib, can't use C++ time_put, and SUNPRO and MSVC add characters
|
||||||
//#define USE_CLIB_LOCALE (IS_ALPHA || IS_IRIX || (IS_KAI && !IS_KAI_3_4))
|
//#define USE_CLIB_LOCALE (IS_ALPHA || IS_IRIX || (IS_KAI && !IS_KAI_3_4))
|
||||||
|
|
||||||
// Threading API
|
// Threading API
|
||||||
// TODO:mdb -- this is not complete or rigorous on the unix side!!!
|
// TODO:mdb -- this is not complete or rigorous on the unix side!!!
|
||||||
#define SUPPORTS_WIN32_THREADS IS_WIN32
|
# define SUPPORTS_WIN32_THREADS IS_WIN32
|
||||||
#define SUPPORTS_POSIX_THREADS (!SUPPORTS_WIN32_THREADS)
|
# define SUPPORTS_POSIX_THREADS (!SUPPORTS_WIN32_THREADS)
|
||||||
|
|
||||||
// Miscellaneous
|
// Miscellaneous
|
||||||
#define WCHAR_IS_16_BITS IS_WIN32
|
# define WCHAR_IS_16_BITS IS_WIN32
|
||||||
#define WCHAR_IS_32_BITS IS_UNIX
|
# define WCHAR_IS_32_BITS IS_UNIX
|
||||||
#define WCHAR_REP_IS_UCS2 IS_WIN32
|
# define WCHAR_REP_IS_UCS2 IS_WIN32
|
||||||
#define USES_MPOPEN IS_UNIX
|
// msystem+mpopen fail on Syllable, so use the libc equivalents until we figure out why.
|
||||||
#define SUPPORTS_WCHART IS_WIN32 // TODO: Remove after getting new ver of KAI
|
// TODO: Figure out why.
|
||||||
#define USES_GLIBC ((COMP == COMP_KAI_GLIBC) || HAVE_GCC)
|
# define USES_MPOPEN (IS_UNIX && !IS_SYLLABLE)
|
||||||
#define SUPPORTS_MEMBER_TEMPLATES ( ! IS_SUNPRO )
|
# define USES_MSYSTEM (IS_UNIX && !IS_SYLLABLE)
|
||||||
#define SUPPORTS_EXPLICIT_TEMPLATE_FUNC_INST ( ! IS_SUNPRO )
|
# define SUPPORTS_WCHART IS_WIN32 // TODO: Remove after getting new ver of KAI
|
||||||
|
# define USES_GLIBC ((COMP == COMP_KAI_GLIBC) || HAVE_GCC)
|
||||||
|
# define SUPPORTS_MEMBER_TEMPLATES (!IS_SUNPRO)
|
||||||
|
# define SUPPORTS_EXPLICIT_TEMPLATE_FUNC_INST (!IS_SUNPRO)
|
||||||
|
|
||||||
#define SUPPORTS_POSIX_SIGNALS (!IS_DOS_DJGPP)
|
# define SUPPORTS_POSIX_SIGNALS (!IS_DOS_DJGPP)
|
||||||
#define SUPPORTS_NETWORKING (!IS_SORTIX && !IS_DOS_DJGPP && !IS_REDOX)
|
# define SUPPORTS_NETWORKING (!IS_SORTIX && !IS_DOS_DJGPP && !IS_REDOX)
|
||||||
#define SUPPORTS_SYSLOG (HAVE_SYSLOG_H && !IS_SKYOS && !IS_RISCOS)
|
# define SUPPORTS_SYSLOG (HAVE_SYSLOG_H && !IS_SKYOS && !IS_RISCOS)
|
||||||
#define NEEDS_SWAB_IMPL (IS_CYGWIN || IS_SYLLABLE || IS_ANDROID || IS_SORTIX)
|
# define NEEDS_SWAB_IMPL (IS_CYGWIN || IS_SYLLABLE || IS_ANDROID || IS_SORTIX)
|
||||||
#define USES_MBLEN (!IS_ANDROID && !IS_AROS)
|
# define USES_MBLEN (!IS_ANDROID && !IS_AROS)
|
||||||
#define USES_DEVICE_PATH (IS_AROS || IS_DOS_DJGPP || IS_RISCOS || IS_REDOX)
|
# define USES_DEVICE_PATH (IS_AROS || IS_DOS_DJGPP || IS_RISCOS || IS_REDOX)
|
||||||
#define ICONV_CONST_SOURCE (IS_MINIX)
|
# define ICONV_CONST_SOURCE (IS_MINIX)
|
||||||
#define SUPPORTS_DIRECT_IO (IS_LINUX)
|
# define SUPPORTS_DIRECT_IO (IS_LINUX)
|
||||||
// Linux is the only platform where direct i/o hashing has been tested & works properly so far.
|
// Linux is the only platform where direct i/o hashing has been tested & works properly so far.
|
||||||
|
|
||||||
#define SUPPORTS_TERMIOS (!IS_RTEMS && !IS_REDOX)
|
# define SUPPORTS_TERMIOS (!IS_RTEMS && !IS_REDOX)
|
||||||
// RTEMS errors are probably just a buildsys issue & this will change or go away.
|
// RTEMS errors are probably just a buildsys issue & this will change or go away.
|
||||||
// Redox will probably implement this in the future.
|
// Redox will probably implement this in the future.
|
||||||
|
|
||||||
#define CAN_UNLINK_WHILE_OPEN (!IS_AROS && !IS_RISCOS && !IS_REDOX && !IS_DOS_DJGPP)
|
# define CAN_UNLINK_WHILE_OPEN (!IS_AROS && !IS_RISCOS && !IS_REDOX && !IS_DOS_DJGPP)
|
||||||
|
|
||||||
#define SUPPORTS_DOUBLE_SLASH_PATH (IS_CYGWIN)
|
# define SUPPORTS_DOUBLE_SLASH_PATH (IS_CYGWIN)
|
||||||
// POSIX standard says paths beginning with 2 slashes are "implementation defined"
|
// POSIX standard says paths beginning with 2 slashes are "implementation defined"
|
||||||
// (see http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap04.html#tag_04_11 )
|
// (see http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap04.html#tag_04_11 )
|
||||||
// The only platform OST works on (afaik) that actually defines a double-slash behavior is Cygwin
|
// The only platform OST works on (afaik) that actually defines a double-slash behavior is Cygwin
|
||||||
// which uses this syntax for UNC paths. So we'll allow leading double slashes there, but
|
// which uses this syntax for UNC paths. So we'll allow leading double slashes there, but
|
||||||
// continue removing them on all other platforms
|
// continue removing them on all other platforms
|
||||||
|
|
||||||
#define USE_DEV_URANDOM (HAVE_DEV_URANDOM && ENABLE_DEV_URANDOM)
|
# define USE_DEV_URANDOM (HAVE_DEV_URANDOM && ENABLE_DEV_URANDOM)
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
// Miscellaneous
|
// Miscellaneous
|
||||||
//
|
//
|
||||||
// Put all items that are not an "IS_" macro here.
|
// Put all items that are not an "IS_" macro here.
|
||||||
|
|
||||||
#if IS_BYTE_ALIGNED
|
# if IS_BYTE_ALIGNED
|
||||||
#define BYTE_ALIGN 8
|
# define BYTE_ALIGN 8
|
||||||
#else
|
# else
|
||||||
#error Unknown Byte alignment
|
# error Unknown Byte alignment
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
// A scalar that matches the sizeof a pointer
|
// A scalar that matches the sizeof a pointer
|
||||||
typedef unsigned long ptr_size_type; // true for all of our current platforms
|
typedef unsigned long ptr_size_type; // true for all of our current platforms
|
||||||
// TODO: I would like to use a XXXX_t like name
|
// TODO: I would like to use a XXXX_t like name
|
||||||
|
|
||||||
// Check integer representation
|
// Check integer representation
|
||||||
#if !(USES_2S_COMPLEMENT)
|
# if !(USES_2S_COMPLEMENT)
|
||||||
#error "Tripwire will only work on a 2's complement CPU. Check \"platform.h\"."
|
# error "Tripwire will only work on a 2's complement CPU. Check \"platform.h\"."
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif // __PLATFORM_H
|
#endif // __PLATFORM_H
|
||||||
|
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
//
|
//
|
||||||
// The developer of the original code and/or files is Tripwire, Inc.
|
// The developer of the original code and/or files is Tripwire, Inc.
|
||||||
// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire,
|
// Portions created by Tripwire, Inc. are copyright (C) 2000-2018 Tripwire,
|
||||||
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
||||||
// reserved.
|
// reserved.
|
||||||
//
|
//
|
||||||
// This program is free software. The contents of this file are subject
|
// 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
|
// 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
|
// Free Software Foundation; either version 2 of the License, or (at your
|
||||||
// option) any later version. You may redistribute it and/or modify it
|
// option) any later version. You may redistribute it and/or modify it
|
||||||
// only in compliance with the GNU General Public License.
|
// only in compliance with the GNU General Public License.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful.
|
// This program is distributed in the hope that it will be useful.
|
||||||
// However, this program is distributed AS-IS WITHOUT ANY
|
// However, this program is distributed AS-IS WITHOUT ANY
|
||||||
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
// FOR A PARTICULAR PURPOSE. Please see the GNU General Public License
|
||||||
// for more details.
|
// for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
// USA.
|
// USA.
|
||||||
//
|
//
|
||||||
// Nothing in the GNU General Public License or any other license to use
|
// 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,
|
// the code or files shall permit you to use Tripwire's trademarks,
|
||||||
// service marks, or other intellectual property without Tripwire's
|
// service marks, or other intellectual property without Tripwire's
|
||||||
// prior written consent.
|
// prior written consent.
|
||||||
//
|
//
|
||||||
// If you have any questions, please contact Tripwire, Inc. at either
|
// If you have any questions, please contact Tripwire, Inc. at either
|
||||||
// info@tripwire.org or www.tripwire.org.
|
// info@tripwire.org or www.tripwire.org.
|
||||||
//
|
//
|
||||||
|
@ -42,14 +42,14 @@
|
||||||
#include "errorutil.h"
|
#include "errorutil.h"
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
int cRefCountObj::objectCounter = 0;
|
int cRefCountObj::objectCounter = 0;
|
||||||
int cRefCountObj::referenceCounter = 0;
|
int cRefCountObj::referenceCounter = 0;
|
||||||
|
|
||||||
#include <typeinfo>
|
#include <typeinfo>
|
||||||
// ok, this is getting serious!
|
// ok, this is getting serious!
|
||||||
#include <set>
|
#include <set>
|
||||||
typedef std::set<void*> RefSet; // collection of addresses of all reference counted objects
|
typedef std::set<void*> RefSet; // collection of addresses of all reference counted objects
|
||||||
RefSet* gpRefCountObj_Objects = 0;
|
RefSet* gpRefCountObj_Objects = 0;
|
||||||
|
|
||||||
// a way to see what hasn't been accounted for....
|
// a way to see what hasn't been accounted for....
|
||||||
struct cRefCountObj_Debug
|
struct cRefCountObj_Debug
|
||||||
|
@ -57,10 +57,10 @@ struct cRefCountObj_Debug
|
||||||
~cRefCountObj_Debug()
|
~cRefCountObj_Debug()
|
||||||
{
|
{
|
||||||
RefSet::iterator i;
|
RefSet::iterator i;
|
||||||
cDebug d("cRefCountObj_Debug");
|
cDebug d("cRefCountObj_Debug");
|
||||||
if(gpRefCountObj_Objects)
|
if (gpRefCountObj_Objects)
|
||||||
{
|
{
|
||||||
for(i = gpRefCountObj_Objects->begin(); i != gpRefCountObj_Objects->end(); i++)
|
for (i = gpRefCountObj_Objects->begin(); i != gpRefCountObj_Objects->end(); i++)
|
||||||
{
|
{
|
||||||
d.TraceNever("Refrence Counted Object %p still exists\n", *i);
|
d.TraceNever("Refrence Counted Object %p still exists\n", *i);
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ cRefCountObj::cRefCountObj()
|
||||||
{
|
{
|
||||||
mRefCount = 1;
|
mRefCount = 1;
|
||||||
|
|
||||||
//std::cout << "Allocated RefObj(" << std::hex << (int)this << ")\n";
|
//std::cout << "Allocated RefObj(" << std::hex << (int)this << ")\n";
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
++objectCounter;
|
++objectCounter;
|
||||||
|
@ -83,7 +83,7 @@ cRefCountObj::cRefCountObj()
|
||||||
cDebug d("cRefCountObj::cRefCountObj");
|
cDebug d("cRefCountObj::cRefCountObj");
|
||||||
d.TraceNever("Object Created[%p] %s\n", this, typeid(*this).name());
|
d.TraceNever("Object Created[%p] %s\n", this, typeid(*this).name());
|
||||||
|
|
||||||
if(! gpRefCountObj_Objects)
|
if (!gpRefCountObj_Objects)
|
||||||
gpRefCountObj_Objects = new RefSet;
|
gpRefCountObj_Objects = new RefSet;
|
||||||
gpRefCountObj_Objects->insert(this);
|
gpRefCountObj_Objects->insert(this);
|
||||||
#endif
|
#endif
|
||||||
|
@ -93,22 +93,22 @@ cRefCountObj::~cRefCountObj()
|
||||||
{
|
{
|
||||||
ASSERT(mRefCount == 0);
|
ASSERT(mRefCount == 0);
|
||||||
|
|
||||||
//std::cout << "Deleted RefObj(" << std::hex << (int)this << ")\n";
|
//std::cout << "Deleted RefObj(" << std::hex << (int)this << ")\n";
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
--objectCounter;
|
--objectCounter;
|
||||||
cDebug d("cRefCountObj::~cRefCountObj");
|
cDebug d("cRefCountObj::~cRefCountObj");
|
||||||
d.TraceNever("Object Destroyed[%p] %s Objects Left = %d\n", this, typeid(*this).name(), objectCounter);
|
d.TraceNever("Object Destroyed[%p] %s Objects Left = %d\n", this, typeid(*this).name(), objectCounter);
|
||||||
if(objectCounter == 0)
|
if (objectCounter == 0)
|
||||||
{
|
{
|
||||||
d.TraceDebug("****** All Reference Counted Objects Destroyed! ******\n") ;
|
d.TraceDebug("****** All Reference Counted Objects Destroyed! ******\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT(gpRefCountObj_Objects);
|
ASSERT(gpRefCountObj_Objects);
|
||||||
RefSet::const_iterator i = gpRefCountObj_Objects->find(this);
|
RefSet::const_iterator i = gpRefCountObj_Objects->find(this);
|
||||||
ASSERT(i != gpRefCountObj_Objects->end());
|
ASSERT(i != gpRefCountObj_Objects->end());
|
||||||
gpRefCountObj_Objects->erase(this);
|
gpRefCountObj_Objects->erase(this);
|
||||||
if(gpRefCountObj_Objects->size() == 0)
|
if (gpRefCountObj_Objects->size() == 0)
|
||||||
{
|
{
|
||||||
delete gpRefCountObj_Objects;
|
delete gpRefCountObj_Objects;
|
||||||
gpRefCountObj_Objects = 0;
|
gpRefCountObj_Objects = 0;
|
||||||
|
@ -128,9 +128,9 @@ void cRefCountObj::AddRef() const
|
||||||
|
|
||||||
++mRefCount;
|
++mRefCount;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
++referenceCounter;
|
++referenceCounter;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void cRefCountObj::Release() const
|
void cRefCountObj::Release() const
|
||||||
|
@ -140,13 +140,12 @@ void cRefCountObj::Release() const
|
||||||
Delete();
|
Delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
--referenceCounter;
|
--referenceCounter;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void cRefCountObj::Delete() const
|
void cRefCountObj::Delete() const
|
||||||
{
|
{
|
||||||
delete this;
|
delete this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue