Example #1
0
bool ResWriteStringLen( const char *string, bool use_unicode, WResFileID handle, uint_16 len )
/********************************************************************************************/
{
    char            *buf = NULL;
    bool            ret;

    if( use_unicode ) {
        if( len * 2 > CONV_BUF_SIZE ) {
            buf = WRESALLOC( 2 * len );
        } else {
            buf = ConvBuffer;
        }
        len = (ConvToUnicode)( len, string, buf );
        string = buf;
    }
    if( WRESWRITE( handle, string, len ) != len ) {
        WRES_ERROR( WRS_WRITE_FAILED );
        ret = true;
    } else {
        ret = false;
    }
    if( use_unicode ) {
        if( buf != ConvBuffer ) {
            WRESFREE( buf );
        }
    }
    return( ret );
}
Example #2
0
extern int ResWriteStringLen( char *string, uint_8 use_unicode, int handle, uint_16 len )
/***************************************************************************************/
{
    wio_ssize_t     numwrote;
    char            *buf;
    int             ret;

    if( use_unicode ) {
        if( len * 2 > CONV_BUF_SIZE ) {
            buf = WRESALLOC( 2 * len );
        } else {
            buf = ConvBuffer;
        }
        len = (ConvToUnicode)( len, string, buf );
    } else {
        buf = string;
    }
    numwrote = WRESWRITE( handle, buf, len );
    if( numwrote != len ) {
        WRES_ERROR( WRS_WRITE_FAILED );
        ret = TRUE;
    } else {
        ret = FALSE;
    }
    if( buf != ConvBuffer && buf != string ) {
        WRESFREE( buf );
    }
    return( ret );
}
Example #3
0
bool ResWrite( void *buffer, int len, WResFileID handle )
/*******************************************************/
{
    if( WRESWRITE( handle, buffer, len ) != len ) {
        WRES_ERROR( WRS_WRITE_FAILED );
        return( true );
    }
    return( false );
}
Example #4
0
bool ResWriteAccelEntry32( AccelTableEntry32 *currentry, WResFileID handle )
/**************************************************************************/
{
    if( WRESWRITE( handle, currentry, sizeof( AccelTableEntry32 ) ) != sizeof( AccelTableEntry32 ) ) {
        WRES_ERROR( WRS_WRITE_FAILED );
        return( true );
    }
    return( false );
}
Example #5
0
/*
 * WResWriteLangRecord - write out a language record at the current file
 *                       position
 */
bool WResWriteLangRecord( const WResLangInfo *info, WResFileID handle )
{
    if( WRESWRITE( handle, info, sizeof( WResLangInfo ) ) != sizeof( WResLangInfo ) ) {
        WRES_ERROR( WRS_WRITE_FAILED );
        return( true );
    } else {
        return( false );
    }
}
Example #6
0
bool ResWrite( void *buffer, WResFileSize len, WResFileID fid )
/*************************************************************/
{
    if( (WResFileSize)WRESWRITE( fid, buffer, len ) != len ) {
        WRES_ERROR( WRS_WRITE_FAILED );
        return( true );
    }
    return( false );
}
Example #7
0
bool ResWriteFontInfo( FontInfo *info, WResFileID fid )
/*****************************************************/
{
    if( WRESWRITE( fid, info, sizeof( FontInfo ) ) != sizeof( FontInfo ) ) {
        WRES_ERROR( WRS_WRITE_FAILED );
        return( true );
    } else {
        return( false );
    }
}
Example #8
0
bool ResWriteMenuHeader( MenuHeader *currhead, WResFileID handle )
/****************************************************************/
{
    if( WRESWRITE( handle, currhead, sizeof( MenuHeader ) ) != sizeof( MenuHeader ) ) {
        WRES_ERROR( WRS_WRITE_FAILED );
        return( true );
    } else {
        return( false );
    }
}
Example #9
0
bool ResWriteUint32( uint_32 newint, WResFileID handle )
/******************************************************/
{
    if( WRESWRITE( handle, &newint, sizeof( uint_32 ) ) != sizeof( uint_32 ) ) {
        WRES_ERROR( WRS_WRITE_FAILED );
        return( true );
    } else {
        return( false );
    }
}
Example #10
0
bool ResWriteFontDirEntry( FontDirEntry *entry, WResFileID fid )
/**************************************************************/
{
    if( WRESWRITE( fid, &(entry->Info), entry->StructSize ) != entry->StructSize ) {
        WRES_ERROR( WRS_WRITE_FAILED );
        return( true );
    } else {
        return( false );
    }
}
Example #11
0
bool WResWriteExtHeader( const WResExtHeader *ext_head, WResFileID handle )
/*************************************************************************/
{
    if( WRESWRITE( handle, ext_head, sizeof( WResExtHeader ) ) != sizeof( WResExtHeader ) ) {
        WRES_ERROR( WRS_WRITE_FAILED );
        return( true );
    } else {
        return( false );
    }
}
Example #12
0
int ResOS2WriteAccelEntry( AccelTableEntryOS2 * currentry, WResFileID handle )
/**********************************************************************/
{
    int     numwrote;

    numwrote = WRESWRITE( handle, currentry, sizeof(AccelTableEntryOS2) );
    if( numwrote != sizeof( AccelTableEntryOS2 ) ) {
        WRES_ERROR( WRS_WRITE_FAILED );
        return( TRUE );
    }
    return( FALSE );
}
Example #13
0
/*
 * WResWriteLangRecord - write out a language record at the current file
 *                       position
 */
int WResWriteLangRecord( const WResLangInfo *info, int handle )
{
    wio_ssize_t     numwrote;

    numwrote = WRESWRITE( handle, info, sizeof( WResLangInfo ) );
    if( numwrote != sizeof( WResLangInfo ) ) {
        WRES_ERROR( WRS_WRITE_FAILED );
        return( TRUE );
    } else {
        return( FALSE );
    }
}
Example #14
0
int WResWriteExtHeader( const WResExtHeader *ext_head, int handle )
/*****************************************************************/
{
    wio_ssize_t     numwrote;

    numwrote = WRESWRITE( handle, ext_head, sizeof(WResExtHeader) );
    if( numwrote != sizeof( WResExtHeader ) ) {
        WRES_ERROR( WRS_WRITE_FAILED );
        return( TRUE );
    } else {
        return( FALSE );
    }
}
Example #15
0
static int ResOS2WriteDlgTemplate( char *tmpldata, int size, WResFileID handle )
/******************************************************************************/
{
    int     numwrote;

    numwrote = WRESWRITE( handle, tmpldata, size );
    if( numwrote != size ) {
        WRES_ERROR( WRS_WRITE_FAILED );
        return( TRUE );
    } else {
        return( FALSE );
    }
}
Example #16
0
int ResWriteUint32( const uint_32 *newint, int handle )
/*****************************************************/
{
    wio_ssize_t     numwrite;

    numwrite = WRESWRITE( handle, newint, sizeof( uint_32 ) );
    if( numwrite != sizeof( uint_32 ) ) {
        WRES_ERROR( WRS_WRITE_FAILED );
        return( TRUE );
    } else {
        return( FALSE );
    }
}
Example #17
0
extern int ResWriteFontInfo( FontInfo *info, int handle )
/*******************************************************/
{
    wio_ssize_t     numwrote;

    numwrote = WRESWRITE( handle, info, sizeof(FontInfo) );
    if( numwrote != sizeof(FontInfo) ) {
        WRES_ERROR( WRS_WRITE_FAILED );
        return( TRUE );
    } else {
        return( FALSE );
    }
}
Example #18
0
extern int ResWriteFontDirEntry( FontDirEntry *entry, int handle )
/****************************************************************/
{
    wio_ssize_t     numwrote;

    numwrote = WRESWRITE( handle, &(entry->Info), entry->StructSize );
    if( numwrote != entry->StructSize ) {
        WRES_ERROR( WRS_WRITE_FAILED );
        return( TRUE );
    } else {
        return( FALSE );
    }
}
Example #19
0
int ResWriteToolBarItems( WResFileID handle, uint_16 *items, unsigned cnt )
/*************************************************************************/
{
    int             numwrite;
    unsigned        size;

    size = cnt * sizeof( uint_16 );
    numwrite = WRESWRITE( handle, items, size );
    if( numwrite != size ) {
        WRES_ERROR( WRS_WRITE_FAILED );
        return( TRUE );
    } else {
        return( FALSE );
    }
}
Example #20
0
int WResWriteWResIDNameUni( const WResIDName *name, uint_8 use_unicode, int handle )
/**********************************************************************************/
{
    int             error;
    wio_ssize_t     numwrote;
    uint_16         numchars;
    uint_8          tmp;
    char            *ptr;
    int             freebuf;

    freebuf = FALSE;
    error = FALSE;
    if (name == NULL) {
        /* a NULL name means write 0 length name */
        numchars = 0;
    } else {
        numchars = name->NumChars;
    }
    if( use_unicode ) {
        // for short strings use a static buffer in improve performance
        if( numchars <= CONV_BUF_SIZE / 2 ) {
            ptr = ConvBuffer;
        } else {
            freebuf = TRUE;
            ptr = WRESALLOC( 2 * numchars );
        }
        numchars = (ConvToUnicode)( numchars, name->Name, ptr ) / 2;
        error = ResWriteUint16( &numchars, handle );
        numchars *= 2;
    } else {
        numchars &= 0xFF;       /* in 16-bit the string can be no more than
                                   256 characters*/
        tmp = numchars;
        ptr = (char *)name->Name;
        error = ResWriteUint8( &tmp, handle );
    }
    if( !error && numchars > 0 ) {
        numwrote = WRESWRITE( handle, ptr, numchars );
        if( numwrote != numchars ) {
            error = TRUE;
            WRES_ERROR( WRS_WRITE_FAILED );
        }
    }
    if( freebuf ) {
        WRESFREE( ptr );
    }
    return( error );
} /* WResWriteWResIDNameUni */
Example #21
0
/*
 * WResWriteTypeRecord - write the type record to the current postion
 *                       in the file identified by fp
 */
bool WResWriteTypeRecord( const WResTypeInfo *type, WResFileID handle )
{
    int             size;

    if( type->TypeName.IsName ) {
        /* -1 because one of the chars in the name is declared in the struct */
        size = sizeof( WResTypeInfo ) + type->TypeName.ID.Name.NumChars - 1;
    } else {
        size = sizeof( WResTypeInfo );
    }
    if( WRESWRITE( handle, type, size ) != size ) {
        WRES_ERROR( WRS_WRITE_FAILED );
        return( true );
    } else {
        return( false );
    }
} /* WResWriteTypeRecord */
Example #22
0
/*
 * WResWriteResRecord - write the resource record to the current position
 *                      in the file identified by  fp
 */
bool WResWriteResRecord( const WResResInfo *res, WResFileID handle )
{
    int             size;

    if( res->ResName.IsName ) {
        /* -1 because one of the chars in the name is declared in the struct */
        size = sizeof( WResResInfo ) + res->ResName.ID.Name.NumChars - 1;
    } else {
        size = sizeof( WResResInfo );
    }
    if( WRESWRITE( handle, (uint_8 *)res, size ) != size ) {
        WRES_ERROR( WRS_WRITE_FAILED );
        return( true );
    } else {
        return( false );
    }
} /* WResWriteResRecord */
Example #23
0
bool WResWriteWResIDNameUni( const WResIDName *name, bool use_unicode, WResFileID handle )
/******************************************************************************************/
{
    bool            error;
    uint_16         numchars;
    char            *ptr;
    bool            freebuf;

    freebuf = false;
    error = false;
    if( name == NULL ) {
        /* a NULL name means write 0 length name */
        numchars = 0;
    } else {
        numchars = name->NumChars;
    }
    if( use_unicode ) {
        // for short strings use a static buffer in improve performance
        if( numchars <= CONV_BUF_SIZE / 2 ) {
            ptr = ConvBuffer;
        } else {
            freebuf = true;
            ptr = WRESALLOC( 2 * numchars );
        }
        numchars = (ConvToUnicode)( numchars, name->Name, ptr ) / 2;
        error = ResWriteUint16( numchars, handle );
        numchars *= 2;
    } else {
        /* in 16-bit resources the string can be no more than 255 characters */
        if( numchars > 0xFF )
            numchars = 0xFF;
        ptr = (char *)name->Name;
        error = ResWriteUint8( numchars, handle );
    }
    if( !error && numchars > 0 ) {
        if( WRESWRITE( handle, ptr, numchars ) != numchars ) {
            error = true;
            WRES_ERROR( WRS_WRITE_FAILED );
        }
    }
    if( freebuf ) {
        WRESFREE( ptr );
    }
    return( error );
} /* WResWriteWResIDNameUni */
Example #24
0
bool WResWriteHeaderRecord( const WResHeader *header, WResFileID handle )
/**********************************************************************/
{
    bool            error;

    error = ( WRESSEEK( handle, 0L, SEEK_SET ) == -1 );
    if( error ) {
        WRES_ERROR( WRS_SEEK_FAILED );
    }

    if( !error ) {
        if( WRESWRITE( handle, header, sizeof( WResHeader ) ) != sizeof( WResHeader ) ) {
            error = true;
            WRES_ERROR( WRS_WRITE_FAILED );
        }
    }

    return( error );
} /* WResWriteHeaderRecord */
Example #25
0
/*
 * WResWriteResRecord - write the resource record to the current position
 *                      in the file identified by  fp
 */
int WResWriteResRecord( const WResResInfo *res, int handle )
{
    wio_ssize_t     numwrote;
    int             size;

    if (res->ResName.IsName) {
        /* -1 because one of the chars in the name is declared in the struct */
        size = sizeof(WResResInfo) + res->ResName.ID.Name.NumChars - 1;
    } else {
        size = sizeof(WResResInfo);
    }

    numwrote = WRESWRITE( handle, (uint_8 *)res, size );
    if( numwrote != size ) {
        WRES_ERROR( WRS_WRITE_FAILED );
        return( TRUE );
    } else {
        return( FALSE );
    }
} /* WResWriteResRecord */
Example #26
0
bool ResWriteMenuExHeader( MenuHeader *currhead, WResFileID handle, uint_8 *headerdata )
/**************************************************************************************/
{
    bool            error;
    int             i;

    if( WRESWRITE( handle, currhead, sizeof( MenuHeader ) ) != sizeof( MenuHeader ) ) {
        WRES_ERROR( WRS_WRITE_FAILED );
        return( true );
    } else {
        if( headerdata != NULL ) {
            for( i = 0; i < currhead->HeaderSize; i++ ) {
                error = ResWriteUint8( headerdata + i, handle );
                if( error ) {
                    WRES_ERROR( WRS_WRITE_FAILED );
                    return( true );
                }
            }
        }
        return( false );
    }
}
Example #27
0
bool ResWritePadDWord( WResFileID handle )
/****************************************/
{
    WResFileOffset  curr_pos;
    WResFileSize    padding;
    bool            error;
    uint_32         zero = 0;

    error = false;
    curr_pos = WRESTELL( handle );
    if( curr_pos == -1 ) {
        WRES_ERROR( WRS_TELL_FAILED );
        return( true );
    }
    padding = RES_PADDING( curr_pos, sizeof( uint_32 ) );
    if( padding != 0 ) {
        if( (WResFileSize)WRESWRITE( handle, &zero, padding ) != padding ) {
            WRES_ERROR( WRS_WRITE_FAILED );
            return( true );
        }
    }
    return( false );
}
Example #28
0
int WResWriteHeaderRecord( const WResHeader *header, int handle )
/***************************************************************/
{
    wio_off_t       seekpos;
    int             error;
    wio_ssize_t     numwrite;

    seekpos = WRESSEEK( handle, 0L, SEEK_SET );
    error = (seekpos == -1L);
    if( error ) {
        WRES_ERROR( WRS_SEEK_FAILED );
    }

    if (!error) {
        numwrite = WRESWRITE( handle, header, sizeof(WResHeader) );
        if( numwrite != sizeof( WResHeader ) ) {
            error = TRUE;
            WRES_ERROR( WRS_WRITE_FAILED );
        }
    }

    return( error );
} /* WResWriteHeaderRecord */