First commit towards replacing pCon-> with someFunc(pCon)
This is accompanied with the removal of dead code in conman.c and else
This commit is contained in:
33
protocol.c
33
protocol.c
@ -307,8 +307,8 @@ static int ProtocolSet(SConnection * pCon, Protocol * pPro, char *pProName)
|
||||
SCSetWriteFunc(pCon, pPro->defaultWriter);
|
||||
break;
|
||||
}
|
||||
pCon->iProtocolID = proID;
|
||||
pMaster->iProtocolID = proID;
|
||||
SCSetProtocolID(pCon,proID);
|
||||
SCSetProtocolID(pMaster,proID);
|
||||
SCSendOK(pCon);
|
||||
return 1;
|
||||
}
|
||||
@ -323,7 +323,7 @@ int ProtocolGet(SConnection * pCon, void *pData, char *pProName, int len)
|
||||
}
|
||||
|
||||
if (pData == NULL) {
|
||||
pCon->iProtocolID = 0;
|
||||
SCSetProtocolID(pCon,0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -331,12 +331,12 @@ int ProtocolGet(SConnection * pCon, void *pData, char *pProName, int len)
|
||||
if (0 == pPro->isDefaultSet) {
|
||||
pPro->defaultWriter = SCGetWriteFunc(pCon);
|
||||
pPro->isDefaultSet = 1;
|
||||
pCon->iProtocolID = 0;
|
||||
SCSetProtocolID(pCon,0);
|
||||
}
|
||||
strlcpy(pProName, pPro->pProList[pCon->iProtocolID], len);
|
||||
strlcpy(pProName, pPro->pProList[SCGetProtocolID(pCon)], len);
|
||||
return 1;
|
||||
#if 0
|
||||
Index = pCon->iProtocolID;
|
||||
Index = SCGetProtocolID(pCon);
|
||||
|
||||
/* check list of protocols for valid name */
|
||||
switch (Index) {
|
||||
@ -449,7 +449,7 @@ static int InitDefaultProtocol(SConnection * pCon, Protocol * pPro)
|
||||
if (0 == pPro->isDefaultSet) {
|
||||
pPro->defaultWriter = SCGetWriteFunc(pCon);
|
||||
pPro->isDefaultSet = 1;
|
||||
pCon->iProtocolID = PROTSICS;
|
||||
SCSetProtocolID(pCon,PROTSICS);
|
||||
}
|
||||
return pPro->isDefaultSet;
|
||||
}
|
||||
@ -499,7 +499,7 @@ struct json_object *mkJSON_Object(SConnection * pCon, char *pBuffer,
|
||||
}
|
||||
/* field 1: connID */
|
||||
json_object_object_add(msg_json, "con",
|
||||
json_object_new_int(pCon->ident));
|
||||
json_object_new_int(SCGetIdent(pCon)));
|
||||
/* field 2: taskID */
|
||||
json_object_object_add(msg_json, "trans", json_object_new_int(taskID));
|
||||
/* deviceID */
|
||||
@ -566,11 +566,7 @@ int SCWriteJSON_String(SConnection * pCon, char *pBuffer, int iOut)
|
||||
return 1;
|
||||
|
||||
/* log it for any case */
|
||||
if (pCon->pSock) {
|
||||
iRet = pCon->pSock->sockid;
|
||||
} else {
|
||||
iRet = 0;
|
||||
}
|
||||
iRet = SCGetSockHandle(pCon);
|
||||
|
||||
/* write to commandlog if user or manager privilege */
|
||||
if (SCGetRights(pCon) <= usUser && !SCinMacro(pCon)) {
|
||||
@ -628,13 +624,13 @@ char *GetProtocolName(SConnection * pCon)
|
||||
InitDefaultProtocol(pCon, pPro);
|
||||
|
||||
/* check list of protocols for valid name */
|
||||
switch (pCon->iProtocolID) {
|
||||
switch (SCGetProtocolID(pCon)) {
|
||||
case PROTSICS: /* default = psi_sics */
|
||||
case PROTNORM: /* normal (connection start default) */
|
||||
case PROTCODE: /* outcodes */
|
||||
case PROTJSON: /* json */
|
||||
case PROTACT: /* act */
|
||||
return strdup(pPro->pProList[pCon->iProtocolID]);
|
||||
return strdup(pPro->pProList[SCGetProtocolID(pCon)]);
|
||||
break;
|
||||
default:
|
||||
return strdup("invalid");
|
||||
@ -645,17 +641,14 @@ char *GetProtocolName(SConnection * pCon)
|
||||
/*----------------------------------*/
|
||||
int GetProtocolID(SConnection * pCon)
|
||||
{
|
||||
if (NULL != pCon) {
|
||||
return pCon->iProtocolID;
|
||||
}
|
||||
return -1;
|
||||
return SCGetProtocolID(pCon);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
writeFunc GetProtocolWriteFunc(SConnection * pCon)
|
||||
{
|
||||
if (pCon != NULL) {
|
||||
switch (pCon->iProtocolID) {
|
||||
switch (SCGetProtocolID(pCon)) {
|
||||
case PROTCODE: /* outcodes */
|
||||
return SCWriteWithOutcode;
|
||||
break;
|
||||
|
Reference in New Issue
Block a user