/[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 860 by stargo, Sun Mar 13 17:36:15 2005 UTC revision 861 by stargo, Sun Mar 13 17:40:51 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;
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;
165  #else  #else
# Line 168  rdp_out_unistr(STREAM s, char *string, i Line 168  rdp_out_unistr(STREAM s, char *string, i
168    
169          memset(pout, 0, len + 4);          memset(pout, 0, len + 4);
170    
171          if (iconv_h == (iconv_t)-1)          if (iconv_h == (iconv_t) - 1)
172          {          {
173                  size_t i = 1, o = 4;                  size_t i = 1, o = 4;
174                  if ((iconv_h = iconv_open(WINDOWS_CODEPAGE, g_codepage)) == (iconv_t)-1)                  if ((iconv_h = iconv_open(WINDOWS_CODEPAGE, g_codepage)) == (iconv_t) - 1)
175                  {                  {
176                          printf("rdp_out_unistr: iconv_open[%s -> %s] fail %d\n",                          printf("rdp_out_unistr: iconv_open[%s -> %s] fail %d\n",
177                                  g_codepage, WINDOWS_CODEPAGE, (int)iconv_h);                                 g_codepage, WINDOWS_CODEPAGE, (int) iconv_h);
178                          return;                          return;
179                  }                  }
180                  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)
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;                  pin = string;
188                  pout = (char*)s->p;                  pout = (char *) s->p;
189          }          }
190    
191          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)
192          {          {
193                  iconv_close(iconv_h);                  iconv_close(iconv_h);
194                  iconv_h = (iconv_t)-1;                  iconv_h = (iconv_t) - 1;
195                  printf("rdp_out_unistr: iconv(2) fail, errno %d\n", errno);                  printf("rdp_out_unistr: iconv(2) fail, errno %d\n", errno);
196                  return;                  return;
197          }          }
198    
199  #ifdef B_ENDIAN  #ifdef B_ENDIAN
200          swab(ss, (char*)s->p, len + 4);          swab(ss, (char *) s->p, len + 4);
201  #endif  #endif
202    
203          s->p += len + 2;          s->p += len + 2;
204    
205  #else /*HAVE_ICONV undef*/  #else /*HAVE_ICONV undef */
206          int i = 0, j = 0;          int i = 0, j = 0;
207    
208          len += 2;          len += 2;
# Line 212  rdp_out_unistr(STREAM s, char *string, i Line 212  rdp_out_unistr(STREAM s, char *string, i
212                  s->p[i++] = string[j++];                  s->p[i++] = string[j++];
213                  s->p[i++] = 0;                  s->p[i++] = 0;
214          }          }
215            
216          s->p += len;          s->p += len;
217  #endif  #endif
218  }  }
# Line 227  rdp_in_unistr(STREAM s, char *string, in Line 227  rdp_in_unistr(STREAM s, char *string, in
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((char*)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;
238  #endif  #endif
239    
240          if (iconv_h == (iconv_t)-1)          if (iconv_h == (iconv_t) - 1)
241          {          {
242                  if ((iconv_h = iconv_open(g_codepage, WINDOWS_CODEPAGE)) == (iconv_t)-1)                  if ((iconv_h = iconv_open(g_codepage, WINDOWS_CODEPAGE)) == (iconv_t) - 1)
243                  {                  {
244                          printf("rdp_in_unistr: iconv_open[%s -> %s] fail %d\n",                          printf("rdp_in_unistr: iconv_open[%s -> %s] fail %d\n",
245                                  WINDOWS_CODEPAGE, g_codepage, (int)iconv_h);                                 WINDOWS_CODEPAGE, g_codepage, (int) iconv_h);
246                          return 0;                          return 0;
247                  }                  }
248          }          }
249    
250          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)
251          {          {
252                  iconv_close(iconv_h);                  iconv_close(iconv_h);
253                  iconv_h = (iconv_t)-1;                  iconv_h = (iconv_t) - 1;
254                  printf("rdp_in_unistr: iconv fail, errno %d\n", errno);                  printf("rdp_in_unistr: iconv fail, errno %d\n", errno);
255                  return 0;                  return 0;
256          }          }

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

  ViewVC Help
Powered by ViewVC 1.1.26