diff --git a/chm_http-bind-localhost.patch b/chm_http-bind-localhost.patch new file mode 100644 index 0000000..05ba0ca --- /dev/null +++ b/chm_http-bind-localhost.patch @@ -0,0 +1,25 @@ +From ad27f1981415f9b9df179099e36d793327ce6d8c Mon Sep 17 00:00:00 2001 +From: "FeRD (Frank Dana)" +Date: Thu, 11 Jul 2019 20:57:19 -0400 +Subject: [PATCH] Change the default binding to 127.0.0.1 + +--- + src/chm_http.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/chm_http.c b/src/chm_http.c +index 237e85a..ddffe55 100644 +--- a/src/chm_http.c ++++ b/src/chm_http.c +@@ -50,7 +50,7 @@ + #include + + int config_port = 8080; +-char config_bind[65536] = "0.0.0.0"; ++char config_bind[65536] = "127.0.0.1"; + + static void usage(const char *argv0) + { +-- +2.21.0 + diff --git a/chm_http-output-server-address.patch b/chm_http-output-server-address.patch new file mode 100644 index 0000000..7359b47 --- /dev/null +++ b/chm_http-output-server-address.patch @@ -0,0 +1,78 @@ +From 472396d694ae1d8b77f8b349ab13e387b9eae629 Mon Sep 17 00:00:00 2001 +From: "FeRD (Frank Dana)" +Date: Thu, 11 Jul 2019 21:16:43 -0400 +Subject: [PATCH] Print URL for server, quiet option suppresses + +This will display a line of text on stdout immediately after +binding to the configured address and port: +`Server running at http://
:/` +An option `-q` / `--quiet` is added, to suppress the output. +--- + src/chm_http.c | 18 +++++++++++++++--- + 1 file changed, 15 insertions(+), 3 deletions(-) + +diff --git a/src/chm_http.c b/src/chm_http.c +index 237e85a..84304f9 100644 +--- a/src/chm_http.c ++++ b/src/chm_http.c +@@ -51,13 +51,14 @@ + + int config_port = 8080; + char config_bind[65536] = "127.0.0.1"; ++char config_quiet = 0; + + static void usage(const char *argv0) + { + #ifdef CHM_HTTP_SIMPLE +- fprintf(stderr, "usage: %s \n", argv0); ++ fprintf(stderr, "usage: %s [--quiet] \n", argv0); + #else +- fprintf(stderr, "usage: %s [--port=PORT] [--bind=IP] \n", argv0); ++ fprintf(stderr, "usage: %s [--quiet] [--port=PORT] [--bind=IP] \n", argv0); + #endif + exit(1); + } +@@ -80,6 +81,7 @@ int main(int c, char **v) + { + { "port", required_argument, 0, 'p' }, + { "bind", required_argument, 0, 'b' }, ++ { "quiet", no_argument, 0, 'q' }, + { "help", no_argument, 0, 'h' }, + { 0, 0, 0, 0 } + }; +@@ -87,7 +89,7 @@ int main(int c, char **v) + while (1) + { + int o; +- o = getopt_long (c, v, "p:b:h", longopts, &optindex); ++ o = getopt_long (c, v, "p:b:qh", longopts, &optindex); + if (o < 0) + { + break; +@@ -109,6 +111,10 @@ int main(int c, char **v) + config_bind[65535] = '\0'; + break; + ++ case 'q': ++ config_quiet = 1; ++ break; ++ + case 'h': + usage (v[0]); + break; +@@ -182,6 +188,12 @@ static void chmhttp_server(const char *filename) + exit(3); + } + ++ /* Display URL for server */ ++ if (!config_quiet) ++ { ++ printf("Server running at http://%s:%d/\n", config_bind, config_port); ++ } ++ + /* listen for connections */ + listen(server.socket, 75); + addrLen = sizeof(struct sockaddr); +-- +2.21.0 + diff --git a/chm_http-port-shortopt.patch b/chm_http-port-shortopt.patch new file mode 100644 index 0000000..d3fdf0c --- /dev/null +++ b/chm_http-port-shortopt.patch @@ -0,0 +1,28 @@ +From 107ce67661c517d1c0b63c31ed1dbe34573de445 Mon Sep 17 00:00:00 2001 +From: "FeRD (Frank Dana)" +Date: Thu, 11 Jul 2019 21:20:23 -0400 +Subject: [PATCH] Correct port short-opt to -p (not -n) + +The getopt_long arguments specified the short option for `--port` as +`-n`, which was not handled by the case statement, making both `-p` +(invalid argument) and `-n` (ignored) unusable to set the port. +--- + src/chm_http.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/chm_http.c b/src/chm_http.c +index 237e85a..6ae00cc 100644 +--- a/src/chm_http.c ++++ b/src/chm_http.c +@@ -87,7 +87,7 @@ int main(int c, char **v) + while (1) + { + int o; +- o = getopt_long (c, v, "n:b:h", longopts, &optindex); ++ o = getopt_long (c, v, "p:b:h", longopts, &optindex); + if (o < 0) + { + break; +-- +2.21.0 + diff --git a/chmlib-0.40.tar.bz2 b/chmlib-0.40.tar.bz2 new file mode 100644 index 0000000..858c5f3 Binary files /dev/null and b/chmlib-0.40.tar.bz2 differ diff --git a/chmlib-0001-Patch-to-fix-integer-types-problem-by-Goswin-von-Bre.patch b/chmlib-0001-Patch-to-fix-integer-types-problem-by-Goswin-von-Bre.patch new file mode 100644 index 0000000..2de748b --- /dev/null +++ b/chmlib-0001-Patch-to-fix-integer-types-problem-by-Goswin-von-Bre.patch @@ -0,0 +1,73 @@ +From be20aa9e5992f371fa0f73be16bb1b145192a428 Mon Sep 17 00:00:00 2001 +From: Jed Wing +Date: Wed, 27 May 2009 18:25:42 -0700 +Subject: [PATCH 1/2] Patch to fix integer types problem by Goswin von + Brederlow. + +This came from Goswin von Brederlow via +Kartik Mistry, the maintainer of the Debian package of chmlib. +--- + src/chm_lib.c | 30 +++++++++++++----------------- + 1 file changed, 13 insertions(+), 17 deletions(-) + +diff --git a/src/chm_lib.c b/src/chm_lib.c +index 6c6736c..ffd213c 100644 +--- a/src/chm_lib.c ++++ b/src/chm_lib.c +@@ -56,6 +56,7 @@ + + #include "lzx.h" + ++#include + #include + #include + #ifdef CHM_DEBUG +@@ -149,22 +150,9 @@ typedef unsigned __int32 UInt32; + typedef __int64 Int64; + typedef unsigned __int64 UInt64; + +-/* I386, 32-bit, non-Windows */ +-/* Sparc */ +-/* MIPS */ +-/* PPC */ +-#elif __i386__ || __sun || __sgi || __ppc__ +-typedef unsigned char UChar; +-typedef short Int16; +-typedef unsigned short UInt16; +-typedef long Int32; +-typedef unsigned long UInt32; +-typedef long long Int64; +-typedef unsigned long long UInt64; +- + /* x86-64 */ + /* Note that these may be appropriate for other 64-bit machines. */ +-#elif __x86_64__ || __ia64__ ++#elif defined(__LP64__) + typedef unsigned char UChar; + typedef short Int16; + typedef unsigned short UInt16; +@@ -173,10 +161,18 @@ typedef unsigned int UInt32; + typedef long Int64; + typedef unsigned long UInt64; + ++/* I386, 32-bit, non-Windows */ ++/* Sparc */ ++/* MIPS */ ++/* PPC */ + #else +- +-/* yielding an error is preferable to yielding incorrect behavior */ +-#error "Please define the sized types for your platform in chm_lib.c" ++typedef unsigned char UChar; ++typedef short Int16; ++typedef unsigned short UInt16; ++typedef long Int32; ++typedef unsigned long UInt32; ++typedef long long Int64; ++typedef unsigned long long UInt64; + #endif + + /* GCC */ +-- +1.8.3.1 + diff --git a/chmlib-0002-Fix-for-extract_chmLib-confusing-empty-files-with-di.patch b/chmlib-0002-Fix-for-extract_chmLib-confusing-empty-files-with-di.patch new file mode 100644 index 0000000..bcd4a0f --- /dev/null +++ b/chmlib-0002-Fix-for-extract_chmLib-confusing-empty-files-with-di.patch @@ -0,0 +1,40 @@ +From 5998ff5105a9cd3f684519927e2ac78d3b6a3c30 Mon Sep 17 00:00:00 2001 +From: Jed Wing +Date: Wed, 27 May 2009 18:41:10 -0700 +Subject: [PATCH 2/2] Fix for extract_chmLib confusing empty files with + directories. + +Patch from Paul Wise via Kartik Mistry, the maintainer of the +Debian chmlib package. +--- + src/extract_chmLib.c | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +diff --git a/src/extract_chmLib.c b/src/extract_chmLib.c +index 078cc35..478c892 100644 +--- a/src/extract_chmLib.c ++++ b/src/extract_chmLib.c +@@ -102,6 +102,7 @@ int _extract_callback(struct chmFile *h, + struct chmUnitInfo *ui, + void *context) + { ++ LONGUINT64 ui_path_len; + char buffer[32768]; + struct extract_context *ctx = (struct extract_context *)context; + char *i; +@@ -119,7 +120,11 @@ int _extract_callback(struct chmFile *h, + if (snprintf(buffer, sizeof(buffer), "%s%s", ctx->base_path, ui->path) > 1024) + return CHM_ENUMERATOR_FAILURE; + +- if (ui->length != 0) ++ /* Get the length of the path */ ++ ui_path_len = strlen(ui->path)-1; ++ ++ /* Distinguish between files and dirs */ ++ if (ui->path[ui_path_len] != '/' ) + { + FILE *fout; + LONGINT64 len, remain=ui->length; +-- +1.8.3.1 + diff --git a/chmlib.spec b/chmlib.spec new file mode 100644 index 0000000..5ff5d24 --- /dev/null +++ b/chmlib.spec @@ -0,0 +1,86 @@ +Name: chmlib +Summary: Library for dealing with ITSS/CHM format files +Version: 0.40 +Release: 1 +License: LGPLv2+ +Url: http://www.jedrea.com/chmlib/ +%if 0%{?el7}%{?fedora} +VCS: https://github.com/jedwing/CHMLib.git +%endif +Source0: http://www.jedrea.com/chmlib/%{name}-%{version}.tar.bz2 +# backported from upstream +Patch1: chmlib-0001-Patch-to-fix-integer-types-problem-by-Goswin-von-Bre.patch +# backported from upstream +Patch2: chmlib-0002-Fix-for-extract_chmLib-confusing-empty-files-with-di.patch +# Submitted upstream https://github.com/jedwing/CHMLib/pull/10 +Patch3: chm_http-port-shortopt.patch +# Submitted upstream https://github.com/jedwing/CHMLib/pull/11 +Patch4: chm_http-bind-localhost.patch +# Submitted upstream https://github.com/jedwing/CHMLib/pull/12 +Patch5: chm_http-output-server-address.patch +BuildRequires: autoconf +BuildRequires: automake +BuildRequires: libtool +BuildRequires: make + + +%description +CHMLIB is a library for dealing with ITSS/CHM format files. Right now, it is +a very simple library, but sufficient for dealing with all of the .chm files +I've come across. Due to the fairly well-designed indexing built into this +particular file format, even a small library is able to gain reasonably good +performance indexing into ITSS archives. + + +%package devel +Summary: Library for dealing with ITSS/CHM format files - development files +Requires: %{name}%{?_isa} = %{version}-%{release} + + +%description devel +Files needed for developing apps using chmlib. + + +%prep +%setup -q +%patch1 -p1 -b .types +%patch2 -p1 -b .files_dirs +%patch3 -p1 -b .shortopt +%patch4 -p1 -b .localhost +%patch5 -p1 -b .printaddr +rm -f libtool +mv configure.in configure.ac +autoreconf -ivf + + +%build +%configure --enable-examples --disable-static +make %{?_smp_mflags} + + +%install +make DESTDIR=%{buildroot} install +rm -f %{buildroot}/%{_libdir}/*.la + + +%ldconfig_scriptlets + + +%files +%{_bindir}/chm_http +%{_bindir}/enum_chmLib +%{_bindir}/enumdir_chmLib +%{_bindir}/extract_chmLib +%{_bindir}/test_chmLib +%{_libdir}/libchm.so.* +%doc README AUTHORS COPYING NEWS + + +%files devel +%{_includedir}/* +%{_libdir}/libchm.so + + +%changelog +* Wed May 24 2023 wangtaozhi - 0.40-1 +- Package init diff --git a/chmlib.yaml b/chmlib.yaml new file mode 100644 index 0000000..a04c167 --- /dev/null +++ b/chmlib.yaml @@ -0,0 +1,4 @@ +version_control: github +src_repo: https://github.com/jedwing/CHMLib +tag_prefix: "v" +separator: "."