BSP Trees/Splitting a polygon

This isnt directly related to OpenGL but…
Anyone know where I can get source code for a BSP tree generator?
or…
Can anyone tell me how to split a quad with a plane while preserving texture coords?

Thanks! BwB