Author: mladen.turk(a)jboss.com
Date: 2007-05-10 09:20:49 -0400 (Thu, 10 May 2007)
New Revision: 52
Added:
sandbox/
sandbox/build/
sandbox/build/NMAKEcommon.inc
sandbox/jreflect/
sandbox/jreflect/README.txt
sandbox/jreflect/native/
sandbox/jreflect/native/NMAKEmakefile
sandbox/jreflect/native/include/
sandbox/jreflect/native/include/jreflect.h
sandbox/jreflect/native/include/jreflect_private.h
sandbox/jreflect/native/src/
sandbox/jreflect/native/src/jboss.ico
sandbox/jreflect/native/src/jreflect.c
sandbox/jreflect/native/src/jreflect.rc
sandbox/nswrap/
sandbox/nswrap/README.txt
sandbox/nswrap/native/
sandbox/nswrap/native/NMAKEmakefile
sandbox/nswrap/native/include/
sandbox/nswrap/native/include/nswrap.h
sandbox/nswrap/native/src/
sandbox/nswrap/native/src/jboss.ico
sandbox/nswrap/native/src/nswrap.c
sandbox/nswrap/native/src/nswrap.rc
Log:
Add some sandbox components.
Added: sandbox/build/NMAKEcommon.inc
===================================================================
--- sandbox/build/NMAKEcommon.inc (rev 0)
+++ sandbox/build/NMAKEcommon.inc 2007-05-10 13:20:49 UTC (rev 52)
@@ -0,0 +1,303 @@
+# Copyright 2001-2006 The Apache Software Foundation or its licensors, as
+# applicable.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#
http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ====================================================================
+#
+# NMAKEcommon.inc Master makefile definitions.
+# This file defines CPU architecture and basic compiler
+# and linker parameters.
+# Common params:
+# CPU Compile for specified CPU. Supported CPU's are:
+# i386
+# AMD64
+# IA64
+# If not specified it will default to the
+# PROCESSOR_ARCHITECTURE environment variable
+# or to the i386 if not specified.
+# WINVER Compile for specified Windows version
+# WINNT for Windows 2000 and up(default)
+# WINXP for Windows XP and up
+# WIN2003 for Windows 2003 and up
+# VSITA for Windows Vista and up
+# Deprecated targets (may not even compile):
+# NT4 for Windows NT4 and up
+# WIN9X for Windows 95, 98 and Me
+# BUILD Build version
+# RETAIL or RELEASE (default)
+# DEBUG
+# TARGET Build application target
+# EXE Console executable (default)
+# GUI Windows GUI executable
+# DLL Dynamic Link Library
+# LIB Static library
+# Environment variables used:
+# CFLAGS Added to the common CFLAGS
+# CPPFLAGS Added to the common CPPFLAGS
+# LIBS Added to the common LIBS
+# INCLUDES Added to the common INCLUDES
+# LFLAGS Added to the common LFLAGS
+# RCFLAGS Added to the common RCFLAGS
+#
+# Originally contributed by Mladen Turk <mturk jboss.com>
+#
+# ====================================================================
+#
+
+!IF !DEFINED(CC) || "$(CC)" == ""
+CC = cl.exe
+!ENDIF
+
+!IF !DEFINED(LINK) || "$(LINK)" == ""
+LINK = link.exe
+!ENDIF
+
+!IF !DEFINED(RC) || "$(RC)" == ""
+RC = rc.exe
+!ENDIF
+
+# Read the PROCESSOR_ARCHITECTURE environment value for a CPU type
+
+!IF !DEFINED(CPU) || "$(CPU)" == ""
+!IF "$(PROCESSOR_ARCHITECTURE)" == ""
+CPU=I386
+!ELSE
+CPU = $(PROCESSOR_ARCHITECTURE)
+!ENDIF
+!ENDIF
+
+!IF "$(CPU)" == "i386" || "$(CPU)" == "x86"
+CPU=I386
+!ENDIF
+
+!IF "$(CPU)" != "I386"
+!IF "$(CPU)" != "AMD64"
+!IF "$(CPU)" != "IA64"
+!ERROR Must specify CPU environment variable (I386, AMD64, IA64)
+!ENDIF
+!ENDIF
+!ENDIF
+
+!IF !DEFINED(TARGET) || "$(TARGET)" == ""
+TARGET=EXE
+!ENDIF
+
+!IF "$(TARGET)" != "EXE"
+!IF "$(TARGET)" != "GUI"
+!IF "$(TARGET)" != "DLL"
+!IF "$(TARGET)" != "LIB"
+!ERROR Must specify TARGET environment variable (EXE, GUI, DLL, LIB)
+!ENDIF
+!ENDIF
+!ENDIF
+!ENDIF
+
+!IF !DEFINED(WINVER) || "$(WINVER)" == ""
+WINVER=WINXP
+!ENDIF
+
+
+!IF "$(WINVER)" != "WINNT"
+!IF "$(WINVER)" != "WINXP"
+!IF "$(WINVER)" != "WIN2003"
+!IF "$(WINVER)" != "NT4"
+!IF "$(WINVER)" != "WIN9X"
+!IF "$(WINVER)" != "WVSITA"
+!ERROR Must specify WINVER environment variable (WINNT, WINXP, WIN2003, VSITA, NT4,
WIN9X)
+!ENDIF
+!ENDIF
+!ENDIF
+!ENDIF
+!ENDIF
+!ENDIF
+
+!IF "$(WINVER)" == "WINNT"
+NMAKE_WINVER = 0x0500
+_WIN32_IE = 0x0500
+!ELSEIF "$(WINVER)" == "WINXP"
+NMAKE_WINVER = 0x0501
+_WIN32_IE = 0x0600
+!ELSEIF "$(WINVER)" == "WIN2003"
+NMAKE_WINVER = 0x0502
+_WIN32_IE = 0x0600
+!ELSEIF "$(WINVER)" == "VSITA"
+NMAKE_WINVER = 0x0600
+_WIN32_IE = 0x0700
+!ELSEIF "$(WINVER)" == "NT4"
+NMAKE_WINVER = 0x0400
+_WIN32_IE = 0x0400
+!ELSE
+!ERROR Must specify WINVER environment variable (WINNT, WINXP, WIN2003, VSITA, NT4,
WIN9X)
+!ENDIF
+
+!IF !DEFINED(NMAKE_WINVER) || "$(NMAKE_WINVER)" == ""
+NMAKE_WINVER = 0x0400
+_WIN32_IE = 0x0400
+NMAKE_WINNT = -D_WIN95 -D_WIN32_WINDOWS=$(NMAKE_WINVER) -DWINVER=$(NMAKE_WINVER)
-D_WIN32_IE=$(_WIN32_IE)
+!ELSE
+NMAKE_WINNT = -D_WINNT -D_WIN32_WINNT=$(NMAKE_WINVER) -DWINVER=$(NMAKE_WINVER)
-D_WIN32_IE=$(_WIN32_IE)
+!ENDIF
+
+!IF !DEFINED(BUILD) || "$(BUILD)" == ""
+BUILD=RELEASE
+!ENDIF
+
+!IFDEF RELEASE
+BUILD=RELEASE
+!ENDIF
+
+!IFDEF DEBUG
+BUILD=DEBUG
+!ENDIF
+
+!IFDEF NODEBUG
+BUILD=RELEASE
+!ENDIF
+
+!IF "$(BUILD)" != "RELEASE"
+!IF "$(BUILD)" != "DEBUG"
+!ERROR Must specify BUILD environment variable (RELEASE, DEBUG)
+!ENDIF
+!ENDIF
+
+# Common flags for all platforms
+CMN_CFLAGS = -c -nologo -DWIN32 -D_WIN32 -D_WINDOWS $(NMAKE_WINNT) -W3
+
+!IF "$(CPU)" == "I386"
+CPU_CFLAGS = -D_X86_=1
+!ELSEIF "$(CPU)" == "AMD64"
+CPU_CFLAGS = -D_AMD64_=1 -DWIN64 -D_WIN64 -Wp64
+!ELSEIF "$(CPU)" == "IA64"
+CPU_CFLAGS = -D_IA64_=1 -DWIN64 -D_WIN64 -Wp64
+!ENDIF
+
+!IF "$(INCLUDE_PRE64PRA)" == "1"
+!IF "$(CPU)" != "I386"
+CPU_CFLAGS = $(CPU_CFLAGS) /FIPRE64PRA.H
+!ENDIF
+!ENDIF
+
+!IF "$(BUILD)" == "RELEASE"
+!IF "$(CPU)" == "I386"
+OPT_CFLAGS = -O2 -Ob2 -Oy- -Zi -DNDEBUG
+!ELSE
+OPT_CFLAGS = -O2 -Ob2 -Zi -DNDEBUG
+!ENDIF
+!ELSE
+OPT_CFLAGS = -Od -Zi -DDEBUG -D_DEBUG
+!ENDIF
+
+!IF DEFINED(STATIC_CRT)
+CRT_CFLAGS = -D_MT -MT
+!ELSE
+CRT_CFLAGS = -D_MT -MD
+!ENDIF
+
+!IF "$(BUILD)" == "DEBUG"
+CRT_CFLAGS = $(CRT_CFLAGS)d
+!ENDIF
+
+CFLAGS = $(CMN_CFLAGS) $(CPU_CFLAGS) $(OPT_CFLAGS) $(CRT_CFLAGS) $(CFLAGS)
+
+!IF DEFINED(EXTRA_CFLAGS)
+CFLAGS = $(CFLAGS) $(EXTRA_CFLAGS)
+!ENDIF
+
+
+# Linker section
+LIBS = kernel32.lib advapi32.lib ws2_32.lib mswsock.lib ole32.lib shell32.lib rpcrt4.lib
$(LIBS)
+!IF "$(INCLUDE_BUFFEROVERFLOWU)" == "1"
+!IF "$(CPU)" != "I386"
+LIBS = $(LIBS) bufferoverflowu.lib
+!ENDIF
+!ENDIF
+
+!IF DEFINED(EXTRA_LIBS)
+LIBS = $(LIBS) $(EXTRA_LIBS)
+!ENDIF
+
+COMMON_LFLAGS = /NOLOGO
+
+# Always add debugging to the linker
+OPT_LFLAGS = /INCREMENTAL:NO /DEBUG
+!IF "$(BUILD)" == "RELEASE"
+OPT_LFLAGS = /OPT:REF
+!ENDIF
+
+!IF "$(TARGET)" == "EXE"
+LFLAGS = $(COMMON_LFLAGS) /SUBSYSTEM:CONSOLE /MACHINE:$(CPU)
+!ELSEIF "$(TARGET)" == "GUI"
+LFLAGS = $(COMMON_LFLAGS) /SUBSYSTEM:WINDOWS /MACHINE:$(CPU)
+!ELSEIF "$(TARGET)" == "DLL"
+LFLAGS = $(COMMON_LFLAGS) /DLL /SUBSYSTEM:WINDOWS /MACHINE:$(CPU)
+!ELSEIF "$(TARGET)" == "LIB"
+LFLAGS = -lib $(COMMON_LFLAGS)
+!ENDIF
+
+!IF DEFINED(EXTRA_LFLAGS)
+LFLAGS = $(LFLAGS) $(EXTRA_LFLAGS)
+!ENDIF
+
+!IF "$(TARGET)" != "LIB"
+LFLAGS = $(LFLAGS) $(OPT_LFLAGS)
+!ENDIF
+
+# Resource compiler flags
+
+BASE_RCFLAGS=/l 0x409
+!IF "$(BUILD)" == "RELEASE"
+BASE_RCFLAGS = $(BASE_RCFLAGS) /d "NDEBUG"
+!ELSE
+BASE_RCFLAGS = $(BASE_RCFLAGS) /d "_DEBUG" /d "DEBUG"
+!ENDIF
+RCFLAGS = $(BASE_RCFLAGS) $(RCFLAGS)
+
+# Build Target dir e.g. WINNT_I386_RELEASE_DLL
+!IF !DEFINED(BUILDIR) || "$(BUILDIR)" == ""
+!IF !DEFINED(BUILDIR_EXT) || "$(BUILDIR_EXT)" == ""
+BUILDIR = $(WINVER)_$(CPU)_$(TARGET)_$(BUILD)
+!ELSE
+BUILDIR = $(WINVER)_$(CPU)_$(BUILDIR_EXT)_$(BUILD)
+!ENDIF
+!ENDIF
+
+!IF "$(OS)" == "Windows_NT"
+CLEANTARGET=if exist "$(BUILDIR)/$(NULL)" rd /s /q $(BUILDIR)
+!ELSE
+CLEANTARGET=deltree /y $(BUILDIR)
+!ENDIF
+
+MAKETARGET=if not exist "$(BUILDIR)/$(NULL)" mkdir $(BUILDIR)
+MAKEINSTALL=if not exist "$(INSTALLLOC)" mkdir $(INSTALLLOC)
+
+!IF DEFINED(JAVA_HOME) && "$(JAVA_HOME)" != ""
+JAVA_INCLUDES=-I "$(JAVA_HOME)/include"
+!IF "$(CPU)" != "I386"
+JAVA_INCLUDES=$(JAVA_INCLUDES) -I "$(JAVA_HOME)/include/win64"
+!ENDIF
+JAVA_INCLUDES=$(JAVA_INCLUDES) -I "$(JAVA_HOME)/include/win32"
+!ENDIF
+
+!IF !DEFINED(ML) || "$(ML)" == ""
+!IF "$(CPU)" == "I386"
+ML = ml.exe
+AFLAGS = /coff /Zi /c
+!ELSEIF "$(CPU)" == "AMD64"
+ML = ml64.exe
+AFLAGS = /Zi /c
+!ELSEIF "$(CPU)" == "IA64"
+ML = ml64.exe
+AFLAGS = /coff /Zi /c
+!ENDIF
+!ENDIF
Added: sandbox/jreflect/README.txt
===================================================================
--- sandbox/jreflect/README.txt (rev 0)
+++ sandbox/jreflect/README.txt 2007-05-10 13:20:49 UTC (rev 52)
@@ -0,0 +1,13 @@
+This directory contains both the native and java-side code for
+JREFLECT. (Native Java Reflection Library).
+
+
+Building
+========
+ant
+To build the native part see native/BUILDING
+
+Running the examples
+====================
+before running the examples you may have to set LD_LIBRARY_PATH, something like
+LD_LIBRARY_PATH=/opt/jreflect/lib; export LD_LIBRARY_PATH
Property changes on: sandbox/jreflect/README.txt
___________________________________________________________________
Name: svn:eol-style
+ native
Added: sandbox/jreflect/native/NMAKEmakefile
===================================================================
--- sandbox/jreflect/native/NMAKEmakefile (rev 0)
+++ sandbox/jreflect/native/NMAKEmakefile 2007-05-10 13:20:49 UTC (rev 52)
@@ -0,0 +1,81 @@
+# Copyright 2001-2006 The Apache Software Foundation or its licensors, as
+# applicable.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#
http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ====================================================================
+#
+# NMAKEmakefile Master JREFLECT makefile.
+# Usage:
+# DEBUG=1 Build DEBUG version of SIGHT
+#
+# Originally contributed by Mladen Turk <mturk jboss.com>
+#
+# ====================================================================
+#
+
+TARGET = DLL
+PROJECT = jreflect
+!include <../../build/NMAKEcommon.inc>
+
+CFLAGS = $(CFLAGS) -DJRP_DECLARE_EXPORT
+
+!IF !DEFINED(SRCDIR) || "$(SRCDIR)" == ""
+SRCDIR = .
+!ENDIF
+
+INCLUDES = -I$(SRCDIR)/include $(JAVA_INCLUDES)
+
+PDBFLAGS = -Fo$(BUILDIR)\ -Fd$(BUILDIR)\$(PROJECT)-src
+OBJECTS = \
+ $(BUILDIR)\jreflect.obj
+
+BUILDLIB = $(BUILDIR)\$(PROJECT).dll
+BUILDPDB = $(BUILDIR)\$(PROJECT).pdb
+BUILDRES = $(BUILDIR)\$(PROJECT).res
+BUILDMAN = $(BUILDLIB).manifest
+
+all : $(BUILDIR) $(BUILDLIB)
+
+$(BUILDIR) :
+ @$(MAKETARGET)
+
+{$(SRCDIR)/src}.c{$(BUILDIR)}.obj:
+ $(CC) $(CFLAGS) $(INCLUDES) $(PDBFLAGS) $<
+
+$(OBJECTS): $(SRCDIR)/include/*.h
+
+$(BUILDRES): $(SRCDIR)/src/jreflect.rc $(SRCDIR)/include/*.h
+ $(RC) $(RCFLAGS) /i "$(SRCDIR)/include" /fo $(BUILDRES)
$(SRCDIR)/src/jreflect.rc
+
+$(BUILDLIB): $(BUILDIR) $(OBJECTS) $(BUILDRES)
+ $(LINK) $(LFLAGS) $(OBJECTS) $(BUILDRES) $(LIBS) $(LDIRS) /pdb:$(BUILDPDB)
/out:$(BUILDLIB)
+ IF EXIST $(BUILDMAN) \
+ mt -nologo -manifest $(BUILDMAN) -outputresource:$(BUILDLIB);2
+
+clean:
+ @$(CLEANTARGET)
+
+!IFNDEF INSTALLNAME
+INSTALLNAME = windows-$(CPU)
+!ENDIF
+
+!IFNDEF INSTALLDIR
+INSTALLLOC = ..\..\dist\$(INSTALLNAME)\bin\native\
+!ENDIF
+
+install: all
+ @$(MAKEINSTALL)
+ @xcopy "$(BUILDLIB)" $(INSTALLLOC) /Q /Y > NUL
+ @IF EXIST $(CRT_REDIST)\msvcr80.dll \
+ xcopy $(CRT_REDIST)\* $(INSTALLLOC) /E /R /Q > NUL
Added: sandbox/jreflect/native/include/jreflect.h
===================================================================
--- sandbox/jreflect/native/include/jreflect.h (rev 0)
+++ sandbox/jreflect/native/include/jreflect.h 2007-05-10 13:20:49 UTC (rev 52)
@@ -0,0 +1,271 @@
+/*
+ * JREFLECT - Native Java Reflection Library
+ *
+ * Copyright(c) 2007 Red Hat Middleware, LLC,
+ * and individual contributors as indicated by the @authors tag.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * @author Mladen Turk
+ *
+ */
+
+#ifndef JREFLECT_H
+#define JREFLECT_H
+
+#if defined(WIN32)
+/* Ignore most warnings (back down to /W3) for poorly constructed headers
+ */
+#if defined(_MSC_VER) && _MSC_VER >= 1200
+#pragma warning(push, 3)
+#endif
+
+/* disable or reduce the frequency of...
+ * C4057: indirection to slightly different base types
+ * C4075: slight indirection changes (unsigned short* vs short[])
+ * C4100: unreferenced formal parameter
+ * C4127: conditional expression is constant
+ * C4163: '_rotl64' : not available as an intrinsic function
+ * C4201: nonstandard extension nameless struct/unions
+ * C4244: int to char/short - precision loss
+ * C4514: unreferenced inline function removed
+ */
+#pragma warning(disable: 4100 4127 4163 4201 4514; once: 4057 4075 4244)
+
+/* Ignore Microsoft's interpretation of secure development
+ * and the POSIX string handling API
+ */
+#if defined(_MSC_VER) && _MSC_VER >= 1400
+#ifndef _CRT_SECURE_NO_DEPRECATE
+#define _CRT_SECURE_NO_DEPRECATE
+#endif
+#pragma warning(disable: 4996)
+#endif
+
+/* Has windows.h already been included? If so, our preferences don't matter,
+ * but we will still need the winsock things no matter what was included.
+ * If not, include a restricted set of windows headers to our tastes.
+ */
+#ifndef _WINDOWS_
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN
+#endif
+#ifndef _WIN32_WINNT
+
+/* Restrict the server to a subset of Windows NT 5.0 header files by default
+ */
+#define _WIN32_WINNT 0x0500
+#endif
+#ifndef NOUSER
+#define NOUSER
+#endif
+#ifndef NOMCX
+#define NOMCX
+#endif
+#ifndef NOIME
+#define NOIME
+#endif
+#include <windows.h>
+#endif /* !_WINDOWS_ */
+
+#ifndef __attribute__
+#define __attribute__(__x)
+#endif
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <stddef.h>
+
+#else /* !WIN32 */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+
+/* So that we can use inline on some critical functions, and use
+ * GNUC attributes (such as to get -Wall warnings for printf-like
+ * functions). Only do this in gcc 2.7 or later ... it may work
+ * on earlier stuff, but why chance it.
+ *
+ * We've since discovered that the gcc shipped with NeXT systems
+ * as "cc" is completely broken. It claims to be __GNUC__ and so
+ * on, but it doesn't implement half of the things that __GNUC__
+ * means. In particular it's missing inline and the __attribute__
+ * stuff. So we hack around it. PR#1613. -djg
+ */
+#if !defined(__GNUC__) || __GNUC__ < 2 || \
+ (__GNUC__ == 2 && __GNUC_MINOR__ < 7) || \
+ defined(NEXT)
+#ifndef __attribute__
+#define __attribute__(__x)
+#endif
+#endif
+
+#endif /* WIN32 */
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @file jreflect.h
+ * @brief
+ *
+ * JREFLECT Public API
+ */
+
+
+#if !defined(WIN32)
+
+/**
+ * The public JRP functions are declared with JRP_DECLARE(), so they may
+ * use the most appropriate calling convention. Public JRP functions with
+ * variable arguments must use JRP_DECLARE_NONSTD().
+ *
+ * @remark Both the declaration and implementations must use the same macro.
+ * @example
+ */
+
+/** JRP_DECLARE(rettype) jrp_func(args)
+ * @see JRP_DECLARE_NONSTD @see JRP_DECLARE_DATA
+ * @remark Note that when JRP compiles the library itself, it passes the
+ * symbol -DJRP_DECLARE_EXPORT to the compiler on some platforms (e.g. Win32)
+ * to export public symbols from the dynamic library build.\n
+ * The user must define the JRP_DECLARE_STATIC when compiling to target
+ * the static JRP library on some platforms (e.g. Win32.) The public symbols
+ * are neither exported nor imported when JRP_DECLARE_STATIC is defined.\n
+ * By default, compiling an application and including the JRP public
+ * headers, without defining JRP_DECLARE_STATIC, will prepare the code to be
+ * linked to the dynamic library.
+ */
+#define JRP_DECLARE(type) type
+
+/**
+ * The public JRP functions using variable arguments are declared with
+ * JRP_DECLARE_NONSTD(), as they must follow the C language calling convention.
+ * @see JRP_DECLARE @see JRP_DECLARE_DATA
+ * @remark Both the declaration and implementations must use the same macro.
+ * @example
+ */
+/** JRP_DECLARE_NONSTD(rettype) jrp_func(args, ...);
+ */
+#define JRP_DECLARE_NONSTD(type) type
+
+/**
+ * The public JRP variables are declared with AP_MODULE_DECLARE_DATA.
+ * This assures the appropriate indirection is invoked at compile time.
+ * @see JRP_DECLARE @see JRP_DECLARE_NONSTD
+ * @remark Note that the declaration and implementations use different forms,
+ * but both must include the macro.
+ * @example
+ */
+/**
+ * extern JRP_DECLARE_DATA type jrp_variable;\n
+ * JRP_DECLARE_DATA type jrp_variable = value;
+ */
+#define JRP_DECLARE_DATA
+
+#elif defined(JRP_DECLARE_STATIC)
+#define JRP_DECLARE(type) type __stdcall
+#define JRP_DECLARE_NONSTD(type) type __cdecl
+#define JRP_DECLARE_DATA
+#elif defined(JRP_DECLARE_EXPORT)
+#define JRP_DECLARE(type) __declspec(dllexport) type __stdcall
+#define JRP_DECLARE_NONSTD(type) __declspec(dllexport) type __cdecl
+#define JRP_DECLARE_DATA __declspec(dllexport)
+#else
+#define JRP_DECLARE(type) __declspec(dllimport) type __stdcall
+#define JRP_DECLARE_NONSTD(type) __declspec(dllimport) type __cdecl
+#define JRP_DECLARE_DATA __declspec(dllimport)
+#endif
+
+typedef struct jrp_env_t {
+ JNIEnv *env;
+ int emode;
+} jrp_env_t;
+
+/**
+ * Called by the client when the library is loaded
+ */
+JRP_DECLARE(jint) jrp_initialize(JavaVM *vm);
+
+/**
+ * Called by the client before the library is unloaded
+ */
+JRP_DECLARE(void) jrp_terminate(void);
+
+/* Standard Java classes */
+typedef enum {
+ JRP_CC_OBJECT,
+ JRP_CC_STRING,
+ JRP_CC_CLASS,
+ JRP_CC_ZARRAY,
+ JRP_CC_BARRAY,
+ JRP_CC_CARRAY,
+ JRP_CC_IARRAY,
+ JRP_CC_JARRAY,
+ JRP_CC_TARRAY,
+ JRP_CC_OARRAY,
+ JRP_CC_MAX
+} jrp_cclass_e;
+
+
+JRP_DECLARE(jobjectArray) jrp_new_cc_array(JNIEnv *, jrp_cclass_e, jsize);
+JRP_DECLARE(jbyteArray) jrp_new_byte_array(JNIEnv *, jbyte *, jsize);
+
+/**
+ * Get current JNIEnv
+ * If this is a thread not created by JVM attach the thread
+ */
+JRP_DECLARE(JNIEnv *) jrp_get_jnienv();
+
+/**
+ * Memory allocation routines
+ */
+JRP_DECLARE(void *) jrp_malloc(jint);
+JRP_DECLARE(void *) jrp_calloc(jint);
+JRP_DECLARE(void) jrp_free(void *);
+
+/**
+ * Convenience function to help throw an java.io.IOException.
+ */
+JRP_DECLARE(void) jrp_throw_io_exception(const char *);
+
+/**
+ * Convenience function to help throw an javax.servlet.ServletException.
+ */
+JRP_DECLARE(void) jrp_throw_servlet_exception(const char *);
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+/* Done with badly written headers
+ */
+#if defined(_MSC_VER) && _MSC_VER >= 1200
+#pragma warning(pop)
+#pragma warning(disable: 4996)
+#endif
+
+#endif /* JREFLECT_H */
Property changes on: sandbox/jreflect/native/include/jreflect.h
___________________________________________________________________
Name: svn:eol-style
+ native
Added: sandbox/jreflect/native/include/jreflect_private.h
===================================================================
--- sandbox/jreflect/native/include/jreflect_private.h (rev 0)
+++ sandbox/jreflect/native/include/jreflect_private.h 2007-05-10 13:20:49 UTC (rev 52)
@@ -0,0 +1,219 @@
+/*
+ * JREFLECT - Native Java Reflection Library
+ *
+ * Copyright(c) 2007 Red Hat Middleware, LLC,
+ * and individual contributors as indicated by the @authors tag.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * @author Mladen Turk
+ *
+ */
+
+#ifndef JREFLECT_PRIVATE_H
+#define JREFLECT_PRIVATE_H
+
+
+#include "jreflect.h"
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @file jreflect_private.h
+ * @brief
+ *
+ * JREFLECT private API
+ */
+
+#define UNREFERENCED(P) (P) = (P)
+#define UNREFERENCED_STDARGS _E = _E; _O = _O
+#define UNREFERENCED_O _O = _O
+#if defined(WIN32)
+#define LLT(X) (X)
+#else
+#define LLT(X) ((long)(X))
+#endif
+#define P2J(P) ((jlong)LLT(P))
+#define J2P(P, T) ((T)LLT((jlong)P))
+#define V2P(T, V) ((T)((T)0 + (V)))
+#define V2Z(V) ((V) ? JNI_TRUE : JNI_FALSE)
+
+#define JRP_STDARGS JNIEnv *_E, jobject _O
+
+
+#define J2S(V) _c##V
+#define J2T(T) (time_t)((T))
+#define JRP_CC const char
+#define JRP_BEGIN_MACRO if (1) {
+#define JRP_END_MACRO } else (void)(0)
+
+#define JRP_ALLOC_CSTRING(V) \
+ JRP_CC *_c##V = V ? (JRP_CC *)((*_E)->GetStringUTFChars(_E, V, 0)) : NULL
+
+#define JRP_INIT_CSTRING(V)
+
+#define JRP_FREE_CSTRING(V) \
+ if (_c##V) (*_E)->ReleaseStringUTFChars(_E, V, _c##V)
+
+
+#define JRP_CSTR_TO_JSTRING(V) (*_E)->NewStringUTF((_E), (V))
+
+#define JRP_RETURN_JCSTR(V) \
+ if ((V)) return (*_E)->NewStringUTF((_E), (V)); \
+ else return NULL
+
+#define JRP_IS_JOBJECT_NULL(E, O) \
+ (!(O) || ((*(E))->IsSameObject((E), (O), NULL) == JNI_TRUE))
+
+#define JRP_IS_JOBJECT_VALID(E, O) \
+ ((O) && !((*(E))->IsSameObject((E), (O), NULL) == JNI_TRUE))
+
+typedef struct JRP_JC_ID {
+ jclass i;
+ jclass a;
+ const char *n;
+} JRP_JC_ID;
+
+typedef struct JRP_JM_ID {
+ jmethodID i;
+ const char *n;
+ const char *s;
+} JRP_JM_ID;
+
+typedef struct JRP_JF_ID {
+ jfieldID i;
+ const char *n;
+ const char *s;
+} JRP_JF_ID;
+
+#define JRP_CLASS_LDEF(CL) \
+ int jrp_class_##CL##_load(JNIEnv *_E)
+
+#define JRP_CLASS_UDEF(CL) \
+ void jrp_class_##CL##_unload(JNIEnv *_E)
+
+#define JRP_CLASS_LDEC(CL) \
+ extern int jrp_class_##CL##_load(JNIEnv *); \
+ extern int jrp_class_##CL##_unload(JNIEnv *)
+
+#define JRP_CLASS_LCAL(CL) \
+ if (jrp_class_##CL##_load(_E)) return 1;
+
+
+#define JRP_CLASS_UCAL(CL) \
+ jrp_class_##CL##_unload(_E)
+
+#define JRP_DECLARE_CLAZZ static JRP_JC_ID _clazzn
+#define JRP_DECLARE_F_ID(I) static JRP_JF_ID _f##I##n
+#define JRP_DECLARE_M_ID(I) static JRP_JM_ID _m##I##n
+
+#define JRP_LOAD_METHOD(I) \
+ if (_m##I##n.i == NULL) { \
+ _m##I##n.i = (*_E)->GetMethodID(_E, _clazzn.i, _m##I##n.n, \
+ _m##I##n.s); \
+ if ((*_E)->ExceptionCheck(_E) || _m##I##n.i == NULL) { \
+ return 1; \
+ } \
+ } else (void)(0)
+
+#define JRP_LOAD_MLOCAL(I) \
+ if (_m##I##n.i == NULL) { \
+ _m##I##n.i = (*_E)->GetStaticMethodID(_E, _clazzn.i, _m##I##n.n, \
+ _m##I##n.s); \
+ if ((*_E)->ExceptionCheck(_E) || _m##I##.i == NULL) { \
+ return 1; \
+ } \
+ } else (void)(0)
+
+#define JRP_LOAD_IFIELD(I) \
+ if (_f##I##n.i == NULL) { \
+ _f##I##n.i = (*_E)->GetFieldID(_E, _clazzn.i, _f##I##n.n, \
+ _f##I##n.s); \
+ if ((*_E)->ExceptionCheck(_E) || _f##I##n.i == NULL) { \
+ return 1; \
+ } \
+ } else (void)(0)
+
+#define JRP_LOAD_SFIELD(I) \
+ if (_f##I##n.i == NULL) { \
+ _f##I##n.i = (*_E)->GetStaticFieldID(_E, _clazzn.i, _f##I##n.n, \
+ _f##I##n.s); \
+ if ((*_E)->ExceptionCheck(_E) || _f##I##n.i == NULL) { \
+ return 1; \
+ } \
+ } else (void)(0)
+
+
+#define JRP_SET_IFIELD_J(I, O, V) \
+ if (_f##I##n.i) { \
+ (*_E)->SetLongField(_E, (O), _f##I##n.i, (jlong)(V)); \
+ } else (void)(0)
+
+#define JRP_SET_IFIELD_I(I, O, V) \
+ if (_f##I##n.i) { \
+ (*_E)->SetIntField(_E, (O), _f##I##n.i, (jint)(V)); \
+ } else (void)(0)
+
+#define JRP_SET_IFIELD_D(I, O, V) \
+ if (_f##I##n.i) { \
+ (*_E)->SetDoubleField(_E, (O), _f##I##n.i, (jdouble)(V)); \
+ } else (void)(0)
+
+#define JRP_SET_IFIELD_Z(I, O, V) \
+ if (_f##I##n.i) { \
+ if ((V)) (*_E)->SetBooleanField(_E, (O), _f##I##n.i, JNI_TRUE); \
+ else (*_E)->SetBooleanField(_E, (O), _f##I##n.i, JNI_FALSE); \
+ } else (void)(0)
+
+#define JRP_SET_IFIELD_S(I, O, V) \
+ if (_f##I##n.i && (V)) { \
+ jstring _str = (*_E)->NewStringUTF(_E, (V)); \
+ (*_E)->SetObjectField(_E, (O), _f##I##n.i, _str); \
+ (*_E)->DeleteLocalRef(_E, _str); \
+ } else (void)(0)
+
+#define JRP_SET_IFIELD_O(I, O, V) \
+ if (_f##I##n.i) { \
+ (*_E)->SetObjectField(_E, (O), _f##I##n.i, (jobject)(V)); \
+ } else (void)(0)
+
+#define JRP_CALL_METHOD1(I, O, V) \
+ if (_m##I##n.i) { \
+ (*_E)->CallVoidMethod(_E, (O), _m##I##n.i, (V), NULL); \
+ } else (void)(0)
+
+#define JRP_CALL_METHOD2(I, O, V, X) \
+ if (_m##I##n.i) { \
+ (*_E)->CallVoidMethod(_E, (O), _m##I##n.i, (V), (X), NULL); \
+ } else (void)(0)
+
+#define JRP_CALL_METHOD3(I, O, V, X, Y) \
+ if (_m##I##n.i) { \
+ (*_E)->CallVoidMethod(_E, (O), _m##I##n.i, (V), (X), (Y), NULL); \
+ } else (void)(0)
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* JREFLECT_PRIVATE_H */
Property changes on: sandbox/jreflect/native/include/jreflect_private.h
___________________________________________________________________
Name: svn:eol-style
+ native
Added: sandbox/jreflect/native/src/jboss.ico
===================================================================
(Binary files differ)
Property changes on: sandbox/jreflect/native/src/jboss.ico
___________________________________________________________________
Name: svn:mime-type
+ image/x-icon
Added: sandbox/jreflect/native/src/jreflect.c
===================================================================
--- sandbox/jreflect/native/src/jreflect.c (rev 0)
+++ sandbox/jreflect/native/src/jreflect.c 2007-05-10 13:20:49 UTC (rev 52)
@@ -0,0 +1,389 @@
+/*
+ * JREFLECT - Native Java Reflection Library
+ *
+ * Copyright(c) 2007 Red Hat Middleware, LLC,
+ * and individual contributors as indicated by the @authors tag.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * @author Mladen Turk
+ *
+ */
+
+#include "jreflect.h"
+#include "jreflect_private.h"
+
+static JavaVM *jrp_global_vm = NULL;
+static int jrp_initalized = 0;
+
+#define STD_GLOBAL_JCLASSES JRP_CC_MAX
+static jclass global_classes[STD_GLOBAL_JCLASSES];
+
+
+#if defined(WIN32)
+
+static DWORD dll_tls_index = 0;
+
+BOOL APIENTRY DllMain(HINSTANCE instance,
+ DWORD ul_reason_for_call,
+ LPVOID lpReserved)
+{
+ jrp_env_t *tls_data;
+
+ switch (ul_reason_for_call) {
+ case DLL_PROCESS_ATTACH:
+ /* Allocate a TLS index. */
+ if ((dll_tls_index = TlsAlloc()) == TLS_OUT_OF_INDEXES)
+ return FALSE;
+ break;
+ case DLL_THREAD_ATTACH:
+ break;
+ case DLL_THREAD_DETACH:
+ case DLL_PROCESS_DETACH:
+ tls_data = (jrp_env_t *)TlsGetValue(dll_tls_index);
+ if (tls_data != NULL) {
+ if (jrp_global_vm != NULL && tls_data->emode == JNI_EDETACHED)
{
+ (*jrp_global_vm)->DetachCurrentThread(jrp_global_vm);
+ }
+ LocalFree(tls_data);
+ }
+ break;
+ }
+ return TRUE;
+}
+
+#else /* !WIN32 */
+
+static pthread_key_t pthread_jenv_key = NULL;
+
+static void jenv_destructor(void *data)
+{
+ jpr_env_t *e = (jpr_env_t *)data;
+ if (e) {
+ if (e->env && e->emode == JNI_EDETACHED) {
+ (*jrp_global_vm)->DetachCurrentThread(jrp_global_vm)
+ }
+ free(e);
+ }
+}
+
+#endif /* WIN32 */
+
+static int load_class(JNIEnv *e, JRP_JC_ID *clazz)
+{
+ jobject c;
+ char an[1024];
+
+ if (clazz->i != NULL) {
+ return 0;
+ }
+ if ((*e)->EnsureLocalCapacity(e, 3) < 0)
+ goto failed;
+ c = (jobject)(*e)->FindClass(e, clazz->n);
+ if ((*e)->ExceptionCheck(e) || c == NULL) {
+ goto failed;
+ }
+ clazz->i = (jclass)(*e)->NewGlobalRef(e, c);
+ if ((*e)->ExceptionCheck(e) || clazz->i == NULL) {
+ clazz->i = NULL;
+ goto failed;
+ }
+ (*e)->DeleteLocalRef(e, c);
+
+ /* Init class array */
+ sprintf(an, "L%s;", clazz->n);
+ c = (jobject)(*e)->FindClass(e, an);
+ if ((*e)->ExceptionCheck(e) || c == NULL) {
+ goto failed;
+ }
+ clazz->a = (jclass)(*e)->NewGlobalRef(e, c);
+ if ((*e)->ExceptionCheck(e) || clazz->a == NULL) {
+ clazz->a = NULL;
+ goto failed;
+ }
+ return 0;
+
+failed:
+ if (clazz->i != NULL) {
+ (*e)->DeleteGlobalRef(e, clazz->i);
+ clazz->i = NULL;
+ }
+ return -1;
+
+}
+
+static void unload_class(JNIEnv *e, JRP_JC_ID *clazz)
+{
+ if (clazz->i != NULL) {
+ (*e)->DeleteGlobalRef(e, clazz->i);
+ clazz->i = NULL;
+ }
+ if (clazz->a != NULL) {
+ (*e)->DeleteGlobalRef(e, clazz->a);
+ clazz->a = NULL;
+ }
+}
+
+static void init_java_rt(JNIEnv *e)
+{
+ jobject c;
+ int i;
+ for (i = 0; i < STD_GLOBAL_JCLASSES; i++)
+ global_classes[i] = NULL;
+
+ c = (jobject)(*e)->FindClass(e, "Ljava/lang/Object;");
+ global_classes[JRP_CC_OBJECT] = (jclass)(*e)->NewGlobalRef(e, c);
+ (*e)->DeleteLocalRef(e, c);
+ c = (jobject)(*e)->FindClass(e, "Ljava/lang/String;");
+ global_classes[JRP_CC_STRING] = (jclass)(*e)->NewGlobalRef(e, c);
+ (*e)->DeleteLocalRef(e, c);
+ c = (jobject)(*e)->FindClass(e, "Ljava/lang/Class;");
+ global_classes[JRP_CC_CLASS] = (jclass)(*e)->NewGlobalRef(e, c);
+ (*e)->DeleteLocalRef(e, c);
+ /* [][] Core Arrays */
+ c = (jobject)(*e)->FindClass(e, "[Z");
+ global_classes[JRP_CC_ZARRAY] = (jclass)(*e)->NewGlobalRef(e, c);
+ (*e)->DeleteLocalRef(e, c);
+ c = (jobject)(*e)->FindClass(e, "[B");
+ global_classes[JRP_CC_BARRAY] = (jclass)(*e)->NewGlobalRef(e, c);
+ (*e)->DeleteLocalRef(e, c);
+ c = (jobject)(*e)->FindClass(e, "[C");
+ global_classes[JRP_CC_CARRAY] = (jclass)(*e)->NewGlobalRef(e, c);
+ (*e)->DeleteLocalRef(e, c);
+ c = (jobject)(*e)->FindClass(e, "[I");
+ global_classes[JRP_CC_IARRAY] = (jclass)(*e)->NewGlobalRef(e, c);
+ (*e)->DeleteLocalRef(e, c);
+ c = (jobject)(*e)->FindClass(e, "[J");
+ global_classes[JRP_CC_JARRAY] = (jclass)(*e)->NewGlobalRef(e, c);
+ (*e)->DeleteLocalRef(e, c);
+ c = (jobject)(*e)->FindClass(e, "[Ljava/lang/String;");
+ global_classes[JRP_CC_TARRAY] = (jclass)(*e)->NewGlobalRef(e, c);
+ (*e)->DeleteLocalRef(e, c);
+ c = (jobject)(*e)->FindClass(e, "[Ljava/lang/Object;");
+ global_classes[JRP_CC_OARRAY] = (jclass)(*e)->NewGlobalRef(e, c);
+ (*e)->DeleteLocalRef(e, c);
+
+}
+
+jclass jrp_get_cc(jrp_cclass_e i)
+{
+ if (i > 0 && i < JRP_CC_MAX)
+ return global_classes[i];
+ else
+ return NULL;
+}
+
+JRP_DECLARE(jobjectArray) jrp_new_cc_array(JNIEnv *e, jrp_cclass_e i, jsize len)
+{
+ if (i > 0 && i < JRP_CC_MAX)
+ return (*e)->NewObjectArray(e, len, global_classes[i], NULL);
+ else
+ return NULL;
+}
+
+JRP_DECLARE(jbyteArray) jrp_new_byte_array(JNIEnv *e, jbyte *data,
+ jsize len)
+{
+ jbyteArray bytes = (*e)->NewByteArray(e, len);
+ if (bytes != NULL) {
+ (*e)->SetByteArrayRegion(e, bytes, 0, (jint)len, data);
+ }
+ return bytes;
+}
+
+static int load_classes(JNIEnv *_E)
+{
+ return 0;
+}
+
+static void unload_classes(JNIEnv *_E)
+{
+}
+
+/* Called by the client when the library is loaded */
+JRP_DECLARE(jint) jrp_initialize(JavaVM *vm)
+{
+ JNIEnv *_E;
+ if (jrp_initalized++) {
+ /** Already initialized */
+ return JNI_VERSION_1_4;
+ }
+ jrp_global_vm = vm;
+ if ((*vm)->GetEnv(vm, (void **)&_E, JNI_VERSION_1_4)) {
+ return JNI_ERR;
+ }
+ init_java_rt(_E);
+ if (load_classes(_E)) {
+ unload_classes(_E);
+ return JNI_ERR;
+ }
+#if !defined(WIN32)
+ pthread_key_create(&pthread_jenv_key, jenv_destructor);
+#endif
+
+ /* Initialize all counters to zero */
+ return JNI_VERSION_1_4;
+}
+
+/* Called by the Client before the library is unloaded */
+JRP_DECLARE(void) jrp_terminate()
+{
+ jint rv;
+ JNIEnv *env = NULL;
+ if (--jrp_initalized != 0 || jrp_global_vm == NULL) {
+ /** Reference count non zero */
+ return;
+ }
+ rv = (*jrp_global_vm)->GetEnv(jrp_global_vm,
+ (void **)&env, JNI_VERSION_1_4);
+ if (rv == JNI_EDETACHED) {
+ (*jrp_global_vm)->AttachCurrentThread(jrp_global_vm,
+ (void**)env, NULL);
+ }
+ if (env) {
+ unload_classes(env);
+ }
+ if (rv == JNI_EDETACHED) {
+ (*jrp_global_vm)->DetachCurrentThread(jrp_global_vm);
+ }
+ jrp_global_vm = NULL;
+}
+
+
+#if defined(WIN32)
+
+/* Get current JNIEnv
+ * If this is a thread not created by JVM attach the thread
+ */
+JRP_DECLARE(JNIEnv *) jrp_get_jnienv()
+{
+ jrp_env_t *e = (jrp_env_t *)TlsGetValue(dll_tls_index);
+
+ if (!e) {
+ if (!(e = (jrp_env_t *)LocalAlloc(LPTR, sizeof(jrp_env_t))))
+ return NULL;
+ e->emode = (*jrp_global_vm)->GetEnv(jrp_global_vm,
+ (void**)&e->env,
+ JNI_VERSION_1_4);
+ if (e->emode == JNI_EDETACHED) {
+ (*jrp_global_vm)->AttachCurrentThread(jrp_global_vm,
+ (void**)&e->env, NULL);
+ }
+ TlsSetValue(dll_tls_index, e);
+ }
+ return e->env;
+}
+
+#else
+
+/* Get current JNIEnv
+ * If this is a thread not created by JVM attach the thread
+ */
+JRP_DECLARE(JNIEnv *) jrp_get_jnienv()
+{
+ jrp_env_t *e = (jrp_env_t *)pthread_getspecific(pthread_jenv_key);
+ if (!e) {
+ if (!(e = (jrp_env_t *)malloc(sizeof(jrp_env_t))))
+ return NULL;
+
+ e->emode = (*jrp_global_vm)->GetEnv(jrp_global_vm,
+ (void**)&e->env,
+ JNI_VERSION_1_4);
+ if (e->emode == JNI_EDETACHED) {
+ (*jrp_global_vm)->AttachCurrentThread(jrp_global_vm,
+ (void**)&e->env, NULL);
+ }
+ pthread_setspecific(pthread_jenv_key, e);
+ }
+ return e->env;
+}
+
+#endif
+
+JRP_DECLARE(void *) jrp_malloc(jint size)
+{
+ void * rv = malloc((size_t)size);
+ if (!rv) {
+ /* TODO: Throw exception */
+
+ }
+ return rv;
+}
+
+JRP_DECLARE(void *) jrp_calloc(jint size)
+{
+ void * rv = calloc(1, (size_t)size);
+ if (!rv) {
+ /* TODO: Throw exception */
+
+ }
+ return rv;
+}
+
+JRP_DECLARE(void) jrp_free(void *mem)
+{
+ if (mem) {
+ free(mem);
+ }
+}
+
+
+/**
+ * Convenience function to help throw an java.io.IOException.
+ */
+JRP_DECLARE(void) jrp_throw_io_exception(const char *msg)
+{
+ JNIEnv *env;
+ jclass cls;
+
+ if (!(env = jrp_get_jnienv())) {
+ fprintf(stderr, "Cannot attach to the JNI Environment\n");
+ return;
+ }
+ cls = (*env)->FindClass(env, "java/io/IOException");
+ if (cls == NULL) {
+ fprintf(stderr, "Cannot find java/io/IOException class\n");
+ }
+ else {
+ (*env)->ThrowNew(env, cls, msg);
+ (*env)->DeleteLocalRef(env, cls);
+ }
+}
+
+/**
+ * Convenience function to help throw an javax.servlet.ServletException.
+ */
+JRP_DECLARE(void) jrp_throw_servlet_exception(const char *msg)
+{
+ JNIEnv *env;
+ jclass cls;
+
+ if (!(env = jrp_get_jnienv())) {
+ fprintf(stderr, "Cannot attach to the JNI Environment\n");
+ return;
+ }
+
+ cls = (*env)->FindClass(env, "javax/servlet/ServletException");
+ if (cls == NULL) {
+ fprintf(stderr, "Cannot find javax/servlet/ServletException class\n");
+ }
+ else {
+ (*env)->ThrowNew(env, cls, msg);
+ (*env)->DeleteLocalRef(env, cls);
+ }
+}
Property changes on: sandbox/jreflect/native/src/jreflect.c
___________________________________________________________________
Name: svn:eol-style
+ native
Added: sandbox/jreflect/native/src/jreflect.rc
===================================================================
--- sandbox/jreflect/native/src/jreflect.rc (rev 0)
+++ sandbox/jreflect/native/src/jreflect.rc 2007-05-10 13:20:49 UTC (rev 52)
@@ -0,0 +1,101 @@
+/*
+ * JREFLECT - Native Java Reflection Library
+ *
+ * Copyright(c) 2007 Red Hat Middleware, LLC,
+ * and individual contributors as indicated by the @authors tag.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * @author Mladen Turk
+ *
+ */
+
+#include <windows.h>
+
+#define STR_COPYRIGHT "Copyright � 2006 Red Hat Middleware, LLC. " \
+ "or its licensors, as applicable."
+
+#define STR_LICENSE "Distributable under LGPL license. " \
+ "See terms of license at gnu.org."
+
+#define STR_COMPANY "Red Hat�, Inc."
+#define STR_TRADEMARK "� Red Hat Inc."
+#define STR_PRODUCT "Native Java Reflection Library"
+#define STR_VERISON "1.0.0.0"
+#define CSV_VERISON 1,0,0,0
+
+#define PRIVATE_BUILD 0
+#define PRERELEASE_BUILD 0
+
+#if PRIVATE_BUILD
+#define STR_PRIVATE "Initial Prerelease"
+#define STR_SPECIAL "Basic functionality"
+#define STD_FILEFLAGS VS_FF_PRIVATEBUILD | VS_FF_SPECIALBUILD
+#else
+#define STD_FILEFLAGS 0x0L
+#endif
+
+#if RERELEASE_BUILD
+#define PSTD_FILEFLAGS STD_FILEFLAGS | VS_FF_PRERELEASE
+#else
+#define PSTD_FILEFLAGS STD_FILEFLAGS
+#endif
+
+#ifdef _DEBUG
+#define APP_FILEFLAGS STD_FILEFLAGS | VS_FF_DEBUG
+#else
+#define APP_FILEFLAGS STD_FILEFLAGS
+#endif
+
+
+IDI_MAINICON ICON "jboss.ico"
+
+1 VERSIONINFO
+ FILEVERSION CSV_VERISON
+ PRODUCTVERSION CSV_VERISON
+ FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
+ FILEFLAGS APP_FILEFLAGS
+ FILEOS VOS_NT
+ FILETYPE VFT_APP
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "Comments", STR_LICENSE "\0"
+ VALUE "CompanyName", STR_COMPANY "\0"
+ VALUE "FileDescription", STR_PRODUCT "\0"
+ VALUE "FileVersion", STR_VERISON "\0"
+ VALUE "InternalName", "jreflect"
+ VALUE "LegalCopyright", STR_COPYRIGHT "\0"
+ VALUE "LegalTrademarks", STR_TRADEMARK "\0"
+ VALUE "OriginalFilename", "jreflect.dll"
+ VALUE "ProductName", STR_PRODUCT "\0"
+ VALUE "ProductVersion", STR_VERISON "\0"
+#if PRIVATE_BUILD
+ VALUE "PrivateBuild", STR_PRIVATE "\0"
+ VALUE "SpecialBuild", STR_SPECIAL "\0"
+#endif
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+END
Added: sandbox/nswrap/README.txt
===================================================================
--- sandbox/nswrap/README.txt (rev 0)
+++ sandbox/nswrap/README.txt 2007-05-10 13:20:49 UTC (rev 52)
@@ -0,0 +1,13 @@
+This directory contains both the native and java-side code for
+NSWRAP. (Native Servlet Wrapper).
+
+
+Building
+========
+ant
+To build the native part see native/BUILDING
+
+Running the examples
+====================
+before running the examples you may have to set LD_LIBRARY_PATH, something like
+LD_LIBRARY_PATH=/opt/nswrap/lib; export LD_LIBRARY_PATH
Property changes on: sandbox/nswrap/README.txt
___________________________________________________________________
Name: svn:eol-style
+ native
Added: sandbox/nswrap/native/NMAKEmakefile
===================================================================
--- sandbox/nswrap/native/NMAKEmakefile (rev 0)
+++ sandbox/nswrap/native/NMAKEmakefile 2007-05-10 13:20:49 UTC (rev 52)
@@ -0,0 +1,81 @@
+# Copyright 2001-2006 The Apache Software Foundation or its licensors, as
+# applicable.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#
http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ====================================================================
+#
+# NMAKEmakefile Master NSWRAP makefile.
+# Usage:
+# DEBUG=1 Build DEBUG version of SIGHT
+#
+# Originally contributed by Mladen Turk <mturk jboss.com>
+#
+# ====================================================================
+#
+
+TARGET = DLL
+PROJECT = nswrap
+!include <../../build/NMAKEcommon.inc>
+
+CFLAGS = $(CFLAGS) -DNSW_DECLARE_EXPORT
+
+!IF !DEFINED(SRCDIR) || "$(SRCDIR)" == ""
+SRCDIR = .
+!ENDIF
+
+INCLUDES = -I$(SRCDIR)/include $(JAVA_INCLUDES)
+
+PDBFLAGS = -Fo$(BUILDIR)\ -Fd$(BUILDIR)\$(PROJECT)-src
+OBJECTS = \
+ $(BUILDIR)\nswrap.obj
+
+BUILDLIB = $(BUILDIR)\$(PROJECT).dll
+BUILDPDB = $(BUILDIR)\$(PROJECT).pdb
+BUILDRES = $(BUILDIR)\$(PROJECT).res
+BUILDMAN = $(BUILDLIB).manifest
+
+all : $(BUILDIR) $(BUILDLIB)
+
+$(BUILDIR) :
+ @$(MAKETARGET)
+
+{$(SRCDIR)/src}.c{$(BUILDIR)}.obj:
+ $(CC) $(CFLAGS) $(INCLUDES) $(PDBFLAGS) $<
+
+$(OBJECTS): $(SRCDIR)/include/*.h
+
+$(BUILDRES): $(SRCDIR)/src/nswrap.rc $(SRCDIR)/include/*.h
+ $(RC) $(RCFLAGS) /i "$(SRCDIR)/include" /fo $(BUILDRES)
$(SRCDIR)/src/nswrap.rc
+
+$(BUILDLIB): $(BUILDIR) $(OBJECTS) $(BUILDRES)
+ $(LINK) $(LFLAGS) $(OBJECTS) $(BUILDRES) $(LIBS) $(LDIRS) /pdb:$(BUILDPDB)
/out:$(BUILDLIB)
+ IF EXIST $(BUILDMAN) \
+ mt -nologo -manifest $(BUILDMAN) -outputresource:$(BUILDLIB);2
+
+clean:
+ @$(CLEANTARGET)
+
+!IFNDEF INSTALLNAME
+INSTALLNAME = windows-$(CPU)
+!ENDIF
+
+!IFNDEF INSTALLDIR
+INSTALLLOC = ..\..\dist\$(INSTALLNAME)\bin\native\
+!ENDIF
+
+install: all
+ @$(MAKEINSTALL)
+ @xcopy "$(BUILDLIB)" $(INSTALLLOC) /Q /Y > NUL
+ @IF "EXIST $(CRT_REDIST)\msvcr80.dll" \
+ xcopy $(CRT_REDIST)\* $(INSTALLLOC)\ /E /R /Q /Y > NUL
Added: sandbox/nswrap/native/include/nswrap.h
===================================================================
--- sandbox/nswrap/native/include/nswrap.h (rev 0)
+++ sandbox/nswrap/native/include/nswrap.h 2007-05-10 13:20:49 UTC (rev 52)
@@ -0,0 +1,562 @@
+/*
+ * NSWRAP - Native Servlet Wrapper
+ *
+ * Copyright(c) 2007 Red Hat Middleware, LLC,
+ * and individual contributors as indicated by the @authors tag.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * @author Mladen Turk
+ *
+ */
+
+#ifndef NSWRAP_H
+#define NSWRAP_H
+
+#if defined(WIN32)
+/* Ignore most warnings (back down to /W3) for poorly constructed headers
+ */
+#if defined(_MSC_VER) && _MSC_VER >= 1200
+#pragma warning(push, 3)
+#endif
+
+/* disable or reduce the frequency of...
+ * C4057: indirection to slightly different base types
+ * C4075: slight indirection changes (unsigned short* vs short[])
+ * C4100: unreferenced formal parameter
+ * C4127: conditional expression is constant
+ * C4163: '_rotl64' : not available as an intrinsic function
+ * C4201: nonstandard extension nameless struct/unions
+ * C4244: int to char/short - precision loss
+ * C4514: unreferenced inline function removed
+ */
+#pragma warning(disable: 4100 4127 4163 4201 4514; once: 4057 4075 4244)
+
+/* Ignore Microsoft's interpretation of secure development
+ * and the POSIX string handling API
+ */
+#if defined(_MSC_VER) && _MSC_VER >= 1400
+#ifndef _CRT_SECURE_NO_DEPRECATE
+#define _CRT_SECURE_NO_DEPRECATE
+#endif
+#pragma warning(disable: 4996)
+#endif
+
+/* Has windows.h already been included? If so, our preferences don't matter,
+ * but we will still need the winsock things no matter what was included.
+ * If not, include a restricted set of windows headers to our tastes.
+ */
+#ifndef _WINDOWS_
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN
+#endif
+#ifndef _WIN32_WINNT
+
+/* Restrict the server to a subset of Windows NT 5.0 header files by default
+ */
+#define _WIN32_WINNT 0x0500
+#endif
+#ifndef NOUSER
+#define NOUSER
+#endif
+#ifndef NOMCX
+#define NOMCX
+#endif
+#ifndef NOIME
+#define NOIME
+#endif
+#include <windows.h>
+#endif /* !_WINDOWS_ */
+
+#ifndef __attribute__
+#define __attribute__(__x)
+#endif
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <stddef.h>
+
+#else /* !WIN32 */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+
+/* So that we can use inline on some critical functions, and use
+ * GNUC attributes (such as to get -Wall warnings for printf-like
+ * functions). Only do this in gcc 2.7 or later ... it may work
+ * on earlier stuff, but why chance it.
+ *
+ * We've since discovered that the gcc shipped with NeXT systems
+ * as "cc" is completely broken. It claims to be __GNUC__ and so
+ * on, but it doesn't implement half of the things that __GNUC__
+ * means. In particular it's missing inline and the __attribute__
+ * stuff. So we hack around it. PR#1613. -djg
+ */
+#if !defined(__GNUC__) || __GNUC__ < 2 || \
+ (__GNUC__ == 2 && __GNUC_MINOR__ < 7) || \
+ defined(NEXT)
+#ifndef __attribute__
+#define __attribute__(__x)
+#endif
+#endif
+
+#endif /* WIN32 */
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @file nswrap.h
+ * @brief
+ *
+ * NSWRAP Public API
+ */
+
+
+#if !defined(WIN32)
+
+/**
+ * The public NSW functions are declared with NSW_DECLARE(), so they may
+ * use the most appropriate calling convention. Public NSW functions with
+ * variable arguments must use NSW_DECLARE_NONSTD().
+ *
+ * @remark Both the declaration and implementations must use the same macro.
+ * @example
+ */
+
+/** NSW_DECLARE(rettype) nsw_func(args)
+ * @see NSW_DECLARE_NONSTD @see NSW_DECLARE_DATA
+ * @remark Note that when NSW compiles the library itself, it passes the
+ * symbol -DNSW_DECLARE_EXPORT to the compiler on some platforms (e.g. Win32)
+ * to export public symbols from the dynamic library build.\n
+ * The user must define the NSW_DECLARE_STATIC when compiling to target
+ * the static NSW library on some platforms (e.g. Win32.) The public symbols
+ * are neither exported nor imported when NSW_DECLARE_STATIC is defined.\n
+ * By default, compiling an application and including the NSW public
+ * headers, without defining NSW_DECLARE_STATIC, will prepare the code to be
+ * linked to the dynamic library.
+ */
+#define NSW_DECLARE(type) type
+
+/**
+ * The public NSW functions using variable arguments are declared with
+ * NSW_DECLARE_NONSTD(), as they must follow the C language calling convention.
+ * @see NSW_DECLARE @see NSW_DECLARE_DATA
+ * @remark Both the declaration and implementations must use the same macro.
+ * @example
+ */
+/** NSW_DECLARE_NONSTD(rettype) nsw_func(args, ...);
+ */
+#define NSW_DECLARE_NONSTD(type) type
+
+/**
+ * The public NSW variables are declared with AP_MODULE_DECLARE_DATA.
+ * This assures the appropriate indirection is invoked at compile time.
+ * @see NSW_DECLARE @see NSW_DECLARE_NONSTD
+ * @remark Note that the declaration and implementations use different forms,
+ * but both must include the macro.
+ * @example
+ */
+/**
+ * extern NSW_DECLARE_DATA type nsw_variable;\n
+ * NSW_DECLARE_DATA type nsw_variable = value;
+ */
+#define NSW_DECLARE_DATA
+
+#elif defined(NSW_DECLARE_STATIC)
+#define NSW_DECLARE(type) type __stdcall
+#define NSW_DECLARE_NONSTD(type) type __cdecl
+#define NSW_DECLARE_DATA
+#elif defined(NSW_DECLARE_EXPORT)
+#define NSW_DECLARE(type) __declspec(dllexport) type __stdcall
+#define NSW_DECLARE_NONSTD(type) __declspec(dllexport) type __cdecl
+#define NSW_DECLARE_DATA __declspec(dllexport)
+#else
+#define NSW_DECLARE(type) __declspec(dllimport) type __stdcall
+#define NSW_DECLARE_NONSTD(type) __declspec(dllimport) type __cdecl
+#define NSW_DECLARE_DATA __declspec(dllimport)
+#endif
+
+
+#define NSW_CLASS_PATH "org/jboss/nswrap/"
+#define UNREFERENCED(P) (P) = (P)
+#define UNREFERENCED_STDARGS _E = _E; _O = _O
+#define UNREFERENCED_O _O = _O
+#if defined(WIN32)
+#define LLT(X) (X)
+#else
+#define LLT(X) ((long)(X))
+#endif
+#define P2J(P) ((jlong)LLT(P))
+#define J2P(P, T) ((T)LLT((jlong)P))
+#define V2P(T, V) ((T)((T)0 + (V)))
+#define V2Z(V) ((V) ? JNI_TRUE : JNI_FALSE)
+
+#define NSW_STDARGS JNIEnv *_E, jobject _O
+
+
+#define NSW_EXPORT_DECLARE(RT, CL, FN) \
+ JNIEXPORT RT JNICALL Java_org_jboss_nswrap_##CL##_##FN
+
+#define NSW_EXPORT_GET(RT, CL, FN) \
+ JNIEXPORT RT JNICALL Java_org_jboss_nswrap_##CL##_get##FN
+#define NSW_EXPORT_GETI(CL, FN) \
+ JNIEXPORT jint JNICALL Java_org_jboss_nswrap_##CL##_get##FN
+#define NSW_EXPORT_GETJ(CL, FN) \
+ JNIEXPORT jlong JNICALL Java_org_jboss_nswrap_##CL##_get##FN
+#define NSW_EXPORT_GETS(CL, FN) \
+ JNIEXPORT jstring JNICALL Java_org_jboss_nswrap_##CL##_get##FN
+#define NSW_EXPORT_GETD(CL, FN) \
+ JNIEXPORT jdouble JNICALL Java_org_jboss_nswrap_##CL##_get##FN
+#define NSW_EXPORT_GETZ(CL, FN) \
+ JNIEXPORT jboolean JNICALL Java_org_jboss_nswrap_##CL##_get##FN
+
+#define J2S(V) _c##V
+#define J2T(T) (time_t)((T))
+#define NSW_CC const char
+#define NSW_BEGIN_MACRO if (1) {
+#define NSW_END_MACRO } else (void)(0)
+
+#define NSW_ALLOC_CSTRING(V) \
+ NSW_CC *_c##V = V ? (NSW_CC *)((*_E)->GetStringUTFChars(_E, V, 0)) : NULL
+
+#define NSW_INIT_CSTRING(V)
+
+#define NSW_FREE_CSTRING(V) \
+ if (_c##V) (*_E)->ReleaseStringUTFChars(_E, V, _c##V)
+
+
+#define NSW_CSTR_TO_JSTRING(V) (*_E)->NewStringUTF((_E), (V))
+
+#define NSW_RETURN_JCSTR(V) \
+ if ((V)) return (*_E)->NewStringUTF((_E), (V)); \
+ else return NULL
+
+#define NSW_IS_JOBJECT_NULL(E, O) \
+ (!(O) || ((*(E))->IsSameObject((E), (O), NULL) == JNI_TRUE))
+
+#define NSW_IS_JOBJECT_VALID(E, O) \
+ ((O) && !((*(E))->IsSameObject((E), (O), NULL) == JNI_TRUE))
+
+typedef struct NSW_JC_ID {
+ jclass i;
+ jclass a;
+ const char *n;
+} NSW_JC_ID;
+
+typedef struct NSW_JM_ID {
+ jmethodID i;
+ const char *n;
+ const char *s;
+} NSW_JM_ID;
+
+typedef struct NSW_JF_ID {
+ jfieldID i;
+ const char *n;
+ const char *s;
+} NSW_JF_ID;
+
+#define NSW_CLASS_LDEF(CL) \
+ int nsw_class_##CL##_load(JNIEnv *_E)
+
+#define NSW_CLASS_UDEF(CL) \
+ void nsw_class_##CL##_unload(JNIEnv *_E)
+
+#define NSW_CLASS_LDEC(CL) \
+ extern int nsw_class_##CL##_load(JNIEnv *); \
+ extern int nsw_class_##CL##_unload(JNIEnv *)
+
+#define NSW_CLASS_LCAL(CL) \
+ if (nsw_class_##CL##_load(_E)) return 1;
+
+
+#define NSW_CLASS_UCAL(CL) \
+ nsw_class_##CL##_unload(_E)
+
+#define NSW_DECLARE_CLAZZ static NSW_JC_ID _clazzn
+#define NSW_DECLARE_F_ID(I) static NSW_JF_ID _f##I##n
+#define NSW_DECLARE_M_ID(I) static NSW_JM_ID _m##I##n
+
+#define NSW_LOAD_METHOD(I) \
+ if (_m##I##n.i == NULL) { \
+ _m##I##n.i = (*_E)->GetMethodID(_E, _clazzn.i, _m##I##n.n, \
+ _m##I##n.s); \
+ if ((*_E)->ExceptionCheck(_E) || _m##I##n.i == NULL) { \
+ return 1; \
+ } \
+ } else (void)(0)
+
+#define NSW_LOAD_IFIELD(I) \
+ if (_f##I##n.i == NULL) { \
+ _f##I##n.i = (*_E)->GetFieldID(_E, _clazzn.i, _f##I##n.n, \
+ _f##I##n.s); \
+ if ((*_E)->ExceptionCheck(_E) || _f##I##n.i == NULL) { \
+ return 1; \
+ } \
+ } else (void)(0)
+
+#define NSW_SET_IFIELD_J(I, O, V) \
+ if (_f##I##n.i) { \
+ (*_E)->SetLongField(_E, (O), _f##I##n.i, (jlong)(V)); \
+ } else (void)(0)
+
+#define NSW_SET_IFIELD_I(I, O, V) \
+ if (_f##I##n.i) { \
+ (*_E)->SetIntField(_E, (O), _f##I##n.i, (jint)(V)); \
+ } else (void)(0)
+
+#define NSW_SET_IFIELD_D(I, O, V) \
+ if (_f##I##n.i) { \
+ (*_E)->SetDoubleField(_E, (O), _f##I##n.i, (jdouble)(V)); \
+ } else (void)(0)
+
+#define NSW_SET_IFIELD_Z(I, O, V) \
+ if (_f##I##n.i) { \
+ if ((V)) (*_E)->SetBooleanField(_E, (O), _f##I##n.i, JNI_TRUE); \
+ else (*_E)->SetBooleanField(_E, (O), _f##I##n.i, JNI_FALSE); \
+ } else (void)(0)
+
+#define NSW_SET_IFIELD_S(I, O, V) \
+ if (_f##I##n.i && (V)) { \
+ jstring _str = (*_E)->NewStringUTF(_E, (V)); \
+ (*_E)->SetObjectField(_E, (O), _f##I##n.i, _str); \
+ (*_E)->DeleteLocalRef(_E, _str); \
+ } else (void)(0)
+
+#define NSW_SET_IFIELD_O(I, O, V) \
+ if (_f##I##n.i) { \
+ (*_E)->SetObjectField(_E, (O), _f##I##n.i, (jobject)(V)); \
+ } else (void)(0)
+
+#define NSW_CALL_METHOD1(I, O, V) \
+ if (_m##I##n.i) { \
+ (*_E)->CallVoidMethod(_E, (O), _m##I##n.i, (V), NULL); \
+ } else (void)(0)
+
+#define NSW_CALL_METHOD2(I, O, V, X) \
+ if (_m##I##n.i) { \
+ (*_E)->CallVoidMethod(_E, (O), _m##I##n.i, (V), (X), NULL); \
+ } else (void)(0)
+
+#define NSW_CALL_METHOD3(I, O, V, X, Y) \
+ if (_m##I##n.i) { \
+ (*_E)->CallVoidMethod(_E, (O), _m##I##n.i, (V), (X), (Y), NULL); \
+ } else (void)(0)
+
+
+/* Standard Java classes */
+typedef enum {
+ NSW_CC_OBJECT,
+ NSW_CC_STRING,
+ NSW_CC_ZARRAY,
+ NSW_CC_BARRAY,
+ NSW_CC_CARRAY,
+ NSW_CC_IARRAY,
+ NSW_CC_JARRAY,
+ NSW_CC_TARRAY,
+ NSW_CC_OARRAY,
+ NSW_CC_MAX
+} nsw_cclass_e;
+
+
+NSW_DECLARE(jobjectArray) nsw_new_cc_array(JNIEnv *, nsw_cclass_e, jsize);
+NSW_DECLARE(jbyteArray) nsw_new_byte_array(JNIEnv *, jbyte *, jsize);
+
+/**
+ * Get current JNIEnv
+ * If this is a thread not created by JVM attach the thread
+ */
+NSW_DECLARE(JNIEnv *) nsw_get_jnienv(void);
+
+/**
+ * Memory allocation routines
+ */
+NSW_DECLARE(void *) nsw_malloc(jint);
+NSW_DECLARE(void *) nsw_calloc(jint);
+NSW_DECLARE(void) nsw_free(void *);
+
+/**
+ * Convenience function to help throw an java.io.IOException.
+ */
+NSW_DECLARE(void) nsw_throw_io_exception(const char *);
+
+/**
+ * Convenience function to help throw an javax.servlet.ServletException.
+ */
+NSW_DECLARE(void) nsw_throw_servlet_exception(const char *);
+
+
+/**
+ * @defgroup HTTP_Status HTTP Status Codes
+ * @{
+ */
+/**
+ * The size of the static array in http_protocol.c for storing
+ * all of the potential response status-lines (a sparse table).
+ * A future version should dynamically generate the apr_table_t at startup.
+ */
+#define RESPONSE_CODES 57
+
+#define HTTP_CONTINUE 100
+#define HTTP_SWITCHING_PROTOCOLS 101
+#define HTTP_PROCESSING 102
+#define HTTP_OK 200
+#define HTTP_CREATED 201
+#define HTTP_ACCEPTED 202
+#define HTTP_NON_AUTHORITATIVE 203
+#define HTTP_NO_CONTENT 204
+#define HTTP_RESET_CONTENT 205
+#define HTTP_PARTIAL_CONTENT 206
+#define HTTP_MULTI_STATUS 207
+#define HTTP_MULTIPLE_CHOICES 300
+#define HTTP_MOVED_PERMANENTLY 301
+#define HTTP_MOVED_TEMPORARILY 302
+#define HTTP_SEE_OTHER 303
+#define HTTP_NOT_MODIFIED 304
+#define HTTP_USE_PROXY 305
+#define HTTP_TEMPORARY_REDIRECT 307
+#define HTTP_BAD_REQUEST 400
+#define HTTP_UNAUTHORIZED 401
+#define HTTP_PAYMENT_REQUIRED 402
+#define HTTP_FORBIDDEN 403
+#define HTTP_NOT_FOUND 404
+#define HTTP_METHOD_NOT_ALLOWED 405
+#define HTTP_NOT_ACCEPTABLE 406
+#define HTTP_PROXY_AUTHENTICATION_REQUIRED 407
+#define HTTP_REQUEST_TIME_OUT 408
+#define HTTP_CONFLICT 409
+#define HTTP_GONE 410
+#define HTTP_LENGTH_REQUIRED 411
+#define HTTP_PRECONDITION_FAILED 412
+#define HTTP_REQUEST_ENTITY_TOO_LARGE 413
+#define HTTP_REQUEST_URI_TOO_LARGE 414
+#define HTTP_UNSUPPORTED_MEDIA_TYPE 415
+#define HTTP_RANGE_NOT_SATISFIABLE 416
+#define HTTP_EXPECTATION_FAILED 417
+#define HTTP_UNPROCESSABLE_ENTITY 422
+#define HTTP_LOCKED 423
+#define HTTP_FAILED_DEPENDENCY 424
+#define HTTP_UPGRADE_REQUIRED 426
+#define HTTP_INTERNAL_SERVER_ERROR 500
+#define HTTP_NOT_IMPLEMENTED 501
+#define HTTP_BAD_GATEWAY 502
+#define HTTP_SERVICE_UNAVAILABLE 503
+#define HTTP_GATEWAY_TIME_OUT 504
+#define HTTP_VERSION_NOT_SUPPORTED 505
+#define HTTP_VARIANT_ALSO_VARIES 506
+#define HTTP_INSUFFICIENT_STORAGE 507
+#define HTTP_NOT_EXTENDED 510
+
+/** is the status code informational */
+#define nsw_is_HTTP_INFO(x) (((x) >= 100)&&((x) < 200))
+/** is the status code OK ?*/
+#define nsw_is_HTTP_SUCCESS(x) (((x) >= 200)&&((x) < 300))
+/** is the status code a redirect */
+#define nsw_is_HTTP_REDIRECT(x) (((x) >= 300)&&((x) < 400))
+/** is the status code a error (client or server) */
+#define nsw_is_HTTP_ERROR(x) (((x) >= 400)&&((x) < 600))
+/** is the status code a client error */
+#define nsw_is_HTTP_CLIENT_ERROR(x) (((x) >= 400)&&((x) < 500))
+/** is the status code a server error */
+#define nsw_is_HTTP_SERVER_ERROR(x) (((x) >= 500)&&((x) < 600))
+
+/** should the status code drop the connection */
+#define nsw_status_drops_connection(x) \
+ (((x) == HTTP_BAD_REQUEST) || \
+ ((x) == HTTP_REQUEST_TIME_OUT) || \
+ ((x) == HTTP_LENGTH_REQUIRED) || \
+ ((x) == HTTP_REQUEST_ENTITY_TOO_LARGE) || \
+ ((x) == HTTP_REQUEST_URI_TOO_LARGE) || \
+ ((x) == HTTP_INTERNAL_SERVER_ERROR) || \
+ ((x) == HTTP_SERVICE_UNAVAILABLE) || \
+ ((x) == HTTP_NOT_IMPLEMENTED))
+
+
+/** @} */
+/**
+ * @defgroup Methods List of Methods recognized by the server
+ * @{
+ */
+/**
+ * Methods recognized (but not necessarily handled) by the server.
+ * These constants are used in bit shifting masks of size int, so it is
+ * unsafe to have more methods than bits in an int. HEAD == M_GET.
+ * This list must be tracked by the list in http_protocol.c in routine
+ * ap_method_name_of().
+ */
+#define M_GET 0 /* RFC 2616: HTTP */
+#define M_PUT 1 /* : */
+#define M_POST 2
+#define M_DELETE 3
+#define M_CONNECT 4
+#define M_OPTIONS 5
+#define M_TRACE 6 /* RFC 2616: HTTP */
+#define M_PATCH 7 /* no rfc(!) ### remove this one? */
+#define M_PROPFIND 8 /* RFC 2518: WebDAV */
+#define M_PROPPATCH 9 /* : */
+#define M_MKCOL 10
+#define M_COPY 11
+#define M_MOVE 12
+#define M_LOCK 13
+#define M_UNLOCK 14 /* RFC 2518: WebDAV */
+#define M_VERSION_CONTROL 15 /* RFC 3253: WebDAV Versioning */
+#define M_CHECKOUT 16 /* : */
+#define M_UNCHECKOUT 17
+#define M_CHECKIN 18
+#define M_UPDATE 19
+#define M_LABEL 20
+#define M_REPORT 21
+#define M_MKWORKSPACE 22
+#define M_MKACTIVITY 23
+#define M_BASELINE_CONTROL 24
+#define M_MERGE 25
+#define M_INVALID 26 /* RFC 3253: WebDAV Versioning */
+
+/**
+ * METHODS needs to be equal to the number of bits
+ * we are using for limit masks.
+ */
+#define METHODS 64
+
+/**
+ * Get the method number associated with the given string, assumed to
+ * contain an HTTP method. Returns M_INVALID if not recognized.
+ *
+ * This is the first step toward placing method names in a configurable
+ * list.
+ */
+NSW_DECLARE(int) nsw_method_number_of(const char *);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+/* Done with badly written headers
+ */
+#if defined(_MSC_VER) && _MSC_VER >= 1200
+#pragma warning(pop)
+#pragma warning(disable: 4996)
+#endif
+
+#endif /* NSWRAP_H */
Property changes on: sandbox/nswrap/native/include/nswrap.h
___________________________________________________________________
Name: svn:eol-style
+ native
Added: sandbox/nswrap/native/src/jboss.ico
===================================================================
(Binary files differ)
Property changes on: sandbox/nswrap/native/src/jboss.ico
___________________________________________________________________
Name: svn:mime-type
+ image/x-icon
Added: sandbox/nswrap/native/src/nswrap.c
===================================================================
--- sandbox/nswrap/native/src/nswrap.c (rev 0)
+++ sandbox/nswrap/native/src/nswrap.c 2007-05-10 13:20:49 UTC (rev 52)
@@ -0,0 +1,582 @@
+/*
+ * NSWRAP - Native Servlet Wrapper
+ *
+ * Copyright(c) 2007 Red Hat Middleware, LLC,
+ * and individual contributors as indicated by the @authors tag.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * @author Mladen Turk
+ *
+ */
+
+#include "nswrap.h"
+
+static JavaVM *nsw_global_vm = NULL;
+static int nsw_initalized = 0;
+
+#define STD_GLOBAL_JCLASSES NSW_CC_MAX
+static jclass global_classes[STD_GLOBAL_JCLASSES];
+
+typedef struct nsw_env_t {
+ JNIEnv *env;
+ int emode;
+} nsw_env_t;
+
+#if defined(WIN32)
+
+static DWORD dll_tls_index = 0;
+
+BOOL APIENTRY DllMain(HINSTANCE instance,
+ DWORD ul_reason_for_call,
+ LPVOID lpReserved)
+{
+ nsw_env_t *tls_data;
+
+ switch (ul_reason_for_call) {
+ case DLL_PROCESS_ATTACH:
+ /* Allocate a TLS index. */
+ if ((dll_tls_index = TlsAlloc()) == TLS_OUT_OF_INDEXES)
+ return FALSE;
+ break;
+ case DLL_THREAD_ATTACH:
+ break;
+ case DLL_THREAD_DETACH:
+ case DLL_PROCESS_DETACH:
+ tls_data = (nsw_env_t *)TlsGetValue(dll_tls_index);
+ if (tls_data != NULL) {
+ if (nsw_global_vm != NULL && tls_data->emode == JNI_EDETACHED)
{
+ (*nsw_global_vm)->DetachCurrentThread(nsw_global_vm);
+ }
+ LocalFree(tls_data);
+ }
+ break;
+ }
+ return TRUE;
+}
+
+#else /* !WIN32 */
+
+static pthread_key_t pthread_jenv_key = NULL;
+
+static void jenv_destructor(void *data)
+{
+ jpr_env_t *e = (jpr_env_t *)data;
+ if (e) {
+ if (e->env && e->emode == JNI_EDETACHED) {
+ (*nsw_global_vm)->DetachCurrentThread(nsw_global_vm)
+ }
+ free(e);
+ }
+}
+
+#endif /* WIN32 */
+
+static int load_class(JNIEnv *e, NSW_JC_ID *clazz)
+{
+ jobject c;
+ char an[1024];
+
+ if (clazz->i != NULL) {
+ return 0;
+ }
+ if ((*e)->EnsureLocalCapacity(e, 3) < 0)
+ goto failed;
+ c = (jobject)(*e)->FindClass(e, clazz->n);
+ if ((*e)->ExceptionCheck(e) || c == NULL) {
+ goto failed;
+ }
+ clazz->i = (jclass)(*e)->NewGlobalRef(e, c);
+ if ((*e)->ExceptionCheck(e) || clazz->i == NULL) {
+ clazz->i = NULL;
+ goto failed;
+ }
+ (*e)->DeleteLocalRef(e, c);
+
+ /* Init class array */
+ sprintf(an, "L%s;", clazz->n);
+ c = (jobject)(*e)->FindClass(e, an);
+ if ((*e)->ExceptionCheck(e) || c == NULL) {
+ goto failed;
+ }
+ clazz->a = (jclass)(*e)->NewGlobalRef(e, c);
+ if ((*e)->ExceptionCheck(e) || clazz->a == NULL) {
+ clazz->a = NULL;
+ goto failed;
+ }
+ return 0;
+
+failed:
+ if (clazz->i != NULL) {
+ (*e)->DeleteGlobalRef(e, clazz->i);
+ clazz->i = NULL;
+ }
+ return -1;
+
+}
+
+static void unload_class(JNIEnv *e, NSW_JC_ID *clazz)
+{
+ if (clazz->i != NULL) {
+ (*e)->DeleteGlobalRef(e, clazz->i);
+ clazz->i = NULL;
+ }
+ if (clazz->a != NULL) {
+ (*e)->DeleteGlobalRef(e, clazz->a);
+ clazz->a = NULL;
+ }
+}
+
+static void init_java_rt(JNIEnv *e)
+{
+ jobject c;
+ int i;
+ for (i = 0; i < STD_GLOBAL_JCLASSES; i++)
+ global_classes[i] = NULL;
+
+ c = (jobject)(*e)->FindClass(e, "Ljava/lang/Object;");
+ global_classes[NSW_CC_OBJECT] = (jclass)(*e)->NewGlobalRef(e, c);
+ (*e)->DeleteLocalRef(e, c);
+ c = (jobject)(*e)->FindClass(e, "Ljava/lang/String;");
+ global_classes[NSW_CC_STRING] = (jclass)(*e)->NewGlobalRef(e, c);
+ (*e)->DeleteLocalRef(e, c);
+ /* [][] Core Arrays */
+ c = (jobject)(*e)->FindClass(e, "[Z");
+ global_classes[NSW_CC_ZARRAY] = (jclass)(*e)->NewGlobalRef(e, c);
+ (*e)->DeleteLocalRef(e, c);
+ c = (jobject)(*e)->FindClass(e, "[B");
+ global_classes[NSW_CC_BARRAY] = (jclass)(*e)->NewGlobalRef(e, c);
+ (*e)->DeleteLocalRef(e, c);
+ c = (jobject)(*e)->FindClass(e, "[C");
+ global_classes[NSW_CC_CARRAY] = (jclass)(*e)->NewGlobalRef(e, c);
+ (*e)->DeleteLocalRef(e, c);
+ c = (jobject)(*e)->FindClass(e, "[I");
+ global_classes[NSW_CC_IARRAY] = (jclass)(*e)->NewGlobalRef(e, c);
+ (*e)->DeleteLocalRef(e, c);
+ c = (jobject)(*e)->FindClass(e, "[J");
+ global_classes[NSW_CC_JARRAY] = (jclass)(*e)->NewGlobalRef(e, c);
+ (*e)->DeleteLocalRef(e, c);
+ c = (jobject)(*e)->FindClass(e, "[Ljava/lang/String;");
+ global_classes[NSW_CC_TARRAY] = (jclass)(*e)->NewGlobalRef(e, c);
+ (*e)->DeleteLocalRef(e, c);
+ c = (jobject)(*e)->FindClass(e, "[Ljava/lang/Object;");
+ global_classes[NSW_CC_OARRAY] = (jclass)(*e)->NewGlobalRef(e, c);
+ (*e)->DeleteLocalRef(e, c);
+
+}
+
+jclass nsw_get_cc(nsw_cclass_e i)
+{
+ if (i > 0 && i < NSW_CC_MAX)
+ return global_classes[i];
+ else
+ return NULL;
+}
+
+NSW_DECLARE(jobjectArray) nsw_new_cc_array(JNIEnv *e, nsw_cclass_e i, jsize len)
+{
+ if (i > 0 && i < NSW_CC_MAX)
+ return (*e)->NewObjectArray(e, len, global_classes[i], NULL);
+ else
+ return NULL;
+}
+
+NSW_DECLARE(jbyteArray) nsw_new_byte_array(JNIEnv *e, jbyte *data,
+ jsize len)
+{
+ jbyteArray bytes = (*e)->NewByteArray(e, len);
+ if (bytes != NULL) {
+ (*e)->SetByteArrayRegion(e, bytes, 0, (jint)len, data);
+ }
+ return bytes;
+}
+
+static int load_classes(JNIEnv *_E)
+{
+ return 0;
+}
+
+static void unload_classes(JNIEnv *_E)
+{
+}
+
+/* Called by the JVM when library is loaded */
+JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved)
+{
+ JNIEnv *_E;
+
+ UNREFERENCED(reserved);
+ if ((*vm)->GetEnv(vm, (void **)&_E, JNI_VERSION_1_4)) {
+ return JNI_ERR;
+ }
+ nsw_global_vm = vm;
+#if !defined(WIN32)
+ pthread_key_create(&pthread_jenv_key, jenv_destructor);
+#endif
+
+ /* Initialize all counters to zero */
+ return JNI_VERSION_1_4;
+}
+
+/* Called by the JVM before the library is unloaded */
+JNIEXPORT void JNICALL JNI_OnUnload(JavaVM *vm, void *reserved)
+{
+ JNIEnv *env;
+
+ UNREFERENCED(reserved);
+
+ if ((*vm)->GetEnv(vm, (void **)&env, JNI_VERSION_1_2)) {
+ return;
+ }
+ if (nsw_global_vm) {
+ unload_classes(env);
+ }
+}
+
+NSW_EXPORT_DECLARE(jboolean, Library, init0)(NSW_STDARGS)
+{
+
+ UNREFERENCED_STDARGS;
+ if (!nsw_initalized++) {
+ init_java_rt(_E);
+ if (load_classes(_E)) {
+ unload_classes(_E);
+ return JNI_FALSE;
+ }
+ }
+ return JNI_TRUE;
+}
+
+NSW_EXPORT_DECLARE(void, Library, term0)(NSW_STDARGS)
+{
+
+ UNREFERENCED_STDARGS;
+ if (--nsw_initalized == 0) {
+ unload_classes(_E);
+ }
+}
+
+
+#if defined(WIN32)
+
+/* Get current JNIEnv
+ * If this is a thread not created by JVM attach the thread
+ */
+NSW_DECLARE(JNIEnv *) nsw_get_jnienv()
+{
+ nsw_env_t *e = (nsw_env_t *)TlsGetValue(dll_tls_index);
+
+ if (!e) {
+ if (!(e = (nsw_env_t *)LocalAlloc(LPTR, sizeof(nsw_env_t))))
+ return NULL;
+ e->emode = (*nsw_global_vm)->GetEnv(nsw_global_vm,
+ (void**)&e->env,
+ JNI_VERSION_1_4);
+ if (e->emode == JNI_EDETACHED) {
+ (*nsw_global_vm)->AttachCurrentThread(nsw_global_vm,
+ (void**)&e->env, NULL);
+ }
+ TlsSetValue(dll_tls_index, e);
+ }
+ return e->env;
+}
+
+#else
+
+/* Get current JNIEnv
+ * If this is a thread not created by JVM attach the thread
+ */
+NSW_DECLARE(JNIEnv *) nsw_get_jnienv()
+{
+ nsw_env_t *e = (nsw_env_t *)pthread_getspecific(pthread_jenv_key);
+ if (!e) {
+ if (!(e = (nsw_env_t *)malloc(sizeof(nsw_env_t))))
+ return NULL;
+
+ e->emode = (*nsw_global_vm)->GetEnv(nsw_global_vm,
+ (void**)&e->env,
+ JNI_VERSION_1_4);
+ if (e->emode == JNI_EDETACHED) {
+ (*nsw_global_vm)->AttachCurrentThread(nsw_global_vm,
+ (void**)&e->env, NULL);
+ }
+ pthread_setspecific(pthread_jenv_key, e);
+ }
+ return e->env;
+}
+
+
+#endif
+
+NSW_DECLARE(void *) nsw_malloc(jint size)
+{
+ void * rv = malloc((size_t)size);
+ if (!rv) {
+ /* TODO: Throw exception */
+
+ }
+ return rv;
+}
+
+NSW_DECLARE(void *) nsw_calloc(jint size)
+{
+ void * rv = calloc(1, (size_t)size);
+ if (!rv) {
+ /* TODO: Throw exception */
+
+ }
+ return rv;
+}
+
+NSW_DECLARE(void) nsw_free(void *mem)
+{
+ if (mem) {
+ free(mem);
+ }
+}
+
+/**
+ * Convenience function to help throw an java.io.IOException.
+ */
+NSW_DECLARE(void) nsw_throw_io_exception(const char *msg)
+{
+ JNIEnv *env;
+ jclass cls;
+
+ if (!(env = nsw_get_jnienv())) {
+ fprintf(stderr, "Cannot attach to the JNI Environment\n");
+ return;
+ }
+ cls = (*env)->FindClass(env, "java/io/IOException");
+ if (cls == NULL) {
+ fprintf(stderr, "Cannot find java/io/IOException class\n");
+ }
+ else {
+ (*env)->ThrowNew(env, cls, msg);
+ (*env)->DeleteLocalRef(env, cls);
+ }
+}
+
+/**
+ * Convenience function to help throw an javax.servlet.ServletException.
+ */
+NSW_DECLARE(void) nsw_throw_servlet_exception(const char *msg)
+{
+ JNIEnv *env;
+ jclass cls;
+
+ if (!(env = nsw_get_jnienv())) {
+ fprintf(stderr, "Cannot attach to the JNI Environment\n");
+ return;
+ }
+
+ cls = (*env)->FindClass(env, "javax/servlet/ServletException");
+ if (cls == NULL) {
+ fprintf(stderr, "Cannot find javax/servlet/ServletException class\n");
+ }
+ else {
+ (*env)->ThrowNew(env, cls, msg);
+ (*env)->DeleteLocalRef(env, cls);
+ }
+}
+
+#define UNKNOWN_METHOD (-1)
+
+static int lookup_builtin_method(const char *method, size_t len)
+{
+ /* Note: the following code was generated by the "shilka" tool from
+ the "cocom" parsing/compilation toolkit. It is an optimized lookup
+ based on analysis of the input keywords. Postprocessing was done
+ on the shilka output, but the basic structure and analysis is
+ from there. Should new HTTP methods be added, then manual insertion
+ into this code is fine, or simply re-running the shilka tool on
+ the appropriate input. */
+
+ /* Note: it is also quite reasonable to just use our method_registry,
+ but I'm assuming (probably incorrectly) we want more speed here
+ (based on the optimizations the previous code was doing). */
+
+ switch (len) {
+ case 3:
+ switch (method[0]) {
+ case 'P':
+ return (method[1] == 'U'
+ && method[2] == 'T'
+ ? M_PUT : UNKNOWN_METHOD);
+ case 'G':
+ return (method[1] == 'E'
+ && method[2] == 'T'
+ ? M_GET : UNKNOWN_METHOD);
+ default:
+ return UNKNOWN_METHOD;
+ }
+
+ case 4:
+ switch (method[0]) {
+ case 'H':
+ return (method[1] == 'E'
+ && method[2] == 'A'
+ && method[3] == 'D'
+ ? M_GET : UNKNOWN_METHOD);
+ case 'P':
+ return (method[1] == 'O'
+ && method[2] == 'S'
+ && method[3] == 'T'
+ ? M_POST : UNKNOWN_METHOD);
+ case 'M':
+ return (method[1] == 'O'
+ && method[2] == 'V'
+ && method[3] == 'E'
+ ? M_MOVE : UNKNOWN_METHOD);
+ case 'L':
+ return (method[1] == 'O'
+ && method[2] == 'C'
+ && method[3] == 'K'
+ ? M_LOCK : UNKNOWN_METHOD);
+ case 'C':
+ return (method[1] == 'O'
+ && method[2] == 'P'
+ && method[3] == 'Y'
+ ? M_COPY : UNKNOWN_METHOD);
+ default:
+ return UNKNOWN_METHOD;
+ }
+
+ case 5:
+ switch (method[2]) {
+ case 'T':
+ return (memcmp(method, "PATCH", 5) == 0
+ ? M_PATCH : UNKNOWN_METHOD);
+ case 'R':
+ return (memcmp(method, "MERGE", 5) == 0
+ ? M_MERGE : UNKNOWN_METHOD);
+ case 'C':
+ return (memcmp(method, "MKCOL", 5) == 0
+ ? M_MKCOL : UNKNOWN_METHOD);
+ case 'B':
+ return (memcmp(method, "LABEL", 5) == 0
+ ? M_LABEL : UNKNOWN_METHOD);
+ case 'A':
+ return (memcmp(method, "TRACE", 5) == 0
+ ? M_TRACE : UNKNOWN_METHOD);
+ default:
+ return UNKNOWN_METHOD;
+ }
+
+ case 6:
+ switch (method[0]) {
+ case 'U':
+ switch (method[5]) {
+ case 'K':
+ return (memcmp(method, "UNLOCK", 6) == 0
+ ? M_UNLOCK : UNKNOWN_METHOD);
+ case 'E':
+ return (memcmp(method, "UPDATE", 6) == 0
+ ? M_UPDATE : UNKNOWN_METHOD);
+ default:
+ return UNKNOWN_METHOD;
+ }
+ case 'R':
+ return (memcmp(method, "REPORT", 6) == 0
+ ? M_REPORT : UNKNOWN_METHOD);
+ case 'D':
+ return (memcmp(method, "DELETE", 6) == 0
+ ? M_DELETE : UNKNOWN_METHOD);
+ default:
+ return UNKNOWN_METHOD;
+ }
+
+ case 7:
+ switch (method[1]) {
+ case 'P':
+ return (memcmp(method, "OPTIONS", 7) == 0
+ ? M_OPTIONS : UNKNOWN_METHOD);
+ case 'O':
+ return (memcmp(method, "CONNECT", 7) == 0
+ ? M_CONNECT : UNKNOWN_METHOD);
+ case 'H':
+ return (memcmp(method, "CHECKIN", 7) == 0
+ ? M_CHECKIN : UNKNOWN_METHOD);
+ default:
+ return UNKNOWN_METHOD;
+ }
+
+ case 8:
+ switch (method[0]) {
+ case 'P':
+ return (memcmp(method, "PROPFIND", 8) == 0
+ ? M_PROPFIND : UNKNOWN_METHOD);
+ case 'C':
+ return (memcmp(method, "CHECKOUT", 8) == 0
+ ? M_CHECKOUT : UNKNOWN_METHOD);
+ default:
+ return UNKNOWN_METHOD;
+ }
+
+ case 9:
+ return (memcmp(method, "PROPPATCH", 9) == 0
+ ? M_PROPPATCH : UNKNOWN_METHOD);
+
+ case 10:
+ switch (method[0]) {
+ case 'U':
+ return (memcmp(method, "UNCHECKOUT", 10) == 0
+ ? M_UNCHECKOUT : UNKNOWN_METHOD);
+ case 'M':
+ return (memcmp(method, "MKACTIVITY", 10) == 0
+ ? M_MKACTIVITY : UNKNOWN_METHOD);
+ default:
+ return UNKNOWN_METHOD;
+ }
+
+ case 11:
+ return (memcmp(method, "MKWORKSPACE", 11) == 0
+ ? M_MKWORKSPACE : UNKNOWN_METHOD);
+
+ case 15:
+ return (memcmp(method, "VERSION-CONTROL", 15) == 0
+ ? M_VERSION_CONTROL : UNKNOWN_METHOD);
+
+ case 16:
+ return (memcmp(method, "BASELINE-CONTROL", 16) == 0
+ ? M_BASELINE_CONTROL : UNKNOWN_METHOD);
+
+ default:
+ return UNKNOWN_METHOD;
+ }
+
+ /* NOTREACHED */
+}
+
+/**
+ * Get the method number associated with the given string, assumed to
+ * contain an HTTP method. Returns M_INVALID if not recognized.
+ *
+ * This is the first step toward placing method names in a configurable
+ * list.
+ */
+NSW_DECLARE(int) nsw_method_number_of(const char *method)
+{
+ size_t len = strlen(method);
+ int which = lookup_builtin_method(method, len);
+
+ if (which != UNKNOWN_METHOD)
+ return which;
+
+ return M_INVALID;
+}
Property changes on: sandbox/nswrap/native/src/nswrap.c
___________________________________________________________________
Name: svn:eol-style
+ native
Added: sandbox/nswrap/native/src/nswrap.rc
===================================================================
--- sandbox/nswrap/native/src/nswrap.rc (rev 0)
+++ sandbox/nswrap/native/src/nswrap.rc 2007-05-10 13:20:49 UTC (rev 52)
@@ -0,0 +1,101 @@
+/*
+ * NSWRAP - Native Servlet Wrapper
+ *
+ * Copyright(c) 2007 Red Hat Middleware, LLC,
+ * and individual contributors as indicated by the @authors tag.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * @author Mladen Turk
+ *
+ */
+
+#include <windows.h>
+
+#define STR_COPYRIGHT "Copyright � 2006 Red Hat Middleware, LLC. " \
+ "or its licensors, as applicable."
+
+#define STR_LICENSE "Distributable under LGPL license. " \
+ "See terms of license at gnu.org."
+
+#define STR_COMPANY "Red Hat�, Inc."
+#define STR_TRADEMARK "� Red Hat Inc."
+#define STR_PRODUCT "Native Servlet Wrapper"
+#define STR_VERISON "1.0.0.0"
+#define CSV_VERISON 1,0,0,0
+
+#define PRIVATE_BUILD 0
+#define PRERELEASE_BUILD 0
+
+#if PRIVATE_BUILD
+#define STR_PRIVATE "Initial Prerelease"
+#define STR_SPECIAL "Basic functionality"
+#define STD_FILEFLAGS VS_FF_PRIVATEBUILD | VS_FF_SPECIALBUILD
+#else
+#define STD_FILEFLAGS 0x0L
+#endif
+
+#if RERELEASE_BUILD
+#define PSTD_FILEFLAGS STD_FILEFLAGS | VS_FF_PRERELEASE
+#else
+#define PSTD_FILEFLAGS STD_FILEFLAGS
+#endif
+
+#ifdef _DEBUG
+#define APP_FILEFLAGS STD_FILEFLAGS | VS_FF_DEBUG
+#else
+#define APP_FILEFLAGS STD_FILEFLAGS
+#endif
+
+
+IDI_MAINICON ICON "jboss.ico"
+
+1 VERSIONINFO
+ FILEVERSION CSV_VERISON
+ PRODUCTVERSION CSV_VERISON
+ FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
+ FILEFLAGS APP_FILEFLAGS
+ FILEOS VOS_NT
+ FILETYPE VFT_APP
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "Comments", STR_LICENSE "\0"
+ VALUE "CompanyName", STR_COMPANY "\0"
+ VALUE "FileDescription", STR_PRODUCT "\0"
+ VALUE "FileVersion", STR_VERISON "\0"
+ VALUE "InternalName", "nswrap"
+ VALUE "LegalCopyright", STR_COPYRIGHT "\0"
+ VALUE "LegalTrademarks", STR_TRADEMARK "\0"
+ VALUE "OriginalFilename", "nswrap.dll"
+ VALUE "ProductName", STR_PRODUCT "\0"
+ VALUE "ProductVersion", STR_VERISON "\0"
+#if PRIVATE_BUILD
+ VALUE "PrivateBuild", STR_PRIVATE "\0"
+ VALUE "SpecialBuild", STR_SPECIAL "\0"
+#endif
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+END