changeset 1223:a09dbf132be6

Remove system includes for dpid
author Jorge Arellano Cid <jcid@dillo.org>
date Mon, 13 Jul 2009 15:24:42 -0400
parents deffd7fc6d52
children bcf29a84abf5
files dpid/Makefile.am dpid/dpi.c dpid/dpi.h dpid/dpi_service.c dpid/dpi_service.h dpid/dpid.c dpid/dpid.h dpid/dpid_common.c dpid/dpid_common.h dpid/main.c dpid/misc_new.c dpid/misc_new.h
diffstat 12 files changed, 72 insertions(+), 179 deletions(-) [+]
line wrap: on
line diff
--- a/dpid/Makefile.am	Sun Jul 12 17:23:39 2009 -0400
+++ b/dpid/Makefile.am	Mon Jul 13 15:24:42 2009 -0400
@@ -8,13 +8,11 @@
 
 dpid_SOURCES = \
 	dpi.h \
-	dpi_service.h \
 	dpi_socket_dir.h \
 	dpid.h \
 	dpid_common.h \
 	misc_new.h \
 	dpi.c \
-	dpi_service.c \
 	dpi_socket_dir.c \
 	dpid.c \
 	dpid_common.c \
--- a/dpid/dpi.c	Sun Jul 12 17:23:39 2009 -0400
+++ b/dpid/dpi.c	Mon Jul 13 15:24:42 2009 -0400
@@ -22,6 +22,7 @@
  */
 
 #include <errno.h>
+#include <stdlib.h>  /* for exit */
 #include "dpid_common.h"
 #include "dpi.h"
 #include "misc_new.h"
--- a/dpid/dpi.h	Sun Jul 12 17:23:39 2009 -0400
+++ b/dpid/dpi.h	Mon Jul 13 15:24:42 2009 -0400
@@ -7,13 +7,8 @@
 #ifndef DPI_H
 #define DPI_H
 
-#include <config.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
+#include <unistd.h>      /* for socklen_t */
+#include <sys/socket.h>  /* for socklen_t and AF_LOCAL */
 
 /* Check the Unix98 goodie */
 #ifndef socklen_t
--- a/dpid/dpi_service.c	Sun Jul 12 17:23:39 2009 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,113 +0,0 @@
-/*
-   Copyright (C) 2003  Ferdi Franceschini <ferdif@optusnet.com.au>
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-/*! \file
- * \todo
- * This module should be removed because its original functions
- * have been removed or modified.
- * Put these functions in dpid.c
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <errno.h>
-#include "dpid_common.h"
-#include "dpid.h"
-#include "../dpip/dpip.h"
-
-#ifdef TEST
-#include "testdat.h"
-#endif
-
-/* exported functions */
-char *get_dpi_dir(char *dpidrc);
-
-
-/*! Get dpi directory path from dpidrc
- * \Return
- * dpi directory on success, NULL on failure
- * \Important
- * The dpi_dir definition in dpidrc must have no leading white space.
- */
-char *get_dpi_dir(char *dpidrc)
-{
-   FILE *In;
-   int len;
-   char *rcline = NULL, *value = NULL, *p;
-
-   if ((In = fopen(dpidrc, "r")) == NULL) {
-      ERRMSG("dpi_dir", "fopen", errno);
-      MSG_ERR(" - %s\n", dpidrc);
-      return (NULL);
-   }
-
-   while ((rcline = dGetline(In)) != NULL) {
-      if (strncmp(rcline, "dpi_dir", 7) == 0)
-         break;
-      dFree(rcline);
-   }
-   fclose(In);
-
-   if (!rcline) {
-      ERRMSG("dpi_dir", "Failed to find a dpi_dir entry in dpidrc", 0);
-      MSG_ERR("Put your dillo plugins path in %s\n", dpidrc);
-      MSG_ERR("eg. dpi_dir=/usr/local/lib/dillo/dpi ");
-      MSG_ERR("with no leading spaces.\n");
-      value = NULL;
-   } else {
-      len = (int) strlen(rcline);
-      if (len && rcline[len - 1] == '\n')
-         rcline[len - 1] = 0;
-
-      if ((p = strchr(rcline, '='))) {
-         while (*++p == ' ');
-         value = dStrdup(p);
-      } else {
-         ERRMSG("dpi_dir", "strchr", 0);
-         MSG_ERR(" - '=' not found in %s\n", rcline);
-         value = NULL;
-      }
-   }
-
-   dFree(rcline);
-   return (value);
-}
-
-/*! Send the list of available dpi IDs to a client
- * \Return
- * 1 on success, -1 on failure.
- *
-static int send_service_list(int sock, struct dp *dpi_attr_list, int srv_num)
-{
-   int i;
-   char *buf;
-   ssize_t wlen = 0;
-
-   for (i = 0; i < srv_num && wlen != -1; i++) {
-      d_cmd = a_Dpip_build_cmd("cmd=%s msg=%s",
-                               "send_data", dpi_attr_list[i].id);
-      wlen = write(sock, d_cmd, strlen(d_cmd));
-      dFree(d_cmd);
-   }
-   if (wlen == -1) {
-      ERRMSG("send_service_list", "write", errno);
-      return (-1);
-   }
-   return (1);
-}
- */
--- a/dpid/dpi_service.h	Sun Jul 12 17:23:39 2009 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,20 +0,0 @@
-/*! \file
- * \todo
- * This module should be removed because its original functions
- * have been removed or modified.
- * Put these functions in dpid.c
- */
-
-#ifndef DPI_SERVICE_H
-#define DPI_SERVICE_H
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include "dpid.h"
-
-char *get_dpi_dir(char *dpidrc);
-
-int send_service_list(int sock, struct dp *dpi_attr_list, int srv_num);
-
-#endif
--- a/dpid/dpid.c	Sun Jul 12 17:23:39 2009 -0400
+++ b/dpid/dpid.c	Mon Jul 13 15:24:42 2009 -0400
@@ -19,6 +19,9 @@
  * Main functions to set-up dpi information and to initialise sockets
  */
 #include <errno.h>
+#include <stdlib.h>   /* for exit */
+#include <fcntl.h>    /* for F_SETFD, F_GETFD, FD_CLOEXEC */
+
 #include <sys/stat.h>
 #include <sys/wait.h>
 #include <unistd.h>
@@ -26,7 +29,6 @@
 #include "dpid.h"
 #include "dpi.h"
 #include "dpi_socket_dir.h"
-#include "dpi_service.h"
 #include "misc_new.h"
 
 #include "../dpip/dpip.h"
@@ -215,6 +217,56 @@
    }
 }
 
+/*! Get dpi directory path from dpidrc
+ * \Return
+ * dpi directory on success, NULL on failure
+ * \Important
+ * The dpi_dir definition in dpidrc must have no leading white space.
+ */
+char *get_dpi_dir(char *dpidrc)
+{
+   FILE *In;
+   int len;
+   char *rcline = NULL, *value = NULL, *p;
+
+   if ((In = fopen(dpidrc, "r")) == NULL) {
+      ERRMSG("dpi_dir", "fopen", errno);
+      MSG_ERR(" - %s\n", dpidrc);
+      return (NULL);
+   }
+
+   while ((rcline = dGetline(In)) != NULL) {
+      if (strncmp(rcline, "dpi_dir", 7) == 0)
+         break;
+      dFree(rcline);
+   }
+   fclose(In);
+
+   if (!rcline) {
+      ERRMSG("dpi_dir", "Failed to find a dpi_dir entry in dpidrc", 0);
+      MSG_ERR("Put your dillo plugins path in %s\n", dpidrc);
+      MSG_ERR("eg. dpi_dir=/usr/local/lib/dillo/dpi ");
+      MSG_ERR("with no leading spaces.\n");
+      value = NULL;
+   } else {
+      len = (int) strlen(rcline);
+      if (len && rcline[len - 1] == '\n')
+         rcline[len - 1] = 0;
+
+      if ((p = strchr(rcline, '='))) {
+         while (*++p == ' ');
+         value = dStrdup(p);
+      } else {
+         ERRMSG("dpi_dir", "strchr", 0);
+         MSG_ERR(" - '=' not found in %s\n", rcline);
+         value = NULL;
+      }
+   }
+
+   dFree(rcline);
+   return (value);
+}
+
 /*! Scans a service directory in dpi_dir and fills dpi_attr
  * \Note
  * Caller must allocate memory for dpi_attr.
--- a/dpid/dpid.h	Sun Jul 12 17:23:39 2009 -0400
+++ b/dpid/dpid.h	Mon Jul 13 15:24:42 2009 -0400
@@ -5,20 +5,10 @@
 #ifndef DPID_H
 #define DPID_H
 
-#include <assert.h>
-#include <signal.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <unistd.h>
-#include <string.h>
 #include <sys/socket.h>
-#include <sys/time.h>
+#include <sys/select.h> /* for fd_set */
 #include <sys/un.h>
-#include <errno.h>
+#include <signal.h>     /* for sig_atomic_t */
 
 #include "d_size.h"
 
--- a/dpid/dpid_common.c	Sun Jul 12 17:23:39 2009 -0400
+++ b/dpid/dpid_common.c	Mon Jul 13 15:24:42 2009 -0400
@@ -9,8 +9,8 @@
  * (at your option) any later version.
  */
 
+#include <errno.h>
 #include <stdio.h>
-#include <string.h>
 #include <unistd.h>
 #include "dpid_common.h"
 
--- a/dpid/dpid_common.h	Sun Jul 12 17:23:39 2009 -0400
+++ b/dpid/dpid_common.h	Mon Jul 13 15:24:42 2009 -0400
@@ -9,9 +9,6 @@
  * the next patch
  */
 
-#include <stdio.h>
-#include <errno.h>
-#include <sys/types.h>
 #include <dirent.h>
 
 #include "../dlib/dlib.h"
--- a/dpid/main.c	Sun Jul 12 17:23:39 2009 -0400
+++ b/dpid/main.c	Mon Jul 13 15:24:42 2009 -0400
@@ -15,12 +15,12 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include <errno.h>
-#include <unistd.h>
-#include <limits.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <assert.h>
+#include <errno.h>    /* for ckd_write */
+#include <unistd.h>   /* for ckd_write */
+#include <stdlib.h>   /* for exit */
+#include <assert.h>   /* for assert */
+#include <sys/stat.h> /* for umask */
+
 #include "dpid_common.h"
 #include "dpid.h"
 #include "dpi.h"
--- a/dpid/misc_new.c	Sun Jul 12 17:23:39 2009 -0400
+++ b/dpid/misc_new.c	Mon Jul 13 15:24:42 2009 -0400
@@ -9,20 +9,15 @@
  * (at your option) any later version.
  */
 
-#include <stdio.h>
-#include <time.h>
-#include <stdlib.h>
-#include <string.h>
+#include <errno.h>      /* errno, err-codes */
 #include <unistd.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <errno.h>
-#include <fcntl.h>
-#include "d_size.h"
-#include "misc_new.h"
+#include <time.h>
+#include <sys/stat.h>   /* stat */
+#include <stdlib.h>     /* rand, srand */
+
+#include "../dlib/dlib.h"
 #include "dpid_common.h"
-
-#include "misc_new.h"  /* for function prototypes */
+#include "misc_new.h"   /* for function prototypes */
 
 
 /*
--- a/dpid/misc_new.h	Sun Jul 12 17:23:39 2009 -0400
+++ b/dpid/misc_new.h	Mon Jul 13 15:24:42 2009 -0400
@@ -1,8 +1,6 @@
 #ifndef MISC_NEW_H
 #define MISC_NEW_H
 
-#include "../dlib/dlib.h"
-
 
 int a_Misc_close_fd(int fd);
 Dstr *a_Misc_rdtag(int socket);