From f2637dea1ef8646bac64f2041c6da223f75dfc75 Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Mon, 1 Dec 2008 19:27:02 +0000 Subject: Add support for building on VC 2005, and remove support for old MSVC. --- ckcapi.c | 17 ++- ckcapi.dsw | 41 ------ ckcapi.mak | 247 ------------------------------------ ckcapi.sln | 20 +++ ckcapi.vcproj | 400 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 433 insertions(+), 292 deletions(-) delete mode 100644 ckcapi.dsw delete mode 100644 ckcapi.mak create mode 100644 ckcapi.sln create mode 100644 ckcapi.vcproj diff --git a/ckcapi.c b/ckcapi.c index 1a398b3..d56d910 100644 --- a/ckcapi.c +++ b/ckcapi.c @@ -23,6 +23,9 @@ #include "ckcapi.h" +/* Warns about all the raw string usage in this file */ +#pragma warning (disable : 4996) + /* ------------------------------------------------------------------- * GLOBALS / DEFINES */ @@ -47,18 +50,24 @@ static HANDLE global_mutex = NULL; * MODULE GLOBAL FUNCTIONS */ +#define LINE 1024 + void ckcapi_debug(const char* msg, ...) { - char buf[1024]; + char buf[LINE]; va_list va; + size_t len; va_start(va, msg); _vsnprintf(buf, 1024, msg, va); va_end(va); - strncat(buf, "\n", 1024); - buf[1024 - 1] = 0; + buf[LINE - 1] = 0; + len = strlen (buf); + + strncpy(buf + len, "\n", 1024 - len); + buf[LINE - 1] = 0; OutputDebugStringA(buf); } @@ -262,7 +271,7 @@ CC_C_GetSlotList(CK_BBOOL tokenPresent, CK_SLOT_ID_PTR slot_list, CK_ULONG_PTR c *count = n_tokens; for(i = 0; i < n_tokens; ++i) - slot_list[i] = i; + slot_list[i] = ckcapi_token_get_slot_id (i); RETURN(CKR_OK); } diff --git a/ckcapi.dsw b/ckcapi.dsw deleted file mode 100644 index a6cb239..0000000 --- a/ckcapi.dsw +++ /dev/null @@ -1,41 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "cryptoki_capi"=".\ckcapi.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "sandbox"=".\sandbox\sandbox.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/ckcapi.mak b/ckcapi.mak deleted file mode 100644 index c55eefc..0000000 --- a/ckcapi.mak +++ /dev/null @@ -1,247 +0,0 @@ -# Microsoft Developer Studio Generated NMAKE File, Based on ckcapi.dsp -!IF "$(CFG)" == "" -CFG=cryptoki_capi - Win32 Debug -!MESSAGE No configuration specified. Defaulting to cryptoki_capi - Win32 Debug. -!ENDIF - -!IF "$(CFG)" != "cryptoki_capi - Win32 Release" && "$(CFG)" != "cryptoki_capi - Win32 Debug" -!MESSAGE Invalid configuration "$(CFG)" specified. -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "ckcapi.mak" CFG="cryptoki_capi - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "cryptoki_capi - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "cryptoki_capi - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE -!ERROR An invalid configuration is specified. -!ENDIF - -!IF "$(OS)" == "Windows_NT" -NULL= -!ELSE -NULL=nul -!ENDIF - -!IF "$(CFG)" == "cryptoki_capi - Win32 Release" - -OUTDIR=.\Release -INTDIR=.\Release -# Begin Custom Macros -OutDir=.\Release -# End Custom Macros - -ALL : "$(OUTDIR)\ckcapi.dll" - - -CLEAN : - -@erase "$(INTDIR)\ckcapi-builtin.obj" - -@erase "$(INTDIR)\ckcapi-cert.obj" - -@erase "$(INTDIR)\ckcapi-object.obj" - -@erase "$(INTDIR)\ckcapi-session.obj" - -@erase "$(INTDIR)\ckcapi-trust.obj" - -@erase "$(INTDIR)\ckcapi-util.obj" - -@erase "$(INTDIR)\ckcapi.obj" - -@erase "$(INTDIR)\vc60.idb" - -@erase "$(OUTDIR)\ckcapi.dll" - -@erase "$(OUTDIR)\ckcapi.exp" - -@erase "$(OUTDIR)\ckcapi.lib" - -"$(OUTDIR)" : - if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" - -CPP=cl.exe -CPP_PROJ=/nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CRYPTOKI_CAPI_EXPORTS" /Fp"$(INTDIR)\ckcapi.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c - -.c{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.c{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -MTL=midl.exe -MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32 -RSC=rc.exe -BSC32=bscmake.exe -BSC32_FLAGS=/nologo /o"$(OUTDIR)\ckcapi.bsc" -BSC32_SBRS= \ - -LINK32=link.exe -LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib crypt32.lib /nologo /dll /incremental:no /pdb:"$(OUTDIR)\ckcapi.pdb" /machine:I386 /out:"$(OUTDIR)\ckcapi.dll" /implib:"$(OUTDIR)\ckcapi.lib" -LINK32_OBJS= \ - "$(INTDIR)\ckcapi-builtin.obj" \ - "$(INTDIR)\ckcapi-cert.obj" \ - "$(INTDIR)\ckcapi-object.obj" \ - "$(INTDIR)\ckcapi-session.obj" \ - "$(INTDIR)\ckcapi-trust.obj" \ - "$(INTDIR)\ckcapi-util.obj" \ - "$(INTDIR)\ckcapi.obj" - -"$(OUTDIR)\ckcapi.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) - $(LINK32) @<< - $(LINK32_FLAGS) $(LINK32_OBJS) -<< - -!ELSEIF "$(CFG)" == "cryptoki_capi - Win32 Debug" - -OUTDIR=.\Debug -INTDIR=.\Debug -# Begin Custom Macros -OutDir=.\Debug -# End Custom Macros - -ALL : "$(OUTDIR)\ckcapi.dll" - - -CLEAN : - -@erase "$(INTDIR)\ckcapi-builtin.obj" - -@erase "$(INTDIR)\ckcapi-cert.obj" - -@erase "$(INTDIR)\ckcapi-object.obj" - -@erase "$(INTDIR)\ckcapi-session.obj" - -@erase "$(INTDIR)\ckcapi-trust.obj" - -@erase "$(INTDIR)\ckcapi-util.obj" - -@erase "$(INTDIR)\ckcapi.obj" - -@erase "$(INTDIR)\vc60.idb" - -@erase "$(INTDIR)\vc60.pdb" - -@erase "$(OUTDIR)\ckcapi.dll" - -@erase "$(OUTDIR)\ckcapi.exp" - -@erase "$(OUTDIR)\ckcapi.ilk" - -@erase "$(OUTDIR)\ckcapi.lib" - -@erase "$(OUTDIR)\ckcapi.pdb" - -"$(OUTDIR)" : - if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" - -CPP=cl.exe -CPP_PROJ=/nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CRYPTOKI_CAPI_EXPORTS" /Fp"$(INTDIR)\ckcapi.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /GZ /c - -.c{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.c{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -MTL=midl.exe -MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32 -RSC=rc.exe -BSC32=bscmake.exe -BSC32_FLAGS=/nologo /o"$(OUTDIR)\ckcapi.bsc" -BSC32_SBRS= \ - -LINK32=link.exe -LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib crypt32.lib /nologo /dll /incremental:yes /pdb:"$(OUTDIR)\ckcapi.pdb" /debug /machine:I386 /out:"$(OUTDIR)\ckcapi.dll" /implib:"$(OUTDIR)\ckcapi.lib" /pdbtype:sept -LINK32_OBJS= \ - "$(INTDIR)\ckcapi-builtin.obj" \ - "$(INTDIR)\ckcapi-cert.obj" \ - "$(INTDIR)\ckcapi-object.obj" \ - "$(INTDIR)\ckcapi-session.obj" \ - "$(INTDIR)\ckcapi-trust.obj" \ - "$(INTDIR)\ckcapi-util.obj" \ - "$(INTDIR)\ckcapi.obj" - -"$(OUTDIR)\ckcapi.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) - $(LINK32) @<< - $(LINK32_FLAGS) $(LINK32_OBJS) -<< - -!ENDIF - - -!IF "$(NO_EXTERNAL_DEPS)" != "1" -!IF EXISTS("ckcapi.dep") -!INCLUDE "ckcapi.dep" -!ELSE -!MESSAGE Warning: cannot find "ckcapi.dep" -!ENDIF -!ENDIF - - -!IF "$(CFG)" == "cryptoki_capi - Win32 Release" || "$(CFG)" == "cryptoki_capi - Win32 Debug" -SOURCE=".\ckcapi-builtin.c" - -"$(INTDIR)\ckcapi-builtin.obj" : $(SOURCE) "$(INTDIR)" - - -SOURCE=".\ckcapi-cert.c" - -"$(INTDIR)\ckcapi-cert.obj" : $(SOURCE) "$(INTDIR)" - - -SOURCE=".\ckcapi-object.c" - -"$(INTDIR)\ckcapi-object.obj" : $(SOURCE) "$(INTDIR)" - - -SOURCE=".\ckcapi-session.c" - -"$(INTDIR)\ckcapi-session.obj" : $(SOURCE) "$(INTDIR)" - - -SOURCE=".\ckcapi-trust.c" - -"$(INTDIR)\ckcapi-trust.obj" : $(SOURCE) "$(INTDIR)" - - -SOURCE=".\ckcapi-util.c" - -"$(INTDIR)\ckcapi-util.obj" : $(SOURCE) "$(INTDIR)" - - -SOURCE=.\ckcapi.c - -"$(INTDIR)\ckcapi.obj" : $(SOURCE) "$(INTDIR)" - - - -!ENDIF - diff --git a/ckcapi.sln b/ckcapi.sln new file mode 100644 index 0000000..e4469b0 --- /dev/null +++ b/ckcapi.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual C++ Express 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cryptoki_capi", "ckcapi.vcproj", "{5FC3E27C-F74F-41ED-8BE9-8A586AFC059A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {5FC3E27C-F74F-41ED-8BE9-8A586AFC059A}.Debug|Win32.ActiveCfg = Debug|Win32 + {5FC3E27C-F74F-41ED-8BE9-8A586AFC059A}.Debug|Win32.Build.0 = Debug|Win32 + {5FC3E27C-F74F-41ED-8BE9-8A586AFC059A}.Release|Win32.ActiveCfg = Release|Win32 + {5FC3E27C-F74F-41ED-8BE9-8A586AFC059A}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/ckcapi.vcproj b/ckcapi.vcproj new file mode 100644 index 0000000..0dd6a40 --- /dev/null +++ b/ckcapi.vcproj @@ -0,0 +1,400 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3