Skip to content
Snippets Groups Projects
Commit b4b31364 authored by rswindell's avatar rswindell
Browse files

Added error checking for getnodedat and putnodedat.

parent 72df8d3b
No related branches found
No related tags found
No related merge requests found
...@@ -83,6 +83,34 @@ void __fastcall TNodeForm::FormShow(TObject *Sender) ...@@ -83,6 +83,34 @@ void __fastcall TNodeForm::FormShow(TObject *Sender)
MainForm->ViewNodesButton->Down=true; MainForm->ViewNodesButton->Down=true;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
int __fastcall TNodeForm::getnodedat(int node_num, node_t* node, bool lockit)
{
char errmsg[128];
int err;
if((err=::getnodedat(&MainForm->cfg,node_num,node,lockit))!=0) {
sprintf(errmsg,"getnodedat returned %d",err);
Application->MessageBox(errmsg
,"ERROR",MB_OK|MB_ICONEXCLAMATION);
}
return(err);
}
//---------------------------------------------------------------------------
int __fastcall TNodeForm::putnodedat(int node_num, node_t* node)
{
char errmsg[128];
int err;
if((err=::putnodedat(&MainForm->cfg,node_num,node))!=0) {
sprintf(errmsg,"putnodedat returned %d",err);
Application->MessageBox(errmsg
,"ERROR",MB_OK|MB_ICONEXCLAMATION);
}
return(err);
}
//---------------------------------------------------------------------------
char* username(int usernumber,char *strin) char* username(int usernumber,char *strin)
{ {
...@@ -374,9 +402,11 @@ void __fastcall TNodeForm::InterruptNodeButtonClick(TObject *Sender) ...@@ -374,9 +402,11 @@ void __fastcall TNodeForm::InterruptNodeButtonClick(TObject *Sender)
for(i=0;i<ListBox->Items->Count;i++) for(i=0;i<ListBox->Items->Count;i++)
if(ListBox->Selected[i]==true) { if(ListBox->Selected[i]==true) {
getnodedat(&MainForm->cfg,i+1,&node,1); if(getnodedat(i+1,&node,true))
break;
node.misc^=NODE_INTR; node.misc^=NODE_INTR;
putnodedat(&MainForm->cfg,i+1,&node); if(putnodedat(i+1,&node))
break;
} }
TimerTick(Sender); TimerTick(Sender);
} }
...@@ -389,9 +419,11 @@ void __fastcall TNodeForm::LockNodeButtonClick(TObject *Sender) ...@@ -389,9 +419,11 @@ void __fastcall TNodeForm::LockNodeButtonClick(TObject *Sender)
for(i=0;i<ListBox->Items->Count;i++) for(i=0;i<ListBox->Items->Count;i++)
if(ListBox->Selected[i]==true) { if(ListBox->Selected[i]==true) {
getnodedat(&MainForm->cfg,i+1,&node,1); if(getnodedat(i+1,&node,true))
break;
node.misc^=NODE_LOCK; node.misc^=NODE_LOCK;
putnodedat(&MainForm->cfg,i+1,&node); if(putnodedat(i+1,&node))
break;
} }
TimerTick(Sender); TimerTick(Sender);
} }
...@@ -404,9 +436,11 @@ void __fastcall TNodeForm::RerunNodeButtonClick(TObject *Sender) ...@@ -404,9 +436,11 @@ void __fastcall TNodeForm::RerunNodeButtonClick(TObject *Sender)
for(i=0;i<ListBox->Items->Count;i++) for(i=0;i<ListBox->Items->Count;i++)
if(ListBox->Selected[i]==true) { if(ListBox->Selected[i]==true) {
getnodedat(&MainForm->cfg,i+1,&node,1); if(getnodedat(i+1,&node,true))
break;
node.misc^=NODE_RRUN; node.misc^=NODE_RRUN;
putnodedat(&MainForm->cfg,i+1,&node); if(putnodedat(i+1,&node))
break;
} }
TimerTick(Sender); TimerTick(Sender);
} }
...@@ -431,14 +465,16 @@ void __fastcall TNodeForm::DownButtonClick(TObject *Sender) ...@@ -431,14 +465,16 @@ void __fastcall TNodeForm::DownButtonClick(TObject *Sender)
for(i=0;i<ListBox->Items->Count;i++) for(i=0;i<ListBox->Items->Count;i++)
if(ListBox->Selected[i]==true) { if(ListBox->Selected[i]==true) {
getnodedat(&MainForm->cfg,i+1,&node,1); if(getnodedat(i+1,&node,true))
break;
if(node.status==NODE_WFC) if(node.status==NODE_WFC)
node.status=NODE_OFFLINE; node.status=NODE_OFFLINE;
else if(node.status==NODE_OFFLINE) else if(node.status==NODE_OFFLINE)
node.status=NODE_WFC; node.status=NODE_WFC;
else else
node.misc^=NODE_DOWN; node.misc^=NODE_DOWN;
putnodedat(&MainForm->cfg,i+1,&node); if(putnodedat(i+1,&node))
break;
} }
TimerTick(Sender); TimerTick(Sender);
} }
...@@ -451,9 +487,11 @@ void __fastcall TNodeForm::ClearErrorButtonClick(TObject *Sender) ...@@ -451,9 +487,11 @@ void __fastcall TNodeForm::ClearErrorButtonClick(TObject *Sender)
for(i=0;i<ListBox->Items->Count;i++) for(i=0;i<ListBox->Items->Count;i++)
if(ListBox->Selected[i]==true) { if(ListBox->Selected[i]==true) {
getnodedat(&MainForm->cfg,i+1,&node,1); if(getnodedat(i+1,&node,true))
break;
node.errors=0; node.errors=0;
putnodedat(&MainForm->cfg,i+1,&node); if(putnodedat(i+1,&node))
break;
} }
TimerTick(Sender); TimerTick(Sender);
} }
...@@ -468,7 +506,8 @@ void __fastcall TNodeForm::ChatButtonClick(TObject *Sender) ...@@ -468,7 +506,8 @@ void __fastcall TNodeForm::ChatButtonClick(TObject *Sender)
for(i=0;i<ListBox->Items->Count;i++) for(i=0;i<ListBox->Items->Count;i++)
if(ListBox->Selected[i]==true) { if(ListBox->Selected[i]==true) {
getnodedat(&MainForm->cfg,i+1,&node,0); if(getnodedat(i+1,&node,false))
break;
if(node.status==NODE_WFC || node.status>NODE_QUIET) if(node.status==NODE_WFC || node.status>NODE_QUIET)
continue; continue;
sprintf(str,"%sCHAT %s %s %d %s" sprintf(str,"%sCHAT %s %s %d %s"
...@@ -510,7 +549,8 @@ void __fastcall TNodeForm::UserEditButtonClick(TObject *Sender) ...@@ -510,7 +549,8 @@ void __fastcall TNodeForm::UserEditButtonClick(TObject *Sender)
for(i=0;i<ListBox->Items->Count;i++) for(i=0;i<ListBox->Items->Count;i++)
if(ListBox->Selected[i]==true) { if(ListBox->Selected[i]==true) {
getnodedat(&MainForm->cfg,i+1,&node,0); if(getnodedat(i+1,&node,false))
break;
if(node.useron==0) if(node.useron==0)
continue; continue;
sprintf(str,"%sUSEREDIT %s %d" sprintf(str,"%sUSEREDIT %s %d"
...@@ -535,7 +575,8 @@ void __fastcall TNodeForm::UserMsgButtonClick(TObject *Sender) ...@@ -535,7 +575,8 @@ void __fastcall TNodeForm::UserMsgButtonClick(TObject *Sender)
UserMsgForm->Memo->Lines->Add(""); UserMsgForm->Memo->Lines->Add("");
for(i=0;i<ListBox->Items->Count;i++) for(i=0;i<ListBox->Items->Count;i++)
if(ListBox->Selected[i]==true) { if(ListBox->Selected[i]==true) {
getnodedat(&MainForm->cfg,i+1,&node,0); if(getnodedat(i+1,&node,false))
break;
if(node.useron==0) if(node.useron==0)
continue; continue;
putsmsg(&MainForm->cfg,node.useron putsmsg(&MainForm->cfg,node.useron
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment