/[rdesktop]/jpeg/rdesktop/trunk/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 /jpeg/rdesktop/trunk/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 879 by astrand, Sun Apr 3 18:08:05 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 157  rdp_out_unistr(STREAM s, char *string, i Line 161  rdp_out_unistr(STREAM s, char *string, i
161  #ifdef HAVE_ICONV  #ifdef HAVE_ICONV
162          size_t ibl = strlen(string), obl = len + 2;          size_t ibl = strlen(string), obl = len + 2;
163          static iconv_t iconv_h = (iconv_t) - 1;          static iconv_t iconv_h = (iconv_t) - 1;
164          char *pin = string, *pout = s->p;          char *pin = string, *pout = (char *) s->p;
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                                    rdp_out_unistr(s, string, len);
180                                    return;
181                            }
182                            if (iconv(iconv_h, (ICONV_CONST char **) &pin, &i, &pout, &o) ==
183                                (size_t) - 1)
184                            {
185                                    iconv_close(iconv_h);
186                                    iconv_h = (iconv_t) - 1;
187                                    warning("rdp_out_unistr: iconv(1) fail, errno %d\n", errno);
188    
189                                    g_iconv_works = False;
190                                    rdp_out_unistr(s, string, len);
191                                    return;
192                            }
193                            pin = string;
194                            pout = (char *) s->p;
195                  }                  }
196                  if (iconv(iconv_h, (ICONV_CONST char **) &pin, &i, &pout, &o) == (size_t) - 1)  
197                    if (iconv(iconv_h, (ICONV_CONST char **) &pin, &ibl, &pout, &obl) == (size_t) - 1)
198                  {                  {
199                          iconv_close(iconv_h);                          iconv_close(iconv_h);
200                          iconv_h = (iconv_t) - 1;                          iconv_h = (iconv_t) - 1;
201                          printf("rdp_out_unistr: iconv(1) fail, errno %d\n", errno);                          warning("rdp_out_unistr: iconv(2) fail, errno %d\n", errno);
202    
203                            g_iconv_works = False;
204                            rdp_out_unistr(s, string, len);
205                          return;                          return;
206                  }                  }
                 pin = string;  
                 pout = (char *) s->p;  
         }  
207    
208          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;  
         }  
209    
210          s->p += len + 2;          }
211            else
212    #endif
213            {
214                    int i = 0, j = 0;
215    
216  #else /* HAVE_ICONV undef */                  len += 2;
         int i = 0, j = 0;  
217    
218          len += 2;                  while (i < len)
219                    {
220                            s->p[i++] = string[j++];
221                            s->p[i++] = 0;
222                    }
223    
224          while (i < len)                  s->p += len;
         {  
                 s->p[i++] = string[j++];  
                 s->p[i++] = 0;  
225          }          }
   
         s->p += len;  
 #endif  
226  }  }
227    
228  /* Input a string in Unicode  /* Input a string in Unicode
# Line 215  rdp_in_unistr(STREAM s, char *string, in Line 234  rdp_in_unistr(STREAM s, char *string, in
234  {  {
235  #ifdef HAVE_ICONV  #ifdef HAVE_ICONV
236          size_t ibl = uni_len, obl = uni_len;          size_t ibl = uni_len, obl = uni_len;
237          char *pin = s->p, *pout = string;          char *pin = (char *) s->p, *pout = string;
238          static iconv_t iconv_h = (iconv_t) - 1;          static iconv_t iconv_h = (iconv_t) - 1;
239    
240          if (iconv_h == (iconv_t) - 1)          if (g_iconv_works)
241          {          {
242                  if ((iconv_h = iconv_open(g_codepage, WINDOWS_CODEPAGE)) == (iconv_t) - 1)                  if (iconv_h == (iconv_t) - 1)
243                  {                  {
244                          printf("rdp_in_unistr: iconv_open[%s -> %s] fail %d\n",                          if ((iconv_h = iconv_open(g_codepage, WINDOWS_CODEPAGE)) == (iconv_t) - 1)
245                                 WINDOWS_CODEPAGE, g_codepage, (int) iconv_h);                          {
246                          return 0;                                  warning("rdp_in_unistr: iconv_open[%s -> %s] fail %d\n",
247                                            WINDOWS_CODEPAGE, g_codepage, (int) iconv_h);
248    
249                                    g_iconv_works = False;
250                                    return rdp_in_unistr(s, string, uni_len);
251                            }
252                  }                  }
         }  
253    
254          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)
255          {                  {
256                  iconv_close(iconv_h);                          iconv_close(iconv_h);
257                  iconv_h = (iconv_t) - 1;                          iconv_h = (iconv_t) - 1;
258                  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;  
259    
260          while (i < uni_len / 2)                          g_iconv_works = False;
261          {                          return rdp_in_unistr(s, string, uni_len);
262                  in_uint8a(s, &string[i++], 1);                  }
263                  in_uint8s(s, 1);                  return pout - string;
264          }          }
265            else
         return i - 1;  
266  #endif  #endif
267            {
268                    int i = 0;
269    
270                    while (i < uni_len / 2)
271                    {
272                            in_uint8a(s, &string[i++], 1);
273                            in_uint8s(s, 1);
274                    }
275    
276                    return i - 1;
277            }
278  }  }
279    
280    
# Line 1178  process_data_pdu(STREAM s, uint32 * ext_ Line 1206  process_data_pdu(STREAM s, uint32 * ext_
1206                  if (mppc_expand(s->p, clen, ctype, &roff, &rlen) == -1)                  if (mppc_expand(s->p, clen, ctype, &roff, &rlen) == -1)
1207                          error("error while decompressing packet\n");                          error("error while decompressing packet\n");
1208    
1209                  //len -= 18;                  /* len -= 18; */
1210    
1211                  /* allocate memory and copy the uncompressed data into the temporary stream */                  /* allocate memory and copy the uncompressed data into the temporary stream */
1212                  ns->data = (uint8 *) xrealloc(ns->data, rlen);                  ns->data = (uint8 *) xrealloc(ns->data, rlen);

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

  ViewVC Help
Powered by ViewVC 1.1.26