1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-22 15:39:03 +00:00

make pcre an NSE C module

This commit is contained in:
fyodor
2007-08-11 06:05:48 +00:00
parent 0dc44d08b0
commit 78f15a7f65
10 changed files with 181 additions and 55 deletions

View File

@@ -56,9 +56,9 @@ INSTALLNSE=@INSTALLNSE@
INSTALLUMIT=@INSTALLUMIT@ INSTALLUMIT=@INSTALLUMIT@
ifneq (@LIBLUA_LIBS@,) ifneq (@LIBLUA_LIBS@,)
NSE_SRC=nse_main.cc nse_auxiliar.cc nse_nsock.cc nse_init.cc nse_nmaplib.cc nse_debug.cc nse_pcrelib.cc nse_string.cc NSE_SRC=nse_main.cc nse_auxiliar.cc nse_nsock.cc nse_init.cc nse_nmaplib.cc nse_debug.cc nse_string.cc
NSE_HDRS=nse_main.h nse_auxiliar.h nse_nsock.h nse_init.h nse_nmaplib.h nse_debug.h nse_macros.h nse_pcrelib.h nse_string.h NSE_HDRS=nse_main.h nse_auxiliar.h nse_nsock.h nse_init.h nse_nmaplib.h nse_debug.h nse_macros.h nse_string.h
NSE_OBJS=nse_main.o nse_auxiliar.o nse_nsock.o nse_init.o nse_nmaplib.o nse_debug.o nse_pcrelib.o nse_string.o NSE_OBJS=nse_main.o nse_auxiliar.o nse_nsock.o nse_init.o nse_nmaplib.o nse_debug.o nse_string.o
NSESTDLIB=nsestdlib NSESTDLIB=nsestdlib
endif endif

View File

@@ -285,10 +285,6 @@
RelativePath="..\nse_nsock.cc" RelativePath="..\nse_nsock.cc"
> >
</File> </File>
<File
RelativePath="..\nse_pcrelib.cc"
>
</File>
<File <File
RelativePath="..\nse_string.cc" RelativePath="..\nse_string.cc"
> >
@@ -474,10 +470,6 @@
RelativePath="..\nse_nsock.h" RelativePath="..\nse_nsock.h"
> >
</File> </File>
<File
RelativePath="..\nse_pcrelib.h"
>
</File>
<File <File
RelativePath="..\nse_string.h" RelativePath="..\nse_string.h"
> >

View File

@@ -4,7 +4,6 @@
#include "nse_debug.h" #include "nse_debug.h"
// 3rd Party libs // 3rd Party libs
#include "nse_pcrelib.h"
#include "nbase.h" #include "nbase.h"
@@ -44,7 +43,6 @@ int init_lua(lua_State* l) {
{LUA_STRLIBNAME, luaopen_string}, {LUA_STRLIBNAME, luaopen_string},
{LUA_MATHLIBNAME, luaopen_math}, {LUA_MATHLIBNAME, luaopen_math},
{LUA_DBLIBNAME, luaopen_debug}, {LUA_DBLIBNAME, luaopen_debug},
{NSE_PCRELIBNAME, luaopen_pcrelib},
{NULL, NULL} {NULL, NULL}
}; };

View File

@@ -1,9 +0,0 @@
#ifndef NSE_PCRELIB
#define NSE_PCRELIB
#define NSE_PCRELIBNAME "pcre"
LUALIB_API int luaopen_pcrelib (lua_State *L);
#endif

View File

@@ -12,15 +12,21 @@ INSTALL = $(SHTOOL) install
LIBTOOL= ./libtool LIBTOOL= ./libtool
LTFLAGS = --tag=CC --silent LTFLAGS = --tag=CC --silent
all: bit.so all: bit.so pcre.so
bit.so: bit.c @LIBTOOL_DEPS@ bit.so: bit.c @LIBTOOL_DEPS@
$(LIBTOOL) $(LTFLAGS) --mode=compile $(CC) @LUAINCLUDE@ $(CFLAGS) -c bit.c $(LIBTOOL) $(LTFLAGS) --mode=compile $(CC) @LUAINCLUDE@ $(CFLAGS) -c bit.c
$(LIBTOOL) $(LTFLAGS) --mode=link $(CC) -avoid-version -module -rpath /usr/local/lib -o bit.la bit.lo $(LIBTOOL) $(LTFLAGS) --mode=link $(CC) -avoid-version -module -rpath /usr/local/lib -o bit.la bit.lo
mv .libs/bit.so bit.so mv .libs/bit.so bit.so
pcre.so: pcre.c @LIBTOOL_DEPS@
$(LIBTOOL) $(LTFLAGS) --mode=compile $(CC) @NBASE_INCLUDE@ @PCRE_INCLUDE@ @LUAINCLUDE@ $(CFLAGS) -c pcre.c
$(LIBTOOL) $(LTFLAGS) --mode=link $(CC) @NBASE_LD@ @PCRE_LD@ @NBASE_LIBS@ @PCRE_LIBS@ -avoid-version -module -rpath /usr/local/lib -o pcre.la pcre.lo
mv .libs/pcre.so pcre.so
clean: clean:
rm -f bit.so *.la *.lo rm -f bit.so pcre.so *.la *.lo
rm -rf .libs rm -rf .libs
distclean: clean distclean: clean

119
nselib/configure vendored
View File

@@ -837,6 +837,12 @@ ac_ct_F77
LIBTOOL LIBTOOL
LIBTOOL_DEPS LIBTOOL_DEPS
LUAINCLUDE LUAINCLUDE
NBASE_LIBS
NBASE_LD
NBASE_INCLUDE
PCRE_INCLUDE
PCRE_LD
PCRE_LIBS
LIBOBJS LIBOBJS
LTLIBOBJS' LTLIBOBJS'
ac_subst_files='' ac_subst_files=''
@@ -1440,6 +1446,10 @@ Optional Packages:
--with-pic try to use only PIC/non-PIC objects [default=use --with-pic try to use only PIC/non-PIC objects [default=use
both] both]
--with-tags[=TAGS] include additional configurations [automatic] --with-tags[=TAGS] include additional configurations [automatic]
--with-libnbase=DIR Look for nbase include/libs in DIR
--with-libpcre=DIR Use an existing (compiled) pcre lib from DIR/include
and DIR/lib.
--with-libpcre=included Always use the version included with Nmap
Some influential environment variables: Some influential environment variables:
CC C compiler command CC C compiler command
@@ -3631,7 +3641,7 @@ ia64-*-hpux*)
;; ;;
*-*-irix6*) *-*-irix6*)
# Find out which ABI we are using. # Find out which ABI we are using.
echo '#line 3634 "configure"' > conftest.$ac_ext echo '#line 3644 "configure"' > conftest.$ac_ext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5 (eval $ac_compile) 2>&5
ac_status=$? ac_status=$?
@@ -6253,11 +6263,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'` -e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:6256: $lt_compile\"" >&5) (eval echo "\"\$as_me:6266: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err) (eval "$lt_compile" 2>conftest.err)
ac_status=$? ac_status=$?
cat conftest.err >&5 cat conftest.err >&5
echo "$as_me:6260: \$? = $ac_status" >&5 echo "$as_me:6270: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized # The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output. # So say no if there are warnings other than the usual output.
@@ -6521,11 +6531,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'` -e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:6524: $lt_compile\"" >&5) (eval echo "\"\$as_me:6534: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err) (eval "$lt_compile" 2>conftest.err)
ac_status=$? ac_status=$?
cat conftest.err >&5 cat conftest.err >&5
echo "$as_me:6528: \$? = $ac_status" >&5 echo "$as_me:6538: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized # The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output. # So say no if there are warnings other than the usual output.
@@ -6625,11 +6635,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'` -e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:6628: $lt_compile\"" >&5) (eval echo "\"\$as_me:6638: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err) (eval "$lt_compile" 2>out/conftest.err)
ac_status=$? ac_status=$?
cat out/conftest.err >&5 cat out/conftest.err >&5
echo "$as_me:6632: \$? = $ac_status" >&5 echo "$as_me:6642: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext if (exit $ac_status) && test -s out/conftest2.$ac_objext
then then
# The compiler can only warn and ignore the option if not recognized # The compiler can only warn and ignore the option if not recognized
@@ -8922,7 +8932,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 8925 "configure" #line 8935 "configure"
#include "confdefs.h" #include "confdefs.h"
#if HAVE_DLFCN_H #if HAVE_DLFCN_H
@@ -9022,7 +9032,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 9025 "configure" #line 9035 "configure"
#include "confdefs.h" #include "confdefs.h"
#if HAVE_DLFCN_H #if HAVE_DLFCN_H
@@ -11362,11 +11372,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'` -e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:11365: $lt_compile\"" >&5) (eval echo "\"\$as_me:11375: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err) (eval "$lt_compile" 2>conftest.err)
ac_status=$? ac_status=$?
cat conftest.err >&5 cat conftest.err >&5
echo "$as_me:11369: \$? = $ac_status" >&5 echo "$as_me:11379: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized # The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output. # So say no if there are warnings other than the usual output.
@@ -11466,11 +11476,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'` -e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:11469: $lt_compile\"" >&5) (eval echo "\"\$as_me:11479: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err) (eval "$lt_compile" 2>out/conftest.err)
ac_status=$? ac_status=$?
cat out/conftest.err >&5 cat out/conftest.err >&5
echo "$as_me:11473: \$? = $ac_status" >&5 echo "$as_me:11483: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext if (exit $ac_status) && test -s out/conftest2.$ac_objext
then then
# The compiler can only warn and ignore the option if not recognized # The compiler can only warn and ignore the option if not recognized
@@ -13027,11 +13037,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'` -e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:13030: $lt_compile\"" >&5) (eval echo "\"\$as_me:13040: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err) (eval "$lt_compile" 2>conftest.err)
ac_status=$? ac_status=$?
cat conftest.err >&5 cat conftest.err >&5
echo "$as_me:13034: \$? = $ac_status" >&5 echo "$as_me:13044: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized # The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output. # So say no if there are warnings other than the usual output.
@@ -13131,11 +13141,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'` -e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:13134: $lt_compile\"" >&5) (eval echo "\"\$as_me:13144: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err) (eval "$lt_compile" 2>out/conftest.err)
ac_status=$? ac_status=$?
cat out/conftest.err >&5 cat out/conftest.err >&5
echo "$as_me:13138: \$? = $ac_status" >&5 echo "$as_me:13148: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext if (exit $ac_status) && test -s out/conftest2.$ac_objext
then then
# The compiler can only warn and ignore the option if not recognized # The compiler can only warn and ignore the option if not recognized
@@ -15322,11 +15332,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'` -e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:15325: $lt_compile\"" >&5) (eval echo "\"\$as_me:15335: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err) (eval "$lt_compile" 2>conftest.err)
ac_status=$? ac_status=$?
cat conftest.err >&5 cat conftest.err >&5
echo "$as_me:15329: \$? = $ac_status" >&5 echo "$as_me:15339: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized # The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output. # So say no if there are warnings other than the usual output.
@@ -15590,11 +15600,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'` -e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:15593: $lt_compile\"" >&5) (eval echo "\"\$as_me:15603: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err) (eval "$lt_compile" 2>conftest.err)
ac_status=$? ac_status=$?
cat conftest.err >&5 cat conftest.err >&5
echo "$as_me:15597: \$? = $ac_status" >&5 echo "$as_me:15607: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized # The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output. # So say no if there are warnings other than the usual output.
@@ -15694,11 +15704,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'` -e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:15697: $lt_compile\"" >&5) (eval echo "\"\$as_me:15707: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err) (eval "$lt_compile" 2>out/conftest.err)
ac_status=$? ac_status=$?
cat out/conftest.err >&5 cat out/conftest.err >&5
echo "$as_me:15701: \$? = $ac_status" >&5 echo "$as_me:15711: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext if (exit $ac_status) && test -s out/conftest2.$ac_objext
then then
# The compiler can only warn and ignore the option if not recognized # The compiler can only warn and ignore the option if not recognized
@@ -18523,6 +18533,61 @@ fi
#needed for pcre - libpcre and nbase
# Check whether --with-libnbase was given.
if test "${with_libnbase+set}" = set; then
withval=$with_libnbase; case "$with_libnbase" in
yes)
;;
*)
NBASEDIR="$with_libnbase"
;;
esac
else
NBASEDIR="../nbase"
fi
NBASE_INCLUDE="-I$NBASEDIR"
NBASE_LD="-L$NBASEDIR"
NBASE_LIBS="-lnbase"
# First we test whether they specified libpcre explicitly
# Check whether --with-libpcre was given.
if test "${with_libpcre+set}" = set; then
withval=$with_libpcre; case "$with_libpcre" in
yes)
;;
included)
PCREDIR="../libpcre"
;;
*)
PCREDIR="$with_libpcre"
;;
esac
else
PCREDIR="../libpcre"
fi
PCRE_INCLUDE="-I$PCREDIR"
PCRE_LD="-L$PCREDIR"
PCRE_LIBS="-lpcre"
# AC_SUBST(PCREDIR)
ac_config_files="$ac_config_files Makefile" ac_config_files="$ac_config_files Makefile"
cat >confcache <<\_ACEOF cat >confcache <<\_ACEOF
@@ -19223,11 +19288,17 @@ ac_ct_F77!$ac_ct_F77$ac_delim
LIBTOOL!$LIBTOOL$ac_delim LIBTOOL!$LIBTOOL$ac_delim
LIBTOOL_DEPS!$LIBTOOL_DEPS$ac_delim LIBTOOL_DEPS!$LIBTOOL_DEPS$ac_delim
LUAINCLUDE!$LUAINCLUDE$ac_delim LUAINCLUDE!$LUAINCLUDE$ac_delim
NBASE_LIBS!$NBASE_LIBS$ac_delim
NBASE_LD!$NBASE_LD$ac_delim
NBASE_INCLUDE!$NBASE_INCLUDE$ac_delim
PCRE_INCLUDE!$PCRE_INCLUDE$ac_delim
PCRE_LD!$PCRE_LD$ac_delim
PCRE_LIBS!$PCRE_LIBS$ac_delim
LIBOBJS!$LIBOBJS$ac_delim LIBOBJS!$LIBOBJS$ac_delim
LTLIBOBJS!$LTLIBOBJS$ac_delim LTLIBOBJS!$LTLIBOBJS$ac_delim
_ACEOF _ACEOF
if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 72; then if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 78; then
break break
elif $ac_last_try; then elif $ac_last_try; then
{ { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5

View File

@@ -19,6 +19,54 @@ AC_CANONICAL_HOST
AC_CHECK_HEADER([lua.h],,[AC_MSG_NOTICE(using lua-includefiles provided with nmap);[LUAINCLUDE=-I../liblua/]],) AC_CHECK_HEADER([lua.h],,[AC_MSG_NOTICE(using lua-includefiles provided with nmap);[LUAINCLUDE=-I../liblua/]],)
AC_SUBST(LUAINCLUDE) AC_SUBST(LUAINCLUDE)
#needed for pcre - libpcre and nbase
AC_ARG_WITH(libnbase,
AC_HELP_STRING([--with-libnbase=DIR], [Look for nbase include/libs in DIR]),
[ case "$with_libnbase" in
yes)
;;
*)
NBASEDIR="$with_libnbase"
;;
esac],
NBASEDIR="../nbase"
)
NBASE_INCLUDE="-I$NBASEDIR"
NBASE_LD="-L$NBASEDIR"
NBASE_LIBS="-lnbase"
AC_SUBST(NBASE_LIBS)
AC_SUBST(NBASE_LD)
AC_SUBST(NBASE_INCLUDE)
# First we test whether they specified libpcre explicitly
AC_ARG_WITH(libpcre,
AC_HELP_STRING([--with-libpcre=DIR], [Use an existing (compiled) pcre lib from DIR/include and DIR/lib.])
AC_HELP_STRING([--with-libpcre=included], [Always use the version included with Nmap]),
[ case "$with_libpcre" in
yes)
;;
included)
PCREDIR="../libpcre"
;;
*)
PCREDIR="$with_libpcre"
;;
esac],
PCREDIR="../libpcre"
)
PCRE_INCLUDE="-I$PCREDIR"
PCRE_LD="-L$PCREDIR"
PCRE_LIBS="-lpcre"
# AC_SUBST(PCREDIR)
AC_SUBST(PCRE_INCLUDE)
AC_SUBST(PCRE_LD)
AC_SUBST(PCRE_LIBS)
AC_CONFIG_FILES([Makefile]) AC_CONFIG_FILES([Makefile])
AC_OUTPUT AC_OUTPUT

View File

@@ -7,18 +7,20 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#ifdef __cplusplus
extern "C" { extern "C" {
#endif
#include "lua.h" #include "lua.h"
#include "lauxlib.h" #include "lauxlib.h"
#ifdef __cplusplus
} }
#endif
#include <locale.h> #include <locale.h>
#include <pcre.h> #include <pcre.h>
#include "nbase.h" #include "pcre.h"
#include "nmap_error.h"
#include "nse_pcrelib.h"
static void L_lua_error(lua_State *L, const char *message) static void L_lua_error(lua_State *L, const char *message)
{ {
@@ -147,9 +149,17 @@ static int Lpcre_comp(lua_State *L)
if(error) L_lua_error(L, error); if(error) L_lua_error(L, error);
pcre_fullinfo(ud->pr, ud->extra, PCRE_INFO_CAPTURECOUNT, &ud->ncapt); pcre_fullinfo(ud->pr, ud->extra, PCRE_INFO_CAPTURECOUNT, &ud->ncapt);
/* since some platforms have problems with nbase and exporting symbols we
* emulate it
*/
if(((ud->ncapt + 1) * 3 * sizeof(int))<0){
L_lua_error(L, "PCRE: negative argument to malloc");
}
/* need (2 ints per capture, plus one for substring match) * 3/2 */ /* need (2 ints per capture, plus one for substring match) * 3/2 */
ud->match = (int *) safe_malloc((ud->ncapt + 1) * 3 * sizeof(int)); ud->match = (int *) malloc((ud->ncapt + 1) * 3 * sizeof(int));
if(ud->match==NULL){
L_lua_error(L, "PCRE: malloc failed!");
}
return 1; return 1;
} }
@@ -362,7 +372,7 @@ static const luaL_reg pcrelib[] = {
{NULL, NULL} {NULL, NULL}
}; };
LUALIB_API int luaopen_pcrelib(lua_State *L) LUALIB_API int luaopen_pcre(lua_State *L)
{ {
createmeta(L, pcre_handle); createmeta(L, pcre_handle);
luaL_openlib(L, NULL, pcremeta, 0); luaL_openlib(L, NULL, pcremeta, 0);

9
nselib/pcre.h Normal file
View File

@@ -0,0 +1,9 @@
#ifndef PCRE_H
#define PCRE_H
#define NSE_PCRELIBNAME "pcre"
LUALIB_API int luaopen_pcre(lua_State *L);
#endif

View File

@@ -10,6 +10,7 @@ categories = {"discovery"}
require("stdnse") require("stdnse")
require "shortport" require "shortport"
require "pcre"
portrule = shortport.port_or_service(6667, "irc") portrule = shortport.port_or_service(6667, "irc")