DRDE/APIG/client/commander.cpp

669 lines
18 KiB
C++
Raw Permalink Normal View History

2014-01-13 01:29:22 +00:00
#include <ncurses.h>
2014-01-11 19:34:15 +00:00
#include "ausreg-cd.h"
2014-01-13 23:19:10 +00:00
#define ASSERT(expr) \
if (!(expr)) { \
std::cerr << __FILE__ << ":" << __LINE__ << ":" << #expr << std::endl;}
2014-01-14 19:58:27 +00:00
const char *banner = CD_NAME " " CD_VERSION " compiled on " __DATE__ " @ " __TIME__ " (%d/%d)";
2014-01-13 01:29:22 +00:00
char theBanner[256];
int targetHost = 0;
2014-01-18 23:09:39 +00:00
const char *xsdPath = "./resources";
const char *xmlPath = "./acInputQueue";
const char *xmlWork = "./xml";
2014-01-13 01:29:22 +00:00
mdDG mdg;
2014-01-17 17:26:02 +00:00
using namespace boost::interprocess;
extern shared_memory_object shm;
2014-01-18 23:09:39 +00:00
#include "eppargs.h"
2014-01-19 07:45:43 +00:00
#include "eppxml.h"
2014-01-18 23:09:39 +00:00
int is_numeric(const char *p) { int i = strlen(p),j=0;
if (*p) {
char c;
while ((c=*p++)) { j++;
if (!isdigit(c)) {
if (j == i) return 2;
else return 0;
}
}
return 1;
}
return 0;
}
2014-01-13 01:29:22 +00:00
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);
}
2014-01-14 03:00:23 +00:00
int mdCommander::selectArg() {
2014-01-13 01:29:22 +00:00
2014-01-19 05:13:48 +00:00
bool didSelect = false;
2014-01-18 23:27:04 +00:00
char legend1[80]="Elements: ",selection[10];
2014-01-14 03:00:23 +00:00
int i, wrow=5;
for (i=0;i < eppArgs[commandsNow[cmdNow]].n;i++) {
sprintf(wwork," %d %s ",i+1,eppArgs[commandsNow[cmdNow]].names[i]);
strcat(legend1,wwork);
}
mvprintw(wrow,2,(char *)legend1);
2014-01-19 05:13:48 +00:00
while (!didSelect) {
say((char *)"Select element to edit");
2014-01-14 03:00:23 +00:00
prompt(true);
mvgetstr(row-1,2,selection);
thisArg = atoi(selection);
2014-01-19 05:13:48 +00:00
if (thisArg >= 1 and thisArg <= eppArgs[commandsNow[cmdNow]].n + 1)
didSelect = true;
else beep();
} -
thisArg--;
2014-01-14 03:00:23 +00:00
}
void mdCommander::getArgStringsByType() {
eppArgDef *sp1;
char buffer[256],*sp;
int i, nLines=0, wrow=7;
2014-01-13 01:29:22 +00:00
nocbreak();
2014-01-14 03:00:23 +00:00
2014-01-13 23:19:10 +00:00
for (;argsNow[cmdNow] < MAX_CMD_ARGS;)
{memset(buffer,0,sizeof(buffer));
mvgetstr(wrow++,2,buffer);
if (strlen(buffer)) {
2014-01-14 03:00:23 +00:00
sp1 = (eppArgDef *)malloc(sizeof(eppArgDef));
sp = (char *) malloc(strlen(buffer)+1);
sp1->name = commandsNow[cmdNow];
sp1->s = sp;
commandArgs[cmdNow][argsNow[cmdNow]++] = sp1;
2014-01-13 23:19:10 +00:00
strcpy(sp,buffer);
}
else break;
2014-01-13 01:29:22 +00:00
}
cbreak();
prompt(false);
}
void mdCommander::prompt(bool forStrings) {
if (forStrings)
mvprintw(row-1,1,">>");
else
2014-01-13 23:19:10 +00:00
mvprintw(row-1,1,">");
2014-01-13 01:29:22 +00:00
}
void mdCommander::driver() {
2014-01-19 07:45:43 +00:00
bool rc, x, eppMainActive =false;
2014-01-13 01:29:22 +00:00
char next,rawString[128],work[128];
const char *mdErrCode = "";
int i,commandLength;
2014-01-13 01:29:22 +00:00
activeCommands = 0;
cmdNow = 0;
cmdsNow = 0;
2014-01-14 03:00:23 +00:00
initEPPArgs();
2014-01-13 01:29:22 +00:00
memset(commandsNow,0,sizeof(commandsNow));
memset(argsNow,0,sizeof(argsNow));
initscr();
cbreak();
2014-01-18 20:35:18 +00:00
getmaxyx(stdscr,row,col);
2014-01-19 05:13:48 +00:00
if (row < 30 || col < 80) { beep();
2014-01-18 20:35:18 +00:00
std::cerr << "Terminal too small for AC commander.";
}
greet();
while(acceptingInput) {
2014-01-14 04:51:30 +00:00
refresh();
2014-01-13 01:29:22 +00:00
mvprintw(row-1,1,"> ");
next=0;
i=0;
memset(rawString,0,sizeof(rawString));
while(next != '\012') {
2014-01-13 01:29:22 +00:00
next = mvgetch(row-1,2+i);
rawString[i++] = next;
2014-01-19 05:13:48 +00:00
if (i > (sizeof(rawString) - 1)) { beep();
2014-01-13 01:29:22 +00:00
say((char *)"Max length exceeded!");
continue;
}
2014-01-13 01:29:22 +00:00
if (next == '\012')
rawString[strlen(rawString)-1] = 0;
}
if (!strlen(rawString)) continue;
2014-01-19 07:45:43 +00:00
if (eppMainActive) {
int ion,nAll; char cmdChars[9] = {'c','i','p','t','C','R','U','D','T'};
eppMainActive = false;
switch(rawString[0]) {
case '?': help();
break;
case 'L':
for (nAll=0;nAll<6;nAll++)
if (loadSchema(nAll)) beep();
break;
case 'W':
for (nAll=0;nAll<9;nAll++)
writeCommand(cmdChars[nAll]);
break;
case 'V':
ion=atoi(&rawString[1]);
viSchema(ion);
break;
case 'l':
ion=atoi(&rawString[1]);
if (loadSchema(ion)) beep();
break;
case 'w':
writeCommand(rawString[1]);
break;
case 'v':
viBlankForm(rawString[1]);
break;
default: beep();
break;
}
continue;
}
2014-01-13 01:29:22 +00:00
if (strlen(rawString) == 1) {
2014-01-11 19:34:15 +00:00
switch(rawString[0]) {
2014-01-13 01:29:22 +00:00
case '1': ; case '2': ; case '3': ; case '4': ; case '5': ;
case '6': ; case '7': ; case '8': ; case '9':
goto retarget ;
2014-01-15 16:44:02 +00:00
case 'q': goto quit;
2014-01-13 01:29:22 +00:00
case '!': runCommand(false);
break;
2014-01-11 19:34:15 +00:00
case '?': help();
break;
case 'e': eppMainMenu();
2014-01-19 07:45:43 +00:00
eppMainActive = true;
2014-01-11 19:34:15 +00:00
break;
case 'a': acMainMenu();
break;
2014-01-13 01:29:22 +00:00
case 'c': commandsNow[(cmdNow=cmdsNow++)]; activeCommands++;
check(false);
break;
case 'p': commandsNow[(cmdNow=cmdsNow++)]; activeCommands++;
poll(false);
2014-01-11 19:34:15 +00:00
break;
2014-01-13 01:29:22 +00:00
case 'i': commandsNow[(cmdNow=cmdsNow++)]; activeCommands++;
info(false);
2014-01-11 19:34:15 +00:00
break;
2014-01-13 01:29:22 +00:00
case 't': commandsNow[(cmdNow=cmdsNow++)]; activeCommands++;
queryTransfer(false);
2014-01-11 19:34:15 +00:00
break;
2014-01-13 01:29:22 +00:00
case 'C': commandsNow[(cmdNow=cmdsNow++)]; activeCommands++;
create(false);
2014-01-11 19:34:15 +00:00
break;
2014-01-13 01:29:22 +00:00
case 'R': commandsNow[(cmdNow=cmdsNow++)]; activeCommands++;
renew(false);
2014-01-11 19:34:15 +00:00
break;
2014-01-13 01:29:22 +00:00
case 'U': commandsNow[(cmdNow=cmdsNow++)]; activeCommands++;
update(false);
2014-01-11 19:34:15 +00:00
break;
2014-01-13 01:29:22 +00:00
case 'D': commandsNow[(cmdNow=cmdsNow++)]; activeCommands++;
trash(false);
2014-01-11 19:34:15 +00:00
break;
2014-01-13 01:29:22 +00:00
case 'T': commandsNow[(cmdNow=cmdsNow++)]; activeCommands++;
transfer(false);
2014-01-11 19:34:15 +00:00
break;
}
continue;
}
2014-01-13 01:29:22 +00:00
if (strlen(rawString) == 2) {
2014-01-11 19:34:15 +00:00
if (!strcmp(rawString,"??")) {
2014-01-13 01:29:22 +00:00
showCommand(true);
continue;
}
if (!strcmp(rawString,"!!")) {
runCommand(true);
2014-01-11 19:34:15 +00:00
continue;
}
}
2014-01-13 01:29:22 +00:00
if (is_numeric(rawString) >= 1) {
retarget:
targetHost = atoi(rawString);
doHeader();
continue;
}
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();}
2014-01-13 23:19:10 +00:00
help();
2014-01-13 01:29:22 +00:00
break;
case 'S':
if (isValidCmd(targetCmd,false)) {
cmdNow = --targetCmd;
sendCommand(cmdNow);
doHeader();
}
2014-01-19 05:13:48 +00:00
else {beep(); say((char *)"Invalid Command Index");}
2014-01-13 01:29:22 +00:00
break;
case 'X':
if (!targetCmd) {targetCmd = 0; x = true;}
else {targetCmd--; x = false;}
if (isValidCmd(targetCmd,true)) {
flushCommand(targetCmd,x);
doHeader();
}
2014-01-19 05:33:21 +00:00
else {say((char *)"Invalid Command Index"); beep();}
2014-01-13 01:29:22 +00:00
break;
}
continue;
}
2014-01-13 01:29:22 +00:00
if (strlen(rawString) >= 3 && strlen(rawString) <= 5 )
2014-01-18 20:35:18 +00:00
{if (!strcmp(rawString,"loG")) {
2014-01-13 01:29:22 +00:00
sprintf(wwork,"cut -b 1-%d /tmp/ausreg-cd.log | less",col);
system(wwork);
clear();
continue;
}
2014-01-18 20:35:18 +00:00
if (!strcmp(rawString,"log")) {
sprintf(wwork,"cut -b 1-%d /tmp/ausreg-cd-ui.log | less",col);
system(wwork);
clear();
continue;
}
2014-01-13 01:29:22 +00:00
if (!strcmp(rawString,"mlog")) {
sprintf(wwork,"cut -b 1-%d /tmp/drde-cliever.log | less",col);
system(wwork);
clear();
continue;
}
2014-01-19 08:55:03 +00:00
if (!strcmp(rawString,"tkvi")) { char *lastLog="./logs/lastLog";
2014-01-19 08:33:16 +00:00
sprintf(wwork,"vim %s",lastLog);
system(wwork);
clear();
continue;
}
2014-01-13 01:29:22 +00:00
if (!strcmp(rawString,"done")) {
goto done;
}
2014-01-15 16:44:02 +00:00
if (!strcmp(rawString,"quit")) { quit:
thisConfig->terminateRequest = true;
2014-01-19 08:55:03 +00:00
if (thisConfig->daemonProcess > 2) {
2014-01-14 19:58:27 +00:00
sprintf(work,"kill -9 %d",thisConfig->daemonProcess);
2014-01-19 08:55:03 +00:00
system(work); }
2014-01-17 17:26:02 +00:00
shm.remove("ausreg-cd-global");
2014-01-17 17:44:14 +00:00
sprintf(work,"rm /tmp/ausreg-cd.lock");
2014-01-19 05:13:48 +00:00
system(work);
2014-01-18 20:35:18 +00:00
sprintf(work,"rm /tmp/ausreg-cd-ui.log");
system(work);
sprintf(work,"rm /tmp/ausreg-cd.log");
2014-01-17 17:33:39 +00:00
system(work);
2014-01-13 01:29:22 +00:00
goto done;
}
continue;
}
2014-01-11 19:34:15 +00:00
}
2014-01-13 01:29:22 +00:00
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() {
2014-01-13 01:29:22 +00:00
const char *title="AusReg Cliever Commander",
2014-01-28 18:16:48 +00:00
*warn="NB: this program is meant to be powerful, reliable, and fast, not safe or user friendly",
2014-01-19 05:33:21 +00:00
*prompt="Enter ? or command";
2014-01-13 01:29:22 +00:00
2014-01-14 19:58:27 +00:00
sprintf(theBanner,banner,thisConfig->shellProcess,thisConfig->daemonProcess);
2014-01-13 01:29:22 +00:00
mvprintw(0,(col-strlen(banner))/2,"%s",theBanner);
mvprintw(row/2,(col-strlen(title))/2,"%s",title);
2014-01-15 16:44:02 +00:00
mvprintw((row/2)+2,(col-strlen(warn))/2,"%s",warn);
2014-01-13 01:29:22 +00:00
mvprintw(row-2,1,"%s",prompt);
refresh();
acceptingInput = true;
}
void mdCommander::help() {
2014-01-14 04:51:30 +00:00
const char *prompt="Enter command";
2014-01-13 01:29:22 +00:00
doHeader();
2014-01-14 04:51:30 +00:00
mvprintw(5,10," a - AC system");
mvprintw(6,10," e - EPP ");
mvprintw(7,10," ? - this screen");
2014-01-13 01:29:22 +00:00
mvprintw(8,10," ?? - display commands");
2014-01-14 04:51:30 +00:00
mvprintw(9,10," ! - run ");
mvprintw(10,10," !! - run all active");
mvprintw(11,10," C<n> - make <n> the current command");
mvprintw(12,10," E<n> - display/edit <n> ");
2014-01-18 23:09:39 +00:00
mvprintw(13,10," W<n> - write <n> to ./acInputQueue*");
2014-01-14 04:51:30 +00:00
mvprintw(14,10," X<n> - discard ");
mvprintw(15,10," <n> - make <n> the target device");
2014-01-19 08:33:16 +00:00
mvprintw(16,10," loG - cd UI log");
mvprintw(17,10," log - cd daemon log*");
mvprintw(18,10," mlog - master daemon log");
2014-01-19 08:55:03 +00:00
mvprintw(19,10," tkvi - xmledit ./logs/lastLog (last toolkit log)");
2014-01-19 08:33:16 +00:00
mvprintw(20,10," done - terminate commander but not process");
mvprintw(21,10," q/quit - end process tree, delete log files");
mvprintw(23,5,"<n> is an integer, above active everywhere outside data entry (>>)");
mvprintw(24,5,"no space before <n>, X0/W0 to delete/write all commands.");
mvprintw(25,5,"*will be inaccessible if another user running cd on this computer.");
2014-01-14 04:51:30 +00:00
mvprintw(row-2,1,"%s",prompt);
refresh();
}
2014-01-11 19:34:15 +00:00
void mdCommander::eppMainMenu() {
2014-01-13 01:29:22 +00:00
doHeader();
mvprintw(5,10," Create a new EPP command");
2014-01-19 23:40:41 +00:00
mvprintw(7,10, "Queries");
mvprintw(8,10, " c - check");
mvprintw(9,10, " i - info");
2014-01-15 16:44:02 +00:00
mvprintw(10,10," p - poll");
mvprintw(11,10," t - transfer query");
mvprintw(12,10,"Transactions");
mvprintw(13,10," C - create");
mvprintw(14,10," R - renew");
mvprintw(15,10," U - update");
mvprintw(16,10," D - delete");
mvprintw(17,10," T - transfer");
2014-01-19 07:45:43 +00:00
mvprintw(19,10,"IO (active this screen only)");
2014-01-19 23:40:41 +00:00
mvprintw(20,10," l<n> - load schema <n>");
mvprintw(21,10," L - load schemata");
2014-01-19 07:45:43 +00:00
mvprintw(22,10," w<letter> - write blank XML form for 1 above ... ");
mvprintw(23,10," W - or all to ./xml.");
mvprintw(24,10," v<letter> - vi/xmledit a blank XML form");
mvprintw(25,10," V<n> - vi/xmledit a XSDs");
2014-01-19 05:33:21 +00:00
2014-01-19 20:56:09 +00:00
mvprintw(7,50, "EPP command schemata are defined by XSDs in ./resources.");
mvprintw(8,50, "These are verified to be IETF standard plus the launch phase");
mvprintw(9,50, "extensions used by major Registries.");
2014-01-19 23:40:41 +00:00
mvprintw(11,50,"Load schema means to activate the code generated from the xsds");
mvprintw(12,50,"and attach it to the commands.");
mvprintw(14,50,"Without this you'll see stub commands in the internal editor.");
2014-01-19 05:33:21 +00:00
2014-01-19 23:40:41 +00:00
mvprintw(16,50," n = 1 : epp-1.0.xsd 2: domain-1-0.xsd 3: contact-1.0.xsd");
mvprintw(17,50," 4: registrant-1.0.xsd 5: host-1-0.xsd 6: kv-1.0.xsd");
2014-01-28 18:16:48 +00:00
mvprintw(18,50," 7: launch-1.0.xsd 8: mark-1-0.xsd 9: signedMark-1.0.xsd");
mvprintw(20,70,"Commands are actually executed by the AC master daemon using,");
mvprintw(21,70,"either the standard defined transactions or specific boost ");
mvprintw(22,70,"FSM implementations (AC BRE) with proprietary biz rules");
mvprintw(23,70,"so use the mlog command to track execution,");
2014-01-11 19:34:15 +00:00
2014-01-19 07:45:43 +00:00
say((char *)"Action sequence or ? to exit");
2014-01-11 19:34:15 +00:00
}
void mdCommander::acMainMenu() {
2014-01-14 04:51:30 +00:00
char selection[10];
2014-01-13 01:29:22 +00:00
doHeader();
mvprintw(5,(col-strlen("AC System Directives"))/2,"AC System Directives");
2014-01-11 19:34:15 +00:00
2014-01-13 01:29:22 +00:00
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");
2014-01-14 04:51:30 +00:00
mvprintw(20,10,"Only active on this screen, there's no confirmation.");
say((char *)"Select Action letter or anything else to exit");
prompt(false);
mvgetstr(row-1,2,selection);
switch(selection[0]) {
case 'H':
break;
case 'L':
break;
case 'B':
break;
}
help();
2014-01-11 19:34:15 +00:00
}
2014-01-13 01:29:22 +00:00
bool sendEPPCommand() {
2014-01-13 01:29:22 +00:00
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;
2014-01-13 01:29:22 +00:00
if (!activeCommands) {say((char *)"There is no active command."); goto done;}
say((char *)"Command execution temporarily disabled.");
done: return value;
}
//--------------------------------
void mdCommander::flushCommand(int which,bool allOfEm){
int i,j;
if (!allOfEm) {
if (argsNow[which]) {
2014-01-14 03:00:23 +00:00
for (i=0;i<argsNow[which];i++) {
free(commandArgs[which][i]->s);
2014-01-13 01:29:22 +00:00
free(commandArgs[which][i]);
2014-01-14 03:00:23 +00:00
}
2014-01-13 01:29:22 +00:00
}
argsNow[which] = 0;
deleted[which] = true;
activeCommands--;
} else for (i=0;i<cmdsNow;i++) {
if (!deleted[i]) {
if (argsNow[i]) {
2014-01-14 03:00:23 +00:00
for (j=0;j<argsNow[i];j++) {
free(commandArgs[i][j]->s);
2014-01-13 01:29:22 +00:00
free(commandArgs[i][j]);
2014-01-14 03:00:23 +00:00
}
2014-01-13 01:29:22 +00:00
}
2014-01-13 23:19:10 +00:00
else deleted[i] = false; // back to start state.
2014-01-13 01:29:22 +00:00
}
cmdNow = 0;
cmdsNow = 0;
activeCommands = 0;
memset(commandArgs,0,sizeof(commandArgs));
memset(argsNow,0,sizeof(argsNow));
}
};
void mdCommander::sendCommand(int which){
2014-01-13 01:29:22 +00:00
say((char *)"Command processing disabled here during OTE Basic Testing");
};
void mdCommander::showCommand(bool allOfEm){
2014-01-13 01:29:22 +00:00
int activethCommand=0,i,nthItem;
const char *befehlJetzt = cmdNames[commandsNow[cmdNow]];
2014-01-13 01:29:22 +00:00
doHeader();
2014-01-13 01:29:22 +00:00
if (!activeCommands) {say((char *)"There is no active command."); goto done;}
2014-01-13 01:29:22 +00:00
if (!allOfEm) {
sprintf(wwork,"EPP directive: %s",befehlJetzt);
mvprintw(5,2,wwork);
for (nthItem=0;nthItem < argsNow[cmdNow];nthItem++) {
2014-01-14 03:00:23 +00:00
ASSERT(commandArgs[cmdNow][nthItem]->s);
sprintf(wwork,"%d %s %s",nthItem+1,
eppArgs[commandsNow[cmdNow]].names[commandArgs[cmdNow][nthItem]->name],
(commandArgs[cmdNow][nthItem]->s));
2014-01-13 23:19:10 +00:00
mvprintw(7+nthItem,2,wwork);
2014-01-13 01:29:22 +00:00
}
} else {
mvprintw(5,2,"These commands are pending/active: ");
2014-01-13 23:19:10 +00:00
for ( i=0, nthItem=0; nthItem < cmdsNow;nthItem++ ) {
2014-01-13 01:29:22 +00:00
2014-01-13 23:19:10 +00:00
if (!deleted[nthItem]) {
2014-01-14 03:00:23 +00:00
sprintf(wwork,"%d %s %s",nthItem+1,cmdNames[commandsNow[nthItem]],commandArgs[nthItem][0]->s);
2014-01-13 01:29:22 +00:00
mvprintw(7+(i++),2,wwork);
}
}
}
done: return;
};
//--------------------------------
// EPP Queries and Commands
//-------------------------------
bool mdCommander::editingCommand(bool run){
const char *befehlJetzt = cmdNames[commandsNow[cmdNow]];
2014-01-13 23:19:10 +00:00
char sp[256],*spp;
2014-01-14 03:00:23 +00:00
eppArgDef *arg;
2014-01-13 23:19:10 +00:00
int editLine,length;
2014-01-13 01:29:22 +00:00
doHeader();
mvprintw(3,(col-strlen(befehlJetzt))/2,befehlJetzt);
if (!run) {
if (!argsNow[cmdNow]) {
2014-01-14 03:00:23 +00:00
selectArg();
2014-01-19 05:13:48 +00:00
sprintf(sp,"Enter strings for '%s', enter to end",eppArgs[commandsNow[cmdNow]].names[thisArg]);
say(sp);
2014-01-14 03:00:23 +00:00
getArgStringsByType();
2014-01-13 01:29:22 +00:00
} else {
2014-01-13 23:19:10 +00:00
nocbreak();
while(true) {
showCommand(false);
2014-01-14 04:51:30 +00:00
say((char *)"line no. to replace, A to add, enter to return");
2014-01-13 23:19:10 +00:00
prompt(false);
2014-01-13 01:29:22 +00:00
mvgetstr(row-1,2,sp);
2014-01-13 23:19:10 +00:00
if (!strlen(sp)) goto done;
if (*sp == 'A' || *sp == 'a') {
2014-01-14 03:00:23 +00:00
selectArg();
2014-01-13 23:19:10 +00:00
prompt(true);
mvgetstr(row-1,2,sp);
if (length=strlen(sp)) {
2014-01-14 03:00:23 +00:00
arg = (eppArgDef *)malloc(sizeof(eppArgDef));
commandArgs[cmdNow][argsNow[cmdNow]++] = arg;
spp = commandArgs[cmdNow][argsNow[cmdNow]++]->s = (char *) malloc(length+1);
2014-01-13 23:19:10 +00:00
strcpy(spp,sp);
}
}
if (is_numeric(sp) >= 1) {
2014-01-13 01:29:22 +00:00
editLine = atoi(sp);
2014-01-13 23:19:10 +00:00
if (editLine > 1 && editLine < argsNow[cmdNow]) {
prompt(true);
mvgetstr(row-1,2,sp);
if (length=strlen(sp)) {
2014-01-14 03:00:23 +00:00
free (commandArgs[cmdNow][editLine-1]->s);
spp = commandArgs[cmdNow][editLine-1]->s = (char *) malloc(strlen(sp)+1);
2014-01-13 23:19:10 +00:00
strcpy(spp,sp);
}
}
2014-01-13 01:29:22 +00:00
}
} // editing loop
2014-01-13 23:19:10 +00:00
done: cbreak();
} // editing block
2014-01-13 01:29:22 +00:00
} // run / execute
else {
say((char *)"Press 'Y' to confirm");
2014-01-14 04:51:30 +00:00
prompt(false);
mvgetstr(row-1,2,sp);
if (sp[0] == 'Y') return false;
2014-01-13 01:29:22 +00:00
}
2014-01-14 04:51:30 +00:00
return true;
2014-01-13 01:29:22 +00:00
};
2014-01-14 19:58:27 +00:00
//
// Wrappers for specific EPP commands.
//
2014-01-13 01:29:22 +00:00
void mdCommander::check(bool run) {
if (!commandsNow[cmdNow]) commandsNow[cmdNow] = 0;
if (!editingCommand(run)) {
2014-01-13 23:19:10 +00:00
} else help();
}
2014-01-13 01:29:22 +00:00
void mdCommander::create(bool run){
if (!commandsNow[cmdNow]) commandsNow[cmdNow] = 4;
if (!editingCommand(run)) {
2014-01-13 23:19:10 +00:00
} else help();
2014-01-13 01:29:22 +00:00
};
void mdCommander::info(bool run){
if (!commandsNow[cmdNow]) commandsNow[cmdNow] = 1;
if (!editingCommand(run)) {
2014-01-13 23:19:10 +00:00
} else help();
2014-01-13 01:29:22 +00:00
};
void mdCommander::renew(bool run){
if (!commandsNow[cmdNow]) commandsNow[cmdNow] = 5;
if (!editingCommand(run)) {
2014-01-13 23:19:10 +00:00
} else help();
2014-01-13 01:29:22 +00:00
};
void mdCommander::queryTransfer(bool run){
if (!commandsNow[cmdNow]) commandsNow[cmdNow] = 3;
if (!editingCommand(run)) {
2014-01-13 23:19:10 +00:00
} else help();
2014-01-13 01:29:22 +00:00
};
void mdCommander::trash(bool run){
if (!commandsNow[cmdNow]) commandsNow[cmdNow] = 7;
if (!editingCommand(run)) {
2014-01-13 23:19:10 +00:00
} else help();
2014-01-13 01:29:22 +00:00
};
void mdCommander::transfer(bool run){
if (!commandsNow[cmdNow]) commandsNow[cmdNow] = 8;
if (!editingCommand(run)) {
2014-01-13 23:19:10 +00:00
} else help();
2014-01-13 01:29:22 +00:00
};
void mdCommander::poll(bool run){
if (!commandsNow[cmdNow]) commandsNow[cmdNow] = 2;
if (!editingCommand(run)) {
2014-01-13 23:19:10 +00:00
} else help();
2014-01-13 01:29:22 +00:00
};
void mdCommander::update(bool run){
if (!commandsNow[cmdNow]) commandsNow[cmdNow] = 6;
if (!editingCommand(run)) {
2014-01-13 23:19:10 +00:00
} else help();
2014-01-13 01:29:22 +00:00
};