Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • opentrafficshaper/opentrafficshaper
  • eezysol/opentrafficshaper
  • sudesh/opentrafficshaper
  • Yuriy/opentrafficshaper
  • nkukard/opentrafficshaper
  • fcardoso/opentrafficshaper
6 results
Show changes
Commits on Source (104)
Showing
with 6121 additions and 57 deletions
[submodule "opentrafficshaper/plugins/webserver/pages/static/awit-flot-toolkit"]
path = opentrafficshaper/plugins/webserver/pages/static/awit-flot-toolkit
url = https://gitlab.devlabs.linuxassist.net/awit-frameworks/awit-flot-toolkit.git
[submodule "awitpt"]
path = awitpt
url = https://gitlab.devlabs.linuxassist.net/awit-frameworks/awit-perl-toolkit.git
Installing OpenTrafficShaper:
*
* Requirements for OpenTrafficShaper
*
- POE
Debian: libpoe-perl
- Config::IniFiles
Debian: libconfig-inifiles-perl
- DateTime
Debian: libdatetime-perl
- Digest::SHA
Debian: libdigest-sha-perl
- JSON
Debian: libjson-perl
- DBD::MySQL
Debian: libdbd-mysql-perl
- Perl 5.6+
*
* Pull in dependency code
*
./update-git-modules
*
* Next steps
*
1. Edit the config file
2. You can now run opentrafficshaper by using ./opentrafficshaperd --debug --config=opentrafficshaper.conf --fg
3. Browse to it using http://SERVER:8088/
For more configuration information see this link:
http://wiki.opentrafficshaper.org/documentation
# Introduction
# Requirements
## POE
Debian-based: libpoe-perl
Arch-based: perl-poe
## Config::IniFiles
Debian-based: libconfig-inifiles-perl
Arch-based: perl-config-inifiles
## DateTime
Debian-based: libdatetime-perl
Arch-based: perl-datetime
## Digest::SHA
Debian-based: libdigest-sha-perl
Arch-based: perl-digest-sha
## JSON
Debian-based: libjson-perl
Arch-based: perl-json
## DBD::MySQL
Debian-based: libdbd-mysql-perl
Arch-based: perl-dbd-mysql
## HTML::Entities module
Debian-based: libhtml-parser-perl
Arch-based: perl-html-parser
## NetAddr::IP
Debian-based: libnetaddr-ip-perl
Arch-based: perl-netaddr-ip
## URI
Debian: liburi-perl
Arch-based: perl-uri
# Installing OpenTrafficShaper
```
git clone https://gitlab.devlabs.linuxassist.net/opentrafficshaper/opentrafficshaper.git
```
# System Configuration
## Shorewall
If you are using Shorewall, you will need to make a few config changes in '/etc/shorewall/config'.
Change config options...
```
CLEAR_TC=No
TC_ENABLED=No
PROVIDER_BITS=0
```
## Module Options
Add this to /etc/modprobe.d/opentrafficshaper-htb.conf...
```
options sch_htb htb_rate_est=1
```
Rebuild your initramfs (on Arch you can use the below command)...
```
mkinitcpio -P
```
This step requires a reboot.
## Temporary Directories
Create directories...
```
mkdir /var/lib/opentrafficshaper
```
# Statistics Setup
Install MariaDB and initialize with...
```
mysql -u ots -p otsdb < database/stats.sql
```
# Security
At present there is no security provided in terms of the management port 8088. It is suggested using something like a reverse proxy
to provide username/password access or restricting access to a fixed IP.
An example of the Nginx http section can be found in the contrib/ directory.
# Next steps
1. Edit the config file
2. You can now run opentrafficshaper by using ./opentrafficshaperd --debug --config=opentrafficshaper.conf --fg
3. Browse to it using http://SERVER:8080/
For more configuration information see this link:
http://wiki.opentrafficshaper.org/documentation
......@@ -17,3 +17,5 @@
- destination IP address shaping
- accounts for using login/pass to access to service
awitpt @ 932340ef
Subproject commit 932340ef7336dc40bdd3d35d2023bde1310e9066
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.
bin/convert-tsql
doxygen/Doxyfile
lib/awitpt/cache.pm
lib/awitpt/db/dbilayer.pm
lib/awitpt/db/dblayer.pm
lib/awitpt/netip.pm
lib/awitpt/util.pm
lib/awitpt/version.pm
lib/SOAP/Transport/HTTPng.pm
LICENSE
Makefile.PL
MANIFEST This list of files
t/isnumber.t
# Makefile
# Copyright (C) 2014, AllWorldIT
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
use strict;
use warnings;
use ExtUtils::MakeMaker;
WriteMakefile(
NAME => 'awitpt',
VERSION_FROM => "lib/awitpt/version.pm",
EXE_FILES => [qw( bin/convert-tsql )],
MAN3PODS => { },
);
# vim: ts=4
#!/bin/bash
# Database translation/creation script
# Copyright (C) 2009-2014, AllWorldIT
# Copyright (C) 2008, LinuxRulz
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
database="$1"
file="$2"
prefix="$3"
# Display usage info
display_usage() {
echo "Usage: $0 <database type> <file> [prefix]"
echo
echo "Valid database types:"
echo " mysql - For MySQL v5 (v5.5)"
echo " mysql55 - For MySQL v5.5"
echo " mysql4 - For MySQL v4"
echo " pgsql - For PostgreSQL"
echo " sqlite - For SQLite v3"
echo
exit
}
# Check we have our params
if [ -z "$database" -o -z "$file" ]
then
display_usage
fi
# Check file exists
if [ ! -f "$file" ]
then
echo "ERROR: Cannot open file '$file'"
exit 1
fi
# Check what we converting for
case "$database" in
"mysql"|"mysql55")
sed \
-e "s/@PREFIX@/$prefix/g" \
-e 's/@PRELOAD@/SET FOREIGN_KEY_CHECKS=0;/' \
-e 's/@POSTLOAD@/SET FOREIGN_KEY_CHECKS=1;/' \
-e 's/@CREATE_TABLE_SUFFIX@/ENGINE=InnoDB CHARACTER SET latin1 COLLATE latin1_bin/' \
-e 's/@SERIAL_TYPE@/SERIAL/' \
-e 's/@BIG_INTEGER_UNSIGNED@/BIGINT UNSIGNED/' \
-e 's/@INT_UNSIGNED@/INT UNSIGNED/' \
-e 's/@TRACK_KEY_LEN@/512/' \
-e 's/@SERIAL_REF_TYPE@/BIGINT UNSIGNED/' < "$file"
;;
"mysql4")
sed \
-e "s/@PREFIX@/$prefix/g" \
-e 's/@PRELOAD@/SET FOREIGN_KEY_CHECKS=0;/' \
-e 's/@POSTLOAD@/SET FOREIGN_KEY_CHECKS=1;/' \
-e 's/@CREATE_TABLE_SUFFIX@/TYPE=InnoDB CHARACTER SET latin1 COLLATE latin1_bin/' \
-e 's/@SERIAL_TYPE@/SERIAL/' \
-e 's/@BIG_INTEGER_UNSIGNED@/BIGINT UNSIGNED/' \
-e 's/@TRACK_KEY_LEN@/255/' \
-e 's/@SERIAL_REF_TYPE@/BIGINT UNSIGNED/' < "$file"
;;
"pgsql")
sed \
-e "s/@PREFIX@/$prefix/g" \
-e 's/@PRELOAD@/SET CONSTRAINTS ALL DEFERRED;/' \
-e 's/@POSTLOAD@//' \
-e 's/@CREATE_TABLE_SUFFIX@//' \
-e 's/@SERIAL_TYPE@/SERIAL PRIMARY KEY/' \
-e 's/@BIG_INTEGER_UNSIGNED@/INT8/' \
-e 's/@TRACK_KEY_LEN@/512/' \
-e 's/@SERIAL_REF_TYPE@/INT8/' < "$file"
;;
"sqlite")
sed \
-e "s/@PREFIX@/$prefix/g" \
-e 's/@PRELOAD@//' \
-e 's/@POSTLOAD@//' \
-e 's/@CREATE_TABLE_SUFFIX@//' \
-e 's/@SERIAL_TYPE@/INTEGER PRIMARY KEY AUTOINCREMENT/' \
-e 's/@BIG_INTEGER_UNSIGNED@/UNSIGNED BIG INT/' \
-e 's/@TRACK_KEY_LEN@/512/' \
-e 's/@SERIAL_REF_TYPE@/INT8/' < "$file"
;;
*)
echo "ERROR: Invalid database type '$database'"
exit 1
;;
esac
# vim: ts=4
# Doxyfile 1.5.7.1
# This file describes the settings to be used by the documentation system
# doxygen (www.doxygen.org) for a project
#
# All text after a hash (#) is considered a comment and will be ignored
# The format is:
# TAG = value [value, ...]
# For lists items can also be appended using:
# TAG += value [value, ...]
# Values that contain spaces should be placed between quotes (" ")
#---------------------------------------------------------------------------
# Project related configuration options
#---------------------------------------------------------------------------
# This tag specifies the encoding used for all characters in the config file
# that follow. The default is UTF-8 which is also the encoding used for all
# text before the first occurrence of this tag. Doxygen uses libiconv (or the
# iconv built into libc) for the transcoding. See
# http://www.gnu.org/software/libiconv for the list of possible encodings.
DOXYFILE_ENCODING = UTF-8
# The PROJECT_NAME tag is a single word (or a sequence of words surrounded
# by quotes) that should identify the project.
PROJECT_NAME = "AWITPT API"
# The PROJECT_NUMBER tag can be used to enter a project or revision number.
# This could be handy for archiving the generated documentation or
# if some version control system is used.
PROJECT_NUMBER = 0.0.0
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
# base path where the generated documentation will be put.
# If a relative path is entered, it will be relative to the location
# where doxygen was started. If left blank the current directory will be used.
OUTPUT_DIRECTORY = docs
# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create
# 4096 sub-directories (in 2 levels) under the output directory of each output
# format and will distribute the generated files over these directories.
# Enabling this option can be useful when feeding doxygen a huge amount of
# source files, where putting all generated files in the same directory would
# otherwise cause performance problems for the file system.
CREATE_SUBDIRS = NO
# The OUTPUT_LANGUAGE tag is used to specify the language in which all
# documentation generated by doxygen is written. Doxygen will use this
# information to generate all constant output in the proper language.
# The default language is English, other supported languages are:
# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional,
# Croatian, Czech, Danish, Dutch, Farsi, Finnish, French, German, Greek,
# Hungarian, Italian, Japanese, Japanese-en (Japanese with English messages),
# Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, Polish,
# Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak, Slovene,
# Spanish, Swedish, and Ukrainian.
OUTPUT_LANGUAGE = English
# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will
# include brief member descriptions after the members that are listed in
# the file and class documentation (similar to JavaDoc).
# Set to NO to disable this.
BRIEF_MEMBER_DESC = YES
# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend
# the brief description of a member or function before the detailed description.
# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
# brief descriptions will be completely suppressed.
REPEAT_BRIEF = YES
# This tag implements a quasi-intelligent brief description abbreviator
# that is used to form the text in various listings. Each string
# in this list, if found as the leading text of the brief description, will be
# stripped from the text and the result after processing the whole list, is
# used as the annotated text. Otherwise, the brief description is used as-is.
# If left blank, the following values are used ("$name" is automatically
# replaced with the name of the entity): "The $name class" "The $name widget"
# "The $name file" "is" "provides" "specifies" "contains"
# "represents" "a" "an" "the"
ABBREVIATE_BRIEF =
# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
# Doxygen will generate a detailed section even if there is only a brief
# description.
ALWAYS_DETAILED_SEC = NO
# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
# inherited members of a class in the documentation of that class as if those
# members were ordinary class members. Constructors, destructors and assignment
# operators of the base classes will not be shown.
INLINE_INHERITED_MEMB = NO
# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full
# path before files name in the file list and in the header files. If set
# to NO the shortest path that makes the file name unique will be used.
FULL_PATH_NAMES = YES
# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag
# can be used to strip a user-defined part of the path. Stripping is
# only done if one of the specified strings matches the left-hand part of
# the path. The tag can be used to show relative paths in the file list.
# If left blank the directory from which doxygen is run is used as the
# path to strip.
STRIP_FROM_PATH =
# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of
# the path mentioned in the documentation of a class, which tells
# the reader which header file to include in order to use a class.
# If left blank only the name of the header file containing the class
# definition is used. Otherwise one should specify the include paths that
# are normally passed to the compiler using the -I flag.
STRIP_FROM_INC_PATH =
# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter
# (but less readable) file names. This can be useful is your file systems
# doesn't support long names like on DOS, Mac, or CD-ROM.
SHORT_NAMES = NO
# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen
# will interpret the first line (until the first dot) of a JavaDoc-style
# comment as the brief description. If set to NO, the JavaDoc
# comments will behave just like regular Qt-style comments
# (thus requiring an explicit @brief command for a brief description.)
JAVADOC_AUTOBRIEF = NO
# If the QT_AUTOBRIEF tag is set to YES then Doxygen will
# interpret the first line (until the first dot) of a Qt-style
# comment as the brief description. If set to NO, the comments
# will behave just like regular Qt-style comments (thus requiring
# an explicit \brief command for a brief description.)
QT_AUTOBRIEF = NO
# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen
# treat a multi-line C++ special comment block (i.e. a block of //! or ///
# comments) as a brief description. This used to be the default behaviour.
# The new default is to treat a multi-line C++ comment block as a detailed
# description. Set this tag to YES if you prefer the old behaviour instead.
MULTILINE_CPP_IS_BRIEF = NO
# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
# member inherits the documentation from any documented member that it
# re-implements.
INHERIT_DOCS = YES
# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce
# a new page for each member. If set to NO, the documentation of a member will
# be part of the file/class/namespace that contains it.
SEPARATE_MEMBER_PAGES = YES
# The TAB_SIZE tag can be used to set the number of spaces in a tab.
# Doxygen uses this value to replace tabs by spaces in code fragments.
TAB_SIZE = 8
# This tag can be used to specify a number of aliases that acts
# as commands in the documentation. An alias has the form "name=value".
# For example adding "sideeffect=\par Side Effects:\n" will allow you to
# put the command \sideeffect (or @sideeffect) in the documentation, which
# will result in a user-defined paragraph with heading "Side Effects:".
# You can put \n's in the value part of an alias to insert newlines.
ALIASES =
# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C
# sources only. Doxygen will then generate output that is more tailored for C.
# For instance, some of the names that are used will be different. The list
# of all members will be omitted, etc.
OPTIMIZE_OUTPUT_FOR_C = NO
# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java
# sources only. Doxygen will then generate output that is more tailored for
# Java. For instance, namespaces will be presented as packages, qualified
# scopes will look different, etc.
OPTIMIZE_OUTPUT_JAVA = NO
# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran
# sources only. Doxygen will then generate output that is more tailored for
# Fortran.
OPTIMIZE_FOR_FORTRAN = NO
# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL
# sources. Doxygen will then generate output that is tailored for
# VHDL.
OPTIMIZE_OUTPUT_VHDL = NO
# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want
# to include (a tag file for) the STL sources as input, then you should
# set this tag to YES in order to let doxygen match functions declarations and
# definitions whose arguments contain STL classes (e.g. func(std::string); v.s.
# func(std::string) {}). This also make the inheritance and collaboration
# diagrams that involve STL classes more complete and accurate.
BUILTIN_STL_SUPPORT = NO
# If you use Microsoft's C++/CLI language, you should set this option to YES to
# enable parsing support.
CPP_CLI_SUPPORT = NO
# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only.
# Doxygen will parse them like normal C++ but will assume all classes use public
# instead of private inheritance when no explicit protection keyword is present.
SIP_SUPPORT = NO
# For Microsoft's IDL there are propget and propput attributes to indicate getter
# and setter methods for a property. Setting this option to YES (the default)
# will make doxygen to replace the get and set methods by a property in the
# documentation. This will only work if the methods are indeed getting or
# setting a simple type. If this is not the case, or you want to show the
# methods anyway, you should set this option to NO.
IDL_PROPERTY_SUPPORT = YES
# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
# tag is set to YES, then doxygen will reuse the documentation of the first
# member in the group (if any) for the other members of the group. By default
# all members of a group must be documented explicitly.
DISTRIBUTE_GROUP_DOC = NO
# Set the SUBGROUPING tag to YES (the default) to allow class member groups of
# the same type (for instance a group of public functions) to be put as a
# subgroup of that type (e.g. under the Public Functions section). Set it to
# NO to prevent subgrouping. Alternatively, this can be done per class using
# the \nosubgrouping command.
SUBGROUPING = YES
# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum
# is documented as struct, union, or enum with the name of the typedef. So
# typedef struct TypeS {} TypeT, will appear in the documentation as a struct
# with name TypeT. When disabled the typedef will appear as a member of a file,
# namespace, or class. And the struct will be named TypeS. This can typically
# be useful for C code in case the coding convention dictates that all compound
# types are typedef'ed and only the typedef is referenced, never the tag name.
TYPEDEF_HIDES_STRUCT = NO
# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to
# determine which symbols to keep in memory and which to flush to disk.
# When the cache is full, less often used symbols will be written to disk.
# For small to medium size projects (<1000 input files) the default value is
# probably good enough. For larger projects a too small cache size can cause
# doxygen to be busy swapping symbols to and from disk most of the time
# causing a significant performance penality.
# If the system has enough physical memory increasing the cache will improve the
# performance by keeping more symbols in memory. Note that the value works on
# a logarithmic scale so increasing the size by one will rougly double the
# memory usage. The cache size is given by this formula:
# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0,
# corresponding to a cache size of 2^16 = 65536 symbols
SYMBOL_CACHE_SIZE = 0
#---------------------------------------------------------------------------
# Build related configuration options
#---------------------------------------------------------------------------
# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
# documentation are documented, even if no documentation was available.
# Private class members and static file members will be hidden unless
# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
EXTRACT_ALL = NO
# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
# will be included in the documentation.
EXTRACT_PRIVATE = NO
# If the EXTRACT_STATIC tag is set to YES all static members of a file
# will be included in the documentation.
EXTRACT_STATIC = NO
# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)
# defined locally in source files will be included in the documentation.
# If set to NO only classes defined in header files are included.
EXTRACT_LOCAL_CLASSES = YES
# This flag is only useful for Objective-C code. When set to YES local
# methods, which are defined in the implementation section but not in
# the interface are included in the documentation.
# If set to NO (the default) only methods in the interface are included.
EXTRACT_LOCAL_METHODS = NO
# If this flag is set to YES, the members of anonymous namespaces will be
# extracted and appear in the documentation as a namespace called
# 'anonymous_namespace{file}', where file will be replaced with the base
# name of the file that contains the anonymous namespace. By default
# anonymous namespace are hidden.
EXTRACT_ANON_NSPACES = NO
# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
# undocumented members of documented classes, files or namespaces.
# If set to NO (the default) these members will be included in the
# various overviews, but no documentation section is generated.
# This option has no effect if EXTRACT_ALL is enabled.
HIDE_UNDOC_MEMBERS = NO
# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
# undocumented classes that are normally visible in the class hierarchy.
# If set to NO (the default) these classes will be included in the various
# overviews. This option has no effect if EXTRACT_ALL is enabled.
HIDE_UNDOC_CLASSES = NO
# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all
# friend (class|struct|union) declarations.
# If set to NO (the default) these declarations will be included in the
# documentation.
HIDE_FRIEND_COMPOUNDS = NO
# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any
# documentation blocks found inside the body of a function.
# If set to NO (the default) these blocks will be appended to the
# function's detailed documentation block.
HIDE_IN_BODY_DOCS = NO
# The INTERNAL_DOCS tag determines if documentation
# that is typed after a \internal command is included. If the tag is set
# to NO (the default) then the documentation will be excluded.
# Set it to YES to include the internal documentation.
INTERNAL_DOCS = NO
# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate
# file names in lower-case letters. If set to YES upper-case letters are also
# allowed. This is useful if you have classes or files whose names only differ
# in case and if your file system supports case sensitive file names. Windows
# and Mac users are advised to set this option to NO.
CASE_SENSE_NAMES = YES
# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen
# will show members with their full class and namespace scopes in the
# documentation. If set to YES the scope will be hidden.
HIDE_SCOPE_NAMES = NO
# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen
# will put a list of the files that are included by a file in the documentation
# of that file.
SHOW_INCLUDE_FILES = YES
# If the INLINE_INFO tag is set to YES (the default) then a tag [inline]
# is inserted in the documentation for inline members.
INLINE_INFO = YES
# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen
# will sort the (detailed) documentation of file and class members
# alphabetically by member name. If set to NO the members will appear in
# declaration order.
SORT_MEMBER_DOCS = YES
# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the
# brief documentation of file, namespace and class members alphabetically
# by member name. If set to NO (the default) the members will appear in
# declaration order.
SORT_BRIEF_DOCS = NO
# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the
# hierarchy of group names into alphabetical order. If set to NO (the default)
# the group names will appear in their defined order.
SORT_GROUP_NAMES = NO
# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be
# sorted by fully-qualified names, including namespaces. If set to
# NO (the default), the class list will be sorted only by class name,
# not including the namespace part.
# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
# Note: This option applies only to the class list, not to the
# alphabetical list.
SORT_BY_SCOPE_NAME = NO
# The GENERATE_TODOLIST tag can be used to enable (YES) or
# disable (NO) the todo list. This list is created by putting \todo
# commands in the documentation.
GENERATE_TODOLIST = YES
# The GENERATE_TESTLIST tag can be used to enable (YES) or
# disable (NO) the test list. This list is created by putting \test
# commands in the documentation.
GENERATE_TESTLIST = YES
# The GENERATE_BUGLIST tag can be used to enable (YES) or
# disable (NO) the bug list. This list is created by putting \bug
# commands in the documentation.
GENERATE_BUGLIST = YES
# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or
# disable (NO) the deprecated list. This list is created by putting
# \deprecated commands in the documentation.
GENERATE_DEPRECATEDLIST= YES
# The ENABLED_SECTIONS tag can be used to enable conditional
# documentation sections, marked by \if sectionname ... \endif.
ENABLED_SECTIONS =
# The MAX_INITIALIZER_LINES tag determines the maximum number of lines
# the initial value of a variable or define consists of for it to appear in
# the documentation. If the initializer consists of more lines than specified
# here it will be hidden. Use a value of 0 to hide initializers completely.
# The appearance of the initializer of individual variables and defines in the
# documentation can be controlled using \showinitializer or \hideinitializer
# command in the documentation regardless of this setting.
MAX_INITIALIZER_LINES = 30
# Set the SHOW_USED_FILES tag to NO to disable the list of files generated
# at the bottom of the documentation of classes and structs. If set to YES the
# list will mention the files that were used to generate the documentation.
SHOW_USED_FILES = YES
# If the sources in your project are distributed over multiple directories
# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy
# in the documentation. The default is NO.
SHOW_DIRECTORIES = NO
# Set the SHOW_FILES tag to NO to disable the generation of the Files page.
# This will remove the Files entry from the Quick Index and from the
# Folder Tree View (if specified). The default is YES.
SHOW_FILES = YES
# Set the SHOW_NAMESPACES tag to NO to disable the generation of the
# Namespaces page. This will remove the Namespaces entry from the Quick Index
# and from the Folder Tree View (if specified). The default is YES.
SHOW_NAMESPACES = YES
# The FILE_VERSION_FILTER tag can be used to specify a program or script that
# doxygen should invoke to get the current version for each file (typically from
# the version control system). Doxygen will invoke the program by executing (via
# popen()) the command <command> <input-file>, where <command> is the value of
# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file
# provided by doxygen. Whatever the program writes to standard output
# is used as the file version. See the manual for examples.
FILE_VERSION_FILTER =
# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed by
# doxygen. The layout file controls the global structure of the generated output files
# in an output format independent way. The create the layout file that represents
# doxygen's defaults, run doxygen with the -l option. You can optionally specify a
# file name after the option, if omitted DoxygenLayout.xml will be used as the name
# of the layout file.
LAYOUT_FILE =
#---------------------------------------------------------------------------
# configuration options related to warning and progress messages
#---------------------------------------------------------------------------
# The QUIET tag can be used to turn on/off the messages that are generated
# by doxygen. Possible values are YES and NO. If left blank NO is used.
QUIET = NO
# The WARNINGS tag can be used to turn on/off the warning messages that are
# generated by doxygen. Possible values are YES and NO. If left blank
# NO is used.
WARNINGS = YES
# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings
# for undocumented members. If EXTRACT_ALL is set to YES then this flag will
# automatically be disabled.
WARN_IF_UNDOCUMENTED = YES
# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for
# potential errors in the documentation, such as not documenting some
# parameters in a documented function, or documenting parameters that
# don't exist or using markup commands wrongly.
WARN_IF_DOC_ERROR = YES
# This WARN_NO_PARAMDOC option can be abled to get warnings for
# functions that are documented, but have no documentation for their parameters
# or return value. If set to NO (the default) doxygen will only warn about
# wrong or incomplete parameter documentation, but not about the absence of
# documentation.
WARN_NO_PARAMDOC = YES
# The WARN_FORMAT tag determines the format of the warning messages that
# doxygen can produce. The string should contain the $file, $line, and $text
# tags, which will be replaced by the file and line number from which the
# warning originated and the warning text. Optionally the format may contain
# $version, which will be replaced by the version of the file (if it could
# be obtained via FILE_VERSION_FILTER)
WARN_FORMAT = "$file:$line: $text"
# The WARN_LOGFILE tag can be used to specify a file to which warning
# and error messages should be written. If left blank the output is written
# to stderr.
WARN_LOGFILE =
#---------------------------------------------------------------------------
# configuration options related to the input files
#---------------------------------------------------------------------------
# The INPUT tag can be used to specify the files and/or directories that contain
# documented source files. You may enter file names like "myfile.cpp" or
# directories like "/usr/src/myproject". Separate the files or directories
# with spaces.
INPUT = ../awitpt
# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
# also the default input encoding. Doxygen uses libiconv (or the iconv built
# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for
# the list of possible encodings.
INPUT_ENCODING = UTF-8
# If the value of the INPUT tag contains directories, you can use the
# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
# and *.h) to filter out the source-files in the directories. If left
# blank the following patterns are tested:
# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx
# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90
FILE_PATTERNS = *.pm
# The RECURSIVE tag can be used to turn specify whether or not subdirectories
# should be searched for input files as well. Possible values are YES and NO.
# If left blank NO is used.
RECURSIVE = NO
# The EXCLUDE tag can be used to specify files and/or directories that should
# excluded from the INPUT source files. This way you can easily exclude a
# subdirectory from a directory tree whose root is specified with the INPUT tag.
EXCLUDE =
# The EXCLUDE_SYMLINKS tag can be used select whether or not files or
# directories that are symbolic links (a Unix filesystem feature) are excluded
# from the input.
EXCLUDE_SYMLINKS = NO
# If the value of the INPUT tag contains directories, you can use the
# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
# certain files from those directories. Note that the wildcards are matched
# against the file with absolute path, so to exclude all test directories
# for example use the pattern */test/*
EXCLUDE_PATTERNS =
# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
# (namespaces, classes, functions, etc.) that should be excluded from the
# output. The symbol name can be a fully qualified name, a word, or if the
# wildcard * is used, a substring. Examples: ANamespace, AClass,
# AClass::ANamespace, ANamespace::*Test
EXCLUDE_SYMBOLS =
# The EXAMPLE_PATH tag can be used to specify one or more files or
# directories that contain example code fragments that are included (see
# the \include command).
EXAMPLE_PATH =
# If the value of the EXAMPLE_PATH tag contains directories, you can use the
# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
# and *.h) to filter out the source-files in the directories. If left
# blank all files are included.
EXAMPLE_PATTERNS =
# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
# searched for input files to be used with the \include or \dontinclude
# commands irrespective of the value of the RECURSIVE tag.
# Possible values are YES and NO. If left blank NO is used.
EXAMPLE_RECURSIVE = NO
# The IMAGE_PATH tag can be used to specify one or more files or
# directories that contain image that are included in the documentation (see
# the \image command).
IMAGE_PATH =
# The INPUT_FILTER tag can be used to specify a program that doxygen should
# invoke to filter for each input file. Doxygen will invoke the filter program
# by executing (via popen()) the command <filter> <input-file>, where <filter>
# is the value of the INPUT_FILTER tag, and <input-file> is the name of an
# input file. Doxygen will then use the output that the filter program writes
# to standard output. If FILTER_PATTERNS is specified, this tag will be
# ignored.
INPUT_FILTER = doxygenfilter
# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
# basis. Doxygen will compare the file name with each pattern and apply the
# filter if there is a match. The filters are a list of the form:
# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further
# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER
# is applied to all files.
FILTER_PATTERNS =
# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
# INPUT_FILTER) will be used to filter the input files when producing source
# files to browse (i.e. when SOURCE_BROWSER is set to YES).
FILTER_SOURCE_FILES = NO
#---------------------------------------------------------------------------
# configuration options related to source browsing
#---------------------------------------------------------------------------
# If the SOURCE_BROWSER tag is set to YES then a list of source files will
# be generated. Documented entities will be cross-referenced with these sources.
# Note: To get rid of all source code in the generated output, make sure also
# VERBATIM_HEADERS is set to NO.
SOURCE_BROWSER = NO
# Setting the INLINE_SOURCES tag to YES will include the body
# of functions and classes directly in the documentation.
INLINE_SOURCES = NO
# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct
# doxygen to hide any special comment blocks from generated source code
# fragments. Normal C and C++ comments will always remain visible.
STRIP_CODE_COMMENTS = YES
# If the REFERENCED_BY_RELATION tag is set to YES
# then for each documented function all documented
# functions referencing it will be listed.
REFERENCED_BY_RELATION = YES
# If the REFERENCES_RELATION tag is set to YES
# then for each documented function all documented entities
# called/used by that function will be listed.
REFERENCES_RELATION = YES
# If the REFERENCES_LINK_SOURCE tag is set to YES (the default)
# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from
# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will
# link to the source code. Otherwise they will link to the documentstion.
REFERENCES_LINK_SOURCE = YES
# If the USE_HTAGS tag is set to YES then the references to source code
# will point to the HTML generated by the htags(1) tool instead of doxygen
# built-in source browser. The htags tool is part of GNU's global source
# tagging system (see http://www.gnu.org/software/global/global.html). You
# will need version 4.8.6 or higher.
USE_HTAGS = NO
# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen
# will generate a verbatim copy of the header file for each class for
# which an include is specified. Set to NO to disable this.
VERBATIM_HEADERS = YES
#---------------------------------------------------------------------------
# configuration options related to the alphabetical class index
#---------------------------------------------------------------------------
# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index
# of all compounds will be generated. Enable this if the project
# contains a lot of classes, structs, unions or interfaces.
ALPHABETICAL_INDEX = NO
# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then
# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns
# in which this list will be split (can be a number in the range [1..20])
COLS_IN_ALPHA_INDEX = 5
# In case all classes in a project start with a common prefix, all
# classes will be put under the same header in the alphabetical index.
# The IGNORE_PREFIX tag can be used to specify one or more prefixes that
# should be ignored while generating the index headers.
IGNORE_PREFIX =
#---------------------------------------------------------------------------
# configuration options related to the HTML output
#---------------------------------------------------------------------------
# If the GENERATE_HTML tag is set to YES (the default) Doxygen will
# generate HTML output.
GENERATE_HTML = YES
# The HTML_OUTPUT tag is used to specify where the HTML docs will be put.
# If a relative path is entered the value of OUTPUT_DIRECTORY will be
# put in front of it. If left blank `html' will be used as the default path.
HTML_OUTPUT = html
# The HTML_FILE_EXTENSION tag can be used to specify the file extension for
# each generated HTML page (for example: .htm,.php,.asp). If it is left blank
# doxygen will generate files with .html extension.
HTML_FILE_EXTENSION = .html
# The HTML_HEADER tag can be used to specify a personal HTML header for
# each generated HTML page. If it is left blank doxygen will generate a
# standard header.
HTML_HEADER =
# The HTML_FOOTER tag can be used to specify a personal HTML footer for
# each generated HTML page. If it is left blank doxygen will generate a
# standard footer.
HTML_FOOTER =
# The HTML_STYLESHEET tag can be used to specify a user-defined cascading
# style sheet that is used by each HTML page. It can be used to
# fine-tune the look of the HTML output. If the tag is left blank doxygen
# will generate a default style sheet. Note that doxygen will try to copy
# the style sheet file to the HTML output directory, so don't put your own
# stylesheet in the HTML output directory as well, or it will be erased!
HTML_STYLESHEET =
# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes,
# files or namespaces will be aligned in HTML using tables. If set to
# NO a bullet list will be used.
HTML_ALIGN_MEMBERS = YES
# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
# documentation will contain sections that can be hidden and shown after the
# page has loaded. For this to work a browser that supports
# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox
# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari).
HTML_DYNAMIC_SECTIONS = NO
# If the GENERATE_DOCSET tag is set to YES, additional index files
# will be generated that can be used as input for Apple's Xcode 3
# integrated development environment, introduced with OSX 10.5 (Leopard).
# To create a documentation set, doxygen will generate a Makefile in the
# HTML output directory. Running make will produce the docset in that
# directory and running "make install" will install the docset in
# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find
# it at startup.
# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html for more information.
GENERATE_DOCSET = NO
# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the
# feed. A documentation feed provides an umbrella under which multiple
# documentation sets from a single provider (such as a company or product suite)
# can be grouped.
DOCSET_FEEDNAME = "Doxygen generated docs"
# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that
# should uniquely identify the documentation set bundle. This should be a
# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen
# will append .docset to the name.
DOCSET_BUNDLE_ID = org.doxygen.Project
# If the GENERATE_HTMLHELP tag is set to YES, additional index files
# will be generated that can be used as input for tools like the
# Microsoft HTML help workshop to generate a compiled HTML help file (.chm)
# of the generated HTML documentation.
GENERATE_HTMLHELP = NO
# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can
# be used to specify the file name of the resulting .chm file. You
# can add a path in front of the file if the result should not be
# written to the html output directory.
CHM_FILE =
# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can
# be used to specify the location (absolute path including file name) of
# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run
# the HTML help compiler on the generated index.hhp.
HHC_LOCATION =
# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag
# controls if a separate .chi index file is generated (YES) or that
# it should be included in the master .chm file (NO).
GENERATE_CHI = NO
# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING
# is used to encode HtmlHelp index (hhk), content (hhc) and project file
# content.
CHM_INDEX_ENCODING =
# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag
# controls whether a binary table of contents is generated (YES) or a
# normal table of contents (NO) in the .chm file.
BINARY_TOC = NO
# The TOC_EXPAND flag can be set to YES to add extra items for group members
# to the contents of the HTML help documentation and to the tree view.
TOC_EXPAND = NO
# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and QHP_VIRTUAL_FOLDER
# are set, an additional index file will be generated that can be used as input for
# Qt's qhelpgenerator to generate a Qt Compressed Help (.qch) of the generated
# HTML documentation.
GENERATE_QHP = NO
# If the QHG_LOCATION tag is specified, the QCH_FILE tag can
# be used to specify the file name of the resulting .qch file.
# The path specified is relative to the HTML output folder.
QCH_FILE =
# The QHP_NAMESPACE tag specifies the namespace to use when generating
# Qt Help Project output. For more information please see
# <a href="http://doc.trolltech.com/qthelpproject.html#namespace">Qt Help Project / Namespace</a>.
QHP_NAMESPACE = org.doxygen.Project
# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating
# Qt Help Project output. For more information please see
# <a href="http://doc.trolltech.com/qthelpproject.html#virtual-folders">Qt Help Project / Virtual Folders</a>.
QHP_VIRTUAL_FOLDER = doc
# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can
# be used to specify the location of Qt's qhelpgenerator.
# If non-empty doxygen will try to run qhelpgenerator on the generated
# .qhp file .
QHG_LOCATION =
# The DISABLE_INDEX tag can be used to turn on/off the condensed index at
# top of each HTML page. The value NO (the default) enables the index and
# the value YES disables it.
DISABLE_INDEX = NO
# This tag can be used to set the number of enum values (range [1..20])
# that doxygen will group on one line in the generated HTML documentation.
ENUM_VALUES_PER_LINE = 4
# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index
# structure should be generated to display hierarchical information.
# If the tag value is set to FRAME, a side panel will be generated
# containing a tree-like index structure (just like the one that
# is generated for HTML Help). For this to work a browser that supports
# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+,
# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are
# probably better off using the HTML help feature. Other possible values
# for this tag are: HIERARCHIES, which will generate the Groups, Directories,
# and Class Hierarchy pages using a tree view instead of an ordered list;
# ALL, which combines the behavior of FRAME and HIERARCHIES; and NONE, which
# disables this behavior completely. For backwards compatibility with previous
# releases of Doxygen, the values YES and NO are equivalent to FRAME and NONE
# respectively.
GENERATE_TREEVIEW = NO
# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be
# used to set the initial width (in pixels) of the frame in which the tree
# is shown.
TREEVIEW_WIDTH = 250
# Use this tag to change the font size of Latex formulas included
# as images in the HTML documentation. The default is 10. Note that
# when you change the font size after a successful doxygen run you need
# to manually remove any form_*.png images from the HTML output directory
# to force them to be regenerated.
FORMULA_FONTSIZE = 10
#---------------------------------------------------------------------------
# configuration options related to the LaTeX output
#---------------------------------------------------------------------------
# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will
# generate Latex output.
GENERATE_LATEX = YES
# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.
# If a relative path is entered the value of OUTPUT_DIRECTORY will be
# put in front of it. If left blank `latex' will be used as the default path.
LATEX_OUTPUT = latex
# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
# invoked. If left blank `latex' will be used as the default command name.
LATEX_CMD_NAME = latex
# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to
# generate index for LaTeX. If left blank `makeindex' will be used as the
# default command name.
MAKEINDEX_CMD_NAME = makeindex
# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact
# LaTeX documents. This may be useful for small projects and may help to
# save some trees in general.
COMPACT_LATEX = NO
# The PAPER_TYPE tag can be used to set the paper type that is used
# by the printer. Possible values are: a4, a4wide, letter, legal and
# executive. If left blank a4wide will be used.
PAPER_TYPE = a4wide
# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX
# packages that should be included in the LaTeX output.
EXTRA_PACKAGES =
# The LATEX_HEADER tag can be used to specify a personal LaTeX header for
# the generated latex document. The header should contain everything until
# the first chapter. If it is left blank doxygen will generate a
# standard header. Notice: only use this tag if you know what you are doing!
LATEX_HEADER =
# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated
# is prepared for conversion to pdf (using ps2pdf). The pdf file will
# contain links (just like the HTML output) instead of page references
# This makes the output suitable for online browsing using a pdf viewer.
PDF_HYPERLINKS = NO
# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of
# plain latex in the generated Makefile. Set this option to YES to get a
# higher quality PDF documentation.
USE_PDFLATEX = NO
# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode.
# command to the generated LaTeX files. This will instruct LaTeX to keep
# running if errors occur, instead of asking the user for help.
# This option is also used when generating formulas in HTML.
LATEX_BATCHMODE = NO
# If LATEX_HIDE_INDICES is set to YES then doxygen will not
# include the index chapters (such as File Index, Compound Index, etc.)
# in the output.
LATEX_HIDE_INDICES = NO
#---------------------------------------------------------------------------
# configuration options related to the RTF output
#---------------------------------------------------------------------------
# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output
# The RTF output is optimized for Word 97 and may not look very pretty with
# other RTF readers or editors.
GENERATE_RTF = NO
# The RTF_OUTPUT tag is used to specify where the RTF docs will be put.
# If a relative path is entered the value of OUTPUT_DIRECTORY will be
# put in front of it. If left blank `rtf' will be used as the default path.
RTF_OUTPUT = rtf
# If the COMPACT_RTF tag is set to YES Doxygen generates more compact
# RTF documents. This may be useful for small projects and may help to
# save some trees in general.
COMPACT_RTF = NO
# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated
# will contain hyperlink fields. The RTF file will
# contain links (just like the HTML output) instead of page references.
# This makes the output suitable for online browsing using WORD or other
# programs which support those fields.
# Note: wordpad (write) and others do not support links.
RTF_HYPERLINKS = NO
# Load stylesheet definitions from file. Syntax is similar to doxygen's
# config file, i.e. a series of assignments. You only have to provide
# replacements, missing definitions are set to their default value.
RTF_STYLESHEET_FILE =
# Set optional variables used in the generation of an rtf document.
# Syntax is similar to doxygen's config file.
RTF_EXTENSIONS_FILE =
#---------------------------------------------------------------------------
# configuration options related to the man page output
#---------------------------------------------------------------------------
# If the GENERATE_MAN tag is set to YES (the default) Doxygen will
# generate man pages
GENERATE_MAN = NO
# The MAN_OUTPUT tag is used to specify where the man pages will be put.
# If a relative path is entered the value of OUTPUT_DIRECTORY will be
# put in front of it. If left blank `man' will be used as the default path.
MAN_OUTPUT = man
# The MAN_EXTENSION tag determines the extension that is added to
# the generated man pages (default is the subroutine's section .3)
MAN_EXTENSION = .3
# If the MAN_LINKS tag is set to YES and Doxygen generates man output,
# then it will generate one additional man file for each entity
# documented in the real man page(s). These additional files
# only source the real man page, but without them the man command
# would be unable to find the correct page. The default is NO.
MAN_LINKS = NO
#---------------------------------------------------------------------------
# configuration options related to the XML output
#---------------------------------------------------------------------------
# If the GENERATE_XML tag is set to YES Doxygen will
# generate an XML file that captures the structure of
# the code including all documentation.
GENERATE_XML = NO
# The XML_OUTPUT tag is used to specify where the XML pages will be put.
# If a relative path is entered the value of OUTPUT_DIRECTORY will be
# put in front of it. If left blank `xml' will be used as the default path.
XML_OUTPUT = xml
# The XML_SCHEMA tag can be used to specify an XML schema,
# which can be used by a validating XML parser to check the
# syntax of the XML files.
XML_SCHEMA =
# The XML_DTD tag can be used to specify an XML DTD,
# which can be used by a validating XML parser to check the
# syntax of the XML files.
XML_DTD =
# If the XML_PROGRAMLISTING tag is set to YES Doxygen will
# dump the program listings (including syntax highlighting
# and cross-referencing information) to the XML output. Note that
# enabling this will significantly increase the size of the XML output.
XML_PROGRAMLISTING = YES
#---------------------------------------------------------------------------
# configuration options for the AutoGen Definitions output
#---------------------------------------------------------------------------
# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will
# generate an AutoGen Definitions (see autogen.sf.net) file
# that captures the structure of the code including all
# documentation. Note that this feature is still experimental
# and incomplete at the moment.
GENERATE_AUTOGEN_DEF = NO
#---------------------------------------------------------------------------
# configuration options related to the Perl module output
#---------------------------------------------------------------------------
# If the GENERATE_PERLMOD tag is set to YES Doxygen will
# generate a Perl module file that captures the structure of
# the code including all documentation. Note that this
# feature is still experimental and incomplete at the
# moment.
GENERATE_PERLMOD = NO
# If the PERLMOD_LATEX tag is set to YES Doxygen will generate
# the necessary Makefile rules, Perl scripts and LaTeX code to be able
# to generate PDF and DVI output from the Perl module output.
PERLMOD_LATEX = NO
# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be
# nicely formatted so it can be parsed by a human reader. This is useful
# if you want to understand what is going on. On the other hand, if this
# tag is set to NO the size of the Perl module output will be much smaller
# and Perl will parse it just the same.
PERLMOD_PRETTY = YES
# The names of the make variables in the generated doxyrules.make file
# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX.
# This is useful so different doxyrules.make files included by the same
# Makefile don't overwrite each other's variables.
PERLMOD_MAKEVAR_PREFIX =
#---------------------------------------------------------------------------
# Configuration options related to the preprocessor
#---------------------------------------------------------------------------
# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will
# evaluate all C-preprocessor directives found in the sources and include
# files.
ENABLE_PREPROCESSING = YES
# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro
# names in the source code. If set to NO (the default) only conditional
# compilation will be performed. Macro expansion can be done in a controlled
# way by setting EXPAND_ONLY_PREDEF to YES.
MACRO_EXPANSION = NO
# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
# then the macro expansion is limited to the macros specified with the
# PREDEFINED and EXPAND_AS_DEFINED tags.
EXPAND_ONLY_PREDEF = NO
# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files
# in the INCLUDE_PATH (see below) will be search if a #include is found.
SEARCH_INCLUDES = YES
# The INCLUDE_PATH tag can be used to specify one or more directories that
# contain include files that are not input files but should be processed by
# the preprocessor.
INCLUDE_PATH =
# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
# patterns (like *.h and *.hpp) to filter out the header-files in the
# directories. If left blank, the patterns specified with FILE_PATTERNS will
# be used.
INCLUDE_FILE_PATTERNS =
# The PREDEFINED tag can be used to specify one or more macro names that
# are defined before the preprocessor is started (similar to the -D option of
# gcc). The argument of the tag is a list of macros of the form: name
# or name=definition (no spaces). If the definition and the = are
# omitted =1 is assumed. To prevent a macro definition from being
# undefined via #undef or recursively expanded use the := operator
# instead of the = operator.
PREDEFINED =
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
# this tag can be used to specify a list of macro names that should be expanded.
# The macro definition that is found in the sources will be used.
# Use the PREDEFINED tag if you want to use a different macro definition.
EXPAND_AS_DEFINED =
# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then
# doxygen's preprocessor will remove all function-like macros that are alone
# on a line, have an all uppercase name, and do not end with a semicolon. Such
# function macros are typically used for boiler-plate code, and will confuse
# the parser if not removed.
SKIP_FUNCTION_MACROS = YES
#---------------------------------------------------------------------------
# Configuration::additions related to external references
#---------------------------------------------------------------------------
# The TAGFILES option can be used to specify one or more tagfiles.
# Optionally an initial location of the external documentation
# can be added for each tagfile. The format of a tag file without
# this location is as follows:
# TAGFILES = file1 file2 ...
# Adding location for the tag files is done as follows:
# TAGFILES = file1=loc1 "file2 = loc2" ...
# where "loc1" and "loc2" can be relative or absolute paths or
# URLs. If a location is present for each tag, the installdox tool
# does not have to be run to correct the links.
# Note that each tag file must have a unique name
# (where the name does NOT include the path)
# If a tag file is not located in the directory in which doxygen
# is run, you must also specify the path to the tagfile here.
TAGFILES =
# When a file name is specified after GENERATE_TAGFILE, doxygen will create
# a tag file that is based on the input files it reads.
GENERATE_TAGFILE =
# If the ALLEXTERNALS tag is set to YES all external classes will be listed
# in the class index. If set to NO only the inherited external classes
# will be listed.
ALLEXTERNALS = NO
# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed
# in the modules index. If set to NO, only the current project's groups will
# be listed.
EXTERNAL_GROUPS = YES
# The PERL_PATH should be the absolute path and name of the perl script
# interpreter (i.e. the result of `which perl').
PERL_PATH = /usr/bin/perl
#---------------------------------------------------------------------------
# Configuration options related to the dot tool
#---------------------------------------------------------------------------
# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will
# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base
# or super classes. Setting the tag to NO turns the diagrams off. Note that
# this option is superseded by the HAVE_DOT option below. This is only a
# fallback. It is recommended to install and use dot, since it yields more
# powerful graphs.
CLASS_DIAGRAMS = NO
# You can define message sequence charts within doxygen comments using the \msc
# command. Doxygen will then run the mscgen tool (see
# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the
# documentation. The MSCGEN_PATH tag allows you to specify the directory where
# the mscgen tool resides. If left empty the tool is assumed to be found in the
# default search path.
MSCGEN_PATH =
# If set to YES, the inheritance and collaboration graphs will hide
# inheritance and usage relations if the target is undocumented
# or is not a class.
HIDE_UNDOC_RELATIONS = YES
# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
# available from the path. This tool is part of Graphviz, a graph visualization
# toolkit from AT&T and Lucent Bell Labs. The other options in this section
# have no effect if this option is set to NO (the default)
HAVE_DOT = NO
# By default doxygen will write a font called FreeSans.ttf to the output
# directory and reference it in all dot files that doxygen generates. This
# font does not include all possible unicode characters however, so when you need
# these (or just want a differently looking font) you can specify the font name
# using DOT_FONTNAME. You need need to make sure dot is able to find the font,
# which can be done by putting it in a standard location or by setting the
# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory
# containing the font.
DOT_FONTNAME = FreeSans
# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs.
# The default size is 10pt.
DOT_FONTSIZE = 10
# By default doxygen will tell dot to use the output directory to look for the
# FreeSans.ttf font (which doxygen will put there itself). If you specify a
# different font using DOT_FONTNAME you can set the path where dot
# can find it using this tag.
DOT_FONTPATH =
# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen
# will generate a graph for each documented class showing the direct and
# indirect inheritance relations. Setting this tag to YES will force the
# the CLASS_DIAGRAMS tag to NO.
CLASS_GRAPH = YES
# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen
# will generate a graph for each documented class showing the direct and
# indirect implementation dependencies (inheritance, containment, and
# class references variables) of the class with other documented classes.
COLLABORATION_GRAPH = YES
# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen
# will generate a graph for groups, showing the direct groups dependencies
GROUP_GRAPHS = YES
# If the UML_LOOK tag is set to YES doxygen will generate inheritance and
# collaboration diagrams in a style similar to the OMG's Unified Modeling
# Language.
UML_LOOK = NO
# If set to YES, the inheritance and collaboration graphs will show the
# relations between templates and their instances.
TEMPLATE_RELATIONS = NO
# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT
# tags are set to YES then doxygen will generate a graph for each documented
# file showing the direct and indirect include dependencies of the file with
# other documented files.
INCLUDE_GRAPH = YES
# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and
# HAVE_DOT tags are set to YES then doxygen will generate a graph for each
# documented header file showing the documented files that directly or
# indirectly include this file.
INCLUDED_BY_GRAPH = YES
# If the CALL_GRAPH and HAVE_DOT options are set to YES then
# doxygen will generate a call dependency graph for every global function
# or class method. Note that enabling this option will significantly increase
# the time of a run. So in most cases it will be better to enable call graphs
# for selected functions only using the \callgraph command.
CALL_GRAPH = NO
# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then
# doxygen will generate a caller dependency graph for every global function
# or class method. Note that enabling this option will significantly increase
# the time of a run. So in most cases it will be better to enable caller
# graphs for selected functions only using the \callergraph command.
CALLER_GRAPH = NO
# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
# will graphical hierarchy of all classes instead of a textual one.
GRAPHICAL_HIERARCHY = YES
# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES
# then doxygen will show the dependencies a directory has on other directories
# in a graphical way. The dependency relations are determined by the #include
# relations between the files in the directories.
DIRECTORY_GRAPH = YES
# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
# generated by dot. Possible values are png, jpg, or gif
# If left blank png will be used.
DOT_IMAGE_FORMAT = png
# The tag DOT_PATH can be used to specify the path where the dot tool can be
# found. If left blank, it is assumed the dot tool can be found in the path.
DOT_PATH =
# The DOTFILE_DIRS tag can be used to specify one or more directories that
# contain dot files that are included in the documentation (see the
# \dotfile command).
DOTFILE_DIRS =
# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of
# nodes that will be shown in the graph. If the number of nodes in a graph
# becomes larger than this value, doxygen will truncate the graph, which is
# visualized by representing a node as a red box. Note that doxygen if the
# number of direct children of the root node in a graph is already larger than
# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note
# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.
DOT_GRAPH_MAX_NODES = 50
# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the
# graphs generated by dot. A depth value of 3 means that only nodes reachable
# from the root by following a path via at most 3 edges will be shown. Nodes
# that lay further from the root node will be omitted. Note that setting this
# option to 1 or 2 may greatly reduce the computation time needed for large
# code bases. Also note that the size of a graph can be further restricted by
# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.
MAX_DOT_GRAPH_DEPTH = 0
# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent
# background. This is disabled by default, because dot on Windows does not
# seem to support this out of the box. Warning: Depending on the platform used,
# enabling this option may lead to badly anti-aliased labels on the edges of
# a graph (i.e. they become hard to read).
DOT_TRANSPARENT = NO
# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output
# files in one run (i.e. multiple -o and -T options on the command line). This
# makes dot run faster, but since only newer versions of dot (>1.8.10)
# support this, this feature is disabled by default.
DOT_MULTI_TARGETS = NO
# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will
# generate a legend page explaining the meaning of the various boxes and
# arrows in the dot generated graphs.
GENERATE_LEGEND = YES
# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will
# remove the intermediate dot files that are used to generate
# the various graphs.
DOT_CLEANUP = YES
#---------------------------------------------------------------------------
# Configuration::additions related to the search engine
#---------------------------------------------------------------------------
# The SEARCHENGINE tag specifies whether or not a search engine should be
# used. If set to NO the values of all tags below this one will be ignored.
SEARCHENGINE = NO
# Copyright (C) 2008-2011, AllWorldIT
# Copyright (C) 2005-2007, LinuxRulz
# Copyright (C) 2005, Nigel Kukard <nkukard@lbsd.net>
# Copyright 1996-2003, Gisle Aas
#
# This library is free software; you can redistribute it and/or
# modify it under the same terms as Perl itself.
use strict;
use warnings;
# Main package
package SOAP::Transport::HTTPng;
our $VERSION = 0.010;
# Overrided server so we can intercept sensitive info
package SOAP::Transport::HTTPng::Server;
use SOAP::Transport::HTTP;
my $COMPRESS = 'deflate';
use base qw(SOAP::Transport::HTTP::Server);
# Setup a logging function
sub set_logger {
my ($self,$logobj) = @_;
$self->{'logobj'} = $logobj;
}
# Setup a call logger function
sub set_soap_method_logger {
my ($self,$loggerobj) = @_;
$self->{'soap_method_logger'} = $loggerobj;
}
sub set_soap_result_logger {
my ($self,$loggerobj) = @_;
$self->{'soap_result_logger'} = $loggerobj;
}
# NK: this is basically a copy of the handle() function from SOAP::Lite, just with a few
# logger changes
sub handle_SOAP_Lite {
SOAP::Trace::trace('()');
my $self = shift;
$self = $self->new if !ref $self; # inits the server when called in a static context
$self->init_context();
# we want to restore it when we are done
local $SOAP::Constants::DEFAULT_XML_SCHEMA
= $SOAP::Constants::DEFAULT_XML_SCHEMA;
# SOAP version WILL NOT be restored when we are done.
# is it problem?
my $result = eval {
local $SIG{__DIE__};
# why is this here:
$self->serializer->soapversion(1.1);
my $request = eval { $self->deserializer->deserialize($_[0]) };
die SOAP::Fault
->faultcode($SOAP::Constants::FAULT_VERSION_MISMATCH)
->faultstring($@)
if $@ && $@ =~ /^$SOAP::Constants::WRONG_VERSION/;
die "Application failed during request deserialization: $@" if $@;
my $som = ref $request;
die "Can't find root element in the message"
unless $request->match($som->envelope);
$self->serializer->soapversion(SOAP::Lite->soapversion);
$self->serializer->xmlschema($SOAP::Constants::DEFAULT_XML_SCHEMA
= $self->deserializer->xmlschema)
if $self->deserializer->xmlschema;
die SOAP::Fault
->faultcode($SOAP::Constants::FAULT_MUST_UNDERSTAND)
->faultstring("Unrecognized header has mustUnderstand attribute set to 'true'")
if !$SOAP::Constants::DO_NOT_CHECK_MUSTUNDERSTAND &&
grep {
$_->mustUnderstand
&& (!$_->actor || $_->actor eq $SOAP::Constants::NEXT_ACTOR)
} $request->dataof($som->headers);
die "Can't find method element in the message"
unless $request->match($som->method);
# TODO - SOAP::Dispatcher plugs in here
# my $handler = $self->dispatcher->find_handler($request);
my($class, $method_uri, $method_name) = $self->find_target($request);
my @results = eval {
local $^W;
my @parameters = $request->paramsin;
# SOAP::Trace::dispatch($fullname);
SOAP::Trace::parameters(@parameters);
# NK: This happens inside an eval? oh well whatever
$self->soap_method_logger($class,$method_uri,$method_name,@parameters);
push @parameters, $request
if UNIVERSAL::isa($class => 'SOAP::Server::Parameters');
SOAP::Server::Object->references(
defined $parameters[0]
&& ref $parameters[0]
&& UNIVERSAL::isa($parameters[0] => $class)
? do {
my $object = shift @parameters;
SOAP::Server::Object->object(ref $class
? $class
: $object
)->$method_name(SOAP::Server::Object->objects(@parameters)),
# send object back as a header
# preserve name, specify URI
SOAP::Header
->uri($SOAP::Constants::NS_SL_HEADER => $object)
->name($request->dataof($som->method.'/[1]')->name)
} # end do block
# SOAP::Dispatcher will plug-in here as well
# $handler->dispatch(SOAP::Server::Object->objects(@parameters)
: $class->$method_name(SOAP::Server::Object->objects(@parameters)) );
}; # end eval block
SOAP::Trace::result(@results);
$self->soap_result_logger($class,$method_uri,$method_name,@results);
# let application errors pass through with 'Server' code
die ref $@
? $@
: $@ =~ /^Can\'t locate object method "$method_name"/
? "Failed to locate method ($method_name) in class ($class)"
: SOAP::Fault->faultcode($SOAP::Constants::FAULT_SERVER)->faultstring($@)
if $@;
my $result = $self->serializer
->prefix('s') # distinguish generated element names between client and server
->uri($method_uri)
->envelope(response => $method_name . 'Response', @results);
return $result;
};
# void context
return unless defined wantarray;
# normal result
return $result unless $@;
# check fails, something wrong with message
return $self->make_fault($SOAP::Constants::FAULT_CLIENT, $@) unless ref $@;
# died with SOAP::Fault
return $self->make_fault($@->faultcode || $SOAP::Constants::FAULT_SERVER,
$@->faultstring || 'Application error',
$@->faultdetail, $@->faultactor)
if UNIVERSAL::isa($@ => 'SOAP::Fault');
# died with complex detail
return $self->make_fault($SOAP::Constants::FAULT_SERVER, 'Application error' => $@);
} # end of handle()
# NK: this is basically a copy of the handle() function from SOAP::Transport::HTTP
sub handle {
my $self = shift->new;
SOAP::Trace::debug( $self->request->content );
if ( $self->request->method eq 'POST' ) {
$self->action( $self->request->header('SOAPAction') || undef );
}
elsif ( $self->request->method eq 'M-POST' ) {
return $self->response(
HTTP::Response->new(
510, # NOT EXTENDED
"Expected Mandatory header with $SOAP::Constants::NS_ENV as unique URI"
) )
if $self->request->header('Man') !~
/^"$SOAP::Constants::NS_ENV";\s*ns\s*=\s*(\d+)/;
$self->action( $self->request->header("$1-SOAPAction") || undef );
}
else {
return $self->response(
HTTP::Response->new(405) ) # METHOD NOT ALLOWED
}
my $compressed =
( $self->request->content_encoding || '' ) =~ /\b$COMPRESS\b/;
$self->options->{is_compress} ||=
$compressed && eval { require Compress::Zlib };
# signal error if content-encoding is 'deflate', but we don't want it OR
# something else, so we don't understand it
return $self->response(
HTTP::Response->new(415) ) # UNSUPPORTED MEDIA TYPE
if $compressed && !$self->options->{is_compress}
|| !$compressed
&& ( $self->request->content_encoding || '' ) =~ /\S/;
my $content_type = $self->request->content_type || '';
# in some environments (PerlEx?) content_type could be empty, so allow it also
# anyway it'll blow up inside ::Server::handle if something wrong with message
# TBD: but what to do with MIME encoded messages in THOSE environments?
return $self->make_fault( $SOAP::Constants::FAULT_CLIENT,
"Content-Type must be 'text/xml,' 'multipart/*,' "
. "'application/soap+xml,' 'or 'application/dime' instead of '$content_type'"
)
if !$SOAP::Constants::DO_NOT_CHECK_CONTENT_TYPE
&& $content_type
&& $content_type ne 'application/soap+xml'
&& $content_type ne 'text/xml'
&& $content_type ne 'application/dime'
&& $content_type !~ m!^multipart/!;
# TODO - Handle the Expect: 100-Continue HTTP/1.1 Header
if ( defined( $self->request->header("Expect") )
&& ( $self->request->header("Expect") eq "100-Continue" ) ) {
}
# TODO - this should query SOAP::Packager to see what types it supports,
# I don't like how this is hardcoded here.
my $content =
$compressed
? Compress::Zlib::uncompress( $self->request->content )
: $self->request->content;
my $response = $self->handle_SOAP_Lite(
$self->request->content_type =~ m!^multipart/!
? join( "\n", $self->request->headers_as_string, $content )
: $content
) or return;
SOAP::Trace::debug($response);
$self->make_response( $SOAP::Constants::HTTP_ON_SUCCESS_CODE, $response );
}
# We want to override the make_fault function to catch sensitive information
# being sent out when code b0rkage occurs.
sub make_fault {
my ($self, $code, $string, $detail, $actor) = @_;
# Check if this is a string?
if (ref($code) eq "") {
# If its a server fault, just output something nice
if ($code eq "Server") {
# If we have a logging element in ourselves, use it
if (defined($self->{'logobj'})) {
$self->{'logobj'}->log(0,"[SOAP::Server] $string");
}
$string = "An error occured while processing the request. Please try again later.";
}
}
return $self->SUPER::make_fault($code,$string,$detail,$actor);
}
# This is the actual interface to the method logger function which allows us
# to customize it
sub soap_method_logger {
my ($self,@params) = @_;
$self->{'soap_method_logger'}(@params) if (defined($self->{'soap_method_logger'}));
}
sub soap_result_logger {
my ($self,@params) = @_;
$self->{'soap_result_logger'}(@params) if (defined($self->{'soap_result_logger'}));
}
# PreForked implementation of a SOAP HTTP transport
package SOAP::Transport::HTTPng::Daemon;
use base qw(Net::Server::PreFork);
use HTTP::Daemon;
use HTTP::Status;
use URI::Escape;
use IO::Socket qw(inet_ntoa);
use Socket;
use SOAP::Lite;
use SOAP::Transport::HTTP;
sub new
{
my $self = shift;
unless (ref $self) {
my $class = ref($self) || $self;
$self = $class->SUPER::new(@_);
$self->{'soap_config'}->{'dispatch_to'} = ();
$self->{'soap_config'}->{'dispatch_with'} = {};
}
return $self;
}
sub post_configure
{
my $self = shift;
my $server = $self->{'server'};
# Make sure we have a timeout
if (!defined($server->{'timeout'})) {
$server->{'timeout'} = 30;
}
$self->SUPER::post_configure(@_);
}
sub child_init_hook
{
my $self = shift;
my $soapcfg = $self->{'soap_config'};
$self->{'_soap_engine'} = SOAP::Transport::HTTPng::Server->new;
# Mappings
if (defined($soapcfg->{'dispatch_to'}) && @{$soapcfg->{'dispatch_to'}} > 0) {
$self->{'_soap_engine'}->dispatch_to(@{$soapcfg->{'dispatch_to'}});
}
if (defined($soapcfg->{'dispatch_with'}) && @{$soapcfg->{'dispatch_with'}} > 0) {
$self->{'_soap_engine'}->dispatch_with(%{$soapcfg->{'dispatch_with'}});
}
# Hooks
if (defined($soapcfg->{'on_action'})) {
$self->{'_soap_engine'}->on_action($soapcfg->{'on_action'});
}
if (defined($soapcfg->{'on_dispatch'})) {
$self->{'_soap_engine'}->on_dispatch($soapcfg->{'on_dispatch'});
}
# Setup logging
if (defined($soapcfg->{'soap_method_logger'})) {
$self->{'_soap_engine'}->set_soap_method_logger($soapcfg->{'soap_method_logger'});
}
if (defined($soapcfg->{'soap_result_logger'})) {
$self->{'_soap_engine'}->set_soap_result_logger($soapcfg->{'soap_result_logger'});
}
$self->{'_soap_engine'}->set_logger($self);
}
sub process_request
{
my ($self) = @_;
my $soap = $self->{'_soap_engine'};
my $c = SOAP::Transport::HTTPng::Daemon::Client->new($self);
my $r = $c->get_request();
$soap->request($r);
$soap->handle;
$c->send_response($soap->response);
}
sub log
{
my $self = shift;
return $self->SUPER::log(@_);
}
package SOAP::Transport::HTTPng::Daemon::Client;
require Exporter;
our (@ISA);
@ISA= qw(Exporter);
use HTTP::Request();
use HTTP::Response();
use HTTP::Status;
use HTTP::Date qw(time2str);
use LWP::MediaTypes qw(guess_media_type);
use Carp ();
use URI;
# Some constants we need
use constant {
DEBUG => 0,
BUFFER_SIZE => 1024,
# Make this big enough to handle an inbound packet ... 1Mb sound sane nowadays?
MAX_REQUEST_SIZE => 1024*1024,
CRLF => "\015\012", # HTTP::Daemon claims \r\n is not portable?
};
# Create object
sub new
{
my ($class,$daemon) = @_;
# Define ourselves and our variables
my $self = {
'daemon' => $daemon,
'_nomore' => undef,
'_rbuf' => undef,
'_client_proto' => undef,
};
bless $self, $class;
return $self;
}
# Get request
sub get_request
{
my($self, $only_headers) = @_;
# Check if no more requests
if ($self->{'_nomore'}) {
$self->reason("No more requests from this connection");
return;
}
# Init
$self->reason("");
my $buf = $self->{'_rbuf'};
$buf = "" unless defined $buf;
# Pull in timeout
my $timeout = $self->{'daemon'}->{'server'}->{'timeout'};
# Grab HTTP header
while (1) {
# loop until we have the whole header in $buf
$buf =~ s/^(?:\015?\012)+//; # ignore leading blank lines
if ($buf =~ /\012/) { # potential, has at least one line
if ($buf =~ /^\w+[^\012]+HTTP\/\d+\.\d+\015?\012/) {
if ($buf =~ /\015?\012\015?\012/) {
last; # we have it
# Header is over 16kb
} elsif (length($buf) > MAX_REQUEST_SIZE) {
$self->send_error(413); # REQUEST_ENTITY_TOO_LARGE
$self->reason("Very long header > ".MAX_REQUEST_SIZE);
return;
}
} else {
last; # HTTP/0.9 client
}
# Again ... too large
} elsif (length($buf) > MAX_REQUEST_SIZE) {
$self->send_error(414); # REQUEST_URI_TOO_LARGE
$self->reason("Very long first line > ".MAX_REQUEST_SIZE);
return;
}
return unless $self->_need_more(\$buf);
}
# Disect the protocol
if ($buf !~ s/^(\S+)[ \t]+(\S+)(?:[ \t]+(HTTP\/\d+\.\d+))?[^\012]*\012//) {
$self->{'_client_proto'} = $self->_http_version("HTTP/1.0");
$self->send_error(400); # BAD_REQUEST
$self->reason("Bad request line: $buf");
return;
}
my $method = $1;
my $uri = $2;
my $proto = $3 || "HTTP/0.9";
$uri = "http://$uri" if $method eq "CONNECT";
$uri = URI->new($uri, $self->{'daemon'}->{'config'}->{'url'});
my $r = HTTP::Request->new($method, $uri);
$r->protocol($proto);
$self->{'_client_proto'} = $proto = $self->_http_version($proto);
if ($self->proto_ge("HTTP/1.0")) {
# we expect to find some headers
my($key, $val);
while ($buf =~ s/^([^\012]*)\012//) {
$_ = $1;
s/\015$//;
if (/^([^:\s]+)\s*:\s*(.*)/) {
$r->push_header($key, $val) if $key;
($key, $val) = ($1, $2);
} elsif (/^\s+(.*)/) {
$val .= " $1";
} else {
last;
}
}
$r->push_header($key, $val) if $key;
}
my $conn = $r->header('Connection');
if ($self->proto_ge("HTTP/1.1")) {
$self->{'_nomore'}++ if $conn && lc($conn) =~ /\bclose\b/;
} else {
$self->{'_nomore'}++ unless $conn && lc($conn) =~ /\bkeep-alive\b/;
}
if ($only_headers) {
$self->{'rbuf'} = $buf;
return $r;
}
# Find out how much content to read
my $te = $r->header('Transfer-Encoding');
my $ct = $r->header('Content-Type');
my $len = $r->header('Content-Length');
if ($te && lc($te) eq 'chunked') {
# Handle chunked transfer encoding
my $body = "";
while (1) {
print STDERR "HTTPNG: Chunked\n" if DEBUG;
if ($buf =~ s/^([^\012]*)\012//) {
my $chunk_head = $1;
unless ($chunk_head =~ /^([0-9A-Fa-f]+)/) {
$self->send_error(400);
$self->reason("Bad chunk header $chunk_head");
return;
}
my $size = hex($1);
last if $size == 0;
my $missing = $size - length($buf) + 2; # 2=CRLF at chunk end
# must read until we have a complete chunk
while ($missing > 0) {
print STDERR "HTTPNG: Need $missing more bytes\n" if DEBUG;
my $n = $self->_need_more(\$buf);
return unless $n;
$missing -= $n;
}
$body .= substr($buf, 0, $size);
substr($buf, 0, $size+2) = '';
# need more data in order to have a complete chunk header
} else {
return unless $self->_need_more(\$buf);
}
}
$r->content($body);
# pretend it was a normal entity body
$r->remove_header('Transfer-Encoding');
$r->header('Content-Length', length($body));
my($key, $val);
while (1) {
if ($buf !~ /\012/) {
# need at least one line to look at
return unless $self->_need_more(\$buf);
} else {
$buf =~ s/^([^\012]*)\012//;
$_ = $1;
s/\015$//;
if (/^([\w\-]+)\s*:\s*(.*)/) {
$r->push_header($key, $val) if $key;
($key, $val) = ($1, $2);
} elsif (/^\s+(.*)/) {
$val .= " $1";
} elsif (!length) {
last;
} else {
$self->reason("Bad footer syntax");
return;
}
}
}
$r->push_header($key, $val) if $key;
} elsif ($te) {
$self->send_error(501); # Unknown transfer encoding
$self->reason("Unknown transfer encoding '$te'");
return;
} elsif ($ct && lc($ct) =~ m/^multipart\/\w+\s*;.*boundary\s*=\s*(\w+)/) {
# Handle multipart content type
my $boundary = sprintf('%s--%s--%s',CRLF,$1,CRLF);
my $index;
while (1) {
$index = index($buf, $boundary);
last if $index >= 0;
# end marker not yet found
return unless $self->_need_more(\$buf);
}
$index += length($boundary);
$r->content(substr($buf, 0, $index));
substr($buf, 0, $index) = '';
} elsif ($len) {
# Plain body specified by "Content-Length"
my $missing = $len - length($buf);
while ($missing > 0) {
print "HTTPNG: Need $missing more bytes of content\n" if DEBUG;
my $n = $self->_need_more(\$buf);
return unless $n;
$missing -= $n;
}
if (length($buf) > $len) {
$r->content(substr($buf,0,$len));
substr($buf, 0, $len) = '';
} else {
$r->content($buf);
$buf='';
}
}
$self->{'rbuf'} = $buf;
return $r;
}
sub _need_more
{
my($self,$buf) = @_;
# Pull in timeout
my $timeout = $self->{'daemon'}->{'server'}->{'timeout'};
# Lets start our select()
my $select = IO::Select->new($self->{'daemon'}->{'server'}->{'client'});
# Check if we can read
if (my ($fd) = $select->can_read($timeout)) {
# Lets read some data ....
# We do not loop here, when reading we check what we have so far
# then read more, check, read more check, not the ENTIRE buffer
# at once
return $self->clever_sysread($fd,$buf,length($$buf));
}
$self->reason("Timeout on read, no data for more than ".$timeout."s");
return;
}
sub clever_sysread
{
my ($self,$fd,$buf,$offset) = @_;
# Setup default offset
if (!defined($offset)) {
$offset = 0;
}
# Loop with read
my $tread = 0;
while (1) {
# Read the actual data
my $nread = sysread($fd,$$buf,BUFFER_SIZE,$offset+$tread);
# Check if we got something back
if (!defined($nread)) {
$self->reason("Client closed");
last;
}
$tread += $nread;
# Short-read , means we got it all
if ($nread < BUFFER_SIZE) {
last;
}
}
return $tread;
}
sub clever_syswrite
{
my ($self,$fd,$buf,$length,$offset) = @_;
# Setup default length
if (!defined($length)) {
$length = length($buf);
}
# Setup default offset
if (!defined($offset)) {
$offset = 0;
}
# Pull in timeout
my $timeout = $self->{'daemon'}->{'server'}->{'timeout'};
# Loop with write
my $twrite = 0;
while ($twrite < $length) {
# Lets start our select()
my $select = IO::Select->new($fd);
# Check if we can write
my $nwrite;
if (my ($fd) = $select->can_write($timeout)) {
# Write the actual data
$nwrite = syswrite($fd,$buf,(($length-$twrite) < BUFFER_SIZE ? ($length-$twrite) : BUFFER_SIZE),$offset+$twrite);
# Check if we got something back
if (!defined($nwrite)) {
$self->reason("Client closed");
last;
}
# Timeout
} else {
$self->reason("Timeout on write, no data for more than ".$timeout."s");
return;
}
$twrite += $nwrite;
}
return $twrite;
}
sub reason
{
my $self = shift;
my $old = $self->{'reason'};
$self->{'reason'} = shift if (@_);
return $old;
}
sub proto_ge
{
my $self = shift;
return ($self->{'_client_proto'} >= $self->_http_version(shift));
}
sub proto_lt
{
my $self = shift;
return ($self->{'_client_proto'} < $self->_http_version(shift));
}
sub _http_version
{
my ($self,$version) = @_;
return 0 unless ($version =~ m,^(?:HTTP/)?(\d+)\.(\d+)$,i);
return ($1 * 1000 + $2);
}
sub antique_client
{
my $self = shift;
return ($self->{'_client_proto'} < $self->_http_version("HTTP/1.0"));
}
sub force_last_request
{
my $self = shift;
$self->{'_nomore'}++;
}
sub send_status_line
{
my ($self, $status, $message, $proto) = @_;
my $client = $self->{'daemon'}->{'server'}->{'client'};
return if $self->antique_client;
$status ||= RC_OK;
$message ||= status_message($status) || "";
$proto ||= $HTTP::Daemon::PROTO || "HTTP/1.1";
$self->clever_syswrite($client,sprintf('%s %s %s%s',$proto,$status,$message,CRLF));
}
sub send_crlf
{
my $self = shift;
my $client = $self->{'daemon'}->{'server'}->{'client'};
$self->clever_syswrite($client,CRLF);
}
sub send_basic_header
{
my $self = shift;
my $client = $self->{'daemon'}->{'server'}->{'client'};
return if $self->antique_client;
$self->send_status_line(@_);
$self->clever_syswrite($client,sprintf('Date: %s%s',time2str(time), CRLF));
if ($self->{'daemon'}->{'_product_tokens'}) {
$self->clever_syswrite($client,sprintf('Server: %s%s', $self->{'daemon'}->{'_product_tokens'}, CRLF));
}
}
sub send_response
{
my ($self,$res) = @_;
my $client = $self->{'daemon'}->{'server'}->{'client'};
if (!ref $res) {
$res ||= RC_OK;
$res = HTTP::Response->new($res, @_);
}
my $content = $res->content;
my $chunked;
unless ($self->antique_client) {
my $code = $res->code;
$self->send_basic_header($code, $res->message, $res->protocol);
if ($code =~ /^(1\d\d|[23]04)$/) {
# make sure content is empty
$res->remove_header("Content-Length");
$content = "";
} elsif ($res->request && $res->request->method eq "HEAD") {
# probably OK
} elsif (ref($content) eq "CODE") {
if ($self->proto_ge("HTTP/1.1")) {
$res->push_header("Transfer-Encoding" => "chunked");
$chunked++;
} else {
$self->force_last_request;
}
} elsif (length($content)) {
$res->header("Content-Length" => length($content));
} else {
$self->force_last_request;
}
$self->clever_syswrite($client,$res->headers_as_string(CRLF));
# Separates headers and content
$self->send_crlf();
}
if (ref($content) eq "CODE") {
while (1) {
my $chunk = &$content();
last unless defined($chunk) && length($chunk);
if ($chunked) {
$self->clever_syswrite($client,sprintf('%x%s%s%s', length($chunk), CRLF, $chunk, CRLF));
} else {
$self->clever_syswrite($client,$chunk);
}
}
$self->clever_syswrite($client,sprintf('0%s%s',CRLF,CRLF)) if $chunked; # no trailers either
} elsif (length $content) {
# Write out content nicely...
my $remaining = length($content);
my $offset = 0;
while ($remaining) {
my $nwrite = $self->clever_syswrite($client,$content,($remaining < BUFFER_SIZE ? $remaining : BUFFER_SIZE),$offset);
# Check if something went wrong
if (!defined($nwrite)) {
$self->reason("Client closed");
last;
}
$remaining -= $nwrite;
$offset += $nwrite;
}
}
}
sub send_redirect
{
my($self, $loc, $status, $content) = @_;
my $client = $self->{'daemon'}->{'server'}->{'client'};
$status ||= RC_MOVED_PERMANENTLY;
Carp::croak("Status '$status' is not redirect") unless is_redirect($status);
$self->send_basic_header($status);
my $base = $self->{'daemon'}->{'config'}->{'url'};
$loc = URI->new($loc, $base) unless ref($loc);
$loc = $loc->abs($base);
$self->clever_syswrite($client,sprintf('Location: %s%s',$loc,CRLF));
if ($content) {
my $ct = $content =~ /^\s*</ ? "text/html" : "text/plain";
$self->clever_syswrite($client,sprintf('Content-Type: %s%s',$ct,CRLF));
}
$self->send_crlf();
$self->clever_syswrite($client,$content) if $content;
return $self->force_last_request; # no use keeping the connection open
}
sub send_error
{
my($self, $status, $error) = @_;
my $client = $self->{'daemon'}->{'server'}->{'client'};
$status ||= RC_BAD_REQUEST;
Carp::croak("Status '$status' is not an error") unless is_error($status);
my $mess = status_message($status);
$error ||= "";
$mess = <<EOT;
<title>$status $mess</title>
<h1>$status $mess</h1>
$error
EOT
unless ($self->antique_client) {
$self->send_basic_header($status);
$self->clever_syswrite($client,sprintf('Content-Type: text/html%s',CRLF));
$self->clever_syswrite($client,sprintf('Content-Length: %s%s',length($mess),CRLF));
$self->send_crlf();
}
$self->clever_syswrite($client,$mess);
return $status;
}
sub send_file_response
{
my($self, $file) = @_;
my $client = $self->{'daemon'}->{'server'}->{'client'};
if (-d $file) {
$self->send_dir($file);
} elsif (-f _) {
# plain file
local(*F);
sysopen(F, $file, 0) or
return $self->send_error(RC_FORBIDDEN);
binmode(F);
my($ct,$ce) = guess_media_type($file);
my($size,$mtime) = (stat _)[7,9];
unless ($self->antique_client) {
$self->send_basic_header;
$self->clever_syswrite($client,sprintf('Content-Type: %s%s',$ct,CRLF));
$self->clever_syswrite($client,sprintf('Content-Encoding: %s%s',$ce,CRLF)) if $ce;
$self->clever_syswrite($client,sprintf('Content-Length: %s%s',$size,CRLF)) if $size;
$self->clever_syswrite($client,sprintf('Last-Modified: %s%s',time2str($mtime),CRLF)) if $mtime;
$self->send_crlf();
}
$self->send_file(\*F);
return RC_OK;
} else {
$self->send_error(RC_NOT_FOUND);
}
}
sub send_dir
{
my($self, $dir) = @_;
$self->send_error(RC_NOT_FOUND) unless -d $dir;
$self->send_error(RC_NOT_IMPLEMENTED);
}
sub send_file
{
my($self, $file) = @_;
my $client = $self->{'daemon'}->{'server'}->{'client'};
my $opened = 0;
local(*$FH);
if (!ref($file)) {
open(my $FH,"r","< $file") || return;
binmode($FH);
$file = \*$FH;
$opened++;
}
my $cnt = 0;
my $buf = "";
my $n;
while ($n = sysread($file, $buf, BUFFER_SIZE)) {
last if !$n;
$cnt += $n;
syswrite($client,$buf);
}
close($file) if $opened;
return $cnt;
}
1;
# vim: ts=4
# Caching engine
# Copyright (C) 2009-2011, AllWorldIT
# Copyright (C) 2008, LinuxRulz
# Copyright (C) 2007 Nigel Kukard <nkukard@lbsd.net>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
package awitpt::cache;
use strict;
use warnings;
require Exporter;
our (@ISA,@EXPORT,@EXPORT_OK);
@ISA = qw(Exporter);
@EXPORT = qw(
cacheStoreKeyPair
cacheStoreComplexKeyPair
cacheGetKeyPair
cacheGetComplexKeyPair
);
@EXPORT_OK = qw(
getCacheHits
getCacheMisses
);
use Cache::FastMmap;
use Storable;
# Cache stuff
my $cache_type = "FastMmap";
my $cache;
# Our current error message
my $error = "";
## @internal
# @fn setError($err)
# This function is used to set the last error for this class
#
# @param err Error message
sub setError
{
my $err = shift;
my ($package,$filename,$line) = caller;
my (undef,undef,undef,$subroutine) = caller(1);
# Set error
$error = "$subroutine($line): $err";
}
## @internal
# @fn Error
# Return current error message
#
# @return Last error message
sub Error
{
my $err = $error;
# Reset error
$error = "";
# Return error
return $err;
}
## @fn Init($server)
# Initialize cache
#
# @param server Server object
# @param params Parameters for the cache
# @li cache_file Filename of the cache file
# @li cache_file_user Owner of the cache file
# @li cache_file_group Group of the cache file
sub Init
{
my ($server,$params) = @_;
my $ch;
# We going to pass these options to new()
my %opt = (
'page_size' => 2048,
'num_pages' => 1000,
'expire_time' => 300,
'raw_values' => 1,
'unlink_on_exit' => 1,
);
# Check if we have the optional $params
if (defined($params)) {
# If we have a special cache file, use it and init it too
if (defined($params->{'cache_file'})) {
$opt{'share_file'} = $params->{'cache_file'};
$opt{'init_file'} = 1;
}
}
# Create Cache
$ch = Cache::FastMmap->new(%opt);
# Check if we have the optional $params
if (defined($params)) {
# If we have an explicit owner set, use it
if (defined($params->{'cache_file_user'})) {
# Check all is ok...
my ($chown_user,$chown_group);
if (!($chown_user = getpwnam($params->{'cache_file_user'}))) {
setError("User '$chown_user' appears to be invalid: $?");
return(-1);
}
if (!($chown_group = getgrnam($params->{'cache_file_group'}))) {
setError("Group '$chown_group' appears to be invalid: $?");
return(-1);
}
# Go in and chown it
if (!chown($chown_user,$chown_group,$opt{'share_file'})) {
setError("Failed to chown cache file '".$opt{'share_file'}."': $!");
return(-1);
}
}
}
# Stats
$ch->set('Cache/Stats/Hit',0);
$ch->set('Cache/Stats/Miss',0);
# Set server vars
$server->{'cache_engine'}{'handle'} = $ch;
};
## @fn Destroy()
# Destroy cache
#
# @param server Server object
sub Destroy
{
};
## @fn connect($server)
# Connect server with the cache
#
# @param server Server object
sub connect
{
my $server = shift;
$cache = $server->{'cache_engine'}{'handle'};
}
## @fn disconnect()
# Disconnect cache from server
#
# @param server Server object
sub disconnect
{
}
## @fn cacheStoreKeyPair($cacheName,$key,$value)
# Store keypair in cache
#
# @param cacheName Cache name to use
# @param key Item key
# @param value Item value
sub cacheStoreKeyPair
{
my ($cacheName,$key,$value) = @_;
if (!defined($cacheName)) {
setError("Cache name not defined in store");
return -1;
}
if ($cacheName eq "") {
setError("Cache name not set in store");
return -1;
}
if (!defined($key)) {
setError("Key not defined for cache '$cacheName' store");
return -1;
}
if (!defined($value)) {
setError("Value not defined for cache '$cacheName' key '$key' store");
return -1;
}
# If we're not caching just return
return 0 if ($cache_type eq 'none');
# Store
$cache->set("$cacheName/$key",$value);
return 0;
}
## @fn cacheGetKeyPair($cacheName,$key)
# Get value from cache
#
# @param cacheName Cache name to use
# @param key Item key
sub cacheGetKeyPair
{
my ($cacheName,$key) = @_;
if (!defined($cacheName)) {
setError("Cache name not defined in get");
return (-1);
}
if ($cacheName eq "") {
setError("Cache name not set in get");
return (-1);
}
if (!defined($key)) {
setError("Key not defined for cache '$cacheName' get");
return (-1);
}
# If we're not caching just return
if ($cache_type eq 'none') {
return (0,undef);
}
# Check and count
my $res = $cache->get("$cacheName/$key");
if ($res) {
$cache->get_and_set('Cache/Stats/Hit',sub { return ++$_[1]; });
} else {
$cache->get_and_set('Cache/Stats/Miss',sub { return ++$_[1]; });
}
return (0,$res);
}
## @fn cacheStoreComplexKeyPair($cacheName,$key,$value)
# Store a complex keypair in cache, this would be an object and
# not a number or text
#
# @param cacheName Cache name to use
# @param key Item key
# @param value Item value
sub cacheStoreComplexKeyPair
{
my ($cacheName,$key,$value) = @_;
my $rawValue = Storable::freeze($value);
if (!defined($rawValue)) {
setError("Unable to freeze cache value in '$cacheName'");
return -1;
}
return cacheStoreKeyPair($cacheName,$key,$rawValue);
}
## @fn cacheGetComplexKeyPair($cacheName,$key)
# Get value from cache
#
# @param cacheName Cache name to use
# @param key Item key
sub cacheGetComplexKeyPair
{
my ($cacheName,$key) = @_;
my ($res,$rawValue) = cacheGetKeyPair($cacheName,$key);
# Thaw out item, if there is no error and we are defined
if (!$res && defined($rawValue)) {
$rawValue = Storable::thaw($rawValue);
}
return ($res,$rawValue);
}
## @fn getCacheHits
# Return cache hits
#
# @return Cache hits
sub getCacheHits
{
my $res;
# Get counter
$res = defined($cache->get('Cache/Stats/Hit')) ? $cache->get('Cache/Stats/Hit') : 0;
return $res;
}
## @fn getCacheMisses
# Return cache misses
#
# @return Cache misses
sub getCacheMisses
{
my $res;
# Get counter
$res = defined($cache->get('Cache/Stats/Miss')) ? $cache->get('Cache/Stats/Miss') : 0;
return $res;
}
1;
# vim: ts=4
# Database independent layer module
# Copyright (C) 2009-2014, AllWorldIT
# Copyright (C) 2008, LinuxRulz
# Copyright (C) 2005-2007 Nigel Kukard <nkukard@lbsd.net>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
## @class awit::db::dbilayer
# Database independant layer module. This module encapsulates the DBI
# module and provides us with some tweaked functionality
package awitpt::db::dbilayer;
use strict;
use warnings;
use DBI;
# Our current error message
my $error = "";
## @internal
# @fn setError($err)
# This function is used to set the last error for this class
#
# @param err Error message
sub setError
{
my $err = shift;
my ($package,$filename,$line) = caller;
my (undef,undef,undef,$subroutine) = caller(1);
# Set error
$error = "$subroutine($line): $err";
}
## @fn internalError
# Return current module error message
#
# @return Last module error message
sub internalError
{
my $err = $error;
# Reset error
$error = "";
# Return error
return $err;
}
## @member Error
# Return current object error message
#
# @return Current object error message
sub Error
{
my $self = shift;
my $err = $self->{_error};
# Reset error
$self->{_error} = "";
# Return error
return $err;
}
## @fn Init($server,$server_name)
# Initialize class and return a fully connected object
#
# @param server Server object
# @param server_name Name of server
#
# @return dbilayer object, undef on error
sub Init
{
my ($server,$server_name) = @_;
if (!defined($server)) {
setError("Server object undefined");
return;
}
if (!defined($server_name)) {
setError("Server name undefined");
return;
}
my $dbconfig = $server->{$server_name}->{'database'};
# Check if we created
my $dbh = awitpt::db::dbilayer->new($dbconfig);
return if (!defined($dbh));
return $dbh;
}
## @member new($dsn,$username,$password)
# Class constructor
#
# @param settings Database settings hashref
# @li DSN Data source name
# @li Username Username to use
# @li Password Password to use
# @li TablePrefix Table prefix
# @li IgnoreTransactions Flag to ignore transactions
# @li SQLiteJournalMode SQLite: set journal mode
# @li SQLiteCacheSize SQLite: set cache size
# @li SQLiteSynchronous SQLite: set synchronous mode
#
# @return Constructed object, undef on error
sub new
{
my ($class,$settings) = @_;
# Check if we were given settings
if (!defined($settings)) {
setError("No database settings given");
}
# Iternals
my $self = {
_type => undef,
_dbh => undef,
_error => undef,
_dsn => undef,
_username => undef,
_password => undef,
_table_prefix => "",
_in_transaction => undef,
};
# Set database parameters
if (defined($settings->{'DSN'})) {
$self->{_dsn} = $settings->{'DSN'};
$self->{_username} = $settings->{'Username'};
$self->{_password} = $settings->{'Password'};
$self->{_table_prefix} = $settings->{'TablePrefix'} || "";
$self->{transactions_ignore} = $settings->{'IgnoreTransactions'};
$self->{'sqlite_journal_mode'} = $settings->{'SQLiteJournalMode'};
$self->{'sqlite_cache_size'} = $settings->{'SQLiteCacheSize'};
$self->{'sqlite_synchronous'} = $settings->{'SQLiteSynchronous'};
} else {
setError("No DSN provided");
return;
}
# Try grab database type
$self->{_dsn} =~ /^DBI:([^:]+):/i;
$self->{_type} = (defined($1) && $1 ne "") ? lc($1) : "unknown";
# Create...
bless $self, $class;
return $self;
}
## @member connect(@params)
# Return connection to database
#
# @param params DBI parameters
#
# @return 0 on success, < 0 on error
sub connect
{
my $self = shift;
$self->{_dbh} = DBI->connect($self->{_dsn}, $self->{_username}, $self->{_password}, {
'AutoCommit' => 1,
'PrintError' => 0,
'RaiseError' => 0,
'FetchHashKeyName' => 'NAME_lc'
});
# Connect to database if we have to, check if we ok
if (!$self->{_dbh}) {
$self->{_error} = "Error connecting to database: $DBI::errstr";
return -1;
}
# Apon connect we are not in a transaction
$self->{_in_transaction} = 0;
# Check for SQLite options
if ($self->{_type} eq "sqlite") {
# Check for journal mode
if (defined($self->{'sqlite_journal_mode'})) {
if (!$self->do("PRAGMA journal_mode = ".$self->{'sqlite_journal_mode'})) {
return -1;
}
}
# Check for cache size
if (defined($self->{'sqlite_cache_size'})) {
if (!$self->do("PRAGMA cache_size = -".$self->{'sqlite_cache_size'})) {
return -1;
};
}
# Check for synchronous setting
if (defined($self->{'sqlite_synchronous'})) {
if (!$self->do("PRAGMA synchronous = ".$self->{'sqlite_synchronous'})) {
return -1;
}
}
}
return 0;
}
## @member type
# Return database type
#
# @return Database type string
sub type
{
my $self = shift;
return $self->{_type};
}
## @member _check
# Check database connection and reconnect if we lost the connection
sub _check
{
my $self = shift;
# DB is disconnected if _dbh is not defined
if (!defined($self->{_dbh})) {
goto RECONNECT;
}
# Try ping
if (!$self->{_dbh}->ping()) {
# If we not in a transaction try connect
if ($self->{_in_transaction} == 0) {
# Disconnect & reconnect
$self->{_dbh}->disconnect();
goto RECONNECT;
}
$self->{_error} = "Cannot reconnect to DB while inside transaction";
return -1;
}
return 0;
RECONNECT:
return $self->connect();
}
## @member select($query)
# Return database selection results...
#
# @param query SQL query
#
# @return DBI statement handle object, undef on error
sub select
{
my ($self,$query,@params) = @_;
if ($self->_check()) {
return;
}
# Prepare query
my $sth;
if (!($sth = $self->{_dbh}->prepare($query))) {
$self->{_error} = $self->{_dbh}->errstr;
return;
}
# Check for execution error
if (!$sth->execute(@params)) {
$self->{_error} = $self->{_dbh}->errstr;
return;
}
return $sth;
}
## @member do($command)
# Perform a command
#
# @param command Command to execute
#
# @return DBI statement handle object, undef on error
sub do
{
my ($self,$command,@params) = @_;
if ($self->_check()) {
return;
}
# # Build single command instead of using binding of params
# # not all databases support binding, and not all support all
# # the places we use ?
# $command =~ s/\?/%s/g;
# # Map each element in params to the quoted value
# $command = sprintf($command,
# map { $self->quote($_) } @params
# );
#use Data::Dumper; print STDERR Dumper($command);
# Prepare query
my $sth;
# if (!($sth = $self->{_dbh}->do($command))) {
if (!($sth = $self->{_dbh}->do($command,undef,@params))) {
$self->{_error} = $self->{_dbh}->errstr;
return;
}
return $sth;
}
## @method lastInsertID($table,$column)
# Function to get last insert id
#
# @param table Table last entry was inserted into
# @param column Column we want the last value for
#
# @return Last inserted ID, undef on error
sub lastInsertID
{
my ($self,$table,$column) = @_;
if ($self->_check()) {
return;
}
# Get last insert id
my $res;
if (!($res = $self->{_dbh}->last_insert_id(undef,undef,$table,$column))) {
$self->{_error} = $self->{_dbh}->errstr;
return;
}
return $res;
}
## @method begin
# Function to begin a transaction
#
# @return 1 on success, undef on error
sub begin
{
my $self = shift;
if ($self->_check()) {
return;
}
$self->{_in_transaction}++;
# Don't really start transaction if we more than 1 deep
if ($self->{_in_transaction} > 1) {
return 1;
}
# Check if we need to ignore transactions
if ($self->{transactions_ignore}) {
return 1;
}
# Begin
my $res;
if (!($res = $self->{_dbh}->begin_work())) {
$self->{_error} = $self->{_dbh}->errstr;
return;
}
return $res;
}
## @method commit
# Function to commit a transaction
#
# @return DBI layer result, or 1 on deep transaction commit
sub commit
{
my $self = shift;
if ($self->_check()) {
return;
}
# Reduce level
$self->{_in_transaction}--;
# If we not at top level, return success
if ($self->{_in_transaction} > 0) {
return 1;
}
# Reset transaction depth to 0
$self->{_in_transaction} = 0;
# Check if we need to ignore transactions
if ($self->{transactions_ignore}) {
return 1;
}
# Commit
my $res;
if (!($res = $self->{_dbh}->commit())) {
$self->{_error} = $self->{_dbh}->errstr;
return;
}
return $res;
}
## @method rollback
# Function to rollback a transaction
#
# @return DBI layer result or 1 on deep transaction
sub rollback
{
my $self = shift;
if ($self->_check()) {
$self->{_in_transaction}--;
return;
}
# If we at top level, return success
if ($self->{_in_transaction} < 1) {
return 1;
}
$self->{_in_transaction} = 0;
# Check if we need to ignore transactions
if ($self->{transactions_ignore}) {
return 1;
}
# Rollback
my $res;
if (!($res = $self->{_dbh}->rollback())) {
$self->{_error} = $self->{_dbh}->errstr;
return;
}
return $res;
}
## @method quote($variable)
# Function to quote a database variable
#
# @param variable Variable to quote
#
# @return Quoted variable
sub quote
{
my ($self,$variable) = @_;
return $self->{_dbh}->quote($variable);
}
## @method free($sth)
# Function to cleanup DB query
#
# @param sth DBI statement handle
sub free
{
my ($self,$sth) = @_;
if ($sth) {
$sth->finish();
}
}
# Function to return the table prefix
sub table_prefix
{
my $self = shift;
return $self->{_table_prefix};
}
1;
# vim: ts=4
# Common database layer module
# Copyright (C) 2009-2014, AllWorldIT
# Copyright (C) 2008, LinuxRulz
# Copyright (C) 2005-2007 Nigel Kukard <nkukard@lbsd.net>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
## @class awitpt::db::dblayer
# Database layer module which makes life a bit esier
package awitpt::db::dblayer;
use strict;
use warnings;
# Exporter stuff
require Exporter;
our (@ISA,@EXPORT);
@ISA = qw(Exporter);
@EXPORT = qw(
DBInit
DBConnect
DBSelect
DBDo
DBLastInsertID
DBBegin
DBCommit
DBRollback
DBQuote
DBFreeRes
DBSelectNumResults
DBSelectSearch
hashifyLCtoMC
);
use POSIX qw( strftime );
use Date::Parse;
use awitpt::db::dbilayer;
# Database handle
my $dbh = undef;
# Our current error message
my $error = "";
## @internal
# @fn setError($err)
# This function is used to set the last error for this class
#
# @param err Error message
sub setError
{
my $err = shift;
my ($package,$filename,$line) = caller;
my (undef,undef,undef,$subroutine) = caller(1);
# Set error
$error = "$subroutine($line): $err";
}
## @internal
# @fn Error
# Return current error message
#
# @return Last error message
sub Error
{
my $err = $error;
# Reset error
$error = "";
# Return error
return $err;
}
## @fn DBInit($dbconfig)
# Initialize the database for use
#
# @param DSN Database DSN
# @li DSN - Database DSN
# @li Username - Optional database username
# @li Password - Optional database password
# @li TablePrefix - Optional database table prefix
sub DBInit
{
my $dbconfig = shift;
if (!defined($dbconfig)) {
setError("The dbconfig hash is not defined");
return;
}
if (ref($dbconfig) ne "HASH") {
setError("The dbconfig option is not a hash");
return;
}
if (!defined($dbconfig->{'DSN'})) {
setError("The dbconfig hash does not contain 'DSN'");
return;
}
# Check if we created
$dbh = awitpt::db::dbilayer->new($dbconfig);
return $dbh;
}
## @fn DBInit($dbconfig)
# Initialize the database for use
#
sub DBConnect
{
my $res;
if ($res = $dbh->connect()) {
setError($dbh->Error());
}
return $res;
}
## @fn setHandle($handle)
# Initialize database handle
#
# @param handle Set internal database handle we use
sub setHandle
{
my $handle = shift;
$dbh = $handle;
}
## @fn DBSelect($query,@params)
# Return database selection results...
#
# @param query Query to run
#
# @return DBI statement handle, undef on error
sub DBSelect
{
my ($query,@params) = @_;
my $table_prefix = $dbh->table_prefix();
# Replace table prefix macro
$query =~ s/\@TP\@/$table_prefix/g;
# Prepare query
my $sth;
if (!($sth = $dbh->select($query,@params))) {
setError("Error executing select: ".$dbh->Error());
return;
}
return $sth;
}
## @fn DBDo($command)
# Perform a command
#
# @param command Command to run
#
# @return DBI statement handle, undef on error
sub DBDo
{
my (@params) = @_;
my $table_prefix = $dbh->table_prefix();
# Check type of params we have
if (ref($params[0]) eq 'HASH') {
my $queryHash = $params[0];
my $dbType = $dbh->type();
# Check DB type is defined, if not use *
if (defined($queryHash->{$dbType})) {
@params = @{$queryHash->{$dbType}};
} elsif (defined($queryHash->{'*'})) {
@params = @{$queryHash->{'*'}};
} else {
setError("Error executing, database type in query not fund and no '*' query found");
return;
}
}
# Grab command and data
my $command = shift(@params);
my @data = @params;
# Replace table prefix macro
$command =~ s/\@TP\@/$table_prefix/g;
# Prepare query
my $sth;
if (!($sth = $dbh->do($command,@data))) {
# Remove newlines...
$command =~ s/(\n|\s{2,})/ /g;
setError("Error executing command '$command': ".$dbh->Error());
return;
}
return $sth;
}
## @fn DBLastInsertID($table,$column)
# Function to get last insert id
#
# @param table Table to check
# @param column Column to get last insert on
#
# @return Last insert ID or undef on error
sub DBLastInsertID
{
my ($table,$column) = @_;
my $res;
if (!($res = $dbh->lastInsertID(undef,undef,$table,$column))) {
setError("Error getting last inserted id: ".$dbh->Error());
return;
}
return $res;
}
## @fn DBBegin
# Function to begin a transaction
#
# @return 1 on success, undef on error
sub DBBegin
{
my $res;
if (!($res = $dbh->begin())) {
setError("Error beginning transaction: ".$dbh->Error());
return;
}
return $res;
}
## @fn DBCommit
# Function to commit a transaction
#
# @return 1 on success, undef on error
sub DBCommit
{
my $res;
if (!($res = $dbh->commit())) {
setError("Error committing transaction: ".$dbh->Error());
return;
}
return $res;
}
## @fn DBRollback
# Function to rollback a transaction
#
# @return 1 on success, undef on error
sub DBRollback
{
my $res;
if (!($res = $dbh->rollback())) {
setError("Error rolling back transaction: ".$dbh->Error());
return;
}
return $res;
}
## @fn DBQuote($variable)
# Function to quote a database variable
#
# @param variable Variable to quote
#
# @return Quoted variable
sub DBQuote
{
my $variable = shift;
return $dbh->quote($variable);
}
## @fn DBFreeRes($sth)
# Function to cleanup DB query
#
# @param sth Statement handle to cleanup
sub DBFreeRes
{
my $sth = shift;
if ($sth) {
$sth->finish();
}
}
# Function to get table prefix
sub DBTablePrefix
{
return $dbh->table_prefix();
}
#
# Value Added Functions
#
## @fn DBSelectNumResults($query)
# Return how many results came up from the specific SELECT query
#
# @param query Query to perform, minus "SELECT COUNT(*) AS num_results"
#
# @return Number of results, undef on error
sub DBSelectNumResults
{
my $query = shift;
# Prepare query
my $sth;
if (!($sth = $dbh->select("SELECT COUNT(*) AS num_results $query"))) {
setError("Error executing select: ".$dbh->Error());
return;
}
# Grab row
my $row = $sth->fetchrow_hashref();
if (!defined($row)) {
setError("Failed to get results from a select: ".$dbh->Error());
return;
}
# Pull number
my $num_results = $row->{'num_results'};
$sth->finish();
return $num_results;
}
## @fn DBSelectSearch($query,$search,$filters,$sorts)
# Select results from database and return the total number aswell
#
# @param query Base query
#
# @param search Search hash ref
# @li Filter - Filter based on this...
# [filter] => Array (
# [0] => Array (
# [field] => Name
# [data] => Array (
# [type] => string
# [value] => hi there
# )
# )
# )
# { 'data' => { 'comparison' => 'gt', 'value' => '5', 'type' => 'numeric' }, 'field' => 'ID' }
# @li Start - Start item number, indexed from 0 onwards
# @li Limit - Limit number of results
# @li Sort - Sort by this item
# @li SortDirection - Sort in this direction, either ASC or DESC
#
# @param filters Filter hash ref
# Hash: 'Column' -> 'Table.DBColumn'
#
# @param sorts Hash ref of valid sort criteria, indexed by what we get, pointing to the DB column in the query
# Hash: 'Column' -> 'Table.DBColumn'
#
# @return Number of results, undef on error
sub DBSelectSearch
{
my ($query,$search,$filters,$sorts) = @_;
# Stuff we need to add to the SQL query
my @where; # Where clauses
my $sqlWhere = "";
my $sqlLimit = "";
my $sqlOffset = "";
my $sqlOrderBy = "";
my $sqlOrderByDirection = "";
# Check if we're searching
if (defined($search) && ref($search)) {
# Check it is a hash
if (ref($search) ne "HASH") {
setError("Parameter 'search' is not a hashtable");
return (undef,-1);
}
# Check if we need to filter
if (defined($search->{'Filter'})) {
# We need filters in order to use filtering
if (!defined($filters)) {
setError("Parameter 'search' element 'Filter' requires 'filters' to be defined");
return (undef,-1);
}
# Check type of Filter
if (ref($search->{'Filter'}) ne "ARRAY") {
setError("Parameter 'search' element 'Filter' is of invalid type, it must be an ARRAY'");
return (undef,-1);
}
# Loop with filters
foreach my $item (@{$search->{'Filter'}}) {
my $data = $item->{'data'}; # value, type, comparison
my $field = $item->{'field'};
my $column = $filters->{$field};
# Check if field is in our allowed filters
if (!defined($filters->{$field})) {
setError("Parameter 'search' element 'Filter' has invalid field item '$field' according to 'filters'");
return (undef,-1);
}
# Check data
if (!defined($data->{'type'})) {
setError("Parameter 'search' element 'Filter' requires field data element 'type' for field '$field'");
return (undef,-1);
}
if (!defined($data->{'value'})) {
setError("Parameter 'search' element 'Filter' requires field data element 'value' for field '$field'");
return (undef,-1);
}
# match =, LIKE, IN (
# matchEnd '' or )
my $match;
my $matchEnd = "";
# value is the DBQuote()'d value
my $value;
# Check what type of comparison
if ($data->{'type'} eq "boolean") {
$match = '=';
$value = DBQuote($data->{'value'});
} elsif ($data->{'type'} eq "date") {
# The comparison type must be defined
if (!defined($data->{'comparison'})) {
setError("Parameter 'search' element 'Filter' requires field data element 'comparison' for date field ".
"'$field'");
return (undef,-1);
}
# Check comparison type
if ($data->{'comparison'} eq "gt") {
$match = ">";
} elsif ($data->{'comparison'} eq "lt") {
$match = "<";
} elsif ($data->{'comparison'} eq "eq") {
$match = "=";
} elsif ($data->{'comparison'} eq "ge") {
$match = ">=";
} elsif ($data->{'comparison'} eq "le") {
$match = "<=";
}
# Convert to ISO format
my $unixtime = str2time($data->{'value'});
my @d = localtime($unixtime);
$value = DBQuote(sprintf("%4d-%02d-%02d", $d[5]+1900, $d[4]+1, $d[3]));
} elsif ($data->{'type'} eq "list") {
# Quote all values
my @valueList;
foreach my $i (split(/,/,$data->{'value'})) {
push(@valueList,DBQuote($i));
}
$match = "IN (";
# Join up 'xx','yy','zz'
$value = join(',',@valueList);
$matchEnd = ")";
} elsif ($data->{'type'} eq "numeric") {
# The comparison type must be defined
if (!defined($data->{'comparison'})) {
setError("Parameter 'search' element 'Filter' requires field data element 'comparison' for numeric field ".
"'$field'");
return (undef,-1);
}
# Check comparison type
if ($data->{'comparison'} eq "gt") {
$match = ">";
} elsif ($data->{'comparison'} eq "lt") {
$match = "<";
} elsif ($data->{'comparison'} eq "eq") {
$match = "=";
} elsif ($data->{'comparison'} eq "ge") {
$match = ">=";
} elsif ($data->{'comparison'} eq "le") {
$match = "<=";
}
$value = DBQuote($data->{'value'});
} elsif ($data->{'type'} eq "string") {
$match = "LIKE";
$value = DBQuote("%".$data->{'value'}."%");
}
# Add to list
push(@where,"$column $match $value $matchEnd");
}
# Check if we have any WHERE clauses to add ...
if (@where > 0) {
# Check if we have WHERE clauses in the query
if ($query =~ /\sWHERE\s/i) {
# If so start off with AND
$sqlWhere .= "AND ";
} else {
$sqlWhere = "WHERE ";
}
$sqlWhere .= join(" AND ",@where);
}
}
# Check if we starting at an OFFSET
if (defined($search->{'Start'})) {
# Check if Start is valid
if ($search->{'Start'} < 0) {
setError("Parameter 'search' element 'Start' invalid value '".$search->{'Start'}."'");
return (undef,-1);
}
$sqlOffset = sprintf("OFFSET %i",$search->{'Start'});
}
# Check if results will be LIMIT'd
if (defined($search->{'Limit'})) {
# Check if Limit is valid
if ($search->{'Limit'} < 1) {
setError("Parameter 'search' element 'Limit' invalid value '".$search->{'Limit'}."'");
return (undef,-1);
}
$sqlLimit = sprintf("LIMIT %i",$search->{'Limit'});
}
# Check if we going to be sorting
if (defined($search->{'Sort'})) {
# We need sorts in order to use sorting
if (!defined($sorts)) {
setError("Parameter 'search' element 'Filter' requires 'filters' to be defined");
return (undef,-1);
}
# Check if sort is defined
if (!defined($sorts->{$search->{'Sort'}})) {
setError("Parameter 'search' element 'Sort' invalid item '".$search->{'Sort'}."' according to 'sorts'");
return (undef,-1);
}
# Build ORDER By
$sqlOrderBy = "ORDER BY ".$sorts->{$search->{'Sort'}};
# Check for sort ORDER
if (defined($search->{'SortDirection'})) {
# Check for valid directions
if (lc($search->{'SortDirection'}) eq "asc") {
$sqlOrderByDirection = "ASC";
} elsif (lc($search->{'SortDirection'}) eq "desc") {
$sqlOrderByDirection = "DESC";
} else {
setError("Parameter 'search' element 'SortDirection' invalid value '".$search->{'SortDirection'}."'");
return (undef,-1);
}
}
}
}
# Select row count, pull out "SELECT .... " as we replace this in the NumResults query
(my $queryCount = $query) =~ s/^\s*SELECT\s.*\sFROM/FROM/is;
my $numResults = DBSelectNumResults("$queryCount $sqlWhere");
if (!defined($numResults)) {
return;
}
# Add Start, Limit, Sort, Direction
my $sth = DBSelect("$query $sqlWhere $sqlOrderBy $sqlOrderByDirection $sqlLimit $sqlOffset");
if (!defined($sth)) {
return;
}
return ($sth,$numResults);
}
# Convert a lower case array to mixed case
sub hashifyLCtoMC
{
my ($record,@entries) = @_;
# If we undefined, return
return if (!defined($record));
my $res;
# Loop with each item, assign from lowecase database record to our result
foreach my $entry (@entries) {
$res->{$entry} = $record->{lc($entry)};
}
return $res;
}
1;
# vim: ts=4
# Network IP Address Handling
# Copyright (C) 2009-2014, AllWorldIT
# Copyright (C) 2008, LinuxRulz
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# * * *
# 2014-03-14: Portions of this are derived from ideas and code in Net::Subnet
# - Nigel Kukard <nkukard@lbsd.net>
# 2009-12-03: Portions of this are derived from ideas and code in Net::IP
# - Robert Anderson <randerson@lbsd.net>
# * * *
package awitpt::netip;
use strict;
use warnings;
use Socket qw(inet_aton);
use Socket6 qw(inet_pton AF_INET6);
# Our current error message
my $error = "";
sub setError
{
my $err = shift;
my ($package,$filename,$line) = caller;
my (undef,undef,undef,$subroutine) = caller(1);
# Set error
$error = "$subroutine($line): $err";
}
sub Error
{
my $err = $error;
# Reset error
$error = "";
# Return error
return $err;
}
# Create object
sub new
{
my ($type,$ip) = @_;
# Make sure IP is defined
if (!defined($ip)) {
setError("IP address not defined");
}
my $self = {};
# Check if this is an IPv4 to IPv6 mapping
if ($ip =~ /\:ffff\:(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/i) {
# Grab the IP
$ip = $1;
}
# Guess ip version
if ($ip =~ /:/) {
$self->{'ip_version'} = 6;
} elsif (($ip =~ /\./) || ($ip =~ /^\d{1,3}(\/\d{1,2})?$/)) {
$self->{'ip_version'} = 4;
} else {
setError("Failed to guess IP address version");
return;
}
$self->{'raw_ip'} = $ip;
# Instantiate object
bless($self,$type);
# Clean the raw IP
if (!$self->_clean_ip()) {
return;
}
return $self;
}
# Clone an object
sub copy
{
my $self = shift;
my %params = @_;
my $clone = bless({
'ip_version' => $self->{'ip_version'},
'ip' => $self->{'ip'},
'cidr' => defined($params{'cidr'}) ? $params{'cidr'} : $self->{'cidr'}
}, ref($self));
return $clone;
}
# Convert to binary
sub to_bin
{
my $self = shift;
# We already have it in bin
return $self->{'ip_bin'} if ($self->{'ip_bin'});
# Check how to convert to bin
if ($self->{'ip_version'} == 6) {
my $cleanIP = $self->{'ip'};
$cleanIP =~ s/://g;
$self->{'ip_bin'} = unpack('B128', pack('H32', $cleanIP));
} elsif ($self->{'ip_version'} == 4) {
$self->{'ip_bin'} = unpack('B32', pack('C4C4C4C4', split(/\./, $self->{'ip'})));
}
return $self->{'ip_bin'};
}
# Convert to string
sub to_str
{
my ($self,$bin) = @_;
# We can only add the cidr suffix if we are working on $self
my $suffix = "";
# Allow us to use a parameter as the bin to convert aswell, if none provided, use self
if (!defined($bin)) {
$bin = $self->to_bin();
$suffix = "/".$self->{'cidr'};
}
# Convert to string format
my $resIP;
if (length($bin) == 32) {
$resIP = join '.', unpack('C4C4C4C4', pack('B32', $bin));
} elsif (length($bin) == 128) {
$resIP = join(':', unpack('H4H4H4H4H4H4H4H4', pack('B128', $bin)));
}
return $resIP.$suffix;
}
# Get the network address
sub to_network
{
my $self = shift;
if (!defined($self->{'network_bin'})) {
$self->_calc_ranges();
}
$self->{'ip'} = $self->to_str($self->{'network_bin'});
$self->{'ip_bin'} = undef;
return $self;
}
# Internal function to convert v4 CIDR into bitmask
sub _cidr2mask_v4 {
my $self = shift;
return pack "N", 0xffffffff << (32 - $self->{'cidr'});
}
# Internal function to convert v6 CIDR into bitmask
sub _cidr2mask_v6 {
my $self = shift;
return pack('B128', '1' x $self->{'cidr'});
}
# Function to match an v4 address
sub _ipv4_matcher {
no locale;
my ($self,$test) = @_;
my $mask = $test->_cidr2mask_v4();
# Make sure we return 1 or 0, not "" for failure
return ((inet_aton($test->{'ip'}) & $mask) eq (inet_aton($self->{'ip'}) & $mask)) ? 1 : 0;
}
# Function to match an v6 address
sub _ipv6_matcher {
no locale;
my ($self,$test) = @_;
my $mask = $test->_cidr2mask_v6();
# Make sure we return 1 or 0, not "" for failure
return ((inet_pton(AF_INET6,$test->{'ip'}) & $mask) eq (inet_pton(AF_INET6, $self->{'ip'}) & $mask)) ? 1 : 0;
}
# Check if ip address is inside another ip address range
sub is_within
{
my ($self,$test) = @_;
# We can only compare IPs of same type
if ($self->{'ip_version'} != $test->{'ip_version'}) {
return;
}
# Check which matcher to use
if ($self->{'ip_version'} == 4) {
return $self->_ipv4_matcher($test);
} elsif ($self->{'ip_version'} == 6) {
return $self->_ipv6_matcher($test);
}
return;
}
# Check for a valid ipv6/ipv4 address
sub is_valid
{
my $ip = shift;
# Check if defined
if (!defined($ip)) {
return 0;
}
# Check for valid IPv4 address
if ($ip =~ /^(\d{1,3})(?:\.(\d{1,3})(?:\.(\d{1,3})(?:\.(\d{1,3}))?)?)?(?:\/(\d{1,2}))?$/) {
# Check octets are within limits
foreach ($1,$2,$3,$4) {
if (defined($_)) {
if ($_ > 255 || $_ < 0) {
return 0;
}
}
}
# Check bitmask is within limits
if (defined($5)) {
if ($5 > 32 || $5 < 1) {
return 0;
}
}
# Check for valid IPv6 address
} elsif ($ip =~ /:/) {
# Pull off and check bitmask
if ($ip =~ s/\/(\d{1,3})$//g) {
if ($1 > 128 || $1 < 1) {
return 0;
}
}
# Check for illegal characters
if (!($ip =~ /^[a-f\d:]+$/i)) {
return 0;
}
# Does the IP address have more than one '::' pattern ?
my $count = 0;
while ($ip =~ /::/g) {
$count++;
}
if ($count > 1) {
return 0;
}
# Count octets
my $n = ($ip =~ tr/:/:/);
if (!($n > 0 and $n < 8)) {
return 0;
}
# Check octets
foreach (split /:/, $ip) {
# Empty octet ?
next if ($_ eq '');
# Normal v6 octet ?
next if (/^[a-f\d]{1,4}$/i);
return 0;
}
# Do not recognise
} else {
return 0;
}
return 1;
}
# Check the IP address and format accordingly
sub _clean_ip
{
my $self = shift;
if ($self->{'ip_version'} == 4) {
# Pull off mask
my $mask;
if ($self->{'raw_ip'} =~ s/\/(\d{1,2})$//g) {
$mask = defined($1) ? $1 : undef;
}
# Check for invalid chars
if (!($self->{'raw_ip'} =~ m/^[\d\.]+$/)) {
setError("IPv4 address '".$self->{'raw_ip'}."' contains invalid characters");
return 0;
}
# Check for leading .
if ($self->{'raw_ip'} =~ m/^\./) {
setError("IPv4 address '".$self->{'raw_ip'}."' begins with '.'");
return 0;
}
# Check for trailing .
if ($self->{'raw_ip'} =~ m/\.$/) {
setError("IPv4 address '".$self->{'raw_ip'}."' ends with '.'");
return 0;
}
# Expand address
if ($self->{'raw_ip'} =~ /^(\d{1,3})(?:\.(\d{1,3})(?:\.(\d{1,3})(?:\.(\d{1,3}))?)?)?$/) {
# Strip ip components from string
my ($a,$b,$c,$d) = ($1,$2,$3,$4);
# Check for invalid octets
foreach my $octet ($a,$b,$c,$d) {
if (defined($octet) && $octet > 255) {
setError("IPv4 address '".$self->{'raw_ip'}."' contains octets which exceed 255");
return 0;
}
}
# Set undefined octets and mask if missing
if (!defined($b)) {
$b = 0;
$mask = 8 if !defined($mask);
}
if (!defined($c)) {
$c = 0;
$mask = 16 if !defined($mask);
}
if (!defined($d)) {
$d = 0;
$mask = 24 if !defined($mask);
}
# Default mask
$mask = ( defined($mask) && $mask >= 0 && $mask <= 32 ) ? $mask : 32;
$self->{'cidr'} = $mask;
# Build ip
$self->{'ip'} = "$a.$b.$c.$d";
# Check for full ipv4
if (!($self->{'ip'} =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/)) {
setError("IPv4 address '".$self->{'ip'}."' is not a full ipv4 address");
return 0;
}
} else {
setError("IP address '".$self->{'raw_ip'}."' is not a supported format");
return 0;
}
} elsif ($self->{'ip_version'} == 6) {
# Pull off mask
my $mask;
if ($self->{'raw_ip'} =~ s/\/(\d{1,3})$//g) {
$mask = defined($1) ? $1 : undef;
}
# Count octets
my $n = ($self->{'raw_ip'} =~ tr/:/:/);
if (!($n > 0 and $n < 8)) {
setError("Address '".$self->{'ip'}."' is not a valid IPv6 address");
return 0;
}
# Number of specified octets
my $numOctets = 0;
# Number of octets specified on the left hand side
my $preOctets = 0;
# Check octets
my $foundEmpty = 0;
foreach my $octet (split /:/, $self->{'raw_ip'}) {
# Empty octet?
if ($octet eq '') {
$foundEmpty = 1;
next;
}
# If we not found an empty octet, we have one more octet on the left hand side (pre)
if (!$foundEmpty) {
$preOctets++;
}
$numOctets++;
# Normal v6 octet?
if ($octet =~ /^[a-f\d]{1,4}$/i) {
next;
}
setError("IPv6 address component '$octet' is invalid");
return 0;
}
# Does the IP address have more than one '::' pattern ?
my $count = 0;
while ($self->{'raw_ip'} =~ /::/g) {
$count++;
}
if ($count > 1) {
setError("IPv6 address '".$self->{'raw_ip'}."' contains more than one ::");
return 0;
}
# Expand address
my $tempIP = $self->{'raw_ip'};
if ($numOctets < 8) {
# If there is no :: return 0
if (!$self->{'raw_ip'} =~ /::/) {
setError("IPv6 address '".$self->{'raw_ip'}."' has missing components");
return 0;
}
# Set mask
if (!defined($mask) && $numOctets == $preOctets) {
$mask = 16 * $preOctets;
}
my @missingOctets;
for (my $i = 0; $i < (8 - $numOctets); $i++) {
push(@missingOctets, '0000');
}
my $octets = join(':', @missingOctets);
# Replace ::
$tempIP =~ s/::/:$octets:/g;
# Remove trailing and leading :
$tempIP =~ s/^://;
$tempIP =~ s/:$//;
}
# Check for and add leading 0s
my @fullipv6;
foreach my $octet (split(':',$tempIP)) {
if ($octet =~ /^[a-f\d]{1}$/) {
$octet = '000'.$octet;
}
if ($octet =~ /^[a-f\d]{2}$/) {
$octet = '00'.$octet;
}
if ($octet =~ /^[a-f\d]{3}$/) {
$octet = '0'.$octet;
}
push(@fullipv6, $octet);
}
$self->{'ip'} = join(':', @fullipv6);
# Check for full ipv6
if (!($self->{'ip'} =~ /^[a-f\d]{4}:[a-f\d]{4}:[a-f\d]{4}:[a-f\d]{4}:[a-f\d]{4}:[a-f\d]{4}:[a-f\d]{4}:[a-f\d]{4}$/i)) {
setError("IPv6 address '".$self->{'raw_ip'}."' is not a valid IPv6 address");
return 0;
}
# Default mask
$self->{'cidr'} = defined($mask) ? $mask : 128;
}
return 1;
}
# Calculate network_bin and broadcast_bin
sub _calc_ranges
{
my $self = shift;
# Grab CIDR
my $cidr = $self->{'cidr'};
# Grab length of this address, we don't care if its v4 or v6
my $bitlen = length($self->to_bin);
# Create the masks
my $NETWORK_MASK = '1' x $cidr . '0' x ($bitlen - $cidr);
my $BROADCAST_MASK = '0' x $cidr . '1' x ($bitlen - $cidr);
# network_bin = remove bits (AND)
# broadcast_bin = add bits (OR)
my $bin = $self->to_bin();
$self->{'network_bin'} = '';
$self->{'broadcast_bin'} = '';
# Loop with all bits
for (my $i = 0; $i < $bitlen; $i++) {
# Cut off the bits
my $a = substr($bin,$i,1);
my $b = substr($NETWORK_MASK,$i,1);
my $c = substr($BROADCAST_MASK,$i,1);
# Bit arithmatic ! , sneaky but quick
$self->{'network_bin'} .= ($a + $b == 2) ? 1 : 0;
$self->{'broadcast_bin'} .= ($a + $c > 0) ? 1 : 0;
}
}
1;
# vim: ts=4
# Utility functions
# Copyright (C) 2008-2014, AllWorldIT
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
## @class awitpt::util
# System functions
package awitpt::util;
use strict;
use warnings;
use File::Spec;
# Exporter stuff
require Exporter;
our (@ISA,@EXPORT,@EXPORT_OK);
@ISA = qw(Exporter);
@EXPORT = qw(
indentExpand
isNumber
isHash
isVariable
isDomain
isUsername
isDatabaseName
isBoolean
isDate
isEmailSpec
isIPv4
booleanize
parseMacro
sanitizePath
prettyUndef
getHashChanges
toHex
parseFormContent
parseURIQuery
parseKeyPairString
ISNUMBER_ALLOW_ZERO
ISNUMBER_ALLOW_NEGATIVE
ISUSERNAME_ALLOW_ATSIGN
ISDATE_YEAR
ISDATE_MONTH
ISDATE_DAY
ISDATE_TIME
ISDATE_UNIX
);
@EXPORT_OK = qw(
);
# Define constants
use constant {
ISNUMBER_ALLOW_ZERO => 1,
ISNUMBER_ALLOW_NEGATIVE => 2,
ISUSERNAME_ALLOW_ATSIGN => 1,
ISDATE_YEAR => 1,
ISDATE_MONTH => 2,
ISDATE_DAY => 4,
ISDATE_TIME => 8,
ISDATE_UNIX => 16
};
## @fn indentExpand($char,$count)
# Return indentation
#
# @param char Indent character
# @param count Number of indent characters to add
#
# @return Indent string
sub indentExpand
{
my ($char,$count) = @_;
my $ret = "";
for (my $i = 0; $i < $count; $i++) {
$ret .= $char;
}
return $ret;
}
## @fn isNumber($var,$options)
# Check if variable is a number
#
# @param var Variable to check
# @param options Optional check options
# ISNUMBER_ALLOW_ZERO: Allow zero
# ISNUMBER_ALLOW_NEGATIVE: Allow negatives
#
# @return undef on error, value otherwise
sub isNumber
{
my ($var,$options) = @_;
$options = 0 if (!defined($options));
# Make sure we're not a ref
if (!isVariable($var)) {
return;
}
# Strip leading 0's
if ($var =~ s/^(-?)0*([0-9]+)$/$1$2/) {
my $val = int($var);
# Check we not 0 or negative
if ($val > 0) {
return $val;
}
# Check if we allow 0's
if ($val == 0 && (($options & ISNUMBER_ALLOW_ZERO) == ISNUMBER_ALLOW_ZERO)) {
return $val;
}
# Check if we negatives
if ($val < 0 && (($options & ISNUMBER_ALLOW_NEGATIVE) == ISNUMBER_ALLOW_NEGATIVE)) {
return $val;
}
}
return;
}
## @fn isHash($var)
# Check if variable is a hash
#
# @param var Variable to check
#
# @return 1 on success, 0 on failure
sub isHash
{
my $var = shift;
# A hash cannot be undef?
if (!defined($var)) {
return;
}
return (ref($var) eq "HASH");
}
## @fn isVariable($var)
# Check if variable is normal
#
# @param var Variable to check
#
# @return 1 on success, 0 on failure
sub isVariable
{
my $var = shift;
# A variable cannot be undef?
if (!defined($var)) {
return;
}
return (ref($var) eq "");
}
# FIXME - improve this function to be more compliant
## @fn isDomain($var,$options)
# Check if variable is a domain
#
# @param var Variable to check
# @param options Optional check options
# (NONE AT PRESENT)
#
# @return undef on error, value otherwise
sub isDomain
{
my ($var,$options) = @_;
$options = 0 if (!defined($options));
# Make sure we're not a ref
if (!isVariable($var)) {
return;
}
# Lowercase it
$var = lc($var);
# Now check
if ($var =~ /^[a-z0-9_\-\.]+$/) {
return $var;
}
return;
}
## @fn isUsername($var,$options)
# Check if variable is a username
#
# @param var Variable to check
# @param options Optional check options
# (NONE AT PRESENT)
#
# @return undef on error, value otherwise
sub isUsername
{
my ($var,$options) = @_;
$options = 0 if (!defined($options));
# Make sure we're not a ref
if (!isVariable($var)) {
return;
}
# Lowercase it
$var = lc($var);
# Normal username
if ($var =~ /^[a-z0-9_\-\.]+$/) {
return $var;
}
# Username with domain
if ($var =~ /^[a-z0-9_\-\.]+\@[a-z0-9\-\.]+$/) {
# Check if this is allowed
if (($options & ISUSERNAME_ALLOW_ATSIGN) == ISUSERNAME_ALLOW_ATSIGN) {
return $var;
}
}
return;
}
## @fn isDatabaseName($var,$options)
# Check if variable can be a database name
#
# @param var Variable to check
# @param options Optional check options
# (NONE AT PRESENT)
#
# @return undef on error, value otherwise
sub isDatabaseName
{
my ($var,$options) = @_;
$options = 0 if (!defined($options));
# Make sure we're not a ref
if (!isVariable($var)) {
return;
}
# Lowercase it
$var = lc($var);
# Now check
if ($var =~ /^[a-z0-9]+$/) {
return $var;
}
return;
}
## @fn booleanize($var)
# Booleanize the variable depending on its contents
#
# @param var Variable to booleanize
#
# @return 1 or 0
sub booleanize
{
my $var = shift;
# Check if we're defined
if (!isVariable($var)) {
return 0;
}
# If we're a number
if (my $val = isNumber($var,ISNUMBER_ALLOW_ZERO)) {
if ($val == 0) {
return 0;
} else {
return 1;
}
}
# Nuke whitespaces
$var =~ s/\s//g;
# Allow true, on, set, enabled, 1
if ($var =~ /^(?:true|on|set|enabled|1)$/i) {
return 1;
}
# Invalid or unknown
return 0;
}
## @fn isBoolean($var)
# Check if a variable is boolean
#
# @param var Variable to check
#
# @return 1, 0 or undef
sub isBoolean
{
my $var = shift;
# Check if we're defined
if (!isVariable($var)) {
return;
}
# Nuke whitespaces
$var =~ s/\s//g;
# Allow true, on, set, enabled, 1, false, off, unset, disabled, 0
if ($var =~ /^(?:true|on|set|enabled|1)$/i) {
return 1;
}
if ($var =~ /^(?:false|off|unset|disabled|0)$/i) {
return 0;
}
# Invalid or unknown
return;
}
## @fn isDate($var)
# Check if a variable is a valid date string and return $year,$month,$day,$hour,$min,$sec
#
# @param var Variable to check
#
# @return ($month,$year,$day,$hour,$min,$sec) or undef
sub isDate
{
my ($date,$options) = @_;
# Make sure we're not a ref
if (!isVariable($date)) {
return;
}
# Check options
if (!defined($options)) {
$options = ISDATE_YEAR | ISDATE_MONTH | ISDATE_DAY
}
# Regex out components
my ($year,$month,$day,$hour,$min,$sec) = ($date =~ /^(\d{4})(?:[-\/ \.](\d{1,2})(?:[-\/ \.](\d{1,2})(?:\s(\d{2})\:(\d{2})(?:\:(\d{2}))?)?)?)?$/);
my @result;
# Year
if (($options & ISDATE_YEAR) == ISDATE_YEAR) {
if (!defined($year)) {
return;
}
# Insane?
if ($year < 1900) {
return;
}
push(@result,$year);
}
# Month
if (($options & ISDATE_MONTH) == ISDATE_MONTH) {
if (!defined($month)) {
return;
}
# Check month is valid
if (!($month > 0 && $month < 13)) {
return;
}
push(@result,$month);
}
# Day
if (($options & ISDATE_DAY) == ISDATE_DAY) {
if (!defined($day)) {
return;
}
# Basic check
if (!($day > 0 && $day < 32)) {
return;
}
# Reject 31st of a month with 30 days
if ($day == 31 && ($month == 4 || $month == 6 || $month == 9 || $month == 11)) {
return;
# Reject February 30th or 31st
} elsif ($day >= 30 && $month == 2) {
return;
# February 29th outside a leap year
} elsif ($month == 2 && $day == 29 && !($year % 4 == 0 && ($year % 100 != 0 || $year % 400 == 0))) {
return;
}
push(@result,$day);
}
# Time
if (($options & ISDATE_TIME) == ISDATE_TIME) {
if (!(defined($hour) && defined($min))) {
return;
}
# Hour
if (!($hour >= 0 && $hour < 25)) {
return;
}
push(@result,$hour);
# Min
if (!($min >= 0 && $min < 61)) {
return;
}
push(@result,$min);
# Sec
if (defined($sec)) {
if (!$sec >= 0 && $sec < 61) {
return;
}
push(@result,$sec);
}
}
# Unix time
if (($options & ISDATE_UNIX) == ISDATE_UNIX) {
if (!isNumber($date)) {
return;
}
return $date;
}
return (@result);
}
## @fn isEmailSpec($var)
# Check if a variable is a valid email spec
#
# @param var Variable to check
#
# @return specification or undef
sub isEmailSpec
{
my $var = shift;
# Make sure we're defined
if (!defined($var)) {
return;
}
# Make sure we're not a ref
if (!isVariable($var)) {
return;
}
# Check IPv4
if ($var =~ /^(?:\d{1,3})(?:\.(?:\d{1,3})(?:\.(?:\d{1,3})(?:\.(?:\d{1,3}))?)?)?(?:\/(\d{1,2}))?$/) {
return $var;
}
# Check user@domain, user@, @domain
if ($var =~ /^(\S+)?@(\S+)?$/) {
my ($user,$domain) = ($1,$2);
if (!(defined($user) || defined($domain))) {
return;
}
if (defined($user)) {
if (!$user =~ /^\S+$/i) {
return;
}
}
if (defined($domain)) {
if (!$domain =~ /^(?:[a-z0-9\-_\*]+\.)+[a-z0-9]+$/i) {
return;
}
}
return $var;
}
return;
}
## @fn isIPv4($string)
# Check if $string is an IPv4 address
#
# @param string String to test
#
# @result Returns a stanitized IPv4 address
sub isIPv4
{
my $var = shift;
# Make sure we're not a ref
if (!isVariable($var)) {
return;
}
# Lowercase it
$var = lc($var);
# Normal IPv4
if ($var =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/) {
return $var;
}
return;
}
## @fn parseMacro($mappings,$specification)
# Parse a $specification against $mappings hash ref and produce result.
#
# @param mappings Hashref of macro => values
# @param specification Macro specification...
# %{MACRO} - Use entire macro value
# %{MACRO(n)} - Use first n characters of value
# %{MACRO(m,n)} - Use n characters starting at m
#
# @result Returns an array with the result code and string.
# Result code of 0 means success and -1 means error. In the case of an
# error, the reason will be the second value in the returned array.
sub parseMacro
{
my ($mappings,$rest) = @_;
# This will be our result
my $res = "";
# Loop with macro items
while ((my $match = $rest) =~ /([^%]+)?(?:\%{([a-zA-Z_0-9]+)(?:\(([0-9]+)(?:,([0-9]+))?\))?})(.*)/) {
my ($before,$macro,$n,$m) = ($1,$2,$3,$4);
$rest = $5;
# Just blank before it isn't present
$before = '' if (!defined($before));
my $value;
# If the macro is defined ...
if (defined($mappings->{$macro})) {
# Check if we using substr
if (defined($n)) {
# Check which substr to use
if (defined($m)) {
$value = substr($mappings->{$macro},$n,$m);
} else {
$value = substr($mappings->{$macro},0,$n);
}
# No substr needed
} else {
$value = $mappings->{$macro};
}
# Oh noes, no macro
} else {
return (-1,"Macro '$macro' does not exist!!!");
}
$res .= "$before$value";
}
# Add on the last rest
$res .= "$rest";
return (0,$res);
}
## @fn sanitizePath
# Get a relative to Abs path and sanitize
sub sanitizePath
{
my $path = shift;
my $newPath = File::Spec->rel2abs($path);
$newPath =~ s/\/+$//;
return $newPath;
}
## @fn prettyUndef
# Return a undef in a pretty fashion
sub prettyUndef
{
my $var = shift;
if (!defined($var)) {
return "-undef-";
} else {
return $var;
}
}
## @fn getHashChanges
# Function to return the changes between two hashes using a list of keys
sub getHashChanges
{
my ($orig,$new,$keys) = @_;
my $changed = { };
foreach my $key (@{$keys}) {
# We can only do this if we have a new value
if (exists($new->{$key})) {
if (!defined($orig->{$key}) || !defined($new->{$key}) || $orig->{$key} ne $new->{$key}) {
$changed->{$key} = $new->{$key};
}
}
}
return $changed;
}
## @fn toHex
# Return hex representation of a decimal
sub toHex
{
my $decimal = shift;
return sprintf('%x',$decimal);
}
## @fn parseFormContent
# Parse form post data from HTTP content
sub parseFormContent
{
my $data = shift;
my %res;
# Split information into name/value pairs
my @pairs = split(/&/, $data);
foreach my $pair (@pairs) {
# Spaces are represented by +'s
$pair =~ tr/+/ /;
# Split off name value pairs
my ($name, $value) = split(/=/, $pair);
# Unescape name value pair
$name =~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg;
$value =~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg;
# Cleanup...
$name =~ s/[^0-9A-Za-z\[\]\.]/_/g;
# Add to hash
$res{$name}->{'value'} = $value;
push(@{$res{$name}->{'values'}},$value);
}
return \%res;
}
## @fn parseURIQuery
# Parse query data
sub parseURIQuery
{
my $request = shift;
my %res;
# Grab URI components
my @components = $request->uri->query_form;
# Loop with the components in sets of name & value
while (@components) {
my ($name,$value) = (shift(@components),shift(@components));
# Unescape name value pair
$name =~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg;
$value =~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg;
# Add to hash
$res{$name}->{'value'} = $value;
push(@{$res{$name}->{'values'}},$value);
}
return \%res;
}
# Function to parse a keypair string and return a hash
sub parseKeyPairString
{
my $str = shift;
my %res;
# Grab components
my @keyPairs = split(/\s+/,$str);
# Loop with the components in sets of name & value
foreach my $item (@keyPairs) {
my ($name,$value) = split(/=/,$item);
# Unescape name value pair
$value =~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg;
# Add to hash
$res{$name}->{'value'} = $value;
push(@{$res{$name}->{'values'}},$value);
}
return \%res;
}
1;
# vim: ts=4
# Version information
# Copyright (C) 2014, AllWorldIT
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
package awitpt::version;
use strict;
use warnings;
our $VERSION = "0.1.x";
1;
# vim: ts=4
# Test harness for code quality
# Copyright (C) 2014, AllWorldIT
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
use Test::More;
use strict;
use warnings;
use awitpt::util;
is(system("perlcritic --statistics --gentle ."),0);
done_testing();
# vim: ts=4
# Test harness for isNumber
# Copyright (C) 2014, AllWorldIT
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
use Test::More;
use strict;
use warnings;
use awitpt::util;
is(isNumber(0),undef);
is(isNumber(0,ISNUMBER_ALLOW_ZERO),0);
is(isNumber("000",ISNUMBER_ALLOW_ZERO),0);
is(isNumber("-0",ISNUMBER_ALLOW_ZERO),0);
is(isNumber(-1),undef);
is(isNumber(-1,ISNUMBER_ALLOW_NEGATIVE),-1);
is(isNumber("-1",ISNUMBER_ALLOW_NEGATIVE),-1);
is(isNumber("-01",ISNUMBER_ALLOW_NEGATIVE),-1);
is(isNumber(1),1);
is(isNumber("0001"),1);
is(isNumber("a"),undef);
is(isNumber("0a"),undef);
is(isNumber("a0"),undef);
is(isNumber("-a0"),undef);
is(isNumber("-0a"),undef);
done_testing();
# vim: ts=4
options sch_htb htb_rate_est=1
\ No newline at end of file