📄 uudecode.lst
字号:
PAGE 1
10-15-89
17:00:42
Line# Source Line Microsoft C Compiler Version 5.10
1 /*
2 * uudecode [input]
3 *
4 * create the specified file, decoding as you go.
5 * used with uuencode.
6 *
7 * modified for MSDOS by Kenneth J. Hendrickson
8 */
9
10 #ifndef MSDOS
11 #include <pwd.h>
12 #else
13 #include <fcntl.h>
14 #include <io.h>
15 #include <process.h>
16 #endif
17
18 #include <stdio.h>
19 #include <sys/types.h>
20 #include <sys/stat.h>
21
22 /* single character decode */
23 #define DEC(c) (((c) - ' ') & 077)
24
25 main(argc, argv)
26 char **argv;
27 {
28 FILE *in, *out;
29 struct stat sbuf;
30 int mode;
31 char dest[128];
32 char buf[80];
33
34 /* optional input arg */
35 if (argc > 1) {
36 if ((in = fopen(argv[1], "r")) == NULL) {
37 perror(argv[1]);
38 exit(1);
39 }
40 argv++; argc--;
41 } else
42 in = stdin;
43
44 if (argc != 1) {
45 printf("Usage: uudecode [infile]\n");
46 exit(2);
47 }
48
49 /* search for header line */
50 for (;;) {
51 if (fgets(buf, sizeof buf, in) == NULL) {
PAGE 2
10-15-89
17:00:42
Line# Source Line Microsoft C Compiler Version 5.10
52 fprintf(stderr, "No begin line\n");
53 exit(3);
54 }
55 if (strncmp(buf, "begin ", 6) == 0)
56 break;
57 }
58 sscanf(buf, "begin %o %s", &mode, dest);
59
60 #ifndef MSDOS /* don't include for MSDOS, K. Hendrickson */
61 /* handle ~user/file format */
62 if (dest[0] == '~') {
63 char *sl;
64 struct passwd *getpwnam();
65 char *index();
66 struct passwd *user;
67 char dnbuf[100];
68
69 sl = index(dest, '/');
70 if (sl == NULL) {
71 fprintf(stderr, "Illegal ~user\n");
72 exit(3);
73 }
74 *sl++ = 0;
75 user = getpwnam(dest+1);
76 if (user == NULL) {
77 fprintf(stderr, "No such user as %s\n", dest);
78 exit(4);
79 }
80 strcpy(dnbuf, user->pw_dir);
81 strcat(dnbuf, "/");
82 strcat(dnbuf, sl);
83 strcpy(dest, dnbuf);
84 }
85 #endif
86
87 /* create output file */
88 out = fopen(dest, "w");
89 if (out == NULL) {
90 perror(dest);
91 exit(4);
92 }
93
94 #ifdef MSDOS
95 /* don't translate LF into CRLF when writing */
96 (void) setmode(fileno(out), O_BINARY);
97 #endif
98
99 chmod(dest, mode);
100
101 decode(in, out);
102
PAGE 3
10-15-89
17:00:42
Line# Source Line Microsoft C Compiler Version 5.10
103 if (fgets(buf, sizeof buf, in) == NULL || strcmp(buf, "end\n")) {
104 fprintf(stderr, "No end line\n");
105 exit(5);
106 }
107 exit(0);
108 }
main Local Symbols
Name Class Type Size Offset Register
buf . . . . . . . . . . . auto -00f4
out . . . . . . . . . . . auto -00a4
in. . . . . . . . . . . . auto -00a2
mode. . . . . . . . . . . auto -00a0
sbuf. . . . . . . . . . . auto -009e
dest. . . . . . . . . . . auto -0080
argc. . . . . . . . . . . param 0004
argv. . . . . . . . . . . param 0006
109
110 /*
111 * copy from in to out, decoding as you go along.
112 */
113 decode(in, out)
114 FILE *in;
115 FILE *out;
116 {
117 char buf[80];
118 char *bp;
119 int n;
120
121 for (;;) {
122 /* for each input line */
123 if (fgets(buf, sizeof buf, in) == NULL) {
124 printf("Short file\n");
125 exit(10);
126 }
127 n = DEC(buf[0]);
128 if (n <= 0)
129 break;
130
131 bp = &buf[1];
132 while (n > 0) {
133 outdec(bp, out, n);
134 bp += 4;
135 n -= 3;
136 }
137 }
138 }
PAGE 4
10-15-89
17:00:42
Microsoft C Compiler Version 5.10
decode Local Symbols
Name Class Type Size Offset Register
n . . . . . . . . . . . . auto -0054
buf . . . . . . . . . . . auto -0052
bp. . . . . . . . . . . . auto -0002
in. . . . . . . . . . . . param 0004
out . . . . . . . . . . . param 0006
139
140 /*
141 * output a group of 3 bytes (4 input characters).
142 * the input chars are pointed to by p, they are to
143 * be output to file f. n is used to tell us not to
144 * output all of them at the end of the file.
145 */
146 outdec(p, f, n)
147 char *p;
148 FILE *f;
149 {
150 int c1, c2, c3;
151
152 c1 = DEC(*p) << 2 | DEC(p[1]) >> 4;
153 c2 = DEC(p[1]) << 4 | DEC(p[2]) >> 2;
154 c3 = DEC(p[2]) << 6 | DEC(p[3]);
155 if (n >= 1)
156 putc(c1, f);
157 if (n >= 2)
158 putc(c2, f);
159 if (n >= 3)
160 putc(c3, f);
161 }
outdec Local Symbols
Name Class Type Size Offset Register
c3. . . . . . . . . . . . auto -0006
c2. . . . . . . . . . . . auto -0004
c1. . . . . . . . . . . . auto -0002
p . . . . . . . . . . . . param 0004
f . . . . . . . . . . . . param 0006
n . . . . . . . . . . . . param 0008
162
163
164 /* fr: like read but stdio */
PAGE 5
10-15-89
17:00:42
Line# Source Line Microsoft C Compiler Version 5.10
165 int
166 fr(fd, buf, cnt)
167 FILE *fd;
168 char *buf;
169 int cnt;
170 {
171 int c, i;
172
173 for (i=0; i<cnt; i++) {
174 c = getc(fd);
175 if (c == EOF)
176 return(i);
177 buf[i] = c;
178 }
179 return (cnt);
180 }
fr Local Symbols
Name Class Type Size Offset Register
i . . . . . . . . . . . . auto -0004
c . . . . . . . . . . . . auto -0002
fd. . . . . . . . . . . . param 0004
buf . . . . . . . . . . . param 0006
cnt . . . . . . . . . . . param 0008
Global Symbols
Name Class Type Size Offset
_filbuf . . . . . . . . . extern near function *** ***
_flsbuf . . . . . . . . . extern near function *** ***
_iob. . . . . . . . . . . extern struct/array *** ***
chmod . . . . . . . . . . extern near function *** ***
decode. . . . . . . . . . global near function *** 016a
exit. . . . . . . . . . . extern near function *** ***
fgets . . . . . . . . . . extern near function *** ***
fopen . . . . . . . . . . extern near function *** ***
fprintf . . . . . . . . . extern near function *** ***
fr. . . . . . . . . . . . global near function *** 02c8
main. . . . . . . . . . . global near function *** 0000
outdec. . . . . . . . . . global near function *** 01d6
perror. . . . . . . . . . extern near function *** ***
printf. . . . . . . . . . extern near function *** ***
setmode . . . . . . . . . extern near function *** ***
sscanf. . . . . . . . . . extern near function *** ***
strcmp. . . . . . . . . . extern near function *** ***
strncmp . . . . . . . . . extern near function *** ***
PAGE 6
10-15-89
17:00:42
Microsoft C Compiler Version 5.10
Code size = 0328 (808)
Data size = 005e (94)
Bss size = 0000 (0)
No errors detected
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -