- fixed mess with SCWrite / SCPrintf due to changes in conman.c
This commit is contained in:
@ -34,7 +34,7 @@ struct SctController {
|
||||
DevSer *devser;
|
||||
Hdb *node; /* the controller node */
|
||||
SConnection *conn;
|
||||
int verbose;
|
||||
SConnection *debugConn;
|
||||
FILE *fd;
|
||||
};
|
||||
|
||||
@ -337,13 +337,13 @@ int SctCallInContext(SConnection * con, char *script, Hdb * node,
|
||||
int ret, l;
|
||||
char *result = NULL;
|
||||
int iRet = 1;
|
||||
int verbose = controller->verbose;
|
||||
char path[MAX_HDB_PATH];
|
||||
|
||||
PushContext(node, controller);
|
||||
if (verbose) {
|
||||
if (controller->debugConn) {
|
||||
GetHdbPath(node, path, sizeof path);
|
||||
SCPrintf(con, eLog, "%6.3f script: (on %s) %s", secondsOfMinute(), path, script);
|
||||
SCPf(SCPureSockWrite, controller->debugConn, eLog,
|
||||
"%6.3f script: (on %s) %s", secondsOfMinute(), path, script);
|
||||
}
|
||||
if (controller->fd != NULL) {
|
||||
GetHdbPath(node, path, sizeof path);
|
||||
@ -362,8 +362,9 @@ int SctCallInContext(SConnection * con, char *script, Hdb * node,
|
||||
result++;
|
||||
}
|
||||
}
|
||||
if (verbose) {
|
||||
SCPrintf(con, eLog, "%6.3f error: %s", secondsOfMinute(), result);
|
||||
if (controller->debugConn) {
|
||||
SCPf(SCPureSockWrite, controller->debugConn, eLog,
|
||||
"%6.3f error: %s", secondsOfMinute(), result);
|
||||
}
|
||||
if(controller->fd != NULL){
|
||||
fprintf(controller->fd, "%6.3f error: %s\n", secondsOfMinute(), result);
|
||||
@ -438,8 +439,9 @@ static char *SctActionHandler(void *actionData, char *lastReply,
|
||||
if (lastReply != NULL) {
|
||||
SetProp(node, controller->node, "result", lastReply);
|
||||
if (*lastReply != '\0') {
|
||||
if (!commError && controller->verbose) {
|
||||
SCPrintf(con, eLog, "%6.3f reply : %s\n", secondsOfMinute(), lastReply);
|
||||
if (!commError && controller->debugConn) {
|
||||
SCPf(SCPureSockWrite, controller->debugConn, eLog,
|
||||
"%6.3f reply : %s\n", secondsOfMinute(), lastReply);
|
||||
}
|
||||
if(!commError && controller->fd != NULL) {
|
||||
fprintf(controller->fd, "%6.3f reply : %s\n", secondsOfMinute(), lastReply);
|
||||
@ -518,9 +520,8 @@ static char *SctActionHandler(void *actionData, char *lastReply,
|
||||
emsg = GetHdbProp(node, eprop);
|
||||
if (emsg == NULL || con != controller->conn) {
|
||||
GetHdbPath(node, path, sizeof path);
|
||||
snprintf(msg,sizeof(msg),"ERROR: action {%s} in {%s} node %s:\nERROR: %s",
|
||||
data->name, origScript, path, result);
|
||||
SCPureSockWrite(con, msg,eLogError);
|
||||
SCPrintf(con, eLogError,
|
||||
"ERROR: action {%s} in {%s} node %s:\nERROR: %s", data->name, origScript, path, result);
|
||||
if(data != NULL && data->controller != NULL){
|
||||
traceIO(data->controller->node->name, "ERROR: action {%s} in {%s} node %s:ERROR: %s",
|
||||
data->name, origScript, path, result);
|
||||
@ -602,7 +603,7 @@ static char *SctActionHandler(void *actionData, char *lastReply,
|
||||
*/
|
||||
iMacro = SCinMacro(con);
|
||||
con->iMacro = 0;
|
||||
SCPureSockWrite(con, "o.k.", eLog);
|
||||
SCWrite(con, "o.k.", eLog);
|
||||
SCsetMacro(con, iMacro);
|
||||
}
|
||||
}
|
||||
@ -638,9 +639,9 @@ static char *SctActionHandler(void *actionData, char *lastReply,
|
||||
send = GetProp(node, controller->node, "send");
|
||||
if (send == NULL)
|
||||
send = "";
|
||||
if (controller->verbose) {
|
||||
snprintf(msg,sizeof(msg),"%6.3f send : %s", secondsOfMinute(), send);
|
||||
SCPureSockWrite(con, msg,eLog);
|
||||
if (controller->debugConn) {
|
||||
SCPf(SCPureSockWrite, controller->debugConn, eLog,
|
||||
"%6.3f send : %s", secondsOfMinute(), send);
|
||||
}
|
||||
if (controller->fd != NULL) {
|
||||
fprintf(controller->fd, "%6.3f send : %s\n", secondsOfMinute(), send);
|
||||
@ -1469,8 +1470,9 @@ static char *TransactionHandler(void *actionData, char *lastReply,
|
||||
|
||||
if (st->sent == 0) {
|
||||
st->sent = 1;
|
||||
if (st->controller->verbose) {
|
||||
SCPrintf(st->con, eLog, "%6.3f send : %s", secondsOfMinute(), st->command);
|
||||
if (st->controller->debugConn) {
|
||||
SCPf(SCPureSockWrite, st->controller->debugConn, eLog,
|
||||
"%6.3f send : %s", secondsOfMinute(), st->command);
|
||||
}
|
||||
if (st->controller->fd != NULL) {
|
||||
fprintf(st->controller->fd, "%6.3f send : %s\n", secondsOfMinute(), st->command);
|
||||
@ -1506,8 +1508,9 @@ static char *SendHandler(void *actionData, char *lastReply,
|
||||
|
||||
if (st->sent == 2) {
|
||||
SetHdbProperty(st->controller->node, "reply", lastReply);
|
||||
if (st->controller->verbose) {
|
||||
SCPrintf(st->con, eLog, "%6.3f reply : %s", secondsOfMinute(), lastReply);
|
||||
if (st->controller->debugConn) {
|
||||
SCPf(SCPureSockWrite, st->controller->debugConn, eLog,
|
||||
"%6.3f reply : %s", secondsOfMinute(), lastReply);
|
||||
}
|
||||
if (st->controller->fd != NULL) {
|
||||
fprintf(st->controller->fd, "%6.3f reply : %s\n", secondsOfMinute(), lastReply);
|
||||
@ -1802,29 +1805,34 @@ static int SctLog(pSICSOBJ ccmd, SConnection * con,
|
||||
return 1;
|
||||
}
|
||||
|
||||
static hdbCallbackReturn SctDebugCallback(Hdb * node, void *userData,
|
||||
hdbMessage * msg)
|
||||
static int SctDebug(pSICSOBJ ccmd, SConnection * con,
|
||||
Hdb * cmdNode, Hdb * par[], int nPar)
|
||||
{
|
||||
hdbDataMessage *mm;
|
||||
SctController *controller = userData;
|
||||
SConnection *con;
|
||||
int i;
|
||||
SctController *c;
|
||||
char *result;
|
||||
hdbValue *v = &cmdNode->child->value;
|
||||
int value;
|
||||
|
||||
mm = GetHdbSetMessage(msg);
|
||||
if (mm != NULL) {
|
||||
i = mm->v->v.intValue;
|
||||
if (i < 0) {
|
||||
controller->verbose = 0;
|
||||
DevDebugMode(controller->devser, -1);
|
||||
} else if (i == 0) {
|
||||
controller->verbose = 1;
|
||||
DevDebugMode(controller->devser, -1);
|
||||
c = (SctController *) ccmd->pPrivate;
|
||||
if (nPar != 0) {
|
||||
value = v->v.intValue;
|
||||
if (c->debugConn) {
|
||||
SCDeleteConnection(c->debugConn);
|
||||
}
|
||||
if (value < 0) {
|
||||
c->debugConn = NULL;
|
||||
DevDebugMode(c->devser, -1);
|
||||
} else {
|
||||
controller->verbose = 1;
|
||||
DevDebugMode(controller->devser, i);
|
||||
c->debugConn = SCCopyConnection(con);
|
||||
if (value == 0) {
|
||||
DevDebugMode(c->devser, -1);
|
||||
} else {
|
||||
DevDebugMode(c->devser, value);
|
||||
}
|
||||
}
|
||||
return hdbContinue;
|
||||
}
|
||||
SCPrintf(con, eValue, "%d", v->v.intValue);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void SctDeferredFree(void *data)
|
||||
@ -1851,6 +1859,9 @@ static void SctKillController(void *c)
|
||||
if (controller->conn) {
|
||||
SCDeleteConnection(controller->conn);
|
||||
}
|
||||
if (controller->debugConn) {
|
||||
SCDeleteConnection(controller->debugConn);
|
||||
}
|
||||
DevKill(controller->devser);
|
||||
controller->devser = NULL;
|
||||
|
||||
@ -1896,7 +1907,7 @@ static int SctMakeController(SConnection * con, SicsInterp * sics,
|
||||
|
||||
controller = calloc(1, sizeof(*controller));
|
||||
assert(controller);
|
||||
controller->verbose = 0;
|
||||
controller->debugConn = NULL;
|
||||
|
||||
ccmd = MakeSICSOBJv(objName, "SctController", HIPNONE, usSpy);
|
||||
controller->node = ccmd->objectNode;
|
||||
@ -1986,8 +1997,6 @@ static int SctMakeController(SConnection * con, SicsInterp * sics,
|
||||
"reconnect", usMugger, MakeSICSFunc(SctReconnect));
|
||||
AddSICSHdbPar(cmd, "hostport", usMugger, MakeHdbText(""));
|
||||
|
||||
par = AddSICSHdbPar(controller->node, "debug", usUser, MakeHdbInt(-1));
|
||||
|
||||
cmd = AddSICSHdbPar(controller->node,
|
||||
"actions", usUser, MakeSICSFunc(SctListActions));
|
||||
|
||||
@ -2011,9 +2020,9 @@ static int SctMakeController(SConnection * con, SicsInterp * sics,
|
||||
/* get the actual timeout value */
|
||||
SctTimeout(ccmd, con, cmd, &par, 0);
|
||||
|
||||
cb = MakeHipadabaCallback(SctDebugCallback, controller, NULL);
|
||||
if (cb)
|
||||
AppendHipadabaCallback(par, cb);
|
||||
cmd = AddSICSHdbPar(controller->node, "debug", usUser, MakeSICSFunc(SctDebug));
|
||||
AddSICSHdbPar(cmd, "value", usUser, MakeHdbInt(-1));
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -2050,9 +2059,9 @@ void SctInit(void)
|
||||
AddCmd("makesctcomtask", SctMakeComTask);
|
||||
}
|
||||
|
||||
int SctVerbose(SctController * c)
|
||||
SConnection *SctDebugConn(SctController * c)
|
||||
{
|
||||
return c->verbose;
|
||||
return c->debugConn;
|
||||
}
|
||||
|
||||
DevSer *SctGetDevser(void *data)
|
||||
|
@ -30,11 +30,11 @@ void SctQueueNode(SctController * controller, Hdb * node,
|
||||
int SctCallInContext(SConnection * con, char *script, Hdb * node,
|
||||
SctController * controller, char **resPtr);
|
||||
/**
|
||||
* test the controller verbose flag
|
||||
* \param c The SctController to test
|
||||
* \return 1 for verbose, 0 for silent
|
||||
* get the controller debug connection (if any)
|
||||
* \param c The SctController
|
||||
* \return the connection for verbose, NULL for silent
|
||||
*/
|
||||
int SctVerbose(SctController * c);
|
||||
SConnection *SctDebugConn(SctController * c);
|
||||
/**
|
||||
* retrieve the device serializer
|
||||
* \param data A pointer to a SICSObject representing a SctController
|
||||
|
Reference in New Issue
Block a user