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

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

revision 567 by matthewc, Wed Jan 21 11:08:39 2004 UTC revision 569 by n-ki, Wed Jan 21 14:40:40 2004 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-2004     Copyright (C) Matthew Chapman 1999-2003
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 73  extern BOOL g_owncolmap; Line 73  extern BOOL g_owncolmap;
73  BOOL g_rdpsnd = False;  BOOL g_rdpsnd = False;
74  #endif  #endif
75    
76    extern RDPDR_DEVICE g_rdpdr_device[];
77    extern uint32 g_num_devices;
78    
79  #ifdef RDP2VNC  #ifdef RDP2VNC
80  extern int rfb_port;  extern int rfb_port;
81  extern int defer_time;  extern int defer_time;
# Line 111  usage(char *program) Line 114  usage(char *program)
114          fprintf(stderr, "   -K: keep window manager key bindings\n");          fprintf(stderr, "   -K: keep window manager key bindings\n");
115          fprintf(stderr, "   -S: caption button size (single application mode)\n");          fprintf(stderr, "   -S: caption button size (single application mode)\n");
116          fprintf(stderr, "   -T: window title\n");          fprintf(stderr, "   -T: window title\n");
117          fprintf(stderr, "   -N: enable numlock synchronisation\n");          fprintf(stderr, "   -N: enable numlock syncronization\n");
118          fprintf(stderr, "   -a: connection colour depth\n");          fprintf(stderr, "   -a: connection colour depth\n");
119          fprintf(stderr, "   -r: enable specified device redirection (currently: sound)\n");          fprintf(stderr, "   -r: enable specified device redirection (this flag can be repeated)\n");
120            fprintf(stderr, "         '-r comport:COM1=/dev/ttyS0': enable serial redirection of /dev/ttyS0 to COM1\n");
121            fprintf(stderr, "             or    :COM1=/dev/ttyS0:9600,0|1|2,0|2,5|6|7|8:dtr \n");
122            fprintf(stderr, "         '-r disk:A=/mnt/floppy': enable redirection of /mnt/floppy to A:\n");
123            fprintf(stderr, "             or   A=/mnt/floppy,D=/mnt/cdrom'\n");
124            fprintf(stderr, "         '-r lptport:LPT1=/dev/lp0': enable parallel redirection of /dev/lp0 to LPT1\n");
125            fprintf(stderr, "             or       LPT1=/dev/lp0,LPT2=/dev/lp1\n");
126            fprintf(stderr, "         '-r printer:mydeskjet': enable printer redirection\n");
127            fprintf(stderr, "             or       mydeskjet:\"HP Laserjet IIIP\" to enter server driver as well\n");
128            fprintf(stderr, "         '-r sound': enable sound redirection\n");
129          fprintf(stderr, "   -0: attach to console\n");          fprintf(stderr, "   -0: attach to console\n");
130          fprintf(stderr, "   -4: use RDP version 4\n");          fprintf(stderr, "   -4: use RDP version 4\n");
131          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 230  main(int argc, char *argv[])
230          uint32 flags;          uint32 flags;
231          char *p;          char *p;
232          int c;          int c;
233    
234          int username_option = 0;          int username_option = 0;
235    
236          flags = RDP_LOGON_NORMAL;          flags = RDP_LOGON_NORMAL;
# Line 225  main(int argc, char *argv[]) Line 238  main(int argc, char *argv[])
238          domain[0] = password[0] = shell[0] = directory[0] = 0;          domain[0] = password[0] = shell[0] = directory[0] = 0;
239          strcpy(keymapname, "en-us");          strcpy(keymapname, "en-us");
240    
241            g_num_devices = 0;
242    
243  #ifdef RDP2VNC  #ifdef RDP2VNC
244  #define VNCOPT "V:Q:"  #define VNCOPT "V:Q:"
245  #else  #else
# Line 385  main(int argc, char *argv[]) Line 400  main(int argc, char *argv[])
400                                  break;                                  break;
401    
402                          case 'r':                          case 'r':
403                                  if (!strcmp(optarg, "sound"))  
404                                    if (strncmp("sound", optarg, 5) == 0)
405                                    {
406  #ifdef WITH_RDPSND  #ifdef WITH_RDPSND
407                                          g_rdpsnd = True;                                          g_rdpsnd = True;
408  #else  #else
409                                          warning("Not compiled with sound support");                                          warning("Not compiled with sound support");
410  #endif  #endif
411                                    }
412                                    else if (strncmp("disk", optarg, 4) == 0)
413                                    {
414                                            /* -r disk:h:=/mnt/floppy */
415                                            disk_enum_devices(&g_num_devices, optarg + 4);
416                                    }
417                                    else if (strncmp("comport", optarg, 7) == 0)
418                                    {
419                                            serial_enum_devices(&g_num_devices, optarg + 7);
420                                    }
421                                    else if (strncmp("lptport", optarg, 7) == 0)
422                                    {
423                                            parallel_enum_devices(&g_num_devices, optarg + 7);
424                                    }
425                                    else if (strncmp("printer", optarg, 7) == 0)
426                                    {
427                                            printer_enum_devices(&g_num_devices, optarg + 7);
428                                    }
429                                    else
430                                    {
431                                            warning("Unknown -r argument\n\n\tPossible arguments are: comport, disk, lptport, printer, sound\n");
432                                    }
433                                  break;                                  break;
434    
435                          case '0':                          case '0':
# Line 470  main(int argc, char *argv[]) Line 509  main(int argc, char *argv[])
509          if (g_rdpsnd)          if (g_rdpsnd)
510                  rdpsnd_init();                  rdpsnd_init();
511  #endif  #endif
512          /* rdpdr_init(); */          rdpdr_init();
513    
514          if (!rdp_connect(server, flags, domain, password, shell, directory))          if (!rdp_connect(server, flags, domain, password, shell, directory))
515                  return 1;                  return 1;
# Line 660  unimpl(char *format, ...) Line 699  unimpl(char *format, ...)
699    
700  /* produce a hex dump */  /* produce a hex dump */
701  void  void
702  hexdump(unsigned char *p, int len)  hexdump(unsigned char *p, unsigned int len)
703  {  {
704          unsigned char *line = p;          unsigned char *line = p;
705          int i, thisline, offset = 0;          int i, thisline, offset = 0;
# Line 687  hexdump(unsigned char *p, int len) Line 726  hexdump(unsigned char *p, int len)
726          }          }
727  }  }
728    
729    /*
730      input: src is the string we look in for needle
731      return value: returns next src pointer, for
732            succesive executions, like in a while loop
733            if retval is 0, then there are no more args.
734      pitfalls:
735            src is modified. 0x00 chars are inserted to
736            terminate strings.
737            return val, points on the next val chr after ins
738            0x00
739    
740            example usage:
741            while( (pos = next_arg( optarg, ',')) ){
742                    printf("%s\n",optarg);
743                    optarg=pos;
744            }
745    
746    */
747    char *
748    next_arg(char *src, char needle)
749    {
750            char *nextval;
751    
752            // EOS
753            if (*src == (char) 0x00)
754                    return 0;
755    
756            // more args available.
757            nextval = strchr(src, needle);
758            if (nextval)
759            {
760                    *nextval = (char) 0x00;
761                    return ++nextval;
762            }
763    
764            // no more args after this, jump to EOS
765            nextval = src + strlen(src);
766            return nextval;
767    }
768    
769    
770    char *
771    toupper(char* p)
772    {
773            while( *p ){
774                    if( (*p >= 'a') && (*p <= 'z') )
775                            *p = *p - 32;
776                    p++;
777            }
778    }
779    
780    
781    /* not all clibs got ltoa */
782    #define LTOA_BUFSIZE (sizeof(long) * 8 + 1)
783    
784    char *
785    ltoa(long N, int base)
786    {
787            static char ret[LTOA_BUFSIZE];
788    
789            register int i = 2;
790            long uarg;
791            char *tail, *head = ret, buf[LTOA_BUFSIZE];
792    
793            if (36 < base || 2 > base)
794                    base = 10;
795    
796            tail = &buf[LTOA_BUFSIZE - 1];
797            *tail-- = '\0';
798    
799            if (10 == base && N < 0L)
800            {
801                    *head++ = '-';
802                    uarg = -N;
803            }
804            else
805                    uarg = N;
806    
807            if (uarg)
808            {
809                    for (i = 1; uarg; ++i)
810                    {
811                            register ldiv_t r;
812    
813                            r = ldiv(uarg, base);
814                            *tail-- = (char) (r.rem + ((9L < r.rem) ? ('A' - 10L) : '0'));
815                            uarg = r.quot;
816                    }
817            }
818            else
819                    *tail-- = '0';
820    
821            memcpy(head, ++tail, i);
822            return ret;
823    }
824    
825    
826  int  int
827  load_licence(unsigned char **data)  load_licence(unsigned char **data)

Legend:
Removed from v.567  
changed lines
  Added in v.569

  ViewVC Help
Powered by ViewVC 1.1.26