/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"><< 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 -x ozc-server.oz -o ozc-server.exe</CODE></BLOCKQUOTE><P> and can be started with the command line: </P><BLOCKQUOTE class="code"><CODE>ozc-server.exe --ticketfile </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> <BR><SPAN class="keyword">import</SPAN> <BR> Compiler Application<BR> Server <SPAN class="keyword">at</SPAN> <SPAN class="string">'server.ozf'</SPAN> <BR><SPAN class="keyword">define</SPAN> <BR> <SPAN class="keyword">class</SPAN> <SPAN class="type">OZC</SPAN> <BR> <SPAN class="keyword">prop</SPAN> locking<BR> <SPAN class="keyword">feat</SPAN> engine interface<BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">init</SPAN> <BR> <SPAN class="keyword">self.</SPAN>engine = {New Compiler<SPAN class="keyword">.</SPAN>engine init}<BR> <SPAN class="keyword">self.</SPAN>interface = {New Compiler<SPAN class="keyword">.</SPAN>interface init(<SPAN class="keyword">self.</SPAN>engine)}<BR> {<SPAN class="keyword">self.</SPAN>engine enqueue(setSwitch(expression <SPAN class="keyword">true</SPAN>))}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">compile</SPAN>(VS $)<BR> <SPAN class="keyword">lock</SPAN> F <SPAN class="keyword">in</SPAN> <BR> {<SPAN class="keyword">self.</SPAN>engine<BR> enqueue(feedVirtualString(VS return(result:F)))}<BR> {Wait {<SPAN class="keyword">self.</SPAN>engine enqueue(ping($))}}<BR> <SPAN class="keyword">if</SPAN> {<SPAN class="keyword">self.</SPAN>interface hasErrors($)} <SPAN class="keyword">then</SPAN> <BR> no({<SPAN class="keyword">self.</SPAN>interface getMessages})<BR> <SPAN class="keyword">else</SPAN> yes(F) <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> Service = {New OZC init}<BR> Args = {Application<SPAN class="keyword">.</SPAN>getCmdArgs<BR> record(<BR> ticketfile(single char:<SPAN class="string">&t</SPAN> type:string optional:<SPAN class="keyword">false</SPAN>))}<BR> {Server<SPAN class="keyword">.</SPAN>start Service Args<SPAN class="keyword">.</SPAN>ticketfile}<BR><SPAN class="keyword">end</SPAN> <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 -x ozc-client.oz -o ozc-client.exe</CODE></BLOCKQUOTE><P> and can be invoked with: </P><BLOCKQUOTE class="code"><CODE>ozc-client.exe --url=</CODE><I>URL</I><CODE> --in=</CODE><I>InFile</I><CODE> --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. 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> <BR><SPAN class="keyword">import</SPAN> Application Open Pickle Connection<BR><SPAN class="keyword">define</SPAN> <BR> Args = {Application<SPAN class="keyword">.</SPAN>getCmdArgs<BR> record(<BR> url( single type:string optional:<SPAN class="keyword">false</SPAN>)<BR> <SPAN class="string">'in'</SPAN>(single type:string optional:<SPAN class="keyword">false</SPAN>)<BR> out( single type:string optional:<SPAN class="keyword">false</SPAN>))}<BR> File = {New Open<SPAN class="keyword">.</SPAN>file init(name:Args<SPAN class="keyword">.</SPAN><SPAN class="string">'in'</SPAN>)}<BR> Text = {File read(list:$ size:all)}<BR> {File close}<BR> OZC = {Connection<SPAN class="keyword">.</SPAN>take {Pickle<SPAN class="keyword">.</SPAN>load Args<SPAN class="keyword">.</SPAN>url}}<BR> <SPAN class="keyword">case</SPAN> {OZC compile({ByteString<SPAN class="keyword">.</SPAN>make Text} $)}<BR> <SPAN class="keyword">of</SPAN> yes(F) <SPAN class="keyword">then</SPAN> <BR> {Pickle<SPAN class="keyword">.</SPAN>save F Args<SPAN class="keyword">.</SPAN>out}<BR> {Application<SPAN class="keyword">.</SPAN>exit 0}<BR> <SPAN class="keyword">elseof</SPAN> no(Msgs) <SPAN class="keyword">then</SPAN> <SPAN class="keyword">raise</SPAN> ozc(Msgs) <SPAN class="keyword">end</SPAN> <SPAN class="keyword">end</SPAN> <BR><SPAN class="keyword">end</SPAN> <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"><< 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 Duchier</A>, <A href="http://www.ps.uni-sb.de/~kornstae/">Leif Kornstaedt</A> and <A href="http://www.ps.uni-sb.de/~schulte/">Christian Schulte</A><BR><SPAN class="version">Version 1.4.0 (20110908185330)</SPAN></ADDRESS></BODY></HTML>
|