From eb1cae45049c5b46caf4eba36f67997d921b018b Mon Sep 17 00:00:00 2001 From: Fritz Elfert Date: Tue, 16 Jul 2002 00:06:30 +0000 Subject: - Added an informational message when a Psion is connected. - Moved log streams declaration into separate header. --- ncpd/Makefile.am | 3 ++- ncpd/link.cc | 4 +--- ncpd/linkchan.cc | 4 +--- ncpd/main.cc | 14 +++++++++----- ncpd/main.h | 39 +++++++++++++++++++++++++++++++++++++++ ncpd/ncp.cc | 14 ++++++++------ ncpd/packet.cc | 4 +--- 7 files changed, 61 insertions(+), 21 deletions(-) create mode 100644 ncpd/main.h (limited to 'ncpd') diff --git a/ncpd/Makefile.am b/ncpd/Makefile.am index f5f4e4e..b06edb3 100644 --- a/ncpd/Makefile.am +++ b/ncpd/Makefile.am @@ -9,7 +9,8 @@ sbin_PROGRAMS = ncpd ncpd_LDADD = $(top_srcdir)/lib/libplp.la -lpthread $(LIBCCMALLOC_CXX) ncpd_SOURCES = channel.cc link.cc linkchan.cc main.cc \ ncp.cc packet.cc socketchan.cc mp_serial.c -EXTRA_DIST = channel.h link.h linkchan.h mp_serial.h ncp.h packet.h socketchan.h +EXTRA_DIST = channel.h link.h linkchan.h main.h mp_serial.h ncp.h packet.h \ + socketchan.h maintainer-clean-local: rm -f Makefile.in diff --git a/ncpd/link.cc b/ncpd/link.cc index 76a8be4..6eec61c 100644 --- a/ncpd/link.cc +++ b/ncpd/link.cc @@ -37,6 +37,7 @@ #include "ncp.h" #include "bufferstore.h" #include "bufferarray.h" +#include "main.h" extern "C" { static void *expire_check(void *arg) @@ -52,9 +53,6 @@ extern "C" { using namespace std; -extern ostream lout; -extern ostream lerr; - ENUM_DEFINITION(Link::link_type, Link::LINK_TYPE_UNKNOWN) { stringRep.add(Link::LINK_TYPE_UNKNOWN, N_("Unknown")); stringRep.add(Link::LINK_TYPE_SIBO, N_("SIBO")); diff --git a/ncpd/linkchan.cc b/ncpd/linkchan.cc index 9a45158..aa21bb1 100644 --- a/ncpd/linkchan.cc +++ b/ncpd/linkchan.cc @@ -29,12 +29,10 @@ #include "ncp.h" #include "bufferstore.h" #include "bufferarray.h" +#include "main.h" using namespace std; -extern ostream lout; -extern ostream lerr; - linkChan::linkChan(ncp * _ncpController, int _ncpChannel):channel(_ncpController) { registerSer = 0x1234; diff --git a/ncpd/main.cc b/ncpd/main.cc index 6e63088..a78f47d 100644 --- a/ncpd/main.cc +++ b/ncpd/main.cc @@ -66,15 +66,17 @@ static int numScp = 0; static socketChan *scp[257]; // MAX_CHANNELS_PSION + 1 +logbuf ilog(LOG_INFO, STDOUT_FILENO); logbuf dlog(LOG_DEBUG, STDOUT_FILENO); logbuf elog(LOG_ERR, STDERR_FILENO); +ostream linf(&ilog); ostream lout(&dlog); ostream lerr(&elog); static RETSIGTYPE term_handler(int) { - lout << "Got SIGTERM" << endl; + linf << "Got SIGTERM" << endl; signal(SIGTERM, term_handler); active = false; }; @@ -82,7 +84,7 @@ term_handler(int) static RETSIGTYPE int_handler(int) { - lout << "Got SIGINT" << endl; + linf << "Got SIGINT" << endl; signal(SIGINT, int_handler); active = false; }; @@ -352,9 +354,10 @@ main(int argc, char **argv) openlog("ncpd", LOG_CONS|LOG_PID, LOG_DAEMON); dlog.setOn(true); elog.setOn(true); - syslog(LOG_INFO, - "daemon started. Listening at %s:%d, " - "using device %s\n", host, sockNum, serialDevice); + ilog.setOn(true); + linf << "daemon started. Listening at " << host << ":" + << sockNum << " using device " << serialDevice + << endl; setsid(); chdir("/"); int devnull = @@ -385,6 +388,7 @@ main(int argc, char **argv) } while (active) checkForNewSocketConnection(); + linf << "terminating" << endl; void *ret; pthread_join(thr_a, &ret); pthread_join(thr_b, &ret); diff --git a/ncpd/main.h b/ncpd/main.h new file mode 100644 index 0000000..1af2c9a --- /dev/null +++ b/ncpd/main.h @@ -0,0 +1,39 @@ +/*-*-c++-*- + * $Id$ + * + * This file is part of plptools. + * + * Copyright (C) 1999 Philip Proudman + * Copyright (C) 1999-2002 Fritz Elfert + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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 + * + */ +#ifndef _main_h_ +#define _main_h_ + +#include + +extern std::ostream lout; +extern std::ostream lerr; +extern std::ostream linf; + +#endif + +/* + * Local variables: + * c-basic-offset: 4 + * End: + */ diff --git a/ncpd/ncp.cc b/ncpd/ncp.cc index aff7867..3abdf87 100644 --- a/ncpd/ncp.cc +++ b/ncpd/ncp.cc @@ -29,22 +29,21 @@ #include #include -#include "ncp.h" -#include "linkchan.h" -#include "link.h" #include #include #include +#include "ncp.h" +#include "linkchan.h" +#include "link.h" +#include "main.h" + #define MAX_CHANNELS_PSION 256 #define MAX_CHANNELS_SIBO 8 #define NCP_SENDLEN 250 using namespace std; -extern ostream lout; -extern ostream lerr; - ncp::ncp(const char *fname, int baud, unsigned short _verbose) { channelPtr = new channel*[MAX_CHANNELS_PSION + 1]; @@ -230,6 +229,9 @@ decodeControlMessage(bufferStore & buff) controlChannel(localChan, NCON_MSG_CONNECT_RESPONSE, b); if (verbose & NCP_DEBUG_LOG) lout << "ncp: Link UP" << endl; + linf << "Connected with a S" + << ((protocolVersion == PV_SERIES_5) ? 5 : 3) << " at " + << getSpeed() << "baud" << endl; // Create linkchan if it does not yet exist if (!lChan) { if (verbose & NCP_DEBUG_LOG) diff --git a/ncpd/packet.cc b/ncpd/packet.cc index 841dc54..31eafd0 100644 --- a/ncpd/packet.cc +++ b/ncpd/packet.cc @@ -43,6 +43,7 @@ extern "C" { } #include "packet.h" #include "link.h" +#include "main.h" #define BUFLEN 4096 // Must be a power of 2 #define BUFMASK (BUFLEN-1) @@ -151,9 +152,6 @@ static const int baud_table[] = { using namespace std; -extern ostream lout; -extern ostream lerr; - packet:: packet(const char *fname, int _baud, Link *_link, unsigned short _verbose) { -- cgit v1.2.3