extern int ResWriteString( char *string, uint_8 use_unicode, int handle ) /***********************************************************************/ { size_t stringlen; int ret; /* if string is NULL output the null string */ if (string == NULL) { string = ""; } /* the +1 is so we will output the '\0' as well */ stringlen = strlen( string ) + 1; ret = ResWriteStringLen( string, use_unicode, handle, stringlen ); return( ret ); }
bool ResWriteString( const char *string, bool use_unicode, WResFileID handle ) /****************************************************************************/ { size_t stringlen; bool ret; /* if string is NULL output the null string */ if( string == NULL ) { string = ""; } /* the +1 is so we will output the '\0' as well */ stringlen = strlen( string ) + 1; ret = ResWriteStringLen( string, use_unicode, handle, stringlen ); return( ret ); }
void SemWriteRawDataItem( RawDataItem item ) /******************************************/ { uint_16 num16; uint_32 num32; bool error; if( item.IsString ) { int len = item.StrLen; if( item.WriteNull ) { ++len; } if( ResWriteStringLen( item.Item.String, item.LongItem, CurrResFile.handle, len ) ) { RcError( ERR_WRITTING_RES_FILE, CurrResFile.filename, LastWresErrStr() ); ErrorHasOccured = true; } if( item.TmpStr ) { RCFREE( item.Item.String ); } } else { if( !item.LongItem ) { if( (int_32)item.Item.Num < 0 ) { if( (int_32)item.Item.Num < SHRT_MIN ) { RcWarning( ERR_RAW_DATA_TOO_SMALL, item.Item.Num, SHRT_MIN ); } } else { if( item.Item.Num > USHRT_MAX ) { RcWarning( ERR_RAW_DATA_TOO_BIG, item.Item.Num, USHRT_MAX ); } } } if( !ErrorHasOccured ) { if( !item.LongItem ) { num16 = item.Item.Num; error = ResWriteUint16( &(num16), CurrResFile.handle ); } else { num32 = item.Item.Num; error = ResWriteUint32( &(num32), CurrResFile.handle ); } if( error ) { RcError( ERR_WRITTING_RES_FILE, CurrResFile.filename, LastWresErrStr() ); ErrorHasOccured = true; } } } }
extern int ResOS2WriteStringTableBlock( StringTableBlock *currblock, int handle, uint_32 codepage ) /********************************************************************/ { int stringid; int error; WResIDName *name; uint_16 tmp16; uint_8 tmp8; uint_8 tmpzero = 0; // Write string table codepage tmp16 = codepage; error = ResWriteUint16( &tmp16, handle ); if( error ) return( error ); tmp16 = 1; for( stringid = 0, error = FALSE; stringid < STRTABLE_STRS_PER_BLOCK && !error; stringid++ ) { name = currblock->String[ stringid ]; if( name == NULL ) { // Write an empty string error = ResWriteUint16( &tmp16, handle ); } else { // The string can't be longer than 255 chars tmp8 = (name->NumChars + 1) & 0xFF; error = ResWriteUint8( &tmp8, handle ); if( !error ) error = ResWriteStringLen( name->Name, FALSE, handle, tmp8 - 1 ); // The terminating NULL is not stored in the table, need to add it now if( !error ) error = ResWriteUint8( &tmpzero, handle ); } } return( error ); } /* ResOS2WriteStringTableBlock */
static bool ResOS2WriteStringTableBlock( StringTableBlock *currblock, WResFileID fid, uint_32 codepage ) /******************************************************************************************************/ { int stringid; bool error; WResIDName *name; // Write string table codepage error = ResWriteUint16( codepage, fid ); if( error ) return( error ); error = false; for( stringid = 0; stringid < STRTABLE_STRS_PER_BLOCK && !error; stringid++ ) { name = currblock->String[stringid]; if( name == NULL ) { // Write an empty string error = ResWriteUint16( 1, fid ); } else { size_t len; // The string can't be longer than 255 chars len = name->NumChars + 1; if( len > 255 ) len = 255; error = ResWriteUint8( len, fid ); if( !error ) error = ResWriteStringLen( name->Name, false, fid, len - 1 ); // The terminating NULL is not stored in the table, need to add it now if( !error ) { error = ResWriteUint8( 0, fid ); } } } return( error ); } /* ResOS2WriteStringTableBlock */