summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChen Congwu <congwu.chen@intel.com>2010-03-08 10:35:08 +0800
committerChen Congwu <congwu.chen@intel.com>2010-03-11 11:13:00 +0800
commit66a2bf2a5b3268e4dc9120b91d4ffe6508b10500 (patch)
tree52927cf073981e95b5ba7e8916fe38a446566767
parent083ad0428c8c873b7508b2710ec1930a7a60b2aa (diff)
Build script and code changes for the new moved utility code.san11
stringutil is inflated to add several functions from stringutils so that we can keep stringutil as enough for SDKs Unnecessary needed utility functions in sysync_utils is disabled in SDK build by wrapping inside #ifdef SYSYNC_ENGINE
-rwxr-xr-xsrc/gen-makefile-am.sh12
-rw-r--r--src/synthesis-linker.map13
-rwxr-xr-xsrc/sysync/sysync.h2
-rwxr-xr-xsrc/sysync_SDK/Sources/lineartime.cpp2
-rw-r--r--src/sysync_SDK/Sources/stringutil.cpp64
-rw-r--r--src/sysync_SDK/Sources/stringutil.h2
-rwxr-xr-xsrc/sysync_SDK/Sources/syncexception.cpp2
-rwxr-xr-xsrc/sysync_SDK/Sources/sysync_utils.cpp75
-rwxr-xr-xsrc/sysync_SDK/Sources/sysync_utils.h4
9 files changed, 117 insertions, 59 deletions
diff --git a/src/gen-makefile-am.sh b/src/gen-makefile-am.sh
index a46a993..d3934bd 100755
--- a/src/gen-makefile-am.sh
+++ b/src/gen-makefile-am.sh
@@ -11,8 +11,6 @@ ENGINE_SOURCES="sysync DB_interfaces sysync_SDK/Sources Transport_interfaces/eng
cat > SDK_FILES <<EOF
enginemodulebridge.cpp
enginemodulebridge.h
-stringutil.cpp
-stringutil.h
target_options.h
san.cpp
san.h
@@ -22,6 +20,14 @@ UI_util.cpp
UI_util.h
EOF
+# files needed exclusively for libsynthesissdk.so
+# They should not go into libsynthesissdk.a because the more complete set of
+# code is available in the engine
+cat > SDK_EXCLUDE_FILES <<EOF
+stringutil.cpp
+stringutil.h
+EOF
+
# The distinction between client and server files is not
# important and even likely to be wrong/incomplete. Right now,
# all of these files are compiled into libsynthesis and only
@@ -60,7 +66,7 @@ enginestubs.c
EOF
# files to be included in libsynthesis
-cat EXTRA_FILES SDK_FILES > EXCLUDE_FILES
+cat EXTRA_FILES SDK_FILES SDK_EXCLUDE_FILES> EXCLUDE_FILES
LIBSYNTHESIS_SOURCES=`find ${ENGINE_SOURCES} \
syncapps/clientEngine_custom \
syncapps/serverEngine_custom \
diff --git a/src/synthesis-linker.map b/src/synthesis-linker.map
index 8fbdf90..2435aca 100644
--- a/src/synthesis-linker.map
+++ b/src/synthesis-linker.map
@@ -6,19 +6,6 @@ VER_1.0 {
extern "C++" {
sysync::DataConversion*;
sysync::SySyncDebugPuts*;
- sysync::smlSrcTargLocURIToCharP*;
- sysync::smlPCDataToLong*;
- sysync::smlPCDataToCharP*;
- sysync::StrToUShort*;
- sysync::newItem*;
- sysync::newMetaType*;
- sysync::_smlMalloc*;
- sysync::addItemToList*;
- sysync::newOptLocation*;
- sysync::newPCDataString*;
- sysync::newPCDataLong*;
- sysync::strucmp*;
- sysync::newLocation*;
};
local:
*;
diff --git a/src/sysync/sysync.h b/src/sysync/sysync.h
index 066f86e..2208b97 100755
--- a/src/sysync/sysync.h
+++ b/src/sysync/sysync.h
@@ -51,7 +51,9 @@ extern "C" {
// utilities
#include "sysync_utils.h"
+#ifdef SYSYNC_ENGINE
#include "stringutils.h"
+#endif
#include "lineartime.h"
#include "iso8601.h"
#include "debuglogger.h"
diff --git a/src/sysync_SDK/Sources/lineartime.cpp b/src/sysync_SDK/Sources/lineartime.cpp
index 2a03013..9b93b26 100755
--- a/src/sysync_SDK/Sources/lineartime.cpp
+++ b/src/sysync_SDK/Sources/lineartime.cpp
@@ -11,7 +11,7 @@
*
*/
#include "prefix_file.h"
-
+#include "sync_include.h"
#include "lineartime.h"
#include "timezones.h"
diff --git a/src/sysync_SDK/Sources/stringutil.cpp b/src/sysync_SDK/Sources/stringutil.cpp
index b7a18e0..54ab6ed 100644
--- a/src/sysync_SDK/Sources/stringutil.cpp
+++ b/src/sysync_SDK/Sources/stringutil.cpp
@@ -12,7 +12,7 @@
#include "target_options.h"
-#ifdef WITHOUT_SAN_1_1
+#ifndef WITHOUT_SAN_1_1
#if defined __MACH__ && !defined __GNUC__ /* used for va_list support */
#include <mw_stdarg.h>
@@ -240,6 +240,68 @@ sInt16 HexStrToUIntPtr( cAppCharP aStr, uIntPtr &aIntPtr, sInt16 aMaxDigits )
#endif
} // HexStrToUIntPtr
+// helper
+static bool isMinus(const char *&aStr, sInt16 &aNumRead)
+{
+ if (!aStr) return false; // not minus
+ if (*aStr=='-') {
+ aStr++;
+ aNumRead++;
+ return true; // is minus
+ }
+ else if (*aStr=='+') {
+ aStr++;
+ aNumRead++;
+ }
+ // is plus
+ return false;
+} // isMinus
+
+// returns number of successfully converted chars
+sInt16 StrToUShort( cAppCharP aStr, uInt16 &aShort, sInt16 aMaxDigits)
+{
+ // our own implementation
+ char c;
+ sInt16 n=0;
+ aShort=0;
+ while (aStr && (c=*aStr++) && (n<aMaxDigits)) {
+ if (!isdigit(c)) break;
+ aShort*=10;
+ aShort+=(c-0x30);
+ n++;
+ }
+ return n;
+} // StrToUShort
+
+// returns number of successfully converted chars
+sInt16 StrToULong(const char *aStr, uInt32 &aLong, sInt16 aMaxDigits)
+{
+ // our own implementation
+ char c;
+ sInt16 n=0;
+ aLong=0;
+ while (aStr && (c=*aStr++) && (n<aMaxDigits)) {
+ if (!isdigit(c)) break;
+ aLong*=10l;
+ aLong+=(c-0x30);
+ n++;
+ }
+ return n;
+} // StrToULong
+
+// returns number of successfully converted chars
+sInt16 StrToLong(const char *aStr, sInt32 &aLong, sInt16 aMaxDigits)
+{
+ // our own implementation
+ uInt32 temp;
+ sInt16 n=0;
+ bool neg=isMinus(aStr,n);
+ n+=StrToULong(aStr,temp,aMaxDigits-n);
+ if (neg) aLong=-(sInt32)temp;
+ else aLong=temp;
+ return n;
+} // StrToLong
+
#ifdef __cplusplus
} // namespace
diff --git a/src/sysync_SDK/Sources/stringutil.h b/src/sysync_SDK/Sources/stringutil.h
index 74dbc00..bb36a94 100644
--- a/src/sysync_SDK/Sources/stringutil.h
+++ b/src/sysync_SDK/Sources/stringutil.h
@@ -39,6 +39,8 @@ sInt16 StrToCStrAppend( cAppCharP aStr, string &aString, bool aAllow8Bit=false,
void StringObjAppendPrintf( string &aStringObj, cAppCharP aFormat, ... );
sInt16 StrToULong ( cAppCharP aStr, uInt32 &aLong, sInt16 aMaxDigits= 100 );
+sInt16 StrToLong ( cAppCharP aStr, sInt32 &aLong, sInt16 aMaxDigits= 100 );
+sInt16 StrToUShort ( cAppCharP aStr, uInt16 &aShort, sInt16 aMaxDigits= 100 );
sInt16 HexStrToULong ( cAppCharP aStr, uInt32 &aLong, sInt16 aMaxDigits= 100 );
sInt16 HexStrToULongLong( cAppCharP aStr, uInt64 &aLongLong, sInt16 aMaxDigits= 100 );
sInt16 HexStrToUIntPtr ( cAppCharP aStr, uIntPtr &aIntPtr, sInt16 aMaxDigits= 100 );
diff --git a/src/sysync_SDK/Sources/syncexception.cpp b/src/sysync_SDK/Sources/syncexception.cpp
index 49179d8..3fb2c3f 100755
--- a/src/sysync_SDK/Sources/syncexception.cpp
+++ b/src/sysync_SDK/Sources/syncexception.cpp
@@ -14,7 +14,7 @@
// includes
#include "prefix_file.h"
-
+#include "sync_include.h"
#include "sysync.h"
#include "syncexception.h"
diff --git a/src/sysync_SDK/Sources/sysync_utils.cpp b/src/sysync_SDK/Sources/sysync_utils.cpp
index 9ba91b6..c31e61f 100755
--- a/src/sysync_SDK/Sources/sysync_utils.cpp
+++ b/src/sysync_SDK/Sources/sysync_utils.cpp
@@ -13,7 +13,7 @@
*/
#include "prefix_file.h"
-
+#include "sync_include.h"
#include "sysync_utils.h"
#include "libmem.h"
@@ -321,6 +321,7 @@ const char * const MIMECharSetNames[numCharSets] = {
};
+#ifdef SYSYNC_ENGINE
// generate RFC2822-style address specificiation
// - Common Name will be quoted
// - recipient will be put in angle brackets
@@ -1878,20 +1879,6 @@ treeval_t searchFlatBintree(const TConvFlatTree &aFlatTree, treeval_t aKey, tree
return aUndefValue;
} // searchFlatBintree
-
-// allocate memory via SyncML toolkit allocation function, but throw
-// exception if it fails. Used by SML
-void *_smlMalloc(MemSize_t size)
-{
- void *p;
-
- p=smlLibMalloc(size);
- if (!p) SYSYNC_THROW(TMemException("smlLibMalloc() failed"));
- return p;
-} // _smlMalloc
-
-
-
// MD5 and B64 given string
void MD5B64(const char *aString, sInt32 aLen, string &aMD5B64)
{
@@ -1985,7 +1972,6 @@ void StringLower(string &aString)
} // StringLower
-
// Substitute occurences of pattern with replacement in string
void StringSubst(
string &aString, const char *aPattern, const string &aReplacement,
@@ -2081,6 +2067,22 @@ void smlPCDataToStringObj(const SmlPcdataPtr_t aPcdataP, string &aStringObj)
} // smlPCDataToStringObj
+// returns item string or empty string (NEVER NULL)
+const char *smlItemDataToCharP(const SmlItemPtr_t aItemP)
+{
+ if (!aItemP) return "";
+ return smlPCDataToCharP(aItemP->data);
+} // smlItemDataToCharP
+
+
+// returns first item string or empty string (NEVER NULL)
+const char *smlFirstItemDataToCharP(const SmlItemListPtr_t aItemListP)
+{
+ if (!aItemListP) return "";
+ return smlItemDataToCharP(aItemListP->item);
+} // smlFirstItemDataToCharP
+#endif //SYSYNC_ENGINE
+
// returns pointer to PCdata contents or null string. If aSizeP!=NULL, length will be stored in *aSize
const char *smlPCDataToCharP(const SmlPcdataPtr_t aPcdataP, stringSize *aSizeP)
{
@@ -2122,23 +2124,6 @@ const char *smlPCDataOptToCharP(const SmlPcdataPtr_t aPcdataP, stringSize *aSize
} // smlPCDataOptToCharP
-// returns item string or empty string (NEVER NULL)
-const char *smlItemDataToCharP(const SmlItemPtr_t aItemP)
-{
- if (!aItemP) return "";
- return smlPCDataToCharP(aItemP->data);
-} // smlItemDataToCharP
-
-
-// returns first item string or empty string (NEVER NULL)
-const char *smlFirstItemDataToCharP(const SmlItemListPtr_t aItemListP)
-{
- if (!aItemListP) return "";
- return smlItemDataToCharP(aItemListP->item);
-} // smlFirstItemDataToCharP
-
-
-
// returns pointer to source or target LocURI
const char *smlSrcTargLocURIToCharP(const SmlTargetPtr_t aSrcTargP)
{
@@ -2165,6 +2150,7 @@ const char *smlSrcTargLocNameToCharP(const SmlTargetPtr_t aSrcTargP)
} // smlSrcTargLocNameToCharP
+#ifdef SYSYNC_ENGINE
// returns error code made ready for SyncML sending (that is, remove offset
// of 10000 if present, and make generic error 500 for non-SyncML errors,
// and return LOCERR_OK as 200)
@@ -2299,6 +2285,7 @@ void splitURL(const char *aURI,string *aProtocol,string *aHost,string *aDoc,stri
}
} // splitURL
+#endif //SYSYNC_ENGINE
// returns type from meta
@@ -2348,12 +2335,16 @@ SmlMetInfMetInfPtr_t smlPCDataToMetInfP(const SmlPcdataPtr_t aPCDataP)
} // smlPCDataToMetInfP
-
-// returns true on successful conversion of PCData string to sInt32
-bool smlPCDataToLong(const SmlPcdataPtr_t aPCDataP, sInt32 &aLong)
+// allocate memory via SyncML toolkit allocation function, but throw
+// exception if it fails. Used by SML
+void *_smlMalloc(MemSize_t size)
{
- return StrToLong(smlPCDataToCharP(aPCDataP),aLong);
-} // smlPCDataToLong
+ void *p;
+
+ p=smlLibMalloc(size);
+ if (!p) SYSYNC_THROW(TMemException("smlLibMalloc() failed"));
+ return p;
+} // _smlMalloc
// returns true on successful conversion of PCData string to sInt32
@@ -2362,7 +2353,13 @@ bool smlPCDataToULong(const SmlPcdataPtr_t aPCDataP, uInt32 &aLong)
return StrToULong(smlPCDataToCharP(aPCDataP),aLong);
} // smlPCDataToLong
+// returns true on successful conversion of PCData string to sInt32
+bool smlPCDataToLong(const SmlPcdataPtr_t aPCDataP, sInt32 &aLong)
+{
+ return StrToLong(smlPCDataToCharP(aPCDataP),aLong);
+} // smlPCDataToLong
+#ifdef SYSYNC_ENGINE
// returns true on successful conversion of PCData string to format
bool smlPCDataToFormat(const SmlPcdataPtr_t aPCDataP, TFmtTypes &aFmt)
{
@@ -2378,7 +2375,7 @@ bool smlPCDataToFormat(const SmlPcdataPtr_t aPCDataP, TFmtTypes &aFmt)
}
return true;
} // smlPCDataToFormat
-
+#endif //SYSYNC_ENGINE
// build Meta anchor
SmlPcdataPtr_t newMetaAnchor(const char *aNextAnchor, const char *aLastAnchor)
diff --git a/src/sysync_SDK/Sources/sysync_utils.h b/src/sysync_SDK/Sources/sysync_utils.h
index 2ba442a..018340b 100755
--- a/src/sysync_SDK/Sources/sysync_utils.h
+++ b/src/sysync_SDK/Sources/sysync_utils.h
@@ -19,7 +19,9 @@
// include external utils in separate files
#include "sysync_b64.h"
#include "sysync_md5.h"
-#include "stringutils.h"
+#ifndef SYSYNC_ENGINE
+#include "stringutil.h"
+#endif
#include "lineartime.h"
#include "iso8601.h"