From b0fff9b9e5becf35cdd051a81d0574a3a6c3be2a Mon Sep 17 00:00:00 2001 From: chatty Date: Tue, 10 May 1994 11:36:23 +0000 Subject: replaced TRUE/FALSE by true/false --- comm/OLD/portserv.cc | 95 +++++++++++++++++++++++++++++----------------------- 1 file changed, 53 insertions(+), 42 deletions(-) (limited to 'comm/OLD/portserv.cc') diff --git a/comm/OLD/portserv.cc b/comm/OLD/portserv.cc index 7719be5..3b66348 100644 --- a/comm/OLD/portserv.cc +++ b/comm/OLD/portserv.cc @@ -17,7 +17,7 @@ #include "error.h" #include "Multiplexer.h" #include "Datagram.h" -#include "Signal.h" +#include "SignalHandler.h" #include "ccu/List.h" #include "ccu/RegExp.h" #include "ccu/String.h" @@ -29,7 +29,18 @@ #include #include #include +#ifdef __osf__ +extern "C" { +#endif #include +#ifdef __osf__ +} +#endif +#ifdef __osf__ +extern "C" { + int setsockopt (int, int, int, char*, int); +} +#endif //---------------- globals // if SaveTime > 0, the state is saved to SaveFile @@ -42,7 +53,7 @@ int SaveFileIsFd = -1; int SaveTime = 0; int Mod = 0; int NbEntries = 0; -bool Trace = FALSE; +bool Trace = false; UchMultiplexer* Mpx = 0; const char* LoadFile; @@ -220,7 +231,7 @@ LoadConfigFile () strcpy (nline, line); char** words = ParseConfigLine (nline); if (! words) { - Error (ErrWarn, "LoadConfigFile", "incorrect line ignored in file"); + ::Error (ErrWarn, "LoadConfigFile", "incorrect line ignored in file"); delete nline; continue; } @@ -231,8 +242,8 @@ LoadConfigFile () s->Host = 0; s->Port = 0; s->Ident = 0; - s->AutoLaunch = TRUE; - s->Running = FALSE; + s->AutoLaunch = true; + s->Running = false; s->LastRun= 0; s->LastRegistered = 0; s->CmdLine = nline; @@ -282,7 +293,7 @@ RegisterService (const char* key, lword host, sword port, int id) if (! s) { s = new Service; s->Key = key; - s->AutoLaunch = FALSE; + s->AutoLaunch = false; s->LastRun = 0; s->CmdLine = 0; s->RunCmd = 0; @@ -293,7 +304,7 @@ RegisterService (const char* key, lword host, sword port, int id) s->Ident = id; CcuTimeStamp now; s->LastRegistered = now; - s->Running = TRUE; + s->Running = true; return s; } @@ -316,7 +327,7 @@ RemoveService (const char* key, lword host, sword port, int id) #endif if (host == s->Host && port == s->Port && id == s->Ident && strcmp (key, s->Key) == 0) { if (s->AutoLaunch) { - s->Running = FALSE; + s->Running = false; s->LastRun = 0; s->LastRegistered = 0; s->Host = 0; @@ -327,12 +338,12 @@ RemoveService (const char* key, lword host, sword port, int id) delete s; ServList.RemoveAfter (trailing_iter); } - return TRUE; + return true; } ++trailing_iter; } - Error (ErrWarn, key, "not found for remove"); - return FALSE; + ::Error (ErrWarn, key, "not found for remove"); + return false; } Service* @@ -372,7 +383,7 @@ InquireService (const char* key) AutoLaunch (s); return s; } - Error (ErrWarn, key, "not found"); + ::Error (ErrWarn, key, "not found"); return 0; } @@ -482,8 +493,8 @@ RegistrationChannel :: HandleRead () return; } - if (! buf.Get (req)) { - Error (ErrWarn, "Receive", "could not read message"); + if (! buf.ReadMsg (req)) { + ::Error (ErrWarn, "Receive", "could not read message"); return; } @@ -516,7 +527,7 @@ RegistrationChannel :: HandleRead () ans.Port = 0; } buf.Flush (); - buf.Append (ans); + buf.WriteMsg (ans); if (Reply (buf) < 0) SysError (ErrWarn, "reply"); } @@ -536,13 +547,13 @@ RegistrationChannel :: HandleRead () if (Trace) printf ("quit\n"); if (SaveTime) DumpToFile (); - KillProcesses (TRUE); + KillProcesses (true); Mpx->Close (); break; default: if (Trace) printf ("unknown\n"); - Error (ErrWarn, "Receive", "unknown request"); + ::Error (ErrWarn, "Receive", "unknown request"); } } @@ -571,7 +582,7 @@ if (Trace) printf ("Match: %s\n", (const char*) s->Key); ans.Host = s->Host; ans.Port = s->Port; ans.SetKey (s->Key); - buf.Append (ans); + buf.WriteMsg (ans); Reply (buf); nb++; } @@ -581,7 +592,7 @@ if (Trace) printf ("Match: %s\n", (const char*) s->Key); ans.Type = PortServEndMatch; ans.Ident = nb; ans.SetKey (0); - buf.Append (ans); + buf.WriteMsg (ans); Reply (buf); } @@ -602,8 +613,8 @@ public: BroadcastChannel (sword, UchInetAddress*); bool SetUp (); void HandleRead (); - void RegisterMe () { printf ("RegisterMe: %d\n", Send (registerBuf, *bcast, TRUE /*peek*/)); } - void RemoveMe () { Send (removeBuf, *bcast, TRUE /*peek*/); printf ("sending remove\n"); } + void RegisterMe () { printf ("RegisterMe: %d\n", Send (registerBuf, *bcast, true /*peek*/)); } + void RemoveMe () { Send (removeBuf, *bcast, true /*peek*/); printf ("sending remove\n"); } }; lword @@ -628,7 +639,7 @@ BroadcastChannel :: BroadcastChannel (sword port, UchInetAddress* reg_addr) if (! l) l = cuserid (0); if (! l) - Error (ErrFatal, "BroadcastChannel", "getlogin failed"); + ::Error (ErrFatal, "BroadcastChannel", "getlogin failed"); /* prepare answerBuf for future requests */ char key [32]; @@ -637,11 +648,11 @@ BroadcastChannel :: BroadcastChannel (sword port, UchInetAddress* reg_addr) sword reg_port = reg_addr->Port (); int pid = getpid (); UchPortServerReq reg (PortServRegister, reg_host, reg_port, pid, key); - registerBuf.Append (reg); + registerBuf.WriteMsg (reg); UchPortServerReq rem (PortServRemove, reg_host, reg_port, pid, key); - removeBuf.Append (rem); + removeBuf.WriteMsg (rem); UchPortServerReq ans (PortServAnswer, reg_host, reg_port, pid, key); - answerBuf.Append (ans); + answerBuf.WriteMsg (ans); } bool @@ -649,16 +660,16 @@ BroadcastChannel :: SetUp () { int on = 1; if (! UchDatagram::Setup ()) - return FALSE; - if (setsockopt (FilDes (), SOL_SOCKET, SO_BROADCAST, (const char*) &on, sizeof (on)) < 0) - return FALSE; - return TRUE; + return false; + if (setsockopt (FilDes (), SOL_SOCKET, SO_BROADCAST, (char*) &on, sizeof (on)) < 0) + return false; + return true; } void BroadcastChannel :: Answer () { - int res = Send (answerBuf, *bcast, TRUE /*peek*/); + int res = Send (answerBuf, *bcast, true /*peek*/); printf ("AnswerMe: %d\n", res); } @@ -676,8 +687,8 @@ BroadcastChannel :: HandleRead () SysError (ErrFatal, "BroadcastChannel", EINTR); return; } - if (! buf.Get (req)) { - Error (ErrWarn, "BroadcastChannel", "could not read message"); + if (! buf.ReadMsg (req)) { + ::Error (ErrWarn, "BroadcastChannel", "could not read message"); return; } @@ -686,7 +697,7 @@ BroadcastChannel :: HandleRead () case PortServRegister: RegisterService (req.Key, req.Host, req.Port, int (req.Ident)); Modified (); - printf ("received registration %s 0x%x %d %d\n", req.Key, req.Host, req.Port, req.Ident); + printf ("received registration %s 0x%x %d %d\n", (const char*) req.Key, req.Host, req.Port, req.Ident); // when somebody else registers, we send our address Answer (); break; @@ -699,7 +710,7 @@ BroadcastChannel :: HandleRead () case PortServAnswer: RegisterService (req.Key, req.Host, req.Port, int (req.Ident)); Modified (); - printf ("received answer %s 0x%x %d %d\n", req.Key, req.Host, req.Port, req.Ident); + printf ("received answer %s 0x%x %d %d\n", (const char*) req.Key, req.Host, req.Port, req.Ident); break; case PortServRemove: @@ -708,7 +719,7 @@ BroadcastChannel :: HandleRead () break; default: - Error (ErrWarn, "main", "unknown request"); + ::Error (ErrWarn, "main", "unknown request"); } } @@ -737,24 +748,24 @@ GetPortNumber (const char* servname, int dflt) void Usage () { - Error (ErrUsage, "portserv", "[-t] [-s service] [-quit] [-save file [time]] [-load file]"); + ::Error (ErrUsage, "portserv", "[-t] [-s service] [-quit] [-save file [time]] [-load file]"); } main (int argc, const char** argv) { const char* servname = "portserv"; int running = 1; - bool qflag = FALSE; + bool qflag = false; ProgramName (argv [0]); LoadFile = getenv ("AGENTMGRCF"); while (--argc) { ++argv; if (strcmp (*argv, "-quit") == 0) { - qflag = TRUE; + qflag = true; } else if (strcmp (*argv, "-t") == 0) { - Trace = TRUE; + Trace = true; } else if (strcmp (*argv, "-s") == 0) { if (--argc < 1) @@ -788,7 +799,7 @@ main (int argc, const char** argv) // the portserver that is running if (qflag) { if (SaveFile || LoadFile) - Error (ErrFatal, "-quit", "incompatible with -save or -load"); + ::Error (ErrFatal, "-quit", "incompatible with -save or -load"); UchPortServer ps (servname, 0); ps.Quit (); exit (0); @@ -824,7 +835,7 @@ main (int argc, const char** argv) // sword reg_port = GetPortNumber (servname, 3003); if (! reg_port) - Error (ErrFatal, servname, "service not available"); + ::Error (ErrFatal, servname, "service not available"); // open dgram socket // @@ -846,7 +857,7 @@ main (int argc, const char** argv) delete bc_chan; bc_chan = 0; } else { - Error (ErrLog, "main", "created broadcast channel"); + ::Error (ErrLog, "main", "created broadcast channel"); bc_chan->SetMode (IORead); bc_chan->RegisterMe (); mpx.Add (bc_chan); -- cgit v1.1