diff --git a/openobex-1.3-utf.patch b/openobex-1.3-utf.patch new file mode 100644 index 0000000..105b8c2 --- /dev/null +++ b/openobex-1.3-utf.patch @@ -0,0 +1,103 @@ +--- openobex-1.3/lib/obex.c 2008-06-02 15:53:56.000000000 +0200 ++++ openobex-1.3/lib/obex.c.utf 2008-06-02 15:54:37.000000000 +0200 +@@ -65,6 +65,9 @@ + typedef char *bdaddr_t; + #endif + ++#include ++#include ++ + void OBEX_FreeInterfaces(obex_t *self); + + /** +@@ -828,21 +831,9 @@ + return 0; + } + +-/** +- * OBEX_CharToUnicode - Simple char to unicode function. +- * @uc: Destination (unicode) +- * @c: Source (char) +- * @size: Length of destination buffer, at least twice the size of source +- * +- * Buffers may not overlap. Returns -1 on error. +- */ +-int OBEX_CharToUnicode(uint8_t *uc, const uint8_t *c, int size) ++static int obex_ascii_to_unicode(uint8_t *uc, const uint8_t *c, int size) + { + int len, n; +- DEBUG(4, "\n"); +- +- obex_return_val_if_fail(uc != NULL, -1); +- obex_return_val_if_fail(c != NULL, -1); + + len = n = strlen((char *) c); + obex_return_val_if_fail(n*2+2 <= size, -1); +@@ -858,6 +849,67 @@ + return (len*2)+2 ; + } + ++static int obex_char_to_unicode(const char * iconv_encoding, uint8_t *uc, const uint8_t *c, int size) ++{ ++ iconv_t hConv; ++ int len = -1; ++ ++ if ((iconv_t)-1 != (hConv = iconv_open("UCS-2BE", iconv_encoding))) { ++ char * inBuffer = (char *)c; ++ char * outBuffer = (char *)uc; ++ size_t inBytes = strlen(inBuffer); ++ size_t outBytes = size; ++ ++ if ((size_t)-1 != iconv(hConv, &inBuffer, &inBytes, &outBuffer, &outBytes)) { ++ len = size - outBytes; ++ uc[len] = 0; ++ uc[len + 1] = 0; ++ len += 2; ++ } ++ ++ iconv_close(hConv); ++ } ++ return len; ++} ++ ++/** ++ * OBEX_CharToUnicode - Simple char to unicode function. ++ * @uc: Destination (unicode) ++ * @c: Source (char) ++ * @size: Length of destination buffer, at least twice the size of source ++ * ++ * Buffers may not overlap. Returns -1 on error. ++ */ ++int OBEX_CharToUnicode(uint8_t *uc, const uint8_t *c, int size) ++{ ++ DEBUG(4, "\n"); ++ int len; ++ //@@@@@ ++ char const *locale = NULL; ++ obex_return_val_if_fail(uc != NULL, -1); ++ obex_return_val_if_fail(c != NULL, -1); ++ ++ /* get current locale */ ++ locale = setlocale(LC_CTYPE, ""); ++ obex_return_val_if_fail(locale != NULL, -1); ++ ++ if (strcmp(locale, "ASCII") == 0 || ++ strcmp(locale, "C") == 0 || ++ strcmp(locale, "POSIX") == 0 || ++ strcmp(locale, "US-ASCII") == 0) ++ locale = "en_US.US-ASCII"; ++ ++ locale = strchr(locale, '.'); ++ obex_return_val_if_fail(locale != NULL, -1); ++ ++ locale ++; ++ obex_return_val_if_fail(locale[0] != '\0', -1); ++ ++ if ((len = obex_char_to_unicode("UTF-8", uc, c, size)) >= 0) return len; ++ if ((len = obex_char_to_unicode("KOI8-U", uc, c, size)) >= 0) return len; ++ return obex_ascii_to_unicode(uc, c, size); ++} ++ + /** + * OBEX_ResponseToString - Return a human understandable string from a response-code. + * @rsp: Response code. diff --git a/openobex.spec b/openobex.spec index 4dc9ee6..2aa1dc0 100644 --- a/openobex.spec +++ b/openobex.spec @@ -1,7 +1,7 @@ Summary: Library for using OBEX Name: openobex Version: 1.3 -Release: 11%{?dist} +Release: 12%{?dist} License: GPLv2+ Group: System Environment/Libraries URL: http://openobex.sourceforge.net @@ -10,6 +10,7 @@ Patch: openobex-apps-flush.patch Patch1: openobex-1.3-push.patch Patch2: openobex-1.3-autoconf.patch Patch3: openobex-1.3-ipv6.patch +Patch4: openobex-1.3-utf.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: autoconf >= 2.57, bluez-libs-devel, sed, libusb-devel @@ -45,6 +46,7 @@ calendar entries (vCal) and business cards (vCard) using the OBEX protocol. %patch1 -p1 -b .push %patch2 -p1 -b .ipv6 %patch3 -p1 -b .autoconf +%patch4 -p1 -b .utf autoreconf --install --force %build @@ -89,6 +91,9 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Fri Jun 6 2008 Jiri Moskovcak - 1.3.12 +- improved utf support + * Tue Feb 19 2008 Fedora Release Engineering - 1.3-11 - Autorebuild for GCC 4.3