bool ResReadMenuItem32( MenuItem *curritem, WResFileID handle ) /************************************************************/ { bool error; uint_16 tmp16; error = ResReadUint16( &tmp16, handle ); curritem->Item.Popup.ItemFlags = tmp16; if( !error ) { if( curritem->Item.Popup.ItemFlags & MENU_POPUP ) { curritem->IsPopup = true; curritem->Item.Popup.ItemText = ResRead32String( handle, NULL ); error = (curritem->Item.Popup.ItemText == NULL); } else { curritem->IsPopup = false; error = ResReadUint16( &tmp16, handle ); curritem->Item.Normal.ItemID = tmp16; if( !error ) { curritem->Item.Normal.ItemText = ResRead32String( handle, NULL ); error = (curritem->Item.Normal.ItemText == NULL); } } } return( error ); }
bool ResReadMenuExItem( MenuExItem *curritem, WResFileID handle ) /***************************************************************/ { bool error; uint_32 type, state, id, helpId; uint_16 resInfo; state = 0; id = 0; resInfo = 0; // Store first structure members in temporary variables until // we know whether or not the item is a MenuExItemNormal or a // MenuExItemPopup error = ResReadUint32( &type, handle ); if( !error ) { error = ResReadUint32( &state, handle ); } if( !error ) { error = ResReadUint32( &id, handle ); } if( !error ) { error = ResReadUint16( &resInfo, handle ); } // Determine if this is a normal menu item or a popup menu item if( resInfo & MENUEX_POPUP ) { curritem->IsPopup = true; curritem->Item.ExPopup.Popup.ItemFlags = resInfo; curritem->Item.ExPopup.ExData.ItemId = id; curritem->Item.ExPopup.ExData.ItemType = type; curritem->Item.ExPopup.ExData.ItemState = state; curritem->Item.ExPopup.Popup.ItemText = ResRead32String( handle, NULL ); // Careful! The string is DWORD aligned. ResPadDWord( handle ); error = ResReadUint32( &helpId, handle ); curritem->Item.ExPopup.ExData.HelpId = helpId; } else { curritem->IsPopup = false; curritem->Item.ExNormal.Normal.ItemFlags = resInfo; curritem->Item.ExNormal.Normal.ItemID = id; curritem->Item.ExNormal.Normal.ItemText = ResRead32String( handle, NULL ); // Careful! The string is DWORD aligned. ResPadDWord( handle ); curritem->Item.ExNormal.ExData.ItemType = type; curritem->Item.ExNormal.ExData.ItemState = state; } return( error ); }
ResNameOrOrdinal *ResRead32NameOrOrdinal( WResFileID handle ) /***********************************************************/ { uint_16 flags; uint_16 ord; ResNameOrOrdinal * newptr; int error; int stringlen; char * restofstr; restofstr = NULL; ord = 0; stringlen = 0; error = ResReadUint16( &flags, handle ); /* read the rest of the Name or Ordinal */ if( !error ) { if( flags == 0xffff ) { error = ResReadUint16( &ord, handle ); } else { if( flags != 0x0000 ) { restofstr = ResRead32String( handle, &stringlen ); stringlen += 1; /* for the '\0' */ error = (restofstr == NULL); } } } /* allocate space for the new Name or Ordinal */ if( error ) { newptr = NULL; } else { newptr = WRESALLOC( sizeof(ResNameOrOrdinal) + stringlen ); error = (newptr == NULL); if( error ) WRES_ERROR( WRS_MALLOC_FAILED ); } /* copy the new new Name or Ordinal into the correct place */ if( !error ) { if( flags == 0xffff ) { newptr->ord.fFlag = 0xff; newptr->ord.wOrdinalID = ord; } else { newptr->name[0] = (char)(flags & 0x00ff); if( flags != 0x0000 ) { memcpy( &(newptr->name[1]), restofstr, stringlen ); WRESFREE( restofstr ); } } } return( newptr ); }