diff --git a/Makefile b/Makefile
index 230f7e0..1c05c25 100644
--- a/Makefile
+++ b/Makefile
@@ -1,14 +1,14 @@
-#
+#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
-#
+#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-#
+#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
#
@@ -29,7 +29,7 @@ IRCDDBOBJS = IRCDDB.o IRCClient.o IRCReceiver.o IRCMessageQueue.o IRCProtocol.o
all : $(PROGRAMS)
-g2_ircddb : g2_ircddb.cpp $(IRCDDBOBJS) aprs.h g2_typedefs.h versions.h
+g2_ircddb : g2_ircddb.cpp $(IRCDDBOBJS) aprs.h g2_typedefs.h versions.h g2_ircddb.h
g++ $(CPPFLAGS) -o g2_ircddb g2_ircddb.cpp $(IRCDDBOBJS) $(LDFLAGS) -pthread
g2_link : g2_link.cpp versions.h
diff --git a/aprs.cpp b/aprs.cpp
index b01c0e9..62a9704 100644
--- a/aprs.cpp
+++ b/aprs.cpp
@@ -112,7 +112,7 @@ void CAPRS::ProcessText(unsigned short streamID, unsigned char seq, unsigned cha
p = strchr(aud, '\r');
*p = '\0';
- sprintf(aprs_buf, "%s,qAR,%s:%s\r\n", hdr, rptr.mod[rptr_idx].call.c_str(), aud);
+ 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);
int rc = WriteSock(aprs_buf, strlen(aprs_buf));
if (rc == -1) {
@@ -264,15 +264,15 @@ void CAPRS::Open(const std::string OWNER)
char snd_buf[512];
char rcv_buf[512];
- bool ok = ResolveRmt(rptr.aprs.ip.c_str(), SOCK_STREAM, &aprs_addr);
+ bool ok = ResolveRmt(m_rptr->aprs.ip.c_str(), SOCK_STREAM, &aprs_addr);
if (!ok) {
- traceit("Can't resolve APRS_HOST %s\n", rptr.aprs.ip.c_str());
+ traceit("Can't resolve APRS_HOST %s\n", m_rptr->aprs.ip.c_str());
return;
}
/* fill it in */
aprs_addr.sin_family = AF_INET;
- aprs_addr.sin_port = htons(rptr.aprs.port);
+ aprs_addr.sin_port = htons(m_rptr->aprs.port);
aprs_addr_len = sizeof(aprs_addr);
@@ -339,15 +339,15 @@ void CAPRS::Open(const std::string OWNER)
return;
}
}
- traceit("Connected to APRS %s:%d\n", rptr.aprs.ip.c_str(), rptr.aprs.port);
+ traceit("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(), rptr.aprs_hash);
+ sprintf(snd_buf, "user %s pass %d vers g2_ircddb 2.99 UDP 5 ", OWNER.c_str(), m_rptr->aprs_hash);
/* add the user's filter */
- if (rptr.aprs_filter.length()) {
+ if (m_rptr->aprs_filter.length()) {
strcat(snd_buf, "filter ");
- strcat(snd_buf, rptr.aprs_filter.c_str());
+ strcat(snd_buf, m_rptr->aprs_filter.c_str());
}
// traceit("APRS login command:[%s]\n", snd_buf);
strcat(snd_buf, "\r\n");
@@ -543,3 +543,12 @@ bool CAPRS::ResolveRmt(const char *name, int type, struct sockaddr_in *addr)
freeaddrinfo(res);
return found;
}
+
+CAPRS::CAPRS(SRPTR *prptr)
+{
+ m_rptr = prptr;
+}
+
+CAPRS::~CAPRS()
+{
+}
diff --git a/aprs.h b/aprs.h
index e06dd2e..ac97c2d 100644
--- a/aprs.h
+++ b/aprs.h
@@ -51,13 +51,12 @@ typedef struct rptr_tag{
} mod[3];
} SRPTR;
-extern SRPTR rptr;
-
class CAPRS {
public:
// functions
- CAPRS() {};
- ~CAPRS() {};
+ CAPRS(SRPTR *prptr);
+ ~CAPRS();
+ SRPTR *m_rptr;
void SelectBand(short int rptr_idx, unsigned short streamID);
void ProcessText(unsigned short streamID, unsigned char seq, unsigned char *buf, unsigned int len);
ssize_t WriteSock(char *buffer, size_t n);
@@ -65,7 +64,7 @@ public:
void Init();
int GetSock();
void SetSock(int value);
-
+
private:
// data
// the aprs TCP socket
@@ -80,7 +79,7 @@ private:
slow_level sl;
bool is_sent;
} aprs_pack[3];
- // lock down a stream per band
+ // lock down a stream per band
struct {
unsigned short streamID;
time_t last_time;
diff --git a/g2_ircddb.cpp b/g2_ircddb.cpp
index 3546e5d..d88dbaa 100644
--- a/g2_ircddb.cpp
+++ b/g2_ircddb.cpp
@@ -1,7 +1,7 @@
/*
* Copyright (C) 2010 by Scott Lawson KI4LKF
*
- * Copyright 2017 by Thomas Early, N7TAE
+ * Copyright 2017-2018 by Thomas Early N7TAE
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -48,173 +48,37 @@
#include
#include
-#include
#include
#include
#include
#include
#include
#include