549 |
|
|
550 |
/* produce a hex dump */ |
/* produce a hex dump */ |
551 |
void |
void |
552 |
hexdump(unsigned char *p, unsigned int len) |
hexdump(unsigned char *p, int len) |
553 |
{ |
{ |
554 |
unsigned char *line = p; |
unsigned char *line = p; |
555 |
unsigned int thisline, offset = 0; |
int i, thisline, offset = 0; |
|
int i; |
|
556 |
|
|
557 |
while (offset < len) |
while (offset < len) |
558 |
{ |
{ |
588 |
if (home == NULL) |
if (home == NULL) |
589 |
return -1; |
return -1; |
590 |
|
|
591 |
path = xmalloc(strlen(home) + strlen(hostname) + sizeof("/.rdesktop/licence.")); |
path = (char*)xmalloc(strlen(home) + strlen(hostname) + sizeof("/.rdesktop/licence.")); |
592 |
sprintf(path, "%s/.rdesktop/licence.%s", home, hostname); |
sprintf(path, "%s/.rdesktop/licence.%s", home, hostname); |
593 |
|
|
594 |
fd = open(path, O_RDONLY); |
fd = open(path, O_RDONLY); |
598 |
if (fstat(fd, &st)) |
if (fstat(fd, &st)) |
599 |
return -1; |
return -1; |
600 |
|
|
601 |
*data = xmalloc(st.st_size); |
*data = (uint8*)xmalloc(st.st_size); |
602 |
length = read(fd, *data, st.st_size); |
length = read(fd, *data, st.st_size); |
603 |
close(fd); |
close(fd); |
604 |
xfree(path); |
xfree(path); |
615 |
if (home == NULL) |
if (home == NULL) |
616 |
return; |
return; |
617 |
|
|
618 |
path = xmalloc(strlen(home) + strlen(hostname) + sizeof("/.rdesktop/licence.")); |
path = (char*)xmalloc(strlen(home) + strlen(hostname) + sizeof("/.rdesktop/licence.")); |
619 |
|
|
620 |
sprintf(path, "%s/.rdesktop", home); |
sprintf(path, "%s/.rdesktop", home); |
621 |
if ((mkdir(path, 0700) == -1) && errno != EEXIST) |
if ((mkdir(path, 0700) == -1) && errno != EEXIST) |
627 |
/* write licence to licence.hostname.new, then atomically rename to licence.hostname */ |
/* write licence to licence.hostname.new, then atomically rename to licence.hostname */ |
628 |
|
|
629 |
sprintf(path, "%s/.rdesktop/licence.%s", home, hostname); |
sprintf(path, "%s/.rdesktop/licence.%s", home, hostname); |
630 |
tmppath = xmalloc(strlen(path) + sizeof(".new")); |
tmppath = (char*)xmalloc(strlen(path) + sizeof(".new")); |
631 |
strcpy(tmppath, path); |
strcpy(tmppath, path); |
632 |
strcat(tmppath, ".new"); |
strcat(tmppath, ".new"); |
633 |
|
|