From dda2e4cee00cd7ea8e90820fb0a4313de028c571 Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Tue, 16 Apr 2002 04:25:44 +0000 Subject: [PATCH] ITS#1646 --- servers/slapd/back-perl/add.c | 9 +- servers/slapd/back-perl/asperl_undefs.h | 20 +++ servers/slapd/back-perl/backperl.dsp | 186 ++++++++++++++++++++++++ servers/slapd/back-perl/bind.c | 18 ++- servers/slapd/back-perl/close.c | 15 +- servers/slapd/back-perl/compare.c | 9 +- servers/slapd/back-perl/config.c | 10 +- servers/slapd/back-perl/delete.c | 9 +- servers/slapd/back-perl/init.c | 26 ++-- servers/slapd/back-perl/modify.c | 9 +- servers/slapd/back-perl/modrdn.c | 9 +- servers/slapd/back-perl/perl_back.h | 22 ++- servers/slapd/back-perl/search.c | 9 +- 13 files changed, 295 insertions(+), 56 deletions(-) create mode 100644 servers/slapd/back-perl/asperl_undefs.h create mode 100644 servers/slapd/back-perl/backperl.dsp diff --git a/servers/slapd/back-perl/add.c b/servers/slapd/back-perl/add.c index 56548d04b3..6f9477b348 100644 --- a/servers/slapd/back-perl/add.c +++ b/servers/slapd/back-perl/add.c @@ -12,14 +12,15 @@ #include "portable.h" #include -/* #include - #include -*/ + +#include "slap.h" +#ifdef HAVE_WIN32_ASPERL +#include "asperl_undefs.h" +#endif #include #include -#include "slap.h" #include "perl_back.h" int diff --git a/servers/slapd/back-perl/asperl_undefs.h b/servers/slapd/back-perl/asperl_undefs.h new file mode 100644 index 0000000000..15d0eab728 --- /dev/null +++ b/servers/slapd/back-perl/asperl_undefs.h @@ -0,0 +1,20 @@ +/* This file is necessary because both PERL headers */ +/* and OpenLDAP define a number of macros without */ +/* checking wether they're already defined */ + +#ifndef ASPERL_UNDEFS_H +#define ASPERL_UNDEFS_H + +/* ActiveState Win32 PERL port support */ +/* set in ldap/include/portable.h */ +# ifdef HAVE_WIN32_ASPERL +/* The following macros are undefined to prevent */ +/* redefinition in PERL headers*/ +# undef gid_t +# undef uid_t +# undef mode_t +# undef caddr_t +# undef WIN32_LEAN_AND_MEAN +# endif +#endif + diff --git a/servers/slapd/back-perl/backperl.dsp b/servers/slapd/back-perl/backperl.dsp new file mode 100644 index 0000000000..358d35861f --- /dev/null +++ b/servers/slapd/back-perl/backperl.dsp @@ -0,0 +1,186 @@ +# Microsoft Developer Studio Project File - Name="backperl" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +CFG=backperl - Win32 Single Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "backperl.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "backperl.mak" CFG="backperl - Win32 Single Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "backperl - Win32 Release" (based on "Win32 (x86) Static Library") +!MESSAGE "backperl - Win32 Debug" (based on "Win32 (x86) Static Library") +!MESSAGE "backperl - Win32 Single Debug" (based on "Win32 (x86) Static Library") +!MESSAGE "backperl - Win32 Single Release" (based on "Win32 (x86) Static Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "backperl - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "..\..\..\Release" +# PROP Intermediate_Dir "..\..\..\Release\backperl" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\\" /I "..\..\..\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_CONSOLE" /D "NO_STRICT" /D "HAVE_DES_CRYPT" /D "PERL_IMPLICIT_CONTEXT" /D "PERL_IMPLICIT_SYS" /D "PERL_MSVCRT_READFIX" /D "MULTIPLICITY" /YX /FD /c +# ADD BASE RSC /l 0x409 +# ADD RSC /l 0x409 +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo + +!ELSEIF "$(CFG)" == "backperl - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "..\..\..\Debug" +# PROP Intermediate_Dir "..\..\..\Debug\backperl" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /MTd /W3 /GX /Z7 /Od /I "..\\" /I "..\..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "PERL_IMPLICIT_CONTEXT" /D "PERL_IMPLICIT_SYS" /D "NO_STRICT" /D "HAVE_DES_FCRYPT" /D "PERL_MSVCRT_READFIX" /FR /YX /FD /c +# ADD BASE RSC /l 0x409 +# ADD RSC /l 0x409 +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo + +!ELSEIF "$(CFG)" == "backperl - Win32 Single Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "backperl" +# PROP BASE Intermediate_Dir "backperl" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "..\..\..\SDebug" +# PROP Intermediate_Dir "..\..\..\SDebug\backperl" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MTd /W3 /GX /Z7 /Od /I "..\\" /I "..\..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /YX /FD /c +# ADD CPP /nologo /W3 /GX /Z7 /Od /I "..\\" /I "..\..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /YX /FD /c +# ADD BASE RSC /l 0x409 +# ADD RSC /l 0x409 +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo + +!ELSEIF "$(CFG)" == "backperl - Win32 Single Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "backldb0" +# PROP BASE Intermediate_Dir "backldb0" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "..\..\..\SRelease" +# PROP Intermediate_Dir "..\..\..\SRelease\backperl" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /GX /O2 /I "..\\" /I "..\..\..\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "D:\perl\lib\CORE" /I "..\\" /I "..\..\..\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_CONSOLE" /D "NO_STRICT" /D "HAVE_DES_FCRYPT" /D "PERL_IMPLICIT_CONTEXT" /D "PERL_IMPLICIT_SYS" /D "PERL_MSVCRT_READFIX" /YX /FD /c +# ADD BASE RSC /l 0x409 +# ADD RSC /l 0x409 +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo + +!ENDIF + +# Begin Target + +# Name "backperl - Win32 Release" +# Name "backperl - Win32 Debug" +# Name "backperl - Win32 Single Debug" +# Name "backperl - Win32 Single Release" +# Begin Source File + +SOURCE=.\add.c +# End Source File +# Begin Source File + +SOURCE=.\asperl_undefs.h +# End Source File +# Begin Source File + +SOURCE=.\bind.c +# End Source File +# Begin Source File + +SOURCE=.\close.c +# End Source File +# Begin Source File + +SOURCE=.\compare.c +# End Source File +# Begin Source File + +SOURCE=.\config.c +# End Source File +# Begin Source File + +SOURCE=.\delete.c +# End Source File +# Begin Source File + +SOURCE=.\external.h +# End Source File +# Begin Source File + +SOURCE=.\init.c +# End Source File +# Begin Source File + +SOURCE=.\modify.c +# End Source File +# Begin Source File + +SOURCE=.\modrdn.c +# End Source File +# Begin Source File + +SOURCE=.\perl_back.h +# End Source File +# Begin Source File + +SOURCE=.\search.c +# End Source File +# End Target +# End Project diff --git a/servers/slapd/back-perl/bind.c b/servers/slapd/back-perl/bind.c index e76236ed39..a3d4b90042 100644 --- a/servers/slapd/back-perl/bind.c +++ b/servers/slapd/back-perl/bind.c @@ -10,17 +10,19 @@ */ #include "portable.h" -/* init.c - initialize shell backend */ +/* init.c - initialize Perl backend */ #include -/* #include - #include -*/ + +#include "slap.h" +#ifdef HAVE_WIN32_ASPERL +#include "asperl_undefs.h" +#endif #include +#include #include -#include "slap.h" #include "perl_back.h" @@ -46,12 +48,16 @@ perl_back_bind( PerlBackend *perl_back = (PerlBackend *) be->be_private; +#ifdef HAVE_WIN32_ASPERL + PERL_SET_CONTEXT( PERL_INTERPRETER ); +#endif + ldap_pvt_thread_mutex_lock( &perl_interpreter_mutex ); { dSP; ENTER; SAVETMPS; - PUSHMARK(sp); + PUSHMARK(SP); XPUSHs( perl_back->pb_obj_ref ); XPUSHs(sv_2mortal(newSVpv( dn->bv_val , 0))); XPUSHs(sv_2mortal(newSVpv( cred->bv_val , cred->bv_len))); diff --git a/servers/slapd/back-perl/close.c b/servers/slapd/back-perl/close.c index b3c407927c..66352378e2 100644 --- a/servers/slapd/back-perl/close.c +++ b/servers/slapd/back-perl/close.c @@ -13,14 +13,15 @@ /* init.c - initialize shell backend */ #include -/* #include - #include -*/ + +#include "slap.h" +#ifdef HAVE_WIN32_ASPERL +#include "asperl_undefs.h" +#endif #include #include -#include "slap.h" #include "perl_back.h" /********************************************************** @@ -36,7 +37,7 @@ perl_back_close( { ldap_pvt_thread_mutex_lock( &perl_interpreter_mutex ); - perl_destruct(perl_interpreter); + perl_destruct(PERL_INTERPRETER); ldap_pvt_thread_mutex_unlock( &perl_interpreter_mutex ); @@ -48,8 +49,8 @@ perl_back_destroy( BackendInfo *bd ) { - perl_free(perl_interpreter); - perl_interpreter = NULL; + perl_free(PERL_INTERPRETER); + PERL_INTERPRETER = NULL; ldap_pvt_thread_mutex_destroy( &perl_interpreter_mutex ); diff --git a/servers/slapd/back-perl/compare.c b/servers/slapd/back-perl/compare.c index a790c526c5..e2151647f5 100644 --- a/servers/slapd/back-perl/compare.c +++ b/servers/slapd/back-perl/compare.c @@ -12,14 +12,15 @@ #include "portable.h" #include -/* #include - #include -*/ + +#include "slap.h" +#ifdef HAVE_WIN32_ASPERL +#include "asperl_undefs.h" +#endif #include #include -#include "slap.h" #include "perl_back.h" /********************************************************** diff --git a/servers/slapd/back-perl/config.c b/servers/slapd/back-perl/config.c index fa46076f74..c461cf0a5e 100644 --- a/servers/slapd/back-perl/config.c +++ b/servers/slapd/back-perl/config.c @@ -10,17 +10,17 @@ */ #include "portable.h" -/* init.c - initialize shell backend */ #include -/* #include - #include -*/ + +#include "slap.h" +#ifdef HAVE_WIN32_ASPERL +#include "asperl_undefs.h" +#endif #include #include -#include "slap.h" #include "perl_back.h" diff --git a/servers/slapd/back-perl/delete.c b/servers/slapd/back-perl/delete.c index 8ce9efdb16..e78881c224 100644 --- a/servers/slapd/back-perl/delete.c +++ b/servers/slapd/back-perl/delete.c @@ -12,14 +12,15 @@ #include "portable.h" #include -/* #include -#include -*/ + +#include "slap.h" +#ifdef HAVE_WIN32_ASPERL +#include "asperl_undefs.h" +#endif #include #include -#include "slap.h" #include "perl_back.h" int diff --git a/servers/slapd/back-perl/init.c b/servers/slapd/back-perl/init.c index 5e87b63b50..54ebf66d56 100644 --- a/servers/slapd/back-perl/init.c +++ b/servers/slapd/back-perl/init.c @@ -13,23 +13,23 @@ /* init.c - initialize shell backend */ #include -/* #include - #include -*/ - +#include "slap.h" +#ifdef HAVE_WIN32_ASPERL +#include "asperl_undefs.h" +#endif #include +#include #include -#include "slap.h" #include "perl_back.h" -static void perl_back_xs_init LDAP_P((void)); -EXT void boot_DynaLoader LDAP_P((CV* cv)); +static void perl_back_xs_init LDAP_P((PERL_BACK_XS_INIT_PARAMS)); +EXT void boot_DynaLoader LDAP_P((PERL_BACK_BOOT_DYNALOADER_PARAMS)); -PerlInterpreter *perl_interpreter = NULL; +PerlInterpreter *PERL_INTERPRETER = NULL; ldap_pvt_thread_mutex_t perl_interpreter_mutex; #ifdef SLAPD_PERL_DYNAMIC @@ -64,16 +64,16 @@ perl_back_initialize( Debug( LDAP_DEBUG_TRACE, "perl backend open\n", 0, 0, 0 ); - if( perl_interpreter != NULL ) { + if( PERL_INTERPRETER != NULL ) { Debug( LDAP_DEBUG_ANY, "perl backend open: already opened\n", 0, 0, 0 ); return 1; } - perl_interpreter = perl_alloc(); - perl_construct(perl_interpreter); - perl_parse(perl_interpreter, perl_back_xs_init, 3, embedding, (char **)NULL); - perl_run(perl_interpreter); + PERL_INTERPRETER = perl_alloc(); + perl_construct(PERL_INTERPRETER); + perl_parse(PERL_INTERPRETER, perl_back_xs_init, 3, embedding, (char **)NULL); + perl_run(PERL_INTERPRETER); bi->bi_open = perl_back_open; bi->bi_config = 0; diff --git a/servers/slapd/back-perl/modify.c b/servers/slapd/back-perl/modify.c index e95e0feed4..2d394bd78a 100644 --- a/servers/slapd/back-perl/modify.c +++ b/servers/slapd/back-perl/modify.c @@ -12,14 +12,15 @@ #include "portable.h" #include -/* #include - #include -*/ + +#include "slap.h" +#ifdef HAVE_WIN32_ASPERL +#include "asperl_undefs.h" +#endif #include #include -#include "slap.h" #include "perl_back.h" int diff --git a/servers/slapd/back-perl/modrdn.c b/servers/slapd/back-perl/modrdn.c index 2990c89e8d..e4b970efdd 100644 --- a/servers/slapd/back-perl/modrdn.c +++ b/servers/slapd/back-perl/modrdn.c @@ -25,14 +25,15 @@ #include "portable.h" #include -/* #include - #include -*/ + +#include "slap.h" +#ifdef HAVE_WIN32_ASPERL +#include "asperl_undefs.h" +#endif #include #include -#include "slap.h" #include "perl_back.h" int diff --git a/servers/slapd/back-perl/perl_back.h b/servers/slapd/back-perl/perl_back.h index cb105577e3..232364492a 100644 --- a/servers/slapd/back-perl/perl_back.h +++ b/servers/slapd/back-perl/perl_back.h @@ -17,9 +17,29 @@ LDAP_BEGIN_DECL #define PERL_IS_5_6 #endif -extern PerlInterpreter *perl_interpreter; extern ldap_pvt_thread_mutex_t perl_interpreter_mutex; +#ifdef HAVE_WIN32_ASPERL +/* We should be using the PL_errgv, I think */ +/* All the old style variables are prefixed with PL_ now */ +# define errgv PL_errgv +# define na PL_na +#endif + +#ifdef HAVE_WIN32_ASPERL +/* pTHX is needed often now */ +# define PERL_INTERPRETER my_perl +# define PERL_BACK_XS_INIT_PARAMS pTHX +# define PERL_BACK_BOOT_DYNALOADER_PARAMS pTHX, CV *cv +#else +# define PERL_INTERPRETER perl_interpreter +# define PERL_BACK_XS_INIT_PARAMS void +# define PERL_BACK_BOOT_DYNALOADER_PARAMS CV *cv +#endif + +extern PerlInterpreter *PERL_INTERPRETER; + + typedef struct perl_backend_instance { char *pb_module_name; SV *pb_obj_ref; diff --git a/servers/slapd/back-perl/search.c b/servers/slapd/back-perl/search.c index 3dac9194e4..54c3d807ef 100644 --- a/servers/slapd/back-perl/search.c +++ b/servers/slapd/back-perl/search.c @@ -12,14 +12,15 @@ #include "portable.h" #include -/* #include - #include -*/ + +#include "slap.h" +#ifdef HAVE_WIN32_ASPERL +#include "asperl_undefs.h" +#endif #include #include -#include "slap.h" #include "perl_back.h" /********************************************************** -- 2.39.5