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

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

revision 569 by n-ki, Wed Jan 21 14:40:40 2004 UTC revision 603 by stargo, Sat Feb 7 18:47: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 118  usage(char *program) Line 119  usage(char *program)
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, "         '-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");          fprintf(stderr, "             or      COM1=/dev/ttyS0,COM2=/dev/ttyS1\n");
123          fprintf(stderr, "         '-r disk:A=/mnt/floppy': enable redirection of /mnt/floppy to A:\n");          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");          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");          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");          fprintf(stderr, "             or      LPT1=/dev/lp0,LPT2=/dev/lp1\n");
127          fprintf(stderr, "         '-r printer:mydeskjet': enable printer redirection\n");          fprintf(stderr, "         '-r printer:mydeskjet': enable printer redirection\n");
128          fprintf(stderr, "             or       mydeskjet:\"HP Laserjet IIIP\" to enter server driver as well\n");          fprintf(stderr, "             or       mydeskjet=\"HP LaserJet IIIP\" to enter server driver as well\n");
129          fprintf(stderr, "         '-r sound': enable sound redirection\n");          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");
# Line 727  hexdump(unsigned char *p, unsigned int l Line 728  hexdump(unsigned char *p, unsigned int l
728  }  }
729    
730  /*  /*
731    input: src is the string we look in for needle    input: src is the string we look in for needle.
732             Needle may be escaped by a backslash, in
733             that case we ignore that particular needle.
734    return value: returns next src pointer, for    return value: returns next src pointer, for
735          succesive executions, like in a while loop          succesive executions, like in a while loop
736          if retval is 0, then there are no more args.          if retval is 0, then there are no more args.
# Line 748  char * Line 751  char *
751  next_arg(char *src, char needle)  next_arg(char *src, char needle)
752  {  {
753          char *nextval;          char *nextval;
754            char *p;
755            char *mvp = 0;
756    
757          // EOS          /* EOS */
758          if (*src == (char) 0x00)          if (*src == (char) 0x00)
759                  return 0;                  return 0;
760    
761          // more args available.          p = src;
762          nextval = strchr(src, needle);          /*  skip escaped needles */
763            while ((nextval = strchr(p, needle)))
764            {
765                    mvp = nextval - 1;
766                    /* found backslashed needle */
767                    if (*mvp == '\\' && (mvp > src))
768                    {
769                            /* move string one to the left */
770                            while (*(mvp + 1) != (char) 0x00)
771                            {
772                                    *mvp = *(mvp + 1);
773                                    *mvp++;
774                            }
775                            *mvp = (char) 0x00;
776                            p = nextval;
777                    }
778                    else
779                    {
780                            p = nextval + 1;
781                            break;
782                    }
783    
784            }
785    
786            /* more args available */
787          if (nextval)          if (nextval)
788          {          {
789                  *nextval = (char) 0x00;                  *nextval = (char) 0x00;
790                  return ++nextval;                  return ++nextval;
791          }          }
792    
793          // no more args after this, jump to EOS          /* no more args after this, jump to EOS */
794          nextval = src + strlen(src);          nextval = src + strlen(src);
795          return nextval;          return nextval;
796  }  }
797    
798    
799  char *  void
800  toupper(char* p)  toupper_str(char *p)
801  {  {
802          while( *p ){          while (*p)
803                  if( (*p >= 'a') && (*p <= 'z') )          {
804                          *p = *p - 32;                  if ((*p >= 'a') && (*p <= 'z'))
805                            *p = toupper((int) *p);
806                  p++;                  p++;
807          }          }
808  }  }
# Line 782  toupper(char* p) Line 812  toupper(char* p)
812  #define LTOA_BUFSIZE (sizeof(long) * 8 + 1)  #define LTOA_BUFSIZE (sizeof(long) * 8 + 1)
813    
814  char *  char *
815  ltoa(long N, int base)  l_to_a(long N, int base)
816  {  {
817          static char ret[LTOA_BUFSIZE];          static char ret[LTOA_BUFSIZE];
818    
819          register int i = 2;          char *head = ret, buf[LTOA_BUFSIZE], *tail = buf + sizeof(buf);
         long uarg;  
         char *tail, *head = ret, buf[LTOA_BUFSIZE];  
820    
821          if (36 < base || 2 > base)          register int divrem;
                 base = 10;  
822    
823          tail = &buf[LTOA_BUFSIZE - 1];          if (base < 36 || 2 > base)
824          *tail-- = '\0';                  base = 10;
825    
826          if (10 == base && N < 0L)          if (N < 0)
827          {          {
828                  *head++ = '-';                  *head++ = '-';
829                  uarg = -N;                  N = -N;
830          }          }
         else  
                 uarg = N;  
831    
832          if (uarg)          tail = buf + sizeof(buf);
833          {          *--tail = 0;
                 for (i = 1; uarg; ++i)  
                 {  
                         register ldiv_t r;  
834    
835                          r = ldiv(uarg, base);          do
836                          *tail-- = (char) (r.rem + ((9L < r.rem) ? ('A' - 10L) : '0'));          {
837                          uarg = r.quot;                  divrem = N % base;
838                  }                  *--tail = (divrem <= 9) ? divrem + '0' : divrem + 'a' - 10;
839                    N /= base;
840          }          }
841          else          while (N);
                 *tail-- = '0';  
842    
843          memcpy(head, ++tail, i);          strcpy(head, tail);
844          return ret;          return ret;
845  }  }
846    

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

  ViewVC Help
Powered by ViewVC 1.1.26