libwinpr-crt: initial commit

This commit is contained in:
Marc-André Moreau 2012-05-05 22:09:08 -04:00
parent 14e50895d9
commit 813cf27ccd
8 changed files with 226 additions and 0 deletions

View File

@ -160,6 +160,7 @@ add_subdirectory(libfreerdp-channels)
add_subdirectory(libfreerdp-locale)
add_subdirectory(libfreerdp-core)
add_subdirectory(libwinpr-crt)
add_subdirectory(libwinpr-rpc)
add_subdirectory(libwinpr-sspi)

30
include/winpr/crt.h Normal file
View File

@ -0,0 +1,30 @@
/**
* WinPR: Windows Portable Runtime
* C Run-Time Library Routines
*
* Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
*
* 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.
*/
#ifndef WINPR_CRT_H
#define WINPR_CRT_H
#include <stdio.h>
#include <stdlib.h>
#include <winpr/winpr.h>
#include <winpr/string.h>
#endif /* WINPR_CRT_H */

42
include/winpr/memory.h Normal file
View File

@ -0,0 +1,42 @@
/**
* WinPR: Windows Portable Runtime
* Memory Allocation
*
* Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
*
* 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.
*/
#ifndef WINPR_CRT_MEMORY_H
#define WINPR_CRT_MEMORY_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <winpr/winpr.h>
#ifndef _WIN32
#define CopyMemory RtlCopyMemory
#define MoveMemory RtlMoveMemory
#define FillMemory RtlFillMemory
#define ZeroMemory RtlZeroMemory
#define RtlCopyMemory(Destination, Source, Length) memcpy((Destination), (Source), (Length))
#define RtlMoveMemory(Destination, Source, Length) memmove((Destination), (Source), (Length))
#define RtlFillMemory(Destination, Length, Fill) memset((Destination), (Fill), (Length))
#define RtlZeroMemory(Destination, Length) memset((Destination), 0, (Length))
#endif
#endif /* WINPR_CRT_MEMORY_H */

34
include/winpr/string.h Normal file
View File

@ -0,0 +1,34 @@
/**
* WinPR: Windows Portable Runtime
* String Manipulation (CRT)
*
* Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
*
* 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.
*/
#ifndef WINPR_CRT_STRING_H
#define WINPR_CRT_STRING_H
#include <wchar.h>
#include <string.h>
#include <winpr/winpr.h>
#ifndef _WIN32
char* _strdup(const char* strSource);
wchar_t* _wcsdup(const wchar_t *strSource);
#endif
#endif /* WINPR_CRT_STRING_H */

View File

@ -0,0 +1,29 @@
# WinPR: Windows Portable Runtime
# libwinpr-crt cmake build script
#
# Copyright 2011 O.S. Systems Software Ltda.
# Copyright 2011 Otavio Salvador <otavio@ossystems.com.br>
# Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
#
# 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.
set(WINPR_CRT_SRCS
memory.c
string.c)
add_library(winpr-crt ${WINPR_CRT_SRCS})
set_target_properties(winpr-crt PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib")
install(TARGETS winpr-crt DESTINATION ${CMAKE_INSTALL_LIBDIR})

29
libwinpr-crt/memory.c Normal file
View File

@ -0,0 +1,29 @@
/**
* WinPR: Windows Portable Runtime
* Memory Allocation
*
* Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
*
* 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 <winpr/crt.h>
/* Memory Allocation: http://msdn.microsoft.com/en-us/library/hk1k7x6x.aspx */
/* Memory Management Functions: http://msdn.microsoft.com/en-us/library/windows/desktop/aa366781/ */
#ifndef _WIN32
#endif

60
libwinpr-crt/string.c Normal file
View File

@ -0,0 +1,60 @@
/**
* WinPR: Windows Portable Runtime
* String Manipulation (CRT)
*
* Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
*
* 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 <winpr/crt.h>
/* String Manipulation (CRT): http://msdn.microsoft.com/en-us/library/f0151s4x.aspx */
#ifndef _WIN32
char* _strdup(const char* strSource)
{
char* strDestination;
if (strSource == NULL)
return NULL;
strDestination = strdup(strSource);
if (strDestination == NULL)
perror("strdup");
return strDestination;
}
wchar_t* _wcsdup(const wchar_t* strSource)
{
wchar_t* strDestination;
if (strSource == NULL)
return NULL;
#if sun
strDestination = wsdup(strSource);
#else
strDestination = wcsdup(strSource);
#endif
if (strDestination == NULL)
perror("wcsdup");
return strDestination;
}
#endif

View File

@ -64,6 +64,7 @@ include_directories(${ZLIB_INCLUDE_DIRS})
set_target_properties(winpr-sspi PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib")
target_link_libraries(winpr-sspi winpr-crt)
target_link_libraries(winpr-sspi freerdp-utils)
target_link_libraries(winpr-sspi freerdp-crypto)
target_link_libraries(winpr-sspi ${ZLIB_LIBRARIES})