MCPcopy Create free account
hub / github.com/NetHack/NetHack / main

Function main

sys/share/uudecode.c:99–189  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

97#define DEC(c) (((c) - ' ') & 077)
98
99DISABLE_WARNING_UNREACHABLE_CODE
100
101int
102main(int argc, char **argv)
103{
104 FILE *in, *out;
105 unsigned int mode;
106 char dest[128];
107 char buf[80];
108
109 /* optional input arg */
110 if (argc > 1) {
111 if ((in = fopen(argv[1], "r")) == NULL) {
112 perror(argv[1]);
113 exit(1);
114 }
115 argv++;
116 argc--;
117 } else
118 in = stdin;
119
120 if (argc != 1) {
121 printf("Usage: uudecode [infile]\n");
122 exit(2);
123 }
124
125 /* search for header line */
126 for (;;) {
127 if (fgets(buf, sizeof buf, in) == NULL) {
128 fprintf(stderr, "No begin line\n");
129 exit(3);
130 }
131 if (strncmp(buf, "begin ", 6) == 0)
132 break;
133 }
134 (void) sscanf(buf, "begin %o %s", &mode, dest);
135
136#if !defined(MSDOS) && !defined(VMS) && !defined(WIN32) && !defined(__APPLE__)
137 /* handle ~user/file format */
138 if (dest[0] == '~') {
139 char *sl;
140 struct passwd *user;
141 char dnbuf[100];
142#ifdef KR_PROTO
143 struct passwd *getpwnam();
144 char *strchr(), *strcat(), *strcpy();
145#endif
146
147 sl = strchr(dest, '/');
148 if (sl == NULL) {
149 fprintf(stderr, "Illegal ~user\n");
150 exit(3);
151 }
152 *sl++ = 0;
153 user = getpwnam(dest + 1);
154 if (user == NULL) {
155 fprintf(stderr, "No such user as %s\n", dest);
156 exit(4);

Callers

nothing calls this directly

Calls 4

printfFunction · 0.85
fgetsFunction · 0.85
fprintfFunction · 0.85
decodeFunction · 0.70

Tested by

no test coverage detected