Aggiornamento note copyright
[gapil.git] / sources / mygetaddr.c
index 3f51313925df35744d01633e6cb0deb5ee0136c3..67a570d79377880c5a6b457a6d179b751f3f8588 100644 (file)
  *
  * Author: S. Piccardi Nov. 2004
  *
- * $Id$
- *
  *****************************************************************************/
-#include <netdb.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <stdlib.h>        /* C standard library */
-#include <stdio.h>         /* I/O standard library */
-#include <unistd.h>
-#include <arpa/inet.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
+#include <string.h>      /* C strings library */
+#include <sys/types.h>   /* primitive system data types */
+#include <sys/stat.h>    /* file characteristics constants and functions */
+#include <unistd.h>      /* unix standard library */
+#include <stdlib.h>      /* C standard library */
+#include <stdio.h>       /* standard I/O library */
+#include <arpa/inet.h>   /* IP addresses conversion utilities */
+#include <sys/socket.h>  /* socket constants, types and functions */
+#include <netinet/in.h>  /* IPv4 and IPv6 constants and types */
+#include <netdb.h>       /* C resolver library */
 
 #include "Gapil.h"
 /*
@@ -67,7 +65,7 @@ int main(int argc, char *argv[])
      * Init variables
      */
     memset(&hint, 0, sizeof(hint));
-    hint.ai_family = PF_UNSPEC;
+    hint.ai_family = AF_UNSPEC;
     /*
      * Input section: decode command line parameters 
      * Use getopt function
@@ -119,11 +117,11 @@ int main(int argc, char *argv[])
        case 'v':                                        /* set address type */
            j = strtol(optarg, NULL, 10);
            if (j == 4) {
-               hint.ai_family = PF_INET;
+               hint.ai_family = AF_INET;
                break;
            } 
            if (j == 6) {
-               hint.ai_family = PF_INET6;
+               hint.ai_family = AF_INET6;
                break;
            }
            printf("Wrong IP protocol version, use 4 o 6\n\n");
@@ -166,13 +164,13 @@ int main(int argc, char *argv[])
     ptr = res;                                        /* init list pointer */
     printf("Canonical name %s\n", ptr->ai_canonname); /* print cname */
     while (ptr != NULL) {                             /* loop on list */
-       if (ptr->ai_family == PF_INET) {              /* if IPv4 */
+       if (ptr->ai_family == AF_INET) {              /* if IPv4 */
            printf("IPv4 address: \n");
            addr = (struct sockaddr_in *) ptr->ai_addr;          /* address */
            port = ntohs(addr->sin_port);                        /* port */
            string = inet_ntop(addr->sin_family, &addr->sin_addr, 
                               buffer, sizeof(buffer));
-       } else if (ptr->ai_family == PF_INET6) {      /* if IPv6 */
+       } else if (ptr->ai_family == AF_INET6) {      /* if IPv6 */
            printf("IPv6 address: \n");
            addr6 = (struct sockaddr_in6 *) ptr->ai_addr;        /* address */
            port = ntohs(addr6->sin6_port);                      /* port */
@@ -193,9 +191,9 @@ int main(int argc, char *argv[])
  * routine to print usage info and exit
  */
 void usage(void) {
-    printf("Program mygethost: do an hostname resolution \n");
+    printf("Program mygetaddr: do an hostname resolution \n");
     printf("Usage:\n");
-    printf("mygethost [-h] [-p protocol] [-t socktype] hostname service\n");
+    printf("mygetaddr [-h] [-p protocol] [-t socktype] hostname service\n");
     printf("  -h              print this help\n");
     printf("  -p udp,tcp      select a protocol\n");
     printf("  -t dgram,stream select a socket type\n");