int encodeServedUserNumber(__u8 *dest, __s8 *servedUserNumber) { if (servedUserNumber[0]) return encodePartyNumber(dest, servedUserNumber); else return encodeNull(dest); }
int encodeInterrogationDiversion(__u8 *dest, struct FacCFInterrogateParameters *params) { __u8 *p; dest[0] = 0x30; // sequence dest[1] = 0; // length p = &dest[2]; p += encodeEnum(p, params->Procedure); #if 0 if (basicService == 0) p += encodeNull(p); else #endif p += encodeEnum(p, params->BasicService); p += encodeServedUserNumber(p, params->ServedUserNumber); dest[1] = p - &dest[2]; return p - dest; }
void PrinterBase::impl_print(const PVField& pv) { static const PVField* marker = (const PVField*)▮ /* Depth first recursive iteration. * Each PV to be printed is appended to the todo queue. * The last child of a structure is followed by a NULL. * As the tree is walked structures and structarrays * are appended to the inprog queue. */ std::deque<const PVField*> todo, inprog; todo.push_back(&pv); while(!todo.empty()) { const PVField *next = todo.front(); todo.pop_front(); if(next==marker) { // finished with a structure or structarray, // now we fall back to its parent. assert(!inprog.empty()); switch(inprog.back()->getField()->getType()) { case structure: endStructure(*static_cast<const PVStructure *>(inprog.back())); break; case structureArray: endStructureArray(*static_cast<const PVStructureArray *>(inprog.back())); break; case union_: endUnion(*static_cast<const PVUnion *>(inprog.back())); break; case unionArray: endUnionArray(*static_cast<const PVUnionArray *>(inprog.back())); break; default: assert(false); // oops! return; } inprog.pop_back(); } else { // real field if(!next) { // NULL entry in a structure array encodeNull(); continue; } switch(next->getField()->getType()) { case scalar: encodeScalar(*static_cast<const PVScalar*>(next)); break; case scalarArray: encodeArray(*static_cast<const PVScalarArray*>(next)); break; case structure: { const PVStructure &fld = *static_cast<const PVStructure*>(next); const PVFieldPtrArray& vals = fld.getPVFields(); inprog.push_back(next); beginStructure(fld); for(size_t i=0, nfld=fld.getStructure()->getNumberFields(); i<nfld; i++) todo.push_back(vals[i].get()); todo.push_back(marker); break; } case structureArray: { const PVStructureArray &fld = *static_cast<const PVStructureArray*>(next); PVStructureArray::const_svector vals(fld.view()); inprog.push_back(next); beginStructureArray(fld); for(PVStructureArray::const_svector::const_iterator it=vals.begin(); it!=vals.end(); ++it) { todo.push_back(it->get()); } todo.push_back(marker); break; } case union_: { const PVUnion &fld = *static_cast<const PVUnion*>(next); inprog.push_back(next); beginUnion(fld); PVFieldPtr val = fld.get(); if (val.get()) // TODO print "(none)" ? todo.push_back(val.get()); todo.push_back(marker); break; } case unionArray: { const PVUnionArray &fld = *static_cast<const PVUnionArray*>(next); PVUnionArray::const_svector vals(fld.view()); inprog.push_back(next); beginUnionArray(fld); for(PVUnionArray::const_svector::const_iterator it=vals.begin(); it!=vals.end(); ++it) { todo.push_back(it->get()); } todo.push_back(marker); break; } } } } }