sobexsrv-1.0.1-openobex16.patch 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. --- sobexsrv-1.0.1/src/obexsrv.c.orig 2016-06-13 01:59:28.000000000 +0300
  2. +++ sobexsrv-1.0.1/src/obexsrv.c 2016-06-13 12:20:15.501101147 +0300
  3. @@ -32,6 +32,10 @@
  4. #include <langinfo.h>
  5. #include <assert.h>
  6. +#if ((OPENOBEX_VERSION_MAJOR==1) && (OPENOBEX_VERSION_MINOR>=6))
  7. +#include <string.h>
  8. +#endif
  9. +
  10. #include "obexsrv.h"
  11. #include "util.h"
  12. #include "sdp.h"
  13. @@ -46,7 +50,8 @@
  14. void UnicodeToChar(uint8_t *c, const uint8_t *uc, int size)
  15. {
  16. - iconv_t dsc = iconv_open(nl_langinfo(CODESET),"UTF16BE");
  17. + char *lang = nl_langinfo(CODESET);
  18. + iconv_t dsc = iconv_open(lang,"UTF16BE");
  19. size_t isiz,osiz;
  20. char *ip = (char*)uc;
  21. char *op = (char*)c;
  22. @@ -54,7 +59,25 @@
  23. if (iconv(dsc,&ip,&isiz,&op,&osiz) == -1) {
  24. debug_printf("iconv: error %s\n", strerror(errno));
  25. +#if ((OPENOBEX_VERSION_MAJOR==1) && (OPENOBEX_VERSION_MINOR>=6))
  26. + // try to convert ignoring errors
  27. + iconv_close(dsc);
  28. + debug_printf("iconv: characters that cannot be converted will be discarded\n");
  29. +
  30. + // append "//IGNORE"
  31. + const char *const suf = "//IGNORE";
  32. + size_t len = strlen(lang);
  33. + char *cd = malloc(len + 9);
  34. + memcpy(cd, lang, len);
  35. + memcpy(cd+len, suf, 8);
  36. + cd[len+8] = '\0';
  37. +
  38. + dsc = iconv_open(cd,"UTF16BE");
  39. + iconv(dsc,&ip,&isiz,&op,&osiz);
  40. + free(cd);
  41. +#else
  42. OBEX_UnicodeToChar(c,uc,size);
  43. +#endif
  44. }
  45. iconv_close(dsc);
  46. }