/[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 520 by matthewc, Tue Oct 28 05:07:00 2003 UTC revision 575 by n-ki, Thu Jan 22 09:03:06 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 66  BOOL g_grab_keyboard = True; Line 67  BOOL g_grab_keyboard = True;
67  BOOL g_hide_decorations = False;  BOOL g_hide_decorations = False;
68  BOOL g_use_rdp5 = True;  BOOL g_use_rdp5 = True;
69  BOOL g_console_session = False;  BOOL g_console_session = False;
70    BOOL g_numlock_sync = False;
71  extern BOOL g_owncolmap;  extern BOOL g_owncolmap;
72    
73  #ifdef WITH_RDPSND  #ifdef WITH_RDPSND
74  BOOL g_rdpsnd = False;  BOOL g_rdpsnd = False;
75  #endif  #endif
76    
77    extern RDPDR_DEVICE g_rdpdr_device[];
78    extern uint32 g_num_devices;
79    
80  #ifdef RDP2VNC  #ifdef RDP2VNC
81  extern int rfb_port;  extern int rfb_port;
82  extern int defer_time;  extern int defer_time;
# Line 110  usage(char *program) Line 115  usage(char *program)
115          fprintf(stderr, "   -K: keep window manager key bindings\n");          fprintf(stderr, "   -K: keep window manager key bindings\n");
116          fprintf(stderr, "   -S: caption button size (single application mode)\n");          fprintf(stderr, "   -S: caption button size (single application mode)\n");
117          fprintf(stderr, "   -T: window title\n");          fprintf(stderr, "   -T: window title\n");
118            fprintf(stderr, "   -N: enable numlock syncronization\n");
119          fprintf(stderr, "   -a: connection colour depth\n");          fprintf(stderr, "   -a: connection colour depth\n");
120          fprintf(stderr, "   -r: enable specified device redirection (currently: sound)\n");          fprintf(stderr, "   -r: enable specified device redirection (this flag can be repeated)\n");
121            fprintf(stderr, "         '-r comport:COM1=/dev/ttyS0': enable serial redirection of /dev/ttyS0 to COM1\n");
122            fprintf(stderr, "             or    :COM1=/dev/ttyS0:9600,0|1|2,0|2,5|6|7|8:dtr \n");
123            fprintf(stderr, "         '-r disk:A=/mnt/floppy': enable redirection of /mnt/floppy to A:\n");
124            fprintf(stderr, "             or   A=/mnt/floppy,D=/mnt/cdrom'\n");
125            fprintf(stderr, "         '-r lptport:LPT1=/dev/lp0': enable parallel redirection of /dev/lp0 to LPT1\n");
126            fprintf(stderr, "             or       LPT1=/dev/lp0,LPT2=/dev/lp1\n");
127            fprintf(stderr, "         '-r printer:mydeskjet': enable printer redirection\n");
128            fprintf(stderr, "             or       mydeskjet:\"HP Laserjet IIIP\" to enter server driver as well\n");
129            fprintf(stderr, "         '-r sound': enable sound redirection\n");
130          fprintf(stderr, "   -0: attach to console\n");          fprintf(stderr, "   -0: attach to console\n");
131          fprintf(stderr, "   -4: use RDP version 4\n");          fprintf(stderr, "   -4: use RDP version 4\n");
132          fprintf(stderr, "   -5: use RDP version 5 (default)\n");          fprintf(stderr, "   -5: use RDP version 5 (default)\n");
# Line 216  main(int argc, char *argv[]) Line 231  main(int argc, char *argv[])
231          uint32 flags;          uint32 flags;
232          char *p;          char *p;
233          int c;          int c;
234    
235          int username_option = 0;          int username_option = 0;
236    
237          flags = RDP_LOGON_NORMAL;          flags = RDP_LOGON_NORMAL;
# Line 223  main(int argc, char *argv[]) Line 239  main(int argc, char *argv[])
239          domain[0] = password[0] = shell[0] = directory[0] = 0;          domain[0] = password[0] = shell[0] = directory[0] = 0;
240          strcpy(keymapname, "en-us");          strcpy(keymapname, "en-us");
241    
242            g_num_devices = 0;
243    
244  #ifdef RDP2VNC  #ifdef RDP2VNC
245  #define VNCOPT "V:Q:"  #define VNCOPT "V:Q:"
246  #else  #else
247  #define VNCOPT  #define VNCOPT
248  #endif  #endif
249    
250          while ((c = getopt(argc, argv, VNCOPT "u:d:s:c:p:n:k:g:fbeEmCDKS:T:a:r:045h?")) != -1)          while ((c = getopt(argc, argv, VNCOPT "u:d:s:c:p:n:k:g:fbeEmCDKS:T:Na:r:045h?")) != -1)
251          {          {
252                  switch (c)                  switch (c)
253                  {                  {
# Line 289  main(int argc, char *argv[]) Line 307  main(int argc, char *argv[])
307                                  break;                                  break;
308    
309                          case 'g':                          case 'g':
310                                    g_fullscreen = False;
311                                  if (!strcmp(optarg, "workarea"))                                  if (!strcmp(optarg, "workarea"))
312                                  {                                  {
313                                          g_width = g_height = 0;                                          g_width = g_height = 0;
# Line 367  main(int argc, char *argv[]) Line 386  main(int argc, char *argv[])
386                                  STRNCPY(g_title, optarg, sizeof(g_title));                                  STRNCPY(g_title, optarg, sizeof(g_title));
387                                  break;                                  break;
388    
389                            case 'N':
390                                    g_numlock_sync = True;
391                                    break;
392    
393                          case 'a':                          case 'a':
394                                  g_server_bpp = strtol(optarg, NULL, 10);                                  g_server_bpp = strtol(optarg, NULL, 10);
395                                  if (g_server_bpp != 8 && g_server_bpp != 16 && g_server_bpp != 15                                  if (g_server_bpp != 8 && g_server_bpp != 16 && g_server_bpp != 15
# Line 378  main(int argc, char *argv[]) Line 401  main(int argc, char *argv[])
401                                  break;                                  break;
402    
403                          case 'r':                          case 'r':
404                                  if (!strcmp(optarg, "sound"))  
405                                    if (strncmp("sound", optarg, 5) == 0)
406                                    {
407  #ifdef WITH_RDPSND  #ifdef WITH_RDPSND
408                                          g_rdpsnd = True;                                          g_rdpsnd = True;
409  #else  #else
410                                          warning("Not compiled with sound support");                                          warning("Not compiled with sound support");
411  #endif  #endif
412                                    }
413                                    else if (strncmp("disk", optarg, 4) == 0)
414                                    {
415                                            /* -r disk:h:=/mnt/floppy */
416                                            disk_enum_devices(&g_num_devices, optarg + 4);
417                                    }
418                                    else if (strncmp("comport", optarg, 7) == 0)
419                                    {
420                                            serial_enum_devices(&g_num_devices, optarg + 7);
421                                    }
422                                    else if (strncmp("lptport", optarg, 7) == 0)
423                                    {
424                                            parallel_enum_devices(&g_num_devices, optarg + 7);
425                                    }
426                                    else if (strncmp("printer", optarg, 7) == 0)
427                                    {
428                                            printer_enum_devices(&g_num_devices, optarg + 7);
429                                    }
430                                    else
431                                    {
432                                            warning("Unknown -r argument\n\n\tPossible arguments are: comport, disk, lptport, printer, sound\n");
433                                    }
434                                  break;                                  break;
435    
436                          case '0':                          case '0':
# Line 463  main(int argc, char *argv[]) Line 510  main(int argc, char *argv[])
510          if (g_rdpsnd)          if (g_rdpsnd)
511                  rdpsnd_init();                  rdpsnd_init();
512  #endif  #endif
513          /* rdpdr_init(); */          rdpdr_init();
514    
515          if (!rdp_connect(server, flags, domain, password, shell, directory))          if (!rdp_connect(server, flags, domain, password, shell, directory))
516                  return 1;                  return 1;
# Line 653  unimpl(char *format, ...) Line 700  unimpl(char *format, ...)
700    
701  /* produce a hex dump */  /* produce a hex dump */
702  void  void
703  hexdump(unsigned char *p, int len)  hexdump(unsigned char *p, unsigned int len)
704  {  {
705          unsigned char *line = p;          unsigned char *line = p;
706          int i, thisline, offset = 0;          int i, thisline, offset = 0;
# Line 680  hexdump(unsigned char *p, int len) Line 727  hexdump(unsigned char *p, int len)
727          }          }
728  }  }
729    
730    /*
731      input: src is the string we look in for needle
732      return value: returns next src pointer, for
733            succesive executions, like in a while loop
734            if retval is 0, then there are no more args.
735      pitfalls:
736            src is modified. 0x00 chars are inserted to
737            terminate strings.
738            return val, points on the next val chr after ins
739            0x00
740    
741            example usage:
742            while( (pos = next_arg( optarg, ',')) ){
743                    printf("%s\n",optarg);
744                    optarg=pos;
745            }
746    
747    */
748    char *
749    next_arg(char *src, char needle)
750    {
751            char *nextval;
752            char *p;
753            char *mvp = 0;
754    
755            /* EOS */
756            if (*src == (char) 0x00)
757                    return 0;
758    
759            p = src;
760            /*  skip escaped needles */
761            while( (nextval = strchr(p, needle) ) )
762            {
763                    mvp = nextval - 1;
764                    /* found backslashed needle */
765                    if( *mvp == '\\' && (mvp > src) )
766                    {
767                            /* move string one to the left */
768                            while( *(mvp+1) != (char)0x00 )
769                            {
770                                    *mvp = *(mvp+1);
771                                    *mvp++;
772                            }
773                            *mvp = (char)0x00;
774                            p = nextval;
775                    }
776                    else
777                    {
778                            p = nextval +1;
779                            break;
780                    }
781    
782            }
783    
784            /* more args available */
785            if (nextval)
786            {
787                    *nextval = (char) 0x00;
788                    return ++nextval;
789            }
790    
791            /* no more args after this, jump to EOS */
792            nextval = src + strlen(src);
793            return nextval;
794    }
795    
796    
797    void
798    toupper_str(char* p)
799    {
800            while( *p ){
801                    if( (*p >= 'a') && (*p <= 'z') )
802                            *p = toupper((int) *p);
803                    p++;
804            }
805    }
806    
807    
808    /* not all clibs got ltoa */
809    #define LTOA_BUFSIZE (sizeof(long) * 8 + 1)
810    
811    char *
812    ltoa(long N, int base)
813    {
814            static char ret[LTOA_BUFSIZE];
815    
816            register int i = 2;
817            long uarg;
818            char *tail, *head = ret, buf[LTOA_BUFSIZE];
819    
820            if (36 < base || 2 > base)
821                    base = 10;
822    
823            tail = &buf[LTOA_BUFSIZE - 1];
824            *tail-- = '\0';
825    
826            if (10 == base && N < 0L)
827            {
828                    *head++ = '-';
829                    uarg = -N;
830            }
831            else
832                    uarg = N;
833    
834            if (uarg)
835            {
836                    for (i = 1; uarg; ++i)
837                    {
838                            register ldiv_t r;
839    
840                            r = ldiv(uarg, base);
841                            *tail-- = (char) (r.rem + ((9L < r.rem) ? ('A' - 10L) : '0'));
842                            uarg = r.quot;
843                    }
844            }
845            else
846                    *tail-- = '0';
847    
848            memcpy(head, ++tail, i);
849            return ret;
850    }
851    
852    
853  int  int
854  load_licence(unsigned char **data)  load_licence(unsigned char **data)

Legend:
Removed from v.520  
changed lines
  Added in v.575

  ViewVC Help
Powered by ViewVC 1.1.26