static Bool WWriteStringEntry( WStringBlock *block, uint_16 string_id, FILE *fp ) { char *strtext; char *text; Bool ok; strtext = NULL; text = WResIDNameToStr( block->block.String[string_id & 0xf] ); ok = (text != NULL); if( ok ) { strtext = WConvertStringFrom( text, "\t\n\"\\", "tn\"\\" ); ok = (strtext != NULL); } if( ok ) { if( block->symbol[string_id & 0xf] ) { fprintf( fp, " %s, \"%s\"\n", block->symbol[string_id & 0xf], strtext ); } else { fprintf( fp, " %u, \"%s\"\n", string_id, strtext ); } } if( strtext != NULL ) { WMemFree( strtext ); } if( text != NULL ) { WMemFree( text ); } return( ok ); }
Bool WAddEditWinLBoxEntry( WStringEditInfo *einfo, WStringBlock *block, uint_16 string_id, int pos ) { Bool ok; char *n; char *lbtext; char *text; char idtext[35]; int tlen, idlen; HWND lbox; text = NULL; lbtext = NULL; n = NULL; ok = (einfo != NULL && einfo->edit_dlg != NULL && block != NULL); if( ok ) { lbox = GetDlgItem( einfo->edit_dlg, IDM_STREDLIST ); ok = (lbox != NULL); } if( ok ) { text = WResIDNameToStr( block->block.String[string_id & 0xf] ); ok = (text != NULL); } if( ok ) { if( block->symbol[string_id & 0xf] != NULL ) { strncpy( idtext, block->symbol[string_id & 0xf], MAX_ID_CHARS ); idtext[MAX_ID_CHARS] = '\0'; } else { utoa( (int)string_id, idtext, 10 ); } idlen = strlen( idtext ); idtext[idlen] = '\t'; ++idlen; idtext[idlen] = '\0'; tlen = strlen( text ); lbtext = (char *)WMemAlloc( tlen + idlen + 4 ); ok = (lbtext != NULL); } if( ok ) { memcpy( lbtext, idtext, idlen ); lbtext[idlen] = ' '; lbtext[idlen + 1] = '\"'; memcpy( lbtext + idlen + 2, text, tlen ); lbtext[tlen + idlen + 2] = '\"'; lbtext[tlen + idlen + 3] = '\0'; n = WConvertStringFrom( lbtext, "\n", "n" ); ok = WInsertLBoxWithStr( lbox, pos, n, (void *)string_id ); } if( n != NULL ) { WMemFree( n ); } if( text != NULL ) { WMemFree( text ); } if( lbtext != NULL ) { WMemFree( lbtext ); } return( ok ); }