use herror
[unix-history] / usr / src / usr.sbin / timed / timedc / cmds.c
index ff14e40..7810242 100644 (file)
@@ -1,12 +1,23 @@
 /*
  * Copyright (c) 1983 Regents of the University of California.
 /*
  * Copyright (c) 1983 Regents of the University of California.
- * All rights reserved.  The Berkeley software License Agreement
- * specifies the terms and conditions for redistribution.
+ * 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.
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)cmds.c     2.2 (Berkeley) %G%";
-#endif not lint
+static char sccsid[] = "@(#)cmds.c     2.6 (Berkeley) %G%";
+#endif /* not lint */
 
 #include "timedc.h"
 #include <netinet/in_systm.h>
 
 #include "timedc.h"
 #include <netinet/in_systm.h>
@@ -67,7 +78,8 @@ char *argv[];
                argc--; argv++;
                hp = gethostbyname(*argv);
                if (hp == NULL) {
                argc--; argv++;
                hp = gethostbyname(*argv);
                if (hp == NULL) {
-                       printf("%s: unknown host\n", *argv);
+                       fprintf(stderr, "timed: %s: ", *argv);
+                       herror((char *)NULL);
                        continue;
                }
                server.sin_family = hp->h_addrtype;
                        continue;
                }
                server.sin_family = hp->h_addrtype;
@@ -135,14 +147,15 @@ int argc;
        if (srvp == 0) {
                fprintf(stderr, "udp/timed: unknown service\n");
                return;
        if (srvp == 0) {
                fprintf(stderr, "udp/timed: unknown service\n");
                return;
-       }       
+       }
        dest.sin_port = srvp->s_port;
        dest.sin_family = AF_INET;
 
        dest.sin_port = srvp->s_port;
        dest.sin_family = AF_INET;
 
-       (void)gethostname(hostname,sizeof(hostname));
+       (void)gethostname(hostname, sizeof(hostname));
        hp = gethostbyname(hostname);
        if (hp == NULL) {
        hp = gethostbyname(hostname);
        if (hp == NULL) {
-               perror("gethostbyname");
+               fprintf(stderr, "timed: %s: ", hostname);
+               herror((char *)NULL);
                return;
        }
        bcopy(hp->h_addr, &dest.sin_addr.s_addr, hp->h_length);
                return;
        }
        bcopy(hp->h_addr, &dest.sin_addr.s_addr, hp->h_length);
@@ -223,7 +236,8 @@ char *argv[];
                argc--; argv++;
                hp = gethostbyname(*argv);
                if (hp == NULL) {
                argc--; argv++;
                hp = gethostbyname(*argv);
                if (hp == NULL) {
-                       printf("%s: unknown host %s\n", *argv);
+                       fprintf(stderr, "timed: %s: ", *argv);
+                       herror((char *)NULL);
                        argc--; argv++;
                        continue;
                }
                        argc--; argv++;
                        continue;
                }