This commit is contained in:
zolliker
2007-09-19 06:41:36 +00:00
parent b59af433e4
commit 4f4e539569
17 changed files with 883 additions and 61 deletions

View File

@ -54,6 +54,7 @@ typedef struct Context {
char *grpFmt;
int exact;
char *callName; /* the called name of the object (different from obj->name in case of an alias) */
int enumText; /* show enum text */
} Context;
static char *loggerDir = NULL;
@ -405,6 +406,7 @@ static int ParExecute(SConnection *con, SicsInterp *sics, void *object, int argc
return 1;
}
if (argc == 1) { /* no args */
ctx->enumText = 0;
ParDo(con, o, PAR_SHOW, "");
if (ctx->returnValue == 0) {
SCSendOK(con);
@ -450,6 +452,11 @@ static int ParExecute(SConnection *con, SicsInterp *sics, void *object, int argc
ParListSugar(con, o);
ParEnd();
return 1;
} else if (strcmp(argv[1],"enumText") == 0) {
if (argc == 3) {
ctx->enumText = 1;
ParDo(con, o, PAR_SHOW, argv[2]);
}
} else {
if (strcmp(argv[1], "=") == 0) {
ctx->argc = argc - 2;
@ -459,6 +466,7 @@ static int ParExecute(SConnection *con, SicsInterp *sics, void *object, int argc
logIt = 1;
} else {
if (argc == 2) {
ctx->enumText = 0;
ParDo(con, o, PAR_SHOW, argv[1]);
} else {
ctx->argc = argc - 2;
@ -792,7 +800,7 @@ ParOp ParWhat(int numeric) {
if (ctx->access < 0) {
ctx->access = usInternal;
}
if (ctx->access < SCGetRights(ctx->con) && !RestoreMode()) {
if (!RestoreMode() && ctx->access < SCGetRights(ctx->con)) {
ctx->returnValue = ILLPRIV;
break;
}
@ -895,6 +903,17 @@ void ParOut(char *buf) {
ParPrintf(NULL, eWarning, "%s %*s%*s%s%s", buffer, l, p, m, ctx->listTail, logged, saved);
break;
case PAR_SHOW:
if (ctx->enumText) {
i = strtol(buf, &endp, 0);
if (endp != buf) {
p = ParInt2Text(i);
} else {
p == NULL;
}
if (p == NULL) p = "undefined";
ParPrintf(NULL, eValue, "%s", p);
break;
}
if (ctx->parName[0]) { p=" "; } else { p=""; }
ParPrintf(NULL, eValue, "%s%s%s = %s", ctx->callName, p, ctx->parName, buf);
break;
@ -1013,10 +1032,10 @@ void ParFloat(float *value, float defValue) {
return;
}
if (ctx->valueArg) {
f = strtod(ctx->valueArg, &endp);
if (endp == ctx->valueArg) {
f = ParText2Int(ctx->valueArg);
if (f < 0) {
f = ParText2Int(ctx->valueArg);
if (f < 0) {
f = strtod(ctx->valueArg, &endp);
if (endp == ctx->valueArg) {
ctx->returnValue = ILLNUM;
break;
}
@ -1061,10 +1080,10 @@ void ParInt(int *value, int defValue) {
return;
}
if (ctx->valueArg) {
i = strtol(ctx->valueArg, &endp, 0);
if (endp == ctx->valueArg) {
i = ParText2Int(ctx->valueArg);
if (i < 0) {
i = ParText2Int(ctx->valueArg);
if (i < 0) {
i = strtol(ctx->valueArg, &endp, 0);
if (endp == ctx->valueArg) {
ctx->returnValue = ILLNUM;
break;
}
@ -1081,6 +1100,10 @@ void ParInt(int *value, int defValue) {
ParOut(buf);
}
break;
case GET_OP:
ctx->value = *value;
ctx->returnValue = 1;
break;
case INIT_OP:
*value = defValue;
break;
@ -1145,7 +1168,7 @@ int ParCmd(ParCommand cmd, void *userarg) {
if (ctx->action != PAR_SHOW && ctx->action != PAR_SET) return 0;
if (ctx->access < 0) ctx->access=usUser;
if (ctx->access < SCGetRights(ctx->con) && !RestoreMode()) {
if (!RestoreMode() && ctx->access < SCGetRights(ctx->con)) {
ctx->returnValue = ILLPRIV;
ctx->action = PAR_NOOP;
return 0;