You can subscribe to this list here.
| 2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(4) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2003 |
Jan
(54) |
Feb
(71) |
Mar
(93) |
Apr
(48) |
May
(53) |
Jun
(33) |
Jul
(19) |
Aug
(39) |
Sep
(35) |
Oct
(36) |
Nov
(33) |
Dec
(13) |
| 2004 |
Jan
(10) |
Feb
(1) |
Mar
(17) |
Apr
(9) |
May
(40) |
Jun
(132) |
Jul
(133) |
Aug
(178) |
Sep
(104) |
Oct
(31) |
Nov
(80) |
Dec
(18) |
| 2005 |
Jan
(54) |
Feb
(9) |
Mar
(35) |
Apr
(2) |
May
(20) |
Jun
(3) |
Jul
(45) |
Aug
(202) |
Sep
(2) |
Oct
(26) |
Nov
|
Dec
(4) |
| 2006 |
Jan
|
Feb
(7) |
Mar
(8) |
Apr
(66) |
May
(9) |
Jun
(40) |
Jul
(4) |
Aug
(4) |
Sep
|
Oct
|
Nov
(1) |
Dec
(4) |
| 2007 |
Jan
(2) |
Feb
(14) |
Mar
(4) |
Apr
(1) |
May
(5) |
Jun
(5) |
Jul
|
Aug
(8) |
Sep
(3) |
Oct
(7) |
Nov
|
Dec
|
| 2008 |
Jan
(6) |
Feb
|
Mar
(1) |
Apr
(8) |
May
(46) |
Jun
(4) |
Jul
(1) |
Aug
|
Sep
(9) |
Oct
(3) |
Nov
|
Dec
(5) |
| 2009 |
Jan
(9) |
Feb
(2) |
Mar
(3) |
Apr
|
May
(6) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(11) |
| 2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(3) |
Jul
(10) |
Aug
(5) |
Sep
(1) |
Oct
(13) |
Nov
|
Dec
(4) |
| 2012 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(4) |
Jun
|
Jul
|
Aug
|
Sep
(5) |
Oct
|
Nov
|
Dec
|
| 2013 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(2) |
Dec
|
| 2014 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2016 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(5) |
|
From: <jh...@us...> - 2008-09-15 20:04:11
|
Update of /cvsroot/aolserver/havardblog/www In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv18023/www Log Message: Directory /cvsroot/aolserver/havardblog/www added to the repository |
|
From: <jh...@us...> - 2008-09-15 20:03:57
|
Update of /cvsroot/aolserver/havardblog/tcl In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv17699/tcl Log Message: Directory /cvsroot/aolserver/havardblog/tcl added to the repository |
|
From: <as...@us...> - 2008-07-14 22:01:04
|
Update of /cvsroot/aolserver/nsoracle In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv23093 Modified Files: nsoracle.c Log Message: Fix typo in error message. Index: nsoracle.c =================================================================== RCS file: /cvsroot/aolserver/nsoracle/nsoracle.c,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** nsoracle.c 19 Apr 2007 19:33:33 -0000 1.26 --- nsoracle.c 14 Jul 2008 22:01:09 -0000 1.27 *************** *** 2929,2933 **** Ns_OracleFree, 0, 0); ! if (oci_error_p(lexpos(), NULL, "OCIEnvInit", 0, oci_status)) return NS_ERROR; --- 2929,2933 ---- Ns_OracleFree, 0, 0); ! if (oci_error_p(lexpos(), NULL, "OCIEnvCreate", 0, oci_status)) return NS_ERROR; |
|
From: <gne...@us...> - 2008-06-20 08:06:32
|
Update of /cvsroot/aolserver/aolserver/nsproxy In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv8778/nsproxy Modified Files: nsproxylib.c Log Message: remove direct access to interp->result, initializing potentially uninitialized variables Index: nsproxylib.c =================================================================== RCS file: /cvsroot/aolserver/aolserver/nsproxy/nsproxylib.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** nsproxylib.c 11 May 2007 22:11:59 -0000 1.6 --- nsproxylib.c 20 Jun 2008 08:06:33 -0000 1.7 *************** *** 281,285 **** Tcl_Interp *interp; Proc proc; ! int result, len, n, max; Req *reqPtr; Tcl_DString in, out; --- 281,285 ---- Tcl_Interp *interp; Proc proc; ! int result, len, n, max = 0; Req *reqPtr; Tcl_DString in, out; *************** *** 330,334 **** if (init != NULL) { if ((*init)(interp) != TCL_OK) { ! FatalExit(interp->result); } } --- 330,334 ---- if (init != NULL) { if ((*init)(interp) != TCL_OK) { ! FatalExit(Tcl_GetStringResult(interp)); } } *************** *** 1461,1465 **** { Res hdr; ! char *einfo, *ecode, *result; int clen, ilen, rlen; --- 1461,1465 ---- { Res hdr; ! char *einfo = NULL, *ecode = NULL, *result; int clen, ilen, rlen; *************** *** 1899,1905 **** ProxyError(Tcl_Interp *interp, Err err) { ! char *msg, *sysmsg, *code; - sysmsg = NULL; switch (err) { case ENone: --- 1899,1904 ---- ProxyError(Tcl_Interp *interp, Err err) { ! char *msg = NULL, *sysmsg = NULL, *code = NULL; switch (err) { case ENone: |
|
From: <gne...@us...> - 2008-06-20 08:06:32
|
Update of /cvsroot/aolserver/aolserver/nsd In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv8778/nsd Modified Files: tclloop.c tclshare.c Log Message: remove direct access to interp->result, initializing potentially uninitialized variables Index: tclloop.c =================================================================== RCS file: /cvsroot/aolserver/aolserver/nsd/tclloop.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** tclloop.c 2 Jun 2006 18:51:49 -0000 1.2 --- tclloop.c 20 Jun 2008 08:06:32 -0000 1.3 *************** *** 854,858 **** Ns_MutexLock(&servPtr->tcl.llock); if (dataPtr->evalPtr == NULL) { ! Ns_Log(Error, "loopctl: dropped result: %s", interp->result); } else { str = Tcl_GetStringFromObj(Tcl_GetObjResult(interp), &len); --- 854,858 ---- Ns_MutexLock(&servPtr->tcl.llock); if (dataPtr->evalPtr == NULL) { ! Ns_Log(Error, "loopctl: dropped result: %s", Tcl_GetStringResult(interp)); } else { str = Tcl_GetStringFromObj(Tcl_GetObjResult(interp), &len); Index: tclshare.c =================================================================== RCS file: /cvsroot/aolserver/aolserver/nsd/tclshare.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** tclshare.c 1 Aug 2005 20:29:58 -0000 1.6 --- tclshare.c 20 Jun 2008 08:06:32 -0000 1.7 *************** *** 224,228 **** } ! if (strcmp(interp->result, "1") == 0) { /* * Get existing value in variable being shared. --- 224,228 ---- } ! if (strcmp(Tcl_GetStringResult(interp), "1") == 0) { /* * Get existing value in variable being shared. *************** *** 247,251 **** int x; Tcl_InitHashTable(&valuePtr->array, TCL_STRING_KEYS); ! if (Tcl_SplitList(interp, interp->result, &argc, (CONST char***)&argv) == TCL_OK) { for (x = 0; x < argc; x += 2) { --- 247,251 ---- int x; Tcl_InitHashTable(&valuePtr->array, TCL_STRING_KEYS); ! if (Tcl_SplitList(interp, Tcl_GetStringResult(interp), &argc, (CONST char***)&argv) == TCL_OK) { for (x = 0; x < argc; x += 2) { |
|
From: <gne...@us...> - 2008-06-20 08:06:29
|
Update of /cvsroot/aolserver/aolserver In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv8778 Modified Files: ChangeLog Log Message: remove direct access to interp->result, initializing potentially uninitialized variables Index: ChangeLog =================================================================== RCS file: /cvsroot/aolserver/aolserver/ChangeLog,v retrieving revision 1.385 retrieving revision 1.386 diff -C2 -d -r1.385 -r1.386 *** ChangeLog 13 May 2008 21:34:15 -0000 1.385 --- ChangeLog 20 Jun 2008 08:06:26 -0000 1.386 *************** *** 1,2 **** --- 1,12 ---- + 2008-06-20 Gustaf Neumann <ne...@wu...> + + * remove direct access to interp->result in + - nscp/nscp.c + - nsd/tclloop.c + - nsd/tclshare.c + - nsproxy/nsproxylib.c + * initializing potentially uninitialized variables in + - nsproxy/nsproxylib.c + 2008-05-13 Jeff Rogers <dv...@di...> |
|
From: <gne...@us...> - 2008-06-20 08:06:28
|
Update of /cvsroot/aolserver/aolserver/nscp In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv8778/nscp Modified Files: nscp.c Log Message: remove direct access to interp->result, initializing potentially uninitialized variables Index: nscp.c =================================================================== RCS file: /cvsroot/aolserver/aolserver/nscp/nscp.c,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** nscp.c 8 Aug 2005 15:32:34 -0000 1.24 --- nscp.c 20 Jun 2008 08:06:32 -0000 1.25 *************** *** 364,368 **** } Tcl_AppendResult(interp, "\r\n", NULL); ! res = interp->result; len = strlen(res); while (len > 0) { --- 364,368 ---- } Tcl_AppendResult(interp, "\r\n", NULL); ! res = Tcl_GetStringResult(interp); len = strlen(res); while (len > 0) { |
Update of /cvsroot/aolserver/knregistration In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv11750 Added Files: Makefile knregistration-mak.inc knregistration.mak.in knregistration.vs7.vcproj knregistration.vs8.vcproj Log Message: knregistration adds the ability to register procedures, filters, and indirects based on patterns in URIs. Matched portions of these URIs are added to the ns_conn "form" before delivery to the procedure, filter, or indirect request. Requires the knutil library. --- NEW FILE: Makefile --- # # Library definitions # MOD = knregistration MODINIT = NsRegistration_ModuleInit OBJS = src/knrcommon.o \ src/knregistration.o \ src/knrproceduremanager.o \ src/knrfiltermanager.o \ src/knrredirectmanager.o \ src/kntclapi.o \ src/knnewdelete.o SRCDIR = .. CUSTOM_DEFS_FILE = knregistration.mak include ../include/ns.mak include knregistration.mak --- NEW FILE: knregistration-mak.inc --- !ifndef KNREGISTRATION_MAK KNREGISTRATION_MAK=1 # # Location of dependencies # SUPPORT = ../../../Support KNAPI = ../knapi KNUTIL = ../knutil # # Additional compiler flags # CPPFLAGS = $(CPPFLAGS) /D KN_PRIVATE /I$(KNAPI)/include /I$(KNUTIL)/include # # Additional libraries # LIBS = $(LIBS) ws2_32.lib /LIBPATH:$(KNAPI) knapi.lib /LIBPATH:$(KNUTIL) knutil.lib !else !endif --- NEW FILE: knregistration.mak.in --- # # Location of dependencies # SUPPORT = ../../../Support KNAPI = ../knapi KNUTIL = ../knutil # # Additional compiler flags # CPPFLAGS += -DKN_PRIVATE=1 -I$(KNAPI)/include -I$(KNUTIL)/include # # Additional libraries # LDFLAGS += -L$(KNAPI) -lknapi -L$(KNUTIL) -lknutil # # Force C++ linkage. Use ':=' to invoke immediate evaluation. # LDLIB := $(subst gcc,g++,$(LDLIB)) LDLIB := $(subst -nostartfiles,,$(LDLIB)) install: --- NEW FILE: knregistration.vs7.vcproj --- <?xml version="1.0" encoding="Windows-1252"?> <VisualStudioProject ProjectType="Visual C++" Version="7.10" Name="knregistration" ProjectGUID="{2AE6E9DB-7CBB-438A-BBC9-A1C4AB0FB85C}" RootNamespace="knregistration"> <Platforms> <Platform Name="Win32"/> </Platforms> <Configurations> <Configuration Name="Release|Win32" OutputDirectory=".\Release" IntermediateDirectory=".\Release" ConfigurationType="2" UseOfMFC="0" ATLMinimizesCRunTimeLibraryUsage="FALSE" CharacterSet="2"> <Tool Name="VCCLCompilerTool" Optimization="1" InlineFunctionExpansion="1" OptimizeForProcessor="2" AdditionalIncludeDirectories="include;..\include;..\knapi\include;..\knutil\include" PreprocessorDefinitions="NDEBUG;_WINDOWS;_USRDLL;WIN32;FD_SETSIZE=2048;NO_CONST=1;KN_PRIVATE" StringPooling="TRUE" RuntimeLibrary="2" EnableFunctionLevelLinking="TRUE" AssemblerListingLocation=".\Release/" ObjectFile=".\Release/" ProgramDataBaseFileName=".\Release/" BrowseInformation="1" WarningLevel="4" SuppressStartupBanner="TRUE" DebugInformationFormat="3" CompileAs="0"/> <Tool Name="VCCustomBuildTool"/> <Tool Name="VCLinkerTool" AdditionalDependencies="knregistration.exp nsd.lib nsthread.lib tcl84t.lib ws2_32.lib" OutputFile=".\Release/knregistration.dll" LinkIncremental="1" SuppressStartupBanner="TRUE" AdditionalLibraryDirectories="Release;..\lib" GenerateDebugInformation="TRUE" ProgramDatabaseFile=".\Release\knregistration.pdb" GenerateMapFile="TRUE" MapFileName=".\Release\knregistration.map" MapExports="TRUE" MapLines="TRUE" LargeAddressAware="0" BaseAddress="@..\base_addresses.txt,$(ProjectName)" ImportLibrary=".\Release\knregistration.lib" TargetMachine="1"/> <Tool Name="VCMIDLTool"/> <Tool Name="VCPostBuildEventTool"/> <Tool Name="VCPreBuildEventTool"/> <Tool Name="VCPreLinkEventTool" Description="Mutual Imports" CommandLine="lib /def /out:release\knregistration.lib release\*.obj"/> <Tool Name="VCResourceCompilerTool" PreprocessorDefinitions="NDEBUG" Culture="1033"/> <Tool Name="VCWebServiceProxyGeneratorTool"/> <Tool Name="VCXMLDataGeneratorTool"/> <Tool Name="VCWebDeploymentTool"/> <Tool Name="VCManagedWrapperGeneratorTool"/> <Tool Name="VCAuxiliaryManagedWrapperGeneratorTool"/> </Configuration> <Configuration Name="Debug|Win32" OutputDirectory="$(ConfigurationName)" IntermediateDirectory="$(ConfigurationName)" ConfigurationType="2" UseOfMFC="0" ATLMinimizesCRunTimeLibraryUsage="FALSE" CharacterSet="2"> <Tool Name="VCCLCompilerTool" Optimization="0" InlineFunctionExpansion="0" OptimizeForProcessor="2" AdditionalIncludeDirectories="include;..\include;..\knapi\include;..\knutil\include" PreprocessorDefinitions="_DEBUG;_WINDOWS;_USRDLL;WIN32;FD_SETSIZE=2048;NO_CONST=1;KN_PRIVATE" StringPooling="TRUE" BasicRuntimeChecks="3" RuntimeLibrary="3" EnableFunctionLevelLinking="TRUE" AssemblerListingLocation=".\Debug/" ObjectFile=".\Debug/" ProgramDataBaseFileName=".\Debug/" BrowseInformation="1" WarningLevel="4" SuppressStartupBanner="TRUE" DebugInformationFormat="3" CompileAs="0"/> <Tool Name="VCCustomBuildTool"/> <Tool Name="VCLinkerTool" AdditionalDependencies="knregistration.exp nsd.lib nsthread.lib tcl84t.lib ws2_32.lib" OutputFile=".\Debug/knregistration.dll" LinkIncremental="1" SuppressStartupBanner="TRUE" AdditionalLibraryDirectories="Debug;..\lib" IgnoreAllDefaultLibraries="FALSE" IgnoreDefaultLibraryNames="" GenerateDebugInformation="TRUE" ProgramDatabaseFile=".\Debug\knregistration.pdb" GenerateMapFile="TRUE" MapFileName=".\Debug\knregistration.map" MapExports="TRUE" MapLines="TRUE" LargeAddressAware="0" BaseAddress="@..\base_addresses.txt,$(ProjectName)" ImportLibrary=".\Debug\knregistration.lib" TargetMachine="1"/> <Tool Name="VCMIDLTool"/> <Tool Name="VCPostBuildEventTool"/> <Tool Name="VCPreBuildEventTool"/> <Tool Name="VCPreLinkEventTool" Description="Mutual Imports" CommandLine="lib /def /out:debug\knregistration.lib debug\*.obj"/> <Tool Name="VCResourceCompilerTool" PreprocessorDefinitions="NDEBUG" Culture="1033"/> <Tool Name="VCWebServiceProxyGeneratorTool"/> <Tool Name="VCXMLDataGeneratorTool"/> <Tool Name="VCWebDeploymentTool"/> <Tool Name="VCManagedWrapperGeneratorTool"/> <Tool Name="VCAuxiliaryManagedWrapperGeneratorTool"/> </Configuration> </Configurations> <References> </References> <Files> <Filter Name="Source Files" Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"> <File RelativePath=".\src\knnewdelete.cpp"> </File> <File RelativePath=".\src\knrcommon.cpp"> </File> <File RelativePath=".\src\knregistration.cpp"> </File> <File RelativePath=".\src\knrfiltermanager.cpp"> </File> <File RelativePath=".\src\knrproceduremanager.cpp"> </File> <File RelativePath=".\src\knrredirectmanager.cpp"> </File> <File RelativePath=".\src\kntclapi.cpp"> </File> </Filter> <Filter Name="Header Files" Filter="h;hpp;hxx;hm;inl;inc;xsd" UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"> <File RelativePath=".\include\knexportlibraryknregistration.h"> </File> <File RelativePath=".\include\knexportlibraryknregistrationmodule.h"> </File> <File RelativePath=".\include\knrcommon.h"> </File> <File RelativePath=".\include\knregistration.h"> </File> <File RelativePath=".\include\knrfiltermanager.h"> </File> <File RelativePath=".\include\knrproceduremanager.h"> </File> <File RelativePath=".\include\knrredirectmanager.h"> </File> <File RelativePath=".\include\kntclapi.h"> </File> </Filter> <Filter Name="Resource Files" Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx" UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"> </Filter> </Files> <Globals> </Globals> </VisualStudioProject> --- NEW FILE: knregistration.vs8.vcproj --- <?xml version="1.0" encoding="Windows-1252"?> <VisualStudioProject ProjectType="Visual C++" Version="8,00" Name="knregistration" ProjectGUID="{2AE6E9DB-7CBB-438A-BBC9-A1C4AB0FB85C}" RootNamespace="knregistration" > <Platforms> <Platform Name="Win32" /> </Platforms> <ToolFiles> </ToolFiles> <Configurations> <Configuration Name="Release|Win32" OutputDirectory=".\Release" IntermediateDirectory=".\Release" ConfigurationType="2" InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" UseOfMFC="0" ATLMinimizesCRunTimeLibraryUsage="false" CharacterSet="2" > <Tool Name="VCPreBuildEventTool" /> <Tool Name="VCCustomBuildTool" /> <Tool Name="VCXMLDataGeneratorTool" /> <Tool Name="VCWebServiceProxyGeneratorTool" /> <Tool Name="VCMIDLTool" /> <Tool Name="VCCLCompilerTool" Optimization="1" InlineFunctionExpansion="1" AdditionalIncludeDirectories="include;..\include;..\knapi\include;..\knutil\include" PreprocessorDefinitions="NDEBUG;_WINDOWS;_USRDLL;WIN32;FD_SETSIZE=2048;NO_CONST=1;KN_PRIVATE" StringPooling="true" RuntimeLibrary="2" EnableFunctionLevelLinking="true" AssemblerListingLocation=".\Release/" ObjectFile=".\Release/" ProgramDataBaseFileName=".\Release/" BrowseInformation="1" WarningLevel="4" SuppressStartupBanner="true" DebugInformationFormat="3" CompileAs="0" /> <Tool Name="VCManagedResourceCompilerTool" /> <Tool Name="VCResourceCompilerTool" PreprocessorDefinitions="NDEBUG" Culture="1033" /> <Tool Name="VCPreLinkEventTool" Description="Mutual Imports" CommandLine="lib /def /out:release\knregistration.lib release\*.obj" /> <Tool Name="VCLinkerTool" AdditionalDependencies="knregistration.exp nsd.lib nsthread.lib tcl84t.lib ws2_32.lib" OutputFile=".\Release/knregistration.dll" LinkIncremental="1" SuppressStartupBanner="true" AdditionalLibraryDirectories="Release;..\lib" GenerateDebugInformation="true" ProgramDatabaseFile=".\Release\knregistration.pdb" GenerateMapFile="true" MapFileName=".\Release\knregistration.map" MapExports="true" LargeAddressAware="0" BaseAddress="@..\base_addresses.txt,$(ProjectName)" ImportLibrary=".\Release\knregistration.lib" TargetMachine="1" /> <Tool Name="VCALinkTool" /> <Tool Name="VCManifestTool" /> <Tool Name="VCXDCMakeTool" /> <Tool Name="VCBscMakeTool" /> <Tool Name="VCFxCopTool" /> <Tool Name="VCAppVerifierTool" /> <Tool Name="VCWebDeploymentTool" /> <Tool Name="VCPostBuildEventTool" /> </Configuration> <Configuration Name="Debug|Win32" OutputDirectory="$(ConfigurationName)" IntermediateDirectory="$(ConfigurationName)" ConfigurationType="2" InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" UseOfMFC="0" ATLMinimizesCRunTimeLibraryUsage="false" CharacterSet="2" > <Tool Name="VCPreBuildEventTool" /> <Tool Name="VCCustomBuildTool" /> <Tool Name="VCXMLDataGeneratorTool" /> <Tool Name="VCWebServiceProxyGeneratorTool" /> <Tool Name="VCMIDLTool" /> <Tool Name="VCCLCompilerTool" Optimization="0" InlineFunctionExpansion="0" AdditionalIncludeDirectories="include;..\include;..\knapi\include;..\knutil\include" PreprocessorDefinitions="_DEBUG;_WINDOWS;_USRDLL;WIN32;FD_SETSIZE=2048;NO_CONST=1;KN_PRIVATE" StringPooling="true" BasicRuntimeChecks="3" RuntimeLibrary="3" EnableFunctionLevelLinking="true" AssemblerListingLocation=".\Debug/" ObjectFile=".\Debug/" ProgramDataBaseFileName=".\Debug/" BrowseInformation="1" WarningLevel="4" SuppressStartupBanner="true" DebugInformationFormat="3" CompileAs="0" /> <Tool Name="VCManagedResourceCompilerTool" /> <Tool Name="VCResourceCompilerTool" PreprocessorDefinitions="NDEBUG" Culture="1033" /> <Tool Name="VCPreLinkEventTool" Description="Mutual Imports" CommandLine="lib /def /out:debug\knregistration.lib debug\*.obj" /> <Tool Name="VCLinkerTool" AdditionalDependencies="knregistration.exp nsd.lib nsthread.lib tcl84t.lib ws2_32.lib" OutputFile=".\Debug/knregistration.dll" LinkIncremental="1" SuppressStartupBanner="true" AdditionalLibraryDirectories="Debug;..\lib" IgnoreAllDefaultLibraries="false" IgnoreDefaultLibraryNames="" GenerateDebugInformation="true" ProgramDatabaseFile=".\Debug\knregistration.pdb" GenerateMapFile="true" MapFileName=".\Debug\knregistration.map" MapExports="true" LargeAddressAware="0" BaseAddress="@..\base_addresses.txt,$(ProjectName)" ImportLibrary=".\Debug\knregistration.lib" TargetMachine="1" /> <Tool Name="VCALinkTool" /> <Tool Name="VCManifestTool" /> <Tool Name="VCXDCMakeTool" /> <Tool Name="VCBscMakeTool" /> <Tool Name="VCFxCopTool" /> <Tool Name="VCAppVerifierTool" /> <Tool Name="VCWebDeploymentTool" /> <Tool Name="VCPostBuildEventTool" /> </Configuration> </Configurations> <References> </References> <Files> <Filter Name="Source Files" Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" > <File RelativePath=".\src\knnewdelete.cpp" > </File> <File RelativePath=".\src\knrcommon.cpp" > </File> <File RelativePath=".\src\knregistration.cpp" > </File> <File RelativePath=".\src\knrfiltermanager.cpp" > </File> <File RelativePath=".\src\knrproceduremanager.cpp" > </File> <File RelativePath=".\src\knrredirectmanager.cpp" > </File> <File RelativePath=".\src\kntclapi.cpp" > </File> </Filter> <Filter Name="Header Files" Filter="h;hpp;hxx;hm;inl;inc;xsd" UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" > <File RelativePath=".\include\knexportlibraryknregistration.h" > </File> <File RelativePath=".\include\knexportlibraryknregistrationmodule.h" > </File> <File RelativePath=".\include\knrcommon.h" > </File> <File RelativePath=".\include\knregistration.h" > </File> <File RelativePath=".\include\knrfiltermanager.h" > </File> <File RelativePath=".\include\knrproceduremanager.h" > </File> <File RelativePath=".\include\knrredirectmanager.h" > </File> <File RelativePath=".\include\kntclapi.h" > </File> </Filter> <Filter Name="Resource Files" Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx" UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}" > </Filter> </Files> <Globals> </Globals> </VisualStudioProject> |
Update of /cvsroot/aolserver/knregistration/src In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv11750/src Added Files: knnewdelete.cpp knrcommon.cpp knregistration.cpp knrfiltermanager.cpp knrproceduremanager.cpp knrredirectmanager.cpp kntclapi.cpp Log Message: knregistration adds the ability to register procedures, filters, and indirects based on patterns in URIs. Matched portions of these URIs are added to the ns_conn "form" before delivery to the procedure, filter, or indirect request. Requires the knutil library. --- NEW FILE: knnewdelete.cpp --- /** * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * * @KNOWNOW_LICENSE_START@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The name "KnowNow" is a trademark of KnowNow, Inc. and may not * be used to endorse or promote any product without prior written * permission from KnowNow, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL KNOWNOW, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @KNOWNOW_LICENSE_END@ **/ #define KNMODULE knregistration #include "knutil/knnewdelete.h" --- NEW FILE: knrcommon.cpp --- /** * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * * @KNOWNOW_LICENSE_START@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The name "KnowNow" is a trademark of KnowNow, Inc. and may not * be used to endorse or promote any product without prior written * permission from KnowNow, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL KNOWNOW, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @KNOWNOW_LICENSE_END@ **/ #include "knexportlibraryknregistrationmodule.h" #include "knrcommon.h" bool addQueryToConn(KnSet& toAdd, Ns_Conn* conn) { if(toAdd.size() == 0) return false; Ns_Set* query; query = Ns_ConnGetQuery(conn); if (query != NULL) { for(int i = 0; i < toAdd.size(); i++) { Ns_SetUpdate(query, (char*)toAdd[i].m_key.c_str(), (char*)toAdd[i].m_value.c_str()); } return true; } return false; } bool removeQueryFromConn(KnSet& toRemove, Ns_Conn* conn) { if(toRemove.size() == 0) return false; Ns_Set* query; query = Ns_ConnGetQuery(conn); if (query != NULL) { for(int i = 0; i < toRemove.size(); i++) { Ns_SetDeleteKey(query, (char*)toRemove[i].m_key.c_str()); } return true; } return false; } --- NEW FILE: knregistration.cpp --- /** * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * * @KNOWNOW_LICENSE_START@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The name "KnowNow" is a trademark of KnowNow, Inc. and may not * be used to endorse or promote any product without prior written * permission from KnowNow, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL KNOWNOW, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @KNOWNOW_LICENSE_END@ **/ #include <vector> #include <list> #include <map> #include "knutil/knlog.h" #include "knutil/knset.h" #include "knutil/kntemplateuri.h" #include "knexportlibraryknregistrationmodule.h" #include "knregistration.h" #include "knrfiltermanager.h" #include "knrproceduremanager.h" #include "knrredirectmanager.h" #include "kntclapi.h" static KnRFilterManager g_filterManager; static KnRProcedureManager g_procManager; static KnRRedirectManager g_redirectManager; static const char* HttpMethods[] = { "GET", "HEAD", "PUT", "DELETE", "POST", "SUBSCRIBE"}; static const int HttpMethodsCount = 6; int KnFilterRegistered(void* context, Ns_Conn* conn, int why) { // redirect if(why == NS_FILTER_PRE_AUTH) { int result = g_redirectManager.redirect(context, conn); if(result != NS_OK) return result; } // filters int result = g_filterManager.runFilters(context, conn, why); if(result == NS_FILTER_RETURN) return result; // procedures if(why == NS_FILTER_POST_AUTH) { return g_procManager.runProcedures(context, conn); } return result; } void KnRegisterProc(const char* server, const char* method, bool inheritable, const char* urlTemplate, KnRegisteredProc* proc, void* context) { if(strcmp(method,"*") != 0) g_procManager.registerProc(new KnCRProcedureHandler(server,method,urlTemplate,inheritable,proc,context)); else { for(int i = 0; i < HttpMethodsCount; i++) g_procManager.registerProc(new KnCRProcedureHandler(server,HttpMethods[i],urlTemplate,inheritable,proc,context)); } } void KnRegisterTclProc(const char* server, const char* method, bool inheritable, const char* urlTemplate, const char* proc ,const char* args) { if(strcmp(method,"*") != 0) g_procManager.registerProc(new KnTclRProcedureHandler(server,method,urlTemplate,inheritable,proc,args)); else { for(int i = 0; i < HttpMethodsCount; i++) g_procManager.registerProc(new KnTclRProcedureHandler(server,HttpMethods[i],urlTemplate,inheritable,proc,args)); } } void KnRegisterFilter(const char* server, const char* method, int why, const char* urlTemplate, KnRegisteredFilter* proc, void* context) { if(strcmp(method,"*") != 0) g_filterManager.registerFilter(new KnCRFilterHandler(server,method,why,urlTemplate,proc,context)); else { for(int i = 0; i < HttpMethodsCount; i++) g_filterManager.registerFilter(new KnCRFilterHandler(server,HttpMethods[i],why,urlTemplate,proc,context)); } } void KnRegisterTclFilter(const char* server, const char* method, int why, const char* urlTemplate, const char* proc, const char* args) { if(strcmp(method,"*") != 0) g_filterManager.registerFilter(new KnTclRFilterHandler(server,method,why,urlTemplate,proc,args)); else { for(int i = 0; i < HttpMethodsCount; i++) g_filterManager.registerFilter(new KnTclRFilterHandler(server,HttpMethods[i],why,urlTemplate,proc,args)); } } void KnRegisterRedirect(bool internal, const char* method, const char* urlTemplateFrom, const char* urlTemplateTo) { if(strcmp(method,"*") != 0) g_redirectManager.addRedirect(new KnRRedirectInfo(internal, method, urlTemplateFrom, urlTemplateTo)); else { for(int i = 0; i < HttpMethodsCount; i++) g_redirectManager.addRedirect(new KnRRedirectInfo(internal, HttpMethods[i], urlTemplateFrom, urlTemplateTo)); } } bool KnUnregisterProc(const char* server, const char* method, bool inheritable, const char* urlTemplate) { if(strcmp(method,"*") != 0) return g_procManager.removeProcedure(server,method,inheritable,urlTemplate); for(int i = 0; i < HttpMethodsCount; i++) g_procManager.removeProcedure(server,HttpMethods[i],inheritable,urlTemplate); return true; } bool KnUnregisterFilter(const char* server, const char* method, int why, const char* urlTemplate) { if(strcmp(method,"*") != 0) return g_filterManager.removeFilter(server,method,why,urlTemplate); for(int i = 0; i < HttpMethodsCount; i++) return g_filterManager.removeFilter(server,HttpMethods[i],why,urlTemplate); return true; } bool KnUnregisterRedirect(const char* method, const char* urlTemplateFrom) { if(strcmp(method,"*") != 0) return g_redirectManager.removeRedirect(method, urlTemplateFrom); for(int i = 0; i < HttpMethodsCount; i++) return g_redirectManager.removeRedirect(HttpMethods[i], urlTemplateFrom); return true; } extern "C" { EXPORT_LIBRARY_KNREGISTRATION int NsRegistration_ModuleInit(char *hServer, char *hModule) { KnLog(KnLogNotice, "knregistration: starting"); KnLog(KnLogNotice, "knregistration: build date: %s %s", __DATE__, __TIME__); char filter_path[1024]; Ns_Set* config = NULL; const char* nsp; if ((nsp = Ns_ConfigGetPath(hServer, hModule, NULL)) == 0 || (config = Ns_ConfigGetSection(const_cast<CONST char*>(nsp))) == 0) { KnLog(KnLogError, "knregistration: could not parse configuration"); return NS_ERROR; } KnString urlfilter; urlfilter += "/*"; Ns_RegisterFilter( hServer, "*", const_cast<char*>(urlfilter.c_str()), KnFilterRegistered, NS_FILTER_POST_AUTH | NS_FILTER_PRE_AUTH | NS_FILTER_TRACE ,NULL ); // Export TCL commands if (NS_OK != Ns_TclInitInterps(hServer, KnRegister_TclCommands::AddCmds, NULL)) { KnLog( KnLogError, "knregistration: Couldn't add kn_ TCL commands to server '%s'", hServer); return NS_ERROR; } KnLog(KnLogNotice, "knregistration: ready"); return NS_OK; } } --- NEW FILE: knrfiltermanager.cpp --- /** * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * * @KNOWNOW_LICENSE_START@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The name "KnowNow" is a trademark of KnowNow, Inc. and may not * be used to endorse or promote any product without prior written * permission from KnowNow, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL KNOWNOW, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @KNOWNOW_LICENSE_END@ **/ #include "knexportlibraryknregistrationmodule.h" #include "knrcommon.h" #include "knrfiltermanager.h" /* ------------------------------------------------------------------------- */ /* IKnRFilterHandler */ /* ------------------------------------------------------------------------- */ IKnRFilterHandler::IKnRFilterHandler(const char* server, const char* method, int why, const char* urlTemplate) : m_server(server),m_method(method),m_why(why),m_urlTemplate(urlTemplate) { } IKnRFilterHandler::~IKnRFilterHandler() { } std::string IKnRFilterHandler::getID() { return m_server+':'+m_method+':'+(char)('a'+m_why); } std::string IKnRFilterHandler::getID(const char* server, const char* method, int why) { std::string result = server; result += ":"; result += method; result += ":"; result += (char)('a'+why); return result; } /* ------------------------------------------------------------------------- */ /* KnCRFilterHandler */ /* ------------------------------------------------------------------------- */ KnCRFilterHandler::KnCRFilterHandler(const char* server, const char* method, int why, const char* urlTemplate, KnRegisteredFilter* proc, void* context) : IKnRFilterHandler(server,method,why,urlTemplate),m_proc(proc),m_context(context) { } int KnCRFilterHandler::handle(void *context, Ns_Conn *conn, int why) { return (*m_proc)(context,conn,why); } /* ------------------------------------------------------------------------- */ /* KnTclRFilterHandler */ /* ------------------------------------------------------------------------- */ KnTclRFilterHandler::KnTclRFilterHandler(const char* server, const char* method, int why, const char* urlTemplate, const char* proc, const char* args) : IKnRFilterHandler(server,method,why,urlTemplate),m_proc(proc),m_args(args) { } int KnTclRFilterHandler::handle(void *context, Ns_Conn *conn, int why) { std::string& command = m_proc; command += " "; command += m_args; Tcl_Interp* interp = Ns_GetConnInterp(conn); int status = Tcl_EvalEx(interp, const_cast<char*>(command.c_str()),command.length(),TCL_EVAL_DIRECT); if (status != TCL_OK) { KnLog(KnLogError,"knregistration: Couldn't evaluate '%s': %s",command.c_str(), Tcl_GetStringResult(interp)); Ns_TclLogError(interp); return NS_ERROR; } Tcl_Obj* result = Tcl_GetObjResult(interp); if(result == TCL_OK) { int filterresult = NS_OK; Tcl_GetIntFromObj(interp,result,&filterresult); return filterresult; } return NS_ERROR; } /* ------------------------------------------------------------------------- */ /* KnRFilterManager */ /* ------------------------------------------------------------------------- */ void KnRFilterManager::registerFilter(IKnRFilterHandler* fh) { FinderType::ScopedWriteable sw(m_filterFinder); KnString name(fh->m_urlTemplate.c_str()); m_filterFinder.put( fh->getID(), new KnTemplateURI(name, KnString(fh->m_urlTemplate.c_str())), fh); } bool KnRFilterManager::removeFilter(const char* server, const char* method, int why, const char* urlTemplate) { FinderType::ScopedWriteable sw(m_filterFinder); std::string id = IKnRFilterHandler::getID(server,method,why); KnString name(urlTemplate); return m_filterFinder.removeByName(id, name); } int KnRFilterManager::runFilters(void *context, Ns_Conn *conn, int why) { if(!m_filterFinder.size()) return NS_OK; int ret = NS_OK; std::string method = conn->request->method; std::string url = conn->request->url; std::string server = Ns_ConnServer(conn); std::string id = IKnRFilterHandler::getID(server.c_str(),method.c_str(),why); KNREGDBG(KnLog(KnLogDev,"ReC: knregistration: Looking for filter for url '%s' in set '%s'", url.c_str(), id.c_str())); ResultType result; { FinderType::ScopedReadable sr(m_filterFinder); if(! m_filterFinder.findAllMatchesSubs(id, url.c_str(), result)) return NS_OK; } KNREGDBG(KnLog(KnLogDev,"ReC: knregistration: Found %d filters that matched '%s'", result.size(), url.c_str())); bool added; KnSet* matched; int i; for(i = 0; i < result.size(); i++) { matched = result[i].first; if (KNREGDBG(KnLog(KnLogDev,"ReC: knregistration: Calling filter with set:"))) { matched->dump(KnString("ReC: knregistration: ")); } added = addQueryToConn(*matched, conn); int filterresult = result[i].second->handle(context, conn, why); if(added) removeQueryFromConn(*matched, conn); if((filterresult == NS_FILTER_BREAK)||(filterresult == NS_FILTER_RETURN)) { ret = filterresult; break; } } for(i = 0 ; i < result.size() ; i++) { matched = result[i].first; SAFE_DELETE(matched); } return ret; } --- NEW FILE: knrproceduremanager.cpp --- /** * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * * @KNOWNOW_LICENSE_START@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The name "KnowNow" is a trademark of KnowNow, Inc. and may not * be used to endorse or promote any product without prior written * permission from KnowNow, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL KNOWNOW, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @KNOWNOW_LICENSE_END@ **/ #include "knexportlibraryknregistrationmodule.h" #include "knrcommon.h" #include "knrproceduremanager.h" /* ------------------------------------------------------------------------- */ /* IKnRProcedureHandler */ /* ------------------------------------------------------------------------- */ IKnRProcedureHandler::IKnRProcedureHandler(const char* server, const char* method, const char* urlTemplate, bool inheritable) : m_server(server),m_method(method),m_urlTemplate(urlTemplate),m_inheritable(inheritable) { } IKnRProcedureHandler::~IKnRProcedureHandler() { } bool IKnRProcedureHandler::isInheritable() { return m_inheritable; } std::string IKnRProcedureHandler::getID() { return m_server+':'+m_method; } std::string IKnRProcedureHandler::getID(const char* server, const char* method) { std::string result = server; result += ":"; result += method; return result; } /* ------------------------------------------------------------------------- */ /* KnRProcedureInfo */ /* ------------------------------------------------------------------------- */ KnRProcedureInfo::KnRProcedureInfo() { m_inheritable = NULL; m_exact = NULL; } KnRProcedureInfo::KnRProcedureInfo(IKnRProcedureHandler* ph) { m_inheritable = NULL; m_exact = NULL; set(ph); } KnRProcedureInfo::~KnRProcedureInfo() { SAFE_DELETE(m_inheritable); SAFE_DELETE(m_exact); } bool KnRProcedureInfo::hasInheritable() { return m_inheritable != NULL; } bool KnRProcedureInfo::hasExact() { return m_exact != NULL; } bool KnRProcedureInfo::removeHandler(bool inheritable) { if(inheritable && hasInheritable()) { SAFE_DELETE(m_inheritable); return true; } if(!inheritable && hasExact()) { SAFE_DELETE(m_exact); return true; } return false; } int KnRProcedureInfo::handle(void* context, Ns_Conn* conn) { return m_exact->handle(context,conn); } int KnRProcedureInfo::handleInheritable(void* context, Ns_Conn* conn) { return m_inheritable->handle(context,conn); } void KnRProcedureInfo::set(IKnRProcedureHandler* ph) { if(ph->isInheritable()) { SAFE_DELETE(m_inheritable); m_inheritable = ph; }else { SAFE_DELETE(m_exact); m_exact = ph; } } /* ------------------------------------------------------------------------- */ /* KnCRProcedureHandler */ /* ------------------------------------------------------------------------- */ KnCRProcedureHandler::KnCRProcedureHandler(const char* server, const char* method, const char* urlTemplate, bool inheritable, KnRegisteredProc* proc, void* context) : IKnRProcedureHandler( server, method, urlTemplate,inheritable) { m_proc = proc; m_context = context; } int KnCRProcedureHandler::handle(void* context, Ns_Conn* conn) { return (*m_proc)(context,conn); } /* ------------------------------------------------------------------------- */ /* KnTclRProcedureHandler */ /* ------------------------------------------------------------------------- */ KnTclRProcedureHandler::KnTclRProcedureHandler(const char* server, const char* method, const char* urlTemplate, bool inheritable, const char* proc, const char* args) : IKnRProcedureHandler(server,method,urlTemplate,inheritable) { m_proc = proc; m_args = args; } int KnTclRProcedureHandler::handle(void* context, Ns_Conn* conn) { Tcl_Interp *interp = Ns_GetConnInterp(conn); int result; std::string command; command += m_proc; int id = Ns_ConnId(conn); char buffer[30]; sprintf(buffer,"cns%d",id); command += ' '; command += buffer; command += m_args; result = Tcl_EvalEx(interp, (char*)command.c_str(), command.size(), 0); if (result != TCL_OK) { Ns_TclLogError(interp); if (Ns_ConnResetReturn(conn) == NS_OK) return Ns_ConnReturnInternalError(conn); return NS_OK; } return NS_OK; } /* ------------------------------------------------------------------------- */ /* KnRProcedureManager */ /* ------------------------------------------------------------------------- */ void KnRProcedureManager::registerProc(IKnRProcedureHandler* ph) { FinderType::ScopedWriteable sw(m_procFinder); std::string id = ph->getID(); KnString name(ph->m_urlTemplate.c_str()); KnSmartRef<KnTemplateURI> temp; KnSmartRef<KnRProcedureInfo> info; if(m_procFinder.findByName(id, name, temp, info)) info->set(ph); else { m_procFinder.put( id, new KnTemplateURI(name, KnString(ph->m_urlTemplate.c_str())), new KnRProcedureInfo(ph) ); } } bool KnRProcedureManager::removeProcedure(const char* server, const char* method, bool inheritable, const char* urlTemplate) { FinderType::ScopedWriteable sw(m_procFinder); std::string id = IKnRProcedureHandler::getID(server,method); KnString name(urlTemplate); KnSmartRef<KnTemplateURI> temp; KnSmartRef<KnRProcedureInfo> info; if(m_procFinder.findByName(id, name, temp, info)) { if(info->removeHandler(inheritable)) { if(!(info->hasExact() || info->hasInheritable())) return m_procFinder.removeByName(id, name); return true; } } return false; } int KnRProcedureManager::runProcedures(void* context, Ns_Conn* conn) { if(!m_procFinder.size()) return NS_OK; int ret = NS_OK; // respond as a filter std::string method = conn->request->method; std::string url = conn->request->url; std::string server = Ns_ConnServer(conn); std::string id = IKnRProcedureHandler::getID(server.c_str(),method.c_str()); KNREGDBG(KnLog(KnLogDev,"ReC: knregistration: Looking for procedure for url '%s' in set '%s'", url.c_str(), id.c_str())); ResultType result; { FinderType::ScopedReadable sr(m_procFinder); if(! m_procFinder.findAllMatchesSubs(id, url.c_str(), result)) return ret; } KNREGDBG(KnLog(KnLogDev,"ReC: knregistration: %d candidates for url '%s'", result.size(), url.c_str())); KnSet* matched; int exactPos; bool hasExact = false; for(exactPos = 0; exactPos < result.size(); exactPos++) { if(result[exactPos].second->hasExact()) { hasExact = true; break; } } bool added; int i; if(hasExact) { for(i = result.size()-1 ; i > exactPos; i--) { if(!result[i].second->hasInheritable()) continue; matched = result[i].first; if (KNREGDBG(KnLog(KnLogDev,"ReC: knregistration: calling inherited procedure using set:"))) { matched->dump(KnString("ReC: knregistration: ")); } added = addQueryToConn(*matched, conn); result[i].second->handleInheritable(context, conn); if(added) removeQueryFromConn(*matched, conn); } matched = result[exactPos].first; if (KNREGDBG(KnLog(KnLogDev,"ReC: knregistration: calling exact-match procedure using set:"))) { matched->dump(KnString("ReC: knregistration: ")); } added = addQueryToConn(*matched, conn); result[exactPos].second->handle(context, conn); ret = NS_FILTER_RETURN; if(added) removeQueryFromConn(*matched, conn); }else { for(i = result.size()-1 ; i >= 0; i--) { if(!result[i].second->hasInheritable()) continue; matched = result[i].first; if (KNREGDBG(KnLog(KnLogDev,"ReC: knregistration: calling inherited procedure using set:"))) { matched->dump(KnString("ReC: knregistration: ")); } added = addQueryToConn(*matched, conn); result[i].second->handleInheritable(context, conn); if(added) removeQueryFromConn(*matched, conn); } } for(i = 0 ; i < result.size() ; i++) { matched = result[i].first; SAFE_DELETE(matched); } return ret; } --- NEW FILE: knrredirectmanager.cpp --- /** * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * * @KNOWNOW_LICENSE_START@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The name "KnowNow" is a trademark of KnowNow, Inc. and may not * be used to endorse or promote any product without prior written * permission from KnowNow, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL KNOWNOW, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @KNOWNOW_LICENSE_END@ **/ #include "knexportlibraryknregistrationmodule.h" #include "knrcommon.h" #include "knrredirectmanager.h" /* ------------------------------------------------------------------------- */ /* Utility */ /* ------------------------------------------------------------------------- */ void createExternalRedirectUrl(Ns_Conn* conn, const std::string& toUrl, std::string& url) { url = ""; if(toUrl[0] == '/') { Ns_DString ds; Ns_DStringInit(&ds); char* location = Ns_ConnLocation(conn, &ds); if(location) url += location; Ns_DStringFree(&ds); } url += toUrl; } /* ------------------------------------------------------------------------- */ /* KnRRedirectInfo */ /* ------------------------------------------------------------------------- */ KnRRedirectInfo::KnRRedirectInfo(bool internal, const char* method, const char* urlTemplateFrom, const char* urlTemplateTo) :m_internal(internal),m_method(method),m_urlTemplateFrom(urlTemplateFrom),m_urlTemplateTo(urlTemplateTo) { } /* ------------------------------------------------------------------------- */ /* KnRRedirectManager */ /* ------------------------------------------------------------------------- */ KnRRedirectManager::KnRRedirectManager() { } KnRRedirectManager::~KnRRedirectManager() { } void KnRRedirectManager::addRedirect(KnRRedirectInfo* ri) { FinderType::ScopedWriteable sw(m_redirectFinder); KnString name; name.printf("%s%s",ri->m_method.c_str(), ri->m_urlTemplateFrom.c_str()); KnTemplateURI* tempuri = new KnTemplateURI(name, KnString(ri->m_urlTemplateFrom.c_str())); m_redirectFinder.put(ri->m_method, tempuri, ri); } bool KnRRedirectManager::removeRedirect(const char* method, const char* urlTemplateFrom) { FinderType::ScopedWriteable sw(m_redirectFinder); KnString name; std::string m = method; name.printf("%s%s",method, urlTemplateFrom); return m_redirectFinder.removeByName(m, name); } int KnRRedirectManager::redirect(void* context, Ns_Conn* conn) { if(!m_redirectFinder.size()) return NS_OK; KnSet matched; std::string url = (conn->request->url? conn->request->url : ""); std::string method = conn->request->method; KnSmartRef<KnTemplateURI> pattern; KnSmartRef<KnRRedirectInfo> ri; std::string newUrl; { FinderType::ScopedReadable sr(m_redirectFinder); bool found = m_redirectFinder.findBestMatchSubs(method, url.c_str(), matched, pattern, ri); if(!found) return NS_OK; } //KnLog(KnLogDebug,"Chose pattern [%s] for redirecting url [%s] from pattern list:",ri->m_urlTemplateFrom.c_str(), url.c_str()); //m_redirectFinder.dump(method, KnLogDebug); std::string redirectTo; bool valid = KnTemplateURI::replaceInto(matched, ri->m_urlTemplateTo.c_str(), redirectTo, true); if(!valid) { KnLog(KnLogNotice, "Invalid redirect translation from [%s] to [%s]", ri->m_urlTemplateFrom.c_str(), ri->m_urlTemplateTo.c_str()); return NS_OK; } newUrl = redirectTo; if(ri->m_internal) { addQueryToConn(matched, conn); // Url rewrite Ns_ConnRedirect(conn, (char*)newUrl.c_str()); }else { createExternalRedirectUrl(conn, redirectTo, newUrl); addQueryToConn(matched, conn); // External redirect Ns_ConnReturnRedirect(conn, (char*)newUrl.c_str()); } return NS_FILTER_RETURN; } --- NEW FILE: kntclapi.cpp --- /** * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * * @KNOWNOW_LICENSE_START@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The name "KnowNow" is a trademark of KnowNow, Inc. and may not * be used to endorse or promote any product without prior written * permission from KnowNow, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL KNOWNOW, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @KNOWNOW_LICENSE_END@ **/ #include "knutil/knstring.h" #include "knutil/knset.h" #include "knutil/knstringtokenizer.h" #include "knutil/kntclinterp.h" #include "knutil/kntclerrors.h" #include "knexportlibraryknregistrationmodule.h" #include "knregistration.h" namespace KnRegister_TclCommands { extern "C" { int kn_registerproc ( void * context, Tcl_Interp* interp, int objc, Tcl_Obj * objv[]) { if (objc < 4) { KnTcl_WrongNumArgs(interp,3,objv,"string"); return TCL_ERROR; } bool inheritable = false; int index = 1; char* elem = (Tcl_GetString(objv[index])); if(strcasecmp(elem,"-noinherit") == 0) { index++; inheritable = false; }else if(strcasecmp(elem,"-inherit") == 0) { index++; inheritable = true; } char* method(Tcl_GetString(objv[index++])); char* url(Tcl_GetString(objv[index++])); char* proc(Tcl_GetString(objv[index++])); std::string args; for(int i = index; i < objc; i++) { args += " {"; args += Tcl_GetString(objv[i]); args += "}"; } KnRegisterTclProc(Ns_TclInterpServer(interp), method, inheritable, url, proc, args.c_str()); return TCL_OK; } int kn_registerfilter ( void * context, Tcl_Interp* interp, int objc, Tcl_Obj * objv[]) { if (objc < 5) { KnTcl_WrongNumArgs(interp,4,objv,"string"); return TCL_ERROR; } int index = 1; char* server = Ns_TclInterpServer(interp); char* type(Tcl_GetString(objv[index++])); char* method(Tcl_GetString(objv[index++])); char* url(Tcl_GetString(objv[index++])); char* proc(Tcl_GetString(objv[index++])); std::string args; for(int i = 5; i < objc; i++) { args += " {"; args += Tcl_GetString(objv[i]); args += "}"; } int filterType; if(strcasecmp(type,"-preauth") == 0) filterType = NS_FILTER_PRE_AUTH; else if(strcasecmp(type,"-postauth") == 0) filterType = NS_FILTER_POST_AUTH; else if(strcasecmp(type,"-trace") == 0) filterType = NS_FILTER_TRACE; else { Tcl_AppendResult(interp,"500 Unknown type for filter: '",type,"'",0); return TCL_ERROR; } KnRegisterTclFilter(server, method, filterType, url, proc, args.c_str()); return TCL_OK; } int kn_registerredirect ( void * context, Tcl_Interp* interp, int objc, Tcl_Obj * objv[]) { if (objc < 5) { KnTcl_WrongNumArgs(interp,4,objv,"string"); return TCL_ERROR; } int index = 1; char* type(Tcl_GetString(objv[index++])); char* method(Tcl_GetString(objv[index++])); char* template1(Tcl_GetString(objv[index++])); char* template2(Tcl_GetString(objv[index++])); if(strcasecmp(type,"-internal") == 0) KnRegisterRedirect(true, method, template1, template2); else if(strcasecmp(type,"-external") == 0) KnRegisterRedirect(false, method, template1, template2); else { Tcl_AppendResult(interp,"500 Unknown type of redirect: '",type,"'",0); return TCL_ERROR; } return TCL_OK; } int kn_unregister ( void * context, Tcl_Interp* interp, int objc, Tcl_Obj * objv[]) { if (objc < 4) { KnTcl_WrongNumArgs(interp,1,objv,"string"); return TCL_ERROR; } char* type(Tcl_GetString(objv[1])); bool success; if(strcasecmp(type,"-redirect") == 0) { char* method(Tcl_GetString(objv[2])); char* from(Tcl_GetString(objv[3])); success = KnUnregisterRedirect(method,from); } else if(strcasecmp(type,"-filter") == 0) { char* why(Tcl_GetString(objv[4])); char* method(Tcl_GetString(objv[2])); char* temp(Tcl_GetString(objv[3])); success = KnUnregisterFilter(Ns_TclInterpServer(interp),method,atoi(why),temp); } else if(strcasecmp(type,"-proc") == 0) { char* what(Tcl_GetString(objv[4])); char* method(Tcl_GetString(objv[2])); char* temp(Tcl_GetString(objv[3])); bool inheritable = true; if(strcasecmp(what,"-noinherit")) inheritable = false; success = KnUnregisterProc(Ns_TclInterpServer(interp),method,inheritable,temp); } else { Tcl_AppendResult(interp,"500 Unknown type of unregister: '",type,"'",0); return TCL_ERROR; } Tcl_Obj *result = Tcl_NewBooleanObj(success); Tcl_SetObjResult(interp,result); return TCL_OK ; } } // extern "C" int AddCmds(Tcl_Interp *nsInterp, void *context) { Tcl_CreateObjCommand(nsInterp, "kn_registerproc", kn_registerproc, context, NULL); Tcl_CreateObjCommand(nsInterp, "kn_registerfilter", kn_registerfilter, context, NULL); Tcl_CreateObjCommand(nsInterp, "kn_registerredirect", kn_registerredirect, context, NULL); Tcl_CreateObjCommand(nsInterp, "kn_unregister", kn_unregister, context, NULL); return 0; } } |
|
From: <co...@us...> - 2008-05-16 00:37:38
|
Update of /cvsroot/aolserver/knregistration/include In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv11750/include Added Files: knexportlibraryknregistration.h knexportlibraryknregistrationmodule.h knrcommon.h knregistration.h knrfiltermanager.h knrproceduremanager.h knrredirectmanager.h kntclapi.h Log Message: knregistration adds the ability to register procedures, filters, and indirects based on patterns in URIs. Matched portions of these URIs are added to the ns_conn "form" before delivery to the procedure, filter, or indirect request. Requires the knutil library. --- NEW FILE: knexportlibraryknregistration.h --- #ifndef KNEXPORTLIBRARYKNREGISTRATION_H /** * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * * @KNOWNOW_LICENSE_START@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The name "KnowNow" is a trademark of KnowNow, Inc. and may not * be used to endorse or promote any product without prior written * permission from KnowNow, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL KNOWNOW, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @KNOWNOW_LICENSE_END@ **/ #define KNEXPORTLIBRARYKNREGISTRATION_H #ifdef WIN32 #ifdef EXPORT_LIBRARY_KNREGISTRATION_MODULE #define EXPORT_LIBRARY_KNREGISTRATION __declspec(dllexport) #else #define EXPORT_LIBRARY_KNREGISTRATION __declspec(dllimport) #endif #else #define EXPORT_LIBRARY_KNREGISTRATION #endif #endif --- NEW FILE: knexportlibraryknregistrationmodule.h --- /* /** * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * * @KNOWNOW_LICENSE_START@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The name "KnowNow" is a trademark of KnowNow, Inc. and may not * be used to endorse or promote any product without prior written * permission from KnowNow, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL KNOWNOW, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @KNOWNOW_LICENSE_END@ **/ * Defines this modules as part of the knregistration.dll. * See knexportlibraryknregistration.h for more details. */ #define EXPORT_LIBRARY_KNREGISTRATION_MODULE #include "knexportlibraryknregistration.h" --- NEW FILE: knrcommon.h --- #ifndef KN_RCOMMON_H /** * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * * @KNOWNOW_LICENSE_START@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The name "KnowNow" is a trademark of KnowNow, Inc. and may not * be used to endorse or promote any product without prior written * permission from KnowNow, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL KNOWNOW, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @KNOWNOW_LICENSE_END@ **/ #define KN_RCOMMON_H #include "ns.h" #include "knutil/knset.h" #include "knexportlibraryknregistration.h" // append this query to the existing query in the conn bool addQueryToConn(KnSet& toAdd, Ns_Conn* conn); // remove elements from the query of the conn bool removeQueryFromConn(KnSet& toRemove, Ns_Conn* conn); // I really dislike the compilation errors we get with these // macros. Always interested in a fix. Just put the macro in; // haven't set up a configuration switch to turn it on or off. // #define KNREGDBG(a) ((a),1) #define KNREGDBG(a) (0) #endif --- NEW FILE: knregistration.h --- #ifndef __KN_REGISTRATION_H__ /** * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * * @KNOWNOW_LICENSE_START@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The name "KnowNow" is a trademark of KnowNow, Inc. and may not * be used to endorse or promote any product without prior written * permission from KnowNow, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL KNOWNOW, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @KNOWNOW_LICENSE_END@ **/ #define __KN_REGISTRATION_H__ #include "ns.h" #include "knexportlibraryknregistration.h" typedef int (KnRegisteredProc) (void *context, Ns_Conn *conn); typedef int (KnRegisteredFilter) (void *context, Ns_Conn *conn, int why); extern EXPORT_LIBRARY_KNREGISTRATION void KnRegisterProc(const char* server, const char* method, bool inheritable, const char* urlTemplate, KnRegisteredProc* proc, void* context); extern EXPORT_LIBRARY_KNREGISTRATION void KnRegisterTclProc(const char* server, const char* method, bool inheritable, const char* urlTemplate, const char* procName ,const char* args); extern EXPORT_LIBRARY_KNREGISTRATION bool KnUnregisterProc(const char* server, const char* method, bool inheritable, const char* urlTemplate); extern EXPORT_LIBRARY_KNREGISTRATION void KnRegisterFilter(const char* server, const char* method, int why, const char* urlTemplate, KnRegisteredFilter* proc, void* context); extern EXPORT_LIBRARY_KNREGISTRATION void KnRegisterTclFilter(const char* server, const char* method, int why, const char* urlTemplate, const char* procName, const char* args); extern EXPORT_LIBRARY_KNREGISTRATION bool KnUnregisterFilter(const char* server, const char* method, int why, const char* urlTemplate); extern EXPORT_LIBRARY_KNREGISTRATION void KnRegisterRedirect(bool internal, const char* method, const char* urlTemplateFrom, const char* urlTemplateTo); extern EXPORT_LIBRARY_KNREGISTRATION bool KnUnregisterRedirect(const char* method, const char* urlTemplateFrom); extern EXPORT_LIBRARY_KNREGISTRATION int KnFilterRegistered(void *context, Ns_Conn *conn, int why); #endif --- NEW FILE: knrfiltermanager.h --- #ifndef __KN_RFILTER_MANAGER_H__ /** * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * * @KNOWNOW_LICENSE_START@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The name "KnowNow" is a trademark of KnowNow, Inc. and may not * be used to endorse or promote any product without prior written * permission from KnowNow, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL KNOWNOW, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @KNOWNOW_LICENSE_END@ **/ #define __KN_RFILTER_MANAGER_H__ #include "knutil/kntemplateuri.h" #include "knexportlibraryknregistration.h" #include "knregistration.h" /* ------------------------------------------------------------------------- */ /* IKnRFilterHandler */ /* ------------------------------------------------------------------------- */ class IKnRFilterHandler { public: IKnRFilterHandler(const char* server, const char* method, int why, const char* urlTemplate); virtual ~IKnRFilterHandler(); virtual int handle(void *context, Ns_Conn *conn, int why) = 0; std::string getID(); static std::string getID(const char* server, const char* method, int why); std::string m_server; std::string m_method; int m_why; std::string m_urlTemplate; }; /* ------------------------------------------------------------------------- */ /* KnCRFilterHandler */ /* ------------------------------------------------------------------------- */ class KnCRFilterHandler : public IKnRFilterHandler { public: KnCRFilterHandler(const char* server, const char* method, int why, const char* urlTemplate, KnRegisteredFilter* proc, void* context); int handle(void *context, Ns_Conn *conn, int why); KnRegisteredFilter* m_proc; void* m_context; }; /* ------------------------------------------------------------------------- */ /* KnTclRFilterHandler */ /* ------------------------------------------------------------------------- */ class KnTclRFilterHandler : public IKnRFilterHandler { public: KnTclRFilterHandler(const char* server, const char* method, int why, const char* urlTemplate, const char* proc, const char* args); int handle(void *context, Ns_Conn *conn, int why); std::string m_proc; std::string m_args; }; /* ------------------------------------------------------------------------- */ /* KnRFilterManager */ /* ------------------------------------------------------------------------- */ class KnRFilterManager { public: void registerFilter(IKnRFilterHandler* fh); bool removeFilter(const char* server, const char* method, int why, const char* urlTemplate); int runFilters(void *context, Ns_Conn *conn, int why); typedef KnPatternList<KnTemplateURI, IKnRFilterHandler> PatternsType; typedef KnPatternFinder<std::string, PatternsType, KnTemplateURI, IKnRFilterHandler> FinderType; typedef std::vector< std::pair < KnSet*, KnSmartRef<IKnRFilterHandler> > > ResultType; private: FinderType m_filterFinder; }; #endif --- NEW FILE: knrproceduremanager.h --- #ifndef __KN_RPROCEDURE_MANAGER_H__ /** * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * * @KNOWNOW_LICENSE_START@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The name "KnowNow" is a trademark of KnowNow, Inc. and may not * be used to endorse or promote any product without prior written * permission from KnowNow, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL KNOWNOW, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @KNOWNOW_LICENSE_END@ **/ #define __KN_RPROCEDURE_MANAGER_H__ #include "knutil/kntemplateuri.h" #include "knexportlibraryknregistration.h" #include "knregistration.h" /* ------------------------------------------------------------------------- */ /* IKnRProcedureHandler */ /* ------------------------------------------------------------------------- */ class IKnRProcedureHandler { public: IKnRProcedureHandler(const char* server, const char* method, const char* urlTemplate, bool inheritable) ; virtual ~IKnRProcedureHandler(); virtual int handle(void* context, Ns_Conn* conn) = 0; virtual bool isInheritable(); std::string getID(); static std::string getID(const char* server, const char* method); bool m_inheritable; std::string m_server; std::string m_method; std::string m_urlTemplate; }; /* ------------------------------------------------------------------------- */ /* KnRProcedureInfo */ /* ------------------------------------------------------------------------- */ class KnRProcedureInfo { public: KnRProcedureInfo(); KnRProcedureInfo(IKnRProcedureHandler* ph); ~KnRProcedureInfo(); bool hasInheritable(); bool hasExact(); bool removeHandler(bool inheritable); int handle(void* context, Ns_Conn* conn); int handleInheritable(void* context, Ns_Conn* conn); void set(IKnRProcedureHandler* ph); private: IKnRProcedureHandler* m_exact; IKnRProcedureHandler* m_inheritable; }; /* ------------------------------------------------------------------------- */ /* KnCRProcedureHandler */ /* ------------------------------------------------------------------------- */ class KnCRProcedureHandler : public IKnRProcedureHandler { public: KnCRProcedureHandler(const char* server, const char* method, const char* urlTemplate, bool inheritable, KnRegisteredProc* proc, void* context); int handle(void* context, Ns_Conn* conn); KnRegisteredProc* m_proc; void* m_context; }; /* ------------------------------------------------------------------------- */ /* KnTclRProcedureHandler */ /* ------------------------------------------------------------------------- */ class KnTclRProcedureHandler : public IKnRProcedureHandler { public: KnTclRProcedureHandler(const char* server, const char* method, const char* urlTemplate, bool inheritable, const char* proc, const char* args); int handle(void* context, Ns_Conn* conn); std::string m_proc; std::string m_args; }; /* ------------------------------------------------------------------------- */ /* KnRProcedureManager */ /* ------------------------------------------------------------------------- */ class KnRProcedureManager { public: void registerProc(IKnRProcedureHandler* ph); bool removeProcedure(const char* server, const char* method, bool inheritable, const char* urlTemplate); int runProcedures(void* context, Ns_Conn* conn); typedef KnPatternSet<KnTemplateURI, KnRProcedureInfo> PatternsType; typedef KnPatternFinder<std::string, PatternsType, KnTemplateURI, KnRProcedureInfo> FinderType; typedef std::vector< std::pair < KnSet*, KnSmartRef<KnRProcedureInfo> > > ResultType; private: FinderType m_procFinder; }; #endif --- NEW FILE: knrredirectmanager.h --- #ifndef __KN_RREDIRECT_MANAGER_H__ /** * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * * @KNOWNOW_LICENSE_START@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The name "KnowNow" is a trademark of KnowNow, Inc. and may not * be used to endorse or promote any product without prior written * permission from KnowNow, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL KNOWNOW, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @KNOWNOW_LICENSE_END@ **/ #define __KN_RREDIRECT_MANAGER_H__ #include "knutil/kntemplateuri.h" #include "knexportlibraryknregistration.h" /* ------------------------------------------------------------------------- */ /* KnRRedirectInfo */ /* ------------------------------------------------------------------------- */ class KnRRedirectInfo { public: KnRRedirectInfo(bool internal, const char* method, const char* urlTemplateFrom, const char* urlTemplateTo); bool m_internal; std::string m_method; std::string m_urlTemplateFrom; std::string m_urlTemplateTo; }; /* ------------------------------------------------------------------------- */ /* KnRRedirectManager */ /* ------------------------------------------------------------------------- */ class KnRRedirectManager { public: KnRRedirectManager(); ~KnRRedirectManager(); void addRedirect(KnRRedirectInfo* ri); bool removeRedirect(const char* method, const char* urlTemplateFrom); int redirect(void* context, Ns_Conn* conn); typedef KnPatternSet<KnTemplateURI,KnRRedirectInfo> PatternSet; typedef KnPatternFinder<std::string, KnPatternSet<KnTemplateURI, KnRRedirectInfo>, KnTemplateURI, KnRRedirectInfo> FinderType; private: FinderType m_redirectFinder; }; #endif --- NEW FILE: kntclapi.h --- #ifndef __KNTCLAPI_H__ /** * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * * @KNOWNOW_LICENSE_START@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The name "KnowNow" is a trademark of KnowNow, Inc. and may not * be used to endorse or promote any product without prior written * permission from KnowNow, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL KNOWNOW, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @KNOWNOW_LICENSE_END@ **/ #define __KNTCLAPI_H__ #include "tcl.h" #include "knexportlibraryknregistration.h" namespace KnRegister_TclCommands { extern "C" { int kn_registerproc ( void * context, Tcl_Interp* interp, int objc, Tcl_Obj * objv[]); int kn_registerfilter ( void * context, Tcl_Interp* interp, int objc, Tcl_Obj * objv[]); int kn_registerredirect ( void * context, Tcl_Interp* interp, int objc, Tcl_Obj * objv[]); int kn_unregister ( void * context, Tcl_Interp* interp, int objc, Tcl_Obj * objv[]); } int AddCmds(Tcl_Interp *nsInterp, void *context); } #endif |
Update of /cvsroot/aolserver/knspnego/winlib/i386 In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv7639/winlib/i386 Added Files: comerr32.dll comerr32.lib delaydlls.lib getopt.lib gssapi32.dll gssapi32.lib kclnt32.lib krb524.lib krb5_32.dll krb5_32.lib krbcc32.lib krbv4w32.lib leashw32.lib loadfuncs.lib wshelp32.lib xpprof32.lib Log Message: First version of port of Apache's "mod_spnego" to AOLServer. Works, but is difficult to configure (relies on environment variables the way Apache does, instead of ns_section/ns_param) and needs some work for integration into the AOLServer "configure" environment. --- NEW FILE: comerr32.dll --- (This appears to be a binary file; contents omitted.) --- NEW FILE: comerr32.lib --- (This appears to be a binary file; contents omitted.) --- NEW FILE: delaydlls.lib --- (This appears to be a binary file; contents omitted.) --- NEW FILE: getopt.lib --- (This appears to be a binary file; contents omitted.) --- NEW FILE: gssapi32.dll --- (This appears to be a binary file; contents omitted.) --- NEW FILE: gssapi32.lib --- (This appears to be a binary file; contents omitted.) --- NEW FILE: kclnt32.lib --- (This appears to be a binary file; contents omitted.) --- NEW FILE: krb524.lib --- (This appears to be a binary file; contents omitted.) --- NEW FILE: krb5_32.dll --- (This appears to be a binary file; contents omitted.) --- NEW FILE: krb5_32.lib --- (This appears to be a binary file; contents omitted.) --- NEW FILE: krbcc32.lib --- (This appears to be a binary file; contents omitted.) --- NEW FILE: krbv4w32.lib --- (This appears to be a binary file; contents omitted.) --- NEW FILE: leashw32.lib --- (This appears to be a binary file; contents omitted.) --- NEW FILE: loadfuncs.lib --- (This appears to be a binary file; contents omitted.) --- NEW FILE: wshelp32.lib --- (This appears to be a binary file; contents omitted.) --- NEW FILE: xpprof32.lib --- (This appears to be a binary file; contents omitted.) |
|
From: <co...@us...> - 2008-05-16 00:27:12
|
Update of /cvsroot/aolserver/knspnego/wininclude/krb5/gssapi In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv7639/wininclude/krb5/gssapi Added Files: gssapi.h gssapi_generic.h gssapi_krb5.h Log Message: First version of port of Apache's "mod_spnego" to AOLServer. Works, but is difficult to configure (relies on environment variables the way Apache does, instead of ns_section/ns_param) and needs some work for integration into the AOLServer "configure" environment. --- NEW FILE: gssapi.h --- /* * Copyright 1993 by OpenVision Technologies, Inc. * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appears in all copies and * that both that copyright notice and this permission notice appear in * supporting documentation, and that the name of OpenVision not be used * in advertising or publicity pertaining to distribution of the software * without specific, written prior permission. OpenVision makes no * representations about the suitability of this software for any * purpose. It is provided "as is" without express or implied warranty. * * OPENVISION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO * EVENT SHALL OPENVISION BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ #ifndef _GSSAPI_H_ #define _GSSAPI_H_ /* * Determine platform-dependent configuration. */ #if defined(macintosh) || (defined(__MACH__) && defined(__APPLE__)) # include <TargetConditionals.h> # if TARGET_RT_MAC_CFM # error "Use KfM 4.0 SDK headers for CFM compilation." # endif #endif #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ #if TARGET_OS_MAC # if defined(__MWERKS__) # pragma import on # endif # pragma options align=mac68k #endif #if defined(_MSDOS) || defined(_WIN32) #include <win-mac.h> #endif #ifndef KRB5_CALLCONV #define KRB5_CALLCONV #define KRB5_CALLCONV_C #endif #define GSS_SIZEOF_INT SIZEOF_INT #define GSS_SIZEOF_LONG SIZEOF_LONG #define GSS_SIZEOF_SHORT SIZEOF_SHORT /* * First, include stddef.h to get size_t defined. */ #if HAVE_STDDEF_H #include <stddef.h> #endif /* HAVE_STDDEF_H */ /* * POSIX says that sys/types.h is where size_t is defined. */ #include <sys/types.h> /* * If the platform supports the xom.h header file, it should be included here. */ #if HAVE_XOM_H #include <xom.h> #endif /* HAVE_XOM_H */ /* * $Id: gssapi.h,v 1.1 2008/05/16 00:27:17 cobbr2 Exp $ */ /* * First, define the three platform-dependent pointer types. */ typedef void * gss_name_t; typedef void * gss_cred_id_t; typedef void * gss_ctx_id_t; /* * The following type must be defined as the smallest natural unsigned integer * supported by the platform that has at least 32 bits of precision. */ #if (GSS_SIZEOF_SHORT == 4) typedef unsigned short gss_uint32; typedef short gss_int32; #elif (GSS_SIZEOF_INT == 4) typedef unsigned int gss_uint32; typedef int gss_int32; #elif (GSS_SIZEOF_LONG == 4) typedef unsigned long gss_uint32; typedef long gss_int32; #endif #ifdef OM_STRING /* * We have included the xom.h header file. Use the definition for * OM_object identifier. */ typedef OM_object_identifier gss_OID_desc, *gss_OID; #else /* OM_STRING */ /* * We can't use X/Open definitions, so roll our own. */ typedef gss_uint32 OM_uint32; typedef struct gss_OID_desc_struct { OM_uint32 length; void *elements; } gss_OID_desc, *gss_OID; #endif /* OM_STRING */ typedef struct gss_OID_set_desc_struct { size_t count; gss_OID elements; } gss_OID_set_desc, *gss_OID_set; typedef struct gss_buffer_desc_struct { size_t length; void *value; } gss_buffer_desc, *gss_buffer_t; typedef struct gss_channel_bindings_struct { OM_uint32 initiator_addrtype; gss_buffer_desc initiator_address; OM_uint32 acceptor_addrtype; gss_buffer_desc acceptor_address; gss_buffer_desc application_data; } *gss_channel_bindings_t; /* * For now, define a QOP-type as an OM_uint32 (pending resolution of ongoing * discussions). */ typedef OM_uint32 gss_qop_t; typedef int gss_cred_usage_t; /* * Flag bits for context-level services. */ #define GSS_C_DELEG_FLAG 1 #define GSS_C_MUTUAL_FLAG 2 #define GSS_C_REPLAY_FLAG 4 #define GSS_C_SEQUENCE_FLAG 8 #define GSS_C_CONF_FLAG 16 #define GSS_C_INTEG_FLAG 32 #define GSS_C_ANON_FLAG 64 #define GSS_C_PROT_READY_FLAG 128 #define GSS_C_TRANS_FLAG 256 /* * Credential usage options */ #define GSS_C_BOTH 0 #define GSS_C_INITIATE 1 #define GSS_C_ACCEPT 2 /* * Status code types for gss_display_status */ #define GSS_C_GSS_CODE 1 #define GSS_C_MECH_CODE 2 /* * The constant definitions for channel-bindings address families */ #define GSS_C_AF_UNSPEC 0 #define GSS_C_AF_LOCAL 1 #define GSS_C_AF_INET 2 #define GSS_C_AF_IMPLINK 3 #define GSS_C_AF_PUP 4 #define GSS_C_AF_CHAOS 5 #define GSS_C_AF_NS 6 #define GSS_C_AF_NBS 7 #define GSS_C_AF_ECMA 8 #define GSS_C_AF_DATAKIT 9 #define GSS_C_AF_CCITT 10 #define GSS_C_AF_SNA 11 #define GSS_C_AF_DECnet 12 #define GSS_C_AF_DLI 13 #define GSS_C_AF_LAT 14 #define GSS_C_AF_HYLINK 15 #define GSS_C_AF_APPLETALK 16 #define GSS_C_AF_BSC 17 #define GSS_C_AF_DSS 18 #define GSS_C_AF_OSI 19 #define GSS_C_AF_X25 21 #define GSS_C_AF_NULLADDR 255 /* * Various Null values. */ #define GSS_C_NO_NAME ((gss_name_t) 0) #define GSS_C_NO_BUFFER ((gss_buffer_t) 0) #define GSS_C_NO_OID ((gss_OID) 0) #define GSS_C_NO_OID_SET ((gss_OID_set) 0) #define GSS_C_NO_CONTEXT ((gss_ctx_id_t) 0) #define GSS_C_NO_CREDENTIAL ((gss_cred_id_t) 0) #define GSS_C_NO_CHANNEL_BINDINGS ((gss_channel_bindings_t) 0) #define GSS_C_EMPTY_BUFFER {0, NULL} /* * Some alternate names for a couple of the above values. These are defined * for V1 compatibility. */ #define GSS_C_NULL_OID GSS_C_NO_OID #define GSS_C_NULL_OID_SET GSS_C_NO_OID_SET /* * Define the default Quality of Protection for per-message services. Note * that an implementation that offers multiple levels of QOP may either reserve * a value (for example zero, as assumed here) to mean "default protection", or * alternatively may simply equate GSS_C_QOP_DEFAULT to a specific explicit * QOP value. However a value of 0 should always be interpreted by a GSSAPI * implementation as a request for the default protection level. */ #define GSS_C_QOP_DEFAULT 0 /* * Expiration time of 2^32-1 seconds means infinite lifetime for a * credential or security context */ #define GSS_C_INDEFINITE ((OM_uint32) 0xfffffffful) /* Major status codes */ #define GSS_S_COMPLETE 0 /* * Some "helper" definitions to make the status code macros obvious. */ #define GSS_C_CALLING_ERROR_OFFSET 24 #define GSS_C_ROUTINE_ERROR_OFFSET 16 #define GSS_C_SUPPLEMENTARY_OFFSET 0 #define GSS_C_CALLING_ERROR_MASK ((OM_uint32) 0377ul) #define GSS_C_ROUTINE_ERROR_MASK ((OM_uint32) 0377ul) #define GSS_C_SUPPLEMENTARY_MASK ((OM_uint32) 0177777ul) /* * The macros that test status codes for error conditions. Note that the * GSS_ERROR() macro has changed slightly from the V1 GSSAPI so that it now * evaluates its argument only once. */ #define GSS_CALLING_ERROR(x) \ ((x) & (GSS_C_CALLING_ERROR_MASK << GSS_C_CALLING_ERROR_OFFSET)) #define GSS_ROUTINE_ERROR(x) \ ((x) & (GSS_C_ROUTINE_ERROR_MASK << GSS_C_ROUTINE_ERROR_OFFSET)) #define GSS_SUPPLEMENTARY_INFO(x) \ ((x) & (GSS_C_SUPPLEMENTARY_MASK << GSS_C_SUPPLEMENTARY_OFFSET)) #define GSS_ERROR(x) \ ((x) & ((GSS_C_CALLING_ERROR_MASK << GSS_C_CALLING_ERROR_OFFSET) | \ (GSS_C_ROUTINE_ERROR_MASK << GSS_C_ROUTINE_ERROR_OFFSET))) /* * Now the actual status code definitions */ /* * Calling errors: */ #define GSS_S_CALL_INACCESSIBLE_READ \ (((OM_uint32) 1ul) << GSS_C_CALLING_ERROR_OFFSET) #define GSS_S_CALL_INACCESSIBLE_WRITE \ (((OM_uint32) 2ul) << GSS_C_CALLING_ERROR_OFFSET) #define GSS_S_CALL_BAD_STRUCTURE \ (((OM_uint32) 3ul) << GSS_C_CALLING_ERROR_OFFSET) /* * Routine errors: */ #define GSS_S_BAD_MECH (((OM_uint32) 1ul) << GSS_C_ROUTINE_ERROR_OFFSET) #define GSS_S_BAD_NAME (((OM_uint32) 2ul) << GSS_C_ROUTINE_ERROR_OFFSET) #define GSS_S_BAD_NAMETYPE (((OM_uint32) 3ul) << GSS_C_ROUTINE_ERROR_OFFSET) #define GSS_S_BAD_BINDINGS (((OM_uint32) 4ul) << GSS_C_ROUTINE_ERROR_OFFSET) #define GSS_S_BAD_STATUS (((OM_uint32) 5ul) << GSS_C_ROUTINE_ERROR_OFFSET) #define GSS_S_BAD_SIG (((OM_uint32) 6ul) << GSS_C_ROUTINE_ERROR_OFFSET) #define GSS_S_NO_CRED (((OM_uint32) 7ul) << GSS_C_ROUTINE_ERROR_OFFSET) #define GSS_S_NO_CONTEXT (((OM_uint32) 8ul) << GSS_C_ROUTINE_ERROR_OFFSET) #define GSS_S_DEFECTIVE_TOKEN (((OM_uint32) 9ul) << GSS_C_ROUTINE_ERROR_OFFSET) #define GSS_S_DEFECTIVE_CREDENTIAL \ (((OM_uint32) 10ul) << GSS_C_ROUTINE_ERROR_OFFSET) #define GSS_S_CREDENTIALS_EXPIRED \ (((OM_uint32) 11ul) << GSS_C_ROUTINE_ERROR_OFFSET) #define GSS_S_CONTEXT_EXPIRED \ (((OM_uint32) 12ul) << GSS_C_ROUTINE_ERROR_OFFSET) #define GSS_S_FAILURE (((OM_uint32) 13ul) << GSS_C_ROUTINE_ERROR_OFFSET) #define GSS_S_BAD_QOP (((OM_uint32) 14ul) << GSS_C_ROUTINE_ERROR_OFFSET) #define GSS_S_UNAUTHORIZED (((OM_uint32) 15ul) << GSS_C_ROUTINE_ERROR_OFFSET) #define GSS_S_UNAVAILABLE (((OM_uint32) 16ul) << GSS_C_ROUTINE_ERROR_OFFSET) #define GSS_S_DUPLICATE_ELEMENT \ (((OM_uint32) 17ul) << GSS_C_ROUTINE_ERROR_OFFSET) #define GSS_S_NAME_NOT_MN \ (((OM_uint32) 18ul) << GSS_C_ROUTINE_ERROR_OFFSET) /* * Supplementary info bits: */ #define GSS_S_CONTINUE_NEEDED (1 << (GSS_C_SUPPLEMENTARY_OFFSET + 0)) #define GSS_S_DUPLICATE_TOKEN (1 << (GSS_C_SUPPLEMENTARY_OFFSET + 1)) #define GSS_S_OLD_TOKEN (1 << (GSS_C_SUPPLEMENTARY_OFFSET + 2)) #define GSS_S_UNSEQ_TOKEN (1 << (GSS_C_SUPPLEMENTARY_OFFSET + 3)) #define GSS_S_GAP_TOKEN (1 << (GSS_C_SUPPLEMENTARY_OFFSET + 4)) /* * Finally, function prototypes for the GSSAPI routines. */ #if defined (_WIN32) && defined (_MSC_VER) # ifdef GSS_DLL_FILE # define GSS_DLLIMP __declspec(dllexport) # else # define GSS_DLLIMP __declspec(dllimport) # endif #else # define GSS_DLLIMP #endif /* Reserved static storage for GSS_oids. Comments are quotes from RFC 2744. * * The implementation must reserve static storage for a * gss_OID_desc object containing the value * {10, (void *)"\x2a\x86\x48\x86\xf7\x12\x01\x02\x01\x01"}, * corresponding to an object-identifier value of * {iso(1) member-body(2) United States(840) mit(113554) * infosys(1) gssapi(2) generic(1) user_name(1)}. The constant * GSS_C_NT_USER_NAME should be initialized to point * to that gss_OID_desc. */ GSS_DLLIMP extern gss_OID GSS_C_NT_USER_NAME; /* * The implementation must reserve static storage for a * gss_OID_desc object containing the value * {10, (void *)"\x2a\x86\x48\x86\xf7\x12\x01\x02\x01\x02"}, * corresponding to an object-identifier value of * {iso(1) member-body(2) United States(840) mit(113554) * infosys(1) gssapi(2) generic(1) machine_uid_name(2)}. * The constant GSS_C_NT_MACHINE_UID_NAME should be * initialized to point to that gss_OID_desc. */ GSS_DLLIMP extern gss_OID GSS_C_NT_MACHINE_UID_NAME; /* * The implementation must reserve static storage for a * gss_OID_desc object containing the value * {10, (void *)"\x2a\x86\x48\x86\xf7\x12\x01\x02\x01\x03"}, * corresponding to an object-identifier value of * {iso(1) member-body(2) United States(840) mit(113554) * infosys(1) gssapi(2) generic(1) string_uid_name(3)}. * The constant GSS_C_NT_STRING_UID_NAME should be * initialized to point to that gss_OID_desc. */ GSS_DLLIMP extern gss_OID GSS_C_NT_STRING_UID_NAME; /* * The implementation must reserve static storage for a * gss_OID_desc object containing the value * {6, (void *)"\x2b\x06\x01\x05\x06\x02"}, * corresponding to an object-identifier value of * {iso(1) org(3) dod(6) internet(1) security(5) * nametypes(6) gss-host-based-services(2)). The constant * GSS_C_NT_HOSTBASED_SERVICE_X should be initialized to point * to that gss_OID_desc. This is a deprecated OID value, and * implementations wishing to support hostbased-service names * should instead use the GSS_C_NT_HOSTBASED_SERVICE OID, * defined below, to identify such names; * GSS_C_NT_HOSTBASED_SERVICE_X should be accepted a synonym * for GSS_C_NT_HOSTBASED_SERVICE when presented as an input * parameter, but should not be emitted by GSS-API * implementations */ GSS_DLLIMP extern gss_OID GSS_C_NT_HOSTBASED_SERVICE_X; /* * The implementation must reserve static storage for a * gss_OID_desc object containing the value * {10, (void *)"\x2a\x86\x48\x86\xf7\x12" * "\x01\x02\x01\x04"}, corresponding to an * object-identifier value of {iso(1) member-body(2) * Unites States(840) mit(113554) infosys(1) gssapi(2) * generic(1) service_name(4)}. The constant * GSS_C_NT_HOSTBASED_SERVICE should be initialized * to point to that gss_OID_desc. */ GSS_DLLIMP extern gss_OID GSS_C_NT_HOSTBASED_SERVICE; /* * The implementation must reserve static storage for a * gss_OID_desc object containing the value * {6, (void *)"\x2b\x06\01\x05\x06\x03"}, * corresponding to an object identifier value of * {1(iso), 3(org), 6(dod), 1(internet), 5(security), * 6(nametypes), 3(gss-anonymous-name)}. The constant * and GSS_C_NT_ANONYMOUS should be initialized to point * to that gss_OID_desc. */ GSS_DLLIMP extern gss_OID GSS_C_NT_ANONYMOUS; /* * The implementation must reserve static storage for a * gss_OID_desc object containing the value * {6, (void *)"\x2b\x06\x01\x05\x06\x04"}, * corresponding to an object-identifier value of * {1(iso), 3(org), 6(dod), 1(internet), 5(security), * 6(nametypes), 4(gss-api-exported-name)}. The constant * GSS_C_NT_EXPORT_NAME should be initialized to point * to that gss_OID_desc. */ GSS_DLLIMP extern gss_OID GSS_C_NT_EXPORT_NAME; /* Function Prototypes */ OM_uint32 KRB5_CALLCONV gss_acquire_cred (OM_uint32 *, /* minor_status */ gss_name_t, /* desired_name */ OM_uint32, /* time_req */ gss_OID_set, /* desired_mechs */ gss_cred_usage_t, /* cred_usage */ gss_cred_id_t *, /* output_cred_handle */ gss_OID_set *, /* actual_mechs */ OM_uint32 * /* time_rec */ ); OM_uint32 KRB5_CALLCONV gss_release_cred (OM_uint32 *, /* minor_status */ gss_cred_id_t * /* cred_handle */ ); OM_uint32 KRB5_CALLCONV gss_init_sec_context (OM_uint32 *, /* minor_status */ gss_cred_id_t, /* claimant_cred_handle */ gss_ctx_id_t *, /* context_handle */ gss_name_t, /* target_name */ gss_OID, /* mech_type (used to be const) */ OM_uint32, /* req_flags */ OM_uint32, /* time_req */ gss_channel_bindings_t, /* input_chan_bindings */ gss_buffer_t, /* input_token */ gss_OID *, /* actual_mech_type */ gss_buffer_t, /* output_token */ OM_uint32 *, /* ret_flags */ OM_uint32 * /* time_rec */ ); OM_uint32 KRB5_CALLCONV gss_accept_sec_context (OM_uint32 *, /* minor_status */ gss_ctx_id_t *, /* context_handle */ gss_cred_id_t, /* acceptor_cred_handle */ gss_buffer_t, /* input_token_buffer */ gss_channel_bindings_t, /* input_chan_bindings */ gss_name_t *, /* src_name */ gss_OID *, /* mech_type */ gss_buffer_t, /* output_token */ OM_uint32 *, /* ret_flags */ OM_uint32 *, /* time_rec */ gss_cred_id_t * /* delegated_cred_handle */ ); OM_uint32 KRB5_CALLCONV gss_process_context_token (OM_uint32 *, /* minor_status */ gss_ctx_id_t, /* context_handle */ gss_buffer_t /* token_buffer */ ); OM_uint32 KRB5_CALLCONV gss_delete_sec_context (OM_uint32 *, /* minor_status */ gss_ctx_id_t *, /* context_handle */ gss_buffer_t /* output_token */ ); OM_uint32 KRB5_CALLCONV gss_context_time (OM_uint32 *, /* minor_status */ gss_ctx_id_t, /* context_handle */ OM_uint32 * /* time_rec */ ); /* New for V2 */ OM_uint32 KRB5_CALLCONV gss_get_mic (OM_uint32 *, /* minor_status */ gss_ctx_id_t, /* context_handle */ gss_qop_t, /* qop_req */ gss_buffer_t, /* message_buffer */ gss_buffer_t /* message_token */ ); /* New for V2 */ OM_uint32 KRB5_CALLCONV gss_verify_mic (OM_uint32 *, /* minor_status */ gss_ctx_id_t, /* context_handle */ gss_buffer_t, /* message_buffer */ gss_buffer_t, /* message_token */ gss_qop_t * /* qop_state */ ); /* New for V2 */ OM_uint32 KRB5_CALLCONV gss_wrap (OM_uint32 *, /* minor_status */ gss_ctx_id_t, /* context_handle */ int, /* conf_req_flag */ gss_qop_t, /* qop_req */ gss_buffer_t, /* input_message_buffer */ int *, /* conf_state */ gss_buffer_t /* output_message_buffer */ ); /* New for V2 */ OM_uint32 KRB5_CALLCONV gss_unwrap (OM_uint32 *, /* minor_status */ gss_ctx_id_t, /* context_handle */ gss_buffer_t, /* input_message_buffer */ gss_buffer_t, /* output_message_buffer */ int *, /* conf_state */ gss_qop_t * /* qop_state */ ); OM_uint32 KRB5_CALLCONV gss_display_status (OM_uint32 *, /* minor_status */ OM_uint32, /* status_value */ int, /* status_type */ gss_OID, /* mech_type (used to be const) */ OM_uint32 *, /* message_context */ gss_buffer_t /* status_string */ ); OM_uint32 KRB5_CALLCONV gss_indicate_mechs (OM_uint32 *, /* minor_status */ gss_OID_set * /* mech_set */ ); OM_uint32 KRB5_CALLCONV gss_compare_name (OM_uint32 *, /* minor_status */ gss_name_t, /* name1 */ gss_name_t, /* name2 */ int * /* name_equal */ ); OM_uint32 KRB5_CALLCONV gss_display_name (OM_uint32 *, /* minor_status */ gss_name_t, /* input_name */ gss_buffer_t, /* output_name_buffer */ gss_OID * /* output_name_type */ ); OM_uint32 KRB5_CALLCONV gss_import_name (OM_uint32 *, /* minor_status */ gss_buffer_t, /* input_name_buffer */ gss_OID, /* input_name_type(used to be const) */ gss_name_t * /* output_name */ ); OM_uint32 KRB5_CALLCONV gss_release_name (OM_uint32 *, /* minor_status */ gss_name_t * /* input_name */ ); OM_uint32 KRB5_CALLCONV gss_release_buffer (OM_uint32 *, /* minor_status */ gss_buffer_t /* buffer */ ); OM_uint32 KRB5_CALLCONV gss_release_oid_set (OM_uint32 *, /* minor_status */ gss_OID_set * /* set */ ); OM_uint32 KRB5_CALLCONV gss_inquire_cred (OM_uint32 *, /* minor_status */ gss_cred_id_t, /* cred_handle */ gss_name_t *, /* name */ OM_uint32 *, /* lifetime */ gss_cred_usage_t *, /* cred_usage */ gss_OID_set * /* mechanisms */ ); /* Last argument new for V2 */ OM_uint32 KRB5_CALLCONV gss_inquire_context (OM_uint32 *, /* minor_status */ gss_ctx_id_t, /* context_handle */ gss_name_t *, /* src_name */ gss_name_t *, /* targ_name */ OM_uint32 *, /* lifetime_rec */ gss_OID *, /* mech_type */ OM_uint32 *, /* ctx_flags */ int *, /* locally_initiated */ int * /* open */ ); /* New for V2 */ OM_uint32 KRB5_CALLCONV gss_wrap_size_limit (OM_uint32 *, /* minor_status */ gss_ctx_id_t, /* context_handle */ int, /* conf_req_flag */ gss_qop_t, /* qop_req */ OM_uint32, /* req_output_size */ OM_uint32 * /* max_input_size */ ); /* New for V2 */ OM_uint32 KRB5_CALLCONV gss_import_name_object (OM_uint32 *, /* minor_status */ void *, /* input_name */ gss_OID, /* input_name_type */ gss_name_t * /* output_name */ ); /* New for V2 */ OM_uint32 KRB5_CALLCONV gss_export_name_object (OM_uint32 *, /* minor_status */ gss_name_t, /* input_name */ gss_OID, /* desired_name_type */ void ** /* output_name */ ); /* New for V2 */ OM_uint32 KRB5_CALLCONV gss_add_cred (OM_uint32 *, /* minor_status */ gss_cred_id_t, /* input_cred_handle */ gss_name_t, /* desired_name */ gss_OID, /* desired_mech */ gss_cred_usage_t, /* cred_usage */ OM_uint32, /* initiator_time_req */ OM_uint32, /* acceptor_time_req */ gss_cred_id_t *, /* output_cred_handle */ gss_OID_set *, /* actual_mechs */ OM_uint32 *, /* initiator_time_rec */ OM_uint32 * /* acceptor_time_rec */ ); /* New for V2 */ OM_uint32 KRB5_CALLCONV gss_inquire_cred_by_mech (OM_uint32 *, /* minor_status */ gss_cred_id_t, /* cred_handle */ gss_OID, /* mech_type */ gss_name_t *, /* name */ OM_uint32 *, /* initiator_lifetime */ OM_uint32 *, /* acceptor_lifetime */ gss_cred_usage_t * /* cred_usage */ ); /* New for V2 */ OM_uint32 KRB5_CALLCONV gss_export_sec_context (OM_uint32 *, /* minor_status */ gss_ctx_id_t *, /* context_handle */ gss_buffer_t /* interprocess_token */ ); /* New for V2 */ OM_uint32 KRB5_CALLCONV gss_import_sec_context (OM_uint32 *, /* minor_status */ gss_buffer_t, /* interprocess_token */ gss_ctx_id_t * /* context_handle */ ); /* New for V2 */ OM_uint32 KRB5_CALLCONV gss_release_oid (OM_uint32 *, /* minor_status */ gss_OID * /* oid */ ); /* New for V2 */ OM_uint32 KRB5_CALLCONV gss_create_empty_oid_set (OM_uint32 *, /* minor_status */ gss_OID_set * /* oid_set */ ); /* New for V2 */ OM_uint32 KRB5_CALLCONV gss_add_oid_set_member (OM_uint32 *, /* minor_status */ gss_OID, /* member_oid */ gss_OID_set * /* oid_set */ ); /* New for V2 */ OM_uint32 KRB5_CALLCONV gss_test_oid_set_member (OM_uint32 *, /* minor_status */ gss_OID, /* member */ gss_OID_set, /* set */ int * /* present */ ); /* New for V2 */ OM_uint32 KRB5_CALLCONV gss_str_to_oid (OM_uint32 *, /* minor_status */ gss_buffer_t, /* oid_str */ gss_OID * /* oid */ ); /* New for V2 */ OM_uint32 KRB5_CALLCONV gss_oid_to_str (OM_uint32 *, /* minor_status */ gss_OID, /* oid */ gss_buffer_t /* oid_str */ ); /* New for V2 */ OM_uint32 KRB5_CALLCONV gss_inquire_names_for_mech (OM_uint32 *, /* minor_status */ gss_OID, /* mechanism */ gss_OID_set * /* name_types */ ); /* * The following routines are obsolete variants of gss_get_mic, gss_wrap, * gss_verify_mic and gss_unwrap. They should be provided by GSSAPI V2 * implementations for backwards compatibility with V1 applications. Distinct * entrypoints (as opposed to #defines) should be provided, to allow GSSAPI * V1 applications to link against GSSAPI V2 implementations. */ OM_uint32 KRB5_CALLCONV gss_sign (OM_uint32 *, /* minor_status */ gss_ctx_id_t, /* context_handle */ int, /* qop_req */ gss_buffer_t, /* message_buffer */ gss_buffer_t /* message_token */ ); OM_uint32 KRB5_CALLCONV gss_verify (OM_uint32 *, /* minor_status */ gss_ctx_id_t, /* context_handle */ gss_buffer_t, /* message_buffer */ gss_buffer_t, /* token_buffer */ int * /* qop_state */ ); OM_uint32 KRB5_CALLCONV gss_seal (OM_uint32 *, /* minor_status */ gss_ctx_id_t, /* context_handle */ int, /* conf_req_flag */ int, /* qop_req */ gss_buffer_t, /* input_message_buffer */ int *, /* conf_state */ gss_buffer_t /* output_message_buffer */ ); OM_uint32 KRB5_CALLCONV gss_unseal (OM_uint32 *, /* minor_status */ gss_ctx_id_t, /* context_handle */ gss_buffer_t, /* input_message_buffer */ gss_buffer_t, /* output_message_buffer */ int *, /* conf_state */ int * /* qop_state */ ); /* New for V2 */ OM_uint32 KRB5_CALLCONV gss_export_name (OM_uint32 *, /* minor_status */ const gss_name_t, /* input_name */ gss_buffer_t /* exported_name */ ); /* New for V2 */ OM_uint32 KRB5_CALLCONV gss_duplicate_name (OM_uint32 *, /* minor_status */ const gss_name_t, /* input_name */ gss_name_t * /* dest_name */ ); /* New for V2 */ OM_uint32 KRB5_CALLCONV gss_canonicalize_name (OM_uint32 *, /* minor_status */ const gss_name_t, /* input_name */ const gss_OID, /* mech_type */ gss_name_t * /* output_name */ ); #if TARGET_OS_MAC # if defined(__MWERKS__) # pragma import reset # endif # pragma options align=reset #endif #ifdef __cplusplus } #endif /* XXXX these are not part of the GSSAPI C bindings! (but should be) */ #define GSS_CALLING_ERROR_FIELD(x) \ (((x) >> GSS_C_CALLING_ERROR_OFFSET) & GSS_C_CALLING_ERROR_MASK) #define GSS_ROUTINE_ERROR_FIELD(x) \ (((x) >> GSS_C_ROUTINE_ERROR_OFFSET) & GSS_C_ROUTINE_ERROR_MASK) #define GSS_SUPPLEMENTARY_INFO_FIELD(x) \ (((x) >> GSS_C_SUPPLEMENTARY_OFFSET) & GSS_C_SUPPLEMENTARY_MASK) /* XXXX This is a necessary evil until the spec is fixed */ #define GSS_S_CRED_UNAVAIL GSS_S_FAILURE #endif /* _GSSAPI_H_ */ --- NEW FILE: gssapi_generic.h --- /* * Copyright 1993 by OpenVision Technologies, Inc. * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appears in all copies and * that both that copyright notice and this permission notice appear in * supporting documentation, and that the name of OpenVision not be used * in advertising or publicity pertaining to distribution of the software * without specific, written prior permission. OpenVision makes no * representations about the suitability of this software for any * purpose. It is provided "as is" without express or implied warranty. * * OPENVISION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO * EVENT SHALL OPENVISION BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ #ifndef _GSSAPI_GENERIC_H_ #define _GSSAPI_GENERIC_H_ /* * $Id: gssapi_generic.h,v 1.1 2008/05/16 00:27:17 cobbr2 Exp $ */ #include <gssapi/gssapi.h> #if defined(__cplusplus) && !defined(GSSAPIGENERIC_BEGIN_DECLS) #define GSSAPIGENERIC_BEGIN_DECLS extern "C" { #define GSSAPIGENERIC_END_DECLS } #else #define GSSAPIGENERIC_BEGIN_DECLS #define GSSAPIGENERIC_END_DECLS #endif GSSAPIGENERIC_BEGIN_DECLS /* Deprecated MIT krb5 oid names provided for compatibility. * The correct oids (GSS_C_NT_USER_NAME, etc) from rfc 2744 * are defined in gssapi.h. */ GSS_DLLIMP extern gss_OID gss_nt_user_name; GSS_DLLIMP extern gss_OID gss_nt_machine_uid_name; GSS_DLLIMP extern gss_OID gss_nt_string_uid_name; extern gss_OID gss_nt_service_name_v2; GSS_DLLIMP extern gss_OID gss_nt_service_name; extern gss_OID gss_nt_exported_name; GSSAPIGENERIC_END_DECLS #endif /* _GSSAPI_GENERIC_H_ */ --- NEW FILE: gssapi_krb5.h --- /* * Copyright 1993 by OpenVision Technologies, Inc. * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appears in all copies and * that both that copyright notice and this permission notice appear in * supporting documentation, and that the name of OpenVision not be used * in advertising or publicity pertaining to distribution of the software * without specific, written prior permission. OpenVision makes no * representations about the suitability of this software for any * purpose. It is provided "as is" without express or implied warranty. * * OPENVISION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO * EVENT SHALL OPENVISION BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ #ifndef _GSSAPI_KRB5_H_ #define _GSSAPI_KRB5_H_ #include <gssapi/gssapi.h> #include <krb5.h> /* C++ friendlyness */ #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /* Reserved static storage for GSS_oids. See rfc 1964 for more details. */ /* 2.1.1. Kerberos Principal Name Form: */ GSS_DLLIMP extern const gss_OID_desc * const GSS_KRB5_NT_PRINCIPAL_NAME; /* This name form shall be represented by the Object Identifier {iso(1) * member-body(2) United States(840) mit(113554) infosys(1) gssapi(2) * krb5(2) krb5_name(1)}. The recommended symbolic name for this type * is "GSS_KRB5_NT_PRINCIPAL_NAME". */ /* 2.1.2. Host-Based Service Name Form */ #define GSS_KRB5_NT_HOSTBASED_SERVICE_NAME GSS_C_NT_HOSTBASED_SERVICE /* This name form shall be represented by the Object Identifier {iso(1) * member-body(2) United States(840) mit(113554) infosys(1) gssapi(2) * generic(1) service_name(4)}. The previously recommended symbolic * name for this type is "GSS_KRB5_NT_HOSTBASED_SERVICE_NAME". The * currently preferred symbolic name for this type is * "GSS_C_NT_HOSTBASED_SERVICE". */ /* 2.2.1. User Name Form */ #define GSS_KRB5_NT_USER_NAME GSS_C_NT_USER_NAME /* This name form shall be represented by the Object Identifier {iso(1) * member-body(2) United States(840) mit(113554) infosys(1) gssapi(2) * generic(1) user_name(1)}. The recommended symbolic name for this * type is "GSS_KRB5_NT_USER_NAME". */ /* 2.2.2. Machine UID Form */ #define GSS_KRB5_NT_MACHINE_UID_NAME GSS_C_NT_MACHINE_UID_NAME /* This name form shall be represented by the Object Identifier {iso(1) * member-body(2) United States(840) mit(113554) infosys(1) gssapi(2) * generic(1) machine_uid_name(2)}. The recommended symbolic name for * this type is "GSS_KRB5_NT_MACHINE_UID_NAME". */ /* 2.2.3. String UID Form */ #define GSS_KRB5_NT_STRING_UID_NAME GSS_C_NT_STRING_UID_NAME /* This name form shall be represented by the Object Identifier {iso(1) * member-body(2) United States(840) mit(113554) infosys(1) gssapi(2) * generic(1) string_uid_name(3)}. The recommended symbolic name for * this type is "GSS_KRB5_NT_STRING_UID_NAME". */ extern const gss_OID_desc * const gss_mech_krb5; extern const gss_OID_desc * const gss_mech_krb5_old; extern const gss_OID_set_desc * const gss_mech_set_krb5; extern const gss_OID_set_desc * const gss_mech_set_krb5_old; extern const gss_OID_set_desc * const gss_mech_set_krb5_both; extern const gss_OID_desc * const gss_nt_krb5_name; extern const gss_OID_desc * const gss_nt_krb5_principal; extern const gss_OID_desc krb5_gss_oid_array[]; #define gss_krb5_nt_general_name gss_nt_krb5_name #define gss_krb5_nt_principal gss_nt_krb5_principal #define gss_krb5_nt_service_name gss_nt_service_name #define gss_krb5_nt_user_name gss_nt_user_name #define gss_krb5_nt_machine_uid_name gss_nt_machine_uid_name #define gss_krb5_nt_string_uid_name gss_nt_string_uid_name /* Alias for Heimdal compat. */ #define gsskrb5_register_acceptor_identity krb5_gss_register_acceptor_identity OM_uint32 KRB5_CALLCONV krb5_gss_register_acceptor_identity(const char *); OM_uint32 KRB5_CALLCONV gss_krb5_get_tkt_flags (OM_uint32 *minor_status, gss_ctx_id_t context_handle, krb5_flags *ticket_flags); OM_uint32 KRB5_CALLCONV gss_krb5_copy_ccache (OM_uint32 *minor_status, gss_cred_id_t cred_handle, krb5_ccache out_ccache); OM_uint32 KRB5_CALLCONV gss_krb5_ccache_name (OM_uint32 *minor_status, const char *name, const char **out_name); #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* _GSSAPI_KRB5_H_ */ |
|
From: <co...@us...> - 2008-05-16 00:27:11
|
Update of /cvsroot/aolserver/knspnego/tcl In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv7639/tcl Added Files: kn_spnego.tcl Log Message: First version of port of Apache's "mod_spnego" to AOLServer. Works, but is difficult to configure (relies on environment variables the way Apache does, instead of ns_section/ns_param) and needs some work for integration into the AOLServer "configure" environment. --- NEW FILE: kn_spnego.tcl --- # Copyright 2007-2008 KnowNow, Inc. # # @KNOWNOW_LICENSE_START@ # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # 3. The name "KnowNow" is a trademark of KnowNow, Inc. and may not # be used to endorse or promote any product without prior written # permission from KnowNow, Inc. # # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. # IN NO EVENT SHALL KNOWNOW, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE # GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # @KNOWNOW_LICENSE_END@ # # To use this, you register the filter using ns_registerfilter, setting # it up as a preauth filter. This can't be used as-is; it relies on # KnowNow's "knconn" utilities, which hacked in a solution for setting user # ids from authentication modules. # # ns_log Notice "kn_spnego(tcl):KNSPNEGO FINAL Started " # _kn_spnego_filter # # AOLServer HTTP filter for hooking in session recognition. # # The argument communicates the part of the URL space that users # are allowed access to without any credentials (typically the login # tree). If null, then either session cookies or basic authentication must be # provided in every request. # # The argument is applied as a [string match $arg $localurl]; the # argument is provided in the registration lines at the bottom of this file. # #AMX: Here we'll parse request Headers again, although it has been already done in # the ConnRun (Conn*) function. But since neither NS_Conn struct nor Conn struct # has appropriate field for putting auth. type, we have to do it here again, # proc _kn_spnego_filter {conn arg context} { ns_log Notice "kn_spnego_filter: 1" if {![kn_conn isconnected]} { # Not much that can be done; must be an internal operation, so we'll # let it pass through return filter_ok; } set hdrs [kn_conn get headers] #AMX: Initial request #amx: set spnego_hdr [ns_set get $hdrs Authorization] ns_log Notice "kn_spnego_filter:1.1 - Header is $spnego_hdr" if {"" == $spnego_hdr} { ns_log Notice "kn_spnego_filter:1.2 - Header is $spnego_hdr" # set auser [kn_conn get user] set vuser [kn_conn get validuser] ns_log Notice "kn_spnego_filter:1.2 - Validuser is $vuser" if {"" == $vuser } { set auth_mech Negotiate kn_conn set outputheader WWW-Authenticate $auth_mech ns_log Notice "kn_spnego_filter: 2 Unathorized: set auth_mech to $auth_mech" #kn_trace "kn_spnego_filter: Unathorized: set outputheader to '$outputheader'" #AMX: would be nice to call here the ns_returnunauthorized. But currently it # handles only the Basic auth. mechanism. So we'll take care about respond #ns_returnunauthorized ns_respond -status 401 -string "HTTP/1.0 401 Unauthorized" ns_log Notice "kn_spnego_filter: 3 - return_filter" return filter_return; # #conn with valid user } elseif {"" !=$vuser} { kn_trace "kn_spnego_filter: the connection already has a valid user - '$vuser'" #auth. ok continue with authorization ns_log Notice "kn_spnego_filter: 4" return filter_break } #the header contains Authorization key word } elseif {"" != $spnego_hdr} { ns_log Notice "kn_spnego_filter: 5 header is $spnego_hdr" #the Auth. mechanis is negotiate if {"Negotiate" == [set auth_mech [lindex [split $spnego_hdr \ ] 0]]} { ns_log Notice "kn_spnego_filter: 6 auth_mechis $auth_mech" # move decoding to the knspnego set token [lindex [split $spnego_hdr \ ] 1] #Calling SPNEGO module; if successfull conn will have a valid user name kn_trace "kn_spnego_filter: Calling kn_spnego auth-module " ns_log Notice "kn_spnego_filter: 7 Calling knspnego auth-module:TOKEN IS $token" #set auser [kn_spnego conn $token] set auser [kn_spnego $token] set userid [lindex [split $auser @ ] 0] ns_log notice "kn_spnego_filter: 6.0 The userid Is '$userid'" kn_conn set validuser $userid #kn_conn set validuser [lindex [split $auser @ ] 0] # ns_log Notice "kn_spnego_filter: 6.1 After Authentication is The User is '$validuser'" ns_log Notice "kn_spnego_filter: 6.2 After Authentication is The User is '$auser'" if { "" != $auser } { #AMX: the user and domain has been injected in conn structure in knspnego kn_trace "kn_spnego_filter: Authentication is succesfull. The User is '$auser'" # auth. ok continue with authorization ns_log Notice "kn_spnego_filter: 7 Authentication is succesfull. The User is '$auser'" # ns_return -status "200 OK" -type text/plain -string "Session $sessiontopic is still active" # ns_respond -status "200" -type text/plain -string "OK" #return filter_ok; return filter_break; } else { #SPMEGO: auth failed: no valid credentials were provided or may be sec. context not complete RFC 2274 kn_conn set outputheader WWW-Authenticate $auth_mech # kn_trace "kn_spnego_filter: Unathorized - No valid User: set outputheader to '$outputheader'" #ns_log Notice "kn_spnego_filter: 8 Unathorized - No valid User: set outputheader to $auth_mech" ns_respond -status 401 -string "HTTP/1.0 401 Unauthorized" return filter_return; } } else { #AMX: different Authentication mechanism is supported by the client kn_trace "kn_spnego_filter: Client supports '$auth_mech' Authentication mechanism" ns_log Notice "kn_spnego_filter: 9 Client supports '$auth_mech' Authentication mechanism" # It is not Negotiate PROTOCOL- continue filter processing return filter_ok; } } return filter_ok; } |
Update of /cvsroot/aolserver/knspnego/include In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv7639/include Added Files: base64.h knexportlibraryknspnego.h knexportlibraryknspnegomodule.h spnegoconfig.h spnegohelp.h Log Message: First version of port of Apache's "mod_spnego" to AOLServer. Works, but is difficult to configure (relies on environment variables the way Apache does, instead of ns_section/ns_param) and needs some work for integration into the AOLServer "configure" environment. --- NEW FILE: base64.h --- /* Copyright 2000-2005 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. * The apr_vsnprintf/apr_snprintf functions are based on, and used with the * permission of, the SIO stdio-replacement strx_* functions by Panos * Tsirigotis <pa...@al...> for xinetd. */ /** * @file base64.h * @brief APR-UTIL Base64 Encoding */ #ifndef BASE64_H #define BASE64_H //#include "apu.h" //#include "apr_general.h" #ifdef __cplusplus extern "C" { #endif /** * @defgroup APR_Util_Base64 Base64 Encoding * @ingroup APR_Util * @{ */ /* Simple BASE64 encode/decode functions. * * As we might encode binary strings, hence we require the length of * the incoming plain source. And return the length of what we decoded. * * The decoding function takes any non valid char (i.e. whitespace, \0 * or anything non A-Z,0-9 etc as terminal. * * plain strings/binary sequences are not assumed '\0' terminated. Encoded * strings are neither. But probably should. * */ /** * Given the length of an un-encrypted string, get the length of the * encrypted string. * @param len the length of an unencrypted string. * @return the length of the string after it is encrypted */ int base64_encode_len(int len); /** * Encode a text string using base64encoding. * @param coded_dst The destination string for the encoded string. * @param plain_src The original string in plain text * @param len_plain_src The length of the plain text string * @return the length of the encoded string */ int base64_encode(char * coded_dst, const char *plain_src, int len_plain_src); /** * Encode an EBCDIC string using base64encoding. * @param coded_dst The destination string for the encoded string. * @param plain_src The original string in plain text * @param len_plain_src The length of the plain text string * @return the length of the encoded string */ int base64_encode_binary(char * coded_dst, const unsigned char *plain_src, int len_plain_src); /** * Determine the length of a plain text string given the encoded version * @param coded_src The encoded string * @return the length of the plain text string */ int base64_decode_len(const char * coded_src); /** * Decode a string to plain text * @param plain_dst The destination string for the plain text * @param coded_src The encoded string * @return the length of the plain text string */ int base64_decode(char * plain_dst, const char *coded_src); /** * Decode an EBCDIC string to plain text * @param plain_dst The destination string for the plain text * @param coded_src The encoded string * @return the length of the plain text string */ int base64_decode_binary(unsigned char * plain_dst, const char *coded_src); /** @} */ #ifdef __cplusplus } #endif #endif /* !bASE64_H */ --- NEW FILE: knexportlibraryknspnego.h --- /* /** * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * * @KNOWNOW_LICENSE_START@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The name "KnowNow" is a trademark of KnowNow, Inc. and may not * be used to endorse or promote any product without prior written * permission from KnowNow, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL KNOWNOW, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @KNOWNOW_LICENSE_END@ **/ * Defines export/import declarations for windows interfaces for this dll. * It is important to declare this as export when compiling modules in the dll * and import for modules not in the dll. */ #ifndef KNEXPORTLIBRARYKNSPNEGO_H #define KNEXPORTLIBRARYKNSPNEGO_H #ifdef WIN32 #ifdef EXPORT_LIBRARY_KNSPNEGO_MODULE #define EXPORT_LIBRARY_KNSPNEGO __declspec(dllexport) #else #define EXPORT_LIBRARY_KNSPNEGO __declspec(dllimport) #endif #else #define EXPORT_LIBRARY_KNSPNEGO #endif #endif /* KNEXPORTLIBRARYKNSPNEGO_H */ --- NEW FILE: knexportlibraryknspnegomodule.h --- /* /** * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * * @KNOWNOW_LICENSE_START@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The name "KnowNow" is a trademark of KnowNow, Inc. and may not * be used to endorse or promote any product without prior written * permission from KnowNow, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL KNOWNOW, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @KNOWNOW_LICENSE_END@ **/ * Defines this modules as part of the knconfig.dll. * See knexportlibraryknconfig.h for more details. */ #define EXPORT_LIBRARY_KNSPNEGO_MODULE #include "knexportlibraryknspnego.h" --- NEW FILE: spnegoconfig.h --- /* ----------------------------------------------------------------------------- /** * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * * @KNOWNOW_LICENSE_START@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The name "KnowNow" is a trademark of KnowNow, Inc. and may not * be used to endorse or promote any product without prior written * permission from KnowNow, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL KNOWNOW, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @KNOWNOW_LICENSE_END@ **/ * spnegoconfig.h declares classes for handling configuration parameters. * * Author: Avet Mnatsakanian * * ----------------------------------------------------------------------------- */ #ifndef SPNEGOCONFIG_H #define SPNEGOCONFIG_H #define APR_HAS_ANSI_FS 1 #define APR_HAS_UNICODE_FS 0 #define APR_SUCCESS 0 #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 /*#ifdef __cplusplus extern "C" { #endif */ #include "ns.h" #include <openssl/asn1.h> /* Object identifier declarations. */ extern const ASN1_OBJECT spnegoGssApi; /* 1.3.6.1.5.5.2 */ /* ----------------------------------------------------------------------------- * makeNegTokenTarg makes an RFC 2478 SPNEGO NegTokenTarg (token) from an * RFC 1964 Kerberos GSS-API token. * * If makeNegTokenTarg is successful, call free (*negTokenTarg) to free the * memory allocated by parseNegTokenInit. * * Returns 0 if successful, 1 otherwise. * ----------------------------------------------------------------------------- */ class DIRECTORY_CONFIG { private: const char * krb5KeyTabFile; const char * krb5ServiceName; public: void setKrb5KeyTabFile(char *tabFile){krb5KeyTabFile = tabFile;} void setKrb5ServiceName(char *srvcName){krb5ServiceName = srvcName;} const char* getKrb5KeyTabFile(){return krb5KeyTabFile;} const char* getKrb5ServiceName(){return krb5ServiceName;} }; // DIRECTORY_CONFIG; class SERVER_CONFIG { int krb5AuthEachReq; public: void setKrb5AuthEachReq(int on){krb5AuthEachReq = on;} int getKrb5AuthEachReq(){return krb5AuthEachReq;} }; class SPNEGO_CONFIG { public: static DIRECTORY_CONFIG *directoryConfig ; static SERVER_CONFIG *serverConfig; static const char *authType; static void setAuthType(char *type) {authType = type;} static const char *getAuthType() {return authType;} static DIRECTORY_CONFIG* getDirConfig(){return directoryConfig;}; static SERVER_CONFIG* getServerConfig(){return serverConfig;}; }; int apr_env_set(const char *envvar, const char *value); //int authenticateUser (Conn *connPtr, const char *authToken); /* #ifdef __cplusplus } #endif */ #endif /*SPNEGOCONFIG_H */ --- NEW FILE: spnegohelp.h --- /* ----------------------------------------------------------------------------- * spnegohelp.h declares RFC 2478 SPNEGO GSS-API mechanism helper APIs. * * Author: Frank Balluffi * * Copyright (C) 2002-2005 Frank Balluffi. All rights reserved. * ----------------------------------------------------------------------------- */ #ifndef SPNEGOHELP_H #define SPNEGOHELP_H #ifdef __cplusplus extern "C" { #endif #include <openssl/asn1.h> //#include <stddef.h> /* Object identifier declarations. */ extern const ASN1_OBJECT spnegoGssApi; /* 1.3.6.1.5.5.2 */ /* ----------------------------------------------------------------------------- * makeSpnegoInitialToken makes an RFC 2743 GSS-API InitialContextToken * containing an RFC 2478 SPNEGO NegotiationToken of choice negTokenInit from a * mechanism token. * * If makeSpnegoInitialToken is successful, call free (spnegoToken), where * spnegoToken is of type unsigned char *, to free the memory allocated by * makeSpnegoInitialToken. * * Returns 1 if successful, 0 otherwise. * ----------------------------------------------------------------------------- */ int makeSpnegoInitialToken (const ASN1_OBJECT * mechType, const unsigned char * mechToken, size_t mechTokenLength, unsigned char ** spnegoToken, size_t * spnegoTokenLength); /* ----------------------------------------------------------------------------- * makeSpnegoTargetToken makes an RFC 2743 GSS-API InitialContextToken * containing an RFC 2478 SPNEGO NegotiationToken of choice negTokenTarg from a * response token. * * If makeSpnegoTargetToken is successful, call free (spnegoToken), where * spnegoToken is of type unsigned char *, to free the memory allocated by * makeSpnegoTargetToken. * * Returns 1 if successful, 0 otherwise. * ----------------------------------------------------------------------------- */ int makeSpnegoTargetToken (const long * negResult, const ASN1_OBJECT * supportedMech, const unsigned char * responseToken, size_t responseTokenLength, const unsigned char * mechListMic, size_t mechListMicLength, unsigned char ** spnegoToken, size_t * spnegoTokenLength); /* ----------------------------------------------------------------------------- * parseSpnegoInitialToken parses an RFC 2743 GSS-API InitialContextToken * containing an RFC 2478 SPNEGO NegotiationToken of choice negTokenInit, and * optionally searches for a mechanism type and extracts the mechanism token. * * If parseSpnegoInitialToken is successful, call free (mechToken), where * mechToken is of type unsigned char *, to free the memory allocated by * parseSpnegoInitialToken. * * Returns 1 if successful, 0 otherwise. * ----------------------------------------------------------------------------- */ int parseSpnegoInitialToken (const unsigned char * spnegoToken, size_t spnegoTokenLength, const ASN1_OBJECT * mechType, unsigned char ** mechToken, size_t * mechTokenLength); /* ----------------------------------------------------------------------------- * parseSpnegoTargetToken parses an RFC 2743 GSS-API InitialContextToken * containing an RFC 2478 SPNEGO NegotiationToken of choice negTokenTarg. * * If parseSpnegoTargetToken is successful, call * ASN1_OBJECT_free (supportedMech), free (responseToken) and * free (mechListMIC), where supportedMech, responseToken and mechListMIC are of * types ASN1_OBJECT *, unsigned char * and unsigned char *, to free the memory * allocated by parseSpnegoTargetToken. * * parseSpnegoTargetToken 1 if successful, 0 otherwise. * ----------------------------------------------------------------------------- */ int parseSpnegoTargetToken (const unsigned char * spnegoToken, size_t spnegoTokenLength, long * negResult, ASN1_OBJECT ** supportedMech, unsigned char ** responseToken, size_t * responseTokenLength, unsigned char ** mechListMIC, size_t * mechListMICLength); #ifdef __cplusplus } #endif #endif /* SPNEGOHELP_H */ |
|
From: <co...@us...> - 2008-05-16 00:27:11
|
Update of /cvsroot/aolserver/knspnego/src In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv7639/src Added Files: decode.c knspnego.cpp mod_spnego.cpp unix-env.cpp win32-env.cpp Log Message: First version of port of Apache's "mod_spnego" to AOLServer. Works, but is difficult to configure (relies on environment variables the way Apache does, instead of ns_section/ns_param) and needs some work for integration into the AOLServer "configure" environment. --- NEW FILE: decode.c --- /* base64 encoder/decoder. Originally part of main/util.c * but moved here so that support/ab and apr_sha1.c could * use it. This meant removing the apr_palloc()s and adding * ugly 'len' functions, which is quite a nasty cost. */ #include "base64.h" #if APR_CHARSET_EBCDIC #include "apr_xlate.h" #endif /* APR_CHARSET_EBCDIC */ static const unsigned char pr2six[256] = { //AMX #if !APR_CHARSET_EBCDIC /* ASCII table */ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 62, 64, 64, 64, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 64, 64, 64, 64, 64, 64, 64, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 64, 64, 64, 64, 64, 64, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 }; /* #if 0 #else /*APR_CHARSET_EBCDIC /* EBCDIC table 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 62, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 26, 27, 28, 29, 30, 31, 32, 33, 34, 64, 64, 64, 64, 64, 64, 64, 35, 36, 37, 38, 39, 40, 41, 42, 43, 64, 64, 64, 64, 64, 64, 64, 64, 44, 45, 46, 47, 48, 49, 50, 51, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 0, 1, 2, 3, 4, 5, 6, 7, 8, 64, 64, 64, 64, 64, 64, 64, 9, 10, 11, 12, 13, 14, 15, 16, 17, 64, 64, 64, 64, 64, 64, 64, 64, 18, 19, 20, 21, 22, 23, 24, 25, 64, 64, 64, 64, 64, 64, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 64, 64, 64, 64, 64, 64 }; #endif /*APR_CHARSET_EBCDIC*/ #if APR_CHARSET_EBCDIC static apr_xlate_t *xlate_to_ebcdic; static unsigned char os_toascii[256]; APU_DECLARE(apr_status_t) base64init_ebcdic(apr_xlate_t *to_ascii, DEBUG_BREAK apr_xlate_t *to_ebcdic) { int i; apr_size_t inbytes_left, outbytes_left; apr_status_t rv; int onoff; /* Only single-byte conversion is supported. */ rv = apr_xlate_sb_get(to_ascii, &onoff); if (rv) { return rv; } if (!onoff) { /* If conversion is not single-byte-only */ return APR_EINVAL; } rv = apr_xlate_sb_get(to_ebcdic, &onoff); if (rv) { return rv; } if (!onoff) { /* If conversion is not single-byte-only */ return APR_EINVAL; } xlate_to_ebcdic = to_ebcdic; for (i = 0; i < sizeof(os_toascii); i++) { os_toascii[i] = i; } inbytes_left = outbytes_left = sizeof(os_toascii); apr_xlate_conv_buffer(to_ascii, os_toascii, &inbytes_left, os_toascii, &outbytes_left); return APR_SUCCESS; } #endif /*APR_CHARSET_EBCDIC*/ int base64_decode_len(const char *bufcoded) { int nbytesdecoded; register const unsigned char *bufin; register int nprbytes; bufin = (const unsigned char *) bufcoded; while (pr2six[*(bufin++)] <= 63); nprbytes = (bufin - (const unsigned char *) bufcoded) - 1; nbytesdecoded = ((nprbytes + 3) / 4) * 3; return nbytesdecoded + 1; } int base64_decode(char *bufplain, const char *bufcoded) { //#if APR_CHARSET_EBCDIC // apr_size_t inbytes_left, outbytes_left; //#endif /* APR_CHARSET_EBCDIC */ int len; len = base64_decode_binary((unsigned char *) bufplain, bufcoded); #if 0 #if APR_CHARSET_EBCDIC inbytes_left = outbytes_left = len; apr_xlate_conv_buffer(xlate_to_ebcdic, bufplain, &inbytes_left, bufplain, &outbytes_left); #endif /* APR_CHARSET_EBCDIC */ #endif bufplain[len] = '\0'; return len; } /* This is the same as base64_decode() except on EBCDIC machines, where * the conversion of the output to ebcdic is left out. */ int base64_decode_binary(unsigned char *bufplain, const char *bufcoded) { int nbytesdecoded; register const unsigned char *bufin; register unsigned char *bufout; register int nprbytes; bufin = (const unsigned char *) bufcoded; while (pr2six[*(bufin++)] <= 63); nprbytes = (bufin - (const unsigned char *) bufcoded) - 1; nbytesdecoded = ((nprbytes + 3) / 4) * 3; bufout = (unsigned char *) bufplain; bufin = (const unsigned char *) bufcoded; while (nprbytes > 4) { *(bufout++) = (unsigned char) (pr2six[*bufin] << 2 | pr2six[bufin[1]] >> 4); *(bufout++) = (unsigned char) (pr2six[bufin[1]] << 4 | pr2six[bufin[2]] >> 2); *(bufout++) = (unsigned char) (pr2six[bufin[2]] << 6 | pr2six[bufin[3]]); bufin += 4; nprbytes -= 4; } /* Note: (nprbytes == 1) would be an error, so just ingore that case */ if (nprbytes > 1) { *(bufout++) = (unsigned char) (pr2six[*bufin] << 2 | pr2six[bufin[1]] >> 4); } if (nprbytes > 2) { *(bufout++) = (unsigned char) (pr2six[bufin[1]] << 4 | pr2six[bufin[2]] >> 2); } if (nprbytes > 3) { *(bufout++) = (unsigned char) (pr2six[bufin[2]] << 6 | pr2six[bufin[3]]); } nbytesdecoded -= (4 - nprbytes) & 3; return nbytesdecoded; } static const char basis_64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; int base64_encode_len(int len) { return ((len + 2) / 3 * 4) + 1; } int base64_encode(char *encoded, const char *string, int len) { #if !APR_CHARSET_EBCDIC return base64_encode_binary(encoded, (const unsigned char *) string, len); #else /* APR_CHARSET_EBCDIC */ int i; char *p; p = encoded; for (i = 0; i < len - 2; i += 3) { *p++ = basis_64[(os_toascii[string[i]] >> 2) & 0x3F]; *p++ = basis_64[((os_toascii[string[i]] & 0x3) << 4) | ((int) (os_toascii[string[i + 1]] & 0xF0) >> 4)]; *p++ = basis_64[((os_toascii[string[i + 1]] & 0xF) << 2) | ((int) (os_toascii[string[i + 2]] & 0xC0) >> 6)]; *p++ = basis_64[os_toascii[string[i + 2]] & 0x3F]; } if (i < len) { *p++ = basis_64[(os_toascii[string[i]] >> 2) & 0x3F]; if (i == (len - 1)) { *p++ = basis_64[((os_toascii[string[i]] & 0x3) << 4)]; *p++ = '='; } else { *p++ = basis_64[((os_toascii[string[i]] & 0x3) << 4) | ((int) (os_toascii[string[i + 1]] & 0xF0) >> 4)]; *p++ = basis_64[((os_toascii[string[i + 1]] & 0xF) << 2)]; } *p++ = '='; } *p++ = '\0'; return p - encoded; #endif /* APR_CHARSET_EBCDIC */ } /* This is the same as base64_encode() except on EBCDIC machines, where * the conversion of the input to ascii is left out. */ int base64_encode_binary(char *encoded, const unsigned char *string, int len) { int i; char *p; p = encoded; for (i = 0; i < len - 2; i += 3) { *p++ = basis_64[(string[i] >> 2) & 0x3F]; *p++ = basis_64[((string[i] & 0x3) << 4) | ((int) (string[i + 1] & 0xF0) >> 4)]; *p++ = basis_64[((string[i + 1] & 0xF) << 2) | ((int) (string[i + 2] & 0xC0) >> 6)]; *p++ = basis_64[string[i + 2] & 0x3F]; } if (i < len) { *p++ = basis_64[(string[i] >> 2) & 0x3F]; if (i == (len - 1)) { *p++ = basis_64[((string[i] & 0x3) << 4)]; *p++ = '='; } else { *p++ = basis_64[((string[i] & 0x3) << 4) | ((int) (string[i + 1] & 0xF0) >> 4)]; *p++ = basis_64[((string[i + 1] & 0xF) << 2)]; } *p++ = '='; } *p++ = '\0'; return p - encoded; } --- NEW FILE: knspnego.cpp --- /* /** * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * * @KNOWNOW_LICENSE_START@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The name "KnowNow" is a trademark of KnowNow, Inc. and may not * be used to endorse or promote any product without prior written * permission from KnowNow, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL KNOWNOW, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @KNOWNOW_LICENSE_END@ **/ * */ #include "knexportlibraryknspnegomodule.h" #include "ns.h" #include "spnegoconfig.h" #include <string.h> #include <fcntl.h> #include <sys/stat.h> #include <time.h> #define bzero(dst,len) memset(dst,0,len) #define bcopy(src,dst,len) memcpy(dst,src,len) extern "C" { //NS_EXPORT int Ns_ModuleVersion = 1; EXPORT_LIBRARY_KNSPNEGO int KnSpnego_ModInit(char *server, char *module); } #define b64_sizeof(x) (((sizeof(x) + 2) / 3) * 4) #define b64_size(x) (((x + 2) / 3) * 4) #define BADARGS(nl,nh,example) \ if ((argc<(nl)) || (argc>(nh))) { \ Tcl_AppendResult(interp,"wrong # args: should be \"",argv[0], \ (example),"\"",NULL); \ return NS_ERROR; \ // } #define ENC_HEADER_LEN 128 #define MIN_ENCODED_STR_LEN 59 int authenticateUser (char** authUser, const char *authToken); SPNEGO_CONFIG *spConfig = NULL; static Ns_Callback ModuleCleanup; static int spnegoInterpInit(Tcl_Interp * interp, void *context); static int kn_spnego(ClientData context, Tcl_Interp * interp, int argc, char **argv); /* *---------------------------------------------------------------------- * * KnSpnego_ModInit -- * * This is the knspnego module's entry point. AOLserver runs * this function right after the module is loaded. It is used to * read configuration data, initialize data structures, kick off * the Tcl initialization function (if any), and do other things * at startup. * * Results: * NS_OK or NS_ERROR * *---------------------------------------------------------------------- */ EXPORT_LIBRARY_KNSPNEGO int KnSpnego_ModInit(char *hServer, char * hModule) { FILE *fd = NULL; Ns_DString ds; char *publickeyfile = NULL; char *privatekeyfile = NULL; char *path = NULL; Ns_Log(Notice, "KN_SPNEGO_*****_ nit(): serv = %s module = %s", hServer, hModule ); Ns_DStringInit(&ds); SPNEGO_CONFIG *spConfig = (SPNEGO_CONFIG *)ns_malloc(sizeof(SPNEGO_CONFIG)); spConfig->directoryConfig = (DIRECTORY_CONFIG *)ns_malloc(sizeof(DIRECTORY_CONFIG)); spConfig->serverConfig = (SERVER_CONFIG *)ns_malloc(sizeof(SERVER_CONFIG)); path = Ns_ConfigGetPath(hServer, hModule, NULL); if (path) { spConfig->directoryConfig->setKrb5ServiceName( Ns_ConfigGet(path, "Krb5ServiceName")); spConfig->directoryConfig->setKrb5KeyTabFile (Ns_ConfigGet(path, "Krb5KeyTabFile")); spConfig->setAuthType(Ns_ConfigGet(path, "AuthType")); } return (Ns_TclInitInterps(hServer, spnegoInterpInit, NULL)); } /* *---------------------------------------------------------------------- * * ModuleCleanup -- * * Deallocates allocated resources. * * Results: * None * *---------------------------------------------------------------------- */ static void ModuleCleanup(void *ignored) { } /* *---------------------------------------------------------------------- * * spnegoInterpInit -- * * Register new commands with the Tcl interpreter. * * Results: * NS_OK or NS_ERROR * *---------------------------------------------------------------------- */ static int spnegoInterpInit(Tcl_Interp * interp, void *context) { Tcl_CreateCommand(interp, "kn_spnego", kn_spnego, NULL, NULL); return NS_OK; } /* *---------------------------------------------------------------------- * * kn_spnego -- * * Gets the authentication token and calls the authenticateUser() * function. Send the authentication results back to the tcl filter. * * Results: * NS_OK * *---------------------------------------------------------------------- */ static int kn_spnego(ClientData context, Tcl_Interp * interp, int argc, char **argv) { FILE *fd = NULL; int keybits = 0; int firstarg = 1; char *token = NULL; Ns_Log(Notice, "KN_SPNEGO_**********_ kn_spneg(): argsnmb = %d", argc ); // DebugBreak(); token = argv[firstarg]; char *authUser =NULL; authenticateUser (/*connPtr,*/&authUser, (const char *)token); Ns_Log(Notice, "knspnego - ***AUTHENTICATED USER Before sending IS %s", authUser); Tcl_AppendResult(interp, authUser, NULL); if(authUser) { ns_free(authUser); } return TCL_OK; } --- NEW FILE: mod_spnego.cpp --- /* ----------------------------------------------------------------------------- * mod_spnego.cpp - is modified version of mod_spnego.c to support * authentication for AOLServer, via the RFC 2478 SPNEGO GSS-API mechanism. * * Original mod_spnego.c was supporting GSS-API authentication mechanism for * Apache web server * * Assumes use from a TCL-based pre-auth filter. * * Author: Avet Mnatsakanian * Authors of original module: Frank Balluffi and Markus Moeller * */ /* Copyright 2000-2005 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. */ #include "ns.h" #include "string.h" #undef strcasecmp #undef strncasecmp #ifdef HEIMDAL #include <gssapi.h> #define gss_nt_service_name GSS_C_NT_HOSTBASED_SERVICE #elif defined(SEAM) #include <gssapi/gssapi.h> #define gss_nt_service_name GSS_C_NT_HOSTBASED_SERVICE #else #include <gssapi_generic.h> #endif #include "spnegohelp.h" #include "krb5help.h" #include "spnegoconfig.h" #include "base64.h" #include <errno.h> static char * connectionUser; DIRECTORY_CONFIG* SPNEGO_CONFIG::directoryConfig = NULL; SERVER_CONFIG* SPNEGO_CONFIG::serverConfig = NULL; const char *SPNEGO_CONFIG::authType=NULL; static int handleKerberosToken (char **authUser, const unsigned char * inputKerberosToken, size_t inputKerberosTokenLength, unsigned char ** outputKerberosToken, size_t * outputKerberosTokenLength) { gss_buffer_desc buffer = GSS_C_EMPTY_BUFFER; gss_buffer_desc serviceBuffer = GSS_C_EMPTY_BUFFER; gss_name_t clientName = GSS_C_NO_NAME; gss_ctx_id_t context = GSS_C_NO_CONTEXT; gss_cred_id_t credential = GSS_C_NO_CREDENTIAL; gss_buffer_desc inputToken = GSS_C_EMPTY_BUFFER; OM_uint32 majorStatus; OM_uint32 minorStatus1; OM_uint32 minorStatus2; gss_buffer_desc outputToken = GSS_C_EMPTY_BUFFER; int rc = TCL_OK; gss_name_t serverName = GSS_C_NO_NAME; char * ServiceName = NULL; char * Krb5ServiceName = NULL; const char * Krb5KeyTabFile = NULL; errno = 0; Krb5ServiceName = (char *)(SPNEGO_CONFIG::getDirConfig())->getKrb5ServiceName(); ServiceName = strtok(Krb5ServiceName," "); while ( ServiceName != NULL ) { serviceBuffer.value = ns_strdup(ServiceName); serviceBuffer.length = sizeof (serviceBuffer.value) ; Ns_Log(Notice, "mod_SPNEGO - handleKerberosToken_1 ServiceName=%s",ServiceName); if (strchr(ServiceName,'/')) { Ns_Log(Notice, "mod_SPNEGO - handleKerberosToken_2 "); majorStatus = gss_import_name (&minorStatus1, &serviceBuffer, (gss_OID) GSS_C_NULL_OID, &serverName); } else { Ns_Log(Notice, "mod_SPNEGO - handleKerberosToken_3 gss_nt_service_name=%s",gss_nt_service_name); Ns_Log(Notice, "mod_SPNEGO - handleKerberosToken_3 gss_nt_service_name=%s",(char *)&serverName); majorStatus = gss_import_name (&minorStatus1, &serviceBuffer, (gss_OID) gss_nt_service_name, &serverName); } ServiceName = strtok(NULL," "); if (majorStatus != GSS_S_COMPLETE) { Ns_Log(Notice, "mod_SPNEGO - handleKerberosToken_4;GSS_S_COMPLETE - not"); return HTTP_INTERNAL_SERVER_ERROR; } /* Optionally, set environment variable KRB5_KTNAME. */ Krb5KeyTabFile = (const char *)(SPNEGO_CONFIG::getDirConfig())->getKrb5KeyTabFile(); //#ifdef _WINDOWS if (Krb5KeyTabFile) { if(apr_env_set("KRB5_KTNAME", Krb5KeyTabFile ) != APR_SUCCESS) { Ns_Log(Error, "mod_SPNEGO_*******handleKerberosToken unable to set KRB5_KTNAME to %s", Krb5KeyTabFile); } else #ifdef HEIMDAL gsskrb5_register_acceptor_identity(Krb5KeyTabFile); #endif Ns_Log(Notice, "mod_SPNEGO_*******handleKerberosToken set KRB5_KTNAME to %s", Krb5KeyTabFile); ; } //#endif majorStatus = gss_acquire_cred (&minorStatus1, serverName, 0, GSS_C_NULL_OID_SET, GSS_C_ACCEPT, &credential, NULL, NULL); if (serverName != GSS_C_NO_NAME) { Ns_Log(Notice, "mod_SPNEGO - handleKerberosToken_5;GSS_C_NO_NAME - not"); gss_release_name (&minorStatus2, &serverName); serverName = GSS_C_NO_NAME; } Ns_Log(Notice, "mod_SPNEGO - handleKerberosToken_1xx majorStatus_acquire_cred=%u",majorStatus); if (majorStatus != GSS_S_COMPLETE) { // logGssApiError (APLOG_MARK, APLOG_ERR, r, "mod_spnego: gss_acquire_cred failed", majorStatus, minorStatus1); Ns_Log(Notice, "mod_SPNEGO - handleKerberosToken_6;GSS_S_COMPLETE - not"); rc = HTTP_INTERNAL_SERVER_ERROR; continue; } /* Normally, gss_accept_sec_context returns GSS_S_CONTINUE_NEEDED if it needs to be called again. In this context, gss_accept_sec_context should not return GSS_S_CONTINUE_NEEDED. If gss_accept_sec_context returns GSS_S_CONTINUE_NEEDED, the decision to release clientName is based on it's value (GSS_C_NO_NAME or not GSS_C_NO_NAME) and outputToken is delegated to gss_release_buffer -- RFC 2744 is not clear about this case. */ inputToken.value = (unsigned char *) inputKerberosToken; inputToken.length = inputKerberosTokenLength; majorStatus = gss_accept_sec_context (&minorStatus1, &context, credential, &inputToken, GSS_C_NO_CHANNEL_BINDINGS, &clientName, NULL, &outputToken, NULL, NULL, NULL); if (credential != GSS_C_NO_CREDENTIAL) { Ns_Log(Notice, "mod_SPNEGO - handleKerberosToken_7 GSS_C_NO_CREDENTIAL"); gss_release_cred (&minorStatus2, &credential); credential = GSS_C_NO_CREDENTIAL; } if (context != GSS_C_NO_CONTEXT) { Ns_Log(Notice, "mod_SPNEGO - handleKerberosToken_8 GSS_C_NO_CONTEXT"); gss_delete_sec_context (&minorStatus2, &context, GSS_C_NO_BUFFER); context = GSS_C_NO_CONTEXT; } if (majorStatus != GSS_S_COMPLETE) { // logGssApiError (APLOG_MARK, APLOG_ERR, r, "mod_spnego: gss_accept_sec_context failed", majorStatus, minorStatus1); Ns_Log(Notice, "mod_SPNEGO - handleKerberosToken_9 GSS_C_NO_CONTEXT"); rc = HTTP_INTERNAL_SERVER_ERROR; continue; } /* Pass client (or user) name to authorization hook. */ Ns_Log(Notice, "mod_SPNEGO - handleKerberosToken buffe_10r is %s", buffer); majorStatus = gss_display_name (&minorStatus1, clientName, &buffer, NULL); if (majorStatus != GSS_S_COMPLETE) { // logGssApiError (APLOG_MARK, APLOG_ERR, r, "mod_spnego: gss_display_name failed", majorStatus, minorStatus1); rc = HTTP_INTERNAL_SERVER_ERROR; goto cleanup; } /* http://httpd.apache.org/docs/misc/API.html says, "You can also see how some bugs have manifested themself, such as setting connection->user to a value from r->pool -- in this case connection exists for the lifetime of ptrans, which is longer than r->pool (especially if r->pool is a subrequest!). So the correct thing to do is to allocate from connection->pool." Apache 1.3 stores user in connection substructure of request_rec. Apache 2.0 stores user in request_rec. */ // connPtr->authUser = ns_strdup((const char*)buffer.value); *authUser = ns_strdup((const char*)buffer.value); Ns_Log(Notice, "mod_SPNEGO_*******AUTHENTICATED USER IS %s", *authUser); gss_release_buffer (&minorStatus1, &buffer); if (outputToken.length) { *outputKerberosToken = (unsigned char*)ns_malloc (outputToken.length); if (!*outputKerberosToken) { rc = HTTP_INTERNAL_SERVER_ERROR; goto cleanup; } memcpy (*outputKerberosToken, outputToken.value, outputToken.length); *outputKerberosTokenLength = outputToken.length; } rc = APR_SUCCESS;// rc = OK; goto cleanup; } ns_free(serviceBuffer.value); cleanup: if (clientName != GSS_C_NO_NAME) { gss_release_name (&minorStatus1, &clientName); clientName = GSS_C_NO_NAME; } gss_release_buffer (&minorStatus1, &outputToken); return rc; } /* ----------------------------------------------------------------------------- * handleSpnegoToken handles an RFC 2478 SPNEGO GSS-API token. * * If handleSpnegoToken is successful, call free (outputSpnegoToken), where * outputSpnegoToken is of type unsigned char *, to free the memory allocated by * handleSpnegoToken. * * Returns an Apache response code. * ----------------------------------------------------------------------------- */ static int handleSpnegoToken (/*Conn *connPtr,*/ char** authUser, const unsigned char * inputSpnegoToken, size_t inputSpnegoTokenLength, unsigned char ** outputSpnegoToken, size_t * outputSpnegoTokenLength) { /* Patch by Frank Taylor */ int brokenOID = 0; unsigned char * inputKerberosToken = NULL; size_t inputKerberosTokenLength = 0; long negResult; unsigned char * outputKerberosToken = NULL; size_t outputKerberosTokenLength = 0; int rc; errno = 0; #ifdef _DEBUG DebugBreak(); #endif if (!parseSpnegoInitialToken (inputSpnegoToken, inputSpnegoTokenLength, &krb5GssApi, &inputKerberosToken, &inputKerberosTokenLength)) { Ns_Log(Notice, "mod_SPNEGO_**********parseSpnegoInitialToken failed for 1.2.840.113554.1.2.2"); /* The correct mechanism OID does not work, let's just check the broken MS one in case this is an old W2K client. - Frank Taylor */ if (inputKerberosToken) ns_free ((void *)inputKerberosToken); inputKerberosToken = NULL; if (!parseSpnegoInitialToken (inputSpnegoToken, inputSpnegoTokenLength, &msKrb5GssApiLegacy, &inputKerberosToken, &inputKerberosTokenLength)) { Ns_Log(Notice, "mod_SPNEGO_**********parseSpnegoInitialToken failed for 1.2.840.48018.1.2.2"); /* Ideally, handleKerberosToken should be called by authenticateUser, not by handleSpnegoToken. For more information, see comment in authenticateUser. */ rc = handleKerberosToken (authUser, inputSpnegoToken, inputSpnegoTokenLength, outputSpnegoToken, outputSpnegoTokenLength); Ns_Log(Notice, "mod_SPNEGO_********** After -1 calling handleKerberosToken"); if (inputKerberosToken) ns_free ((void *)inputKerberosToken); inputKerberosToken = NULL; return rc; } //AMX: repl by NS_Log ap_log_rerror (APLOG_MARK, PORTABLE_APLOG_INFO, r, "mod_spnego: parseSpnegoInitialToken succeeded for 1.2.840.48018.1.2.2 -- probably Windows 2000 client"); brokenOID = 1; } Ns_Log(Notice, "mod_SPNEGO_********** before -2 calling handleKerberosToken"); rc = handleKerberosToken (authUser, inputKerberosToken, inputKerberosTokenLength, &outputKerberosToken, &outputKerberosTokenLength); Ns_Log(Notice, "mod_SPNEGO_********** After -2 calling handleKerberosToken outputKerberosToken=%s",&outputKerberosToken); if (inputKerberosToken) free ((void *)inputKerberosToken); negResult = 0; if (!makeSpnegoTargetToken (&negResult, /* Frank Taylor */ (brokenOID ? &msKrb5GssApiLegacy : &krb5GssApi), outputKerberosToken, outputKerberosTokenLength, NULL, 0, outputSpnegoToken, outputSpnegoTokenLength)) { Ns_Log(Notice, "mod_SPNEGO_********** After -3 calling makeSpnegoTargetToken outputSpnegoToken=%s",&outputSpnegoToken); return HTTP_INTERNAL_SERVER_ERROR; } return rc; } /* ----------------------------------------------------------------------------- * authenticateUser authenticates a user (or Apache client). * * Returns an Apache response code. * ----------------------------------------------------------------------------- */ //static int authenticateUser (Conn * conPtr) int authenticateUser (char **authUser, const char *authToken) { static unsigned char ntlmProtocol [] = {'N', 'T', 'L', 'M', 'S', 'S', 'P', 0}; const char * authType = NULL; unsigned char * inputToken = NULL; size_t inputTokenLength = NULL; //sizeof (authToken); //AMX: auth token already decoded in tcl; unsigned char * outputToken = NULL; size_t outputTokenLength = 0; int rc; char * string = NULL; errno = 0; /* Get AuthType. */ authType = SPNEGO_CONFIG::getAuthType(); //getting authType from config params if (!authType || strcasecmp (authType, "SPNEGO")) { //AMX: repl by NS_Log ap_log_rerror (APLOG_MARK, PORTABLE_APLOG_INFO, r, "mod_spnego: unrecognized AuthType \'%s\'", authType ? authType : "NULL"); return -1;// DECLINED; } //AMX: The request for already authenticatedUser (!!?). So just ret OK /*AMX TEMP if (!(SPNEGO_CONFIG::getServerConfig())->getKrb5AuthEachReq() && connectionUser) { //AMX: repl by NS_Log ap_log_rerror (APLOG_MARK, PORTABLE_APLOG_INFO, r, "mod_spnego: setting request user to %s", connectionUser); connPtr->authUser = ns_strdup(connectionUser); return APR_SUCCESS; //OK } */ //#endif //This part is done in kn_spnego_filer // authValue = apr_table_get (r->headers_in, "Authorization"); //AMX-TODO: For now we may drop this function assuming that only kn_spengo_filter // is the only caller of autUser func. And the not only authToken (Negotiate + sec_token), // but the token itself is retrieved in tcl and passed as an arg to AuthenticateUser() function //So authValue presumably is not zero if the function was called /* if (!authValue) { //AMX: repl by NS_Log ap_log_rerror (APLOG_MARK, PORTABLE_APLOG_INFO, r, "mod_spnego: sending 401 and \"WWW-Authenticate: Negotiate\""); apr_table_add (r->err_headers_out, "WWW-Authenticate", "Negotiate"); return HTTP_UNAUTHORIZED; } */ //AMX if (!strncasecmp (string, "Negotiate", 9)) //AMX { //AMX string = ap_getword_white (r->pool, &authValue); //AMX if (!string) //AMX return HTTP_UNAUTHORIZED; //AMX: all decodin is done in kn_spnego_filter by utilizing // the base64::decode library function; SO all this part is gone /************** */ //We already got the Token from tcl - so we don't need the above lines */ // inputTokenLength = base64_decode_len (string); inputTokenLength = base64_decode_len (authToken); inputToken = (unsigned char*)ns_malloc(inputTokenLength); //#endif if (!inputToken) { return HTTP_INTERNAL_SERVER_ERROR; } inputTokenLength = base64_decode ((char *)inputToken, authToken); string = NULL; /* Check if NTLM token. */ Ns_Log(Notice, "MOD_SPNEGO_*****_ authorizeUser(): Client respond to Negotiate challenge with %s auth. mechanism", &inputToken ); if (inputTokenLength >= sizeof ntlmProtocol + 1) if (!memcmp (inputToken, ntlmProtocol, sizeof ntlmProtocol)) { //AMX: repl by NS_Log ap_log_rerror (APLOG_MARK, PORTABLE_APLOG_ERR, r, "mod_spnego: received type %d NTLM token", (int) *(inputToken + sizeof ntlmProtocol)); Ns_Log(Notice, "MOD_SPNEGO_*****_ authorizeUser(): Client respond to Negotiate challenge with %s auth. mechanism", &inputToken ); return HTTP_UNAUTHORIZED; } /* Ideally, authenticateUser should parse RFC 2743 InitialContextTokens, look at mechType element and call handleSpnegoToken or handleKerberosToken. Because d2i_GSSAPI_INITIAL_CONTEXT_TOKEN fails to parse RFC 1964 Kerberos tokens (they contain non-DER token IDs after mechType element), handleSpnegoToken passes input tokens to handleKerberosToken if parseSpnegoInitialToken fails. */ Ns_Log(Notice, "MOD_SPNEGO_*****_ authenticateUser(): Before calling handleSpnegoToken" ); rc = handleSpnegoToken (/*connPtr, */authUser, inputToken, inputTokenLength, &outputToken, &outputTokenLength); Ns_Log(Notice, "MOD_SPNEGO_*****_ authenticateUser(): After calling handleSpnegoToken" ); int len = base64_encode_len ((int) outputTokenLength); string = ( char *)ns_malloc(size_t(len)); if (!string) { //AMX: repl by NS_Log ap_log_rerror (APLOG_MARK, PORTABLE_APLOG_ERR, r, "mod_spnego: apr_pcalloc failed"); if (outputToken) ns_free (outputToken); return HTTP_INTERNAL_SERVER_ERROR; } Ns_Log(Notice, "MOD_SPNEGO_*****_ authenticateUser(): outputToken = %s", outputToken ); base64_encode (string, (const char*)outputToken, (int) outputTokenLength); if (outputToken) ns_free (outputToken); /* Does apr_table_set copy string? */ //AMX: Is this mistake ? shoulddn't we see the the returning of 200 OK msg /*AMX FIND OUT WHY WE SHOULD PUT IN HEADERS apr_table_set (r->err_headers_out, "WWW-Authenticate", apr_pstrcat (r->pool, "Negotiate ", string, NULL)); //AMX: repl by NS_Log ap_log_rerror (APLOG_MARK, PORTABLE_APLOG_INFO, r, "mod_spnego: authenticateUser returning %d", rc); */ if(string) ns_free(string); return rc; } /* ----------------------------------------------------------------------------- * logGssApiError writes GSS-API messages to Apache's error log. * * Returns nothing. * ----------------------------------------------------------------------------- */ /* static void logGssApiError (const char * file, int line, int level, const request_rec * r, char * s, OM_uint32 maj_stat, OM_uint32 min_stat) { OM_uint32 gmaj_stat; OM_uint32 gmin_stat; gss_buffer_desc msg; OM_uint32 msg_ctx = 0; while (!msg_ctx) { gmaj_stat = gss_display_status (&gmin_stat, maj_stat, GSS_C_GSS_CODE, GSS_C_NULL_OID, &msg_ctx, &msg); if (gmaj_stat == GSS_S_COMPLETE) { #ifdef APACHE13 //AMX: repl by NS_Log ap_log_rerror (file, line, level, r, "%s; GSS-API: %s)", s, (char *) msg.value); #else //AMX: repl by NS_Log ap_log_rerror (file, line, level, 0, r, "%s; GSS-API: %s)", s, (char *) msg.value); #endif gss_release_buffer (&gmin_stat, &msg); break; } gss_release_buffer (&gmin_stat, &msg); } msg_ctx = 0; while (!msg_ctx) { gmaj_stat = gss_display_status (&gmin_stat, min_stat, GSS_C_MECH_CODE, GSS_C_NULL_OID, &msg_ctx, &msg); if (gmaj_stat == GSS_S_COMPLETE) { #ifdef APACHE13 //AMX: repl by NS_Log ap_log_rerror (file, line, level, r, "%s; GSS-API mechanism: %s)", s, (char *) msg.value); #else //AMX: repl by NS_Log ap_log_rerror (file, line, level, 0, r, "%s; GSS-API mechanism: %s)", s, (char *) msg.value); #endif Ns_Log(Notice, "%s: Loaded private key file: %s", hModule, privatekeyfile); gss_release_buffer (&gmin_stat, &msg); break; } gss_release_buffer (&gmin_stat, &msg); } } */ /* ----------------------------------------------------------------------------- * handlePoolCleanup handles pool cleanup. * * Is registered by calling apr_pool_cleanup_register. Is called by Apache. * * Returns an Apache status code. * ----------------------------------------------------------------------------- */ /* #ifndef APACHE13 static apr_status_t handlePoolCleanup (void * data) { connectionUser = NULL; return APR_SUCCESS; } #endif */ /* ----------------------------------------------------------------------------- * handleKerberosToken handles an RFC 1964 Kerberos GSS-API token. * * Returns an Apache response code. * ----------------------------------------------------------------------------- */ --- NEW FILE: unix-env.cpp --- /* unix-env.c */ /* Frank Balluffi modified the following code from Apache 2.0. */ /* ==================================================================== * The Apache Software License, Version 1.1 * * Copyright (c) 2000-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software itself, * if and wherever such third-party acknowledgments normally appear. * * 4. The names "Apache" and "Apache Software Foundation" must * not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact ap...@ap.... * * 5. Products derived from this software may not be called "Apache", * nor may "Apache" appear in their name, without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. */ //#ifdef APACHE13 // #include "httpd.h" //#define APR_DECLARE(rc) rc //#define APR_ENOMEM 1 //#define APR_ENOTIMPL 1 //#define APR_SUCCESS 0 //#define apr_palloc ap_palloc //#define apr_pool_t pool #ifndef _WINDOWS #define HAVE_SETENV typedef int apr_status_t; //typedef size_t apr_size_t; //APR_DECLARE(apr_status_t) apr_env_set(const char *envvar, // const char *value//, // /*apr_pool_t *pool*/) #include "spnegoconfig.h" int apr_env_set(const char *envvar, const char *value) { #if defined(HAVE_SETENV) if (0 > setenv(envvar, value, 1)) return 1; // APR_ENOMEM; return 0; //APR_SUCCESS; #elif defined(HAVE_PUTENV) apr_size_t elen = strlen(envvar); apr_size_t vlen = strlen(value); char *env = apr_palloc(pool, elen + vlen + 2); char *p = env + elen; memcpy(env, envvar, elen); *p++ = '='; memcpy(p, value, vlen); p[vlen] = '\0'; if (0 > putenv(env)) return APR_ENOMEM; return APR_SUCCESS; #else return APR_ENOTIMPL; #endif } #endif --- NEW FILE: win32-env.cpp --- /* win32-env.c */ /* Frank Balluffi modified the following code from Apache 2.0. */ /* ==================================================================== * The Apache Software License, Version 1.1 * * Copyright (c) 2000-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software itself, * if and wherever such third-party acknowledgments normally appear. * * 4. The names "Apache" and "Apache Software Foundation" must * not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact ap...@ap.... * * 5. Products derived from this software may not be called "Apache", * nor may "Apache" appear in their name, without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. */ //#include "httpd.h" /* For now, force apr_env_set to call call SetEnvironmentVariableA. */ #ifdef _WINDOWS #include "spnegoconfig.h" #define ELSE_WIN_OS_IS_ANSI #define IF_WIN_OS_IS_UNICODE int apr_env_set(const char *envvar, const char *value /*, pool *pool */) { #if APR_HAS_UNICODE_FS IF_WIN_OS_IS_UNICODE { apr_wchar_t wenvvar[APR_PATH_MAX]; apr_wchar_t *wvalue; apr_size_t inchars, outchars; apr_status_t status; status = widen_envvar_name(wenvvar, APR_PATH_MAX, envvar); if (status) return status; outchars = inchars = strlen(value) + 1; wvalue = apr_palloc(pool, outchars * sizeof(*wvalue)); status = apr_conv_utf8_to_ucs2(value, &inchars, wvalue, &outchars); if (status) return status; if (!SetEnvironmentVariableW(wenvvar, wvalue)) return apr_get_os_error(); } #endif #if APR_HAS_ANSI_FS ELSE_WIN_OS_IS_ANSI { /* If SetEnvironmentVariableA fails, return 1 -- do not call apr_get_os_error. */ if (!SetEnvironmentVariableA(envvar, value)) /* return apr_get_os_error(); */ return 1; } #endif return APR_SUCCESS; } #endif |
|
From: <co...@us...> - 2008-05-16 00:27:11
|
Update of /cvsroot/aolserver/knspnego/wininclude/krb5 In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv7639/wininclude/krb5 Added Files: com_err.h krb5.h profile.h win-mac.h Log Message: First version of port of Apache's "mod_spnego" to AOLServer. Works, but is difficult to configure (relies on environment variables the way Apache does, instead of ns_section/ns_param) and needs some work for integration into the AOLServer "configure" environment. --- NEW FILE: com_err.h --- /* * Header file for common error description library. * * Copyright 1988, Student Information Processing Board of the * Massachusetts Institute of Technology. * * Copyright 1995 by Cygnus Support. * * For copyright and distribution info, see the documentation supplied * with this package. */ #ifndef __COM_ERR_H #if defined(_WIN32) #include <win-mac.h> #endif #ifndef KRB5_CALLCONV #define KRB5_CALLCONV #define KRB5_CALLCONV_C #endif #include <stdarg.h> typedef long errcode_t; typedef void (*et_old_error_hook_func) (const char *, errcode_t, const char *, va_list ap); struct error_table { /*@shared@*/ char const * const * msgs; long base; unsigned int n_msgs; }; #ifdef __cplusplus extern "C" { #endif /* Public interfaces */ extern void KRB5_CALLCONV_C com_err (const char *, errcode_t, const char *, ...); extern void KRB5_CALLCONV com_err_va (const char *whoami, errcode_t code, const char *fmt, va_list ap); extern /*@observer@*//*@dependent@*/ const char * KRB5_CALLCONV error_message (errcode_t) /*@modifies internalState@*/; extern errcode_t KRB5_CALLCONV add_error_table (/*@dependent@*/ const struct error_table *) /*@modifies internalState@*/; extern errcode_t KRB5_CALLCONV remove_error_table (const struct error_table *) /*@modifies internalState@*/; #if !defined(_WIN32) /* * The display routine should be application specific. A global hook, * may cause inappropriate display procedures to be called between * applications under non-Unix environments. */ extern et_old_error_hook_func set_com_err_hook (et_old_error_hook_func); extern et_old_error_hook_func reset_com_err_hook (void); #endif #ifdef __cplusplus } #endif #define __COM_ERR_H #endif /* ! defined(__COM_ERR_H) */ --- NEW FILE: krb5.h --- /* * include/krb5.h * * Copyright 1989,1990,1995,2001, 2003 by the Massachusetts Institute of Technology. * All Rights Reserved. * * Export of this software from the United States of America may * require a specific license from the United States Government. * It is the responsibility of any person or organization contemplating * export to obtain such a license before exporting. * * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and * distribute this software and its documentation for any purpose and * without fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright notice and * this permission notice appear in supporting documentation, and that * the name of M.I.T. not be used in advertising or publicity pertaining * to distribution of the software without specific, written prior * permission. Furthermore if you modify this software you must label [...3024 lines suppressed...] #define ASN1_BAD_FORMAT (1859794440L) #define ASN1_PARSE_ERROR (1859794441L) #define ASN1_BAD_GMTIME (1859794442L) #define ASN1_MISMATCH_INDEF (1859794443L) #define ASN1_MISSING_EOC (1859794444L) #define ERROR_TABLE_BASE_asn1 (1859794432L) extern const struct error_table et_asn1_error_table; #if !defined(_WIN32) /* for compatibility with older versions... */ extern void initialize_asn1_error_table () /*@modifies internalState@*/; #else #define initialize_asn1_error_table() #endif #if !defined(_WIN32) #define init_asn1_err_tbl initialize_asn1_error_table #define asn1_err_base ERROR_TABLE_BASE_asn1 #endif --- NEW FILE: profile.h --- /* * profile.h */ #ifndef _KRB5_PROFILE_H #define _KRB5_PROFILE_H #if defined(_WIN32) #include <win-mac.h> #endif #if defined(macintosh) || (defined(__MACH__) && defined(__APPLE__)) # include <TargetConditionals.h> # if TARGET_RT_MAC_CFM # error "Use KfM 4.0 SDK headers for CFM compilation." # endif #endif #ifndef KRB5_CALLCONV #define KRB5_CALLCONV #define KRB5_CALLCONV_C #endif typedef struct _profile_t *profile_t; /* * Used by the profile iterator in prof_get.c */ #define PROFILE_ITER_LIST_SECTION 0x0001 #define PROFILE_ITER_SECTIONS_ONLY 0x0002 #define PROFILE_ITER_RELATIONS_ONLY 0x0004 #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ #if TARGET_OS_MAC # if defined(__MWERKS__) # pragma import on # endif #endif typedef char* profile_filespec_t; /* path as C string */ typedef char* profile_filespec_list_t; /* list of : separated paths, C string */ typedef const char * const_profile_filespec_t; /* path as C string */ typedef const char * const_profile_filespec_list_t; /* list of : separated paths, C string */ long KRB5_CALLCONV profile_init (const_profile_filespec_t *files, profile_t *ret_profile); long KRB5_CALLCONV profile_init_path (const_profile_filespec_list_t filelist, profile_t *ret_profile); long KRB5_CALLCONV profile_flush (profile_t profile); void KRB5_CALLCONV profile_abandon (profile_t profile); void KRB5_CALLCONV profile_release (profile_t profile); long KRB5_CALLCONV profile_get_values (profile_t profile, const char *const *names, char ***ret_values); void KRB5_CALLCONV profile_free_list (char **list); long KRB5_CALLCONV profile_get_string (profile_t profile, const char *name, const char *subname, const char *subsubname, const char *def_val, char **ret_string); long KRB5_CALLCONV profile_get_integer (profile_t profile, const char *name, const char *subname, const char *subsubname, int def_val, int *ret_default); long KRB5_CALLCONV profile_get_boolean (profile_t profile, const char *name, const char *subname, const char *subsubname, int def_val, int *ret_default); long KRB5_CALLCONV profile_get_relation_names (profile_t profile, const char **names, char ***ret_names); long KRB5_CALLCONV profile_get_subsection_names (profile_t profile, const char **names, char ***ret_names); long KRB5_CALLCONV profile_iterator_create (profile_t profile, const char **names, int flags, void **ret_iter); void KRB5_CALLCONV profile_iterator_free (void **iter_p); long KRB5_CALLCONV profile_iterator (void **iter_p, char **ret_name, char **ret_value); void KRB5_CALLCONV profile_release_string (char *str); long KRB5_CALLCONV profile_update_relation (profile_t profile, const char **names, const char *old_value, const char *new_value); long KRB5_CALLCONV profile_clear_relation (profile_t profile, const char **names); long KRB5_CALLCONV profile_rename_section (profile_t profile, const char **names, const char *new_name); long KRB5_CALLCONV profile_add_relation (profile_t profile, const char **names, const char *new_value); #if TARGET_OS_MAC # if defined(__MWERKS__) # pragma import reset # endif #endif #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* _KRB5_PROFILE_H */ /* * util/profile/prof_err.h: * This file is automatically generated; please do not edit it. */ #include <com_err.h> #define PROF_VERSION (-1429577728L) #define PROF_MAGIC_NODE (-1429577727L) #define PROF_NO_SECTION (-1429577726L) #define PROF_NO_RELATION (-1429577725L) #define PROF_ADD_NOT_SECTION (-1429577724L) #define PROF_SECTION_WITH_VALUE (-1429577723L) #define PROF_BAD_LINK_LIST (-1429577722L) #define PROF_BAD_GROUP_LVL (-1429577721L) #define PROF_BAD_PARENT_PTR (-1429577720L) #define PROF_MAGIC_ITERATOR (-1429577719L) #define PROF_SET_SECTION_VALUE (-1429577718L) #define PROF_EINVAL (-1429577717L) #define PROF_READ_ONLY (-1429577716L) #define PROF_SECTION_NOTOP (-1429577715L) #define PROF_SECTION_SYNTAX (-1429577714L) #define PROF_RELATION_SYNTAX (-1429577713L) #define PROF_EXTRA_CBRACE (-1429577712L) #define PROF_MISSING_OBRACE (-1429577711L) #define PROF_MAGIC_PROFILE (-1429577710L) #define PROF_MAGIC_SECTION (-1429577709L) #define PROF_TOPSECTION_ITER_NOSUPP (-1429577708L) #define PROF_INVALID_SECTION (-1429577707L) #define PROF_END_OF_SECTIONS (-1429577706L) #define PROF_BAD_NAMESET (-1429577705L) #define PROF_NO_PROFILE (-1429577704L) #define PROF_MAGIC_FILE (-1429577703L) #define PROF_FAIL_OPEN (-1429577702L) #define PROF_EXISTS (-1429577701L) #define PROF_BAD_BOOLEAN (-1429577700L) #define PROF_BAD_INTEGER (-1429577699L) #define PROF_MAGIC_FILE_DATA (-1429577698L) #define ERROR_TABLE_BASE_prof (-1429577728L) extern const struct error_table et_prof_error_table; #if !defined(_WIN32) /* for compatibility with older versions... */ extern void initialize_prof_error_table () /*@modifies internalState@*/; #else #define initialize_prof_error_table() #endif #if !defined(_WIN32) #define init_prof_err_tbl initialize_prof_error_table #define prof_err_base ERROR_TABLE_BASE_prof #endif --- NEW FILE: win-mac.h --- /* * This file is now only used on Windows */ /* * type functions split out of here to make things look nicer in the * various include files which need these definitions, as well as in * the util/ directories. */ #ifndef _KRB5_WIN_MAC_H #define _KRB5_WIN_MAC_H #ifdef _WIN32 #define ID_READ_PWD_DIALOG 10000 #define ID_READ_PWD_PROMPT 10001 #define ID_READ_PWD_PROMPT2 10002 #define ID_READ_PWD_PWD 10003 #ifdef RES_ONLY #define APSTUDIO_HIDDEN_SYMBOLS #include <windows.h> #else /* ! RES_ONLY */ #define SIZEOF_INT 4 #define SIZEOF_SHORT 2 #define SIZEOF_LONG 4 #include <windows.h> #include <limits.h> #define HAVE_LABS #ifndef SIZE_MAX /* in case Microsoft defines max size of size_t */ #define SIZE_MAX UINT_MAX #endif #ifndef KRB5_CALLCONV # define KRB5_CALLCONV __stdcall # define KRB5_CALLCONV_C __cdecl /* * Use this to mark an incorrect calling convention that has been * "immortalized" because it was incorrectly exported in a previous * release. */ # define KRB5_CALLCONV_WRONG KRB5_CALLCONV_C #endif /* !KRB5_CALLCONV */ #ifndef KRB5_SYSTYPES__ #define KRB5_SYSTYPES__ #include <sys/types.h> typedef unsigned long u_long; /* Not part of sys/types.h on the pc */ typedef unsigned int u_int; typedef unsigned short u_short; typedef unsigned char u_char; #endif /* KRB5_SYSTYPES__ */ #define MAXHOSTNAMELEN 512 #ifndef MAXPATHLEN #define MAXPATHLEN 256 /* Also for Windows temp files */ #endif #define HAVE_NETINET_IN_H #define MSDOS_FILESYSTEM #define HAVE_STRING_H #define HAVE_SRAND #define HAVE_ERRNO #define HAVE_STRDUP #define NO_USERID #define NO_PASSWORD #define WM_KERBEROS5_CHANGED "Kerberos5 Changed" #ifdef KRB4 #define WM_KERBEROS_CHANGED "Kerberos Changed" #endif /* Kerberos Windows initialization file */ #define KERBEROS_INI "kerberos.ini" #ifdef CYGNUS #define KERBEROS_HLP "kerbnet.hlp" #else #define KERBEROS_HLP "krb5clnt.hlp" #endif #define INI_DEFAULTS "Defaults" #define INI_USER "User" /* Default user */ #define INI_INSTANCE "Instance" /* Default instance */ #define INI_REALM "Realm" /* Default realm */ #define INI_POSITION "Position" #define INI_OPTIONS "Options" #define INI_DURATION "Duration" /* Ticket duration in minutes */ #define INI_EXPIRATION "Expiration" /* Action on expiration (alert or beep) */ #define INI_ALERT "Alert" #define INI_BEEP "Beep" #define INI_FILES "Files" #ifdef KRB4 #define INI_KRB_CONF "krb.conf" /* Location of krb.conf file */ #define DEF_KRB_CONF "krb.conf" /* Default name for krb.conf file */ #else #define INI_KRB5_CONF "krb5.ini" /* From k5-config.h */ #define INI_KRB_CONF INI_KRB5_CONF /* Location of krb.conf file */ #define DEF_KRB_CONF INI_KRB5_CONF /* Default name for krb.conf file */ #define INI_TICKETOPTS "TicketOptions" /* Ticket options */ #define INI_FORWARDABLE "Forwardable" /* get forwardable tickets */ #define INI_KRB_CCACHE "krb5cc" /* From k5-config.h */ #endif #define INI_KRB_REALMS "krb.realms" /* Location of krb.realms file */ #define DEF_KRB_REALMS "krb.realms" /* Default name for krb.realms file */ #define INI_RECENT_LOGINS "Recent Logins" #define INI_LOGIN "Login" #define HAS_VOID_TYPE #define HAVE_STDARG_H #define HAVE_SYS_TYPES_H #define HAVE_STDLIB_H /* This controls which encryption routines libcrypto will provide */ #define PROVIDE_DES_CBC_MD5 #define PROVIDE_DES_CBC_CRC #define PROVIDE_DES_CBC_RAW #define PROVIDE_DES_CBC_CKSUM #define PROVIDE_CRC32 #define PROVIDE_RSA_MD4 #define PROVIDE_RSA_MD5 /* #define PROVIDE_DES3_CBC_SHA */ /* #define PROVIDE_DES3_CBC_RAW */ /* #define PROVIDE_NIST_SHA */ /* Ugly. Microsoft, in stdc mode, doesn't support the low-level i/o * routines directly. Rather, they only export the _<function> version. * The following defines works around this problem. */ #include <sys\types.h> #include <sys\stat.h> #include <fcntl.h> #include <io.h> #include <process.h> #ifdef NEED_SYSERROR /* Only needed by util/et/error_message.c but let's keep the source clean */ #define sys_nerr _sys_nerr #define sys_errlist _sys_errlist #endif /* * Functions with slightly different names on the PC */ #ifndef strcasecmp #define strcasecmp stricmp #endif #ifndef strncasecmp #define strncasecmp strnicmp #endif HINSTANCE get_lib_instance(void); #endif /* !RES_ONLY */ #endif /* _WIN32 */ #define THREEPARAMOPEN(x,y,z) open(x,y,z) #ifndef KRB5_CALLCONV #define KRB5_CALLCONV #endif #ifndef KRB5_CALLCONV_C #define KRB5_CALLCONV_C #endif #endif /* _KRB5_WIN_MAC_H */ |
|
From: <co...@us...> - 2008-05-16 00:27:11
|
Update of /cvsroot/aolserver/knspnego/doc In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv7639/doc Added Files: KerbSSO4LS.doc Log Message: First version of port of Apache's "mod_spnego" to AOLServer. Works, but is difficult to configure (relies on environment variables the way Apache does, instead of ns_section/ns_param) and needs some work for integration into the AOLServer "configure" environment. --- NEW FILE: KerbSSO4LS.doc --- (This appears to be a binary file; contents omitted.) |
|
From: <co...@us...> - 2008-05-16 00:27:11
|
Update of /cvsroot/aolserver/knspnego In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv7639 Added Files: Makefile knspnego-mak.inc knspnego.mak.in knspnego.sln knspnego.vcproj Log Message: First version of port of Apache's "mod_spnego" to AOLServer. Works, but is difficult to configure (relies on environment variables the way Apache does, instead of ns_section/ns_param) and needs some work for integration into the AOLServer "configure" environment. --- NEW FILE: Makefile --- # # Library definitions # MOD = knspnego MODINIT = KnSpnego_ModInit OBJS = src/decode.o \ src/knspnego.o \ src/mod_spnego.o \ src/win32-env.o \ src/unix-env.o SRCDIR = .. CUSTOM_DEFS_FILE = knspnego.mak include ../include/ns.mak include knspnego.mak install: install-knspnego install-knspnego: $(INST) -d $(AOLSERVER)/bin winlib/i386/comerr32.dll $(INST) -d $(AOLSERVER)/bin winlib/i386/gssapi32.dll $(INST) -d $(AOLSERVER)/bin winlib/i386/krb5_32.dll --- NEW FILE: knspnego-mak.inc --- # # Location of dependencies # SUPPORT = ../../../Support FBOPENSSL = $(SUPPORT)/FbOpenSSL #KERBEROS = $(SUPPORT)/KERBEROS OPENSSL = $(SUPPORT)/OpenSSL # # Additional compiler flags # CPPFLAGS = $(CPPFLAGS) /Iwininclude/krb5/gssapi /Iwininclude/krb5 /I$(OPENSSL)/inc32 /I$(FBOPENSSL)/include # # Additional libraries # LIBS = $(LIBS) /LIBPATH:$(FBOPENSSL)/lib fbopenssl.lib /LIBPATH:winlib/i386/ gssapi32.lib /LIBPATH:$(OPENSSL)/out32dll libeay32.lib ssleay32.lib # # Additional compiler flags # CPPFLAGS = $(CPPFLAGS) /D KN_PRIVATE /I$(KNAPI)/include /I$(KNUTIL)/include --- NEW FILE: knspnego.mak.in --- # # Location of dependencies # SUPPORT = ../../../Support FBOPENSSL = $(SUPPORT)/FbOpenSSL KERBEROS = $(SUPPORT)/kerberos OPENSSL = $(SUPPORT)/OpenSSL # # Additional compiler flags # CPPFLAGS += -DKN_PRIVATE=l -I$(KERBEROS)/include/gssapi -I$(KERBEROS)/include -I$(OPENSSL)/include -I$(FBOPENSSL)/include # # Additional libraries # LDFLAGS += -L$(FBOPENSSL)/lib -lfbopenssl -L$(KERBEROS)/lib -lgssapi_krb5 -L${OPENSSL}/lib -lcrypto # # Force C++ linkage. Use ':=' to invoke immediate evaluation. # LDLIB := $(subst gcc,g++,$(LDLIB)) install: install-fbopenssl install-fbopenssl: (cd $(FBOPENSSL)/lib ; tar -cf- lib*.so*) | (cd $(AOLSERVER)/lib ; tar -xf-) --- NEW FILE: knspnego.sln --- Microsoft Visual Studio Solution File, Format Version 8.00 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "knspnego", "knspnego.vcproj", "{E7C2797C-449A-4277-AE0C-0070EA36184F}" ProjectSection(ProjectDependencies) = postProject EndProjectSection EndProject Global GlobalSection(SolutionConfiguration) = preSolution Debug = Debug Release = Release EndGlobalSection GlobalSection(ProjectConfiguration) = postSolution {E7C2797C-449A-4277-AE0C-0070EA36184F}.Debug.ActiveCfg = Debug|Win32 {E7C2797C-449A-4277-AE0C-0070EA36184F}.Debug.Build.0 = Debug|Win32 {E7C2797C-449A-4277-AE0C-0070EA36184F}.Release.ActiveCfg = Release|Win32 {E7C2797C-449A-4277-AE0C-0070EA36184F}.Release.Build.0 = Release|Win32 EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution EndGlobalSection GlobalSection(ExtensibilityAddIns) = postSolution EndGlobalSection EndGlobal --- NEW FILE: knspnego.vcproj --- <?xml version="1.0" encoding="Windows-1252"?> <VisualStudioProject ProjectType="Visual C++" Version="7.10" Name="knspnego" ProjectGUID="{E7C2797C-449A-4277-AE0C-0070EA36184F}" Keyword="Win32Proj"> <Platforms> <Platform Name="Win32"/> </Platforms> <Configurations> <Configuration Name="Debug|Win32" OutputDirectory="Debug" IntermediateDirectory="Debug" ConfigurationType="2" CharacterSet="2"> <Tool Name="VCCLCompilerTool" Optimization="0" OptimizeForProcessor="2" AdditionalIncludeDirectories="..\include;..\..\..\Support\Kerberos5\inc\krb5\;..\..\nsd;..\..\knownow\include;..\..\..\Support\FbOpenSSL\include;..\..\..\Support\OpenSSL\inc32;.\include" PreprocessorDefinitions="_DEBUG;_WINDOWS;_USRDLL;NSOPENSSL_EXPORTS;KN_PRIVATE;NSD_VERSION=\"$(VERSION)\";WIN32;FD_SETSIZE=2048;KNSPNEGO_EXPORTS" StringPooling="TRUE" MinimalRebuild="FALSE" BasicRuntimeChecks="0" RuntimeLibrary="3" EnableFunctionLevelLinking="TRUE" UsePrecompiledHeader="2" PrecompiledHeaderFile=".\Debug/knspnego.pch" AssemblerListingLocation=".\Debug/" ObjectFile=".\Debug/" ProgramDataBaseFileName=".\Debug/" BrowseInformation="1" WarningLevel="4" Detect64BitPortabilityProblems="FALSE" DebugInformationFormat="3" CompileAs="0"/> <Tool Name="VCCustomBuildTool"/> <Tool Name="VCLinkerTool" AdditionalDependencies="..\nsthread\debug\nsthread.lib ..\nsd\debug\nsd.lib ..\nstcl\debug\nstcl.lib ..\..\..\..\..\Support\FbOpenSSL\win32-debug\fbopenssl.lib ..\..\..\..\..\Support\OpenSSL\out32\ssleay32.lib ..\..\..\..\..\Support\OpenSSL\out32\libeay32.lib ws2_32.lib ..\..\..\..\..\Support\Kerberos5\lib\i386\gssapi32.lib" OutputFile="$(OutDir)/knspnego.dll" LinkIncremental="1" SuppressStartupBanner="TRUE" IgnoreAllDefaultLibraries="FALSE" GenerateDebugInformation="TRUE" ProgramDatabaseFile="$(OutDir)/knspnego.pdb" GenerateMapFile="TRUE" MapFileName=".\Debug/knspnego.map" MapExports="TRUE" MapLines="TRUE" SubSystem="0" BaseAddress="@..\base_addresses.txt,$(ProjectName)" ImportLibrary="$(OutDir)/knspnego.lib" TargetMachine="1"/> <Tool Name="VCMIDLTool"/> <Tool Name="VCPostBuildEventTool"/> <Tool Name="VCPreBuildEventTool"/> <Tool Name="VCPreLinkEventTool"/> <Tool Name="VCResourceCompilerTool"/> <Tool Name="VCWebServiceProxyGeneratorTool"/> <Tool Name="VCXMLDataGeneratorTool"/> <Tool Name="VCWebDeploymentTool"/> <Tool Name="VCManagedWrapperGeneratorTool"/> <Tool Name="VCAuxiliaryManagedWrapperGeneratorTool"/> </Configuration> <Configuration Name="Release|Win32" OutputDirectory="Release" IntermediateDirectory="Release" ConfigurationType="2" CharacterSet="2"> <Tool Name="VCCLCompilerTool" Optimization="1" InlineFunctionExpansion="1" OptimizeForProcessor="2" AdditionalIncludeDirectories=""$(KRB5DIR)\src\athena\auth\krb5\src\include";"$(KRB5DIR)\src\athena\auth\krb5\src\lib\gssapi\generic";..\..\include;..\..\nsd;..\..\knownow\include;"$(FBOPENSSLDIR)\include";"$(OPENSSLDIR)\include"" PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;KNSPNEGO_EXPORTS" StringPooling="TRUE" RuntimeLibrary="2" EnableFunctionLevelLinking="TRUE" UsePrecompiledHeader="2" AssemblerListingLocation=".\Release/" ObjectFile=".\Release/" ProgramDataBaseFileName=".\Release/" BrowseInformation="1" WarningLevel="4" Detect64BitPortabilityProblems="FALSE" DebugInformationFormat="3" CompileAs="0"/> <Tool Name="VCCustomBuildTool"/> <Tool Name="VCLinkerTool" AdditionalDependencies="..\nsthread\debug\nsthread.lib ..\nsd\debug\nsd.lib ..\nstcl\debug\nstcl.lib $(FBOPENSSLDIR)\win32-debug\fbopenssl.lib ..\..\..\..\..\Support\OpenSSL\out32\ssleay32.lib ..\..\..\..\..\Support\OpenSSL\out32\libeay32.lib ws2_32.lib $(KRB5DIR)\lib\i386\gssapi32.lib" OutputFile=".\Release/knspnego.dll" LinkIncremental="1" SuppressStartupBanner="TRUE" GenerateDebugInformation="TRUE" GenerateMapFile="TRUE" MapFileName=".\Release/knspnego.map" MapExports="TRUE" MapLines="TRUE" SubSystem="0" OptimizeReferences="0" EnableCOMDATFolding="0" ImportLibrary=".\Release/knspnego.lib" TargetMachine="1"/> <Tool Name="VCMIDLTool"/> <Tool Name="VCPostBuildEventTool"/> <Tool Name="VCPreBuildEventTool"/> <Tool Name="VCPreLinkEventTool"/> <Tool Name="VCResourceCompilerTool"/> <Tool Name="VCWebServiceProxyGeneratorTool"/> <Tool Name="VCXMLDataGeneratorTool"/> <Tool Name="VCWebDeploymentTool"/> <Tool Name="VCManagedWrapperGeneratorTool"/> <Tool Name="VCAuxiliaryManagedWrapperGeneratorTool"/> </Configuration> </Configurations> <References> </References> <Files> <Filter Name="Resource Files" Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx" UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"> </Filter> <Filter Name="Source" Filter=""> <File RelativePath=".\src\decode.c"> </File> <File RelativePath=".\src\knspnego.cpp"> </File> <File RelativePath=".\src\mod_spnego.cpp"> </File> <File RelativePath=".\src\win32-env.cpp"> </File> </Filter> <Filter Name="Include" Filter=""> <File RelativePath=".\include\base64.h"> </File> <File RelativePath=".\include\spnegoconfig.h"> </File> <File RelativePath=".\include\spnegohelp.h"> </File> </Filter> </Files> <Globals> </Globals> </VisualStudioProject> |
Update of /cvsroot/aolserver/knutil/src In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv6393/src Added Files: atomicint.cpp atomicint.il counter.cpp kncircularmapping.cpp knconsistenthash.cpp kncrashhandler.cpp kncrypt.cpp knerror.cpp knhash.cpp knlog.cpp knmarkuputil.cpp knmemory.cpp knmutex.cpp knnetwork.cpp knnewdelete.cpp knpattern.cpp knperfstatistics.cpp knregex.cpp knrwlock.cpp knrwlogginglock.cpp knset.cpp knsleep.cpp knstring.cpp knstringtokenizer.cpp knsysutility_unix.cpp knsysutility_win32.cpp kntclerrors.cpp kntclfile.cpp kntclinterp.cpp kntemplateuri.cpp kntime.cpp knurl.cpp mtrand.cpp randomnumber.cpp shahash.cpp uuidgenerator.cpp Log Message: Added this library to the AOLServer.com repository. It contains a number of C/C++ utilities, some of which integrate into AOLServer, and many of which standalone. A portion of the library is required for the knregistration module, which will be checked in next. I believe this compiles fine in "native" AOLServer, but it has not been tested recently. --- NEW FILE: atomicint.cpp --- #include "knexportlibraryknutilmodule.h" /** * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * * @KNOWNOW_LICENSE_START@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The name "KnowNow" is a trademark of KnowNow, Inc. and may not * be used to endorse or promote any product without prior written * permission from KnowNow, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL KNOWNOW, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @KNOWNOW_LICENSE_END@ **/ #include "knutil/atomicint.h" #ifndef WIN32 #include <unistd.h> #endif namespace { #ifdef WIN32 int getNumberOfProcessors() { SYSTEM_INFO si; memset(&si, 0, sizeof(si)); GetSystemInfo(&si); return si.dwNumberOfProcessors; } #else int getNumberOfProcessors() { return sysconf(_SC_NPROCESSORS_ONLN); } #endif /* WIN32 */ /* * Assume that the number of processors remains static during process * lifetime. This may be dicey if the superuser is using/abusing tools * such as Solaris's psradm. */ const int gNumberOfProcessors = getNumberOfProcessors(); #ifdef WIN32 #pragma warning(disable : 4035) /* * Return with the result in EAX. */ inline int atomicAdd(int *pcnt, int cnt) { if (gNumberOfProcessors == 1) { __asm { mov ecx, pcnt mov eax, cnt xadd dword ptr [ecx], eax add eax, cnt } } else { __asm { mov ecx, pcnt mov eax, cnt lock xadd dword ptr [ecx], eax add eax, cnt } } } #pragma warning(default : 4035) inline bool atomicCompareAndSwap(int *pcnt, int oval, int val) { unsigned char c; if (gNumberOfProcessors == 1) { __asm { mov ecx, pcnt mov eax, oval mov edx, val cmpxchg dword ptr [ecx], edx sete c } } else { __asm { mov ecx, pcnt mov eax, oval mov edx, val lock cmpxchg dword ptr [ecx], edx sete c } } return c != 0; } inline bool atomicDecrementAndTest(int *pcnt) { unsigned char c; if (gNumberOfProcessors == 1) { __asm { mov ecx, pcnt dec dword ptr [ecx] sete c } } else { __asm { mov ecx, pcnt lock dec dword ptr [ecx] sete c } } return c != 0; } inline bool atomicDoubleCompareAndSwap(int64_t *pcnt, int64_t oval, int64_t val) { unsigned char c; if (gNumberOfProcessors == 1) { __asm { mov esi, pcnt mov edx, dword ptr [oval + 4] mov eax, dword ptr [oval] mov ecx, dword ptr [val + 4] mov ebx, dword ptr [val] cmpxchg8b qword ptr [esi] sete c } } else { __asm { mov esi, pcnt mov edx, dword ptr [oval + 4] mov eax, dword ptr [oval] mov ecx, dword ptr [val + 4] mov ebx, dword ptr [val] lock cmpxchg8b qword ptr [esi] sete c } } return c != 0; } inline void atomicIncrement(int *pcnt) { if (gNumberOfProcessors == 1) { __asm { mov ecx, pcnt inc dword ptr [ecx] } } else { __asm { mov ecx, pcnt lock inc dword ptr [ecx] } } } inline void atomicReadBarrier() { /* * A read barrier is only necessary on a multiprocessor box. */ if (gNumberOfProcessors != 1) { __asm { lock add dword ptr [esp], 0 } } } inline void atomicWriteBarrier() { /* * Intel doesn't reorder writes. */ } #elif __linux inline int atomicAdd(int *pcnt, int cnt) { int rc; if (gNumberOfProcessors == 1) { __asm__ __volatile__( "xaddl %0,%2" : "=r" (rc) : "0" (cnt), "m" (*pcnt) : "memory"); } else { __asm__ __volatile__( "lock xaddl %0,%2" : "=r" (rc) : "0" (cnt), "m" (*pcnt) : "memory"); } return rc + cnt; } inline bool atomicCompareAndSwap(int *pcnt, int oval, int val) { unsigned char c; if (gNumberOfProcessors == 1) { __asm__ __volatile__( "cmpxchgl %2,%1; sete %0" : "=q" (c), "=m" (*pcnt) : "r" (val), "1" (*pcnt), "a" (oval)); } else { __asm__ __volatile__( "lock cmpxchgl %2,%1; sete %0" : "=q" (c), "=m" (*pcnt) : "r" (val), "1" (*pcnt), "a" (oval)); } return c != 0; } inline bool atomicDecrementAndTest(int *pcnt) { unsigned char c; if (gNumberOfProcessors == 1) { __asm__ __volatile__( "decl %1; sete %0" : "=q" (c) : "m" (*pcnt) : "memory"); } else { __asm__ __volatile__( "lock decl %1; sete %0" : "=q" (c) : "m" (*pcnt) : "memory" ); } return c != 0; } inline bool atomicDoubleCompareAndSwap(int64_t *pcnt, int64_t oval, int64_t val) { unsigned char c; if (gNumberOfProcessors == 1) { __asm__ __volatile__( "cmpxchg8b %1; sete %0" : "=q" (c), "=m" (*pcnt) : "1" (*pcnt), "A" (oval), "c" (static_cast<int>(val >> 32)), "b" (static_cast<int>(val))); } else { __asm__ __volatile__( "lock cmpxchg8b %1; sete %0" : "=q" (c), "=m" (*pcnt) : "1" (*pcnt), "A" (oval), "c" (static_cast<int>(val >> 32)), "b" (static_cast<int>(val))); } return c != 0; } inline void atomicIncrement(int *pcnt) { if (gNumberOfProcessors == 1) { __asm__ __volatile__( "incl %0" : "+m" (*pcnt) ); } else { __asm__ __volatile__( "lock incl %0" : "+m" (*pcnt) ); } } inline void atomicReadBarrier() { if (gNumberOfProcessors == 1) { __asm__ __volatile__( "" : : : "memory"); } else { int x = 0, y = 1; __asm__ __volatile__( "xchgl %0,%1" : "=r" (x) : "m" (y), "0" (x) : "memory"); } } inline void atomicWriteBarrier() { __asm__ __volatile__( "" : : : "memory"); } #elif __sun extern "C" int atomicAdd(int *, int); extern "C" bool atomicCompareAndSwap(int *, int, int); extern "C" bool atomicDoubleCompareAndSwap(int64_t *, int64_t *, int64_t *); extern "C" void atomicReadBarrier(); extern "C" void atomicWriteBarrier(); inline bool atomicDecrementAndTest(int *pcnt) { return atomicAdd(pcnt, -1) == 0; } inline bool atomicDoubleCompareAndSwap(int64_t *pcnt, int64_t oval, int64_t val) { return atomicDoubleCompareAndSwap(pcnt, &oval, &val); } inline void atomicIncrement(int *pcnt) { atomicAdd(pcnt, 1); } #endif /* WIN32 */ } //namespace int AtomicInt::operator+=(int cnt) { return atomicAdd(&m_cnt, cnt); } int AtomicInt::operator-=(int cnt) { return atomicAdd(&m_cnt, -cnt); } int AtomicInt::operator++() { return atomicAdd(&m_cnt, 1); } int AtomicInt::operator++(int) { return atomicAdd(&m_cnt, 1) - 1; } int AtomicInt::operator--() { return atomicAdd(&m_cnt, -1); } int AtomicInt::operator--(int) { return atomicAdd(&m_cnt, -1) + 1; } bool AtomicInt::decrementAndTest() { return atomicDecrementAndTest(&m_cnt); } void AtomicInt::increment() { atomicIncrement(&m_cnt); } --- NEW FILE: atomicint.il --- .inline atomicAdd,8 1: ld [%o0],%o2 add %o2,%o1,%o3 cas [%o0],%o2,%o3 cmp %o2,%o3 bne,pn %icc,1b nop add %o2,%o1,%o0 .end .inline atomicCompareAndSwap,12 cas [%o0],%o1,%o2 xor %o0,%o0,%o0 cmp %o1,%o2 bne,pn %icc,2f nop add %o0,1,%o0 2: .end .inline atomicDoubleCompareAndSwap,12 ldx [%o1],%o3 ldx [%o2],%o4 casx [%o0],%o3,%o4 xor %o0,%o0,%o0 cmp %o3,%o4 bne,pn %xcc,3f nop add %o0,1,%o0 3: .end .inline atomicReadBarrier,0 membar #LoadLoad .end .inline atomicWriteBarrier,0 membar #StoreStore .end --- NEW FILE: counter.cpp --- #include "knexportlibraryknutilmodule.h" /** * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * * @KNOWNOW_LICENSE_START@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The name "KnowNow" is a trademark of KnowNow, Inc. and may not * be used to endorse or promote any product without prior written * permission from KnowNow, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL KNOWNOW, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @KNOWNOW_LICENSE_END@ **/ #include "knutil/counter.h" Counter::Counter(int c) : count(c) { } Counter::~Counter() { } --- NEW FILE: kncircularmapping.cpp --- #include <math.h> /** * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * * @KNOWNOW_LICENSE_START@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The name "KnowNow" is a trademark of KnowNow, Inc. and may not * be used to endorse or promote any product without prior written * permission from KnowNow, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL KNOWNOW, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @KNOWNOW_LICENSE_END@ **/ #include <sstream> #include <algorithm> #include "knexportlibraryknutilmodule.h" #include "knutil/knerror.h" #include "knutil/knlog.h" #include "knutil/kncircularmapping.h" //-------------------------------------------------------------------------- // Bucket Class //-------------------------------------------------------------------------- class Bucket { public: Bucket(const std::string& bucketName, double weight) : m_name(bucketName), m_weight(weight) { } std::string m_name; double m_weight; std::vector<KnCircularMapping::PointT> m_replicaPoints; }; bool BucketComp(const Bucket* lhs, const Bucket* rhs) { return lhs->m_name < rhs->m_name; } bool insertSorted(std::vector<Bucket*>& v, Bucket* value) { std::pair<std::vector<Bucket*>::iterator, std::vector<Bucket*>::iterator> bounds; bounds = equal_range(v.begin(), v.end(), value, BucketComp); if(bounds.first == bounds.second) { if(bounds.first == v.end()) { v.push_back(value); return true; } v.insert(bounds.second, value); return true; } return false; } //-------------------------------------------------------------------------- // ReplicaPoint Class //-------------------------------------------------------------------------- class ReplicaPoint { public: ReplicaPoint(KnCircularMapping::PointT& point) : m_point(point) { } ~ReplicaPoint() { } Bucket* getFirstBucket() { if(!m_replicas.size()) { KnLog(KnLogError, "KnConsistentHash: replica point with no replicas."); return NULL; } Bucket* bucket = *m_replicas.begin(); return bucket; } bool addReplica(Bucket* bucket) // keep them sorted , return true if conflict { if(!m_replicas.size()) { m_replicas.push_back(bucket); return false; } bool result = insertSorted(m_replicas, bucket); if(!result) { KnLog(KnLogError, "KnConsistentHash: Bucket with same ID already present at replica"); } KnLog(KnLogWarning, "KnConsistentHash: conflict when adding bucket %s replica at point %u.", bucket->m_name.c_str(), m_point); return true; } KnCircularMapping::PointT m_point; std::vector<Bucket*> m_replicas; // should be just one or there are conflicts }; //-------------------------------------------------------------------------- // KnCircularMapping //-------------------------------------------------------------------------- KnCircularMapping::KnCircularMapping() { m_totalWeight = 0; } KnCircularMapping::~KnCircularMapping() { removeAllBuckets(); } bool KnCircularMapping::addBucket(const char* bucketName, std::vector<PointT>& replicas, double weight) { if (weight <= 0) return false; if (m_buckets.find(bucketName) != m_buckets.end()) return false; Bucket* bucket = new Bucket(bucketName, weight); m_buckets[bucketName] = bucket; ReplicaPoint* rp; bucket->m_replicaPoints = replicas; for (int i = 0; i < replicas.size(); i++) { rp = findOrAddReplicaPoint(replicas[i]); rp->addReplica(bucket); } m_totalWeight += weight; return true; } bool KnCircularMapping::removeBucket(const char* bucketName) { BucketMapIterator it = m_buckets.find(bucketName); if (it == m_buckets.end()) return false; Bucket* bucket = it->second; m_buckets.erase(it); double weight = bucket->m_weight; m_totalWeight -= weight; for (int i = 0; i < bucket->m_replicaPoints.size(); i++) { if(!removeReplicaPoint(bucket->m_replicaPoints[i], bucket)) { KnLog(KnLogError, "KnConsistentHash: could not remove replica point %u for bucket %s.", bucket->m_replicaPoints[i] ,bucket->m_name.c_str()); } } SAFE_DELETE(bucket); return true; } ReplicaPoint* KnCircularMapping::findOrAddReplicaPoint(PointT point) { ReplicaMapRange bounds; ReplicaPoint* result; bounds = m_replicaMap.equal_range(point); if(bounds.first == bounds.second) { // not found result = new ReplicaPoint(point); if(bounds.first == m_replicaMap.end()) { m_replicaMap[point] = result; return result; } m_replicaMap.insert(bounds.second, std::pair<const PointT, ReplicaPoint*>(point, result)); return result; } return (*bounds.first).second; } ReplicaPoint* KnCircularMapping::findReplicaPoint(PointT point) { ReplicaMapIterator it = m_replicaMap.find(point); if(it == m_replicaMap.end()) return NULL; return it->second; } bool KnCircularMapping::removeReplicaPoint(PointT point, Bucket* bucket) { ReplicaMapRange bounds; bounds = m_replicaMap.equal_range(point); if(bounds.first == bounds.second) return false; ReplicaPoint* rp = (*bounds.first).second; std::vector<Bucket*>& replicas = rp->m_replicas; std::vector<Bucket*>::iterator it = find(replicas.begin(), replicas.end(), bucket); if(it == replicas.end()) return false; replicas.erase(it); if(!replicas.size()) { m_replicaMap.erase(bounds.first); SAFE_DELETE(rp); } return true; } Bucket* KnCircularMapping::findBucketForPoint(PointT point) { if (m_replicaMap.empty() || m_buckets.empty()) return NULL; if (m_buckets.size() == 1) return (*m_replicaMap.begin()).second->getFirstBucket(); ReplicaMapRange bounds; bounds = m_replicaMap.equal_range(point); if(bounds.first == bounds.second) { // not found if(bounds.first == m_replicaMap.end()) { // point is after all replicas => assign to first replica return (*m_replicaMap.begin()).second->getFirstBucket(); } // assign to greater replica return (*bounds.second).second->getFirstBucket(); } // assign to this replica as it has the same point value return (*bounds.first).second->getFirstBucket(); } void KnCircularMapping::removeAllBuckets() { ReplicaMapIterator it; for(it = m_replicaMap.begin(); it != m_replicaMap.end(); it++) SAFE_DELETE(it->second); m_replicaMap.clear(); BucketMapIterator bmi = m_buckets.begin(); for(; bmi != m_buckets.end(); bmi++) SAFE_DELETE(bmi->second); m_buckets.clear(); } double KnCircularMapping::getWeight(const std::string& bucketName) { BucketMapIterator it = m_buckets.find(bucketName.c_str()); if(it != m_buckets.end()) return it->second->m_weight; return -1; } double KnCircularMapping::getTotalWeight() { return m_totalWeight; } bool KnCircularMapping::existsBucket(const std::string& bucketName) { return m_buckets.find(bucketName.c_str()) != m_buckets.end(); } std::string KnCircularMapping::assignPointToBucket(PointT point) { Bucket* bucket = findBucketForPoint(point); if(!bucket) return ""; return bucket->m_name; } int KnCircularMapping::bucketCount() { return m_buckets.size(); } --- NEW FILE: knconsistenthash.cpp --- #include <math.h> /** * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * * @KNOWNOW_LICENSE_START@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The name "KnowNow" is a trademark of KnowNow, Inc. and may not * be used to endorse or promote any product without prior written * permission from KnowNow, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL KNOWNOW, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @KNOWNOW_LICENSE_END@ **/ #include <sstream> #include <algorithm> #include <vector> #include "knexportlibraryknutilmodule.h" #include "knutil/knerror.h" #include "knutil/knlog.h" #include "knutil/knhash.h" #include "knutil/mtrand.h" #include "knutil/knconsistenthash.h" //-------------------------------------------------------------------------- // KnConsistentHash //-------------------------------------------------------------------------- KnConsistentHash::KnConsistentHash(int replicasPerBucket, KnCircularMapping::PointT pointInterval) { m_replicasPerBucket = replicasPerBucket; m_pointInterval = pointInterval; } KnConsistentHash::~KnConsistentHash() { } KnConsistentHash::IDHash KnConsistentHash::computeHash(const char* identifier) { return hash32(identifier, strlen(identifier), 1492); } KnCircularMapping::PointT KnConsistentHash::computePointForResource(const char* identifier) { MTRand_int32 randGen( computeHash(identifier) ); return randGen() % m_pointInterval; } bool KnConsistentHash::addBucket(const char* bucketName, double weight) { return addBucketUnsafe(bucketName, computeHash(bucketName), weight); } bool KnConsistentHash::addBucket(const char* bucketName, IDHash bucketHash, double weight) { KnRWLock::KnWriteLock wlock(m_bucketLock); return addBucketUnsafe(bucketName, bucketHash, weight); } bool KnConsistentHash::addBucketUnsafe(const char* bucketName, IDHash bucketHash, double weight) { if (weight < 0.000001) return m_mapping.removeBucket(bucketName); if(m_mapping.existsBucket(bucketName)) { // Bucket already exists => remove before adding m_mapping.removeBucket(bucketName); } MTRand_int32 randGen(bucketHash); KnCircularMapping::PointT point; std::vector<KnCircularMapping::PointT> replicas; int replicaCount = floor(weight * m_replicasPerBucket); replicas.reserve(replicaCount); for (int i = 0; i < replicaCount; i++) { point = randGen() % m_pointInterval; replicas.push_back(point); } return m_mapping.addBucket(bucketName, replicas, weight); } bool KnConsistentHash::removeBucket(const char* bucketName) { KnRWLock::KnWriteLock wlock(m_bucketLock); return m_mapping.removeBucket(bucketName); } void KnConsistentHash::removeAllBuckets() { KnRWLock::KnWriteLock wlock(m_bucketLock); m_mapping.removeAllBuckets(); } std::string KnConsistentHash::assignPointToBucket(KnCircularMapping::PointT point) { KnRWLock::KnReadLock rlock(m_bucketLock); return m_mapping.assignPointToBucket(point); } std::string KnConsistentHash::assignResourceToBucket(const char* identifier) { KnRWLock::KnReadLock rlock(m_bucketLock); return m_mapping.assignPointToBucket( computePointForResource(identifier) ); } int KnConsistentHash::bucketCount() { return m_mapping.bucketCount(); } bool KnConsistentHash::addBucketsFromSet(const KnSet& bucketSet) { if(bucketSet.size() == 0) return true; KnRWLock::KnWriteLock wlock(m_bucketLock); return addBucketsFromSetUnsafe(bucketSet); } bool KnConsistentHash::setBucketsFromSet(const KnSet& bucketSet) { if(bucketSet.size() == 0) return true; KnRWLock::KnWriteLock wlock(m_bucketLock); m_mapping.removeAllBuckets(); return addBucketsFromSetUnsafe(bucketSet); } bool KnConsistentHash::addBucketsFromSetUnsafe(const KnSet& bucketSet) { if(bucketSet.size() == 0) return true; for (size_t ix = 0; ix < bucketSet.size(); ++ix) { KnSetElem entry = bucketSet[ix]; KnString bucketName = entry.m_key; if(entry.m_value == "") { // A delete bucket request m_mapping.removeBucket(bucketName.c_str()); continue; } double weight = entry.m_value.toDouble(); addBucketUnsafe(bucketName.c_str(), computeHash(bucketName.c_str()), weight); } return true; } double KnConsistentHash::getTotalWeight() { return m_mapping.getTotalWeight(); } --- NEW FILE: kncrashhandler.cpp --- #include "knexportlibraryknutilmodule.h" /** * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * * @KNOWNOW_LICENSE_START@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The name "KnowNow" is a trademark of KnowNow, Inc. and may not * be used to endorse or promote any product without prior written * permission from KnowNow, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL KNOWNOW, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @KNOWNOW_LICENSE_END@ **/ #include "knutil/kncrashhandler.h" #include "knutil/knlog.h" #include "knutil/knmemory.h" #include "knutil/knmutex.h" #include "string" namespace { KnMutex gCrashHandlerMutex; std::string gDumpLocation; // For occasions when we change it. bool gDumpAtAll = true; // Avoid denial of service by running out of disk (Customer Support called for the default to be false for this reason). } #ifdef WIN32 #define _MSJDBG_H #include "BugslayerUtil.h" namespace { // From http://msdn.microsoft.com/library/default.asp?url=/library/en-us/debug/base/minidumpwritedump.asp: // DumpType // [in] The type of information to be generated. This parameter can be // one or more of the values from the MINIDUMP_TYPE enumeration. unsigned int gMiniDumpType = static_cast<unsigned int>(MiniDumpNormal); char* gMiniDumpFile = "log/liveserver.dmp"; } LONG __stdcall KnCrashHandler( EXCEPTION_POINTERS * pExPtrs ) { // Count on the BugSlayer's OutputDebugString (annoying) if // we're out of stack; if we're a service, we'll have hung // before getting here. Unfortunately, it's not as rare for us as // for many other programs, since we're multithreaded (and have therefore // declared a stack size), but it's rare enough to have worked out OK for a while. // When we get hangs or crashes on Windows with no stack trace or minidump, then // we're probably looking at exactly that case. Try increasing the stack size // in knrouter.tcl. if ( EXCEPTION_STACK_OVERFLOW != pExPtrs->ExceptionRecord->ExceptionCode ) { // None of the BugSlayer routines are thread-safe. OTOH, it's hard // to bring myself to use another mutex at this point, since we deadlock // so often for mutex problems. Doing it anyway. KnMutex::KnLock lock(gCrashHandlerMutex); KnLog(KnLogBug,GetFaultReason(pExPtrs)); KnLog(KnLogNotice,GetRegisterString(pExPtrs)); // Want the ns_fatal call to have all the info about minidump so it's easy // to see in the Monitor Alarms view. char *miniDumpIntro = "No .dmp generated:"; char *miniDumpExtra = ""; char *miniDumpFile = gDumpLocation.length() ? const_cast<char*>(gDumpLocation.c_str()) : gMiniDumpFile; if (!gDumpAtAll) { miniDumpExtra = "disabled. See Configuration: Memory in the KSA"; } else if (IsMiniDumpFunctionAvailable()) { BSUMDRET problems = CreateCurrentProcessMiniDump( static_cast<MINIDUMP_TYPE>(gMiniDumpType), miniDumpFile, GetCurrentThreadId(), pExPtrs); switch (problems) { case eDUMP_SUCCEEDED: miniDumpIntro = "See minidump file"; miniDumpExtra = miniDumpFile; break; case eDBGHELP_NOT_FOUND: miniDumpExtra = "dbghelp.dll not found."; break; case eDBGHELP_MISSING_EXPORTS: miniDumpExtra = "dbghelp.dll missing functionality."; break; case eBAD_PARAM: miniDumpExtra = "Bad parameter."; break; case eOPEN_DUMP_FAILED: miniDumpIntro = "Could not open minidump file"; miniDumpExtra = miniDumpFile; // No guidance from Mr. Robbins on why in this case. break; case eMINIDUMPWRITEDUMP_FAILED: KnLog(KnLogNotice,"Couldn't write dump; GetLastError returns %d",GetLastError()); miniDumpExtra = "Dump writing failed."; break; case eDEATH_ERROR: miniDumpExtra = "Minidump thread could not be started."; break; case eINVALID_ERROR: miniDumpExtra = "Bad bugslayer code"; break; } } else { miniDumpExtra = "Minidump facility not available."; } KnLog(KnLogNotice,"Stack trace:"); DWORD dwOpts = GSTSO_SRCLINE | GSTSO_SYMBOL | GSTSO_PARAMS; for ( LPCSTR pStackMessage =GetFirstStackTraceString( dwOpts, pExPtrs ) ; 0 != pStackMessage ; pStackMessage = GetNextStackTraceString( dwOpts, pExPtrs ) ) { KnLog(KnLogNotice,pStackMessage); } KnMemory::logStatistics( KnLogNotice ) ; KnLog(KnLogNotice,"knownow: Memory available: %lu",KnMemory::getMemoryAvail()); Ns_Fatal("Exception shuts down server immediately. %s %s", miniDumpIntro, miniDumpExtra); } return EXCEPTION_EXECUTE_HANDLER ; }; // This routine should be called from DLLMAIN, but so far, we're doing // OK just installing it from nskn. Since we're not limiting ourselves // to just one dll, it works pretty nicely, without requiring changes in // AOLServer. If we ever integrate any DLL that sets its own in this way, // though, we will run into some conflicts, at which point we'll have to // BE_NICE_TO_OUR_MODULE_WRITERS and get this called from each of our .dlls. // // See Robbins; I'm using "Debugging Applications" (the VS 6 - era book) // // Separated KnSetCrashHandler from KnSetCrashInfo for two reasons (one // very minor) // // (1) didn't want to change an existing API [very minor, it's only called // in one place] // // (2) want it called *before* we try to do anything across dll boundaries // from nskn. // // OTOH, since it's going to be set before we even _can_ look at the defauls // from the nskn ns_section, we've set up the defaults here so we do get a // stack trace dump during that short time. That shouldn't be enough data // to cause a serious denial of service -- and is a huge win for debugging. /* bool KnSetCrashHandler() { if (! SetCrashHandlerFilter( KnCrashHandler ) ) { KnLog(KnLogError,"Could not set crash handler.\n"); return false ; } #if BE_NICE_TO_OUR_MODULE_WRITERS /* Get the handle for this DLL or module */ HMODULE hMyModule = GetModuleHandle(NULL) ; if (! AddCrashHandlerLimitModule( hMyModule )) { KnLog(KnLogError,"Could not limit crash handling\n"); return false ; } #endif return true; } #else #ifdef __sun #else #include "google/coredumper.h" #endif namespace { char* gCoreFile = "log/liveserver.core"; } bool KnDumpCore() { if (gDumpAtAll) { const char *coreFile = gDumpLocation.length() ? gDumpLocation.c_str() : gCoreFile; #ifdef __sun KnLog(KnLogNotice,"Core dumping currently not supported on Solaris."); #else return 0 == WriteCoreDump(coreFile); #endif } return true; } bool KnSetCrashHandler() { return true; } #endif bool KnSetCrashInfo(const char* dumpLocation, const char* dumpLevel) { if (dumpLocation != NULL) gDumpLocation = dumpLocation; std::string level(dumpLevel); if (level[0] == '0') { gDumpAtAll = false; } #ifdef WIN32 else if (level[0] == '1') { gDumpAtAll = true; gMiniDumpType = MiniDumpNormal; // Just the stacks, ma'am } else if (level[0] == '2') { gDumpAtAll = true; gMiniDumpType = MiniDumpWithDataSegs; } else if (level[0] == '3') { gDumpAtAll = true; gMiniDumpType = MiniDumpWithFullMemory | MiniDumpWithHandleData ; // Hope this also contains Full Data } else { KnLog(KnLogNotice,"Unrecognized dump level '%s'; will set to 'just the stacks' level",level.c_str()); gDumpAtAll = true; gMiniDumpType = MiniDumpNormal; } #else else if (level[0] == '1') { gDumpAtAll = true; } else { KnLog(KnLogNotice,"Unrecognized dump level '%s'; setting dump level to 'true'",level.c_str()); gDumpAtAll = true; } #endif return true; } // We wrote our own so we always get crash dumps the way we want 'em // (and get the assertion in the log) void KnAssert(char *exp, char *file, unsigned int line) { KnLog(KnLogBug,"%s @ %s:%u", exp, file, line); // I wanted something reasonably portable without working too hard, so here's the best I could do on short // notice. All attempts do it with kill (and any portable fault) were // caught by nsd and didn't give core dumps. char *p = 0; ++p; strcpy(p,"assertion failed"); } --- NEW FILE: kncrypt.cpp --- #include "knexportlibraryknutilmodule.h" /** * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * * @KNOWNOW_LICENSE_START@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The name "KnowNow" is a trademark of KnowNow, Inc. and may not * be used to endorse or promote any product without prior written * permission from KnowNow, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL KNOWNOW, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @KNOWNOW_LICENSE_END@ **/ #include "knutil/kncrypt.h" KnError KnCrypt(KnString &buf, const KnString &key, const KnString &salt) { char tmp[NS_ENCRYPT_BUFSIZE]; /* * Copy the raw byte string into a KnString. */ buf = Ns_Encrypt(const_cast<char*>(key.c_str()), const_cast<char*>(salt.c_str()), tmp); return KnErrorSuccess; } --- NEW FILE: knerror.cpp --- /* Copyright 2004-2005 KnowNow, Inc */ /** * @KNOWNOW_LICENSE_START@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The name "KnowNow" is a trademark of KnowNow, Inc. and may not * be used to endorse or promote any product without prior written * permission from KnowNow, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL KNOWNOW, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @KNOWNOW_LICENSE_END@ **/ #include "knexportlibraryknutilmodule.h" #include "knutil/knerror.h" #include "knutil/knmutex.h" #include "knutil/knstring.h" #include "knutil/knlog.h" #include "knutil/simpletraits.h" #include "knutil/simplemap.h" namespace { class KnErrorSingleton { public: static KnErrorSingleton& instance(); const KnString* get(KnError errEnum) { unsigned int err = static_cast<unsigned int>(errEnum); const KnString *val = m_map.get(err); if (0 == val) { err &= 0xFF00; val = m_map.get(err); } if (0 == val) { KnString *unknown = new KnString("Unregistered error "); unknown->printf("%u",err); m_map.put(err,unknown); val = m_map.get(err); } if (0 == val) { Ns_Fatal("knerror: Can't map error %d",err); } return val; } private: // Not implemented KnErrorSingleton(const KnErrorSingleton &); KnErrorSingleton &operator=(const KnErrorSingleton &); // Implemented KnErrorSingleton() ; SimpleMap<unsigned int,const KnString *> m_map; static KnErrorSingleton *m_instance ; static KnMutex m_lock; }; KnErrorSingleton* KnErrorSingleton::m_instance = 0 ; KnMutex KnErrorSingleton::m_lock ; KnErrorSingleton& KnErrorSingleton::instance( void ) { if ( 0 == m_instance ) { KnMutex::KnLock guard(m_lock) ; if ( 0 == m_instance ) { m_instance = new KnErrorSingleton ; if (0 == m_instance) { KnLog(KnLogFatal,"knerror: Can't allocate instance"); } } } return *m_instance ; } KnErrorSingleton::KnErrorSingleton() { m_map.put(KnErrorSuccess, &KnStringConstants::success); m_map.put(KnErrorUnauthorized, &KnStringConstants::unauthorized); m_map.put(KnErrorForbidden, &KnStringConstants::forbidden); m_map.put(KnErrorNotFound, &KnStringConstants::notspacefound); m_map.put(KnErrorFailure, &KnStringConstants::failed); /* m_map.put(KnErrorNotFound_Event, new KnString("event not found")); m_map.put(KnErrorNotFound_Route, new KnString("route not found")); m_map.put(KnErrorNotFound_Topic, new KnString("topic not found")); m_map.put(KnErrorNotFound_Journal, new KnString("journal not found")); m_map.put(KnErrorNotFound_Parent, new KnString("parent topic not found")); m_map.put(KnErrorNotFound_SubTopic, new KnString("subtopic not found")); m_map.put(KnErrorNotFound_User, new KnString("user not found")); m_map.put(KnErrorNotFound_Group, new KnString("group not found")); */ } } // Namespace const KnString& KnError_AsString( const KnError err ) { return *KnErrorSingleton::instance().get(err); } const int KnError_AsHTTP(const KnError err) { return err >> 8; } #if 0 KnError KnError_Register(unsigned int err, KnString string) { if (err > 65500 || err < 256) { return KnError_OutOfRange; } return KnErrorSingleton::instance().put(err,string); } #endif --- NEW FILE: knhash.cpp --- #include "knexportlibraryknutilmodule.h" /** * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * * @KNOWNOW_LICENSE_START@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The name "KnowNow" is a trademark of KnowNow, Inc. and may not * be used to endorse or promote any product without prior written * permission from KnowNow, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL KNOWNOW, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @KNOWNOW_LICENSE_END@ **/ #include "knutil/knhash.h" #define ind32(value, bits) \ (static_cast<uint32_t>(value) << (bits)) #define ind64(value, bits) \ (static_cast<uint64_t>(value) << (bits)) #define mix32(a, b, c) \ { \ a -= b; a -= c; a ^= (c >> 13); \ b -= c; b -= a; b ^= (a << 8); \ c -= a; c -= b; c ^= (b >> 13); \ a -= b; a -= c; a ^= (c >> 12); \ b -= c; b -= a; b ^= (a << 16); \ c -= a; c -= b; c ^= (b >> 5); \ a -= b; a -= c; a ^= (c >> 3); \ b -= c; b -= a; b ^= (a << 10); \ c -= a; c -= b; c ^= (b >> 15); \ } #define mix64(a, b, c) \ { \ a -= b; a -= c; a ^= (c >> 43); \ b -= c; b -= a; b ^= (a << 9); \ c -= a; c -= b; c ^= (b >> 8); \ a -= b; a -= c; a ^= (c >> 38); \ b -= c; b -= a; b ^= (a << 23); \ c -= a; c -= b; c ^= (b >> 5); \ a -= b; a -= c; a ^= (c >> 35); \ b -= c; b -= a; b ^= (a << 49); \ c -= a; c -= b; c ^= (b >> 11); \ a -= b; a -= c; a ^= (c >> 12); \ b -= c; b -= a; b ^= (a << 18); \ c -= a; c -= b; c ^= (b >> 22); \ } extern "C" { uint32_t hash32(const void *buf, uint32_t len, uint32_t seed) { const uint8_t *p = static_cast<const uint8_t *>(buf); uint32_t a = 0x9E3779B9; uint32_t b = 0x9E3779B9; uint32_t c = seed; uint32_t d = len; for (; d >= 12; d -= 12, p += 12) { a += ind32(p[ 0], 0) + ind32(p[ 1], 8) + ind32(p[ 2], 16) + ind32(p[ 3], 24); b += ind32(p[ 4], 0) + ind32(p[ 5], 8) + ind32(p[ 6], 16) + ind32(p[ 7], 24); c += ind32(p[ 8], 0) + ind32(p[ 9], 8) + ind32(p[10], 16) + ind32(p[11], 24); mix32(a, b, c); } c += len; /* * Duff's Device lives! The first byte of c is reserved for the length. */ switch (d) { case 11: c += ind32(p[10], 24); case 10: c += ind32(p[ 9], 16); case 9: c += ind32(p[ 8], 8); case 8: b += ind32(p[ 7], 24); case 7: b += ind32(p[ 6], 16); case 6: b += ind32(p[ 5], 8); case 5: b += ind32(p[ 4], 0); case 4: a += ind32(p[ 3], 24); case 3: a += ind32(p[ 2], 16); case 2: a += ind32(p[ 1], 8); case 1: a += ind32(p[ 0], 0); } mix32(a, b, c); return c; } uint64_t hash64(const void *buf, uint64_t len, uint64_t seed) { const uint8_t *p = static_cast<const uint8_t *>(buf); uint64_t a = seed; uint64_t b = seed; uint64_t c = 0x9E3779B97F4A7C13ULL; uint64_t d = len; for (; d >= 24; d -= 24, p += 24) { a += ind64(p[ 0], 0) + ind64(p[ 1], 8) + ind64(p[ 2], 16) + ind64(p[ 3], 24) + ind64(p[ 4], 32) + ind64(p[ 5], 40) + ind64(p[ 6], 48) + ind64(p[ 7], 56); b += ind64(p[ 8], 0) + ind64(p[ 9], 8) + ind64(p[10], 16) + ind64(p[11], 24) + ind64(p[12], 32) + ind64(p[13], 40) + ind64(p[14], 48) + ind64(p[15], 56); c += ind64(p[16], 0) + ind64(p[17], 8) + ind64(p[18], 16) + ind64(p[19], 24) + ind64(p[20], 32) + ind64(p[21], 40) + ind64(p[22], 48) + ind64(p[23], 56); mix64(a, b, c); } c += len; /* * Duff's Device lives! The first byte of c is reserved for the length. */ switch (d) { case 23: c += ind64(p[22], 56); case 22: c += ind64(p[21], 48); case 21: c += ind64(p[20], 40); case 20: c += ind64(p[19], 32); case 19: c += ind64(p[18], 24); case 18: c += ind64(p[17], 16); case 17: c += ind64(p[16], 8); case 16: b += ind64(p[15], 56); case 15: b += ind64(p[14], 48); case 14: b += ind64(p[13], 40); case 13: b += ind64(p[12], 32); case 12: b += ind64(p[11], 24); case 11: b += ind64(p[10], 16); case 10: b += ind64(p[ 9], 8); case 9: b += ind64(p[ 8], 0); case 8: a += ind64(p[ 7], 56); case 7: a += ind64(p[ 6], 48); case 6: a += ind64(p[ 5], 40); case 5: a += ind64(p[ 4], 32); case 4: a += ind64(p[ 3], 24); case 3: a += ind64(p[ 2], 16); case 2: a += ind64(p[ 1], 8); case 1: a += ind64(p[ 0], 0); } mix64(a, b, c); return c; } } // extern "C" --- NEW FILE: knlog.cpp --- #include "knexportlibraryknutilmodule.h" /** * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * * @KNOWNOW_LICENSE_START@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The name "KnowNow" is a trademark of KnowNow, Inc. and may not * be used to endorse or promote any product without prior written * permission from KnowNow, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL KNOWNOW, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @KNOWNOW_LICENSE_END@ **/ #include "knutil/kntypes.h" #include "knutil/knlog.h" #include <cstdarg> KnError KnLog(KnLogSeverity severity, const KnString &msg) { /* * Reuse existing interface. */ return KnLog(severity, "%.*s", (int)msg.length(), msg.c_str()); } KnError KnLog(KnLogSeverity severity, const char *fmt, ...) { va_list ap; /* * Grab the arguments off the stack. */ va_start(ap, fmt); /* * Note the C-style cast for converting between unrelated enums. */ Ns_ServerLog(Ns_LogSeverity(severity), const_cast<char*>(fmt), &ap); /* * Restore the stack. */ va_end(ap); return KnErrorSuccess; } --- NEW FILE: knmarkuputil.cpp --- ////////////////////////////////////////////////////// /** * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * * @KNOWNOW_LICENSE_START@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The name "KnowNow" is a trademark of KnowNow, Inc. and may not * be used to endorse or promote any product without prior written * permission from KnowNow, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL KNOWNOW, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @KNOWNOW_LICENSE_END@ **/ // knmarkuputil.cpp // // (c)2002-2006, KnowNow, Inc. All Rights Reserved. #include "knexportlibraryknutilmodule.h" #include "knutil/knmarkuputil.h" #include "knutil/knlog.h" template class EXPORT_LIBRARY_KNUTIL SimpleMap<char*, char*>; KnMarkupUtil::KnMarkupUtil() { buildHtlmEntity(); buildHtlmTags(); } KnMarkupUtil::~KnMarkupUtil() { } void KnMarkupUtil::buildHtlmEntity() { // http://www.w3schools.com/tags/ref_entities.asp // http://www.utoronto.ca/webdocs/HTMLdocs/NewHTML/iso_table.html entityMap.put("#32"," "); entityMap.put("#0x0020"," "); entityMap.put("nbsp"," "); entityMap.put("#33","!"); entityMap.put("#0x0021","!"); entityMap.put("#34","\""); entityMap.put("#0x0022","\""); entityMap.put("quot","\""); entityMap.put("#35","#"); entityMap.put("#0x0023","#"); entityMap.put("#36","$"); entityMap.put("#0x0024","$"); entityMap.put("#37","%"); entityMap.put("#0x0025","%"); entityMap.put("#38","&"); entityMap.put("#0x0026","&"); entityMap.put("amp","&"); entityMap.put("#39","'"); entityMap.put("#0x0027","'"); entityMap.put("#40","("); entityMap.put("#0x0028","("); entityMap.put("#41",")"); entityMap.put("#0x0029",")"); entityMap.put("#42","*"); entityMap.put("#0x002a","*"); entityMap.put("#43","+"); entityMap.put("#0x002b","+"); entityMap.put("#44",","); entityMap.put("#0x002c",","); entityMap.put("#45","-"); entityMap.put("#0x002d","-"); entityMap.put("#46","."); entityMap.put("#0x002e","."); entityMap.put("#47","/"); entityMap.put("#0x002f","/"); entityMap.put("#48","0"); entityMap.put("#0x0030","0"); entityMap.put("#49","1"); entityMap.put("#0x0031","1"); entityMap.put("#50","2"); entityMap.put("#0x0032","2"); entityMap.put("#51","3"); entityMap.put("#0x0033","3"); entityMap.put("#52","4"); entityMap.put("#0x0034","4"); entityMap.put("#53","5"); entityMap.put("#0x0035","5"); entityMap.put("#54","6"); entityMap.put("#0x0036","6"); entityMap.put("#55","7"); entityMap.put("#0x0037","7"); entityMap.put("#56","8"); entityMap.put("#0x0038","8"); entityMap.put("#57","9"); entityMap.put("#0x0039","9"); entityMap.put("#58",":"); entityMap.put("#0x003a",":"); entityMap.put("#59",";"); entityMap.put("#0x003b",";"); entityMap.put("#60","<"); entityMap.put("#0x003c","<"); entityMap.put("lt","<"); entityMap.put("#61","="); entityMap.put("#0x003d","="); entityMap.put("#62",">"); entityMap.put("#0x003e",">"); entityMap.put("gt",">"); entityMap.put("#63","?"); entityMap.put("#0x003f","?"); entityMap.put("#64","@"); entityMap.put("#0x0040","@"); entityMap.put("#65","A"); entityMap.put("#0x0041","A"); entityMap.put("#66","B"); entityMap.put("#0x0042","B"); entityMap.put("#67","C"); entityMap.put("#0x0043","C"); entityMap.put("#68","D"); entityMap.put("#0x0044","D"); entityMap.put("#69","E"); entityMap.put("#0x0045","E"); entityMap.put("#70","F"); entityMap.put("#0x0046","F"); entityMap.put("#71","G"); entityMap.put("#0x0047","G"); entityMap.put("#72","H"); entityMap.put("#0x0048","H"); entityMap.put("#73","I"); entityMap.put("#0x0049","I"); entityMap.put("#74","J"); entityMap.put("#0x004a","J"); entityMap.put("#75","K"); entityMap.put("#0x004b","K"); entityMap.put("#76","L"); entityMap.put("#0x004c","L"); entityMap.put("#77","M"); entityMap.put("#0x004d","M"); entityMap.put("#78","N"); entityMap.put("#0x004e","N"); entityMap.put("#79","O"); entityMap.put("#0x004f","O"); entityMap.put("#80","P"); entityMap.put("#0x0050","P"); entityMap.put("#81","Q"); entityMap.put("#0x0051","Q"); entityMap.put("#82","R"); entityMap.put("#0x0052","R"); entityMap.put("#83","S"); entityMap.put("#0x0053","S"); entityMap.put("#84","T"); entityMap.put("#0x0054","T"); entityMap.put("#85","U"); entityMap.put("#0x0055","U"); entityMap.put("#86","V"); entityMap.put("#0x0056","V"); entityMap.put("#87","W"); entityMap.put("#0x0057","W"); entityMap.put("#88","X"); entityMap.put("#0x0058","X"); entityMap.put("#89","Y"); entityMap.put("#0x0059","Y"); entityMap.put("#90","Z"); entityMap.put("#0x005a","Z"); entityMap.put("#91","["); entityMap.put("#0x005b","["); entityMap.put("#92","\\"); entityMap.put("#0x005c","\\"); entityMap.put("#93","]"); entityMap.put("#0x005d","]"); entityMap.put("#94","^"); entityMap.put("#0x005e","^"); entityMap.put("#95","_"); entityMap.put("#0x005e","_"); entityMap.put("#96","`"); entityMap.put("#0x0060","`"); entityMap.put("#97","a"); entityMap.put("#0x0061","a"); entityMap.put("#98","b"); entityMap.put("#0x0062","b"); entityMap.put("#99","c"); entityMap.put("#0x0063","c"); entityMap.put("#100","d"); entityMap.put("#0x0064","d"); entityMap.put("#101","e"); entityMap.put("#0x0065","e"); entityMap.put("#102","f"); entityMap.put("#0x0066","f"); entityMap.put("#103","g"); entityMap.put("#0x0067","g"); entityMap.put("#104","h"); entityMap.put("#0x0068","h"); entityMap.put("#105","i"); entityMap.put("#0x0069","i"); entityMap.put("#106","j"); entityMap.put("#0x006a","j"); entityMap.put("#107","k"); entityMap.put("#0x006b","k"); entityMap.put("#108","l"); entityMap.put("#0x006c","l"); entityMap.put("#109","m"); entityMap.put("#0x006d","m"); entityMap.put("#110","n"); entityMap.put("#0x006e","n"); entityMap.put("#111","o"); entityMap.put("#0x006f","o"); entityMap.put("#112","p"); entityMap.put("#0x0070","p"); entityMap.put("#113","q"); entityMap.put("#0x0071","q"); entityMap.put("#114","r"); entityMap.put("#0x0072","r"); entityMap.put("#115","s"); entityMap.put("#0x0073","s"); entityMap.put("#116","t"); entityMap.put("#0x0074","t"); entityMap.put("#117","u"); entityMap.put("#0x0075","u"); entityMap.put("#118","v"); entityMap.put("#0x0076","v"); entityMap.put("#119","w"); entityMap.put("#0x0077","w"); entityMap.put("#120","x"); entityMap.put("#0x0078","x"); entityMap.put("#121","y"); entityMap.put("#0x0079","y"); entityMap.put("#122","z"); entityMap.put("#0x007a","z"); entityMap.put("#123","{"); entityMap.put("#0x007b","{"); entityMap.put("#124","|"); entityMap.put("#0x007c","|"); entityMap.put("#125","}"); entityMap.put("#0x007d","}"); entityMap.put("#126","~"); entityMap.put("#0x007e","~"); // ---------------------------- END ASCII ----------------------------- entityMap.put("#160"," "); ... [truncated message content] |
Update of /cvsroot/aolserver/knutil/include/knutil In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv6393/include/knutil Added Files: atomicint.h counter.h kncircularmapping.h knconsistenthash.h kncrashhandler.h kncrypt.h knerror.h knexportlibraryknutil.h knhash.h knlog.h knmarkuputil.h knmemory.h knmutex.h knnetwork.h knnewdelete.h knpattern.h knperfstatistics.h knregex.h knrwlock.h knrwlogginglock.h knset.h knsett.h knsleep.h knsmartref.h knstring.h knstringtokenizer.h knstrops.h knsysutility.h kntclargs.h kntclerrors.h kntclfile.h kntclinterp.h kntemplateuri.h kntime.h kntypes.h knurl.h mtrand.h randomnumber.h shahash.h simplecache.h simpleheap.h simpleiterator.h simplelist.h simplemap.h simplenull.h simplequeue.h simpleset.h simplesynccache.h simplesyncmap.h simplesyncvector.h simpletraits.h simplevector.h uuidgenerator.h Log Message: Added this library to the AOLServer.com repository. It contains a number of C/C++ utilities, some of which integrate into AOLServer, and many of which standalone. A portion of the library is required for the knregistration module, which will be checked in next. I believe this compiles fine in "native" AOLServer, but it has not been tested recently. --- NEW FILE: atomicint.h --- #ifndef ATOMICINT_H #define ATOMICINT_H /** * Copyright (c) 2001 KnowNow, Inc. All rights reserved. * * @KNOWNOW_LICENSE_START@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The name "KnowNow" is a trademark of KnowNow, Inc. and may not * be used to endorse or promote any product without prior written * permission from KnowNow, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL KNOWNOW, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @KNOWNOW_LICENSE_END@ **/ /* * Object supporting atomic integer operations. */ #include "knutil/knexportlibraryknutil.h" #include "knutil/kntypes.h" class EXPORT_LIBRARY_KNUTIL AtomicInt { public: /* * Constructors/destructor. */ inline AtomicInt(int cnt=0) : m_cnt(cnt){}; inline AtomicInt(const AtomicInt &atom):m_cnt(atom.m_cnt){}; inline ~AtomicInt(){}; /* * Set the object to an arbitrary value. */ inline AtomicInt &operator=(const AtomicInt &atom) {m_cnt = atom.m_cnt;return *this;}; inline AtomicInt &operator=(int cnt) {m_cnt = cnt;return *this;} /* * Increment/decrement the object by an arbitrary value. */ int operator+=(int cnt); int operator-=(int cnt); /* * Prefix and postfix increment. */ int operator++(); int operator++(int); /* * Prefix and postfix decrement. */ int operator--(); int operator--(int); /* * Object returned as an integer. */ inline operator int() const { return m_cnt; } /* * Decrement the object, and return true if the result is 0. */ bool decrementAndTest(); /* * Increment the object, without returning the result. */ void increment(); private: int m_cnt; }; #endif /* ATOMICINT_H */ --- NEW FILE: counter.h --- #ifndef COUNTER_H /** * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * * @KNOWNOW_LICENSE_START@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The name "KnowNow" is a trademark of KnowNow, Inc. and may not * be used to endorse or promote any product without prior written * permission from KnowNow, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL KNOWNOW, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @KNOWNOW_LICENSE_END@ **/ #define COUNTER_H #include "knutil/knexportlibraryknutil.h" #include "knutil/atomicint.h" #include "knutil/knmutex.h" class EXPORT_LIBRARY_KNUTIL Counter { public: Counter(int c = 1); ~Counter(); AtomicInt count; }; #endif /* COUNTER_H */ --- NEW FILE: kncircularmapping.h --- #ifndef KN_CIRCULAR_MAPPING_H #define KN_CIRCULAR_MAPPING_H /** * Copyright (c) 2001 KnowNow, Inc. All rights reserved. * * @KNOWNOW_LICENSE_START@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The name "KnowNow" is a trademark of KnowNow, Inc. and may not * be used to endorse or promote any product without prior written * permission from KnowNow, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL KNOWNOW, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @KNOWNOW_LICENSE_END@ **/ #include <limits.h> #include <map> #include <string> #include <vector> #include "knutil/knexportlibraryknutil.h" #include "knutil/knset.h" class Bucket; class ReplicaPoint; class EXPORT_LIBRARY_KNUTIL KnCircularMapping { public: KnCircularMapping(); virtual ~KnCircularMapping(); typedef unsigned int PointT; // Add a bucket bool addBucket(const char* bucketName, std::vector<PointT>& points, double weight); bool addBucketsFromSet(const KnSet& bucketSet); // Remove a bucket by name bool removeBucket(const char* bucketName); // Remove all buckets void removeAllBuckets(); // Compute the bucket where the point should go // and return the bucket's name std::string assignPointToBucket(PointT point); int bucketCount(); double getWeight(const std::string& bucketName); double getTotalWeight(); bool existsBucket(const std::string& bucketName); private: typedef std::map<std::string, Bucket*> BucketMap; typedef BucketMap::iterator BucketMapIterator; typedef std::map<PointT, ReplicaPoint*> ReplicaMap; typedef ReplicaMap::iterator ReplicaMapIterator; typedef std::pair<ReplicaMapIterator, ReplicaMapIterator> ReplicaMapRange; ReplicaPoint* findOrAddReplicaPoint(PointT point); ReplicaPoint* findReplicaPoint(PointT point); bool removeReplicaPoint(PointT point, Bucket* bucket); Bucket* findBucketForPoint(PointT point); BucketMap m_buckets; ReplicaMap m_replicaMap; double m_totalWeight; }; #endif --- NEW FILE: knconsistenthash.h --- #ifndef KN_CONSISTENT_HASH_H #define KN_CONSISTENT_HASH_H /** * Copyright (c) 2001 KnowNow, Inc. All rights reserved. * * @KNOWNOW_LICENSE_START@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The name "KnowNow" is a trademark of KnowNow, Inc. and may not * be used to endorse or promote any product without prior written * permission from KnowNow, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL KNOWNOW, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @KNOWNOW_LICENSE_END@ **/ #include <limits.h> #include <string> #include <map> #include "knutil/knexportlibraryknutil.h" #include "knutil/knset.h" #include "knutil/knrwlock.h" #include "knutil/kncircularmapping.h" #define DEFAULT_REPLICAS_PER_BUCKET 200 class EXPORT_LIBRARY_KNUTIL KnConsistentHash { public: KnConsistentHash(int replicasPerBucket = DEFAULT_REPLICAS_PER_BUCKET, KnCircularMapping::PointT pointInterval = UINT_MAX); virtual ~KnConsistentHash(); typedef unsigned int IDHash; // Compute the hash for a bucket virtual IDHash computeHash(const char* identifier); // Add a bucket given a hash computed from some unique data virtual bool addBucket(const char* bucketName, IDHash bucketHash, double weight); // or by the computing hash from bucket name bool addBucket(const char* bucketName, double weight); // Remove a bucket by name bool removeBucket(const char* bucketName); // Remove all buckets void removeAllBuckets(); // Add buckets from a set where the keys are bucket names and the values are weights bool addBucketsFromSet(const KnSet& bucketSet); bool setBucketsFromSet(const KnSet& bucketSet); int bucketCount(); // Given a resource identifier find the point on the circle it belongs to virtual KnCircularMapping::PointT computePointForResource(const char* identifier); // Compute the bucket where the point should go and return the bucket's name std::string assignPointToBucket(KnCircularMapping::PointT point); // Calculate the point and then assign the point to a bucket for a resource std::string assignResourceToBucket(const char* identifier); double getTotalWeight(); private: bool addBucketUnsafe(const char* bucketName, IDHash bucketHash, double weight); bool addBucketsFromSetUnsafe(const KnSet& bucketSet); KnCircularMapping m_mapping; KnRWLock m_bucketLock; int m_replicasPerBucket; KnCircularMapping::PointT m_pointInterval; }; #endif --- NEW FILE: kncrashhandler.h --- #ifndef KNCRASHHANDLER_H #define KNCRASHHANDLER_H /** * Copyright (c) 2001 KnowNow, Inc. All rights reserved. * * @KNOWNOW_LICENSE_START@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The name "KnowNow" is a trademark of KnowNow, Inc. and may not * be used to endorse or promote any product without prior written * permission from KnowNow, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL KNOWNOW, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @KNOWNOW_LICENSE_END@ **/ #include "knutil/knexportlibraryknutil.h" /** * Register the KnowNow standard crash handler for this module * (no-op under Unix or Linux right now). Returns false if could * not register. Logs any error itself. */ extern EXPORT_LIBRARY_KNUTIL bool KnSetCrashHandler() ; /** * Set the crash handler's dump location and severity */ extern EXPORT_LIBRARY_KNUTIL bool KnSetCrashInfo(const char* location, const char* level) ; #endif /* KNCRASHHANDLER_H */ --- NEW FILE: kncrypt.h --- #ifndef KNCRYPT_H /** * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * * @KNOWNOW_LICENSE_START@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The name "KnowNow" is a trademark of KnowNow, Inc. and may not * be used to endorse or promote any product without prior written * permission from KnowNow, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL KNOWNOW, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @KNOWNOW_LICENSE_END@ **/ #define KNCRYPT_H #include "knutil/knexportlibraryknutil.h" #include "knutil/knstring.h" /** * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * * Encrypt the specified key, perturbed by salt, into buf. */ EXPORT_LIBRARY_KNUTIL KnError KnCrypt(KnString &buf, const KnString &key, const KnString &salt); #endif /* KNCRYPT_H */ --- NEW FILE: knerror.h --- #ifndef KNERROR_H #define KNERROR_H /** * Copyright (c) 2001 KnowNow, Inc. All rights reserved. * * @KNOWNOW_LICENSE_START@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The name "KnowNow" is a trademark of KnowNow, Inc. and may not * be used to endorse or promote any product without prior written * permission from KnowNow, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL KNOWNOW, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @KNOWNOW_LICENSE_END@ **/ #include "knutil/knexportlibraryknutil.h" #include "knutil/kntypes.h" /** * Error state, and preferred return type. */ /** * In 3.1.9, experimenting with moving to an Apache-style set of * codes. All codes come from the HTTP error space, with 6xx codes below * 655 reserved for KnowNow errors. * * We shift them left 8 bits, then add in any subcodes we care about. * This assumes that enums are represented as at least 16 bit unsigned ints. * To get an HTTP error code, shift right 8. To get a nice string, look * them up as-is. * * This check-in requires recompiling the Modules to get the new constants * * Use KnError_Is(constant, code) to do comparisons; we'll figure out how * to get it inlined, yet available to C modules, yet. * * I.e., if you just care if it's found or not, use * KnError_Is(KnErrorNotFound, status) * so you don't have to know the encodings. */ enum KnError { KnErrorSuccess = (200 << 8), ///< Operation succeeded KnErrorUnauthorized = (401 << 8), ///< Operation requires credentials (401) KnErrorForbidden = (403 << 8), ///< Credentials are not authorized (403) KnErrorNotFound = (404 << 8), ///< Something (page) not found KnErrorNotFound_Event = (404 << 8) + 1, KnErrorNotFound_Route = (404 << 8) + 2, KnErrorNotFound_Topic = (404 << 8) + 3, KnErrorNotFound_Journal = (404 << 8) + 4, KnErrorNotFound_Parent = (404 << 8) + 5, KnErrorNotFound_SubTopic = (404 << 8) + 6, KnErrorNotFound_Filter = (404 << 8) + 7, KnErrorNotFound_User = (404 << 8) + 10, KnErrorNotFound_Group = (404 << 8) + 11, KnErrorFailure = (500 << 8) ///< Operation failed (500) }; extern EXPORT_LIBRARY_KNUTIL const int KnError_AsHTTP( const KnError code ) ; #ifdef __cplusplus inline int KnError_Is(const KnError constant, const KnError code ) { return (static_cast<unsigned int>(constant) & static_cast<unsigned int>(code)) == static_cast<unsigned int>(constant); } #else #define KnError_Is(c,s) (c == (c & s)) #endif #endif /* KNERROR_H */ --- NEW FILE: knexportlibraryknutil.h --- /* /** * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * * @KNOWNOW_LICENSE_START@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The name "KnowNow" is a trademark of KnowNow, Inc. and may not * be used to endorse or promote any product without prior written * permission from KnowNow, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL KNOWNOW, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @KNOWNOW_LICENSE_END@ **/ * Defines export/import declarations for windows interfaces for this dll. * It is important to declare this as export when compiling modules in the dll * and import for modules not in the dll. */ #ifndef KNEXPORTLIBRARYKNUTIL_H #define KNEXPORTLIBRARYKNUTIL_H #ifdef WIN32 #ifdef EXPORT_LIBRARY_KNUTIL_MODULE #define EXPORT_LIBRARY_KNUTIL __declspec(dllexport) #else #define EXPORT_LIBRARY_KNUTIL __declspec(dllimport) #endif #else #define EXPORT_LIBRARY_KNUTIL #endif #endif /* KNEXPORTLIBRARYKNUTIL_H */ --- NEW FILE: knhash.h --- #ifndef KNHASH_H #define KNHASH_H /** * Copyright (c) 2001 KnowNow, Inc. All rights reserved. * * @KNOWNOW_LICENSE_START@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The name "KnowNow" is a trademark of KnowNow, Inc. and may not * be used to endorse or promote any product without prior written * permission from KnowNow, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL KNOWNOW, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @KNOWNOW_LICENSE_END@ **/ #include "knutil/knexportlibraryknutil.h" #include "knutil/kntypes.h" #ifdef __cplusplus extern "C" { #endif /* * General purpose hashing routine. The seed parameter can be * any value, such as the previous hash result. Please see * http://burtleburtle.net/bob/hash/evahash.html for theory. */ extern EXPORT_LIBRARY_KNUTIL uint32_t hash32(const void *buf, uint32_t len, uint32_t seed); extern EXPORT_LIBRARY_KNUTIL uint64_t hash64(const void *buf, uint64_t len, uint64_t seed); #ifdef __cplusplus } // extern "C" #endif #endif /* KNHASH_H */ --- NEW FILE: knlog.h --- #ifndef KNLOG_H /** * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * * @KNOWNOW_LICENSE_START@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The name "KnowNow" is a trademark of KnowNow, Inc. and may not * be used to endorse or promote any product without prior written * permission from KnowNow, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL KNOWNOW, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @KNOWNOW_LICENSE_END@ **/ #define KNLOG_H #include "knutil/knexportlibraryknutil.h" #include "knutil/knerror.h" #include "knutil/knstring.h" /***************************************************************/ * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * /**@defgroup loggingAPI Logging API * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * * * Log to the server.log file. * @{ ****************************************************************/ /** * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * * Logging levels. See KnLog for details on their use. */ enum KnLogSeverity { KnLogNotice, ///< Something somebody might care about KnLogWarning, ///< Something somebody should do something about KnLogError, ///< Something somebody should call KnowNow about KnLogFatal, ///< Something that will cause a non-recoverable crash KnLogBug, ///< Something that "asserts" a fault in the code KnLogDebug, ///< Something only printed when Log_Debug is enabled KnLogDev ///< Something conditional on a specific debug flag }; /** * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * * Log a message to the router. */ extern EXPORT_LIBRARY_KNUTIL KnError KnLog(KnLogSeverity severity, const KnString &msg); /** * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * * Log a printf-style message to the router. */ extern EXPORT_LIBRARY_KNUTIL KnError KnLog(KnLogSeverity severity, const char *fmt, ...) __attribute__ ((format (printf, 2, 3))); #endif --- NEW FILE: knmarkuputil.h --- ////////////////////////////////////////////////////// /** * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * * @KNOWNOW_LICENSE_START@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The name "KnowNow" is a trademark of KnowNow, Inc. and may not * be used to endorse or promote any product without prior written * permission from KnowNow, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL KNOWNOW, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @KNOWNOW_LICENSE_END@ **/ // knmarkuputil.h // // (c)2002-2006, KnowNow, Inc. All Rights Reserved. #ifndef KNMARKUPUTIL_H #define KNMARKUPUTIL_H #include "knutil/knexportlibraryknutil.h" #include "knutil/knstring.h" #include "knutil/simplemap.h" typedef SimpleMap<char*, char*> EntityMap; class EXPORT_LIBRARY_KNUTIL KnMarkupUtil { public: KnMarkupUtil(); ~KnMarkupUtil(); /** * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * * This expands whitespaces HTML tags from the source string and strip all other tags */ bool expandTagsAndStrip(const KnString& source, KnString& transformed); /** * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * * This expands HTML entities from the source string */ bool expandHtmlEntities(const KnString& source, KnString& transformed); /** * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * * This removes XML tags from the source string */ void stripTags(const KnString& source, KnString& transformed); /** * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * * This removes all tags and HTML expands entities from the source string */ bool stripTagsAndExpandEntities(const KnString& source, KnString& transformed); /** * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * * This expands HTML whitespaces tags, removes all other tags and expands HTML entities from the source string */ bool expandTagsAndEntities(const KnString& source, KnString& transformed); // to enable this you will have to add some headers to .cpp and xalan\xerces libraries // bool renderXmlHtml(const KnString* source, KnString* transformed); private: void buildHtlmEntity(); void buildHtlmTags(); EntityMap entityMap; EntityMap tagMap; }; #endif /* KNMARKUPUTIL_H */ --- NEW FILE: knmemory.h --- #ifndef __KNMEMORY_H__ /** * @KNOWNOW_LICENSE_START@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The name "KnowNow" is a trademark of KnowNow, Inc. and may not * be used to endorse or promote any product without prior written * permission from KnowNow, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL KNOWNOW, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @KNOWNOW_LICENSE_END@ **/ #define __KNMEMORY_H__ /* Copyright (c) 2003 KnowNow, Inc. All rights reserved */ #include "knutil/knexportlibraryknutil.h" #include "knutil/kntypes.h" #include "knutil/knlog.h" /** * The KnMemory module retains memory allocation statistics for C++ code * linked into the KnowNow server. * * Used as a very elementary "leak detector": we count on new and * decrement on delete, so if everything is wrapped in objects that * know how to unallocate themselves, we should get zero as we * exit the KnowNow modules. * * Behind the scenes, this module integrates C++ memory allocation * with the ns_malloc() / ns_free() memory allocation of AOLServer * by implementing operator new() and operator delete(). */ class EXPORT_LIBRARY_KNUTIL KnMemory { public: static void increment(); static void decrement(); /** Get the amount of available virtual memory for * this process (volatile). Expressed in bytes */ static size_t getMemoryAvail() ; /** Get the balance of news against deletes * May always return 0 in high-performance release configurations */ static size_t getBalance(); /** Log memory statistics * * If in high-performance release configuration, will print * a message saying that allocations were not tracked. */ static void logStatistics( KnLogSeverity severity = KnLogNotice //- What severity to log with ); private: // Not implemented; makes this a global routine container, since // the class itself can not be instantiated. KnMemory(); KnMemory(const KnMemory &); ~KnMemory(); KnMemory &operator=(const KnMemory &); }; #endif // __KNMEMORY_H__ --- NEW FILE: knmutex.h --- #ifndef KNMUTEX_H #define KNMUTEX_H /** * Copyright (c) 2001 KnowNow, Inc. All rights reserved. * * @KNOWNOW_LICENSE_START@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The name "KnowNow" is a trademark of KnowNow, Inc. and may not * be used to endorse or promote any product without prior written * permission from KnowNow, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL KNOWNOW, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @KNOWNOW_LICENSE_END@ **/ #include "knutil/knexportlibraryknutil.h" #include "knutil/kntypes.h" /* * Mutual exclusion abstraction. */ class EXPORT_LIBRARY_KNUTIL KnMutex { public: KnMutex(); ~KnMutex(); /* * Controls locking/unlocking scope through object lifetime. * If blocking is false, the object will not attempt to wait * for an owned lock. */ class EXPORT_LIBRARY_KNUTIL KnLock { public: KnLock(KnMutex &mutex, bool blocking=true); ~KnLock(); bool owner() const; private: // Not implemented KnLock(); KnLock(const KnLock &); KnLock &operator=(const KnLock &); KnMutex &m_mutex; bool m_owner; }; friend class KnMutex::KnLock; private: // Not implemented KnMutex(const KnMutex &); KnMutex &operator=(const KnMutex &); bool lock(); bool trylock(); bool unlock(); void *m_impl; }; #endif /* KNMUTEX_H */ --- NEW FILE: knnetwork.h --- #ifndef KNNETWORK_H #define KNNETWORK_H /** * Copyright (c) 2001 KnowNow, Inc. All rights reserved. * * @KNOWNOW_LICENSE_START@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The name "KnowNow" is a trademark of KnowNow, Inc. and may not * be used to endorse or promote any product without prior written * permission from KnowNow, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL KNOWNOW, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @KNOWNOW_LICENSE_END@ **/ #include <vector> #include <stack> #include <algorithm> #include "knutil/knexportlibraryknutil.h" #include "knutil/knsmartref.h" #include "knutil/knstring.h" #include "knutil/simplemap.h" #include "knutil/knerror.h" #include "knutil/knlog.h" #include "knutil/knurl.h" #include "knutil/knstrops.h" #include "knutil/kntclinterp.h" #include "knutil/knstringtokenizer.h" /* Maintains a registered sets of URL urlspaces that can be used to * normalize & manage URLs, DNS names, or addresses, comparing them for * membership in particular sets. Sets are arranged in a forest for * comparison, so, e.g., we can have: * * corpnet * + extranet * + liveserver federation * + cluster * + node * <name> * <name>... * * We do our own declarations of these so an individual node that * belongs to more than one domain can still be recognized as having * its own topicspace. We have to do this because our API supports * operations over fully-qualified URIs -- and those URIs might be * for any reachable name for the hosts in the cluster. */ /* These are the reserved network names. We also use the word * "local" to mean "cluster", but this is somewhat more precise. */ class EXPORT_LIBRARY_KNUTIL KnNetworkClassName { public: static const KnString localhost ; static const KnString node ; static const KnString cluster ; static const KnString federation ; }; class EXPORT_LIBRARY_KNUTIL KnUrlSpaceName { public: static const KnString topic ; }; /* Violation of our normal lexical convention: * I'm directly marking each method with whether it's public * etc., because I think that makes it easier to maintain the code. * Follows Wilson (Imperfect C++) * * It's really irritating; in the end, I just hid the singleton * behind static methods, so this could have just as easily just * been a namespace, instead of a class. Did that because the * easier-to-write edition (with lots of inlines & templates) * literally blew up the VS7 compiler. OTOH, now we can * more gradually expose the internal classes if we need them. */ class EXPORT_LIBRARY_KNUTIL KnNetwork { // --------------------- // Process initialization // --------------------- public: static KnError configure(const KnSet& configSet, const KnString& urlSpace = KnStringConstants::slash_kn) ; // --------------------- // Network class queries // --------------------- public: static bool isNode( const std::string& address ) { KnString addr(address.c_str(),address.length()); return isNode(addr); } public: static bool isNode( const KnString& address ) { KnUrl url(address); return isNode(url); } public: static bool isNode( const KnUrl& url ) { return isMember(url,KnNetworkClassName::node); } public: static bool isLocal( const std::string& address ) { KnString addr(address.c_str(),address.length()); return isLocal(addr); } public: static bool isLocal( const KnString& address ) { KnUrl url(address); return isLocal(url); } public: static bool isLocal( const KnUrl& url ) ; public: static bool isMember( const KnUrl& url, const KnString& network ) ; public: static KnError getHttpUri(KnString& root, const KnString& netName); public: static KnError getHttpsUri(KnString& root, const KnString& netName) ; public: static Tcl_Obj* listNetworks(Tcl_Interp *interp); public: /* Should take string for matching with */ static Tcl_Obj* listHosts(Tcl_Interp *interp); // ------------------------- // Network class management // ------------------------- public: static KnError addNetwork(const KnString& newClass, const KnString& inClass, bool hasURI) ; public: static KnError addUrlToClass(const KnString& url, const KnString& netName) ; /* --------------------- * urlspace query * -------------------- */ public: static KnError inSpace( bool& yesno, const std::string& url, const KnString& space = KnUrlSpaceName::topic); /* --------------------- * urlspace management * -------------------- */ public: static Tcl_Obj* listUrlSpaces(Tcl_Interp *interp) ; public: // urlRoot must be relative, single initial /. Should *not* end // in '/'. Considered adding KnUrlSpace class; seemed to heavy. // Currently think there's no need to have lookup; urlspace name should == urlroot. // but coded this way for another level of indirection. Hmm. static KnError addUrlSpace(const KnString& urlSpace, const KnString& urlRoot) ; public: static const KnString* getUrlRoot(KnString& urlSpace) ; public: // Add just the prefix to the set of URL mappings; don't add the host. // This is used for "mappings", where // a reverse proxy has said that it is mapped to a specific prefix, but // we don't know that the host part is actually reachable, nor that // it is shared with any of the rest of our URLspace. E.g. // // proxy @ http://www.example.com maps // /ess to locally name http://xyz.ex.com/kness/live // /topics to local name http://xyz.ex.com/kn // We want several things: // is_topic http://xyz.ex.com/topics/foobar => true // is_local http://xyz.ex.com/topics/foobar => true // is_local http://xyz.ex.com/ess/foobar => true // is_local http://xyz.ex.com/something/else => false // normalize_topic http://xyz.ex.com/topics/foobar => /kn/foobar // relative_path http://xyz.ex.com/ess/foobar => /kness/live/foobar // relative_path http://xyz.ex.com/something/else => // http://xyz.ex.com/something/else static KnError addMapping(const KnString& urlSpace, const KnString& prefix) ; // ------------------------------ // Combined operations. // // Use these as the normal ways to record // things we learn about how we're accessed // ------------------------------ public: // Topicspace should call this with urlspace == its urlroot. Perms and other // AOLServer filters (as opposed to procs) usually should leave it null, since they // don't necessarily know the root of the pattern they're manageing. // should keep it 0, since it doesn't know what U static KnError KnNetwork::addHostAlias(Ns_Conn *conn, const KnString *urlspace = 0) ; public: // Adds the location as a mapping for the urlspace name "urlspace", // Also adds the host & port component of the URL to the network class class. // Used as the replacement for typical // KnProperties::addHostAlias(KnString prefix); it's a convenience entry point in // the case where you know scheme & host part of the URL address this server. // // It's convenient, but not always correct; in some mapping scenarios, it's // perfectly possible, for example, for us to want: // is_local http://xyz.ex.com/kn/foobar => true // is_local http://xyz.ex.com/some/thing => false // We do this by only registering the mapping. See "addMapping" static KnError addUrl( const KnString& urlspace, const KnString& prefix, const KnString& network = KnNetworkClassName::cluster ) ; public: // This is like addUrl, but it takes an url with no path, and extends it with the // urlroot for the given urlspace before registering it as a mapping. Useful // during configuration, where we know the addresses and want to factor the basic // urlroot across all those addresses. Adds to the default network if none specified. static KnError addHostWithPrefix( const KnString& urlSpace, const KnString& url, const KnString& network = KnStringConstants::empty) ; /* ----------------------------------------*/ /* URL normalization & relativization */ /* ----------------------------------------*/ // Creates *canonicalized*, *normalized*, // path-absolute URI IFF the given URL is known // to be cluster-local & in some prefix associated // with the urlspace. As part of canonicalizing, // any matching prefix is _replaced_ with the first prefix // registered for that urlspace. If no matching // prefix is given, the canonical prefix is prepended. // // Note that KnProperties::formatLocation contains // additional logic associated with any event replicated // by the clustering code. I hope that can be deleted // now (but see GS' comment regarding TD3095). // // Could certainly be made faster by removing some // KnString uses and using std::string. But I'm out of time. public: static KnError formatTopicLocation( KnString& location, const KnString& urlSpace = KnUrlSpaceName::topic ); public: static KnError formatNonNetworkRelativeRef(KnString& location,size_t inputPfxLen) ; // Accepts a string that should be a "path" (and tail and query & fragment) part // with no "network" component (recall that there are "network relative refs" which // look like '//user:info@host:port/pathpart'; those won't work here). // // Normalizes just the path & tail part, but treats '?' & '#' as legal // characters inside components, rather than the termination of the path part. // This is required for topicnames, since they've always worked that way // and we have lots of existing topics with un-escaped '?' in their names. // // Treats the first inputPfxLen chars as "can't touch these". public: static KnError formatTopicRelativeRef(KnString& location,size_t inputPfxLen); }; #endif /* KNNETWORK_H */ --- NEW FILE: knnewdelete.h --- #ifndef KNNEWDELETE_H /** * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * * @KNOWNOW_LICENSE_START@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The name "KnowNow" is a trademark of KnowNow, Inc. and may not * be used to endorse or promote any product without prior written * permission from KnowNow, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL KNOWNOW, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @KNOWNOW_LICENSE_END@ **/ #define KNNEWDELETE_H #ifndef KNMODULE /* You should define your module name before including this file. * Right now, it's unused, but we may really want it in future. */ static unsigned int foo ( unsigned int bar ) { return 0 ; } ; // Generate a warning #endif /** * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * * This is some wierd code. * * Operator new & operator delete have single linkage scope. * * That means they only get as big as one DLL or one .so; you can't * ensure that the same one is used in all dynamic libraries easily. * See Matthew Wilson, Imperfect C++, p. 130 * * So to get a global counter, we need to have (a) global counters * (defined in knmemory.cpp), but local routines. * * This is now a pretty fair amount of CPU overhead per allocation. * (though still constant time). * We may need to optimize things a bit better in future. * * To do that, we #include this file once in all our modules. * Yuck!!! * * -- ReC 05/08/03, updated 7 Apr 06 */ #include "knutil/knexportlibraryknutil.h" #include "knutil/kntypes.h" #include "knutil/atomicint.h" #include "knutil/knmemory.h" /** * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * * C++ wrapper for ns_malloc * * To get the benefits of using the ns_malloc routine (integrated error * messages, clearing cache memory when approaching fullness), we override * the C++ memory allocation system to use ns_malloc. Of course, ns_malloc * eventually uses malloc underneath it, which gives us the opportunity to * use ATS, Purify, or other allocation systems. * * We need to link this into all our C++ DLLs. We also need to examine our * topic & event API; if we support new & deletion of refcounted structures * in customer-written filters, we'll want to encourage them to use these * wrappers. */ void * operator new ( size_t size ) { #if 0 if (0 == nAllocs) KnLog(KnLogNotice,"Registering KnowNow ns_malloc wrapper"); #endif KnMemory::increment() ; return ns_malloc(size) ; } void * operator new[] (size_t size) { KnMemory::increment() ; return ns_malloc(size); } /** * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * * C++ wrapper for ns_free * * To get the benefits of using the ns_malloc routine (integrated error * messages, clearing cache memory when approaching fullness), we override * the C++ memory allocation system to use ns_malloc. Of course, ns_malloc * eventually uses malloc underneath it, which gives us the opportunity to * use ATS, Purify, or other allocation systems. */ void operator delete( void *pFreeThis ) { ns_free(pFreeThis); KnMemory::decrement() ; } void operator delete[]( void *pFreeThis ) { ns_free(pFreeThis); KnMemory::decrement() ; } #endif /* KNNEWDELETE_H */ --- NEW FILE: knpattern.h --- #ifndef KN_PATTERN_H /** * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * * @KNOWNOW_LICENSE_START@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The name "KnowNow" is a trademark of KnowNow, Inc. and may not * be used to endorse or promote any product without prior written * permission from KnowNow, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL KNOWNOW, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @KNOWNOW_LICENSE_END@ **/ #define KN_PATTERN_H #include "knutil/knexportlibraryknutil.h" #include "knutil/knlog.h" #include "knutil/knregex.h" #include "knutil/knrwlock.h" #include "knutil/knset.h" #include "knutil/knsmartref.h" #include "knutil/knstring.h" #include <vector> #include <list> #include <map> class EXPORT_LIBRARY_KNUTIL KnMatcher { public: KnMatcher(const char* string); ~KnMatcher(); Tcl_Obj* getTclObj(); private: Tcl_Obj* m_obj; }; class EXPORT_LIBRARY_KNUTIL KnPattern { public: KnPattern(); KnPattern( const KnString& name ); virtual ~KnPattern() {}; bool isValidRegex() const; virtual bool match(const char* string) const; virtual bool match(KnMatcher& matchObj) const; virtual int getSubCount() const; virtual bool matchSubs(const char *str, KnSet& result); bool setRegexPattern(const char* pattern); bool setRegexPattern(const KnString& pattern); const KnString& getName() const; const KnString& getRegexPattern() const; const KnRegEx& getRegexMatcher() const; protected: bool lessSpecificThan(const KnPattern& rhs) const; KnRegEx m_regex; KnString m_name; KnString m_regexPattern; }; template<class Pattern, class Info> class IKnPatterns { public: IKnPatterns() {} virtual ~IKnPatterns() {} virtual bool findBestMatch( const char* string, KnSmartRef<Pattern>& pattern, KnSmartRef<Info>& info) const = 0; virtual bool findAllMatches( const char* string, std::vector<std::pair<KnSmartRef<Pattern>, KnSmartRef<Info> > >& matches) const = 0; virtual bool findBestMatchSubs( const char* string, KnSet& subs, KnSmartRef<Pattern>& pattern, KnSmartRef<Info>& info) const = 0; virtual bool findAllMatchesSubs( const char* string, std::vector<std::pair< KnSet*, KnSmartRef<Info> > >& matches) const = 0; virtual bool findByName( const KnString& name, KnSmartRef<Pattern>& pattern, KnSmartRef<Info>& info) const = 0; virtual bool removeByName( const KnString& name) = 0; virtual void dump(KnLogSeverity severity = KnLogDev) = 0; virtual void put(Pattern* pattern, Info* info) = 0; virtual bool isEmpty() = 0; }; // MapValue must be a subclass of IKnPatterns template<class MapKey, class MapValue, class Pattern, class Info> class KnPatternFinder { public: class ScopedWriteable { public: ScopedWriteable(KnPatternFinder<MapKey,MapValue,Pattern,Info>& pf) : m_writeLock(pf.m_rwlock) { }; private: KnRWLock::KnWriteLock m_writeLock; }; friend class KnPatternFinder<MapKey,MapValue,Pattern,Info>::ScopedWriteable; class ScopedReadable { public: ScopedReadable(KnPatternFinder<MapKey,MapValue,Pattern,Info>& pf) : m_readLock(pf.m_rwlock) { }; private: KnRWLock::KnReadLock m_readLock; }; friend class KnPatternFinder<MapKey,MapValue,Pattern,Info>::ScopedWriteable; MapValue* get( const MapKey& mk) const { MapTypeIteratorConst it = m_map.find(mk); if(it != m_map.end()) return it->second; return NULL; } bool findBestMatch( const MapKey& mk, const char* string, KnSmartRef<Pattern>& pattern, KnSmartRef<Info>& info) const { MapValue* mv = get(mk); if(!mv) return false; return mv->findBestMatch(string,pattern,info); } bool findAllMatches( const MapKey& mk, const char* string, std::vector<std::pair<KnSmartRef<Pattern>, KnSmartRef<Info> > >& matches) const { MapValue* mv = get(mk); if(!mv) return false; return mv->findAllMatches(string,matches); } bool findBestMatchSubs( const MapKey& mk, const char* string, KnSet& subs, KnSmartRef<Pattern>& pattern, KnSmartRef<Info>& info) const { MapValue* mv = get(mk); if(!mv) return false; return mv->findBestMatchSubs(string,subs,pattern,info); } virtual bool findAllMatchesSubs( const MapKey& mk, const char* string, std::vector<std::pair< KnSet*, KnSmartRef<Info> > >& matches) const { MapValue* mv = get(mk); if(!mv) return false; return mv->findAllMatchesSubs(string,matches); } bool findByName( const MapKey& mk, const KnString& name, KnSmartRef<Pattern>& pattern, KnSmartRef<Info>& info) const { MapValue* mv = get(mk); if(!mv) return false; return mv->findByName(name,pattern,info); } // remove first found with that name bool removeByName( const KnString& name) { MapValue* value; bool result = false; for(MapTypeIterator it = m_map.begin(); it != m_map.end(); ) { value = it->second; result = result || (value->removeByName(name)); if(value->isEmpty()) { m_map.erase(it); return result; } } return re... [truncated message content] |
|
From: <co...@us...> - 2008-05-16 00:24:13
|
Update of /cvsroot/aolserver/knutil/include In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv6393/include Added Files: knexportlibraryknutilmodule.h knkillprocess_win32.h Log Message: Added this library to the AOLServer.com repository. It contains a number of C/C++ utilities, some of which integrate into AOLServer, and many of which standalone. A portion of the library is required for the knregistration module, which will be checked in next. I believe this compiles fine in "native" AOLServer, but it has not been tested recently. --- NEW FILE: knexportlibraryknutilmodule.h --- /* /** * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * * @KNOWNOW_LICENSE_START@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The name "KnowNow" is a trademark of KnowNow, Inc. and may not * be used to endorse or promote any product without prior written * permission from KnowNow, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL KNOWNOW, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @KNOWNOW_LICENSE_END@ **/ * Defines this modules as part of the knutil.dll. * See knexportlibraryknutil.h for more details. */ #define EXPORT_LIBRARY_KNUTIL_MODULE #include "knutil/knexportlibraryknutil.h" --- NEW FILE: knkillprocess_win32.h --- /** * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * * @KNOWNOW_LICENSE_START@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The name "KnowNow" is a trademark of KnowNow, Inc. and may not * be used to endorse or promote any product without prior written * permission from KnowNow, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL KNOWNOW, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @KNOWNOW_LICENSE_END@ **/ /* * This code is from http://www.codeproject.com/threads/killprocess.asp * knprocmgr uses it to kill processes on windows given the process name since * processes are spawned using cmd.exe and the process id available is only * that of the cmd.exe. */ #include <tlhelp32.h> #include "windows.h" typedef LONG NTSTATUS; typedef LONG KPRIORITY; #define NT_SUCCESS(Status) ((NTSTATUS)(Status) >= 0) #define STATUS_INFO_LENGTH_MISMATCH ((NTSTATUS)0xC0000004L) #define SystemProcessesAndThreadsInformation 5 typedef struct _CLIENT_ID { DWORD UniqueProcess; DWORD UniqueThread; } CLIENT_ID; typedef struct _UNICODE_STRING { USHORT Length; USHORT MaximumLength; PWSTR Buffer; } UNICODE_STRING; typedef struct _VM_COUNTERS { SIZE_T PeakVirtualSize; SIZE_T VirtualSize; ULONG PageFaultCount; SIZE_T PeakWorkingSetSize; SIZE_T WorkingSetSize; SIZE_T QuotaPeakPagedPoolUsage; SIZE_T QuotaPagedPoolUsage; SIZE_T QuotaPeakNonPagedPoolUsage; SIZE_T QuotaNonPagedPoolUsage; SIZE_T PagefileUsage; SIZE_T PeakPagefileUsage; } VM_COUNTERS; typedef struct _SYSTEM_THREADS { LARGE_INTEGER KernelTime; LARGE_INTEGER UserTime; LARGE_INTEGER CreateTime; ULONG WaitTime; PVOID StartAddress; CLIENT_ID ClientId; KPRIORITY Priority; KPRIORITY BasePriority; ULONG ContextSwitchCount; LONG State; LONG WaitReason; } SYSTEM_THREADS, * PSYSTEM_THREADS; // Note that the size of the SYSTEM_PROCESSES structure is // different on NT 4 and Win2K, but we don't care about it, // since we don't access neither IoCounters member nor //Threads array typedef struct _SYSTEM_PROCESSES { ULONG NextEntryDelta; ULONG ThreadCount; ULONG Reserved1[6]; LARGE_INTEGER CreateTime; LARGE_INTEGER UserTime; LARGE_INTEGER KernelTime; UNICODE_STRING ProcessName; KPRIORITY BasePriority; ULONG ProcessId; ULONG InheritedFromProcessId; ULONG HandleCount; ULONG Reserved2[2]; VM_COUNTERS VmCounters; #if _WIN32_WINNT >= 0x500 IO_COUNTERS IoCounters; #endif SYSTEM_THREADS Threads[1]; } SYSTEM_PROCESSES, * PSYSTEM_PROCESSES; class CKillProcess { private: //Functions loaded from Kernel32 typedef HANDLE (WINAPI *PFCreateToolhelp32Snapshot)( DWORD dwFlags, DWORD th32ProcessID ); typedef BOOL (WINAPI *PFProcess32First)( HANDLE hSnapshot, LPPROCESSENTRY32 lppe ); typedef BOOL (WINAPI *PFProcess32Next)( HANDLE hSnapshot, LPPROCESSENTRY32 lppe ); // Native NT API Definitions typedef NTSTATUS (WINAPI * PFZwQuerySystemInformation) (UINT, PVOID, ULONG, PULONG); typedef HANDLE (WINAPI* PFGetProcessHeap)(VOID); typedef LPVOID (WINAPI* PFHeapAlloc) (HANDLE,DWORD,SIZE_T); typedef BOOL (WINAPI* PFHeapFree)(HANDLE,DWORD,LPVOID); public: CKillProcess() : FCreateToolhelp32Snapshot(NULL), FProcess32First(NULL), FProcess32Next(NULL), m_hKernelLib(NULL), m_hNTLib(NULL) { m_hKernelLib = ::LoadLibraryA("Kernel32"); if (m_hKernelLib) { // Find ToolHelp functions FCreateToolhelp32Snapshot = (PFCreateToolhelp32Snapshot) ::GetProcAddress(m_hKernelLib, "CreateToolhelp32Snapshot"); FProcess32First = (PFProcess32First) ::GetProcAddress(m_hKernelLib, "Process32First"); FProcess32Next = (PFProcess32Next) ::GetProcAddress(m_hKernelLib, "Process32Next"); } if(!FCreateToolhelp32Snapshot || !FProcess32First || !FProcess32Next) { // i.e. we couldn't find the ToolHelp functions, //so we must be on NT4. Let's load the // undocumented one instead. if(!m_hKernelLib) return; // can't do anything at all without //the kernel. m_hNTLib = ::LoadLibraryA("ntdll.dll"); if(m_hNTLib) { FQuerySysInfo = (PFZwQuerySystemInformation) ::GetProcAddress(m_hNTLib, "ZwQuerySystemInformation"); // load some support funcs from the kernel FGetProcessHeap = (PFGetProcessHeap) ::GetProcAddress(m_hKernelLib, "GetProcessHeap"); FHeapAlloc = (PFHeapAlloc) ::GetProcAddress(m_hKernelLib, "HeapAlloc"); FHeapFree = (PFHeapFree) ::GetProcAddress(m_hKernelLib, "HeapFree"); } } } ~CKillProcess() { if(m_hKernelLib) FreeLibrary(m_hKernelLib); if(m_hNTLib) FreeLibrary(m_hNTLib); } bool KillProcess(IN const char* pstrProcessName, OUT int *exitcode) { DWORD dwId; HANDLE hProcess = FindProcess(pstrProcessName, dwId); BOOL bResult; if(!hProcess) return true; // TerminateAppEnum() posts WM_CLOSE to all windows whose PID // matches your process's. ::EnumWindows((WNDENUMPROC) CKillProcess::TerminateAppEnum, (LPARAM) dwId); // Wait on the handle. If it signals, great. //If it times out, then you kill it. if(WaitForSingleObject(hProcess, 5000) !=WAIT_OBJECT_0) bResult = TerminateProcess(hProcess,static_cast<UINT>(-1)); else bResult = TRUE; CloseHandle(hProcess); if (exitcode) *exitcode = -1; return bResult == TRUE; } HANDLE FindProcess(IN const char* pstrProcessName, OUT DWORD& dwId) { if(!m_hKernelLib) return NULL; if(FCreateToolhelp32Snapshot && FProcess32First && FProcess32Next) // use toolhelpapi return THFindProcess(pstrProcessName, dwId); if(FQuerySysInfo && FHeapAlloc && FGetProcessHeap && FHeapFree) // use NT api return NTFindProcess(pstrProcessName, dwId); // neither one got loaded. Strange. return NULL; } private: HANDLE THFindProcess(IN const char* pstrProcessName, OUT DWORD& dwId) { HANDLE hSnapShot=NULL; HANDLE hResult = NULL; PROCESSENTRY32 processInfo; char* pstrExeName; bool bFirst = true; ::ZeroMemory(&processInfo, sizeof(PROCESSENTRY32)); processInfo.dwSize = sizeof(PROCESSENTRY32); hSnapShot = FCreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0); if(hSnapShot == INVALID_HANDLE_VALUE) return NULL; // ok now let's iterate with Process32Next until we // match up the name of our process while((bFirst ? FProcess32First(hSnapShot, &processInfo) : FProcess32Next(hSnapShot, &processInfo))) { bFirst = false; // we need to check for path... and extract // just the exe name pstrExeName = strrchr(processInfo.szExeFile, '\\'); if(!pstrExeName) pstrExeName = processInfo.szExeFile; else pstrExeName++; // skip the \ // ok now compare against our process name if(stricmp(pstrExeName, pstrProcessName) == 0) // wee weee we found it { // let's get a HANDLE on it hResult=OpenProcess( SYNCHRONIZE|PROCESS_TERMINATE, TRUE, processInfo.th32ProcessID); dwId = processInfo.th32ProcessID; break; } } // while(Process32Next(hSnapShot, &processInfo){ if(hSnapShot) CloseHandle(hSnapShot); return hResult; } HANDLE NTFindProcess(IN const char* pstrProcessName, OUT DWORD& dwId) { HANDLE hHeap = FGetProcessHeap(); NTSTATUS Status; ULONG cbBuffer = 0x8000; PVOID pBuffer = NULL; HANDLE hResult = NULL; // it is difficult to say a priory which size of // the buffer will be enough to retrieve all // information, so we startwith 32K buffer and // increase its size until we get the // information successfully do { pBuffer = HeapAlloc(hHeap, 0, cbBuffer); if (pBuffer == NULL) return SetLastError( ERROR_NOT_ENOUGH_MEMORY), NULL; Status = FQuerySysInfo( SystemProcessesAndThreadsInformation, pBuffer, cbBuffer, NULL); if (Status == STATUS_INFO_LENGTH_MISMATCH) { HeapFree(hHeap, 0, pBuffer); cbBuffer *= 2; } else if (!NT_SUCCESS(Status)) { HeapFree(hHeap, 0, pBuffer); return SetLastError(Status), NULL; } } while (Status == STATUS_INFO_LENGTH_MISMATCH); PSYSTEM_PROCESSES pProcesses = (PSYSTEM_PROCESSES)pBuffer; for (;;) { PCWSTR pszProcessName = pProcesses->ProcessName.Buffer; if (pszProcessName == NULL) pszProcessName = L"Idle"; CHAR szProcessName[MAX_PATH]; WideCharToMultiByte(CP_ACP, 0, pszProcessName, -1,szProcessName, MAX_PATH, NULL, NULL); if(stricmp(szProcessName, pstrProcessName) == 0) // found it { hResult=OpenProcess( SYNCHRONIZE|PROCESS_TERMINATE, TRUE, pProcesses->ProcessId); dwId = pProcesses->ProcessId; break; } if (pProcesses->NextEntryDelta == 0) break; // find the address of the next process // structure pProcesses = (PSYSTEM_PROCESSES)( ((LPBYTE)pProcesses) + pProcesses->NextEntryDelta); } HeapFree(hHeap, 0, pBuffer); return hResult; } // callback function for window enumeration static BOOL CALLBACK TerminateAppEnum( HWND hwnd, LPARAM lParam ) { DWORD dwID ; GetWindowThreadProcessId(hwnd, &dwID) ; if(dwID == (DWORD)lParam) { PostMessage(hwnd, WM_CLOSE, 0, 0) ; } return TRUE ; } HMODULE m_hNTLib; HMODULE m_hKernelLib; // ToolHelp related functions PFCreateToolhelp32Snapshot FCreateToolhelp32Snapshot; PFProcess32First FProcess32First; PFProcess32Next FProcess32Next; // native NT api functions PFZwQuerySystemInformation FQuerySysInfo; PFGetProcessHeap FGetProcessHeap; PFHeapAlloc FHeapAlloc; PFHeapFree FHeapFree; }; |
|
From: <co...@us...> - 2008-05-16 00:24:13
|
Update of /cvsroot/aolserver/knutil In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv6393 Added Files: Makefile knutil-mak.inc knutil.mak.in knutil.vs7.vcproj knutil.vs8.vcproj Log Message: Added this library to the AOLServer.com repository. It contains a number of C/C++ utilities, some of which integrate into AOLServer, and many of which standalone. A portion of the library is required for the knregistration module, which will be checked in next. I believe this compiles fine in "native" AOLServer, but it has not been tested recently. --- NEW FILE: Makefile --- # # Library definitions # DLL = knutil DLLDEVEL= knutil HDRS = include/knutil OBJS = src/atomicint.o \ src/counter.o \ src/kncircularmapping.o \ src/knconsistenthash.o \ src/kncrashhandler.o \ src/kncrypt.o \ src/knerror.o \ src/knhash.o \ src/knlog.o \ src/knmemory.o \ src/knmutex.o \ src/knnetwork.o \ src/knnewdelete.o \ src/knpattern.o \ src/knperfstatistics.o \ src/knregex.o \ src/knrwlock.o \ src/knrwlogginglock.o \ src/knset.o \ src/knsleep.o \ src/knstring.o \ src/knstringtokenizer.o \ src/kntclerrors.o \ src/kntclfile.o \ src/kntclinterp.o \ src/kntemplateuri.o \ src/kntime.o \ src/knurl.o \ src/mtrand.o \ src/randomnumber.o \ src/shahash.o \ src/knmarkuputil.o \ src/uuidgenerator.o SRCDIR = .. UNIXOBJS = src/knsysutility_unix.o WINOBJS = src/knsysutility_win32.o CUSTOM_DEFS_FILE = knutil.mak include ../include/ns.mak include knutil.mak --- NEW FILE: knutil-mak.inc --- !ifndef KNUTIL_MAK KNUTIL_MAK=1 # # Location of dependencies # SUPPORT = ../../../Support BUGSLAYER = $(SUPPORT)/BugSlayer # # Additional compiler flags # CPPFLAGS = $(CPPFLAGS) /D KN_PRIVATE /I$(BUGSLAYER)/include # # Additional C++ libraries # LIBS = $(LIBS) gdi32.lib rpcrt4.lib user32.lib /LIBPATH:$(BUGSLAYER)/release bugslayerutil.lib !else install: install-includes install-bugslayer install-includes: $(INST) -d $(INSTINC) $(HDRS)/*.h install-bugslayer: $(INST) -d $(AOLSERVER)/bin $(BUGSLAYER)/release/*.dll !endif --- NEW FILE: knutil.mak.in --- # # Location of dependencies # SUPPORT = ../../../Support COREDUMPER = $(SUPPORT)/coredumper # # Additional compiler flags # CPPFLAGS += -DKN_PRIVATE=1 -I$(COREDUMPER)/include # # Additional C++ libraries # ifneq (,$(findstring Linux,$(uname))) LDFLAGS += -L$(COREDUMPER)/lib -lcoredumper endif # # Force C++ linkage. Use ':=' to invoke immediate evaluation. # LDLIB := $(subst gcc,g++,$(LDLIB)) LDLIB := $(subst -nostartfiles,,$(LDLIB)) install: install-includes install-coredumper install-includes: $(INST) -d $(INSTINC)/knutil $(HDRS)/*.h install-coredumper: ifneq (,$(findstring Linux,$(uname))) (cd $(COREDUMPER)/lib ; tar -cf- lib*.so*) | (cd $(AOLSERVER)/lib ; tar -xf-) endif --- NEW FILE: knutil.vs7.vcproj --- <?xml version="1.0" encoding="Windows-1252"?> <VisualStudioProject ProjectType="Visual C++" Version="7.10" Name="knutil" ProjectGUID="{540797B1-E241-4EBB-9CC9-8C0070289A26}" RootNamespace="knutil"> <Platforms> <Platform Name="Win32"/> </Platforms> <Configurations> <Configuration Name="Release|Win32" OutputDirectory=".\Release" IntermediateDirectory=".\Release" ConfigurationType="2" UseOfMFC="0" ATLMinimizesCRunTimeLibraryUsage="FALSE" CharacterSet="2"> <Tool Name="VCCLCompilerTool" Optimization="1" InlineFunctionExpansion="1" OptimizeForProcessor="2" AdditionalIncludeDirectories="include;..\include;..\..\..\Support\BugSlayer\include" PreprocessorDefinitions="NDEBUG;_WINDOWS;_USRDLL;WIN32;FD_SETSIZE=2048;NO_CONST=1;KN_PRIVATE;CURL_STATICLIB" StringPooling="TRUE" RuntimeLibrary="2" EnableFunctionLevelLinking="TRUE" UsePrecompiledHeader="2" PrecompiledHeaderFile=".\Release\knutil.pch" AssemblerListingLocation=".\Release/" ObjectFile=".\Release/" ProgramDataBaseFileName=".\Release/" BrowseInformation="1" WarningLevel="4" SuppressStartupBanner="TRUE" DebugInformationFormat="3" CompileAs="0"/> <Tool Name="VCCustomBuildTool"/> <Tool Name="VCLinkerTool" AdditionalDependencies="knutil.exp nsd.lib nsthread.lib tcl84t.lib BugslayerUtil.lib rpcrt4.lib ws2_32.lib" OutputFile=".\Release/knutil.dll" LinkIncremental="1" SuppressStartupBanner="TRUE" AdditionalLibraryDirectories="Release;..\lib;..\..\..\Support\BugSlayer\release" GenerateDebugInformation="TRUE" ProgramDatabaseFile=".\Release\knutil.pdb" GenerateMapFile="TRUE" MapFileName=".\Release\knutil.map" MapExports="TRUE" MapLines="TRUE" LargeAddressAware="0" BaseAddress="@..\base_addresses.txt,$(ProjectName)" ImportLibrary=".\Release\knutil.lib" TargetMachine="1"/> <Tool Name="VCMIDLTool"/> <Tool Name="VCPostBuildEventTool"/> <Tool Name="VCPreBuildEventTool"/> <Tool Name="VCPreLinkEventTool" Description="Mutual Imports" CommandLine="lib /def /out:release\knutil.lib release\*.obj"/> <Tool Name="VCResourceCompilerTool" PreprocessorDefinitions="NDEBUG" Culture="1033"/> <Tool Name="VCWebServiceProxyGeneratorTool"/> <Tool Name="VCXMLDataGeneratorTool"/> <Tool Name="VCWebDeploymentTool"/> <Tool Name="VCManagedWrapperGeneratorTool"/> <Tool Name="VCAuxiliaryManagedWrapperGeneratorTool"/> </Configuration> <Configuration Name="Debug|Win32" OutputDirectory="$(ConfigurationName)" IntermediateDirectory="$(ConfigurationName)" ConfigurationType="2" UseOfMFC="0" ATLMinimizesCRunTimeLibraryUsage="FALSE" CharacterSet="2"> <Tool Name="VCCLCompilerTool" Optimization="0" InlineFunctionExpansion="0" OptimizeForProcessor="2" AdditionalIncludeDirectories="include;..\include;..\..\..\Support\BugSlayer\include" PreprocessorDefinitions="_DEBUG;_WINDOWS;_USRDLL;WIN32;FD_SETSIZE=2048;NO_CONST=1;KN_PRIVATE;CURL_STATICLIB" StringPooling="TRUE" BasicRuntimeChecks="3" RuntimeLibrary="3" BufferSecurityCheck="TRUE" EnableFunctionLevelLinking="TRUE" UsePrecompiledHeader="2" PrecompiledHeaderFile=".\Debug\knutil.pch" AssemblerListingLocation=".\Debug/" ObjectFile=".\Debug/" ProgramDataBaseFileName=".\Debug/" BrowseInformation="1" WarningLevel="4" SuppressStartupBanner="TRUE" DebugInformationFormat="3" CompileAs="0"/> <Tool Name="VCCustomBuildTool"/> <Tool Name="VCLinkerTool" AdditionalDependencies="knutil.exp nsd.lib nsthread.lib tcl84t.lib BugslayerUtil.lib rpcrt4.lib ws2_32.lib" OutputFile=".\Debug/knutil.dll" LinkIncremental="1" SuppressStartupBanner="TRUE" AdditionalLibraryDirectories="Debug;..\lib;..\..\..\Support\BugSlayer\release" IgnoreAllDefaultLibraries="FALSE" GenerateDebugInformation="TRUE" ProgramDatabaseFile=".\Debug\knutil.pdb" GenerateMapFile="TRUE" MapFileName=".\Debug\knutil.map" MapExports="TRUE" MapLines="TRUE" LargeAddressAware="0" BaseAddress="@..\base_addresses.txt,$(ProjectName)" ImportLibrary=".\Debug\knutil.lib" TargetMachine="1"/> <Tool Name="VCMIDLTool"/> <Tool Name="VCPostBuildEventTool"/> <Tool Name="VCPreBuildEventTool"/> <Tool Name="VCPreLinkEventTool" Description="Mutual Imports" CommandLine="lib /def /out:debug\knutil.lib debug\*.obj"/> <Tool Name="VCResourceCompilerTool" PreprocessorDefinitions="NDEBUG" Culture="1033"/> <Tool Name="VCWebServiceProxyGeneratorTool"/> <Tool Name="VCXMLDataGeneratorTool"/> <Tool Name="VCWebDeploymentTool"/> <Tool Name="VCManagedWrapperGeneratorTool"/> <Tool Name="VCAuxiliaryManagedWrapperGeneratorTool"/> </Configuration> </Configurations> <References> </References> <Files> <Filter Name="Source Files" Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"> <File RelativePath=".\src\atomicint.cpp"> </File> <File RelativePath=".\src\counter.cpp"> </File> <File RelativePath=".\src\kncircularmapping.cpp"> </File> <File RelativePath=".\src\knconsistenthash.cpp"> </File> <File RelativePath=".\src\kncrashhandler.cpp"> </File> <File RelativePath=".\src\kncrypt.cpp"> </File> <File RelativePath=".\src\knerror.cpp"> </File> <File RelativePath=".\src\knhash.cpp"> </File> <File RelativePath=".\src\knlog.cpp"> </File> <File RelativePath=".\src\knmarkuputil.cpp"> </File> <File RelativePath=".\src\knmemory.cpp"> </File> <File RelativePath=".\src\knmutex.cpp"> </File> <File RelativePath=".\src\knnetwork.cpp"> </File> <File RelativePath=".\src\knnewdelete.cpp"> </File> <File RelativePath=".\src\knpattern.cpp"> </File> <File RelativePath=".\src\knperfstatistics.cpp"> </File> <File RelativePath=".\src\knregex.cpp"> </File> <File RelativePath=".\src\knrwlock.cpp"> </File> <File RelativePath=".\src\knrwlogginglock.cpp"> </File> <File RelativePath=".\src\knset.cpp"> </File> <File RelativePath=".\src\knsleep.cpp"> </File> <File RelativePath=".\src\knstring.cpp"> </File> <File RelativePath=".\src\knstringtokenizer.cpp"> </File> <File RelativePath=".\src\knsysutility_win32.cpp"> </File> <File RelativePath=".\src\kntclerrors.cpp"> </File> <File RelativePath=".\src\kntclfile.cpp"> </File> <File RelativePath=".\src\kntclinterp.cpp"> </File> <File RelativePath=".\src\kntemplateuri.cpp"> </File> <File RelativePath=".\src\kntime.cpp"> </File> <File RelativePath=".\src\knurl.cpp"> </File> <File RelativePath=".\src\mtrand.cpp"> </File> <File RelativePath=".\src\randomnumber.cpp"> </File> <File RelativePath=".\src\shahash.cpp"> </File> <File RelativePath=".\src\uuidgenerator.cpp"> </File> </Filter> <Filter Name="Header Files" Filter="h;hpp;hxx;hm;inl"> <File RelativePath=".\include\knexportlibraryknutilmodule.h"> </File> <File RelativePath=".\include\knkillprocess_win32.h"> </File> <Filter Name="knutil" Filter=""> <File RelativePath=".\include\knutil\atomicint.h"> </File> <File RelativePath=".\include\knutil\counter.h"> </File> <File RelativePath=".\include\knutil\kncircularmapping.h"> </File> <File RelativePath=".\include\knutil\knconsistenthash.h"> </File> <File RelativePath=".\include\knutil\kncrashhandler.h"> </File> <File RelativePath=".\include\knutil\kncrypt.h"> </File> <File RelativePath=".\include\knutil\knerror.h"> </File> <File RelativePath=".\include\knutil\knexportlibraryknutil.h"> </File> <File RelativePath=".\include\knutil\knhash.h"> </File> <File RelativePath=".\include\knutil\knlog.h"> </File> <File RelativePath=".\include\knutil\knmarkuputil.h"> </File> <File RelativePath=".\include\knutil\knmemory.h"> </File> <File RelativePath=".\include\knutil\knmutex.h"> </File> <File RelativePath=".\include\knutil\knnetwork.h"> </File> <File RelativePath=".\include\knutil\knnewdelete.h"> </File> <File RelativePath=".\include\knutil\knpattern.h"> </File> <File RelativePath=".\include\knutil\knperfstatistics.h"> </File> <File RelativePath=".\include\knutil\knregex.h"> </File> <File RelativePath=".\include\knutil\knrwlock.h"> </File> <File RelativePath=".\include\knutil\knrwlogginglock.h"> </File> <File RelativePath=".\include\knutil\knset.h"> </File> <File RelativePath=".\include\knutil\knsett.h"> </File> <File RelativePath=".\include\knutil\knsleep.h"> </File> <File RelativePath=".\include\knutil\knsmartref.h"> </File> <File RelativePath=".\include\knutil\knstring.h"> </File> <File RelativePath=".\include\knutil\knstringtokenizer.h"> </File> <File RelativePath=".\include\knutil\knsysutility.h"> </File> <File RelativePath=".\include\knutil\kntclerrors.h"> </File> <File RelativePath=".\include\knutil\kntclfile.h"> </File> <File RelativePath=".\include\knutil\kntclinterp.h"> </File> <File RelativePath=".\include\knutil\kntemplateuri.h"> </File> <File RelativePath=".\include\knutil\kntime.h"> </File> <File RelativePath=".\include\knutil\kntypes.h"> </File> <File RelativePath=".\include\knutil\knurl.h"> </File> <File RelativePath=".\include\knutil\mtrand.h"> </File> <File RelativePath=".\include\knutil\randomnumber.h"> </File> <File RelativePath=".\include\knutil\shahash.h"> </File> <File RelativePath=".\include\knutil\simplecache.h"> </File> <File RelativePath=".\include\knutil\simpleheap.h"> </File> <File RelativePath=".\include\knutil\simpleiterator.h"> </File> <File RelativePath=".\include\knutil\simplelist.h"> </File> <File RelativePath=".\include\knutil\simplemap.h"> </File> <File RelativePath=".\include\knutil\simplenull.h"> </File> <File RelativePath=".\include\knutil\simplequeue.h"> </File> <File RelativePath=".\include\knutil\simpleset.h"> </File> <File RelativePath=".\include\knutil\simplesynccache.h"> </File> <File RelativePath=".\include\knutil\simplesyncmap.h"> </File> <File RelativePath=".\include\knutil\simplesyncvector.h"> </File> <File RelativePath=".\include\knutil\simpletraits.h"> </File> <File RelativePath=".\include\knutil\simplevector.h"> </File> <File RelativePath=".\include\knutil\uuidgenerator.h"> </File> </Filter> </Filter> <Filter Name="Resource Files" Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"> </Filter> </Files> <Globals> </Globals> </VisualStudioProject> --- NEW FILE: knutil.vs8.vcproj --- <?xml version="1.0" encoding="Windows-1252"?> <VisualStudioProject ProjectType="Visual C++" Version="8,00" Name="knutil" ProjectGUID="{540797B1-E241-4EBB-9CC9-8C0070289A26}" RootNamespace="knutil" > <Platforms> <Platform Name="Win32" /> </Platforms> <ToolFiles> </ToolFiles> <Configurations> <Configuration Name="Release|Win32" OutputDirectory=".\Release" IntermediateDirectory=".\Release" ConfigurationType="2" InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" UseOfMFC="0" ATLMinimizesCRunTimeLibraryUsage="false" CharacterSet="2" > <Tool Name="VCPreBuildEventTool" /> <Tool Name="VCCustomBuildTool" /> <Tool Name="VCXMLDataGeneratorTool" /> <Tool Name="VCWebServiceProxyGeneratorTool" /> <Tool Name="VCMIDLTool" /> <Tool Name="VCCLCompilerTool" Optimization="1" InlineFunctionExpansion="1" AdditionalIncludeDirectories="include;..\include;..\..\..\Support\BugSlayer\include" PreprocessorDefinitions="NDEBUG;_WINDOWS;_USRDLL;WIN32;_USE_32BIT_TIME_T;FD_SETSIZE=2048;NO_CONST=1;KN_PRIVATE;CURL_STATICLIB" StringPooling="true" RuntimeLibrary="2" EnableFunctionLevelLinking="true" UsePrecompiledHeader="0" PrecompiledHeaderFile=".\Release\knutil.pch" AssemblerListingLocation=".\Release/" ObjectFile=".\Release/" ProgramDataBaseFileName=".\Release/" BrowseInformation="1" WarningLevel="4" SuppressStartupBanner="true" DebugInformationFormat="3" CompileAs="0" /> <Tool Name="VCManagedResourceCompilerTool" /> <Tool Name="VCResourceCompilerTool" PreprocessorDefinitions="NDEBUG" Culture="1033" /> <Tool Name="VCPreLinkEventTool" Description="Mutual Imports" CommandLine="lib /def /out:release\knutil.lib release\*.obj" /> <Tool Name="VCLinkerTool" AdditionalDependencies="knutil.exp nsd.lib nsthread.lib tcl84t.lib BugslayerUtil.lib rpcrt4.lib ws2_32.lib" OutputFile=".\Release/knutil.dll" LinkIncremental="1" SuppressStartupBanner="true" AdditionalLibraryDirectories="Release;..\lib;..\..\..\Support\BugSlayer\release" GenerateDebugInformation="true" ProgramDatabaseFile=".\Release\knutil.pdb" GenerateMapFile="true" MapFileName=".\Release\knutil.map" MapExports="true" LargeAddressAware="0" BaseAddress="@..\base_addresses.txt,$(ProjectName)" ImportLibrary=".\Release\knutil.lib" TargetMachine="1" /> <Tool Name="VCALinkTool" /> <Tool Name="VCManifestTool" /> <Tool Name="VCXDCMakeTool" /> <Tool Name="VCBscMakeTool" /> <Tool Name="VCFxCopTool" /> <Tool Name="VCAppVerifierTool" /> <Tool Name="VCWebDeploymentTool" /> <Tool Name="VCPostBuildEventTool" /> </Configuration> <Configuration Name="Debug|Win32" OutputDirectory="$(ConfigurationName)" IntermediateDirectory="$(ConfigurationName)" ConfigurationType="2" InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" UseOfMFC="0" ATLMinimizesCRunTimeLibraryUsage="false" CharacterSet="2" > <Tool Name="VCPreBuildEventTool" /> <Tool Name="VCCustomBuildTool" /> <Tool Name="VCXMLDataGeneratorTool" /> <Tool Name="VCWebServiceProxyGeneratorTool" /> <Tool Name="VCMIDLTool" /> <Tool Name="VCCLCompilerTool" Optimization="0" InlineFunctionExpansion="0" AdditionalIncludeDirectories="include;..\include;..\..\..\Support\BugSlayer\include" PreprocessorDefinitions="_DEBUG;_WINDOWS;_USRDLL;WIN32;_USE_32BIT_TIME_T;FD_SETSIZE=2048;NO_CONST=1;KN_PRIVATE;CURL_STATICLIB" StringPooling="true" BasicRuntimeChecks="3" RuntimeLibrary="3" BufferSecurityCheck="true" EnableFunctionLevelLinking="true" UsePrecompiledHeader="0" PrecompiledHeaderFile=".\Debug\knutil.pch" AssemblerListingLocation=".\Debug/" ObjectFile=".\Debug/" ProgramDataBaseFileName=".\Debug/" BrowseInformation="1" WarningLevel="4" SuppressStartupBanner="true" DebugInformationFormat="3" CompileAs="0" /> <Tool Name="VCManagedResourceCompilerTool" /> <Tool Name="VCResourceCompilerTool" PreprocessorDefinitions="NDEBUG" Culture="1033" /> <Tool Name="VCPreLinkEventTool" Description="Mutual Imports" CommandLine="lib /def /out:debug\knutil.lib debug\*.obj" /> <Tool Name="VCLinkerTool" AdditionalDependencies="knutil.exp nsd.lib nsthread.lib tcl84t.lib BugslayerUtil.lib rpcrt4.lib ws2_32.lib" OutputFile=".\Debug/knutil.dll" LinkIncremental="1" SuppressStartupBanner="true" AdditionalLibraryDirectories="Debug;..\lib;..\..\..\Support\BugSlayer\release" IgnoreAllDefaultLibraries="false" GenerateDebugInformation="true" ProgramDatabaseFile=".\Debug\knutil.pdb" GenerateMapFile="true" MapFileName=".\Debug\knutil.map" MapExports="true" LargeAddressAware="0" BaseAddress="@..\base_addresses.txt,$(ProjectName)" ImportLibrary=".\Debug\knutil.lib" TargetMachine="1" /> <Tool Name="VCALinkTool" /> <Tool Name="VCManifestTool" /> <Tool Name="VCXDCMakeTool" /> <Tool Name="VCBscMakeTool" /> <Tool Name="VCFxCopTool" /> <Tool Name="VCAppVerifierTool" /> <Tool Name="VCWebDeploymentTool" /> <Tool Name="VCPostBuildEventTool" /> </Configuration> </Configurations> <References> </References> <Files> <Filter Name="Source Files" Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" > <File RelativePath=".\src\atomicint.cpp" > </File> <File RelativePath=".\src\counter.cpp" > </File> <File RelativePath=".\src\kncircularmapping.cpp" > </File> <File RelativePath=".\src\knconsistenthash.cpp" > </File> <File RelativePath=".\src\kncrashhandler.cpp" > </File> <File RelativePath=".\src\kncrypt.cpp" > </File> <File RelativePath=".\src\knerror.cpp" > </File> <File RelativePath=".\src\knhash.cpp" > </File> <File RelativePath=".\src\knlog.cpp" > </File> <File RelativePath=".\src\knmarkuputil.cpp" > </File> <File RelativePath=".\src\knmemory.cpp" > </File> <File RelativePath=".\src\knmutex.cpp" > </File> <File RelativePath=".\src\knnetwork.cpp" > </File> <File RelativePath=".\src\knnewdelete.cpp" > </File> <File RelativePath=".\src\knpattern.cpp" > </File> <File RelativePath=".\src\knperfstatistics.cpp" > </File> <File RelativePath=".\src\knregex.cpp" > </File> <File RelativePath=".\src\knrwlock.cpp" > </File> <File RelativePath=".\src\knrwlogginglock.cpp" > </File> <File RelativePath=".\src\knset.cpp" > </File> <File RelativePath=".\src\knsleep.cpp" > </File> <File RelativePath=".\src\knstring.cpp" > </File> <File RelativePath=".\src\knstringtokenizer.cpp" > </File> <File RelativePath=".\src\knsysutility_win32.cpp" > </File> <File RelativePath=".\src\kntclerrors.cpp" > </File> <File RelativePath=".\src\kntclfile.cpp" > </File> <File RelativePath=".\src\kntclinterp.cpp" > </File> <File RelativePath=".\src\kntemplateuri.cpp" > </File> <File RelativePath=".\src\kntime.cpp" > </File> <File RelativePath=".\src\knurl.cpp" > </File> <File RelativePath=".\src\mtrand.cpp" > </File> <File RelativePath=".\src\randomnumber.cpp" > </File> <File RelativePath=".\src\shahash.cpp" > </File> <File RelativePath=".\src\uuidgenerator.cpp" > </File> </Filter> <Filter Name="Header Files" Filter="h;hpp;hxx;hm;inl" > <File RelativePath=".\include\knexportlibraryknutilmodule.h" > </File> <File RelativePath=".\include\knkillprocess_win32.h" > </File> <Filter Name="knutil" > <File RelativePath=".\include\knutil\atomicint.h" > </File> <File RelativePath=".\include\knutil\counter.h" > </File> <File RelativePath=".\include\knutil\kncircularmapping.h" > </File> <File RelativePath=".\include\knutil\knconsistenthash.h" > </File> <File RelativePath=".\include\knutil\kncrashhandler.h" > </File> <File RelativePath=".\include\knutil\kncrypt.h" > </File> <File RelativePath=".\include\knutil\knerror.h" > </File> <File RelativePath=".\include\knutil\knexportlibraryknutil.h" > </File> <File RelativePath=".\include\knutil\knhash.h" > </File> <File RelativePath=".\include\knutil\knlog.h" > </File> <File RelativePath=".\include\knutil\knmarkuputil.h" > </File> <File RelativePath=".\include\knutil\knmemory.h" > </File> <File RelativePath=".\include\knutil\knmutex.h" > </File> <File RelativePath=".\include\knutil\knnetwork.h" > </File> <File RelativePath=".\include\knutil\knnewdelete.h" > </File> <File RelativePath=".\include\knutil\knpattern.h" > </File> <File RelativePath=".\include\knutil\knperfstatistics.h" > </File> <File RelativePath=".\include\knutil\knregex.h" > </File> <File RelativePath=".\include\knutil\knrwlock.h" > </File> <File RelativePath=".\include\knutil\knrwlogginglock.h" > </File> <File RelativePath=".\include\knutil\knset.h" > </File> <File RelativePath=".\include\knutil\knsett.h" > </File> <File RelativePath=".\include\knutil\knsleep.h" > </File> <File RelativePath=".\include\knutil\knsmartref.h" > </File> <File RelativePath=".\include\knutil\knstring.h" > </File> <File RelativePath=".\include\knutil\knstringtokenizer.h" > </File> <File RelativePath=".\include\knutil\knstrops.h" > </File> <File RelativePath=".\include\knutil\knsysutility.h" > </File> <File RelativePath=".\include\knutil\kntclargs.h" > </File> <File RelativePath=".\include\knutil\kntclerrors.h" > </File> <File RelativePath=".\include\knutil\kntclfile.h" > </File> <File RelativePath=".\include\knutil\kntclinterp.h" > </File> <File RelativePath=".\include\knutil\kntemplateuri.h" > </File> <File RelativePath=".\include\knutil\kntime.h" > </File> <File RelativePath=".\include\knutil\kntypes.h" > </File> <File RelativePath=".\include\knutil\knurl.h" > </File> <File RelativePath=".\include\knutil\mtrand.h" > </File> <File RelativePath=".\include\knutil\randomnumber.h" > </File> <File RelativePath=".\include\knutil\shahash.h" > </File> <File RelativePath=".\include\knutil\simplecache.h" > </File> <File RelativePath=".\include\knutil\simpleheap.h" > </File> <File RelativePath=".\include\knutil\simpleiterator.h" > </File> <File RelativePath=".\include\knutil\simplelist.h" > </File> <File RelativePath=".\include\knutil\simplemap.h" > </File> <File RelativePath=".\include\knutil\simplenull.h" > </File> <File RelativePath=".\include\knutil\simplequeue.h" > </File> <File RelativePath=".\include\knutil\simpleset.h" > </File> <File RelativePath=".\include\knutil\simplesynccache.h" > </File> <File RelativePath=".\include\knutil\simplesyncmap.h" > </File> <File RelativePath=".\include\knutil\simplesyncvector.h" > </File> <File RelativePath=".\include\knutil\simpletraits.h" > </File> <File RelativePath=".\include\knutil\simplevector.h" > </File> <File RelativePath=".\include\knutil\uuidgenerator.h" > </File> </Filter> </Filter> <Filter Name="Resource Files" Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" > </Filter> </Files> <Globals> </Globals> </VisualStudioProject> |
|
From: <co...@us...> - 2008-05-16 00:16:13
|
Update of /cvsroot/aolserver/knutil/include/knutil In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv2987/knutil Log Message: Directory /cvsroot/aolserver/knutil/include/knutil added to the repository |
|
From: <co...@us...> - 2008-05-16 00:16:09
|
Update of /cvsroot/aolserver/knutil/include In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv2790/include Log Message: Directory /cvsroot/aolserver/knutil/include added to the repository |
|
From: <co...@us...> - 2008-05-16 00:16:09
|
Update of /cvsroot/aolserver/knutil/src In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv2790/src Log Message: Directory /cvsroot/aolserver/knutil/src added to the repository |