/[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 21 by matty, Mon Oct 16 08:44:48 2000 UTC revision 25 by matty, Sat Jan 6 03:47:04 2001 UTC
# Line 18  Line 18 
18     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19  */  */
20    
21  #include <stdlib.h>     /* malloc realloc free */  #include <stdlib.h>             /* malloc realloc free */
22  #include <unistd.h>     /* read close getuid getgid getpid getppid gethostname */  #include <unistd.h>             /* read close getuid getgid getpid getppid gethostname */
23  #include <fcntl.h>      /* open */  #include <fcntl.h>              /* open */
24  #include <pwd.h>        /* getpwuid */  #include <pwd.h>                /* getpwuid */
25  #include <sys/stat.h>   /* stat */  #include <sys/stat.h>           /* stat */
26  #include <sys/time.h>   /* gettimeofday */  #include <sys/time.h>           /* gettimeofday */
27  #include <sys/times.h>  /* times */  #include <sys/times.h>          /* times */
28  #include "rdesktop.h"  #include "rdesktop.h"
29    
30  char username[16];  char username[16];
# Line 37  BOOL orders = True; Line 37  BOOL orders = True;
37  BOOL licence = True;  BOOL licence = True;
38    
39  /* Display usage information */  /* Display usage information */
40  static void usage(char *program)  static void
41    usage(char *program)
42  {  {
43          STATUS("Usage: %s [options] server\n", program);          STATUS("Usage: %s [options] server\n", program);
44          STATUS("   -u: user name\n");          STATUS("   -u: user name\n");
# Line 55  static void usage(char *program) Line 56  static void usage(char *program)
56  }  }
57    
58  /* Client program */  /* Client program */
59  int main(int argc, char *argv[])  int
60    main(int argc, char *argv[])
61  {  {
62          struct passwd *pw;          struct passwd *pw;
63          char *server;          char *server;
# Line 68  int main(int argc, char *argv[]) Line 70  int main(int argc, char *argv[])
70          int c;          int c;
71    
72          STATUS("rdesktop: A Remote Desktop Protocol client.\n");          STATUS("rdesktop: A Remote Desktop Protocol client.\n");
73          STATUS("Version "VERSION". Copyright (C) 1999-2000 Matt Chapman.\n");          STATUS("Version " VERSION
74                   ". Copyright (C) 1999-2000 Matt Chapman.\n");
75          STATUS("See http://www.rdesktop.org/ for more information.\n\n");          STATUS("See http://www.rdesktop.org/ for more information.\n\n");
76    
77          flags = RDP_LOGON_NORMAL;          flags = RDP_LOGON_NORMAL;
# Line 182  int main(int argc, char *argv[]) Line 185  int main(int argc, char *argv[])
185  }  }
186    
187  /* Generate a 32-byte random for the secure transport code. */  /* Generate a 32-byte random for the secure transport code. */
188  void generate_random(uint8 *random)  void
189    generate_random(uint8 *random)
190  {  {
191          struct stat st;          struct stat st;
192          uint32 *r = (uint32 *)random;          struct tms tmsbuf;
193            uint32 *r = (uint32 *) random;
194          int fd;          int fd;
195    
196          /* If we have a kernel random device, use it. */          /* If we have a kernel random device, use it. */
# Line 199  void generate_random(uint8 *random) Line 204  void generate_random(uint8 *random)
204          /* Otherwise use whatever entropy we can gather - ideas welcome. */          /* Otherwise use whatever entropy we can gather - ideas welcome. */
205          r[0] = (getpid()) | (getppid() << 16);          r[0] = (getpid()) | (getppid() << 16);
206          r[1] = (getuid()) | (getgid() << 16);          r[1] = (getuid()) | (getgid() << 16);
207          r[2] = times(NULL); /* system uptime (clocks) */          r[2] = times(&tmsbuf);  /* system uptime (clocks) */
208          gettimeofday((struct timeval *)&r[3], NULL); /* sec and usec */          gettimeofday((struct timeval *) &r[3], NULL);   /* sec and usec */
209          stat("/tmp", &st);          stat("/tmp", &st);
210          r[5] = st.st_atime;          r[5] = st.st_atime;
211          r[6] = st.st_mtime;          r[6] = st.st_mtime;
# Line 208  void generate_random(uint8 *random) Line 213  void generate_random(uint8 *random)
213  }  }
214    
215  /* malloc; exit if out of memory */  /* malloc; exit if out of memory */
216  void *xmalloc(int size)  void *
217    xmalloc(int size)
218  {  {
219          void *mem = malloc(size);          void *mem = malloc(size);
220          if (mem == NULL)          if (mem == NULL)
# Line 220  void *xmalloc(int size) Line 226  void *xmalloc(int size)
226  }  }
227    
228  /* realloc; exit if out of memory */  /* realloc; exit if out of memory */
229  void *xrealloc(void *oldmem, int size)  void *
230    xrealloc(void *oldmem, int size)
231  {  {
232          void *mem = realloc(oldmem, size);          void *mem = realloc(oldmem, size);
233          if (mem == NULL)          if (mem == NULL)
# Line 232  void *xrealloc(void *oldmem, int size) Line 239  void *xrealloc(void *oldmem, int size)
239  }  }
240    
241  /* free */  /* free */
242  void xfree(void *mem)  void
243    xfree(void *mem)
244  {  {
245          free(mem);          free(mem);
246  }  }
247    
248  /* Produce a hex dump */  /* Produce a hex dump */
249  void hexdump(unsigned char *p, unsigned int len)  void
250    hexdump(unsigned char *p, unsigned int len)
251  {  {
252          unsigned char *line = p;          unsigned char *line = p;
253          unsigned int thisline, offset = 0;          unsigned int thisline, offset = 0;
# Line 252  void hexdump(unsigned char *p, unsigned Line 261  void hexdump(unsigned char *p, unsigned
261                          thisline = 16;                          thisline = 16;
262    
263                  for (i = 0; i < thisline; i++)                  for (i = 0; i < thisline; i++)
264                          STATUS("%02x ", line[i])                          STATUS("%02x ", line[i]) for (; i < 16; i++)
265                                    STATUS("   ");
                 for (; i < 16; i++)  
                         STATUS("   ");  
266    
267                  for (i = 0; i < thisline; i++)                  for (i = 0; i < thisline; i++)
268                          STATUS("%c", (line[i] >= 0x20 && line[i] < 0x7f) ? line[i] : '.');                          STATUS("%c",
269                                   (line[i] >= 0x20
270                                    && line[i] < 0x7f) ? line[i] : '.');
271    
272                  STATUS("\n");                  STATUS("\n");
273                  offset += thisline;                  offset += thisline;

Legend:
Removed from v.21  
changed lines
  Added in v.25

  ViewVC Help
Powered by ViewVC 1.1.26