示例#1
0
bool ResReadMenuItem( 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 = ResReadString( 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 = ResReadString( handle, NULL );
                error = (curritem->Item.Normal.ItemText == NULL);
            }
        }
    }

    return( error );
}
示例#2
0
static void * readString( WResFileID handle, long offset, ReadStrErrInfo *err )
/*****************************************************************************/
{
    char    *retstr;


    if( RCSEEK( handle, offset, SEEK_SET ) == -1 ) {
        err->status = RS_READ_ERROR;
        err->err_code = errno;
        return( NULL );
    } else {
        retstr = ResReadString( handle, NULL );
        if( retstr == NULL ) {
            if( LastWresStatus() == WRS_READ_INCOMPLETE ) {
                err->status = RS_READ_INCMPLT;
            } else {
                err->status = RS_READ_ERROR;
                err->err_code = LastWresErr();
            }
            return( NULL );
        } else {
            return( retstr );
        }
    }
}
示例#3
0
ResNameOrOrdinal *ResReadNameOrOrdinal( WResFileID handle )
/*********************************************************/
{
    ResNameOrOrdinal    newname;
    ResNameOrOrdinal *  newptr;
    int                 error;
    int                 stringlen;
    char *              restofstr;
    uint_8              tmp8;
    uint_16             tmp16;

    restofstr = NULL;
    error = ResReadUint8( &tmp8, handle );
    newname.ord.fFlag = tmp8;
    newname.ord.wOrdinalID = 0;
    stringlen = 0;

    /* read the rest of the Name or Ordinal */
    if (!error) {
        if (newname.ord.fFlag == 0xff) {
            error = ResReadUint16( &tmp16, handle );
            newname.ord.wOrdinalID = tmp16;
        } else {
            if (newname.name[0] != '\0') {
                restofstr = ResReadString( 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) {
        newptr->ord.fFlag = newname.ord.fFlag;
        if (newname.ord.fFlag == 0xff) {
            newptr->ord.wOrdinalID = newname.ord.wOrdinalID;
        } else {
            if (newptr->name[0] != '\0') {
                memcpy( &(newptr->name[1]), restofstr, stringlen );
                WRESFREE( restofstr );
            }
        }
    }

    return( newptr );
}