This file is indexed.

/usr/share/mozart/doc/apptut/node14.html is in mozart-doc 1.4.0-8ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

1
2
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>11 Compile Server Application</TITLE><LINK href="ozdoc.css" rel="stylesheet" type="text/css"></HEAD><BODY><TABLE align="center" border="0" cellpadding="6" cellspacing="6" class="nav"><TR bgcolor="#DDDDDD"><TD><A href="node13.html#chapter.client.server.db">&lt;&lt; Prev</A></TD><TD><A href="node11.html">- Up -</A></TD></TR></TABLE><DIV id="chapter.client.server.ozc"><H1><A name="chapter.client.server.ozc">11 Compile Server Application</A></H1><P>We now develop an application where a client can send an Oz file containing a functor expression to a compile server and gets back the corresponding compiled functor. The server provides a compilation service.</P><H2><A name="label38">11.1 Server <CODE>ozc-server.oz</CODE></A></H2><P>The compile server is compiled as follows: </P><BLOCKQUOTE class="code"><CODE>ozc&nbsp;-x&nbsp;ozc-server.oz&nbsp;-o&nbsp;ozc-server.exe</CODE></BLOCKQUOTE><P> and can be started with the command line: </P><BLOCKQUOTE class="code"><CODE>ozc-server.exe&nbsp;--ticketfile&nbsp;</CODE><I>file</I></BLOCKQUOTE><P> the server returns <CODE>yes(F)</CODE> where <CODE>F</CODE> is a functor value, or <CODE>no(Msgs)</CODE>, if compilation failed, where <CODE>Msgs</CODE> are the error messages obtained from the compiler's interface. </P><BLOCKQUOTE><PRE><SPAN class="keyword">functor</SPAN>&nbsp;<BR><SPAN class="keyword">import</SPAN>&nbsp;<BR>&nbsp;&nbsp;&nbsp;Compiler&nbsp;Application<BR>&nbsp;&nbsp;&nbsp;Server&nbsp;<SPAN class="keyword">at</SPAN>&nbsp;<SPAN class="string">'server.ozf'</SPAN>&nbsp;<BR><SPAN class="keyword">define</SPAN>&nbsp;<BR>&nbsp;&nbsp;&nbsp;<SPAN class="keyword">class</SPAN>&nbsp;<SPAN class="type">OZC</SPAN>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN class="keyword">prop</SPAN>&nbsp;locking<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN class="keyword">feat</SPAN>&nbsp;engine&nbsp;interface<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN class="keyword">meth</SPAN>&nbsp;<SPAN class="functionname">init</SPAN>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN class="keyword">self.</SPAN>engine&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;{New&nbsp;Compiler<SPAN class="keyword">.</SPAN>engine&nbsp;&nbsp;&nbsp;&nbsp;init}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN class="keyword">self.</SPAN>interface&nbsp;=&nbsp;{New&nbsp;Compiler<SPAN class="keyword">.</SPAN>interface&nbsp;init(<SPAN class="keyword">self.</SPAN>engine)}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<SPAN class="keyword">self.</SPAN>engine&nbsp;enqueue(setSwitch(expression&nbsp;<SPAN class="keyword">true</SPAN>))}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN class="keyword">end</SPAN>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN class="keyword">meth</SPAN>&nbsp;<SPAN class="functionname">compile</SPAN>(VS&nbsp;$)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN class="keyword">lock</SPAN>&nbsp;F&nbsp;<SPAN class="keyword">in</SPAN>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<SPAN class="keyword">self.</SPAN>engine<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;enqueue(feedVirtualString(VS&nbsp;return(result:F)))}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{Wait&nbsp;{<SPAN class="keyword">self.</SPAN>engine&nbsp;enqueue(ping($))}}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN class="keyword">if</SPAN>&nbsp;{<SPAN class="keyword">self.</SPAN>interface&nbsp;hasErrors($)}&nbsp;<SPAN class="keyword">then</SPAN>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;no({<SPAN class="keyword">self.</SPAN>interface&nbsp;getMessages})<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN class="keyword">else</SPAN>&nbsp;yes(F)&nbsp;<SPAN class="keyword">end</SPAN>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN class="keyword">end</SPAN>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN class="keyword">end</SPAN>&nbsp;<BR>&nbsp;&nbsp;&nbsp;<SPAN class="keyword">end</SPAN>&nbsp;<BR>&nbsp;&nbsp;&nbsp;Service&nbsp;=&nbsp;{New&nbsp;OZC&nbsp;init}<BR>&nbsp;&nbsp;&nbsp;Args&nbsp;=&nbsp;{Application<SPAN class="keyword">.</SPAN>getCmdArgs<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;record(<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ticketfile(single&nbsp;char:<SPAN class="string">&amp;t</SPAN>&nbsp;type:string&nbsp;optional:<SPAN class="keyword">false</SPAN>))}<BR>&nbsp;&nbsp;&nbsp;{Server<SPAN class="keyword">.</SPAN>start&nbsp;Service&nbsp;Args<SPAN class="keyword">.</SPAN>ticketfile}<BR><SPAN class="keyword">end</SPAN>&nbsp;<BR></PRE></BLOCKQUOTE><P></P><H2><A name="label39">11.2 Client <CODE>ozc-client.oz</CODE></A></H2><P>The client can be compiled as follows: </P><BLOCKQUOTE class="code"><CODE>ozc&nbsp;-x&nbsp;ozc-client.oz&nbsp;-o&nbsp;ozc-client.exe</CODE></BLOCKQUOTE><P> and can be invoked with: </P><BLOCKQUOTE class="code"><CODE>ozc-client.exe&nbsp;--url=</CODE><I>URL</I><CODE>&nbsp;--in=</CODE><I>InFile</I><CODE>&nbsp;--out=</CODE><I>OutFile</I></BLOCKQUOTE><P> It loads the compile server's ticket from <I>URL</I>, uses it to obtain the forwarding procedure, applies it to the textual contents of <I>InFile</I> and saves the returned functor value in <I>OutFile</I>. Note that we convert the string (i.&nbsp;e. list) representation of the file's contents to a byte string for more efficient transmission; this is not necessary, but greatly reduces the amount of data that needs to be transmitted. </P><BLOCKQUOTE><PRE><SPAN class="keyword">functor</SPAN>&nbsp;<BR><SPAN class="keyword">import</SPAN>&nbsp;Application&nbsp;Open&nbsp;Pickle&nbsp;Connection<BR><SPAN class="keyword">define</SPAN>&nbsp;<BR>&nbsp;&nbsp;&nbsp;Args&nbsp;=&nbsp;{Application<SPAN class="keyword">.</SPAN>getCmdArgs<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;record(<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;url(&nbsp;single&nbsp;type:string&nbsp;optional:<SPAN class="keyword">false</SPAN>)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN class="string">'in'</SPAN>(single&nbsp;type:string&nbsp;optional:<SPAN class="keyword">false</SPAN>)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;out(&nbsp;single&nbsp;type:string&nbsp;optional:<SPAN class="keyword">false</SPAN>))}<BR>&nbsp;&nbsp;&nbsp;File&nbsp;=&nbsp;{New&nbsp;Open<SPAN class="keyword">.</SPAN>file&nbsp;init(name:Args<SPAN class="keyword">.</SPAN><SPAN class="string">'in'</SPAN>)}<BR>&nbsp;&nbsp;&nbsp;Text&nbsp;=&nbsp;{File&nbsp;read(list:$&nbsp;size:all)}<BR>&nbsp;&nbsp;&nbsp;{File&nbsp;close}<BR>&nbsp;&nbsp;&nbsp;OZC&nbsp;&nbsp;=&nbsp;{Connection<SPAN class="keyword">.</SPAN>take&nbsp;{Pickle<SPAN class="keyword">.</SPAN>load&nbsp;Args<SPAN class="keyword">.</SPAN>url}}<BR>&nbsp;&nbsp;&nbsp;<SPAN class="keyword">case</SPAN>&nbsp;{OZC&nbsp;compile({ByteString<SPAN class="keyword">.</SPAN>make&nbsp;Text}&nbsp;$)}<BR>&nbsp;&nbsp;&nbsp;<SPAN class="keyword">of</SPAN>&nbsp;yes(F)&nbsp;<SPAN class="keyword">then</SPAN>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{Pickle<SPAN class="keyword">.</SPAN>save&nbsp;F&nbsp;Args<SPAN class="keyword">.</SPAN>out}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{Application<SPAN class="keyword">.</SPAN>exit&nbsp;0}<BR>&nbsp;&nbsp;&nbsp;<SPAN class="keyword">elseof</SPAN>&nbsp;no(Msgs)&nbsp;<SPAN class="keyword">then</SPAN>&nbsp;<SPAN class="keyword">raise</SPAN>&nbsp;ozc(Msgs)&nbsp;<SPAN class="keyword">end</SPAN>&nbsp;<SPAN class="keyword">end</SPAN>&nbsp;<BR><SPAN class="keyword">end</SPAN>&nbsp;<BR></PRE></BLOCKQUOTE><P></P></DIV><TABLE align="center" border="0" cellpadding="6" cellspacing="6" class="nav"><TR bgcolor="#DDDDDD"><TD><A href="node13.html#chapter.client.server.db">&lt;&lt; Prev</A></TD><TD><A href="node11.html">- Up -</A></TD></TR></TABLE><HR><ADDRESS><A href="http://www.ps.uni-sb.de/~duchier/">Denys&nbsp;Duchier</A>, <A href="http://www.ps.uni-sb.de/~kornstae/">Leif&nbsp;Kornstaedt</A> and&nbsp;<A href="http://www.ps.uni-sb.de/~schulte/">Christian&nbsp;Schulte</A><BR><SPAN class="version">Version 1.4.0 (20110908185330)</SPAN></ADDRESS></BODY></HTML>