static void prepareStringTable( owl_file_handle file ) { //****************************************************** unsigned size; // we need to emit the string table to a buffer so that we can get offsets via OWLStringOffset // this will be freed in emitStringTable below size = OWLStringTableSize( file->string_table ); file->x.coff.string_table = _ClientAlloc( file, sizeof( coff_string_table ) + size - 1 ); file->x.coff.string_table->size = size + 4; OWLStringEmit( file->string_table, file->x.coff.string_table->buffer ); }
void main( int argc, char *argv[] ) { char buffer[ BUFFER_SIZE ]; owl_handle owl; owl_file_handle file; owl_string_table *table; owl_client_funcs funcs = { NULL, NULL, NULL, malloc, free }; char *t_buff; owl = OWLInit( &funcs, OWL_CPU_PPC ); file = OWLFileInit( owl, "test", NULL, OWL_FORMAT_ELF, OWL_FILE_OBJECT ); table = OWLStringInit( file ); while( fgets( buffer, BUFFER_SIZE, stdin ) != NULL ) { addStrings( table, buffer ); OWLStringDump( table ); } t_buff = malloc( OWLStringTableSize( table ) + 1 ); OWLStringEmit( table, t_buff ); write( STDOUT_FILENO, t_buff, OWLStringTableSize( table ) ); free( t_buff ); OWLStringFini( table ); OWLFileFini( file ); OWLFini( owl ); }