Author: tkreuzer
Date: Tue Aug 26 15:51:14 2008
New Revision: 35682
URL:
http://svn.reactos.org/svn/reactos?rev=35682&view=rev
Log:
Start a new strsafe lib. Nothing implemented so far, more something like a framework. The
actual function implementation will be in the header, because the ms header allows to
inline the functions. It uses recursive include to avoid code duplication. The lib uses
these functions to generate the code.
Added:
branches/ros-amd64-bringup/reactos/include/psdk/strsafe.h (with props)
branches/ros-amd64-bringup/reactos/lib/sdk/strsafe/
branches/ros-amd64-bringup/reactos/lib/sdk/strsafe/StringCbCatA.c (with props)
branches/ros-amd64-bringup/reactos/lib/sdk/strsafe/StringCbCopyA.c (with props)
branches/ros-amd64-bringup/reactos/lib/sdk/strsafe/StringCbPrintfA.c (with props)
branches/ros-amd64-bringup/reactos/lib/sdk/strsafe/strsafe.rbuild (with props)
Modified:
branches/ros-amd64-bringup/reactos/lib/sdk/sdk.rbuild
Added: branches/ros-amd64-bringup/reactos/include/psdk/strsafe.h
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/inclu…
==============================================================================
--- branches/ros-amd64-bringup/reactos/include/psdk/strsafe.h (added)
+++ branches/ros-amd64-bringup/reactos/include/psdk/strsafe.h [iso-8859-1] Tue Aug 26
15:51:14 2008
@@ -1,0 +1,144 @@
+#ifndef __STRSAFE_H_
+#define __STRSAFE_H_
+
+#include <stdlib.h>
+#include <stdarg.h>
+
+#if defined(STRSAFE_NO_CCH_FUNCTIONS) && defined(STRSAFE_NO_CB_FUNCTIONS)
+#error Both STRSAFE_NO_CCH_FUNCTIONS and STRSAFE_NO_CB_FUNCTIONS are defined
+#endif
+
+
+#ifndef _HRESULT_DEFINED
+#define _HRESULT_DEFINED
+typedef long HRESULT;
+#endif
+
+typedef char * STRSAFE_LPSTR;
+typedef const char * STRSAFE_LPCSTR;
+typedef wchar_t * STRSAFE_LPWSTR;
+typedef const wchar_t * STRSAFE_LPCWSTR;
+typedef unsigned long STRSAFE_DWORD;
+
+/* Implement for ansi and unicode */
+#define STRSAFE_PASS2
+#define STRSAFE_UNICODE 0
+# include <strsafe.h>
+#undef STRSAFE_UNICODE
+#define STRSAFE_UNICODE 1
+# include <strsafe.h>
+#undef STRSAFE_UNICODE
+#undef STRSAFE_PASS2
+
+/* Now define the functions depending on UNICODE */
+#ifdef UNICODE
+# define STRSAFE_UNICODE 1
+#else
+# define STRSAFE_UNICODE 0
+#endif
+#include <strsafe.h>
+#undef STRSAFE_UNICODE
+
+#endif // !__STRSAFE_H_
+
+/*****************************************************************************/
+
+#if defined(STRSAFE_UNICODE)
+#if (STRSAFE_UNICODE == 1)
+
+#define STRSAFE_LPTSTR STRSAFE_LPWSTR
+#define STRSAFE_LPCTSTR STRSAFE_LPCWSTR
+
+#define StringCbCat StringCbCatW
+#define StringCbCopy StringCbCopyW
+#define StringCbVPrintf StringCbVPrintfW
+#define StringCbPrintf StringCbPrintfW
+
+#else // (STRSAFE_UNICODE != 1)
+
+#define STRSAFE_LPTSTR STRSAFE_LPSTR
+#define STRSAFE_LPCTSTR STRSAFE_LPCSTR
+
+#define StringCbCat StringCbCatA
+#define StringCbCopy StringCbCopyA
+#define StringCbVPrintf StringCbVPrintfA
+#define StringCbPrintf StringCbPrintfA
+
+#endif // (STRSAFE_UNICODE != 1)
+#endif // defined(STRSAFE_UNICODE)
+
+/*****************************************************************************/
+
+#if defined (STRSAFE_PASS2)
+
+#ifdef STRSAFE_LIB
+
+/* Normal function prototypes only */
+#define STRSAFEAPI HRESULT __stdcall
+
+#ifndef STRSAFE_NO_CB_FUNCTIONS
+STRSAFEAPI StringCbCat(STRSAFE_LPTSTR pszDest, size_t cbDest, STRSAFE_LPCTSTR pszSrc);
+STRSAFEAPI StringCbCopy(STRSAFE_LPTSTR pszDest, size_t cbDest, STRSAFE_LPCTSTR pszSrc);
+STRSAFEAPI StringCbVPrintf(STRSAFE_LPTSTR pszDest, size_t cbDest, STRSAFE_LPCTSTR
pszFormat, va_list args);
+STRSAFEAPI StringCbPrintf(STRSAFE_LPTSTR pszDest, size_t cbDest, STRSAFE_LPCTSTR
pszFormat, ...);
+#endif // !STRSAFE_NO_CB_FUNCTIONS
+
+#ifndef STRSAFE_NO_CCH_FUNCTIONS
+
+#endif // !STRSAFE_NO_CCH_FUNCTIONS
+
+
+#else // !STRSAFE_LIB
+
+/* Create inlined versions */
+#define STRSAFEAPI HRESULT static __inline__
+
+#ifndef STRSAFE_NO_CB_FUNCTIONS
+
+STRSAFEAPI StringCbCat(STRSAFE_LPTSTR pszDest, size_t cbDest, STRSAFE_LPCTSTR pszSrc)
+{
+ return 0; // FIXME
+}
+
+STRSAFEAPI
+StringCbCopy(STRSAFE_LPTSTR pszDest, size_t cbDest, STRSAFE_LPCTSTR pszSrc)
+{
+ return 0; // FIXME
+}
+
+STRSAFEAPI
+StringCbVPrintf(STRSAFE_LPTSTR pszDest, size_t cbDest, STRSAFE_LPCTSTR pszFormat, va_list
args)
+{
+ return 0; // FIXME
+}
+
+STRSAFEAPI
+StringCbPrintf(STRSAFE_LPTSTR pszDest, size_t cbDest, STRSAFE_LPCTSTR pszFormat, ...)
+{
+ HRESULT result;
+ va_list args;
+ va_start(args, pszFormat);
+ result = StringCbVPrintf(pszDest, cbDest, pszFormat, args);
+ va_end(args);
+ return result;
+}
+
+#endif // !STRSAFE_NO_CB_FUNCTIONS
+
+#ifndef STRSAFE_NO_CCH_FUNCTIONS
+
+#endif // !STRSAFE_NO_CCH_FUNCTIONS
+
+#endif // !STRSAFE_LIB
+
+/* Functions are implemented or defined, clear #defines for next pass */
+#undef StringCbCat
+#undef StringCbCopy
+#undef StringCbVPrintf
+#undef StringCbPrintf
+
+#undef STRSAFE_LPTSTR
+#undef STRSAFE_LPCTSTR
+
+#endif // defined (STRSAFE_PASS2)
+
Propchange: branches/ros-amd64-bringup/reactos/include/psdk/strsafe.h
------------------------------------------------------------------------------
svn:eol-style = native
Modified: branches/ros-amd64-bringup/reactos/lib/sdk/sdk.rbuild
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/lib/s…
==============================================================================
--- branches/ros-amd64-bringup/reactos/lib/sdk/sdk.rbuild [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/lib/sdk/sdk.rbuild [iso-8859-1] Tue Aug 26 15:51:14
2008
@@ -14,6 +14,9 @@
<directory name="strmiids">
<xi:include href="strmiids/strmiids.rbuild" />
</directory>
+ <directory name="strsafe">
+ <xi:include href="strsafe/strsafe.rbuild" />
+ </directory>
<directory name="uuid">
<xi:include href="uuid/uuid.rbuild" />
</directory>
Added: branches/ros-amd64-bringup/reactos/lib/sdk/strsafe/StringCbCatA.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/lib/s…
==============================================================================
--- branches/ros-amd64-bringup/reactos/lib/sdk/strsafe/StringCbCatA.c (added)
+++ branches/ros-amd64-bringup/reactos/lib/sdk/strsafe/StringCbCatA.c [iso-8859-1] Tue Aug
26 15:51:14 2008
@@ -1,0 +1,14 @@
+#define STRSAFE_NO_CCH_FUNCTIONS
+#define StringCbCatA _StringCbCatA
+#include <strsafe.h>
+
+#undef StringCbCatA
+HRESULT __stdcall
+StringCbCatA(
+ STRSAFE_LPSTR pszDest,
+ size_t cbDest,
+ STRSAFE_LPCSTR pszSrc)
+{
+ /* Use the inlined version */
+ return _StringCbCatA(pszDest, cbDest, pszSrc);
+}
Propchange: branches/ros-amd64-bringup/reactos/lib/sdk/strsafe/StringCbCatA.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: branches/ros-amd64-bringup/reactos/lib/sdk/strsafe/StringCbCopyA.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/lib/s…
==============================================================================
--- branches/ros-amd64-bringup/reactos/lib/sdk/strsafe/StringCbCopyA.c (added)
+++ branches/ros-amd64-bringup/reactos/lib/sdk/strsafe/StringCbCopyA.c [iso-8859-1] Tue
Aug 26 15:51:14 2008
@@ -1,0 +1,14 @@
+#define STRSAFE_NO_CCH_FUNCTIONS
+#define StringCbCopyA _StringCbCopyA
+#include <strsafe.h>
+
+#undef StringCbCopyA
+HRESULT __stdcall
+StringCbCopyA(
+ STRSAFE_LPSTR pszDest,
+ size_t cbDest,
+ STRSAFE_LPCSTR pszSrc)
+{
+ /* Use the inlined version */
+ return _StringCbCopyA(pszDest, cbDest, pszSrc);
+}
Propchange: branches/ros-amd64-bringup/reactos/lib/sdk/strsafe/StringCbCopyA.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: branches/ros-amd64-bringup/reactos/lib/sdk/strsafe/StringCbPrintfA.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/lib/s…
==============================================================================
--- branches/ros-amd64-bringup/reactos/lib/sdk/strsafe/StringCbPrintfA.c (added)
+++ branches/ros-amd64-bringup/reactos/lib/sdk/strsafe/StringCbPrintfA.c [iso-8859-1] Tue
Aug 26 15:51:14 2008
@@ -1,0 +1,19 @@
+#define STRSAFE_NO_CCH_FUNCTIONS
+#define StringCbPrintfA _StringCbPrintfA
+#include <strsafe.h>
+
+#undef StringCbPrintfA
+HRESULT __stdcall
+StringCbPrintfA(
+ STRSAFE_LPSTR pszDest,
+ size_t cbDest,
+ STRSAFE_LPCSTR pszFormat,
+ ...)
+{
+ HRESULT result;
+ va_list args;
+ va_start(args, pszFormat);
+ result = StringCbVPrintfA(pszDest, cbDest, pszFormat, args);
+ va_end(args);
+ return result;
+}
Propchange: branches/ros-amd64-bringup/reactos/lib/sdk/strsafe/StringCbPrintfA.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: branches/ros-amd64-bringup/reactos/lib/sdk/strsafe/strsafe.rbuild
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/lib/s…
==============================================================================
--- branches/ros-amd64-bringup/reactos/lib/sdk/strsafe/strsafe.rbuild (added)
+++ branches/ros-amd64-bringup/reactos/lib/sdk/strsafe/strsafe.rbuild [iso-8859-1] Tue Aug
26 15:51:14 2008
@@ -1,0 +1,8 @@
+<?xml version="1.0"?>
+<!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
+<module name="strsafe" type="staticlibrary">
+ <define name="_DISABLE_TIDENTS" />
+ <file>StringCbCatA.c</file>
+ <file>StringCbCopyA.c</file>
+ <file>StringCbPrintfA.c</file>
+</module>
Propchange: branches/ros-amd64-bringup/reactos/lib/sdk/strsafe/strsafe.rbuild
------------------------------------------------------------------------------
svn:eol-style = native