/////////////////////////////////////////////////////////////////////////////// // Loads BIN file LoadStatus BINLoad(wchar_t* in_file_name) { FILE* bin_file; size_t length; // initialize InitDataBuffer(); // open BIN file bin_file = _wfopen(in_file_name, L"rb"); if(bin_file == NULL) return LS_Fatal; length = fread(g_db_buffer, sizeof(uint8_t), DB_MAX_DATA_LENGTH, bin_file); g_db_buffer_length = (uint16_t)length; return LS_Success; }
uint /* 521*/ ShowStruct(DFILE *dfp,uint row,uint rows,uint skip) /* -> dfile node containing stucture.*/ /* screen row. */ /* rows available for display. */ /* # of logical data recs to skip. */ { /* */ uint item; /* */ uint rr; /* */ uint n; /* */ TD_STRUCT *tp; /* 813*/ TD_TYPELIST *typelist; /* 813*/ Trec *namelist; /* */ uint Nitems; /* */ uint mid; /* */ uint sfx; /* */ uchar *cp; /* */ uint baseaddr; /* 112*/ uchar buffer[2*DATALINESPAN]; /* */ uint memberoffs; /* offset of member within structure.*/ uint membertype; /* type of the structure member. */ USHORT MaxLen; /* length of max structure name813529*/ /* */ mid = dfp->mid; /* */ sfx = dfp->sfx; /* */ baseaddr = dfp->baseaddr; /* */ /*****************************************************************************/ /* The first thing we want to do is get a pointer to the base type record. */ /* If the showtype is <= 512, indicating a primitive type, then we will */ /* get a back a NULL. */ /*****************************************************************************/ tp = (TD_STRUCT*)QbasetypeRec(mid, dfp->showtype); /* 813*/ if(!tp || /* cutting through the typedefs. */ tp->RecType != T_STRUCT /* */ ) /* cutting through the typedefs. */ return(FALSE); /*****************************************************************************/ /* Now, we are going to get the number of structure members and quit if we */ /* were told to skip more than the number of structure members. */ /*****************************************************************************/ Nitems = tp->NumMembers; /* 813*/ if( Nitems <= skip ) return(FALSE); /*****************************************************************************/ /* Now, get pointers to the type list and the name list. */ /*****************************************************************************/ typelist = (TD_TYPELIST*)QtypeRec(mid, tp->TypeListIndex); /*813*/ namelist = QtypeRec(mid, tp->NameListIndex); /*813*/ /* */ if( skip ) /* */ dfp = NULL; /* */ /* */ for( rr=0, item=skip+1; /* 813*/ (rr < rows) && /* */ (item <= Nitems); /* */ ++rr, ++item /* */ ) /* */ { /* */ cp = (UCHAR *)QNameList(namelist,NAME,item-1); /* find a member name. 813*/ if(!cp) /* if there is no name then go home. */ break; /* */ /* */ InitDataBuffer( buffer, /* initialize the data buffer, i.e. */ DATALINESPAN, /* clear it, put expression name in */ dfp /* it, put attributes in it, and . */ ); /* and terminate it with \0. */ dfp = NULL; /* kill dfp so we won't write the */ /* expression name again. */ MaxLen = *(USHORT*)cp; /* length of structure name 813529*/ MaxLen = /* limit the length of the name 529*/ (MaxLen < (TAB2-2)) ? MaxLen : (TAB2-2); /* till TAB2 position 529*/ n = sprintf( buffer + STGCOL+1, /* put the member name in the buffer.*/ "%.*s: ", /* 521*/ MaxLen, /* 529*/ cp+sizeof(USHORT) /* 813*/ ); /* */ /* */ /* compute the offset of this member */ /* within the data structure. */ memberoffs = QNameList(namelist,MEMBEROFFSET,item-1); /*813*/ /* find the type of this member. */ membertype = typelist->TypeIndex[item-1]; /*813112*/ /* */ /* */ *(buffer + STGCOL+1 + n) = ' '; /* remove null inserted by buffmt */ /* */ if ( n <= TAB1 ) n = TAB1; /* move to a tab position based */ else n = TAB2; /* on length of member name */ /* */ /* */ /* now format this item in the buffer*/ FormatDataItem( buffer + STGCOL+1 + n,/* starting position for the data. */ baseaddr + memberoffs,/* address of the member to format. */ mid, /* mid containing the data. */ membertype, /* type of the member. */ sfx /* stack frame index if there is one*/ ); /* */ /* */ buffer[ DATALINESPAN-1 ] = 0; /* terminate the data buffer...again.*/ putrc( row + rr, 0, buffer ); /* now display the data line. */ } /* */ /* */ if( rr < rows ) /* now clear the remaining rows. */ ClrScr( row + rr, /* */ row + rows - 1, /* */ vaStgExp /* */ ); /* */ return( TRUE ); /* */ } /* */
uint /* 521*/ ShowArray( DFILE *dfp, uint row, uint rows, uint skip ) /*112*/ { /**12*/ TD_ARRAY *tp; /* 813*/ uint item; /* array item to display. 112*/ uint rr; /* 112*/ uint n; /* gp integer. 112*/ uint Nitems; /* number of array items. 112*/ uint atomtype; /* type of array items. 112*/ uint atomsize; /* size of an array item. 112*/ uint mid; /* module id for the array var. 112*/ uint sfx; /* stack frame index if auto. 112*/ uint baseaddr; /* user addr where array starts. 112*/ uchar buffer[2*DATALINESPAN]; /* display buffer for array item. 112*/ uchar *cp; /* gp char ptr. 112*/ uint addr; /* gp address. 112*/ /*112*/ mid = dfp->mid; /*112*/ sfx = dfp->sfx; /*112*/ baseaddr = dfp->baseaddr; /*112*/ /*112*/ /****************************************************************************/ /* - get a ptr to the defining type record in $$type seg. 112*/ /* - get the atomic type of the array elements. 112*/ /* - get the size of the atomic type. 112*/ /* - get the number of array items. 112*/ /* - handle any errors in the above steps by simply returning false. 112*/ /* 112*/ /****************************************************************************/ tp = (TD_ARRAY*)QbasetypeRec(mid, dfp->showtype); /*813112*/ if( ( tp == NULL ) || ( tp->RecType != T_ARRAY ) ) /*813112*/ return( FALSE ); /*112*/ /*112*/ atomtype = tp->ElemType; /*813112*/ atomtype = HandleUserDefs(mid,atomtype); /*813*/ /*512*/ if( atomtype == 0 ) /*112*/ return( FALSE ); /*112*/ /*112*/ atomsize = QtypeSize(mid, atomtype); /*112*/ if( atomsize == 0 ) /*112*/ return( FALSE ); /*112*/ /*112*/ Nitems = tp->ByteSize/atomsize; /*813112*/ if( Nitems == 0 ) /*912*/ Nitems = 1; /*912*/ if( Nitems <= skip ) /*112*/ return( FALSE ); /*112*/ /*112*/ /************************************************************************112*/ /* simply show character array bytes as a string. 112*/ /************************************************************************112*/ if( atomtype == TYPE_CHAR || atomtype == TYPE_UCHAR ) /*112*/ { /*112*/ ShowHexBytes(dfp, row, rows, skip); /*112*/ return( TRUE ); /*112*/ } /*112*/ /*112*/ /************************************************************************112*/ /* -we only want to associate the array name with the first element of 112*/ /* the array. We set dfp == null after the first element, or before the 112*/ /* first element if we have scrolled the array name off the screen. 112*/ /* -format each element. 112*/ /* -display in int and hex format. 112*/ /* -truncate long lines. 112*/ /* 112*/ /************************************************************************112*/ if( skip ) /*112*/ dfp = NULL; /*112*/ /*112*/ for( rr=0, item=skip+1; (rr < rows) && (item <= Nitems); ++rr, ++item) /*112*/ { /*112*/ InitDataBuffer( buffer, DATALINESPAN, dfp ); /*112*/ dfp = NULL; /*112*/ n = sprintf( buffer + STGCOL+1, "[%02u] ", item-1 ); /*521*/ /*112*/ *(buffer + STGCOL+1 + n) = ' '; /*112*/ /*112*/ if ( n <= TAB1 ) n = TAB1; /*112*/ else n = TAB2; /*112*/ /*112*/ /*112*/ cp = buffer + STGCOL + 1 + n; /*112*/ addr = baseaddr+atomsize*(item-1); /*112*/ FormatDataItem( cp , addr, mid, atomtype, sfx); /*112*/ buffer[ DATALINESPAN-1 ] = 0; /*112*/ putrc( row + rr, 0, buffer ); /*112*/ } /*112*/ if( rr < rows ) /*112*/ ClrScr( row + rr, row + rows - 1, vaStgExp ); /*112*/ return( TRUE ); /*112*/ } /* end ShowArray(). /*112*/