I want to cover primitives like a cube as well as more complex meshes with one or more textures (skins) from external bitmap files (e.g. 128x128 pixel / 32 Bit color / tga format) by code NOT with an editor. Any ideas?

I tried different things like this but w/o success:

ent = ent_create(CUBE_MDL, vector(-100, 0, 0), NULL); //create primitive
ent_clone(ent); //clone primitive
set(ent, SHADOW | CAST); //enable shadow if lighted by spots
BMAP* skin = bmap_create("Brick_08.tga");
ent_setskin(ent, skin, 1);