/[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 552 by astrand, Mon Dec 8 12:01:25 2003 UTC revision 629 by n-ki, Thu Mar 4 13:23:23 2004 UTC
# Line 26  Line 26 
26  #include <sys/stat.h>           /* stat */  #include <sys/stat.h>           /* stat */
27  #include <sys/time.h>           /* gettimeofday */  #include <sys/time.h>           /* gettimeofday */
28  #include <sys/times.h>          /* times */  #include <sys/times.h>          /* times */
29    #include <ctype.h>              /* toupper */
30  #include <errno.h>  #include <errno.h>
31  #include "rdesktop.h"  #include "rdesktop.h"
32    
# Line 68  BOOL g_use_rdp5 = True; Line 69  BOOL g_use_rdp5 = True;
69  BOOL g_console_session = False;  BOOL g_console_session = False;
70  BOOL g_numlock_sync = False;  BOOL g_numlock_sync = False;
71  extern BOOL g_owncolmap;  extern BOOL g_owncolmap;
72    extern BOOL g_ownbackstore;
73    
74  #ifdef WITH_RDPSND  #ifdef WITH_RDPSND
75  BOOL g_rdpsnd = False;  BOOL g_rdpsnd = False;
76  #endif  #endif
77    
78    extern RDPDR_DEVICE g_rdpdr_device[];
79    extern uint32 g_num_devices;
80    
81  #ifdef RDP2VNC  #ifdef RDP2VNC
82  extern int rfb_port;  extern int rfb_port;
83  extern int defer_time;  extern int defer_time;
# Line 103  usage(char *program) Line 108  usage(char *program)
108          fprintf(stderr, "   -g: desktop geometry (WxH)\n");          fprintf(stderr, "   -g: desktop geometry (WxH)\n");
109          fprintf(stderr, "   -f: full-screen mode\n");          fprintf(stderr, "   -f: full-screen mode\n");
110          fprintf(stderr, "   -b: force bitmap updates\n");          fprintf(stderr, "   -b: force bitmap updates\n");
111            fprintf(stderr, "   -B: use BackingStore of X-server (if available)\n");
112          fprintf(stderr, "   -e: disable encryption (French TS)\n");          fprintf(stderr, "   -e: disable encryption (French TS)\n");
113          fprintf(stderr, "   -E: disable encryption from client to server\n");          fprintf(stderr, "   -E: disable encryption from client to server\n");
114          fprintf(stderr, "   -m: do not send motion events\n");          fprintf(stderr, "   -m: do not send motion events\n");
# Line 113  usage(char *program) Line 119  usage(char *program)
119          fprintf(stderr, "   -T: window title\n");          fprintf(stderr, "   -T: window title\n");
120          fprintf(stderr, "   -N: enable numlock syncronization\n");          fprintf(stderr, "   -N: enable numlock syncronization\n");
121          fprintf(stderr, "   -a: connection colour depth\n");          fprintf(stderr, "   -a: connection colour depth\n");
122          fprintf(stderr, "   -r: enable specified device redirection (currently: sound)\n");          fprintf(stderr, "   -r: enable specified device redirection (this flag can be repeated)\n");
123            fprintf(stderr,
124                    "         '-r comport:COM1=/dev/ttyS0': enable serial redirection of /dev/ttyS0 to COM1\n");
125            fprintf(stderr, "             or      COM1=/dev/ttyS0,COM2=/dev/ttyS1\n");
126            fprintf(stderr,
127                    "         '-r disk:A=/mnt/floppy': enable redirection of /mnt/floppy to A:\n");
128            fprintf(stderr, "             or   A=/mnt/floppy,D=/mnt/cdrom'\n");
129            fprintf(stderr,
130                    "         '-r lptport:LPT1=/dev/lp0': enable parallel redirection of /dev/lp0 to LPT1\n");
131            fprintf(stderr, "             or      LPT1=/dev/lp0,LPT2=/dev/lp1\n");
132            fprintf(stderr, "         '-r printer:mydeskjet': enable printer redirection\n");
133            fprintf(stderr,
134                    "             or      mydeskjet=\"HP LaserJet IIIP\" to enter server driver as well\n");
135            fprintf(stderr, "         '-r sound:[on|off|remote]': enable sound redirection\n");
136            fprintf(stderr, "                     remote would leave sound on server\n");
137          fprintf(stderr, "   -0: attach to console\n");          fprintf(stderr, "   -0: attach to console\n");
138          fprintf(stderr, "   -4: use RDP version 4\n");          fprintf(stderr, "   -4: use RDP version 4\n");
139          fprintf(stderr, "   -5: use RDP version 5 (default)\n");          fprintf(stderr, "   -5: use RDP version 5 (default)\n");
# Line 218  main(int argc, char *argv[]) Line 238  main(int argc, char *argv[])
238          uint32 flags;          uint32 flags;
239          char *p;          char *p;
240          int c;          int c;
241    
242          int username_option = 0;          int username_option = 0;
243    
244          flags = RDP_LOGON_NORMAL;          flags = RDP_LOGON_NORMAL;
# Line 225  main(int argc, char *argv[]) Line 246  main(int argc, char *argv[])
246          domain[0] = password[0] = shell[0] = directory[0] = 0;          domain[0] = password[0] = shell[0] = directory[0] = 0;
247          strcpy(keymapname, "en-us");          strcpy(keymapname, "en-us");
248    
249            g_num_devices = 0;
250    
251  #ifdef RDP2VNC  #ifdef RDP2VNC
252  #define VNCOPT "V:Q:"  #define VNCOPT "V:Q:"
253  #else  #else
254  #define VNCOPT  #define VNCOPT
255  #endif  #endif
256    
257          while ((c = getopt(argc, argv, VNCOPT "u:d:s:c:p:n:k:g:fbeEmCDKS:T:Na:r:045h?")) != -1)          while ((c = getopt(argc, argv, VNCOPT "u:d:s:c:p:n:k:g:fbBeEmCDKS:T:Na:r:045h?")) != -1)
258          {          {
259                  switch (c)                  switch (c)
260                  {                  {
# Line 327  main(int argc, char *argv[]) Line 350  main(int argc, char *argv[])
350                                  g_orders = False;                                  g_orders = False;
351                                  break;                                  break;
352    
353                            case 'B':
354                                    g_ownbackstore = False;
355                                    break;
356    
357                          case 'e':                          case 'e':
358                                  g_encryption = False;                                  g_encryption = False;
359                                  break;                                  break;
# Line 385  main(int argc, char *argv[]) Line 412  main(int argc, char *argv[])
412                                  break;                                  break;
413    
414                          case 'r':                          case 'r':
415                                  if (!strcmp(optarg, "sound"))  
416                                    if (strncmp("sound", optarg, 5) == 0)
417                                    {
418                                            optarg += 5;
419    
420                                            if (*optarg == ':')
421                                            {
422                                                    *optarg++;
423                                                    while ((p = next_arg(optarg, ',')))
424                                                    {
425                                                            if (strncmp("remote", optarg, 6) == 0)
426                                                                    flags |= RDP_LOGON_LEAVE_AUDIO;
427    
428                                                            if (strncmp("on", optarg, 2) == 0)
429  #ifdef WITH_RDPSND  #ifdef WITH_RDPSND
430                                          g_rdpsnd = True;                                                                  g_rdpsnd = True;
431  #else  #else
432                                          warning("Not compiled with sound support");                                                                  warning("Not compiled with sound support");
433  #endif  #endif
434    
435                                                            if (strncmp("off", optarg, 3) == 0)
436                                                                    g_rdpsnd = False;
437    
438                                                            optarg = p;
439                                                    }
440                                            }
441                                            else
442                                            {
443    #ifdef WITH_RDPSND
444                                                    g_rdpsnd = True;
445    #else
446                                                    warning("Not compiled with sound support");
447    #endif
448                                            }
449                                    }
450                                    else if (strncmp("disk", optarg, 4) == 0)
451                                    {
452                                            /* -r disk:h:=/mnt/floppy */
453                                            disk_enum_devices(&g_num_devices, optarg + 4);
454                                    }
455                                    else if (strncmp("comport", optarg, 7) == 0)
456                                    {
457                                            serial_enum_devices(&g_num_devices, optarg + 7);
458                                    }
459                                    else if (strncmp("lptport", optarg, 7) == 0)
460                                    {
461                                            parallel_enum_devices(&g_num_devices, optarg + 7);
462                                    }
463                                    else if (strncmp("printer", optarg, 7) == 0)
464                                    {
465                                            printer_enum_devices(&g_num_devices, optarg + 7);
466                                    }
467                                    else
468                                    {
469                                            warning("Unknown -r argument\n\n\tPossible arguments are: comport, disk, lptport, printer, sound\n");
470                                    }
471                                  break;                                  break;
472    
473                          case '0':                          case '0':
# Line 413  main(int argc, char *argv[]) Line 490  main(int argc, char *argv[])
490                  }                  }
491          }          }
492    
493          if (argc - optind < 1)          if (argc - optind != 1)
494          {          {
495                  usage(argv[0]);                  usage(argv[0]);
496                  return 1;                  return 1;
# Line 470  main(int argc, char *argv[]) Line 547  main(int argc, char *argv[])
547          if (g_rdpsnd)          if (g_rdpsnd)
548                  rdpsnd_init();                  rdpsnd_init();
549  #endif  #endif
550          /* rdpdr_init(); */          rdpdr_init();
551    
552          if (!rdp_connect(server, flags, domain, password, shell, directory))          if (!rdp_connect(server, flags, domain, password, shell, directory))
553                  return 1;                  return 1;
# Line 660  unimpl(char *format, ...) Line 737  unimpl(char *format, ...)
737    
738  /* produce a hex dump */  /* produce a hex dump */
739  void  void
740  hexdump(unsigned char *p, int len)  hexdump(unsigned char *p, unsigned int len)
741  {  {
742          unsigned char *line = p;          unsigned char *line = p;
743          int i, thisline, offset = 0;          int i, thisline, offset = 0;
# Line 687  hexdump(unsigned char *p, int len) Line 764  hexdump(unsigned char *p, int len)
764          }          }
765  }  }
766    
767    /*
768      input: src is the string we look in for needle.
769             Needle may be escaped by a backslash, in
770             that case we ignore that particular needle.
771      return value: returns next src pointer, for
772            succesive executions, like in a while loop
773            if retval is 0, then there are no more args.
774      pitfalls:
775            src is modified. 0x00 chars are inserted to
776            terminate strings.
777            return val, points on the next val chr after ins
778            0x00
779    
780            example usage:
781            while( (pos = next_arg( optarg, ',')) ){
782                    printf("%s\n",optarg);
783                    optarg=pos;
784            }
785    
786    */
787    char *
788    next_arg(char *src, char needle)
789    {
790            char *nextval;
791            char *p;
792            char *mvp = 0;
793    
794            /* EOS */
795            if (*src == (char) 0x00)
796                    return 0;
797    
798            p = src;
799            /*  skip escaped needles */
800            while ((nextval = strchr(p, needle)))
801            {
802                    mvp = nextval - 1;
803                    /* found backslashed needle */
804                    if (*mvp == '\\' && (mvp > src))
805                    {
806                            /* move string one to the left */
807                            while (*(mvp + 1) != (char) 0x00)
808                            {
809                                    *mvp = *(mvp + 1);
810                                    *mvp++;
811                            }
812                            *mvp = (char) 0x00;
813                            p = nextval;
814                    }
815                    else
816                    {
817                            p = nextval + 1;
818                            break;
819                    }
820    
821            }
822    
823            /* more args available */
824            if (nextval)
825            {
826                    *nextval = (char) 0x00;
827                    return ++nextval;
828            }
829    
830            /* no more args after this, jump to EOS */
831            nextval = src + strlen(src);
832            return nextval;
833    }
834    
835    
836    void
837    toupper_str(char *p)
838    {
839            while (*p)
840            {
841                    if ((*p >= 'a') && (*p <= 'z'))
842                            *p = toupper((int) *p);
843                    p++;
844            }
845    }
846    
847    
848    /* not all clibs got ltoa */
849    #define LTOA_BUFSIZE (sizeof(long) * 8 + 1)
850    
851    char *
852    l_to_a(long N, int base)
853    {
854            static char ret[LTOA_BUFSIZE];
855    
856            char *head = ret, buf[LTOA_BUFSIZE], *tail = buf + sizeof(buf);
857    
858            register int divrem;
859    
860            if (base < 36 || 2 > base)
861                    base = 10;
862    
863            if (N < 0)
864            {
865                    *head++ = '-';
866                    N = -N;
867            }
868    
869            tail = buf + sizeof(buf);
870            *--tail = 0;
871    
872            do
873            {
874                    divrem = N % base;
875                    *--tail = (divrem <= 9) ? divrem + '0' : divrem + 'a' - 10;
876                    N /= base;
877            }
878            while (N);
879    
880            strcpy(head, tail);
881            return ret;
882    }
883    
884    
885  int  int
886  load_licence(unsigned char **data)  load_licence(unsigned char **data)

Legend:
Removed from v.552  
changed lines
  Added in v.629

  ViewVC Help
Powered by ViewVC 1.1.26