static void toolAction ( d_storeMMFKernel kernel, c_voidp addr) { c_base base; c_type type; c_char *name; c_object o; c_address offset; c_long size; struct toolActionData actionData; actionData.fin = stdin; actionData.fout = stdout; actionData.depth = 0; actionData.stack = NULL; base = c_getBase(kernel); o = c_baseCheckPtr(base, addr); if (o) { type = c_getType(o); size = c_typeSize(type); if (o != addr) { offset = C_ADDRESS(addr) - C_ADDRESS(o); if (offset < (c_address)size) { printf("Warning: address is %lu bytes in %s " "object starting at 0x"PA_ADDRFMT"\n", offset, _METANAME(type), (os_address)o); OBJECT_PUSH(&actionData, o); tryPrintOffset(o,&actionData,offset); OBJECT_POP(&actionData); } else { printf("Warning: address is %lu bytes in " "memory starting at 0x"PA_ADDRFMT"\n", offset, (os_address)o); } } else { name = c_metaScopedName(c_metaObject(type)); printf("Object <0x"PA_ADDRFMT"> refCount=%d size=%d type is: <0x"PA_ADDRFMT"> %s\n", (os_address)o, c_refCount(o), size, (os_address)type, name); os_free(name); OBJECT_PUSH(&actionData, o); printType(type, &actionData); printf("\n"); OBJECT_POP(&actionData); } } else { printf("Address <0x"PA_ADDRFMT"> is not a Database Object\n", (os_address)addr); } }
c_iter v_cfElementXPath( v_cfElement element, const c_char *xpathExpr) { c_iter result; const c_char *posInExpr; const c_char *slash; char *attribEnd; c_ulong length; struct getChildrenArg arg; c_long nrToProcess; v_cfNode node; assert(C_TYPECHECK(element, v_cfElement)); assert(xpathExpr != NULL); result = c_iterNew(element); nrToProcess = 1; posInExpr = xpathExpr; slash = strchr(posInExpr, XPATH_SEPERATOR); while (nrToProcess > 0) { node = c_iterTakeFirst(result); nrToProcess--; if (node->kind == V_CFELEMENT) { /* do not process data elements */ if (slash) { length = C_ADDRESS(slash) - C_ADDRESS(posInExpr); } else { length = strlen(posInExpr); } arg.children = c_iterNew(NULL); arg.tagName = (c_char *)os_malloc(length + 1U); os_strncpy(arg.tagName, posInExpr, length); arg.tagName[length] = 0; /* Look for selection criteria based on attribute value * Example XPath expression: * /aaa/bbb[@name='value']/ccc or /aaa/bbb[@name!='value']/ccc */ arg.attribName = strchr(arg.tagName, '['); if (arg.attribName != NULL) { *arg.attribName = '\0'; arg.attribName = &(arg.attribName[1]); assert(*arg.attribName == '@'); arg.attribName = &(arg.attribName[1]); arg.attribValue = strchr(arg.attribName, '!'); if (arg.attribValue != NULL) { arg.attribNegate = TRUE; *arg.attribValue = '\0'; arg.attribValue = &arg.attribValue[1]; assert(*arg.attribValue == '='); } else { arg.attribNegate = FALSE; arg.attribValue = strchr(arg.attribName, '='); } assert(arg.attribValue != NULL); *arg.attribValue = '\0'; arg.attribValue = &arg.attribValue[1]; assert(*arg.attribValue == '\''); arg.attribValue = &(arg.attribValue[1]); attribEnd = strchr(arg.attribValue, '\''); assert(attribEnd != NULL); *attribEnd = '\0'; assert(attribEnd[1] == ']'); } c_walk(v_cfElement(node)->children, getChildren, &arg); os_free(arg.tagName); if (slash) { nrToProcess += c_iterLength(arg.children); } /* now append */ node = v_cfNode(c_iterTakeFirst(arg.children)); while (node != NULL) { c_iterAppend(result, node); node = v_cfNode(c_iterTakeFirst(arg.children)); } c_iterFree(arg.children); if (slash) { posInExpr = (const c_char *)(C_ADDRESS(slash) + 1U); slash = strchr(posInExpr, XPATH_SEPERATOR); } } } return result; }