Репозитории ALT
Группа :: Мониторинг
Пакет: ngrep
Главная Изменения Спек Патчи Sources Загрузить Gear Bugs and FR Repocop
Патч: ngrep-1.45-alt-regex.patch
Скачать
Скачать
--- configure.in
+++ configure.in
@@ -14,6 +14,7 @@ echo 'Configuring System ...'
echo
AC_CANONICAL_SYSTEM
+AC_USE_SYSTEM_EXTENSIONS
AC_PROG_CC
AC_HEADER_STDC
@@ -130,8 +131,8 @@ if test $use_pcre = yes; then
echo 'Configuring Perl-Compatible Regular Expression (PCRE) library ...'
echo
- REGEX_DIR='pcre-5.0'
- REGEX_OBJS="$REGEX_DIR/pcre.o $REGEX_DIR/study.o"
+ AC_CHECK_LIB(pcre, pcre_compile, , AC_MSG_ERROR(libpcre-devel is required for pcre support))
+ EXTRA_LIBS="$EXTRA_LIBS -lpcre"
USE_PCRE="1"
else
@@ -140,14 +141,12 @@ else
echo 'Configuring GNU Regular Expression library ...'
echo
- REGEX_DIR='regex-0.12'
- REGEX_OBJS="$REGEX_DIR/regex.o"
USE_PCRE="0"
fi
-( cd $REGEX_DIR && ./configure )
-
+REGEX_DIR=
+REGEX_OBJS=
AC_SUBST(REGEX_DIR)
AC_SUBST(REGEX_OBJS)
@@ -161,7 +160,7 @@ dnl
dnl OS-specific options
dnl
-STRIPFLAG="-s"
+STRIPFLAG=
HAVE_DUMB_UDPHDR="0"
case "$target_os" in
@@ -258,8 +257,6 @@ esac
AC_SUBST(STRIPFLAG)
-EXTRA_DEFINES="$EXTRA_DEFINES -D_BSD_SOURCE=1 -D__FAVOR_BSD=1"
-
dnl
dnl First find some usable PCAP headers.
--- ngrep.c
+++ ngrep.c
@@ -7,6 +7,10 @@
*
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#if defined(BSD) || defined(SOLARIS) || defined(MACOSX)
#include <unistd.h>
#include <ctype.h>
@@ -51,26 +55,6 @@
#include <pwd.h>
#endif
-#if defined(_WIN32)
-#include <io.h>
-#include <getopt.h>
-#include <winsock2.h>
-#include <types.h>
-#include <inet_ntop.h>
-#include <config.h>
-
-#define strcasecmp stricmp
-
-#else
-
-#include <netinet/ip.h>
-#include <netinet/tcp.h>
-#include <netinet/udp.h>
-#include <netinet/ip_icmp.h>
-#include <netinet/igmp.h>
-
-#endif
-
#include <stdlib.h>
#include <string.h>
#include <signal.h>
@@ -82,19 +66,41 @@
#include <pcap.h>
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
#if USE_IPv6 && !defined(_WIN32)
#include <netinet/ip6.h>
#include <netinet/icmp6.h>
#endif
#if USE_PCRE
-#include "pcre-5.0/pcre.h"
+#include <pcre/pcre.h>
#else
-#include "regex-0.12/regex.h"
+#include <regex.h>
+#endif
+
+#if defined(LINUX)
+#ifndef __FAVOR_BSD
+# define __FAVOR_BSD
+#endif
+#endif
+
+#if defined(_WIN32)
+#include <io.h>
+#include <getopt.h>
+#include <winsock2.h>
+#include <types.h>
+#include <inet_ntop.h>
+#include <config.h>
+
+#define strcasecmp stricmp
+
+#else
+
+#include <netinet/ip.h>
+#include <netinet/tcp.h>
+#include <netinet/udp.h>
+#include <netinet/ip_icmp.h>
+#include <netinet/igmp.h>
+
#endif
#include "ngrep.h"
@@ -467,25 +473,10 @@ int main(int argc, char **argv) {
if (re_multiline_match)
re_syntax_options |= RE_DOT_NEWLINE;
- if (re_ignore_case) {
- uint32_t i;
- char *s;
-
- pattern.translate = (char*)malloc(256);
- s = pattern.translate;
-
- for (i = 0; i < 256; i++)
- s[i] = i;
- for (i = 'A'; i <= 'Z'; i++)
- s[i] = i + 32;
-
- s = match_data;
- while (*s) {
- *s = tolower(*s);
- s++;
- }
+ if (re_ignore_case)
+ re_syntax_options |= RE_ICASE;
- } else pattern.translate = NULL;
+ pattern.translate = NULL;
#endif
if (re_match_word) {
@@ -900,7 +891,7 @@ int8_t re_match_func(unsigned char *data, uint32_t len) {
return 0;
}
#else
- switch (re_search(&pattern, data, (int32_t)len, 0, len, 0)) {
+ switch (re_search(&pattern, (const char *)data, (int32_t)len, 0, len, 0)) {
case -2:
perror("she's dead, jim\n");
clean_exit(-2);