From 89dbfb29991d201f6100b0a2658077f11efd03e5 Mon Sep 17 00:00:00 2001 From: Tom Early Date: Fri, 6 Apr 2018 16:41:00 -0700 Subject: [PATCH] traceit to printf --- DVAPDongle.cpp | 108 ++++++++------- IRCClient.cpp | 42 +++--- IRCDDB.cpp | 70 +++++----- IRCDDBApp.cpp | 36 ++--- IRCMessageQueue.cpp | 2 +- IRCProtocol.cpp | 6 +- IRCReceiver.cpp | 8 +- IRCutils.cpp | 25 +--- IRCutils.h | 2 - aprs.cpp | 54 ++++---- dvap_rptr.cpp | 135 ++++++++----------- g2_ircddb.cpp | 318 ++++++++++++++++++++++---------------------- 12 files changed, 376 insertions(+), 430 deletions(-) diff --git a/DVAPDongle.cpp b/DVAPDongle.cpp index 75f9e46..6971ca8 100644 --- a/DVAPDongle.cpp +++ b/DVAPDongle.cpp @@ -28,8 +28,6 @@ #include "DVAPDongle.h" -extern void traceit(const char *fmt,...); - CDVAPDongle::CDVAPDongle() : MAX_REPL_CNT(20u) { } @@ -58,10 +56,10 @@ bool CDVAPDongle::Initialize(char *serialno, int frequency, int offset, int powe close(serfd); serfd = -1; ok = false; - traceit("Device %s is already locked/used\n", device); + printf("Device %s is already locked/used\n", device); continue; } - traceit("Device %s now locked for exclusive use\n", device); + printf("Device %s now locked for exclusive use\n", device); ok = get_ser(device, serialno); if (!ok) { @@ -149,7 +147,7 @@ REPLY_TYPE CDVAPDongle::GetReply(SDVAP_REGISTER &dr) case 0xc012u: break; // these are all expected headers default: - traceit("unknown header=0x%d\n", (unsigned)dr.header); + printf("unknown header=0x%d\n", (unsigned)dr.header); if (syncit()) return RT_ERR; return RT_TIMEOUT; @@ -228,7 +226,7 @@ REPLY_TYPE CDVAPDongle::GetReply(SDVAP_REGISTER &dr) case 0xc012u: return RT_DAT; } - traceit("Unrecognized data from dvap: header=%#x control=%#x\n", (unsigned)dr.header, (unsigned)dr.param.control); + printf("Unrecognized data from dvap: header=%#x control=%#x\n", (unsigned)dr.header, (unsigned)dr.param.control); if (syncit()) return RT_ERR; return RT_TIMEOUT; @@ -241,7 +239,7 @@ bool CDVAPDongle::syncit() fd_set fds; short cnt = 0; - traceit("Starting syncing dvap\n"); + printf("Starting syncing dvap\n"); memset(data, 0x00, 7); dvapreg.header = 0x2007u; dvapreg.param.control = 0x90u; @@ -255,7 +253,7 @@ bool CDVAPDongle::syncit() if (n <= 0) { cnt ++; if (cnt > 100) { - traceit("syncit() uncessful...stopping\n"); + printf("syncit() uncessful...stopping\n"); return true; } } else { @@ -274,7 +272,7 @@ bool CDVAPDongle::syncit() } } } - traceit("Stopping syncing dvap\n"); + printf("Stopping syncing dvap\n"); return false; } @@ -287,7 +285,7 @@ bool CDVAPDongle::get_ser(char *dvp, char *dvap_serial_number) int rc = write_to_dvp(&dvapreg, 4); if (rc != 4) { - traceit("Failed to send request to get dvap serial#\n"); + printf("Failed to send request to get dvap serial#\n"); return false; } @@ -297,16 +295,16 @@ bool CDVAPDongle::get_ser(char *dvp, char *dvap_serial_number) reply = GetReply(dvapreg); cnt ++; if (cnt >= MAX_REPL_CNT) { - traceit("Reached max number of requests to receive dvap serial#\n"); + printf("Reached max number of requests to receive dvap serial#\n"); return false; } } while (reply != RT_SER); if (0 == strcmp(dvapreg.param.sstr, dvap_serial_number)) { - traceit("Using %s: %s, because serial number matches your dvap_rptr.cfg\n", dvp, dvap_serial_number); + printf("Using %s: %s, because serial number matches your dvap_rptr.cfg\n", dvp, dvap_serial_number); return true; } - traceit("Device %s has serial %s, but does not match your config value %s\n", dvp, dvapreg.param.sstr, dvap_serial_number); + printf("Device %s has serial %s, but does not match your config value %s\n", dvp, dvapreg.param.sstr, dvap_serial_number); return false; } @@ -319,7 +317,7 @@ bool CDVAPDongle::get_name() int rc = write_to_dvp(&dvapreg, 4); if (rc != 4) { - traceit("Failed to send request to get dvap name\n"); + printf("Failed to send request to get dvap name\n"); return false; } @@ -329,17 +327,17 @@ bool CDVAPDongle::get_name() reply = GetReply(dvapreg); cnt ++; if (cnt >= MAX_REPL_CNT) { - traceit("Reached max number of requests to receive dvap name\n"); + printf("Reached max number of requests to receive dvap name\n"); return false; } } while (reply != RT_NAME); if (0x10u!=dvapreg.header || 0x1u!=dvapreg.param.control || strncmp(dvapreg.param.sstr, "DVAP Dongle", 11)) { - traceit("Failed to receive dvap name, got %s\n", dvapreg.param.sstr); + printf("Failed to receive dvap name, got %s\n", dvapreg.param.sstr); return false; } - traceit("Device name: %.*s\n", 11, dvapreg.param.sstr); + printf("Device name: %.*s\n", 11, dvapreg.param.sstr); return true; } @@ -353,7 +351,7 @@ bool CDVAPDongle::get_fw() int rc = write_to_dvp(&dvapreg, 5); if (rc != 5) { - traceit("Failed to send request to get dvap fw\n"); + printf("Failed to send request to get dvap fw\n"); return false; } @@ -363,13 +361,13 @@ bool CDVAPDongle::get_fw() reply = GetReply(dvapreg); cnt ++; if (cnt >= MAX_REPL_CNT) { - traceit("Reached max number of requests to receive dvap fw\n"); + printf("Reached max number of requests to receive dvap fw\n"); return false; } } while (reply != RT_FW); unsigned int ver = dvapreg.param.ustr[1] + 256 * dvapreg.param.ustr[2]; - traceit("dvap fw ver: %u.%u\n", ver / 100, ver % 100); + printf("dvap fw ver: %u.%u\n", ver / 100, ver % 100); return true; } @@ -384,7 +382,7 @@ bool CDVAPDongle::set_modu() int rc = write_to_dvp(&dvapreg, 5); if (rc != 5) { - traceit("Failed to send request to set dvap modulation\n"); + printf("Failed to send request to set dvap modulation\n"); return false; } @@ -395,7 +393,7 @@ bool CDVAPDongle::set_modu() cnt ++; if (cnt >= MAX_REPL_CNT) { - traceit("Reached max number of requests to set dvap modulation\n"); + printf("Reached max number of requests to set dvap modulation\n"); return false; } } while (reply != RT_MODU); @@ -413,7 +411,7 @@ bool CDVAPDongle::set_mode() int rc = write_to_dvp(&dvapreg, 5); if (rc != 5) { - traceit("Failed to send request to set dvap mode\n"); + printf("Failed to send request to set dvap mode\n"); return false; } @@ -424,7 +422,7 @@ bool CDVAPDongle::set_mode() cnt ++; if (cnt >= MAX_REPL_CNT) { - traceit("Reached max number of requests to set dvap mode\n"); + printf("Reached max number of requests to set dvap mode\n"); return false; } } while (reply != RT_MODE); @@ -440,17 +438,17 @@ bool CDVAPDongle::set_sql(int squelch) dvapreg.header = 0x5u; dvapreg.param.control = 0x80u; if (squelch < -128) { - traceit("Squelch setting of %d too small, resetting...\n", squelch); + printf("Squelch setting of %d too small, resetting...\n", squelch); squelch = -128; } else if (squelch > -45) { - traceit("Squelch setting of %d too large, resetting...\n", squelch); + printf("Squelch setting of %d too large, resetting...\n", squelch); squelch = -45; } dvapreg.param.byte = (int8_t)squelch; int rc = write_to_dvp(&dvapreg, 5); if (rc != 5) { - traceit("Failed to send request to set dvap sql\n"); + printf("Failed to send request to set dvap sql\n"); return false; } @@ -461,11 +459,11 @@ bool CDVAPDongle::set_sql(int squelch) cnt ++; if (cnt >= MAX_REPL_CNT) { - traceit("Reached max number of requests to set dvap sql\n"); + printf("Reached max number of requests to set dvap sql\n"); return false; } } while (reply != RT_SQL); - traceit("DVAP squelch is %d dB\n", (int)dvapreg.param.byte); + printf("DVAP squelch is %d dB\n", (int)dvapreg.param.byte); return true; } @@ -477,17 +475,17 @@ bool CDVAPDongle::set_pwr(int power) dvapreg.header = 0x6u; dvapreg.param.control = 0x138u; if (power < -12) { - traceit("Power setting of %d is too low, resetting...\n", power); + printf("Power setting of %d is too low, resetting...\n", power); power = -12; } else if (power > 10) { - traceit("Power setting of %d is too high, resetting...\n", power); + printf("Power setting of %d is too high, resetting...\n", power); power = 10; } dvapreg.param.word = (int16_t)power; int rc = write_to_dvp(&dvapreg, 6); if (rc != 6) { - traceit("Failed to send request to set dvap pwr\n"); + printf("Failed to send request to set dvap pwr\n"); return false; } @@ -498,11 +496,11 @@ bool CDVAPDongle::set_pwr(int power) cnt ++; if (cnt >= MAX_REPL_CNT) { - traceit("Reached max number of requests to set dvap pwr\n"); + printf("Reached max number of requests to set dvap pwr\n"); return false; } } while (reply != RT_PWR); - traceit("DVAP power is %d dB\n", (int)dvapreg.param.word); + printf("DVAP power is %d dB\n", (int)dvapreg.param.word); return true; } @@ -514,17 +512,17 @@ bool CDVAPDongle::set_off(int offset) dvapreg.header = 0x6u; dvapreg.param.control = 0x400u; if (offset < -2000) { - traceit("Offset of %d is too low, resetting...\n", offset); + printf("Offset of %d is too low, resetting...\n", offset); offset = -2000; } else if (offset > 2000) { - traceit("Offset of %d is too high, resetting...\n", offset); + printf("Offset of %d is too high, resetting...\n", offset); offset = 2000; } dvapreg.param.word = (int16_t)offset; int rc = write_to_dvp(&dvapreg, 6); if (rc != 6) { - traceit("Failed to send request to set dvap offset\n"); + printf("Failed to send request to set dvap offset\n"); return false; } @@ -535,11 +533,11 @@ bool CDVAPDongle::set_off(int offset) cnt ++; if (cnt >= MAX_REPL_CNT) { - traceit("Reached max number of requests to set dvap offset\n"); + printf("Reached max number of requests to set dvap offset\n"); return false; } } while (reply != RT_OFF); - traceit("DVAP offset is %d Hz\n", (int)dvapreg.param.word); + printf("DVAP offset is %d Hz\n", (int)dvapreg.param.word); return true; } @@ -554,7 +552,7 @@ bool CDVAPDongle::set_freq(int frequency) int rc = write_to_dvp(&dvapreg, 4); if (rc != 4) { - traceit("Failed to send request for frequency limits\n"); + printf("Failed to send request for frequency limits\n"); return false; } @@ -565,18 +563,18 @@ bool CDVAPDongle::set_freq(int frequency) cnt++; if (cnt >= MAX_REPL_CNT) { - traceit("Reached max number of requests for dvap frequency limits\n"); + printf("Reached max number of requests for dvap frequency limits\n"); return false; } } while (reply != RT_FREQ_LIMIT); - traceit("DVAP Frequency limits are from %d to %d Hz\n", dvapreg.param.twod[0], dvapreg.param.twod[1]); + printf("DVAP Frequency limits are from %d to %d Hz\n", dvapreg.param.twod[0], dvapreg.param.twod[1]); // okay, now we know the frequency limits, get on with the show... if (frequency < dvapreg.param.twod[0]) { - traceit("Frequency of %d is too small, resetting...\n", frequency); + printf("Frequency of %d is too small, resetting...\n", frequency); frequency = dvapreg.param.twod[0]; } else if (frequency > dvapreg.param.twod[1]) { - traceit("Frequency of %d is too large, resetting...\n", frequency); + printf("Frequency of %d is too large, resetting...\n", frequency); frequency = dvapreg.param.twod[1]; } @@ -587,7 +585,7 @@ bool CDVAPDongle::set_freq(int frequency) rc = write_to_dvp(&dvapreg, 8); if (rc != 8) { - traceit("Failed to send request to set dvap frequency\n"); + printf("Failed to send request to set dvap frequency\n"); return false; } @@ -598,11 +596,11 @@ bool CDVAPDongle::set_freq(int frequency) cnt ++; if (cnt >= MAX_REPL_CNT) { - traceit("Reached max number of requests to set dvap frequency\n"); + printf("Reached max number of requests to set dvap frequency\n"); return false; } } while (reply != RT_FREQ); - traceit("DVAP frequency is %d Hz\n", dvapreg.param.dword); + printf("DVAP frequency is %d Hz\n", dvapreg.param.dword); return true; } @@ -617,7 +615,7 @@ bool CDVAPDongle::start_dvap() int rc = write_to_dvp(&dvapreg, 5); if (rc != 5) { - traceit("Failed to send request to start the dvap dongle\n"); + printf("Failed to send request to start the dvap dongle\n"); return false; } @@ -628,7 +626,7 @@ bool CDVAPDongle::start_dvap() cnt ++; if (cnt >= MAX_REPL_CNT) { - traceit("Reached max number of requests to start the dvap dongle\n"); + printf("Reached max number of requests to start the dvap dongle\n"); return false; } } while (reply != RT_START); @@ -654,7 +652,7 @@ int CDVAPDongle::write_to_dvp(const void *buffer, const unsigned int len) while (ptr < len) { ssize_t n = write(serfd, buf + ptr, len - ptr); if (n < 0) { - traceit("Error %d writing to dvap, message=%s\n", errno, strerror(errno)); + printf("Error %d writing to dvap, message=%s\n", errno, strerror(errno)); return -1; } @@ -691,7 +689,7 @@ int CDVAPDongle::read_from_dvp(void *buffer, unsigned int len) n = select(serfd + 1, &fds, NULL, NULL, NULL); if (n < 0) { - traceit("select error=%d on dvap\n", errno); + printf("select error=%d on dvap\n", errno); return -1; } @@ -711,19 +709,19 @@ bool CDVAPDongle::OpenSerial(char *device) serfd = open(device, O_RDWR | O_NOCTTY | O_NDELAY, 0); if (serfd < 0) { - traceit("Failed to open device [%s], error=%d, message=%s\n", device, errno, strerror(errno)); + printf("Failed to open device [%s], error=%d, message=%s\n", device, errno, strerror(errno)); return false; } if (isatty(serfd) == 0) { - traceit("Device %s is not a tty device\n", device); + printf("Device %s is not a tty device\n", device); close(serfd); serfd = -1; return false; } if (tcgetattr(serfd, &t) < 0) { - traceit("tcgetattr failed for %s, error=%d, message-%s\n", device, errno, strerror(errno)); + printf("tcgetattr failed for %s, error=%d, message-%s\n", device, errno, strerror(errno)); close(serfd); serfd = -1; return false; @@ -741,7 +739,7 @@ bool CDVAPDongle::OpenSerial(char *device) cfsetispeed(&t, B230400); if (tcsetattr(serfd, TCSANOW, &t) < 0) { - traceit("tcsetattr failed for %s, error=%dm message=%s\n", device, errno, strerror(errno)); + printf("tcsetattr failed for %s, error=%dm message=%s\n", device, errno, strerror(errno)); close(serfd); serfd = -1; return false; diff --git a/IRCClient.cpp b/IRCClient.cpp index 14bff62..83b17d6 100644 --- a/IRCClient.cpp +++ b/IRCClient.cpp @@ -75,7 +75,7 @@ void IRCClient::Entry() int result = getAllIPV4Addresses(local_addr, 0, &numAddr, &myaddr, 1); if ((result != 0) || (numAddr != 1)) { - traceit("IRCClient::Entry: local address not parseable, using 0.0.0.0\n"); + printf("IRCClient::Entry: local address not parseable, using 0.0.0.0\n"); memset(&myaddr, 0x00, sizeof(struct sockaddr_in)); } @@ -88,7 +88,7 @@ void IRCClient::Entry() switch (state) { case 0: if (terminateThread) { - traceit("IRCClient::Entry: thread terminated at state=%d\n", state); + printf("IRCClient::Entry: thread terminated at state=%d\n", state); return; } @@ -96,7 +96,7 @@ void IRCClient::Entry() timer = 30; if (getAllIPV4Addresses(host_name, port, &numAddr, addr, MAXIPV4ADDR) == 0) { - //traceit("IRCClient::Entry: number of DNS entries %d\n", numAddr); + //printf("IRCClient::Entry: number of DNS entries %d\n", numAddr); if (numAddr > 0) { currentAddr = 0; state = 1; @@ -108,7 +108,7 @@ void IRCClient::Entry() case 1: if (terminateThread) { - traceit("IRCClient::Entry: thread terminated at state=%d\n", state); + printf("IRCClient::Entry: thread terminated at state=%d\n", state); return; } @@ -116,12 +116,12 @@ void IRCClient::Entry() sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); if (sock < 0) { - traceit("IRCClient::Entry: could not create socket!\n"); + printf("IRCClient::Entry: could not create socket!\n"); timer = 30; state = 0; } else { if (fcntl(sock, F_SETFL, O_NONBLOCK) < 0) { - traceit("IRCClient::Entry: fcntl error\n"); + printf("IRCClient::Entry: fcntl error\n"); close(sock); timer = 30; state = 0; @@ -131,12 +131,12 @@ void IRCClient::Entry() int res; if ((h[0] != 0) || (h[1] != 0) || (h[2] != 0) || (h[3] != 0)) - traceit("IRCClient::Entry: bind: local address %d.%d.%d.%d\n", h[0], h[1], h[2], h[3]); + printf("IRCClient::Entry: bind: local address %d.%d.%d.%d\n", h[0], h[1], h[2], h[3]); res = bind(sock, (struct sockaddr *) &myaddr, sizeof (struct sockaddr_in)); if (res != 0) { - traceit("IRCClient::Entry: bind error\n"); + printf("IRCClient::Entry: bind error\n"); close(sock); state = 0; timer = 30; @@ -145,20 +145,20 @@ void IRCClient::Entry() h = (unsigned char *) &(addr[currentAddr].sin_addr); - //traceit("IRCClient::Entry: trying to connect to %d.%d.%d.%d\n", h[0], h[1], h[2], h[3]); + //printf("IRCClient::Entry: trying to connect to %d.%d.%d.%d\n", h[0], h[1], h[2], h[3]); res = connect(sock, (struct sockaddr *) (addr + currentAddr), sizeof (struct sockaddr_in)); if (res == 0) { - traceit("IRCClient::Entry: connected to %d.%d.%d.%d\n", h[0], h[1], h[2], h[3]); + printf("IRCClient::Entry: connected to %d.%d.%d.%d\n", h[0], h[1], h[2], h[3]); state = 4; } else { if (errno == EINPROGRESS) { - //traceit("IRCClient::Entry: connect in progress\n"); + //printf("IRCClient::Entry: connect in progress\n"); state = 3; timer = 10; // 5 second timeout } else { - traceit("IRCClient::Entry: connect\n"); + printf("IRCClient::Entry: connect\n"); close(sock); currentAddr++; if (currentAddr >= numAddr) { @@ -185,7 +185,7 @@ void IRCClient::Entry() int res = select(sock+1, NULL, &myset, NULL, &tv); if (res < 0) { - traceit("IRCClient::Entry: select\n"); + printf("IRCClient::Entry: select\n"); close(sock); state = 0; timer = 30; @@ -196,13 +196,13 @@ void IRCClient::Entry() val_len = sizeof value; if (getsockopt(sock, SOL_SOCKET, SO_ERROR, (char *) &value, &val_len) < 0) { - traceit("IRCClient::Entry: getsockopt error\n"); + printf("IRCClient::Entry: getsockopt error\n"); close(sock); state = 0; timer = 30; } else { if (value != 0) { - traceit("IRCClient::Entry: SO_ERROR=%d\n", value); + printf("IRCClient::Entry: SO_ERROR=%d\n", value); close(sock); currentAddr ++; if (currentAddr >= numAddr) { @@ -213,14 +213,14 @@ void IRCClient::Entry() timer = 2; } } else { - traceit("IRCClient::Entry: connected2\n"); + printf("IRCClient::Entry: connected2\n"); state = 4; } } } else if (timer == 0) { // select timeout and timer timeout - //traceit("IRCClient::Entry: connect timeout\n"); + //printf("IRCClient::Entry: connect timeout\n"); close(sock); currentAddr++; if (currentAddr >= numAddr) { @@ -278,17 +278,17 @@ void IRCClient::Entry() int r = send(sock, buf, len, 0); if (r != len) { - traceit("IRCClient::Entry: short write %d < %d\n", r, len); + printf("IRCClient::Entry: short write %d < %d\n", r, len); timer = 0; state = 6; } /* else { - traceit("write %d bytes (%s)\n", len, out.c_str()); + printf("write %d bytes (%s)\n", len, out.c_str()); } */ } else { - traceit("IRCClient::Entry: no NL at end, len=%d\n", len); + printf("IRCClient::Entry: no NL at end, len=%d\n", len); timer = 0; state = 6; @@ -317,7 +317,7 @@ void IRCClient::Entry() close(sock); if (terminateThread) { // request to end the thread - traceit("IRCClient::Entry: thread terminated at state=%d\n", state); + printf("IRCClient::Entry: thread terminated at state=%d\n", state); return; } diff --git a/IRCDDB.cpp b/IRCDDB.cpp index f208ecb..94966c4 100644 --- a/IRCDDB.cpp +++ b/IRCDDB.cpp @@ -32,7 +32,7 @@ CIRCDDB::~CIRCDDB() // A false return implies a network error, or unable to log in bool CIRCDDB::open() { - traceit("start"); + printf("start"); return d->client->startWork() && d->app->startWork(); } @@ -65,27 +65,27 @@ bool CIRCDDB::sendHeard(const std::string &myCall, const std::string &myCallExt, const std::string &rpt2, unsigned char flag1, unsigned char flag2, unsigned char flag3) { if (myCall.size() != 8) { - traceit("CIRCDDB::sendHeard:myCall: len != 8"); + printf("CIRCDDB::sendHeard:myCall: len != 8"); return false; } if (myCallExt.size() != 4) { - traceit("CIRCDDB::sendHeard:myCallExt: len != 4"); + printf("CIRCDDB::sendHeard:myCallExt: len != 4"); return false; } if (yourCall.size() != 8) { - traceit("CIRCDDB::sendHeard:yourCall: len != 8"); + printf("CIRCDDB::sendHeard:yourCall: len != 8"); return false; } if (rpt1.size() != 8) { - traceit("CIRCDDB::sendHeard:rpt1: len != 8"); + printf("CIRCDDB::sendHeard:rpt1: len != 8"); return false; } if (rpt2.size() != 8) { - traceit("CIRCDDB::sendHeard:rpt2: len != 8"); + printf("CIRCDDB::sendHeard:rpt2: len != 8"); return false; } @@ -97,27 +97,27 @@ bool CIRCDDB::sendHeardWithTXMsg(const std::string &myCall, const std::string &m unsigned char flag2, unsigned char flag3, const std::string &network_destination, const std::string &tx_message) { if (myCall.size() != 8) { - traceit("CIRCDDB::sendHeard:myCall: len != 8"); + printf("CIRCDDB::sendHeard:myCall: len != 8"); return false; } if (myCallExt.size() != 4) { - traceit("CIRCDDB::sendHeard:myCallExt: len != 4"); + printf("CIRCDDB::sendHeard:myCallExt: len != 4"); return false; } if (yourCall.size() != 8) { - traceit("CIRCDDB::sendHeard:yourCall: len != 8"); + printf("CIRCDDB::sendHeard:yourCall: len != 8"); return false; } if (rpt1.size() != 8) { - traceit("CIRCDDB::sendHeard:rpt1: len != 8"); + printf("CIRCDDB::sendHeard:rpt1: len != 8"); return false; } if (rpt2.size() != 8) { - traceit("CIRCDDB::sendHeard:rpt2: len != 8"); + printf("CIRCDDB::sendHeard:rpt2: len != 8"); return false; } @@ -127,7 +127,7 @@ bool CIRCDDB::sendHeardWithTXMsg(const std::string &myCall, const std::string &m dest = " "; if (dest.size() != 8) { - traceit("CIRCDDB::sendHeard:network_destination: len != 8"); + printf("CIRCDDB::sendHeard:network_destination: len != 8"); return false; } @@ -154,42 +154,42 @@ bool CIRCDDB::sendHeardWithTXStats(const std::string &myCall, const std::string unsigned char flag2, unsigned char flag3, int num_dv_frames, int num_dv_silent_frames, int num_bit_errors) { if (num_dv_frames<= 0 || num_dv_frames>65535) { - traceit("CIRCDDB::sendHeard:num_dv_frames not in range 1-65535"); + printf("CIRCDDB::sendHeard:num_dv_frames not in range 1-65535"); return false; } if (num_dv_silent_frames > num_dv_frames) { - traceit("CIRCDDB::sendHeard:num_dv_silent_frames > num_dv_frames"); + printf("CIRCDDB::sendHeard:num_dv_silent_frames > num_dv_frames"); return false; } if (num_bit_errors > 4*num_dv_frames) { // max 4 bit errors per frame - traceit("CIRCDDB::sendHeard:num_bit_errors > (4*num_dv_frames)"); + printf("CIRCDDB::sendHeard:num_bit_errors > (4*num_dv_frames)"); return false; } if (myCall.size() != 8) { - traceit("CIRCDDB::sendHeard:myCall: len != 8"); + printf("CIRCDDB::sendHeard:myCall: len != 8"); return false; } if (myCallExt.size() != 4) { - traceit("CIRCDDB::sendHeard:myCallExt: len != 4"); + printf("CIRCDDB::sendHeard:myCallExt: len != 4"); return false; } if (yourCall.size() != 8) { - traceit("CIRCDDB::sendHeard:yourCall: len != 8"); + printf("CIRCDDB::sendHeard:yourCall: len != 8"); return false; } if (rpt1.size() != 8) { - traceit("CIRCDDB::sendHeard:rpt1: len != 8"); + printf("CIRCDDB::sendHeard:rpt1: len != 8"); return false; } if (rpt2.size() != 8) { - traceit("CIRCDDB::sendHeard:rpt2: len != 8"); + printf("CIRCDDB::sendHeard:rpt2: len != 8"); return false; } @@ -222,7 +222,7 @@ bool CIRCDDB::sendHeardWithTXStats(const std::string &myCall, const std::string bool CIRCDDB::findGateway(const std::string &gatewayCallsign) { if (gatewayCallsign.size() != 8) { - traceit("CIRCDDB::findGateway: len != 8"); + printf("CIRCDDB::findGateway: len != 8"); return false; } std::string gcs = gatewayCallsign; @@ -234,7 +234,7 @@ bool CIRCDDB::findGateway(const std::string &gatewayCallsign) bool CIRCDDB::findRepeater(const std::string &repeaterCallsign) { if (repeaterCallsign.size() != 8) { - traceit("CIRCDDB::findRepeater: len != 8"); + printf("CIRCDDB::findRepeater: len != 8"); return false; } std::string rcs = repeaterCallsign; @@ -246,7 +246,7 @@ bool CIRCDDB::findRepeater(const std::string &repeaterCallsign) bool CIRCDDB::findUser(const std::string &userCallsign) { if (userCallsign.size() != 8) { - traceit("CIRCDDB::findUser: len != 8"); + printf("CIRCDDB::findUser: len != 8"); return false; } std::string ucs = userCallsign; @@ -269,24 +269,24 @@ bool CIRCDDB::receiveRepeater(std::string &repeaterCallsign, std::string &gatewa IRCDDB_RESPONSE_TYPE rt = d->app->getReplyMessageType(); if (rt != IDRT_REPEATER) { - traceit("CIRCDDB::receiveRepeater: unexpected response type"); + printf("CIRCDDB::receiveRepeater: unexpected response type"); return false; } IRCMessage * m = d->app->getReplyMessage(); if (m == NULL) { - traceit("CIRCDDB::receiveRepeater: no message"); + printf("CIRCDDB::receiveRepeater: no message"); return false; } if (m->getCommand().compare("IDRT_REPEATER")) { - traceit("CIRCDDB::receiveRepeater: wrong message type"); + printf("CIRCDDB::receiveRepeater: wrong message type"); return false; } if (m->getParamCount() != 3) { - traceit("CIRCDDB::receiveRepeater: unexpected number of message parameters"); + printf("CIRCDDB::receiveRepeater: unexpected number of message parameters"); return false; } @@ -306,24 +306,24 @@ bool CIRCDDB::receiveGateway(std::string &gatewayCallsign, std::string &address, IRCDDB_RESPONSE_TYPE rt = d->app->getReplyMessageType(); if (rt != IDRT_GATEWAY) { - traceit("CIRCDDB::receiveGateway: unexpected response type"); + printf("CIRCDDB::receiveGateway: unexpected response type"); return false; } IRCMessage * m = d->app->getReplyMessage(); if (m == NULL) { - traceit("CIRCDDB::receiveGateway: no message"); + printf("CIRCDDB::receiveGateway: no message"); return false; } if (m->getCommand().compare("IDRT_GATEWAY")) { - traceit("CIRCDDB::receiveGateway: wrong message type"); + printf("CIRCDDB::receiveGateway: wrong message type"); return false; } if (m->getParamCount() != 2) { - traceit("CIRCDDB::receiveGateway: unexpected number of message parameters"); + printf("CIRCDDB::receiveGateway: unexpected number of message parameters"); return false; } @@ -349,24 +349,24 @@ bool CIRCDDB::receiveUser(std::string &userCallsign, std::string &repeaterCallsi IRCDDB_RESPONSE_TYPE rt = d->app->getReplyMessageType(); if (rt != IDRT_USER) { - traceit("CIRCDDB::receiveUser: unexpected response type"); + printf("CIRCDDB::receiveUser: unexpected response type"); return false; } IRCMessage * m = d->app->getReplyMessage(); if (m == NULL) { - traceit("CIRCDDB::receiveUser: no message"); + printf("CIRCDDB::receiveUser: no message"); return false; } if (m->getCommand().compare("IDRT_USER")) { - traceit("CIRCDDB::receiveUser: wrong message type"); + printf("CIRCDDB::receiveUser: wrong message type"); return false; } if (m->getParamCount() != 5) { - traceit("CIRCDDB::receiveUser: unexpected number of message parameters"); + printf("CIRCDDB::receiveUser: unexpected number of message parameters"); return false; } diff --git a/IRCDDBApp.cpp b/IRCDDBApp.cpp index 01bbf2e..a2e7f7c 100644 --- a/IRCDDBApp.cpp +++ b/IRCDDBApp.cpp @@ -165,7 +165,7 @@ void IRCDDBApp::rptrQTH(const std::string &rptrcall, double latitude, double lon d->locationMap[rptrcall] = f; d->locationMapMutex.unlock(); - traceit("IRCDDB RPTRQTH: %s\n", f.c_str()); + printf("IRCDDB RPTRQTH: %s\n", f.c_str()); std::regex urlNonValid("[^[:graph:]]+"); @@ -179,7 +179,7 @@ void IRCDDBApp::rptrQTH(const std::string &rptrcall, double latitude, double lon d->urlMap[rptrcall] = g; d->urlMapMutex.unlock(); - traceit("IRCDDB RPTRURL: %s\n", g.c_str()); + printf("IRCDDB RPTRURL: %s\n", g.c_str()); std::string sw = swVersion; while (std::regex_search(sw, sm, nonValid)) @@ -190,7 +190,7 @@ void IRCDDBApp::rptrQTH(const std::string &rptrcall, double latitude, double lon d->swMap[rptrcall] = h; d->swMapMutex.unlock(); - traceit("IRCDDB RPTRSW: %s\n", h.c_str()); + printf("IRCDDB RPTRSW: %s\n", h.c_str()); d->infoTimer = 5; // send info in 5 seconds } @@ -211,7 +211,7 @@ void IRCDDBApp::rptrQRG(const std::string &rptrcall, double txFrequency, double d->moduleMap[rptrcall] = g; d->moduleMapMutex.unlock(); - traceit("IRCDDB RPTRQRG: %s\n", g.c_str()); + printf("IRCDDB RPTRQRG: %s\n", g.c_str()); d->infoTimer = 5; // send info in 5 seconds } @@ -255,7 +255,7 @@ IRCDDB_RESPONSE_TYPE IRCDDBApp::getReplyMessageType() return IDRT_GATEWAY; } - traceit("IRCDDBApp::getMessageType: unknown msg type: %s\n", msgType.c_str()); + printf("IRCDDBApp::getMessageType: unknown msg type: %s\n", msgType.c_str()); return IDRT_NONE; } @@ -289,7 +289,7 @@ void IRCDDBApp::userJoin(const std::string &nick, const std::string &name, const d->user[lnick] = u; d->userMapMutex.unlock(); - //traceit("add %d: (%s) (%s)\n", d->user.size(), nick.c_str(), host.c_str()); + //printf("add %d: (%s) (%s)\n", d->user.size(), nick.c_str(), host.c_str()); if (d->initReady) { unsigned hyphenPos = nick.find('-'); @@ -306,7 +306,7 @@ void IRCDDBApp::userJoin(const std::string &nick, const std::string &name, const d->replyQ.putMessage(m2); } } - //traceit("user %d\n", u.usn); + //printf("user %d\n", u.usn); } void IRCDDBApp::userLeave(const std::string &nick) @@ -318,11 +318,11 @@ void IRCDDBApp::userLeave(const std::string &nick) d->user.erase(lnick); d->userMapMutex.unlock(); - // traceit("rm %d: %s\n" d->user.size(), nick.c_str()); + // printf("rm %d: %s\n" d->user.size(), nick.c_str()); if (d->currentServer.length() > 0) { if (d->user.count(d->myNick) != 1) { - traceit("IRCDDBApp::userLeave: could not find own nick\n"); + printf("IRCDDBApp::userLeave: could not find own nick\n"); return; } @@ -351,13 +351,13 @@ void IRCDDBApp::userListReset() void IRCDDBApp::setCurrentNick(const std::string &nick) { d->myNick = nick; - traceit("IRCDDBApp::setCurrentNick %s\n", nick.c_str()); + printf("IRCDDBApp::setCurrentNick %s\n", nick.c_str()); } void IRCDDBApp::setBestServer(const std::string &ircUser) { d->bestServer = ircUser; - traceit("IRCDDBApp::setBestServer %s\n", ircUser.c_str()); + printf("IRCDDBApp::setBestServer %s\n", ircUser.c_str()); } void IRCDDBApp::setTopic(const std::string &topic) @@ -454,7 +454,7 @@ std::string IRCDDBApp::getIPAddress(std::string &zonerp_cs) ipAddr = o.host; } } - // traceit("getIP %d (%s) (%s)\n", i, ircUser.c_str(), ipAddr.c_str()); + // printf("getIP %d (%s) (%s)\n", i, ircUser.c_str(), ipAddr.c_str()); } d->userMapMutex.unlock(); @@ -679,7 +679,7 @@ void IRCDDBApp::doNotFound(std::string &msg, std::string &retval) long tableID = std::stol(tk); if ((tableID < 0) || (tableID >= numberOfTables)) { - traceit("invalid table ID %d", tableID); + printf("invalid table ID %ld", tableID); return; } @@ -713,7 +713,7 @@ void IRCDDBApp::doUpdate(std::string &msg) if (std::regex_match(tk, d->tablePattern)) { tableID = stol(tk); if ((tableID < 0) || (tableID >= numberOfTables)) { - traceit("invalid table ID %d", tableID); + printf("invalid table ID %d", tableID); return; } @@ -755,7 +755,7 @@ void IRCDDBApp::doUpdate(std::string &msg) if (! std::regex_match(value, d->dbPattern)) return; // no valid key - //traceit("TABLE %d %s %s\n", tableID, key.c_str(), value.c_str()); + //printf("TABLE %d %s %s\n", tableID, key.c_str(), value.c_str()); if (tableID == 1) { d->rptrMapMutex.lock(); @@ -934,7 +934,7 @@ void IRCDDBApp::Entry() break; case 2: // choose server - traceit("IRCDDBApp: state=2 choose new 's-'-user\n"); + printf("IRCDDBApp: state=2 choose new 's-'-user\n"); if (getSendQ() == NULL) { d->state = 10; } else { @@ -964,7 +964,7 @@ void IRCDDBApp::Entry() if (sendlistTableID < 0) { d->state = 6; // end of sendlist } else { - traceit("IRCDDBApp: state=3 tableID=%d\n", sendlistTableID); + printf("IRCDDBApp: state=3 tableID=%d\n", sendlistTableID); d->state = 4; // send "SENDLIST" d->timer = 900; // 15 minutes max for update } @@ -1010,7 +1010,7 @@ void IRCDDBApp::Entry() if (getSendQ() == NULL) { d->state = 10; // disconnect DB } else { - traceit("IRCDDBApp: state=6 initialization completed\n"); + printf("IRCDDBApp: state=6 initialization completed\n"); d->infoTimer = 2; diff --git a/IRCMessageQueue.cpp b/IRCMessageQueue.cpp index c2d6285..315a559 100644 --- a/IRCMessageQueue.cpp +++ b/IRCMessageQueue.cpp @@ -94,7 +94,7 @@ void IRCMessageQueue::putMessage( IRCMessage * m ) { accessMutex.lock(); - //traceit("IRCMessageQueue::putMessage\n"); + //printf("IRCMessageQueue::putMessage\n"); IRCMessageQueueItem * k = new IRCMessageQueueItem(m); diff --git a/IRCProtocol.cpp b/IRCProtocol.cpp index f36ad89..ab8ecb9 100644 --- a/IRCProtocol.cpp +++ b/IRCProtocol.cpp @@ -6,8 +6,6 @@ #include "IRCutils.h" #include "IRCProtocol.h" -extern void traceit(const char *fmt,...); - #define CIRCDDB_VERSION "2.0.0" IRCProtocol::IRCProtocol(IRCApplication *app, const std::string &callsign, const std::string &password, const std::string &channel, const std::string &versionInfo) @@ -67,7 +65,7 @@ void IRCProtocol::setNetworkReady(bool b) { if (b == true) { if (state != 0) - traceit("IRCProtocol::setNetworkReady: unexpected state"); + printf("IRCProtocol::setNetworkReady: unexpected state"); state = 1; chooseNewNick(); @@ -93,7 +91,7 @@ bool IRCProtocol::processQueues(IRCMessageQueue *recvQ, IRCMessageQueue *sendQ) } // d.Replace(std::string("%"), std::string("%%"), true); // d.Replace(std::string("\\"), std::string("\\\\"), true); - traceit("%s\n", d.c_str()); + printf("%s\n", d.c_str()); #endif if (0 == m->command.compare("004")) { diff --git a/IRCReceiver.cpp b/IRCReceiver.cpp index 6408e95..f2c0bcf 100644 --- a/IRCReceiver.cpp +++ b/IRCReceiver.cpp @@ -24,11 +24,11 @@ static int doRead(int sock, char * buf, int buf_size) res = select(sock+1, &rdset, NULL, &errset, &tv); if ( res < 0 ) { - traceit("IRCReceiver::doread: select() error.\n"); + printf("IRCReceiver::doread: select() error.\n"); return -1; } else if ( res > 0 ) { if (FD_ISSET(sock, &errset)) { - traceit("IRCReceiver::doRead: FD_ISSET error\n"); + printf("IRCReceiver::doRead: FD_ISSET error\n"); return -1; } @@ -36,10 +36,10 @@ static int doRead(int sock, char * buf, int buf_size) res = recv(sock, buf, buf_size, 0); if (res < 0) { - traceit("IRCReceiver::doRead: recv error\n"); + printf("IRCReceiver::doRead: recv error\n"); return -1; } else if (res == 0) { - traceit("IRCReceiver::doRead: EOF read==0\n"); + printf("IRCReceiver::doRead: EOF read==0\n"); return -1; } else return res; diff --git a/IRCutils.cpp b/IRCutils.cpp index 3959c7e..9076b66 100644 --- a/IRCutils.cpp +++ b/IRCutils.cpp @@ -105,7 +105,7 @@ int getAllIPV4Addresses(const char * name, unsigned short port, unsigned int * n return 0; } else { - traceit("getaddrinfo: %s\n", gai_strerror(r)); + printf("getaddrinfo: %s\n", gai_strerror(r)); return 1; } @@ -140,29 +140,6 @@ char *getCurrentTime(void) return buffer; } -void traceit(const char *fmt,...) -{ - time_t ltime; - struct tm tm; - const short BFSZ = 512; - char buf[BFSZ]; - - time(<ime); - localtime_r(<ime, &tm); - - snprintf(buf,BFSZ - 1,"%02d/%02d/%02d %d:%02d:%02d:", - tm.tm_mon+1,tm.tm_mday,tm.tm_year % 100, - tm.tm_hour,tm.tm_min,tm.tm_sec); - - va_list args; - va_start(args,fmt); - vsnprintf(buf + strlen(buf), BFSZ - strlen(buf) -1, fmt, args); - va_end(args); - - fprintf(stdout, "%s", buf); - return; -} - void ToUpper(std::string &str) { for (auto it=str.begin(); it!=str.end(); it++) { diff --git a/IRCutils.h b/IRCutils.h index 07ebb48..d139ed6 100644 --- a/IRCutils.h +++ b/IRCutils.h @@ -33,8 +33,6 @@ void safeStringCopy(char * dest, const char * src, unsigned int buf_size); char *getCurrentTime(void); -void traceit(const char *fmt,...); - void ToUpper(std::string &str); void ToLower(std::string &str); diff --git a/aprs.cpp b/aprs.cpp index 62a9704..8b9b679 100644 --- a/aprs.cpp +++ b/aprs.cpp @@ -33,7 +33,7 @@ void CAPRS::SelectBand(short int rptr_idx, unsigned short streamID) { if ((rptr_idx < 0) || (rptr_idx > 2)) { - traceit("ERROR in aprs_select_band, invalid mod %d\n", rptr_idx); + printf("ERROR in aprs_select_band, invalid mod %d\n", rptr_idx); return; } @@ -70,7 +70,7 @@ void CAPRS::ProcessText(unsigned short streamID, unsigned char seq, unsigned cha } if ((rptr_idx < 0) || (rptr_idx > 2)) { - // traceit("ERROR in aprs_process_text: rptr_idx %d is invalid\n", rptr_idx); + // printf("ERROR in aprs_process_text: rptr_idx %d is invalid\n", rptr_idx); return; } @@ -113,7 +113,7 @@ void CAPRS::ProcessText(unsigned short streamID, unsigned char seq, unsigned cha *p = '\0'; sprintf(aprs_buf, "%s,qAR,%s:%s\r\n", hdr, m_rptr->mod[rptr_idx].call.c_str(), aud); - // traceit("GPS-A=%s", aprs_buf); + // printf("GPS-A=%s", aprs_buf); int rc = WriteSock(aprs_buf, strlen(aprs_buf)); if (rc == -1) { if ((errno == EPIPE) || @@ -127,11 +127,11 @@ void CAPRS::ProcessText(unsigned short streamID, unsigned char seq, unsigned cha (errno == ENETUNREACH) || (errno == EHOSTDOWN) || (errno == ENOTCONN)) { - traceit("CAPRS::ProcessText(): APRS_HOST closed connection,error=%d\n",errno); + printf("CAPRS::ProcessText(): APRS_HOST closed connection,error=%d\n",errno); close(aprs_sock); aprs_sock = -1; } else /* if it is WOULDBLOCK, we will not go into a loop here */ - traceit("CAPRS::ProcessText(): send error=%d\n", errno); + printf("CAPRS::ProcessText(): send error=%d\n", errno); } time(&aprs_streamID[rptr_idx].last_time); @@ -177,7 +177,7 @@ bool CAPRS::WriteData(short int rptr_idx, unsigned char *data) { if ((rptr_idx < 0) || (rptr_idx > 2)) { - traceit("CAPRS::WriteData: rptr_idx %d is invalid\n", rptr_idx); + printf("CAPRS::WriteData: rptr_idx %d is invalid\n", rptr_idx); return false; } @@ -210,7 +210,7 @@ bool CAPRS::WriteData(short int rptr_idx, unsigned char *data) void CAPRS::SyncIt(short int rptr_idx) { if ((rptr_idx < 0) || (rptr_idx > 2)) { - traceit("CAPRS::SyncIt(): rptr_idx %d is invalid\n", rptr_idx); + printf("CAPRS::SyncIt(): rptr_idx %d is invalid\n", rptr_idx); return; } @@ -221,7 +221,7 @@ void CAPRS::SyncIt(short int rptr_idx) void CAPRS::Reset(short int rptr_idx) { if ((rptr_idx < 0) || (rptr_idx > 2)) { - traceit("CAPRS::Reset(): rptr_idx %d is invalid\n", rptr_idx); + printf("CAPRS::Reset(): rptr_idx %d is invalid\n", rptr_idx); return; } @@ -236,7 +236,7 @@ void CAPRS::Reset(short int rptr_idx) unsigned int CAPRS::GetData(short int rptr_idx, unsigned char *data, unsigned int len) { if ((rptr_idx < 0) || (rptr_idx > 2)) { - traceit("CAPRS::GetData: rptr_idx %d is invalid\n", rptr_idx); + printf("CAPRS::GetData: rptr_idx %d is invalid\n", rptr_idx); return 0; } @@ -266,7 +266,7 @@ void CAPRS::Open(const std::string OWNER) bool ok = ResolveRmt(m_rptr->aprs.ip.c_str(), SOCK_STREAM, &aprs_addr); if (!ok) { - traceit("Can't resolve APRS_HOST %s\n", m_rptr->aprs.ip.c_str()); + printf("Can't resolve APRS_HOST %s\n", m_rptr->aprs.ip.c_str()); return; } @@ -278,24 +278,24 @@ void CAPRS::Open(const std::string OWNER) aprs_sock = socket(PF_INET, SOCK_STREAM, 0); if (aprs_sock == -1) { - traceit("Failed to create aprs socket,error=%d\n",errno); + printf("Failed to create aprs socket,error=%d\n",errno); return; } fcntl(aprs_sock,F_SETFL,O_NONBLOCK); val = 1; if (setsockopt(aprs_sock,IPPROTO_TCP,TCP_NODELAY,(char *)&val, sizeof(val)) == -1) { - traceit("setsockopt TCP_NODELAY TCP for aprs socket failed,error=%d\n",errno); + printf("setsockopt TCP_NODELAY TCP for aprs socket failed,error=%d\n",errno); close(aprs_sock); aprs_sock = -1; return; } - traceit("Trying to connect to APRS...\n"); + printf("Trying to connect to APRS...\n"); int rc = connect(aprs_sock, (struct sockaddr *)&aprs_addr, aprs_addr_len); if (rc != 0) { if (errno == EINPROGRESS) { - traceit("Waiting for up to %d seconds for APRS_HOST\n", MAX_WAIT); + printf("Waiting for up to %d seconds for APRS_HOST\n", MAX_WAIT); while (MAX_WAIT > 0) { tv.tv_sec = 0; tv.tv_usec = 0; @@ -304,7 +304,7 @@ void CAPRS::Open(const std::string OWNER) rc = select(aprs_sock + 1, NULL, &fdset, NULL, &tv); if (rc < 0) { - traceit("Failed to connect to APRS...select,error=%d\n", errno); + printf("Failed to connect to APRS...select,error=%d\n", errno); close(aprs_sock); aprs_sock = -1; return; @@ -315,7 +315,7 @@ void CAPRS::Open(const std::string OWNER) val = 1; /* Assume it fails */ val_len = sizeof(val); if (getsockopt(aprs_sock, SOL_SOCKET, SO_ERROR, (char *) &val, &val_len) < 0) { - traceit("Failed to connect to APRS...getsockopt, error=%d\n", errno); + printf("Failed to connect to APRS...getsockopt, error=%d\n", errno); close(aprs_sock); aprs_sock = -1; return; @@ -327,19 +327,19 @@ void CAPRS::Open(const std::string OWNER) } } if (MAX_WAIT == 0) { - traceit("Failed to connect to APRS...timeout\n"); + printf("Failed to connect to APRS...timeout\n"); close(aprs_sock); aprs_sock = -1; return; } } else { - traceit("Failed to connect to APRS, error=%d\n", errno); + printf("Failed to connect to APRS, error=%d\n", errno); close(aprs_sock); aprs_sock = -1; return; } } - traceit("Connected to APRS %s:%d\n", m_rptr->aprs.ip.c_str(), m_rptr->aprs.port); + printf("Connected to APRS %s:%d\n", m_rptr->aprs.ip.c_str(), m_rptr->aprs.port); /* login to aprs */ sprintf(snd_buf, "user %s pass %d vers g2_ircddb 2.99 UDP 5 ", OWNER.c_str(), m_rptr->aprs_hash); @@ -349,7 +349,7 @@ void CAPRS::Open(const std::string OWNER) strcat(snd_buf, "filter "); strcat(snd_buf, m_rptr->aprs_filter.c_str()); } - // traceit("APRS login command:[%s]\n", snd_buf); + // printf("APRS login command:[%s]\n", snd_buf); strcat(snd_buf, "\r\n"); while (true) { @@ -359,11 +359,11 @@ void CAPRS::Open(const std::string OWNER) recv(aprs_sock, rcv_buf, sizeof(rcv_buf), 0); std::this_thread::sleep_for(std::chrono::milliseconds(100)); } else { - traceit("APRS login command failed, error=%d\n", errno); + printf("APRS login command failed, error=%d\n", errno); break; } } else { - // traceit("APRS login command sent\n"); + // printf("APRS login command sent\n"); break; } } @@ -375,7 +375,7 @@ void CAPRS::Open(const std::string OWNER) bool CAPRS::AddData(short int rptr_idx, unsigned char *data) { if ((rptr_idx < 0) || (rptr_idx > 2)) { - traceit("CAPRS::AddData(): rptr_idx %d is invalid\n", rptr_idx); + printf("CAPRS::AddData(): rptr_idx %d is invalid\n", rptr_idx); return false; } @@ -427,7 +427,7 @@ bool CAPRS::AddData(short int rptr_idx, unsigned char *data) aprs_pack[rptr_idx].len++; if (aprs_pack[rptr_idx].len >= 300) { - traceit("ERROR in aprs_add_data: Expected END of APRS data\n"); + printf("ERROR in aprs_add_data: Expected END of APRS data\n"); aprs_pack[rptr_idx].len = 0; aprs_pack[rptr_idx].al = al_none; } @@ -441,7 +441,7 @@ bool CAPRS::AddData(short int rptr_idx, unsigned char *data) aprs_pack[rptr_idx].al = al_end; return true; } else { - traceit("BAD checksum in APRS data\n"); + printf("BAD checksum in APRS data\n"); aprs_pack[rptr_idx].al = al_none; aprs_pack[rptr_idx].len = 0; } @@ -459,7 +459,7 @@ bool CAPRS::CheckData(short int rptr_idx) char buf[5]; if ((rptr_idx < 0) || (rptr_idx > 2)) { - traceit("CAPRS::CheckData(): rptr_idx %d is invalid\n", rptr_idx); + printf("CAPRS::CheckData(): rptr_idx %d is invalid\n", rptr_idx); return false; } my_sum = CalcCRC(aprs_pack[rptr_idx].data + 10, aprs_pack[rptr_idx].len - 10); @@ -528,7 +528,7 @@ bool CAPRS::ResolveRmt(const char *name, int type, struct sockaddr_in *addr) int rc = getaddrinfo(name, NULL, &hints, &res); if (rc != 0) { - traceit("getaddrinfo return error code %d for [%s]\n", rc, name); + printf("getaddrinfo return error code %d for [%s]\n", rc, name); return false; } diff --git a/dvap_rptr.cpp b/dvap_rptr.cpp index 1ae67e4..766069f 100644 --- a/dvap_rptr.cpp +++ b/dvap_rptr.cpp @@ -97,7 +97,6 @@ static unsigned int space = 0; static unsigned int aseed = 0; /* helper routines */ -void traceit(const char *fmt,...); static int read_config(const char *cfgFile); static void sig_catch(int signum); static int open_sock(); @@ -156,30 +155,6 @@ static void sig_catch(int signum) exit(0); } -/* log the event */ -void traceit(const char *fmt,...) -{ - time_t ltime; - struct tm mytm; - const int TRACE_BFSZ = 256; - char trace_buf[TRACE_BFSZ]; - - time(<ime); - localtime_r(<ime,&mytm); - - snprintf(trace_buf,TRACE_BFSZ - 1,"%02d/%02d/%02d %02d:%02d:%02d:", - mytm.tm_mon+1,mytm.tm_mday,mytm.tm_year % 100, - mytm.tm_hour,mytm.tm_min,mytm.tm_sec); - - va_list args; - va_start(args,fmt); - vsnprintf(trace_buf + strlen(trace_buf), TRACE_BFSZ - strlen(trace_buf) - 1, fmt, args); - va_end(args); - - fprintf(stdout, "%s", trace_buf); - return; -} - bool get_value(const Config &cfg, const char *path, int &value, int min, int max, int default_value) { if (cfg.lookupValue(path, value)) { @@ -187,7 +162,7 @@ bool get_value(const Config &cfg, const char *path, int &value, int min, int max value = default_value; } else value = default_value; - traceit("%s = [%d]\n", path, value); + printf("%s = [%d]\n", path, value); return true; } @@ -198,7 +173,7 @@ bool get_value(const Config &cfg, const char *path, double &value, double min, d value = default_value; } else value = default_value; - traceit("%s = [%lg]\n", path, value); + printf("%s = [%lg]\n", path, value); return true; } @@ -206,7 +181,7 @@ bool get_value(const Config &cfg, const char *path, bool &value, bool default_va { if (! cfg.lookupValue(path, value)) value = default_value; - traceit("%s = [%s]\n", path, value ? "true" : "false"); + printf("%s = [%s]\n", path, value ? "true" : "false"); return true; } @@ -215,12 +190,12 @@ bool get_value(const Config &cfg, const char *path, std::string &value, int min, if (cfg.lookupValue(path, value)) { int l = value.length(); if (lmax) { - traceit("%s is invalid\n", path, value.c_str()); + printf("%s is invalid\n", path); return false; } } else value = default_value; - traceit("%s = [%s]\n", path, value.c_str()); + printf("%s = [%s]\n", path, value.c_str()); return true; } @@ -230,17 +205,17 @@ static int read_config(const char *cfgFile) int i; Config cfg; - traceit("Reading file %s\n", cfgFile); + printf("Reading file %s\n", cfgFile); // Read the file. If there is an error, report it and exit. try { cfg.readFile(cfgFile); } catch(const FileIOException &fioex) { - traceit("Can't read %s\n", cfgFile); + printf("Can't read %s\n", cfgFile); return 1; } catch(const ParseException &pex) { - traceit("Parse error at %s:%d - %s\n", pex.getFile(), pex.getLine(), pex.getError()); + printf("Parse error at %s:%d - %s\n", pex.getFile(), pex.getLine(), pex.getError()); return 1; } @@ -254,7 +229,7 @@ static int read_config(const char *cfgFile) } } if (i >= 3) { - traceit("dvap not defined in any module!\n"); + printf("dvap not defined in any module!\n"); return 1; } RPTR_MOD = 'A' + i; @@ -262,7 +237,7 @@ static int read_config(const char *cfgFile) if (cfg.lookupValue(std::string(dvap_path+".callsign").c_str(), value) || cfg.lookupValue("ircddb.login", value)) { int l = value.length(); if (l<3 || l>CALL_SIZE-2) { - traceit("Call '%s' is invalid length!\n", value.c_str()); + printf("Call '%s' is invalid length!\n", value.c_str()); return 1; } else { for (i=0; iCALL_SIZE-2) { - traceit("Call '%s' is invalid length!\n", value.c_str()); + printf("Call '%s' is invalid length!\n", value.c_str()); return 1; } else { for (i=0; i readthread; try { readthread = std::async(std::launch::async, ReadDVAPThread); } catch (const std::exception &e) { - traceit("Unable to start ReadDVAPThread(). Exception: %s\n", e.what()); + printf("Unable to start ReadDVAPThread(). Exception: %s\n", e.what()); keep_running = false; } - traceit("Started ReadDVAPThread()\n"); + printf("Started ReadDVAPThread()\n"); while (keep_running) { time(&tnow); @@ -729,7 +704,7 @@ int main(int argc, const char **argv) if (rc < 0) { cnt ++; if (cnt > 5) { - traceit("Could not send KEEPALIVE signal to dvap 5 times...exiting\n"); + printf("Could not send KEEPALIVE signal to dvap 5 times...exiting\n"); keep_running = false; } } else @@ -741,7 +716,7 @@ int main(int argc, const char **argv) readthread.get(); close(insock); - traceit("dvap_rptr exiting\n"); + printf("dvap_rptr exiting\n"); return 0; } @@ -764,15 +739,15 @@ static void RptrAckThread(SDVAP_ACK_ARG *parg) act.sa_handler = sig_catch; sigemptyset(&act.sa_mask); if (sigaction(SIGTERM, &act, 0) != 0) { - traceit("sigaction-TERM failed, error=%d\n", errno); + printf("sigaction-TERM failed, error=%d\n", errno); return; } if (sigaction(SIGHUP, &act, 0) != 0) { - traceit("sigaction-HUP failed, error=%d\n", errno); + printf("sigaction-HUP failed, error=%d\n", errno); return; } if (sigaction(SIGINT, &act, 0) != 0) { - traceit("sigaction-INT failed, error=%d\n", errno); + printf("sigaction-INT failed, error=%d\n", errno); return; } @@ -902,17 +877,17 @@ static void ReadDVAPThread() act.sa_handler = sig_catch; sigemptyset(&act.sa_mask); if (sigaction(SIGTERM, &act, 0) != 0) { - traceit("sigaction-TERM failed, error=%d\n", errno); + printf("sigaction-TERM failed, error=%d\n", errno); keep_running = false; return; } if (sigaction(SIGHUP, &act, 0) != 0) { - traceit("sigaction-HUP failed, error=%d\n", errno); + printf("sigaction-HUP failed, error=%d\n", errno); keep_running = false; return; } if (sigaction(SIGINT, &act, 0) != 0) { - traceit("sigaction-INT failed, error=%d\n", errno); + printf("sigaction-INT failed, error=%d\n", errno); keep_running = false; return; } @@ -949,16 +924,16 @@ static void ReadDVAPThread() // read from the dvap and process reply = dongle.GetReply(dr); if (reply == RT_ERR) { - traceit("Detected ERROR event from DVAP dongle, stopping...n"); + printf("Detected ERROR event from DVAP dongle, stopping...n"); break; } else if (reply == RT_STOP) { - traceit("Detected STOP event from DVAP dongle, stopping...\n"); + printf("Detected STOP event from DVAP dongle, stopping...\n"); break; } else if (reply == RT_START) { - traceit("Detected START event from DVAP dongle\n"); + printf("Detected START event from DVAP dongle\n"); // else if (reply == RT_PTT) { // ptt = (dvp_buf[4] == 0x01); - // traceit("Detected PTT=%s\n", ptt?"on":"off"); + // printf("Detected PTT=%s\n", ptt?"on":"off"); } else if (reply == RT_STS) { space = (unsigned int)dr.param.sstr[2]; if (status_cntr < 3000) @@ -967,7 +942,7 @@ static void ReadDVAPThread() num_dv_frames = 0; num_bit_errors = 0; - traceit("From DVAP: flags=%02x:%02x:%02x, my=%.8s, sfx=%.4s, ur=%.8s, rpt1=%.8s, rpt2=%.8s\n", + printf("From DVAP: flags=%02x:%02x:%02x, my=%.8s, sfx=%.4s, ur=%.8s, rpt1=%.8s, rpt2=%.8s\n", dr.frame.hdr.flag[0], dr.frame.hdr.flag[1], dr.frame.hdr.flag[2], dr.frame.hdr.mycall, dr.frame.hdr.sfx, dr.frame.hdr.urcall, dr.frame.hdr.rpt2, dr.frame.hdr.rpt1); @@ -990,7 +965,7 @@ static void ReadDVAPThread() temp_yrcall[CALL_SIZE] = '\0'; temp_ptr = strstr(temp_yrcall, INVALID_YRCALL_KEY); if (temp_ptr == temp_yrcall) { // found it at first position - traceit("YRCALL value [%s] starts with the INVALID_YRCALL_KEY [%s], resetting to CQCQCQ\n", + printf("YRCALL value [%s] starts with the INVALID_YRCALL_KEY [%s], resetting to CQCQCQ\n", temp_yrcall, INVALID_YRCALL_KEY); memcpy(dr.frame.hdr.urcall, "CQCQCQ ", 8); } @@ -1028,11 +1003,11 @@ static void ReadDVAPThread() */ if (memcmp(RPTR, OWNER, RPTR_SIZE) != 0) { if (memcmp(net_buf.vpkt.hdr.mycall, RPTR, RPTR_SIZE) != 0) { - traceit("mycall=[%.8s], not equal to %s\n", net_buf.vpkt.hdr.mycall, RPTR); + printf("mycall=[%.8s], not equal to %s\n", net_buf.vpkt.hdr.mycall, RPTR); ok = false; } } else if (memcmp(net_buf.vpkt.hdr.mycall, " ", 8) == 0) { - traceit("Invalid value for mycall=[%.8s]\n", net_buf.vpkt.hdr.mycall); + printf("Invalid value for mycall=[%.8s]\n", net_buf.vpkt.hdr.mycall); ok = false; } @@ -1043,7 +1018,7 @@ static void ReadDVAPThread() (net_buf.vpkt.hdr.mycall[i] != ' ')) { memset(net_buf.vpkt.hdr.mycall, ' ', 8); ok = false; - traceit("Invalid value for MYCALL\n"); + printf("Invalid value for MYCALL\n"); break; } } @@ -1152,14 +1127,14 @@ static void ReadDVAPThread() dvap_busy = false; static SDVAP_ACK_ARG dvap_ack_arg; dvap_ack_arg.ber = (num_dv_frames==0) ? 0.f : 100.f * (float)num_bit_errors / (float)(num_dv_frames * 24); - traceit("End of dvap audio, ber=%.02f\n", dvap_ack_arg.ber); + printf("End of dvap audio, ber=%.02f\n", dvap_ack_arg.ber); if (RPTR_ACK && !busy20000) { memcpy(dvap_ack_arg.mycall, mycall, 8); try { std::async(std::launch::async, RptrAckThread, &dvap_ack_arg); } catch (const std::exception &e) { - traceit("Failed to start RptrAckThread(). Exception: %s\n", e.what()); + printf("Failed to start RptrAckThread(). Exception: %s\n", e.what()); } } } @@ -1175,7 +1150,7 @@ static void ReadDVAPThread() dongle.Stop(); close(serfd); - traceit("ReadDVAPThread exiting\n"); + printf("ReadDVAPThread exiting\n"); keep_running = false; return; diff --git a/g2_ircddb.cpp b/g2_ircddb.cpp index c369aa2..9f5f715 100644 --- a/g2_ircddb.cpp +++ b/g2_ircddb.cpp @@ -178,7 +178,7 @@ bool CG2_ircddb::get_value(const Config &cfg, const char *path, int &value, int value = default_value; } else value = default_value; - traceit("%s = [%d]\n", path, value); + printf("%s = [%d]\n", path, value); return true; } @@ -189,7 +189,7 @@ bool CG2_ircddb::get_value(const Config &cfg, const char *path, double &value, d value = default_value; } else value = default_value; - traceit("%s = [%lg]\n", path, value); + printf("%s = [%lg]\n", path, value); return true; } @@ -197,7 +197,7 @@ bool CG2_ircddb::get_value(const Config &cfg, const char *path, bool &value, boo { if (! cfg.lookupValue(path, value)) value = default_value; - traceit("%s = [%s]\n", path, value ? "true" : "false"); + printf("%s = [%s]\n", path, value ? "true" : "false"); return true; } @@ -206,12 +206,12 @@ bool CG2_ircddb::get_value(const Config &cfg, const char *path, std::string &val if (cfg.lookupValue(path, value)) { int l = value.length(); if (lmax) { - traceit("%s is invalid\n", path, value.c_str()); + printf("%s is invalid\n", path); return false; } } else value = default_value; - traceit("%s = [%s]\n", path, value.c_str()); + printf("%s = [%s]\n", path, value.c_str()); return true; } @@ -220,15 +220,15 @@ bool CG2_ircddb::read_config(char *cfgFile) { Config cfg; - traceit("Reading file %s\n", cfgFile); + printf("Reading file %s\n", cfgFile); // Read the file. If there is an error, report it and exit. try { cfg.readFile(cfgFile); } catch(const FileIOException &fioex) { - traceit("Can't read %s\n", cfgFile); + printf("Can't read %s\n", cfgFile); return true; } catch(const ParseException &pex) { - traceit("Parse error at %s:%d - %s\n", pex.getFile(), pex.getLine(), pex.getError()); + printf("Parse error at %s:%d - %s\n", pex.getFile(), pex.getLine(), pex.getError()); return true; } @@ -237,7 +237,7 @@ bool CG2_ircddb::read_config(char *cfgFile) OWNER = owner; ToLower(owner); ToUpper(OWNER); - traceit("OWNER=[%s]\n", OWNER.c_str()); + printf("OWNER=[%s]\n", OWNER.c_str()); OWNER.resize(CALL_SIZE, ' '); for (short int m=0; m<3; m++) { @@ -246,7 +246,7 @@ bool CG2_ircddb::read_config(char *cfgFile) std::string type; if (cfg.lookupValue(std::string(path+".type").c_str(), type)) { if (strcasecmp(type.c_str(), "dvap") && strcasecmp(type.c_str(), "dvrptr") && strcasecmp(type.c_str(), "mmdvm")) { - traceit("%s.type '%s' is invalid\n", type.c_str()); + printf("module type '%s' is invalid\n", type.c_str()); return true; } rptr.mod[m].defined = true; @@ -284,7 +284,7 @@ bool CG2_ircddb::read_config(char *cfgFile) rptr.mod[m].defined = false; } if (false==rptr.mod[0].defined && false==rptr.mod[1].defined && false==rptr.mod[2].defined) { - traceit("No repeaters defined!\n"); + printf("No repeaters defined!\n"); return true; } @@ -367,7 +367,7 @@ int CG2_ircddb::open_port(const SPORTIP &pip) int sock = socket(PF_INET, SOCK_DGRAM, 0); if (0 > sock) { - traceit("Failed to create socket on %s:%d, errno=%d\n", pip.ip.c_str(), pip.port, errno); + printf("Failed to create socket on %s:%d, errno=%d\n", pip.ip.c_str(), pip.port, errno); return -1; } fcntl(sock, F_SETFL, O_NONBLOCK); @@ -378,7 +378,7 @@ int CG2_ircddb::open_port(const SPORTIP &pip) sin.sin_addr.s_addr = inet_addr(pip.ip.c_str()); if (bind(sock, (struct sockaddr *)&sin, sizeof(struct sockaddr_in)) != 0) { - traceit("Failed to bind %s:%d, errno=%d\n", pip.ip.c_str(), pip.port, errno); + printf("Failed to bind %s:%d, errno=%d\n", pip.ip.c_str(), pip.port, errno); close(sock); return -1; } @@ -399,17 +399,17 @@ void CG2_ircddb::GetIRCDataThread() sigemptyset(&act.sa_mask); act.sa_flags = SA_RESTART; if (sigaction(SIGTERM, &act, 0) != 0) { - traceit("GetIRCDataThread: sigaction-TERM failed, error=%d\n", errno); + printf("GetIRCDataThread: sigaction-TERM failed, error=%d\n", errno); keep_running = false; return; } if (sigaction(SIGINT, &act, 0) != 0) { - traceit("GetIRCDataThread: sigaction-INT failed, error=%d\n", errno); + printf("GetIRCDataThread: sigaction-INT failed, error=%d\n", errno); keep_running = false; return; } if (sigaction(SIGPIPE, &act, 0) != 0) { - traceit("GetIRCDataThread: sigaction-PIPE failed, error=%d\n", errno); + printf("GetIRCDataThread: sigaction-PIPE failed, error=%d\n", errno); keep_running = false; return; } @@ -421,17 +421,17 @@ void CG2_ircddb::GetIRCDataThread() int rc = ii->getConnectionState(); if ((rc == 0) || (rc == 10)) { if (last_status != 0) { - traceit("irc status=%d, probable disconnect...\n", rc); + printf("irc status=%d, probable disconnect...\n", rc); last_status = 0; } } else if (rc == 7) { if (last_status != 2) { - traceit("irc status=%d, probable connect...\n", rc); + printf("irc status=%d, probable connect...\n", rc); last_status = 2; } } else { if (last_status != 1) { - traceit("irc status=%d, probable connect...\n", rc); + printf("irc status=%d, probable connect...\n", rc); last_status = 1; } } @@ -444,7 +444,7 @@ void CG2_ircddb::GetIRCDataThread() if (!user.empty()) { if (!rptr.empty() && !gateway.empty() && !ipaddr.empty()) { if (bool_irc_debug) - traceit("C-u:%s,%s,%s,%s\n", user.c_str(), rptr.c_str(), gateway.c_str(), ipaddr.c_str()); + printf("C-u:%s,%s,%s,%s\n", user.c_str(), rptr.c_str(), gateway.c_str(), ipaddr.c_str()); pthread_mutex_lock(&irc_data_mutex); @@ -454,7 +454,7 @@ void CG2_ircddb::GetIRCDataThread() pthread_mutex_unlock(&irc_data_mutex); - // traceit("%d users, %d repeaters, %d gateways\n", user2rptr_map.size(), rptr2gwy_map.size(), gwy2ip_map.size()); + // printf("%d users, %d repeaters, %d gateways\n", user2rptr_map.size(), rptr2gwy_map.size(), gwy2ip_map.size()); } } @@ -463,7 +463,7 @@ void CG2_ircddb::GetIRCDataThread() if (!rptr.empty()) { if (!gateway.empty() && !ipaddr.empty()) { if (bool_irc_debug) - traceit("C-r:%s,%s,%s\n", rptr.c_str(), gateway.c_str(), ipaddr.c_str()); + printf("C-r:%s,%s,%s\n", rptr.c_str(), gateway.c_str(), ipaddr.c_str()); pthread_mutex_lock(&irc_data_mutex); @@ -472,7 +472,7 @@ void CG2_ircddb::GetIRCDataThread() pthread_mutex_unlock(&irc_data_mutex); - // traceit("%d repeaters, %d gateways\n", rptr2gwy_map.size(), gwy2ip_map.size()); + // printf("%d repeaters, %d gateways\n", rptr2gwy_map.size(), gwy2ip_map.size()); } } @@ -480,7 +480,7 @@ void CG2_ircddb::GetIRCDataThread() ii->receiveGateway(gateway, ipaddr, proto); if (!gateway.empty() && !ipaddr.empty()) { if (bool_irc_debug) - traceit("C-g:%s,%s\n", gateway.c_str(),ipaddr.c_str()); + printf("C-g:%s,%s\n", gateway.c_str(),ipaddr.c_str()); pthread_mutex_lock(&irc_data_mutex); @@ -488,14 +488,14 @@ void CG2_ircddb::GetIRCDataThread() pthread_mutex_unlock(&irc_data_mutex); - // traceit("%d gateways\n", gwy2ip_map.size()); + // printf("%d gateways\n", gwy2ip_map.size()); } } } std::this_thread::sleep_for(std::chrono::milliseconds(500)); } - traceit("GetIRCDataThread exiting...\n"); + printf("GetIRCDataThread exiting...\n"); return; } @@ -522,12 +522,12 @@ int CG2_ircddb::get_yrcall_rptr_from_cache(char *call, char *arearp_cs, char *zo memcpy(arearp_cs, call, 7); *mod = call[7]; } else { - traceit("Invalid specification %c for RoU\n", RoU); + printf("Invalid specification %c for RoU\n", RoU); return 2; } if ((*mod != 'A') && (*mod != 'B') && (*mod != 'C')) { - traceit("Invalid module %c\n", *mod); + printf("Invalid module %c\n", *mod); return 2; } @@ -546,11 +546,11 @@ int CG2_ircddb::get_yrcall_rptr_from_cache(char *call, char *arearp_cs, char *zo ip[IP_SIZE] = '\0'; return 0; } else { - /* traceit("Could not find IP for Gateway %s\n", zonerp_cs); */ + /* printf("Could not find IP for Gateway %s\n", zonerp_cs); */ return 1; } } else { - /* traceit("Could not find Gateway for repeater %s\n", temp); */ + /* printf("Could not find Gateway for repeater %s\n", temp); */ return 1; } @@ -570,27 +570,27 @@ bool CG2_ircddb::get_yrcall_rptr(char *call, char *arearp_cs, char *zonerp_cs, c /* at this point, the data is not in cache */ /* report the irc status */ int status = ii->getConnectionState(); - // traceit("irc status=%d\n", status); + // printf("irc status=%d\n", status); if (status != 7) { - traceit("Remote irc database not ready, irc status is not 7, try again\n"); + printf("Remote irc database not ready, irc status is not 7, try again\n"); return false; } /* request data from irc server */ if (RoU == 'U') { - traceit("User [%s] not in local cache, try again\n", call); + printf("User [%s] not in local cache, try again\n", call); /*** YRCALL=KJ4NHFBL ***/ if (((call[6] == 'A') || (call[6] == 'B') || (call[6] == 'C')) && (call[7] == 'L')) - traceit("If this was a gateway link request, that is ok\n"); + printf("If this was a gateway link request, that is ok\n"); if (!ii->findUser(call)) { - traceit("findUser(%s): Network error\n", call); + printf("findUser(%s): Network error\n", call); return false; } } else if (RoU == 'R') { - traceit("Repeater [%s] not in local cache, try again\n", call); + printf("Repeater [%s] not in local cache, try again\n", call); if (!ii->findRepeater(call)) { - traceit("findRepeater(%s): Network error\n", call); + printf("findRepeater(%s): Network error\n", call); return false; } } @@ -635,27 +635,27 @@ void CG2_ircddb::process() max_nfds = g2_sock; if (srv_sock > max_nfds) max_nfds = srv_sock; - traceit("g2=%d, srv=%d, MAX+1=%d\n", g2_sock, srv_sock, max_nfds + 1); + printf("g2=%d, srv=%d, MAX+1=%d\n", g2_sock, srv_sock, max_nfds + 1); /* start the beacon thread */ if (bool_send_aprs) { try { aprs_future = std::async(std::launch::async, &CG2_ircddb::APRSBeaconThread, this); } catch (const std::exception &e) { - traceit("Failed to start the APRSBeaconThread. Exception: %s\n", e.what()); + printf("Failed to start the APRSBeaconThread. Exception: %s\n", e.what()); } if (aprs_future.valid()) - traceit("APRS beacon thread started\n"); + printf("APRS beacon thread started\n"); } try { irc_data_future = std::async(std::launch::async, &CG2_ircddb::GetIRCDataThread, this); } catch (const std::exception &e) { - traceit("Failed to start GetIRCDataThread. Exception: %s\n", e.what()); + printf("Failed to start GetIRCDataThread. Exception: %s\n", e.what()); keep_running = false; } if (keep_running) - traceit("get_irc_data thread started\n"); + printf("get_irc_data thread started\n"); ii->kickWatchdog(IRCDDB_VERSION); @@ -665,20 +665,20 @@ void CG2_ircddb::process() if (recd[i].last_time != 0) { time(&t_now); if ((t_now - recd[i].last_time) > echotest_rec_timeout) { - traceit("Inactivity on echotest recording mod %d, removing stream id=%04x\n", + printf("Inactivity on echotest recording mod %d, removing stream id=%04x\n", i, recd[i].streamid); recd[i].streamid = 0; recd[i].last_time = 0; close(recd[i].fd); recd[i].fd = -1; - // traceit("Closed echotest audio file:[%s]\n", recd[i].file); + // printf("Closed echotest audio file:[%s]\n", recd[i].file); /* START: echotest thread setup */ try { std::async(std::launch::async, &CG2_ircddb::PlayFileThread, this, recd[i].file); } catch (const std::exception &e) { - traceit("Failed to start echotest thread. Exception: %s\n", e.what()); + printf("Failed to start echotest thread. Exception: %s\n", e.what()); // when the echotest thread runs, it deletes the file, // Because the echotest thread did NOT start, we delete the file here unlink(recd[i].file); @@ -691,14 +691,14 @@ void CG2_ircddb::process() if (vm[i].last_time != 0) { time(&t_now); if ((t_now - vm[i].last_time) > voicemail_rec_timeout) { - traceit("Inactivity on voicemail recording mod %d, removing stream id=%04x\n", + printf("Inactivity on voicemail recording mod %d, removing stream id=%04x\n", i, vm[i].streamid); vm[i].streamid = 0; vm[i].last_time = 0; close(vm[i].fd); vm[i].fd = -1; - // traceit("Closed voicemail audio file:[%s]\n", vm[i].file); + // printf("Closed voicemail audio file:[%s]\n", vm[i].file); } } @@ -709,7 +709,7 @@ void CG2_ircddb::process() // so we could use either FROM_LOCAL_RPTR_TIMEOUT or FROM_REMOTE_G2_TIMEOUT // but FROM_REMOTE_G2_TIMEOUT makes more sense, probably is a bigger number if ((t_now - toRptr[i].last_time) > from_remote_g2_timeout) { - traceit("Inactivity to local rptr mod index %d, removing stream id %04x\n", i, toRptr[i].streamid); + printf("Inactivity to local rptr mod index %d, removing stream id %04x\n", i, toRptr[i].streamid); // Send end_of_audio to local repeater. // Let the repeater re-initialize @@ -740,7 +740,7 @@ void CG2_ircddb::process() if ((t_now - band_txt[i].last_time) > from_local_rptr_timeout) { /* This local stream never went to a remote system, so trace the timeout */ if (to_remote_g2[i].toDst4.sin_addr.s_addr == 0) - traceit("Inactivity from local rptr band %d, removing stream id %04x\n", i, band_txt[i].streamID); + printf("Inactivity from local rptr band %d, removing stream id %04x\n", i, band_txt[i].streamID); band_txt[i].streamID = 0; band_txt[i].flags[0] = band_txt[i].flags[1] = band_txt[i].flags[2] = 0x0; @@ -767,7 +767,7 @@ void CG2_ircddb::process() if (to_remote_g2[i].toDst4.sin_addr.s_addr != 0) { time(&t_now); if ((t_now - to_remote_g2[i].last_time) > from_local_rptr_timeout) { - traceit("Inactivity from local rptr mod %d, removing stream id %04x\n", + printf("Inactivity from local rptr mod %d, removing stream id %04x\n", i, to_remote_g2[i].streamid); memset(&(to_remote_g2[i].toDst4),0,sizeof(struct sockaddr_in)); @@ -793,11 +793,11 @@ void CG2_ircddb::process() // save incoming port for mobile systems if (portmap.end() == portmap.find(fromDst4.sin_addr.s_addr)) { - traceit("New g2 contact at %s on port %u\n", inet_ntoa(fromDst4.sin_addr), ntohs(fromDst4.sin_port)); + printf("New g2 contact at %s on port %u\n", inet_ntoa(fromDst4.sin_addr), ntohs(fromDst4.sin_port)); portmap[fromDst4.sin_addr.s_addr] = ntohs(fromDst4.sin_port); } else { if (ntohs(fromDst4.sin_port) != portmap[fromDst4.sin_addr.s_addr]) { - traceit("New g2 port from %s is now %u, it was %u\n", inet_ntoa(fromDst4.sin_addr), ntohs(fromDst4.sin_port), portmap[fromDst4.sin_addr.s_addr]); + printf("New g2 port from %s is now %u, it was %u\n", inet_ntoa(fromDst4.sin_addr), ntohs(fromDst4.sin_port), portmap[fromDst4.sin_addr.s_addr]); portmap[fromDst4.sin_addr.s_addr] = ntohs(fromDst4.sin_port); } } @@ -824,7 +824,7 @@ void CG2_ircddb::process() (g2buf.hdr.flag[0] == 0x28) || (g2buf.hdr.flag[0] == 0x40))) { if (bool_qso_details) - traceit("START from g2: streamID=%04x, flags=%02x:%02x:%02x, my=%.8s, sfx=%.4s, ur=%.8s, rpt1=%.8s, rpt2=%.8s, %d bytes fromIP=%s and port %u\n", + printf("START from g2: streamID=%04x, flags=%02x:%02x:%02x, my=%.8s, sfx=%.4s, ur=%.8s, rpt1=%.8s, rpt2=%.8s, %d bytes fromIP=%s and port %u\n", g2buf.streamid, g2buf.hdr.flag[0], g2buf.hdr.flag[1], g2buf.hdr.flag[2], g2buf.hdr.mycall, @@ -862,7 +862,7 @@ void CG2_ircddb::process() } else { if (g2buf.counter & 0x40) { if (bool_qso_details) - traceit("END from g2: streamID=%04x, %d bytes from IP=%s\n", g2buf.streamid, g2buflen,inet_ntoa(fromDst4.sin_addr)); + printf("END from g2: streamID=%04x, %d bytes from IP=%s\n", g2buf.streamid, g2buflen,inet_ntoa(fromDst4.sin_addr)); } /* find out which repeater module to send the data to */ @@ -917,7 +917,7 @@ void CG2_ircddb::process() if (0==memcmp(toRptr[i].saved_hdr + 14, &g2buf.streamid, 2) && toRptr[i].saved_adr==fromDst4.sin_addr.s_addr) { /* repeater module is inactive ? */ if ((toRptr[i].last_time == 0) && (band_txt[i].last_time == 0)) { - traceit("Re-generating header for streamID=%04x\n", g2buf.streamid); + printf("Re-generating header for streamID=%04x\n", g2buf.streamid); toRptr[i].saved_hdr[5] = (unsigned char)(toRptr[i].G2_COUNTER & 0xff); toRptr[i].saved_hdr[4] = (unsigned char)((toRptr[i].G2_COUNTER >> 8) & 0xff); @@ -984,7 +984,7 @@ void CG2_ircddb::process() if (recvlen == 58) { if (bool_qso_details) - traceit("START from rptr: cntr=%04x, streamID=%04x, flags=%02x:%02x:%02x, my=%.8s, sfx=%.4s, ur=%.8s, rpt1=%.8s, rpt2=%.8s, %d bytes fromIP=%s\n", + printf("START from rptr: cntr=%04x, streamID=%04x, flags=%02x:%02x:%02x, my=%.8s, sfx=%.4s, ur=%.8s, rpt1=%.8s, rpt2=%.8s, %d bytes fromIP=%s\n", rptrbuf.counter, rptrbuf.vpkt.streamid, rptrbuf.vpkt.hdr.flag[0], rptrbuf.vpkt.hdr.flag[1], rptrbuf.vpkt.hdr.flag[2], @@ -1065,12 +1065,12 @@ void CG2_ircddb::process() int mycall_valid = regexec(&preg, temp_radio_user, 0, NULL, 0); if (mycall_valid == REG_NOERROR) - ; // traceit("MYCALL [%s] passed IRC expression validation\n", temp_radio_user); + ; // printf("MYCALL [%s] passed IRC expression validation\n", temp_radio_user); else { if (mycall_valid == REG_NOMATCH) - traceit("MYCALL [%s] failed IRC expression validation\n", temp_radio_user); + printf("MYCALL [%s] failed IRC expression validation\n", temp_radio_user); else - traceit("Failed to validate MYCALL [%s], regexec error=%d\n", temp_radio_user, mycall_valid); + printf("Failed to validate MYCALL [%s], regexec error=%d\n", temp_radio_user, mycall_valid); } /* send data g2_link */ @@ -1157,11 +1157,11 @@ void CG2_ircddb::process() for (int j=0; j<5; j++) sendto(g2_sock, g2buf.title, 56, 0, (struct sockaddr *)&(to_remote_g2[i].toDst4), sizeof(struct sockaddr_in)); - traceit("Routing to IP=%s port=%u, streamID=%04x, my=%.8s, sfx=%.4s, ur=%.8s, rpt1=%.8s, rpt2=%.8s, %d bytes\n", + printf("Routing to IP=%s port=%u, streamID=%04x, my=%.8s, sfx=%.4s, ur=%.8s, rpt1=%.8s, rpt2=%.8s, %d bytes\n", inet_ntoa(to_remote_g2[i].toDst4.sin_addr), ntohs(to_remote_g2[i].toDst4.sin_port), g2buf.streamid, g2buf.hdr.mycall, g2buf.hdr.sfx, g2buf.hdr.urcall, - g2buf.hdr.rpt1, &g2buf.hdr.rpt2, + g2buf.hdr.rpt1, g2buf.hdr.rpt2, 56); time(&(to_remote_g2[i].last_time)); @@ -1234,7 +1234,7 @@ void CG2_ircddb::process() for (int j=0; j<5; j++) sendto(g2_sock, g2buf.title, 56, 0, (struct sockaddr *)&(to_remote_g2[i].toDst4), sizeof(struct sockaddr_in)); - traceit("Routing to IP=%s, port=%u, streamID=%04x, my=%.8s, sfx=%.4s, ur=%.8s, rpt1=%.8s, rpt2=%.8s, %d bytes\n", + printf("Routing to IP=%s, port=%u, streamID=%04x, my=%.8s, sfx=%.4s, ur=%.8s, rpt1=%.8s, rpt2=%.8s, %d bytes\n", inet_ntoa(to_remote_g2[i].toDst4.sin_addr), ntohs(to_remote_g2[i].toDst4.sin_port), g2buf.streamid, g2buf.hdr.mycall, g2buf.hdr.sfx, g2buf.hdr.urcall, @@ -1268,7 +1268,7 @@ void CG2_ircddb::process() band_txt[i] : local RF is talking. */ if ((toRptr[i].last_time == 0) && (band_txt[i].last_time == 0)) { - traceit("CALLmode cross-banding from mod %c to %c\n", rptrbuf.vpkt.hdr.rpt2[7], temp_mod); + printf("CALLmode cross-banding from mod %c to %c\n", rptrbuf.vpkt.hdr.rpt2[7], temp_mod); rptrbuf.vpkt.hdr.rpt1[7] = temp_mod; rptrbuf.vpkt.hdr.rpt2[7] = 'G'; @@ -1290,7 +1290,7 @@ void CG2_ircddb::process() } } } else - traceit("icom rule: no routing from %.8s to %s%c\n", rptrbuf.vpkt.hdr.rpt2, arearp_cs, temp_mod); + printf("icom rule: no routing from %.8s to %s%c\n", rptrbuf.vpkt.hdr.rpt2, arearp_cs, temp_mod); } } } @@ -1304,10 +1304,10 @@ void CG2_ircddb::process() /* voicemail file is closed */ if ((vm[i].fd == -1) && (vm[i].file[0] != '\0')) { unlink(vm[i].file); - traceit("removed voicemail file: %s\n", vm[i].file); + printf("removed voicemail file: %s\n", vm[i].file); vm[i].file[0] = '\0'; } else - traceit("No voicemail to clear or still recording\n"); + printf("No voicemail to clear or still recording\n"); } } else if ((rptrbuf.vpkt.hdr.urcall[7] == '0') && (rptrbuf.vpkt.hdr.urcall[6] == 'R') && @@ -1331,10 +1331,10 @@ void CG2_ircddb::process() try { std::async(std::launch::async, &CG2_ircddb::PlayFileThread, this, vm[i].file); } catch (const std::exception &e) { - traceit("Filed to start voicemail playback. Exception: %s\n", e.what()); + printf("Filed to start voicemail playback. Exception: %s\n", e.what()); } } else - traceit("No voicemail to recall or still recording\n"); + printf("No voicemail to recall or still recording\n"); } } else if ((rptrbuf.vpkt.hdr.urcall[7] == '0') && (rptrbuf.vpkt.hdr.urcall[6] == 'S') && @@ -1343,7 +1343,7 @@ void CG2_ircddb::process() if (i>=0 && i<3) { if (vm[i].fd >= 0) - traceit("Already recording for voicemail on mod %d\n", i); + printf("Already recording for voicemail on mod %d\n", i); else { memset(tempfile, '\0', sizeof(tempfile)); snprintf(tempfile, FILENAME_MAX, "%s/%c_%s", @@ -1355,10 +1355,10 @@ void CG2_ircddb::process() O_CREAT | O_WRONLY | O_TRUNC | O_APPEND, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); if (vm[i].fd < 0) - traceit("Failed to create file %s for voicemail\n", tempfile); + printf("Failed to create file %s for voicemail\n", tempfile); else { strcpy(vm[i].file, tempfile); - traceit("Recording mod %c for voicemail into file:[%s]\n", + printf("Recording mod %c for voicemail into file:[%s]\n", rptrbuf.vpkt.hdr.rpt2[7], vm[i].file); @@ -1396,7 +1396,7 @@ void CG2_ircddb::process() if (i>=0 && i<3) { if (recd[i].fd >= 0) - traceit("Already recording for echotest on mod %d\n", i); + printf("Already recording for echotest on mod %d\n", i); else { memset(tempfile, '\0', sizeof(tempfile)); snprintf(tempfile, FILENAME_MAX, "%s/%c_%s", echotest_dir.c_str(), @@ -1406,10 +1406,10 @@ void CG2_ircddb::process() O_CREAT | O_WRONLY | O_EXCL | O_TRUNC | O_APPEND, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); if (recd[i].fd < 0) - traceit("Failed to create file %s for echotest\n", tempfile); + printf("Failed to create file %s for echotest\n", tempfile); else { strcpy(recd[i].file, tempfile); - traceit("Recording mod %c for echotest into file:[%s]\n", + printf("Recording mod %c for echotest into file:[%s]\n", rptrbuf.vpkt.hdr.rpt2[7], recd[i].file); time(&recd[i].last_time); @@ -1468,7 +1468,7 @@ void CG2_ircddb::process() // toRptr[i] : receiving from a remote system or cross-band // band_txt[i] : local RF is talking. if ((toRptr[i].last_time == 0) && (band_txt[i].last_time == 0)) { - traceit("ZONEmode cross-banding from mod %c to %c\n", rptrbuf.vpkt.hdr.rpt2[7], rptrbuf.vpkt.hdr.rpt1[7]); + printf("ZONEmode cross-banding from mod %c to %c\n", rptrbuf.vpkt.hdr.rpt2[7], rptrbuf.vpkt.hdr.rpt1[7]); rptrbuf.vpkt.hdr.rpt2[7] = 'G'; calcPFCS(rptrbuf.pkt_id, 58); @@ -1501,13 +1501,13 @@ void CG2_ircddb::process() dtmf_file.push_back('A'+i); dtmf_file += "_mod_DTMF_NOTIFY"; if (bool_dtmf_debug) - traceit("Saving dtmfs=[%s] into file: [%s]\n", dtmf_buf[i], dtmf_file.c_str()); + printf("Saving dtmfs=[%s] into file: [%s]\n", dtmf_buf[i], dtmf_file.c_str()); FILE *dtmf_fp = fopen(dtmf_file.c_str(), "w"); if (dtmf_fp) { fprintf(dtmf_fp, "%s\n%s", dtmf_buf[i], band_txt[i].lh_mycall); fclose(dtmf_fp); } else - traceit("Failed to create dtmf file %s\n", dtmf_file.c_str()); + printf("Failed to create dtmf file %s\n", dtmf_file.c_str()); memset(dtmf_buf[i], 0, sizeof(dtmf_buf[i])); @@ -1585,13 +1585,13 @@ void CG2_ircddb::process() else memcpy(tmp_txt, rptrbuf.vpkt.vasd1.text, 3); - // traceit("%x%x%x\n", tmp_txt[0], tmp_txt[1], tmp_txt[2]); - // traceit("%c%c%c\n", tmp_txt[0] ^ 0x70, tmp_txt[1] ^ 0x4f, tmp_txt[2] ^ 0x93); + // printf("%x%x%x\n", tmp_txt[0], tmp_txt[1], tmp_txt[2]); + // printf("%c%c%c\n", tmp_txt[0] ^ 0x70, tmp_txt[1] ^ 0x4f, tmp_txt[2] ^ 0x93); /* extract 20-byte RADIO ID */ if ((tmp_txt[0] != 0x55) || (tmp_txt[1] != 0x2d) || (tmp_txt[2] != 0x16)) { - // traceit("%x%x%x\n", tmp_txt[0], tmp_txt[1], tmp_txt[2]); - // traceit("%c%c%c\n", tmp_txt[0] ^ 0x70, tmp_txt[1] ^ 0x4f, tmp_txt[2] ^ 0x93); + // printf("%x%x%x\n", tmp_txt[0], tmp_txt[1], tmp_txt[2]); + // printf("%c%c%c\n", tmp_txt[0] ^ 0x70, tmp_txt[1] ^ 0x4f, tmp_txt[2] ^ 0x93); for (int i=0; i<3; i++) { if (band_txt[i].streamID == rptrbuf.vpkt.streamid) { @@ -1616,7 +1616,7 @@ void CG2_ircddb::process() if ((to_print[i] > 1) && (to_print[i] <= 5)) { /* something went wrong? all bets are off */ if (band_txt[i].temp_line_cnt > 200) { - traceit("Reached the limit in the OLD gps mode\n"); + printf("Reached the limit in the OLD gps mode\n"); band_txt[i].temp_line[0] = '\0'; band_txt[i].temp_line_cnt = 0; } @@ -1657,7 +1657,7 @@ void CG2_ircddb::process() } else { /* something went wrong? all bets are off */ if (band_txt[i].temp_line_cnt > 200) { - traceit("Reached the limit in the OLD gps mode\n"); + printf("Reached the limit in the OLD gps mode\n"); band_txt[i].temp_line[0] = '\0'; band_txt[i].temp_line_cnt = 0; } @@ -1729,7 +1729,7 @@ void CG2_ircddb::process() band_txt[i].dest_rptr, band_txt[i].txt); ***/ - // traceit("TEXT1=[%s]\n", band_txt[i].txt); + // printf("TEXT1=[%s]\n", band_txt[i].txt); band_txt[i].txt_cnt = 0; } } else { @@ -1786,7 +1786,7 @@ void CG2_ircddb::process() band_txt[i].flags[2], band_txt[i].dest_rptr, band_txt[i].txt); - // traceit("TEXT2=[%s], destination repeater=[%s]\n", band_txt[i].txt, band_txt[i].dest_rptr); + // printf("TEXT2=[%s], destination repeater=[%s]\n", band_txt[i].txt, band_txt[i].dest_rptr); band_txt[i].txt_stats_sent = true; } band_txt[i].txt_cnt = 0; @@ -1796,7 +1796,7 @@ void CG2_ircddb::process() } else { /* something went wrong? all bets are off */ if (band_txt[i].temp_line_cnt > 200) { - traceit("Reached the limit in the OLD gps mode\n"); + printf("Reached the limit in the OLD gps mode\n"); band_txt[i].temp_line[0] = '\0'; band_txt[i].temp_line_cnt = 0; } @@ -1841,7 +1841,7 @@ void CG2_ircddb::process() } else if (to_print[i] == 2) { /* something went wrong? all bets are off */ if (band_txt[i].temp_line_cnt > 200) { - traceit("Reached the limit in the OLD gps mode\n"); + printf("Reached the limit in the OLD gps mode\n"); band_txt[i].temp_line[0] = '\0'; band_txt[i].temp_line_cnt = 0; } @@ -1875,7 +1875,7 @@ void CG2_ircddb::process() } else if (to_print[i] == 1) { /* something went wrong? all bets are off */ if (band_txt[i].temp_line_cnt > 200) { - traceit("Reached the limit in the OLD gps mode\n"); + printf("Reached the limit in the OLD gps mode\n"); band_txt[i].temp_line[0] = '\0'; band_txt[i].temp_line_cnt = 0; } @@ -1974,13 +1974,13 @@ void CG2_ircddb::process() recd[i].last_time = 0; close(recd[i].fd); recd[i].fd = -1; - // traceit("Closed echotest audio file:[%s]\n", recd[i].file); + // printf("Closed echotest audio file:[%s]\n", recd[i].file); /* we are in echotest mode, so play it back */ try { std::async(std::launch::async, &CG2_ircddb::PlayFileThread, this, recd[i].file); } catch (const std::exception &e) { - traceit("failed to start PlayFileThread. Exception: %s\n", e.what()); + printf("failed to start PlayFileThread. Exception: %s\n", e.what()); // When the echotest thread runs, it deletes the file, // Because the echotest thread did NOT start, we delete the file here unlink(recd[i].file); @@ -2014,7 +2014,7 @@ void CG2_ircddb::process() vm[i].last_time = 0; close(vm[i].fd); vm[i].fd = -1; - // traceit("Closed voicemail audio file:[%s]\n", vm[i].file); + // printf("Closed voicemail audio file:[%s]\n", vm[i].file); } break; } else @@ -2042,7 +2042,7 @@ void CG2_ircddb::process() if (rptrbuf.vpkt.ctrl & 0x40) { if (bool_qso_details) - traceit("END from rptr: cntr=%04x, streamID=%04x, %d bytes\n", rptrbuf.counter, rptrbuf.vpkt.streamid, recvlen); + printf("END from rptr: cntr=%04x, streamID=%04x, %d bytes\n", rptrbuf.counter, rptrbuf.vpkt.streamid, recvlen); } } } @@ -2067,7 +2067,7 @@ void CG2_ircddb::compute_aprs_hash() strcpy(rptr_sign, OWNER.c_str()); char *p = strchr(rptr_sign, ' '); if (!p) { - traceit("Failed to build repeater callsign for aprs hash\n"); + printf("Failed to build repeater callsign for aprs hash\n"); return; } *p = '\0'; @@ -2078,7 +2078,7 @@ void CG2_ircddb::compute_aprs_hash() hash ^= (*p++) << 8; hash ^= (*p++); } - traceit("aprs hash code=[%d] for %s\n", hash, OWNER.c_str()); + printf("aprs hash code=[%d] for %s\n", hash, OWNER.c_str()); rptr.aprs_hash = hash; return; @@ -2107,15 +2107,15 @@ void CG2_ircddb::APRSBeaconThread() sigemptyset(&act.sa_mask); act.sa_flags = SA_RESTART; if (sigaction(SIGTERM, &act, 0) != 0) { - traceit("APRSBeaconThread: sigaction-TERM failed, error=%d\n", errno); + printf("APRSBeaconThread: sigaction-TERM failed, error=%d\n", errno); return; } if (sigaction(SIGINT, &act, 0) != 0) { - traceit("APRSBeaconThread: sigaction-INT failed, error=%d\n", errno); + printf("APRSBeaconThread: sigaction-INT failed, error=%d\n", errno); return; } if (sigaction(SIGPIPE, &act, 0) != 0) { - traceit("APRSBeaconThread: sigaction-PIPE failed, error=%d\n", errno); + printf("APRSBeaconThread: sigaction-PIPE failed, error=%d\n", errno); return; } @@ -2172,7 +2172,7 @@ void CG2_ircddb::APRSBeaconThread() lon_s, (rptr.mod[i].longitude < 0.0) ? 'W' : 'E', (unsigned int)rptr.mod[i].range, rptr.mod[i].band.c_str(), rptr.mod[i].desc.c_str()); - // traceit("APRS Beacon =[%s]\n", snd_buf); + // printf("APRS Beacon =[%s]\n", snd_buf); strcat(snd_buf, "\r\n"); while (keep_running) { @@ -2196,18 +2196,18 @@ void CG2_ircddb::APRSBeaconThread() (errno == ENETUNREACH) || (errno == EHOSTDOWN) || (errno == ENOTCONN)) { - traceit("send_aprs_beacon: APRS_HOST closed connection,error=%d\n",errno); + printf("send_aprs_beacon: APRS_HOST closed connection,error=%d\n",errno); close(aprs->GetSock()); aprs->SetSock( -1 ); } else if (errno == EWOULDBLOCK) { std::this_thread::sleep_for(std::chrono::milliseconds(100)); } else { /* Cant do nothing about it */ - traceit("send_aprs_beacon failed, error=%d\n", errno); + printf("send_aprs_beacon failed, error=%d\n", errno); break; } } else { - // traceit("APRS beacon sent\n"); + // printf("APRS beacon sent\n"); break; } } @@ -2238,12 +2238,12 @@ void CG2_ircddb::APRSBeaconThread() (errno == ENETUNREACH) || (errno == EHOSTDOWN) || (errno == ENOTCONN)) { - traceit("send_aprs_beacon: recv error: APRS_HOST closed connection,error=%d\n",errno); + printf("send_aprs_beacon: recv error: APRS_HOST closed connection,error=%d\n",errno); close(aprs->GetSock()); aprs->SetSock( -1 ); } } else if (rc == 0) { - traceit("send_aprs_beacon: recv: APRS shutdown\n"); + printf("send_aprs_beacon: recv: APRS shutdown\n"); close(aprs->GetSock()); aprs->SetSock( -1 ); } else @@ -2260,7 +2260,7 @@ void CG2_ircddb::APRSBeaconThread() THRESHOLD_COUNTDOWN--; if (THRESHOLD_COUNTDOWN == 0) { - traceit("APRS host keepalive timeout\n"); + printf("APRS host keepalive timeout\n"); close(aprs->GetSock()); aprs->SetSock( -1 ); } @@ -2269,7 +2269,7 @@ void CG2_ircddb::APRSBeaconThread() time(&last_keepalive_time); } } - traceit("APRS beacon thread exiting...\n"); + printf("APRS beacon thread exiting...\n"); return; } @@ -2285,35 +2285,35 @@ void CG2_ircddb::PlayFileThread(char *file) sigemptyset(&act.sa_mask); act.sa_flags = SA_RESTART; if (sigaction(SIGTERM, &act, 0) != 0) { - traceit("sigaction-TERM failed, error=%d\n", errno); + printf("sigaction-TERM failed, error=%d\n", errno); return; } if (sigaction(SIGINT, &act, 0) != 0) { - traceit("sigaction-INT failed, error=%d\n", errno); + printf("sigaction-INT failed, error=%d\n", errno); return; } if (sigaction(SIGPIPE, &act, 0) != 0) { - traceit("sigaction-PIPE failed, error=%d\n", errno); + printf("sigaction-PIPE failed, error=%d\n", errno); return; } - traceit("File to playback:[%s]\n", file); + printf("File to playback:[%s]\n", file); FILE *fp = fopen(file, "rb"); if (!fp) { - traceit("Failed to open file %s\n", file); + printf("Failed to open file %s\n", file); return; } size_t nread = fread(dstar_buf, 10, 1, fp); if (nread != 1) { - traceit("Cant read first 10 bytes in %s\n", file); + printf("Cant read first 10 bytes in %s\n", file); fclose(fp); return; } if (memcmp(dstar_buf, "DVTOOL", 6) != 0) { - traceit("DVTOOL keyword not found in %s\n", file); + printf("DVTOOL keyword not found in %s\n", file); fclose(fp); return; } @@ -2325,23 +2325,23 @@ void CG2_ircddb::PlayFileThread(char *file) break; if ((rlen != 56) && (rlen != 27)) { - traceit("Expected 56 bytes or 27 bytes, found %d\n", rlen); + printf("Expected 56 bytes or 27 bytes, found %d\n", rlen); break; } nread = fread(dstar_buf, rlen, 1, fp); if (nread == 1) { if (memcmp(dstar_buf, "DSVT", 4) != 0) { - traceit("DVST keyword not found in %s\n", file); + printf("DVST keyword not found in %s\n", file); break; } if (dstar_buf[8] != 0x20) { - traceit("Not Voice type in %s\n", file); + printf("Not Voice type in %s\n", file); break; } if ((dstar_buf[4] != 0x10) && (dstar_buf[4] != 0x20)) { - traceit("Not a valid record type in %s\n",file); + printf("Not a valid record type in %s\n",file); break; } @@ -2383,7 +2383,7 @@ void CG2_ircddb::PlayFileThread(char *file) fclose(fp); if (!strstr(file, "voicemail.dat")) unlink(file); - traceit("Finished playing\n"); + printf("Finished playing\n"); return; } @@ -2413,7 +2413,7 @@ int CG2_ircddb::init(char *cfgfile) /* Used to validate MYCALL input */ int rc = regcomp(&preg, "^(([1-9][A-Z])|([A-Z][0-9])|([A-Z][A-Z][0-9]))[0-9A-Z]*[A-Z][ ]*[ A-RT-Z]$", REG_EXTENDED | REG_NOSUB); if (rc != REG_NOERROR) { - traceit("The IRC regular expression is NOT valid\n"); + printf("The IRC regular expression is NOT valid\n"); return 1; } @@ -2421,15 +2421,15 @@ int CG2_ircddb::init(char *cfgfile) sigemptyset(&act.sa_mask); act.sa_flags = SA_RESTART; if (sigaction(SIGTERM, &act, 0) != 0) { - traceit("sigaction-TERM failed, error=%d\n", errno); + printf("sigaction-TERM failed, error=%d\n", errno); return 1; } if (sigaction(SIGINT, &act, 0) != 0) { - traceit("sigaction-INT failed, error=%d\n", errno); + printf("sigaction-INT failed, error=%d\n", errno); return 1; } if (sigaction(SIGPIPE, &act, 0) != 0) { - traceit("sigaction-PIPE failed, error=%d\n", errno); + printf("sigaction-PIPE failed, error=%d\n", errno); return 1; } @@ -2443,7 +2443,7 @@ int CG2_ircddb::init(char *cfgfile) /* process configuration file */ if ( read_config(cfgfile) ) { - traceit("Failed to process config file %s\n", cfgfile); + printf("Failed to process config file %s\n", cfgfile); return 1; } @@ -2459,14 +2459,14 @@ int CG2_ircddb::init(char *cfgfile) rptr.mod[0].call += "-A"; rptr.mod[1].call += "-B"; rptr.mod[2].call += "-C"; - traceit("Repeater callsigns: [%s] [%s] [%s]\n", rptr.mod[0].call.c_str(), rptr.mod[1].call.c_str(), rptr.mod[2].call.c_str()); + printf("Repeater callsigns: [%s] [%s] [%s]\n", rptr.mod[0].call.c_str(), rptr.mod[1].call.c_str(), rptr.mod[2].call.c_str()); if (bool_send_aprs) { aprs = new CAPRS(&rptr); if (aprs) aprs->Init(); else { - traceit("aprs class init failed!\nAPRS will be turned off"); + printf("aprs class init failed!\nAPRS will be turned off"); bool_send_aprs = false; } } @@ -2475,15 +2475,15 @@ int CG2_ircddb::init(char *cfgfile) ii = new CIRCDDB(ircddb.ip, ircddb.port, owner, irc_pass, IRCDDB_VERSION, local_irc_ip); bool ok = ii->open(); if (!ok) { - traceit("irc open failed\n"); + printf("irc open failed\n"); return 1; } rc = ii->getConnectionState(); - traceit("Waiting for irc connection status of 2\n"); + printf("Waiting for irc connection status of 2\n"); i = 0; while (rc < 2) { - traceit("irc status=%d\n", rc); + printf("irc status=%d\n", rc); if (rc < 2) { i++; sleep(5); @@ -2494,7 +2494,7 @@ int CG2_ircddb::init(char *cfgfile) break; if (i > 5) { - traceit("We can not wait any longer...\n"); + printf("We can not wait any longer...\n"); break; } rc = ii->getConnectionState(); @@ -2503,14 +2503,14 @@ int CG2_ircddb::init(char *cfgfile) /* udp port 40000 must open first */ g2_sock = open_port(g2_external); if (0 > g2_sock) { - traceit("Can't open %s:%d\n", g2_external.ip.c_str(), g2_external.port); + printf("Can't open %s:%d\n", g2_external.ip.c_str(), g2_external.port); return 1; } /* Open udp INTERNAL port (default: 19000) */ srv_sock = open_port(g2_internal); if (0 > srv_sock) { - traceit("Can't open %s:%d\n", g2_internal.ip.c_str(), g2_internal.port); + printf("Can't open %s:%d\n", g2_internal.ip.c_str(), g2_internal.port); return 1; } @@ -2532,7 +2532,7 @@ int CG2_ircddb::init(char *cfgfile) if (access(vm[i].file, F_OK) != 0) memset(vm[i].file, 0, sizeof(vm[i].file)); else - traceit("Loaded voicemail file: %s for mod %d\n", vm[i].file, i); + printf("Loaded voicemail file: %s for mod %d\n", vm[i].file, i); // the repeater modules run on these ports memset(&toRptr[i],0,sizeof(toRptr[i])); @@ -2583,7 +2583,7 @@ int CG2_ircddb::init(char *cfgfile) plug.sin_port = htons(g2_link.port); plug.sin_addr.s_addr = inet_addr(g2_link.ip.c_str()); - traceit("g2_ircddb...entering processing loop\n"); + printf("g2_ircddb...entering processing loop\n"); if (bool_send_qrgs) qrgs_and_maps(); @@ -2598,18 +2598,18 @@ CG2_ircddb::~CG2_ircddb() { if (srv_sock != -1) { close(srv_sock); - traceit("Closed G2_INTERNAL_PORT\n"); + printf("Closed G2_INTERNAL_PORT\n"); } if (g2_sock != -1) { close(g2_sock); - traceit("Closed G2_EXTERNAL_PORT\n"); + printf("Closed G2_EXTERNAL_PORT\n"); } if (bool_send_aprs) { if (aprs->GetSock() != -1) { close(aprs->GetSock()); - traceit("Closed APRS\n"); + printf("Closed APRS\n"); } delete aprs; } @@ -2626,7 +2626,7 @@ CG2_ircddb::~CG2_ircddb() ii->close(); delete ii; - traceit("g2_ircddb exiting\n"); + printf("g2_ircddb exiting\n"); } bool CG2_ircddb::validate_csum(SBANDTXT &bt, bool is_gps) @@ -2636,7 +2636,7 @@ bool CG2_ircddb::validate_csum(SBANDTXT &bt, bool is_gps) char *p = strrchr(s, '*'); if (!p) { // BAD news, something went wrong - traceit("Missing asterisk before checksum in %s\n", name); + printf("Missing asterisk before checksum in %s\n", name); bt.gprmc[0] = bt.gpid[0] = '\0'; return true; } else { @@ -2644,7 +2644,7 @@ bool CG2_ircddb::validate_csum(SBANDTXT &bt, bool is_gps) // verify csum in GPRMC bool ok = verify_gps_csum(s + 1, p + 1); if (!ok) { - traceit("csum in %s not good\n", name); + printf("csum in %s not good\n", name); bt.gprmc[0] = bt.gpid[0] = '\0'; return true; } @@ -2658,22 +2658,22 @@ void CG2_ircddb::gps_send(short int rptr_idx) static char old_mycall[CALL_SIZE + 1] = { " " }; if ((rptr_idx < 0) || (rptr_idx > 2)) { - traceit("ERROR in gps_send: rptr_idx %d is invalid\n", rptr_idx); + printf("ERROR in gps_send: rptr_idx %d is invalid\n", rptr_idx); return; } if (band_txt[rptr_idx].gprmc[0] == '\0') { band_txt[rptr_idx].gpid[0] = '\0'; - traceit("missing GPS ID\n"); + printf("missing GPS ID\n"); return; } if (band_txt[rptr_idx].gpid[0] == '\0') { band_txt[rptr_idx].gprmc[0] = '\0'; - traceit("Missing GPSRMC\n"); + printf("Missing GPSRMC\n"); return; } if (memcmp(band_txt[rptr_idx].gpid, band_txt[rptr_idx].lh_mycall, CALL_SIZE) != 0) { - traceit("MYCALL [%s] does not match first 8 characters of GPS ID [%.8s]\n", + printf("MYCALL [%s] does not match first 8 characters of GPS ID [%.8s]\n", band_txt[rptr_idx].lh_mycall, band_txt[rptr_idx].gpid); band_txt[rptr_idx].gprmc[0] = '\0'; band_txt[rptr_idx].gpid[0] = '\0'; @@ -2691,8 +2691,8 @@ void CG2_ircddb::gps_send(short int rptr_idx) if ((tnow - band_txt[rptr_idx].gps_last_time) < 31) return; - traceit("GPRMC=[%s]\n", band_txt[rptr_idx].gprmc); - traceit("GPS id=[%s]\n",band_txt[rptr_idx].gpid); + printf("GPRMC=[%s]\n", band_txt[rptr_idx].gprmc); + printf("GPS id=[%s]\n",band_txt[rptr_idx].gpid); if (validate_csum(band_txt[rptr_idx], false) || validate_csum(band_txt[rptr_idx], true)) return; @@ -2746,22 +2746,22 @@ void CG2_ircddb::build_aprs_from_gps_and_send(short int rptr_idx) if (lat_str && lat_NS) { if ((*lat_NS != 'N') && (*lat_NS != 'S')) { - traceit("Invalid North or South indicator in latitude\n"); + printf("Invalid North or South indicator in latitude\n"); return; } if (strlen(lat_str) != 9) { - traceit("Invalid latitude\n"); + printf("Invalid latitude\n"); return; } if (lat_str[4] != '.') { - traceit("Invalid latitude\n"); + printf("Invalid latitude\n"); return; } lat_str[7] = '\0'; strcat(buf, lat_str); strcat(buf, lat_NS); } else { - traceit("Invalid latitude\n"); + printf("Invalid latitude\n"); return; } /* secondary table */ @@ -2769,22 +2769,22 @@ void CG2_ircddb::build_aprs_from_gps_and_send(short int rptr_idx) if (lon_str && lon_EW) { if ((*lon_EW != 'E') && (*lon_EW != 'W')) { - traceit("Invalid East or West indicator in longitude\n"); + printf("Invalid East or West indicator in longitude\n"); return; } if (strlen(lon_str) != 10) { - traceit("Invalid longitude\n"); + printf("Invalid longitude\n"); return; } if (lon_str[5] != '.') { - traceit("Invalid longitude\n"); + printf("Invalid longitude\n"); return; } lon_str[8] = '\0'; strcat(buf, lon_str); strcat(buf, lon_EW); } else { - traceit("Invalid longitude\n"); + printf("Invalid longitude\n"); return; } @@ -2792,18 +2792,18 @@ void CG2_ircddb::build_aprs_from_gps_and_send(short int rptr_idx) strcat(buf, "k"); strncat(buf, band_txt[rptr_idx].gpid + 13, 32); - // traceit("Built APRS from old GPS mode=[%s]\n", buf); + // printf("Built APRS from old GPS mode=[%s]\n", buf); strcat(buf, "\r\n"); if (-1 == aprs->WriteSock(buf, strlen(buf))) { if ((errno == EPIPE) || (errno == ECONNRESET) || (errno == ETIMEDOUT) || (errno == ECONNABORTED) || (errno == ESHUTDOWN) || (errno == EHOSTUNREACH) || (errno == ENETRESET) || (errno == ENETDOWN) || (errno == ENETUNREACH) || (errno == EHOSTDOWN) || (errno == ENOTCONN)) { - traceit("build_aprs_from_gps_and_send: APRS_HOST closed connection, error=%d\n", errno); + printf("build_aprs_from_gps_and_send: APRS_HOST closed connection, error=%d\n", errno); close(aprs->GetSock()); aprs->SetSock( -1 ); } else - traceit("build_aprs_from_gps_and_send: send error=%d\n", errno); + printf("build_aprs_from_gps_and_send: send error=%d\n", errno); } return; } @@ -2822,7 +2822,7 @@ bool CG2_ircddb::verify_gps_csum(char *gps_text, char *csum_text) computed_csum = computed_csum ^ ((char)c); } sprintf(computed_csum_text, "%02X", computed_csum); - // traceit("computed_csum_text=[%s]\n", computed_csum_text); + // printf("computed_csum_text=[%s]\n", computed_csum_text); char *p = strchr(csum_text, ' '); if (p) @@ -2836,14 +2836,14 @@ bool CG2_ircddb::verify_gps_csum(char *gps_text, char *csum_text) int main(int argc, char **argv) { - traceit("VERSION %s\n", IRCDDB_VERSION); + printf("VERSION %s\n", IRCDDB_VERSION); if (argc != 2) { - traceit("Example: g2_ircddb g2_ircddb.cfg\n"); + printf("Example: g2_ircddb g2_ircddb.cfg\n"); return 1; } CG2_ircddb g2; if (g2.init(argv[1])) return 1; g2.process(); - traceit("Leaving processing loop...\n"); + printf("Leaving processing loop...\n"); }