This commit is contained in:
Ren RenJuan 2014-01-13 23:19:10 +00:00
parent ddc9b4c179
commit 15404b4bcd
8 changed files with 143 additions and 61 deletions

Binary file not shown.

View File

@ -211,9 +211,12 @@ void setSignals() {
}
void signal_handler(int sig)
{
{ int debug=0;
switch(sig) {
case SIGSEGV:
debug=1; // for breakpoint
theseLogs.logN(0,"Segfault great that you can see this.");
break;
case SIGUSR1:
break;

View File

@ -1,6 +1,10 @@
#include <ncurses.h>
#include "ausreg-cd.h"
#define ASSERT(expr) \
if (!(expr)) { \
std::cerr << __FILE__ << ":" << __LINE__ << ":" << #expr << std::endl;}
const char *banner = CD_NAME " " CD_VERSION " compiled on " __DATE__ " @ " __TIME__ " (%d)";
const char *cmdNames[9] = { "check", "info", "poll", "transfer query",
"create", "renew", "update", "delete", "transfer" };
@ -35,14 +39,19 @@ void mdCommander::doHeader() {
}
void mdCommander::digestibleLines() {
char *sp;
char buffer[256],*sp;
int nLines=0, wrow=5;
nocbreak();
for (;argsNow[cmdNow] < MAX_CMD_ARGS;argsNow[cmdNow]++)
{sp = commandArgs[cmdNow][argsNow[cmdNow]++] = (char *) malloc(256);
mvgetstr(wrow++,2,sp);
if (!strlen(sp)) break;
for (;argsNow[cmdNow] < MAX_CMD_ARGS;)
{memset(buffer,0,sizeof(buffer));
mvgetstr(wrow++,2,buffer);
if (strlen(buffer)) {
sp = (char *) malloc(strlen(buffer)+1);
commandArgs[cmdNow][argsNow[cmdNow]++] = sp;
strcpy(sp,buffer);
}
else break;
}
cbreak();
prompt(false);
@ -160,6 +169,7 @@ void mdCommander::driver() {
cmdNow = --targetCmd;
editingCommand(false);
doHeader();}
help();
break;
case 'S':
if (isValidCmd(targetCmd,false)) {
@ -318,6 +328,7 @@ void mdCommander::flushCommand(int which,bool allOfEm){
for (j=0;j<argsNow[i];j++)
free(commandArgs[i][j]);
}
else deleted[i] = false; // back to start state.
}
cmdNow = 0;
cmdsNow = 0;
@ -345,7 +356,9 @@ void mdCommander::showCommand(bool allOfEm){
sprintf(wwork,"EPP directive: %s",befehlJetzt);
mvprintw(5,2,wwork);
for (nthItem=0;nthItem < argsNow[cmdNow];nthItem++) {
mvprintw(7+nthItem,2,(char *)commandArgs[cmdNow][nthItem]);
ASSERT(commandArgs[cmdNow][nthItem]);
sprintf(wwork,"%d %s",nthItem+1,(commandArgs[cmdNow][nthItem]));
mvprintw(7+nthItem,2,wwork);
}
} else {
@ -354,8 +367,8 @@ void mdCommander::showCommand(bool allOfEm){
for ( i=0, nthItem=0; nthItem < cmdsNow;nthItem++ ) {
if (!deleted[0]) {
sprintf(wwork,"%d %s %s",i+1,cmdNames[commandsNow[nthItem]],commandArgs[nthItem][0]);
if (!deleted[nthItem]) {
sprintf(wwork,"%d %s %s",nthItem+1,cmdNames[commandsNow[nthItem]],commandArgs[nthItem][0]);
mvprintw(7+(i++),2,wwork);
}
@ -372,46 +385,47 @@ void mdCommander::showCommand(bool allOfEm){
bool mdCommander::editingCommand(bool run){
const char *befehlJetzt = cmdNames[commandsNow[cmdNow]];
char *sp;
int editLine;
bool editing=true;
char sp[256],*spp;
int editLine,length;
doHeader();
mvprintw(3,(col-strlen(befehlJetzt))/2,befehlJetzt);
if (!run) {
if (!argsNow[cmdNow]) {
say((char *)"Enter strings for command or just enter to end data entry");
say((char *)"Enter command arg strings, just enter to end data entry, ? to main menu");
prompt(true);
digestibleLines();
} else {
while(editing) {
say((char *)"<n> of arg to replace, A to add, -<n> to erase, just enter to finish");
nocbreak();
while(true) {
showCommand(false);
say((char *)"line no to replace, A to add, enter to return");
prompt(false);
mvgetstr(row-1,2,sp);
if (!strlen(sp)) goto done;
if (*sp == 'A' || *sp == 'a') {
prompt(true);
mvgetstr(row-1,2,sp);
if (!strlen(sp)) editing = false;
else {
if (*sp == 'A' || *sp == 'a') {
if (strlen(sp)) {
sp = commandArgs[cmdNow][argsNow[cmdNow]++] = (char *) malloc(256);
mvgetstr(row-1,2,sp);
if (length=strlen(sp)) {
spp = commandArgs[cmdNow][argsNow[cmdNow]++] = (char *) malloc(length+1);
strcpy(spp,sp);
}
continue;
}
if (is_numeric(sp) >= 1) {
editLine = atoi(sp);
if (editLine>0) {
if (editLine > 1 && editLine < argsNow[cmdNow]) {
prompt(true);
mvgetstr(row-1,2,sp);
if (strlen(sp)) {
free (commandArgs[cmdNow][editLine]);
commandArgs[cmdNow][editLine] = (char *) malloc(strlen(sp)+1);
strcpy(commandArgs[cmdNow][editLine],sp);
if (length=strlen(sp)) {
free (commandArgs[cmdNow][editLine-1]);
spp = commandArgs[cmdNow][editLine-1] = (char *) malloc(strlen(sp)+1);
strcpy(spp,sp);
}
}
else { editLine = editLine * -1 ;
memset(commandArgs[cmdNow][editLine],0,strlen(commandArgs[cmdNow][editLine]));
}
} // editing body
} // editing loop
} // new / existing
done: cbreak();
} // editing block
} // run / execute
else {
say((char *)"Press 'Y' to confirm");
@ -423,62 +437,62 @@ void mdCommander::check(bool run) {
if (!commandsNow[cmdNow]) commandsNow[cmdNow] = 0;
if (!editingCommand(run)) {
}
} else help();
}
void mdCommander::create(bool run){
if (!commandsNow[cmdNow]) commandsNow[cmdNow] = 4;
if (!editingCommand(run)) {
}
} else help();
};
void mdCommander::info(bool run){
if (!commandsNow[cmdNow]) commandsNow[cmdNow] = 1;
if (!editingCommand(run)) {
}
} else help();
};
void mdCommander::renew(bool run){
if (!commandsNow[cmdNow]) commandsNow[cmdNow] = 5;
if (!editingCommand(run)) {
}
} else help();
};
void mdCommander::queryTransfer(bool run){
if (!commandsNow[cmdNow]) commandsNow[cmdNow] = 3;
if (!editingCommand(run)) {
}
} else help();
};
void mdCommander::trash(bool run){
if (!commandsNow[cmdNow]) commandsNow[cmdNow] = 7;
if (!editingCommand(run)) {
}
} else help();
};
void mdCommander::transfer(bool run){
if (!commandsNow[cmdNow]) commandsNow[cmdNow] = 8;
if (!editingCommand(run)) {
}
} else help();
};
void mdCommander::poll(bool run){
if (!commandsNow[cmdNow]) commandsNow[cmdNow] = 2;
if (!editingCommand(run)) {
}
} else help();
};
void mdCommander::update(bool run){
if (!commandsNow[cmdNow]) commandsNow[cmdNow] = 6;
if (!editingCommand(run)) {
}
} else help();
};

View File

@ -8,7 +8,6 @@ class mdCommander {
bool acceptingInput,deleted[MAX_CMDS];
bool EPPmode; // RFC 9
int activeCommands, argsNow[MAX_CMDS], cmdNow, cmdsNow, mdStdDevIdx;
std::string currentDevice;
int row,col;
int commandsNow[MAX_CMDS]; // type index into cmdNames
char *commandArgs[MAX_CMDS][MAX_CMD_ARGS];
@ -16,7 +15,9 @@ class mdCommander {
public:
mdCommander() {mdStdDevIdx=0; cmdsNow=0; cmdNow = 0;}
mdCommander() {mdStdDevIdx=0; cmdsNow=0; cmdNow = 0;
memset(commandArgs,0,sizeof(commandArgs));
}
~mdCommander() {}
void say(char *what) ;

View File

@ -32,5 +32,6 @@ class ausRegEPPTK {
}
bool didInit(const std::string propertiesFilePath);
void doOTEA();
void doOTEB();
};

View File

@ -144,6 +144,9 @@ enum acTKScenario {
ACTK_ALONE = 0,
ACTK_INSECURE,
ACTK_OTEA,
ACTK_OTEB,
ACTK_OTEC,
ACTK_PROD,
N_ACTK_SCENARIOS
};

View File

@ -231,6 +231,18 @@ void oteA() {
}
}void oteB() {
int nthDay;
for (nthDay=0;nthDay<30;nthDay++) {
theseLogs->logNdebug(MAX_DEBUG,1,"PreProd / OTEB day %d",nthDay);
thisService->artk->doOTEB();
theseLogs->logNdebug(MAX_DEBUG,1,"Preprod/ OTEB day %d",nthDay);
thisService->artk->daysRunning = nthDay;
}
}
void masterDaemon::run() {
@ -238,13 +250,17 @@ void masterDaemon::run() {
fg = new mdDGChannel( thisService->io_, 0 );
if (initAusRegTK()) return;
else switch(artk->tkScenario) {
case ACTK_OTEA:
if (artk->tkScenario == ACTK_OTEA) {
boost::thread oteArun(oteA);
assert(oteArun.joinable());
oteArun.join();
theseLogs->logNdebug(MAX_DEBUG,0,"OTE Connectivity Test EOJ.");
break;
}
if (artk->tkScenario == ACTK_OTEB) {
boost::thread oteBrun(oteB);
assert(oteBrun.joinable());
oteBrun.join();
theseLogs->logNdebug(MAX_DEBUG,0,"Pre-production Ops / OTEB EOJ.");
}
listen();
boost::thread work(mdWQ);

View File

@ -30,6 +30,50 @@ bool ausRegEPPTK::didInit(const std::string propertiesFilePath) {
}
void ausRegEPPTK::doOTEA()
{
int hours,hoops;
string op("newInstance");
if (!daysRunning)
scenario(tkScenario);
try {
Timer::setTime("20070101.010101");
auto_ptr<SessionManager> manager(SessionManagerFactory::newInstance(&props));
auto_ptr<Session> sess(SessionFactory::newInstance(&props));
op = "startup";
manager->startup();
op = "run (keep-alive)";
manager->run();
sess->open();
for (hours=0;hours < 24;hours++) {
// Spawn the keep alive thread.
theseLogs->logN(1,"Send Test SEs on or about start OTE Test Hour %d.",hours);
for (hoops=0;hoops<7;hoops++) {
sess->writeXML(TEST_SE);
sess->read();
sleep(857);
}
}
sess->close();
manager->shutdown();
}
catch (EPPException& e)
{ const char *eMsg = e.getMessage().c_str();
const char *opNow = op.c_str();
theseLogs->logN(2,"EPP Exception during OTE A (%s): %s .",opNow,eMsg);
throw e;
}
catch (...)
{
theseLogs->logN(2,"General Exception during OTE A (%s).",op.c_str());
}
}
void ausRegEPPTK::doOTEB()
{
int hours;
string op("newInstance");
@ -51,7 +95,7 @@ void ausRegEPPTK::doOTEA()
// Spawn the keep alive thread.
theseLogs->logN(1,"Send Test SE at start of OTE Test Hour %d.",hours);
sess->writeXML(TEST_SE);
sess->read();
// sess->read();
sleep(3630);
}