/[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 570 by stargo, Wed Jan 21 18:02:38 2004 UTC revision 608 by astrand, Sun Feb 15 21:19:28 2004 UTC
# Line 118  usage(char *program) Line 118  usage(char *program)
118          fprintf(stderr, "   -N: enable numlock syncronization\n");          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 (this flag can be repeated)\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");          fprintf(stderr,
122          fprintf(stderr, "             or    :COM1=/dev/ttyS0:9600,0|1|2,0|2,5|6|7|8:dtr \n");                  "         '-r comport:COM1=/dev/ttyS0': enable serial redirection of /dev/ttyS0 to COM1\n");
123          fprintf(stderr, "         '-r disk:A=/mnt/floppy': enable redirection of /mnt/floppy to A:\n");          fprintf(stderr, "             or      COM1=/dev/ttyS0,COM2=/dev/ttyS1\n");
124            fprintf(stderr,
125                    "         '-r disk:A=/mnt/floppy': enable redirection of /mnt/floppy to A:\n");
126          fprintf(stderr, "             or   A=/mnt/floppy,D=/mnt/cdrom'\n");          fprintf(stderr, "             or   A=/mnt/floppy,D=/mnt/cdrom'\n");
127          fprintf(stderr, "         '-r lptport:LPT1=/dev/lp0': enable parallel redirection of /dev/lp0 to LPT1\n");          fprintf(stderr,
128          fprintf(stderr, "             or       LPT1=/dev/lp0,LPT2=/dev/lp1\n");                  "         '-r lptport:LPT1=/dev/lp0': enable parallel redirection of /dev/lp0 to LPT1\n");
129            fprintf(stderr, "             or      LPT1=/dev/lp0,LPT2=/dev/lp1\n");
130          fprintf(stderr, "         '-r printer:mydeskjet': enable printer redirection\n");          fprintf(stderr, "         '-r printer:mydeskjet': enable printer redirection\n");
131          fprintf(stderr, "             or       mydeskjet:\"HP Laserjet IIIP\" to enter server driver as well\n");          fprintf(stderr,
132                    "             or       mydeskjet=\"HP LaserJet IIIP\" to enter server driver as well\n");
133          fprintf(stderr, "         '-r sound': enable sound redirection\n");          fprintf(stderr, "         '-r sound': enable sound redirection\n");
134          fprintf(stderr, "   -0: attach to console\n");          fprintf(stderr, "   -0: attach to console\n");
135          fprintf(stderr, "   -4: use RDP version 4\n");          fprintf(stderr, "   -4: use RDP version 4\n");
# Line 728  hexdump(unsigned char *p, unsigned int l Line 732  hexdump(unsigned char *p, unsigned int l
732  }  }
733    
734  /*  /*
735    input: src is the string we look in for needle    input: src is the string we look in for needle.
736             Needle may be escaped by a backslash, in
737             that case we ignore that particular needle.
738    return value: returns next src pointer, for    return value: returns next src pointer, for
739          succesive executions, like in a while loop          succesive executions, like in a while loop
740          if retval is 0, then there are no more args.          if retval is 0, then there are no more args.
# Line 749  char * Line 755  char *
755  next_arg(char *src, char needle)  next_arg(char *src, char needle)
756  {  {
757          char *nextval;          char *nextval;
758            char *p;
759            char *mvp = 0;
760    
761          // EOS          /* EOS */
762          if (*src == (char) 0x00)          if (*src == (char) 0x00)
763                  return 0;                  return 0;
764    
765          // more args available.          p = src;
766          nextval = strchr(src, needle);          /*  skip escaped needles */
767            while ((nextval = strchr(p, needle)))
768            {
769                    mvp = nextval - 1;
770                    /* found backslashed needle */
771                    if (*mvp == '\\' && (mvp > src))
772                    {
773                            /* move string one to the left */
774                            while (*(mvp + 1) != (char) 0x00)
775                            {
776                                    *mvp = *(mvp + 1);
777                                    *mvp++;
778                            }
779                            *mvp = (char) 0x00;
780                            p = nextval;
781                    }
782                    else
783                    {
784                            p = nextval + 1;
785                            break;
786                    }
787    
788            }
789    
790            /* more args available */
791          if (nextval)          if (nextval)
792          {          {
793                  *nextval = (char) 0x00;                  *nextval = (char) 0x00;
794                  return ++nextval;                  return ++nextval;
795          }          }
796    
797          // no more args after this, jump to EOS          /* no more args after this, jump to EOS */
798          nextval = src + strlen(src);          nextval = src + strlen(src);
799          return nextval;          return nextval;
800  }  }
801    
802    
803  void  void
804  toupper_str(char* p)  toupper_str(char *p)
805  {  {
806          while( *p ){          while (*p)
807                  if( (*p >= 'a') && (*p <= 'z') )          {
808                    if ((*p >= 'a') && (*p <= 'z'))
809                          *p = toupper((int) *p);                          *p = toupper((int) *p);
810                  p++;                  p++;
811          }          }
# Line 783  toupper_str(char* p) Line 816  toupper_str(char* p)
816  #define LTOA_BUFSIZE (sizeof(long) * 8 + 1)  #define LTOA_BUFSIZE (sizeof(long) * 8 + 1)
817    
818  char *  char *
819  ltoa(long N, int base)  l_to_a(long N, int base)
820  {  {
821          static char ret[LTOA_BUFSIZE];          static char ret[LTOA_BUFSIZE];
822    
823          register int i = 2;          char *head = ret, buf[LTOA_BUFSIZE], *tail = buf + sizeof(buf);
         long uarg;  
         char *tail, *head = ret, buf[LTOA_BUFSIZE];  
824    
825          if (36 < base || 2 > base)          register int divrem;
                 base = 10;  
826    
827          tail = &buf[LTOA_BUFSIZE - 1];          if (base < 36 || 2 > base)
828          *tail-- = '\0';                  base = 10;
829    
830          if (10 == base && N < 0L)          if (N < 0)
831          {          {
832                  *head++ = '-';                  *head++ = '-';
833                  uarg = -N;                  N = -N;
834          }          }
         else  
                 uarg = N;  
835    
836          if (uarg)          tail = buf + sizeof(buf);
837          {          *--tail = 0;
                 for (i = 1; uarg; ++i)  
                 {  
                         register ldiv_t r;  
838    
839                          r = ldiv(uarg, base);          do
840                          *tail-- = (char) (r.rem + ((9L < r.rem) ? ('A' - 10L) : '0'));          {
841                          uarg = r.quot;                  divrem = N % base;
842                  }                  *--tail = (divrem <= 9) ? divrem + '0' : divrem + 'a' - 10;
843                    N /= base;
844          }          }
845          else          while (N);
                 *tail-- = '0';  
846    
847          memcpy(head, ++tail, i);          strcpy(head, tail);
848          return ret;          return ret;
849  }  }
850    

Legend:
Removed from v.570  
changed lines
  Added in v.608

  ViewVC Help
Powered by ViewVC 1.1.26