Hey,<br>I would like to ask the list here about the feasibility of the following hack. I&#39;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 &amp; 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&nbsp; 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>
&quot;.:/usr/local/texmf/:/home/www/<a href="http://marx.su/www_docs/lab/inc" target="_blank">marx.su/www_docs/lab/inc</a>&quot;<br>
<br>
and a file-name like:<br>
<br>
&quot;include-me.tex&quot;<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 &quot;/usr/local/texmf/include-me.tex&quot;, 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>
&quot;.:/usr/local/texmf:[[database=mysql,dbserver=&#39;localhost&#39;,dbusername=&#39;USERNAME&#39;,dbpassword=&#39;PASSWORD&#39;,query=&#39;SELECT<br>
content FROM tex-files WHERE name=&#39;.$filename.&#39;;&#39;,outdir=&#39;/tmp/5grTj3/&#39;]]:/home/www/<a href="http://marx.su/www_docs/lab/inc" target="_blank">marx.su/www_docs/lab/inc</a>&quot;<br>
<br>
In the loop that goes through the directories, it will then call a<br>
function &quot;check_mysql&quot; when it encounters a &quot;[[&quot; coupled with a<br>
&quot;database=mysql&quot;. 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 &#39;outdir&#39; into which it fills the contents gained from the database.<br>
It then returns the path to that file (fx: &quot;/tmp/5grTj3/include-me.tex&quot;).<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 &quot;get_contents&quot;. 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&#39;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&#39;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>