/[rdesktop]/sourceforge.net/trunk/rdesktop/rdp.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /sourceforge.net/trunk/rdesktop/rdp.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 858 by stargo, Sun Mar 13 13:58:23 2005 UTC revision 863 by stargo, Mon Mar 14 17:47:46 2005 UTC
# Line 156  rdp_out_unistr(STREAM s, char *string, i Line 156  rdp_out_unistr(STREAM s, char *string, i
156  {  {
157  #ifdef HAVE_ICONV  #ifdef HAVE_ICONV
158          size_t ibl = strlen(string), obl = len + 2;          size_t ibl = strlen(string), obl = len + 2;
159          static iconv_t iconv_h = (iconv_t)-1;          static iconv_t iconv_h = (iconv_t) - 1;
160          char   *pin = string, *pout;          char *pin = string, *pout = s->p;
 #ifdef B_ENDIAN  
         char ss[4096];  // FIXME: global MAX_BUF_SIZE macro need  
   
         pout = ss;  
 #else  
         pout = s->p;  
 #endif  
161    
162          memset(pout, 0, len + 4);          memset(pout, 0, len + 4);
163    
164          if (iconv_h == (iconv_t)-1)          if (iconv_h == (iconv_t) - 1)
165          {          {
166                  size_t i = 1, o = 4;                  size_t i = 1, o = 4;
167                  if ((iconv_h = iconv_open(WINDOWS_CODEPAGE, g_codepage)) == (iconv_t)-1)                  if ((iconv_h = iconv_open(WINDOWS_CODEPAGE, g_codepage)) == (iconv_t) - 1)
168                  {                  {
169                          printf("rdp_out_unistr: iconv_open[%s -> %s] fail %d\n",                          printf("rdp_out_unistr: iconv_open[%s -> %s] fail %d\n",
170                                  g_codepage, WINDOWS_CODEPAGE, (int)iconv_h);                                 g_codepage, WINDOWS_CODEPAGE, (int) iconv_h);
171                          return;                          return;
172                  }                  }
173                  if (iconv(iconv_h, (ICONV_CONST char**)&pin, &i, &pout, &o) == (size_t)-1)                  if (iconv(iconv_h, (ICONV_CONST char **) &pin, &i, &pout, &o) == (size_t) - 1)
174                  {                  {
175                          iconv_close(iconv_h);                          iconv_close(iconv_h);
176                          iconv_h = (iconv_t)-1;                          iconv_h = (iconv_t) - 1;
177                          printf("rdp_out_unistr: iconv(1) fail, errno %d\n", errno);                          printf("rdp_out_unistr: iconv(1) fail, errno %d\n", errno);
178                          return;                          return;
179                  }                  }
180                  pin = string; pout = s->p;                  pin = string;
181                    pout = (char *) s->p;
182          }          }
183    
184          if (iconv(iconv_h, (ICONV_CONST char**)&pin, &ibl, &pout, &obl) == (size_t)-1)          if (iconv(iconv_h, (ICONV_CONST char **) &pin, &ibl, &pout, &obl) == (size_t) - 1)
185          {          {
186                  iconv_close(iconv_h);                  iconv_close(iconv_h);
187                  iconv_h = (iconv_t)-1;                  iconv_h = (iconv_t) - 1;
188                  printf("rdp_out_unistr: iconv(2) fail, errno %d\n", errno);                  printf("rdp_out_unistr: iconv(2) fail, errno %d\n", errno);
189                  return;                  return;
190          }          }
191    
 #ifdef B_ENDIAN  
         swab(ss, s->p, len + 4);  
 #endif  
   
192          s->p += len + 2;          s->p += len + 2;
193    
194  #else /*HAVE_ICONV undef*/  #else /* HAVE_ICONV undef */
195          int i = 0, j = 0;          int i = 0, j = 0;
196    
197          len += 2;          len += 2;
# Line 211  rdp_out_unistr(STREAM s, char *string, i Line 201  rdp_out_unistr(STREAM s, char *string, i
201                  s->p[i++] = string[j++];                  s->p[i++] = string[j++];
202                  s->p[i++] = 0;                  s->p[i++] = 0;
203          }          }
204            
205          s->p += len;          s->p += len;
206  #endif  #endif
207  }  }
# Line 225  rdp_in_unistr(STREAM s, char *string, in Line 215  rdp_in_unistr(STREAM s, char *string, in
215  {  {
216  #ifdef HAVE_ICONV  #ifdef HAVE_ICONV
217          size_t ibl = uni_len, obl = uni_len;          size_t ibl = uni_len, obl = uni_len;
218          char *pin, *pout = string;          char *pin = s->p, *pout = string;
219          static iconv_t iconv_h = (iconv_t)-1;          static iconv_t iconv_h = (iconv_t) - 1;
 #ifdef B_ENDIAN  
         char ss[4096];  // FIXME: global MAX_BUF_SIZE macro need  
   
         swab(s->p, ss, uni_len);  
         pin = ss;  
 #else  
         pin = s->p;  
 #endif  
220    
221          if (iconv_h == (iconv_t)-1)          if (iconv_h == (iconv_t) - 1)
222          {          {
223                  if ((iconv_h = iconv_open(g_codepage, WINDOWS_CODEPAGE)) == (iconv_t)-1)                  if ((iconv_h = iconv_open(g_codepage, WINDOWS_CODEPAGE)) == (iconv_t) - 1)
224                  {                  {
225                          printf("rdp_in_unistr: iconv_open[%s -> %s] fail %d\n",                          printf("rdp_in_unistr: iconv_open[%s -> %s] fail %d\n",
226                                  WINDOWS_CODEPAGE, g_codepage, (int)iconv_h);                                 WINDOWS_CODEPAGE, g_codepage, (int) iconv_h);
227                          return 0;                          return 0;
228                  }                  }
229          }          }
230    
231          if (iconv(iconv_h, (ICONV_CONST char**)&pin, &ibl, &pout, &obl) == (size_t)-1)          if (iconv(iconv_h, (ICONV_CONST char **) &pin, &ibl, &pout, &obl) == (size_t) - 1)
232          {          {
233                  iconv_close(iconv_h);                  iconv_close(iconv_h);
234                  iconv_h = (iconv_t)-1;                  iconv_h = (iconv_t) - 1;
235                  printf("rdp_in_unistr: iconv fail, errno %d\n", errno);                  printf("rdp_in_unistr: iconv fail, errno %d\n", errno);
236                  return 0;                  return 0;
237          }          }

Legend:
Removed from v.858  
changed lines
  Added in v.863

  ViewVC Help
Powered by ViewVC 1.1.26