mirror of
https://git.FreeBSD.org/ports.git
synced 2025-01-10 07:04:03 +00:00
* Update to 1.4
* STAGE support Approved by: wg (mentor)
This commit is contained in:
parent
a01b966ddd
commit
110db9ce68
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=335112
net-mgmt/grepcidr
@ -2,8 +2,7 @@
|
||||
# $FreeBSD$
|
||||
|
||||
PORTNAME= grepcidr
|
||||
PORTVERSION= 1.3
|
||||
PORTREVISION= 1
|
||||
PORTVERSION= 1.4
|
||||
CATEGORIES= net-mgmt textproc
|
||||
MASTER_SITES= http://www.pc-tools.net/files/unix/ \
|
||||
ftp://ftp.renatasystems.org/pub/FreeBSD/ports/distfiles/
|
||||
@ -11,14 +10,19 @@ MASTER_SITES= http://www.pc-tools.net/files/unix/ \
|
||||
MAINTAINER= alexey@renatasystems.org
|
||||
COMMENT= Filter IP addresses matching IPv4 CIDR/network specification
|
||||
|
||||
PLIST_FILES= bin/grepcidr
|
||||
LICENSE= GPLv2
|
||||
|
||||
USES= gmake
|
||||
|
||||
PLIST_FILES= bin/grepcidr \
|
||||
man/man1/grepcidr.1.gz
|
||||
|
||||
NO_STAGE= yes
|
||||
do-configure:
|
||||
@${REINPLACE_CMD} \
|
||||
-e 's|/usr/local/bin|${PREFIX}/bin|' \
|
||||
-e 's|-s -O3 -Wall -pedantic|${CFLAGS} -DHAVE_STRING_H|' \
|
||||
-e 's|gcc|${CC}|' \
|
||||
${REINPLACE_CMD} \
|
||||
-e 's|PREFIX=.*|PREFIX=${PREFIX}|' \
|
||||
-e 's|CFLAGS=.*|CFLAGS=${CFLAGS}|' \
|
||||
-e 's|DESTDIR=.*|DESTDIR=${STAGEDIR}|' \
|
||||
-e 's|MANDIR=.*|MANDIR=${MANPREFIX}/man|' \
|
||||
${WRKSRC}/Makefile
|
||||
|
||||
.include <bsd.port.mk>
|
||||
|
@ -1,2 +1,2 @@
|
||||
SHA256 (grepcidr-1.3.tar.gz) = 2bef080fe2efd9d82326fa41f3b1cca6b7ecbdac7b3c53f3db8fe0da5ab8fb81
|
||||
SIZE (grepcidr-1.3.tar.gz) = 21691
|
||||
SHA256 (grepcidr-1.4.tar.gz) = 0feca6a6905ab293d15a77ef5956bf58ae5dea8d88eb63c06c8024e9441bdb3b
|
||||
SIZE (grepcidr-1.4.tar.gz) = 13806
|
||||
|
@ -1,65 +0,0 @@
|
||||
--- ./grepcidr.c.orig 2005-04-23 18:00:16.000000000 -0400
|
||||
+++ ./grepcidr.c 2010-01-14 18:17:58.469773170 -0500
|
||||
@@ -81,13 +81,38 @@
|
||||
Convert IP address string to 32-bit integer version
|
||||
Returns 0 on failure
|
||||
*/
|
||||
-unsigned int ip_to_uint(const char* ip)
|
||||
+unsigned int ip_to_uint(char** ip)
|
||||
{
|
||||
unsigned int IP[4]; /* 4 octets for IP address */
|
||||
- if ((sscanf(ip, "%u.%u.%u.%u", &IP[0], &IP[1], &IP[2], &IP[3]) == 4) && VALID_IP(IP))
|
||||
+ char *p = *ip;
|
||||
+ char *dot;
|
||||
+
|
||||
+ while (*p) {
|
||||
+ while (*p && (*p < '0' || *p > '9'))
|
||||
+ p++;
|
||||
+ if (!*p)
|
||||
+ break;
|
||||
+
|
||||
+ /* speedup: check if the first digits are followed by a dot */
|
||||
+ dot = p + 1;
|
||||
+ while (*dot >= '0' && *dot <='9')
|
||||
+ dot++;
|
||||
+ if (dot > p+3 || *dot != '.') {
|
||||
+ p = dot;
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ if ((sscanf(p, "%u.%u.%u.%u", &IP[0], &IP[1], &IP[2], &IP[3]) == 4) && VALID_IP(IP)) {
|
||||
+ /* point to next possible integer */
|
||||
+ while (*p >= '0' && *p <= '9')
|
||||
+ p++;
|
||||
+ *ip = p;
|
||||
return BUILD_IP(IP);
|
||||
- else
|
||||
- return 0;
|
||||
+ }
|
||||
+ p++;
|
||||
+ }
|
||||
+ *ip = p;
|
||||
+ return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -276,7 +301,10 @@
|
||||
while (fgets(line, sizeof(line), inp_stream))
|
||||
{
|
||||
struct netspec key;
|
||||
- if ((key.min=ip_to_uint(line)))
|
||||
+ char *ptr;
|
||||
+
|
||||
+ ptr = line;
|
||||
+ while ((key.min=ip_to_uint(&ptr)))
|
||||
{
|
||||
int match = 0;
|
||||
if (bsearch(&key, array, patterns, sizeof(struct netspec), netsearch))
|
||||
@@ -288,6 +316,7 @@
|
||||
counting++;
|
||||
else
|
||||
printf("%s", line);
|
||||
+ break; /* match only once per line */
|
||||
}
|
||||
}
|
||||
}
|
@ -11,4 +11,4 @@ filtering and processing, network security, log analysis, and many
|
||||
custom applications.
|
||||
|
||||
Author: Jem Berkes
|
||||
WWW: http://www.pc-tools.net/unix/grepcidr/
|
||||
WWW: http://www.pc-tools.net/unix/grepcidr/
|
||||
|
Loading…
Reference in New Issue
Block a user