diff options
author | Rodrigo Arias Mallo <rodarima@gmail.com> | 2024-03-28 19:06:04 +0100 |
---|---|---|
committer | Rodrigo Arias Mallo <rodarima@gmail.com> | 2024-03-28 22:53:07 +0100 |
commit | a6e64b01f81161cc614f238c37eb56f91cc4247f (patch) | |
tree | 4dc346c697465c51bfabae5cd51d535827df76e0 /dpid | |
parent | f6d6fcb6ebdb8079ffa69fb5545714b14ed5fd5c (diff) |
Handle .exe extension in Windows for dpis
On Cygwin the binaries have the ".exe" extension, so the logic to detect
dpi files has to take it into account when scanning the dpi_dir. The
extension DPI_EXT is defined to ".dpi" or ".dpi.exe" depending on the
platform extension discovered by autoconf.
Similarly, the dpidrc configuration file is also configured to match the
name of the DPI binaries.
See: https://github.com/cygwinports-extras/dillo/blob/master/3.0.2-exeext.patch
Fixes: https://github.com/dillo-browser/dillo/issues/105
Diffstat (limited to 'dpid')
-rw-r--r-- | dpid/Makefile.am | 3 | ||||
-rw-r--r-- | dpid/dpid.c | 20 | ||||
-rw-r--r-- | dpid/dpidrc.in | 6 |
3 files changed, 21 insertions, 8 deletions
diff --git a/dpid/Makefile.am b/dpid/Makefile.am index a59fa083..7f8e751e 100644 --- a/dpid/Makefile.am +++ b/dpid/Makefile.am @@ -1,5 +1,6 @@ AM_CPPFLAGS = \ -I$(top_srcdir) \ + -DEXEEXT='"$(EXEEXT)"' \ -DDPIDRC_SYS='"$(sysconfdir)/dpidrc"' bin_PROGRAMS = dpid dpidc @@ -31,5 +32,5 @@ sysconf_DATA = dpidrc CLEANFILES = $(sysconf_DATA) dpidrc: $(srcdir)/dpidrc.in Makefile - sed -e 's|[@]libdir[@]|$(libdir)|' $(srcdir)/dpidrc.in > dpidrc + sed -e 's|[@]libdir[@]|$(libdir)|;s|[@]EXEEXT[@]|$(EXEEXT)|g' $(srcdir)/dpidrc.in > dpidrc diff --git a/dpid/dpid.c b/dpid/dpid.c index 21e33bf2..06ae86b7 100644 --- a/dpid/dpid.c +++ b/dpid/dpid.c @@ -36,6 +36,8 @@ #include "../dpip/dpip.h" +#define DPI_EXT (".dpi" EXEEXT) + #define QUEUE 5 volatile sig_atomic_t caught_sigchld = 0; @@ -140,16 +142,26 @@ void est_dpi_terminator() } } +static int ends_with(const char *str, const char *suffix) +{ + if (!str || !suffix) + return 0; + size_t lenstr = strlen(str); + size_t lensuffix = strlen(suffix); + if (lensuffix > lenstr) + return 0; + return strncmp(str + lenstr - lensuffix, suffix, lensuffix) == 0; +} + /*! Identify a given file * Currently there is only one file type associated with dpis. * More file types will be added as needed */ enum file_type get_file_type(char *file_name) { - char *dot = strrchr(file_name, '.'); - - if (dot && !strcmp(dot, ".dpi")) - return DPI_FILE; /* Any filename ending in ".dpi" */ + if (ends_with(file_name, DPI_EXT)) + /* Any filename ending in ".dpi" (or ".dpi.exe" on Windows) */ + return DPI_FILE; else { MSG_ERR("get_file_type: Unknown file type for %s\n", file_name); return UNKNOWN_FILE; diff --git a/dpid/dpidrc.in b/dpid/dpidrc.in index b16f9b56..f0e69a0f 100644 --- a/dpid/dpidrc.in +++ b/dpid/dpidrc.in @@ -1,5 +1,5 @@ dpi_dir=@libdir@/dillo/dpi -proto.file=file/file.dpi -proto.ftp=ftp/ftp.filter.dpi -proto.data=datauri/datauri.filter.dpi +proto.file=file/file.dpi@EXEEXT@ +proto.ftp=ftp/ftp.filter.dpi@EXEEXT@ +proto.data=datauri/datauri.filter.dpi@EXEEXT@ |