From 63c08cfe0e108035f5ca300ec0fd9e719a388b3b Mon Sep 17 00:00:00 2001 From: Olaf Barthel Date: Thu, 20 Oct 2005 06:50:32 +0000 Subject: [PATCH] - The network startup code no longer checks for the presence of a possible daemon startup message by default. You now have to enable this feature by declaring a global variable called "__check_daemon_startup" which is described in . git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15050 87f5fb63-7c3d-0410-a384-fd976d0f7a62 --- library/GNUmakefile.68k | 3 ++- library/GNUmakefile.os4 | 3 ++- library/changes | 5 ++++ library/include/dos.h | 19 ++++++++++++-- library/smakefile | 3 ++- library/socket_check_daemon.c | 48 +++++++++++++++++++++++++++++++++++ library/socket_init_exit.c | 19 ++++++-------- 7 files changed, 84 insertions(+), 16 deletions(-) create mode 100644 library/socket_check_daemon.c diff --git a/library/GNUmakefile.68k b/library/GNUmakefile.68k index 05cd611..7476998 100644 --- a/library/GNUmakefile.68k +++ b/library/GNUmakefile.68k @@ -1,5 +1,5 @@ # -# $Id: GNUmakefile.68k,v 1.71 2005-10-17 13:54:25 obarthel Exp $ +# $Id: GNUmakefile.68k,v 1.72 2005-10-20 06:50:32 obarthel Exp $ # # :ts=8 # @@ -728,6 +728,7 @@ NET_LIB = \ net.lib_rev.o \ socket_accept.o \ socket_bind.o \ + socket_check_daemon.o \ socket_connect.o \ socket_gethostbyaddr.o \ socket_gethostbyname.o \ diff --git a/library/GNUmakefile.os4 b/library/GNUmakefile.os4 index c689e93..73d237b 100644 --- a/library/GNUmakefile.os4 +++ b/library/GNUmakefile.os4 @@ -1,5 +1,5 @@ # -# $Id: GNUmakefile.os4,v 1.80 2005-10-17 13:54:25 obarthel Exp $ +# $Id: GNUmakefile.os4,v 1.81 2005-10-20 06:50:32 obarthel Exp $ # # :ts=8 # @@ -699,6 +699,7 @@ NET_LIB = \ net.lib_rev.o \ socket_accept.o \ socket_bind.o \ + socket_check_daemon.o \ socket_connect.o \ socket_gethostbyaddr.o \ socket_gethostbyname.o \ diff --git a/library/changes b/library/changes index f97f86e..a15b5fe 100644 --- a/library/changes +++ b/library/changes @@ -27,6 +27,11 @@ "__bool_true_false_are_defined" rather than "__bool_true_and_false_are_defined". Thanks go to Peter Bengtsson for finding and fixing it. +- The network startup code no longer checks for the presence of a possible + daemon startup message by default. You now have to enable this feature + by declaring a global variable called "__check_daemon_startup" which is + described in . + c.lib 1.196 (11.10.2005) diff --git a/library/include/dos.h b/library/include/dos.h index 8b04d26..77e43fc 100644 --- a/library/include/dos.h +++ b/library/include/dos.h @@ -1,5 +1,5 @@ /* - * $Id: dos.h,v 1.12 2005-10-17 13:54:25 obarthel Exp $ + * $Id: dos.h,v 1.13 2005-10-20 06:50:32 obarthel Exp $ * * :ts=4 * @@ -148,9 +148,24 @@ extern int __get_default_file(int file_descriptor,long * file_ptr); /****************************************************************************/ +/* + * If your program is intended to be launched by the Internet superserver + * (inetd) to run as a daemon, receiving and sending data through a network + * connection set up for it, declare the following variable in your program + * and set it to TRUE. This will make the program's network startup code + * link the stdin/stdout/stderr streams with the daemon socket passed to it. + * Whether or not your program is running as a daemon can be tested by + * checking the global __is_daemon variable described below. + */ +extern BOOL __check_daemon_startup; + +/****************************************************************************/ + /* * This will be set to TRUE if the current program was launched from - * the internet superserver ('inetd') or an equivalent facility. + * the internet superserver ('inetd') or an equivalent facility. Note + * that you need to have set __check_daemon_startup to TRUE before + * you can rely upon __is_daemon to be initialized correctly. */ extern BOOL __is_daemon; diff --git a/library/smakefile b/library/smakefile index dc083c0..384ba4a 100644 --- a/library/smakefile +++ b/library/smakefile @@ -1,5 +1,5 @@ # -# $Id: smakefile,v 1.53 2005-10-17 13:54:25 obarthel Exp $ +# $Id: smakefile,v 1.54 2005-10-20 06:50:32 obarthel Exp $ # # :ts=8 # @@ -317,6 +317,7 @@ SOCKET_OBJ = \ socket_accept.o \ socket_bind.o \ socket_connect.o \ + socket_check_daemon.o \ socket_gethostbyaddr.o \ socket_gethostbyname.o \ socket_gethostid.o \ diff --git a/library/socket_check_daemon.c b/library/socket_check_daemon.c new file mode 100644 index 0000000..d679f13 --- /dev/null +++ b/library/socket_check_daemon.c @@ -0,0 +1,48 @@ +/* + * $Id: socket_check_daemon.c,v 1.1 2005-10-20 06:50:32 obarthel Exp $ + * + * :ts=4 + * + * Portable ISO 'C' (1994) runtime library for the Amiga computer + * Copyright (c) 2002-2005 by Olaf Barthel + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Neither the name of Olaf Barthel nor the names of contributors + * may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#if defined(SOCKET_SUPPORT) + +/****************************************************************************/ + +#ifndef _SOCKET_HEADERS_H +#include "socket_headers.h" +#endif /* _SOCKET_HEADERS_H */ + +/****************************************************************************/ + +BOOL __check_daemon_startup; + +/****************************************************************************/ + +#endif /* SOCKET_SUPPORT */ diff --git a/library/socket_init_exit.c b/library/socket_init_exit.c index ee01f85..a6175a0 100644 --- a/library/socket_init_exit.c +++ b/library/socket_init_exit.c @@ -1,5 +1,5 @@ /* - * $Id: socket_init_exit.c,v 1.21 2005-10-17 13:54:25 obarthel Exp $ + * $Id: socket_init_exit.c,v 1.22 2005-10-20 06:50:32 obarthel Exp $ * * :ts=4 * @@ -174,7 +174,8 @@ SOCKET_DESTRUCTOR(socket_exit) PROFILE_ON(); } - /* Careful: if this function is ever invoked, it must make sure that + /* + * Careful: if this function is ever invoked, it must make sure that * the socket file descriptors are invalidated. If that * does not happen, the stdio cleanup function will * crash (with bells on). @@ -213,8 +214,7 @@ SOCKET_CONSTRUCTOR(socket_init) PROFILE_OFF(); /* bsdsocket.library V3 is sufficient for all the tasks we - * may have to perform. - */ + may have to perform. */ __SocketBase = OpenLibrary("bsdsocket.library",3); #if defined(__amigaos4__) @@ -316,15 +316,13 @@ SOCKET_CONSTRUCTOR(socket_init) #endif /* __THREAD_SAFE */ /* Check if this program was launched as a server by the Internet - * superserver. - */ - if(Cli() != NULL && NOT __detach) + superserver. */ + if(Cli() != NULL && NOT __detach && __check_daemon_startup) { struct DaemonMessage * dm; /* The socket the superserver may have launched this program - * with is attached to the exit data entry of the process. - */ + with is attached to the exit data entry of the process. */ #if defined(__amigaos4__) { dm = (struct DaemonMessage *)GetExitData(); @@ -348,8 +346,7 @@ SOCKET_CONSTRUCTOR(socket_init) SHOWMSG("we have a daemon message; this is a server"); /* Try to grab that socket and attach is to the three - * standard I/O streams. - */ + standard I/O streams. */ PROFILE_OFF(); daemon_socket = __ObtainSocket(dm->dm_ID,dm->dm_Family,dm->dm_Type,0);