command rewritten for AC
This commit is contained in:
parent
633a9992b7
commit
a6bac1335c
|
@ -23,17 +23,17 @@ BOSTLIB=-L/usr/lib/boost
|
|||
BOSINCL=-L/usr/include/boost
|
||||
LOG4LIB=-L/usr/lib
|
||||
|
||||
#DEF_XML_RPC=-DXMLRPC-C
|
||||
#XMLRPC_INCL=
|
||||
#XMLRPC_LIB=
|
||||
#DEF_XML_RPC=-DXMLRPC_C
|
||||
#XMLRPC_INCL=-I/usr/include/xmlrpc-c
|
||||
#XMLRPC_LIB=-I/usr/lib
|
||||
|
||||
CLIENT=drde
|
||||
|
||||
SLIBS= -L/usr/lib $(BOSTLIB) $(LOG4LIB) -l boost_system -l boost_thread -l log4cpp
|
||||
SLIBS= -L/usr/lib $(BOSTLIB) $(LOG4LIB) -l boost_system -l boost_thread -l log4cpp -l ncurses
|
||||
|
||||
ifeq ($(LOCATION),authoring)
|
||||
SINCL= -I include -I ../AusRegCliever/include -I /usr/include/log4cpp $(BOSINCL)
|
||||
CFLAGS= -DCURRENT_DEBUG=1000
|
||||
CFLAGS= -DCURRENT_DEBUG=1000 -ggdb3
|
||||
endif
|
||||
|
||||
CLIBS= -L$(USRLIB)
|
||||
|
@ -86,7 +86,7 @@ build/cdLogger.o: client/cdLogger.cpp include/cdLogger.h
|
|||
$(CC) $(CFLAGS) client/cdLogger.cpp -c -o build/cdLogger.o $(SINCL)
|
||||
|
||||
build/cliever.o: client/ausreg-cd.cpp include/*.h
|
||||
$(CC) $(CFLAGS) client/ausreg-cd.cpp -c -o build/cliever.o $(SINCL)
|
||||
$(CC) $(CFLAGS) client/ausreg-cd.cpp -c -o build/cliever.o $(SINCL) $(DEF_XML_RPC) $(XMLRPC_INCL)
|
||||
|
||||
build/clientDaemonConfig.o: client/clientDaemonConfig.cpp include/*.h
|
||||
$(CC) $(CFLAGS) client/clientDaemonConfig.cpp -c -o build/clientDaemonConfig.o $(SINCL)
|
||||
|
@ -101,12 +101,12 @@ build/commander.o: client/commander.cpp include/mdCommander.h
|
|||
$(CC) $(CFLAGS) client/commander.cpp $(SINCL) -c -o build/commander.o
|
||||
|
||||
build/$(CLIENT)-cd: $(ACOBJS)
|
||||
$(CC) $(CFLAGS) -o build/$(CLIENT)-cd $(SINCL) $(LIBS) $(ACOBJS) $(SLIBS)
|
||||
$(CC) $(CFLAGS) -o build/$(CLIENT)-cd $(SINCL) $(LIBS) $(ACOBJS) $(SLIBS) $(XMLRPC_LIB)
|
||||
|
||||
build/apig-cli: build/mdClientBehavior.o build/mdClientState.o build/mdClientDevice.o \
|
||||
build/tools.o build/coretestbucket.o client/apig-cli.cpp
|
||||
$(CC) $(CFLAGS) client/apig-cli.cpp $(CLIBS) $(CINCL) -o build/apig-cli build/tools.o build/coretestbucket.o \
|
||||
build/mdClientBehavior.o build/mdClientState.o build/mdClientDevice.o
|
||||
build/mdClientBehavior.o build/mdClientState.o build/mdClientDevice.o $(XMLRPC_LIB)
|
||||
|
||||
doxygen/index.html: etc/doxygen.config
|
||||
doxygen etc/doxygen.config
|
||||
|
|
Binary file not shown.
|
@ -6,8 +6,8 @@
|
|||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
|
||||
bool cdHasTk;
|
||||
char cdOrTkValue;
|
||||
bool cdHasTk;
|
||||
char cdOrTkValue;
|
||||
const char *cdOrTk=&cdOrTkValue;
|
||||
|
||||
using namespace std;
|
||||
|
@ -72,7 +72,7 @@ void acClientServer() { // AKA "Cliever"
|
|||
boost::thread cliever(runCliever);
|
||||
boost::thread apiLayer(runAPILayer);
|
||||
|
||||
#ifdef XMLRPC-C
|
||||
#ifdef XMLRPC_C
|
||||
|
||||
xmlrpc_c::serverAbyss myAbyssServer(
|
||||
thisConfig->api_registry,
|
||||
|
@ -80,7 +80,6 @@ void acClientServer() { // AKA "Cliever"
|
|||
thisConfig->xmlrpcLogpath
|
||||
);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
if (!apiLayer.joinable() || !cliever.joinable()) {
|
||||
|
@ -91,7 +90,7 @@ void acClientServer() { // AKA "Cliever"
|
|||
}
|
||||
else {
|
||||
theseLogs.logN(0,"Cliever started OK.");
|
||||
#ifdef XMLRPC-C
|
||||
#ifdef XMLRPC_C
|
||||
theseLogs->logN(2,"%s %d","Accepting XMLRPC API Requests on Port",thisConfig->xmlrpcPort);
|
||||
myAbyssServer.run();
|
||||
#endif
|
||||
|
|
|
@ -1,5 +1,14 @@
|
|||
#include <ncurses.h>
|
||||
#include "ausreg-cd.h"
|
||||
|
||||
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" };
|
||||
char theBanner[256];
|
||||
int targetHost = 0;
|
||||
|
||||
mdDG mdg;
|
||||
|
||||
int is_numeric(const char *p) { int i = strlen(p),j=0;
|
||||
if (*p) {
|
||||
char c;
|
||||
|
@ -13,190 +22,463 @@ int is_numeric(const char *p) { int i = strlen(p),j=0;
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
void mdCommander::doHeader() {
|
||||
|
||||
int displayCmd = cmdsNow ? cmdNow + 1 : 0;
|
||||
|
||||
clear();
|
||||
mvprintw(0,(col-strlen(banner))/2,"%s",theBanner);
|
||||
sprintf(wwork,"Target AC host: %d this one: %d commmands: %d current: %d",
|
||||
targetHost,mdStdDevIdx,activeCommands,displayCmd);
|
||||
mvprintw(1,(col-strlen(wwork))/2,"%s",wwork);
|
||||
|
||||
}
|
||||
void mdCommander::digestibleLines() {
|
||||
|
||||
char *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;
|
||||
}
|
||||
cbreak();
|
||||
prompt(false);
|
||||
|
||||
}
|
||||
void mdCommander::prompt(bool forStrings) {
|
||||
|
||||
if (forStrings)
|
||||
mvprintw(row-1,1,">>");
|
||||
else
|
||||
mvprintw(row-1,1,"> ");
|
||||
|
||||
}
|
||||
void mdCommander::driver() {
|
||||
|
||||
bool rc;
|
||||
char instrinsic[16],next,rawString[4096],work[4096];
|
||||
bool rc, x;
|
||||
char next,rawString[128],work[128];
|
||||
const char *mdErrCode = "";
|
||||
int i,commandLength;
|
||||
|
||||
activeCommands = 0;
|
||||
cmdNow = 0;
|
||||
cmdsNow = 0;
|
||||
memset(commandsNow,0,sizeof(commandsNow));
|
||||
memset(argsNow,0,sizeof(argsNow));
|
||||
initscr();
|
||||
cbreak();
|
||||
greet();
|
||||
while(acceptingInput) {
|
||||
putchar('>');
|
||||
mvprintw(row-1,1,"> ");
|
||||
next=0;
|
||||
i=0;
|
||||
memset(rawString,0,sizeof(rawString));
|
||||
while(next != '\012') {
|
||||
next = getchar();
|
||||
next = mvgetch(row-1,2+i);
|
||||
rawString[i++] = next;
|
||||
if (i > (sizeof(rawString) - 1)) {
|
||||
puts("Max length exceeded!");
|
||||
say((char *)"Max length exceeded!");
|
||||
continue;
|
||||
}
|
||||
if (next == '\012')
|
||||
rawString[strlen(rawString)-1] = 0;
|
||||
}
|
||||
if (!strlen(rawString)) continue;
|
||||
if (strlen(rawString) == 2) {
|
||||
if (strlen(rawString) == 1) {
|
||||
switch(rawString[0]) {
|
||||
case '1': ; case '2': ; case '3': ; case '4': ; case '5': ;
|
||||
case '6': ; case '7': ; case '8': ; case '9':
|
||||
goto retarget ;
|
||||
case '!': runCommand(false);
|
||||
break;
|
||||
case '?': help();
|
||||
break;
|
||||
case 'e': eppMainMenu();
|
||||
break;
|
||||
case '!': sendCommand();
|
||||
break;
|
||||
case 'X': flushCommand();
|
||||
break;
|
||||
case 'a': acMainMenu();
|
||||
break;
|
||||
case 'c': check();
|
||||
case 'c': commandsNow[(cmdNow=cmdsNow++)]; activeCommands++;
|
||||
check(false);
|
||||
break;
|
||||
case 'i': info();
|
||||
case 'p': commandsNow[(cmdNow=cmdsNow++)]; activeCommands++;
|
||||
poll(false);
|
||||
break;
|
||||
case 't': transferCheck();
|
||||
case 'i': commandsNow[(cmdNow=cmdsNow++)]; activeCommands++;
|
||||
info(false);
|
||||
break;
|
||||
case 'C': create();
|
||||
case 't': commandsNow[(cmdNow=cmdsNow++)]; activeCommands++;
|
||||
queryTransfer(false);
|
||||
break;
|
||||
case 'R': renew();
|
||||
case 'C': commandsNow[(cmdNow=cmdsNow++)]; activeCommands++;
|
||||
create(false);
|
||||
break;
|
||||
case 'U': update();
|
||||
case 'R': commandsNow[(cmdNow=cmdsNow++)]; activeCommands++;
|
||||
renew(false);
|
||||
break;
|
||||
case 'D': trash();
|
||||
case 'U': commandsNow[(cmdNow=cmdsNow++)]; activeCommands++;
|
||||
update(false);
|
||||
break;
|
||||
case 'T': transfer();
|
||||
case 'D': commandsNow[(cmdNow=cmdsNow++)]; activeCommands++;
|
||||
trash(false);
|
||||
break;
|
||||
case 'T': commandsNow[(cmdNow=cmdsNow++)]; activeCommands++;
|
||||
transfer(false);
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (strlen(rawString) == 3) {
|
||||
if (strlen(rawString) == 2) {
|
||||
if (!strcmp(rawString,"??")) {
|
||||
showCommand();
|
||||
showCommand(true);
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(rawString,"!!")) {
|
||||
runCommand(true);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (is_numeric(rawString) == 2) {
|
||||
rawString[strlen(rawString)] = 0;
|
||||
mdStdDevIdx = atoi(rawString);
|
||||
if (is_numeric(rawString) >= 1) {
|
||||
retarget:
|
||||
targetHost = atoi(rawString);
|
||||
doHeader();
|
||||
continue;
|
||||
}
|
||||
if (strlen(rawString) >= 4 && strlen(rawString) <= 6 )
|
||||
{if (!strcmp(rawString,"log\n")) {
|
||||
system("less /tmp/ausreg-cd.log");
|
||||
if (is_numeric(rawString+1) >= 1) {
|
||||
int targetCmd = atoi(rawString+1);
|
||||
switch(rawString[0]) {
|
||||
case 'C':
|
||||
if (isValidCmd(targetCmd,false)) {
|
||||
cmdNow = --targetCmd;
|
||||
doHeader();}
|
||||
else say((char *)"Invalid Command Index");
|
||||
break;
|
||||
case 'E':
|
||||
if (isValidCmd(targetCmd,false)) {
|
||||
cmdNow = --targetCmd;
|
||||
editingCommand(false);
|
||||
doHeader();}
|
||||
break;
|
||||
case 'S':
|
||||
if (isValidCmd(targetCmd,false)) {
|
||||
cmdNow = --targetCmd;
|
||||
sendCommand(cmdNow);
|
||||
doHeader();
|
||||
}
|
||||
else say((char *)"Invalid Command Index");
|
||||
break;
|
||||
case 'X':
|
||||
if (!targetCmd) {targetCmd = 0; x = true;}
|
||||
else {targetCmd--; x = false;}
|
||||
if (isValidCmd(targetCmd,true)) {
|
||||
flushCommand(targetCmd,x);
|
||||
doHeader();
|
||||
}
|
||||
else say((char *)"Invalid Command Index");
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strlen(rawString) >= 3 && strlen(rawString) <= 5 )
|
||||
{if (!strcmp(rawString,"log")) {
|
||||
sprintf(wwork,"cut -b 1-%d /tmp/ausreg-cd.log | less",col);
|
||||
system(wwork);
|
||||
clear();
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(rawString,"done\n")) {
|
||||
return;
|
||||
}
|
||||
if (!strcmp(rawString,"mdapi\n")) {
|
||||
system("mdclient ");
|
||||
if (!strcmp(rawString,"mlog")) {
|
||||
sprintf(wwork,"cut -b 1-%d /tmp/drde-cliever.log | less",col);
|
||||
system(wwork);
|
||||
clear();
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(rawString,"quit\n")) {
|
||||
if (!strcmp(rawString,"done")) {
|
||||
goto done;
|
||||
}
|
||||
if (!strcmp(rawString,"quit")) {
|
||||
thisConfig->terminateRequest = true;
|
||||
return;
|
||||
}
|
||||
if (!strcmp(rawString,"mdapi\n")) {
|
||||
continue;
|
||||
}
|
||||
if (strlen(rawString) < 3) {
|
||||
puts("That SCPI command is too short!");
|
||||
continue;
|
||||
goto done;
|
||||
}
|
||||
rc = epp(rawString);
|
||||
if (!rc) puts("Command transmitted: OK.");
|
||||
else printf("Command result: %s.",mdErrCode);
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
done:
|
||||
nocbreak();
|
||||
endwin();
|
||||
}
|
||||
void mdCommander::say(char *what)
|
||||
{ memset(wwork,' ',sizeof(wwork));
|
||||
mvprintw(row-2,1,wwork);
|
||||
mvprintw(row-2,1,what);
|
||||
}
|
||||
|
||||
void mdCommander::greet() {
|
||||
|
||||
puts(" AC Commander ");
|
||||
puts("Enter ? for help or an AC command");
|
||||
const char *title="AusReg Cliever Commander",
|
||||
*prompt="? for main menu or enter commander command now";
|
||||
|
||||
sprintf(theBanner,banner,thisConfig->shellProcess);
|
||||
getmaxyx(stdscr,row,col);
|
||||
mvprintw(0,(col-strlen(banner))/2,"%s",theBanner);
|
||||
mvprintw(row/2,(col-strlen(title))/2,"%s",title);
|
||||
mvprintw(row-2,1,"%s",prompt);
|
||||
refresh();
|
||||
acceptingInput = true;
|
||||
EPPmode = true;
|
||||
currentDevice = std::string("ALX");
|
||||
|
||||
}
|
||||
void mdCommander::help() {
|
||||
|
||||
const char *banner = "\n" CD_NAME " " CD_VERSION " compiled on " __DATE__ " @ " __TIME__ " (%d)\n\n";
|
||||
|
||||
system("clear");
|
||||
printf(banner,thisConfig->shellProcess);
|
||||
printf(" target acEPPDevIdx-> %d this acEPPDevIdx: %d \n\n",0,mdStdDevIdx);
|
||||
puts(" ? - display this screen");
|
||||
puts(" ! - send the pending command");
|
||||
puts(" ?? - display the pending command");
|
||||
puts(" X - discard the pending command");
|
||||
puts(" <n> - make <n> (an integer) the target acEPPDevIdx");
|
||||
puts(" done - terminate this command loop but not ausreg-cd");
|
||||
puts(" e - standard EPP command menu");
|
||||
puts(" a - AC system control menu");
|
||||
puts(" log - display this cliever's log");
|
||||
puts(" rlog - pull and display the master daemon log");
|
||||
puts(" quit - terminate this process tree\n\n");
|
||||
puts("Any command valid outside command data loop(>>).");
|
||||
doHeader();
|
||||
mvprintw(5,10," a - AC system control menu");
|
||||
mvprintw(6,10," e - standard EPP command menu");
|
||||
mvprintw(7,10," ? - display this screen");
|
||||
mvprintw(8,10," ?? - display commands");
|
||||
mvprintw(9,10," ! - run the active command");
|
||||
mvprintw(10,10," !! - run active commands");
|
||||
mvprintw(11,10," C<n> - make <n> the active command");
|
||||
mvprintw(12,10," E<n> - display/edit command <n> ");
|
||||
mvprintw(13,10," S<n> - send command <n>");
|
||||
mvprintw(14,10," X<n> - discard the command(s)");
|
||||
mvprintw(15,10," <n> - make <n> the target EPP server");
|
||||
mvprintw(16,10," log - display this cliever's log");
|
||||
mvprintw(17,10," mlog - display the master daemon log");
|
||||
mvprintw(18,10," done - terminate commander but not process");
|
||||
mvprintw(19,10," quit - terminate this process and its' children");
|
||||
mvprintw(23,5,"<n> is an integer, above active everywhere outside data entry (>>)");
|
||||
mvprintw(24,5,"no space before <n>, X0 to delete all commands.");
|
||||
|
||||
}
|
||||
void mdCommander::eppMainMenu() {
|
||||
|
||||
const char *banner = "\n" CD_NAME " " CD_VERSION " compiled on " __DATE__ " @ " __TIME__ " (%d)\n\n";
|
||||
doHeader();
|
||||
mvprintw(5,10," Create a new EPP command");
|
||||
|
||||
system("clear");
|
||||
printf(banner,thisConfig->shellProcess);
|
||||
printf(" target acEPPDevIdx-> %d this acEPPDevIdx: %d \n\n",0,mdStdDevIdx);
|
||||
puts(" Queries \n");
|
||||
puts(" c - check");
|
||||
puts(" i - info");
|
||||
puts(" t - transfer\n");
|
||||
puts(" Commands \n");
|
||||
puts(" C - create");
|
||||
puts(" R - renew");
|
||||
puts(" U - update\n");
|
||||
puts(" D - delete");
|
||||
puts(" T - transfer");
|
||||
mvprintw(10,10," Queries ");
|
||||
mvprintw(12,10," c - check");
|
||||
mvprintw(13,10," i - info");
|
||||
mvprintw(14,10," p - poll");
|
||||
mvprintw(15,10," t - transfer query");
|
||||
mvprintw(17,10," Transactions");
|
||||
mvprintw(19,10," C - create");
|
||||
mvprintw(20,10," R - renew");
|
||||
mvprintw(21,10," U - update");
|
||||
mvprintw(22,10," D - delete");
|
||||
mvprintw(23,10," T - transfer");
|
||||
|
||||
}
|
||||
void mdCommander::acMainMenu() {
|
||||
|
||||
const char *banner = "\n" CD_NAME " " CD_VERSION " compiled on " __DATE__ " @ " __TIME__ " (%d)\n\n";
|
||||
doHeader();
|
||||
mvprintw(5,(col-strlen("AC System Directives"))/2,"AC System Directives");
|
||||
|
||||
system("clear");
|
||||
printf(banner,thisConfig->shellProcess);
|
||||
printf(" target acEPPDevIdx-> %d this acEPPDevIdx: %d \n\n",0,mdStdDevIdx);
|
||||
puts(" Directives \n\n");
|
||||
puts(" RST - followed by quit resets entire AC system");
|
||||
mvprintw(15,10," (H)ALT - Flush queues, stop, ignore incoming requests");
|
||||
mvprintw(16,10," (L)OAD - Resume execution, accept work");
|
||||
mvprintw(17,10," (B)ANG - Force reload the entire AC system");
|
||||
mvprintw(20,10,"These are only active on this screen, there's no confirmation.");
|
||||
|
||||
}
|
||||
bool mdCommander::epp(char *cmd) {
|
||||
bool sendEPPCommand() {
|
||||
|
||||
char *command,work[256];
|
||||
bool isDirect=false,rc=true;
|
||||
mdg.dg.hdr.sourceHandle = thisCliever->myHandle;
|
||||
mdg.dg.hdr.payloadSize = 0;
|
||||
mdg.dg.hdr.msgType = MDDG_CDRESET;
|
||||
return thisCliever->fg->send(mdg.dg);
|
||||
}
|
||||
bool mdCommander::runCommand(bool allOfEm) {
|
||||
|
||||
bool value=false;
|
||||
|
||||
if (!mdStdDevIdx && !strncmp(cmd,"RST",3)) {
|
||||
if (!activeCommands) {say((char *)"There is no active command."); goto done;}
|
||||
|
||||
mdDG mdg;
|
||||
say((char *)"Command execution temporarily disabled.");
|
||||
|
||||
mdg.dg.hdr.sourceHandle = thisCliever->myHandle;
|
||||
mdg.dg.hdr.payloadSize = 0;
|
||||
mdg.dg.hdr.msgType = MDDG_CDRESET;
|
||||
if (thisCliever->fg->send(mdg.dg)) rc = false;
|
||||
|
||||
}
|
||||
|
||||
return rc;
|
||||
done: return value;
|
||||
|
||||
}
|
||||
void mdCommander::check(){};
|
||||
void mdCommander::create(){};
|
||||
void mdCommander::flushCommand(){};
|
||||
void mdCommander::info(){};
|
||||
void mdCommander::renew(){};
|
||||
void mdCommander::sendCommand(){};
|
||||
void mdCommander::showCommand(){};
|
||||
void mdCommander::trash(){};
|
||||
void mdCommander::transfer(){};
|
||||
void mdCommander::transferCheck(){};
|
||||
void mdCommander::update(){};
|
||||
//--------------------------------
|
||||
void mdCommander::flushCommand(int which,bool allOfEm){
|
||||
|
||||
int i,j;
|
||||
|
||||
if (!allOfEm) {
|
||||
if (argsNow[which]) {
|
||||
for (i=0;i<argsNow[which];i++)
|
||||
free(commandArgs[which][i]);
|
||||
}
|
||||
argsNow[which] = 0;
|
||||
deleted[which] = true;
|
||||
activeCommands--;
|
||||
} else for (i=0;i<cmdsNow;i++) {
|
||||
if (!deleted[i]) {
|
||||
if (argsNow[i]) {
|
||||
for (j=0;j<argsNow[i];j++)
|
||||
free(commandArgs[i][j]);
|
||||
}
|
||||
}
|
||||
cmdNow = 0;
|
||||
cmdsNow = 0;
|
||||
activeCommands = 0;
|
||||
memset(commandArgs,0,sizeof(commandArgs));
|
||||
memset(argsNow,0,sizeof(argsNow));
|
||||
}
|
||||
|
||||
};
|
||||
void mdCommander::sendCommand(int which){
|
||||
|
||||
say((char *)"Command processing disabled here during OTE Basic Testing");
|
||||
};
|
||||
void mdCommander::showCommand(bool allOfEm){
|
||||
|
||||
int activethCommand=0,i,nthItem;
|
||||
const char *befehlJetzt = cmdNames[commandsNow[cmdNow]];
|
||||
|
||||
doHeader();
|
||||
|
||||
if (!activeCommands) {say((char *)"There is no active command."); goto done;}
|
||||
|
||||
if (!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]);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
mvprintw(5,2,"These commands are pending/active: ");
|
||||
|
||||
for (i=0, nthItem=0; nthItem < cmdsNow;nthItem++ ) {
|
||||
|
||||
if (!deleted[0]) {
|
||||
sprintf(wwork,"%d %s %s",i+1,cmdNames[commandsNow[nthItem]],commandArgs[nthItem][0]);
|
||||
mvprintw(7+(i++),2,wwork);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
done: return;
|
||||
|
||||
};
|
||||
//--------------------------------
|
||||
// EPP Queries and Commands
|
||||
//-------------------------------
|
||||
bool mdCommander::editingCommand(bool run){
|
||||
const char *befehlJetzt = cmdNames[commandsNow[cmdNow]];
|
||||
|
||||
char *sp;
|
||||
int editLine;
|
||||
bool editing=true;
|
||||
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");
|
||||
prompt(true);
|
||||
digestibleLines();
|
||||
} else {
|
||||
while(editing) {
|
||||
say((char *)"<n> of arg to replace, A to add, -<n> to erase, just enter to finish");
|
||||
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);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
editLine = atoi(sp);
|
||||
if (editLine>0) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
else { editLine = editLine * -1 ;
|
||||
memset(commandArgs[cmdNow][editLine],0,strlen(commandArgs[cmdNow][editLine]));
|
||||
}
|
||||
} // editing body
|
||||
} // editing loop
|
||||
} // new / existing
|
||||
} // run / execute
|
||||
else {
|
||||
say((char *)"Press 'Y' to confirm");
|
||||
}
|
||||
|
||||
};
|
||||
void mdCommander::check(bool run) {
|
||||
|
||||
if (!commandsNow[cmdNow]) commandsNow[cmdNow] = 0;
|
||||
if (!editingCommand(run)) {
|
||||
|
||||
}
|
||||
}
|
||||
void mdCommander::create(bool run){
|
||||
|
||||
if (!commandsNow[cmdNow]) commandsNow[cmdNow] = 4;
|
||||
if (!editingCommand(run)) {
|
||||
|
||||
}
|
||||
};
|
||||
void mdCommander::info(bool run){
|
||||
|
||||
if (!commandsNow[cmdNow]) commandsNow[cmdNow] = 1;
|
||||
if (!editingCommand(run)) {
|
||||
|
||||
}
|
||||
};
|
||||
void mdCommander::renew(bool run){
|
||||
|
||||
if (!commandsNow[cmdNow]) commandsNow[cmdNow] = 5;
|
||||
if (!editingCommand(run)) {
|
||||
|
||||
}
|
||||
};
|
||||
void mdCommander::queryTransfer(bool run){
|
||||
|
||||
if (!commandsNow[cmdNow]) commandsNow[cmdNow] = 3;
|
||||
if (!editingCommand(run)) {
|
||||
|
||||
}
|
||||
};
|
||||
void mdCommander::trash(bool run){
|
||||
|
||||
if (!commandsNow[cmdNow]) commandsNow[cmdNow] = 7;
|
||||
if (!editingCommand(run)) {
|
||||
|
||||
}
|
||||
};
|
||||
void mdCommander::transfer(bool run){
|
||||
|
||||
if (!commandsNow[cmdNow]) commandsNow[cmdNow] = 8;
|
||||
if (!editingCommand(run)) {
|
||||
|
||||
}
|
||||
};
|
||||
void mdCommander::poll(bool run){
|
||||
|
||||
if (!commandsNow[cmdNow]) commandsNow[cmdNow] = 2;
|
||||
if (!editingCommand(run)) {
|
||||
|
||||
}
|
||||
};
|
||||
void mdCommander::update(bool run){
|
||||
|
||||
if (!commandsNow[cmdNow]) commandsNow[cmdNow] = 6;
|
||||
if (!editingCommand(run)) {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -7,21 +7,21 @@ typedef struct _DE {
|
|||
char sig;
|
||||
const char * name; } newDEs;
|
||||
|
||||
// Test bogus name last.
|
||||
const char *predefinedObservables[5] = { "spintime", "omega-squared", "pressure", "temperature", "adsfasdf" };
|
||||
// Lots to do here, need to complete migration to the EPP context which is
|
||||
// enoromously better better bounded than the original. In the end will have
|
||||
// a test suite here that can be generated from the XMLRPC registry.
|
||||
|
||||
const char *standardEPPDirectives[8] =
|
||||
{ "check", "infod", "transfer", "create", "renew, "update", "delete", "transfer" };
|
||||
const char *randomValues[4] = { "333.333", "111.111", "34.43", "7777.777" };
|
||||
const char *requiredCmdSubSys[2] = { "SYSTEM", "STATUS" };
|
||||
string debug1,debug2,success("OK");
|
||||
newDEs otherP1Elements[6] = { {'d', "absorbance"}, {'d', "acceleration"},
|
||||
{'b', "_powered" }, {'t', "_uptime"},
|
||||
{'i', "_vacuum" }, {'d', "_rotorspeed"}
|
||||
};
|
||||
|
||||
void mdCoreAPITestSuite::bucket01(char const *title) {
|
||||
|
||||
phase = string("core API test bucket");
|
||||
|
||||
int nTests=(sizeof(predefinedObservables)/sizeof(char *)),variation;
|
||||
int nTests=(sizeof(standardEPPDirectives)/sizeof(char *)),variation;
|
||||
XmlRpcValue focus,gotten[nTests];
|
||||
cout << "\nTest Bucket: " << title << endl;
|
||||
|
||||
|
@ -29,11 +29,11 @@ void mdCoreAPITestSuite::bucket01(char const *title) {
|
|||
|
||||
for ( variation=0; variation < nTests; variation++) {
|
||||
|
||||
cout << ".Get '" << predefinedObservables[variation] << "'\n";
|
||||
gotten[variation] = testState->get(mdServerHandle,predefinedObservables[variation]).getStruct();
|
||||
cout << ".Get '" << standardEPPDirectives[variation] << "'\n";
|
||||
gotten[variation] = testState->get(mdServerHandle,standardEPPDirectives[variation]).getStruct();
|
||||
focus = gotten[variation].structGetValue("dataname");
|
||||
if (variation < (nTests - 1))
|
||||
TEST(focus.getString() == string(predefinedObservables[variation]));
|
||||
TEST(focus.getString() == string(standardEPPDirectives[variation]));
|
||||
else TEST(focus.getString() == string("not found"));
|
||||
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ void mdCoreAPITestSuite::bucket01(char const *title) {
|
|||
// Set to some value.
|
||||
|
||||
for (variation=0;variation < (nTests - 1);variation++) {
|
||||
cout << ".Set '" << predefinedObservables[variation] << "'\n";
|
||||
cout << ".Set '" << standardEPPDirectives[variation] << "'\n";
|
||||
gotten[variation].structSetValue("sValue",XmlRpcValue::makeString(randomValues[variation]));
|
||||
TEST(string("OK") == testState->set(mdServerHandle,gotten[variation]));
|
||||
}
|
||||
|
@ -50,8 +50,8 @@ void mdCoreAPITestSuite::bucket01(char const *title) {
|
|||
|
||||
for ( variation=0; variation < (nTests -1); variation++) {
|
||||
|
||||
cout << ".Cmp '" << predefinedObservables[variation] << "'\n";
|
||||
gotten[variation] = testState->get(mdServerHandle,predefinedObservables[variation]).getStruct();
|
||||
cout << ".Cmp '" << standardEPPDirectives[variation] << "'\n";
|
||||
gotten[variation] = testState->get(mdServerHandle,standardEPPDirectives[variation]).getStruct();
|
||||
focus = gotten[variation].structGetValue("sValue");
|
||||
debug1 = focus.getString();
|
||||
debug2 = string(randomValues[variation]);
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
#define MD_NAME CLIEVER_APP " " MD_COMPONENT
|
||||
#define MD_VERSION " 1.0 " // Version
|
||||
#define MD_DEFAULT_IP "188.138.106.163"
|
||||
|
||||
#include "mdconstants.h"
|
||||
#include "mdcommon.h"
|
||||
|
||||
#include "cdEvents.h"
|
||||
|
@ -50,7 +50,7 @@
|
|||
#define CD_EPOCH date()
|
||||
#define CD_GLOBAL_SIZE 4096
|
||||
#define CD_LOCK_FILE "ausreg-cd.lock"
|
||||
#define CD_NAME CLIEVER_APP " ausreg-cd"
|
||||
#define CD_NAME CLIEVER_APP " drde-cd"
|
||||
#define CD_VERSION "1.0"
|
||||
#define CD_REFRESH MD_HEARTBEAT // default milliseconds between telemetry frame updates
|
||||
#define CD_MAX_DEVICE 4 // including ourselves
|
||||
|
|
|
@ -1,36 +1,56 @@
|
|||
#ifndef MD_CHARGUI
|
||||
#define MD_CHARGUI
|
||||
|
||||
#define MAX_CMDS 20
|
||||
|
||||
class mdCommander {
|
||||
|
||||
bool acceptingInput;
|
||||
bool EPPmode; // RFC 8
|
||||
int mdStdDevIdx;
|
||||
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];
|
||||
char wwork[1024];
|
||||
|
||||
public:
|
||||
|
||||
mdCommander() {mdStdDevIdx=0;}
|
||||
mdCommander() {mdStdDevIdx=0; cmdsNow=0; cmdNow = 0;}
|
||||
~mdCommander() {}
|
||||
|
||||
void say(char *what) ;
|
||||
|
||||
void acMainMenu();
|
||||
void check();
|
||||
void create();
|
||||
void check(bool run);
|
||||
void create(bool run);
|
||||
void doHeader();
|
||||
void driver();
|
||||
void digestibleLines();
|
||||
void eppMainMenu();
|
||||
void flushCommand();
|
||||
void flushCommand(int which,bool allowsZero);
|
||||
void greet();
|
||||
void help();
|
||||
void info();
|
||||
void renew();
|
||||
void sendCommand();
|
||||
void showCommand();
|
||||
void trash();
|
||||
void transfer();
|
||||
void transferCheck();
|
||||
void update();
|
||||
void info(bool run);
|
||||
bool isValidCmd(int which,bool isX)
|
||||
{ if (which == 0 && !isX) return false;
|
||||
if (which > cmdsNow) return false;
|
||||
if (!isX && which < 1) return false;
|
||||
if (which && deleted[which-1]) return false;
|
||||
return true;
|
||||
}
|
||||
void poll(bool run);
|
||||
void prompt(bool forStrings);
|
||||
void queryTransfer(bool run);
|
||||
void renew(bool run);
|
||||
void sendCommand(int which);
|
||||
void showCommand(bool all);
|
||||
void trash(bool run);
|
||||
void transfer(bool run);
|
||||
void update(bool run);
|
||||
|
||||
bool epp(char *command);
|
||||
bool editingCommand(bool run);
|
||||
bool runCommand(bool all);
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -78,7 +78,9 @@ using boost::asio::ip::udp;
|
|||
#define CURRENT_DEBUG NORMAL_DEBUG
|
||||
#endif
|
||||
#define NOT_OK -1
|
||||
#ifndef OK
|
||||
#define OK 0
|
||||
#endif
|
||||
#define RUNNING_DIR "/tmp"
|
||||
|
||||
#define theMachine thisConfig->machine[thisConfig->thisMachineContext]
|
||||
|
|
|
@ -4,37 +4,21 @@
|
|||
*/
|
||||
|
||||
|
||||
#define MAX_CMD_ARGS 20
|
||||
#define N_EPP_VERBS 9
|
||||
#define INSTRUMENT 1
|
||||
#define MAX_DEVICE 5 // Machine, Up to 3 optical instruments and the US i/f (Phase II and later)
|
||||
#define MD_DATAGRAM_RESPONSE_SIZE 16 // First three bytes after header are ACK or NAK
|
||||
#define MD_DEFAULT_RULE 0
|
||||
// Our rendering of SCPI-99
|
||||
// Custom behaviors greater than this
|
||||
#define MD_DEFAULT_DEVICE_PROTOCOL 1
|
||||
#define MD_DEFAULT_IP "208.109.106.127"
|
||||
#define MD_EPOCH date()
|
||||
#define MD_HEARTBEAT 1 // Network peer heartbeat in seconds.
|
||||
#define MD_HEARTBEAT_SIZE 8 // Network peer heartbeat in seconds.
|
||||
#define MD_MAX_DATAGRAM (63*1024) // 1K short of the IPV4 max
|
||||
#define MD_NAME "AusReg Cliever"
|
||||
#define MD_VERSION " 1.0 "
|
||||
#define MD_REFRESH 10 // default milliseconds between telemetry frame updates
|
||||
#define MD_TYPE "EPP CLIENT-SERVER" // Change per your MD derivation
|
||||
#define MACHINE 0 // Null machine type impliss MD_TYPE
|
||||
#define OK 0
|
||||
|
||||
#define OTHERCLIENT 2
|
||||
|
||||
enum md_units {
|
||||
|
||||
centimeters,
|
||||
millimeters,
|
||||
microns,
|
||||
nanometers,
|
||||
angstroms,
|
||||
volts,
|
||||
cubiccentemeter
|
||||
|
||||
};
|
||||
|
||||
enum md_datagrams {
|
||||
|
||||
|
|
Loading…
Reference in New Issue