Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package epub2txt2 for openSUSE:Factory checked in at 2022-08-04 13:23:48 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/epub2txt2 (Old) and /work/SRC/openSUSE:Factory/.epub2txt2.new.1521 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "epub2txt2" Thu Aug 4 13:23:48 2022 rev:5 rq:992660 version:2.06 Changes: -------- --- /work/SRC/openSUSE:Factory/epub2txt2/epub2txt2.changes 2022-06-24 08:45:15.831136039 +0200 +++ /work/SRC/openSUSE:Factory/.epub2txt2.new.1521/epub2txt2.changes 2022-08-04 13:24:14.116630040 +0200 @@ -1,0 +2,9 @@ +Thu Jul 28 03:10:37 UTC 2022 - Soc Virnyl Estela <socvirnyl.est...@gmail.com> + +- Update to version 2.06: + * No changelog available + +- Added 54b41e87156bc823d5938749d71c4c57adc75b1b.patch: + * Fixed handling of URL-encoded spine hrefs + +------------------------------------------------------------------- Old: ---- 02f69e6243d6c96f78da45fb710a265e5aee2fb5.tar.gz New: ---- 54b41e87156bc823d5938749d71c4c57adc75b1b.patch ac4e73fa79202ccc106b36c06c20e36c37345a58.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ epub2txt2.spec ++++++ --- /var/tmp/diff_new_pack.cN5ifh/_old 2022-08-04 13:24:14.612631447 +0200 +++ /var/tmp/diff_new_pack.cN5ifh/_new 2022-08-04 13:24:14.616631458 +0200 @@ -16,16 +16,17 @@ # -%global _commit_hash "02f69e6243d6c96f78da45fb710a265e5aee2fb5" +%global _commit_hash ac4e73fa79202ccc106b36c06c20e36c37345a58 Name: epub2txt2 -Version: 2.04 +Version: 2.06 Release: 0 Summary: Simple command-line utility for extracting text from EPUB documents License: GPL-3.0-only Group: Productivity/Text/Utilities URL: https://github.com/kevinboone/epub2txt2 -Source0: https://github.com/kevinboone/epub2txt2/archive/02f69e6243d6c96f78da45fb710a265e5aee2fb5.tar.gz +Source0: https://github.com/kevinboone/epub2txt2/archive/%{_commit_hash}.tar.gz +Patch0: 54b41e87156bc823d5938749d71c4c57adc75b1b.patch BuildRequires: gcc BuildRequires: make Requires: unzip @@ -34,7 +35,7 @@ Simple command-line utility for extracting text from EPUB documents %prep -%setup -n %{name}-%{_commit_hash} +%autosetup -n %{name}-%{_commit_hash} -p1 %build %make_build ++++++ 54b41e87156bc823d5938749d71c4c57adc75b1b.patch ++++++ >From 54b41e87156bc823d5938749d71c4c57adc75b1b Mon Sep 17 00:00:00 2001 From: Kevin Boone <ke...@railwayterrace.com> Date: Thu, 30 Jun 2022 15:41:59 +0100 Subject: [PATCH] Fixed handling of URL-encoded spine hrefs --- README.md | 1 + src/epub2txt.c | 3 ++- src/util.c | 44 +++++++++++++++++++++++++++++++++++++++++++- src/util.h | 6 +++++- src/xhtml.c | 5 +++++ 5 files changed, 56 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4fbcafc..546242f 100644 --- a/README.md +++ b/README.md @@ -244,6 +244,7 @@ covered. Date | Change -----|------- +?, Jun 2022 | Fixed handling of URL-encoded spine href's 2.06, Jun 2022 | Fixed bug in invoking unzip 2.05, Apr 2022 | Fixed bug with empty metadata tags 2.04, Apr 2022 | Improved handling of UTF-8 BOMs diff --git a/src/epub2txt.c b/src/epub2txt.c index 7e9f4a1..72e0504 100644 --- a/src/epub2txt.c +++ b/src/epub2txt.c @@ -312,7 +312,8 @@ List *epub2txt_get_items (const char *opf, char **error) char *val2 = r3->attributes[p].value; if (strcmp (name2, "href") == 0) { - list_append (ret, strdup (val2)); + char *decoded_val2 = decode_url (val2); + list_append (ret, decoded_val2); } } } diff --git a/src/util.c b/src/util.c index 853343c..16e7431 100644 --- a/src/util.c +++ b/src/util.c @@ -1,12 +1,14 @@ /*============================================================================ epub2txt v2 util.c - Copyright (c)2022 Marco Bonelli, GPL v3.0 + Copyright (c)2022 Marco Bonelli, Kevin Boone, GPL v3.0 ============================================================================*/ #include <errno.h> #include <string.h> #include <unistd.h> +#include <stdlib.h> +#include <ctype.h> #include <signal.h> #include <sys/wait.h> #include "util.h" @@ -16,6 +18,7 @@ run_command Run an helper command through fork + execvp, wait for it to finish and return its status. Log execvp errors, and abort execution if abort_on_error is TRUE. +(Marco Bonelli) *==========================================================================*/ int run_command (const char *const argv[], BOOL abort_on_error) { @@ -39,3 +42,42 @@ int run_command (const char *const argv[], BOOL abort_on_error) waitpid (pid, &status, 0); return status; } + +/*========================================================================== + Decode %xx in URL-type strings. The caller must free the resulting + string, which will be no longer than the input. + (Kevin Boone) +*==========================================================================*/ +char *decode_url (const char *url) + { + char *ret = malloc (strlen (url) + 2); + + int len = 0; + for (; *url; len++) + { + if (*url == '%' && url[1] && url[2] && + isxdigit(url[1]) && isxdigit(url[2])) + { + char url1 = url[1]; + char url2 = url[2]; + url1 -= url1 <= '9' ? '0' : (url1 <= 'F' ? 'A' : 'a')-10; + url2 -= url2 <= '9' ? '0' : (url2 <= 'F' ? 'A' : 'a')-10; + ret[len] = 16 * url1 + url2; + url += 3; + continue; + } + else if (*url == '+') + { + /* I have not tested this piece of the function, because I have not + seen any instances of '+' (meaning space) in a spine href */ + url += 1; + ret[len] = ' '; + } + ret[len] = *url++; + } + ret[len] = '\0'; + + return ret; + } + + diff --git a/src/util.h b/src/util.h index 2685a02..6b0c197 100644 --- a/src/util.h +++ b/src/util.h @@ -1,7 +1,7 @@ /*============================================================================ epub2txt v2 util.h - Copyright (c)2022 Marco Bonelli, GPL v3.0 + Copyright (c)2022 Marco Bonelli, Kevin Boone GPL v3.0 ============================================================================*/ #pragma once @@ -9,3 +9,7 @@ #include "defs.h" int run_command (const char *const argv[], BOOL abort_on_error); + +/** Decode %xx in URL-type strings. The caller must free the resulting + string, which will be no longer than the input. */ +char *decode_url (const char *url); diff --git a/src/xhtml.c b/src/xhtml.c index 1338882..fbfceae 100644 --- a/src/xhtml.c +++ b/src/xhtml.c @@ -530,6 +530,8 @@ WString *xhtml_transform_char (uint32_t c, BOOL to_ascii) ============================================================================*/ WString *xhtml_translate_entity (const WString *entity) { + /* Program flow in this function is very ugly, and prone to memory + leaks when modified. The whole thing needs to be rewritten */ char out[20]; IN char *in = wstring_to_utf8 (entity); @@ -569,8 +571,11 @@ WString *xhtml_translate_entity (const WString *entity) WString *ret = wstring_create_empty(); wstring_append_c (ret, (uint32_t)v); OUT + free (s); + free (in); return ret; } + free (s); } else { ++++++ 02f69e6243d6c96f78da45fb710a265e5aee2fb5.tar.gz -> ac4e73fa79202ccc106b36c06c20e36c37345a58.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/epub2txt2-02f69e6243d6c96f78da45fb710a265e5aee2fb5/Makefile new/epub2txt2-ac4e73fa79202ccc106b36c06c20e36c37345a58/Makefile --- old/epub2txt2-02f69e6243d6c96f78da45fb710a265e5aee2fb5/Makefile 2022-04-13 10:51:39.000000000 +0200 +++ new/epub2txt2-ac4e73fa79202ccc106b36c06c20e36c37345a58/Makefile 2022-06-30 10:48:08.000000000 +0200 @@ -1,7 +1,8 @@ -VERSION := 2.04 +VERSION := 2.06 CC := gcc CFLAGS := -Wall -fPIC -fPIE -LDFLAGS := -pie -s +#LDFLAGS := -pie -s +LDFLAGS := -pie DESTDIR := PREFIX := /usr BINDIR := /bin diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/epub2txt2-02f69e6243d6c96f78da45fb710a265e5aee2fb5/README.md new/epub2txt2-ac4e73fa79202ccc106b36c06c20e36c37345a58/README.md --- old/epub2txt2-02f69e6243d6c96f78da45fb710a265e5aee2fb5/README.md 2022-04-13 10:51:39.000000000 +0200 +++ new/epub2txt2-ac4e73fa79202ccc106b36c06c20e36c37345a58/README.md 2022-06-30 10:48:08.000000000 +0200 @@ -1,6 +1,6 @@ # epub2txt -- Extract text from EPUB documents -Version 2.04, April 2022 +Version 2.06, June 2022 ## What is this? @@ -91,7 +91,7 @@ `-a, --asiii` Reduces multi-byte charaters to 7-bit ASCII if possible. Some very common -characters are easilty converted, like the various Unicode spaces, which +characters are easily converted, like the various Unicode spaces, which can be converted into plain ASCII spaces. Common accented characters (.e.,g "é" are converted -- for better or worse -- into their non-accented equivalents. Some single-character entities like © @@ -135,7 +135,7 @@ is a terminal, the program will try to work out how wide it is. If it can't, it will assume 80 characters. The implication of using standard input to determine terminal width is that -`epub2txt` still assumes it must produced fixed-width output, +`epub2txt` still assumes it must produce fixed-width output, even if output is redirected to some other utility. This makes it possible to use `epub2txt` without specific command-line switches in common modes of operation like: @@ -182,56 +182,70 @@ ## Bugs and limitations +The main development priorities for `epub2txt` are speed and compactness, not +military-grade security. The program is not designed for use in hostile +environments, such as processing input from the Internet. It's almost +certainly possible to craft an EPUB file that will cause a buffer overrun or +stack collision, with uncertain results. I don't want to bloat the utility +further by adding checks for every conceivable failure that a hostile EPUB +might manifest. Please don't use `epub2txt` for applications where security is +a primary concern -- it's not designed for this, and is really not suitable. + There is no support for any form of DRM or encryption, and such support is unlikely to be added in the future. -`epub2txt` only handles documents that use -UTF8 (or ASCII) encoding (but I believe that UTF8 is more-or-less -universal in EPUB), -and writes output only in UTF8 encoding, -regardless of the platform's locale. This limitation exists because -`epub2txt` does all its own -character encoding conversions -to avoid creating a dependency on an external library. Doing this for UTF8 -is enough work on its own; doing it for arbitrary encodings would be -overwhelming. - -The program can't correct errors in encoding, and there are a large number -of EPUB documents in public repositories that contain encoding errors. -A common problem is spurious use of non-UTF8 8-bit characters, often -in documents that have been converted from Microsoft Office applications. - -`epub2txt` does not right-justify text, as there are already many -good utilities to do this (e.g., `groff`) - -`epub2txt` extracts text aggressively, and will include things that -cannot possibly be rendered properly in plain text. This includes constructs -like indices and tables of contents, which will be of little use. The captions -of pictures will also likely be included, even though the pictures themselves -can not. It seemed -better to err on the side of extracting too much text than too little; -unfortunately there is little in the EPUB format to distinguish content that -is meaningful in a text-only representation from that which is not. - -It is unlikely that any kind of fixed-layout structure of the -source document will be rendered accurately in plain text, so -`epub2txt` does not try. Tabs and other layout elements are -collapsed -into spaces, and text re-flowed according to the line length (except -in raw mode). +`epub2txt` only handles documents that use UTF8 (or ASCII) encoding (but I +believe that UTF8 is more-or-less universal in EPUB), and writes output only in +UTF8 encoding, regardless of the platform's locale. This limitation exists +because `epub2txt` does all its own character encoding conversions to avoid +creating a dependency on an external library. Doing this for UTF8 is enough +work on its own; doing it for arbitrary encodings would be overwhelming. + +The program can't correct errors in encoding, and there are a large number of +EPUB documents in public repositories that contain encoding errors. A common +problem is spurious use of non-UTF8 8-bit characters, often in documents that +have been converted from Microsoft Office applications. + +`epub2txt` does not right-justify text, as there are already many good +utilities to do this (e.g., `groff`) + +`epub2txt` extracts text aggressively, and will include things that cannot +possibly be rendered properly in plain text. This includes constructs like +indices and tables of contents, which will be of little use. The captions of +pictures will also likely be included, even though the pictures themselves can +not. It seemed better to err on the side of extracting too much text than too +little; unfortunately there is little in the EPUB format to distinguish content +that is meaningful in a text-only representation from that which is not. + +It is unlikely that any kind of fixed-layout structure of the source document +will be rendered accurately in plain text, so `epub2txt` does not try. Tabs and +other layout elements are collapsed into spaces, and text re-flowed according +to the line length (except in raw mode). Conversion of Unicode to ASCII is, in the general case, impossible. The -`--ascii` switch tells `epub2txt` to perform some -common conversions, such as straight quotes for angled quotes. -It will also attempt to replace accented latin characters with non-accented -equivalents, at least for commonly-used characters. However, there are -a huge number of characters in the Unicode set that cannot be rendered, -even approximately, in ASCII. +`--ascii` switch tells `epub2txt` to perform some common conversions, such as +straight quotes for angled quotes. It will also attempt to replace accented +Latin characters with non-accented equivalents, at least for commonly-used +characters. However, there are a huge number of characters in the Unicode set +that cannot be rendered, even approximately, in ASCII. + +Only limited testing has been done with EPUB 3.x documents. + +It would be possible to enhance `epub2txt` so that it outputs HTML, or +LaTeX, or PDF; it would be possible to add searching and indexing features; +it would be possible to extend it to include other input formats. +However, I intended `epub2txt` to be a simple, lightweight utility and, +at present, I consider it to be feature-complete. One day I might develop +a more sophisticated version but, frankly, Calibre already has this +covered. + ## Revision history Date | Change -----|------- +2.06, Jun 2022 | Fixed bug in invoking unzip +2.05, Apr 2022 | Fixed bug with empty metadata tags 2.04, Apr 2022 | Improved handling of UTF-8 BOMs 2.03, Jan 2022 | Fixed a buffer overrun bug 2.02, May 2020 | Updated XML parser @@ -246,8 +260,8 @@ ## Author and legal -`epub2txt` is maintained by Kevin Boone, and distributed under the terms -of the GNU Public Licence, v3.0. Essentially, this means that you may -use this software as you wish, at your own risk, provided that the -original author continues to be acknowledged. +`epub2txt` is maintained by Kevin Boone, with contributions from various other +people, and distributed under the terms of the GNU Public Licence, v3.0. +Essentially, this means that you may use this software as you wish, at your +own risk, provided that the original authors continue to be acknowledged. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/epub2txt2-02f69e6243d6c96f78da45fb710a265e5aee2fb5/man1/epub2txt.1 new/epub2txt2-ac4e73fa79202ccc106b36c06c20e36c37345a58/man1/epub2txt.1 --- old/epub2txt2-02f69e6243d6c96f78da45fb710a265e5aee2fb5/man1/epub2txt.1 2022-04-13 10:51:39.000000000 +0200 +++ new/epub2txt2-ac4e73fa79202ccc106b36c06c20e36c37345a58/man1/epub2txt.1 2022-06-30 10:48:08.000000000 +0200 @@ -3,7 +3,7 @@ .\" redistribute this software so long as all of the original files are .\" included, and that this copyright notice is retained. .\" -.TH epub2txt 1 "April 2022" +.TH epub2txt 1 "May 2022" .SH NAME epub2txt \- Extract text from EPUB documents .SH SYNOPSIS @@ -82,7 +82,8 @@ .SH AUTHOR AND LEGAL \fIepub2txt\fR -is maintained by Kevin Boone, and is open source under the +is maintained by Kevin Boone, with contributions from others, +and is open source under the terms of the GNU Public Licence, version 3.0. There is no warranty of any kind. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/epub2txt2-02f69e6243d6c96f78da45fb710a265e5aee2fb5/src/epub2txt.c new/epub2txt2-ac4e73fa79202ccc106b36c06c20e36c37345a58/src/epub2txt.c --- old/epub2txt2-02f69e6243d6c96f78da45fb710a265e5aee2fb5/src/epub2txt.c 2022-04-13 10:51:39.000000000 +0200 +++ new/epub2txt2-ac4e73fa79202ccc106b36c06c20e36c37345a58/src/epub2txt.c 2022-06-30 10:48:08.000000000 +0200 @@ -11,8 +11,6 @@ #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> -#include <sys/wait.h> -#include <signal.h> #include <errno.h> #ifndef __APPLE__ #include <malloc.h> @@ -23,6 +21,7 @@ #include "string.h" #include "sxmlc.h" #include "xhtml.h" +#include "util.h" /*============================================================================ epub2txt_unescape_html @@ -89,14 +88,22 @@ static void epub2txt_format_meta (const Epub2TxtOptions *options, const char *key, const char *text) { - char *ss = epub2txt_unescape_html (text); - char *s; - asprintf (&s, "%s: %s", key, ss); - char *error = NULL; - xhtml_utf8_to_stdout (s, options, &error); - if (error) free (error); - free (s); - free (ss); + // text ends up "null" here, if the meta tag had no content (which should + // not happen, but we don't want to crash if it does). I suppress all + // output in this case, but perhaps it would be better to print the + // metadata key, and the value "null", or "empty"? I can't really predict + // what a user would prefer to see. + if (text) + { + char *ss = epub2txt_unescape_html (text); + char *s; + asprintf (&s, "%s: %s", key, ss); + char *error = NULL; + xhtml_utf8_to_stdout (s, options, &error); + if (error) free (error); + free (s); + free (ss); + } } @@ -134,10 +141,16 @@ XMLNode *r2 = metadata->children[i]; const char *mdtag = r2->tag; const char *mdtext = r2->text; + // Don't try to print anything if the metadata text is null + if (!mdtext) continue; if (strstr (mdtag, "creator")) epub2txt_format_meta (options, "Creator", mdtext); else if (strstr (mdtag, "publisher")) epub2txt_format_meta (options, "Publisher", mdtext); + else if (strstr (mdtag, "contributor")) + epub2txt_format_meta (options, "Contributor", mdtext); + else if (strstr (mdtag, "identifier")) + epub2txt_format_meta (options, "Identifier", mdtext); else if (strstr (mdtag, "date")) { char *mdate = strdup (mdtext); @@ -400,68 +413,52 @@ { log_debug ("File access OK"); - //output_para = 0; - char tempdir[512]; - char tempbase[256]; - char cmd[1024]; - - if (getenv ("TMP")) - strcpy (tempbase, getenv("TMP")); - else if (getenv ("TMPDIR")) - strcpy (tempbase, getenv("TMPDIR")); - else - strcpy (tempbase, "/tmp"); + char *tempbase, *tempdir; - log_debug ("tempbase is: %s", tempbase); + if (!(tempbase = getenv("TMP")) && !(tempbase = getenv("TMPDIR"))) + tempbase = "/tmp"; - sprintf (tempdir, "%s/epub2txt%d", tempbase, getpid()); + log_debug ("tempbase is: %s", tempbase); + asprintf (&tempdir, "%s/epub2txt%d", tempbase, getpid()); log_debug ("tempdir is: %s", tempdir); - // We should really check this but, honestly, anybody who creates - // a non-writable tempdir has problems far worse than being unable - // to run this utility - mkdir (tempdir, 0777); + if (mkdir (tempdir, 0777) == -1) + { + log_error ("Can't create directory for extraction: \"%s\": %s", tempdir, + strerror (errno)); + free(tempdir); + return; + } BOOL unzip_ok = TRUE; log_debug ("Running unzip command"); - int pid = fork(); - if (pid == 0) - { - execlp ("unzip", "unzip", "-o", "-qq", file, "-d", tempdir, NULL); - log_error ("Can't execute unzip: %s", strerror (errno)); - kill (getppid(), SIGTERM); - exit (-1); - } - else - { - int status = 0; - waitpid (pid, &status, 0); - // We could set unzip_ok here, but I'm not sure that unzip really - // returns a reliable status code - } + run_command ((const char *[]){"unzip", "-o", "-qq", file, "-d", tempdir, + NULL}, TRUE); + // We could set unzip_ok here, but I'm not sure that unzip really + // returns a reliable status code if (unzip_ok) { log_debug ("Unzip finished"); // On some systems, unzip results in a file with no read permissions - // for the user -- reason unknown - sprintf (cmd, "chmod -R 744 \"%s\"", tempdir); - log_debug ("Fix permissions: %s", cmd); - system (cmd); + // for the user -- reason unknown + log_debug ("Fix permissions: %s", tempdir); + run_command((const char *[]){"chmod", "-R", "744", tempdir, NULL}, FALSE); log_debug ("Permissions fixed"); - - char opf[1024]; - sprintf (opf, "%s/META-INF/container.xml", tempdir); + char *opf; + asprintf (&opf, "%s/META-INF/container.xml", tempdir); log_debug ("OPF path is: %s", opf); String *rootfile = epub2txt_get_root_file (opf, error); if (*error == NULL) { log_debug ("OPF rootfile is: %s", string_cstr(rootfile)); - sprintf (opf, "%s/%s", tempdir, string_cstr (rootfile)); + free (opf); + asprintf (&opf, "%s/%s", tempdir, string_cstr (rootfile)); + char *content_dir = strdup (opf); char *p = strrchr (content_dir, '/'); *p = 0; @@ -490,24 +487,27 @@ for (i = 0; i < l; i++) { const char *item = (const char *)list_get (list, i); - sprintf (opf, "%s/%s", content_dir, item); + free (opf); + asprintf (&opf, "%s/%s", content_dir, item); xhtml_file_to_stdout (opf, options, error); } list_destroy (list); } } free (content_dir); + free (opf); } if (rootfile) string_destroy (rootfile); - sprintf (cmd, "rm -rf \"%s\"", tempdir); log_debug ("Deleting temporary directory"); - system (cmd); + run_command ((const char *[]){"rm", "-rf", tempdir, NULL}, FALSE); } else { // unzip failed } + + free (tempdir); } else { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/epub2txt2-02f69e6243d6c96f78da45fb710a265e5aee2fb5/src/util.c new/epub2txt2-ac4e73fa79202ccc106b36c06c20e36c37345a58/src/util.c --- old/epub2txt2-02f69e6243d6c96f78da45fb710a265e5aee2fb5/src/util.c 1970-01-01 01:00:00.000000000 +0100 +++ new/epub2txt2-ac4e73fa79202ccc106b36c06c20e36c37345a58/src/util.c 2022-06-30 10:48:08.000000000 +0200 @@ -0,0 +1,41 @@ +/*============================================================================ + epub2txt v2 + util.c + Copyright (c)2022 Marco Bonelli, GPL v3.0 +============================================================================*/ + +#include <errno.h> +#include <string.h> +#include <unistd.h> +#include <signal.h> +#include <sys/wait.h> +#include "util.h" +#include "log.h" + +/*========================================================================== +run_command +Run an helper command through fork + execvp, wait for it to finish and return +its status. Log execvp errors, and abort execution if abort_on_error is TRUE. +*==========================================================================*/ +int run_command (const char *const argv[], BOOL abort_on_error) + { + int status; + int pid = fork(); + + if (pid == 0) + { + execvp(argv[0], (char **const)argv); + log_error ("Can't execute command \"%s\": %s", argv[0], strerror (errno)); + + if (abort_on_error) + { + kill (getppid(), SIGTERM); + _exit (-1); + } + + _exit (0); + } + + waitpid (pid, &status, 0); + return status; + } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/epub2txt2-02f69e6243d6c96f78da45fb710a265e5aee2fb5/src/util.h new/epub2txt2-ac4e73fa79202ccc106b36c06c20e36c37345a58/src/util.h --- old/epub2txt2-02f69e6243d6c96f78da45fb710a265e5aee2fb5/src/util.h 1970-01-01 01:00:00.000000000 +0100 +++ new/epub2txt2-ac4e73fa79202ccc106b36c06c20e36c37345a58/src/util.h 2022-06-30 10:48:08.000000000 +0200 @@ -0,0 +1,11 @@ +/*============================================================================ + epub2txt v2 + util.h + Copyright (c)2022 Marco Bonelli, GPL v3.0 +============================================================================*/ + +#pragma once + +#include "defs.h" + +int run_command (const char *const argv[], BOOL abort_on_error);