/[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 855 by stargo, Sun Mar 13 13:18:48 2005 UTC revision 860 by stargo, Sun Mar 13 17:36:15 2005 UTC
# Line 23  Line 23 
23  #include <unistd.h>  #include <unistd.h>
24  #include "rdesktop.h"  #include "rdesktop.h"
25    
26    #ifdef HAVE_ICONV
27  #ifdef HAVE_ICONV_H  #ifdef HAVE_ICONV_H
28  #include <iconv.h>  #include <iconv.h>
29  #endif  #endif
30    
31    #ifndef ICONV_CONST
32    #define ICONV_CONST ""
33    #endif
34    #endif
35    
36  extern uint16 g_mcs_userid;  extern uint16 g_mcs_userid;
37  extern char g_username[64];  extern char g_username[64];
38  extern char g_codepage[16];  extern char g_codepage[16];
# Line 148  rdp_send_data(STREAM s, uint8 data_pdu_t Line 154  rdp_send_data(STREAM s, uint8 data_pdu_t
154  void  void
155  rdp_out_unistr(STREAM s, char *string, int len)  rdp_out_unistr(STREAM s, char *string, int len)
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;
161  #ifdef  B_ENDIAN  #ifdef B_ENDIAN
162          char ss[4096];  // FIXME: global MAX_BUF_SIZE macro need          char ss[4096];  // FIXME: global MAX_BUF_SIZE macro need
163    
164          pout = ss;          pout = ss;
# Line 171  rdp_out_unistr(STREAM s, char *string, i Line 177  rdp_out_unistr(STREAM s, char *string, i
177                                  g_codepage, WINDOWS_CODEPAGE, (int)iconv_h);                                  g_codepage, WINDOWS_CODEPAGE, (int)iconv_h);
178                          return;                          return;
179                  }                  }
180                  if (iconv(iconv_h, (const char**)&pin, &i, &pout, &o) == (size_t)-1)                  if (iconv(iconv_h, (ICONV_CONST char**)&pin, &i, &pout, &o) == (size_t)-1)
181                  {                  {
182                          iconv_close(iconv_h);                          iconv_close(iconv_h);
183                          iconv_h = (iconv_t)-1;                          iconv_h = (iconv_t)-1;
184                          printf("rdp_out_unistr: iconv(1) fail, errno %d\n", errno);                          printf("rdp_out_unistr: iconv(1) fail, errno %d\n", errno);
185                          return;                          return;
186                  }                  }
187                  pin = string; pout = s->p;                  pin = string;
188                    pout = (char*)s->p;
189          }          }
190    
191          if (iconv(iconv_h, (const char**)&pin, &ibl, &pout, &obl) == (size_t)-1)          if (iconv(iconv_h, (ICONV_CONST char**)&pin, &ibl, &pout, &obl) == (size_t)-1)
192          {          {
193                  iconv_close(iconv_h);                  iconv_close(iconv_h);
194                  iconv_h = (iconv_t)-1;                  iconv_h = (iconv_t)-1;
# Line 189  rdp_out_unistr(STREAM s, char *string, i Line 196  rdp_out_unistr(STREAM s, char *string, i
196                  return;                  return;
197          }          }
198    
199  #ifdef  B_ENDIAN  #ifdef B_ENDIAN
200          swab(ss, s->p, len + 4);          swab(ss, (char*)s->p, len + 4);
201  #endif  #endif
202    
203          s->p += len + 2;          s->p += len + 2;
# Line 217  rdp_out_unistr(STREAM s, char *string, i Line 224  rdp_out_unistr(STREAM s, char *string, i
224  int  int
225  rdp_in_unistr(STREAM s, char *string, int uni_len)  rdp_in_unistr(STREAM s, char *string, int uni_len)
226  {  {
227  #ifdef  HAVE_ICONV  #ifdef HAVE_ICONV
228          size_t ibl = uni_len, obl = uni_len;          size_t ibl = uni_len, obl = uni_len;
229          char *pin, *pout = string;          char *pin, *pout = string;
230          static iconv_t iconv_h = (iconv_t)-1;          static iconv_t iconv_h = (iconv_t)-1;
231  #ifdef  B_ENDIAN  #ifdef B_ENDIAN
232          char ss[4096];  // FIXME: global MAX_BUF_SIZE macro need          char ss[4096];  // FIXME: global MAX_BUF_SIZE macro need
233    
234          swab(s->p, ss, uni_len);          swab((char*)s->p, ss, uni_len);
235          pin = ss;          pin = ss;
236  #else  #else
237          pin = s->p;          pin = s->p;
# Line 240  rdp_in_unistr(STREAM s, char *string, in Line 247  rdp_in_unistr(STREAM s, char *string, in
247                  }                  }
248          }          }
249    
250          if (iconv(iconv_h, (const char**)&pin, &ibl, &pout, &obl) == (size_t)-1)          if (iconv(iconv_h, (ICONV_CONST char**)&pin, &ibl, &pout, &obl) == (size_t)-1)
251          {          {
252                  iconv_close(iconv_h);                  iconv_close(iconv_h);
253                  iconv_h = (iconv_t)-1;                  iconv_h = (iconv_t)-1;

Legend:
Removed from v.855  
changed lines
  Added in v.860

  ViewVC Help
Powered by ViewVC 1.1.26