This commit is contained in:
Ren RenJuan 2014-01-14 03:00:23 +00:00
parent 15404b4bcd
commit 92c478d0d2
5 changed files with 112 additions and 72 deletions

View File

@ -55,31 +55,8 @@
<storageModule moduleId="refreshScope"/>
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets">
<buildTargets>
<target name="clean" path="ACTK1_3_2" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildTarget>clean</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
</target>
<target name="all" path="ACTK1_3_2" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildTarget>all</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
</target>
<target name="tests" path="ACTK1_3_2" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>tests</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
</target>
<target name="libACTK1_0.so" path="ACTK1_0" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>libACTK1_0.so</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
@ -87,6 +64,7 @@
</target>
<target name="clean" path="ACTK1_0" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>clean</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
@ -94,7 +72,6 @@
</target>
<target name="tests" path="ACTK1_0" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>tests</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
@ -102,7 +79,6 @@
</target>
<target name="dirs" path="ACTK1_0" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>dirs</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
@ -110,13 +86,27 @@
</target>
<target name="dclean" path="ACTK1_0" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>dclean</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
</target>
<target name="all" path="ACTK1_0" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildTarget>all</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
</target>
<target name="clean" path="ACTK1_3_2" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>clean</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
</target>
<target name="all" path="ACTK1_3_2" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>all</buildTarget>
@ -124,8 +114,16 @@
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
</target>
<target name="tests" path="ACTK1_3_2" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildTarget>tests</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
</target>
<target name="clean" path="APIG" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>clean</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
@ -133,7 +131,6 @@
</target>
<target name="dirs" path="APIG" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>dirs</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
@ -141,7 +138,6 @@
</target>
<target name="ausreg_cd" path="APIG" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>ausreg_cd</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
@ -149,38 +145,21 @@
</target>
<target name="apig-cli" path="APIG" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>apig-cli</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
</target>
<target name="cliever" path="AusRegCliever" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildTarget>cliever</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
</target>
<target name="clean" path="AusRegCliever" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<target name="build/commander.o" path="APIG" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>clean</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
</target>
<target name="distclean" path="AusRegCliever" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>distclean</buildTarget>
<buildTarget>build/commander.o</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
</target>
<target name="AusRegEPPTK.so" path="AusRegEPPTK" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>all</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
@ -188,7 +167,6 @@
</target>
<target name="tests" path="AusRegEPPTK" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>tests</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
@ -196,12 +174,33 @@
</target>
<target name="clean" path="AusRegEPPTK" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>clean</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
</target>
<target name="cliever" path="AusRegCliever" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>cliever</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
</target>
<target name="clean" path="AusRegCliever" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildTarget>clean</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
</target>
<target name="distclean" path="AusRegCliever" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildTarget>distclean</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
</target>
</buildTargets>
</storageModule>
</cproject>

View File

@ -88,7 +88,7 @@ build/cdLogger.o: client/cdLogger.cpp include/cdLogger.h
build/cliever.o: client/ausreg-cd.cpp include/*.h
$(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
build/clientDaemonConfig.o: client/clientDaemonConfig.cpp include/clientDaemonConfig.h
$(CC) $(CFLAGS) client/clientDaemonConfig.cpp -c -o build/clientDaemonConfig.o $(SINCL)
build/clientDaemon.o: client/clientDaemon.cpp include/*.h
@ -97,7 +97,7 @@ build/clientDaemon.o: client/clientDaemon.cpp include/*.h
build/mdBehavior.o: client/mdBehavior.cpp include/mdBehavior.h
$(CC) $(CFLAGS) client/mdBehavior.cpp $(SINCL) -c -o build/mdBehavior.o
build/commander.o: client/commander.cpp include/mdCommander.h
build/commander.o: client/commander.cpp include/mdCommander.h include/eppargs.h
$(CC) $(CFLAGS) client/commander.cpp $(SINCL) -c -o build/commander.o
build/$(CLIENT)-cd: $(ACOBJS)

Binary file not shown.

View File

@ -1,13 +1,12 @@
#include <ncurses.h>
#include "ausreg-cd.h"
#include "eppargs.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" };
char theBanner[256];
int targetHost = 0;
@ -37,18 +36,41 @@ void mdCommander::doHeader() {
mvprintw(1,(col-strlen(wwork))/2,"%s",wwork);
}
void mdCommander::digestibleLines() {
int mdCommander::selectArg() {
char buffer[256],*sp;
int nLines=0, wrow=5;
char legend1[80]="Arg types: ",selection[10];
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);
say((char *)"Select arg string type");
prompt(true);
mvgetstr(row-1,2,selection);
thisArg = atoi(selection);
}
void mdCommander::getArgStringsByType() {
eppArgDef *sp1;
char buffer[256],*sp;
int i, nLines=0, wrow=7;
nocbreak();
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;
sp1 = (eppArgDef *)malloc(sizeof(eppArgDef));
sp = (char *) malloc(strlen(buffer)+1);
sp1->name = commandsNow[cmdNow];
sp1->s = sp;
commandArgs[cmdNow][argsNow[cmdNow]++] = sp1;
strcpy(sp,buffer);
}
else break;
@ -75,6 +97,7 @@ void mdCommander::driver() {
activeCommands = 0;
cmdNow = 0;
cmdsNow = 0;
initEPPArgs();
memset(commandsNow,0,sizeof(commandsNow));
memset(argsNow,0,sizeof(argsNow));
initscr();
@ -316,8 +339,10 @@ void mdCommander::flushCommand(int which,bool allOfEm){
if (!allOfEm) {
if (argsNow[which]) {
for (i=0;i<argsNow[which];i++)
for (i=0;i<argsNow[which];i++) {
free(commandArgs[which][i]->s);
free(commandArgs[which][i]);
}
}
argsNow[which] = 0;
deleted[which] = true;
@ -325,8 +350,10 @@ void mdCommander::flushCommand(int which,bool allOfEm){
} else for (i=0;i<cmdsNow;i++) {
if (!deleted[i]) {
if (argsNow[i]) {
for (j=0;j<argsNow[i];j++)
for (j=0;j<argsNow[i];j++) {
free(commandArgs[i][j]->s);
free(commandArgs[i][j]);
}
}
else deleted[i] = false; // back to start state.
}
@ -356,8 +383,10 @@ void mdCommander::showCommand(bool allOfEm){
sprintf(wwork,"EPP directive: %s",befehlJetzt);
mvprintw(5,2,wwork);
for (nthItem=0;nthItem < argsNow[cmdNow];nthItem++) {
ASSERT(commandArgs[cmdNow][nthItem]);
sprintf(wwork,"%d %s",nthItem+1,(commandArgs[cmdNow][nthItem]));
ASSERT(commandArgs[cmdNow][nthItem]->s);
sprintf(wwork,"%d %s %s",nthItem+1,
eppArgs[commandsNow[cmdNow]].names[commandArgs[cmdNow][nthItem]->name],
(commandArgs[cmdNow][nthItem]->s));
mvprintw(7+nthItem,2,wwork);
}
@ -368,7 +397,7 @@ void mdCommander::showCommand(bool allOfEm){
for ( i=0, nthItem=0; nthItem < cmdsNow;nthItem++ ) {
if (!deleted[nthItem]) {
sprintf(wwork,"%d %s %s",nthItem+1,cmdNames[commandsNow[nthItem]],commandArgs[nthItem][0]);
sprintf(wwork,"%d %s %s",nthItem+1,cmdNames[commandsNow[nthItem]],commandArgs[nthItem][0]->s);
mvprintw(7+(i++),2,wwork);
}
@ -386,15 +415,16 @@ bool mdCommander::editingCommand(bool run){
const char *befehlJetzt = cmdNames[commandsNow[cmdNow]];
char sp[256],*spp;
eppArgDef *arg;
int editLine,length;
doHeader();
mvprintw(3,(col-strlen(befehlJetzt))/2,befehlJetzt);
if (!run) {
if (!argsNow[cmdNow]) {
say((char *)"Enter command arg strings, just enter to end data entry, ? to main menu");
prompt(true);
digestibleLines();
selectArg();
say((char *)"Enter arg string(s), just enter to end");
getArgStringsByType();
} else {
nocbreak();
while(true) {
@ -404,10 +434,13 @@ const char *befehlJetzt = cmdNames[commandsNow[cmdNow]];
mvgetstr(row-1,2,sp);
if (!strlen(sp)) goto done;
if (*sp == 'A' || *sp == 'a') {
selectArg();
prompt(true);
mvgetstr(row-1,2,sp);
if (length=strlen(sp)) {
spp = commandArgs[cmdNow][argsNow[cmdNow]++] = (char *) malloc(length+1);
arg = (eppArgDef *)malloc(sizeof(eppArgDef));
commandArgs[cmdNow][argsNow[cmdNow]++] = arg;
spp = commandArgs[cmdNow][argsNow[cmdNow]++]->s = (char *) malloc(length+1);
strcpy(spp,sp);
}
}
@ -417,8 +450,8 @@ const char *befehlJetzt = cmdNames[commandsNow[cmdNow]];
prompt(true);
mvgetstr(row-1,2,sp);
if (length=strlen(sp)) {
free (commandArgs[cmdNow][editLine-1]);
spp = commandArgs[cmdNow][editLine-1] = (char *) malloc(strlen(sp)+1);
free (commandArgs[cmdNow][editLine-1]->s);
spp = commandArgs[cmdNow][editLine-1]->s = (char *) malloc(strlen(sp)+1);
strcpy(spp,sp);
}
}

View File

@ -3,14 +3,21 @@
#define MAX_CMDS 20
typedef
struct {
int name;
char *s;
}
eppArgDef;
class mdCommander {
bool acceptingInput,deleted[MAX_CMDS];
bool EPPmode; // RFC 9
int activeCommands, argsNow[MAX_CMDS], cmdNow, cmdsNow, mdStdDevIdx;
int row,col;
int row,col, thisArg;
int commandsNow[MAX_CMDS]; // type index into cmdNames
char *commandArgs[MAX_CMDS][MAX_CMD_ARGS];
eppArgDef *commandArgs[MAX_CMDS][MAX_CMD_ARGS];
char wwork[1024];
public:
@ -27,7 +34,7 @@ class mdCommander {
void create(bool run);
void doHeader();
void driver();
void digestibleLines();
void getArgStringsByType();
void eppMainMenu();
void flushCommand(int which,bool allowsZero);
void greet();
@ -44,6 +51,7 @@ class mdCommander {
void prompt(bool forStrings);
void queryTransfer(bool run);
void renew(bool run);
int selectArg();
void sendCommand(int which);
void showCommand(bool all);
void trash(bool run);