added redist.man
[unix-history] / usr / src / libexec / tftpd / tftpd.c
index 0307bfc..1cea861 100644 (file)
@@ -2,17 +2,7 @@
  * Copyright (c) 1983 Regents of the University of California.
  * All rights reserved.
  *
  * Copyright (c) 1983 Regents of the University of California.
  * All rights reserved.
  *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley.  The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ * %sccs.include.redist.c%
  */
 
 #ifndef lint
  */
 
 #ifndef lint
@@ -22,7 +12,7 @@ char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)tftpd.c    5.10 (Berkeley) %G%";
+static char sccsid[] = "@(#)tftpd.c    5.13 (Berkeley) %G%";
 #endif /* not lint */
 
 /*
 #endif /* not lint */
 
 /*
@@ -32,22 +22,23 @@ static char sccsid[] = "@(#)tftpd.c 5.10 (Berkeley) %G%";
  */
 
 #include <sys/types.h>
  */
 
 #include <sys/types.h>
-#include <sys/socket.h>
 #include <sys/ioctl.h>
 #include <sys/ioctl.h>
-#include <sys/wait.h>
 #include <sys/stat.h>
 #include <sys/stat.h>
+#include <signal.h>
+#include <fcntl.h>
 
 
+#include <sys/socket.h>
 #include <netinet/in.h>
 #include <netinet/in.h>
-
 #include <arpa/tftp.h>
 #include <arpa/tftp.h>
+#include <netdb.h>
 
 
-#include <signal.h>
+#include <setjmp.h>
+#include <syslog.h>
 #include <stdio.h>
 #include <errno.h>
 #include <ctype.h>
 #include <stdio.h>
 #include <errno.h>
 #include <ctype.h>
-#include <netdb.h>
-#include <setjmp.h>
-#include <syslog.h>
+#include <string.h>
+#include <stdlib.h>
 
 #define        TIMEOUT         5
 
 
 #define        TIMEOUT         5
 
@@ -83,7 +74,7 @@ main(ac, av)
        }
        fromlen = sizeof (from);
        n = recvfrom(0, buf, sizeof (buf), 0,
        }
        fromlen = sizeof (from);
        n = recvfrom(0, buf, sizeof (buf), 0,
-           (caddr_t)&from, &fromlen);
+           (struct sockaddr *)&from, &fromlen);
        if (n < 0) {
                syslog(LOG_ERR, "recvfrom: %m\n");
                exit(1);
        if (n < 0) {
                syslog(LOG_ERR, "recvfrom: %m\n");
                exit(1);
@@ -122,7 +113,7 @@ main(ac, av)
                                 */
                                j = sizeof from;
                                i = recvfrom(0, buf, sizeof (buf), 0,
                                 */
                                j = sizeof from;
                                i = recvfrom(0, buf, sizeof (buf), 0,
-                                   (caddr_t)&from, &j);
+                                   (struct sockaddr *)&from, &j);
                                if (i > 0) {
                                        n = i;
                                        fromlen = j;
                                if (i > 0) {
                                        n = i;
                                        fromlen = j;
@@ -147,11 +138,11 @@ main(ac, av)
                syslog(LOG_ERR, "socket: %m\n");
                exit(1);
        }
                syslog(LOG_ERR, "socket: %m\n");
                exit(1);
        }
-       if (bind(peer, (caddr_t)&sin, sizeof (sin)) < 0) {
+       if (bind(peer, (struct sockaddr *)&sin, sizeof (sin)) < 0) {
                syslog(LOG_ERR, "bind: %m\n");
                exit(1);
        }
                syslog(LOG_ERR, "bind: %m\n");
                exit(1);
        }
-       if (connect(peer, (caddr_t)&from, sizeof(from)) < 0) {
+       if (connect(peer, (struct sockaddr *)&from, sizeof(from)) < 0) {
                syslog(LOG_ERR, "connect: %m\n");
                exit(1);
        }
                syslog(LOG_ERR, "connect: %m\n");
                exit(1);
        }
@@ -287,6 +278,7 @@ validate_access(filename, mode)
 int    timeout;
 jmp_buf        timeoutbuf;
 
 int    timeout;
 jmp_buf        timeoutbuf;
 
+void
 timer()
 {
 
 timer()
 {
 
@@ -358,6 +350,7 @@ abort:
        (void) fclose(file);
 }
 
        (void) fclose(file);
 }
 
+void
 justquit()
 {
        exit(0);
 justquit()
 {
        exit(0);
@@ -466,7 +459,6 @@ nak(error)
        register struct tftphdr *tp;
        int length;
        register struct errmsg *pe;
        register struct tftphdr *tp;
        int length;
        register struct errmsg *pe;
-       extern char *sys_errlist[];
 
        tp = (struct tftphdr *)buf;
        tp->th_opcode = htons((u_short)ERROR);
 
        tp = (struct tftphdr *)buf;
        tp->th_opcode = htons((u_short)ERROR);
@@ -475,7 +467,7 @@ nak(error)
                if (pe->e_code == error)
                        break;
        if (pe->e_code < 0) {
                if (pe->e_code == error)
                        break;
        if (pe->e_code < 0) {
-               pe->e_msg = sys_errlist[error - 100];
+               pe->e_msg = strerror(error - 100);
                tp->th_code = EUNDEF;   /* set 'undef' errorcode */
        }
        strcpy(tp->th_msg, pe->e_msg);
                tp->th_code = EUNDEF;   /* set 'undef' errorcode */
        }
        strcpy(tp->th_msg, pe->e_msg);