. add StrUtil_IsASCII (not used by the OVT code).
. other changes in shared code that don't affect open-vm-tools
functionality
Signed-off-by: Dmitry Torokhov <dtor@vmware.com>
/* for uint32 */
#include "vm_basic_types.h"
+
+#if defined __APPLE__ && defined USERLEVEL
+
+/*
+ * Apple provides basic crypto functions in its system runtime that are
+ * maintained for both speed and security. Use those instead.
+ */
+
+#include <CommonCrypto/CommonDigest.h>
+
+#define SHA1_HASH_LEN CC_SHA1_DIGEST_LENGTH
+#define SHA1_CTX CC_SHA1_CTX
+#define SHA1Init CC_SHA1_Init
+#define SHA1Update CC_SHA1_Update
+#define SHA1Final CC_SHA1_Final
+
+#else
+
/*
SHA-1 in C
By Steve Reid <steve@edmweb.com>
#endif
void SHA1Final(unsigned char digest[SHA1_HASH_LEN], SHA1_CTX* context);
-void SHA1Transform(uint32 state[5], const unsigned char buffer[64]);
+#endif // defined __APPLE__ && defined USERLEVEL
#endif // ifndef _SHA1_H_
Bool StrUtil_StartsWith(const char *s, const char *prefix);
Bool StrUtil_CaselessStartsWith(const char *s, const char *prefix);
Bool StrUtil_EndsWith(const char *s, const char *suffix);
+Bool StrUtil_IsASCII(const char *s);
Bool StrUtil_VDynBufPrintf(struct DynBuf *b, const char *fmt, va_list args);
Bool StrUtil_DynBufPrintf(struct DynBuf *b, const char *fmt, ...);
* Wide versions of string constants.
*/
+#ifndef WSTR
#define WSTR_(X) L ## X
#define WSTR(X) WSTR_(X)
+#endif
/*
*/
#include "vm_version.h"
+#ifndef WSTR
+#define WSTR_(x) L ## x
+#define WSTR(x) WSTR_(x)
+#endif
+
+
+#define COPYRIGHT_YEARS "1998-2012"
+#define COPYRIGHT_STRING "Copyright (C) " COPYRIGHT_YEARS " " COMPANY_NAME
+#define RIGHT_RESERVED "All rights reserved."
/*
* Use UTF8_COPYRIGHT_STRING_BASE when the COMPANY_NAME must be separated out
* to create a hyperlink.
*/
-#define COPYRIGHT_YEARS "1998-2012"
-#define COPYRIGHT_STRING "Copyright \251 " COPYRIGHT_YEARS " " COMPANY_NAME
#define UTF8_COPYRIGHT_STRING_BASE "Copyright \302\251 " COPYRIGHT_YEARS
#define UTF8_COPYRIGHT_STRING UTF8_COPYRIGHT_STRING_BASE " " COMPANY_NAME
-#define GENERIC_COPYRIGHT_STRING "Copyright (C) " COPYRIGHT_YEARS " " COMPANY_NAME
-#define RIGHT_RESERVED "All rights reserved."
+
+/*
+ * A UTF-16 version of the copyright string. wchar_t is an
+ * implementation-defined type, but we can expect it to be UTF-16 on
+ * Windows. (Only Windows cares about UTF-16 anyway.)
+ */
+#ifdef _WIN32
+#define UTF16_COPYRIGHT_STRING L"Copyright \x00A9 " WSTR(COPYRIGHT_YEARS) L" " WSTR(COMPANY_NAME)
+#endif
+
/*
* Use PATENTS_STRING for showing the patents string in plaintext form.
}
#ifdef SHA1HANDSOFF
-void SHA1Transform(uint32 state[5], const unsigned char buffer[64])
+static void
+SHA1Transform(uint32 state[5], const unsigned char buffer[64])
#else
-void SHA1Transform(uint32 state[5], unsigned char buffer[64])
+static void
+SHA1Transform(uint32 state[5], unsigned char buffer[64])
#endif
{
#ifdef SHA1HANDSOFF
#include "strutil.h"
#include "str.h"
#include "dynbuf.h"
+#include "vm_ctype.h"
/*
}
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * StrUtil_IsASCII --
+ *
+ * Results:
+ * Returns TRUE if the string contains only ASCII characters, FALSE
+ * otherwise.
+ *
+ * Side effects:
+ * None.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+Bool
+StrUtil_IsASCII(const char *s) // IN
+{
+ ASSERT(s != NULL);
+
+ while (*s != '\0') {
+ if (!CType_IsAscii(*s)) {
+ return FALSE;
+ }
+ s++;
+ }
+
+ return TRUE;
+}
+
+
/*
*-----------------------------------------------------------------------------
*
*-----------------------------------------------------------------------------
*/
-string::string(const Glib::ustring &s) // IN
+string::string(const Glib::ustring& s) // IN
+#ifdef I_LOVE_STRICT_SENSITIVESTRING
+ : mUstr(s),
+#else
: mUstr(s.c_str()),
+#endif
mUtf16Cache(NULL),
mUtf16Length(npos)
{
*-----------------------------------------------------------------------------
*/
-string::string(const string &s) // IN
+string::string(const string& s) // IN
+#ifdef I_LOVE_STRICT_SENSITIVESTRING
+ : mUstr(s.mUstr),
+#else
: mUstr(s.mUstr.c_str()),
+#endif
mUtf16Cache(NULL),
mUtf16Length(npos)
{
}
-/*
- *-----------------------------------------------------------------------------
- *
- * utf::string::isASCII --
- *
- * Test if every character in the string is in the ASCII range.
- *
- * Results:
- * true if all ASCII, otherwise false.
- *
- * Side effects:
- * None
- *
- *-----------------------------------------------------------------------------
- */
-
-bool
-string::isASCII()
- const
-{
- return mUstr.is_ascii();
-}
-
-
/*
*-----------------------------------------------------------------------------
*
}
+#ifndef I_LOVE_STRICT_SENSITIVESTRING
/*
*-----------------------------------------------------------------------------
*
Util_Zero(const_cast<char *>(mUstr.data()), mUstr.bytes());
mUstr.clear();
}
+#endif // I_LOVE_STRICT_SENSITIVESTRING
/*
void swap(string &s);
void resize(size_type n, value_type c = '\0');
bool empty() const;
- bool isASCII() const;
size_type size() const;
size_type w_size() const;
size_type length() const;
string& assign(const string &s);
void push_back(value_type uc);
void clear();
+#ifndef I_LOVE_STRICT_SENSITIVESTRING
void zero_clear();
+#endif
string& insert(size_type i, const string& s);
string& insert(size_type i, size_type n, value_type uc);
string& insert(iterator p, value_type uc);