From 2cb7369e203d8c381ac4cbe733cd427b3e1ee044 Mon Sep 17 00:00:00 2001
From: Sami Kerola
Date: Tue, 7 Jun 2011 22:02:57 +0200
Subject: [PATCH 001/401] docs: help screen & man page
The help screen has now same notation as most of the GNU/Linux
utilities, e.g. if a option requires argument it is marked as
option=ARG. That enabled me to use help2man to make small nroff
fixes to manual page to unify it's outlook as well.
Signed-off-by: Sami Kerola
---
man/dhcpd-pools.1 | 36 +++++++++++++++++++++-------------
src/other.c | 50 +++++++++++++++++++++++------------------------
2 files changed, 47 insertions(+), 39 deletions(-)
diff --git a/man/dhcpd-pools.1 b/man/dhcpd-pools.1
index 722e772..87de379 100644
--- a/man/dhcpd-pools.1
+++ b/man/dhcpd-pools.1
@@ -5,12 +5,12 @@
.\" Add'l ontributions by:
.\" Dan Thorson
.\"
-.TH DHCPD-POOLS 1 "Jan 21 2011" "SourceForge" "ISC dhcpd analysis"
+.TH DHCPD-POOLS "1" "June 2011" "dhcpd-pools 2.15" "User Commands"
.SH NAME
dhcpd-pools \- ISC dhcpd pools usage analysis
.SH SYNOPSIS
.B dhcpd-pools
-[-c file] [-l file] [-f thcxX] [-s nimcptTe] [-r] [-o file] [-L nr] [-v] [-h]
+[\fIOPTIONS\fR]
.SH DESCRIPTION
The program analyses ISC dhcpd shared network and pool usage and outputs the
results in a user selectable format.
@@ -55,21 +55,21 @@ Percent of addresses that failover pair can allocate. The percent appears
only if there is failover configuration.
.SH ARGUMENTS
.TP
-.I "\-c, \-\-config"
+\fB\-c\fR, \fB\-\-config\fR=\fIFILE\fR
Path to the dhcpd.conf file.
.TP
-.I "\-l, \-\-leases"
+\fB\-l\fR, \fB\-\-leases\fR=\fIFILE\fR
Path to the dhcpd.leases file.
.TP
-.I "\-s, \-\-sort"
+\fB\-s\fR, \fB\-\-sort\fR=\fI[nimcptTe]\fR
Sort ranges by chosen fields as a sorting keys. Maximum of five sort keys
can be defined. Keys weight from left to right IE if more weighting keys
are equal next one is used. The IP field is default sort key.
.TP
-.I "\-r, \-\-reverse"
+\fB\-r\fR, \fB\-\-reverse\fR
Sort results in reverse order.
.TP
-.I "\-f, \-\-format"
+\fB\-f\fR, \fB\-\-format\fR=\fI[thcxX]\fR
Output format. Currently there is text, html, full-html and csv
(comma-separated values). Default is text. Standard html (h) outputs only
the HTML tables, and is useful for embeding more complex web pages.
@@ -77,16 +77,15 @@ Full-html (H) provides complete HTML headers, etc., including in-line CSS.
Output format xml (x) is similar to the dhcpstatus Perl module output. The
extended xml (X) format will print ethernet address details.
.TP
-.I "\-o, \-\-output"
+\fB\-o\fR, \fB\-\-output\fR=\fIFILE\fR
File where output is written. Default is stdout.
.TP
-.I "\-L, \-\-limit"
+\fB\-L\fR, \fB\-\-limit\fR=\fINR\fR
Limit what will be printed. Syntax is similar to chmod permission string.
The limit string uses two digits which vary between 0 to 7. The first digit
determines which headers to display, and the second digit determines which
numeric analysis tables to include in the output. The following values are
"OR'd" together to create the desired output. The default is 77.
-
.RS
.PD 0
.TP
@@ -110,10 +109,10 @@ Print headers for z
.PD
.RE
.TP
-.I "\-v, \-\-version"
+\fB\-v\fR, \fB\-\-version\fR
Print version information to standard output and exit successfully.
.TP
-.I "\-h, \-\-help"
+\fB\-h\fR, \fB\-\-help\fR
Print help to standard output and exit successfully.
.SH FILES
.if n .ta 2.8i
@@ -127,9 +126,18 @@ Print help to standard output and exit successfully.
.br
ISC dhcpd lease file.
.SH AUTHOR
-Sami Kerola
+Written by Sami Kerola.
.br
-http://dhcpd-pools.sourceforge.net/
+XML support by Dominic Germain, Sogetel inc.
+.PP
+License GPLv3+: GNU GPL version 3 or later
+
+This is free software: you are free to change and redistribute it.
+There is NO WARRANTY, to the extent permitted by law.
+.SH "REPORTING BUGS"
+Report bugs to
+.br
+Homepage: http://dhcpd-pools.sourceforge.net/
.SH "SEE ALSO"
.BR dhcpd.leases (5),
.BR dhcpd.conf (5),
diff --git a/src/other.c b/src/other.c
index 4a9730b..a16240b 100644
--- a/src/other.c
+++ b/src/other.c
@@ -123,38 +123,38 @@ void usage(int status)
FILE *out;
out = status != 0 ? stderr : stdout;
- fprintf(out, "\
-Usage: %s [OPTIONS]\n", program_invocation_short_name);
+ fprintf(out, "\n\
+Usage: %s [OPTIONS]\n\n", program_invocation_short_name);
fprintf(out, "\
This is ISC dhcpd pools usage analyzer.\n\
\n");
fprintf(out, "\
- -c --config file path to the dhcpd.conf file\n\
- -l --leases file path to the dhcpd.leases file\n\
- -f --format [thcxX] output format\n");
+ -c, --config=FILE path to the dhcpd.conf file\n\
+ -l, --leases=FILE path to the dhcpd.leases file\n\
+ -f, --format=[thcxX] output format\n");
fprintf(out, "\
- t for text\n\
- h for html table\n\
- H for full html page\n\
- x for xml\n\
- X for xml with active lease details\n\
- c for comma separated values\n");
+ t for text\n\
+ h for html table\n\
+ H for full html page\n\
+ x for xml\n\
+ X for xml with active lease details\n\
+ c for comma separated values\n");
fprintf(out, "\
- -s --sort [nimcptTe] sort ranges by\n\
- n name\n\
- i IP\n\
- m maxium\n\
- c current\n\
- p percent\n\
- t touched\n\
- T t+c\n\
- e t+c perc\n");
+ -s, --sort=[nimcptTe] sort ranges by\n\
+ n name\n\
+ i IP\n\
+ m maxium\n\
+ c current\n\
+ p percent\n\
+ t touched\n\
+ T t+c\n\
+ e t+c perc\n");
fprintf(out, "\
- -r --reverse reverse order sort\n\
- -o --output file output into a file\n\
- -L --limit nr output limit mask 77 - 00\n\
- -v --version version information\n\
- -h --help this screen\n\
+ -r, --reverse reverse order sort\n\
+ -o, --output=FILE output into a file\n\
+ -L, --limit=NR output limit mask 77 - 00\n\
+ -v, --version version information\n\
+ -h, --help this screen\n\
\n\
Report bugs to <%s>\n\
Homepage: %s\n", PACKAGE_BUGREPORT, PACKAGE_URL);
From 4c9f177b2ea35eed95226e8c461855a927716418 Mon Sep 17 00:00:00 2001
From: Sami Kerola
Date: Tue, 7 Jun 2011 22:47:02 +0200
Subject: [PATCH 002/401] docs: add missing full-html flag
Missing both from help output & manual page.
Signed-off-by: Sami Kerola
---
man/dhcpd-pools.1 | 2 +-
src/other.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/man/dhcpd-pools.1 b/man/dhcpd-pools.1
index 87de379..5a468e3 100644
--- a/man/dhcpd-pools.1
+++ b/man/dhcpd-pools.1
@@ -69,7 +69,7 @@ are equal next one is used. The IP field is default sort key.
\fB\-r\fR, \fB\-\-reverse\fR
Sort results in reverse order.
.TP
-\fB\-f\fR, \fB\-\-format\fR=\fI[thcxX]\fR
+\fB\-f\fR, \fB\-\-format\fR=\fI[thHcxX]\fR
Output format. Currently there is text, html, full-html and csv
(comma-separated values). Default is text. Standard html (h) outputs only
the HTML tables, and is useful for embeding more complex web pages.
diff --git a/src/other.c b/src/other.c
index a16240b..7719c4e 100644
--- a/src/other.c
+++ b/src/other.c
@@ -131,7 +131,7 @@ This is ISC dhcpd pools usage analyzer.\n\
fprintf(out, "\
-c, --config=FILE path to the dhcpd.conf file\n\
-l, --leases=FILE path to the dhcpd.leases file\n\
- -f, --format=[thcxX] output format\n");
+ -f, --format=[thHcxX] output format\n");
fprintf(out, "\
t for text\n\
h for html table\n\
From e299e7fce261036090d78547a91cfeb840d5a6ce Mon Sep 17 00:00:00 2001
From: Sami Kerola
Date: Wed, 8 Jun 2011 20:59:56 +0200
Subject: [PATCH 003/401] headers: include-what-you-use fixes
Usage of includes are set up the way found to be in use, with a help of
magnificent utility.
http://code.google.com/p/include-what-you-use/
Signed-off-by: Sami Kerola
---
src/analyze.c | 6 +-----
src/dhcpd-pools.c | 9 +++------
src/dhcpd-pools.h | 4 +++-
src/getdata.c | 20 ++++++++------------
src/getopt.c | 6 +-----
src/getopt1.c | 8 +-------
src/other.c | 4 ++--
src/output.c | 6 +++---
src/sort.c | 10 +++-------
9 files changed, 25 insertions(+), 48 deletions(-)
diff --git a/src/analyze.c b/src/analyze.c
index e9bfad7..a023f98 100644
--- a/src/analyze.c
+++ b/src/analyze.c
@@ -15,12 +15,8 @@
** along with this program. If not, see .
*/
-#ifdef HAVE_CONFIG_H
-#include
-#endif
-
+#include
#include
-#include
#include "dhcpd-pools.h"
diff --git a/src/dhcpd-pools.c b/src/dhcpd-pools.c
index abcb8ca..232ed94 100644
--- a/src/dhcpd-pools.c
+++ b/src/dhcpd-pools.c
@@ -20,9 +20,6 @@
#endif
#include
-#ifdef HAVE_UNISTD_H
-#include
-#endif
#ifdef HAVE_STDLIB_H
#include
#else /* Not STDC_HEADERS */
@@ -33,12 +30,12 @@ extern char *malloc();
#else
#include
#endif
-#include
-#include
#include
+#include
+#include
-#include "dhcpd-pools.h"
#include "defaults.h"
+#include "dhcpd-pools.h"
int main(int argc, char **argv)
{
diff --git a/src/dhcpd-pools.h b/src/dhcpd-pools.h
index fcf75b2..c43bd33 100644
--- a/src/dhcpd-pools.h
+++ b/src/dhcpd-pools.h
@@ -19,16 +19,18 @@
# define DHCPD_POOLS_H 1
#include
+#include
/* Feature test switches */
#define _POSIX_SOURCE 1
#define POSIXLY_CORRECT 1
#ifdef HAVE_STDLIB_H
-#include
#else
extern void exit();
extern char *malloc();
+#define EXIT_FAILURE 1
+#define EXIT_SUCCESS 0
#endif /* STDC_HEADERS */
#ifndef HAVE_PROGRAM_INVOCATION_SHORT_NAME
diff --git a/src/getdata.c b/src/getdata.c
index 5456b65..215c707 100644
--- a/src/getdata.c
+++ b/src/getdata.c
@@ -19,10 +19,6 @@
#include
#endif
-#ifdef HAVE_UNISTD_H
-#include
-#endif
-
#ifdef HAVE_STDLIB_H
#include
#else /* Not STDC_HEADERS */
@@ -37,20 +33,20 @@ extern char *malloc();
#include
#endif
-#include
#include
+#include
+#include
+#include
+#include
+#include
+#include
#include
-#include
+#include
+#include
#include
-#include
#ifndef _XOPEN_SOURCE
#define _XOPEN_SOURCE 600
#endif
-#include
-#include
-#include
-#include
-#include
#include "dhcpd-pools.h"
#include "defaults.h"
diff --git a/src/getopt.c b/src/getopt.c
index 9f01d83..8f49931 100644
--- a/src/getopt.c
+++ b/src/getopt.c
@@ -26,9 +26,7 @@
# define _NO_PROTO
#endif
-#ifdef HAVE_CONFIG_H
-# include
-#endif
+#include
#if !defined __STDC__ || !__STDC__
/* This is a separate conditional since some stdc systems
@@ -38,8 +36,6 @@
# endif
#endif
-#include
-
/* Comment out all this code if we are using the GNU C Library, and are not
actually compiling the library itself. This code is part of the GNU C
Library, but also included in many other GNU distributions. Compiling
diff --git a/src/getopt1.c b/src/getopt1.c
index d3182d8..652ae07 100644
--- a/src/getopt1.c
+++ b/src/getopt1.c
@@ -17,11 +17,7 @@
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-#ifdef HAVE_CONFIG_H
-#include
-#endif
-
-#include "getopt.h"
+#include
#if !defined __STDC__ || !__STDC__
/* This is a separate conditional since some stdc systems
@@ -31,8 +27,6 @@
#endif
#endif
-#include
-
/* Comment out all this code if we are using the GNU C Library, and are not
actually compiling the library itself. This code is part of the GNU C
Library, but also included in many other GNU distributions. Compiling
diff --git a/src/other.c b/src/other.c
index 7719c4e..5e887e6 100644
--- a/src/other.c
+++ b/src/other.c
@@ -28,9 +28,9 @@
extern void exit();
extern char *malloc();
#endif /* STDC_HEADERS */
-#include
#include
-#include
+#include
+#include
#ifdef HAVE_STRING_H
#include
#else
diff --git a/src/output.c b/src/output.c
index 874efa4..86423d9 100644
--- a/src/output.c
+++ b/src/output.c
@@ -19,11 +19,11 @@
#include
#endif
-#include
-#include
-#include
#include
#include
+#include
+#include
+#include
#include "dhcpd-pools.h"
diff --git a/src/sort.c b/src/sort.c
index e436f5a..460f4cd 100644
--- a/src/sort.c
+++ b/src/sort.c
@@ -15,15 +15,11 @@
** along with this program. If not, see .
*/
-#ifdef HAVE_CONFIG_H
#include
-#endif
-
-#include
-#include
-#include
-#include
#include
+#include
+#include
+#include
#include "dhcpd-pools.h"
From 55ab31e48242b94253a0825f3ff4420b70ca1347 Mon Sep 17 00:00:00 2001
From: Sami Kerola
Date: Tue, 21 Jun 2011 22:15:48 +0200
Subject: [PATCH 004/401] other: free backup ranges
Fix to memory leak I overlooked earlier.
Signed-off-by: Sami Kerola
---
src/other.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/other.c b/src/other.c
index 5e887e6..2cf3599 100644
--- a/src/other.c
+++ b/src/other.c
@@ -100,6 +100,7 @@ void clean_up(void)
free(config.output_file);
free(ranges);
free(leases);
+ free(backups);
free(touches);
free(shared_networks);
}
From dd5b77b62c2f2132392af4f5bacb551546cb2c5c Mon Sep 17 00:00:00 2001
From: Sami Kerola
Date: Tue, 21 Jun 2011 22:34:42 +0200
Subject: [PATCH 005/401] prepare_memory bug: initialization missing
The lack of initialization may have cause unexpected outputs to
some users some times. That sort of behavior is also known by
name a bug.
Signed-off-by: Sami Kerola
---
src/dhcpd-pools.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/dhcpd-pools.c b/src/dhcpd-pools.c
index 232ed94..cf03db6 100644
--- a/src/dhcpd-pools.c
+++ b/src/dhcpd-pools.c
@@ -218,6 +218,9 @@ int prepare_memory()
/* First shared network entry is all networks */
shared_networks->name = safe_strdup("All networks");
+ shared_networks->used = 0;
+ shared_networks->touched = 0;
+ shared_networks->backups = 0;
return 0;
}
From a31fd0d97ab18115198b33160ffc390f50d8b2f6 Mon Sep 17 00:00:00 2001
From: Sami Kerola
Date: Tue, 21 Jun 2011 22:54:03 +0200
Subject: [PATCH 006/401] licensing: use FreeBSD license (was GNUv3)
This change will also remove getopt source code and headers,
which has GNU license that I cannot change.
Signed-off-by: Sami Kerola
---
COPYING | 708 ++----------------------------
configure.ac | 4 -
man/dhcpd-pools.1 | 5 +-
src/Makefile.am | 2 +-
src/analyze.c | 50 ++-
src/defaults.h | 50 ++-
src/dhcpd-pools.c | 50 ++-
src/dhcpd-pools.h | 50 ++-
src/getdata.c | 50 ++-
src/getopt.c | 1042 ---------------------------------------------
src/getopt.h | 183 --------
src/getopt1.c | 181 --------
src/other.c | 56 ++-
src/output.c | 50 ++-
src/sort.c | 50 ++-
15 files changed, 309 insertions(+), 2222 deletions(-)
delete mode 100644 src/getopt.c
delete mode 100644 src/getopt.h
delete mode 100644 src/getopt1.c
diff --git a/COPYING b/COPYING
index 94a9ed0..a0261db 100644
--- a/COPYING
+++ b/COPYING
@@ -1,674 +1,34 @@
- GNU GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc.
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The GNU General Public License is a free, copyleft license for
-software and other kinds of works.
-
- The licenses for most software and other practical works are designed
-to take away your freedom to share and change the works. By contrast,
-the GNU General Public License is intended to guarantee your freedom to
-share and change all versions of a program--to make sure it remains free
-software for all its users. We, the Free Software Foundation, use the
-GNU General Public License for most of our software; it applies also to
-any other work released this way by its authors. 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
-them 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 prevent others from denying you
-these rights or asking you to surrender the rights. Therefore, you have
-certain responsibilities if you distribute copies of the software, or if
-you modify it: responsibilities to respect the freedom of others.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must pass on to the recipients the same
-freedoms that you received. 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.
-
- Developers that use the GNU GPL protect your rights with two steps:
-(1) assert copyright on the software, and (2) offer you this License
-giving you legal permission to copy, distribute and/or modify it.
-
- For the developers' and authors' protection, the GPL clearly explains
-that there is no warranty for this free software. For both users' and
-authors' sake, the GPL requires that modified versions be marked as
-changed, so that their problems will not be attributed erroneously to
-authors of previous versions.
-
- Some devices are designed to deny users access to install or run
-modified versions of the software inside them, although the manufacturer
-can do so. This is fundamentally incompatible with the aim of
-protecting users' freedom to change the software. The systematic
-pattern of such abuse occurs in the area of products for individuals to
-use, which is precisely where it is most unacceptable. Therefore, we
-have designed this version of the GPL to prohibit the practice for those
-products. If such problems arise substantially in other domains, we
-stand ready to extend this provision to those domains in future versions
-of the GPL, as needed to protect the freedom of users.
-
- Finally, every program is threatened constantly by software patents.
-States should not allow patents to restrict development and use of
-software on general-purpose computers, but in those that do, we wish to
-avoid the special danger that patents applied to a free program could
-make it effectively proprietary. To prevent this, the GPL assures that
-patents cannot be used to render the program non-free.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- TERMS AND CONDITIONS
-
- 0. Definitions.
-
- "This License" refers to version 3 of the GNU General Public License.
-
- "Copyright" also means copyright-like laws that apply to other kinds of
-works, such as semiconductor masks.
-
- "The Program" refers to any copyrightable work licensed under this
-License. Each licensee is addressed as "you". "Licensees" and
-"recipients" may be individuals or organizations.
-
- To "modify" a work means to copy from or adapt all or part of the work
-in a fashion requiring copyright permission, other than the making of an
-exact copy. The resulting work is called a "modified version" of the
-earlier work or a work "based on" the earlier work.
-
- A "covered work" means either the unmodified Program or a work based
-on the Program.
-
- To "propagate" a work means to do anything with it that, without
-permission, would make you directly or secondarily liable for
-infringement under applicable copyright law, except executing it on a
-computer or modifying a private copy. Propagation includes copying,
-distribution (with or without modification), making available to the
-public, and in some countries other activities as well.
-
- To "convey" a work means any kind of propagation that enables other
-parties to make or receive copies. Mere interaction with a user through
-a computer network, with no transfer of a copy, is not conveying.
-
- An interactive user interface displays "Appropriate Legal Notices"
-to the extent that it includes a convenient and prominently visible
-feature that (1) displays an appropriate copyright notice, and (2)
-tells the user that there is no warranty for the work (except to the
-extent that warranties are provided), that licensees may convey the
-work under this License, and how to view a copy of this License. If
-the interface presents a list of user commands or options, such as a
-menu, a prominent item in the list meets this criterion.
-
- 1. Source Code.
-
- The "source code" for a work means the preferred form of the work
-for making modifications to it. "Object code" means any non-source
-form of a work.
-
- A "Standard Interface" means an interface that either is an official
-standard defined by a recognized standards body, or, in the case of
-interfaces specified for a particular programming language, one that
-is widely used among developers working in that language.
-
- The "System Libraries" of an executable work include anything, other
-than the work as a whole, that (a) is included in the normal form of
-packaging a Major Component, but which is not part of that Major
-Component, and (b) serves only to enable use of the work with that
-Major Component, or to implement a Standard Interface for which an
-implementation is available to the public in source code form. A
-"Major Component", in this context, means a major essential component
-(kernel, window system, and so on) of the specific operating system
-(if any) on which the executable work runs, or a compiler used to
-produce the work, or an object code interpreter used to run it.
-
- The "Corresponding Source" for a work in object code form means all
-the source code needed to generate, install, and (for an executable
-work) run the object code and to modify the work, including scripts to
-control those activities. However, it does not include the work's
-System Libraries, or general-purpose tools or generally available free
-programs which are used unmodified in performing those activities but
-which are not part of the work. For example, Corresponding Source
-includes interface definition files associated with source files for
-the work, and the source code for shared libraries and dynamically
-linked subprograms that the work is specifically designed to require,
-such as by intimate data communication or control flow between those
-subprograms and other parts of the work.
-
- The Corresponding Source need not include anything that users
-can regenerate automatically from other parts of the Corresponding
-Source.
-
- The Corresponding Source for a work in source code form is that
-same work.
-
- 2. Basic Permissions.
-
- All rights granted under this License are granted for the term of
-copyright on the Program, and are irrevocable provided the stated
-conditions are met. This License explicitly affirms your unlimited
-permission to run the unmodified Program. The output from running a
-covered work is covered by this License only if the output, given its
-content, constitutes a covered work. This License acknowledges your
-rights of fair use or other equivalent, as provided by copyright law.
-
- You may make, run and propagate covered works that you do not
-convey, without conditions so long as your license otherwise remains
-in force. You may convey covered works to others for the sole purpose
-of having them make modifications exclusively for you, or provide you
-with facilities for running those works, provided that you comply with
-the terms of this License in conveying all material for which you do
-not control copyright. Those thus making or running the covered works
-for you must do so exclusively on your behalf, under your direction
-and control, on terms that prohibit them from making any copies of
-your copyrighted material outside their relationship with you.
-
- Conveying under any other circumstances is permitted solely under
-the conditions stated below. Sublicensing is not allowed; section 10
-makes it unnecessary.
-
- 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
-
- No covered work shall be deemed part of an effective technological
-measure under any applicable law fulfilling obligations under article
-11 of the WIPO copyright treaty adopted on 20 December 1996, or
-similar laws prohibiting or restricting circumvention of such
-measures.
-
- When you convey a covered work, you waive any legal power to forbid
-circumvention of technological measures to the extent such circumvention
-is effected by exercising rights under this License with respect to
-the covered work, and you disclaim any intention to limit operation or
-modification of the work as a means of enforcing, against the work's
-users, your or third parties' legal rights to forbid circumvention of
-technological measures.
-
- 4. Conveying Verbatim Copies.
-
- You may convey 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;
-keep intact all notices stating that this License and any
-non-permissive terms added in accord with section 7 apply to the code;
-keep intact all notices of the absence of any warranty; and give all
-recipients a copy of this License along with the Program.
-
- You may charge any price or no price for each copy that you convey,
-and you may offer support or warranty protection for a fee.
-
- 5. Conveying Modified Source Versions.
-
- You may convey a work based on the Program, or the modifications to
-produce it from the Program, in the form of source code under the
-terms of section 4, provided that you also meet all of these conditions:
-
- a) The work must carry prominent notices stating that you modified
- it, and giving a relevant date.
-
- b) The work must carry prominent notices stating that it is
- released under this License and any conditions added under section
- 7. This requirement modifies the requirement in section 4 to
- "keep intact all notices".
-
- c) You must license the entire work, as a whole, under this
- License to anyone who comes into possession of a copy. This
- License will therefore apply, along with any applicable section 7
- additional terms, to the whole of the work, and all its parts,
- regardless of how they are packaged. This License gives no
- permission to license the work in any other way, but it does not
- invalidate such permission if you have separately received it.
-
- d) If the work has interactive user interfaces, each must display
- Appropriate Legal Notices; however, if the Program has interactive
- interfaces that do not display Appropriate Legal Notices, your
- work need not make them do so.
-
- A compilation of a covered work with other separate and independent
-works, which are not by their nature extensions of the covered work,
-and which are not combined with it such as to form a larger program,
-in or on a volume of a storage or distribution medium, is called an
-"aggregate" if the compilation and its resulting copyright are not
-used to limit the access or legal rights of the compilation's users
-beyond what the individual works permit. Inclusion of a covered work
-in an aggregate does not cause this License to apply to the other
-parts of the aggregate.
-
- 6. Conveying Non-Source Forms.
-
- You may convey a covered work in object code form under the terms
-of sections 4 and 5, provided that you also convey the
-machine-readable Corresponding Source under the terms of this License,
-in one of these ways:
-
- a) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by the
- Corresponding Source fixed on a durable physical medium
- customarily used for software interchange.
-
- b) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by a
- written offer, valid for at least three years and valid for as
- long as you offer spare parts or customer support for that product
- model, to give anyone who possesses the object code either (1) a
- copy of the Corresponding Source for all the software in the
- product that is covered by this License, on a durable physical
- medium customarily used for software interchange, for a price no
- more than your reasonable cost of physically performing this
- conveying of source, or (2) access to copy the
- Corresponding Source from a network server at no charge.
-
- c) Convey individual copies of the object code with a copy of the
- written offer to provide the Corresponding Source. This
- alternative is allowed only occasionally and noncommercially, and
- only if you received the object code with such an offer, in accord
- with subsection 6b.
-
- d) Convey the object code by offering access from a designated
- place (gratis or for a charge), and offer equivalent access to the
- Corresponding Source in the same way through the same place at no
- further charge. You need not require recipients to copy the
- Corresponding Source along with the object code. If the place to
- copy the object code is a network server, the Corresponding Source
- may be on a different server (operated by you or a third party)
- that supports equivalent copying facilities, provided you maintain
- clear directions next to the object code saying where to find the
- Corresponding Source. Regardless of what server hosts the
- Corresponding Source, you remain obligated to ensure that it is
- available for as long as needed to satisfy these requirements.
-
- e) Convey the object code using peer-to-peer transmission, provided
- you inform other peers where the object code and Corresponding
- Source of the work are being offered to the general public at no
- charge under subsection 6d.
-
- A separable portion of the object code, whose source code is excluded
-from the Corresponding Source as a System Library, need not be
-included in conveying the object code work.
-
- A "User Product" is either (1) a "consumer product", which means any
-tangible personal property which is normally used for personal, family,
-or household purposes, or (2) anything designed or sold for incorporation
-into a dwelling. In determining whether a product is a consumer product,
-doubtful cases shall be resolved in favor of coverage. For a particular
-product received by a particular user, "normally used" refers to a
-typical or common use of that class of product, regardless of the status
-of the particular user or of the way in which the particular user
-actually uses, or expects or is expected to use, the product. A product
-is a consumer product regardless of whether the product has substantial
-commercial, industrial or non-consumer uses, unless such uses represent
-the only significant mode of use of the product.
-
- "Installation Information" for a User Product means any methods,
-procedures, authorization keys, or other information required to install
-and execute modified versions of a covered work in that User Product from
-a modified version of its Corresponding Source. The information must
-suffice to ensure that the continued functioning of the modified object
-code is in no case prevented or interfered with solely because
-modification has been made.
-
- If you convey an object code work under this section in, or with, or
-specifically for use in, a User Product, and the conveying occurs as
-part of a transaction in which the right of possession and use of the
-User Product is transferred to the recipient in perpetuity or for a
-fixed term (regardless of how the transaction is characterized), the
-Corresponding Source conveyed under this section must be accompanied
-by the Installation Information. But this requirement does not apply
-if neither you nor any third party retains the ability to install
-modified object code on the User Product (for example, the work has
-been installed in ROM).
-
- The requirement to provide Installation Information does not include a
-requirement to continue to provide support service, warranty, or updates
-for a work that has been modified or installed by the recipient, or for
-the User Product in which it has been modified or installed. Access to a
-network may be denied when the modification itself materially and
-adversely affects the operation of the network or violates the rules and
-protocols for communication across the network.
-
- Corresponding Source conveyed, and Installation Information provided,
-in accord with this section must be in a format that is publicly
-documented (and with an implementation available to the public in
-source code form), and must require no special password or key for
-unpacking, reading or copying.
-
- 7. Additional Terms.
-
- "Additional permissions" are terms that supplement the terms of this
-License by making exceptions from one or more of its conditions.
-Additional permissions that are applicable to the entire Program shall
-be treated as though they were included in this License, to the extent
-that they are valid under applicable law. If additional permissions
-apply only to part of the Program, that part may be used separately
-under those permissions, but the entire Program remains governed by
-this License without regard to the additional permissions.
-
- When you convey a copy of a covered work, you may at your option
-remove any additional permissions from that copy, or from any part of
-it. (Additional permissions may be written to require their own
-removal in certain cases when you modify the work.) You may place
-additional permissions on material, added by you to a covered work,
-for which you have or can give appropriate copyright permission.
-
- Notwithstanding any other provision of this License, for material you
-add to a covered work, you may (if authorized by the copyright holders of
-that material) supplement the terms of this License with terms:
-
- a) Disclaiming warranty or limiting liability differently from the
- terms of sections 15 and 16 of this License; or
-
- b) Requiring preservation of specified reasonable legal notices or
- author attributions in that material or in the Appropriate Legal
- Notices displayed by works containing it; or
-
- c) Prohibiting misrepresentation of the origin of that material, or
- requiring that modified versions of such material be marked in
- reasonable ways as different from the original version; or
-
- d) Limiting the use for publicity purposes of names of licensors or
- authors of the material; or
-
- e) Declining to grant rights under trademark law for use of some
- trade names, trademarks, or service marks; or
-
- f) Requiring indemnification of licensors and authors of that
- material by anyone who conveys the material (or modified versions of
- it) with contractual assumptions of liability to the recipient, for
- any liability that these contractual assumptions directly impose on
- those licensors and authors.
-
- All other non-permissive additional terms are considered "further
-restrictions" within the meaning of section 10. If the Program as you
-received it, or any part of it, contains a notice stating that it is
-governed by this License along with a term that is a further
-restriction, you may remove that term. If a license document contains
-a further restriction but permits relicensing or conveying under this
-License, you may add to a covered work material governed by the terms
-of that license document, provided that the further restriction does
-not survive such relicensing or conveying.
-
- If you add terms to a covered work in accord with this section, you
-must place, in the relevant source files, a statement of the
-additional terms that apply to those files, or a notice indicating
-where to find the applicable terms.
-
- Additional terms, permissive or non-permissive, may be stated in the
-form of a separately written license, or stated as exceptions;
-the above requirements apply either way.
-
- 8. Termination.
-
- You may not propagate or modify a covered work except as expressly
-provided under this License. Any attempt otherwise to propagate or
-modify it is void, and will automatically terminate your rights under
-this License (including any patent licenses granted under the third
-paragraph of section 11).
-
- However, if you cease all violation of this License, then your
-license from a particular copyright holder is reinstated (a)
-provisionally, unless and until the copyright holder explicitly and
-finally terminates your license, and (b) permanently, if the copyright
-holder fails to notify you of the violation by some reasonable means
-prior to 60 days after the cessation.
-
- Moreover, your license from a particular copyright holder is
-reinstated permanently if the copyright holder notifies you of the
-violation by some reasonable means, this is the first time you have
-received notice of violation of this License (for any work) from that
-copyright holder, and you cure the violation prior to 30 days after
-your receipt of the notice.
-
- Termination of your rights under this section does not terminate the
-licenses of parties who have received copies or rights from you under
-this License. If your rights have been terminated and not permanently
-reinstated, you do not qualify to receive new licenses for the same
-material under section 10.
-
- 9. Acceptance Not Required for Having Copies.
-
- You are not required to accept this License in order to receive or
-run a copy of the Program. Ancillary propagation of a covered work
-occurring solely as a consequence of using peer-to-peer transmission
-to receive a copy likewise does not require acceptance. However,
-nothing other than this License grants you permission to propagate or
-modify any covered work. These actions infringe copyright if you do
-not accept this License. Therefore, by modifying or propagating a
-covered work, you indicate your acceptance of this License to do so.
-
- 10. Automatic Licensing of Downstream Recipients.
-
- Each time you convey a covered work, the recipient automatically
-receives a license from the original licensors, to run, modify and
-propagate that work, subject to this License. You are not responsible
-for enforcing compliance by third parties with this License.
-
- An "entity transaction" is a transaction transferring control of an
-organization, or substantially all assets of one, or subdividing an
-organization, or merging organizations. If propagation of a covered
-work results from an entity transaction, each party to that
-transaction who receives a copy of the work also receives whatever
-licenses to the work the party's predecessor in interest had or could
-give under the previous paragraph, plus a right to possession of the
-Corresponding Source of the work from the predecessor in interest, if
-the predecessor has it or can get it with reasonable efforts.
-
- You may not impose any further restrictions on the exercise of the
-rights granted or affirmed under this License. For example, you may
-not impose a license fee, royalty, or other charge for exercise of
-rights granted under this License, and you may not initiate litigation
-(including a cross-claim or counterclaim in a lawsuit) alleging that
-any patent claim is infringed by making, using, selling, offering for
-sale, or importing the Program or any portion of it.
-
- 11. Patents.
-
- A "contributor" is a copyright holder who authorizes use under this
-License of the Program or a work on which the Program is based. The
-work thus licensed is called the contributor's "contributor version".
-
- A contributor's "essential patent claims" are all patent claims
-owned or controlled by the contributor, whether already acquired or
-hereafter acquired, that would be infringed by some manner, permitted
-by this License, of making, using, or selling its contributor version,
-but do not include claims that would be infringed only as a
-consequence of further modification of the contributor version. For
-purposes of this definition, "control" includes the right to grant
-patent sublicenses in a manner consistent with the requirements of
-this License.
-
- Each contributor grants you a non-exclusive, worldwide, royalty-free
-patent license under the contributor's essential patent claims, to
-make, use, sell, offer for sale, import and otherwise run, modify and
-propagate the contents of its contributor version.
-
- In the following three paragraphs, a "patent license" is any express
-agreement or commitment, however denominated, not to enforce a patent
-(such as an express permission to practice a patent or covenant not to
-sue for patent infringement). To "grant" such a patent license to a
-party means to make such an agreement or commitment not to enforce a
-patent against the party.
-
- If you convey a covered work, knowingly relying on a patent license,
-and the Corresponding Source of the work is not available for anyone
-to copy, free of charge and under the terms of this License, through a
-publicly available network server or other readily accessible means,
-then you must either (1) cause the Corresponding Source to be so
-available, or (2) arrange to deprive yourself of the benefit of the
-patent license for this particular work, or (3) arrange, in a manner
-consistent with the requirements of this License, to extend the patent
-license to downstream recipients. "Knowingly relying" means you have
-actual knowledge that, but for the patent license, your conveying the
-covered work in a country, or your recipient's use of the covered work
-in a country, would infringe one or more identifiable patents in that
-country that you have reason to believe are valid.
-
- If, pursuant to or in connection with a single transaction or
-arrangement, you convey, or propagate by procuring conveyance of, a
-covered work, and grant a patent license to some of the parties
-receiving the covered work authorizing them to use, propagate, modify
-or convey a specific copy of the covered work, then the patent license
-you grant is automatically extended to all recipients of the covered
-work and works based on it.
-
- A patent license is "discriminatory" if it does not include within
-the scope of its coverage, prohibits the exercise of, or is
-conditioned on the non-exercise of one or more of the rights that are
-specifically granted under this License. You may not convey a covered
-work if you are a party to an arrangement with a third party that is
-in the business of distributing software, under which you make payment
-to the third party based on the extent of your activity of conveying
-the work, and under which the third party grants, to any of the
-parties who would receive the covered work from you, a discriminatory
-patent license (a) in connection with copies of the covered work
-conveyed by you (or copies made from those copies), or (b) primarily
-for and in connection with specific products or compilations that
-contain the covered work, unless you entered into that arrangement,
-or that patent license was granted, prior to 28 March 2007.
-
- Nothing in this License shall be construed as excluding or limiting
-any implied license or other defenses to infringement that may
-otherwise be available to you under applicable patent law.
-
- 12. No Surrender of Others' Freedom.
-
- If 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 convey a
-covered work so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you may
-not convey it at all. For example, if you agree to terms that obligate you
-to collect a royalty for further conveying from those to whom you convey
-the Program, the only way you could satisfy both those terms and this
-License would be to refrain entirely from conveying the Program.
-
- 13. Use with the GNU Affero General Public License.
-
- Notwithstanding any other provision of this License, you have
-permission to link or combine any covered work with a work licensed
-under version 3 of the GNU Affero General Public License into a single
-combined work, and to convey the resulting work. The terms of this
-License will continue to apply to the part which is the covered work,
-but the special requirements of the GNU Affero General Public License,
-section 13, concerning interaction through a network will apply to the
-combination as such.
-
- 14. Revised Versions of this License.
-
- The Free Software Foundation may publish revised and/or new versions of
-the GNU 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 that a certain numbered version of the GNU General
-Public License "or any later version" applies to it, you have the
-option of following the terms and conditions either of that numbered
-version or of any later version published by the Free Software
-Foundation. If the Program does not specify a version number of the
-GNU General Public License, you may choose any version ever published
-by the Free Software Foundation.
-
- If the Program specifies that a proxy can decide which future
-versions of the GNU General Public License can be used, that proxy's
-public statement of acceptance of a version permanently authorizes you
-to choose that version for the Program.
-
- Later license versions may give you additional or different
-permissions. However, no additional obligations are imposed on any
-author or copyright holder as a result of your choosing to follow a
-later version.
-
- 15. Disclaimer of Warranty.
-
- 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.
-
- 16. Limitation of Liability.
-
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
-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.
-
- 17. Interpretation of Sections 15 and 16.
-
- If the disclaimer of warranty and limitation of liability provided
-above cannot be given local legal effect according to their terms,
-reviewing courts shall apply local law that most closely approximates
-an absolute waiver of all civil liability in connection with the
-Program, unless a warranty or assumption of liability accompanies a
-copy of the Program in return for a fee.
-
- 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
-state the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
-
- Copyright (C)
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see .
-
-Also add information on how to contact you by electronic and paper mail.
-
- If the program does terminal interaction, make it output a short
-notice like this when it starts in an interactive mode:
-
- Copyright (C)
- This program 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, your program's commands
-might be different; for a GUI interface, you would use an "about box".
-
- You should also get your employer (if you work as a programmer) or school,
-if any, to sign a "copyright disclaimer" for the program, if necessary.
-For more information on this, and how to apply and follow the GNU GPL, see
-.
-
- The GNU 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. But first, please read
-.
+/*
+ * The dhcpd-pools has BSD 2-clause license which also known as "Simplified
+ * BSD License" or "FreeBSD License".
+ *
+ * Copyright 2006- Sami Kerola. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are
+ * those of the authors and should not be interpreted as representing
+ * official policies, either expressed or implied, of Sami Kerola.
+ */
diff --git a/configure.ac b/configure.ac
index eab7a1b..0894f27 100644
--- a/configure.ac
+++ b/configure.ac
@@ -42,10 +42,6 @@ AC_TYPE_SIZE_T
AC_FUNC_MALLOC
AC_CHECK_FUNCS([inet_ntoa memset strerror strstr strdup])
-# GNU commandline parsing in getopt.h present?
-AC_CHECK_HEADERS(getopt.h, AC_DEFINE(HAVE_GETOPT_H),
- import_sources="getopt.c getopt1.c $import_sources")
-
AC_CONFIG_FILES([Makefile
man/Makefile
src/Makefile
diff --git a/man/dhcpd-pools.1 b/man/dhcpd-pools.1
index 5a468e3..92a663c 100644
--- a/man/dhcpd-pools.1
+++ b/man/dhcpd-pools.1
@@ -130,10 +130,7 @@ Written by Sami Kerola.
.br
XML support by Dominic Germain, Sogetel inc.
.PP
-License GPLv3+: GNU GPL version 3 or later
-
-This is free software: you are free to change and redistribute it.
-There is NO WARRANTY, to the extent permitted by law.
+The software has FreeBSD License.
.SH "REPORTING BUGS"
Report bugs to
.br
diff --git a/src/Makefile.am b/src/Makefile.am
index 73a5f4c..d964c95 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -3,6 +3,6 @@
bin_PROGRAMS = dhcpd-pools
AC_PROG_RANLIB = resolv
-dhcpd_pools_SOURCES = dhcpd-pools.h defaults.h dhcpd-pools.c analyze.c getdata.c getopt1.c getopt.c other.c sort.c output.c getopt.h
+dhcpd_pools_SOURCES = dhcpd-pools.h defaults.h dhcpd-pools.c analyze.c getdata.c other.c sort.c output.c
INCLUDES = -I. -I..
diff --git a/src/analyze.c b/src/analyze.c
index a023f98..0032605 100644
--- a/src/analyze.c
+++ b/src/analyze.c
@@ -1,19 +1,37 @@
-/* http://dhcpd-pools.sourceforge.net/
-** Copyright 2006- Sami Kerola
-**
-** This program is free software: you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation, either version 3 of the License, or
-** (at your option) any later version.
-**
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-** GNU General Public License for more details.
-**
-** You should have received a copy of the GNU General Public License
-** along with this program. If not, see .
-*/
+/*
+ * The dhcpd-pools has BSD 2-clause license which also known as "Simplified
+ * BSD License" or "FreeBSD License".
+ *
+ * Copyright 2006- Sami Kerola. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are
+ * those of the authors and should not be interpreted as representing
+ * official policies, either expressed or implied, of Sami Kerola.
+ */
#include
#include
diff --git a/src/defaults.h b/src/defaults.h
index 8cb69e0..597da7c 100644
--- a/src/defaults.h
+++ b/src/defaults.h
@@ -1,19 +1,37 @@
-/* http://dhcpd-pools.sourceforge.net/
-** Copyright 2006- Sami Kerola
-**
-** This program is free software: you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation, either version 3 of the License, or
-** (at your option) any later version.
-**
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-** GNU General Public License for more details.
-**
-** You should have received a copy of the GNU General Public License
-** along with this program. If not, see .
-*/
+/*
+ * The dhcpd-pools has BSD 2-clause license which also known as "Simplified
+ * BSD License" or "FreeBSD License".
+ *
+ * Copyright 2006- Sami Kerola. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are
+ * those of the authors and should not be interpreted as representing
+ * official policies, either expressed or implied, of Sami Kerola.
+ */
#ifndef DEFAULTS_H
# define DEFAULTS_H 1
diff --git a/src/dhcpd-pools.c b/src/dhcpd-pools.c
index cf03db6..6c344cc 100644
--- a/src/dhcpd-pools.c
+++ b/src/dhcpd-pools.c
@@ -1,19 +1,37 @@
-/* http://dhcpd-pools.sourceforge.net/
-** Copyright 2006- Sami Kerola
-**
-** This program is free software: you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation, either version 3 of the License, or
-** (at your option) any later version.
-**
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-** GNU General Public License for more details.
-**
-** You should have received a copy of the GNU General Public License
-** along with this program. If not, see .
-*/
+/*
+ * The dhcpd-pools has BSD 2-clause license which also known as "Simplified
+ * BSD License" or "FreeBSD License".
+ *
+ * Copyright 2006- Sami Kerola. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are
+ * those of the authors and should not be interpreted as representing
+ * official policies, either expressed or implied, of Sami Kerola.
+ */
#ifdef HAVE_CONFIG_H
#include
diff --git a/src/dhcpd-pools.h b/src/dhcpd-pools.h
index c43bd33..dc7ab97 100644
--- a/src/dhcpd-pools.h
+++ b/src/dhcpd-pools.h
@@ -1,19 +1,37 @@
-/* http://dhcpd-pools.sourceforge.net/
-** Copyright 2006- Sami Kerola
-**
-** This program is free software: you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation, either version 3 of the License, or
-** (at your option) any later version.
-**
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-** GNU General Public License for more details.
-**
-** You should have received a copy of the GNU General Public License
-** along with this program. If not, see .
-*/
+/*
+ * The dhcpd-pools has BSD 2-clause license which also known as "Simplified
+ * BSD License" or "FreeBSD License".
+ *
+ * Copyright 2006- Sami Kerola. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are
+ * those of the authors and should not be interpreted as representing
+ * official policies, either expressed or implied, of Sami Kerola.
+ */
#ifndef DHCPD_POOLS_H
# define DHCPD_POOLS_H 1
diff --git a/src/getdata.c b/src/getdata.c
index 215c707..2c5e627 100644
--- a/src/getdata.c
+++ b/src/getdata.c
@@ -1,19 +1,37 @@
-/* http://dhcpd-pools.sourceforge.net/
-** Copyright 2006- Sami Kerola
-**
-** This program is free software: you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation, either version 3 of the License, or
-** (at your option) any later version.
-**
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-** GNU General Public License for more details.
-**
-** You should have received a copy of the GNU General Public License
-** along with this program. If not, see .
-*/
+/*
+ * The dhcpd-pools has BSD 2-clause license which also known as "Simplified
+ * BSD License" or "FreeBSD License".
+ *
+ * Copyright 2006- Sami Kerola. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are
+ * those of the authors and should not be interpreted as representing
+ * official policies, either expressed or implied, of Sami Kerola.
+ */
#ifdef HAVE_CONFIG_H
#include
diff --git a/src/getopt.c b/src/getopt.c
deleted file mode 100644
index 8f49931..0000000
--- a/src/getopt.c
+++ /dev/null
@@ -1,1042 +0,0 @@
-/* Getopt for GNU.
- NOTE: getopt is now part of the C library, so if you don't know what
- "Keep this file name-space clean" means, talk to drepper@gnu.org
- before changing it!
- Copyright (C) 1987,88,89,90,91,92,93,94,95,96,98,99,2000,2001
- Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- 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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/* This tells Alpha OSF/1 not to define a getopt prototype in .
- Ditto for AIX 3.2 and . */
-#ifndef _NO_PROTO
-# define _NO_PROTO
-#endif
-
-#include
-
-#if !defined __STDC__ || !__STDC__
-/* This is a separate conditional since some stdc systems
- reject `defined (const)'. */
-# ifndef const
-# define const
-# endif
-#endif
-
-/* Comment out all this code if we are using the GNU C Library, and are not
- actually compiling the library itself. This code is part of the GNU C
- Library, but also included in many other GNU distributions. Compiling
- and linking in this code is a waste when using the GNU C library
- (especially if it is a shared library). Rather than having every GNU
- program understand `configure --with-gnu-libc' and omit the object files,
- it is simpler to just do this in the source for each such file. */
-
-#define GETOPT_INTERFACE_VERSION 2
-#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2
-# include
-# if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION
-# define ELIDE_CODE
-# endif
-#endif
-
-#ifndef ELIDE_CODE
-
-
-/* This needs to come after some library #include
- to get __GNU_LIBRARY__ defined. */
-#ifdef __GNU_LIBRARY__
-/* Don't include stdlib.h for non-GNU C libraries because some of them
- contain conflicting prototypes for getopt. */
-# include
-# include
-#endif /* GNU C library. */
-
-#ifdef VMS
-# include
-# if HAVE_STRING_H - 0
-# include
-# endif
-#endif
-
-#ifndef _
-/* This is for other GNU distributions with internationalized messages. */
-# if (HAVE_LIBINTL_H && ENABLE_NLS) || defined _LIBC
-# include
-# ifndef _
-# define _(msgid) gettext (msgid)
-# endif
-# else
-# define _(msgid) (msgid)
-# endif
-#endif
-
-/* This version of `getopt' appears to the caller like standard Unix `getopt'
- but it behaves differently for the user, since it allows the user
- to intersperse the options with the other arguments.
-
- As `getopt' works, it permutes the elements of ARGV so that,
- when it is done, all the options precede everything else. Thus
- all application programs are extended to handle flexible argument order.
-
- Setting the environment variable POSIXLY_CORRECT disables permutation.
- Then the behavior is completely standard.
-
- GNU application programs can use a third alternative mode in which
- they can distinguish the relative order of options and other arguments. */
-
-#include "getopt.h"
-
-/* For communication from `getopt' to the caller.
- When `getopt' finds an option that takes an argument,
- the argument value is returned here.
- Also, when `ordering' is RETURN_IN_ORDER,
- each non-option ARGV-element is returned here. */
-
-char *optarg;
-
-/* Index in ARGV of the next element to be scanned.
- This is used for communication to and from the caller
- and for communication between successive calls to `getopt'.
-
- On entry to `getopt', zero means this is the first call; initialize.
-
- When `getopt' returns -1, this is the index of the first of the
- non-option elements that the caller should itself scan.
-
- Otherwise, `optind' communicates from one call to the next
- how much of ARGV has been scanned so far. */
-
-/* 1003.2 says this must be 1 before any call. */
-int optind = 1;
-
-/* Formerly, initialization of getopt depended on optind==0, which
- causes problems with re-calling getopt as programs generally don't
- know that. */
-
-int __getopt_initialized;
-
-/* The next char to be scanned in the option-element
- in which the last option character we returned was found.
- This allows us to pick up the scan where we left off.
-
- If this is zero, or a null string, it means resume the scan
- by advancing to the next ARGV-element. */
-
-static char *nextchar;
-
-/* Callers store zero here to inhibit the error message
- for unrecognized options. */
-
-int opterr = 1;
-
-/* Set to an option character which was unrecognized.
- This must be initialized on some systems to avoid linking in the
- system's own getopt implementation. */
-
-int optopt = '?';
-
-/* Describe how to deal with options that follow non-option ARGV-elements.
-
- If the caller did not specify anything,
- the default is REQUIRE_ORDER if the environment variable
- POSIXLY_CORRECT is defined, PERMUTE otherwise.
-
- REQUIRE_ORDER means don't recognize them as options;
- stop option processing when the first non-option is seen.
- This is what Unix does.
- This mode of operation is selected by either setting the environment
- variable POSIXLY_CORRECT, or using `+' as the first character
- of the list of option characters.
-
- PERMUTE is the default. We permute the contents of ARGV as we scan,
- so that eventually all the non-options are at the end. This allows options
- to be given in any order, even with programs that were not written to
- expect this.
-
- RETURN_IN_ORDER is an option available to programs that were written
- to expect options and other ARGV-elements in any order and that care about
- the ordering of the two. We describe each non-option ARGV-element
- as if it were the argument of an option with character code 1.
- Using `-' as the first character of the list of option characters
- selects this mode of operation.
-
- The special argument `--' forces an end of option-scanning regardless
- of the value of `ordering'. In the case of RETURN_IN_ORDER, only
- `--' can cause `getopt' to return -1 with `optind' != ARGC. */
-
-static enum {
- REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
-} ordering;
-
-/* Value of POSIXLY_CORRECT environment variable. */
-static char *posixly_correct;
-
-#ifdef __GNU_LIBRARY__
-/* We want to avoid inclusion of string.h with non-GNU libraries
- because there are many ways it can cause trouble.
- On some systems, it contains special magic macros that don't work
- in GCC. */
-# include
-# define my_index strchr
-#else
-
-# if HAVE_STRING_H
-# include
-# else
-# include
-# endif
-
-/* Avoid depending on library functions or files
- whose names are inconsistent. */
-
-#ifndef getenv
-extern char *getenv();
-#endif
-
-static char *my_index(str, chr)
-const char *str;
-int chr;
-{
- while (*str) {
- if (*str == chr)
- return (char *) str;
- str++;
- }
- return 0;
-}
-
-/* If using GCC, we can safely declare strlen this way.
- If not using GCC, it is ok not to declare it. */
-#ifdef __GNUC__
-/* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h.
- That was relevant to code that was here before. */
-# if (!defined __STDC__ || !__STDC__) && !defined strlen
-/* gcc with -traditional declares the built-in strlen to return int,
- and has done so at least since version 2.4.5. -- rms. */
-extern int strlen(const char *);
-# endif /* not __STDC__ */
-#endif /* __GNUC__ */
-
-#endif /* not __GNU_LIBRARY__ */
-
-/* Handle permutation of arguments. */
-
-/* Describe the part of ARGV that contains non-options that have
- been skipped. `first_nonopt' is the index in ARGV of the first of them;
- `last_nonopt' is the index after the last of them. */
-
-static int first_nonopt;
-static int last_nonopt;
-
-#ifdef _LIBC
-/* Bash 2.0 gives us an environment variable containing flags
- indicating ARGV elements that should not be considered arguments. */
-
-#ifdef USE_NONOPTION_FLAGS
-/* Defined in getopt_init.c */
-extern char *__getopt_nonoption_flags;
-
-static int nonoption_flags_max_len;
-static int nonoption_flags_len;
-#endif
-
-static int original_argc;
-static char *const *original_argv;
-
-/* Make sure the environment variable bash 2.0 puts in the environment
- is valid for the getopt call we must make sure that the ARGV passed
- to getopt is that one passed to the process. */
-static void
- __attribute__ ((unused)) store_args_and_env(int argc,
- char *const *argv)
-{
- /* XXX This is no good solution. We should rather copy the args so
- that we can compare them later. But we must not use malloc(3). */
- original_argc = argc;
- original_argv = argv;
-}
-
-# ifdef text_set_element
-text_set_element(__libc_subinit, store_args_and_env);
-# endif /* text_set_element */
-
-# ifdef USE_NONOPTION_FLAGS
-# define SWAP_FLAGS(ch1, ch2) \
- if (nonoption_flags_len > 0) \
- { \
- char __tmp = __getopt_nonoption_flags[ch1]; \
- __getopt_nonoption_flags[ch1] = __getopt_nonoption_flags[ch2]; \
- __getopt_nonoption_flags[ch2] = __tmp; \
- }
-# else
-# define SWAP_FLAGS(ch1, ch2)
-# endif
-#else /* !_LIBC */
-# define SWAP_FLAGS(ch1, ch2)
-#endif /* _LIBC */
-
-/* Exchange two adjacent subsequences of ARGV.
- One subsequence is elements [first_nonopt,last_nonopt)
- which contains all the non-options that have been skipped so far.
- The other is elements [last_nonopt,optind), which contains all
- the options processed since those non-options were skipped.
-
- `first_nonopt' and `last_nonopt' are relocated so that they describe
- the new indices of the non-options in ARGV after they are moved. */
-
-#if defined __STDC__ && __STDC__
-static void exchange(char **);
-#endif
-
-static void exchange(argv)
-char **argv;
-{
- int bottom = first_nonopt;
- int middle = last_nonopt;
- int top = optind;
- char *tem;
-
- /* Exchange the shorter segment with the far end of the longer segment.
- That puts the shorter segment into the right place.
- It leaves the longer segment in the right place overall,
- but it consists of two parts that need to be swapped next. */
-
-#if defined _LIBC && defined USE_NONOPTION_FLAGS
- /* First make sure the handling of the `__getopt_nonoption_flags'
- string can work normally. Our top argument must be in the range
- of the string. */
- if (nonoption_flags_len > 0 && top >= nonoption_flags_max_len) {
- /* We must extend the array. The user plays games with us and
- presents new arguments. */
- char *new_str = malloc(top + 1);
- if (new_str == NULL)
- nonoption_flags_len = nonoption_flags_max_len = 0;
- else {
- memset(__mempcpy(new_str, __getopt_nonoption_flags,
- nonoption_flags_max_len),
- '\0', top + 1 - nonoption_flags_max_len);
- nonoption_flags_max_len = top + 1;
- __getopt_nonoption_flags = new_str;
- }
- }
-#endif
-
- while (top > middle && middle > bottom) {
- if (top - middle > middle - bottom) {
- /* Bottom segment is the short one. */
- int len = middle - bottom;
- register int i;
-
- /* Swap it with the top part of the top segment. */
- for (i = 0; i < len; i++) {
- tem = argv[bottom + i];
- argv[bottom + i] =
- argv[top - (middle - bottom) + i];
- argv[top - (middle - bottom) + i] = tem;
- SWAP_FLAGS(bottom + i,
- top - (middle - bottom) + i);
- }
- /* Exclude the moved bottom segment from further swapping. */
- top -= len;
- } else {
- /* Top segment is the short one. */
- int len = top - middle;
- register int i;
-
- /* Swap it with the bottom part of the bottom segment. */
- for (i = 0; i < len; i++) {
- tem = argv[bottom + i];
- argv[bottom + i] = argv[middle + i];
- argv[middle + i] = tem;
- SWAP_FLAGS(bottom + i, middle + i);
- }
- /* Exclude the moved top segment from further swapping. */
- bottom += len;
- }
- }
-
- /* Update records for the slots the non-options now occupy. */
-
- first_nonopt += (optind - last_nonopt);
- last_nonopt = optind;
-}
-
-/* Initialize the internal data when the first call is made. */
-
-#if defined __STDC__ && __STDC__
-static const char *_getopt_initialize(int, char *const *, const char *);
-#endif
-static const char *_getopt_initialize(argc, argv, optstring)
-int argc;
-char *const *argv;
-const char *optstring;
-{
- /* Start processing options with ARGV-element 1 (since ARGV-element 0
- is the program name); the sequence of previously skipped
- non-option ARGV-elements is empty. */
-
- first_nonopt = last_nonopt = optind;
-
- nextchar = NULL;
-
- posixly_correct = getenv("POSIXLY_CORRECT");
-
- /* Determine how to handle the ordering of options and nonoptions. */
-
- if (optstring[0] == '-') {
- ordering = RETURN_IN_ORDER;
- ++optstring;
- } else if (optstring[0] == '+') {
- ordering = REQUIRE_ORDER;
- ++optstring;
- } else if (posixly_correct != NULL)
- ordering = REQUIRE_ORDER;
- else
- ordering = PERMUTE;
-
-#if defined _LIBC && defined USE_NONOPTION_FLAGS
- if (posixly_correct == NULL
- && argc == original_argc && argv == original_argv) {
- if (nonoption_flags_max_len == 0) {
- if (__getopt_nonoption_flags == NULL
- || __getopt_nonoption_flags[0] == '\0')
- nonoption_flags_max_len = -1;
- else {
- const char *orig_str =
- __getopt_nonoption_flags;
- int len = nonoption_flags_max_len =
- strlen(orig_str);
- if (nonoption_flags_max_len < argc)
- nonoption_flags_max_len = argc;
- __getopt_nonoption_flags = (char *)
- malloc(nonoption_flags_max_len);
- if (__getopt_nonoption_flags == NULL)
- nonoption_flags_max_len = -1;
- else
- memset(__mempcpy
- (__getopt_nonoption_flags,
- orig_str, len), '\0',
- nonoption_flags_max_len -
- len);
- }
- }
- nonoption_flags_len = nonoption_flags_max_len;
- } else
- nonoption_flags_len = 0;
-#endif
-
- return optstring;
-}
-
-/* Scan elements of ARGV (whose length is ARGC) for option characters
- given in OPTSTRING.
-
- If an element of ARGV starts with '-', and is not exactly "-" or "--",
- then it is an option element. The characters of this element
- (aside from the initial '-') are option characters. If `getopt'
- is called repeatedly, it returns successively each of the option characters
- from each of the option elements.
-
- If `getopt' finds another option character, it returns that character,
- updating `optind' and `nextchar' so that the next call to `getopt' can
- resume the scan with the following option character or ARGV-element.
-
- If there are no more option characters, `getopt' returns -1.
- Then `optind' is the index in ARGV of the first ARGV-element
- that is not an option. (The ARGV-elements have been permuted
- so that those that are not options now come last.)
-
- OPTSTRING is a string containing the legitimate option characters.
- If an option character is seen that is not listed in OPTSTRING,
- return '?' after printing an error message. If you set `opterr' to
- zero, the error message is suppressed but we still return '?'.
-
- If a char in OPTSTRING is followed by a colon, that means it wants an arg,
- so the following text in the same ARGV-element, or the text of the following
- ARGV-element, is returned in `optarg'. Two colons mean an option that
- wants an optional arg; if there is text in the current ARGV-element,
- it is returned in `optarg', otherwise `optarg' is set to zero.
-
- If OPTSTRING starts with `-' or `+', it requests different methods of
- handling the non-option ARGV-elements.
- See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above.
-
- Long-named options begin with `--' instead of `-'.
- Their names may be abbreviated as long as the abbreviation is unique
- or is an exact match for some defined option. If they have an
- argument, it follows the option name in the same ARGV-element, separated
- from the option name by a `=', or else the in next ARGV-element.
- When `getopt' finds a long-named option, it returns 0 if that option's
- `flag' field is nonzero, the value of the option's `val' field
- if the `flag' field is zero.
-
- The elements of ARGV aren't really const, because we permute them.
- But we pretend they're const in the prototype to be compatible
- with other systems.
-
- LONGOPTS is a vector of `struct option' terminated by an
- element containing a name which is zero.
-
- LONGIND returns the index in LONGOPT of the long-named option found.
- It is only valid when a long-named option has been found by the most
- recent call.
-
- If LONG_ONLY is nonzero, '-' as well as '--' can introduce
- long-named options. */
-
-int _getopt_internal(argc, argv, optstring, longopts, longind, long_only)
-int argc;
-char *const *argv;
-const char *optstring;
-const struct option *longopts;
-int *longind;
-int long_only;
-{
- int print_errors = opterr;
- if (optstring[0] == ':')
- print_errors = 0;
-
- if (argc < 1)
- return -1;
-
- optarg = NULL;
-
- if (optind == 0 || !__getopt_initialized) {
- if (optind == 0)
- optind = 1; /* Don't scan ARGV[0], the program name. */
- optstring = _getopt_initialize(argc, argv, optstring);
- __getopt_initialized = 1;
- }
-
- /* Test whether ARGV[optind] points to a non-option argument.
- Either it does not have option syntax, or there is an environment flag
- from the shell indicating it is not an option. The later information
- is only used when the used in the GNU libc. */
-#if defined _LIBC && defined USE_NONOPTION_FLAGS
-# define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0' \
- || (optind < nonoption_flags_len \
- && __getopt_nonoption_flags[optind] == '1'))
-#else
-# define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0')
-#endif
-
- if (nextchar == NULL || *nextchar == '\0') {
- /* Advance to the next ARGV-element. */
-
- /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been
- moved back by the user (who may also have changed the arguments). */
- if (last_nonopt > optind)
- last_nonopt = optind;
- if (first_nonopt > optind)
- first_nonopt = optind;
-
- if (ordering == PERMUTE) {
- /* If we have just processed some options following some non-options,
- exchange them so that the options come first. */
-
- if (first_nonopt != last_nonopt
- && last_nonopt != optind)
- exchange((char **) argv);
- else if (last_nonopt != optind)
- first_nonopt = optind;
-
- /* Skip any additional non-options
- and extend the range of non-options previously skipped. */
-
- while (optind < argc && NONOPTION_P)
- optind++;
- last_nonopt = optind;
- }
-
- /* The special ARGV-element `--' means premature end of options.
- Skip it like a null option,
- then exchange with previous non-options as if it were an option,
- then skip everything else like a non-option. */
-
- if (optind != argc && !strcmp(argv[optind], "--")) {
- optind++;
-
- if (first_nonopt != last_nonopt
- && last_nonopt != optind)
- exchange((char **) argv);
- else if (first_nonopt == last_nonopt)
- first_nonopt = optind;
- last_nonopt = argc;
-
- optind = argc;
- }
-
- /* If we have done all the ARGV-elements, stop the scan
- and back over any non-options that we skipped and permuted. */
-
- if (optind == argc) {
- /* Set the next-arg-index to point at the non-options
- that we previously skipped, so the caller will digest them. */
- if (first_nonopt != last_nonopt)
- optind = first_nonopt;
- return -1;
- }
-
- /* If we have come to a non-option and did not permute it,
- either stop the scan or describe it to the caller and pass it by. */
-
- if (NONOPTION_P) {
- if (ordering == REQUIRE_ORDER)
- return -1;
- optarg = argv[optind++];
- return 1;
- }
-
- /* We have found another option-ARGV-element.
- Skip the initial punctuation. */
-
- nextchar = (argv[optind] + 1
- + (longopts != NULL
- && argv[optind][1] == '-'));
- }
-
- /* Decode the current option-ARGV-element. */
-
- /* Check whether the ARGV-element is a long option.
-
- If long_only and the ARGV-element has the form "-f", where f is
- a valid short option, don't consider it an abbreviated form of
- a long option that starts with f. Otherwise there would be no
- way to give the -f short option.
-
- On the other hand, if there's a long option "fubar" and
- the ARGV-element is "-fu", do consider that an abbreviation of
- the long option, just like "--fu", and not "-f" with arg "u".
-
- This distinction seems to be the most useful approach. */
-
- if (longopts != NULL
- && (argv[optind][1] == '-' || (long_only && (argv[optind][2]
- ||
- !my_index
- (optstring,
- argv[optind]
- [1]))))) {
- char *nameend;
- const struct option *p;
- const struct option *pfound = NULL;
- int exact = 0;
- int ambig = 0;
- int indfound = -1;
- int option_index;
-
- for (nameend = nextchar; *nameend && *nameend != '=';
- nameend++)
- /* Do nothing. */ ;
-
- /* Test all long options for either exact match
- or abbreviated matches. */
- for (p = longopts, option_index = 0; p->name;
- p++, option_index++)
- if (!strncmp
- (p->name, nextchar, nameend - nextchar)) {
- if ((unsigned int) (nameend - nextchar)
- == (unsigned int) strlen(p->name)) {
- /* Exact match found. */
- pfound = p;
- indfound = option_index;
- exact = 1;
- break;
- } else if (pfound == NULL) {
- /* First nonexact match found. */
- pfound = p;
- indfound = option_index;
- } else if (long_only
- || pfound->has_arg != p->has_arg
- || pfound->flag != p->flag
- || pfound->val != p->val)
- /* Second or later nonexact match found. */
- ambig = 1;
- }
-
- if (ambig && !exact) {
- if (print_errors)
- fprintf(stderr,
- _
- ("%s: option `%s' is ambiguous\n"),
- argv[0], argv[optind]);
- nextchar += strlen(nextchar);
- optind++;
- optopt = 0;
- return '?';
- }
-
- if (pfound != NULL) {
- option_index = indfound;
- optind++;
- if (*nameend) {
- /* Don't test has_arg with >, because some C compilers don't
- allow it to be used on enums. */
- if (pfound->has_arg)
- optarg = nameend + 1;
- else {
- if (print_errors) {
- if (argv[optind - 1][1] ==
- '-')
- /* --option */
- fprintf(stderr,
- _
- ("%s: option `--%s' doesn't allow an argument\n"),
- argv[0],
- pfound->
- name);
- else
- /* +option or -option */
- fprintf(stderr,
- _
- ("%s: option `%c%s' doesn't allow an argument\n"),
- argv[0],
- argv[optind
- -
- 1][0],
- pfound->
- name);
- }
-
- nextchar += strlen(nextchar);
-
- optopt = pfound->val;
- return '?';
- }
- } else if (pfound->has_arg == 1) {
- if (optind < argc)
- optarg = argv[optind++];
- else {
- if (print_errors)
- fprintf(stderr,
- _
- ("%s: option `%s' requires an argument\n"),
- argv[0],
- argv[optind - 1]);
- nextchar += strlen(nextchar);
- optopt = pfound->val;
- return optstring[0] ==
- ':' ? ':' : '?';
- }
- }
- nextchar += strlen(nextchar);
- if (longind != NULL)
- *longind = option_index;
- if (pfound->flag) {
- *(pfound->flag) = pfound->val;
- return 0;
- }
- return pfound->val;
- }
-
- /* Can't find it as a long option. If this is not getopt_long_only,
- or the option starts with '--' or is not a valid short
- option, then it's an error.
- Otherwise interpret it as a short option. */
- if (!long_only || argv[optind][1] == '-'
- || my_index(optstring, *nextchar) == NULL) {
- if (print_errors) {
- if (argv[optind][1] == '-')
- /* --option */
- fprintf(stderr,
- _
- ("%s: unrecognized option `--%s'\n"),
- argv[0], nextchar);
- else
- /* +option or -option */
- fprintf(stderr,
- _
- ("%s: unrecognized option `%c%s'\n"),
- argv[0], argv[optind][0],
- nextchar);
- }
- nextchar = (char *) "";
- optind++;
- optopt = 0;
- return '?';
- }
- }
-
- /* Look at and handle the next short option-character. */
-
- {
- char c = *nextchar++;
- char *temp = my_index(optstring, c);
-
- /* Increment `optind' when we start to process its last character. */
- if (*nextchar == '\0')
- ++optind;
-
- if (temp == NULL || c == ':') {
- if (print_errors) {
- if (posixly_correct)
- /* 1003.2 specifies the format of this message. */
- fprintf(stderr,
- _
- ("%s: illegal option -- %c\n"),
- argv[0], c);
- else
- fprintf(stderr,
- _
- ("%s: invalid option -- %c\n"),
- argv[0], c);
- }
- optopt = c;
- return '?';
- }
- /* Convenience. Treat POSIX -W foo same as long option --foo */
- if (temp[0] == 'W' && temp[1] == ';') {
- char *nameend;
- const struct option *p;
- const struct option *pfound = NULL;
- int exact = 0;
- int ambig = 0;
- int indfound = 0;
- int option_index;
-
- /* This is an option that requires an argument. */
- if (*nextchar != '\0') {
- optarg = nextchar;
- /* If we end this ARGV-element by taking the rest as an arg,
- we must advance to the next element now. */
- optind++;
- } else if (optind == argc) {
- if (print_errors) {
- /* 1003.2 specifies the format of this message. */
- fprintf(stderr,
- _
- ("%s: option requires an argument -- %c\n"),
- argv[0], c);
- }
- optopt = c;
- if (optstring[0] == ':')
- c = ':';
- else
- c = '?';
- return c;
- } else
- /* We already incremented `optind' once;
- increment it again when taking next ARGV-elt as argument. */
- optarg = argv[optind++];
-
- /* optarg is now the argument, see if it's in the
- table of longopts. */
-
- for (nextchar = nameend = optarg;
- *nameend && *nameend != '='; nameend++)
- /* Do nothing. */ ;
-
- /* Test all long options for either exact match
- or abbreviated matches. */
- for (p = longopts, option_index = 0; p->name;
- p++, option_index++)
- if (!strncmp
- (p->name, nextchar,
- nameend - nextchar)) {
- if ((unsigned int) (nameend -
- nextchar) ==
- strlen(p->name)) {
- /* Exact match found. */
- pfound = p;
- indfound = option_index;
- exact = 1;
- break;
- } else if (pfound == NULL) {
- /* First nonexact match found. */
- pfound = p;
- indfound = option_index;
- } else
- /* Second or later nonexact match found. */
- ambig = 1;
- }
- if (ambig && !exact) {
- if (print_errors)
- fprintf(stderr,
- _
- ("%s: option `-W %s' is ambiguous\n"),
- argv[0], argv[optind]);
- nextchar += strlen(nextchar);
- optind++;
- return '?';
- }
- if (pfound != NULL) {
- option_index = indfound;
- if (*nameend) {
- /* Don't test has_arg with >, because some C compilers don't
- allow it to be used on enums. */
- if (pfound->has_arg)
- optarg = nameend + 1;
- else {
- if (print_errors)
- fprintf(stderr, _("\
-%s: option `-W %s' doesn't allow an argument\n"), argv[0], pfound->
- name);
-
- nextchar +=
- strlen(nextchar);
- return '?';
- }
- } else if (pfound->has_arg == 1) {
- if (optind < argc)
- optarg = argv[optind++];
- else {
- if (print_errors)
- fprintf(stderr,
- _
- ("%s: option `%s' requires an argument\n"),
- argv[0],
- argv[optind
- - 1]);
- nextchar +=
- strlen(nextchar);
- return optstring[0] ==
- ':' ? ':' : '?';
- }
- }
- nextchar += strlen(nextchar);
- if (longind != NULL)
- *longind = option_index;
- if (pfound->flag) {
- *(pfound->flag) = pfound->val;
- return 0;
- }
- return pfound->val;
- }
- nextchar = NULL;
- return 'W'; /* Let the application handle it. */
- }
- if (temp[1] == ':') {
- if (temp[2] == ':') {
- /* This is an option that accepts an argument optionally. */
- if (*nextchar != '\0') {
- optarg = nextchar;
- optind++;
- } else
- optarg = NULL;
- nextchar = NULL;
- } else {
- /* This is an option that requires an argument. */
- if (*nextchar != '\0') {
- optarg = nextchar;
- /* If we end this ARGV-element by taking the rest as an arg,
- we must advance to the next element now. */
- optind++;
- } else if (optind == argc) {
- if (print_errors) {
- /* 1003.2 specifies the format of this message. */
- fprintf(stderr,
- _
- ("%s: option requires an argument -- %c\n"),
- argv[0], c);
- }
- optopt = c;
- if (optstring[0] == ':')
- c = ':';
- else
- c = '?';
- } else
- /* We already incremented `optind' once;
- increment it again when taking next ARGV-elt as argument. */
- optarg = argv[optind++];
- nextchar = NULL;
- }
- }
- return c;
- }
-}
-
-int getopt(argc, argv, optstring)
-int argc;
-char *const *argv;
-const char *optstring;
-{
- return _getopt_internal(argc, argv, optstring,
- (const struct option *) 0, (int *) 0, 0);
-}
-
-#endif /* Not ELIDE_CODE. */
-
-#ifdef TEST
-
-/* Compile with -DTEST to make an executable for use in testing
- the above definition of `getopt'. */
-
-int main(argc, argv)
-int argc;
-char **argv;
-{
- int c;
- int digit_optind = 0;
-
- while (1) {
- int this_option_optind = optind ? optind : 1;
-
- c = getopt(argc, argv, "abc:d:0123456789");
- if (c == -1)
- break;
-
- switch (c) {
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- if (digit_optind != 0
- && digit_optind != this_option_optind)
- printf
- ("digits occur in two different argv-elements.\n");
- digit_optind = this_option_optind;
- printf("option %c\n", c);
- break;
-
- case 'a':
- printf("option a\n");
- break;
-
- case 'b':
- printf("option b\n");
- break;
-
- case 'c':
- printf("option c with value `%s'\n", optarg);
- break;
-
- case '?':
- break;
-
- default:
- printf
- ("?? getopt returned character code 0%o ??\n",
- c);
- }
- }
-
- if (optind < argc) {
- printf("non-option ARGV-elements: ");
- while (optind < argc)
- printf("%s ", argv[optind++]);
- printf("\n");
- }
-
- exit(0);
-}
-
-#endif /* TEST */
diff --git a/src/getopt.h b/src/getopt.h
deleted file mode 100644
index 39c9e4f..0000000
--- a/src/getopt.h
+++ /dev/null
@@ -1,183 +0,0 @@
-/* Declarations for getopt.
- Copyright (C) 1989-1994, 1996-1999, 2001 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- 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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#ifndef _GETOPT_H
-
-#ifndef __need_getopt
-# define _GETOPT_H 1
-#endif
-
-/* If __GNU_LIBRARY__ is not already defined, either we are being used
- standalone, or this is the first header included in the source file.
- If we are being used with glibc, we need to include , but
- that does not exist if we are standalone. So: if __GNU_LIBRARY__ is
- not defined, include , which will pull in for us
- if it's from glibc. (Why ctype.h? It's guaranteed to exist and it
- doesn't flood the namespace with stuff the way some other headers do.) */
-#if !defined __GNU_LIBRARY__
-# include
-#endif
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-/* For communication from `getopt' to the caller.
- When `getopt' finds an option that takes an argument,
- the argument value is returned here.
- Also, when `ordering' is RETURN_IN_ORDER,
- each non-option ARGV-element is returned here. */
-
- extern char *optarg;
-
-/* Index in ARGV of the next element to be scanned.
- This is used for communication to and from the caller
- and for communication between successive calls to `getopt'.
-
- On entry to `getopt', zero means this is the first call; initialize.
-
- When `getopt' returns -1, this is the index of the first of the
- non-option elements that the caller should itself scan.
-
- Otherwise, `optind' communicates from one call to the next
- how much of ARGV has been scanned so far. */
-
- extern int optind;
-
-/* Callers store zero here to inhibit the error message `getopt' prints
- for unrecognized options. */
-
- extern int opterr;
-
-/* Set to an option character which was unrecognized. */
-
- extern int optopt;
-
-#ifndef __need_getopt
-/* Describe the long-named options requested by the application.
- The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
- of `struct option' terminated by an element containing a name which is
- zero.
-
- The field `has_arg' is:
- no_argument (or 0) if the option does not take an argument,
- required_argument (or 1) if the option requires an argument,
- optional_argument (or 2) if the option takes an optional argument.
-
- If the field `flag' is not NULL, it points to a variable that is set
- to the value given in the field `val' when the option is found, but
- left unchanged if the option is not found.
-
- To have a long-named option do something other than set an `int' to
- a compiled-in constant, such as set a value from `optarg', set the
- option's `flag' field to zero and its `val' field to a nonzero
- value (the equivalent single-letter option character, if there is
- one). For long options that have a zero `flag' field, `getopt'
- returns the contents of the `val' field. */
-
- struct option
- {
-# if (defined __STDC__ && __STDC__) || defined __cplusplus
- const char *name;
-# else
- char *name;
-# endif
- /* has_arg can't be an enum because some compilers complain about
- type mismatches in all the code that assumes it is an int. */
- int has_arg;
- int *flag;
- int val;
- };
-
-/* Names for the values of the `has_arg' field of `struct option'. */
-
-# define no_argument 0
-# define required_argument 1
-# define optional_argument 2
-#endif /* need getopt */
-
-
-/* Get definitions and prototypes for functions to process the
- arguments in ARGV (ARGC of them, minus the program name) for
- options given in OPTS.
-
- Return the option character from OPTS just read. Return -1 when
- there are no more options. For unrecognized options, or options
- missing arguments, `optopt' is set to the option letter, and '?' is
- returned.
-
- The OPTS string is a list of characters which are recognized option
- letters, optionally followed by colons, specifying that that letter
- takes an argument, to be placed in `optarg'.
-
- If a letter in OPTS is followed by two colons, its argument is
- optional. This behavior is specific to the GNU `getopt'.
-
- The argument `--' causes premature termination of argument
- scanning, explicitly telling `getopt' that there are no more
- options.
-
- If OPTS begins with `--', then non-option arguments are treated as
- arguments to the option '\0'. This behavior is specific to the GNU
- `getopt'. */
-
-#if (defined __STDC__ && __STDC__) || defined __cplusplus
-# ifdef __GNU_LIBRARY__
-/* Many other libraries have conflicting prototypes for getopt, with
- differences in the consts, in stdlib.h. To avoid compilation
- errors, only prototype getopt for the GNU C library. */
- extern int getopt (int __argc, char *const *__argv,
- const char *__shortopts);
-# else /* not __GNU_LIBRARY__ */
- extern int getopt ();
-# endif /* __GNU_LIBRARY__ */
-
-# ifndef __need_getopt
- extern int getopt_long (int __argc, char *const *__argv,
- const char *__shortopts,
- const struct option *__longopts, int *__longind);
- extern int getopt_long_only (int __argc, char *const *__argv,
- const char *__shortopts,
- const struct option *__longopts,
- int *__longind);
-
-/* Internal only. Users should not call this directly. */
- extern int _getopt_internal (int __argc, char *const *__argv,
- const char *__shortopts,
- const struct option *__longopts,
- int *__longind, int __long_only);
-# endif
-#else /* not __STDC__ */
- extern int getopt ();
-# ifndef __need_getopt
- extern int getopt_long ();
- extern int getopt_long_only ();
-
- extern int _getopt_internal ();
-# endif
-#endif /* __STDC__ */
-
-#ifdef __cplusplus
-}
-#endif
-
-/* Make sure we later can get all the definitions and declarations. */
-#undef __need_getopt
-
-#endif /* getopt.h */
diff --git a/src/getopt1.c b/src/getopt1.c
deleted file mode 100644
index 652ae07..0000000
--- a/src/getopt1.c
+++ /dev/null
@@ -1,181 +0,0 @@
-/* getopt_long and getopt_long_only entry points for GNU getopt.
- Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98
- Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- 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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include
-
-#if !defined __STDC__ || !__STDC__
-/* This is a separate conditional since some stdc systems
- reject `defined (const)'. */
-#ifndef const
-#define const
-#endif
-#endif
-
-/* Comment out all this code if we are using the GNU C Library, and are not
- actually compiling the library itself. This code is part of the GNU C
- Library, but also included in many other GNU distributions. Compiling
- and linking in this code is a waste when using the GNU C library
- (especially if it is a shared library). Rather than having every GNU
- program understand `configure --with-gnu-libc' and omit the object files,
- it is simpler to just do this in the source for each such file. */
-
-#define GETOPT_INTERFACE_VERSION 2
-#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2
-#include
-#if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION
-#define ELIDE_CODE
-#endif
-#endif
-
-#ifndef ELIDE_CODE
-
-
-/* This needs to come after some library #include
- to get __GNU_LIBRARY__ defined. */
-#ifdef __GNU_LIBRARY__
-#include
-#endif
-
-#ifndef NULL
-#define NULL 0
-#endif
-
-int getopt_long(argc, argv, options, long_options, opt_index)
-int argc;
-char *const *argv;
-const char *options;
-const struct option *long_options;
-int *opt_index;
-{
- return _getopt_internal(argc, argv, options, long_options,
- opt_index, 0);
-}
-
-/* Like getopt_long, but '-' as well as '--' can indicate a long option.
- If an option that starts with '-' (not '--') doesn't match a long option,
- but does match a short option, it is parsed as a short option
- instead. */
-
-int getopt_long_only(argc, argv, options, long_options, opt_index)
-int argc;
-char *const *argv;
-const char *options;
-const struct option *long_options;
-int *opt_index;
-{
- return _getopt_internal(argc, argv, options, long_options,
- opt_index, 1);
-}
-
-
-#endif /* Not ELIDE_CODE. */
-
-#ifdef TEST
-
-#include
-
-int main(argc, argv)
-int argc;
-char **argv;
-{
- int c;
- int digit_optind = 0;
-
- while (1) {
- int this_option_optind = optind ? optind : 1;
- int option_index = 0;
- static struct option long_options[] = {
- {"add", 1, 0, 0},
- {"append", 0, 0, 0},
- {"delete", 1, 0, 0},
- {"verbose", 0, 0, 0},
- {"create", 0, 0, 0},
- {"file", 1, 0, 0},
- {0, 0, 0, 0}
- };
-
- c = getopt_long(argc, argv, "abc:d:0123456789",
- long_options, &option_index);
- if (c == -1)
- break;
-
- switch (c) {
- case 0:
- printf("option %s",
- long_options[option_index].name);
- if (optarg)
- printf(" with arg %s", optarg);
- printf("\n");
- break;
-
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- if (digit_optind != 0
- && digit_optind != this_option_optind)
- printf
- ("digits occur in two different argv-elements.\n");
- digit_optind = this_option_optind;
- printf("option %c\n", c);
- break;
-
- case 'a':
- printf("option a\n");
- break;
-
- case 'b':
- printf("option b\n");
- break;
-
- case 'c':
- printf("option c with value `%s'\n", optarg);
- break;
-
- case 'd':
- printf("option d with value `%s'\n", optarg);
- break;
-
- case '?':
- break;
-
- default:
- printf
- ("?? getopt returned character code 0%o ??\n",
- c);
- }
- }
-
- if (optind < argc) {
- printf("non-option ARGV-elements: ");
- while (optind < argc)
- printf("%s ", argv[optind++]);
- printf("\n");
- }
-
- exit(0);
-}
-
-#endif /* TEST */
diff --git a/src/other.c b/src/other.c
index 2cf3599..49b064a 100644
--- a/src/other.c
+++ b/src/other.c
@@ -1,19 +1,37 @@
-/* http://dhcpd-pools.sourceforge.net/
-** Copyright 2006- Sami Kerola
-**
-** This program is free software: you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation, either version 3 of the License, or
-** (at your option) any later version.
-**
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-** GNU General Public License for more details.
-**
-** You should have received a copy of the GNU General Public License
-** along with this program. If not, see .
-*/
+/*
+ * The dhcpd-pools has BSD 2-clause license which also known as "Simplified
+ * BSD License" or "FreeBSD License".
+ *
+ * Copyright 2006- Sami Kerola. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are
+ * those of the authors and should not be interpreted as representing
+ * official policies, either expressed or implied, of Sami Kerola.
+ */
#ifdef HAVE_CONFIG_H
#include
@@ -111,11 +129,7 @@ void print_version(void)
fprintf(stdout,
"Written by Sami Kerola.\nXML support by Dominic Germain, Sogetel inc.\n\n");
fprintf(stdout,
- "License GPLv3+: GNU GPL version 3 or later \n");
- fprintf(stdout,
- "This is free software: you are free to change and redistribute it.\n");
- fprintf(stdout,
- "There is NO WARRANTY, to the extent permitted by law.\n");
+ "The software has FreeBSD License.\n");
exit(EXIT_SUCCESS);
}
diff --git a/src/output.c b/src/output.c
index 86423d9..5daa610 100644
--- a/src/output.c
+++ b/src/output.c
@@ -1,19 +1,37 @@
-/* http://dhcpd-pools.sourceforge.net/
-** Copyright 2006- Sami Kerola
-**
-** This program is free software: you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation, either version 3 of the License, or
-** (at your option) any later version.
-**
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-** GNU General Public License for more details.
-**
-** You should have received a copy of the GNU General Public License
-** along with this program. If not, see .
-*/
+/*
+ * The dhcpd-pools has BSD 2-clause license which also known as "Simplified
+ * BSD License" or "FreeBSD License".
+ *
+ * Copyright 2006- Sami Kerola. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are
+ * those of the authors and should not be interpreted as representing
+ * official policies, either expressed or implied, of Sami Kerola.
+ */
#ifdef HAVE_CONFIG_H
#include
diff --git a/src/sort.c b/src/sort.c
index 460f4cd..1a010a1 100644
--- a/src/sort.c
+++ b/src/sort.c
@@ -1,19 +1,37 @@
-/* http://dhcpd-pools.sourceforge.net/
-** Copyright 2006- Sami Kerola
-**
-** This program is free software: you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation, either version 3 of the License, or
-** (at your option) any later version.
-**
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-** GNU General Public License for more details.
-**
-** You should have received a copy of the GNU General Public License
-** along with this program. If not, see .
-*/
+/*
+ * The dhcpd-pools has BSD 2-clause license which also known as "Simplified
+ * BSD License" or "FreeBSD License".
+ *
+ * Copyright 2006- Sami Kerola. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are
+ * those of the authors and should not be interpreted as representing
+ * official policies, either expressed or implied, of Sami Kerola.
+ */
#include
#include
From 8d94580c3deef2f0a303333fff23b5ab4a31da4c Mon Sep 17 00:00:00 2001
From: Sami Kerola
Date: Thu, 23 Jun 2011 15:59:06 +0200
Subject: [PATCH 007/401] parse_leases: exit at read error
Signed-off-by: Sami Kerola
---
src/getdata.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/getdata.c b/src/getdata.c
index 2c5e627..b0a3f5c 100644
--- a/src/getdata.c
+++ b/src/getdata.c
@@ -130,7 +130,9 @@ int parse_leases(void)
}
while (!feof(dhcpd_leases)) {
- fgets(line, MAXLEN, dhcpd_leases);
+ if (!fgets(line, MAXLEN, dhcpd_leases) && ferror(dhcpd_leases)) {
+ err(EXIT_FAILURE, "parse_leases: %s", config.dhcpdlease_file);
+ }
/* It's a lease, save IP */
if (strstr(line, "lease") == line) {
strncpy(ipstring, line, (size_t) MAXLEN);
From c28488cbe8978b5b826944cdda5d626efe8ea102 Mon Sep 17 00:00:00 2001
From: Sami Kerola
Date: Fri, 8 Jul 2011 14:36:47 +0200
Subject: [PATCH 008/401] getdata: realloc instead of asserting
Ahmed reported he saw the following error with version 2.15 which
is an indication of unusual high number of clients that has been
seen. I am not sure where that happen, but I suspect an airport
or some other 'lots of mobiles getting leases' might be able to
case same situation.
dhcpd-pools: getdata.c:136: parse_leases: Assertion `!(touchesmallocsize < num_touches)' failed.
The problem was quite easy to fix simply getting rid of assert
and putting realloc in place.
Reported-by: Ahmed AL Dakhil
Signed-off-by: Sami Kerola
---
src/getdata.c | 26 ++++++++++++++++++++------
1 file changed, 20 insertions(+), 6 deletions(-)
diff --git a/src/getdata.c b/src/getdata.c
index b0a3f5c..4e878e2 100644
--- a/src/getdata.c
+++ b/src/getdata.c
@@ -78,9 +78,9 @@ int parse_leases(void)
struct in_addr inp;
struct stat lease_file_stats;
struct macaddr_t *macaddr_p = NULL;
- unsigned long leasesmallocsize;
- unsigned long touchesmallocsize;
- unsigned long backupsmallocsize;
+ size_t leasesmallocsize;
+ size_t touchesmallocsize;
+ size_t backupsmallocsize;
int sw_active_lease = 0;
num_touches = num_leases = num_backups = 0;
@@ -144,12 +144,21 @@ int parse_leases(void)
else if (strstr(line, "binding state active")) {
leases[num_leases] = htonl(inp.s_addr);
num_leases++;
- assert(!(leasesmallocsize < num_leases));
+ if (leasesmallocsize < num_leases) {
+ leasesmallocsize =
+ sizeof(unsigned long int) * num_leases * 2;
+ leases = safe_realloc(leases, leasesmallocsize);
+ }
sw_active_lease = 1;
} else if (strstr(line, " binding state free")) {
touches[num_touches] = htonl(inp.s_addr);
num_touches++;
- assert(!(touchesmallocsize < num_touches));
+ if (touchesmallocsize < num_touches) {
+ touchesmallocsize =
+ sizeof(unsigned long int) * num_touches * 2;
+ touches =
+ safe_realloc(touches, touchesmallocsize);
+ }
} else if (strstr(line, " binding state backup")) {
if (num_backups == 0) {
backups =
@@ -158,7 +167,12 @@ int parse_leases(void)
}
backups[num_backups] = htonl(inp.s_addr);
num_backups++;
- assert(!(backupsmallocsize < num_backups));
+ if (backupsmallocsize < num_backups) {
+ backupsmallocsize =
+ sizeof(unsigned long int) * num_backups * 2;
+ backups =
+ safe_realloc(backups, backupsmallocsize);
+ }
}
if ((macaddr != NULL)
From 3c1d033a79ebae20618a4285353c9ae1b5c27a12 Mon Sep 17 00:00:00 2001
From: Sami Kerola
Date: Fri, 8 Jul 2011 15:27:15 +0200
Subject: [PATCH 009/401] getdata: potential overflow due unit change
The commit c28488cbe8978b5b826944cdda5d626efe8ea102 introduced
potential memory overflow due unintentional unit change.
Signed-off-by: Sami Kerola
---
src/getdata.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/getdata.c b/src/getdata.c
index 4e878e2..097e1ad 100644
--- a/src/getdata.c
+++ b/src/getdata.c
@@ -148,6 +148,7 @@ int parse_leases(void)
leasesmallocsize =
sizeof(unsigned long int) * num_leases * 2;
leases = safe_realloc(leases, leasesmallocsize);
+ leasesmallocsize /= sizeof(unsigned long int);
}
sw_active_lease = 1;
} else if (strstr(line, " binding state free")) {
@@ -158,6 +159,7 @@ int parse_leases(void)
sizeof(unsigned long int) * num_touches * 2;
touches =
safe_realloc(touches, touchesmallocsize);
+ touchesmallocsize /= sizeof(unsigned long int);
}
} else if (strstr(line, " binding state backup")) {
if (num_backups == 0) {
@@ -172,6 +174,7 @@ int parse_leases(void)
sizeof(unsigned long int) * num_backups * 2;
backups =
safe_realloc(backups, backupsmallocsize);
+ backupsmallocsize /= sizeof(unsigned long int);
}
}
From 1e82461875373748d619acd72791d0af2d2cb621 Mon Sep 17 00:00:00 2001
From: Sami Kerola
Date: Fri, 8 Jul 2011 16:28:22 +0200
Subject: [PATCH 010/401] bug: use uint32_t for IP numbers
There where long and unsigned long used for IPs in use which
caused occasional off by one errors. The word occasional should
be read: pretty much every one with large enough configuration
has been affected.
Signed-off-by: Sami Kerola
---
src/analyze.c | 6 +++---
src/dhcpd-pools.h | 11 ++++++-----
src/getdata.c | 12 ++++++------
src/output.c | 9 ++++++---
src/sort.c | 4 ++--
5 files changed, 23 insertions(+), 19 deletions(-)
diff --git a/src/analyze.c b/src/analyze.c
index 0032605..e914940 100644
--- a/src/analyze.c
+++ b/src/analyze.c
@@ -44,7 +44,7 @@ int prepare_data(void)
unsigned long int i, j, k;
/* Sort leases */
- qsort(leases, (size_t) num_leases, sizeof(long int), &intcomp);
+ qsort(leases, (size_t) num_leases, sizeof(uint32_t), &intcomp);
/* Get rid of lease dublicates */
for (k = j = i = 0; i < num_leases; i++) {
@@ -67,7 +67,7 @@ int prepare_data(void)
}
}
num_touches = j;
- qsort(touches, (size_t) num_touches, sizeof(long int), &intcomp);
+ qsort(touches, (size_t) num_touches, sizeof(uint32_t), &intcomp);
/* Sort ranges */
qsort(ranges, (size_t) num_ranges, sizeof(struct range_t),
@@ -75,7 +75,7 @@ int prepare_data(void)
/* Sort backups */
if (0 < num_backups) {
- qsort(backups, (size_t) num_backups, sizeof(long int),
+ qsort(backups, (size_t) num_backups, sizeof(uint32_t),
&intcomp);
}
diff --git a/src/dhcpd-pools.h b/src/dhcpd-pools.h
index dc7ab97..f20bf02 100644
--- a/src/dhcpd-pools.h
+++ b/src/dhcpd-pools.h
@@ -37,6 +37,7 @@
# define DHCPD_POOLS_H 1
#include
+#include
#include
/* Feature test switches */
@@ -103,8 +104,8 @@ struct shared_network_t {
};
struct range_t {
struct shared_network_t *shared_net;
- unsigned long int first_ip;
- unsigned long int last_ip;
+ uint32_t first_ip;
+ uint32_t last_ip;
unsigned long int count;
unsigned long int touched;
unsigned long int backups;
@@ -132,13 +133,13 @@ unsigned int num_shared_networks;
struct range_t *ranges;
unsigned int num_ranges;
-unsigned long int *leases;
+uint32_t *leases;
unsigned long int num_leases;
-unsigned long int *touches;
+uint32_t *touches;
unsigned long int num_touches;
-unsigned long int *backups;
+uint32_t *backups;
unsigned long int num_backups;
struct macaddr_t *macaddr;
diff --git a/src/getdata.c b/src/getdata.c
index 097e1ad..6cbd27b 100644
--- a/src/getdata.c
+++ b/src/getdata.c
@@ -146,9 +146,9 @@ int parse_leases(void)
num_leases++;
if (leasesmallocsize < num_leases) {
leasesmallocsize =
- sizeof(unsigned long int) * num_leases * 2;
+ sizeof(uint32_t) * num_leases * 2;
leases = safe_realloc(leases, leasesmallocsize);
- leasesmallocsize /= sizeof(unsigned long int);
+ leasesmallocsize /= sizeof(uint32_t);
}
sw_active_lease = 1;
} else if (strstr(line, " binding state free")) {
@@ -156,10 +156,10 @@ int parse_leases(void)
num_touches++;
if (touchesmallocsize < num_touches) {
touchesmallocsize =
- sizeof(unsigned long int) * num_touches * 2;
+ sizeof(uint32_t) * num_touches * 2;
touches =
safe_realloc(touches, touchesmallocsize);
- touchesmallocsize /= sizeof(unsigned long int);
+ touchesmallocsize /= sizeof(uint32_t);
}
} else if (strstr(line, " binding state backup")) {
if (num_backups == 0) {
@@ -171,10 +171,10 @@ int parse_leases(void)
num_backups++;
if (backupsmallocsize < num_backups) {
backupsmallocsize =
- sizeof(unsigned long int) * num_backups * 2;
+ sizeof(uint32_t) * num_backups * 2;
backups =
safe_realloc(backups, backupsmallocsize);
- backupsmallocsize /= sizeof(unsigned long int);
+ backupsmallocsize /= sizeof(uint32_t);
}
}
diff --git a/src/output.c b/src/output.c
index 5daa610..19a5d30 100644
--- a/src/output.c
+++ b/src/output.c
@@ -43,6 +43,9 @@
#include
#include
+#define _FILE_OFFSET_BITS 64
+#include
+
#include "dhcpd-pools.h"
int output_txt(void)
@@ -90,7 +93,7 @@ int output_txt(void)
}
fprintf(outfile, "%-16s", inet_ntoa(first));
fprintf(outfile,
- " - %-16s %5lu %5lu %10.3f %5lu %5lu %9.3f",
+ " - %-16s %5"PRIu32" %5lu %10.3f %5lu %5lu %9.3f",
inet_ntoa(last),
range_p->last_ip - range_p->first_ip - 1,
range_p->count,
@@ -256,7 +259,7 @@ int output_xml(void)
fprintf(outfile, "- %s\n",
inet_ntoa(last));
fprintf(outfile, "\t\n");
- fprintf(outfile, "\t%lu\n",
+ fprintf(outfile, "\t%"PRIu32"\n",
range_p->last_ip - range_p->first_ip - 1);
fprintf(outfile, "\t%lu\n",
range_p->count);
@@ -679,7 +682,7 @@ int output_csv(void)
}
fprintf(outfile, "\"%s\",", inet_ntoa(first));
fprintf(outfile,
- "\"%s\",\"%lu\",\"%lu\",\"%.3f\",\"%lu\",\"%lu\",\"%.3f\"",
+ "\"%s\",\"%"PRIu32"\",\"%lu\",\"%.3f\",\"%lu\",\"%lu\",\"%.3f\"",
inet_ntoa(last),
range_p->last_ip - range_p->first_ip - 1,
range_p->count,
diff --git a/src/sort.c b/src/sort.c
index 1a010a1..31c0739 100644
--- a/src/sort.c
+++ b/src/sort.c
@@ -44,9 +44,9 @@
/* Sort functions for range sorting */
int intcomp(const void *x, const void *y)
{
- if (*(unsigned long int *) x < *(unsigned long int *) y)
+ if (*(uint32_t *) x < *(uint32_t *) y)
return -1;
- else if (*(unsigned long int *) y < *(unsigned long int *) x)
+ else if (*(uint32_t *) y < *(uint32_t *) x)
return 1;
else
return 0;
From 12271887db4f6e48cea65de787f006a3cabddc19 Mon Sep 17 00:00:00 2001
From: Sami Kerola
Date: Fri, 8 Jul 2011 17:03:12 +0200
Subject: [PATCH 011/401] analyze: use more logical variable names
Signed-off-by: Sami Kerola
---
src/analyze.c | 29 ++++++++++++++---------------
1 file changed, 14 insertions(+), 15 deletions(-)
diff --git a/src/analyze.c b/src/analyze.c
index e914940..f0409ce 100644
--- a/src/analyze.c
+++ b/src/analyze.c
@@ -86,17 +86,16 @@ int prepare_data(void)
int do_counting(void)
{
struct range_t *range_p;
- unsigned int i, j, k, m, block_size;
+ unsigned int i, j, k, l, block_size;
- i = j = m = 0;
range_p = ranges;
/* Walk through ranges */
- for (k = 0; k < num_ranges; k++) {
+ for (i = j = k = l = 0; i < num_ranges; i++) {
/* Count IPs in use */
- for (; leases[i] < range_p->last_ip
- && (unsigned long) i < num_leases; i++) {
- if (leases[i] < range_p->first_ip) {
+ for (j = j; leases[j] < range_p->last_ip
+ && (unsigned long) j < num_leases; j++) {
+ if (leases[j] < range_p->first_ip) {
continue;
}
/* IP with in range */
@@ -107,9 +106,9 @@ int do_counting(void)
}
/* Count touched IPs */
- for (; touches[j] < range_p->last_ip
- && (unsigned long) j < num_touches; j++) {
- if (touches[j] < range_p->first_ip) {
+ for (k = k; touches[k] < range_p->last_ip
+ && (unsigned long) k < num_touches; k++) {
+ if (touches[k] < range_p->first_ip) {
continue;
}
/* IP with in range */
@@ -121,9 +120,9 @@ int do_counting(void)
/* Count backup IPs */
if (0 < num_backups) {
- for (; backups[m] < range_p->last_ip
- && (unsigned long) m < num_touches; m++) {
- if (touches[m] < range_p->first_ip) {
+ for (; backups[l] < range_p->last_ip
+ && (unsigned long) l < num_touches; l++) {
+ if (touches[l] < range_p->first_ip) {
continue;
}
/* IP with in range */
@@ -144,12 +143,12 @@ int do_counting(void)
/* Go backwards one step so that not even a one IP will be
* missed. This is possibly always unnecessary. */
- if (i) {
- i--;
- }
if (j) {
j--;
}
+ if (k) {
+ k--;
+ }
range_p++;
}
From d02b68413329870fc006d78a8ec2e1f4a967a8f8 Mon Sep 17 00:00:00 2001
From: Sami Kerola
Date: Fri, 8 Jul 2011 17:34:39 +0200
Subject: [PATCH 012/401] getdata: initialize memory
Signed-off-by: Sami Kerola
---
src/getdata.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/getdata.c b/src/getdata.c
index 6cbd27b..fca6573 100644
--- a/src/getdata.c
+++ b/src/getdata.c
@@ -120,6 +120,9 @@ int parse_leases(void)
touches =
safe_malloc((size_t) sizeof(long int) * touchesmallocsize);
+ memset(leases, 0, sizeof(long int) * leasesmallocsize);
+ memset(touches, 0, sizeof(long int) * touchesmallocsize);
+
line = safe_malloc(sizeof(long int) * MAXLEN);
ipstring = safe_malloc(sizeof(long int) * MAXLEN);
if (config.output_format[0] == 'X') {
From 26db4eafdc927ab1c66c3e56c052a979ffdd0466 Mon Sep 17 00:00:00 2001
From: Sami Kerola
Date: Fri, 8 Jul 2011 18:02:36 +0200
Subject: [PATCH 013/401] all: include-what-you-see fixes
After uint32_t fix from 1e82461875373748d619acd72791d0af2d2cb621
it was good idea to check which headers where needed where. And
generally clean up the includes while doing the check.
---
src/analyze.c | 3 +++
src/dhcpd-pools.c | 10 +++++-----
src/getdata.c | 5 ++---
src/other.c | 16 ++++++++--------
src/output.c | 2 --
src/sort.c | 2 ++
6 files changed, 20 insertions(+), 18 deletions(-)
diff --git a/src/analyze.c b/src/analyze.c
index f0409ce..9bbc16f 100644
--- a/src/analyze.c
+++ b/src/analyze.c
@@ -33,7 +33,10 @@
* official policies, either expressed or implied, of Sami Kerola.
*/
+/* #include */
+
#include
+#include
#include
#include "dhcpd-pools.h"
diff --git a/src/dhcpd-pools.c b/src/dhcpd-pools.c
index 6c344cc..bcd3d32 100644
--- a/src/dhcpd-pools.c
+++ b/src/dhcpd-pools.c
@@ -33,24 +33,24 @@
* official policies, either expressed or implied, of Sami Kerola.
*/
-#ifdef HAVE_CONFIG_H
#include
-#endif
-#include
#ifdef HAVE_STDLIB_H
#include
-#else /* Not STDC_HEADERS */
+#else
extern char *malloc();
-#endif /* STDC_HEADERS */
+#endif
+
#ifdef HAVE_STRING_H
#include
#else
#include
#endif
+
#include
#include
#include
+#include
#include "defaults.h"
#include "dhcpd-pools.h"
diff --git a/src/getdata.c b/src/getdata.c
index fca6573..adc4f7d 100644
--- a/src/getdata.c
+++ b/src/getdata.c
@@ -33,9 +33,7 @@
* official policies, either expressed or implied, of Sami Kerola.
*/
-#ifdef HAVE_CONFIG_H
#include
-#endif
#ifdef HAVE_STDLIB_H
#include
@@ -60,14 +58,15 @@ extern char *malloc();
#include
#include
#include
+#include
#include
#include
#ifndef _XOPEN_SOURCE
#define _XOPEN_SOURCE 600
#endif
-#include "dhcpd-pools.h"
#include "defaults.h"
+#include "dhcpd-pools.h"
/* Parse dhcpd.leases file. All performance boosts for this function are
* wellcome */
diff --git a/src/other.c b/src/other.c
index 49b064a..d3c81fb 100644
--- a/src/other.c
+++ b/src/other.c
@@ -33,28 +33,28 @@
* official policies, either expressed or implied, of Sami Kerola.
*/
-#ifdef HAVE_CONFIG_H
#include
-#endif
#include "dhcpd-pools.h"
-#include
#ifdef HAVE_STDLIB_H
#include
-#else /* Not STDC_HEADERS */
+#else
extern void exit();
extern char *malloc();
-#endif /* STDC_HEADERS */
-#include
-#include
-#include
+#endif
+
#ifdef HAVE_STRING_H
#include
#else
#include
#endif
+#include
+#include
+#include
+#include
+
/* Simple memory allocation wrapper */
void *safe_malloc(const size_t size)
{
diff --git a/src/output.c b/src/output.c
index 19a5d30..b0b0cfe 100644
--- a/src/output.c
+++ b/src/output.c
@@ -33,9 +33,7 @@
* official policies, either expressed or implied, of Sami Kerola.
*/
-#ifdef HAVE_CONFIG_H
#include
-#endif
#include
#include
diff --git a/src/sort.c b/src/sort.c
index 31c0739..a562996 100644
--- a/src/sort.c
+++ b/src/sort.c
@@ -34,8 +34,10 @@
*/
#include
+
#include
#include
+#include
#include
#include
From d29fd809c9263073301e0032ab6d32e63e6abb84 Mon Sep 17 00:00:00 2001
From: Sami Kerola
Date: Fri, 8 Jul 2011 18:05:20 +0200
Subject: [PATCH 014/401] analyze: debugging leftover removed
My stupid mistake to leave statement hanging around while I where
wondering where the uninitialized memory came from.
Signed-off-by: Sami Kerola
---
src/analyze.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/analyze.c b/src/analyze.c
index 9bbc16f..c38cd55 100644
--- a/src/analyze.c
+++ b/src/analyze.c
@@ -96,7 +96,7 @@ int do_counting(void)
/* Walk through ranges */
for (i = j = k = l = 0; i < num_ranges; i++) {
/* Count IPs in use */
- for (j = j; leases[j] < range_p->last_ip
+ for (; leases[j] < range_p->last_ip
&& (unsigned long) j < num_leases; j++) {
if (leases[j] < range_p->first_ip) {
continue;
@@ -109,7 +109,7 @@ int do_counting(void)
}
/* Count touched IPs */
- for (k = k; touches[k] < range_p->last_ip
+ for (; touches[k] < range_p->last_ip
&& (unsigned long) k < num_touches; k++) {
if (touches[k] < range_p->first_ip) {
continue;
From 68c2d7b8cc7544dff31d6675c5e66f304c415bd9 Mon Sep 17 00:00:00 2001
From: Sami Kerola
Date: Fri, 8 Jul 2011 20:04:17 +0200
Subject: [PATCH 015/401] THANKS: add Ahmed AL Dakhil
Signed-off-by: Sami Kerola
---
THANKS | 1 +
1 file changed, 1 insertion(+)
diff --git a/THANKS b/THANKS
index 6735a5a..46d1efc 100644
--- a/THANKS
+++ b/THANKS
@@ -17,3 +17,4 @@ Stian
Dominic Germain
Anders Låstad
Thor Eivind Brantzeg
+Ahmed AL Dakhil
From 76915512b244823706664a185339376432f913dc Mon Sep 17 00:00:00 2001
From: Sami Kerola
Date: Fri, 8 Jul 2011 20:49:49 +0200
Subject: [PATCH 016/401] maint: coding style fixes
Remove unnecessary type casting, move .gitignore file contents to
right location, reindent to use Linux coding style, fix few type
mismatches, clean up to help & version output and hint compiler
call to these functions will end program.
Signed-off-by: Sami Kerola
---
.gitignore | 5 +-
src/.gitignore | 6 ++
src/analyze.c | 16 ++---
src/defaults.h | 2 +-
src/dhcpd-pools.c | 44 ++++++------
src/dhcpd-pools.h | 14 +---
src/getdata.c | 37 +++++-----
src/other.c | 28 ++++----
src/output.c | 169 +++++++++++++++++++++-------------------------
src/sort.c | 16 ++---
10 files changed, 148 insertions(+), 189 deletions(-)
diff --git a/.gitignore b/.gitignore
index f4fb084..b663d88 100644
--- a/.gitignore
+++ b/.gitignore
@@ -21,8 +21,5 @@ Makefile.in
man/Makefile
man/Makefile.in
missing
-src/.deps/
-src/Makefile
-src/Makefile.in
-src/*.o
stamp-h1
+tags
diff --git a/src/.gitignore b/src/.gitignore
index b586827..8dc22f3 100644
--- a/src/.gitignore
+++ b/src/.gitignore
@@ -1 +1,7 @@
+*~
+*.o
+.deps/
dhcpd-pools
+Makefile
+Makefile.in
+tags
diff --git a/src/analyze.c b/src/analyze.c
index c38cd55..0887b17 100644
--- a/src/analyze.c
+++ b/src/analyze.c
@@ -73,8 +73,7 @@ int prepare_data(void)
qsort(touches, (size_t) num_touches, sizeof(uint32_t), &intcomp);
/* Sort ranges */
- qsort(ranges, (size_t) num_ranges, sizeof(struct range_t),
- &rangecomp);
+ qsort(ranges, (size_t) num_ranges, sizeof(struct range_t), &rangecomp);
/* Sort backups */
if (0 < num_backups) {
@@ -89,15 +88,14 @@ int prepare_data(void)
int do_counting(void)
{
struct range_t *range_p;
- unsigned int i, j, k, l, block_size;
+ unsigned long i, j, k, l, block_size;
range_p = ranges;
/* Walk through ranges */
for (i = j = k = l = 0; i < num_ranges; i++) {
/* Count IPs in use */
- for (; leases[j] < range_p->last_ip
- && (unsigned long) j < num_leases; j++) {
+ for (; leases[j] < range_p->last_ip && j < num_leases; j++) {
if (leases[j] < range_p->first_ip) {
continue;
}
@@ -109,8 +107,7 @@ int do_counting(void)
}
/* Count touched IPs */
- for (; touches[k] < range_p->last_ip
- && (unsigned long) k < num_touches; k++) {
+ for (; touches[k] < range_p->last_ip && k < num_touches; k++) {
if (touches[k] < range_p->first_ip) {
continue;
}
@@ -124,7 +121,7 @@ int do_counting(void)
/* Count backup IPs */
if (0 < num_backups) {
for (; backups[l] < range_p->last_ip
- && (unsigned long) l < num_touches; l++) {
+ && l < num_touches; l++) {
if (touches[l] < range_p->first_ip) {
continue;
}
@@ -138,8 +135,7 @@ int do_counting(void)
/* Size of range, shared net & all networks */
block_size =
- (unsigned int) (range_p->last_ip - range_p->first_ip -
- 1);
+ (unsigned int)(range_p->last_ip - range_p->first_ip - 1);
if (range_p->shared_net) {
range_p->shared_net->available += block_size;
}
diff --git a/src/defaults.h b/src/defaults.h
index 597da7c..4994732 100644
--- a/src/defaults.h
+++ b/src/defaults.h
@@ -37,7 +37,7 @@
# define DEFAULTS_H 1
/* Maximum line length in dhcpd.conf and dhcpd.leases */
-static const int MAXLEN = 1024;
+static const size_t MAXLEN = 1024;
/* Maximum number of shared networks */
static const unsigned int SHARED_NETWORKS = 8192;
diff --git a/src/dhcpd-pools.c b/src/dhcpd-pools.c
index bcd3d32..a23c69f 100644
--- a/src/dhcpd-pools.c
+++ b/src/dhcpd-pools.c
@@ -64,16 +64,16 @@ int main(int argc, char **argv)
/* Options for getopt_long */
static struct option const long_options[] = {
- {"config", required_argument, 0, (int) 'c'},
- {"leases", required_argument, 0, (int) 'l'},
- {"format", required_argument, 0, (int) 'f'},
- {"sort", required_argument, 0, (int) 's'},
- {"reverse", no_argument, 0, (int) 'r'},
- {"output", required_argument, 0, (int) 'o'},
- {"limit", required_argument, 0, (int) 'L'},
- {"version", no_argument, 0, (int) 'v'},
- {"help", no_argument, 0, (int) 'h'},
- {0, 0, 0, 0}
+ {"config", required_argument, NULL, 'c'},
+ {"leases", required_argument, NULL, 'l'},
+ {"format", required_argument, NULL, 'f'},
+ {"sort", required_argument, NULL, 's'},
+ {"reverse", no_argument, NULL, 'r'},
+ {"output", required_argument, NULL, 'o'},
+ {"limit", required_argument, NULL, 'L'},
+ {"version", no_argument, NULL, 'v'},
+ {"help", no_argument, NULL, 'h'},
+ {NULL, 0, NULL, 0}
};
/* FIXME: make these allocations dynamic up on need. */
@@ -86,14 +86,12 @@ int main(int argc, char **argv)
config.output_file[0] = '\0';
/* File location defaults */
- strncpy(config.dhcpdconf_file, DHCPDCONF_FILE,
- (size_t) MAXLEN - 1);
- strncpy(config.dhcpdlease_file, DHCPDLEASE_FILE,
- (size_t) MAXLEN - 1);
+ strncpy(config.dhcpdconf_file, DHCPDCONF_FILE, MAXLEN - 1);
+ strncpy(config.dhcpdlease_file, DHCPDLEASE_FILE, MAXLEN - 1);
tmp = OUTPUT_LIMIT;
- config.output_limit[0] = (int) (*tmp - '0');
+ config.output_limit[0] = (*tmp - '0');
tmp++;
- config.output_limit[1] = (int) (*tmp - '0');
+ config.output_limit[1] = (*tmp - '0');
fullhtml = false;
/* Make sure some output format is selected by default */
@@ -113,13 +111,11 @@ int main(int argc, char **argv)
switch (c) {
case 'c':
/* config file */
- strncpy(config.dhcpdconf_file, optarg,
- (size_t) MAXLEN - 1);
+ strncpy(config.dhcpdconf_file, optarg, MAXLEN - 1);
break;
case 'l':
/* lease file */
- strncpy(config.dhcpdlease_file, optarg,
- (size_t) MAXLEN - 1);
+ strncpy(config.dhcpdlease_file, optarg, MAXLEN - 1);
break;
case 'f':
/* Output format */
@@ -134,8 +130,7 @@ int main(int argc, char **argv)
strncpy(config.sort, optarg, (size_t) 5);
sorts = 5;
} else {
- strncpy(config.sort, optarg,
- (size_t) sorts);
+ strncpy(config.sort, optarg, (size_t) sorts);
}
for (i = 0; i < sorts; i++) {
field_selector(config.sort[i]);
@@ -147,15 +142,14 @@ int main(int argc, char **argv)
break;
case 'o':
/* Output file */
- strncpy(config.output_file, optarg,
- (size_t) MAXLEN - 1);
+ strncpy(config.output_file, optarg, MAXLEN - 1);
break;
case 'L':
/* Specification what will be printed */
for (i = 0; i < 2; i++) {
if (optarg[i] >= '0' && optarg[i] < '8') {
config.output_limit[i] =
- (int) optarg[i] - '0';
+ optarg[i] - '0';
} else {
errx(EXIT_FAILURE,
"main: output mask `%s' is illegal",
diff --git a/src/dhcpd-pools.h b/src/dhcpd-pools.h
index f20bf02..437384b 100644
--- a/src/dhcpd-pools.h
+++ b/src/dhcpd-pools.h
@@ -65,8 +65,8 @@ extern char *__progname;
# define program_invocation_short_name \
prog_inv_sh_nm_from_file(__FILE__, 1)
# endif /* HAVE_PROGRAM_INVOCATION_SHORT_NAME */
-static char prog_inv_sh_nm_buf[256];
-static inline char *prog_inv_sh_nm_from_file(char *f, char stripext)
+char prog_inv_sh_nm_buf[256];
+inline char *prog_inv_sh_nm_from_file(char *f, char stripext)
{
char *t;
if ((t = strrchr(f, '/')) != NULL) {
@@ -119,29 +119,21 @@ struct macaddr_t {
/* Global variables */
static int const true = 1;
static int const false = 0;
-
struct configuration_t config;
-
static int const output_limit_bit_1 = 1;
static int const output_limit_bit_2 = 2;
static int const output_limit_bit_3 = 4;
unsigned int fullhtml;
-
struct shared_network_t *shared_networks;
unsigned int num_shared_networks;
-
struct range_t *ranges;
unsigned int num_ranges;
-
uint32_t *leases;
unsigned long int num_leases;
-
uint32_t *touches;
unsigned long int num_touches;
-
uint32_t *backups;
unsigned long int num_backups;
-
struct macaddr_t *macaddr;
/* Function prototypes */
@@ -159,7 +151,7 @@ int prepare_data(void);
int do_counting(void);
void flip_ranges(struct range_t *ranges, struct range_t *tmp_ranges)
__attribute__ ((nonnull(1, 2)));
-/* General support functions */
+/* support functions */
void *safe_malloc(const size_t size)
#if __GNUC__ >= 3
__attribute__ ((__malloc__))
diff --git a/src/getdata.c b/src/getdata.c
index adc4f7d..507234c 100644
--- a/src/getdata.c
+++ b/src/getdata.c
@@ -86,18 +86,17 @@ int parse_leases(void)
dhcpd_leases = fopen(config.dhcpdlease_file, "r");
if (dhcpd_leases == NULL) {
- err(EXIT_FAILURE, "parse_leases: %s",
- config.dhcpdlease_file);
+ err(EXIT_FAILURE, "parse_leases: %s", config.dhcpdlease_file);
}
#ifdef POSIX_FADV_WILLNEED
- posix_fadvise((long) dhcpd_leases, 0, 0, POSIX_FADV_WILLNEED);
+ posix_fadvise(fileno(dhcpd_leases), 0, 0, POSIX_FADV_WILLNEED);
if (errno) {
err(EXIT_FAILURE, "parse_leases: fadvise %s",
config.dhcpdlease_file);
}
#endif /* POSIX_FADV_WILLNEED */
#ifdef POSIX_FADV_SEQUENTIAL
- posix_fadvise((long) dhcpd_leases, 0, 0, POSIX_FADV_SEQUENTIAL);
+ posix_fadvise(fileno(dhcpd_leases), 0, 0, POSIX_FADV_SEQUENTIAL);
if (errno) {
err(EXIT_FAILURE, "parse_leases: fadvise %s",
config.dhcpdlease_file);
@@ -109,15 +108,13 @@ int parse_leases(void)
* If someone has higher density in lease file I'm interested to
* hear about that. */
if (stat(config.dhcpdlease_file, &lease_file_stats)) {
- err(EXIT_FAILURE, "parse_leases: %s",
- config.dhcpdlease_file);
+ err(EXIT_FAILURE, "parse_leases: %s", config.dhcpdlease_file);
}
leasesmallocsize = (lease_file_stats.st_size / 250) + MAXLEN - 2;
touchesmallocsize = (lease_file_stats.st_size / 250) + MAXLEN - 2;
backupsmallocsize = (lease_file_stats.st_size / 120) + MAXLEN - 2;
leases = safe_malloc(sizeof(long int) * leasesmallocsize);
- touches =
- safe_malloc((size_t) sizeof(long int) * touchesmallocsize);
+ touches = safe_malloc((size_t) sizeof(long int) * touchesmallocsize);
memset(leases, 0, sizeof(long int) * leasesmallocsize);
memset(touches, 0, sizeof(long int) * touchesmallocsize);
@@ -133,11 +130,12 @@ int parse_leases(void)
while (!feof(dhcpd_leases)) {
if (!fgets(line, MAXLEN, dhcpd_leases) && ferror(dhcpd_leases)) {
- err(EXIT_FAILURE, "parse_leases: %s", config.dhcpdlease_file);
+ err(EXIT_FAILURE, "parse_leases: %s",
+ config.dhcpdlease_file);
}
/* It's a lease, save IP */
if (strstr(line, "lease") == line) {
- strncpy(ipstring, line, (size_t) MAXLEN);
+ strncpy(ipstring, line, MAXLEN);
nth_field(2, ipstring, ipstring);
inet_aton(ipstring, &inp);
sw_active_lease = 0;
@@ -187,8 +185,7 @@ int parse_leases(void)
macstring[17] = '\0';
macaddr_p->ethernet = safe_strdup(macstring);
macaddr_p->ip = safe_strdup(ipstring);
- macaddr_p->next =
- safe_malloc(sizeof(struct macaddr_t));
+ macaddr_p->next = safe_malloc(sizeof(struct macaddr_t));
macaddr_p = macaddr_p->next;
macaddr_p->next = NULL;
}
@@ -251,8 +248,9 @@ void parse_config(int is_include, char *config_file,
struct shared_network_t *shared_p)
{
FILE *dhcpd_config;
- int i = 0, newclause = true, argument = false, comment =
+ int newclause = true, argument = false, comment =
false, braces = 0, quote = false;
+ size_t i = 0;
char *word, c;
int braces_shared = 1000;
struct in_addr inp;
@@ -271,13 +269,13 @@ void parse_config(int is_include, char *config_file,
err(EXIT_FAILURE, "parse_config: %s", config_file);
}
#ifdef POSIX_FADV_WILLNEED
- posix_fadvise((long) dhcpd_config, 0, 0, POSIX_FADV_WILLNEED);
+ posix_fadvise(fileno(dhcpd_config), 0, 0, POSIX_FADV_WILLNEED);
if (errno) {
err(EXIT_FAILURE, "parse_config: fadvise %s", config_file);
}
#endif /* POSIX_FADV_WILLNEED */
#ifdef POSIX_FADV_SEQUENTIAL
- posix_fadvise((long) dhcpd_config, 0, 0, POSIX_FADV_SEQUENTIAL);
+ posix_fadvise(fileno(dhcpd_config), 0, 0, POSIX_FADV_SEQUENTIAL);
if (errno) {
err(EXIT_FAILURE, "parse_config: fadvise %s", config_file);
}
@@ -313,8 +311,7 @@ void parse_config(int is_include, char *config_file,
if (quote == true) {
break;
}
- if (comment == false && argument != 2
- && argument != 4) {
+ if (comment == false && argument != 2 && argument != 4) {
newclause = true;
i = 0;
} else if (argument == 2) {
@@ -364,8 +361,7 @@ void parse_config(int is_include, char *config_file,
}
/* Either inside comment or Nth word of clause. */
- if (comment == true
- || (newclause == false && argument == 0)) {
+ if (comment == true || (newclause == false && argument == 0)) {
continue;
}
/* Strip white spaces before new clause word. */
@@ -446,8 +442,7 @@ void parse_config(int is_include, char *config_file,
shared_p->used = 0;
shared_p->touched = 0;
shared_p->backups = 0;
- if (SHARED_NETWORKS <
- num_shared_networks + 2) {
+ if (SHARED_NETWORKS < num_shared_networks + 2) {
/* FIXME: make this
* away by reallocationg
* more space. */
diff --git a/src/other.c b/src/other.c
index d3c81fb..aaf63a4 100644
--- a/src/other.c
+++ b/src/other.c
@@ -123,38 +123,35 @@ void clean_up(void)
free(shared_networks);
}
-void print_version(void)
+void __attribute__ ((__noreturn__)) print_version(void)
{
- fprintf(stdout, "%s\n", PACKAGE_STRING);
- fprintf(stdout,
- "Written by Sami Kerola.\nXML support by Dominic Germain, Sogetel inc.\n\n");
- fprintf(stdout,
- "The software has FreeBSD License.\n");
+ fprintf(stdout, "%s\n"
+ "Written by Sami Kerola.\n"
+ "XML support by Dominic Germain, Sogetel inc.\n\n"
+ "The software has FreeBSD License.\n", PACKAGE_STRING);
exit(EXIT_SUCCESS);
}
-void usage(int status)
+void __attribute__ ((__noreturn__)) usage(int status)
{
FILE *out;
out = status != 0 ? stderr : stdout;
- fprintf(out, "\n\
+ fprintf(out, "\
Usage: %s [OPTIONS]\n\n", program_invocation_short_name);
+
fprintf(out, "\
This is ISC dhcpd pools usage analyzer.\n\
-\n");
- fprintf(out, "\
+\n\
-c, --config=FILE path to the dhcpd.conf file\n\
-l, --leases=FILE path to the dhcpd.leases file\n\
- -f, --format=[thHcxX] output format\n");
- fprintf(out, "\
+ -f, --format=[thHcxX] output format\n\
t for text\n\
h for html table\n\
H for full html page\n\
x for xml\n\
X for xml with active lease details\n\
- c for comma separated values\n");
- fprintf(out, "\
+ c for comma separated values\n\
-s, --sort=[nimcptTe] sort ranges by\n\
n name\n\
i IP\n\
@@ -163,8 +160,7 @@ This is ISC dhcpd pools usage analyzer.\n\
p percent\n\
t touched\n\
T t+c\n\
- e t+c perc\n");
- fprintf(out, "\
+ e t+c perc\n\
-r, --reverse reverse order sort\n\
-o, --output=FILE output into a file\n\
-L, --limit=NR output limit mask 77 - 00\n\
diff --git a/src/output.c b/src/output.c
index b0b0cfe..6350ae1 100644
--- a/src/output.c
+++ b/src/output.c
@@ -58,8 +58,7 @@ int output_txt(void)
if (config.output_file[0]) {
outfile = fopen(config.output_file, "w+");
if (outfile == NULL) {
- err(EXIT_FAILURE, "output_txt: %s",
- config.output_file);
+ err(EXIT_FAILURE, "output_txt: %s", config.output_file);
}
} else {
outfile = stdout;
@@ -91,23 +90,24 @@ int output_txt(void)
}
fprintf(outfile, "%-16s", inet_ntoa(first));
fprintf(outfile,
- " - %-16s %5"PRIu32" %5lu %10.3f %5lu %5lu %9.3f",
+ " - %-16s %5" PRIu32
+ " %5lu %10.3f %5lu %5lu %9.3f",
inet_ntoa(last),
range_p->last_ip - range_p->first_ip - 1,
range_p->count,
- (float) (100 * range_p->count) /
+ (float)(100 * range_p->count) /
(range_p->last_ip - range_p->first_ip - 1),
range_p->touched,
range_p->touched + range_p->count,
- (float) (100 *
- (range_p->touched +
- range_p->count)) /
- (range_p->last_ip - range_p->first_ip -
- 1));
+ (float)(100 *
+ (range_p->touched +
+ range_p->count)) / (range_p->last_ip -
+ range_p->first_ip -
+ 1));
if (0 < num_backups) {
fprintf(outfile, "%7lu %8.3f",
range_p->backups,
- (float) (100 * range_p->backups) /
+ (float)(100 * range_p->backups) /
(range_p->last_ip -
range_p->first_ip - 1));
}
@@ -135,17 +135,17 @@ int output_txt(void)
"%-20s %5lu %5lu %10.3f %7lu %6lu %9.3f",
shared_p->name, shared_p->available,
shared_p->used,
- (float) (100 * shared_p->used) /
+ (float)(100 * shared_p->used) /
shared_p->available, shared_p->touched,
shared_p->touched + shared_p->used,
- (float) (100 *
- (shared_p->touched +
- shared_p->used)) /
+ (float)(100 *
+ (shared_p->touched +
+ shared_p->used)) /
shared_p->available);
if (0 < num_backups) {
fprintf(outfile, "%7lu %8.3f",
shared_p->backups,
- (float) (100 * shared_p->backups) /
+ (float)(100 * shared_p->backups) /
shared_p->available);
}
@@ -171,19 +171,19 @@ int output_txt(void)
shared_networks->name,
shared_networks->available,
shared_networks->used,
- (float) (100 * shared_networks->used) /
+ (float)(100 * shared_networks->used) /
shared_networks->available,
shared_networks->touched,
shared_networks->touched + shared_networks->used,
- (float) (100 *
- (shared_networks->touched +
- shared_networks->used)) /
+ (float)(100 *
+ (shared_networks->touched +
+ shared_networks->used)) /
shared_networks->available);
if (0 < num_backups) {
fprintf(outfile, "%7lu %8.3f",
shared_networks->backups,
- (float) (100 * shared_networks->backups) /
+ (float)(100 * shared_networks->backups) /
shared_networks->available);
}
fprintf(outfile, "\n");
@@ -216,8 +216,7 @@ int output_xml(void)
if (config.output_file[0]) {
outfile = fopen(config.output_file, "w+");
if (outfile == NULL) {
- err(EXIT_FAILURE, "output_xml: %s",
- config.output_file);
+ err(EXIT_FAILURE, "output_xml: %s", config.output_file);
}
} else {
outfile = stdout;
@@ -247,17 +246,15 @@ int output_xml(void)
"\t%s\n",
range_p->shared_net->name);
} else {
- fprintf(outfile,
- "\t\n");
+ fprintf(outfile, "\t\n");
}
fprintf(outfile, "\t\n");
fprintf(outfile, "\t\n");
fprintf(outfile, "\t%s ", inet_ntoa(first));
- fprintf(outfile, "- %s\n",
- inet_ntoa(last));
+ fprintf(outfile, "- %s\n", inet_ntoa(last));
fprintf(outfile, "\t\n");
- fprintf(outfile, "\t%"PRIu32"\n",
+ fprintf(outfile, "\t%" PRIu32 "\n",
range_p->last_ip - range_p->first_ip - 1);
fprintf(outfile, "\t%lu\n",
range_p->count);
@@ -291,11 +288,9 @@ int output_xml(void)
shared_networks->name);
fprintf(outfile, "\t%lu\n",
shared_networks->available);
- fprintf(outfile, "\t%lu\n",
- shared_networks->used);
+ fprintf(outfile, "\t%lu\n", shared_networks->used);
fprintf(outfile, "\t%lu\n",
- shared_networks->available -
- shared_networks->used);
+ shared_networks->available - shared_networks->used);
fprintf(outfile, "\n");
}
@@ -317,8 +312,7 @@ int output_xml(void)
void html_header(FILE * f)
{
- fprintf(f,
- "\n");
fprintf(f, "\n");
fprintf(f, "\n");
@@ -381,7 +375,7 @@ void html_footer(FILE * f)
fprintf(f, "
\n");
fprintf(f, "\nData generated by ");
fprintf(f, "", PACKAGE_URL);
- fprintf(f, "dhcpd-pools.\n
\n");
+ fprintf(f, "%s.\n
\n", PACKAGE_NAME);
fprintf(f, "\n");
fprintf(f, "\n
\n
\n");
fprintf(f, "\n");
@@ -568,7 +568,7 @@ static void newrow(FILE *restrict f)
*/
static void endrow(FILE *restrict f)
{
- fprintf(f, "\n\n");
+ fprintf(f, "\n");
}
/*! \brief Line with text in html output format.
@@ -581,7 +581,7 @@ static void endrow(FILE *restrict f)
static void output_line(FILE *restrict f, char const *restrict type,
char const *restrict class, char const *restrict text)
{
- fprintf(f, " <%s class=%s>%s%s>\n", type, class, text, type);
+ fprintf(f, "<%s class=\"%s\">%s%s>\n", type, class, text, type);
}
/*! \brief Line with digit in html output format.
@@ -592,7 +592,7 @@ static void output_line(FILE *restrict f, char const *restrict type,
*/
static void output_double(FILE *restrict f, char const *restrict type, double d)
{
- fprintf(f, " <%s class=ralign>%g%s>\n", type, d, type);
+ fprintf(f, "<%s class=\"ralign\">%g%s>\n", type, d, type);
}
/*! \brief Line with float in html output format.
@@ -603,7 +603,7 @@ static void output_double(FILE *restrict f, char const *restrict type, double d)
*/
static void output_float(FILE *f, char const *restrict type, float fl)
{
- fprintf(f, " <%s class=ralign>%.3f%s>\n", type, fl, type);
+ fprintf(f, "<%s class=\"ralign\">%.3f%s>\n", type, fl, type);
}
/*! \brief Begin table in html output format.
@@ -634,7 +634,7 @@ static void table_end(FILE *restrict f)
static void newsection(FILE *restrict f, char const *restrict title)
{
newrow(f);
- output_line(f, "td", "calign", " ");
+ output_line(f, "td", "lalign", " ");
endrow(f);
newrow(f);
output_line(f, "th", "section", title);
@@ -671,9 +671,9 @@ int output_html(void)
if (config.output_limit[0] & BIT1) {
newsection(outfile, "Ranges:");
newrow(outfile);
- output_line(outfile, "th", "calign", "shared net name");
- output_line(outfile, "th", "calign", "first ip");
- output_line(outfile, "th", "calign", "last ip");
+ output_line(outfile, "th", "lalign", "shared net name");
+ output_line(outfile, "th", "lalign", "first ip");
+ output_line(outfile, "th", "lalign", "last ip");
output_line(outfile, "th", "ralign", "max");
output_line(outfile, "th", "ralign", "cur");
output_line(outfile, "th", "ralign", "percent");
@@ -690,12 +690,12 @@ int output_html(void)
for (i = 0; i < num_ranges; i++) {
newrow(outfile);
if (range_p->shared_net) {
- output_line(outfile, "td", "calign", range_p->shared_net->name);
+ output_line(outfile, "td", "lalign", range_p->shared_net->name);
} else {
- output_line(outfile, "td", "calign", "not_defined");
+ output_line(outfile, "td", "lalign", "not_defined");
}
- output_line(outfile, "td", "calign", ntop_ipaddr(&range_p->first_ip));
- output_line(outfile, "td", "calign", ntop_ipaddr(&range_p->last_ip));
+ output_line(outfile, "td", "lalign", ntop_ipaddr(&range_p->first_ip));
+ output_line(outfile, "td", "lalign", ntop_ipaddr(&range_p->last_ip));
output_double(outfile, "td", range_size);
output_double(outfile, "td", range_p->count);
output_float(outfile, "td", (float)(100 * range_p->count) / range_size);
@@ -719,7 +719,7 @@ int output_html(void)
if (config.output_limit[0] & BIT2) {
newsection(outfile, "Shared networks:");
newrow(outfile);
- output_line(outfile, "th", "calign", "name");
+ output_line(outfile, "th", "lalign", "name");
output_line(outfile, "th", "ralign", "max");
output_line(outfile, "th", "ralign", "cur");
output_line(outfile, "th", "ralign", "percent");
@@ -736,7 +736,7 @@ int output_html(void)
for (i = 0; i < num_shared_networks; i++) {
shared_p++;
newrow(outfile);
- output_line(outfile, "td", "calign", shared_p->name);
+ output_line(outfile, "td", "lalign", shared_p->name);
output_double(outfile, "td", shared_p->available);
output_double(outfile, "td", shared_p->used);
output_float(outfile, "td",
@@ -765,7 +765,7 @@ int output_html(void)
if (config.output_limit[0] & BIT3) {
newsection(outfile, "Sum of all ranges:");
newrow(outfile);
- output_line(outfile, "th", "calign", "name");
+ output_line(outfile, "th", "lalign", "name");
output_line(outfile, "th", "ralign", "max");
output_line(outfile, "th", "ralign", "cur");
output_line(outfile, "th", "ralign", "percent");
@@ -781,7 +781,7 @@ int output_html(void)
}
if (config.output_limit[1] & BIT3) {
newrow(outfile);
- output_line(outfile, "td", "calign", shared_networks->name);
+ output_line(outfile, "td", "lalign", shared_networks->name);
output_double(outfile, "td", shared_networks->available);
output_double(outfile, "td", shared_networks->used);
output_float(outfile, "td",
From cf26e17fe761bbc4e21e501c8cf800c2990ba9a1 Mon Sep 17 00:00:00 2001
From: Sami Kerola
Date: Fri, 29 May 2015 09:18:08 +0100
Subject: [PATCH 214/401] add hint about configure options to README
Proposed-by: Tim Cantin
Signed-off-by: Sami Kerola
---
README | 4 ++++
THANKS | 1 +
2 files changed, 5 insertions(+)
diff --git a/README b/README
index d38bd29..270c6b7 100644
--- a/README
+++ b/README
@@ -7,6 +7,10 @@ This is dhcpd-pools which is made for ISC dhcpd pool range analysis.
make
make install
+ # Notice that there are configuration options for dhcpd.conf,
+ # dhcpd.leases, and uthash include paths, among other things.
+
+ ./configure --help
== General information
diff --git a/THANKS b/THANKS
index 260293d..286cbce 100644
--- a/THANKS
+++ b/THANKS
@@ -33,3 +33,4 @@ Fredrik Lys
Conor McCarthy
Wolfgang Steudel
Aaron Paetznick
+Tim Cantin
From d8aef85d012c483177fbe4acfe1d5fb0dca7a774 Mon Sep 17 00:00:00 2001
From: Sami Kerola
Date: Fri, 4 Sep 2015 11:11:56 +0100
Subject: [PATCH 215/401] man: fix character class change
Debian package lint found going back to roman mode was broken.
Reported-by: Martijn van Brummelen
Signed-off-by: Sami Kerola
---
THANKS | 1 +
man/dhcpd-pools.1.in | 4 ++--
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/THANKS b/THANKS
index 286cbce..07b1f68 100644
--- a/THANKS
+++ b/THANKS
@@ -34,3 +34,4 @@ Conor McCarthy
Wolfgang Steudel
Aaron Paetznick
Tim Cantin
+Martijn van Brummelen
diff --git a/man/dhcpd-pools.1.in b/man/dhcpd-pools.1.in
index 28b2fc5..a054a5f 100644
--- a/man/dhcpd-pools.1.in
+++ b/man/dhcpd-pools.1.in
@@ -1,4 +1,4 @@
-.TH DHCPD-POOLS "1" "2012-11-25" "@PACKAGE_STRING@" "User Commands"
+.TH DHCPD-POOLS "1" "2015-09-04" "@PACKAGE_STRING@" "User Commands"
.SH NAME
dhcpd-pools \- ISC dhcpd pools usage analysis
.SH SYNOPSIS
@@ -161,7 +161,7 @@ is
If critical percentage is not specified it defaults to
.BR @ALARM_CRIT@ .
.TP
-\fB\-\-minsize\fR=\fIsize\f
+\fB\-\-minsize\fR=\fIsize\fR
Ignore ranges and shared networks that are smaller or equal to the
defined size. This option is meaningful only in context of alarming, and
will intented to supress for example single host ranges. By default this
From 167c4b698916b7d095beb3fda9da73d2dec8a9b2 Mon Sep 17 00:00:00 2001
From: Sami Kerola
Date: Sat, 5 Sep 2015 13:33:02 +0100
Subject: [PATCH 216/401] gitignore: update gnulib file list
Signed-off-by: Sami Kerola
---
lib/.gitignore | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/lib/.gitignore b/lib/.gitignore
index 928a516..2e2c50e 100644
--- a/lib/.gitignore
+++ b/lib/.gitignore
@@ -7,6 +7,7 @@
/Makefile.am
/Makefile.in
/_Exit.c
+/alloca.in.h
/arg-nonnull.h
/arpa/
/arpa_inet.in.h
@@ -75,6 +76,9 @@
/localcharset.h
/lseek.c
/malloc.c
+/malloca.c
+/malloca.h
+/malloca.valgrind
/math.c
/math.h
/math.in.h
@@ -83,6 +87,8 @@
/memchr.c
/memchr.valgrind
/memcpy.c
+/mktime-internal.h
+/mktime.c
/msvc-inval.c
/msvc-inval.h
/msvc-nothrow.c
@@ -99,12 +105,14 @@
/ref-add.sin
/ref-del.sed
/ref-del.sin
+/setenv.c
/stat.c
/stdalign.h
/stdalign.in.h
/stdarg.in.h
/stdbool.in.h
/stddef.in.h
+/stdint.in.h
/stdio-impl.h
/stdio.c
/stdio.h
@@ -131,12 +139,16 @@
/sys_time.in.h
/sys_types.in.h
/sys_uio.in.h
+/time-internal.h
/time.h
/time.in.h
/time_r.c
+/time_rz.c
+/timegm.c
/unistd.c
/unistd.h
/unistd.in.h
+/unsetenv.c
/unused-parameter.h
/verify.h
/warn-on-use.h
From fae20302cf8dc8fe6ff354fec00a93b9b1f6a2c4 Mon Sep 17 00:00:00 2001
From: Sami Kerola
Date: Sat, 5 Sep 2015 13:17:46 +0100
Subject: [PATCH 217/401] release: 2.27
Signed-off-by: Sami Kerola
---
NEWS | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/NEWS b/NEWS
index 8c0a1a2..77360eb 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,19 @@ Please send dhcpd-pools bug reports to kerolasa@iki.fi.
gpg: Signature is crated using RSA key ID FDE9B739.
+Version 2.27
+Sami Kerola (9):
+ docs: remove very basic git usage info
+ docs: remove todo items that will never happen
+ output: remove empty element from xml
+ add touched addresses counts to xml and json reports
+ add xml format check
+ improve html output
+ add hint about configure options to README
+ man: fix character class change
+ gitignore: update gnulib file list
+ release: 2.27
+
Version 2.26
$ git shortlog v2.25..v2.26
Sami Kerola (15):
From 535dfc4fc2ac64183466a6e1f584852de19e45c6 Mon Sep 17 00:00:00 2001
From: Sami Kerola
Date: Mon, 26 Oct 2015 22:12:37 +0000
Subject: [PATCH 218/401] portability: Solaris 10 does not have err.h
Use error(3) function, that has gnulib portability fixes, instead of err(3)
and warn(3) family.
Reported-by: Anton Tkachev
Signed-off-by: Sami Kerola
---
THANKS | 1 +
bootstrap.conf | 1 +
build-aux/.gitignore | 1 +
lib/.gitignore | 1 +
src/dhcpd-pools.c | 20 +++++++------
src/getdata.c | 29 ++++++++++---------
src/hash.c | 5 +++-
src/other.c | 19 ++++++------
src/output.c | 69 +++++++++++++++++++++++---------------------
src/sort.c | 10 +++----
10 files changed, 84 insertions(+), 72 deletions(-)
diff --git a/THANKS b/THANKS
index 07b1f68..331b868 100644
--- a/THANKS
+++ b/THANKS
@@ -35,3 +35,4 @@ Wolfgang Steudel
Aaron Paetznick
Tim Cantin
Martijn van Brummelen
+Anton Tkachev
diff --git a/bootstrap.conf b/bootstrap.conf
index b815859..b51e08a 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -20,6 +20,7 @@
gnulib_modules="
close-stream
closeout
+ error
fclose
fcntl-h
fdopen
diff --git a/build-aux/.gitignore b/build-aux/.gitignore
index a7f0fb2..a85ce13 100644
--- a/build-aux/.gitignore
+++ b/build-aux/.gitignore
@@ -1,3 +1,4 @@
+/ar-lib
/compile
/config.guess
/config.sub
diff --git a/lib/.gitignore b/lib/.gitignore
index 2e2c50e..b0e5275 100644
--- a/lib/.gitignore
+++ b/lib/.gitignore
@@ -7,6 +7,7 @@
/Makefile.am
/Makefile.in
/_Exit.c
+/alloca.h
/alloca.in.h
/arg-nonnull.h
/arpa/
diff --git a/src/dhcpd-pools.c b/src/dhcpd-pools.c
index bfb312b..267d185 100644
--- a/src/dhcpd-pools.c
+++ b/src/dhcpd-pools.c
@@ -38,10 +38,9 @@
*/
#include
+
#include
#include
-#include
-#include
#include
#include
#include
@@ -49,11 +48,13 @@
#include "close-stream.h"
#include "closeout.h"
-#include "defaults.h"
-#include "dhcpd-pools.h"
+#include "error.h"
#include "progname.h"
#include "xalloc.h"
+#include "dhcpd-pools.h"
+#include "defaults.h"
+
/* Global variables */
int prefix_length[2][NUM_OF_PREFIX];
struct configuration_t config;
@@ -165,7 +166,7 @@ int main(int argc, char **argv)
/* Output sorting option */
sorts = strlen(optarg);
if (5 < sorts) {
- warnx("main: only first 5 sort orders will be used");
+ error(0, 0, "main: only first 5 sort orders will be used");
strncpy(config.sort, optarg, (size_t)5);
sorts = 5;
} else
@@ -188,8 +189,8 @@ int main(int argc, char **argv)
config.output_limit[i] = optarg[i] - '0';
else {
clean_up();
- errx(EXIT_FAILURE,
- "main: output mask `%s' is illegal", optarg);
+ error(EXIT_FAILURE, 0,
+ "main: output mask `%s' is illegal", optarg);
}
}
break;
@@ -211,7 +212,8 @@ int main(int argc, char **argv)
/* Print help */
usage(EXIT_SUCCESS);
default:
- errx(EXIT_FAILURE, "Try `%s --help' for more information.", program_name);
+ error(EXIT_FAILURE, 0, "Try `%s --help' for more information.",
+ program_name);
}
}
/* Output function selection */
@@ -246,7 +248,7 @@ int main(int argc, char **argv)
break;
default:
clean_up();
- errx(EXIT_FAILURE, "main: unknown output format `%c'", config.output_format[0]);
+ error(EXIT_FAILURE, 0, "main: unknown output format `%c'", config.output_format[0]);
}
/* Do the job */
prepare_memory();
diff --git a/src/getdata.c b/src/getdata.c
index bf2de86..591d743 100644
--- a/src/getdata.c
+++ b/src/getdata.c
@@ -42,7 +42,6 @@
#include
#include
#include
-#include
#include
#include
#include
@@ -53,10 +52,12 @@
#include
#include
-#include "defaults.h"
-#include "dhcpd-pools.h"
+#include "error.h"
#include "xalloc.h"
+#include "dhcpd-pools.h"
+#include "defaults.h"
+
/*! \brief Lease file parser. The parser can only read ISC DHCPD
* dhcpd.leases file format. */
int parse_leases(void)
@@ -70,15 +71,15 @@ int parse_leases(void)
dhcpd_leases = fopen(config.dhcpdlease_file, "r");
if (dhcpd_leases == NULL)
- err(EXIT_FAILURE, "parse_leases: %s", config.dhcpdlease_file);
+ error(EXIT_FAILURE, errno, "parse_leases: %s", config.dhcpdlease_file);
#ifdef HAVE_POSIX_FADVISE
# ifdef POSIX_FADV_NOREUSE
if (posix_fadvise(fileno(dhcpd_leases), 0, 0, POSIX_FADV_NOREUSE) != 0)
- err(EXIT_FAILURE, "parse_leases: fadvise %s", config.dhcpdlease_file);
+ error(EXIT_FAILURE, errno, "parse_leases: fadvise %s", config.dhcpdlease_file);
# endif /* POSIX_FADV_NOREUSE */
# ifdef POSIX_FADV_SEQUENTIAL
if (posix_fadvise(fileno(dhcpd_leases), 0, 0, POSIX_FADV_SEQUENTIAL) != 0)
- err(EXIT_FAILURE, "parse_leases: fadvise %s", config.dhcpdlease_file);
+ error(EXIT_FAILURE, errno, "parse_leases: fadvise %s", config.dhcpdlease_file);
# endif /* POSIX_FADV_SEQUENTIAL */
#endif /* HAVE_POSIX_FADVISE */
/* I found out that there's one lease address per 300 bytes in
@@ -86,7 +87,7 @@ int parse_leases(void)
* If someone has higher density in lease file I'm interested to
* hear about that. */
if (stat(config.dhcpdlease_file, &lease_file_stats))
- err(EXIT_FAILURE, "parse_leases: %s", config.dhcpdlease_file);
+ error(EXIT_FAILURE, errno, "parse_leases: %s", config.dhcpdlease_file);
line = xmalloc(sizeof(char) * MAXLEN);
line[0] = '\0';
ipstring = xmalloc(sizeof(char) * MAXLEN);
@@ -95,7 +96,7 @@ int parse_leases(void)
ethernets = true;
while (!feof(dhcpd_leases)) {
if (!fgets(line, MAXLEN, dhcpd_leases) && ferror(dhcpd_leases))
- err(EXIT_FAILURE, "parse_leases: %s", config.dhcpdlease_file);
+ error(EXIT_FAILURE, errno, "parse_leases: %s", config.dhcpdlease_file);
switch (xstrstr(line)) {
/* It's a lease, save IP */
case PREFIX_LEASE:
@@ -186,15 +187,15 @@ void parse_config(int is_include, const char *restrict config_file,
/* Open configuration file */
dhcpd_config = fopen(config_file, "r");
if (dhcpd_config == NULL)
- err(EXIT_FAILURE, "parse_config: %s", config_file);
+ error(EXIT_FAILURE, errno, "parse_config: %s", config_file);
#ifdef HAVE_POSIX_FADVISE
# ifdef POSIX_FADV_NOREUSE
if (posix_fadvise(fileno(dhcpd_config), 0, 0, POSIX_FADV_NOREUSE) != 0)
- err(EXIT_FAILURE, "parse_config: fadvise %s", config_file);
+ error(EXIT_FAILURE, errno, "parse_config: fadvise %s", config_file);
# endif /* POSIX_FADV_NOREUSE */
# ifdef POSIX_FADV_SEQUENTIAL
if (posix_fadvise(fileno(dhcpd_config), 0, 0, POSIX_FADV_SEQUENTIAL) != 0)
- err(EXIT_FAILURE, "parse_config: fadvise %s", config_file);
+ error(EXIT_FAILURE, errno, "parse_config: fadvise %s", config_file);
# endif /* POSIX_FADV_SEQUENTIAL */
#endif /* HAVE_POSIX_FADVISE */
/* Very hairy stuff begins. */
@@ -364,8 +365,8 @@ void parse_config(int is_include, const char *restrict config_file,
shared_p->backups = 0;
if (SHARED_NETWORKS < num_shared_networks + 2)
/* FIXME: make this to go away by reallocating more space. */
- errx(EXIT_FAILURE,
- "parse_config: increase default.h SHARED_NETWORKS and recompile");
+ error(EXIT_FAILURE, 0,
+ "parse_config: increase default.h SHARED_NETWORKS and recompile");
argument = ITS_NOTHING_INTERESTING;
braces_shared = braces;
break;
@@ -380,7 +381,7 @@ void parse_config(int is_include, const char *restrict config_file,
argument = ITS_NOTHING_INTERESTING;
break;
default:
- warnx("impossible occurred, report a bug");
+ error(0, 0, "impossible occurred, report a bug");
assert(0);
}
}
diff --git a/src/hash.c b/src/hash.c
index a75e9f4..08b95b4 100644
--- a/src/hash.c
+++ b/src/hash.c
@@ -38,9 +38,12 @@
* analysis happen as quick as possible..
*/
-#include "dhcpd-pools.h"
+#include
+
#include "xalloc.h"
+#include "dhcpd-pools.h"
+
#define HASH_FIND_V6(head, findv6, out) HASH_FIND(hh, head, findv6, 16, out)
#define HASH_ADD_V6(head, v6field, add) HASH_ADD(hh, head, v6field, 16, add)
diff --git a/src/other.c b/src/other.c
index e9f49c8..67c2f4d 100644
--- a/src/other.c
+++ b/src/other.c
@@ -39,13 +39,9 @@
#include
-#include "dhcpd-pools.h"
-#include "defaults.h"
-#include "progname.h"
-
#include
-#include
#include
+#include
#include
#include
#include
@@ -53,7 +49,12 @@
#include
#include
#include
-#include
+
+#include "error.h"
+#include "progname.h"
+
+#include "dhcpd-pools.h"
+#include "defaults.h"
/*! \brief Set function pointers depending on IP version.
* \param ip IP version.
@@ -378,9 +379,7 @@ double strtod_or_err(const char *restrict str, const char *restrict errmesg)
goto err;
return num;
err:
- if (errno)
- err(EXIT_FAILURE, "%s: '%s'", errmesg, str);
- errx(EXIT_FAILURE, "%s: '%s'", errmesg, str);
+ error(EXIT_FAILURE, errno, "%s: '%s'", errmesg, str);
}
/*! \brief Reverse range.
@@ -404,7 +403,7 @@ void clean_up(void)
{
/* Just in case there something in buffers */
if (fflush(NULL))
- warn("clean_up: fflush");
+ error(0, 0, "clean_up: fflush");
free(config.dhcpdconf_file);
free(config.dhcpdlease_file);
free(config.output_file);
diff --git a/src/output.c b/src/output.c
index 28d6775..06a5469 100644
--- a/src/output.c
+++ b/src/output.c
@@ -40,7 +40,6 @@
#include
#include
-#include
#include
#include
#include
@@ -53,10 +52,12 @@
#include
#include "close-stream.h"
-#include "dhcpd-pools.h"
+#include "error.h"
#include "progname.h"
#include "strftime.h"
+#include "dhcpd-pools.h"
+
/*! \brief Text output format, which is the default.
* FIXME: This function should return void. */
int output_txt(void)
@@ -72,7 +73,7 @@ int output_txt(void)
if (config.output_file[0]) {
outfile = fopen(config.output_file, "w+");
if (outfile == NULL) {
- err(EXIT_FAILURE, "output_txt: %s", config.output_file);
+ error(EXIT_FAILURE, errno, "output_txt: %s", config.output_file);
}
} else {
outfile = stdout;
@@ -201,12 +202,12 @@ int output_txt(void)
if (outfile == stdout) {
ret = fflush(stdout);
if (ret) {
- warn("output_txt: fflush");
+ error(0, 0, "output_txt: fflush");
}
} else {
ret = close_stream(outfile);
if (ret) {
- warn("output_txt: fclose");
+ error(0, 0, "output_txt: fclose");
}
}
@@ -228,7 +229,7 @@ int output_xml(void)
if (config.output_file[0]) {
outfile = fopen(config.output_file, "w+");
if (outfile == NULL) {
- err(EXIT_FAILURE, "output_xml: %s", config.output_file);
+ error(EXIT_FAILURE, errno, "output_xml: %s", config.output_file);
}
} else {
outfile = stdout;
@@ -242,6 +243,7 @@ int output_xml(void)
if (config.output_format[0] == 'X' || config.output_format[0] == 'J') {
struct leases_t *l;
+
for (l = leases; l != NULL; l = l->hh.next) {
if (l->type == ACTIVE) {
fputs("\n\t", outfile);
@@ -305,12 +307,12 @@ int output_xml(void)
if (outfile == stdout) {
ret = fflush(stdout);
if (ret) {
- warn("output_xml: fflush");
+ error(0, 0, "output_xml: fflush");
}
} else {
ret = close_stream(outfile);
if (ret) {
- warn("output_xml: fclose");
+ error(0, 0, "output_xml: fclose");
}
}
@@ -333,7 +335,7 @@ int output_json(void)
if (config.output_file[0]) {
outfile = fopen(config.output_file, "w+");
if (outfile == NULL) {
- err(EXIT_FAILURE, "output_json: %s", config.output_file);
+ error(EXIT_FAILURE, errno, "output_json: %s", config.output_file);
}
} else {
outfile = stdout;
@@ -348,6 +350,7 @@ int output_json(void)
if (config.output_format[0] == 'X' || config.output_format[0] == 'J') {
struct leases_t *l;
+
fprintf(outfile, " \"active_leases\": [");
for (l = leases; l != NULL; l = l->hh.next) {
if (l->type == ACTIVE) {
@@ -443,12 +446,12 @@ int output_json(void)
if (outfile == stdout) {
ret = fflush(stdout);
if (ret) {
- warn("output_json: fflush");
+ error(0, 0, "output_json: fflush");
}
} else {
ret = close_stream(outfile);
if (ret) {
- warn("output_json: fclose");
+ error(0, 0, "output_json: fclose");
}
}
@@ -465,14 +468,15 @@ static void html_header(FILE *restrict f)
struct tm *tmp, result;
struct stat statbuf;
+
stat(config.dhcpdlease_file, &statbuf);
tmp = localtime_r(&statbuf.st_mtime, &result);
if (tmp == NULL) {
- err(EXIT_FAILURE, "html_header: localtime");
+ error(EXIT_FAILURE, errno, "html_header: localtime");
}
if (strftime(outstr, sizeof(outstr), nl_langinfo(D_T_FMT), &result) == 0) {
- errx(EXIT_FAILURE, "html_header: strftime returned 0");
+ error(EXIT_FAILURE, 0, "html_header: strftime returned 0");
}
fprintf(f, "backups);
output_float(outfile, "td",
shared_p->available == 0 ? -NAN : (float)(100 *
- shared_p->
- backups) /
- shared_p->available);
+ shared_p->backups)
+ / shared_p->available);
}
endrow(outfile);
@@ -792,18 +796,16 @@ int output_html(void)
output_double(outfile, "td", shared_networks->touched + shared_networks->used);
output_float(outfile, "td",
shared_networks->available == 0 ? -NAN : (float)(100 *
- (shared_networks->
- touched +
- shared_networks->
- used)) /
- shared_networks->available);
+ (shared_networks->touched
+ +
+ shared_networks->used))
+ / shared_networks->available);
if (config.backups_found == true) {
output_double(outfile, "td", shared_networks->backups);
output_float(outfile, "td",
shared_networks->available == 0 ? -NAN : (float)(100 *
- shared_networks->
- backups) /
- shared_networks->available);
+ shared_networks->backups)
+ / shared_networks->available);
}
endrow(outfile);
}
@@ -814,12 +816,12 @@ int output_html(void)
if (outfile == stdout) {
ret = fflush(stdout);
if (ret) {
- warn("output_html: fflush");
+ error(0, 0, "output_html: fflush");
}
} else {
ret = close_stream(outfile);
if (ret) {
- warn("output_html: fclose");
+ error(0, 0, "output_html: fclose");
}
}
return 0;
@@ -836,10 +838,11 @@ int output_csv(void)
struct shared_network_t *shared_p;
FILE *outfile;
int ret;
+
if (config.output_file[0]) {
outfile = fopen(config.output_file, "w+");
if (outfile == NULL) {
- err(EXIT_FAILURE, "output_csv: %s", config.output_file);
+ error(EXIT_FAILURE, errno, "output_csv: %s", config.output_file);
}
} else {
outfile = stdout;
@@ -957,12 +960,12 @@ int output_csv(void)
if (outfile == stdout) {
ret = fflush(stdout);
if (ret) {
- warn("output_cvs: fflush");
+ error(0, 0, "output_cvs: fflush");
}
} else {
ret = close_stream(outfile);
if (ret) {
- warn("output_cvs: fclose");
+ error(0, 0, "output_cvs: fclose");
}
}
return 0;
@@ -989,7 +992,7 @@ int output_alarming(void)
if (config.output_file[0]) {
outfile = fopen(config.output_file, "w+");
if (outfile == NULL) {
- err(EXIT_FAILURE, "output_alarming: %s", config.output_file);
+ error(EXIT_FAILURE, errno, "output_alarming: %s", config.output_file);
}
} else {
outfile = stdout;
@@ -1077,12 +1080,12 @@ int output_alarming(void)
if (outfile == stdout) {
ret = fflush(stdout);
if (ret) {
- warn("output_alarming: fflush");
+ error(0, 0, "output_alarming: fflush");
}
} else {
ret = close_stream(outfile);
if (ret) {
- warn("output_alarming: fclose");
+ error(0, 0, "output_alarming: fclose");
}
}
return ret_val;
diff --git a/src/sort.c b/src/sort.c
index b01db91..d0af3cb 100644
--- a/src/sort.c
+++ b/src/sort.c
@@ -40,15 +40,15 @@
#include
-#include
-#include
#include
#include
#include
-#include "dhcpd-pools.h"
+#include "error.h"
#include "progname.h"
+#include "dhcpd-pools.h"
+
/*! \brief Compare IP address, with IPv4/v6 determination.
* \param a Binary IP address.
* \param b Binary IP address.
@@ -237,8 +237,7 @@ comparer_t field_selector(char c)
return comp_tcperc;
default:
clean_up();
- warnx("field_selector: unknown sort order `%c'", c);
- errx(EXIT_FAILURE, "Try `%s --help' for more information.", program_name);
+ error(EXIT_FAILURE, 0, "field_selector: unknown sort order `%c'", c);
}
return NULL;
}
@@ -289,6 +288,7 @@ void mergesort_ranges(struct range_t *restrict orig, int size, struct range_t *r
{
int left, right, i;
struct range_t hold;
+
/* Merge sort split size */
static const int MIN_MERGE_SIZE = 8;
From c30c122027811fc158c5d5711d0fb9116f75a089 Mon Sep 17 00:00:00 2001
From: Sami Kerola
Date: Mon, 26 Oct 2015 22:43:31 +0000
Subject: [PATCH 219/401] fix couple compiler warnings
src/getdata.c:248:22: warning: 'range_p' may be used uninitialized in this
function [-Wmaybe-uninitialized]
src/other.c:383:1: warning: control reaches end of non-void function
[-Wreturn-type]
Signed-off-by: Sami Kerola
---
src/getdata.c | 5 ++++-
src/other.c | 1 +
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/getdata.c b/src/getdata.c
index 591d743..ce56a2b 100644
--- a/src/getdata.c
+++ b/src/getdata.c
@@ -178,7 +178,7 @@ void parse_config(int is_include, const char *restrict config_file,
char *word;
int braces_shared = 1000;
union ipaddr_t addr;
- struct range_t *range_p;
+ struct range_t *range_p = NULL;
word = xmalloc(sizeof(char) * MAXLEN);
if (is_include)
@@ -245,6 +245,9 @@ void parse_config(int is_include, const char *restrict config_file,
c = ' ';
break;
} else if (argument == ITS_A_RANGE_SECOND_IP && i == 0) {
+ if (!range_p) {
+ error(EXIT_FAILURE, 0, "parse_config: range_p uninitialized: please report a bug");
+ }
range_p->last_ip = range_p->first_ip;
goto newrange;
}
diff --git a/src/other.c b/src/other.c
index 67c2f4d..040c55a 100644
--- a/src/other.c
+++ b/src/other.c
@@ -380,6 +380,7 @@ double strtod_or_err(const char *restrict str, const char *restrict errmesg)
return num;
err:
error(EXIT_FAILURE, errno, "%s: '%s'", errmesg, str);
+ return 0;
}
/*! \brief Reverse range.
From 2528c4c9d693d16d2b57582e008e3e59e1f537af Mon Sep 17 00:00:00 2001
From: Sami Kerola
Date: Wed, 25 Nov 2015 21:53:29 +0000
Subject: [PATCH 220/401] make binary exec path dynamic in scripts referring to
it
Everything should just work out of the box without poking. This change
makes that goal to be yet agian one step closer. In same go make all
autotools related variable substitutions better.
Requested-by: Martijn van Brummelen
Signed-off-by: Sami Kerola
---
Makefile.am | 28 ++++++++++++++++++-
configure.ac | 4 +--
contrib/.gitignore | 2 ++
contrib/Makemodule.am | 4 ++-
.../{dhcpd-pools.cgi => dhcpd-pools.cgi.in} | 4 +--
contrib/nagios.conf | 1 -
contrib/nagios.conf.in | 1 +
doc/.gitignore | 1 +
doc/Makemodule.am | 6 +++-
doc/doxy.conf.in | 2 +-
man/Makemodule.am | 3 +-
man/dhcpd-pools.1.in | 2 +-
12 files changed, 45 insertions(+), 13 deletions(-)
create mode 100644 contrib/.gitignore
rename contrib/{dhcpd-pools.cgi => dhcpd-pools.cgi.in} (91%)
delete mode 100644 contrib/nagios.conf
create mode 100644 contrib/nagios.conf.in
create mode 100644 doc/.gitignore
diff --git a/Makefile.am b/Makefile.am
index b2beaca..0daa8bf 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -16,9 +16,35 @@ $(top_srcdir)/.version:
dist-hook:
echo $(VERSION) > $(distdir)/.tarball-version
-CLEANFILES =
+PATHFILES =
+CLEANFILES = $(PATHFILES)
+EXTRA_DIST += $(PATHFILES:=.in)
CLEAN_LOCALS =
+edit_cmd = sed \
+ -e 's|@ALARM_CRIT[@]|$(ALARM_CRIT)|g' \
+ -e 's|@ALARM_WARN[@]|$(ALARM_WARN)|g' \
+ -e 's|@DHCPDCONF_FILE[@]|$(DHCPDCONF_FILE)|g' \
+ -e 's|@DHCPDLEASE_FILE[@]|$(DHCPDLEASE_FILE)|g' \
+ -e 's|@OUTPUT_FORMAT[@]|$(OUTPUT_FORMAT)|g' \
+ -e 's|@OUTPUT_LIMIT[@]|$(OUTPUT_LIMIT)|g' \
+ -e 's|@PACKAGE_BUGREPORT[@]|$(PACKAGE_BUGREPORT)|g' \
+ -e 's|@PACKAGE_MAINTAINER[@]|$(PACKAGE_MAINTAINER)|g' \
+ -e 's|@PACKAGE_NAME[@]|$(PACKAGE_NAME)|g' \
+ -e 's|@PACKAGE_URL[@]|$(PACKAGE_URL)|g' \
+ -e 's|@SHELL[@]|$(SHELL)|g' \
+ -e 's|@VERSION[@]|$(VERSION)|g' \
+ -e 's|@bindir[@]|$(bindir)|g' \
+ -e 's|@top_srcdir[@]|$(top_srcdir)|g'
+
+$(PATHFILES): Makefile
+ @ rm -f $@ $@.tmp
+ $(AM_V_at) test -d $(dir $@) || mkdir -p $(dir $@)
+ $(AM_V_GEN) srcdir=''; \
+ test -f ./$@.in || srcdir=$(srcdir)/; \
+ $(edit_cmd) $${srcdir}$@.in >$@.tmp
+ @ mv $@.tmp $@
+
include contrib/Makemodule.am
include doc/Makemodule.am
include man/Makemodule.am
diff --git a/configure.ac b/configure.ac
index cfa9271..ec993c7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -134,8 +134,7 @@ AM_CONDITIONAL([ENABLE_DOXYGEN], [test "x$enable_doxygen" = "xyes"])
AS_IF([test x$enable_doxygen = xyes], [
AC_CHECK_PROGS([DOXYGEN], [doxygen])
AS_IF([test "x$DOXYGEN" = "x"],
- AC_MSG_ERROR([doxygen not in path]),
- AC_CONFIG_FILES([doc/doxy.conf])
+ AC_MSG_ERROR([doxygen not in path])
)
AC_CHECK_PROGS([DOXYGEN_DOT], [dot])
@@ -149,7 +148,6 @@ AM_CONDITIONAL([HAVE_DOXYGEN_DOT], [test "x$DOXYGEN_DOT" != "x"])
AC_CONFIG_FILES([
Makefile
lib/Makefile
- man/dhcpd-pools.1
])
AC_OUTPUT
diff --git a/contrib/.gitignore b/contrib/.gitignore
new file mode 100644
index 0000000..591c7bd
--- /dev/null
+++ b/contrib/.gitignore
@@ -0,0 +1,2 @@
+/dhcpd-pools.cgi
+/nagios.conf
diff --git a/contrib/Makemodule.am b/contrib/Makemodule.am
index f6aee1f..a6bbc1e 100644
--- a/contrib/Makemodule.am
+++ b/contrib/Makemodule.am
@@ -1,3 +1,5 @@
contribdir = $(datadir)/dhcpd-pools/
+PATHFILES += contrib/dhcpd-pools.cgi contrib/nagios.conf
dist_contrib_SCRIPTS = contrib/dhcpd-pools.cgi contrib/snmptest.pl
-EXTRA_DIST += contrib/nagios.conf contrib/munin_plugins
+dist_contrib_DATA = contrib/nagios.conf
+EXTRA_DIST += contrib/munin_plugins
diff --git a/contrib/dhcpd-pools.cgi b/contrib/dhcpd-pools.cgi.in
similarity index 91%
rename from contrib/dhcpd-pools.cgi
rename to contrib/dhcpd-pools.cgi.in
index 15a73fb..117a7cf 100755
--- a/contrib/dhcpd-pools.cgi
+++ b/contrib/dhcpd-pools.cgi.in
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!@SHELL@
#
# Simple CGI for dhcpd-pools.
@@ -26,7 +26,7 @@ echo "This was situation at "
date
echo "
"
-/usr/local/bin/dhcpd-pools --format html
+@bindir@/dhcpd-pools --format html
echo ""
echo "