2023-11-20 Fred Gleason <fredg@paravelsystems.com>

* Fixed a bug in ripcd(8) that caused memory to be leaked when
	processing RMLs.

Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
Fred Gleason
2023-11-20 14:35:36 -05:00
parent 8dcb7a6099
commit 9f2495d4ec
2 changed files with 269 additions and 267 deletions

View File

@@ -20991,3 +20991,6 @@
RPM package. RPM package.
2023-03-17 Fred Gleason <fredg@paravelsystems.com> 2023-03-17 Fred Gleason <fredg@paravelsystems.com>
* Updated the copyright notices to use an interval of 2002-2023. * Updated the copyright notices to use an interval of 2002-2023.
2023-11-20 Fred Gleason <fredg@paravelsystems.com>
* Fixed a bug in ripcd(8) that caused memory to be leaked when
processing RMLs.

View File

@@ -254,131 +254,130 @@ void MainObject::RunLocalMacros(RDMacro *rml_in)
(const char *)rml_in->toString().toUtf8(), (const char *)rml_in->toString().toUtf8(),
(const char *)rml_in->address().toString().toUtf8()); (const char *)rml_in->address().toString().toUtf8());
RDMacro *rml=new RDMacro(); RDMacro rml=ForwardConvert(*rml_in);
*rml=ForwardConvert(*rml_in);
switch(rml->command()) { switch(rml.command()) {
case RDMacro::BO: case RDMacro::BO:
tty_port=rml->arg(0).toInt(); tty_port=rml.arg(0).toInt();
if((tty_port<0)||(tty_port>MAX_TTYS)) { if((tty_port<0)||(tty_port>MAX_TTYS)) {
if(rml->echoRequested()) { if(rml.echoRequested()) {
rml->acknowledge(false); rml.acknowledge(false);
sendRml(rml); sendRml(&rml);
return; return;
} }
} }
if(ripcd_tty_dev[tty_port]==NULL) { if(ripcd_tty_dev[tty_port]==NULL) {
rml->acknowledge(false); rml.acknowledge(false);
sendRml(rml); sendRml(&rml);
return; return;
} }
for(int i=1;i<(rml->argQuantity());i++) { for(int i=1;i<(rml.argQuantity());i++) {
sscanf((const char *)rml->arg(i),"%x",&d); sscanf((const char *)rml.arg(i),"%x",&d);
bin_buf[i-1]=0xFF&d; bin_buf[i-1]=0xFF&d;
} }
ripcd_tty_dev[tty_port]->write(bin_buf,rml->argQuantity()-1); ripcd_tty_dev[tty_port]->write(bin_buf,rml.argQuantity()-1);
rml->acknowledge(true); rml.acknowledge(true);
sendRml(rml); sendRml(&rml);
return; return;
break; break;
case RDMacro::GI: case RDMacro::GI:
if(rml->argQuantity()!=5) { if(rml.argQuantity()!=5) {
if(rml->echoRequested()) { if(rml.echoRequested()) {
rml->acknowledge(false); rml.acknowledge(false);
sendRml(rml); sendRml(&rml);
} }
return; return;
} }
matrix_num=rml->arg(0).toInt(); matrix_num=rml.arg(0).toInt();
if(rml->arg(1).lower()=="i") { if(rml.arg(1).lower()=="i") {
gpio_type=RDMatrix::GpioInput; gpio_type=RDMatrix::GpioInput;
} }
else { else {
if(rml->arg(1).lower()=="o") { if(rml.arg(1).lower()=="o") {
gpio_type=RDMatrix::GpioOutput; gpio_type=RDMatrix::GpioOutput;
} }
else { else {
if(rml->echoRequested()) { if(rml.echoRequested()) {
rml->acknowledge(false); rml.acknowledge(false);
sendRml(rml); sendRml(&rml);
} }
return; return;
} }
} }
gpi=rml->arg(2).toInt()-1; gpi=rml.arg(2).toInt()-1;
if((ripcd_switcher[matrix_num]==NULL)|| if((ripcd_switcher[matrix_num]==NULL)||
(gpi>(MAX_GPIO_PINS-1))|| (gpi>(MAX_GPIO_PINS-1))||
(gpi<0)|| (gpi<0)||
(rml->arg(3).toInt()<0)||(rml->arg(3).toInt()>1)|| (rml.arg(3).toInt()<0)||(rml.arg(3).toInt()>1)||
(rml->arg(4).toInt()<-1)||(rml->arg(4).toInt()>999999)) { (rml.arg(4).toInt()<-1)||(rml.arg(4).toInt()>999999)) {
if(rml->echoRequested()) { if(rml.echoRequested()) {
rml->acknowledge(false); rml.acknowledge(false);
sendRml(rml); sendRml(&rml);
} }
return; return;
} }
switch(gpio_type) { switch(gpio_type) {
case RDMatrix::GpioInput: case RDMatrix::GpioInput:
ripcd_gpi_macro[matrix_num][gpi][rml->arg(3).toInt()]= ripcd_gpi_macro[matrix_num][gpi][rml.arg(3).toInt()]=
rml->arg(4).toInt(); rml.arg(4).toInt();
BroadcastCommand(QString().sprintf("GC %d %d %d %d!",matrix_num,gpi, BroadcastCommand(QString().sprintf("GC %d %d %d %d!",matrix_num,gpi,
ripcd_gpi_macro[matrix_num][gpi][0], ripcd_gpi_macro[matrix_num][gpi][0],
ripcd_gpi_macro[matrix_num][gpi][1])); ripcd_gpi_macro[matrix_num][gpi][1]));
break; break;
case RDMatrix::GpioOutput: case RDMatrix::GpioOutput:
ripcd_gpo_macro[matrix_num][gpi][rml->arg(3).toInt()]= ripcd_gpo_macro[matrix_num][gpi][rml.arg(3).toInt()]=
rml->arg(4).toInt(); rml.arg(4).toInt();
BroadcastCommand(QString().sprintf("GD %d %d %d %d!",matrix_num,gpi, BroadcastCommand(QString().sprintf("GD %d %d %d %d!",matrix_num,gpi,
ripcd_gpo_macro[matrix_num][gpi][0], ripcd_gpo_macro[matrix_num][gpi][0],
ripcd_gpo_macro[matrix_num][gpi][1])); ripcd_gpo_macro[matrix_num][gpi][1]));
break; break;
} }
if(rml->echoRequested()) { if(rml.echoRequested()) {
rml->acknowledge(true); rml.acknowledge(true);
sendRml(rml); sendRml(&rml);
} }
break; break;
case RDMacro::GE: case RDMacro::GE:
if(rml->argQuantity()!=4) { if(rml.argQuantity()!=4) {
if(rml->echoRequested()) { if(rml.echoRequested()) {
rml->acknowledge(false); rml.acknowledge(false);
sendRml(rml); sendRml(&rml);
} }
return; return;
} }
matrix_num=rml->arg(0).toInt(); matrix_num=rml.arg(0).toInt();
if(rml->arg(1).lower()=="i") { if(rml.arg(1).lower()=="i") {
gpio_type=RDMatrix::GpioInput; gpio_type=RDMatrix::GpioInput;
} }
else { else {
if(rml->arg(1).lower()=="o") { if(rml.arg(1).lower()=="o") {
gpio_type=RDMatrix::GpioOutput; gpio_type=RDMatrix::GpioOutput;
} }
else { else {
if(rml->echoRequested()) { if(rml.echoRequested()) {
rml->acknowledge(false); rml.acknowledge(false);
sendRml(rml); sendRml(&rml);
} }
return; return;
} }
} }
gpi=rml->arg(2).toInt()-1; gpi=rml.arg(2).toInt()-1;
if((ripcd_switcher[matrix_num]==NULL)|| if((ripcd_switcher[matrix_num]==NULL)||
(gpi>(MAX_GPIO_PINS-1))|| (gpi>(MAX_GPIO_PINS-1))||
(gpi<0)|| (gpi<0)||
(rml->arg(3).toInt()<0)||(rml->arg(3).toInt()>1)) { (rml.arg(3).toInt()<0)||(rml.arg(3).toInt()>1)) {
if(rml->echoRequested()) { if(rml.echoRequested()) {
rml->acknowledge(false); rml.acknowledge(false);
sendRml(rml); sendRml(&rml);
} }
return; return;
} }
switch(gpio_type) { switch(gpio_type) {
case RDMatrix::GpioInput: case RDMatrix::GpioInput:
if(rml->arg(3).toInt()==1) { if(rml.arg(3).toInt()==1) {
ripcd_gpi_mask[matrix_num][gpi]=true; ripcd_gpi_mask[matrix_num][gpi]=true;
BroadcastCommand(QString().sprintf("GM %d %d 1!",matrix_num,gpi)); BroadcastCommand(QString().sprintf("GM %d %d 1!",matrix_num,gpi));
} }
@@ -389,7 +388,7 @@ void MainObject::RunLocalMacros(RDMacro *rml_in)
break; break;
case RDMatrix::GpioOutput: case RDMatrix::GpioOutput:
if(rml->arg(3).toInt()==1) { if(rml.arg(3).toInt()==1) {
ripcd_gpo_mask[matrix_num][gpi]=true; ripcd_gpo_mask[matrix_num][gpi]=true;
BroadcastCommand(QString().sprintf("GN %d %d 1!",matrix_num,gpi)); BroadcastCommand(QString().sprintf("GN %d %d 1!",matrix_num,gpi));
} }
@@ -399,108 +398,108 @@ void MainObject::RunLocalMacros(RDMacro *rml_in)
} }
break; break;
} }
if(rml->echoRequested()) { if(rml.echoRequested()) {
rml->acknowledge(true); rml.acknowledge(true);
sendRml(rml); sendRml(&rml);
} }
break; break;
case RDMacro::JC: case RDMacro::JC:
#ifdef JACK #ifdef JACK
if(rml->argQuantity()!=2) { if(rml.argQuantity()!=2) {
if(rml->echoRequested()) { if(rml.echoRequested()) {
rml->acknowledge(false); rml.acknowledge(false);
sendRml(rml); sendRml(&rml);
} }
return; return;
} }
if(ripcd_jack_client!=NULL) { if(ripcd_jack_client!=NULL) {
if((err=jack_connect(ripcd_jack_client,rml->arg(1).toUtf8(), if((err=jack_connect(ripcd_jack_client,rml.arg(1).toUtf8(),
rml->arg(0).toUtf8()))==0) { rml.arg(0).toUtf8()))==0) {
rda->syslog(LOG_DEBUG, rda->syslog(LOG_DEBUG,
"executed JACK port connection \"%s %s\"", "executed JACK port connection \"%s %s\"",
(const char *)rml->arg(0).toUtf8(), (const char *)rml.arg(0).toUtf8(),
(const char *)rml->arg(1).toUtf8()); (const char *)rml.arg(1).toUtf8());
} }
else { else {
if(err!=EEXIST) { if(err!=EEXIST) {
rda->syslog(LOG_WARNING, rda->syslog(LOG_WARNING,
"JACK port connection \"%s %s\" failed, err: %d", "JACK port connection \"%s %s\" failed, err: %d",
(const char *)rml->arg(0).toUtf8(), (const char *)rml.arg(0).toUtf8(),
(const char *)rml->arg(1).toUtf8(), (const char *)rml.arg(1).toUtf8(),
err); err);
} }
} }
} }
else { else {
if(rml->echoRequested()) { if(rml.echoRequested()) {
rml->acknowledge(false); rml.acknowledge(false);
sendRml(rml); sendRml(&rml);
} }
return; return;
} }
if(rml->echoRequested()) { if(rml.echoRequested()) {
rml->acknowledge(true); rml.acknowledge(true);
sendRml(rml); sendRml(&rml);
} }
#else #else
if(rml->echoRequested()) { if(rml.echoRequested()) {
rml->acknowledge(false); rml.acknowledge(false);
sendRml(rml); sendRml(&rml);
} }
#endif // JACK #endif // JACK
break; break;
case RDMacro::JD: case RDMacro::JD:
#ifdef JACK #ifdef JACK
if(rml->argQuantity()!=2) { if(rml.argQuantity()!=2) {
if(rml->echoRequested()) { if(rml.echoRequested()) {
rml->acknowledge(false); rml.acknowledge(false);
sendRml(rml); sendRml(&rml);
} }
return; return;
} }
if(ripcd_jack_client!=NULL) { if(ripcd_jack_client!=NULL) {
if((err=jack_disconnect(ripcd_jack_client,rml->arg(1).toUtf8(), if((err=jack_disconnect(ripcd_jack_client,rml.arg(1).toUtf8(),
rml->arg(0).toUtf8()))==0) { rml.arg(0).toUtf8()))==0) {
rda->syslog(LOG_DEBUG, rda->syslog(LOG_DEBUG,
"executed JACK port disconnection \"%s %s\"", "executed JACK port disconnection \"%s %s\"",
(const char *)rml->arg(0).toUtf8(), (const char *)rml.arg(0).toUtf8(),
(const char *)rml->arg(1).toUtf8()); (const char *)rml.arg(1).toUtf8());
} }
else { else {
rda->syslog(LOG_WARNING, rda->syslog(LOG_WARNING,
"JACK port disconnection \"%s %s\" failed, err: %d", "JACK port disconnection \"%s %s\" failed, err: %d",
(const char *)rml->arg(0).toUtf8(), (const char *)rml.arg(0).toUtf8(),
(const char *)rml->arg(1).toUtf8(), (const char *)rml.arg(1).toUtf8(),
err); err);
} }
} }
else { else {
if(rml->echoRequested()) { if(rml.echoRequested()) {
rml->acknowledge(false); rml.acknowledge(false);
sendRml(rml); sendRml(&rml);
} }
return; return;
} }
if(rml->echoRequested()) { if(rml.echoRequested()) {
rml->acknowledge(true); rml.acknowledge(true);
sendRml(rml); sendRml(&rml);
} }
#else #else
if(rml->echoRequested()) { if(rml.echoRequested()) {
rml->acknowledge(false); rml.acknowledge(false);
sendRml(rml); sendRml(&rml);
} }
#endif // JACK #endif // JACK
break; break;
case RDMacro::JZ: case RDMacro::JZ:
#ifdef JACK #ifdef JACK
if(rml->argQuantity()!=0) { if(rml.argQuantity()!=0) {
if(rml->echoRequested()) { if(rml.echoRequested()) {
rml->acknowledge(false); rml.acknowledge(false);
sendRml(rml); sendRml(&rml);
} }
return; return;
} }
@@ -533,70 +532,70 @@ void MainObject::RunLocalMacros(RDMacro *rml_in)
i++; i++;
} }
} }
if(rml->echoRequested()) { if(rml.echoRequested()) {
rml->acknowledge(true); rml.acknowledge(true);
sendRml(rml); sendRml(&rml);
} }
} }
#else #else
if(rml->echoRequested()) { if(rml.echoRequested()) {
rml->acknowledge(false); rml.acknowledge(false);
sendRml(rml); sendRml(&rml);
} }
#endif // JACK #endif // JACK
break; break;
case RDMacro::LO: case RDMacro::LO:
if(rml->argQuantity()>2) { if(rml.argQuantity()>2) {
if(rml->echoRequested()) { if(rml.echoRequested()) {
rml->acknowledge(false); rml.acknowledge(false);
sendRml(rml); sendRml(&rml);
} }
return; return;
} }
if(rml->argQuantity()==0) { if(rml.argQuantity()==0) {
rduser=new RDUser(rda->station()->defaultName()); rduser=new RDUser(rda->station()->defaultName());
} }
else { else {
rduser=new RDUser(rml->arg(0)); rduser=new RDUser(rml.arg(0));
if(!rduser->exists()) { if(!rduser->exists()) {
if(rml->echoRequested()) { if(rml.echoRequested()) {
rml->acknowledge(false); rml.acknowledge(false);
sendRml(rml); sendRml(&rml);
} }
delete rduser; delete rduser;
return; return;
} }
if(!rduser->checkPassword(rml->arg(1),false)) { if(!rduser->checkPassword(rml.arg(1),false)) {
if(rml->echoRequested()) { if(rml.echoRequested()) {
rml->acknowledge(false); rml.acknowledge(false);
sendRml(rml); sendRml(&rml);
} }
delete rduser; delete rduser;
return; return;
} }
} }
SetUser(rduser->name()); SetUser(rduser->name());
if(rml->echoRequested()) { if(rml.echoRequested()) {
rml->acknowledge(true); rml.acknowledge(true);
sendRml(rml); sendRml(&rml);
} }
delete rduser; delete rduser;
break; break;
case RDMacro::MB: case RDMacro::MB:
if(rml->argQuantity()<3) { if(rml.argQuantity()<3) {
if(rml->echoRequested()) { if(rml.echoRequested()) {
rml->acknowledge(false); rml.acknowledge(false);
sendRml(rml); sendRml(&rml);
} }
return; return;
} }
severity=rml->arg(1).toInt(); severity=rml.arg(1).toInt();
if((severity<1)||(severity>3)) { if((severity<1)||(severity>3)) {
if(rml->echoRequested()) { if(rml.echoRequested()) {
rml->acknowledge(false); rml.acknowledge(false);
sendRml(rml); sendRml(&rml);
} }
return; return;
} }
@@ -605,165 +604,165 @@ void MainObject::RunLocalMacros(RDMacro *rml_in)
if(setegid(rda->config()->gid())<0) { if(setegid(rda->config()->gid())<0) {
rda->syslog(LOG_WARNING,"unable to set group id %d for RDPopup", rda->syslog(LOG_WARNING,"unable to set group id %d for RDPopup",
rda->config()->gid()); rda->config()->gid());
if(rml->echoRequested()) { if(rml.echoRequested()) {
rml->acknowledge(false); rml.acknowledge(false);
sendRml(rml); sendRml(&rml);
} }
} }
if(seteuid(rda->config()->uid())<0) { if(seteuid(rda->config()->uid())<0) {
rda->syslog(LOG_WARNING,"unable to set user id %d for RDPopup", rda->syslog(LOG_WARNING,"unable to set user id %d for RDPopup",
rda->config()->uid()); rda->config()->uid());
if(rml->echoRequested()) { if(rml.echoRequested()) {
rml->acknowledge(false); rml.acknowledge(false);
sendRml(rml); sendRml(&rml);
} }
} }
} }
if(system(QString(). if(system(QString().
sprintf("rdpopup -display %s %s %s", sprintf("rdpopup -display %s %s %s",
(const char *)rml->arg(0), (const char *)rml.arg(0),
(const char *)rml->arg(1), (const char *)rml.arg(1),
(const char *)RDEscapeString(rml->rollupArgs(2))))<0) { (const char *)RDEscapeString(rml.rollupArgs(2))))<0) {
rda->syslog(LOG_WARNING,"RDPopup returned an error"); rda->syslog(LOG_WARNING,"RDPopup returned an error");
} }
exit(0); exit(0);
} }
if(rml->echoRequested()) { if(rml.echoRequested()) {
rml->acknowledge(true); rml.acknowledge(true);
sendRml(rml); sendRml(&rml);
} }
break; break;
case RDMacro::MT: case RDMacro::MT:
if(rml->argQuantity()!=3) { if(rml.argQuantity()!=3) {
if(rml->echoRequested()) { if(rml.echoRequested()) {
rml->acknowledge(false); rml.acknowledge(false);
sendRml(rml); sendRml(&rml);
} }
return; return;
} }
if((rml->arg(0).toUInt()==0)|| if((rml.arg(0).toUInt()==0)||
(rml->arg(0).toUInt()>RD_MAX_MACRO_TIMERS)|| (rml.arg(0).toUInt()>RD_MAX_MACRO_TIMERS)||
(rml->arg(2).toUInt()>999999)) { (rml.arg(2).toUInt()>999999)) {
if(rml->echoRequested()) { if(rml.echoRequested()) {
rml->acknowledge(false); rml.acknowledge(false);
sendRml(rml); sendRml(&rml);
} }
return; return;
} }
if((rml->arg(1).toUInt()==0)|| if((rml.arg(1).toUInt()==0)||
(rml->arg(2).toUInt()==0)) { (rml.arg(2).toUInt()==0)) {
ripc_macro_cart[rml->arg(0).toUInt()-1]=0; ripc_macro_cart[rml.arg(0).toUInt()-1]=0;
ripc_macro_timer[rml->arg(0).toUInt()-1]->stop(); ripc_macro_timer[rml.arg(0).toUInt()-1]->stop();
if(rml->echoRequested()) { if(rml.echoRequested()) {
rml->acknowledge(true); rml.acknowledge(true);
sendRml(rml); sendRml(&rml);
} }
return; return;
} }
ripc_macro_cart[rml->arg(0).toUInt()-1]=rml->arg(2).toUInt(); ripc_macro_cart[rml.arg(0).toUInt()-1]=rml.arg(2).toUInt();
ripc_macro_timer[rml->arg(0).toUInt()-1]->stop(); ripc_macro_timer[rml.arg(0).toUInt()-1]->stop();
ripc_macro_timer[rml->arg(0).toUInt()-1]-> ripc_macro_timer[rml.arg(0).toUInt()-1]->
start(rml->arg(1).toInt(),true); start(rml.arg(1).toInt(),true);
if(rml->echoRequested()) { if(rml.echoRequested()) {
rml->acknowledge(true); rml.acknowledge(true);
sendRml(rml); sendRml(&rml);
} }
return; return;
case RDMacro::RN: case RDMacro::RN:
if(rml->argQuantity()<1) { if(rml.argQuantity()<1) {
if(rml->echoRequested()) { if(rml.echoRequested()) {
rml->acknowledge(false); rml.acknowledge(false);
sendRml(rml); sendRml(&rml);
} }
return; return;
} }
for(int i=0;i<rml->argQuantity();i++) { for(int i=0;i<rml.argQuantity();i++) {
cmd+=rml->arg(i)+" "; cmd+=rml.arg(i)+" ";
} }
RunCommand(rda->config()->rnRmlUid(),rda->config()->rnRmlGid(), RunCommand(rda->config()->rnRmlUid(),rda->config()->rnRmlGid(),
cmd.trimmed()); cmd.trimmed());
if(rml->echoRequested()) { if(rml.echoRequested()) {
rml->acknowledge(true); rml.acknowledge(true);
sendRml(rml); sendRml(&rml);
} }
break; break;
case RDMacro::SI: case RDMacro::SI:
tty_port=rml->arg(0).toInt(); tty_port=rml.arg(0).toInt();
if((tty_port<0)||(tty_port>MAX_TTYS)||(rml->argQuantity()!=3)) { if((tty_port<0)||(tty_port>MAX_TTYS)||(rml.argQuantity()!=3)) {
if(rml->echoRequested()) { if(rml.echoRequested()) {
rml->acknowledge(false); rml.acknowledge(false);
sendRml(rml); sendRml(&rml);
} }
return; return;
} }
if(ripcd_tty_dev[tty_port]==NULL) { if(ripcd_tty_dev[tty_port]==NULL) {
rml->acknowledge(false); rml.acknowledge(false);
sendRml(rml); sendRml(&rml);
return; return;
} }
for(int i=2;i<(rml->argQuantity()-1);i++) { for(int i=2;i<(rml.argQuantity()-1);i++) {
str+=(rml->arg(i)+" "); str+=(rml.arg(i)+" ");
} }
str+=rml->arg(rml->argQuantity()-1); str+=rml.arg(rml.argQuantity()-1);
ripcd_tty_trap[tty_port]->addTrap(rml->arg(1).toInt(), ripcd_tty_trap[tty_port]->addTrap(rml.arg(1).toInt(),
str,str.length()); str,str.length());
rda->syslog(LOG_DEBUG,"added trap \"%s\" to tty port %d", rda->syslog(LOG_DEBUG,"added trap \"%s\" to tty port %d",
(const char *)str.toUtf8(),rml->arg(1).toInt()); (const char *)str.toUtf8(),rml.arg(1).toInt());
rml->acknowledge(true); rml.acknowledge(true);
sendRml(rml); sendRml(&rml);
return; return;
break; break;
case RDMacro::SC: case RDMacro::SC:
tty_port=rml->arg(0).toInt(); tty_port=rml.arg(0).toInt();
if((tty_port<0)||(tty_port>MAX_TTYS)) { if((tty_port<0)||(tty_port>MAX_TTYS)) {
if(rml->echoRequested()) { if(rml.echoRequested()) {
rml->acknowledge(false); rml.acknowledge(false);
sendRml(rml); sendRml(&rml);
return; return;
} }
} }
if(ripcd_tty_dev[tty_port]==NULL) { if(ripcd_tty_dev[tty_port]==NULL) {
if(rml->echoRequested()) { if(rml.echoRequested()) {
rml->acknowledge(false); rml.acknowledge(false);
sendRml(rml); sendRml(&rml);
} }
return; return;
} }
switch(rml->argQuantity()) { switch(rml.argQuantity()) {
case 1: case 1:
ripcd_tty_trap[tty_port]->clear(); ripcd_tty_trap[tty_port]->clear();
if(rml->echoRequested()) { if(rml.echoRequested()) {
rml->acknowledge(true); rml.acknowledge(true);
sendRml(rml); sendRml(&rml);
} }
break; break;
case 2: case 2:
ripcd_tty_trap[tty_port]->removeTrap(rml->arg(1).toInt()); ripcd_tty_trap[tty_port]->removeTrap(rml.arg(1).toInt());
if(rml->echoRequested()) { if(rml.echoRequested()) {
rml->acknowledge(true); rml.acknowledge(true);
sendRml(rml); sendRml(&rml);
} }
break; break;
case 3: case 3:
ripcd_tty_trap[tty_port]->removeTrap(rml->arg(1).toInt(), ripcd_tty_trap[tty_port]->removeTrap(rml.arg(1).toInt(),
(const char *)rml->arg(2), (const char *)rml.arg(2),
rml->arg(2).length()); rml.arg(2).length());
if(rml->echoRequested()) { if(rml.echoRequested()) {
rml->acknowledge(true); rml.acknowledge(true);
sendRml(rml); sendRml(&rml);
} }
break; break;
default: default:
if(rml->echoRequested()) { if(rml.echoRequested()) {
rml->acknowledge(false); rml.acknowledge(false);
sendRml(rml); sendRml(&rml);
} }
return; return;
break; break;
@@ -771,23 +770,23 @@ void MainObject::RunLocalMacros(RDMacro *rml_in)
break; break;
case RDMacro::SO: case RDMacro::SO:
tty_port=rml->arg(0).toInt(); tty_port=rml.arg(0).toInt();
if((tty_port<0)||(tty_port>MAX_TTYS)) { if((tty_port<0)||(tty_port>MAX_TTYS)) {
if(rml->echoRequested()) { if(rml.echoRequested()) {
rml->acknowledge(false); rml.acknowledge(false);
sendRml(rml); sendRml(&rml);
return; return;
} }
} }
if(ripcd_tty_dev[tty_port]==NULL) { if(ripcd_tty_dev[tty_port]==NULL) {
rml->acknowledge(false); rml.acknowledge(false);
sendRml(rml); sendRml(&rml);
return; return;
} }
for(int i=1;i<(rml->argQuantity()-1);i++) { for(int i=1;i<(rml.argQuantity()-1);i++) {
str+=(rml->arg(i)+" "); str+=(rml.arg(i)+" ");
} }
str+=rml->arg(rml->argQuantity()-1); str+=rml.arg(rml.argQuantity()-1);
switch(ripcd_tty_term[tty_port]) { switch(ripcd_tty_term[tty_port]) {
case RDTty::CrTerm: case RDTty::CrTerm:
str+=QString().sprintf("\x0d"); str+=QString().sprintf("\x0d");
@@ -806,8 +805,8 @@ void MainObject::RunLocalMacros(RDMacro *rml_in)
} }
data=RDStringToData(str); data=RDStringToData(str);
ripcd_tty_dev[tty_port]->write(data); ripcd_tty_dev[tty_port]->write(data);
rml->acknowledge(true); rml.acknowledge(true);
sendRml(rml); sendRml(&rml);
return; return;
break; break;
@@ -821,29 +820,29 @@ void MainObject::RunLocalMacros(RDMacro *rml_in)
case RDMacro::SR: case RDMacro::SR:
case RDMacro::SL: case RDMacro::SL:
case RDMacro::SX: case RDMacro::SX:
if((rml->arg(0).toInt()<0)||(rml->arg(0).toInt()>=MAX_MATRICES)) { if((rml.arg(0).toInt()<0)||(rml.arg(0).toInt()>=MAX_MATRICES)) {
if(!rml->echoRequested()) { if(!rml.echoRequested()) {
rml->acknowledge(false); rml.acknowledge(false);
sendRml(rml); sendRml(&rml);
} }
return; return;
} }
if(ripcd_switcher[rml->arg(0).toInt()]==NULL) { if(ripcd_switcher[rml.arg(0).toInt()]==NULL) {
if(rml->echoRequested()) { if(rml.echoRequested()) {
rml->acknowledge(false); rml.acknowledge(false);
sendRml(rml); sendRml(&rml);
} }
} }
else { else {
ripcd_switcher[rml->arg(0).toInt()]->processCommand(rml); ripcd_switcher[rml.arg(0).toInt()]->processCommand(&rml);
} }
break; break;
case RDMacro::SY: case RDMacro::SY:
if(rml->argQuantity()!=1) { if(rml.argQuantity()!=1) {
return; return;
} }
tty_port=rml->arg(0).toInt(); tty_port=rml.arg(0).toInt();
if((tty_port<0)||(tty_port>=MAX_TTYS)) { if((tty_port<0)||(tty_port>=MAX_TTYS)) {
return; return;
} }
@@ -901,10 +900,10 @@ void MainObject::RunLocalMacros(RDMacro *rml_in)
break; break;
case RDMacro::SZ: case RDMacro::SZ:
if(rml->argQuantity()!=1) { if(rml.argQuantity()!=1) {
return; return;
} }
matrix_num=rml->arg(0).toInt(); matrix_num=rml.arg(0).toInt();
if((matrix_num<0)||(matrix_num>=MAX_MATRICES)) { if((matrix_num<0)||(matrix_num>=MAX_MATRICES)) {
return; return;
} }
@@ -932,62 +931,62 @@ void MainObject::RunLocalMacros(RDMacro *rml_in)
break; break;
case RDMacro::TA: case RDMacro::TA:
if((rml->argQuantity()!=1)|| if((rml.argQuantity()!=1)||
(rml->arg(0).toInt()<0)||(rml->arg(0).toInt()>1)) { (rml.arg(0).toInt()<0)||(rml.arg(0).toInt()>1)) {
if(rml->echoRequested()) { if(rml.echoRequested()) {
rml->acknowledge(false); rml.acknowledge(false);
sendRml(rml); sendRml(&rml);
} }
return; return;
} }
if((rml->arg(0).toInt()==0)&&ripc_onair_flag) { if((rml.arg(0).toInt()==0)&&ripc_onair_flag) {
BroadcastCommand("TA 0!"); BroadcastCommand("TA 0!");
rda->syslog(LOG_INFO,"onair flag OFF"); rda->syslog(LOG_INFO,"onair flag OFF");
} }
if((rml->arg(0).toInt()==1)&&(!ripc_onair_flag)) { if((rml.arg(0).toInt()==1)&&(!ripc_onair_flag)) {
BroadcastCommand("TA 1!"); BroadcastCommand("TA 1!");
rda->syslog(LOG_INFO,"onair flag ON"); rda->syslog(LOG_INFO,"onair flag ON");
} }
ripc_onair_flag=rml->arg(0).toInt(); ripc_onair_flag=rml.arg(0).toInt();
if(rml->echoRequested()) { if(rml.echoRequested()) {
rml->acknowledge(true); rml.acknowledge(true);
sendRml(rml); sendRml(&rml);
} }
break; break;
case RDMacro::UO: case RDMacro::UO:
if(rml->argQuantity()<3) { if(rml.argQuantity()<3) {
if(rml->echoRequested()) { if(rml.echoRequested()) {
rml->acknowledge(false); rml.acknowledge(false);
sendRml(rml); sendRml(&rml);
} }
return; return;
} }
if(!addr.setAddress(rml->arg(0))) { if(!addr.setAddress(rml.arg(0))) {
if(rml->echoRequested()) { if(rml.echoRequested()) {
rml->acknowledge(false); rml.acknowledge(false);
sendRml(rml); sendRml(&rml);
} }
return; return;
} }
if((rml->arg(1).toInt()<0)||(rml->arg(1).toInt()>0xFFFF)) { if((rml.arg(1).toInt()<0)||(rml.arg(1).toInt()>0xFFFF)) {
if(rml->echoRequested()) { if(rml.echoRequested()) {
rml->acknowledge(false); rml.acknowledge(false);
sendRml(rml); sendRml(&rml);
} }
return; return;
} }
for(int i=2;i<(rml->argQuantity()-1);i++) { for(int i=2;i<(rml.argQuantity()-1);i++) {
str+=(rml->arg(i)+" "); str+=(rml.arg(i)+" ");
} }
str+=rml->arg(rml->argQuantity()-1); str+=rml.arg(rml.argQuantity()-1);
rda->syslog(LOG_INFO,"sending \"%s\" to %s:%d",(const char *)str.toUtf8(), rda->syslog(LOG_INFO,"sending \"%s\" to %s:%d",(const char *)str.toUtf8(),
(const char *)addr.toString().toUtf8(),rml->arg(1).toInt()); (const char *)addr.toString().toUtf8(),rml.arg(1).toInt());
data=RDStringToData(str); data=RDStringToData(str);
ripcd_rml_send->writeDatagram(data,addr,(Q_UINT16)(rml->arg(1).toInt())); ripcd_rml_send->writeDatagram(data,addr,(Q_UINT16)(rml.arg(1).toInt()));
if(rml->echoRequested()) { if(rml.echoRequested()) {
rml->acknowledge(true); rml.acknowledge(true);
sendRml(rml); sendRml(&rml);
} }
break; break;