Changeset 208
- Timestamp:
- 06/14/08 20:45:38 (5 months ago)
- Location:
- trunk
- Files:
-
- 2 added
- 4 modified
-
configure.in (modified) (1 diff)
-
obexftp/Makefile.am (modified) (1 diff)
-
obexftp/cache.c (modified) (4 diffs)
-
obexftp/object.c (modified) (7 diffs)
-
obexftp/unicode.c (added)
-
obexftp/unicode.h (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/configure.in
r205 r208 32 32 33 33 AM_ICONV 34 AC_CHECK_HEADERS([langinfo.h]) 34 35 dnl IRDA_CHECK 35 36 BLUETOOTH_CHECK -
trunk/obexftp/Makefile.am
r193 r208 12 12 cache.c cache.h \ 13 13 uuid.h obexftp.h \ 14 unicode.c unicode.h \ 14 15 bt_kit.c bt_kit.h 15 16 -
trunk/obexftp/cache.c
r192 r208 37 37 #endif 38 38 39 #ifdef HAVE_ICONV40 #include <iconv.h>41 #include <locale.h>42 #include <langinfo.h>43 #endif44 45 39 #include <openobex/obex.h> 46 40 … … 48 42 #include "client.h" 49 43 #include "object.h" 44 #include "unicode.h" 50 45 #include "cache.h" 51 46 … … 261 256 262 257 stat_entry_t *dir_start, *dir; 263 int i; 264 #ifdef HAVE_ICONV 265 iconv_t utf8; 266 char *xml_latin1, *xml_end; 267 size_t ni, no, nrc; 268 int ret; 269 #endif 258 int ret, n, i; 259 char *xml_conv; 270 260 271 261 if (!xml) 272 262 return NULL; 273 #ifdef HAVE_ICONV 274 setlocale(LC_CTYPE, ""); 275 DEBUG(2, "Iconv to %s\n", nl_langinfo(CODESET)); 276 utf8 = iconv_open (nl_langinfo(CODESET), "UTF-8"); 277 ni = strlen(xml); 278 no = ni; 279 xml_latin1 = xml_end = malloc(no+1); 280 p = xml; 281 if (xml_latin1) { 282 nrc = iconv (utf8, (char* *)&p, &ni, &xml_end, &no); 283 ret = iconv_close (utf8); 284 if (nrc != (size_t)(-1)) { 285 xml = xml_latin1; 286 } else { 287 DEBUG(1, "Iconv conversion error: '%s'\n", p); 288 } 289 } 290 #endif 263 n = strlen(xml) + 1; 264 xml_conv = malloc(n); 265 ret = Utf8ToChar(xml_conv, xml, n); 266 if (ret > 0) { 267 xml = xml_conv; 268 } else { 269 DEBUG(1, "UTF-8 conversion error\n"); 270 } 291 271 292 272 DEBUG(4, "Converted cache xml: '%s'\n", xml); … … 343 323 dir->name[0] = '\0'; 344 324 345 #ifdef HAVE_ICONV 346 if (xml_latin1) 347 free (xml_latin1); 348 #endif 325 if (xml_conv) 326 free (xml_conv); 327 349 328 return dir_start; 350 329 } -
trunk/obexftp/object.c
r186 r208 4 4 ObexFTP library - language bindings for OBEX file transfer. 5 5 6 Copyright (c) 2002 Christian W. Zuckschwerdt <zany@triq.net>6 Copyright (c) 2002-2007 Christian W. Zuckschwerdt <zany@triq.net> 7 7 8 8 ObexFTP is free software; you can redistribute it and/or modify … … 24 24 #include <string.h> 25 25 26 #include "unicode.h" 26 27 #include "object.h" 28 27 29 28 30 /** … … 99 101 } 100 102 101 ucname_len = OBEX_CharToUnicode(ucname, (uint8_t*)name, ucname_len);103 ucname_len = CharToUnicode(ucname, (uint8_t*)name, ucname_len); 102 104 103 105 hv.bs = (const uint8_t *) ucname; … … 159 161 160 162 *appstr_p++ = 0x35; 161 ucname_len = OBEX_CharToUnicode(appstr_p + 1, (uint8_t*)from, strlen(from)*2 + 2);163 ucname_len = CharToUnicode(appstr_p + 1, (uint8_t*)from, strlen(from)*2 + 2); 162 164 *appstr_p = ucname_len - 2; /* no trailing 0 */ 163 165 appstr_p += ucname_len - 1; 164 166 165 167 *appstr_p++ = 0x36; 166 ucname_len = OBEX_CharToUnicode(appstr_p + 1, (uint8_t*)to, strlen(to)*2 + 2);168 ucname_len = CharToUnicode(appstr_p + 1, (uint8_t*)to, strlen(to)*2 + 2); 167 169 *appstr_p = ucname_len - 2; /* no trailing 0 */ 168 170 … … 211 213 } 212 214 213 ucname_len = OBEX_CharToUnicode(ucname, (uint8_t*)name, ucname_len);215 ucname_len = CharToUnicode(ucname, (uint8_t*)name, ucname_len); 214 216 215 217 hv.bs = (const uint8_t *) ucname; … … 264 266 return NULL; 265 267 } 266 ucname_len = OBEX_CharToUnicode(ucname, (uint8_t*)name, ucname_len);268 ucname_len = CharToUnicode(ucname, (uint8_t*)name, ucname_len); 267 269 268 270 /* apparently the empty name header is meant to be really empty... */ … … 318 320 } 319 321 320 ucname_len = OBEX_CharToUnicode(ucname, (uint8_t*)name, ucname_len);322 ucname_len = CharToUnicode(ucname, (uint8_t*)name, ucname_len); 321 323 322 324 hv.bs = (const uint8_t *) ucname;
