/[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 863 by stargo, Mon Mar 14 17:47:46 2005 UTC revision 864 by stargo, Mon Mar 14 18:02:24 2005 UTC
# Line 59  extern RDPCOMP g_mppc_dict; Line 59  extern RDPCOMP g_mppc_dict;
59  static uint32 g_packetno;  static uint32 g_packetno;
60  #endif  #endif
61    
62    #ifdef HAVE_ICONV
63    static BOOL g_iconv_works = True;
64    #endif
65    
66  /* Receive an RDP packet */  /* Receive an RDP packet */
67  static STREAM  static STREAM
68  rdp_recv(uint8 * type)  rdp_recv(uint8 * type)
# Line 161  rdp_out_unistr(STREAM s, char *string, i Line 165  rdp_out_unistr(STREAM s, char *string, i
165    
166          memset(pout, 0, len + 4);          memset(pout, 0, len + 4);
167    
168          if (iconv_h == (iconv_t) - 1)          if (g_iconv_works)
169          {          {
170                  size_t i = 1, o = 4;                  if (iconv_h == (iconv_t) - 1)
                 if ((iconv_h = iconv_open(WINDOWS_CODEPAGE, g_codepage)) == (iconv_t) - 1)  
171                  {                  {
172                          printf("rdp_out_unistr: iconv_open[%s -> %s] fail %d\n",                          size_t i = 1, o = 4;
173                                 g_codepage, WINDOWS_CODEPAGE, (int) iconv_h);                          if ((iconv_h = iconv_open(WINDOWS_CODEPAGE, g_codepage)) == (iconv_t) - 1)
174                          return;                          {
175                                    warning("rdp_out_unistr: iconv_open[%s -> %s] fail %d\n",
176                                            g_codepage, WINDOWS_CODEPAGE, (int) iconv_h);
177    
178                                    g_iconv_works = False;
179                                    return (rdp_out_unistr(s, string, len));
180                            }
181                            if (iconv(iconv_h, (ICONV_CONST char **) &pin, &i, &pout, &o) ==
182                                (size_t) - 1)
183                            {
184                                    iconv_close(iconv_h);
185                                    iconv_h = (iconv_t) - 1;
186                                    warning("rdp_out_unistr: iconv(1) fail, errno %d\n", errno);
187    
188                                    g_iconv_works = False;
189                                    return (rdp_out_unistr(s, string, len));
190                            }
191                            pin = string;
192                            pout = (char *) s->p;
193                  }                  }
194                  if (iconv(iconv_h, (ICONV_CONST char **) &pin, &i, &pout, &o) == (size_t) - 1)  
195                    if (iconv(iconv_h, (ICONV_CONST char **) &pin, &ibl, &pout, &obl) == (size_t) - 1)
196                  {                  {
197                          iconv_close(iconv_h);                          iconv_close(iconv_h);
198                          iconv_h = (iconv_t) - 1;                          iconv_h = (iconv_t) - 1;
199                          printf("rdp_out_unistr: iconv(1) fail, errno %d\n", errno);                          warning("rdp_out_unistr: iconv(2) fail, errno %d\n", errno);
200                          return;  
201                            g_iconv_works = False;
202                            return (rdp_out_unistr(s, string, len));
203                  }                  }
                 pin = string;  
                 pout = (char *) s->p;  
         }  
204    
205          if (iconv(iconv_h, (ICONV_CONST char **) &pin, &ibl, &pout, &obl) == (size_t) - 1)                  s->p += len + 2;
         {  
                 iconv_close(iconv_h);  
                 iconv_h = (iconv_t) - 1;  
                 printf("rdp_out_unistr: iconv(2) fail, errno %d\n", errno);  
                 return;  
         }  
206    
207          s->p += len + 2;          }
208            else
209    #endif
210            {
211                    int i = 0, j = 0;
212    
213  #else /* HAVE_ICONV undef */                  len += 2;
         int i = 0, j = 0;  
214    
215          len += 2;                  while (i < len)
216                    {
217                            s->p[i++] = string[j++];
218                            s->p[i++] = 0;
219                    }
220    
221          while (i < len)                  s->p += len;
         {  
                 s->p[i++] = string[j++];  
                 s->p[i++] = 0;  
222          }          }
   
         s->p += len;  
 #endif  
223  }  }
224    
225  /* Input a string in Unicode  /* Input a string in Unicode
# Line 218  rdp_in_unistr(STREAM s, char *string, in Line 234  rdp_in_unistr(STREAM s, char *string, in
234          char *pin = s->p, *pout = string;          char *pin = s->p, *pout = string;
235          static iconv_t iconv_h = (iconv_t) - 1;          static iconv_t iconv_h = (iconv_t) - 1;
236    
237          if (iconv_h == (iconv_t) - 1)          if (g_iconv_works)
238          {          {
239                  if ((iconv_h = iconv_open(g_codepage, WINDOWS_CODEPAGE)) == (iconv_t) - 1)                  if (iconv_h == (iconv_t) - 1)
240                  {                  {
241                          printf("rdp_in_unistr: iconv_open[%s -> %s] fail %d\n",                          if ((iconv_h = iconv_open(g_codepage, WINDOWS_CODEPAGE)) == (iconv_t) - 1)
242                                 WINDOWS_CODEPAGE, g_codepage, (int) iconv_h);                          {
243                          return 0;                                  warning("rdp_in_unistr: iconv_open[%s -> %s] fail %d\n",
244                                            WINDOWS_CODEPAGE, g_codepage, (int) iconv_h);
245    
246                                    g_iconv_works = False;
247                                    return rdp_in_unistr(s, string, uni_len);
248                            }
249                  }                  }
         }  
250    
251          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)
252          {                  {
253                  iconv_close(iconv_h);                          iconv_close(iconv_h);
254                  iconv_h = (iconv_t) - 1;                          iconv_h = (iconv_t) - 1;
255                  printf("rdp_in_unistr: iconv fail, errno %d\n", errno);                          warning("rdp_in_unistr: iconv fail, errno %d\n", errno);
                 return 0;  
         }  
         return pout - string;  
 #else /* HAVE_ICONV undef */  
         int i = 0;  
256    
257          while (i < uni_len / 2)                          g_iconv_works = False;
258          {                          return rdp_in_unistr(s, string, uni_len);
259                  in_uint8a(s, &string[i++], 1);                  }
260                  in_uint8s(s, 1);                  return pout - string;
261          }          }
262            else
         return i - 1;  
263  #endif  #endif
264            {
265                    int i = 0;
266    
267                    while (i < uni_len / 2)
268                    {
269                            in_uint8a(s, &string[i++], 1);
270                            in_uint8s(s, 1);
271                    }
272    
273                    return i - 1;
274            }
275  }  }
276    
277    

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

  ViewVC Help
Powered by ViewVC 1.1.26