Commit 2e4c846c authored by Christoffer Ackelman's avatar Christoffer Ackelman

Refactored pwr_lst to remove redundant pointer to data,

the data struct already contain the linked list,
so the linked list do not need pointers to the data.
parent a557a8ee
......@@ -59,27 +59,24 @@ typedef struct sAttribute sAttribute;
typedef struct sObject sObject;
typedef struct sSupObject sSupObject;
LstType(sAttribute);
LstType(sSupObject);
struct sObject {
tree_sNode tn;
pwr_tObjid oid;
int sup_c;
int attr_c;
LstHead(sAttribute) attr_l;
struct LstHead attr_l;
};
struct sAttribute {
LstLink(sAttribute) attr_l;
struct LstHead attr_l;
pwr_sAttrRef aref;
pwr_tClassId cid;
int sup_c;
LstHead(sSupObject) sup_l;
struct LstHead sup_l;
};
struct sSupObject {
LstLink(sSupObject) sup_l;
struct LstHead sup_l;
pwr_tObjid oid;
void* p;
};
......@@ -100,8 +97,8 @@ static alimsrv_sSupDataBuf* buildBuffer(
sObject* op;
sAttribute* ap;
sSupObject* sp;
LstLink(sAttribute) * al;
LstLink(sSupObject) * sl;
struct LstHead * al;
struct LstHead * sl;
pwr_tStatus sts;
*size = 0;
......@@ -123,15 +120,15 @@ static alimsrv_sSupDataBuf* buildBuffer(
bp->NoOfSupAttr = op->attr_c;
bap = bp->AttrSupList;
for (al = LstFir(&op->attr_l); al != LstEnd(&op->attr_l); al = LstNex(al)) {
ap = LstObj(al);
LstForEach(al, &op->attr_l) {
ap = LstEntry(al, sAttribute, attr_l);
bap->SupAttr = ap->aref;
bap->NoOfSupObjs = ap->sup_c;
bap->SupClass = ap->cid;
bsp = bap->SupList;
for (sl = LstFir(&ap->sup_l); sl != LstEnd(&ap->sup_l); sl = LstNex(sl)) {
sp = LstObj(sl);
LstForEach(sl, &ap->sup_l) {
sp = LstEntry(sl, sSupObject, sup_l);
bsp->SupObjid = sp->oid;
if (ap->cid == pwr_cClass_ASup) {
pwr_sClass_ASup* asup = (pwr_sClass_ASup*)sp->p;
......@@ -160,12 +157,12 @@ static alimsrv_sSupDataBuf* buildBuffer(
static sAttribute* findAttribute(
sObject* op, pwr_sAttrRef* aref, pwr_tClassId cid)
{
LstLink(sAttribute) * al;
struct LstHead * al;
sAttribute* ap = NULL;
for (al = LstFir(&op->attr_l); al != LstEnd(&op->attr_l); al = LstNex(al)) {
if (aref->Offset == LstObj(al)->aref.Offset) {
ap = LstObj(al);
LstForEach(al, &op->attr_l) {
if (aref->Offset == LstEntry(al, sAttribute, attr_l)->aref.Offset) {
ap = LstEntry(al, sAttribute, attr_l);
break;
}
}
......@@ -175,9 +172,9 @@ static sAttribute* findAttribute(
if (ap == NULL)
exit(2);
LstIni(&ap->attr_l);
LstIni(&ap->sup_l);
(void)LstIns(&op->attr_l, ap, attr_l);
LstInit(&ap->attr_l);
LstInit(&ap->sup_l);
LstInsert(&op->attr_l, &ap->attr_l);
op->attr_c++;
ap->cid = cid;
ap->aref = *aref;
......@@ -204,13 +201,13 @@ static void init()
op = tree_Find(&sts, ltp, &asp->Attribute.Objid);
if (op == NULL) {
op = tree_Insert(&sts, ltp, &asp->Attribute.Objid);
LstIni(&op->attr_l);
LstInit(&op->attr_l);
}
ap = findAttribute(op, &asp->Attribute, pwr_cClass_ASup);
sp = calloc(1, sizeof(*sp));
(void)LstIns(LstEnd(&ap->sup_l), sp, sup_l);
LstInsert(&ap->sup_l, &sp->sup_l);
sp->oid = oid;
sp->p = asp;
op->sup_c++;
......@@ -225,13 +222,13 @@ static void init()
op = tree_Find(&sts, ltp, &dsp->Attribute.Objid);
if (op == NULL) {
op = tree_Insert(&sts, ltp, &dsp->Attribute.Objid);
LstIni(&op->attr_l);
LstInit(&op->attr_l);
}
ap = findAttribute(op, &dsp->Attribute, pwr_cClass_DSup);
sp = calloc(1, sizeof(*sp));
(void)LstIns(LstEnd(&ap->sup_l), sp, sup_l);
LstInsert(&ap->sup_l, &sp->sup_l);
sp->oid = oid;
sp->p = dsp;
op->sup_c++;
......
......@@ -92,16 +92,8 @@ typedef struct s_DSup sDSup;
typedef struct s_DSupComp sDSupComp;
typedef union u_Event uEvent;
LstType(sActive);
LstType(sApplActive);
LstType(sAppl);
LstType(sBlock);
LstType(sOutunit);
LstType(sProcLink);
LstType(sSupActive);
struct s_ProcLink {
LstLink(sProcLink) proc_l;
struct LstHead proc_l;
mh_eSource source;
pwr_tNodeIndex nix;
qcom_sQid qid;
......@@ -111,8 +103,8 @@ struct s_ProcLink {
struct s_Appl {
sProcLink link; /* Link in process list */
LstLink(sAppl) appl_l; /* Link in application list */
LstHead(sApplActive) active_l; /* Head of application alarm list */
struct LstHead appl_l; /* Link in application list */
struct LstHead active_l; /* Head of application alarm list */
pwr_tUInt32 activeMessages; /* Active messages */
mh_eApplState state;
mh_eApplState oldState;
......@@ -121,7 +113,7 @@ struct s_Appl {
};
struct s_Active {
LstLink(sActive) active_l; /* Link in active list */
struct LstHead active_l; /* Link in active list */
pwr_tUInt32 idx; /* Event index of alarm */
pwr_tUInt32 returnIdx; /* Event index of return message */
pwr_tUInt32 ackIdx; /* Event index of ack message */
......@@ -161,7 +153,7 @@ struct s_NodeInfo {
struct s_Block {
sActive link;
LstLink(sBlock) block_l;
struct LstHead block_l;
mh_sOutunitBlock outunitBlock;
mh_sOutunitBlock outunitUnblock;
mh_sEventId targetId;
......@@ -254,9 +246,9 @@ struct s_Sup {
struct s_SupActive {
sActive link;
LstLink(sSupActive) sup_l;
LstLink(sSupActive) detect_l;
LstLink(sSupActive) timer_l;
struct LstHead sup_l;
struct LstHead detect_l;
struct LstHead timer_l;
mh_eAgent agent;
mh_uEventInfo alarmVisibility;
mh_eSupType supType;
......@@ -304,7 +296,7 @@ struct s_DSupComp {
struct s_ApplActive {
sActive link;
LstLink(sApplActive) active_l;
struct LstHead active_l;
mh_sApplMessage message;
pwr_tTime ackTime;
pwr_tObjid ackOutunit;
......@@ -316,7 +308,7 @@ struct s_ApplActive {
struct s_Outunit {
sProcLink link; /* Link in process list */
LstLink(sOutunit) outunit_l; /* Link in outunit list */
struct LstHead outunit_l; /* Link in outunit list */
pwr_tTime birthTime; /* Time when outunit was started */
pwr_tObjid outunit; /* Object id of outunit object */
mh_eOutunitType type; /* Type of outunit */
......@@ -376,18 +368,18 @@ struct sLocal {
pwr_sClass_MessageHandler* emon;
pwr_tOName emonName;
pwr_tObjid emonObject;
LstHead(sOutunit) outunit_l;
struct LstHead outunit_l;
mh_sHead head;
LstHead(sActive) active_l;
struct LstHead active_l;
sEventList* event_l;
LstHead(sProcLink) proc_l;
LstHead(sAppl) appl_l;
LstHead(sSupActive) sup_l;
LstHead(sBlock) block_l;
LstHead(sBlock) blockFree_l;
LstHead(sSupActive) detect_l;
LstHead(sSupActive) timer_l;
LstHead(sApplActive) handlerFree_l;
struct LstHead proc_l;
struct LstHead appl_l;
struct LstHead sup_l;
struct LstHead block_l;
struct LstHead blockFree_l;
struct LstHead detect_l;
struct LstHead timer_l;
struct LstHead handlerFree_l;
eSupListState supListState;
tree_sTable* eventTab;
pwr_tBoolean newBlock;
......@@ -603,16 +595,16 @@ int main()
eventListInit();
LstIni(&l.outunit_l);
LstIni(&l.active_l);
LstIni(&l.proc_l);
LstIni(&l.appl_l);
LstIni(&l.sup_l);
LstIni(&l.block_l);
LstIni(&l.blockFree_l);
LstIni(&l.detect_l);
LstIni(&l.timer_l);
LstIni(&l.handlerFree_l);
LstInit(&l.outunit_l);
LstInit(&l.active_l);
LstInit(&l.proc_l);
LstInit(&l.appl_l);
LstInit(&l.sup_l);
LstInit(&l.block_l);
LstInit(&l.blockFree_l);
LstInit(&l.detect_l);
LstInit(&l.timer_l);
LstInit(&l.handlerFree_l);
l.supListState = eSupListState_Init;
......@@ -659,13 +651,13 @@ static sActive* activeListGet(pwr_tUInt32 idx)
static void activeListInsert(sActive* ap, sEvent* ep, mh_eSource source)
{
int inserted;
LstLink(sActive) * al;
LstLink(sBlock) * bl;
struct LstHead * al;
struct LstHead * bl;
/* Check that not already inserted */
inserted = 0;
for (al = LstFir(&l.active_l); al != LstEnd(&l.active_l); al = LstNex(al)) {
if (ap == LstObj(al)) {
LstForEach(al, &l.active_l) {
if (ap == LstEntry(al, sActive, active_l)) {
inserted = 1;
break;
}
......@@ -675,8 +667,8 @@ static void activeListInsert(sActive* ap, sEvent* ep, mh_eSource source)
ap->source = source;
if (!inserted) {
al = LstEnd(&l.active_l);
LstIns(al, ap, active_l);
al = &l.active_l;
LstInsert(al, &ap->active_l);
}
switch (ap->event) {
......@@ -691,8 +683,8 @@ static void activeListInsert(sActive* ap, sEvent* ep, mh_eSource source)
break;
case mh_eEvent_Block:
case mh_eEvent_Reblock:
bl = LstEnd(&l.block_l);
LstIns(bl, (sBlock*)ap, block_l);
bl = &l.block_l;
LstInsert(bl, &((sBlock*)ap)->block_l);
++l.emon->BlockCount;
break;
case mh_eEvent_Info:
......@@ -712,11 +704,11 @@ static void activeListRemove(sActive* ap)
sApplActive* aap;
sBlock* bp;
if (LstIsNul(&ap->active_l))
if (LstIsNull(&ap->active_l))
return;
LstRem(&ap->active_l);
LstNul(&ap->active_l);
LstRemove(&ap->active_l);
LstNull(&ap->active_l);
ap->idx = 0;
ap->ackIdx = 0;
ap->returnIdx = 0;
......@@ -736,8 +728,8 @@ static void activeListRemove(sActive* ap)
case mh_eEvent_Reblock:
case mh_eEvent_CancelBlock:
bp = (sBlock*)ap;
LstRem(&bp->block_l);
LstNul(&bp->block_l);
LstRemove(&bp->block_l);
LstNull(&bp->block_l);
--l.emon->BlockCount;
break;
case mh_eEvent_Info:
......@@ -773,8 +765,8 @@ static void activeListRemove(sActive* ap)
|| ap->source == mh_eSource_Handler) {
aap = (sApplActive*)ap;
LstRem(&aap->active_l); /* Remove from application alarm list */
LstNul(&aap->active_l);
LstRemove(&aap->active_l); /* Remove from application alarm list */
LstNull(&aap->active_l);
if (aap->ap->activeMessages > 0)
--aap->ap->activeMessages;
if (ap->source == mh_eSource_Application)
......@@ -814,10 +806,10 @@ static void applDisconnect(mh_sHead* hp, sAppl* ap, mh_uApplReply* Reply)
/* Cancel all active messages */
LstRem(&ap->appl_l); /* Remove from application list */
LstNul(&ap->appl_l);
LstRem(&ap->link.proc_l); /* Remove from process link */
LstNul(&ap->link.proc_l);
LstRemove(&ap->appl_l); /* Remove from application list */
LstNull(&ap->appl_l);
LstRemove(&ap->link.proc_l); /* Remove from process link */
LstNull(&ap->link.proc_l);
free(ap); /* Free control block */
Reply->Sts = MH__SUCCESS;
}
......@@ -844,7 +836,7 @@ static void applGetMsgInfo(mh_sHead* hp, sAppl* ap, mh_uApplReply* Reply)
{
pwr_tUInt32* TargetIdxP = (pwr_tUInt32*)(hp + 1);
sApplActive* aap;
LstLink(sApplActive) * al;
struct LstHead * al;
switch (ap->state) {
case mh_eApplState_Connected:
......@@ -861,12 +853,12 @@ static void applGetMsgInfo(mh_sHead* hp, sAppl* ap, mh_uApplReply* Reply)
return;
}
for (al = LstFir(&ap->active_l); al != LstEnd(&ap->active_l); al = LstNex(al))
if (LstObj(al)->link.idx >= *TargetIdxP)
LstForEach(al, &l.active_l)
if (LstEntry(al, sApplActive, active_l)->link.idx >= *TargetIdxP)
break;
if (al != LstEnd(&ap->active_l)) {
aap = LstObj(al);
if (al != &ap->active_l) {
aap = LstEntry(al, sApplActive, active_l);
Reply->Info.Sts = MH__SUCCESS;
Reply->Info.Message = aap->message;
} else
......@@ -947,7 +939,7 @@ static void applMessage(mh_sHead* hp, sAppl* ap, mh_uApplReply* reply)
}
/* Insert in application alarm list */
(void)LstIns(&ap->active_l, aap, active_l);
LstInsert(&ap->active_l, &aap->active_l);
aap->ap = ap;
++ap->activeMessages;
......@@ -1070,35 +1062,35 @@ static void applReturn(mh_sHead* hp, sAppl* ApplP, mh_uApplReply* reply)
static sBlock* blockListAlloc()
{
LstLink(sBlock) * bl;
LstHead(sBlock) * ll;
struct LstHead * bl;
struct LstHead * ll;
sBlock* bp;
const int alloc = 100;
int i;
ll = &l.blockFree_l;
if (LstEmp(ll)) {
if (LstEmpty(ll)) {
bp = (sBlock*)calloc(alloc, sizeof(sBlock));
if (bp != NULL) {
for (i = 0; i < alloc; i++, bp++)
LstIns(ll, bp, link.active_l);
LstInsert(ll, &bp->link.active_l);
l.emon->FreeCount += alloc;
} else {
return NULL;
}
}
bl = LstFir(ll);
LstRem(bl);
bl = ll->next;
LstRemove(bl);
--l.emon->FreeCount;
return LstObj(bl);
return LstEntry(bl, sBlock, block_l);
}
static void blockListFree(sBlock* bp)
{
memset(bp, 0, sizeof(*bp));
LstIns(&l.blockFree_l, bp, link.active_l);
LstInsert(&l.blockFree_l, &bp->link.active_l);
++l.emon->FreeCount;
return;
}
......@@ -1189,7 +1181,7 @@ static void cancelAlarm(sActive* ap, char* text)
static void sendAlarmStatus(sOutunit* op)
{
LstLink(sActive) * al;
struct LstHead * al;
sEvent* ep;
sActive* ap;
mh_sAlarmStatus* msg;
......@@ -1199,8 +1191,8 @@ static void sendAlarmStatus(sOutunit* op)
/* Count alarms */
int count = 0;
for (al = LstFir(&l.active_l); al != LstEnd(&l.active_l); al = LstNex(al)) {
ap = LstObj(al);
LstForEach(al, &l.active_l) {
ap = LstEntry(al, sActive, active_l);
if (!ap->detect_etp)
continue;
......@@ -1247,8 +1239,8 @@ static void sendAlarmStatus(sOutunit* op)
msg->Count = count;
count = 0;
for (al = LstFir(&l.active_l); al != LstEnd(&l.active_l); al = LstNex(al)) {
ap = LstObj(al);
LstForEach(al, &l.active_l) {
ap = LstEntry(al, sActive, active_l);
if (!ap->detect_etp)
continue;
......@@ -1299,10 +1291,10 @@ static void sendAlarmStatus(sOutunit* op)
static void checkOutunits()
{
sOutunit* op;
LstLink(sOutunit) * ol;
struct LstHead * ol;
for (ol = LstFir(&l.outunit_l); ol != LstEnd(&l.outunit_l); ol = LstNex(ol)) {
op = LstObj(ol);
LstForEach(ol, &l.outunit_l) {
op = LstEntry(ol, sOutunit, outunit_l);
if (op->linkUp && op->type == mh_eOutunitType_Operator && op->ver >= 5)
/* Set alarm status to operator */
......@@ -1578,11 +1570,11 @@ static sEvent* eventListInsert(mh_eEvent event, char* text, sActive* ap)
static void eventToOutunits(sEvent* ep)
{
LstLink(sOutunit) * ol;
struct LstHead * ol;
sOutunit* op;
for (ol = LstFir(&l.outunit_l); ol != LstEnd(&l.outunit_l); ol = LstNex(ol)) {
op = LstObj(ol);
LstForEach(ol, &l.outunit_l) {
op = LstEntry(ol, sOutunit, outunit_l);
if (op->syncedIdx == op->eventIdx)
sendEventListToOutunit(op);
}
......@@ -2085,7 +2077,7 @@ static void fromEvent(qcom_sGet* get)
new_event.m = ep->mask;
if (new_event.b.swapDone & !cur_event.b.swapDone) {
LstLink(sOutunit) * ol;
struct LstHead * ol;
sOutunit* op;
errh_Info("Warm restart completed.");
......@@ -2093,10 +2085,10 @@ static void fromEvent(qcom_sGet* get)
handlerEvent(pwr_eSystemEventTypeEnum_NodeRestart, l.head.nix, 0);
reInitSupList();
if (!LstEmp(&l.sup_l)) {
if (!LstEmpty(&l.sup_l)) {
l.supListState = eSupListState_Scan;
setTimerActive(cMessageIdx, TRUE);
if (!LstEmp(&l.detect_l)) {
if (!LstEmpty(&l.detect_l)) {
scanTimerList();
scanDetectList();
setTimerActive(cDetectIdx, TRUE);
......@@ -2107,14 +2099,12 @@ static void fromEvent(qcom_sGet* get)
setTimerActive(cMessageIdx, FALSE);
errh_Info("No supervise objects.");
}
for (ol = LstFir(&l.outunit_l); ol != LstEnd(&l.outunit_l);
ol = LstNex(ol)) {
op = LstObj(ol);
LstForEach(ol, &l.outunit_l) {
op = LstEntry(ol, sOutunit, outunit_l);
sendToOutunit(op, mh_eMsg_OutunitClear, 0, 0, NULL, 0);
}
for (ol = LstFir(&l.outunit_l); ol != LstEnd(&l.outunit_l);
ol = LstNex(ol)) {
op = LstObj(ol);
LstForEach(ol, &l.outunit_l) {
op = LstEntry(ol, sOutunit, outunit_l);
sendEventListToOutunit(op);
}
pwrb_IOHandler_Exec(handlerEvent_cb, 1);
......@@ -2124,15 +2114,14 @@ static void fromEvent(qcom_sGet* get)
errh_Info("Warm restart initiated.");
handlerEvent(pwr_eSystemEventTypeEnum_NodeRestart, l.head.nix, 1);
} else if (new_event.b.simLoadStart & !cur_event.b.simLoadStart) {
LstLink(sOutunit) * ol;
struct LstHead * ol;
sOutunit* op;
l.supListState = eSupListState_Wait;
handlerEvent(pwr_eSystemEventTypeEnum_SimulateLoad, l.head.nix, 1);
for (ol = LstFir(&l.outunit_l); ol != LstEnd(&l.outunit_l);
ol = LstNex(ol)) {
op = LstObj(ol);
LstForEach(ol, &l.outunit_l) {
op = LstEntry(ol, sOutunit, outunit_l);
if (op->syncedIdx == op->eventIdx)
sendToOutunit(op, mh_eMsg_OutunitClear, 0, 0, NULL, 0);
}
......@@ -2142,10 +2131,10 @@ static void fromEvent(qcom_sGet* get)
handlerEvent(pwr_eSystemEventTypeEnum_SimulateLoad, l.head.nix, 0);
reInitSupList();
if (!LstEmp(&l.sup_l)) {
if (!LstEmpty(&l.sup_l)) {
l.supListState = eSupListState_Scan;
setTimerActive(cMessageIdx, TRUE);
if (!LstEmp(&l.detect_l)) {
if (!LstEmpty(&l.detect_l)) {
scanTimerList();
scanDetectList();
setTimerActive(cDetectIdx, TRUE);
......@@ -2521,7 +2510,7 @@ static void handlerEvent(
gdh_ArefANameToAref(&aref, attr, &hp->link.supObject);
/* Insert in application alarm list */
(void)LstIns(&node->appl.active_l, hp, active_l);
LstInsert(&node->appl.active_l, &hp->active_l);
hp->ap = (sAppl*)&node->appl;
++hp->ap->activeMessages;
ep = eventListInsert(ssup->EventType, NULL, (sActive*)hp);
......@@ -2564,8 +2553,8 @@ static void handlerEvent_cb(int event, int status)
static sApplActive* handlerListAlloc(pwr_eSystemEventTypeEnum event)
{
LstLink(sApplActive) * hl;
LstHead(sApplActive) * ll;
struct LstHead * hl;
struct LstHead * ll;
sApplActive* hp;
const int Alloc = 50;
int i;
......@@ -2581,31 +2570,31 @@ static sApplActive* handlerListAlloc(pwr_eSystemEventTypeEnum event)
ll = &l.handlerFree_l;
if (LstEmp(ll)) {
if (LstEmpty(ll)) {
hp = (sApplActive*)calloc(Alloc, sizeof(sApplActive));
if (hp != NULL) {
for (i = 0; i < Alloc; i++, hp++)
LstIns(ll, hp, link.active_l);
LstInsert(ll, &hp->link.active_l);
l.emon->AlarmMaxCount += Alloc;
} else {
return NULL;
}
}
hl = LstFir(ll);
LstRem(hl);
LstNul(hl);
hl = ll->next;
LstRemove(hl);
LstNull(hl);
--l.emon->AlarmMaxCount;
l.handlerListCount++;
return LstObj(hl);
return LstEntry(hl, sApplActive, active_l);
}
static void handlerListFree(sApplActive* hp)
{
// return;
memset(hp, 0, sizeof(*hp));
LstIns(&l.handlerFree_l, hp, link.active_l);
LstInsert(&l.handlerFree_l, &hp->link.active_l);
++l.emon->AlarmMaxCount;
l.handlerListCount--;
return;
......@@ -2707,7 +2696,7 @@ static void initNodeDb()
strncpy(np->name, qnode.name, sizeof(np->name));
for (i = 0; i < cNodes; i++) {
LstIni(&l.nodeDb[i].appl.active_l);
LstInit(&l.nodeDb[i].appl.active_l);
}
}
......@@ -2968,7 +2957,7 @@ static pwr_tStatus initSupList()
if (EVEN(sts))
errh_Error("Initialize list of CycleSup's\n%m", sts);
if (LstEmp(&l.sup_l))
if (LstEmpty(&l.sup_l))
errh_Info("No sup objects");
return (sts);
......@@ -2977,13 +2966,13 @@ static pwr_tStatus initSupList()
static pwr_tStatus initSupListClass(pwr_tClassId cid)
{
pwr_tStatus sts;
LstLink(sSupActive) * sl;
LstLink(sSupActive) * dl;
struct LstHead * sl;
struct LstHead * dl;
sSupActive* sp;
pwr_tAttrRef aref;
sl = LstEnd(&l.sup_l);
dl = LstEnd(&l.detect_l);
sl = &l.sup_l;
dl = &l.detect_l;
/* Loop trough objects in class list. */
......@@ -2994,10 +2983,12 @@ static pwr_tStatus initSupListClass(pwr_tClassId cid)
sts = initSupActiveCB(&aref, cid, &sp, 1, 1);
if (ODD(sts)) {
sl = LstIns(sl, sp, sup_l);
LstInsert(sl, &sp->sup_l);
sl = &sp->sup_l;
l.emon->BlockMaxCount++;
if (sp->agent == mh_eAgent_MH) {
dl = LstIns(dl, sp, detect_l);
LstInsert(dl, &sp->detect_l);
dl = &sp->detect_l;
l.emon->EventFirstIdx++;
}
}
......@@ -3049,7 +3040,7 @@ static pwr_tBoolean isValidApplication(
mh_sHead* hp, qcom_sAid* aid, sAppl** appl, mh_uApplReply* Reply)
{
sAppl* ap;
LstLink(sAppl) * al;
struct LstHead * al;
if (!(hp->ver == mh_cVersion
|| (mh_cVersion == 5
......@@ -3064,11 +3055,11 @@ static pwr_tBoolean isValidApplication(
/* Find outunit in outunit list */
for (al = LstFir(&l.appl_l); al != LstEnd(&l.appl_l); al = LstNex(al))
if (cdh_ObjidIsEqual(LstObj(al)->aid, hp->aid))
LstForEach(al, &l.appl_l)
if (cdh_ObjidIsEqual(LstEntry(al, sAppl, appl_l)->aid, hp->aid))
break;
if (al == LstEnd(&l.appl_l)) {
if (al == &l.appl_l) {
/* Application not known, make it known */
ap = (sAppl*)calloc(1, sizeof(*ap));
if (ap == NULL) {
......@@ -3084,12 +3075,12 @@ static pwr_tBoolean isValidApplication(
ap->aid = hp->aid;
ap->state = mh_eApplState_New;
/* Insert in application list */
LstIns(&l.appl_l, ap, appl_l);
LstInsert(&l.appl_l, &ap->appl_l);
/* Insert in process list */
LstIns(&l.proc_l, ap, link.proc_l);
LstIni(&ap->active_l); /* Init application alarm list */
LstInsert(&l.proc_l, &ap->link.proc_l);
LstInit(&ap->active_l); /* Init application alarm list */
} else {
ap = LstObj(al);
ap = LstEntry(al, sAppl, appl_l);
if (ap->birthTime.tv_sec != hp->birthTime.tv_sec) {
/* Different times, i.e. the application is restarted */
......@@ -3113,7 +3104,7 @@ static pwr_tBoolean isValidOutunit(
mh_sHead* hp, qcom_sAid* aid, sOutunit** outunit)
{
sOutunit* op;
LstLink(sOutunit) * ol;
struct LstHead * ol;
if (!(hp->ver == mh_cVersion
|| (mh_cVersion == 5
......@@ -3127,11 +3118,11 @@ static pwr_tBoolean isValidOutunit(
/* Find outunit in outunit list */
for (ol = LstFir(&l.outunit_l); ol != LstEnd(&l.outunit_l); ol = LstNex(ol))
if (cdh_ObjidIsEqual(LstObj(ol)->outunit, hp->outunit))
LstForEach(ol, &l.outunit_l)
if (cdh_ObjidIsEqual(LstEntry(ol, sOutunit, outunit_l)->outunit, hp->outunit))
break;
if (ol == LstEnd(&l.outunit_l)) {
if (ol == &l.outunit_l) {
/* Outunit not known, make it known */
op = (sOutunit*)calloc(1, sizeof(*op));
if (op == NULL) {
......@@ -3147,13 +3138,13 @@ static pwr_tBoolean isValidOutunit(
op->ver = hp->ver;
op->outunit = hp->outunit;
/* Insert in outunit list */
LstIns(&l.outunit_l, op, outunit_l);
LstInsert(&l.outunit_l, &op->outunit_l);
/* Insert in process list */
LstIns(&l.proc_l, op, link.proc_l);
LstInsert(&l.proc_l, &op->link.proc_l);
op->linkUp = TRUE;
outunitLog(op, "New outunit");
} else {
op = LstObj(ol);
op = LstEntry(ol, sOutunit, outunit_l);
if (op->birthTime.tv_sec != hp->birthTime.tv_sec) {
if (hp->type == mh_eMsg_OutunitInfo) {
......@@ -3198,7 +3189,7 @@ static void linkActive(qcom_sGet* msg)
static void linkConnect(qcom_sGet* msg)
{
pwr_tStatus sts;
LstLink(sOutunit) * ol;
struct LstHead * ol;
qcom_sNode* qnode = (qcom_sNode*)msg->data;
int nix = qnode->nid;
......@@ -3215,9 +3206,9 @@ static void linkConnect(qcom_sGet* msg)
node->newLinkState = gdh_eLinkState_Up;
node->check = TRUE;
for (ol = LstFir(&l.outunit_l); ol != LstEnd(&l.outunit_l); ol = LstNex(ol))
if (nix == LstObj(ol)->link.qid.nid) {
LstObj(ol)->linkUp = TRUE;
LstForEach(ol, &l.outunit_l)
if (nix == LstEntry(ol, sOutunit, outunit_l)->link.qid.nid) {
LstEntry(ol, sOutunit, outunit_l)->linkUp = TRUE;
}
sts = sendMessage(mh_eMsg_HandlerHello, NULL, NULL, NULL,
......@@ -3226,7 +3217,7 @@ static void linkConnect(qcom_sGet* msg)
static void linkDisconnect(qcom_sGet* msg)
{
LstLink(sOutunit) * ol;
struct LstHead * ol;
qcom_sNode* qnode = (qcom_sNode*)msg->data;
int nix = qnode->nid;
......@@ -3243,9 +3234,9 @@ static void linkDisconnect(qcom_sGet* msg)
node->check = TRUE;
}
for (ol = LstFir(&l.outunit_l); ol != LstEnd(&l.outunit_l); ol = LstNex(ol))
if (nix == LstObj(ol)->link.qid.nid) {
LstObj(ol)->linkUp = FALSE;
LstForEach(ol, &l.outunit_l)
if (nix == LstEntry(ol, sOutunit, outunit_l)->link.qid.nid) {
LstEntry(ol, sOutunit, outunit_l)->linkUp = FALSE;
}
}
......@@ -3264,10 +3255,10 @@ static void outunitAborted(sOutunit* op)
{
outunitLog(op, "Outunit aborted");
LstRem(&op->outunit_l); /* Remove from outunit list */
LstNul(&op->outunit_l);
LstRem(&op->link.proc_l); /* Remove from process link */
LstNul(&op->link.proc_l);
LstRemove(&op->outunit_l); /* Remove from outunit list */
LstNull(&op->outunit_l);
LstRemove(&op->link.proc_l); /* Remove from process link */
LstNull(&op->link.proc_l);
free(op); /* Free control block */
}
......@@ -3340,15 +3331,15 @@ static void outunitBlock(mh_sHead* hp, sOutunit* op)
sBlock* bp = NULL;
mh_sOutunitBlock* ip = (mh_sOutunitBlock*)(hp + 1);
sEvent* ep;
LstLink(sBlock) * bl;
struct LstHead * bl;
pwr_tNodeIndex nix;
op->blockGen = ip->blockGen;
sendToOutunit(op, mh_eMsg_Sync, 0, 0, NULL, 0);
for (bl = LstFir(&l.block_l); bl != LstEnd(&l.block_l); bl = LstNex(bl))
if (cdh_ObjidIsEqual(ip->object, LstObj(bl)->link.object.Objid))
bp = LstObj(bl);
LstForEach(bl, &l.block_l)
if (cdh_ObjidIsEqual(ip->object, LstEntry(bl, sBlock, block_l)->link.object.Objid))
bp = LstEntry(bl, sBlock, block_l);
if (bp == NULL) {
sts = gdh_GetObjectNodeIndex(ip->object, &nix);
......@@ -3473,10 +3464,10 @@ static void outunitDisconnect(mh_sHead* hp, sOutunit* op)
{
outunitLog(op, "Outunit disconnected");
LstRem(&op->outunit_l); /* Remove from outunit list */
LstNul(&op->outunit_l);
LstRem(&op->link.proc_l); /* Remove from process link */
LstNul(&op->link.proc_l);
LstRemove(&op->outunit_l); /* Remove from outunit list */
LstNull(&op->outunit_l);
LstRemove(&op->link.proc_l); /* Remove from process link */
LstNull(&op->link.proc_l);
free(op); /* Free control block */
}
......@@ -3511,14 +3502,14 @@ static void outunitAlarmReq(mh_sHead* hp, sOutunit* op)
{
mh_sOutunitAlarmReq* msg = (mh_sOutunitAlarmReq*)(hp + 1);
int i;
LstLink(sActive) * al;
struct LstHead * al;
sActive* ap;
int ok;
/* Find events in active list */
for (i = 0; i < msg->Count; i++) {
for (al = LstFir(&l.active_l); al != LstEnd(&l.active_l); al = LstNex(al)) {
ap = LstObj(al);
LstForEach(al, &l.active_l) {
ap = LstEntry(al, sActive, active_l);
if (ap->idx == msg->Idx[i]) {
if (!ap->detect_etp->ap)
......@@ -3543,19 +3534,19 @@ static void outunitAlarmReq(mh_sHead* hp, sOutunit* op)
static void procDown(qcom_sAid* aid)
{
LstLink(sProcLink) * pl;
struct LstHead * pl;
for (pl = LstFir(&l.proc_l); pl != LstEnd(&l.proc_l); pl = LstNex(pl))
if (LstObj(pl)->aid.nid == aid->nid && LstObj(pl)->aid.aix == aid->aix) {
switch (LstObj(pl)->source) {
LstForEach(pl, &l.proc_l)
if (LstEntry(pl, sProcLink, proc_l)->aid.nid == aid->nid && LstEntry(pl, sProcLink, proc_l)->aid.aix == aid->aix) {
switch (LstEntry(pl, sProcLink, proc_l)->source) {
case mh_eSource_Outunit:
outunitAborted((sOutunit*)LstObj(pl));
outunitAborted((sOutunit*)LstEntry(pl, sProcLink, proc_l));
break;
case mh_eSource_Application:
break;
default:
errh_Error(
"procDown, programming error, source: %d", LstObj(pl)->source);
"procDown, programming error, source: %d", LstEntry(pl, sProcLink, proc_l)->source);
break;
}
return;
......@@ -3585,7 +3576,7 @@ static void receive(qcom_sQid myQ)
if (l.redu && l.nodep->RedundancyState == pwr_eRedundancyState_Passive) {
if (l.supListState == eSupListState_Init) {
initSupList();
if (!LstEmp(&l.sup_l))
if (!LstEmpty(&l.sup_l))
l.supListState = eSupListState_Scan;
else
l.supListState = eSupListState_NoSup;
......@@ -3645,12 +3636,12 @@ static void receive(qcom_sQid myQ)
static void reInitSupList()
{
pwr_tStatus sts;
LstLink(sSupActive) * sl;
struct LstHead * sl;
sSupActive* sp;
sActive* ap;
for (sl = LstFir(&l.sup_l); sl != LstEnd(&l.sup_l); sl = LstNex(sl))
LstObj(sl)->found = FALSE;
LstForEach(sl, &l.sup_l)
LstEntry(sl, sSupActive, sup_l)->found = FALSE;
sts = reInitSupListClass(pwr_cClass_ASup);
if (EVEN(sts))
......@@ -3668,26 +3659,26 @@ static void reInitSupList()
if (EVEN(sts))
errh_Error("Reinitialize list of CycleSup's\n%m", sts);
for (sl = LstFir(&l.sup_l); sl != LstEnd(&l.sup_l); sl = LstNex(sl)) {
sp = LstObj(sl);
LstForEach(sl, &l.sup_l) {
sp = LstEntry(sl, sSupActive, sup_l);
if (!sp->found) {
if ((ap = activeListGet(sp->link.idx)) != NULL)
cancelAlarm(ap, cText_Restart);
sl = LstPre(&sp->sup_l);
LstRem(&sp->sup_l);
LstNul(&sp->sup_l);
sl = sp->sup_l.prev;
LstRemove(&sp->sup_l);
LstNull(&sp->sup_l);
l.emon->BlockMaxCount--;
gdh_DLUnrefObjectInfo(sp->supDlid);
if (sp->agent == mh_eAgent_MH) {
gdh_DLUnrefObjectInfo(sp->attrDlid);
if (LstInl(&sp->timer_l)) {
LstRem(&sp->timer_l);
LstNul(&sp->timer_l);
if (!LstIsNull(&sp->timer_l)) {
LstRemove(&sp->timer_l);
LstNull(&sp->timer_l);
l.emon->EventLastIdx--;
}
LstRem(&sp->detect_l);
LstNul(&sp->detect_l);
LstRemove(&sp->detect_l);
LstNull(&sp->detect_l);
l.emon->EventFirstIdx--;
}
free(sp);
......@@ -3698,13 +3689,13 @@ static void reInitSupList()
static pwr_tStatus reInitSupListClass(pwr_tClassId cid)
{
pwr_tStatus sts;
LstLink(sSupActive) * sl;
LstLink(sSupActive) * dl;
struct LstHead * sl;
struct LstHead * dl;
sSupActive* sp;
pwr_tAttrRef aref;
dl = LstEnd(&l.detect_l);
sl = LstEnd(&l.sup_l);
dl = &l.detect_l;
sl = &l.sup_l;
/* Loop through objects in class list. */
......@@ -3716,11 +3707,13 @@ static pwr_tStatus reInitSupListClass(pwr_tClassId cid)
if ((sp = supListGet(&aref)) == NULL) {
sts = initSupActiveCB(&aref, cid, &sp, 1, 1);
if (ODD(sts)) {
sl = LstIns(sl, sp, sup_l);
LstInsert(sl, &sp->sup_l);
sl = &sp->sup_l;
l.emon->BlockMaxCount++;
sp->found = TRUE;
if (sp->agent == mh_eAgent_MH) {
dl = LstIns(dl, sp, detect_l);
LstInsert(dl, &sp->detect_l);
dl = &sp->detect_l;
l.emon->EventFirstIdx++;
}
}
......@@ -3800,7 +3793,7 @@ static void saveBlockList()
{
unsigned long size;
sSaveBlock* sp;
LstLink(sBlock) * bl;
struct LstHead * bl;
sBlock* bp;
if (l.blockDb == NULL)
......@@ -3816,12 +3809,14 @@ static void saveBlockList()
}
}
for (bl = LstFir(&l.block_l), sp = l.blockSave, size = 0;
bl != LstEnd(&l.block_l);
bl = LstNex(bl), sp++, size += sizeof(sSaveBlock)) {
bp = LstObj(bl);
sp = l.blockSave;
size = 0;
LstForEach(bl, &l.block_l) {
bp = LstEntry(bl, sBlock, block_l);
sp->outunitBlock = bp->outunitBlock;
sp->targetId = bp->targetId;
sp++;
size += sizeof(sSaveBlock);
}
l.blockDb = mh_BlockDbPut(l.blockDb, size, (char*)l.blockSave);
......@@ -3829,10 +3824,10 @@ static void saveBlockList()
static void scanDetectList()
{
LstLink(sSupActive) * dl;
struct LstHead * dl;
for (dl = LstFir(&l.detect_l); dl != LstEnd(&l.detect_l); dl = LstNex(dl)) {
sSupActive* sp = LstObj(dl);
LstForEach(dl, &l.detect_l) {
sSupActive* sp = LstEntry(dl, sSupActive, detect_l);
if (sp->detect_exec != NULL)
sp->detect_exec(sp);
}
......@@ -3843,10 +3838,10 @@ static void scanSupList()
pwr_tStatus sts;
mh_uEventInfo AlarmVisibility;
sSupActive* sp;
LstLink(sSupActive) * sl;
struct LstHead * sl;
for (sl = LstFir(&l.sup_l); sl != LstEnd(&l.sup_l); sl = LstNex(sl)) {
sp = LstObj(sl);
LstForEach(sl, &l.sup_l) {
sp = LstEntry(sl, sSupActive, sup_l);
if (l.newBlock) {
sts = gdh_GetAlarmInfo(
sp->link.object.Objid, NULL, NULL, NULL, NULL, &AlarmVisibility.All);
......@@ -3894,17 +3889,17 @@ static void scanSupList()
static void scanTimerList()
{
LstLink(sSupActive) * sl, *nsl;
struct LstHead * sl, *nsl;
sTimer* tp;
for (sl = LstFir(&l.timer_l); sl != LstEnd(&l.timer_l); sl = nsl) {
tp = LstObj(sl)->timer;
nsl = LstNex(sl);
for (sl = l.timer_l.next; sl != &l.timer_l; sl = nsl) {
tp = LstEntry(sl, sSupActive, timer_l)->timer;
nsl = sl->next;
if (tp->TimerCount <= 1 || !tp->TimerFlag) {
tp->TimerCount = 0;
tp->TimerFlag = FALSE;
LstRem(sl);
LstNul(sl);
LstRemove(sl);
LstNull(sl);
l.emon->EventLastIdx--;
} else {
tp->TimerCount--;
......@@ -4102,10 +4097,10 @@ static void setTimerActive(int timerIdx, pwr_tBoolean active)
static sSupActive* supListGet(pwr_tAttrRef* arp)
{
LstLink(sSupActive) * sl;
struct LstHead * sl;
for (sl = LstFir(&l.sup_l); sl != LstEnd(&l.sup_l); sl = LstNex(sl)) {
sSupActive* sp = LstObj(sl);
LstForEach(sl, &l.sup_l) {
sSupActive* sp = LstEntry(sl, sSupActive, sup_l);
if (cdh_ArefIsEqual(&sp->link.supObject, arp))
return sp;
......@@ -4135,9 +4130,9 @@ static void timeOut()
} else if (l.supListState == eSupListState_Init) {
if (qcom_EventMask(NULL, &qcom_cQini) & ini_mEvent_newPlcStartDone) {
initSupList();
if (!LstEmp(&l.sup_l)) {
if (!LstEmpty(&l.sup_l)) {
l.supListState = eSupListState_Scan;
if (!LstEmp(&l.detect_l)) {
if (!LstEmpty(&l.detect_l)) {
scanTimerList();
scanDetectList();
setTimerActive(cDetectIdx, TRUE);
......@@ -4176,8 +4171,8 @@ static void timerIn(sSupActive* s, sTimer* t)
{
t->TimerCount = t->TimerTime / l.detectTimerTime;
if (!t->TimerFlag && t->TimerCount > 0) {
if (!LstInl(&s->timer_l)) {
LstIns(&l.timer_l, s, timer_l);
if (LstIsNull(&s->timer_l)) {
LstInsert(&l.timer_l, &s->timer_l);
l.emon->EventLastIdx++;
}
t->TimerFlag = TRUE;
......@@ -4278,7 +4273,7 @@ static void updateAlarm(sActive* ap, sEvent* ep)
static void updateAlarmInfo(sActive* iap)
{
sActive* ap;
LstLink(sActive) * al;
struct LstHead * al;
mh_uEventInfo maxAlarm;
if (cdh_ObjidIsEqual(iap->object.Objid,
......@@ -4287,8 +4282,8 @@ static void updateAlarmInfo(sActive* iap)
/* Search alarm list for ocurrence of object */
maxAlarm.All = 0;
for (al = LstFir(&l.active_l); al != LstEnd(&l.active_l); al = LstNex(al)) {
ap = LstObj(al);
LstForEach(al, &l.active_l) {
ap = LstEntry(al, sActive, active_l);
if (cdh_ArefIsEqual(&iap->object, &ap->object))
if (ap->event == mh_eEvent_Alarm
|| ap->event == mh_eEvent_MaintenanceAlarm
......@@ -4315,7 +4310,7 @@ static void updateSupActive(sSupActive* sp)
mh_eAgent agent;
pwr_tClassId cid = 0;
pwr_tBoolean newAttribute;
LstLink(sSupActive)* dl = LstEnd(&l.detect_l);
struct LstHead* dl = &l.detect_l;
/* Get pointer to supervisory object */
......@@ -4373,15 +4368,15 @@ static void updateSupActive(sSupActive* sp)
sp->found = TRUE;
if (sp->agent != agent) {
if (sp->agent == mh_eAgent_MH) {
LstIns(dl, sp, detect_l);
LstInsert(dl, &sp->detect_l);
l.emon->EventFirstIdx++;
} else {
LstRem(&sp->detect_l);
LstNul(&sp->detect_l);
LstRemove(&sp->detect_l);
LstNull(&sp->detect_l);
l.emon->EventFirstIdx--;
if (LstInl(&sp->timer_l)) {
LstRem(&sp->timer_l);
LstNul(&sp->timer_l);
if (!LstIsNull(&sp->timer_l)) {
LstRemove(&sp->timer_l);
LstNull(&sp->timer_l);
l.emon->EventLastIdx--;
}
}
......@@ -4570,7 +4565,7 @@ static pwr_tStatus emon_redu_send()
{
pwr_tStatus sts;
void* msg;
LstLink(sActive) * al;
struct LstHead * al;
sActive* ap;
sSupActive* sp;
int size;
......@@ -4582,19 +4577,19 @@ static pwr_tStatus emon_redu_send()
redu_sEvEventList* eventlistp;
redu_sEvEvent* eventp;
sOutunit* op;
LstLink(sOutunit) * ol;
struct LstHead * ol;
sEvent* ep;
int i;
// Count active
active_cnt = 0;
for (al = LstFir(&l.active_l); al != LstEnd(&l.active_l); al = LstNex(al))
LstForEach(al, &l.active_l)
active_cnt++;
// Count outunits
outunit_cnt = 0;
for (ol = LstFir(&l.outunit_l); ol != LstEnd(&l.outunit_l); ol = LstNex(ol)) {
op = LstObj(ol);
LstForEach(ol, &l.outunit_l) {
op = LstEntry(ol, sOutunit, outunit_l);
if (op->outunit.vid != l.nodeObject.vid)
outunit_cnt++;
......@@ -4615,8 +4610,8 @@ static pwr_tStatus emon_redu_send()
((redu_sEvMsgHeader*)msg)->events = event_cnt;
activep = (redu_sEvActive*)((char*)msg + sizeof(redu_sEvMsgHeader));
for (al = LstFir(&l.active_l); al != LstEnd(&l.active_l); al = LstNex(al)) {
ap = LstObj(al);
LstForEach(al, &l.active_l) {
ap = LstEntry(al, sActive, active_l);
activep->idx = ap->idx;
activep->returnIdx = ap->returnIdx;
......@@ -4656,8 +4651,8 @@ static pwr_tStatus emon_redu_send()
/* Outunits, only remote */
outunitp = (redu_sEvOutunit*)activep;
for (ol = LstFir(&l.outunit_l); ol != LstEnd(&l.outunit_l); ol = LstNex(ol)) {
op = LstObj(ol);
LstForEach(ol, &l.outunit_l) {
op = LstEntry(ol, sOutunit, outunit_l);
if (op->outunit.vid != l.nodeObject.vid) {
outunitp->outunit = op->outunit;
......@@ -4748,12 +4743,12 @@ static pwr_tStatus emon_redu_receive()
int outunits;
int events;
int i;
LstLink(sActive) * al;
struct LstHead * al;
sActive *ap = NULL, *tp;
sSupActive* sp;
sEvent* ep;
sOutunit* op;
LstLink(sOutunit) * ol;
struct LstHead * ol;
int found;
sts = redu_receive(l.redu, timeout, &size, &msg);
......@@ -4819,8 +4814,8 @@ static pwr_tStatus emon_redu_receive()
/* Active list */
/* Find removed elements in active list */
for (al = LstFir(&l.active_l); al != LstEnd(&l.active_l); al = LstNex(al)) {
ap = LstObj(al);
LstForEach(al, &l.active_l) {
ap = LstEntry(al, sActive, active_l);
if (ap->source == mh_eSource_Scanner
|| ap->source == mh_eSource_Handler) {
sp = (sSupActive*)ap;
......@@ -4832,9 +4827,8 @@ static pwr_tStatus emon_redu_receive()
for (i = 0; i < actives; i++) {
if (activep->source == mh_eSource_Scanner
|| activep->source == mh_eSource_Handler) {
for (al = LstFir(&l.active_l); al != LstEnd(&l.active_l);
al = LstNex(al)) {
ap = LstObj(al);
LstForEach(al, &l.active_l) {
ap = LstEntry(al, sActive, active_l);
if ((activep->source == mh_eSource_Scanner
|| activep->source == mh_eSource_Handler)
&& cdh_ArefIsEqual(&activep->supObject, &ap->supObject)) {
......@@ -4847,9 +4841,9 @@ static pwr_tStatus emon_redu_receive()
activep++;
}
for (al = LstFir(&l.active_l); al != LstEnd(&l.active_l);) {
ap = LstObj(al);
al = LstNex(al);
for (al = l.active_l.next; al != &l.active_l;) {
ap = LstEntry(al, sActive, active_l);
al = al->next;
if (ap->source == mh_eSource_Scanner
|| ap->source == mh_eSource_Handler) {
sp = (sSupActive*)ap;
......@@ -4875,9 +4869,8 @@ static pwr_tStatus emon_redu_receive()
found = 0;
if (activep->source == mh_eSource_Scanner
|| activep->source == mh_eSource_Handler) {
for (al = LstFir(&l.active_l); al != LstEnd(&l.active_l);
al = LstNex(al)) {
ap = LstObj(al);
LstForEach(al, &l.active_l) {
ap = LstEntry(al, sActive, active_l);
if ((activep->source == mh_eSource_Scanner
|| activep->source == mh_eSource_Handler)
&& cdh_ArefIsEqual(&activep->supObject, &ap->supObject)) {
......@@ -4896,9 +4889,8 @@ static pwr_tStatus emon_redu_receive()
activep++;
continue;
}
for (al = LstFir(&l.active_l); al != LstEnd(&l.active_l);
al = LstNex(al)) {
tp = LstObj(al);
LstForEach(al, &l.active_l) {
tp = LstEntry(al, sActive, active_l);
if (ap == tp)
/* Already in active list */
found = 1;
......@@ -4956,8 +4948,8 @@ static pwr_tStatus emon_redu_receive()
continue;
}
if (!found) {
LstLink(sActive) * al;
LstLink(sBlock) * bl;
struct LstHead * al;
struct LstHead * bl;
// printf( "Active add, idx %d %s\n", ap->detect_etp->idx,
// ap->detect_etp->ep ? ap->detect_etp->ep->objName : "");
......@@ -4972,8 +4964,8 @@ static pwr_tStatus emon_redu_receive()
//}
/* Insert in active list */
al = LstEnd(&l.active_l);
LstIns(al, ap, active_l);
al = &l.active_l;
LstInsert(al, &ap->active_l);
switch (ap->event) {
case mh_eEvent_Alarm:
......@@ -4987,8 +4979,8 @@ static pwr_tStatus emon_redu_receive()
break;
case mh_eEvent_Block:
case mh_eEvent_Reblock:
bl = LstEnd(&l.block_l);
LstIns(bl, (sBlock*)ap, block_l);
bl = &l.block_l;
LstInsert(bl, &((sBlock*)ap)->block_l);
++l.emon->BlockCount;
break;
case mh_eEvent_Info:
......@@ -5012,9 +5004,9 @@ static pwr_tStatus emon_redu_receive()
outunit_start = (redu_sEvOutunit*)activep;
/* Remove outunits */
for (ol = LstFir(&l.outunit_l); ol != LstEnd(&l.outunit_l);) {
op = LstObj(ol);
ol = LstNex(ol);
for (ol = l.outunit_l.next; ol != &l.outunit_l;) {
op = LstEntry(ol, sOutunit, outunit_l);
ol = ol->next;
if (op->outunit.vid == l.nodeObject.vid)
continue;
......@@ -5038,9 +5030,9 @@ static pwr_tStatus emon_redu_receive()
outunitp = outunit_start;
for (i = 0; i < outunits; i++) {
found = 0;
for (ol = LstFir(&l.outunit_l); ol != LstEnd(&l.outunit_l);) {
op = LstObj(ol);
ol = LstNex(ol);
for (ol = l.outunit_l.next; ol != &l.outunit_l;) {
op = LstEntry(ol, sOutunit, outunit_l);
ol = ol->next;
if (cdh_ObjidIsEqual(outunitp->outunit, op->outunit)) {
found = 1;
......@@ -5087,9 +5079,9 @@ static pwr_tStatus emon_redu_receive()
op->selSize = outunitp->selSize;
memcpy(op->sel_l, outunitp->sel_l, sizeof(op->sel_l));
/* Insert in outunit list */
LstIns(&l.outunit_l, op, outunit_l);
LstInsert(&l.outunit_l, &op->outunit_l);
/* Insert in process list */
LstIns(&l.proc_l, op, link.proc_l);
LstInsert(&l.proc_l, &op->link.proc_l);
op->linkUp = TRUE;
outunitLog(op, "New outunit");
printf("Outunit added, (%d,%d)\n", op->outunit.oix, op->outunit.vid);
......
......@@ -69,11 +69,9 @@ typedef enum { eTimer_ScanMessage = 1 } eTimer;
typedef struct s_Node sNode;
LstType(sNode);
struct s_Node {
LstLink(sNode) node_l;
LstLink(sNode) timer_l;
struct LstHead node_l;
struct LstHead timer_l;
pwr_tObjid oid;
pwr_sClass_NodeLinkSup node;
pwr_sClass_NodeLinkSup* o;
......@@ -84,8 +82,8 @@ struct s_Node {
};
static eListState list_state = eListState_Init;
static LstHead(sNode) node_l;
static LstHead(sNode) timer_l;
static struct LstHead node_l;
static struct LstHead timer_l;
static void detect(pwr_sClass_NodeLinkSup*, pwr_tBoolean, sNode*);
static void event(qcom_sGet*);
......@@ -137,11 +135,11 @@ int main(int argc, char** argv)
plc_UtlWaitForPlc();
LstIni(&node_l);
LstIni(&timer_l);
LstInit(&node_l);
LstInit(&timer_l);
init_nodes();
if (!LstEmp(&node_l)) {
if (!LstEmpty(&node_l)) {
list_state = eListState_Scan;
} else {
errh_Info("No nodes to supervise, exiting");
......@@ -195,8 +193,8 @@ static void detect(pwr_sClass_NodeLinkSup* o, pwr_tBoolean con, sNode* np)
if (o->DetectCheck) {
o->TimerCount = (o->TimerTime * 1000) / cTimerTimeDetect;
if (!o->TimerFlag && o->TimerCount > 0) {
if (!LstInl(&np->timer_l)) {
LstIns(&timer_l, np, timer_l);
if (LstIsNull(&np->timer_l)) {
LstInsert(&timer_l, &np->timer_l);
}
o->TimerFlag = TRUE;
}
......@@ -229,7 +227,7 @@ static void event(qcom_sGet* get)
if (new_event.b.swapDone & !cur_event.b.swapDone) {
errh_Info("Warm restart completed.");
reinit_nodes();
if (!LstEmp(&node_l)) {
if (!LstEmpty(&node_l)) {
list_state = eListState_Scan;
scan_timers();
scan_nodes();
......@@ -322,21 +320,22 @@ static sNode* init_node(pwr_tObjid oid, sNode* np, pwr_tBoolean new_sub)
static pwr_tStatus init_nodes()
{
pwr_tStatus sts;
LstLink(sNode) * nl;
struct LstHead * nl;
sNode* np;
pwr_tObjid oid;
nl = LstEnd(&node_l);
nl = &node_l;
for (sts = gdh_GetClassList(pwr_cClass_NodeLinkSup, &oid); ODD(sts);
sts = gdh_GetNextObject(oid, &oid)) {
np = init_node(oid, NULL, 1);
if (np != NULL) {
nl = LstIns(nl, np, node_l);
LstInsert(nl, &np->node_l);
nl = &np->node_l;
}
}
if (LstEmp(&node_l))
if (LstEmpty(&node_l))
errh_Info("No NodeLink objects");
return (sts);
......@@ -346,11 +345,11 @@ static pwr_tStatus init_nodes()
static sNode* get_nodes(pwr_tObjid oid)
{
LstLink(sNode) * nl;
struct LstHead * nl;
for (nl = LstFir(&node_l); nl != LstEnd(&node_l); nl = LstNex(nl)) {
if (cdh_ObjidIsEqual(LstObj(nl)->oid, oid))
return LstObj(nl);
LstForEach(nl, &node_l) {
if (cdh_ObjidIsEqual(LstEntry(nl, sNode, node_l)->oid, oid))
return LstEntry(nl, sNode, node_l);
}
return NULL;
......@@ -359,20 +358,21 @@ static sNode* get_nodes(pwr_tObjid oid)
static void reinit_nodes()
{
pwr_tStatus sts;
LstLink(sNode) * nl;
struct LstHead * nl;
sNode* np;
pwr_tObjid oid;
/* Mark all links in the NodeLink list */
for (nl = LstFir(&node_l); nl != LstEnd(&node_l); nl = LstNex(nl))
LstObj(nl)->found = FALSE;
LstForEach(nl, &node_l)
LstEntry(nl, sNode, node_l)->found = FALSE;
for (sts = gdh_GetClassList(pwr_cClass_NodeLinkSup, &oid); ODD(sts);
sts = gdh_GetNextObject(oid, &oid)) {
if ((np = get_nodes(oid)) == NULL) {
np = init_node(oid, NULL, 1);
if (np != NULL) {
nl = LstIns(nl, np, node_l);
LstInsert(nl, &np->node_l);
nl = &np->node_l;
np->found = TRUE;
}
} else {
......@@ -380,12 +380,12 @@ static void reinit_nodes()
}
}
for (nl = LstFir(&node_l); nl != LstEnd(&node_l); nl = LstNex(nl)) {
np = LstObj(nl);
LstForEach(nl, &node_l) {
np = LstEntry(nl, sNode, node_l);
if (!np->found) {
nl = LstPre(&np->node_l);
LstRem(&np->node_l);
LstNul(&np->node_l);
nl = np->node_l.prev;
LstRemove(&np->node_l);
LstNull(&np->node_l);
gdh_SubUnrefObjectInfo(np->o->SubId);
gdh_DLUnrefObjectInfo(np->dlid);
free(np);
......@@ -395,7 +395,7 @@ static void reinit_nodes()
static void scan_nodes()
{
LstLink(sNode) * nl;
struct LstHead * nl;
pwr_tStatus sts;
pwr_tBoolean Old;
pwr_tTime LastUpdate, Timeout, CurrentTime;
......@@ -404,8 +404,8 @@ static void scan_nodes()
time_GetTime(&CurrentTime);
for (nl = LstFir(&node_l); nl != LstEnd(&node_l); nl = LstNex(nl)) {
sNode* np = LstObj(nl);
LstForEach(nl, &node_l) {
sNode* np = LstEntry(nl, sNode, node_l);
pwr_sClass_NodeLinkSup* o = np->o;
LinkUp = 0;
sts = gdh_GetSubscriptionOldness(o->SubId, &Old, &LastUpdate, NULL);
......@@ -435,17 +435,17 @@ static void scan_nodes()
static void scan_timers()
{
LstLink(sNode) * nl, *nxtnl;
struct LstHead * nl, *nxtnl;
plc_sTimer* tp;
for (nl = LstFir(&timer_l); nl != LstEnd(&timer_l); nl = nxtnl) {
tp = LstObj(nl)->timer;
nxtnl = LstNex(nl);
for (nl = timer_l.next; nl != &timer_l; nl = nxtnl) {
tp = LstEntry(nl, sNode, timer_l)->timer;
nxtnl = nl->next;
if (tp->TimerCount <= 1 || !tp->TimerFlag) {
tp->TimerCount = 0;
tp->TimerFlag = FALSE;
LstRem(nl);
LstNul(nl);
LstRemove(nl);
LstNull(nl);
} else {
tp->TimerCount--;
}
......
......@@ -57,19 +57,17 @@
typedef struct s_Timer sTimer;
LstType(sTimer);
struct s_Timer {
LstLink(sTimer) ll;
struct LstHead ll;
time_tClock clock;
pwr_tBoolean wrapped;
void* data;
void (*exec)();
};
static LstHead(sTimer) timer_lh;
static LstHead(sTimer) wrap_lh;
static LstHead(sTimer) free_lh;
static struct LstHead timer_lh;
static struct LstHead wrap_lh;
static struct LstHead free_lh;
static time_tClock now_clock;
static time_tClock last_clock;
......@@ -104,7 +102,7 @@ static void waitClock(time_tClock c, int* tmo_ms);
static void setInterval(time_tClock* c, pwr_tUInt32 i);
static void executeExpired(LstHead(sTimer) * lh, pwr_tBoolean force);
static void executeExpired(struct LstHead * lh, pwr_tBoolean force);
static void getNewTimers();
......@@ -370,16 +368,16 @@ static void cacheTrim(sTimer* tp)
static void insertTimer(sTimer* tp)
{
LstLink(sTimer) * tl;
struct LstHead * tl;
sTimer* tip;
if (LstEmp(&timer_lh)) {
(void)LstIns(LstEnd(&timer_lh), tp, ll);
if (LstEmpty(&timer_lh)) {
LstInsert(&timer_lh, &tp->ll);
return;
}
for (tl = LstLas(&timer_lh); tl != LstEnd(&timer_lh); tl = LstPre(tl)) {
tip = LstObj(tl);
for (tl = timer_lh.prev; tl != &timer_lh; tl = tl->prev) {
tip = LstEntry(tl, sTimer, ll);
if (tp->wrapped) {
if (!tip->wrapped || tip->clock < tp->clock)
......@@ -388,8 +386,8 @@ static void insertTimer(sTimer* tp)
break;
}
tl = LstNex(tl);
(void)LstIns(tl, tp, ll);
tl = tl->next;
LstInsert(tl, &tp->ll);
}
/* . */
......@@ -416,7 +414,7 @@ static sTimer* newTimer(time_tClock* clock, void* data, void (*exec)())
static void freeTimer(sTimer* tp)
{
memset(tp, 0, sizeof(*tp));
LstIns(&LstEnd(free_lh), tp, ll);
LstInsert(&free_lh, &tp->ll);
}
/* . */
......@@ -425,19 +423,19 @@ static sTimer* allocTimer()
{
const int cAllocCount = 100;
sTimer* ftp;
LstLink(sTimer) * ftl;
struct LstHead * ftl;
int i;
if (LstEmp(&free_lh)) {
if (LstEmpty(&free_lh)) {
ftp = (sTimer*)calloc(cAllocCount, sizeof(sTimer));
for (i = 0; i < cAllocCount; i++, ftp++) {
LstIns(&LstEnd(free_lh), ftp, ll);
LstInsert(&free_lh, &ftp->ll);
}
}
ftl = LstFir(&free_lh);
LstRem(ftl);
return LstObj(ftl);
ftl = free_lh.next;
LstRemove(ftl);
return LstEntry(ftl, sTimer, ll);
}
static void setTimer(sTimer* tp, time_tClock offs)
......@@ -498,21 +496,21 @@ static void setInterval(time_tClock* c,
#endif
}
static void executeExpired(LstHead(sTimer) * lh, pwr_tBoolean force)
static void executeExpired(struct LstHead * lh, pwr_tBoolean force)
{
LstLink(sTimer) * tl;
struct LstHead * tl;
sTimer* tp;
gdb_AssumeUnlocked;
gdb_ScopeLock
{
for (tl = LstFir(lh); tl != LstEnd(lh); tl = LstFir(lh)) {
tp = LstObj(tl);
LstForEach(tl, lh) {
tp = LstEntry(tl, sTimer, ll);
if (force || (!tp->wrapped && tp->clock <= now_clock)) {
LstRem(tl);
LstNul(tl);
LstRemove(tl);
LstNull(tl);
tp->exec(tp);
} else
break;
......@@ -560,11 +558,11 @@ static void getNewTimers()
static void getWaitClock(time_tClock* wait_clock, time_tClock last_clock)
{
int diff;
LstLink(sTimer) * tl;
struct LstHead * tl;
sTimer* tp;
tl = LstFir(&timer_lh);
tp = LstObj(tl);
tl = timer_lh.next;
tp = LstEntry(tl, sTimer, ll);
if (now_clock < last_clock) {
if (tp->wrapped) {
......@@ -610,9 +608,9 @@ static void init()
gdbroot->db->tmon = gdbroot->my_qid;
gdbroot->is_tmon = 1;
LstIni(&timer_lh);
LstIni(&wrap_lh);
LstIni(&free_lh);
LstInit(&timer_lh);
LstInit(&wrap_lh);
LstInit(&free_lh);
last_clock = now_clock = time_Clock(NULL, NULL);
......@@ -631,18 +629,18 @@ static void init()
static void toggleWrapped()
{
LstLink(sTimer) * tl;
LstLink(sTimer) * ntl;
struct LstHead * tl;
struct LstHead * ntl;
sTimer* tp;
LstHead(sTimer)* tlh = &timer_lh;
struct LstHead* tlh = &timer_lh;
for (tl = LstFir(tlh); tl != LstEnd(tlh); tl = ntl) {
tp = LstObj(tl);
ntl = LstNex(tl);
for (tl = tlh->next; tl != tlh; tl = ntl) {
tp = LstEntry(tl, sTimer, ll);
ntl = tl->next;
if (!tp->wrapped) {
LstRem(tl);
(void)LstIns(LstEnd(&wrap_lh), tp, ll);
LstRemove(tl);
LstInsert(&wrap_lh, &tp->ll);
} else
tp->wrapped = 0;
}
......
......@@ -40,33 +40,96 @@
/* pwr_lst.h -- list macros
*/
#define LstType(a) \
typedef struct s_LstLink_##a sLstLink_##a; \
struct s_LstLink_##a { \
sLstLink_##a* nex; \
sLstLink_##a* pre; \
a* obj; \
}
struct LstHead {
struct LstHead *next, *prev;
};
#define LstLink(a) sLstLink_##a
/*
* LstInsert(s_LstLink_T* next, s_LstLink_T elem) inserts the element \a into
* the linked list before the element \a next.
*
* Before:
* a <-> c
*
* Calling LstInsert(c, b)
* a <- b (a <- b)
* b -> c (a <- b -> c)
* a -> b (a <-> b -> c)
* b <- c (a <-> b <-> c)
*/
static inline void LstInsert(struct LstHead *p, struct LstHead *e)
{
e->prev = p->prev;
e->next = p;
p->prev->next = e;
p->prev = e;
}
/*
* LstRemove(s_LstLink_T) removes the element from the linked list, which is
* done by modifying the next element to point at the previous and vice versa.
*/
static inline void LstRemove(struct LstHead *p)
{
p->next->prev = p->prev;
p->prev->next = p->next;
}
#define LstHead(a) sLstLink_##a
/*
* LstNull(s_LstLink_T) sets the linked list to NULL.
*/
static inline void LstNull(struct LstHead *p)
{
p->next = p->prev = NULL;
}
#define LstNex(p) ((p)->nex)
#define LstPre(p) ((p)->pre)
#define LstLas(h) ((h)->pre)
#define LstFir(h) ((h)->nex)
#define LstEnd(h) (h)
#define LstIns(p, o, e) \
((o)->e.obj = (void*)o, (o)->e.pre = (void*)((p)->pre), \
(o)->e.nex = (void*)(p), (p)->pre->nex = (void*)(&(o)->e), \
(p)->pre = (void*)(&(o)->e))
#define LstRem(p) ((p)->nex->pre = (p)->pre, (p)->pre->nex = (p)->nex)
#define LstNul(p) ((p)->nex = (p)->pre = NULL)
#define LstIsNul(p) ((p)->nex == NULL && (p)->pre == NULL)
#define LstInl(p) ((p)->nex != NULL && (p)->pre != NULL)
#define LstIni(h) ((h)->nex = (h)->pre = (h))
#define LstObj(p) ((p)->obj)
#define LstEmp(h) ((h) == (h)->nex)
/*
* LstIsNull(s_LstLink_T) checks if the linked list is NULL.
*/
static inline int LstIsNull(struct LstHead *p)
{
return (p->next == NULL && p->prev == NULL);
}
/*
* LstInit(s_LstLink_T) initializes the linked list.
*/
static inline void LstInit(struct LstHead *h)
{
h->next = h->prev = h;
}
/*
* LstEntry(s_LstLink_T*, sTimer, ll) fetches the struct sTimer corresponding to
* the list pointer \a ptr.
* It does this by calculating the offset of a list pointers \a ll within the
* struct sTimer, and then subtracts that from the list pointer \a ptr.
*/
#ifndef offsetof
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
#endif
#ifndef container_of
#define container_of(ptr, type, member) ({ \
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
(type *)( (char *)__mptr - offsetof(type,member) );})
#endif
#define LstEntry(ptr, type, member) container_of(ptr, type, member)
/*
* LstEmpty(s_LstLink_T) checks if the linked list is empty.
*/
static inline int LstEmpty(struct LstHead *h)
{
return h->next == h;
}
/*
* LstForEach(i, listHead) is a convenience macro for:
* for (i = listHead->next; i != listHead, i = i->next)
*/
#define LstForEach(pos, head) \
for (pos = (head)->next; pos != (head); pos = pos->next)
#endif
......@@ -51,31 +51,28 @@
typedef struct s_Ack sAck;
typedef struct s_Block sBlock;
typedef struct s_Handler sHandler;
LstType(sAck);
LstType(sBlock);
LstType(sHandler);
struct s_Ack {
LstLink(sAck) ack_l;
struct LstHead ack_l;
mh_sOutunitAck ack;
};
struct s_Block {
LstLink(sBlock) block_l;
struct LstHead block_l;
mh_sOutunitBlock block;
};
struct s_Handler {
LstLink(sHandler) handler_l;
LstLink(sHandler) sync_l;
struct LstHead handler_l;
struct LstHead sync_l;
pwr_tTime birthTime; /* Time when handler started */
qcom_sQid qid; /* Qcom queue of handler */
qcom_sAid aid; /* Qcom application id */
co_sPlatform platform; /* Platform identity */
pwr_tNodeIndex nix; /* Node index of handler */
LstHead(sAck) ack_l; /* Head to ack list */
struct LstHead ack_l; /* Head to ack list */
pwr_tUInt32 ackGen; /* Ack generation */
LstHead(sBlock) block_l; /* Head to block list */
struct LstHead block_l; /* Head to block list */
pwr_tUInt32 blockGen; /* Block generation */
pwr_tBoolean isDummy;
pwr_tBoolean linkUp;
......@@ -100,8 +97,8 @@ typedef struct {
pwr_tStatus (*cbInfo)(mh_sMessage*);
pwr_tStatus (*cbReturn)(mh_sReturn*);
pwr_tStatus (*cbAlarmStatus)(mh_sAlarmStatus*);
LstHead(sHandler) handler_l;
LstHead(sHandler) sync_l;
struct LstHead handler_l;
struct LstHead sync_l;
pwr_tUInt32 selGen;
pwr_tUInt32 selSize;
pwr_tString80 (*pSelL)[];
......@@ -153,18 +150,18 @@ pwr_tStatus mh_OutunitAck(mh_sEventId* targetId /**< The identity of an alarm.*/
{
pwr_tStatus sts = MH__SUCCESS;
sHandler* hp;
LstLink(sHandler) * hl;
struct LstHead * hl;
/* Find originating handler */
for (hl = LstFir(&l.handler_l); hl != LstEnd(&l.handler_l); hl = LstNex(hl))
if (LstObj(hl)->nix == targetId->Nix)
LstForEach(hl, &l.handler_l)
if (LstEntry(hl, sHandler, handler_l)->nix == targetId->Nix)
break;
if (hl == LstEnd(&l.handler_l)) {
if (hl == &l.handler_l) {
return MH__HANDLERDOWN;
} else {
hp = LstObj(hl);
hp = LstEntry(hl, sHandler, handler_l);
}
ackListInsert(hp, targetId->Idx);
......@@ -183,7 +180,7 @@ pwr_tStatus mh_OutunitBlock(
{
pwr_tStatus sts;
sHandler* hp;
LstLink(sHandler) * hl;
struct LstHead * hl;
pwr_tNodeIndex nix;
pwr_tBoolean is_mount_clean;
......@@ -193,18 +190,18 @@ pwr_tStatus mh_OutunitBlock(
if (EVEN(sts))
return sts;
for (hl = LstFir(&l.handler_l); hl != LstEnd(&l.handler_l); hl = LstNex(hl)) {
LstForEach(hl, &l.handler_l) {
if (!hl)
return MH__HANDLERDOWN;
if (LstObj(hl)->nix == nix)
if (LstEntry(hl, sHandler, handler_l)->nix == nix)
break;
}
if (hl == LstEnd(&l.handler_l)) {
if (hl == &l.handler_l) {
return MH__HANDLERDOWN;
} else {
hp = LstObj(hl);
hp = LstEntry(hl, sHandler, handler_l);
}
blockListInsert(hp, &object, prio);
......@@ -359,13 +356,13 @@ pwr_tStatus mh_OutunitConnect(
l.cbReturn = cbReturn;
l.cbAlarmStatus = cbAlarmStatus;
LstIni(&l.handler_l);
LstIni(&l.sync_l);
LstInit(&l.handler_l);
LstInit(&l.sync_l);
for (i = 0; i < 5; i++) {
hp = (sHandler*)calloc(1, sizeof(*hp));
hp->isDummy = TRUE;
LstIns(&l.sync_l, hp, sync_l);
LstInsert(&l.sync_l, &hp->sync_l);
}
getSelectList();
......@@ -397,18 +394,17 @@ pwr_tStatus mh_OutunitConnect(
pwr_tStatus mh_OutunitDisconnect()
{
sHandler* hp;
LstLink(sHandler) * hl;
struct LstHead * hl;
/* Disconnect all handlers and free memory */
for (hl = LstFir(&l.handler_l); hl != LstEnd(&l.handler_l);
hl = LstFir(&l.handler_l)) {
hp = LstObj(hl);
LstForEach(hl, &l.handler_l) {
hp = LstEntry(hl, sHandler, handler_l);
sendToHandler(hp, mh_eMsg_OutunitDisconnect, 0, NULL);
ackListDestroy(hp);
blockListDestroy(hp);
LstRem(hl);
LstNul(hl);
LstRemove(hl);
LstNull(hl);
free(hp);
}
......@@ -494,12 +490,12 @@ pwr_tStatus mh_OutunitSetTimeout(int timeout /**< The timeout in ms. */
pwr_tStatus mh_OutunitUpdate()
{
LstLink(sHandler) * hl;
struct LstHead * hl;
getSelectList();
for (hl = LstFir(&l.handler_l); hl != LstEnd(&l.handler_l); hl = LstNex(hl))
sendInfo(LstObj(hl));
LstForEach(hl, &l.handler_l)
sendInfo(LstEntry(hl, sHandler, handler_l));
return MH__SUCCESS;
}
......@@ -512,18 +508,18 @@ pwr_tStatus mh_OutunitUpdate()
pwr_tStatus mh_OutunitAlarmRequest(mh_sOutunitAlarmReq* msg)
{
sHandler* hp;
LstLink(sHandler) * hl;
struct LstHead * hl;
/* Find originating handler */
for (hl = LstFir(&l.handler_l); hl != LstEnd(&l.handler_l); hl = LstNex(hl))
if (LstObj(hl)->nix == msg->Nix)
LstForEach(hl, &l.handler_l)
if (LstEntry(hl, sHandler, handler_l)->nix == msg->Nix)
break;
if (hl == LstEnd(&l.handler_l)) {
if (hl == &l.handler_l) {
return MH__HANDLERDOWN;
} else {
hp = LstObj(hl);
hp = LstEntry(hl, sHandler, handler_l);
}
sendToHandler(hp, mh_eMsg_OutunitAlarmReq, sizeof(*msg), (void*)msg);
......@@ -533,10 +529,8 @@ pwr_tStatus mh_OutunitAlarmRequest(mh_sOutunitAlarmReq* msg)
static void ackListDelete(sHandler* hp, sAck* ap)
{
LstLink(sAck) * al;
al = LstRem(&ap->ack_l);
LstNul(&ap->ack_l);
LstRemove(&ap->ack_l);
LstNull(&ap->ack_l);
free(ap);
checkSyncListDelete(hp);
......@@ -545,13 +539,12 @@ static void ackListDelete(sHandler* hp, sAck* ap)
static void ackListDestroy(sHandler* hp)
{
sAck* ap;
LstLink(sAck) * al;
struct LstHead * al;
for (al = LstFir(&hp->ack_l); al != LstEnd(&hp->ack_l);
al = LstFir(&hp->ack_l)) {
ap = LstObj(al);
LstRem(al);
LstNul(al);
LstForEach(al, &hp->ack_l) {
ap = LstEntry(al, sAck, ack_l);
LstRemove(al);
LstNull(al);
free(ap);
}
......@@ -562,34 +555,32 @@ static void ackListDestroy(sHandler* hp)
static void ackListInsert(sHandler* hp, pwr_tUInt32 targetIdx)
{
sAck* ap;
LstLink(sAck) * al;
struct LstHead * al;
/* Don't insert if already present */
for (al = LstFir(&hp->ack_l); al != LstEnd(&hp->ack_l); al = LstNex(al))
if (LstObj(al)->ack.targetIdx == targetIdx)
LstForEach(al, &hp->ack_l)
if (LstEntry(al, sAck, ack_l)->ack.targetIdx == targetIdx)
return;
ap = (sAck*)calloc(1, sizeof(*ap));
ap->ack.ackGen = ++hp->ackGen;
ap->ack.targetIdx = targetIdx;
al = LstEnd(&hp->ack_l);
LstIns(al, ap, ack_l);
al = &hp->ack_l;
LstInsert(al, &ap->ack_l);
if (!LstInl(&hp->sync_l)) {
LstIns(LstEnd(&l.sync_l), hp, sync_l);
if (LstIsNull(&hp->sync_l)) {
LstInsert(&l.sync_l, &hp->sync_l);
}
if (ap == LstObj(LstFir(&hp->ack_l))) {
if (ap == LstEntry(hp->ack_l.next, sAck, ack_l)) {
sendToHandler(hp, mh_eMsg_OutunitAck, sizeof(ap->ack), (void*)&ap->ack);
}
}
static void blockListDelete(sHandler* hp, sBlock* bp)
{
LstLink(sBlock) * bl;
bl = LstRem(&bp->block_l);
LstNul(&bp->block_l);
LstRemove(&bp->block_l);
LstNull(&bp->block_l);
free(bp);
checkSyncListDelete(hp);
......@@ -598,13 +589,12 @@ static void blockListDelete(sHandler* hp, sBlock* bp)
static void blockListDestroy(sHandler* hp)
{
sBlock* bp;
LstLink(sBlock) * bl;
struct LstHead * bl;
for (bl = LstFir(&hp->block_l); bl != LstEnd(&hp->block_l);
bl = LstFir(&hp->block_l)) {
bp = LstObj(bl);
LstRem(bl);
LstNul(bl);
LstForEach(bl, &hp->block_l) {
bp = LstEntry(bl, sBlock, block_l);
LstRemove(bl);
LstNull(bl);
free(bp);
}
......@@ -615,21 +605,21 @@ static void blockListDestroy(sHandler* hp)
static void blockListInsert(sHandler* hp, pwr_tObjid* op, pwr_tUInt32 prio)
{
sBlock* bp;
LstLink(sBlock) * bl;
struct LstHead * bl;
bp = (sBlock*)calloc(1, sizeof(*bp));
bp->block.blockGen = ++hp->blockGen;
bp->block.object = *op;
bp->block.outunit = l.head.outunit;
bp->block.prio = prio;
bl = LstEnd(&hp->block_l);
LstIns(bl, bp, block_l);
bl = &hp->block_l;
LstInsert(bl, &bp->block_l);
if (!LstInl(&hp->sync_l)) {
LstIns(LstEnd(&l.sync_l), hp, sync_l);
if (LstIsNull(&hp->sync_l)) {
LstInsert(&l.sync_l, &hp->sync_l);
}
if (bp == LstObj(LstFir(&hp->block_l))) {
if (bp == LstEntry(hp->block_l.next, sBlock, block_l)) {
sendToHandler(
hp, mh_eMsg_OutunitBlock, sizeof(bp->block), (void*)&bp->block);
}
......@@ -637,14 +627,13 @@ static void blockListInsert(sHandler* hp, pwr_tObjid* op, pwr_tUInt32 prio)
static void checkSync()
{
LstLink(sHandler) * sl;
struct LstHead * sl;
sHandler* hp;
for (sl = LstFir(&l.sync_l); sl != LstEnd(&l.sync_l);
sl = LstFir(&l.sync_l)) {
hp = LstObj(sl);
LstRem(sl);
LstIns(LstEnd(&l.sync_l), hp, sync_l);
LstForEach(sl, &l.sync_l) {
hp = LstEntry(sl, sHandler, sync_l);
LstRemove(sl);
LstInsert(&l.sync_l, &hp->sync_l);
if (hp->isDummy)
return;
if (!hp->linkUp)
......@@ -656,39 +645,39 @@ static void checkSync()
static void checkSyncListDelete(sHandler* hp)
{
if (!LstInl(&hp->sync_l))
if (LstIsNull(&hp->sync_l))
return;
if (!LstEmp(&hp->ack_l))
if (!LstEmpty(&hp->ack_l))
return;
if (!LstEmp(&hp->block_l))
if (!LstEmpty(&hp->block_l))
return;
if (hp->selGen != l.selGen)
return;
LstRem(&hp->sync_l);
LstNul(&hp->sync_l);
LstRemove(&hp->sync_l);
LstNull(&hp->sync_l);
}
static void checkSyncReply(sHandler* hp)
{
if (hp->selGen != l.selGen) {
sendInfo(hp);
} else if (!LstEmp(&hp->block_l)) {
} else if (!LstEmpty(&hp->block_l)) {
sBlock* bp;
bp = LstObj(LstNex(&hp->block_l));
bp = LstEntry(hp->block_l.next, sBlock, block_l);
sendToHandler(
hp, mh_eMsg_OutunitBlock, sizeof(bp->block), (void*)&bp->block);
} else if (!LstEmp(&hp->ack_l)) {
} else if (!LstEmpty(&hp->ack_l)) {
sAck* ap;
ap = LstObj(LstNex(&hp->ack_l));
ap = LstEntry(hp->ack_l.next, sAck, ack_l);
sendToHandler(hp, mh_eMsg_OutunitAck, sizeof(ap->ack), (void*)&ap->ack);
}
if (LstInl(&hp->sync_l)) {
LstRem(&hp->sync_l);
LstIns(LstEnd(&l.sync_l), hp, sync_l);
if (!LstIsNull(&hp->sync_l)) {
LstRemove(&hp->sync_l);
LstInsert(&l.sync_l, &hp->sync_l);
}
}
......@@ -823,7 +812,7 @@ static void handlerEvent(sHandler* hp, mh_sHead* p)
{
pwr_tStatus sts;
mh_sMsgInfo* mp = (mh_sMsgInfo*)(p + 1);
LstLink(sAck) * al;
struct LstHead * al;
mh_sAck* ap;
mh_sReturn* cp;
......@@ -852,9 +841,9 @@ static void handlerEvent(sHandler* hp, mh_sHead* p)
ap = (mh_sAck*)mp;
for (al = LstFir(&hp->ack_l); al != LstEnd(&hp->ack_l); al = LstNex(al))
if (LstObj(al)->ack.targetIdx == ap->TargetId.Idx) {
ackListDelete(hp, LstObj(al));
LstForEach(al, &hp->ack_l)
if (LstEntry(al, sAck, ack_l)->ack.targetIdx == ap->TargetId.Idx) {
ackListDelete(hp, LstEntry(al, sAck, ack_l));
break;
}
......@@ -883,9 +872,9 @@ static void handlerEvent(sHandler* hp, mh_sHead* p)
cp = (mh_sReturn*)mp;
for (al = LstFir(&hp->ack_l); al != LstEnd(&hp->ack_l); al = LstNex(al))
if (LstObj(al)->ack.targetIdx == cp->TargetId.Idx) {
ackListDelete(hp, LstObj(al));
LstForEach(al, &hp->ack_l)
if (LstEntry(al, sAck, ack_l)->ack.targetIdx == cp->TargetId.Idx) {
ackListDelete(hp, LstEntry(al, sAck, ack_l));
break;
}
......@@ -915,18 +904,18 @@ static void handlerLog(sHandler* hp, char* s)
static void handlerSync(sHandler* hp, mh_sHead* p)
{
if (!LstEmp(&hp->ack_l)) {
if (!LstEmpty(&hp->ack_l)) {
sAck* ap;
ap = LstObj(LstNex(&hp->ack_l));
ap = LstEntry(hp->ack_l.next, sAck, ack_l);
if (ap->ack.ackGen == p->ackGen)
ackListDelete(hp, ap);
}
if (!LstEmp(&hp->block_l)) {
if (!LstEmpty(&hp->block_l)) {
sBlock* bp;
bp = LstObj(LstNex(&hp->block_l));
bp = LstEntry(hp->block_l.next, sBlock, block_l);
if (bp->block.blockGen == p->blockGen)
blockListDelete(hp, bp);
}
......@@ -953,7 +942,7 @@ static void handlerAlarmStatus(sHandler* hp, mh_sHead* p)
static pwr_tBoolean isValidHandler(mh_sHead* p, qcom_sAid* aid, sHandler** h)
{
sHandler* hp;
LstLink(sHandler) * hl;
struct LstHead * hl;
if (!(p->ver == mh_cVersion
|| (mh_cVersion == 5
......@@ -969,11 +958,11 @@ static pwr_tBoolean isValidHandler(mh_sHead* p, qcom_sAid* aid, sHandler** h)
/* Find handler in handler list */
for (hl = LstFir(&l.handler_l); hl != LstEnd(&l.handler_l); hl = LstNex(hl))
if (LstObj(hl)->qid.qix == p->qid.qix && LstObj(hl)->qid.nid == p->qid.nid)
LstForEach(hl, &l.handler_l)
if (LstEntry(hl, sHandler, handler_l)->qid.qix == p->qid.qix && LstEntry(hl, sHandler, handler_l)->qid.nid == p->qid.nid)
break;
if (hl == LstEnd(&l.handler_l)) {
if (hl == &l.handler_l) {
/* Handler not known, make it known */
hp = (sHandler*)calloc(1, sizeof(*hp));
hp->birthTime = net_NetTimeToTime(&p->birthTime);
......@@ -982,12 +971,12 @@ static pwr_tBoolean isValidHandler(mh_sHead* p, qcom_sAid* aid, sHandler** h)
hp->platform = p->platform;
hp->nix = p->nix;
hp->linkUp = TRUE;
LstIns(&l.handler_l, hp, handler_l);
LstIni(&hp->ack_l);
LstIni(&hp->block_l);
LstInsert(&l.handler_l, &hp->handler_l);
LstInit(&hp->ack_l);
LstInit(&hp->block_l);
handlerLog(hp, "New handler");
} else {
hp = LstObj(hl);
hp = LstEntry(hl, sHandler, handler_l);
if (hp->birthTime.tv_sec != p->birthTime.tv_sec) {
/* Different times, i.e. the handler is restarted */
......@@ -1010,12 +999,12 @@ static pwr_tBoolean isValidHandler(mh_sHead* p, qcom_sAid* aid, sHandler** h)
static void linkDown(qcom_sNode* nodep)
{
LstLink(sHandler) * hl;
struct LstHead * hl;
sHandler* hp;
for (hl = LstFir(&l.handler_l); hl != LstEnd(&l.handler_l); hl = LstNex(hl))
if (LstObj(hl)->qid.nid == nodep->nid) {
hp = LstObj(hl);
LstForEach(hl, &l.handler_l)
if (LstEntry(hl, sHandler, handler_l)->qid.nid == nodep->nid) {
hp = LstEntry(hl, sHandler, handler_l);
hp->linkUp = FALSE;
handlerLog(hp, "Link down");
return;
......@@ -1024,12 +1013,12 @@ static void linkDown(qcom_sNode* nodep)
static void linkUp(qcom_sNode* nodep)
{
LstLink(sHandler) * hl;
struct LstHead * hl;
sHandler* hp;
for (hl = LstFir(&l.handler_l); hl != LstEnd(&l.handler_l); hl = LstNex(hl))
if (LstObj(hl)->qid.nid == nodep->nid) {
hp = LstObj(hl);
LstForEach(hl, &l.handler_l)
if (LstEntry(hl, sHandler, handler_l)->qid.nid == nodep->nid) {
hp = LstEntry(hl, sHandler, handler_l);
hp->linkUp = TRUE;
handlerLog(hp, "Link up");
return;
......@@ -1039,20 +1028,21 @@ static void linkUp(qcom_sNode* nodep)
static void procDown(qcom_sAid* aid)
{
sHandler* hp;
LstLink(sHandler) * hl;
struct LstHead * hl;
for (hl = LstFir(&l.handler_l); hl != LstEnd(&l.handler_l); hl = LstNex(hl))
if (LstObj(hl)->aid.aix == aid->aix && LstObj(hl)->aid.nid == aid->nid) {
LstForEach(hl, &l.handler_l) {
hp = LstEntry(hl, sHandler, handler_l);
if (hp->aid.aix == aid->aix && hp->aid.nid == aid->nid) {
/* Delete this handler from handler list */
hp = LstObj(hl);
handlerLog(hp, "Handler aborted");
ackListDestroy(hp);
blockListDestroy(hp);
LstRem(hl);
LstNul(hl);
LstRemove(hl);
LstNull(hl);
free(hp);
return;
}
}
}
static void sendInfo(sHandler* hp)
......@@ -1081,8 +1071,8 @@ static void sendInfo(sHandler* hp)
free(mp);
if (!LstInl(&hp->sync_l)) {
LstIns(LstEnd(&l.sync_l), hp, sync_l);
if (LstIsNull(&hp->sync_l)) {
LstInsert(&l.sync_l, &hp->sync_l);
}
}
......
......@@ -64,10 +64,8 @@
typedef struct s_FacilityCB sFacilityCB;
LstType(sFacilityCB);
struct s_FacilityCB {
LstLink(sFacilityCB) FacL;
struct LstHead FacL;
char* facnam;
int facnum;
};
......@@ -76,7 +74,7 @@ extern int lineno;
static int SyntaxError;
static LstHead(sFacilityCB) lFacH;
static struct LstHead lFacH;
static sFacilityCB* CurrFac = NULL;
static void CopyFile(FILE* ifp, FILE* ofp);
......@@ -122,7 +120,7 @@ int main(int argc, char** argv)
exit(1);
}
LstIni(&lFacH);
LstInit(&lFacH);
SyntaxError = 0;
lineno = 1;
......@@ -159,7 +157,7 @@ void lex_FacName(char* facnam)
void lex_FacNum(int facnum)
{
LstLink(sFacilityCB) * fl;
struct LstHead * fl;
/*
* To do: Check that the facility number is within the valid range
......@@ -167,14 +165,14 @@ void lex_FacNum(int facnum)
*/
/* Insert in ascending order */
for (fl = LstFir(&lFacH); fl != LstEnd(&lFacH); fl = LstNex(fl)) {
if (LstObj(fl)->facnum > facnum) {
LstForEach(fl, &lFacH) {
if (LstEntry(fl, sFacilityCB, FacL)->facnum > facnum) {
break;
}
}
CurrFac->facnum = facnum;
LstIns(fl, CurrFac, FacL);
LstInsert(fl, &CurrFac->FacL);
CurrFac = NULL;
}
......@@ -192,20 +190,20 @@ static void CopyFile(FILE* ifp, FILE* ofp)
static void WriteFacility(FILE* cfp, char* branch)
{
LstLink(sFacilityCB) * fl;
struct LstHead * fl;
int i = 0;
fprintf(cfp, "static msg_sFacility *Facilities[] = {\n");
for (fl = LstFir(&lFacH); fl != LstEnd(&lFacH); fl = LstNex(fl)) {
LstForEach(fl, &lFacH) {
if (i++)
fprintf(cfp, ",\n");
fprintf(cfp, "\t%-20s /* %4d */", LstObj(fl)->facnam, LstObj(fl)->facnum);
fprintf(cfp, "\t%-20s /* %4d */", LstEntry(fl, sFacilityCB, FacL)->facnam, LstEntry(fl, sFacilityCB, FacL)->facnum);
}
fprintf(cfp, "};\n\n");
if (LstFir(&lFacH) == LstEnd(&lFacH))
if (LstEmpty(&lFacH))
fprintf(cfp, "msg_sHead %sMsgHead = {0, 0};\n", branch ? branch : "pwrp");
else
fprintf(cfp, "msg_sHead %sMsgHead = {MSG_NOF(Facilities), Facilities};\n",
......
......@@ -61,18 +61,15 @@
typedef struct s_FacilityCB sFacilityCB;
typedef struct s_MsgCB sMsgCB;
LstType(sFacilityCB);
LstType(sMsgCB);
struct s_MsgCB {
LstLink(sMsgCB) MsgL;
struct LstHead MsgL;
msg_sMsg m;
msg_eSeverity Severity;
};
struct s_FacilityCB {
LstLink(sFacilityCB) FacL;
LstHead(sMsgCB) MsgH;
struct LstHead FacL;
struct LstHead MsgH;
msg_sFacility f;
};
......@@ -81,7 +78,7 @@ extern int lineno;
static int SyntaxError;
static LstHead(sFacilityCB) lFacH;
static struct LstHead lFacH;
/*
* Local functions
......@@ -125,7 +122,7 @@ int main(int argc, char** argv)
exit(2);
}
LstIni(&lFacH);
LstInit(&lFacH);
SyntaxError = 0;
lineno = 1;
yylex();
......@@ -160,20 +157,20 @@ void lex_FacName(const char* FacName)
{
sFacilityCB* facp = (sFacilityCB*)calloc(1, sizeof(sFacilityCB));
LstIni(&facp->MsgH);
LstInit(&facp->MsgH);
facp->f.FacName = MSG_NEW_STRING(FacName);
LstIns(&lFacH, facp, FacL);
LstInsert(&lFacH, &facp->FacL);
}
void lex_FacNum(int FacNum)
{
LstObj(LstLas(&lFacH))->f.FacNum = FacNum;
LstEntry(lFacH.prev, sFacilityCB, FacL)->f.FacNum = FacNum;
}
void lex_FacPrefix(const char* Prefix)
{
LstObj(LstLas(&lFacH))->f.Prefix = MSG_NEW_STRING(Prefix);
LstEntry(lFacH.prev, sFacilityCB, FacL)->f.Prefix = MSG_NEW_STRING(Prefix);
}
void lex_MsgName(const char* MsgName)
......@@ -187,21 +184,21 @@ void lex_MsgName(const char* MsgName)
msgp->m.MsgName[i] = toupper(MsgName[i]);
msgp->m.MsgName[i] = '\0';
(void)LstIns(&LstObj(LstLas(&lFacH))->MsgH, msgp, MsgL);
LstInsert(&LstEntry(lFacH.prev, sFacilityCB, FacL)->MsgH, &msgp->MsgL);
}
void lex_MsgText(const char* Text)
{
LstLink(sMsgCB)* ml = LstLas(&LstObj(LstLas(&lFacH))->MsgH);
struct LstHead* ml = LstEntry(lFacH.prev, sFacilityCB, FacL)->MsgH.prev;
TranslateFormatSpec(
Text, &LstObj(ml)->m.MsgTxt); /* convert any VMS-style form spec */
Text, &LstEntry(ml, sMsgCB, MsgL)->m.MsgTxt); /* convert any VMS-style form spec */
}
void lex_MsgSeverity(msg_eSeverity Severity)
{
LstLink(sMsgCB)* ml = LstLas(&LstObj(LstLas(&lFacH))->MsgH);
LstObj(ml)->Severity = Severity;
struct LstHead* ml = LstEntry(lFacH.prev, sFacilityCB, FacL)->MsgH.prev;
LstEntry(ml, sMsgCB, MsgL)->Severity = Severity;
}
void lex_LexError(int Lineno, char* Str)
......@@ -215,8 +212,8 @@ void lex_LexError(int Lineno, char* Str)
*/
static void WriteFiles(char* fname, FILE* cfp, FILE* hfp)
{
LstLink(sFacilityCB) * fl;
LstLink(sMsgCB) * ml;
struct LstHead * fl;
struct LstHead * ml;
int idx;
int facid;
char prefix[32];
......@@ -227,37 +224,38 @@ static void WriteFiles(char* fname, FILE* cfp, FILE* hfp)
fprintf(hfp, "#ifndef %s_h\n", fname);
fprintf(hfp, "#define %s_h\n\n", fname);
for (fl = LstFir(&lFacH); fl != LstEnd(&lFacH); fl = LstNex(fl)) {
facid = 0x800 + LstObj(fl)->f.FacNum;
snprintf(name, sizeof(name), "%s_FACILITY", LstObj(fl)->f.FacName);
LstForEach(fl, &lFacH) {
facid = 0x800 + LstEntry(fl, sFacilityCB, FacL)->f.FacNum;
snprintf(name, sizeof(name), "%s_FACILITY", LstEntry(fl, sFacilityCB, FacL)->f.FacName);
fprintf(hfp, "#define %-29s %9d /* x%08x */\n", name, facid, facid);
facid = facid << 16;
if (LstObj(fl)->f.Prefix)
strncpy(prefix, LstObj(fl)->f.Prefix, sizeof(prefix));
if (LstEntry(fl, sFacilityCB, FacL)->f.Prefix)
strncpy(prefix, LstEntry(fl, sFacilityCB, FacL)->f.Prefix, sizeof(prefix));
else
snprintf(prefix, sizeof(prefix), "%s_", LstObj(fl)->f.FacName);
snprintf(prefix, sizeof(prefix), "%s_", LstEntry(fl, sFacilityCB, FacL)->f.FacName);
snprintf(msgName, sizeof(msgName), "%smsg", LstObj(fl)->f.FacName);
snprintf(msgName, sizeof(msgName), "%smsg", LstEntry(fl, sFacilityCB, FacL)->f.FacName);
fprintf(cfp, "static msg_sMsg %s[] = {\n", msgName);
for (idx = 1, ml = LstFir(&LstObj(fl)->MsgH);
ml != LstEnd(&LstObj(fl)->MsgH); ml = LstNex(ml), idx++) {
idx = 1;
LstForEach(ml, &LstEntry(fl, sFacilityCB, FacL)->MsgH) {
if (idx != 1)
fprintf(cfp, ",\n");
msg = facid + 0x8000 + (idx << 3) + LstObj(ml)->Severity;
snprintf(name, sizeof(name), "%s%s", prefix, LstObj(ml)->m.MsgName);
msg = facid + 0x8000 + (idx << 3) + LstEntry(ml, sMsgCB, MsgL)->Severity;
snprintf(name, sizeof(name), "%s%s", prefix, LstEntry(ml, sMsgCB, MsgL)->m.MsgName);
fprintf(hfp, "#define %-29s %9.9d /* x%08x */\n", name, msg, msg);
fprintf(cfp, "\t{\"%s\", \"%s\"}", LstObj(ml)->m.MsgName,
LstObj(ml)->m.MsgTxt);
fprintf(cfp, "\t{\"%s\", \"%s\"}", LstEntry(ml, sMsgCB, MsgL)->m.MsgName,
LstEntry(ml, sMsgCB, MsgL)->m.MsgTxt);
idx++;
}
fprintf(cfp, "\n};\n\n");
fprintf(cfp, "static msg_sFacility %sfacility[] = {\n\t",
LstObj(fl)->f.FacName);
LstEntry(fl, sFacilityCB, FacL)->f.FacName);
fprintf(cfp, "{%d, \"%s\", \"%s\", MSG_NOF(%s), %s}\n",
LstObj(fl)->f.FacNum, LstObj(fl)->f.FacName, prefix, msgName, msgName);
LstEntry(fl, sFacilityCB, FacL)->f.FacNum, LstEntry(fl, sFacilityCB, FacL)->f.FacName, prefix, msgName, msgName);
fprintf(cfp, "};\n\n");
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment