/[rdesktop]/sourceforge.net/branches/seamlessrdp-branch/rdesktop/rdesktop.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/branches/seamlessrdp-branch/rdesktop/rdesktop.c

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

revision 738 by astrand, Mon Jul 12 21:07:39 2004 UTC revision 861 by stargo, Sun Mar 13 17:40:51 2005 UTC
# Line 1  Line 1 
1  /* -*- c-basic-offset: 8 -*-  /* -*- c-basic-offset: 8 -*-
2     rdesktop: A Remote Desktop Protocol client.     rdesktop: A Remote Desktop Protocol client.
3     Entrypoint and utility functions     Entrypoint and utility functions
4     Copyright (C) Matthew Chapman 1999-2003     Copyright (C) Matthew Chapman 1999-2005
5    
6     This program is free software; you can redistribute it and/or modify     This program is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by     it under the terms of the GNU General Public License as published by
# Line 30  Line 30 
30  #include <errno.h>  #include <errno.h>
31  #include "rdesktop.h"  #include "rdesktop.h"
32    
33    #ifdef HAVE_ICONV
34    #ifdef HAVE_LOCALE_H
35    #include <locale.h>
36    #endif
37    #ifdef HAVE_LANGINFO_H
38    #include <langinfo.h>
39    #endif
40    #endif
41    
42  #ifdef EGD_SOCKET  #ifdef EGD_SOCKET
43  #include <sys/socket.h>         /* socket connect */  #include <sys/socket.h>         /* socket connect */
44  #include <sys/un.h>             /* sockaddr_un */  #include <sys/un.h>             /* sockaddr_un */
45  #endif  #endif
46    
 #ifdef WITH_OPENSSL  
47  #include <openssl/md5.h>  #include <openssl/md5.h>
 #else  
 #include "crypto/md5.h"  
 #endif  
48    
49  char g_title[64] = "";  char g_title[64] = "";
50  char g_username[64];  char g_username[64];
# Line 53  int g_width = 800;             /* width is special: Line 58  int g_width = 800;             /* width is special:
58                                     absolute value specifies the                                     absolute value specifies the
59                                     percent of the whole screen. */                                     percent of the whole screen. */
60  int g_height = 600;  int g_height = 600;
61    int g_xpos = 0;
62    int g_ypos = 0;
63  extern int g_tcp_port_rdp;  extern int g_tcp_port_rdp;
64  int g_server_bpp = 8;  int g_server_bpp = 8;
65  int g_win_button_size = 0;      /* If zero, disable single app mode */  int g_win_button_size = 0;      /* If zero, disable single app mode */
# Line 63  BOOL g_bitmap_cache_persist_enable = Fal Line 70  BOOL g_bitmap_cache_persist_enable = Fal
70  BOOL g_bitmap_cache_precache = True;  BOOL g_bitmap_cache_precache = True;
71  BOOL g_encryption = True;  BOOL g_encryption = True;
72  BOOL packet_encryption = True;  BOOL packet_encryption = True;
73  BOOL g_desktop_save = True;  BOOL g_desktop_save = True;     /* desktop save order */
74    BOOL g_polygon_ellipse_orders = True;   /* polygon / ellipse orders */
75  BOOL g_fullscreen = False;  BOOL g_fullscreen = False;
76  BOOL g_grab_keyboard = True;  BOOL g_grab_keyboard = True;
77  BOOL g_hide_decorations = False;  BOOL g_hide_decorations = False;
# Line 80  uint32 g_rdp5_performanceflags = Line 88  uint32 g_rdp5_performanceflags =
88  BOOL g_rdpsnd = False;  BOOL g_rdpsnd = False;
89  #endif  #endif
90    
91    #ifdef HAVE_ICONV
92    char g_codepage[16] = "";
93    #endif
94    
95  extern RDPDR_DEVICE g_rdpdr_device[];  extern RDPDR_DEVICE g_rdpdr_device[];
96  extern uint32 g_num_devices;  extern uint32 g_num_devices;
97  extern char *g_rdpdr_clientname;  extern char *g_rdpdr_clientname;
# Line 96  static void Line 108  static void
108  usage(char *program)  usage(char *program)
109  {  {
110          fprintf(stderr, "rdesktop: A Remote Desktop Protocol client.\n");          fprintf(stderr, "rdesktop: A Remote Desktop Protocol client.\n");
111          fprintf(stderr, "Version " VERSION ". Copyright (C) 1999-2003 Matt Chapman.\n");          fprintf(stderr, "Version " VERSION ". Copyright (C) 1999-2005 Matt Chapman.\n");
112          fprintf(stderr, "See http://www.rdesktop.org/ for more information.\n\n");          fprintf(stderr, "See http://www.rdesktop.org/ for more information.\n\n");
113    
114          fprintf(stderr, "Usage: %s [options] server[:port]\n", program);          fprintf(stderr, "Usage: %s [options] server[:port]\n", program);
# Line 114  usage(char *program) Line 126  usage(char *program)
126          fprintf(stderr, "   -g: desktop geometry (WxH)\n");          fprintf(stderr, "   -g: desktop geometry (WxH)\n");
127          fprintf(stderr, "   -f: full-screen mode\n");          fprintf(stderr, "   -f: full-screen mode\n");
128          fprintf(stderr, "   -b: force bitmap updates\n");          fprintf(stderr, "   -b: force bitmap updates\n");
129    #ifdef HAVE_ICONV
130            fprintf(stderr, "   -L: local codepage\n");
131    #endif
132          fprintf(stderr, "   -B: use BackingStore of X-server (if available)\n");          fprintf(stderr, "   -B: use BackingStore of X-server (if available)\n");
133          fprintf(stderr, "   -e: disable encryption (French TS)\n");          fprintf(stderr, "   -e: disable encryption (French TS)\n");
134          fprintf(stderr, "   -E: disable encryption from client to server\n");          fprintf(stderr, "   -E: disable encryption from client to server\n");
# Line 126  usage(char *program) Line 141  usage(char *program)
141          fprintf(stderr, "   -N: enable numlock syncronization\n");          fprintf(stderr, "   -N: enable numlock syncronization\n");
142          fprintf(stderr, "   -X: embed into another window with a given id.\n");          fprintf(stderr, "   -X: embed into another window with a given id.\n");
143          fprintf(stderr, "   -a: connection colour depth\n");          fprintf(stderr, "   -a: connection colour depth\n");
144            fprintf(stderr, "   -z: enable rdp compression\n");
145          fprintf(stderr, "   -x: RDP5 experience (m[odem 28.8], b[roadband], l[an] or hex nr.)\n");          fprintf(stderr, "   -x: RDP5 experience (m[odem 28.8], b[roadband], l[an] or hex nr.)\n");
146          fprintf(stderr, "   -P: use persistent bitmap caching\n");          fprintf(stderr, "   -P: use persistent bitmap caching\n");
147          fprintf(stderr, "   -r: enable specified device redirection (this flag can be repeated)\n");          fprintf(stderr, "   -r: enable specified device redirection (this flag can be repeated)\n");
# Line 133  usage(char *program) Line 149  usage(char *program)
149                  "         '-r comport:COM1=/dev/ttyS0': enable serial redirection of /dev/ttyS0 to COM1\n");                  "         '-r comport:COM1=/dev/ttyS0': enable serial redirection of /dev/ttyS0 to COM1\n");
150          fprintf(stderr, "             or      COM1=/dev/ttyS0,COM2=/dev/ttyS1\n");          fprintf(stderr, "             or      COM1=/dev/ttyS0,COM2=/dev/ttyS1\n");
151          fprintf(stderr,          fprintf(stderr,
152                  "         '-r disk:A=/mnt/floppy': enable redirection of /mnt/floppy to A:\n");                  "         '-r disk:floppy=/mnt/floppy': enable redirection of /mnt/floppy to 'floppy' share\n");
153          fprintf(stderr, "             or   A=/mnt/floppy,D=/mnt/cdrom'\n");          fprintf(stderr, "             or   'floppy=/mnt/floppy,cdrom=/mnt/cdrom'\n");
154          fprintf(stderr, "         '-r clientname=<client name>': Set the client name displayed\n");          fprintf(stderr, "         '-r clientname=<client name>': Set the client name displayed\n");
155          fprintf(stderr, "             for redirected disks\n");          fprintf(stderr, "             for redirected disks\n");
156          fprintf(stderr,          fprintf(stderr,
# Line 367  main(int argc, char *argv[]) Line 383  main(int argc, char *argv[])
383  #endif  #endif
384    
385          while ((c = getopt(argc, argv,          while ((c = getopt(argc, argv,
386                             VNCOPT "u:d:s:c:p:n:k:g:fbBeEmCDKS:T:NX:a:x:Pr:045h?")) != -1)                             VNCOPT "u:L:d:s:c:p:n:k:g:fbBeEmzCDKS:T:NX:a:x:Pr:045h?")) != -1)
387          {          {
388                  switch (c)                  switch (c)
389                  {                  {
# Line 390  main(int argc, char *argv[]) Line 406  main(int argc, char *argv[])
406                                  username_option = 1;                                  username_option = 1;
407                                  break;                                  break;
408    
409                            case 'L':
410    #ifdef HAVE_ICONV
411                                    STRNCPY(g_codepage, optarg, sizeof(g_codepage));
412    #else
413                                    error("iconv support not available\n");
414    #endif
415                                    break;
416    
417                          case 'd':                          case 'd':
418                                  STRNCPY(domain, optarg, sizeof(domain));                                  STRNCPY(domain, optarg, sizeof(domain));
419                                  break;                                  break;
# Line 442  main(int argc, char *argv[]) Line 466  main(int argc, char *argv[])
466                                  }                                  }
467    
468                                  if (*p == 'x')                                  if (*p == 'x')
469                                          g_height = strtol(p + 1, NULL, 10);                                          g_height = strtol(p + 1, &p, 10);
470    
471                                  if (g_height <= 0)                                  if (g_height <= 0)
472                                  {                                  {
# Line 451  main(int argc, char *argv[]) Line 475  main(int argc, char *argv[])
475                                  }                                  }
476    
477                                  if (*p == '%')                                  if (*p == '%')
478                                    {
479                                          g_width = -g_width;                                          g_width = -g_width;
480                                            p++;
481                                    }
482    
483                                    if (*p == '+' || *p == '-')
484                                            g_xpos = strtol(p, &p, 10);
485    
486                                    if (*p == '+' || *p == '-')
487                                            g_ypos = strtol(p, NULL, 10);
488    
489                                  break;                                  break;
490    
# Line 528  main(int argc, char *argv[]) Line 561  main(int argc, char *argv[])
561                                  }                                  }
562                                  break;                                  break;
563    
564                          case 'x':                          case 'z':
565                                    DEBUG(("rdp compression enabled\n"));
566                                    flags |= RDP_COMPRESSION;
567                                    break;
568    
569                            case 'x':
570                                  if (strncmp("modem", optarg, 1) == 0)                                  if (strncmp("modem", optarg, 1) == 0)
571                                  {                                  {
572                                          g_rdp5_performanceflags =                                          g_rdp5_performanceflags =
# Line 572  main(int argc, char *argv[]) Line 609  main(int argc, char *argv[])
609  #ifdef WITH_RDPSND  #ifdef WITH_RDPSND
610                                                                  g_rdpsnd = True;                                                                  g_rdpsnd = True;
611  #else  #else
612                                                                  warning("Not compiled with sound support");                                                                  warning("Not compiled with sound support\n");
613  #endif  #endif
614    
615                                                          if (strncmp("off", optarg, 3) == 0)                                                          if (strncmp("off", optarg, 3) == 0)
616  #ifdef WITH_RDPSND  #ifdef WITH_RDPSND
617                                                                  g_rdpsnd = False;                                                                  g_rdpsnd = False;
618  #else  #else
619                                                                  warning("Not compiled with sound support");                                                                  warning("Not compiled with sound support\n");
620  #endif  #endif
621    
622                                                          optarg = p;                                                          optarg = p;
# Line 590  main(int argc, char *argv[]) Line 627  main(int argc, char *argv[])
627  #ifdef WITH_RDPSND  #ifdef WITH_RDPSND
628                                                  g_rdpsnd = True;                                                  g_rdpsnd = True;
629  #else  #else
630                                                  warning("Not compiled with sound support");                                                  warning("Not compiled with sound support\n");
631  #endif  #endif
632                                          }                                          }
633                                  }                                  }
# Line 663  main(int argc, char *argv[]) Line 700  main(int argc, char *argv[])
700                  STRNCPY(g_username, pw->pw_name, sizeof(g_username));                  STRNCPY(g_username, pw->pw_name, sizeof(g_username));
701          }          }
702    
703    #ifdef HAVE_ICONV
704            if (g_codepage[0] == 0)
705            {
706                    if (setlocale(LC_CTYPE, ""))
707                    {
708                            STRNCPY(g_codepage, nl_langinfo(CODESET), sizeof(g_codepage));
709                    }
710                    else
711                    {
712                            STRNCPY(g_codepage, DEFAULT_CODEPAGE, sizeof(g_codepage));
713                    }
714            }
715    #endif
716    
717          if (g_hostname[0] == 0)          if (g_hostname[0] == 0)
718          {          {
719                  if (gethostname(fullhostname, sizeof(fullhostname)) == -1)                  if (gethostname(fullhostname, sizeof(fullhostname)) == -1)
# Line 678  main(int argc, char *argv[]) Line 729  main(int argc, char *argv[])
729                  STRNCPY(g_hostname, fullhostname, sizeof(g_hostname));                  STRNCPY(g_hostname, fullhostname, sizeof(g_hostname));
730          }          }
731    
732            if ((flags & RDP_COMPRESSION) && (g_server_bpp > 8))
733            {
734                    warning("rdp compression not supported for bpp > 8, compression disabled\n");
735                    flags ^= RDP_COMPRESSION;
736            }
737    
738          if (prompt_password && read_password(password, sizeof(password)))          if (prompt_password && read_password(password, sizeof(password)))
739                  flags |= RDP_LOGON_AUTO;                  flags |= RDP_LOGON_AUTO;
740    
# Line 851  xmalloc(int size) Line 908  xmalloc(int size)
908  void *  void *
909  xrealloc(void *oldmem, int size)  xrealloc(void *oldmem, int size)
910  {  {
911          void *mem = realloc(oldmem, size);          void *mem;
912    
913            if (size < 1)
914                    size = 1;
915            mem = realloc(oldmem, size);
916          if (mem == NULL)          if (mem == NULL)
917          {          {
918                  error("xrealloc %d\n", size);                  error("xrealloc %d\n", size);

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

  ViewVC Help
Powered by ViewVC 1.1.26