Hey,<br>I would like to ask the list here about the feasibility of the following hack. I'm currently trying to help on an open source solution to compile Latex-files, which includes storing and compiling on a server. It would be a lot nicer to not have to check everything and store as files before using latex & co on them. Just figuring out what kinds of files need to be checked out creates considerable headaches, and so I wondered if it would be something hack on kpathsea could alleviate.<br>
<div class="gmail_quote"><br>
<br>As I understand it, the way it works is that it gets handed a string such as the following:<br>
<br>
".:/usr/local/texmf/:/home/www/<a href="http://marx.su/www_docs/lab/inc" target="_blank">marx.su/www_docs/lab/inc</a>"<br>
<br>
and a file-name like:<br>
<br>
"include-me.tex"<br>
<br>
it then splits these up at the colon-signs, and tests if the file<br>
exists starting form the first directory to the next, etc. Once it<br>
hits one, under normal circumstances it returns just that one filename<br>
with path, like "/usr/local/texmf/include-me.tex", however, one can also set it to find all instances.<br>
<br>
( <a href="http://www.tug.org/svn/texlive/trunk/Build/source/texk/kpathsea/pathsearch.c?view=markup" target="_blank">http://www.tug.org/svn/texlive/trunk/Build/source/texk/kpathsea/pathsearch.c?view=markup</a><br>
)<br>
<br>
I thought now to modify this in two steps:<br>
<br>
First, add an option to retrieve from database, using a string like:<br>
<br>
".:/usr/local/texmf:[[database=mysql,dbserver='localhost',dbusername='USERNAME',dbpassword='PASSWORD',query='SELECT<br>
content FROM tex-files WHERE name='.$filename.';',outdir='/tmp/5grTj3/']]:/home/www/<a href="http://marx.su/www_docs/lab/inc" target="_blank">marx.su/www_docs/lab/inc</a>"<br>
<br>
In the loop that goes through the directories, it will then call a<br>
function "check_mysql" when it encounters a "[[" coupled with a<br>
"database=mysql". That function connects to the database and then<br>
calls the query. If it finds something, it checks out the first result<br>
and creates a file in the directory specified<br>
as 'outdir' into which it fills the contents gained from the database.<br>
It then returns the path to that file (fx: "/tmp/5grTj3/include-me.tex").<br>
<br>
That way we should save the database and more so the filesystem some<br>
load because it only checks out the files that actually are required<br>
for the compilation of the current document. Also, this should work<br>
seamlessly with all current applications.<br><br>In addition, when packaging, this directory should now contain all latex-files except those that were encountered in the file-system (likely standard system latex files) and so they can be packages togetehr with the currently accessed file into a nice *.tar.gz or included into a compiled pdf-file with a name such as *.latex.pdf .<br>
<br>
The second change would be to add an option "get_contents". If that is<br>
specified, then kpathsea will return the contents of the file that is<br>
being looked for, rather than just the filename. It should be easy to<br>
add this part to the filesystem-based file-lookup, and of course it<br>
would simplify the mysql-based part. Common applications (latex,<br>
bibtex) would likely only need to be modified slightly to take<br>
advantage of this change as well.<br>
<br>
But one thing that I was thinking about is the database-connection.<br>
The compilation of a single document might be opening and closing<br>
connections to the database for 40-200 times (completely unscientific<br>
estimate). But I just couldn't figure out how to make a persistent<br>
connection, as it would need to be closed, and we never know when the<br>
last mysql-query is being called, if I get the structure of kpathsea right.<br>
<br>
Do you have any thoughts/considerations in connection with this? Do similar projects exist already? <br>
<br><br>I have only started to look at your code, but maybe you can tell me whether I'm looking in vain and should rather start somewhere else…<br></div>-- <br>Johannes Wilm<br><a href="http://www.johanneswilm.org">http://www.johanneswilm.org</a><br>
tel: +5059173717<br>