From fad45baee35ac1801499bebfe24c53cfaff5cf67 Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Mon, 13 Jul 2009 15:24:42 -0400 Subject: Remove system includes for dpid --- dpid/dpid.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) (limited to 'dpid/dpid.c') diff --git a/dpid/dpid.c b/dpid/dpid.c index a21dcf9f..45324730 100644 --- a/dpid/dpid.c +++ b/dpid/dpid.c @@ -19,6 +19,9 @@ * Main functions to set-up dpi information and to initialise sockets */ #include +#include /* for exit */ +#include /* for F_SETFD, F_GETFD, FD_CLOEXEC */ + #include #include #include @@ -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 @@ enum file_type get_file_type(char *file_name) } } +/*! 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. -- cgit v1.2.3