I recommend that you take a look at the Camelot.NET connector, which allows you to query SharePoint 2007/2010 using standard SQL queries. Its driver is ADO.NET, which can also be opened through a simple WCF service and is accessible through any programming language. Suppose you would like to choose from the "general documents", you should write something like:
select * from `shared documents`
or with specific columns:
select id, title, filetype, filesize, created, createdby from `shared documents`
or with the where statement:
select id, title, filetype, filesize, created, createdby from `shared documents` where filetype = '.gif'
source share