Changeset 62 for pjproject/trunk
- Timestamp:
- Nov 20, 2005 7:55:42 PM (19 years ago)
- Location:
- pjproject/trunk/pjlib
- Files:
-
- 1 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib/build/pjlib.dsp
r36 r62 179 179 # Begin Source File 180 180 181 SOURCE=..\src\pj\ctype.c 182 # End Source File 183 # Begin Source File 184 181 185 SOURCE=..\src\pj\equeue_winnt.c 182 186 # End Source File … … 235 239 236 240 SOURCE=..\src\pj\ioqueue_winnt.c 237 238 !IF "$(CFG)" == "pjlib - Win32 Release"239 240 !ELSEIF "$(CFG)" == "pjlib - Win32 Debug"241 242 !ENDIF243 244 241 # End Source File 245 242 # Begin Source File -
pjproject/trunk/pjlib/include/pj/compat/string.h
r51 r62 45 45 46 46 #define pj_native_strcmp strcmp 47 #define pj_native_strncmp strncmp 47 48 #define pj_native_strlen strlen 48 49 #define pj_native_strcpy strcpy … … 50 51 #define pj_native_strchr strchr 51 52 #define pj_native_strcasecmp strcasecmp 53 #define pj_native_stricmp strcasecmp 52 54 #define pj_native_strncasecmp strncasecmp 53 55 #define pj_native_strnicmp strncasecmp 54 56 55 57 #endif /* __PJ_COMPAT_STRING_H__ */ -
pjproject/trunk/pjlib/include/pj/ctype.h
r51 r62 25 25 */ 26 26 27 #include <pj/types.h> 27 28 #include <pj/compat/ctype.h> 29 30 PJ_BEGIN_DECL 28 31 29 32 /** … … 100 103 101 104 /** 102 * Returns a non-zero value if c is a particular representation of103 * an hexadecimal digit character.104 * @param c The integer character to test.105 * @return Non-zero value if c is a particular representation of106 * an hexadecimal digit character.107 */108 PJ_INLINE(int) pj_isxdigit(int c){ return isxdigit(c); }109 110 /**111 105 * Returns a non-zero value if c is a either a space (' ') or horizontal 112 106 * tab ('\\t') character. … … 131 125 PJ_INLINE(int) pj_toupper(int c) { return toupper(c); } 132 126 127 /** 128 * Returns a non-zero value if c is a particular representation of 129 * an hexadecimal digit character. 130 * @param c The integer character to test. 131 * @return Non-zero value if c is a particular representation of 132 * an hexadecimal digit character. 133 */ 134 PJ_INLINE(int) pj_isxdigit(int c){ return isxdigit(c); } 135 136 /** 137 * Array of hex digits, in lowerspace. 138 */ 139 extern char pj_hex_digits[]; 140 141 /** 142 * Convert a value to hex representation. 143 * @param value Integral value to convert. 144 * @param p Buffer to hold the hex representation, which must be 145 * at least two bytes length. 146 */ 147 PJ_INLINE(void) pj_val_to_hex_digit(unsigned value, char *p) 148 { 149 *p++ = pj_hex_digits[ (value & 0xF0) >> 4 ]; 150 *p = pj_hex_digits[ (value & 0x0F) ]; 151 } 152 153 /** 154 * Convert hex digit c to integral value. 155 * @param c The hex digit character. 156 * @return The integral value between 0 and 15. 157 */ 158 PJ_INLINE(unsigned) pj_hex_digit_to_val(unsigned c) 159 { 160 if (c <= '9') 161 return (c-'0') & 0x0F; 162 else if (c <= 'F') 163 return (c-'A'+10) & 0x0F; 164 else 165 return (c-'a'+10) & 0x0F; 166 } 167 133 168 /** @} */ 169 170 PJ_END_DECL 134 171 135 172 #endif /* __PJ_CTYPE_H__ */ -
pjproject/trunk/pjlib/include/pj/errno.h
r51 r62 165 165 * Unknown error has been reported. 166 166 */ 167 #define PJ_EUNKNOWN (PJ_ERRNO_START_STATUS + 1) 167 #define PJ_EUNKNOWN (PJ_ERRNO_START_STATUS + 1) /* 70001 */ 168 168 /** 169 169 * @hideinitializer 170 170 * The operation is pending and will be completed later. 171 171 */ 172 #define PJ_EPENDING (PJ_ERRNO_START_STATUS + 2) 172 #define PJ_EPENDING (PJ_ERRNO_START_STATUS + 2) /* 70002 */ 173 173 /** 174 174 * @hideinitializer 175 175 * Too many connecting sockets. 176 176 */ 177 #define PJ_ETOOMANYCONN (PJ_ERRNO_START_STATUS + 3) 177 #define PJ_ETOOMANYCONN (PJ_ERRNO_START_STATUS + 3) /* 70003 */ 178 178 /** 179 179 * @hideinitializer 180 180 * Invalid argument. 181 181 */ 182 #define PJ_EINVAL (PJ_ERRNO_START_STATUS + 4) 182 #define PJ_EINVAL (PJ_ERRNO_START_STATUS + 4) /* 70004 */ 183 183 /** 184 184 * @hideinitializer 185 185 * Name too long (eg. hostname too long). 186 186 */ 187 #define PJ_ENAMETOOLONG (PJ_ERRNO_START_STATUS + 5) 187 #define PJ_ENAMETOOLONG (PJ_ERRNO_START_STATUS + 5) /* 70005 */ 188 188 /** 189 189 * @hideinitializer 190 190 * Not found. 191 191 */ 192 #define PJ_ENOTFOUND (PJ_ERRNO_START_STATUS + 6) 192 #define PJ_ENOTFOUND (PJ_ERRNO_START_STATUS + 6) /* 70006 */ 193 193 /** 194 194 * @hideinitializer 195 195 * Not enough memory. 196 196 */ 197 #define PJ_ENOMEM (PJ_ERRNO_START_STATUS + 7) 197 #define PJ_ENOMEM (PJ_ERRNO_START_STATUS + 7) /* 70007 */ 198 198 /** 199 199 * @hideinitializer 200 200 * Bug detected! 201 201 */ 202 #define PJ_EBUG (PJ_ERRNO_START_STATUS + 8) 202 #define PJ_EBUG (PJ_ERRNO_START_STATUS + 8) /* 70008 */ 203 203 /** 204 204 * @hideinitializer 205 205 * Operation timed out. 206 206 */ 207 #define PJ_ETIMEDOUT (PJ_ERRNO_START_STATUS + 9) 207 #define PJ_ETIMEDOUT (PJ_ERRNO_START_STATUS + 9) /* 70009 */ 208 208 /** 209 209 * @hideinitializer 210 210 * Too many objects. 211 211 */ 212 #define PJ_ETOOMANY (PJ_ERRNO_START_STATUS + 10) 212 #define PJ_ETOOMANY (PJ_ERRNO_START_STATUS + 10)/* 70010 */ 213 213 /** 214 214 * @hideinitializer 215 215 * Object is busy. 216 216 */ 217 #define PJ_EBUSY (PJ_ERRNO_START_STATUS + 11) 217 #define PJ_EBUSY (PJ_ERRNO_START_STATUS + 11)/* 70011 */ 218 218 /** 219 219 * @hideinitializer 220 220 * The specified option is not supported. 221 221 */ 222 #define PJ_ENOTSUP (PJ_ERRNO_START_STATUS + 12) 222 #define PJ_ENOTSUP (PJ_ERRNO_START_STATUS + 12)/* 70012 */ 223 223 /** 224 224 * @hideinitializer 225 225 * Invalid operation. 226 226 */ 227 #define PJ_EINVALIDOP (PJ_ERRNO_START_STATUS + 13) 227 #define PJ_EINVALIDOP (PJ_ERRNO_START_STATUS + 13)/* 70013 */ 228 228 /** 229 229 * @hideinitializer 230 230 * Operation is cancelled. 231 231 */ 232 #define PJ_ECANCELLED (PJ_ERRNO_START_STATUS + 14) 232 #define PJ_ECANCELLED (PJ_ERRNO_START_STATUS + 14)/* 70014 */ 233 233 /** 234 234 * @hideinitializer 235 235 * Object already exists. 236 236 */ 237 #define PJ_EEXISTS (PJ_ERRNO_START_STATUS + 1 4)237 #define PJ_EEXISTS (PJ_ERRNO_START_STATUS + 15)/* 70015 */ 238 238 239 239 /** @} */ /* pj_errnum */ … … 255 255 /** 256 256 * PJ_ERRNO_START_STATUS is where PJLIB specific status codes start. 257 * Effectively the error in this class would be 70000 - 119000. 257 258 */ 258 259 #define PJ_ERRNO_START_STATUS (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE) … … 261 262 * PJ_ERRNO_START_SYS converts platform specific error codes into 262 263 * pj_status_t values. 264 * Effectively the error in this class would be 120000 - 169000. 263 265 */ 264 266 #define PJ_ERRNO_START_SYS (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE) … … 267 269 * PJ_ERRNO_START_USER are reserved for applications that use error 268 270 * codes along with PJLIB codes. 271 * Effectively the error in this class would be 170000 - 219000. 269 272 */ 270 273 #define PJ_ERRNO_START_USER (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE) -
pjproject/trunk/pjlib/include/pj/log.h
r51 r62 26 26 27 27 #include <pj/types.h> 28 28 #include <stdarg.h> 29 29 30 30 PJ_BEGIN_DECL … … 125 125 126 126 /** 127 * Write to log. 128 * 129 * @param sender Source of the message. 130 * @param level Verbosity level. 131 * @param format Format. 132 * @param marker Marker. 133 */ 134 PJ_DECL(void) pj_log(const char *sender, int level, 135 const char *format, va_list marker); 136 137 /** 127 138 * Change log output function. The front-end logging functions will call 128 139 * this function to write the actual message to the desired device. -
pjproject/trunk/pjlib/include/pj/string.h
r51 r62 175 175 176 176 /** 177 * Copy source string to destination up to the specified max length. 178 * 179 * @param dst The target string. 180 * @param src The source string. 181 * @param max Maximum characters to copy. 182 * 183 * @return the target string. 184 */ 185 PJ_IDECL(pj_str_t*) pj_strncpy(pj_str_t *dst, const pj_str_t *src, 186 pj_ssize_t max); 187 188 /** 189 * Copy source string to destination up to the specified max length, 190 * and NULL terminate the destination. If source string length is 191 * greater than or equal to max, then max-1 will be copied. 192 * 193 * @param dst The target string. 194 * @param src The source string. 195 * @param max Maximum characters to copy. 196 * 197 * @return the target string. 198 */ 199 PJ_IDECL(pj_str_t*) pj_strncpy_with_null(pj_str_t *dst, const pj_str_t *src, 200 pj_ssize_t max); 201 202 /** 177 203 * Duplicate string. 178 204 * … … 521 547 } 522 548 549 523 550 /** 524 551 * @} -
pjproject/trunk/pjlib/include/pj/string_i.h
r51 r62 22 22 pj_str_t dst; 23 23 dst.ptr = str; 24 dst.slen = str ? strlen(str) : 0;24 dst.slen = str ? pj_native_strlen(str) : 0; 25 25 return dst; 26 26 } … … 57 57 const char *src) 58 58 { 59 dst->slen = src ? strlen(src) : 0;59 dst->slen = src ? pj_native_strlen(src) : 0; 60 60 if (dst->slen) { 61 61 dst->ptr = (char*)pj_pool_alloc(pool, dst->slen); … … 92 92 PJ_IDEF(pj_str_t*) pj_strcpy2(pj_str_t *dst, const char *src) 93 93 { 94 dst->slen = src ? strlen(src) : 0;94 dst->slen = src ? pj_native_strlen(src) : 0; 95 95 if (dst->slen > 0) 96 96 pj_memcpy(dst->ptr, src, dst->slen); 97 97 return dst; 98 98 } 99 100 PJ_IDEF(pj_str_t*) pj_strncpy( pj_str_t *dst, const pj_str_t *src, 101 pj_ssize_t max) 102 { 103 if (max > src->slen) max = src->slen; 104 pj_memcpy(dst->ptr, src->ptr, max); 105 dst->slen = max; 106 return dst; 107 } 108 109 PJ_IDEF(pj_str_t*) pj_strncpy_with_null( pj_str_t *dst, const pj_str_t *src, 110 pj_ssize_t max) 111 { 112 if (max <= src->slen) 113 max = max-1; 114 else 115 max = src->slen; 116 117 pj_memcpy(dst->ptr, src->ptr, max); 118 dst->ptr[max] = '\0'; 119 dst->slen = max; 120 return dst; 121 } 122 99 123 100 124 PJ_IDEF(int) pj_strcmp( const pj_str_t *str1, const pj_str_t *str2) … … 105 129 if (diff) { 106 130 return (int)diff; 107 } else if (str1->ptr ) {108 return strncmp(str1->ptr, str2->ptr, str1->slen);131 } else if (str1->ptr && str1->slen) { 132 return pj_native_strncmp(str1->ptr, str2->ptr, str1->slen); 109 133 } else { 110 134 return 0; … … 115 139 pj_size_t len) 116 140 { 117 return (str1->ptr && str2->ptr) ? strncmp(str1->ptr, str2->ptr, len) : 118 (str1->ptr == str2->ptr ? 0 : 1); 141 return (str1->ptr && str2->ptr) ? 142 pj_native_strncmp(str1->ptr, str2->ptr, len) : 143 (str1->ptr == str2->ptr ? 0 : 1); 119 144 } 120 145 … … 122 147 pj_size_t len) 123 148 { 124 return (str1->ptr && str2) ? strncmp(str1->ptr, str2, len) :149 return (str1->ptr && str2) ? pj_native_strncmp(str1->ptr, str2, len) : 125 150 (str1->ptr==str2 ? 0 : 1); 126 151 } … … 139 164 return (int)diff; 140 165 } else { 141 return strnicmp(str1->ptr, str2->ptr, str1->slen);166 return pj_native_strnicmp(str1->ptr, str2->ptr, str1->slen); 142 167 } 143 168 } … … 145 170 PJ_IDEF(int) pj_stricmp2( const pj_str_t *str1, const char *str2) 146 171 { 147 return (str1->ptr && str2) ? strnicmp(str1->ptr, str2, str1->slen) : 148 (str1->ptr==str2 ? 0 : 1); 172 return (str1->ptr && str2) ? 173 pj_native_strnicmp(str1->ptr, str2, str1->slen) : 174 (str1->ptr==str2 ? 0 : 1); 149 175 } 150 176 … … 152 178 pj_size_t len) 153 179 { 154 return (str1->ptr && str2->ptr) ? strnicmp(str1->ptr, str2->ptr, len) : 155 (str1->ptr == str2->ptr ? 0 : 1); 180 return (str1->ptr && str2->ptr) ? 181 pj_native_strnicmp(str1->ptr, str2->ptr, len) : 182 (str1->ptr == str2->ptr ? 0 : 1); 156 183 } 157 184 … … 159 186 pj_size_t len) 160 187 { 161 return (str1->ptr && str2) ? strnicmp(str1->ptr, str2, len) : 162 (str1->ptr == str2 ? 0 : 1); 188 return (str1->ptr && str2) ? 189 pj_native_strnicmp(str1->ptr, str2, len) : 190 (str1->ptr == str2 ? 0 : 1); 163 191 } 164 192 -
pjproject/trunk/pjlib/src/pj/log.c
r51 r62 65 65 } 66 66 67 static void pj_log(const char *sender, int level,68 const char *format, va_list marker)67 PJ_DEF(void) pj_log( const char *sender, int level, 68 const char *format, va_list marker) 69 69 { 70 70 pj_time_val now; -
pjproject/trunk/pjlib/src/pj/os_core_win32.c
r51 r62 130 130 pj_status_t rc; 131 131 132 PJ_LOG(5, ("pj_init", "Initializing PJ Library.."));133 134 132 /* Init Winsock.. */ 135 133 if (WSAStartup(MAKEWORD(2,0), &wsa) != 0) { 136 PJ_LOG(1, ("pj_init", "Winsock initialization has returned an error"));137 134 return PJ_RETURN_OS_ERROR(WSAGetLastError()); 138 135 } … … 140 137 /* Init this thread's TLS. */ 141 138 if ((rc=pj_thread_init()) != PJ_SUCCESS) { 142 PJ_LOG(1, ("pj_init", "Thread initialization has returned an error"));143 139 return rc; 144 140 } -
pjproject/trunk/pjlib/src/pj/string.c
r51 r62 28 28 29 29 30 static char hex[] = {'0', '1', '2', '3', '4', '5', '6', '7',31 '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };32 33 30 PJ_DEF(pj_str_t*) pj_strltrim( pj_str_t *str ) 34 31 { … … 51 48 } 52 49 53 PJ_INLINE(void) pj_val_to_hex_digit(unsigned value, char *p)54 {55 *p++ = hex[ (value & 0xF0) >> 4 ];56 *p++ = hex[ (value & 0x0F) ];57 }58 59 50 PJ_DEF(char*) pj_create_random_string(char *str, pj_size_t len) 60 51 { … … 73 64 } 74 65 for (i=i * 8; i<len; ++i) { 75 *p++ = hex[ pj_rand() & 0x0F ];66 *p++ = pj_hex_digits[ pj_rand() & 0x0F ]; 76 67 } 77 68 return str; … … 130 121 } 131 122 123
Note: See TracChangeset
for help on using the changeset viewer.