/[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 725 by jsorg71, Sun Jun 27 17:51:54 2004 UTC revision 828 by stargo, Sun Mar 6 21:11:18 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 35  Line 35 
35  #include <sys/un.h>             /* sockaddr_un */  #include <sys/un.h>             /* sockaddr_un */
36  #endif  #endif
37    
 #ifdef WITH_OPENSSL  
38  #include <openssl/md5.h>  #include <openssl/md5.h>
 #else  
 #include "crypto/md5.h"  
 #endif  
39    
40  char g_title[64] = "";  char g_title[64] = "";
41  char g_username[64];  char g_username[64];
# Line 53  int g_width = 800;             /* width is special: Line 49  int g_width = 800;             /* width is special:
49                                     absolute value specifies the                                     absolute value specifies the
50                                     percent of the whole screen. */                                     percent of the whole screen. */
51  int g_height = 600;  int g_height = 600;
52    int g_xpos = 0;
53    int g_ypos = 0;
54  extern int g_tcp_port_rdp;  extern int g_tcp_port_rdp;
55  int g_server_bpp = 8;  int g_server_bpp = 8;
56  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 96  static void Line 94  static void
94  usage(char *program)  usage(char *program)
95  {  {
96          fprintf(stderr, "rdesktop: A Remote Desktop Protocol client.\n");          fprintf(stderr, "rdesktop: A Remote Desktop Protocol client.\n");
97          fprintf(stderr, "Version " VERSION ". Copyright (C) 1999-2003 Matt Chapman.\n");          fprintf(stderr, "Version " VERSION ". Copyright (C) 1999-2005 Matt Chapman.\n");
98          fprintf(stderr, "See http://www.rdesktop.org/ for more information.\n\n");          fprintf(stderr, "See http://www.rdesktop.org/ for more information.\n\n");
99    
100          fprintf(stderr, "Usage: %s [options] server[:port]\n", program);          fprintf(stderr, "Usage: %s [options] server[:port]\n", program);
# Line 126  usage(char *program) Line 124  usage(char *program)
124          fprintf(stderr, "   -N: enable numlock syncronization\n");          fprintf(stderr, "   -N: enable numlock syncronization\n");
125          fprintf(stderr, "   -X: embed into another window with a given id.\n");          fprintf(stderr, "   -X: embed into another window with a given id.\n");
126          fprintf(stderr, "   -a: connection colour depth\n");          fprintf(stderr, "   -a: connection colour depth\n");
127            fprintf(stderr, "   -z: enable rdp compression\n");
128          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");
129          fprintf(stderr, "   -P: use persistent bitmap caching\n");          fprintf(stderr, "   -P: use persistent bitmap caching\n");
130          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 132  usage(char *program)
132                  "         '-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");
133          fprintf(stderr, "             or      COM1=/dev/ttyS0,COM2=/dev/ttyS1\n");          fprintf(stderr, "             or      COM1=/dev/ttyS0,COM2=/dev/ttyS1\n");
134          fprintf(stderr,          fprintf(stderr,
135                  "         '-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");
136          fprintf(stderr, "             or   A=/mnt/floppy,D=/mnt/cdrom'\n");          fprintf(stderr, "             or   'floppy=/mnt/floppy,cdrom=/mnt/cdrom'\n");
137          fprintf(stderr, "         '-r clientname=<client name>': Set the client name displayed\n");          fprintf(stderr, "         '-r clientname=<client name>': Set the client name displayed\n");
138          fprintf(stderr, "             for redirected disks\n");          fprintf(stderr, "             for redirected disks\n");
139          fprintf(stderr,          fprintf(stderr,
# Line 367  main(int argc, char *argv[]) Line 366  main(int argc, char *argv[])
366  #endif  #endif
367    
368          while ((c = getopt(argc, argv,          while ((c = getopt(argc, argv,
369                          VNCOPT "u:d:s:c:p:n:k:g:fbBeEmCDKS:T:NX:a:x:Pr:045h?")) != -1)                             VNCOPT "u:d:s:c:p:n:k:g:fbBeEmzCDKS:T:NX:a:x:Pr:045h?")) != -1)
370          {          {
371                  switch (c)                  switch (c)
372                  {                  {
# Line 442  main(int argc, char *argv[]) Line 441  main(int argc, char *argv[])
441                                  }                                  }
442    
443                                  if (*p == 'x')                                  if (*p == 'x')
444                                          g_height = strtol(p + 1, NULL, 10);                                          g_height = strtol(p + 1, &p, 10);
445    
446                                  if (g_height <= 0)                                  if (g_height <= 0)
447                                  {                                  {
# Line 451  main(int argc, char *argv[]) Line 450  main(int argc, char *argv[])
450                                  }                                  }
451    
452                                  if (*p == '%')                                  if (*p == '%')
453                                    {
454                                          g_width = -g_width;                                          g_width = -g_width;
455                                            p++;
456                                    }
457    
458                                    if (*p == '+' || *p == '-')
459                                            g_xpos = strtol(p, &p, 10);
460    
461                                    if (*p == '+' || *p == '-')
462                                            g_ypos = strtol(p, NULL, 10);
463    
464                                  break;                                  break;
465    
# Line 528  main(int argc, char *argv[]) Line 536  main(int argc, char *argv[])
536                                  }                                  }
537                                  break;                                  break;
538    
539                          case 'x':                          case 'z':
540                                    DEBUG(("rdp compression enabled\n"));
541                                    flags |= RDP_COMPRESSION;
542                                    break;
543    
544                            case 'x':
545                                  if (strncmp("modem", optarg, 1) == 0)                                  if (strncmp("modem", optarg, 1) == 0)
546                                  {                                  {
547                                          g_rdp5_performanceflags =                                          g_rdp5_performanceflags =
# Line 572  main(int argc, char *argv[]) Line 584  main(int argc, char *argv[])
584  #ifdef WITH_RDPSND  #ifdef WITH_RDPSND
585                                                                  g_rdpsnd = True;                                                                  g_rdpsnd = True;
586  #else  #else
587                                                                  warning("Not compiled with sound support");                                                                  warning("Not compiled with sound support\n");
588  #endif  #endif
589    
590                                                          if (strncmp("off", optarg, 3) == 0)                                                          if (strncmp("off", optarg, 3) == 0)
591  #ifdef WITH_RDPSND  #ifdef WITH_RDPSND
592                                                                  g_rdpsnd = False;                                                                  g_rdpsnd = False;
593  #else  #else
594                                                                  warning("Not compiled with sound support");                                                                  warning("Not compiled with sound support\n");
595  #endif  #endif
596    
597                                                          optarg = p;                                                          optarg = p;
# Line 590  main(int argc, char *argv[]) Line 602  main(int argc, char *argv[])
602  #ifdef WITH_RDPSND  #ifdef WITH_RDPSND
603                                                  g_rdpsnd = True;                                                  g_rdpsnd = True;
604  #else  #else
605                                                  warning("Not compiled with sound support");                                                  warning("Not compiled with sound support\n");
606  #endif  #endif
607                                          }                                          }
608                                  }                                  }
# Line 678  main(int argc, char *argv[]) Line 690  main(int argc, char *argv[])
690                  STRNCPY(g_hostname, fullhostname, sizeof(g_hostname));                  STRNCPY(g_hostname, fullhostname, sizeof(g_hostname));
691          }          }
692    
693            if ((flags & RDP_COMPRESSION) && (g_server_bpp > 8))
694            {
695                    warning("rdp compression not supported for bpp > 8, compression disabled\n");
696                    flags ^= RDP_COMPRESSION;
697            }
698    
699          if (prompt_password && read_password(password, sizeof(password)))          if (prompt_password && read_password(password, sizeof(password)))
700                  flags |= RDP_LOGON_AUTO;                  flags |= RDP_LOGON_AUTO;
701    
# Line 720  main(int argc, char *argv[]) Line 738  main(int argc, char *argv[])
738          }          }
739    
740          DEBUG(("Disconnecting...\n"));          DEBUG(("Disconnecting...\n"));
         cache_save_state();  
741          rdp_disconnect();          rdp_disconnect();
742            cache_save_state();
743          ui_deinit();          ui_deinit();
744    
745          if (ext_disc_reason >= 2)          if (ext_disc_reason >= 2)
# Line 851  xmalloc(int size) Line 869  xmalloc(int size)
869  void *  void *
870  xrealloc(void *oldmem, int size)  xrealloc(void *oldmem, int size)
871  {  {
872          void *mem = realloc(oldmem, size);          void *mem;
873    
874            if (size < 1)
875                    size = 1;
876            mem = realloc(oldmem, size);
877          if (mem == NULL)          if (mem == NULL)
878          {          {
879                  error("xrealloc %d\n", size);                  error("xrealloc %d\n", size);
# Line 1167  rd_open_file(char *filename) Line 1189  rd_open_file(char *filename)
1189  {  {
1190          char *home;          char *home;
1191          char fn[256];          char fn[256];
1192     int fd;          int fd;
1193    
1194          home = getenv("HOME");          home = getenv("HOME");
1195          if (home == NULL)          if (home == NULL)
# Line 1183  rd_open_file(char *filename) Line 1205  rd_open_file(char *filename)
1205  void  void
1206  rd_close_file(int fd)  rd_close_file(int fd)
1207  {  {
1208    close(fd);          close(fd);
1209  }  }
1210    
1211  /* read from file*/  /* read from file*/
1212  int  int
1213  rd_read_file(int fd, void *ptr, int len)  rd_read_file(int fd, void *ptr, int len)
1214  {  {
1215    return read(fd, ptr, len);          return read(fd, ptr, len);
1216  }  }
1217    
1218  /* write to file */  /* write to file */
1219  int  int
1220  rd_write_file(int fd, void* ptr, int len)  rd_write_file(int fd, void *ptr, int len)
1221  {  {
1222    return write(fd, ptr, len);          return write(fd, ptr, len);
1223  }  }
1224    
1225  /* move file pointer */  /* move file pointer */
1226  int  int
1227  rd_lseek_file(int fd, int offset)  rd_lseek_file(int fd, int offset)
1228  {  {
1229    return lseek(fd, offset, SEEK_SET);          return lseek(fd, offset, SEEK_SET);
1230  }  }
1231    
1232  /* do a write lock on a file */  /* do a write lock on a file */

Legend:
Removed from v.725  
changed lines
  Added in v.828

  ViewVC Help
Powered by ViewVC 1.1.26