FORMAT_PTR formatChoosePtrFormat(CONST_FORMAT_PTR format, FORMAT_PTR parentFormat) { return(CHOOSE_PTR_FORMAT(format, parentFormat)); }
static void Print_Structured_Data(FILE *Stream, Print_Data_Ptr printer, CONST_FORMAT_PTR Format, CONST_GENERIC_DATA_PTR Data_Ptr, int32 DStart, CONST_FORMAT_PTR parentFormat, int32 Keep_With_Next) { TRANSLATE_FN_DPRINT printProc; int32 i, last_element_p, next_keep, length, currentDStart; u_int32 byte; void *StructPtr, *ArrayPtr; FORMAT_ARRAY_PTR format_array, fixed_format_array; currentDStart = DStart; switch (Format->type) { case LengthFMT: length = Format->formatter.i; printString(Stream, printer, "(", DEFAULT_KEEP); for (i=0; i<length; i++) { if (printer->truncatedGlobal) { return; } else { byte = 0; *(((u_char *)&byte)+sizeof(u_int32)-sizeof(u_char)) = *(u_char *)(Data_Ptr+currentDStart+i); printHex(Stream, printer, &byte, (i == length-1 ? Keep_With_Next+1 : 1)); if (i == length-1) printString(Stream, printer, ")", Keep_With_Next); else printCommaSpace(Stream, printer); } } break; case PrimitiveFMT: printProc = GET_M_GLOBAL(TransTable)[Format->formatter.i].DPrint; (* printProc)(Data_Ptr, currentDStart, Stream, printer, Keep_With_Next); break; case PointerFMT: StructPtr = REF(GENERIC_DATA_PTR, Data_Ptr, currentDStart); if (StructPtr) { printString(Stream, printer, "*", DEFAULT_KEEP); Print_Structured_Data(Stream, printer, CHOOSE_PTR_FORMAT(Format, parentFormat), (CONST_GENERIC_DATA_PTR)StructPtr, 0, (CONST_FORMAT_PTR)NULL, Keep_With_Next); } else printString(Stream, printer, "NULL", Keep_With_Next); break; case StructFMT: printString(Stream, printer, "{", DEFAULT_KEEP); format_array = Format->formatter.a; for (i=1;i<format_array[0].i;i++) { if (printer->truncatedGlobal) return; else { last_element_p = (i+1 == format_array[0].i); next_keep = ((last_element_p) ? Keep_With_Next+1 : 1); Print_Structured_Data(Stream, printer, format_array[i].f, Data_Ptr+DStart, currentDStart-DStart, Format, next_keep); currentDStart += x_ipc_dataStructureSize(format_array[i].f); currentDStart = x_ipc_alignField(Format, i, currentDStart); if (last_element_p) printString(Stream, printer, "}", Keep_With_Next); else printCommaSpace(Stream, printer); } } break; case FixedArrayFMT: (void)printArrayData(Stream, printer, Format->formatter.a[1].f, Data_Ptr, currentDStart, Format->formatter.a, 2, Keep_With_Next, "[", "]"); break; case VarArrayFMT: ArrayPtr = REF(GENERIC_DATA_PTR, Data_Ptr, currentDStart); format_array = Format->formatter.a; if (ArrayPtr) { fixed_format_array = fix_format_array(format_array, parentFormat, Data_Ptr, currentDStart); (void)printArrayData(Stream, printer, format_array[1].f, ArrayPtr, 0, fixed_format_array, 2, Keep_With_Next, "<", ">"); x_ipcFree((char *)fixed_format_array); } else printString(Stream, printer, "NULL", Keep_With_Next); break; case NamedFMT: Print_Structured_Data(Stream, printer, x_ipc_fmtFind(Format->formatter.name), Data_Ptr, currentDStart, parentFormat, Keep_With_Next); break; case BadFormatFMT: printString(Stream, printer, "Bad Format", Keep_With_Next); case EnumFMT: { int32 eVal; eVal = x_ipc_enumToInt(Format, Data_Ptr, ¤tDStart); if (Format->formatter.a[0].i > 2 && /* enum value within range */ 0 <= eVal && eVal <= ENUM_MAX_VAL(Format)) { printString(Stream, printer, Format->formatter.a[eVal+2].f->formatter.name, Keep_With_Next); } else { printInt(Stream, printer, &eVal, Keep_With_Next); } break; } #ifndef TEST_CASE_COVERAGE default: X_IPC_MOD_ERROR1("Unknown Print_Structured_Data Type %d", Format->type); break; #endif } }