From 5d2c2b27a6323e2666378b986129b2a7c2c39e5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Sun, 6 Feb 2022 16:04:24 +0100 Subject: New upstream version 5.2.2GA --- app/wlib/gtklib/osxhelp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/wlib/gtklib/osxhelp.c') diff --git a/app/wlib/gtklib/osxhelp.c b/app/wlib/gtklib/osxhelp.c index 4ec1f5e..2fed375 100644 --- a/app/wlib/gtklib/osxhelp.c +++ b/app/wlib/gtklib/osxhelp.c @@ -28,7 +28,6 @@ #include #include -#include "misc.h" #include "gtkint.h" #include "i18n.h" @@ -40,6 +39,7 @@ static pid_t pidOfChild; static int handleOfPipe; extern char *wExecutableName; +extern wBool_t CheckHelpTopicExists(const char *); /** * Create the fully qualified filename for the help helper -- cgit v1.2.3 From a14a7a0ccc9de76aeab0b2e4bbf58f1a79deedc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Wed, 3 Jul 2024 10:19:30 +0200 Subject: New upstream version 5.3.0GA --- app/wlib/gtklib/osxhelp.c | 167 +++++++++++++++++++++++----------------------- 1 file changed, 84 insertions(+), 83 deletions(-) (limited to 'app/wlib/gtklib/osxhelp.c') diff --git a/app/wlib/gtklib/osxhelp.c b/app/wlib/gtklib/osxhelp.c index 2fed375..b508961 100644 --- a/app/wlib/gtklib/osxhelp.c +++ b/app/wlib/gtklib/osxhelp.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include @@ -51,15 +51,15 @@ extern wBool_t CheckHelpTopicExists(const char *); static char *ChildProgramFile(char *parentProgram) { - char *startOfFilename; - char *childProgram; + char *startOfFilename; + char *childProgram; - childProgram = malloc(strlen(parentProgram)+ sizeof(HELPERPROGRAM) + 1); - strcpy(childProgram, parentProgram); - startOfFilename = strrchr(childProgram, '/'); - strcpy(startOfFilename + 1, HELPERPROGRAM); + childProgram = malloc(strlen(parentProgram)+ sizeof(HELPERPROGRAM) + 1); + strcpy(childProgram, parentProgram); + startOfFilename = strrchr(childProgram, '/'); + strcpy(startOfFilename + 1, HELPERPROGRAM); - return (childProgram); + return (childProgram); } @@ -71,92 +71,93 @@ char *ChildProgramFile(char *parentProgram) void wHelp(const char * topic) { - pid_t newPid; - int status; - const char html[] = ".html"; - static char *directory; /**< base directory for HTML files */ - char * htmlFile; - - struct { - int length; - char *page; - } buffer; - - if (!CheckHelpTopicExists(topic)) return; - - // check whether child already exists - if (pidOfChild != 0) { - if (waitpid(pidOfChild, &status, WNOHANG) < 0) { - // child exited -> clean up - close(handleOfPipe); - unlink(HELPCOMMANDPIPE); - handleOfPipe = 0; - pidOfChild = 0; // child exited - } - } - - // (re)start child - if (pidOfChild == 0) { - unlink(HELPCOMMANDPIPE); - int rc = mkfifo(HELPCOMMANDPIPE, 0666); - newPid = fork(); /* New process starts here */ - - if (newPid > 0) { - pidOfChild = newPid; - } else if (newPid == 0) { + pid_t newPid; + int status; + const char html[] = ".html"; + static char *directory; /**< base directory for HTML files */ + char * htmlFile; + + struct { + int length; + char *page; + } buffer; + + if (!CheckHelpTopicExists(topic)) { return; } + + // check whether child already exists + if (pidOfChild != 0) { + if (waitpid(pidOfChild, &status, WNOHANG) < 0) { + // child exited -> clean up + close(handleOfPipe); + unlink(HELPCOMMANDPIPE); + handleOfPipe = 0; + pidOfChild = 0; // child exited + } + } + + // (re)start child + if (pidOfChild == 0) { + unlink(HELPCOMMANDPIPE); + int rc = mkfifo(HELPCOMMANDPIPE, 0666); + newPid = fork(); /* New process starts here */ + + if (newPid > 0) { + pidOfChild = newPid; + } else if (newPid == 0) { char *child = ChildProgramFile(wExecutableName); - - if (execlp(child, child, NULL) < 0) { /* never normally returns */ - exit(8); - } - - free(child); - } else { /* -1 signifies fork failure */ - pidOfChild = 0; - return; - } - } - - buffer.page = malloc(sizeof(int)+strlen(topic) + strlen(html) + 1); - - if (!buffer.page) { - return; - } - - strcpy(buffer.page, topic); - strcat(buffer.page, html); - buffer.length = strlen(buffer.page); - - if (buffer.length>255) { - printf("Help Topic too long %s", buffer.page); - return; - } - - if (!handleOfPipe) { + + if (execlp(child, child, NULL) < 0) { /* never normally returns */ + exit(8); + } + + free(child); + } else { /* -1 signifies fork failure */ + pidOfChild = 0; + return; + } + } + + buffer.page = malloc(sizeof(int)+strlen(topic) + strlen(html) + 1); + + if (!buffer.page) { + return; + } + + strcpy(buffer.page, topic); + strcat(buffer.page, html); + buffer.length = strlen(buffer.page); + + if (buffer.length>255) { + printf("Help Topic too long %s", buffer.page); + return; + } + + if (!handleOfPipe) { handleOfPipe = open(HELPCOMMANDPIPE, O_WRONLY); if (handleOfPipe < 0) { - if (pidOfChild) - kill(pidOfChild, SIGKILL); /* tidy up on next call */ + if (pidOfChild) { + kill(pidOfChild, SIGKILL); /* tidy up on next call */ + } handleOfPipe = 0; return; } } - int written = 0; - int towrite = sizeof(int); + int written = 0; + int towrite = sizeof(int); - while (written < towrite){ - written += write(handleOfPipe, &buffer.length, sizeof(int)); - } - written =0; - towrite = strlen(buffer.page); - while (written < towrite){ - written += write(handleOfPipe, buffer.page+written, towrite-written); - } + while (written < towrite) { + written += write(handleOfPipe, &buffer.length, sizeof(int)); + } + written =0; + towrite = strlen(buffer.page); + while (written < towrite) { + written += write(handleOfPipe, buffer.page+written, towrite-written); + } - fsync(handleOfPipe); + fsync(handleOfPipe); - free(buffer.page); + free(buffer.page); } -- cgit v1.2.3