Created
March 4, 2018 05:31
-
-
Save jeandrek/2b69f0592ec75700d09df5b5c81359ca to your computer and use it in GitHub Desktop.
Windows patch for 4.4BSD uudecode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- ../Downloads/uudecode.c 1994-04-03 06:16:37 +1200 | |
+++ uudecode.c 2018-03-04 18:23:50 +1300 | |
@@ -50,8 +50,8 @@ | |
#include <sys/param.h> | |
#include <sys/stat.h> | |
-#include <pwd.h> | |
#include <stdio.h> | |
+#include <stdlib.h> | |
#include <string.h> | |
char *filename; | |
@@ -85,7 +85,6 @@ | |
decode() | |
{ | |
extern int errno; | |
- struct passwd *pw; | |
register int n; | |
register char ch, *p; | |
int mode, n1; | |
@@ -103,32 +102,11 @@ | |
/* handle ~user/file format */ | |
if (buf[0] == '~') { | |
- if (!(p = index(buf, '/'))) { | |
- (void)fprintf(stderr, "uudecode: %s: illegal ~user.\n", | |
- filename); | |
- return(1); | |
- } | |
- *p++ = NULL; | |
- if (!(pw = getpwnam(buf + 1))) { | |
- (void)fprintf(stderr, "uudecode: %s: no user %s.\n", | |
- filename, buf); | |
- return(1); | |
- } | |
- n = strlen(pw->pw_dir); | |
- n1 = strlen(p); | |
- if (n + n1 + 2 > MAXPATHLEN) { | |
- (void)fprintf(stderr, "uudecode: %s: path too long.\n", | |
- filename); | |
- return(1); | |
- } | |
- bcopy(p, buf + n + 1, n1 + 1); | |
- bcopy(pw->pw_dir, buf, n); | |
- buf[n] = '/'; | |
} | |
/* create output file, set mode */ | |
if (!freopen(buf, "w", stdout) || | |
- fchmod(fileno(stdout), mode&0666)) { | |
+ _chmod(buf, mode&0666)) { | |
(void)fprintf(stderr, "uudecode: %s: %s: %s\n", buf, | |
filename, strerror(errno)); | |
return(1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment