rpms/gimp-print/devel gimp-print-ipv6.patch,NONE,1.1

fedora-cvs-commits at redhat.com fedora-cvs-commits at redhat.com
Thu Sep 28 11:53:09 UTC 2006


Author: twaugh

Update of /cvs/dist/rpms/gimp-print/devel
In directory cvs.devel.redhat.com:/tmp/cvs-serv5997

Added Files:
	gimp-print-ipv6.patch 
Log Message:
Include the patch.

gimp-print-ipv6.patch:
 canon.c |   21 +++++++++++++--------
 epson.c |   21 +++++++++++++--------
 2 files changed, 26 insertions(+), 16 deletions(-)

--- NEW FILE gimp-print-ipv6.patch ---
--- gimp-print-4.2.7/src/cups/epson.c.ipv6	2003-01-25 00:51:41.000000000 +0000
+++ gimp-print-4.2.7/src/cups/epson.c	2006-09-28 12:51:25.000000000 +0100
@@ -107,8 +107,9 @@
   int		fd_out,		/* Parallel/USB device or socket */
   		fd_in,		/* Print file */
 		error;		/* Last error */
-  struct sockaddr_in addr;	/* Socket address */
-  struct hostent *hostaddr;	/* Host address */
+  struct sockaddr_storage addr;	/* Socket address */
+  size_t	addrlen;	/* Socker address length */
+  struct addrinfo *hostai;	/* Host address */
   int		wbytes;		/* Number of bytes written */
   int		nbytes,		/* Number of bytes read */
 		tbytes;		/* Total number of bytes written */
@@ -182,7 +183,7 @@
     * Lookup the IP address...
     */
 
-    if ((hostaddr = gethostbyname(hostname)) == NULL)
+    if (getaddrinfo(hostname, NULL, NULL, &hostai))
     {
       fprintf(stderr, "ERROR: Unable to locate printer \'%s\' - %s",
               hostname, strerror(errno));
@@ -195,10 +196,14 @@
     fprintf(stderr, "INFO: Attempting to connect to printer %s on port %d\n",
             hostname, port);
 
+    addrlen = hostai->ai_addrlen;
     memset(&addr, 0, sizeof(addr));
-    memcpy(&(addr.sin_addr), hostaddr->h_addr, hostaddr->h_length);
-    addr.sin_family = hostaddr->h_addrtype;
-    addr.sin_port   = htons(port);
+    memcpy(&addr, hostai->ai_addr, addrlen);
+    freeaddrinfo(hostai);
+    if (addr.ss_family == AF_INET)
+      ((struct sockaddr_in *)&addr)->sin_port = htons(port);
+    else if (addr.ss_family == AF_INET6)
+      ((struct sockaddr_in6 *)&addr)->sin6_port = htons(port);
 
    /*
     * Try to connect...
@@ -206,13 +211,13 @@
 
     for (;;)
     {
-      if ((fd_out = socket(AF_INET, SOCK_STREAM, 0)) < 0)
+      if ((fd_out = socket(addr.ss_family, SOCK_STREAM, 0)) < 0)
       {
 	perror("ERROR: Unable to create socket");
 	return (1);
       }
 
-      if (connect(fd_out, (struct sockaddr *)&addr, sizeof(addr)) < 0)
+      if (connect(fd_out, (struct sockaddr *)&addr, addrlen) < 0)
       {
         error = errno;
 	close(fd_out);
--- gimp-print-4.2.7/src/cups/canon.c.ipv6	2002-11-24 01:48:55.000000000 +0000
+++ gimp-print-4.2.7/src/cups/canon.c	2006-09-28 12:51:25.000000000 +0100
@@ -77,8 +77,9 @@
   		fd_in,		/* Print file */
 		error,		/* Last error */
 		backchannel;	/* Read backchannel data? */
-  struct sockaddr_in addr;	/* Socket address */
-  struct hostent *hostaddr;	/* Host address */
+  struct sockaddr_storage addr;	/* Socket address */
+  size_t	addrlen;	/* Socker address length */
+  struct addrinfo *hostai;	/* Host address */
   int		wbytes;		/* Number of bytes written */
   int		nbytes,		/* Number of bytes read */
 		tbytes;		/* Total number of bytes written */
@@ -154,7 +155,7 @@
     * Lookup the IP address...
     */
 
-    if ((hostaddr = gethostbyname(hostname)) == NULL)
+    if (getaddrinfo(hostname, NULL, NULL, &hostai))
     {
       fprintf(stderr, "ERROR: Unable to locate printer \'%s\' - %s",
               hostname, strerror(errno));
@@ -167,10 +168,14 @@
     fprintf(stderr, "INFO: Attempting to connect to printer %s on port %d\n",
             hostname, port);
 
+    addrlen = hostai->ai_addrlen;
     memset(&addr, 0, sizeof(addr));
-    memcpy(&(addr.sin_addr), hostaddr->h_addr, hostaddr->h_length);
-    addr.sin_family = hostaddr->h_addrtype;
-    addr.sin_port   = htons(port);
+    memcpy(&addr, hostai->ai_addr, addrlen);
+    freeaddrinfo(hostai);
+    if (addr.ss_family == AF_INET)
+      ((struct sockaddr_in *)&addr)->sin_port = htons(port);
+    else if (addr.ss_family == AF_INET6)
+      ((struct sockaddr_in6 *)&addr)->sin6_port = htons(port);
 
    /*
     * Try to connect...
@@ -178,13 +183,13 @@
 
     for (;;)
     {
-      if ((fd_out = socket(AF_INET, SOCK_STREAM, 0)) < 0)
+      if ((fd_out = socket(addr.ss_family, SOCK_STREAM, 0)) < 0)
       {
 	perror("ERROR: Unable to create socket");
 	return (1);
       }
 
-      if (connect(fd_out, (struct sockaddr *)&addr, sizeof(addr)) < 0)
+      if (connect(fd_out, (struct sockaddr *)&addr, addrlen) < 0)
       {
         error = errno;
 	close(fd_out);




More information about the fedora-cvs-commits mailing list