diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/CEH/commands_types.h | 2 | ||||
-rw-r--r-- | source/LCDriver.h | 4 | ||||
-rw-r--r-- | source/LCDriver.rc | 115 | ||||
-rw-r--r-- | source/LCDriver.vcproj | 16 | ||||
-rw-r--r-- | source/api_wrappers/linux/LinuxApiWrappers.h | 1 | ||||
-rw-r--r-- | source/api_wrappers/linux/OS.cpp | 30 | ||||
-rw-r--r-- | source/api_wrappers/linux/OS.h | 73 | ||||
-rw-r--r-- | source/api_wrappers/windows/WinApiWrappers.h | 19 | ||||
-rwxr-xr-x | source/gen_rc.sh | 168 | ||||
-rw-r--r-- | source/security_algorithms/sha/sha2.cpp | 1 | ||||
-rw-r--r-- | source/utilities/Logger.h | 2 | ||||
-rw-r--r-- | source/utilities/String_s.cpp | 34 | ||||
-rw-r--r-- | source/utilities/String_s.h | 80 |
13 files changed, 300 insertions, 245 deletions
diff --git a/source/CEH/commands_types.h b/source/CEH/commands_types.h index eec039c..7231edf 100644 --- a/source/CEH/commands_types.h +++ b/source/CEH/commands_types.h @@ -62,4 +62,4 @@ struct TEntriesInternal { } }; -#endif // _COMMANDS_TYPES_H_
\ No newline at end of file +#endif // _COMMANDS_TYPES_H_ diff --git a/source/LCDriver.h b/source/LCDriver.h index 0456570..314a8fd 100644 --- a/source/LCDriver.h +++ b/source/LCDriver.h @@ -11,6 +11,10 @@ #define LCDRIVER_API __declspec(dllexport) #else #define LCDRIVER_API __declspec(dllimport) +#endif //LCDRIVER_EXPORTS + +#ifndef __int64 +#define __int64 long long #endif typedef unsigned __int64 uint64; diff --git a/source/LCDriver.rc b/source/LCDriver.rc deleted file mode 100644 index 0b30f01..0000000 --- a/source/LCDriver.rc +++ /dev/null @@ -1,115 +0,0 @@ -// Microsoft Visual C++ generated resource script.
-//
-#include "resource.h"
-
-#define APSTUDIO_READONLY_SYMBOLS
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 2 resource.
-//
-#include "windows.h"
-
-/////////////////////////////////////////////////////////////////////////////
-#undef APSTUDIO_READONLY_SYMBOLS
-
-/////////////////////////////////////////////////////////////////////////////
-// English (U.S.) resources
-
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
-#ifdef _WIN32
-LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
-#pragma code_page(1252)
-#endif //_WIN32
-
-#ifdef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// TEXTINCLUDE
-//
-
-1 TEXTINCLUDE
-BEGIN
- "resource.h\0"
-END
-
-2 TEXTINCLUDE
-BEGIN
- "#include ""windows.h""\r\n"
- "\0"
-END
-
-3 TEXTINCLUDE
-BEGIN
- "\r\n"
- "\0"
-END
-
-#endif // APSTUDIO_INVOKED
-
-#endif // English (U.S.) resources
-/////////////////////////////////////////////////////////////////////////////
-
-
-/////////////////////////////////////////////////////////////////////////////
-// English (U.K.) resources
-
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG)
-#ifdef _WIN32
-LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
-#pragma code_page(1252)
-#endif //_WIN32
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Version
-//
-
-VS_VERSION_INFO VERSIONINFO
- FILEVERSION 1,0,0,1
- PRODUCTVERSION 1,0,0,1
- FILEFLAGSMASK 0x1fL
-#ifdef _DEBUG
- FILEFLAGS 0x9L
-#else
- FILEFLAGS 0x8L
-#endif
- FILEOS 0x4L
- FILETYPE 0x2L
- FILESUBTYPE 0x0L
-BEGIN
- BLOCK "StringFileInfo"
- BEGIN
- BLOCK "000904b0"
- BEGIN
- VALUE "Comments", "Build date: 2012-03-14" - VALUE "CompanyName", "STEricsson AB"
- VALUE "FileDescription", "LCDriver Dynamic Link Library"
- VALUE "FileVersion", "1, 0, 0, 1"
- VALUE "InternalName", "Loader Communication Driver"
- VALUE "LegalCopyright", "Copyright (C) STEricsson AB 2012"
- VALUE "PrivateBuild", "Change-Id: I2f2835b56857eb9640501ff681400517600ccdef" - VALUE "ProductName", "CXC 173 0865, LCDriver DLL"
- VALUE "ProductVersion", "P5Y" - END
- END
- BLOCK "VarFileInfo"
- BEGIN
- VALUE "Translation", 0x9, 1200
- END
-END
-
-#endif // English (U.K.) resources
-/////////////////////////////////////////////////////////////////////////////
-
-
-
-#ifndef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 3 resource.
-//
-
-
-/////////////////////////////////////////////////////////////////////////////
-#endif // not APSTUDIO_INVOKED
-
diff --git a/source/LCDriver.vcproj b/source/LCDriver.vcproj index 21feb76..703954c 100644 --- a/source/LCDriver.vcproj +++ b/source/LCDriver.vcproj @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
- Version="8.00"
+ Version="8,00"
Name="LCDriver"
ProjectGUID="{E195BE97-0727-419C-931E-08C8B99AB884}"
RootNamespace="LCDriver"
@@ -224,7 +224,6 @@ />
<Tool
Name="VCPreLinkEventTool"
- Description=""
CommandLine=""
/>
<Tool
@@ -265,8 +264,8 @@ />
<Tool
Name="VCPostBuildEventTool"
- Description="Copying $(TargetPath) to $(TargetDir)..\win_binaries"
- CommandLine="copy /B /Y $(TargetPath) $(TargetDir)..\win_binaries"
+ Description=""
+ CommandLine=""
/>
</Configuration>
<Configuration
@@ -310,7 +309,6 @@ />
<Tool
Name="VCPreLinkEventTool"
- Description=""
CommandLine=""
/>
<Tool
@@ -351,8 +349,8 @@ />
<Tool
Name="VCPostBuildEventTool"
- Description="Copying $(TargetPath) to $(TargetDir)..\win_binaries"
- CommandLine="copy /B /Y $(TargetPath) $(TargetDir)..\win_binaries"
+ Description=""
+ CommandLine=""
/>
</Configuration>
<Configuration
@@ -1512,10 +1510,6 @@ >
</File>
</Filter>
- <File
- RelativePath=".\LCDriver.rc"
- >
- </File>
</Files>
<Globals>
</Globals>
diff --git a/source/api_wrappers/linux/LinuxApiWrappers.h b/source/api_wrappers/linux/LinuxApiWrappers.h index b63b840..b89e42f 100644 --- a/source/api_wrappers/linux/LinuxApiWrappers.h +++ b/source/api_wrappers/linux/LinuxApiWrappers.h @@ -15,6 +15,7 @@ #include "CWaitableObject.h" #include "CWaitableObjectCollection.h" #include "OS.h" +#include "String_s.h" #endif /* _LINUXAPIWRAPPERS_H */ diff --git a/source/api_wrappers/linux/OS.cpp b/source/api_wrappers/linux/OS.cpp index 6ed6425..aaaa592 100644 --- a/source/api_wrappers/linux/OS.cpp +++ b/source/api_wrappers/linux/OS.cpp @@ -2,7 +2,6 @@ * Copyright (C) ST-Ericsson SA 2011 * License terms: 3-clause BSD license ******************************************************************************/ - #include <time.h> #include <errno.h> #include <sys/time.h> @@ -59,32 +58,3 @@ timespec OS::GetAbsoluteTime(DWORD dwTimeout) return absolute_time; } - - -char *strcpy_s(char *dst, size_t _Size, const char *src) -{ - return strncpy(dst, src, _Size); -} - -int sprintf_s(char *dst, size_t _Size, const char *format, ...) -{ - va_list l; - int ReturnValue; - - va_start(l, format); - ReturnValue = vsnprintf(dst, _Size, format, l); - va_end(l); - - return ReturnValue; -} - -char *strncpy_s(char *dst, const char *src, size_t _Size) -{ - return strncpy(dst, src, _Size); -} - -int _stricmp(const char *s1, const char *s2) -{ - return strcasecmp(s1, s2); -} - diff --git a/source/api_wrappers/linux/OS.h b/source/api_wrappers/linux/OS.h index b79c6ea..ad1e7af 100644 --- a/source/api_wrappers/linux/OS.h +++ b/source/api_wrappers/linux/OS.h @@ -7,9 +7,6 @@ #define _OS_H #include <sys/time.h> #include <stdio.h> -#include <stdarg.h> -#include <string.h> -#include <strings.h> #include <stdlib.h> #include "Types.h" @@ -36,74 +33,4 @@ private: static DWORD ErrorCode; }; - -#define MAX(a, b) ((a) > (b) ? (a) : (b)) - -/* - * str manipulation functions used in windows build - */ - -char *strcpy_s(char *dst, size_t _Size, const char *src); -char *strncpy_s(char *dst, const char *src, size_t _Size); -int _stricmp(const char *s1, const char *s2); -int sprintf_s(char *dst, size_t _Size, const char *format, ...); - -#define _snprintf snprintf - -template <size_t _Size> -char *strcpy_s(char(&dst)[_Size], const char src[]) -{ - return strncpy(dst, src, _Size); -} - -template<size_t _Size> -int sprintf_s(char(&dst)[_Size], const char *format, ...) -{ - int ReturnValue; - va_list l; - va_start(l, format); - ReturnValue = vsnprintf(dst, _Size, format, l); - va_end(l); - return ReturnValue; -} - -template <size_t _Size> -char *strcat_s(char(&dst)[_Size], const char src[]) -{ - return strncat(dst, src, _Size); -} - -template <size_t _Size> -int _ultoa_s(unsigned long value, char(&str)[_Size], int radix) -{ - switch (radix) { - case 10: - return sprintf_s(str, "%ul", value); - - case 16: - return sprintf_s(str, "%ulX", value); - - default: - return -1; - } -} - -template<size_t _Size> -int _snprintf_s(char(&dst)[_Size], size_t _MaxCount, const char *format, ...) -{ - int ReturnValue; - va_list l; - va_start(l, format); - ReturnValue = vsnprintf(dst, MAX(_MaxCount, _Size), format, l); - va_end(l); - return ReturnValue; -} - -template<size_t _Size> -int vsprintf_s(char(&dst)[_Size], const char *format, va_list l) -{ - return vsnprintf(dst, _Size, format, l); -} - #endif /* _OS_H */ - diff --git a/source/api_wrappers/windows/WinApiWrappers.h b/source/api_wrappers/windows/WinApiWrappers.h index f3fbfa1..2d5a7ed 100644 --- a/source/api_wrappers/windows/WinApiWrappers.h +++ b/source/api_wrappers/windows/WinApiWrappers.h @@ -22,6 +22,11 @@ #include <process.h> #include <assert.h> #include <vector> +#ifdef __MINGW32__ +#include "String_s.h" +#include <stdlib.h> +#endif + using namespace std; class CWaitableObject @@ -95,20 +100,6 @@ public: DWORD Wait(DWORD milliseconds = INFINITE) { return ::WaitForSingleObject(m_Handle, milliseconds); } - void WaitForAllEvents(HANDLE *pHandles, int iHandles, DWORD msec = INFINITE) { - ::WaitForMultipleObjects( - iHandles, // Number of objects in handles - pHandles, - TRUE, // Wait all events - msec); - } // Wait indefinitely default i.e. INFINITE - int WaitForFirstEvent(HANDLE *pHandles, int iHandles, DWORD msec = INFINITE) { - ::WaitForMultipleObjects( - iHandles, // Number of objects in handles - pHandles, - FALSE, // Wait for first event object - msec); - } // Wait indefinitely default i.e. INFINITE HANDLE GetHandle() { return m_Handle; } diff --git a/source/gen_rc.sh b/source/gen_rc.sh new file mode 100755 index 0000000..61400ab --- /dev/null +++ b/source/gen_rc.sh @@ -0,0 +1,168 @@ +#!/usr/bin/env bash +# ------------------------------------------------------------------------------ +# Copyright (C) ST-Ericsson SA 2012 +# License terms: 3-clause BSD license +# ------------------------------------------------------------------------------ + +#-------- Global vars init values ----------- + +#script version +SCRIPT_VERSION="v1.0" + +#printout stream channels +error_channel=/dev/stderr +normal_channel=/dev/stdout +stream_channel=$normal_channel + +#current date +DATE="" + +#git revision info +VERSION="" + +LCD_RC_PATH=out/autogen/outLCDriver.rc +LCM_RC_PATH=out/autogen/outLCM.rc + +# ------------------------------INTERNAL FUNCTIONS ---------------------------- + +function show_err() +{ + cat >> $stream_channel << INLINE_DOC + +Syntax ERROR! +Try reading the script help info +$0 --help + +INLINE_DOC +} + +function get_help() +{ + cat >> $stream_channel << INLINE_DOC +================================ HELP ================================ +The purpose of this script is generating resource .rc files +that will be used by the resource compiler in order to +produce compiled resource files .res +This res files will be used by the linker when it will try to embedd +the version info into the executables. + +INLINE_DOC +} + +function get_init_data() +{ + DATE=`date` + VERSION=`git describe --tags --always --long` +} + +# +# Loader Communication module +# +function process_lcm() +{ + cat > $LCM_RC_PATH << INLINE_DOC +1 VERSIONINFO + FILEVERSION 1,0,0,1 + PRODUCTVERSION 1,0,0,1 + FILEFLAGSMASK 0x1fL +#ifdef _DEBUG + FILEFLAGS 0x9L +#else + FILEFLAGS 0x8L +#endif + FILEOS 0x4L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN +INLINE_DOC +echo " VALUE \"Comments\", \"Build date: $DATE\"" >> $LCM_RC_PATH +cat >> $LCM_RC_PATH << INLINE_DOC + VALUE "CompanyName", "STEricsson AB" + VALUE "FileDescription", "LCM Dynamic Link Library" + VALUE "FileVersion", "1, 0, 0, 1" + VALUE "InternalName", "Loader Communication Module" + VALUE "LegalCopyright", "Copyright (C) STEricsson AB 2012" + VALUE "ProductName", "CXA1104507 Loader Communication Module" +INLINE_DOC +echo " VALUE \"ProductVersion\", \"$VERSION\"" >> $LCM_RC_PATH +cat >> $LCM_RC_PATH << INLINE_DOC + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x9, 1200 + END +END + +INLINE_DOC + +} + +# +# Loader Communication Driver +# +function process_lcd() +{ + cat > $LCD_RC_PATH << INLINE_DOC +1 VERSIONINFO + FILEVERSION 1,0,0,1 + PRODUCTVERSION 1,0,0,1 + FILEFLAGSMASK 0x1fL +#ifdef _DEBUG + FILEFLAGS 0x9L +#else + FILEFLAGS 0x8L +#endif + FILEOS 0x4L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "000904b0" + BEGIN +INLINE_DOC +echo " VALUE \"Comments\", \"Build date: $DATE\"" >> $LCD_RC_PATH +cat >> $LCD_RC_PATH << INLINE_DOC + VALUE "CompanyName", "STEricsson AB" + VALUE "FileDescription", "LCDriver Dynamic Link Library" + VALUE "FileVersion", "1, 0, 0, 1" + VALUE "InternalName", "Loader Communication Driver" + VALUE "LegalCopyright", "Copyright (C) STEricsson AB 2012" + VALUE "ProductName", "CXC 173 0865, LCDriver DLL" +INLINE_DOC +echo " VALUE \"ProductVersion\", \"$VERSION\"" >> $LCD_RC_PATH +cat >> $LCD_RC_PATH << INLINE_DOC + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x9, 1200 + END +END + +INLINE_DOC +} + +# ------------------------------- main script routine ------------------------- +get_init_data +case $1 in + + --lcm) + echo "Generating LCM.rc file .." + process_lcm;; + --lcd) + echo "Generating LCDriver.rc file." + process_lcd;; + + -h|?|--help) + get_help;; + *) + stream_channel=$error_channel + show_err;; +esac + diff --git a/source/security_algorithms/sha/sha2.cpp b/source/security_algorithms/sha/sha2.cpp index 07473e7..ec214f6 100644 --- a/source/security_algorithms/sha/sha2.cpp +++ b/source/security_algorithms/sha/sha2.cpp @@ -85,6 +85,7 @@ * <machine/endian.h> where the appropriate definitions are actually * made). */ + #if !defined(BYTE_ORDER) || (BYTE_ORDER != LITTLE_ENDIAN && BYTE_ORDER != BIG_ENDIAN) #error Define BYTE_ORDER to be equal to either LITTLE_ENDIAN or BIG_ENDIAN #endif diff --git a/source/utilities/Logger.h b/source/utilities/Logger.h index 2388bb4..ec1f0a9 100644 --- a/source/utilities/Logger.h +++ b/source/utilities/Logger.h @@ -30,4 +30,4 @@ private: MessageCallback_t messageCallback_; }; -#endif // _LOGGER_H_
\ No newline at end of file +#endif // _LOGGER_H_ diff --git a/source/utilities/String_s.cpp b/source/utilities/String_s.cpp new file mode 100644 index 0000000..c204ec8 --- /dev/null +++ b/source/utilities/String_s.cpp @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright (C) ST-Ericsson SA 2012 + * License terms: 3-clause BSD license + ******************************************************************************/ +#include "String_s.h" + +char *strcpy_s(char *dst, size_t _Size, const char *src) +{ + return strncpy(dst, src, _Size); +} + +int sprintf_s(char *dst, size_t _Size, const char *format, ...) +{ + va_list l; + int ReturnValue; + + va_start(l, format); + ReturnValue = vsnprintf(dst, _Size, format, l); + va_end(l); + + return ReturnValue; +} + +char *strncpy_s(char *dst, const char *src, size_t _Size) +{ + return strncpy(dst, src, _Size); +} + +#ifndef __MINGW32__ +int _stricmp(const char *s1, const char *s2) +{ + return strcasecmp(s1, s2); +} +#endif diff --git a/source/utilities/String_s.h b/source/utilities/String_s.h new file mode 100644 index 0000000..88179e8 --- /dev/null +++ b/source/utilities/String_s.h @@ -0,0 +1,80 @@ +/******************************************************************************* + * Copyright (C) ST-Ericsson SA 2012 + * License terms: 3-clause BSD license + ******************************************************************************/ +#include <stdio.h> +#include <stdarg.h> +#include <string.h> +#include <strings.h> + +#define MAX(a, b) ((a) > (b) ? (a) : (b)) + +/* + * str manipulation functions used in windows build + */ + +char *strcpy_s(char *dst, size_t _Size, const char *src); +char *strncpy_s(char *dst, const char *src, size_t _Size); +#ifndef __MINGW32__ +int _stricmp(const char *s1, const char *s2); +#endif +int sprintf_s(char *dst, size_t _Size, const char *format, ...); + +#define _snprintf snprintf + +template <size_t _Size> +char *strcpy_s(char(&dst)[_Size], const char src[]) +{ + return strncpy(dst, src, _Size); +} + +template<size_t _Size> +int sprintf_s(char(&dst)[_Size], const char *format, ...) +{ + int ReturnValue; + va_list l; + va_start(l, format); + ReturnValue = vsnprintf(dst, _Size, format, l); + va_end(l); + return ReturnValue; +} + +template <size_t _Size> +char *strcat_s(char(&dst)[_Size], const char src[]) +{ + return strncat(dst, src, _Size); +} + +template <size_t _Size> +int _ultoa_s(unsigned long value, char(&str)[_Size], int radix) +{ + switch (radix) { + case 10: + return sprintf_s(str, "%ul", value); + + case 16: + return sprintf_s(str, "%ulX", value); + + default: + return -1; + } +} + +template<size_t _Size> +int _snprintf_s(char(&dst)[_Size], size_t _MaxCount, const char *format, ...) +{ + int ReturnValue; + va_list l; + va_start(l, format); + ReturnValue = vsnprintf(dst, MAX(_MaxCount, _Size), format, l); + va_end(l); + return ReturnValue; +} + +template<size_t _Size> +int vsprintf_s(char(&dst)[_Size], const char *format, va_list l) +{ + return vsnprintf(dst, _Size, format, l); +} + + |