From: Jarkko Hietaniemi Date: Mon, 22 Apr 2002 15:15:22 +0000 (+0000) Subject: NetWare changeover from Watcom to Codewarrior, from C Aditya. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=011f1a1a00b94fe919083a224d5df636f05ae32a;p=p5sagit%2Fp5-mst-13.2.git NetWare changeover from Watcom to Codewarrior, from C Aditya. p4raw-id: //depot/perl@16076 --- diff --git a/NetWare/MP.imp b/NetWare/MP.imp new file mode 100644 index 0000000..fc38291 --- /dev/null +++ b/NetWare/MP.imp @@ -0,0 +1,5 @@ +# MPK Symbols not defined in the sdk import files +# Created by: Guruprasad on 25th May 2000 +kSemaphoreTimedWait, +kEnterNetWare, +kDelayThread diff --git a/NetWare/Makefile b/NetWare/Makefile index bda9695..e7f6ce7 100644 --- a/NetWare/Makefile +++ b/NetWare/Makefile @@ -1,7 +1,7 @@ ## -## Makefile to build Perl on NetWare using Microsoft NMAKE and Watcom tools +## Makefile to build Perl on NetWare using Microsoft NMAKE and CodeWarrior tools ## -## This will build perl.nlm, perl.lib and extensions called NLPs +## This will build perl.nlm, perl.lib and extensions called NLMs ## ## @@ -13,11 +13,12 @@ ## ## This file is created by using the makefile that creates Windows Perl as the reference -## Author: sgp -## Date Created: 13th July 2000 -## Date Modified: 29th Mar 2001 - +## Author: +## Date Created: 25th March 2002 +## Date Modified: # Name of the NLM + + NLM_NAME = perl.nlm NLM_NAME8 = Perl @@ -31,6 +32,7 @@ NW_FLAGS = -DNETWARE -DNLM_PLATFORM -DNETDB_USE_INTERNET REL_DIR = Release DEB_DIR = Debug + !ifndef MAKE_TYPE #MAKE_TYPE = Release !message "Run bat\buildtype.bat to set the build type before continuing.\n" @@ -44,101 +46,106 @@ XDCTOOL = mpkxdc !ifndef MPKBASE #MPKBASE = p:\mpk !message "Run bat\setnwbld.bat to set the NetWare MPK SDK before continuing.\n" -!error !endif #ifndef MPKBASE -NLM_INCLUDE_MP = $(MPKBASE)\include +NLM_INCLUDE_MP = -I$(MPKBASE)\include MPKTOOL = $(MPKBASE)\$(XDCTOOL) !else MPKMESSAGE = Non MPK Build... NLM_INCLUDE_MP = MPKTOOL = -!endif #ifdef USE_MPK +!endif #ifdef USE_MPK + +!ifndef NLM_VERSION +NLM_VERSION = 3,20,0 +!endif !ifndef NLMSDKBASE #NLMSDKBASE = P:\ndk\nwsdk !message "Run bat\setnwbld.bat to set the NetWare SDK before continuing.\n" !error -!endif #ifndef NLMSDKBASE +!endif #ifndef NLMSDKBASE +UCSINC = p:\apps\script\sw\ucs-inc NLMIMPORTS = $(NLMSDKBASE)\imports -!ifdef WATCOM -C_COMPILER = wcc386 -CPP_COMPILER = wpp386 -NLM_LINK = wlink -NLM_LIB = lib386 -TOOL_HEADERS = $(WATCOM)\H;$(WATCOM)\H\NT -TOOL_PATH = $(WATCOM)\BINNT;$(WATCOM)\BINW -CCFLAGS = /zp1 /5s /w1 /zq /ms /otexanih /fpi -COMPILER_FLAG = -DWATCOM -ERROR_FLAG = -Fr -!if "$(MAKE_TYPE)"=="Debug" -BLDDIR = $(DEB_DIR) -BLDMESG = Debug version, -!ifdef USE_D2 -BS_CFLAGS = /od /d2 /en /st /hc -DDEBUGGING -DUSE_D2 $(DBG_FLAG) -BLDMESG = $(BLDMESG) Using /d2 option -!else -BS_CFLAGS = /od /d1 /en /st /hc -DDEBUGGING $(DBG_FLAG) -BLDMESG = $(BLDMESG) Using /d1 option -!endif #!ifdef USE_D2 -! else -BLDDIR = $(REL_DIR) -BLDMESG = Release version -BS_CFLAGS = -!endif #if "$(MAKE_TYPE)"=="Debug" -!else #ifdef WATCOM -!ifdef CODEWARRIOR -# Here comes the CW tools - TO BE FILLED TO BUILD WITH CW - -C_COMPILER = -CPP_COMPILER = -NLM_LINK = -NLM_LIB = +!ifndef SECURITYBASE +SECURITYBASE = P:\apps\script\sw\nwsec +!message "Run bat\SetSecSdk.bat to set the Security paths before continuing.\n" +#!error +!endif #!ifndef MAKE_TYPE +SECURITY_IMPORTS = $(SECURITYBASE)\imports + + # Here comes the CW tools - TO BE FILLED TO BUILD WITH CW - +MODULE_DESC = "Perl 5.7.3 for NetWare" +CCTYPE = CodeWarrior +C_COMPILER = mwccnlm -c +CPP_COMPILER = mwccnlm +LINK = mwldnlm +LD = mwldnlm +NLM_LIB = mwldnlm -type library TOOL_HEADERS = TOOL_PATH = -CCFLAGS = -COMPILER_FLAG = -ERROR_FLAG = +CWCPPFLAGS = -cpp_exceptions on -wchar_t off -bool on -w on -ansi off +CCFLAGS = -maxerrors 25 -processor Pentium -align packed \ + -w nounusedarg -msext on -sym on -sym codeview4 -sym internal \ + -DN_PLAT_NLM -DNLM=1 -D__NO_MATH_OPS -msgstyle gcc +COMPILER_FLAG = -d NETWARE +ERROR_FLAG = -sym on -sym codeview4 -sym internal +LDFLAGS = -type generic -stacksize 16384 -zerobss \ + -nofail -msgstyle gcc -nostderr -w on \ + -nlmversion $(NLM_VERSION) \ + -copy "Copyright (C) 2000-01\, 2002 Novell\, Inc. All Rights Reserved." \ + -sym on -sym codeview4 -sym internal -osym perl.sym + # Debug flags comes here - Not mandatory - required only for debug build !if "$(MAKE_TYPE)"=="Debug" BLDDIR = $(DEB_DIR) -BLDMESG = Debug version, +BLDMESG = Debug version, !ifdef USE_D2 -BS_CFLAGS = +BS_CFLAGS = -opt off -inline off -sym on -sym codeview4 -sym internal -DDEBUGGING -DDKFBPON BLDMESG = $(BLDMESG) Using /d2 option +##LDFLAGS = $(LDFLAGS) -sym on -sym codeview4 -sym internal -osym $(BLDDIR)\$*.sym +LDFLAGS = $(LDFLAGS) -sym on -sym codeview4 -sym internal +## -osym $(BLDDIR)\$(NLM_NAME8).sym !else -BS_CFLAGS = +BS_CFLAGS = -opt off -inline off -sym on -sym codeview4 -sym internal -DDEBUGGING -DDKFBPON BLDMESG = $(BLDMESG) Using /d1 option -!endif #!ifdef USE_D2 -! else +##LDFLAGS = $(LDFLAGS) -sym on -sym codeview4 -sym internal -osym $(BLDDIR)\$*.sym +LDFLAGS = $(LDFLAGS) -sym on -sym codeview4 -sym internal +## -osym $(BLDDIR)\$(NLM_NAME8).sym +!endif #!ifdef USE_D2 +!else BLDDIR = $(REL_DIR) BLDMESG = Release version +##BS_CFLAGS = -opt speed -inline smart -inline auto -sym off BS_CFLAGS = -!endif #if "$(MAKE_TYPE)"=="Debug" -!else #!ifdef CODEWARRIOR -!message "Tools base directory is not defined. Run bat\setnwbld.bat before proceeding" -!error -Run bat\setnwbld.bat -!endif #!ifdef CODEWARRIOR -!endif #ifdef WATCOM +!endif #if "$(MAKE_TYPE)"=="Debug" #!ifdef CODEWARRIOR ADD_LOCDEFS = -DPERL_CORE NLM_INCLUDE = -I$(NLMSDKBASE)\include NLM_INCLUDE_NLM = -I$(NLMSDKBASE)\include\nlm NLM_INCLUDE_NLM_SYS = -I$(NLMSDKBASE)\include\nlm\sys +NLM_INCLUDE_OBSLETE = -I$(NLMSDKBASE)\include\nlm\obsolete +# SECURITY_INCLUDE = -I$(SECURITYBASE)\include +NLM_INCLUDE_UCS = -I$(UCSINC) +!if "$(NW_EXTNS)"=="yes" INCLUDE_NW = -I.\include +!endif INC_PREV = -I.. -INC_THIS = -I.\ +INC_THIS = -I. -NLM_INCLUDE_PATH = $(NLMSDKBASE)\include\nlm;$(NLMSDKBASE)\include;$(NLMSDKBASE)\include\nlm\sys;$(NLM_INCLUDE_MP);$(TOOL_HEADERS) - -INCLUDE = $(NLM_INCLUDE_PATH) +NLM_INCLUDE_PATH = $(NLM_INCLUDE) $(NLM_INCLUDE_NLM) $(NLM_INCLUDE_NLM_SYS) $(NLM_INCLUDE_OBSLETE) \ + $(NLM_INCLUDE_MP) $(NLM_INCLUDE_UCS) $(TOOL_HEADERS) +INCLUDE = $(INC_THIS) $(INC_PREV) -I- $(NLM_INCLUDE_PATH) PATH = $(PATH);$(TOOL_PATH) -NLM_INCLUDES = -I$(COREDIR) $(INCLUDE_NW) $(INC_THIS) $(INC_PREV) +NLM_INCLUDES = -I$(COREDIR) $(INCLUDE_NW) + +CCFLAGS = $(CCFLAGS) $(INCLUDE) -COMPLER_FLAGS = $(CCFLAGS) $(BS_CFLAGS) $(ADD_BUILDOPT) $(NW_FLAGS) $(COMPILER_FLAG) $(MPKFLAGS) +COMPLER_FLAGS = $(BS_CFLAGS) $(ADD_BUILDOPT) $(NW_FLAGS) $(COMPILER_FLAG) $(MPKFLAGS) $(CCFLAGS) + # Source file list NW_H_FILES = \ @@ -151,14 +158,15 @@ NW_H_FILES = \ .\nwplglob.h \ .\nwtinfo.h \ .\nwutil.h \ - .\nwperlsys.h \ + .\nwhashcls.h \ NW_HOST_H_FILES = \ .\iperlhost.h \ .\interface.h \ .\netware.h \ .\nw5sck.h \ - .\nwperlsys.h \ + .\nwperlhost.h \ + CLIB_H_FILES = \ .\clibsdio.h \ @@ -178,18 +186,23 @@ NW_SRC = \ .\nwtinfo.c \ .\nwutil.c \ +NW_CPP_SRC = \ + .\nwhashcls.cpp \ + .\interface.cpp \ + .\perllib.cpp \ + EXT_MAIN_SRC = \ .\Main.c \ PERL_IO_SRC = \ ..\perlio.c -PERL_LIB_SRC = \ - .\interface.c \ - .\nwperlsys.c \ - +CLIBSTUF_OBJ = \ + .\CLIBstuf.obj +#PERL_TMP_OBJ = $(PERL_TEMP_SRC:.c=.obj) NW_SRC_OBJ = $(NW_SRC:.c=.obj) +NW_CPP_SRC_OBJ = $(NW_CPP_SRC:.cpp=.obj) NLM_MICROCORE_OBJ = $(MICROCORE_SRC:.c=.obj) PERL_LIB_OBJ = $(PERL_LIB_SRC:.c=.obj) PERL_IO_OBJ = $(PERL_IO_SRC:.c=.obj) @@ -198,14 +211,16 @@ EXT_MAIN_OBJ = $(EXT_MAIN_SRC:.c=.obj) # For dependency checking # $(BLDDIR) in place of Release or Debug is not working, should look into this - sgp -!if "$(BLDDIR)"=="Release" +!if "$(BLDDIR)"=="Release" NLM_OBJ = $(NLM_CORE_OBJ:..\=.\Release\) NEWTARE_OBJ_DEP = $(NW_SRC_OBJ:.\=.\Release\) +NEWTARE_CPP_OBJ_DEP = $(NW_CPP_SRC_OBJ:.\=.\Release\) PERL_LIB_OBJ_DEP = $(PERL_LIB_OBJ:.\=.\Release\) PERL_IO_OBJ_DEP = $(PERL_IO_OBJ:..\=.\Release\) !else NLM_OBJ = $(NLM_CORE_OBJ:..\=.\Debug\) NEWTARE_OBJ_DEP = $(NW_SRC_OBJ:.\=.\Debug\) +NEWTARE_CPP_OBJ_DEP = $(NW_CPP_SRC_OBJ:.\=.\Debug\) PERL_LIB_OBJ_DEP = $(PERL_LIB_OBJ:.\=.\Debug\) PERL_IO_OBJ_DEP = $(PERL_IO_OBJ:..\=.\Debug\) !endif @@ -221,6 +236,7 @@ NW_CFG_VARS = \ "INST_NW_VER=$(INST_NW_VER)" \ "archname=$(ARCHNAME)" \ "cc=$(C_COMPILER)" \ + "ar=$(LINK)" \ "ccflags=$(COMPLER_FLAGS)" \ "cf_email=$(EMAIL)" \ "d_crypt=$(D_CRYPT)" \ @@ -238,16 +254,15 @@ NW_CFG_VARS = \ "useithreads=$(USE_ITHREADS)" \ "usethreads=$(USE_5005THREADS)" \ "usemultiplicity=$(USE_MULTI)" \ - "ld=$(NLM_LINK)" \ + "ld=$(LINK)" \ "base_import=$(BASE_IMPORT_FILES)" \ "LINK_FLAGS=$(LINK_FLAGS:"=\")" \ "optimize=" \ - "d_times=define" \ "d_stdio_cnt_lval=undef" \ "d_stdio_ptr_lval=undef" \ "d_stdiobase=undef" \ "d_stdstdio=undef" \ - "d_times=undef" \ + "d_times=undef" \ "direntrytype=DIR" \ "nlm_version=$(NLM_VERSION)" \ "d_archname=NetWare" \ @@ -258,72 +273,70 @@ NW_CFG_VARS = \ NW_CFGSH_TMPL = config.wc NW_CFGH_TMPL = config_H.wc -SOCKET_NLP = $(AUTODIR)\Socket\Socket.nlp -FCNTL_NLP = $(AUTODIR)\Fcntl\Fcntl.nlp -IO_NLP = $(AUTODIR)\IO\IO.nlp -OPCODE_NLP = $(AUTODIR)\Opcode\Opcode.nlp -SDBM_FILE_NLP = $(AUTODIR)\SDBM_File\SDBM_File.nlp -POSIX_NLP = $(AUTODIR)\POSIX\POSIX.nlp -ATTRS_NLP = $(AUTODIR)\attrs\attrs.nlp -THREAD_NLP = $(AUTODIR)\Thread\Thread.nlp -B_NLP = $(AUTODIR)\B\B.nlp -DUMPER_NLP = $(AUTODIR)\Data\Dumper\Dumper.nlp -PEEK_NLP = $(AUTODIR)\Devel\Peek\Peek.nlp -RE_NLP = $(AUTODIR)\re\re.nlp -BYTELOADER_NLP = $(AUTODIR)\ByteLoader\ByteLoader.nlp -DPROF_NLP = $(AUTODIR)\Devel\DProf\DProf.nlp -GLOB_NLP = $(AUTODIR)\File\Glob\Glob.nlp -HOSTNAME_NLP = $(AUTODIR)\Sys\Hostname\Hostname.nlp -CWD_NLP = $(AUTODIR)\Cwd\Cwd.nlp -STORABLE_NLP = $(AUTODIR)\Storable\Storable.nlp -LISTUTIL_NLP = $(AUTODIR)\List\Util\Util.nlp -MIMEBASE64_NLP = $(AUTODIR)\MIME\Base64\Base64.nlp -XSTYPEMAP_NLP = $(AUTODIR)\XS\Typemap\Typemap.nlp -UNICODENORMALIZE_NLP = $(AUTODIR)\XS\Typemap\Typemap.nlp - -EXTENSION_NLP = \ - $(FCNTL_NLP) \ - $(BYTELOADER_NLP) \ - $(IO_NLP) \ - $(SOCKET_NLP) \ - $(OPCODE_NLP) \ - $(B_NLP) \ - $(ATTRS_NLP) \ - $(SDBM_FILE_NLP) \ - $(POSIX_NLP) \ - $(THREAD_NLP) \ - $(DUMPER_NLP) \ - $(GLOB_NLP) \ - $(PEEK_NLP) \ - $(RE_NLP) \ - $(DPROF_NLP) \ - $(HOSTNAME_NLP) \ - $(STORABLE_NLP) \ - $(LISTUTIL_NLP) \ - $(MIMEBASE64_NLP) \ - $(XSTYPEMAP_NLP) \ - $(UNICODENORMALIZE_NLP) \ -# $(CWD_NLP) \ -# cwd.pm needs to be modifed for NetWare. - - -# Begin - Following is required to build NetWare specific extensions Perl2UCS, UCSExt & CGI2Perl - -PERL2UCS = $(EXTDIR)\Perl2UCS\Perl2UCS -UCSEXT = $(EXTDIR)\UCSExt\UCSExt -CGI2PERL = CGI2Perl\CGI2Perl - -PERL2UCS_NLP = $(AUTODIR)\Perl2UCS\Perl2UCS.nlp -UCSEXT_NLP = $(AUTODIR)\UCSExt\UCSExt.nlp -CGI2PERL_NLP = \CGI2Perl\CGI2Perl.nlp +SOCKET_NLM = $(AUTODIR)\Socket\Socket.NLM +FCNTL_NLM = $(AUTODIR)\Fcntl\Fcntl.NLM +IO_NLM = $(AUTODIR)\IO\IO.NLM +OPCODE_NLM = $(AUTODIR)\Opcode\Opcode.NLM +SDBM_FILE_NLM = $(AUTODIR)\SDBM_File\SDBM_File.NLM +POSIX_NLM = $(AUTODIR)\POSIX\POSIX.NLM +ATTRS_NLM = $(AUTODIR)\attrs\attrs.NLM +THREAD_NLM = $(AUTODIR)\Thread\Thread.NLM +B_NLM = $(AUTODIR)\B\B.NLM +DUMPER_NLM = $(AUTODIR)\Data\Dumper\Dumper.NLM +PEEK_NLM = $(AUTODIR)\Devel\Peek\Peek.NLM +RE_NLM = $(AUTODIR)\re\re.NLM +BYTELOADER_NLM = $(AUTODIR)\ByteLoader\ByteLoader.NLM +DPROF_NLM = $(AUTODIR)\Devel\DProf\DProf.NLM +GLOB_NLM = $(AUTODIR)\File\Glob\Glob.NLM +HOSTNAME_NLM = $(AUTODIR)\Sys\Hostname\Hostname.NLM +CWD_NLM = $(EXTDIR)\Cwd\Cwd.NLM +STORABLE_NLM = $(EXTDIR)\Storable\Storable.NLM +LISTUTIL_NLM = $(EXTDIR)\List\Util.NLM +MIMEBASE64_NLM = $(EXTDIR)\MIME\Base64\Base64.NLM +XSTYPEMAP_NLM = $(EXTDIR)\XS\Typemap\Typemap.NLM +UNICODENORMALIZE_NLM = $(EXTDIR)\Unicode\Normalize\Normalize.NLM + +EXTENSION_NLM = \ + $(SDBM_FILE_NLM) \ + $(POSIX_NLM) \ + $(THREAD_NLM) \ + $(DUMPER_NLM) \ + $(GLOB_NLM) \ + $(PEEK_NLM) \ + $(RE_NLM) \ + $(DPROF_NLM) \ + $(HOSTNAME_NLM) \ + $(CWD_NLM) \ + $(STORABLE_NLM) \ + $(LISTUTIL_NLM) \ + $(MIMEBASE64_NLM) \ + $(XSTYPEMAP_NLM) \ + $(FCNTL_NLM) \ + $(SOCKET_NLM) \ + $(OPCODE_NLM) \ + $(B_NLM) \ + $(ATTRS_NLM) \ + $(BYTELOADER_NLM) \ + $(IO_NLM) \ + $(UNICODENORMALIZE_NLM) + +# Begin - Following is required to build NetWare specific extensions CGI2Perl, Perl2UCS and UCSExt + +CGI2PERL = CGI2Perl\CGI2Perl +PERL2UCS = $(EXTDIR)\Perl2UCS\Perl2UCS +UCSExt = $(EXTDIR)\Perl2UCS\UCSExt + +CGI2PERL_NLM = \CGI2Perl\CGI2Perl.NLM +PERL2UCS_NLM = $(AUTODIR)\Perl2UCS\Perl2UCS.NLM +UCSExt_NLM = $(AUTODIR)\UCSExt\UCSExt.NLM NETWARE_EXTNS = \ - $(PERL2UCS_NLP) \ - $(UCSEXT_NLP) \ - $(CGI2PERL_NLP) + $(CGI2PERL_NLM) \ + $(UCSExt_NLM) \ + $(PERL2UCS_NLM) \ -# End +# End ECHO_SRC = TestNLM\echo\echo.c TYPE_SRC = TestNLM\type\type.c @@ -342,15 +355,15 @@ SCREEN = 'none' !endif !ifndef NLM_DESCRIPTION -NLM_DESCRIPTION = $(NLM_NAME8) for Netware +NLM_DESCRIPTION = $(NLM_NAME8) for NetWare !endif !ifndef NLM_VERSION -NLM_VERSION = 5.72.0 +NLM_VERSION = 3.1.0 !endif !ifndef NLM_EXT -NLM_EXT = NLM +NLM_EXT = NLM !endif !ifndef BUILT @@ -358,7 +371,8 @@ BUILT = $(BLDDIR)\$(NLM_NAME8).$(NLM_EXT) !endif !ifndef BASE_IMPORT_FILES -BASE_IMPORT_FILES = Import @$(NLMIMPORTS)\clib.imp, @$(NLMIMPORTS)\nlmlib.imp, @$(NLMIMPORTS)\threads.imp, @$(NLMIMPORTS)\nit.imp, @$(NLMIMPORTS)\socklib.imp, @$(NLMIMPORTS)\fpsm.imp, @$(NLMIMPORTS)\lib0.imp +BASE_IMPORT_FILES = Import @$(NLMIMPORTS)\clib.imp, @$(NLMIMPORTS)\nlmlib.imp, @$(NLMIMPORTS)\threads.imp, @$(NLMIMPORTS)\nit.imp, @$(NLMIMPORTS)\socklib.imp, \ +@$(NLMIMPORTS)\fpsm.imp, @$(NLMIMPORTS)\lib0.imp, @$(SECURITY_IMPORTS)\nwsec.imp !endif !ifdef USE_MPK @@ -368,32 +382,18 @@ BASE_IMPORT_FILES = $(BASE_IMPORT_FILES), @$(MPKBASE)\import\mpkorg.imp !ifndef BASE_IMPORT_FNS BASE_IMPORT_FNS = Import ImportSymbol, GetSystemConsoleScreen, LoadModule !endif - -!ifdef WATCOM -NWLIBPATH = $(WATCOM)\lib386\netware -LIBPATH386 = $(WATCOM)\lib386 -LIBPATH = $(NWLIBPATH);$(LIBPATH386) -!else #!ifdef WATCOM -!ifdef CODEWARRIOR -NWLIBPATH = -LIBPATH386 = -LIBPATH = -!else #!ifdef CODEWARRIOR -!error Please define the tools base directory before proceeding -!endif #!ifdef CODEWARRIOR -!endif #!ifdef WATCOM - + + !ifndef BASE_LIBRARIES -!ifdef WATCOM -BASE_LIBRARIES = Library plib3s.lib,math3s.lib,clib3s.lib -!else -!ifdef CODEWARRIOR +#!ifdef WATCOM +#BASE_LIBRARIES = Library plib3s.lib,math3s.lib,clib3s.lib +#!else +!ifdef CODEWAR BASE_LIBRARIES = !endif #!ifdef CODEWARRIOR -!endif #!ifdef WATCOM -!endif #!ifndef BASE_LIBRARIES - -COPYRIGHT = (C) Copyright 2001-2002 Novell Inc. All rights reserved. +!endif + +COPYRIGHT = (C) Copyright 2002 Novell Inc. All Rights Reserved. EXPORTS = Export @perl.imp @@ -401,7 +401,7 @@ EXPORTS = Export @perl.imp # Set these to wherever you want "nmake install" to put your # newly built perl. # -INST_DRV = c: +INST_DRV = C: INST_TOP = $(INST_DRV)\perl INST_NW_DRV = i: @@ -419,7 +419,7 @@ INST_NW_TOP2 = $(INST_NW_DRV)\perl # versioned installation can be obtained by setting INST_TOP above to a # path that includes an arbitrary version string. # -INST_VER = \5.7.3 +INST_VER = \5.7.2 # # Comment this out if you DON'T want your perl installation to have @@ -436,6 +436,7 @@ INST_ARCH = \$(ARCHNAME) # uncomment to enable multiple interpreters. This is need for fork() # emulation. # + USE_MULTI = define # @@ -456,7 +457,6 @@ USE_IMP_SYS = define # else USE_STDIO will be defined. #USE_PERLIO = define #USE_STDIO = define - # # WARNING! This option is deprecated and will eventually go away (enable # USE_ITHREADS instead). @@ -587,6 +587,7 @@ ARCHNAME = $(ARCHNAME)-perlio #ADD_BUILDOPT = $(ADD_BUILDOPT) -DUSE_STDIO !ENDIF + ARCHDIR = ..\lib\$(ARCHNAME) COREDIR = ..\lib\CORE AUTODIR = ..\lib\auto @@ -621,7 +622,7 @@ o = .obj # Rules # -.SUFFIXES : .c $(o) .nlm .lib .nlp +.SUFFIXES : .c $(o) .nlm .lib .NLM # @@ -657,6 +658,7 @@ UTILS = \ ..\x2p\s2p MAKE = nmake -nologo +#NMAKE = $(C_COMPILER) $(INCLUDE) $(NLM_INCLUDES) $(COMPLER_FLAGS) $(ADD_LOCDEFS) $(ERROR_FLAG) $(*F).c -o $@ XCOPY = xcopy /f /r /i /d RCOPY = xcopy /f /r /i /e /d @@ -759,8 +761,8 @@ CORE_NOCFG_H = \ ..\EXTERN.h \ ..\perlvars.h \ ..\intrpvar.h \ - ..\thrdvar.h - + ..\thrdvar.h + CORE_H = $(CORE_NOCFG_H) .\config.h DLL_OBJ = $(DLL_SRC:.c=.obj) @@ -771,28 +773,27 @@ DYNAMIC_EXT = Socket IO Fcntl Opcode SDBM_File POSIX attrs Thread B re \ Storable/Storable List/Util MIME/Base64/Base64 \ XS/Typemap/Typemap Unicode/Normalize/Normalize Sys/Hostname - STATIC_EXT = DynaLoader NONXS_EXT = Errno -DYNALOADER = $(EXTDIR)\DynaLoader\DynaLoader -SOCKET = $(EXTDIR)\Socket\Socket -FCNTL = $(EXTDIR)\Fcntl\Fcntl -OPCODE = $(EXTDIR)\Opcode\Opcode -SDBM_FILE = $(EXTDIR)\SDBM_File\SDBM_File +DYNALOADER = $(EXTDIR)\DynaLoader\DynaLoader +SOCKET = $(EXTDIR)\Socket\Socket +FCNTL = $(EXTDIR)\Fcntl\Fcntl +OPCODE = $(EXTDIR)\Opcode\Opcode +SDBM_FILE = $(EXTDIR)\SDBM_File\SDBM_File IO = $(EXTDIR)\IO\IO -POSIX = $(EXTDIR)\POSIX\POSIX -ATTRS = $(EXTDIR)\attrs\attrs -THREAD = $(EXTDIR)\Thread\Thread +POSIX = $(EXTDIR)\POSIX\POSIX +ATTRS = $(EXTDIR)\attrs\attrs +THREAD = $(EXTDIR)\Thread\Thread B = $(EXTDIR)\B\B RE = $(EXTDIR)\re\re -DUMPER = $(EXTDIR)\Data\Dumper\Dumper -ERRNO = $(EXTDIR)\Errno\Errno -PEEK = $(EXTDIR)\Devel\Peek\Peek -BYTELOADER = $(EXTDIR)\ByteLoader\ByteLoader -DPROF = $(EXTDIR)\Devel\DProf\DProf -GLOB = $(EXTDIR)\File\Glob\Glob -HOSTNAME = $(EXTDIR)\Sys\Hostname\Hostname +DUMPER = $(EXTDIR)\Data\Dumper\Dumper +ERRNO = $(EXTDIR)\Errno\Errno +PEEK = $(EXTDIR)\Devel\Peek\Peek +BYTELOADER = $(EXTDIR)\ByteLoader\ByteLoader +DPROF = $(EXTDIR)\Devel\DProf\DProf +GLOB = $(EXTDIR)\File\Glob\Glob +HOSTNAME = $(EXTDIR)\Sys\Hostname\Hostname CWD = $(EXTDIR)\Cwd\Cwd STORABLE = $(EXTDIR)\Storable\Storable LISTUTIL = $(EXTDIR)\List\Util @@ -802,7 +803,7 @@ UNICODENORMALIZE = $(EXTDIR)\Unicode\Normalize\Normalize ERRNO_PM_NW = $(LIBDIR)\Errno.pm -EXTENSION_C = \ +EXTENSION_C = \ $(SOCKET).c \ $(FCNTL).c \ $(OPCODE).c \ @@ -838,7 +839,7 @@ POD2TEXT = $(PODDIR)\pod2text # Top targets # -all : .cleanoldfiles .\nwconfig.h $(CONFIGPM) $(NLM_NAME) $(EXTENSION_NLP) $(EXTENSION_NPM) $(TEST_NLMS) $(NETWARE_EXTNS) +all : .cleanoldfiles .\nwconfig.h $(CONFIGPM) $(NLM_NAME) $(EXTENSION_NPM) $(NETWARE_EXTNS) $(TEST_NLMS) $(EXTENSION_NLM) #------------------------------------------------------------ @@ -877,65 +878,44 @@ $(MINIMOD) : $(MINIPERL) ..\minimod.pl ..\x2p\a2p$(o) : ..\x2p\a2p.c @echo $(MPKMESSAGE)...$(BLDMESG)...$@ - @$(C_COMPILER) -I..\x2p $(NLM_INCLUDES) $(COMPLER_FLAGS) $(ADD_LOCDEFS) $(OBJOUT_FLAG)$@ $(ERROR_FLAG)$*.err ..\x2p\a2p.c - + $(C_COMPILER) $(COMPLER_FLAGS) $(NLM_INCLUDES) -I..\x2p $(ADD_LOCDEFS) $(ERROR_FLAG) $*.c -o $@ + @echo Built $(@) + ..\x2p\hash$(o) : ..\x2p\hash.c @echo $(MPKMESSAGE)...$(BLDMESG)...$@ - @$(C_COMPILER) -I..\x2p $(NLM_INCLUDES) $(COMPLER_FLAGS) $(ADD_LOCDEFS) $(OBJOUT_FLAG)$@ $(ERROR_FLAG)$*.err ..\x2p\hash.c - + $(C_COMPILER) $(COMPLER_FLAGS) $(NLM_INCLUDES) -I..\x2p $(ADD_LOCDEFS) $(ERROR_FLAG) $*.c -o $@ + @echo Built $(@) + ..\x2p\str$(o) : ..\x2p\str.c @echo $(MPKMESSAGE)...$(BLDMESG)...$@ - @$(C_COMPILER) -I..\x2p $(NLM_INCLUDES) $(COMPLER_FLAGS) $(ADD_LOCDEFS) $(OBJOUT_FLAG)$@ $(ERROR_FLAG)$*.err ..\x2p\str.c + $(C_COMPILER) $(COMPLER_FLAGS) $(NLM_INCLUDES) -I..\x2p $(ADD_LOCDEFS) $(ERROR_FLAG) $*.c -o $@ + @echo Built $(@) ..\x2p\util$(o) : ..\x2p\util.c @echo $(MPKMESSAGE)...$(BLDMESG)...$@ - @$(C_COMPILER) -I..\x2p $(NLM_INCLUDES) $(COMPLER_FLAGS) $(ADD_LOCDEFS) $(OBJOUT_FLAG)$@ $(ERROR_FLAG)$*.err ..\x2p\util.c + $(C_COMPILER) $(COMPLER_FLAGS) $(NLM_INCLUDES) -I..\x2p $(ADD_LOCDEFS) $(ERROR_FLAG) $*.c -o $@ + @echo Built $(@) ..\x2p\walk$(o) : ..\x2p\walk.c @echo $(MPKMESSAGE)...$(BLDMESG)...$@ - @$(C_COMPILER) -I..\x2p $(NLM_INCLUDES) $(COMPLER_FLAGS) $(ADD_LOCDEFS) $(OBJOUT_FLAG)$@ $(ERROR_FLAG)$*.err ..\x2p\walk.c - + $(C_COMPILER) $(COMPLER_FLAGS) $(NLM_INCLUDES) -I..\x2p $(ADD_LOCDEFS) $(ERROR_FLAG) $*.c -o $@ + @echo Built $(@) + $(X2P) : $(MINIPERL) $(X2P_OBJ) + @echo Building $@.......... $(MINIPERL) ..\x2p\find2perl.PL $(MINIPERL) ..\x2p\s2p.PL +# Linker definitions and lining come here for CODEWARRIOR + @echo $(BASE_IMPORT_FILES) > $*.def + @echo MODULE clib >> $*.def + @echo Import @perl.imp >> $*.def !ifdef USE_XDC $(MPKTOOL) $(XDCFLAGS) $*.xdc + @echo Import Mp.imp >> $*.def + @echo xdcdata $*.xdc >> $*.def !endif -!ifdef WATCOM - @$(NLM_LINK) @<<$*.link - Form Novell NLM 'Awk to Perl converter' - Name $(X2P) - Option Quiet - Option Version = $(NLM_VERSION) - Option Copyright '$(COPYRIGHT)' - Option Caseexact - Option Map=$*.map, Verbose, screenname 'System Console' - Option Stack=32k - Option SYMFILE=$*.sym -!ifdef USE_XDC - OPTION XDCDATA=$*.xdc -!endif - Option NoDefaultLibs - $(EXTRA_LINK_OPTION) -!if "$(MAKE_TYPE)"=="Debug" - Debug novell - Debug codeview -!endif -LibPath $(LIBPATH) - $(BASE_LIBRARIES) - Module clib - $(BASE_IMPORT_FNS) - $(BASE_IMPORT_FILES) - $(ADD_IMPORT_FNS) -Import @perl.imp - $(EXPORTS) - File $(X2P_OBJ:.obj=,) .\$(BLDDIR)\clibstuf.obj -<\nwnul /* - * (C) Copyright 2001-2002 Novell Inc. All rights reserved. + * (C) Copyright 2002 Novell Inc. All Rights Reserved. * * You may distribute under the terms of either the GNU General Public * License or the Artistic License, as specified in the README file. @@ -957,7 +937,7 @@ HEADERS : * DESCRIPTION : Generated header file, do not edit. See makefile. * This header file causes the includer to use clibstuf.h * The purpose of clibstuf is to make sure that Perl, cgi2perl and - * all the perl extension nlm's (*.NLP) use the Novell Netware CLIB versions + * all the perl extension nlm's (*.NLM) use the Novell Netware CLIB versions * of standard functions. This code loads up a whole bunch of function pointers * to point at the standard CLIB functions. * Author : HYAK @@ -982,7 +962,7 @@ HEADERS : @copy << string.h >\nwnul /* - * (C) Copyright 2001-2002 Novell Inc. All rights reserved. + * (C) Copyright 2002 Novell Inc. All Rights Reserved. * * You may distribute under the terms of either the GNU General Public * License or the Artistic License, as specified in the README file. @@ -994,7 +974,7 @@ HEADERS : * DESCRIPTION : Generated header file, do not edit. See makefile. * This header file causes the includer to use clibstuf.h * The purpose of clibstuf is to make sure that Perl, cgi2perl and - * all the perl extension nlm's (*.NLP) use the Novell Netware CLIB versions + * all the perl extension nlm's (*.NLM) use the Novell Netware CLIB versions * of standard functions. This code loads up a whole bunch of function pointers * to point at the standard CLIB functions. * Author : HYAK @@ -1017,99 +997,64 @@ HEADERS : @copy string.h $(COREDIR) -$(NLM_NAME): MESSAGE HEADERS $(BLDDIR)\nwnul $(NLM_OBJ) $(NEWTARE_OBJ_DEP) $(PERL_IO_OBJ_DEP) $(PERL_LIB_OBJ_DEP) $(DLL_OBJ) .XDC $(PERLIMPLIB) $(EXT_MAIN_OBJ) +$(NLM_NAME): MESSAGE HEADERS $(BLDDIR)\nul $(NLM_OBJ) $(NEWTARE_OBJ_DEP) $(NEWTARE_CPP_OBJ_DEP) $(PERL_IO_OBJ_DEP) $(DLL_OBJ) \ + $(PERLIMPLIB) $(EXT_MAIN_OBJ) $(PERL_TEMP_OBJ) #$(PERL_LIB_OBJ) @echo======= Linking $@ at $(MAKEDIR)\$(BLDDIR) ======= -!ifdef WATCOM - @$(NLM_LINK) @<<$(BLDDIR)\$*.link - Form Novell NLM '$(NLM_DESCRIPTION)' - Name $(BUILT) - Option Quiet - Option Version = $(NLM_VERSION) - Option Copyright '$(COPYRIGHT)' - Option Caseexact - Option Map=$(BLDDIR)\$(NLM_NAME8).map, Verbose, screenname $(SCREEN) - Option Stack=1000 -!ifdef NLM_NAME8 - Option SYMFILE=$(BLDDIR)\$(NLM_NAME8).sym -!ifdef USE_XDC - OPTION XDCDATA=$(BLDDIR)\$(NLM_NAME8).xdc -!endif -!else - Option SYMFILE=$(BLDDIR)\$(NLM_NAME).sym -!ifdef USE_XDC - OPTION XDCDATA=$(BLDDIR)\$(NLM_NAME).xdc -!endif -!endif - Option NoDefaultLibs - $(EXTRA_LINK_OPTION) -!if "$(MAKE_TYPE)"=="Debug" - # Debug all - Debug novell - Debug codeview -!endif -LibPath $(LIBPATH) - $(BASE_LIBRARIES) - Module clib - Module netdb - $(BASE_IMPORT_FNS) - $(BASE_IMPORT_FILES) - $(ADD_IMPORT_FNS) -Import @perl.imp - $(EXPORTS) - File $(NEWTARE_OBJ_DEP:.obj=.obj,) $(NLM_OBJ:.obj=.obj,) $(PERL_IO_OBJ_DEP:.obj=.obj,) $(PERL_LIB_OBJ_DEP:.obj=.obj,) $(DLL_OBJ:.obj=.obj,) -< $*.def + @echo MODULE clib >> $*.def + @echo MODULE netdb >> $*.def +# @echo MODULE nwsec >> $*.def + @echo $(EXPORTS) >> $*.def +!ifdef USE_XDC + @echo======= Creating XDC file + @echo Import Mp.imp >> $*.def !ifdef NLM_NAME8 - .\bat\cvpack $(BLDDIR)\$(NLM_NAME8).sym + $(MPKTOOL) $(XDCFLAGS) $(BLDDIR)\$(NLM_NAME8).xdc + @echo xdcdata $(BLDDIR)\$(NLM_NAME8).xdc >> $*.def !else - .\bat\cvpack $(BLDDIR)\$(NLM_NAME).sym + $(MPKTOOL) $(XDCFLAGS) $(BLDDIR)\$(NLM_NAME).xdc + @echo xdcdata $(BLDDIR)\$(NLM_NAME).xdc >> $*.def !endif !endif - +## $(LINK) $(LDFLAGS) $(BS_CFLAGS) -desc "Perl 5.6.1 for NetWare" $(NEWTARE_OBJ_DEP:.obj=.obj) $(NLM_OBJ:.obj=.obj) $(PERL_IO_OBJ_DEP:.obj=.obj) $(DLL_OBJ:.obj=.obj) $(NEWTARE_CPP_OBJ_DEP:.obj=.obj) -commandfile $*.def -o .\$(BLDDIR)\$@ + $(LINK) $(LDFLAGS) -desc $(MODULE_DESC) $(NEWTARE_OBJ_DEP:.obj=.obj) $(NLM_OBJ:.obj=.obj) $(PERL_IO_OBJ_DEP:.obj=.obj) $(DLL_OBJ:.obj=.obj) $(NEWTARE_CPP_OBJ_DEP:.obj=.obj) -commandfile $*.def -o .\$(BLDDIR)\$@ + copy splittree.pl .. + $(MINIPERL) -I..\lib ..\splittree.pl "../LIB" $(AUTODIR) + @echo ========Linked $@ ========== +##!if "$(MAKE_TYPE)"=="Debug" +##!ifdef NLM_NAME8 +## .\bat\cvpack $(BLDDIR)\$(NLM_NAME8).sym +##!else +## .\bat\cvpack $(BLDDIR)\$(NLM_NAME).sym +##!endif +##!endif @echo======= Finished building $(BUILT). - -# Create the debug\release directory if not existing -$(BLDDIR)\nwnul: - @echo . . . . mkdir $(BLDDIR) - @mkdir $(BLDDIR) + +# Create the debug or release directory if not existing +$(BLDDIR)\nul: + @echo . . . . mkdir $(BLDDIR) + @mkdir $(BLDDIR) + @echo '$(BLDDIR)' directory created. MESSAGE: @echo======= $(MAKE_ACTION)ing $(NLM_NAME) at $(MAKEDIR)\$(BLDDIR) ======= - -.XDC: -!ifdef USE_XDC - @echo======= Creating XDC file -!ifdef NLM_NAME8 - $(MPKTOOL) $(XDCFLAGS) $(BLDDIR)\$(NLM_NAME8).xdc -!else - $(MPKTOOL) $(XDCFLAGS) $(BLDDIR)\$(NLM_NAME).xdc -!endif -!endif - -$(PERLIMPLIB): perllib.def - $(NLM_LIB) -def:perllib.def -out:$(PERLIMPLIB) - $(XCOPY) $(PERLIMPLIB) $(COREDIR) - -perllib.def : $(MINIPERL) $(CONFIGPM) ..\global.sym ..\pp.sym ..\makedef.pl - $(MINIPERL) -w ..\makedef.pl PLATFORM=netware FILETYPE=def $(BS_CFLAGS) $(DEFINES) $(ADD_BUILDOPT) \ - CCTYPE=$(CCTYPE) > perllib.def - $(MINIPERL) -w ..\makedef.pl PLATFORM=netware FILETYPE=imp $(BS_CFLAGS) $(DEFINES) $(ADD_BUILDOPT) \ - CCTYPE=$(CCTYPE) > perl.imp - + +$(PERLIMPLIB): perllib.imp + +perllib.imp : $(MINIPERL) $(CONFIGPM) ..\global.sym ..\pp.sym ..\makedef.pl +# $(MINIPERL) -w ..\makedef.pl PLATFORM=netware FILETYPE=def $(ADD_BUILDOPT) \ +# CCTYPE=$(CCTYPE) > perllib.def + @echo (Perl) > perl.imp + $(MINIPERL) -w ..\makedef.pl PLATFORM=netware FILETYPE=imp $(BS_CFLAGS) $(DEFINES) $(ADD_BUILDOPT) \ + CCTYPE=$(CCTYPE) >> perl.imp + copy perl.imp $(COREDIR) + $(DLL_OBJ) : $(DYNALOADER).c $(CORE_H) $(EXTDIR)\DynaLoader\dlutils.c - @echo $(MPKMESSAGE)...$(BLDMESG)...$@ - @$(C_COMPILER) @<<$(BLDDIR)\$(*F).options - $(NLM_INCLUDES) -I$(EXTDIR)\DynaLoader\ $(COMPLER_FLAGS) $(ADD_LOCDEFS) $(OBJOUT_FLAG)$@ $(ERROR_FLAG)$(BLDDIR)\$(*F).err $(EXTDIR)\DynaLoader\$(*F).c -< $(*B).c cd ..\..\netware + @echo Dynaloader Done -$(PERL_LIB_OBJ_DEP) : $(NW_HOST_H_FILES) $(*F).c - @echo $(MPKMESSAGE)...$(BLDMESG)...$@ - @$(CPP_COMPILER) @<<$(BLDDIR)\$(*F).options - -I.. $(NLM_INCLUDES) $(COMPLER_FLAGS) $(ADD_LOCDEFS) $(OBJOUT_FLAG)$@ $(ERROR_FLAG)$*.err $(*F).c -< $*.def + @echo MODULE clib >> $*.def + @echo Import @perl.imp >> $*.def !ifdef USE_XDC $(MPKTOOL) $(XDCFLAGS) $*.xdc + @echo Import @MP.imp >> $*.def + @echo xdcdata $*.xdc >> $*.def !endif -!ifdef WATCOM - @$(NLM_LINK) @<<$*.link - Form Novell NLM 'DOS echo emulation for Perl Testing' Name $@ - Option Quiet Option Version = $(NLM_VERSION) Option Copyright '$(COPYRIGHT)' Option Caseexact Option Map=$*.map, Verbose, screenname 'System Console' Option Stack=1000 Option SYMFILE=$*.sym Option NoDefaultLibs -!ifdef USE_XDC - OPTION XDCDATA=$*.xdc -!endif - $(EXTRA_LINK_OPTION) -!if "$(MAKE_TYPE)"=="Debug" - Debug novell - Debug codeview -!endif -LibPath $(LIBPATH) - $(BASE_LIBRARIES) Module clib $(BASE_IMPORT_FNS) $(BASE_IMPORT_FILES) $(ADD_IMPORT_FNS) -Import @perl.imp - $(EXPORTS) - File $(ECHO_SRC_OBJ:.obj=.obj,) .\$(BLDDIR)\clibstuf.obj -< $*.def + @echo MODULE clib >> $*.def + @echo Import @perl.imp >> $*.def !ifdef USE_XDC $(MPKTOOL) $(XDCFLAGS) $*.xdc + @echo Import @MP.imp >> $*.def + @echo xdcdata $*.xdc >> $*.def !endif -!ifdef WATCOM - @$(NLM_LINK) @<<$*.link - Form Novell NLM 'DOS type emulation for Perl Testing' Name $@ - Option Quiet Option Version = $(NLM_VERSION) Option Copyright '$(COPYRIGHT)' Option Caseexact Option Map=$*.map, Verbose, screenname 'System Console' Option Stack=1000 Option SYMFILE=$*.sym -!ifdef USE_XDC - OPTION XDCDATA=$*.xdc -!endif - Option NoDefaultLibs - $(EXTRA_LINK_OPTION) -!if "$(MAKE_TYPE)"=="Debug" - Debug novell - Debug codeview -!endif -LibPath $(LIBPATH) - $(BASE_LIBRARIES) Module clib $(BASE_IMPORT_FNS) $(BASE_IMPORT_FILES) $(ADD_IMPORT_FNS) -Import @perl.imp - $(EXPORTS) - File $(TYPE_SRC_OBJ:.obj=.obj,) .\$(BLDDIR)\clibstuf.obj -<data = ldata; + list->next = NULL; + unsigned long Bucket = ((unsigned long)ldata) % BUCKET_SIZE; + if (MemListHash[Bucket]) { + //Elements existing, insert at the beginning + list->next = MemListHash[Bucket]; + MemListHash[Bucket] = list; + DEBUGPRINT("Inserted to %d\n",Bucket); + } else { + //First element + MemListHash[Bucket] = list; + DEBUGPRINT("Inserted first time to %d\n",Bucket); + } + return 1; + } else + return 0; +} + +int +NWPerlHashList::remove(void *ldata) +{ + unsigned long Bucket = ((unsigned long)ldata) % BUCKET_SIZE; + HASHNODE *list = MemListHash[Bucket]; + if (list) { + int found = 0; + HASHNODE *next =list; + HASHNODE *prev =NULL; + do + { + if (list->data != ldata) { + prev = list; + list = list->next; + } + else { + found = 1; + next = list->next; + /*if(list->data) + { + free(list->data); + list->data = NULL; + }*/ + //ConsolePrintf ("A:%x;",list->data); + delete list; + list = NULL; + if (prev) { + prev->next = next; + } else { + MemListHash[Bucket]=next; + } + DEBUGPRINT("Removed element from %d\n",Bucket); + } + ThreadSwitchWithDelay(); + } while(list && !found); +// if (!found) +// ConsolePrintf("Couldn;t find %x in Bucket %d\n",ldata,Bucket); + return(found); + } + return 1; +} + + +void NWPerlHashList::forAll( register void (*user_fn)(void *, void*), void *data ) const +{ + + for(int i=0; inext; + if(next->data) + { + DEBUGPRINT("- To remove element from bucket %d\n",i); + user_fn( next->data, data ); + } + next = temp; + ThreadSwitchWithDelay(); + } + } + return ; +}; + +void NWPerlHashList::removeAll( ) const +{ + + for(int i=0; inext; + delete next; + next = temp; + ThreadSwitchWithDelay(); + } + } + return ; +}; + +/** +NWPerlKeyHashList::NWPerlKeyHashList() +{ + //initialize the hash list to null + for(int i=0;ikey = key; + list->data = ldata; + list->next = NULL; + unsigned long Bucket = ((unsigned long)key) % BUCKET_SIZE; + if (MemListHash[Bucket]) { + //Elements existing, insert at the beginning + list->next = MemListHash[Bucket]; + MemListHash[Bucket] = list; + DEBUGPRINT("Inserted to %d\n",Bucket); + } else { + //First element + MemListHash[Bucket] = list; + DEBUGPRINT("Inserted first time to %d\n",Bucket); + } + return 1; + } else + return 0; +} + +int +NWPerlKeyHashList::remove(void *key) +{ + unsigned long Bucket = ((unsigned long)key) % BUCKET_SIZE; + KEYHASHNODE *list = MemListHash[Bucket]; + if (list) { + int found = 0; + KEYHASHNODE *next =list; + KEYHASHNODE *prev =NULL; + do + { + if (list->key != key) { + prev = list; + list = list->next; + } + else { + found = 1; + next = list->next; + delete list; + list = NULL; + if (prev) { + prev->next = next; + } else { + MemListHash[Bucket]=next; + } + DEBUGPRINT("Removed element from %d\n",Bucket); + } + } while(list && !found); +// if (!found) +// ConsolePrintf("Couldn;t find %x in Bucket %d\n",key,Bucket); + return(found); + } + return 1; +} + + +void NWPerlKeyHashList::forAll( register void (*user_fn)(void *, void*), void *data ) const +{ + + for(int i=0; inext; + if(next->data) + { + DEBUGPRINT("- To remove element from bucket %d\n",i); + user_fn( next->data, data ); + } + next = temp; + ThreadSwitchWithDelay(); + } + } + return ; +}; + +int NWPerlKeyHashList::find(void *key,void **pData) +{ + for(int i=0; ikey==key) + { + *pData=next->data; + return 1; + } + next = next->next; + ThreadSwitchWithDelay(); + } + } + return 0; +} + +void NWPerlKeyHashList::removeAll( ) const +{ + + for(int i=0; inext; + delete next; + next = temp; + ThreadSwitchWithDelay(); + } + } + return ; +}; +**/ diff --git a/NetWare/nwhashcls.h b/NetWare/nwhashcls.h new file mode 100644 index 0000000..88956af --- /dev/null +++ b/NetWare/nwhashcls.h @@ -0,0 +1,79 @@ + +/* + * Copyright © 2001 Novell, Inc. All Rights Reserved. + * + * You may distribute under the terms of either the GNU General Public + * License or the Artistic License, as specified in the README file. + * + */ + +/* + * FILENAME : nwhashcls.h + * DESCRIPTION : Equivalent of Hash class + * + * Author : Srivathsa M + * Date Created : July 26 2001 + */ +#include +#include +#include + +#define BUCKET_SIZE 37 + +struct HASHNODE +{ + void *data; + struct HASHNODE *next; +}; + +typedef void (*HASHFORALLFUN)(void *, void *); + +class NWPerlHashList +{ +private: + HASHNODE* MemListHash[BUCKET_SIZE]; + void removeAll() const; + +public: + ~NWPerlHashList(); + NWPerlHashList(); + int insert(void *lData); + int remove(void *lData); + void forAll( void (*)(void *, void*), void * ) const; +}; + +struct KEYHASHNODE +{ + void *key; + void *data; + KEYHASHNODE *next; +}; + +/** +typedef void (*KEYHASHFORALLFUN)(void *, void *); + +class NWPerlKeyHashList +{ +private: + KEYHASHNODE* MemListHash[BUCKET_SIZE]; + void removeAll() const; + +public: + ~NWPerlKeyHashList(); + NWPerlKeyHashList(); + int insert(void *key, void *lData); + int remove(void *key); + void forAll( void (*)(void *, void*), void * ) const; + int find(void *key, void **pData); +}; +**/ + +//#define DEBUG_HASH 1 + +#ifdef DEBUG_HASH +#define DEBUGPRINT ConsolePrintf +#else +#define DEBUGPRINT +#endif + + diff --git a/NetWare/nwperlhost.h b/NetWare/nwperlhost.h new file mode 100644 index 0000000..002bc67 --- /dev/null +++ b/NetWare/nwperlhost.h @@ -0,0 +1,1699 @@ + +/* + * Copyright © 2001 Novell, Inc. All Rights Reserved. + * + * You may distribute under the terms of either the GNU General Public + * License or the Artistic License, as specified in the README file. + * + */ + +/* + * FILENAME : nwperlhost.h + * DESCRIPTION : This is modelled on the perlhost.h module of Win32 port. + * This is the host that include all the functions for running Perl within a class. + * Author : SGP, HYAK + * Date : January 2001. + * + */ + + + +#ifndef ___NWPerlHost_H___ +#define ___NWPerlHost_H___ + + +#include "iperlsys.h" +#include "nwvmem.h" + +#include "nw5sck.h" +#include "netware.h" + +#define LPBYTE unsigned char * + +#if !defined(PERL_OBJECT) +START_EXTERN_C +#endif /* PERL_OBJECT */ + +extern int do_spawn2(char *cmd, int exectype); +extern int do_aspawn(void *vreally, void **vmark, void **vsp); +extern void Perl_init_os_extras(void); + +#if !defined(PERL_OBJECT) +END_EXTERN_C +#endif /* PERL_OBJECT */ + +#ifdef PERL_OBJECT +extern int g_do_aspawn(void *vreally, void **vmark, void **vsp); +#define do_aspawn g_do_aspawn +#endif /* PERL_OBJECT */ + +class CPerlHost +{ +public: + CPerlHost(void); + CPerlHost(struct IPerlMem** ppMem, struct IPerlMem** ppMemShared, + struct IPerlMem** ppMemParse, struct IPerlEnv** ppEnv, + struct IPerlStdIO** ppStdIO, struct IPerlLIO** ppLIO, + struct IPerlDir** ppDir, struct IPerlSock** ppSock, + struct IPerlProc** ppProc); + CPerlHost(const CPerlHost& host); + virtual ~CPerlHost(void); + + static CPerlHost* IPerlMem2Host(struct IPerlMem* piPerl); + static CPerlHost* IPerlMemShared2Host(struct IPerlMem* piPerl); + static CPerlHost* IPerlMemParse2Host(struct IPerlMem* piPerl); + static CPerlHost* IPerlEnv2Host(struct IPerlEnv* piPerl); + static CPerlHost* IPerlStdIO2Host(struct IPerlStdIO* piPerl); + static CPerlHost* IPerlLIO2Host(struct IPerlLIO* piPerl); + static CPerlHost* IPerlDir2Host(struct IPerlDir* piPerl); + static CPerlHost* IPerlSock2Host(struct IPerlSock* piPerl); + static CPerlHost* IPerlProc2Host(struct IPerlProc* piPerl); + +/* IPerlMem */ + inline void* Malloc(size_t size) { return m_pVMem->Malloc(size); }; + inline void* Realloc(void* ptr, size_t size) { return m_pVMem->Realloc(ptr, size); }; + inline void Free(void* ptr) { m_pVMem->Free(ptr); }; + inline void* Calloc(size_t num, size_t size){ return m_pVMem->Calloc(num, size); }; + +/* IPerlMemShared */ + inline void* MallocShared(size_t size) + { + return m_pVMemShared->Malloc(size); + }; + inline void* ReallocShared(void* ptr, size_t size) { return m_pVMemShared->Realloc(ptr, size); }; + inline void FreeShared(void* ptr) { m_pVMemShared->Free(ptr); }; + inline void* CallocShared(size_t num, size_t size) + { + size_t count = num*size; + void* lpVoid = MallocShared(count); + + return lpVoid; + }; + +/* IPerlMemParse */ + inline void* MallocParse(size_t size) { return m_pVMemParse->Malloc(size); }; + inline void* ReallocParse(void* ptr, size_t size) { return m_pVMemParse->Realloc(ptr, size); }; + inline void FreeParse(void* ptr) { m_pVMemParse->Free(ptr); }; + inline void* CallocParse(size_t num, size_t size) + { + size_t count = num*size; + void* lpVoid = MallocParse(count); + + return lpVoid; + }; + +/* IPerlEnv */ + char *Getenv(const char *varname); + int Putenv(const char *envstring); + inline char *Getenv(const char *varname, unsigned long *len) + { + *len = 0; + char *e = Getenv(varname); + if (e) + *len = strlen(e); + return e; + } + + +public: + +/* IPerlDIR */ + + +/* IPerllProc */ + void Abort(void); + void Exit(int status); + void _Exit(int status); + int Execl(const char *cmdname, const char *arg0, const char *arg1, const char *arg2, const char *arg3); + int Execv(const char *cmdname, const char *const *argv); + int Execvp(const char *cmdname, const char *const *argv); + +public: + + struct IPerlMem m_hostperlMem; + struct IPerlMem m_hostperlMemShared; + struct IPerlMem m_hostperlMemParse; + struct IPerlEnv m_hostperlEnv; + struct IPerlStdIO m_hostperlStdIO; + struct IPerlLIO m_hostperlLIO; + struct IPerlDir m_hostperlDir; + struct IPerlSock m_hostperlSock; + struct IPerlProc m_hostperlProc; + + struct IPerlMem* m_pHostperlMem; + struct IPerlMem* m_pHostperlMemShared; + struct IPerlMem* m_pHostperlMemParse; + struct IPerlEnv* m_pHostperlEnv; + struct IPerlStdIO* m_pHostperlStdIO; + struct IPerlLIO* m_pHostperlLIO; + struct IPerlDir* m_pHostperlDir; + struct IPerlSock* m_pHostperlSock; + struct IPerlProc* m_pHostperlProc; + +protected: + + VMem* m_pVMem; + VMem* m_pVMemShared; + VMem* m_pVMemParse; +}; + + +#define STRUCT2PTR(x, y) (CPerlHost*)(((LPBYTE)x)-offsetof(CPerlHost, y)) + +inline CPerlHost* IPerlMem2Host(struct IPerlMem* piPerl) +{ + return STRUCT2PTR(piPerl, m_hostperlMem); +} + +inline CPerlHost* IPerlMemShared2Host(struct IPerlMem* piPerl) +{ + return STRUCT2PTR(piPerl, m_hostperlMemShared); +} + +inline CPerlHost* IPerlMemParse2Host(struct IPerlMem* piPerl) +{ + return STRUCT2PTR(piPerl, m_hostperlMemParse); +} + +inline CPerlHost* IPerlEnv2Host(struct IPerlEnv* piPerl) +{ + return STRUCT2PTR(piPerl, m_hostperlEnv); +} + +inline CPerlHost* IPerlStdIO2Host(struct IPerlStdIO* piPerl) +{ + return STRUCT2PTR(piPerl, m_hostperlStdIO); +} + +inline CPerlHost* IPerlLIO2Host(struct IPerlLIO* piPerl) +{ + return STRUCT2PTR(piPerl, m_hostperlLIO); +} + +inline CPerlHost* IPerlDir2Host(struct IPerlDir* piPerl) +{ + return STRUCT2PTR(piPerl, m_hostperlDir); +} + +inline CPerlHost* IPerlSock2Host(struct IPerlSock* piPerl) +{ + return STRUCT2PTR(piPerl, m_hostperlSock); +} + +inline CPerlHost* IPerlProc2Host(struct IPerlProc* piPerl) +{ + return STRUCT2PTR(piPerl, m_hostperlProc); +} + + +#undef IPERL2HOST +#define IPERL2HOST(x) IPerlMem2Host(x) + + +/* IPerlMem */ +void* +PerlMemMalloc(struct IPerlMem* piPerl, size_t size) +{ + return IPERL2HOST(piPerl)->Malloc(size); +} +void* +PerlMemRealloc(struct IPerlMem* piPerl, void* ptr, size_t size) +{ + return IPERL2HOST(piPerl)->Realloc(ptr, size); +} +void +PerlMemFree(struct IPerlMem* piPerl, void* ptr) +{ + IPERL2HOST(piPerl)->Free(ptr); +} +void* +PerlMemCalloc(struct IPerlMem* piPerl, size_t num, size_t size) +{ + return IPERL2HOST(piPerl)->Calloc(num, size); +} + + +struct IPerlMem perlMem = +{ + PerlMemMalloc, + PerlMemRealloc, + PerlMemFree, + PerlMemCalloc, +}; + +#undef IPERL2HOST +#define IPERL2HOST(x) IPerlMemShared2Host(x) + +/* IPerlMemShared */ +void* +PerlMemSharedMalloc(struct IPerlMem* piPerl, size_t size) +{ + return IPERL2HOST(piPerl)->MallocShared(size); +} +void* +PerlMemSharedRealloc(struct IPerlMem* piPerl, void* ptr, size_t size) +{ + return IPERL2HOST(piPerl)->ReallocShared(ptr, size); +} +void +PerlMemSharedFree(struct IPerlMem* piPerl, void* ptr) +{ + IPERL2HOST(piPerl)->FreeShared(ptr); +} +void* +PerlMemSharedCalloc(struct IPerlMem* piPerl, size_t num, size_t size) +{ + return IPERL2HOST(piPerl)->CallocShared(num, size); +} + + +struct IPerlMem perlMemShared = +{ + PerlMemSharedMalloc, + PerlMemSharedRealloc, + PerlMemSharedFree, + PerlMemSharedCalloc, +}; + +#undef IPERL2HOST +#define IPERL2HOST(x) IPerlMemParse2Host(x) + +/* IPerlMemParse */ +void* +PerlMemParseMalloc(struct IPerlMem* piPerl, size_t size) +{ + return IPERL2HOST(piPerl)->MallocParse(size); +} +void* +PerlMemParseRealloc(struct IPerlMem* piPerl, void* ptr, size_t size) +{ + return IPERL2HOST(piPerl)->ReallocParse(ptr, size); +} +void +PerlMemParseFree(struct IPerlMem* piPerl, void* ptr) +{ + IPERL2HOST(piPerl)->FreeParse(ptr); +} +void* +PerlMemParseCalloc(struct IPerlMem* piPerl, size_t num, size_t size) +{ + return IPERL2HOST(piPerl)->CallocParse(num, size); +} + + +struct IPerlMem perlMemParse = +{ + PerlMemParseMalloc, + PerlMemParseRealloc, + PerlMemParseFree, + PerlMemParseCalloc, +}; + + +#undef IPERL2HOST +#define IPERL2HOST(x) IPerlEnv2Host(x) + +/* IPerlEnv */ +char* +PerlEnvGetenv(struct IPerlEnv* piPerl, const char *varname) +{ + return IPERL2HOST(piPerl)->Getenv(varname); +}; + +int +PerlEnvPutenv(struct IPerlEnv* piPerl, const char *envstring) +{ + return IPERL2HOST(piPerl)->Putenv(envstring); +}; + +char* +PerlEnvGetenv_len(struct IPerlEnv* piPerl, const char* varname, unsigned long* len) +{ + return IPERL2HOST(piPerl)->Getenv(varname, len); +} + +int +PerlEnvUname(struct IPerlEnv* piPerl, struct utsname *name) +{ + return nw_uname(name); +} + +void +PerlEnvClearenv(struct IPerlEnv* piPerl) +{ + // If removed, compilation fails while compiling CGI2Perl. +} + +void* +PerlEnvGetChildenv(struct IPerlEnv* piPerl) +{ + // If removed, compilation fails while compiling CGI2Perl. + return NULL; +} + +void +PerlEnvFreeChildenv(struct IPerlEnv* piPerl, void* childEnv) +{ + // If removed, compilation fails while compiling CGI2Perl. +} + +char* +PerlEnvGetChilddir(struct IPerlEnv* piPerl) +{ + // If removed, compilation fails while compiling CGI2Perl. + return NULL; +} + +void +PerlEnvFreeChilddir(struct IPerlEnv* piPerl, char* childDir) +{ + // If removed, compilation fails while compiling CGI2Perl. +} + +struct IPerlEnv perlEnv = +{ + PerlEnvGetenv, + PerlEnvPutenv, + PerlEnvGetenv_len, + PerlEnvUname, + PerlEnvClearenv, + PerlEnvGetChildenv, + PerlEnvFreeChildenv, + PerlEnvGetChilddir, + PerlEnvFreeChilddir, +}; + +#undef IPERL2HOST +#define IPERL2HOST(x) IPerlStdIO2Host(x) + +/* PerlStdIO */ +PerlIO* +PerlStdIOStdin(struct IPerlStdIO* piPerl) +{ + return (PerlIO*)nw_stdin(); +} + +PerlIO* +PerlStdIOStdout(struct IPerlStdIO* piPerl) +{ + return (PerlIO*)nw_stdout(); +} + +PerlIO* +PerlStdIOStderr(struct IPerlStdIO* piPerl) +{ + return (PerlIO*)nw_stderr(); +} + +PerlIO* +PerlStdIOOpen(struct IPerlStdIO* piPerl, const char *path, const char *mode) +{ + return (PerlIO*)nw_fopen(path, mode); +} + +int +PerlStdIOClose(struct IPerlStdIO* piPerl, PerlIO* pf) +{ + return nw_fclose(((FILE*)pf)); +} + +int +PerlStdIOEof(struct IPerlStdIO* piPerl, PerlIO* pf) +{ + return nw_feof((FILE*)pf); +} + +int +PerlStdIOError(struct IPerlStdIO* piPerl, PerlIO* pf) +{ + return nw_ferror((FILE*)pf); +} + +void +PerlStdIOClearerr(struct IPerlStdIO* piPerl, PerlIO* pf) +{ + nw_clearerr((FILE*)pf); +} + +int +PerlStdIOGetc(struct IPerlStdIO* piPerl, PerlIO* pf) +{ + return nw_getc((FILE*)pf); +} + +char* +PerlStdIOGetBase(struct IPerlStdIO* piPerl, PerlIO* pf) +{ +#ifdef FILE_base + FILE *f = (FILE*)pf; + return FILE_base(f); +#else + return Nullch; +#endif +} + +int +PerlStdIOGetBufsiz(struct IPerlStdIO* piPerl, PerlIO* pf) +{ +#ifdef FILE_bufsiz + FILE *f = (FILE*)pf; + return FILE_bufsiz(f); +#else + return (-1); +#endif +} + +int +PerlStdIOGetCnt(struct IPerlStdIO* piPerl, PerlIO* pf) +{ +#ifdef USE_STDIO_PTR + FILE *f = (FILE*)pf; + return FILE_cnt(f); +#else + return (-1); +#endif +} + +char* +PerlStdIOGetPtr(struct IPerlStdIO* piPerl, PerlIO* pf) +{ +#ifdef USE_STDIO_PTR + FILE *f = (FILE*)pf; + return FILE_ptr(f); +#else + return Nullch; +#endif +} + +char* +PerlStdIOGets(struct IPerlStdIO* piPerl, PerlIO* pf, char* s, int n) +{ + return nw_fgets(s, n, (FILE*)pf); +} + +int +PerlStdIOPutc(struct IPerlStdIO* piPerl, PerlIO* pf, int c) +{ + return nw_fputc(c, (FILE*)pf); +} + +int +PerlStdIOPuts(struct IPerlStdIO* piPerl, PerlIO* pf, const char *s) +{ + return nw_fputs(s, (FILE*)pf); +} + +int +PerlStdIOFlush(struct IPerlStdIO* piPerl, PerlIO* pf) +{ + return nw_fflush((FILE*)pf); +} + +int +PerlStdIOUngetc(struct IPerlStdIO* piPerl, int c, PerlIO* pf) //(J) +{ + return nw_ungetc(c, (FILE*)pf); +} + +int +PerlStdIOFileno(struct IPerlStdIO* piPerl, PerlIO* pf) +{ + return nw_fileno((FILE*)pf); +} + +PerlIO* +PerlStdIOFdopen(struct IPerlStdIO* piPerl, int fd, const char *mode) +{ + return (PerlIO*)nw_fdopen(fd, mode); +} + +PerlIO* +PerlStdIOReopen(struct IPerlStdIO* piPerl, const char*path, const char*mode, PerlIO* pf) +{ + return (PerlIO*)nw_freopen(path, mode, (FILE*)pf); +} + +SSize_t +PerlStdIORead(struct IPerlStdIO* piPerl, void *buffer, Size_t size, Size_t dummy, PerlIO* pf) +{ + return nw_fread(buffer, 1, size, (FILE*)pf); +} + +SSize_t +PerlStdIOWrite(struct IPerlStdIO* piPerl, const void *buffer, Size_t size, Size_t dummy, PerlIO* pf) +//PerlStdIOWrite(struct IPerlStdIO* piPerl, PerlIO* pf, const void *buffer, Size_t size) +{ + return nw_fwrite(buffer, 1, size, (FILE*)pf); +} + +void +PerlStdIOSetBuf(struct IPerlStdIO* piPerl, PerlIO* pf, char* buffer) +{ + nw_setbuf((FILE*)pf, buffer); +} + +int +PerlStdIOSetVBuf(struct IPerlStdIO* piPerl, PerlIO* pf, char* buffer, int type, Size_t size) +{ + return nw_setvbuf((FILE*)pf, buffer, type, size); +} + +void +PerlStdIOSetCnt(struct IPerlStdIO* piPerl, PerlIO* pf, int n) +{ +#ifdef STDIO_CNT_LVALUE + FILE *f = (FILE*)pf; + FILE_cnt(f) = n; +#endif +} + +void +PerlStdIOSetPtrCnt(struct IPerlStdIO* piPerl, PerlIO* pf, char * ptr, int n) +{ +#ifdef STDIO_PTR_LVALUE + FILE *f = (FILE*)pf; + FILE_ptr(f) = ptr; + FILE_cnt(f) = n; +#endif +} + +void +PerlStdIOSetlinebuf(struct IPerlStdIO* piPerl, PerlIO* pf) +{ + nw_setvbuf((FILE*)pf, NULL, _IOLBF, 0); +} + +int +PerlStdIOPrintf(struct IPerlStdIO* piPerl, PerlIO* pf, const char *format,...) +{ + va_list(arglist); + va_start(arglist, format); + return nw_vfprintf((FILE*)pf, format, arglist); +} + +int +PerlStdIOVprintf(struct IPerlStdIO* piPerl, PerlIO* pf, const char *format, va_list arglist) +{ + return nw_vfprintf((FILE*)pf, format, arglist); +} + +long +PerlStdIOTell(struct IPerlStdIO* piPerl, PerlIO* pf) +{ + return nw_ftell((FILE*)pf); +} + +int +PerlStdIOSeek(struct IPerlStdIO* piPerl, PerlIO* pf, off_t offset, int origin) +{ + return nw_fseek((FILE*)pf, offset, origin); +} + +void +PerlStdIORewind(struct IPerlStdIO* piPerl, PerlIO* pf) +{ + nw_rewind((FILE*)pf); +} + +PerlIO* +PerlStdIOTmpfile(struct IPerlStdIO* piPerl) +{ + return (PerlIO*)nw_tmpfile(); +} + +int +PerlStdIOGetpos(struct IPerlStdIO* piPerl, PerlIO* pf, Fpos_t *p) +{ + return nw_fgetpos((FILE*)pf, p); +} + +int +PerlStdIOSetpos(struct IPerlStdIO* piPerl, PerlIO* pf, const Fpos_t *p) +{ + return nw_fsetpos((FILE*)pf, p); +} + +void +PerlStdIOInit(struct IPerlStdIO* piPerl) +{ + // If removed, compilation error occurs. +} + +void +PerlStdIOInitOSExtras(struct IPerlStdIO* piPerl) +{ + Perl_init_os_extras(); +} + + +int +PerlStdIOOpenOSfhandle(struct IPerlStdIO* piPerl, long osfhandle, int flags) +{ + return nw_open_osfhandle(osfhandle, flags); +} + +int +PerlStdIOGetOSfhandle(struct IPerlStdIO* piPerl, int filenum) +{ + return nw_get_osfhandle(filenum); +} + +PerlIO* +PerlStdIOFdupopen(struct IPerlStdIO* piPerl, PerlIO* pf) +{ + PerlIO* pfdup=NULL; + fpos_t pos=0; + char mode[3]={'\0'}; + int fileno = nw_dup(nw_fileno((FILE*)pf)); + + /* open the file in the same mode */ + if(((FILE*)pf)->_flag & _IOREAD) { + mode[0] = 'r'; + mode[1] = 0; + } + else if(((FILE*)pf)->_flag & _IOWRT) { + mode[0] = 'a'; + mode[1] = 0; + } + else if(((FILE*)pf)->_flag & _IORW) { + mode[0] = 'r'; + mode[1] = '+'; + mode[2] = 0; + } + + /* it appears that the binmode is attached to the + * file descriptor so binmode files will be handled + * correctly + */ + pfdup = (PerlIO*)nw_fdopen(fileno, mode); + + /* move the file pointer to the same position */ + if (!fgetpos((FILE*)pf, &pos)) { + fsetpos((FILE*)pfdup, &pos); + } + return pfdup; +} + +struct IPerlStdIO perlStdIO = +{ + PerlStdIOStdin, + PerlStdIOStdout, + PerlStdIOStderr, + PerlStdIOOpen, + PerlStdIOClose, + PerlStdIOEof, + PerlStdIOError, + PerlStdIOClearerr, + PerlStdIOGetc, + PerlStdIOGetBase, + PerlStdIOGetBufsiz, + PerlStdIOGetCnt, + PerlStdIOGetPtr, + PerlStdIOGets, + PerlStdIOPutc, + PerlStdIOPuts, + PerlStdIOFlush, + PerlStdIOUngetc, + PerlStdIOFileno, + PerlStdIOFdopen, + PerlStdIOReopen, + PerlStdIORead, + PerlStdIOWrite, + PerlStdIOSetBuf, + PerlStdIOSetVBuf, + PerlStdIOSetCnt, + PerlStdIOSetPtrCnt, + PerlStdIOSetlinebuf, + PerlStdIOPrintf, + PerlStdIOVprintf, + PerlStdIOTell, + PerlStdIOSeek, + PerlStdIORewind, + PerlStdIOTmpfile, + PerlStdIOGetpos, + PerlStdIOSetpos, + PerlStdIOInit, + PerlStdIOInitOSExtras, + PerlStdIOFdupopen, +}; + + +#undef IPERL2HOST +#define IPERL2HOST(x) IPerlLIO2Host(x) + +/* IPerlLIO */ +int +PerlLIOAccess(struct IPerlLIO* piPerl, const char *path, int mode) +{ + return nw_access(path, mode); +} + +int +PerlLIOChmod(struct IPerlLIO* piPerl, const char *filename, int pmode) +{ + return nw_chmod(filename, pmode); +} + +int +PerlLIOChown(struct IPerlLIO* piPerl, const char *filename, uid_t owner, gid_t group) +{ + // If removed, compilation error occurs. + return 0; +} + +int +PerlLIOChsize(struct IPerlLIO* piPerl, int handle, long size) +{ + return (nw_chsize(handle,size)); +} + +int +PerlLIOClose(struct IPerlLIO* piPerl, int handle) +{ + return nw_close(handle); +} + +int +PerlLIODup(struct IPerlLIO* piPerl, int handle) +{ + return nw_dup(handle); +} + +int +PerlLIODup2(struct IPerlLIO* piPerl, int handle1, int handle2) +{ + return nw_dup2(handle1, handle2); +} + +int +PerlLIOFlock(struct IPerlLIO* piPerl, int fd, int oper) +{ + //On NetWare simulate flock by locking a range on the file + return nw_flock(fd, oper); +} + +int +PerlLIOFileStat(struct IPerlLIO* piPerl, int handle, struct stat *buffer) +{ + return fstat(handle, buffer); +} + +int +PerlLIOIOCtl(struct IPerlLIO* piPerl, int i, unsigned int u, char *data) +{ + // If removed, compilation error occurs. + return 0; +} + +int +PerlLIOIsatty(struct IPerlLIO* piPerl, int fd) +{ + return nw_isatty(fd); +} + +int +PerlLIOLink(struct IPerlLIO* piPerl, const char*oldname, const char *newname) +{ + return nw_link(oldname, newname); +} + +long +PerlLIOLseek(struct IPerlLIO* piPerl, int handle, long offset, int origin) +{ + return nw_lseek(handle, offset, origin); +} + +int +PerlLIOLstat(struct IPerlLIO* piPerl, const char *path, struct stat *buffer) +{ + return nw_stat(path, buffer); +} + +char* +PerlLIOMktemp(struct IPerlLIO* piPerl, char *Template) +{ + return(nw_mktemp(Template)); +} + +int +PerlLIOOpen(struct IPerlLIO* piPerl, const char *filename, int oflag) +{ + return nw_open(filename, oflag); +} + +int +PerlLIOOpen3(struct IPerlLIO* piPerl, const char *filename, int oflag, int pmode) +{ + return nw_open(filename, oflag, pmode); +} + +int +PerlLIORead(struct IPerlLIO* piPerl, int handle, void *buffer, unsigned int count) +{ + return nw_read(handle, buffer, count); +} + +int +PerlLIORename(struct IPerlLIO* piPerl, const char *OldFileName, const char *newname) +{ + return nw_rename(OldFileName, newname); +} + +int +PerlLIOSetmode(struct IPerlLIO* piPerl, FILE *fp, int mode) +{ + return nw_setmode(fp, mode); +} + +int +PerlLIONameStat(struct IPerlLIO* piPerl, const char *path, struct stat *buffer) +{ + return nw_stat(path, buffer); +} + +char* +PerlLIOTmpnam(struct IPerlLIO* piPerl, char *string) +{ + return tmpnam(string); +} + +int +PerlLIOUmask(struct IPerlLIO* piPerl, int pmode) +{ + return umask(pmode); +} + +int +PerlLIOUnlink(struct IPerlLIO* piPerl, const char *filename) +{ + return nw_unlink(filename); +} + +int +PerlLIOUtime(struct IPerlLIO* piPerl, char *filename, struct utimbuf *times) +{ + return nw_utime(filename, times); +} + +int +PerlLIOWrite(struct IPerlLIO* piPerl, int handle, const void *buffer, unsigned int count) +{ + return nw_write(handle, buffer, count); +} + +struct IPerlLIO perlLIO = +{ + PerlLIOAccess, + PerlLIOChmod, + PerlLIOChown, + PerlLIOChsize, + PerlLIOClose, + PerlLIODup, + PerlLIODup2, + PerlLIOFlock, + PerlLIOFileStat, + PerlLIOIOCtl, + PerlLIOIsatty, + PerlLIOLink, + PerlLIOLseek, + PerlLIOLstat, + PerlLIOMktemp, + PerlLIOOpen, + PerlLIOOpen3, + PerlLIORead, + PerlLIORename, + PerlLIOSetmode, + PerlLIONameStat, + PerlLIOTmpnam, + PerlLIOUmask, + PerlLIOUnlink, + PerlLIOUtime, + PerlLIOWrite, +}; + + +#undef IPERL2HOST +#define IPERL2HOST(x) IPerlDir2Host(x) + +/* IPerlDIR */ +int +PerlDirMakedir(struct IPerlDir* piPerl, const char *dirname, int mode) +{ + return mkdir(dirname); +} + +int +PerlDirChdir(struct IPerlDir* piPerl, const char *dirname) +{ + return nw_chdir(dirname); +} + +int +PerlDirRmdir(struct IPerlDir* piPerl, const char *dirname) +{ + return nw_rmdir(dirname); +} + +int +PerlDirClose(struct IPerlDir* piPerl, DIR *dirp) +{ + return nw_closedir(dirp); +} + +DIR* +PerlDirOpen(struct IPerlDir* piPerl, char *filename) +{ + return nw_opendir(filename); +} + +struct direct * +PerlDirRead(struct IPerlDir* piPerl, DIR *dirp) +{ + return nw_readdir(dirp); +} + +void +PerlDirRewind(struct IPerlDir* piPerl, DIR *dirp) +{ + nw_rewinddir(dirp); +} + +void +PerlDirSeek(struct IPerlDir* piPerl, DIR *dirp, long loc) +{ + nw_seekdir(dirp, loc); +} + +long +PerlDirTell(struct IPerlDir* piPerl, DIR *dirp) +{ + return nw_telldir(dirp); +} + +struct IPerlDir perlDir = +{ + PerlDirMakedir, + PerlDirChdir, + PerlDirRmdir, + PerlDirClose, + PerlDirOpen, + PerlDirRead, + PerlDirRewind, + PerlDirSeek, + PerlDirTell, +}; + + +/* IPerlSock */ +u_long +PerlSockHtonl(struct IPerlSock* piPerl, u_long hostlong) +{ + return(nw_htonl(hostlong)); +} + +u_short +PerlSockHtons(struct IPerlSock* piPerl, u_short hostshort) +{ + return(nw_htons(hostshort)); +} + +u_long +PerlSockNtohl(struct IPerlSock* piPerl, u_long netlong) +{ + return nw_ntohl(netlong); +} + +u_short +PerlSockNtohs(struct IPerlSock* piPerl, u_short netshort) +{ + return nw_ntohs(netshort); +} + +SOCKET PerlSockAccept(struct IPerlSock* piPerl, SOCKET s, struct sockaddr* addr, int* addrlen) +{ + return nw_accept(s, addr, addrlen); +} + +int +PerlSockBind(struct IPerlSock* piPerl, SOCKET s, const struct sockaddr* name, int namelen) +{ + return nw_bind(s, name, namelen); +} + +int +PerlSockConnect(struct IPerlSock* piPerl, SOCKET s, const struct sockaddr* name, int namelen) +{ + return nw_connect(s, name, namelen); +} + +void +PerlSockEndhostent(struct IPerlSock* piPerl) +{ + nw_endhostent(); +} + +void +PerlSockEndnetent(struct IPerlSock* piPerl) +{ + nw_endnetent(); +} + +void +PerlSockEndprotoent(struct IPerlSock* piPerl) +{ + nw_endprotoent(); +} + +void +PerlSockEndservent(struct IPerlSock* piPerl) +{ + nw_endservent(); +} + +struct hostent* +PerlSockGethostbyaddr(struct IPerlSock* piPerl, const char* addr, int len, int type) +{ + return(nw_gethostbyaddr(addr,len,type)); +} + +struct hostent* +PerlSockGethostbyname(struct IPerlSock* piPerl, const char* name) +{ + return nw_gethostbyname(name); +} + +struct hostent* +PerlSockGethostent(struct IPerlSock* piPerl) +{ + return(nw_gethostent()); +} + +int +PerlSockGethostname(struct IPerlSock* piPerl, char* name, int namelen) +{ + return nw_gethostname(name,namelen); +} + +struct netent * +PerlSockGetnetbyaddr(struct IPerlSock* piPerl, long net, int type) +{ + return nw_getnetbyaddr(net, type); +} + +struct netent * +PerlSockGetnetbyname(struct IPerlSock* piPerl, const char *name) +{ + return nw_getnetbyname((char*)name); +} + +struct netent * +PerlSockGetnetent(struct IPerlSock* piPerl) +{ + return nw_getnetent(); +} + +int PerlSockGetpeername(struct IPerlSock* piPerl, SOCKET s, struct sockaddr* name, int* namelen) +{ + return nw_getpeername(s, name, namelen); +} + +struct protoent* +PerlSockGetprotobyname(struct IPerlSock* piPerl, const char* name) +{ + return nw_getprotobyname(name); +} + +struct protoent* +PerlSockGetprotobynumber(struct IPerlSock* piPerl, int number) +{ + return nw_getprotobynumber(number); +} + +struct protoent* +PerlSockGetprotoent(struct IPerlSock* piPerl) +{ + return nw_getprotoent(); +} + +struct servent* +PerlSockGetservbyname(struct IPerlSock* piPerl, const char* name, const char* proto) +{ + return nw_getservbyname((char*)name, (char*)proto); +} + +struct servent* +PerlSockGetservbyport(struct IPerlSock* piPerl, int port, const char* proto) +{ + return nw_getservbyport(port, proto); +} + +struct servent* +PerlSockGetservent(struct IPerlSock* piPerl) +{ + return nw_getservent(); +} + +int +PerlSockGetsockname(struct IPerlSock* piPerl, SOCKET s, struct sockaddr* name, int* namelen) +{ + return nw_getsockname(s, name, namelen); +} + +int +PerlSockGetsockopt(struct IPerlSock* piPerl, SOCKET s, int level, int optname, char* optval, int* optlen) +{ + return nw_getsockopt(s, level, optname, optval, optlen); +} + +unsigned long +PerlSockInetAddr(struct IPerlSock* piPerl, const char* cp) +{ + return(nw_inet_addr(cp)); +} + +char* +PerlSockInetNtoa(struct IPerlSock* piPerl, struct in_addr in) +{ + return nw_inet_ntoa(in); +} + +int +PerlSockListen(struct IPerlSock* piPerl, SOCKET s, int backlog) +{ + return (nw_listen(s, backlog)); +} + +int +PerlSockRecv(struct IPerlSock* piPerl, SOCKET s, char* buffer, int len, int flags) +{ + return (nw_recv(s, buffer, len, flags)); +} + +int +PerlSockRecvfrom(struct IPerlSock* piPerl, SOCKET s, char* buffer, int len, int flags, struct sockaddr* from, int* fromlen) +{ + return nw_recvfrom(s, buffer, len, flags, from, fromlen); +} + +int +PerlSockSelect(struct IPerlSock* piPerl, int nfds, char* readfds, char* writefds, char* exceptfds, const struct timeval* timeout) +{ + return nw_select(nfds, (fd_set*) readfds, (fd_set*) writefds, (fd_set*) exceptfds, timeout); +} + +int +PerlSockSend(struct IPerlSock* piPerl, SOCKET s, const char* buffer, int len, int flags) +{ + return (nw_send(s, buffer, len, flags)); +} + +int +PerlSockSendto(struct IPerlSock* piPerl, SOCKET s, const char* buffer, int len, int flags, const struct sockaddr* to, int tolen) +{ + return(nw_sendto(s, buffer, len, flags, to, tolen)); +} + +void +PerlSockSethostent(struct IPerlSock* piPerl, int stayopen) +{ + nw_sethostent(stayopen); +} + +void +PerlSockSetnetent(struct IPerlSock* piPerl, int stayopen) +{ + nw_setnetent(stayopen); +} + +void +PerlSockSetprotoent(struct IPerlSock* piPerl, int stayopen) +{ + nw_setprotoent(stayopen); +} + +void +PerlSockSetservent(struct IPerlSock* piPerl, int stayopen) +{ + nw_setservent(stayopen); +} + +int +PerlSockSetsockopt(struct IPerlSock* piPerl, SOCKET s, int level, int optname, const char* optval, int optlen) +{ + return nw_setsockopt(s, level, optname, optval, optlen); +} + +int +PerlSockShutdown(struct IPerlSock* piPerl, SOCKET s, int how) +{ + return nw_shutdown(s, how); +} + +SOCKET +PerlSockSocket(struct IPerlSock* piPerl, int af, int type, int protocol) +{ + return nw_socket(af, type, protocol); +} + +int +PerlSockSocketpair(struct IPerlSock* piPerl, int domain, int type, int protocol, int* fds) +{ + dTHX; // (J) dTHXo + Perl_croak(aTHX_ "socketpair not implemented!\n"); + return 0; +} + +int +PerlSockIoctlsocket(struct IPerlSock* piPerl, SOCKET s, long cmd, u_long *argp) +{ + dTHX; // (J) dTHXo + Perl_croak(aTHX_ "ioctlsocket not implemented!\n"); + return 0; +} + +struct IPerlSock perlSock = +{ + PerlSockHtonl, + PerlSockHtons, + PerlSockNtohl, + PerlSockNtohs, + PerlSockAccept, + PerlSockBind, + PerlSockConnect, + PerlSockEndhostent, + PerlSockEndnetent, + PerlSockEndprotoent, + PerlSockEndservent, + PerlSockGethostname, + PerlSockGetpeername, + PerlSockGethostbyaddr, + PerlSockGethostbyname, + PerlSockGethostent, + PerlSockGetnetbyaddr, + PerlSockGetnetbyname, + PerlSockGetnetent, + PerlSockGetprotobyname, + PerlSockGetprotobynumber, + PerlSockGetprotoent, + PerlSockGetservbyname, + PerlSockGetservbyport, + PerlSockGetservent, + PerlSockGetsockname, + PerlSockGetsockopt, + PerlSockInetAddr, + PerlSockInetNtoa, + PerlSockListen, + PerlSockRecv, + PerlSockRecvfrom, + PerlSockSelect, + PerlSockSend, + PerlSockSendto, + PerlSockSethostent, + PerlSockSetnetent, + PerlSockSetprotoent, + PerlSockSetservent, + PerlSockSetsockopt, + PerlSockShutdown, + PerlSockSocket, + PerlSockSocketpair, + //Following commented by sgp bcos of comiplation error too many initializers (E279) +// PerlSockClosesocket, +}; + + +/* IPerlProc */ + +#define EXECF_EXEC 1 +#define EXECF_SPAWN 2 + +void +PerlProcAbort(struct IPerlProc* piPerl) +{ + nw_abort(); +} + +char * +PerlProcCrypt(struct IPerlProc* piPerl, const char* clear, const char* salt) +{ + return nw_crypt(clear, salt); +} + +void +PerlProcExit(struct IPerlProc* piPerl, int status) +{ +// exit(status); + dTHX; + //dJMPENV; + JMPENV_JUMP(2); +} + +void +PerlProc_Exit(struct IPerlProc* piPerl, int status) +{ +// _exit(status); + dTHX; + //dJMPENV; + JMPENV_JUMP(2); +} + +int +PerlProcExecl(struct IPerlProc* piPerl, const char *cmdname, const char *arg0, const char *arg1, const char *arg2, const char *arg3) +{ + // If removed, compilation error occurs. + return 0; +} + +int +PerlProcExecv(struct IPerlProc* piPerl, const char *cmdname, const char *const *argv) +{ + return nw_execvp((char *)cmdname, (char **)argv); +} + +int +PerlProcExecvp(struct IPerlProc* piPerl, const char *cmdname, const char *const *argv) +{ + return nw_execvp((char *)cmdname, (char **)argv); +} + +uid_t +PerlProcGetuid(struct IPerlProc* piPerl) +{ + // If removed, compilation error occurs. + return 0; +} + +uid_t +PerlProcGeteuid(struct IPerlProc* piPerl) +{ + // If removed, compilation error occurs. + return 0; +} + +gid_t +PerlProcGetgid(struct IPerlProc* piPerl) +{ + // If removed, compilation error occurs. + return 0; +} + +gid_t +PerlProcGetegid(struct IPerlProc* piPerl) +{ + // If removed, compilation error occurs. + return 0; +} + +char * +PerlProcGetlogin(struct IPerlProc* piPerl) +{ + // If removed, compilation error occurs. + return NULL; +} + +int +PerlProcKill(struct IPerlProc* piPerl, int pid, int sig) +{ + return nw_kill(pid, sig); +} + +int +PerlProcKillpg(struct IPerlProc* piPerl, int pid, int sig) +{ + dTHX; // (J) dTHXo + Perl_croak(aTHX_ "killpg not implemented!\n"); + return 0; +} + +int +PerlProcPauseProc(struct IPerlProc* piPerl) +{ + return nw_sleep((32767L << 16) + 32767); +} + +PerlIO* +PerlProcPopen(struct IPerlProc* piPerl, const char *command, const char *mode) +{ + dTHX; // (J) dTHXo + PERL_FLUSHALL_FOR_CHILD; + + return (PerlIO*)nw_Popen((char *)command, (char *)mode, (int *)errno); +} + +int +PerlProcPclose(struct IPerlProc* piPerl, PerlIO *stream) +{ + return nw_Pclose((FILE*)stream, (int *)errno); +} + +int +PerlProcPipe(struct IPerlProc* piPerl, int *phandles) +{ + return nw_Pipe((int *)phandles, (int *)errno); +} + +int +PerlProcSetuid(struct IPerlProc* piPerl, uid_t u) +{ + // If removed, compilation error occurs. + return 0; +} + +int +PerlProcSetgid(struct IPerlProc* piPerl, gid_t g) +{ + // If removed, compilation error occurs. + return 0; +} + +int +PerlProcSleep(struct IPerlProc* piPerl, unsigned int s) +{ + return nw_sleep(s); +} + +int +PerlProcTimes(struct IPerlProc* piPerl, struct tms *timebuf) +{ + return nw_times(timebuf); +} + +int +PerlProcWait(struct IPerlProc* piPerl, int *status) +{ + return nw_wait(status); +} + +int +PerlProcWaitpid(struct IPerlProc* piPerl, int pid, int *status, int flags) +{ + return nw_waitpid(pid, status, flags); +} + +Sighandler_t +PerlProcSignal(struct IPerlProc* piPerl, int sig, Sighandler_t subcode) +{ + // If removed, compilation error occurs. + return 0; +} + +int +PerlProcFork(struct IPerlProc* piPerl) +{ + // If removed, compilation error occurs. + return 0; +} + +int +PerlProcGetpid(struct IPerlProc* piPerl) +{ + return nw_getpid(); +} + +BOOL +PerlProcDoCmd(struct IPerlProc* piPerl, char *cmd) +{ + do_spawn2(cmd, EXECF_EXEC); + return FALSE; +} + +int +PerlProcSpawn(struct IPerlProc* piPerl, char* cmds) +{ + return do_spawn2(cmds, EXECF_SPAWN); +} + +int +PerlProcSpawnvp(struct IPerlProc* piPerl, int mode, const char *cmdname, const char *const *argv) +{ + return nw_spawnvp(mode, (char *)cmdname, (char **)argv); +} + +int +PerlProcASpawn(struct IPerlProc* piPerl, void *vreally, void **vmark, void **vsp) +{ + return do_aspawn(vreally, vmark, vsp); +} + +struct IPerlProc perlProc = +{ + PerlProcAbort, + PerlProcCrypt, + PerlProcExit, + PerlProc_Exit, + PerlProcExecl, + PerlProcExecv, + PerlProcExecvp, + PerlProcGetuid, + PerlProcGeteuid, + PerlProcGetgid, + PerlProcGetegid, + PerlProcGetlogin, + PerlProcKill, + PerlProcKillpg, + PerlProcPauseProc, + PerlProcPopen, + PerlProcPclose, + PerlProcPipe, + PerlProcSetuid, + PerlProcSetgid, + PerlProcSleep, + PerlProcTimes, + PerlProcWait, + PerlProcWaitpid, + PerlProcSignal, + PerlProcFork, + PerlProcGetpid, +/* PerlProcDynaLoader, + PerlProcGetOSError, + PerlProcDoCmd, + PerlProcSpawn, + PerlProcSpawnvp, + PerlProcASpawn,*/ +}; + + +/* + * CPerlHost + */ + +CPerlHost::CPerlHost(void) +{ + m_pVMem = new VMem(); + m_pVMemShared = new VMem(); + m_pVMemParse = new VMem(); + + memcpy(&m_hostperlMem, &perlMem, sizeof(perlMem)); + memcpy(&m_hostperlMemShared, &perlMemShared, sizeof(perlMemShared)); + memcpy(&m_hostperlMemParse, &perlMemParse, sizeof(perlMemParse)); + memcpy(&m_hostperlEnv, &perlEnv, sizeof(perlEnv)); + memcpy(&m_hostperlStdIO, &perlStdIO, sizeof(perlStdIO)); + memcpy(&m_hostperlLIO, &perlLIO, sizeof(perlLIO)); + memcpy(&m_hostperlDir, &perlDir, sizeof(perlDir)); + memcpy(&m_hostperlSock, &perlSock, sizeof(perlSock)); + memcpy(&m_hostperlProc, &perlProc, sizeof(perlProc)); + + m_pHostperlMem = &m_hostperlMem; + m_pHostperlMemShared = &m_hostperlMemShared; + m_pHostperlMemParse = &m_hostperlMemParse; + m_pHostperlEnv = &m_hostperlEnv; + m_pHostperlStdIO = &m_hostperlStdIO; + m_pHostperlLIO = &m_hostperlLIO; + m_pHostperlDir = &m_hostperlDir; + m_pHostperlSock = &m_hostperlSock; + m_pHostperlProc = &m_hostperlProc; +} + +#define SETUPEXCHANGE(xptr, iptr, table) \ + STMT_START { \ + if (xptr) { \ + iptr = *xptr; \ + *xptr = &table; \ + } \ + else { \ + iptr = &table; \ + } \ + } STMT_END + +CPerlHost::CPerlHost(struct IPerlMem** ppMem, struct IPerlMem** ppMemShared, + struct IPerlMem** ppMemParse, struct IPerlEnv** ppEnv, + struct IPerlStdIO** ppStdIO, struct IPerlLIO** ppLIO, + struct IPerlDir** ppDir, struct IPerlSock** ppSock, + struct IPerlProc** ppProc) +{ + m_pVMem = new VMem(); + m_pVMemShared = new VMem(); + m_pVMemParse = new VMem(); + + memcpy(&m_hostperlMem, &perlMem, sizeof(perlMem)); + memcpy(&m_hostperlMemShared, &perlMemShared, sizeof(perlMemShared)); + memcpy(&m_hostperlMemParse, &perlMemParse, sizeof(perlMemParse)); + memcpy(&m_hostperlEnv, &perlEnv, sizeof(perlEnv)); + memcpy(&m_hostperlStdIO, &perlStdIO, sizeof(perlStdIO)); + memcpy(&m_hostperlLIO, &perlLIO, sizeof(perlLIO)); + memcpy(&m_hostperlDir, &perlDir, sizeof(perlDir)); + memcpy(&m_hostperlSock, &perlSock, sizeof(perlSock)); + memcpy(&m_hostperlProc, &perlProc, sizeof(perlProc)); + + SETUPEXCHANGE(ppMem, m_pHostperlMem, m_hostperlMem); + SETUPEXCHANGE(ppMemShared, m_pHostperlMemShared, m_hostperlMemShared); + SETUPEXCHANGE(ppMemParse, m_pHostperlMemParse, m_hostperlMemParse); + SETUPEXCHANGE(ppEnv, m_pHostperlEnv, m_hostperlEnv); + SETUPEXCHANGE(ppStdIO, m_pHostperlStdIO, m_hostperlStdIO); + SETUPEXCHANGE(ppLIO, m_pHostperlLIO, m_hostperlLIO); + SETUPEXCHANGE(ppDir, m_pHostperlDir, m_hostperlDir); + SETUPEXCHANGE(ppSock, m_pHostperlSock, m_hostperlSock); + SETUPEXCHANGE(ppProc, m_pHostperlProc, m_hostperlProc); +} +#undef SETUPEXCHANGE + +CPerlHost::CPerlHost(const CPerlHost& host) +{ + memcpy(&m_hostperlMem, &perlMem, sizeof(perlMem)); + memcpy(&m_hostperlMemShared, &perlMemShared, sizeof(perlMemShared)); + memcpy(&m_hostperlMemParse, &perlMemParse, sizeof(perlMemParse)); + memcpy(&m_hostperlEnv, &perlEnv, sizeof(perlEnv)); + memcpy(&m_hostperlStdIO, &perlStdIO, sizeof(perlStdIO)); + memcpy(&m_hostperlLIO, &perlLIO, sizeof(perlLIO)); + memcpy(&m_hostperlDir, &perlDir, sizeof(perlDir)); + memcpy(&m_hostperlSock, &perlSock, sizeof(perlSock)); + memcpy(&m_hostperlProc, &perlProc, sizeof(perlProc)); + + m_pHostperlMem = &m_hostperlMem; + m_pHostperlMemShared = &m_hostperlMemShared; + m_pHostperlMemParse = &m_hostperlMemParse; + m_pHostperlEnv = &m_hostperlEnv; + m_pHostperlStdIO = &m_hostperlStdIO; + m_pHostperlLIO = &m_hostperlLIO; + m_pHostperlDir = &m_hostperlDir; + m_pHostperlSock = &m_hostperlSock; + m_pHostperlProc = &m_hostperlProc; + +} + +CPerlHost::~CPerlHost(void) +{ + if ( m_pVMemParse ) delete m_pVMemParse; + if ( m_pVMemShared ) delete m_pVMemShared; + if ( m_pVMem ) delete m_pVMem; +} + +char* +CPerlHost::Getenv(const char *varname) +{ + // getenv is always present. In old CLIB, it is implemented + // to always return NULL. With java loaded on NW411, it will + // return values set by envset. Is correctly implemented by + // CLIB on MOAB. + // + return getenv(varname); +} + +int +CPerlHost::Putenv(const char *envstring) +{ + return(putenv(envstring)); +} + + +#endif /* ___NWPerlHost_H___ */ + diff --git a/NetWare/nwvmem.h b/NetWare/nwvmem.h new file mode 100644 index 0000000..5999d88 --- /dev/null +++ b/NetWare/nwvmem.h @@ -0,0 +1,340 @@ + +/* + * Copyright © 2001 Novell, Inc. All Rights Reserved. + * + * You may distribute under the terms of either the GNU General Public + * License or the Artistic License, as specified in the README file. + * + */ + +/* + * FILENAME : NWVMem.h + * DESCRIPTION : Memory management for Perl Interpreter on NetWare. + * Watcom's hash table is used to store memory pointers. + * All malloc's, realloc's, free's go through this. + * Author : HYAK, SGP + * Date : Januray 2001. + * + */ + + + +#ifndef ___NWVMEM_H_INC___ +#define ___NWVMEM_H_INC___ + + +#include "win32ish.h" // For "BOOL", "TRUE" and "FALSE" +#include // CW changes +#include +#include "string.h" + + + +class VMem +{ +public: + VMem(); + virtual ~VMem(); + virtual void* Malloc(size_t size); + virtual void* Realloc(void* pMem, size_t size); + virtual void Free(void* pMem); + virtual void* Calloc(size_t num, size_t size); + +protected: + BOOL m_dontTouchHashLists; +// WCValHashTable* m_allocList; + NWPerlHashList *m_allocList; // CW changes +}; + + + + +/*============================================================================================ + + Function : fnAllocListHash + + Description : Hashing function for hash table of memory allocations. + + Parameters : invalue (IN). + + Returns : unsigned. + +==============================================================================================*/ + +unsigned fnAllocListHash(void* const& invalue) +{ + return (((unsigned) invalue & 0x0000ff00) >> 8); +} + + + +/*============================================================================================ + + Function : fnFreeMemEntry + + Description : Called for each outstanding memory allocation at the end of a script run. + Frees the outstanding allocations + + Parameters : ptr (IN). + context (IN) + + Returns : Nothing. + +==============================================================================================*/ + +void fnFreeMemEntry(void* ptr, void* context) +{ + VMem* pVMem = (VMem*) context; + + if(ptr && pVMem) + { + pVMem->Free(ptr); + ptr=NULL; + pVMem = NULL; + context = NULL; + } +} + + + +/*============================================================================================ + + Function : VMem Constructor + + Description : + + Parameters : + + Returns : + +==============================================================================================*/ + +VMem::VMem() +{ + //Constructor + m_dontTouchHashLists = FALSE; + m_allocList = NULL; + // m_allocList = new WCValHashTable (fnAllocListHash, 256); + m_allocList = new NWPerlHashList(); // CW changes +} + + + +/*============================================================================================ + + Function : VMem Destructor + + Description : + + Parameters : + + Returns : + +==============================================================================================*/ + +VMem::~VMem(void) +{ + //Destructor + m_dontTouchHashLists = TRUE; + if (m_allocList) + { + m_allocList->forAll(fnFreeMemEntry, (void*) this); + + delete m_allocList; + m_allocList = NULL; + } + m_dontTouchHashLists = FALSE; +} + + + +/*============================================================================================ + + Function : VMem::Malloc + + Description : Allocates memory. + + Parameters : size (IN) - Size of memory to be allocated. + + Returns : Pointer to the allocated memory block. + +==============================================================================================*/ + +void* VMem::Malloc(size_t size) +{ + void *ptr = NULL; + + if (size <= 0) + return NULL; + + ptr = malloc(size); + if (ptr) + { + if(m_allocList) + m_allocList->insert(ptr); + } + else + { + m_dontTouchHashLists = TRUE; + if (m_allocList) + { + m_allocList->forAll(fnFreeMemEntry, (void*) this); + delete m_allocList; + m_allocList = NULL; + } + m_dontTouchHashLists = FALSE; + + // Serious error since memory allocation falied. So, exiting... + ExitThread(TSR_THREAD, 1); + } + + return(ptr); +} + + + +/*============================================================================================ + + Function : VMem::Realloc + + Description : Reallocates block of memory. + + Parameters : block (IN) - Points to a previously allocated memory block. + size (IN) - Size of memory to be allocated. + + Returns : Pointer to the allocated memory block. + +==============================================================================================*/ + +void* VMem::Realloc(void* block, size_t size) +{ + void *ptr = NULL; + + if (size <= 0) + return NULL; + + ptr = realloc(block, size); + if (ptr) + { + if (block) + { + if (m_allocList) + m_allocList->remove(block); + } + if (m_allocList) + m_allocList->insert(ptr); + } + else + { + m_dontTouchHashLists = TRUE; + if (m_allocList) + { + m_allocList->forAll(fnFreeMemEntry, (void*) this); + delete m_allocList; + m_allocList = NULL; + } + m_dontTouchHashLists = FALSE; + + // Serious error since memory allocation falied. So, exiting... + ExitThread(TSR_THREAD, 1); + } + + return(ptr); +} + + + +/*============================================================================================ + + Function : VMem::Calloc + + Description : Allocates and clears memory space for an array of objects. + + Parameters : num (IN) - Specifies the number of objects. + size (IN) - Size of each object. + + Returns : Pointer to the allocated memory block. + +==============================================================================================*/ + +void* VMem::Calloc(size_t num, size_t size) +{ + void *ptr = NULL; + + if (size <= 0) + return NULL; + + ptr = calloc(num, size); + if (ptr) + { + if(m_allocList) + m_allocList->insert(ptr); + } + else + { + m_dontTouchHashLists = TRUE; + if (m_allocList) + { + m_allocList->forAll(fnFreeMemEntry, (void*) this); + delete m_allocList; + m_allocList = NULL; + } + m_dontTouchHashLists = FALSE; + + // Serious error since memory allocation falied. So, exiting... + ExitThread(TSR_THREAD, 1); + } + + return(ptr); +} + + + +/*============================================================================================ + + Function : VMem::Free + + Description : Frees allocated memory. + + Parameters : p (IN) - Points to the allocated memory. + + Returns : Nothing. + +==============================================================================================*/ + +void VMem::Free(void* p) +{ + // Final clean up, free all the nodes from the hash list + if (m_dontTouchHashLists) + { + if(p) + { + free(p); + p = NULL; + } + } + else + { + if(p && m_allocList) + { + if (m_allocList->remove(p)) + { + free(p); + p = NULL; + } + else + { + // If it comes here, that means that the memory pointer is not contained in the hash list. + // But no need to free now, since if is deleted here, it will result in an abend!! + // If the memory is still there, it will be cleaned during final cleanup anyway. + } + } + } + + + return; +} + + +#endif //___NWVMEM_H_INC___ + diff --git a/NetWare/perllib.cpp b/NetWare/perllib.cpp new file mode 100644 index 0000000..a9eb824 --- /dev/null +++ b/NetWare/perllib.cpp @@ -0,0 +1,273 @@ + +/* + * Copyright © 2001 Novell, Inc. All Rights Reserved. + * + * You may distribute under the terms of either the GNU General Public + * License or the Artistic License, as specified in the README file. + * + */ + +/* + * FILENAME : perllib.c + * DESCRIPTION : Library functions for parsing and running Perl. + * This is based on the perllib.c file of Win32 port. + * Author : SGP + * Date : January 2001. + * + */ + +/* + * "The Road goes ever on and on, down from the door where it began." + */ + + + +#include "EXTERN.h" +#include "perl.h" + + +#ifdef PERL_OBJECT +#define NO_XSLOCKS +#endif + +//CHKSGP +//Including this is giving premature end-of-file error during compilation +//#include "XSUB.h" + +#ifdef PERL_IMPLICIT_SYS + +#include "nw5iop.h" +#include + +#endif //PERL_IMPLICIT_SYS + + +#ifdef PERL_IMPLICIT_SYS + +#include "nwperlhost.h" +#define w32_internal_host (PL_sys_intern.internal_host) // (J) + + +EXTERN_C void +perl_get_host_info(struct IPerlMemInfo* perlMemInfo, + struct IPerlMemInfo* perlMemSharedInfo, + struct IPerlMemInfo* perlMemParseInfo, + struct IPerlEnvInfo* perlEnvInfo, + struct IPerlStdIOInfo* perlStdIOInfo, + struct IPerlLIOInfo* perlLIOInfo, + struct IPerlDirInfo* perlDirInfo, + struct IPerlSockInfo* perlSockInfo, + struct IPerlProcInfo* perlProcInfo) +{ + if (perlMemInfo) { + Copy(&perlMem, &perlMemInfo->perlMemList, perlMemInfo->nCount, void*); + perlMemInfo->nCount = (sizeof(struct IPerlMem)/sizeof(void*)); + } + if (perlMemSharedInfo) { + Copy(&perlMem, &perlMemSharedInfo->perlMemList, perlMemSharedInfo->nCount, void*); + perlMemSharedInfo->nCount = (sizeof(struct IPerlMem)/sizeof(void*)); + } + if (perlMemParseInfo) { + Copy(&perlMem, &perlMemParseInfo->perlMemList, perlMemParseInfo->nCount, void*); + perlMemParseInfo->nCount = (sizeof(struct IPerlMem)/sizeof(void*)); + } + if (perlEnvInfo) { + Copy(&perlEnv, &perlEnvInfo->perlEnvList, perlEnvInfo->nCount, void*); + perlEnvInfo->nCount = (sizeof(struct IPerlEnv)/sizeof(void*)); + } + if (perlStdIOInfo) { + Copy(&perlStdIO, &perlStdIOInfo->perlStdIOList, perlStdIOInfo->nCount, void*); + perlStdIOInfo->nCount = (sizeof(struct IPerlStdIO)/sizeof(void*)); + } + if (perlLIOInfo) { + Copy(&perlLIO, &perlLIOInfo->perlLIOList, perlLIOInfo->nCount, void*); + perlLIOInfo->nCount = (sizeof(struct IPerlLIO)/sizeof(void*)); + } + if (perlDirInfo) { + Copy(&perlDir, &perlDirInfo->perlDirList, perlDirInfo->nCount, void*); + perlDirInfo->nCount = (sizeof(struct IPerlDir)/sizeof(void*)); + } + if (perlSockInfo) { + Copy(&perlSock, &perlSockInfo->perlSockList, perlSockInfo->nCount, void*); + perlSockInfo->nCount = (sizeof(struct IPerlSock)/sizeof(void*)); + } + if (perlProcInfo) { + Copy(&perlProc, &perlProcInfo->perlProcList, perlProcInfo->nCount, void*); + perlProcInfo->nCount = (sizeof(struct IPerlProc)/sizeof(void*)); + } +} + +EXTERN_C PerlInterpreter* +perl_alloc_override(struct IPerlMem** ppMem, struct IPerlMem** ppMemShared, + struct IPerlMem** ppMemParse, struct IPerlEnv** ppEnv, + struct IPerlStdIO** ppStdIO, struct IPerlLIO** ppLIO, + struct IPerlDir** ppDir, struct IPerlSock** ppSock, + struct IPerlProc** ppProc) +{ + PerlInterpreter *my_perl = NULL; + CPerlHost* pHost = new CPerlHost(ppMem, ppMemShared, ppMemParse, ppEnv, + ppStdIO, ppLIO, ppDir, ppSock, ppProc); + + if (pHost) { + my_perl = perl_alloc_using(pHost->m_pHostperlMem, + pHost->m_pHostperlMemShared, + pHost->m_pHostperlMemParse, + pHost->m_pHostperlEnv, + pHost->m_pHostperlStdIO, + pHost->m_pHostperlLIO, + pHost->m_pHostperlDir, + pHost->m_pHostperlSock, + pHost->m_pHostperlProc); + if (my_perl) { +#ifdef PERL_OBJECT + CPerlObj* pPerl = (CPerlObj*)my_perl; +#endif + w32_internal_host = pHost; + } + } + return my_perl; +} + +EXTERN_C PerlInterpreter* +perl_alloc(void) +{ + PerlInterpreter* my_perl = NULL; + CPerlHost* pHost = new CPerlHost(); + if (pHost) { + my_perl = perl_alloc_using(pHost->m_pHostperlMem, + pHost->m_pHostperlMemShared, + pHost->m_pHostperlMemParse, + pHost->m_pHostperlEnv, + pHost->m_pHostperlStdIO, + pHost->m_pHostperlLIO, + pHost->m_pHostperlDir, + pHost->m_pHostperlSock, + pHost->m_pHostperlProc); + if (my_perl) { +#ifdef PERL_OBJECT + CPerlObj* pPerl = (CPerlObj*)my_perl; +#endif + //The following Should be uncommented - CHKSGP + w32_internal_host = pHost; + } + } + return my_perl; +} + +EXTERN_C void +nw_delete_internal_host(void *h) +{ + CPerlHost *host = (CPerlHost*)h; + if(host && h) + { + delete host; + host=NULL; + h=NULL; + } +} + +#ifdef PERL_OBJECT + +EXTERN_C void +perl_construct(PerlInterpreter* my_perl) +{ + CPerlObj* pPerl = (CPerlObj*)my_perl; + try + { + Perl_construct(); + } + catch(...) + { + win32_fprintf(stderr, "%s\n", + "Error: Unable to construct data structures"); + perl_free(my_perl); + } +} + +EXTERN_C void +perl_destruct(PerlInterpreter* my_perl) +{ + CPerlObj* pPerl = (CPerlObj*)my_perl; +#ifdef DEBUGGING + Perl_destruct(); +#else + try + { + Perl_destruct(); + } + catch(...) + { + } +#endif +} + +EXTERN_C void +perl_free(PerlInterpreter* my_perl) +{ + CPerlObj* pPerl = (CPerlObj*)my_perl; + void *host = w32_internal_host; +#ifdef DEBUGGING + Perl_free(); +#else + try + { + Perl_free(); + } + catch(...) + { + } +#endif + win32_delete_internal_host(host); + PERL_SET_THX(NULL); +} + +EXTERN_C int +perl_run(PerlInterpreter* my_perl) +{ + CPerlObj* pPerl = (CPerlObj*)my_perl; + int retVal; +#ifdef DEBUGGING + retVal = Perl_run(); +#else + try + { + retVal = Perl_run(); + } + catch(...) + { + win32_fprintf(stderr, "Error: Runtime exception\n"); + retVal = -1; + } +#endif + return retVal; +} + +EXTERN_C int +perl_parse(PerlInterpreter* my_perl, void (*xsinit)(CPerlObj*), int argc, char** argv, char** env) +{ + int retVal; + CPerlObj* pPerl = (CPerlObj*)my_perl; +#ifdef DEBUGGING + retVal = Perl_parse(xsinit, argc, argv, env); +#else + try + { + retVal = Perl_parse(xsinit, argc, argv, env); + } + catch(...) + { + win32_fprintf(stderr, "Error: Parse exception\n"); + retVal = -1; + } +#endif + *win32_errno() = 0; + return retVal; +} + +#undef PL_perl_destruct_level +#define PL_perl_destruct_level int dummy + +#endif /* PERL_OBJECT */ +#endif /* PERL_IMPLICIT_SYS */ + + diff --git a/NetWare/splittree.pl b/NetWare/splittree.pl new file mode 100644 index 0000000..3c76daa --- /dev/null +++ b/NetWare/splittree.pl @@ -0,0 +1,24 @@ +use DirHandle; +use AutoSplit; + +sub splitthis { +my ($top,$base,$dest) = @_; +my $d = new DirHandle $base; +if (defined $d) { + while (defined($_ = $d->read)) { + next if $_ eq "."; + next if $_ eq ".."; + my $entry = "$base\\$_"; + my $entrywithouttop = $entry; + $entrywithouttop =~ s/^$top//; + if (-d $entry) {splitthis ($top,$entry,$dest);} + else { + next unless ($entry=~/pm$/i); + #print "Will run autosplit on $entry to $dest\n"; + autosplit($entry,$dest,0,1,1); + }; + }; + }; +} + +splitthis $ARGV[0],$ARGV[0],$ARGV[1]; diff --git a/NetWare/t/NWScripts.pl b/NetWare/t/NWScripts.pl index c659b0d..2c18c38 100644 --- a/NetWare/t/NWScripts.pl +++ b/NetWare/t/NWScripts.pl @@ -11,7 +11,7 @@ $DirName = "t"; # These scripts have problems (either abend or hang) as of now (11 May 2001). # So, they are commented out in the corresponding auto scripts, io.pl and lib.pl -@ScriptsNotUsed = ("t/io/openpid.t", "t/lib/filehandle.t", "t/lib/memoize/t/expire_module_t.t", "t/lib/NEXT/t/next.t", "t/lib/Math/BigInt/t/require.t", "t/ext/B/t/debug.t","t/lib/IPC/Open3.t", "t/ext/B/t/showlex.t", "t/op/subst_wamp.t", "t/uni/upper.t"); +@ScriptsNotUsed = ("t/io/openpid.t", "t/lib/filehandle.t", "t/lib/memoize/t/expire_module_t.t", "t/lib/NEXT/t/next.t", "t/lib/Math/BigInt/t/require.t", "t/ext/B/t/debug.t","t/lib/IPC/Open3.t", "t/ext/B/t/showlex.t", "t/op/subst_wamp.t", "t/uni/upper.t", "t/lib/Net/t/ftp.t"); opendir(DIR, $DirName); @Dirs = readdir(DIR); diff --git a/NetWare/testnlm/type/type.c b/NetWare/testnlm/type/type.c index 8d5c394..c680fcd 100644 --- a/NetWare/testnlm/type/type.c +++ b/NetWare/testnlm/type/type.c @@ -24,7 +24,7 @@ void main (int argc, char** argv) fnInitGpfGlobals(); SetCurrentNameSpace(NWOS2_NAME_SPACE); - defaultDir = getenv("PERL_ROOT"); + defaultDir = (char *)getenv("PERL_ROOT"); if (!defaultDir || (strlen(defaultDir) == 0)) defaultDir = "sys:\\perl\\scripts"; chdir(defaultDir); diff --git a/ext/File/Glob/bsd_glob.c b/ext/File/Glob/bsd_glob.c index 46b52aa..14af31c 100644 --- a/ext/File/Glob/bsd_glob.c +++ b/ext/File/Glob/bsd_glob.c @@ -200,7 +200,11 @@ static Direntry_t * my_readdir(DIR*); static Direntry_t * my_readdir(DIR *d) { +#ifndef NETWARE return PerlDir_read(d); +#else + return (DIR *)PerlDir_read(d); +#endif } #else #define my_readdir readdir diff --git a/iperlsys.h b/iperlsys.h index dc43dd5..de45ff1 100644 --- a/iperlsys.h +++ b/iperlsys.h @@ -88,7 +88,13 @@ typedef void (*LPSetBuf)(struct IPerlStdIO*, FILE*, char*); typedef int (*LPSetVBuf)(struct IPerlStdIO*, FILE*, char*, int, Size_t); typedef void (*LPSetCnt)(struct IPerlStdIO*, FILE*, int); + +#ifndef NETWARE typedef void (*LPSetPtr)(struct IPerlStdIO*, FILE*, char*); +#elif defined(NETWARE) +typedef void (*LPSetPtr)(struct IPerlStdIO*, FILE*, char*, int); +#endif + typedef void (*LPSetlinebuf)(struct IPerlStdIO*, FILE*); typedef int (*LPPrintf)(struct IPerlStdIO*, FILE*, const char*, ...); diff --git a/lib/ExtUtils/MM.pm b/lib/ExtUtils/MM.pm index 2c23263..3e98c9a 100644 --- a/lib/ExtUtils/MM.pm +++ b/lib/ExtUtils/MM.pm @@ -52,7 +52,7 @@ if( $^O eq 'MSWin32' ) { } $Is{UWIN} = 1 if $^O eq 'uwin'; $Is{Cygwin} = 1 if $^O eq 'cygwin'; -$Is{NW5} = 1 if $Config{osname} eq 'NetWare'; # intentional +$Is{NW5} = 1 if $Config{'osname'} eq 'NetWare'; # intentional $Is{BeOS} = 1 if $^O =~ /beos/i; # XXX should this be that loose? $Is{DOS} = 1 if $^O eq 'dos'; diff --git a/lib/ExtUtils/MM_NW5.pm b/lib/ExtUtils/MM_NW5.pm index 1759eb2..8b382f6 100644 --- a/lib/ExtUtils/MM_NW5.pm +++ b/lib/ExtUtils/MM_NW5.pm @@ -21,6 +21,12 @@ the semantics. use Config; use File::Basename; +#require Exporter; + +#use ExtUtils::MakeMaker; +#Exporter::import('ExtUtils::MakeMaker', +# qw( $Verbose &neatvalue)); + use vars qw(@ISA $VERSION); $VERSION = '2.01_01'; @@ -30,14 +36,16 @@ require ExtUtils::MM_Win32; use ExtUtils::MakeMaker qw( &neatvalue ); $ENV{EMXSHELL} = 'sh'; # to run `commands` +#unshift @MM::ISA, 'ExtUtils::MM_NW5'; -$BORLAND = 1 if $Config{'cc'} =~ /^bcc/i; -$GCC = 1 if $Config{'cc'} =~ /^gcc/i; -$DMAKE = 1 if $Config{'make'} =~ /^dmake/i; -$NMAKE = 1 if $Config{'make'} =~ /^nmake/i; +$BORLAND = 1 if $Config{'cc'} =~ /^bcc/i; +$GCC = 1 if $Config{'cc'} =~ /^gcc/i; +$DMAKE = 1 if $Config{'make'} =~ /^dmake/i; +$NMAKE = 1 if $Config{'make'} =~ /^nmake/i; $PERLMAKE = 1 if $Config{'make'} =~ /^pmake/i; + sub init_others { my ($self) = @_; @@ -51,7 +59,7 @@ sub init_others # Additional import file specified from Makefile.pl if($self->{'base_import'}) { - $self->{'BASE_IMPORT'} .= ',' . $self->{'base_import'}; + $self->{'BASE_IMPORT'} .= ', ' . $self->{'base_import'}; } $self->{'NLM_VERSION'} = $Config{'nlm_version'}; @@ -65,16 +73,15 @@ sub init_others Initializes lots of constants and .SUFFIXES and .PHONY =cut - # NetWare override sub const_cccmd { my($self,$libperl)=@_; return $self->{CONST_CCCMD} if $self->{CONST_CCCMD}; return '' unless $self->needs_linking(); - return $self->{CONST_CCCMD} = - q{CCCMD = $(CC) $(INC) $(CCFLAGS) $(OPTIMIZE) \\ - $(PERLTYPE) $(MPOLLUTE) \\ - -DVERSION="$(VERSION)" -DXS_VERSION="$(XS_VERSION)"}; + return $self->{CONST_CCCMD} = + q{CCCMD = $(CC) $(CCFLAGS) $(INC) $(OPTIMIZE) \\ + $(PERLTYPE) $(MPOLLUTE) -o $@ \\ + -DVERSION=\"$(VERSION)\" -DXS_VERSION=\"$(XS_VERSION)\"}; } sub constants { @@ -94,9 +101,9 @@ sub constants { PERL_ARCHLIB SITELIBEXP SITEARCHEXP LIBPERL_A MYEXTLIB FIRST_MAKEFILE MAKE_APERL_FILE PERLMAINCC PERL_SRC PERL_INC PERL FULLPERL LIBPTH BASE_IMPORT PERLRUN - FULLPERLRUN PERLRUNINST FULLPERLRUNINST - FULL_AR PERL_CORE NLM_VERSION MPKTOOL TOOLPATH - + FULLPERLRUN PERLRUNINST FULL_AR PERL_CORE FULLPERLRUNINST + NLM_VERSION MPKTOOL TOOLPATH + / ) { next unless defined $self->{$tmp}; push @m, "$tmp = $self->{$tmp}\n"; @@ -109,11 +116,12 @@ sub constants { # If the final binary name is greater than 8 chars, # truncate it here and rename it after creation # otherwise, Watcom Linker fails + if(length($self->{'BASEEXT'}) > 8) { - $self->{'NLM_SHORT_NAME'} = substr($self->{'NAME'},0,8); + $self->{'NLM_SHORT_NAME'} = substr($self->{'BASEEXT'},0,8); push @m, "NLM_SHORT_NAME = $self->{'NLM_SHORT_NAME'}\n"; } - + push @m, qq{ VERSION_MACRO = VERSION DEFINE_VERSION = -D\$(VERSION_MACRO)=\\\"\$(VERSION)\\\" @@ -123,18 +131,26 @@ XS_DEFINE_VERSION = -D\$(XS_VERSION_MACRO)=\\\"\$(XS_VERSION)\\\" # Get the include path and replace the spaces with ; # Copy this to makefile as INCLUDE = d:\...;d:\; - (my $inc = $Config{'incpath'}) =~ s/ /;/g; + (my $inc = $Config{'incpath'}) =~ s/([ ]*)-I/;/g; + +=head + # Commented by Ananth since the below code was not adding the DBI path + # and compilation was failing due to non-availability of the correct path. 3 Jan 2002 # Get the additional include path and append to INCLUDE, keep it in # INC will give problems during compilation, hence reset it after getting # the value - (my $add_inc = $self->{'INC'}) =~ s/ -I/;/g; +## (my $add_inc = $self->{'INC'}) =~ s/ -I/;/g; $self->{'INC'} = ''; - push @m, qq{ + push @m, qq{ INCLUDE = $inc;$add_inc; }; +=cut - # Set the path to Watcom binaries which might not have been set in +push @m, qq{ +INCLUDE = $inc; +}; + # Set the path to CodeWarrior binaries which might not have been set in # any other place push @m, qq{ PATH = \$(PATH);\$(TOOLPATH) @@ -253,7 +269,6 @@ PM_TO_BLIB = }.join(" \\\n\t", %{$self->{PM}}).q{ join('',@m); } - =item dynamic_lib (o) Defines how to produce the *.so (or equivalent) files. @@ -285,56 +300,70 @@ $(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP) # .q{$(MYEXTLIB) $(PERL_ARCHIVE) $(LDLOADLIBS) -def:$(EXPORT_LIST)}); # Create xdc data for an MT safe NLM in case of mpk build +# if ( scalar(keys %XS) == 0 ) { return; } + push(@m, + q{ @echo Export boot_$(BOOT_SYMBOL) > $(BASEEXT).def +}); + push(@m, + q{ @echo $(BASE_IMPORT) >> $(BASEEXT).def +}); + push(@m, + q{ @echo Import @$(PERL_INC)\perl.imp >> $(BASEEXT).def +}); + if ( $self->{CCFLAGS} =~ m/ -DMPK_ON /) { $mpk=1; - push @m, ' $(MPKTOOL) $(BASEEXT).xdc + push @m, ' $(MPKTOOL) $(XDCFLAGS) $(BASEEXT).xdc +'; + push @m, ' @echo xdcdata $(BASEEXT).xdc >> $(BASEEXT).def '; } else { $mpk=0; } - + push(@m, - q{ $(LD) Form Novell NLM '$(DISTNAME) Extension, XS_VERSION=$(XS_VERSION)'} + q{ $(LD) $(LDFLAGS) $(OBJECT:.obj=.obj) } ); + push(@m, + q{ -desc "Perl 5.7.3 Extension ($(BASEEXT)) XS_VERSION: $(XS_VERSION)" -nlmversion $(NLM_VERSION) } + ); + # Taking care of long names like FileHandle, ByteLoader, SDBM_File etc if($self->{NLM_SHORT_NAME}) { # In case of nlms with names exceeding 8 chars, build nlm in the # current dir, rename and move to auto\lib. If we create in auto\lib # in the first place, we can't rename afterwards. push(@m, - q{ Name $(NLM_SHORT_NAME).$(DLEXT)} + q{ -o $(NLM_SHORT_NAME).$(DLEXT)} ); } else { push(@m, - q{ Name $(INST_AUTODIR)\\$(BASEEXT).$(DLEXT)} + q{ -o $(INST_AUTODIR)\\$(BASEEXT).$(DLEXT)} ); } - push(@m, - q{ Option Quiet Option Version = $(NLM_VERSION) Option Caseexact Option NoDefaultLibs Option screenname 'none' Option Synchronize } - ); - - if ($mpk) { - push (@m, - q{ Option XDCDATA=$(BASEEXT).xdc } - ); - } + +# if ($mpk) { +# push (@m, +# q{ Option XDCDATA=$(BASEEXT).xdc } +# ); +# } # Add additional lib files if any (SDBM_File) if($self->{MYEXTLIB}) { push(@m, - q{ Library $(MYEXTLIB) } + q{ $(MYEXTLIB) } ); } #For now lets comment all the Watcom lib calls #q{ LibPath $(LIBPTH) Library plib3s.lib Library math3s.lib Library clib3s.lib Library emu387.lib Library $(PERL_ARCHIVE) Library $(PERL_INC)\Main.lib} - + + push(@m, - q{ Library $(PERL_ARCHIVE) Library $(PERL_INC)\Main.lib} - .q{ Export boot_$(BOOT_SYMBOL) $(BASE_IMPORT) } - .q{ FILE $(OBJECT:.obj=,)} + q{ $(PERL_INC)\Main.lib} + .q{ -commandfile $(BASEEXT).def } ); # If it is having a short name, rename it @@ -352,6 +381,11 @@ $(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP) '; push @m, $self->dir_target('$(INST_ARCHAUTODIR)'); +# } else { +# push @m, ' +# @$(NOOP) +#'; +# } join('',@m); } @@ -363,4 +397,3 @@ __END__ =cut - diff --git a/lib/ExtUtils/MM_Unix.pm b/lib/ExtUtils/MM_Unix.pm index b106ab2..08660d0 100644 --- a/lib/ExtUtils/MM_Unix.pm +++ b/lib/ExtUtils/MM_Unix.pm @@ -12,7 +12,7 @@ use File::Spec; use DirHandle; use strict; use vars qw($VERSION @ISA - $Is_Mac $Is_OS2 $Is_VMS $Is_Win32 $Is_Dos $Is_VOS + $Is_Mac $Is_OS2 $Is_VMS $Is_Win32 $Is_Dos $Is_VOS $Is_NetWare $Verbose %pm %static $Xsubpp_Version %Config_Override ); @@ -29,6 +29,11 @@ $Is_Mac = $^O eq 'MacOS'; $Is_Win32 = $^O eq 'MSWin32'; $Is_Dos = $^O eq 'dos'; $Is_VOS = $^O eq 'vos'; ++$Is_NetWare = $Config{'osname'} eq 'NetWare'; # Config{'osname'} intentional +if ($Is_NetWare) { + $^O = 'NetWare'; + $Is_Win32 = 0; +} if ($Is_VMS = $^O eq 'VMS') { require VMS::Filespec; @@ -1557,7 +1562,7 @@ sub init_main { if ($self->{PERL_SRC}){ $self->{PERL_LIB} ||= File::Spec->catdir("$self->{PERL_SRC}","lib"); $self->{PERL_ARCHLIB} = $self->{PERL_LIB}; - $self->{PERL_INC} = ($Is_Win32) ? File::Spec->catdir($self->{PERL_LIB},"CORE") : $self->{PERL_SRC}; + $self->{PERL_INC} = ($Is_Win32 || $Is_NetWare) ? File::Spec->catdir($self->{PERL_LIB},"CORE") : $self->{PERL_SRC}; # catch a situation that has occurred a few times in the past: unless ( @@ -1570,6 +1575,8 @@ sub init_main { $Is_Mac or $Is_Win32 + or + $Is_NetWare ){ warn qq{ You cannot build extensions below the perl source tree after executing @@ -2255,7 +2262,7 @@ sub installbin { push(@m, qq{ EXE_FILES = @{$self->{EXE_FILES}} -} . ($Is_Win32 +} . (($Is_Win32 || $Is_NetWare)x ? q{FIXIN = pl2bat.bat } : q{FIXIN = $(PERLRUN) "-MExtUtils::MY" \ -e "MY->fixin(shift)" diff --git a/makedef.pl b/makedef.pl index b715d4a..330d6a2 100644 --- a/makedef.pl +++ b/makedef.pl @@ -438,6 +438,33 @@ elsif ($PLATFORM eq 'netware') { Perl_getenv_len Perl_my_pclose Perl_my_popen + Perl_sys_intern_init + Perl_sys_intern_dup + Perl_sys_intern_clear + Perl_my_bcopy + Perl_PerlIO_write + Perl_PerlIO_unread + Perl_PerlIO_tell + Perl_PerlIO_stdout + Perl_PerlIO_stdin + Perl_PerlIO_stderr + Perl_PerlIO_setlinebuf + Perl_PerlIO_set_ptrcnt + Perl_PerlIO_set_cnt + Perl_PerlIO_seek + Perl_PerlIO_read + Perl_PerlIO_get_ptr + Perl_PerlIO_get_cnt + Perl_PerlIO_get_bufsiz + Perl_PerlIO_get_base + Perl_PerlIO_flush + Perl_PerlIO_fill + Perl_PerlIO_fileno + Perl_PerlIO_error + Perl_PerlIO_eof + Perl_PerlIO_close + Perl_PerlIO_clearerr + PerlIO_perlio )]; } @@ -1118,6 +1145,10 @@ foreach my $symbol (qw( fnInsertHashListAddrs fnGetHashListAddrs Perl_deb + Perl_sv_setsv + Perl_sv_catsv + Perl_sv_catpvn + Perl_sv_2pv )) { try_symbol($symbol); @@ -1131,12 +1162,7 @@ foreach my $symbol (sort keys %export) { output_symbol($symbol); } -if ($PLATFORM eq 'netware') { - # This may not be the right way to do. This is to make sure - # that the last symbol will not contain a comma else - # Watcom linker cribs - print "\tdummy\n"; -} elsif ($PLATFORM eq 'os2') { +if ($PLATFORM eq 'os2') { print "; LAST_ORDINAL=$sym_ord\n"; } diff --git a/perl.c b/perl.c index 78fd402..7b6eb62 100644 --- a/perl.c +++ b/perl.c @@ -16,6 +16,11 @@ #include "perl.h" #include "patchlevel.h" /* for local_patches */ +#ifdef NETWARE +#include "nwutil.h" +char *nw_get_sitelib(const char *pl); +#endif + /* XXX If this causes problems, set i_unistd=undef in the hint file. */ #ifdef I_UNISTD #include @@ -925,7 +930,7 @@ perl_free(pTHXx) # endif PerlMem_free(aTHXx); # ifdef NETWARE - nw5_delete_internal_host(host); + nw_delete_internal_host(host); # else win32_delete_internal_host(host); # endif diff --git a/x2p/a2py.c b/x2p/a2py.c index 1b14fdd..dbbc7bb 100644 --- a/x2p/a2py.c +++ b/x2p/a2py.c @@ -31,6 +31,10 @@ int oper3(int type, int arg1, int arg2, int arg3); int oper4(int type, int arg1, int arg2, int arg3, int arg4); int oper5(int type, int arg1, int arg2, int arg3, int arg4, int arg5); STR *walk(int useval, int level, register int node, int *numericptr, int minprec); +#ifdef NETWARE +char *savestr(char *str); +char *cpy2(register char *to, register char *from, register int delim); +#endif #if defined(OS2) || defined(WIN32) || defined(NETWARE) static void usage(void); @@ -57,6 +61,7 @@ main(register int argc, register char **argv, register char **env) register STR *str; int i; STR *tmpstr; + /* char *namelist; */ #ifdef NETWARE fnInitGpfGlobals(); /* For importing the CLIB calls in place of Watcom calls */ diff --git a/x2p/hash.c b/x2p/hash.c index ac8caa2..dbdc928 100644 --- a/x2p/hash.c +++ b/x2p/hash.c @@ -13,6 +13,10 @@ #include "a2p.h" #include "util.h" +#ifdef NETWARE +char *savestr(char *str); +#endif + STR * hfetch(register HASH *tb, char *key) { diff --git a/x2p/walk.c b/x2p/walk.c index 997ea34..0823289 100644 --- a/x2p/walk.c +++ b/x2p/walk.c @@ -34,7 +34,11 @@ static void tab ( STR *str, int lvl ); int prewalk ( int numit, int level, int node, int *numericptr ); STR * walk ( int useval, int level, int node, int *numericptr, int minprec ); - +#ifdef NETWARE +char *savestr(char *str); +char *cpytill(register char *to, register char *from, register int delim); +char *instr(char *big, char *little); +#endif STR * walk(int useval, int level, register int node, int *numericptr, int minprec)