changeset 445:92dd688aafce

- Cleaned up and normalized D_SUN_LEN usage.
author jcid
date Wed, 05 Nov 2008 19:11:02 +0100
parents 32cbd6607669
children 1b0dabe4afa2
files ChangeLog dpi/bookmarks.c dpi/cookies.c dpi/https.c dpid/dpid.c src/IO/dpi.c
diffstat 6 files changed, 6 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu Oct 30 21:26:46 2008 +0100
+++ b/ChangeLog	Wed Nov 05 19:11:02 2008 +0100
@@ -17,6 +17,7 @@
 +- Switched SSL-enabled to configure.in (./configure --enable-ssl).
  - Standardised the installation of dpid/dpidrc with auto* tools.
  - Set the ScrollGroup as the resizable widget in downloads dpi.
+ - Cleaned up and normalized D_SUN_LEN usage.
    Patches: Jeremy Henty
 +- Allowed compilation with older machines by removing a few C99isms.
  - Added use of inttypes.h when stdint.h isn't found.
--- a/dpi/bookmarks.c	Thu Oct 30 21:26:46 2008 +0100
+++ b/dpi/bookmarks.c	Wed Nov 05 19:11:02 2008 +0100
@@ -44,11 +44,6 @@
 #define _MSG(...)
 #define MSG(...)  printf("[bookmarks dpi]: " __VA_ARGS__)
 
-/* This one is tricky, some sources state it should include the byte
- * for the terminating NULL, and others say it shouldn't. */
-# define D_SUN_LEN(ptr) ((size_t) (((struct sockaddr_un *) 0)->sun_path) \
-                        + strlen ((ptr)->sun_path))
-
 #define DOCTYPE \
    "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>\n"
 
--- a/dpi/cookies.c	Thu Oct 30 21:26:46 2008 +0100
+++ b/dpi/cookies.c	Wed Nov 05 19:11:02 2008 +0100
@@ -64,12 +64,6 @@
 #define MSG(...)  printf("[cookies dpi]: " __VA_ARGS__)
 
 
-/* This one is tricky, some sources state it should include the byte
- * for the terminating NULL, and others say it shouldn't. */
-# define D_SUN_LEN(ptr) ((size_t) (((struct sockaddr_un *) 0)->sun_path) \
-                        + strlen ((ptr)->sun_path))
-
-
 /*
  * a_List_add()
  *
--- a/dpi/https.c	Thu Oct 30 21:26:46 2008 +0100
+++ b/dpi/https.c	Wed Nov 05 19:11:02 2008 +0100
@@ -25,7 +25,7 @@
  * the https dillo plugin with the OpenSSL project's "OpenSSL"
  * library, and distribute the linked executables, without including
  * the source code for OpenSSL in the source distribution. You must
- * obey the GNU General Public License, version 2, in all respects
+ * obey the GNU General Public License, version 3, in all respects
  * for all of the code used other than "OpenSSL".
  *
  */
--- a/dpid/dpid.c	Thu Oct 30 21:26:46 2008 +0100
+++ b/dpid/dpid.c	Wed Nov 05 19:11:02 2008 +0100
@@ -728,7 +728,6 @@
       DpiBye_cmd = a_Dpip_build_cmd("cmd=%s", "DpiBye");
 
    sun_path_len = sizeof(sa.sun_path);
-   addr_len = sizeof(dpi_addr);
 
    dpi_addr.sun_family = AF_LOCAL;
 
@@ -746,6 +745,7 @@
          MSG_ERR("\n - socket path = %s\n", dpi_attr_list[i].sockpath);
       }
       strncpy(dpi_addr.sun_path, dpi_attr_list[i].sockpath, sun_path_len);
+      addr_len = D_SUN_LEN(&dpi_addr);
       if (connect(dpi_socket, (struct sockaddr *) &dpi_addr, addr_len) == -1) {
          ERRMSG("stop_active_dpis", "connect", errno);
          MSG_ERR("%s\n", dpi_addr.sun_path);
--- a/src/IO/dpi.c	Thu Oct 30 21:26:46 2008 +0100
+++ b/src/IO/dpi.c	Wed Nov 05 19:11:02 2008 +0100
@@ -353,7 +353,7 @@
       strncpy(pun.sun_path, uds_name, sizeof (pun.sun_path));
 
       if ((SockFD = socket(AF_LOCAL, SOCK_STREAM, 0)) == -1 ||
-          connect(SockFD, (void*)&pun, D_SUN_LEN(&pun)) == -1) {
+          connect(SockFD, (struct sockaddr *) &pun, D_SUN_LEN(&pun)) == -1) {
          MSG("Dpi_check_uds: %s %s\n", dStrerror(errno), uds_name);
       } else {
          Dpi_close_fd(SockFD);
@@ -497,7 +497,7 @@
       _MSG("dpid_uds_name = [%s]\n", dpid_uds_name);
       strncpy(dpid.sun_path, dpid_uds_name, sizeof(dpid.sun_path));
 
-      if (connect(sock, (struct sockaddr *) &dpid, sizeof(dpid)) == -1)
+      if (connect(sock, (struct sockaddr *) &dpid, D_SUN_LEN(&dpid)) == -1)
          perror("connect");
       /* ask dpid to check the server plugin and send its UDS name back */
       request = a_Dpip_build_cmd("cmd=%s msg=%s", "check_server", server_name);
@@ -717,7 +717,6 @@
 
    srs_name = Dpi_get_dpid_uds_name();
    sun_path_len = sizeof(sa.sun_path);
-   addr_len = sizeof(sa);
 
    sa.sun_family = AF_LOCAL;
 
@@ -725,6 +724,7 @@
       MSG("a_Dpi_bye_dpid: %s\n", dStrerror(errno));
    }
    strncpy(sa.sun_path, srs_name, sizeof (sa.sun_path));
+   addr_len = D_SUN_LEN(&sa);
    if (connect(new_socket, (struct sockaddr *) &sa, addr_len) == -1) {
       MSG("a_Dpi_bye_dpid: %s\n", dStrerror(errno));
       MSG("%s\n", sa.sun_path);