diff --git a/CMakeLists.txt b/CMakeLists.txt index aae3e6268..e24e982f0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/include/winpr/crt.h b/include/winpr/crt.h new file mode 100644 index 000000000..498d3574a --- /dev/null +++ b/include/winpr/crt.h @@ -0,0 +1,30 @@ +/** + * WinPR: Windows Portable Runtime + * C Run-Time Library Routines + * + * Copyright 2012 Marc-Andre Moreau + * + * 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 +#include + +#include + +#include + +#endif /* WINPR_CRT_H */ diff --git a/include/winpr/memory.h b/include/winpr/memory.h new file mode 100644 index 000000000..3a9ca0678 --- /dev/null +++ b/include/winpr/memory.h @@ -0,0 +1,42 @@ +/** + * WinPR: Windows Portable Runtime + * Memory Allocation + * + * Copyright 2012 Marc-Andre Moreau + * + * 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 +#include +#include +#include + +#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 */ diff --git a/include/winpr/string.h b/include/winpr/string.h new file mode 100644 index 000000000..0ac2052de --- /dev/null +++ b/include/winpr/string.h @@ -0,0 +1,34 @@ +/** + * WinPR: Windows Portable Runtime + * String Manipulation (CRT) + * + * Copyright 2012 Marc-Andre Moreau + * + * 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 +#include +#include + +#ifndef _WIN32 + +char* _strdup(const char* strSource); +wchar_t* _wcsdup(const wchar_t *strSource); + +#endif + +#endif /* WINPR_CRT_STRING_H */ diff --git a/libwinpr-crt/CMakeLists.txt b/libwinpr-crt/CMakeLists.txt new file mode 100644 index 000000000..a4a35ac37 --- /dev/null +++ b/libwinpr-crt/CMakeLists.txt @@ -0,0 +1,29 @@ +# WinPR: Windows Portable Runtime +# libwinpr-crt cmake build script +# +# Copyright 2011 O.S. Systems Software Ltda. +# Copyright 2011 Otavio Salvador +# Copyright 2011 Marc-Andre Moreau +# +# 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}) + diff --git a/libwinpr-crt/memory.c b/libwinpr-crt/memory.c new file mode 100644 index 000000000..0f9b16f39 --- /dev/null +++ b/libwinpr-crt/memory.c @@ -0,0 +1,29 @@ +/** + * WinPR: Windows Portable Runtime + * Memory Allocation + * + * Copyright 2012 Marc-Andre Moreau + * + * 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 + +/* 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 diff --git a/libwinpr-crt/string.c b/libwinpr-crt/string.c new file mode 100644 index 000000000..cafb7d513 --- /dev/null +++ b/libwinpr-crt/string.c @@ -0,0 +1,60 @@ +/** + * WinPR: Windows Portable Runtime + * String Manipulation (CRT) + * + * Copyright 2012 Marc-Andre Moreau + * + * 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 + +/* 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 diff --git a/libwinpr-sspi/CMakeLists.txt b/libwinpr-sspi/CMakeLists.txt index 08f8c39c2..cdf527d71 100644 --- a/libwinpr-sspi/CMakeLists.txt +++ b/libwinpr-sspi/CMakeLists.txt @@ -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})