1/*************************************************************************/ 2/* module: SyncML xpt portability header file */ 3/* file: src/xpt/inc/xptport.h */ 4/* target system: all */ 5/* target OS: all */ 6/*************************************************************************/ 7 8 9/* 10 * Copyright Notice 11 * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication 12 * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc., 13 * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001). 14 * All Rights Reserved. 15 * Implementation of all or part of any Specification may require 16 * licenses under third party intellectual property rights, 17 * including without limitation, patent rights (such a third party 18 * may or may not be a Supporter). The Sponsors of the Specification 19 * are not responsible and shall not be held responsible in any 20 * manner for identifying or failing to identify any or all such 21 * third party intellectual property rights. 22 * 23 * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED 24 * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM, 25 * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA, 26 * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML 27 * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING 28 * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION 29 * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF 30 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT 31 * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO., 32 * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY 33 * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF 34 * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF 35 * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL, 36 * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH 37 * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED 38 * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE. 39 * 40 * The above notice and this paragraph must be included on all copies 41 * of this document that are made. 42 * 43 */ 44 45 46/** 47 * Isolate here the differences between ANSI string and memory functions and 48 * Palm string and memory functions. Note the sml tree contains similar 49 * mappings, but we avoid those for two reasons: 50 * 51 * 1. They are all implemented as functions, which makes calling them less 52 * efficient, especially on the Palm. Also, if they are implemented as 53 * functions, then the xpt DLL and the DLLs of all transport 54 * implementations must be linked to the sml DLL, which seems unnecessary. 55 * 56 * 2. Even on the Palm, the libstr.h and libmem.h header files include ANSI C 57 * header files like string.h and stdlib.h. These shouldn't be included 58 * on the Palm, because with some compilers, the introduced typedefs 59 * conflict with typedefs from the Palm SDK, causing compilation errors. 60 * 61 * We start the names of these functions with a different prefix so they are 62 * not confused with functions of the official xpt interface. We use "xpp" 63 * here instead of "xpt". 64 */ 65 66#ifndef XPTPORT_H 67#define XPTPORT_H 68 69#include <xptdef.h> 70 71/* 72 * If we neglect some of the return values, most of the functions have simple 73 * mappings. 74 */ 75#ifdef __PALM_OS__ 76 77 /* Palm mappings */ 78 79 #include <StringMgr.h> 80 #include <MemoryMgr.h> 81 82 #define xppStrcpy(target, source) StrCopy(target, source) 83 #define xppStrncpy(target, source, cnt) StrNCopy(target, source, cnt) 84 #define xppStrcat(target, source) StrCat(target, source) 85 #define xppStrncat(target, source, cnt) StrNCat(target, source, cnt) 86 #define xppStrcmp(first, second) StrCompare(first, second) 87 #define xppStrncmp(first, second, cnt) StrNCompare(first, second, cnt) 88 #define xppStrchr(string, c) StrChr(string, c) 89 #define xppStrstr(string, substr) StrStr(string, substr) 90 #define xppStrlen(string) StrLen(string) 91 #define xppAtoi(string) StrAToI(string) 92 93 #define xppMemset(s, c, n) MemSet(s, n, c) 94 #define xppMemcpy(target, source, cnt) MemMove(target, source, cnt) 95 #define xppMemmove(target, source, cnt) MemMove(target, source, cnt) 96 #define xppMemcmp(target, source, cnt) MemCmp(target, source, cnt) 97 #define xppMalloc(size) MemPtrNew(size) 98 XPTDECLEXP1 void * XPTAPI xppRealloc(void *ptr, size_t size) XPT_SECTION; 99 #define xppFree(ptr) MemPtrFree(ptr) 100 101 #define xppStricmp(first, second) StrCaselessCompare(first, second) 102 #define xppMemicmp(first, second, cnt) StrNCaselessCompare(first, second, cnt) 103 104#endif 105#if !defined(__EPOC_OS__) && !defined(__PALM_OS__) 106 107 /* ANSI C mappings */ 108 109 #include <string.h> 110 #include <stdlib.h> 111 112 #define xppStrcpy(target, source) strcpy(target, source) 113 #define xppStrncpy(target, source, cnt) strncpy(target, source, cnt) 114 #define xppStrcat(target, source) strcat(target, source) 115 #define xppStrncat(target, source, cnt) strncat(target, source, cnt) 116 #define xppStrcmp(first, second) strcmp(first, second) 117 #define xppStrncmp(first, second, cnt) strncmp(first, second, cnt) 118 #define xppStrchr(string, c) strchr(string, c) 119 #define xppStrstr(string, substr) strstr(string, substr) 120 #define xppStrlen(string) strlen(string) 121 #define xppAtoi(string) atoi(string) 122 123 #define xppMemset(s, c, n) memset(s, c, n) 124 #define xppMemcpy(target, source, cnt) memcpy(target, source, cnt) 125 #define xppMemmove(target, source, cnt) memmove(target, source, cnt) 126 #define xppMemcmp(target, source, cnt) memcmp(target, source, cnt) 127 #define xppMalloc(size) malloc(size) 128 #define xppRealloc(ptr, size) realloc(ptr, size) 129 #define xppFree(ptr) free(ptr) 130 131 /* These aren't ANSI C functions, but they're pretty common */ 132 133 #ifdef _WIN32 134 #define xppStricmp(first, second) stricmp(first, second) 135 #endif 136 137 /* Most other systems call it strcasecmp */ 138 #ifndef xppStricmp 139 #define xppStricmp(first, second) strcasecmp(first, second) 140 #endif 141 142 #ifdef _WIN32 143 #define xppMemicmp(first, second, cnt) memicmp(first, second, cnt) 144 #endif 145 146 #ifndef xppMemicmp 147 #define xppMemicmp(first, second, cnt) strncasecmp(first, second, cnt) 148 #endif 149 150#endif 151 152#if defined(__EPOC_OS__) 153 154/* EPOC mappings */ 155 156#include <string.h> 157#include <stdlib.h> 158 159#define xppStrcpy(target, source) strcpy(target, source) 160#define xppStrncpy(target, source, cnt) strncpy(target, source, cnt) 161#define xppStrcat(target, source) strcat(target, source) 162#define xppStrncat(target, source, cnt) strncat(target, source, cnt) 163#define xppStrcmp(first, second) strcmp(first, second) 164#define xppStrncmp(first, second, cnt) strncmp(first, second, cnt) 165#define xppStrchr(string, c) strchr(string, c) 166#define xppStrstr(string, substr) strstr(string, substr) 167#define xppStrlen(string) strlen(string) 168#define xppAtoi(string) atoi(string) 169 170#define xppMemset(s, c, n) memset(s, c, n) 171#define xppMemcpy(target, source, cnt) memcpy(target, source, cnt) 172#define xppMemmove(target, source, cnt) memmove(target, source, cnt) 173#define xppMemcmp(target, source, cnt) memcmp(target, source, cnt) 174#define xppMalloc(size) malloc(size) 175#define xppRealloc(ptr, size) realloc(ptr, size) 176#define xppFree(ptr) free(ptr) 177 178#define xppStricmp(first, second) strcasecmp(first, second) 179#define xppMemicmp(first, second, cnt) strncasecmp(first, second, cnt) 180 181#endif 182 183#endif 184