📄 uuencode.lst
字号:
PAGE 1
10-15-89
17:00:16
Line# Source Line Microsoft C Compiler Version 5.10
1 /*
2 * uuencode [input] output
3 *
4 * Encode a file so it can be mailed to a remote system.
5 *
6 * modified for MSDOS by Kenneth J. Hendrickson
7 */
8
9 #ifdef MSDOS
10 #include <fcntl.h>
11 #include <io.h>
12 #include <process.h>
13 #endif
14
15 #include <stdio.h>
16 #include <sys/types.h>
17 #include <sys/stat.h>
18
19 /* ENC is the basic 1 character encoding function to make a char printing */
20 #define ENC(c) (((c) & 077) + ' ')
21
22 main(argc, argv)
23 char **argv;
24 {
25 FILE *in;
26 struct stat sbuf;
27 int mode;
28
29 #ifndef MSDOS
30 /* optional 1st argument */
31 if (argc > 2) {
32 if ((in = fopen(argv[1], "r")) == NULL) {
33 perror(argv[1]);
34 exit(1);
35 }
36 argv++; argc--;
37 } else
38 in = stdin;
39
40 if (argc != 2) {
41 printf("Usage: uuencode [infile] remotefile\n");
42 exit(2);
43 }
44 #else
45 /* no optional 1st argument, input file must be given */
46 /* MSDOS handling of stdin is brain-dead. It thinks EOF
47 occured when a ^Z is read, even if there is more . . . */
48 if (argc == 2) {
49 if ((in = fopen(argv[1], "r")) == NULL) {
50 perror(argv[1]);
51 exit(1);
PAGE 2
10-15-89
17:00:16
Line# Source Line Microsoft C Compiler Version 5.10
52 }
53 /* don't translate CRLF into LF when reading */
54 (void) setmode(fileno(in), O_BINARY);
55 }
56 else {
57 (void) fprintf(stderr, "Usage: uuencode infile\n");
58 exit(2);
59 }
60 #endif
61
62 /* figure out the input file mode */
63 fstat(fileno(in), &sbuf);
64 mode = sbuf.st_mode & 0777;
65 /* for MSDOS, remotefile == infile */
66 printf("begin %o %s\n", mode, argv[1]);
67
68 encode(in, stdout);
69
70 printf("end\n");
71 exit(0);
72 }
main Local Symbols
Name Class Type Size Offset Register
in. . . . . . . . . . . . auto -0022
mode. . . . . . . . . . . auto -0020
sbuf. . . . . . . . . . . auto -001e
argc. . . . . . . . . . . param 0004
argv. . . . . . . . . . . param 0006
73
74 /*
75 * copy from in to out, encoding as you go along.
76 */
77 encode(in, out)
78 FILE *in;
79 FILE *out;
80 {
81 char buf[80];
82 int i, n;
83
84 for (;;) {
85 /* 1 (up to) 45 character line */
86 n = fr(in, buf, 45);
87 putc(ENC(n), out);
88
89 for (i=0; i<n; i += 3)
90 outdec(&buf[i], out);
PAGE 3
10-15-89
17:00:16
Line# Source Line Microsoft C Compiler Version 5.10
91
92 putc('\n', out);
93 if (n <= 0)
94 break;
95 }
96 }
encode Local Symbols
Name Class Type Size Offset Register
n . . . . . . . . . . . . auto -0054
buf . . . . . . . . . . . auto -0052
i . . . . . . . . . . . . auto -0002
in. . . . . . . . . . . . param 0004
out . . . . . . . . . . . param 0006
97
98 /*
99 * output one group of 3 bytes, pointed at by p, on file f.
100 */
101 outdec(p, f)
102 char *p;
103 FILE *f;
104 {
105 int c1, c2, c3, c4;
106
107 c1 = *p >> 2;
108 c2 = (*p << 4) & 060 | (p[1] >> 4) & 017;
109 c3 = (p[1] << 2) & 074 | (p[2] >> 6) & 03;
110 c4 = p[2] & 077;
111 putc(ENC(c1), f);
112 putc(ENC(c2), f);
113 putc(ENC(c3), f);
114 putc(ENC(c4), f);
115 }
outdec Local Symbols
Name Class Type Size Offset Register
c4. . . . . . . . . . . . auto -0008
c3. . . . . . . . . . . . auto -0006
c2. . . . . . . . . . . . auto -0004
c1. . . . . . . . . . . . auto -0002
p . . . . . . . . . . . . param 0004
f . . . . . . . . . . . . param 0006
116
PAGE 4
10-15-89
17:00:16
Line# Source Line Microsoft C Compiler Version 5.10
117 /* fr: like read but stdio */
118 int
119 fr(fd, buf, cnt)
120 FILE *fd;
121 char *buf;
122 int cnt;
123 {
124 int c, i;
125
126 for (i=0; i<cnt; i++) {
127 c = getc(fd);
128 #ifndef MSDOS
129 if (c == EOF)
130 #else
131 if (feof(fd))
132 #endif
133 return(i);
134 buf[i] = c;
135 }
136 return (cnt);
137 }
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 *** ***
encode. . . . . . . . . . global near function *** 00b6
exit. . . . . . . . . . . extern near function *** ***
fopen . . . . . . . . . . extern near function *** ***
fprintf . . . . . . . . . extern near function *** ***
fr. . . . . . . . . . . . global near function *** 0270
fstat . . . . . . . . . . extern near function *** ***
main. . . . . . . . . . . global near function *** 0000
outdec. . . . . . . . . . global near function *** 0156
perror. . . . . . . . . . extern near function *** ***
printf. . . . . . . . . . extern near function *** ***
PAGE 5
10-15-89
17:00:16
Microsoft C Compiler Version 5.10
Global Symbols
Name Class Type Size Offset
setmode . . . . . . . . . extern near function *** ***
Code size = 02d4 (724)
Data size = 002c (44)
Bss size = 0000 (0)
No errors detected
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -