lejp-conf: substitute _lws_ddir_ with install dir
authorAndy Green <andy@warmcat.com>
Wed, 6 Jul 2016 02:48:41 +0000 (10:48 +0800)
committerAndy Green <andy@warmcat.com>
Thu, 14 Jul 2016 00:57:28 +0000 (08:57 +0800)
CMakeLists.txt
README.lwsws.md
doc/html/md_README.generic-table.html [deleted file]
doc/html/md_README.lwsws.html
doc/latex/md_README.lwsws.tex
lib/lejp-conf.c
lws_config.h.in
lwsws/etc-lwsws-conf.d-localhost-EXAMPLE

index 1c5a0bb..356b409 100644 (file)
@@ -401,6 +401,8 @@ SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
 SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib")
 SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib")
 
+SET(LWS_INSTALL_PATH "${CMAKE_INSTALL_PREFIX}")
+
 # Put absolute path of dynamic libraries into the object code. Some
 # architectures, notably Mac OS X, need this.
 SET(CMAKE_INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/${LWS_INSTALL_LIB_DIR}${LIB_SUFFIX}")
index 244aeea..a8722b0 100644 (file)
@@ -20,6 +20,11 @@ Configuration
 
 lwsws uses JSON config files, they're pure JSON but # may be used to turn the rest of the line into a comment.
 
+There's also a single substitution, if a string contains "_lws_ddir_", then that is
+replaced with the LWS install data directory path, eg, "/usr/share" or whatever was
+set when LWS was built + installed.  That lets you refer to installed paths without
+having to change the config if your install path was different.
+
 There is a single file intended for global settings
 
 /etc/lwsws/conf
diff --git a/doc/html/md_README.generic-table.html b/doc/html/md_README.generic-table.html
deleted file mode 100644 (file)
index cae3cba..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
-<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
-<meta http-equiv="X-UA-Compatible" content="IE=9"/>
-<meta name="generator" content="Doxygen 1.8.11"/>
-<title>libwebsockets: Notes about generic-table</title>
-<link href="tabs.css" rel="stylesheet" type="text/css"/>
-<script type="text/javascript" src="jquery.js"></script>
-<script type="text/javascript" src="dynsections.js"></script>
-<link href="navtree.css" rel="stylesheet" type="text/css"/>
-<script type="text/javascript" src="resize.js"></script>
-<script type="text/javascript" src="navtreedata.js"></script>
-<script type="text/javascript" src="navtree.js"></script>
-<script type="text/javascript">
-  $(document).ready(initResizable);
-  $(window).load(resizeHeight);
-</script>
-<link href="doxygen.css" rel="stylesheet" type="text/css" />
-</head>
-<body>
-<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
-<div id="titlearea">
-<table cellspacing="0" cellpadding="0">
- <tbody>
- <tr style="height: 56px;">
-  <td id="projectlogo"><img alt="Logo" src="libwebsockets.org-logo.png"/></td>
-  <td id="projectalign" style="padding-left: 0.5em;">
-   <div id="projectname">libwebsockets
-   </div>
-   <div id="projectbrief">Lightweight C library for HTML5 websockets</div>
-  </td>
- </tr>
- </tbody>
-</table>
-</div>
-<!-- end header part -->
-<!-- Generated by Doxygen 1.8.11 -->
-  <div id="navrow1" class="tabs">
-    <ul class="tablist">
-      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
-      <li class="current"><a href="pages.html"><span>Related&#160;Pages</span></a></li>
-      <li><a href="modules.html"><span>Modules</span></a></li>
-      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
-      <li><a href="files.html"><span>Files</span></a></li>
-    </ul>
-  </div>
-</div><!-- top -->
-<div id="side-nav" class="ui-resizable side-nav-resizable">
-  <div id="nav-tree">
-    <div id="nav-tree-contents">
-      <div id="nav-sync" class="sync"></div>
-    </div>
-  </div>
-  <div id="splitbar" style="-moz-user-select:none;" 
-       class="ui-resizable-handle">
-  </div>
-</div>
-<script type="text/javascript">
-$(document).ready(function(){initNavTree('md_README.generic-table.html','');});
-</script>
-<div id="doc-content">
-<div class="header">
-  <div class="headertitle">
-<div class="title">Notes about generic-table </div>  </div>
-</div><!--header-->
-<div class="contents">
-<div class="textblock"><h2>What is generic-table? </h2>
-<p>Generic-table is a JSON schema and client-side JS file that makes it easy to display live, table structured HTML over a ws link.</p>
-<p>An example plugin and index.html using it are provided.</p>
-<h2>Enabling for build </h2>
-<p>Enable at CMake with -DLWS_WITH_PLUGINS=1</p>
-<h2>Generic-table JSON </h2>
-<h3>Column layout</h3>
-<p>When the ws connection is established, the protocol should send a JSON message describing the table columns. For example</p>
-<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;msg = &quot;{\&quot;cols\&quot;:[&quot;</div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;      &quot;  {\&quot;name\&quot;: \&quot;Date\&quot;},&quot;</div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;      &quot;  {\&quot;name\&quot;: \&quot;Size\&quot;, \&quot;align\&quot;: \&quot;right\&quot;},&quot;</div><div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;      &quot;  {\&quot;name\&quot;: \&quot;Icon\&quot;},&quot;</div><div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;      &quot;  {\&quot;name\&quot;: \&quot;Name\&quot;, \&quot;href\&quot;: \&quot;uri\&quot;},&quot;</div><div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;      &quot;  {\&quot;name\&quot;: \&quot;uri\&quot;, \&quot;hide\&quot;: \&quot;1\&quot; }&quot;</div><div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;      &quot; ]&quot;</div><div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;      &quot;}&quot;;</div></div><!-- fragment --><ul>
-<li>This describes 5 columns</li>
-<li>Only four columns (not "uri") should be visible</li>
-<li>"Name" should be presented as a clickable link using "uri" as the destination, when a "uri" field is presented.</li>
-<li>"Size" field should be presented aligned to the right</li>
-</ul>
-<h3>Table data</h3>
-<p>The </p>
-</div></div><!-- contents -->
-</div><!-- doc-content -->
-<!-- start footer part -->
-<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
-  <ul>
-    <li class="footer">Generated by
-    <a href="http://www.doxygen.org/index.html">
-    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.11 </li>
-  </ul>
-</div>
-</body>
-</html>
index 10ea75b..85f779c 100644 (file)
@@ -72,6 +72,7 @@ $(document).ready(function(){initNavTree('md_README.lwsws.html','');});
 <p>It enables libuv and plugin support automatically.</p>
 <h2>Configuration </h2>
 <p>lwsws uses JSON config files, they're pure JSON but # may be used to turn the rest of the line into a comment.</p>
+<p>There's also a single substitution, if a string contains "_lws_ddir_", then that is replaced with the LWS install data directory path, eg, "/usr/share" or whatever was set when LWS was built + installed. That lets you refer to installed paths without having to change the config if your install path was different.</p>
 <p>There is a single file intended for global settings</p>
 <p>/etc/lwsws/conf </p><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;# these are the server global settings</div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;# stuff related to vhosts should go in one</div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;# file per vhost in ../conf.d/</div><div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;</div><div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;{</div><div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;  &quot;global&quot;: {</div><div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;   &quot;uid&quot;: &quot;48&quot;,  # apache user</div><div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;   &quot;gid&quot;: &quot;48&quot;,  # apache user</div><div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;   &quot;count-threads&quot;: &quot;1&quot;,</div><div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;   &quot;server-string&quot;: &quot;myserver v1&quot;, # returned in http headers</div><div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;   &quot;init-ssl&quot;: &quot;yes&quot;</div><div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160; }</div><div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;}</div></div><!-- fragment --><p> and a config directory intended to take one file per vhost</p>
 <p>/etc/lwsws/conf.d/warmcat.com </p><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;{</div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;        &quot;vhosts&quot;: [{</div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;                &quot;name&quot;: &quot;warmcat.com&quot;,</div><div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;                &quot;port&quot;: &quot;443&quot;,</div><div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;                &quot;interface&quot;: &quot;eth0&quot;,  # optional</div><div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;                &quot;host-ssl-key&quot;: &quot;/etc/pki/tls/private/warmcat.com.key&quot;,  # if given enable ssl</div><div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;                &quot;host-ssl-cert&quot;: &quot;/etc/pki/tls/certs/warmcat.com.crt&quot;,</div><div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;                &quot;host-ssl-ca&quot;: &quot;/etc/pki/tls/certs/warmcat.com.cer&quot;,</div><div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;                &quot;mounts&quot;: [{  # autoserve</div><div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;                        &quot;mountpoint&quot;: &quot;/&quot;,</div><div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;                        &quot;origin&quot;: &quot;file:///var/www/warmcat.com&quot;,</div><div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;                        &quot;default&quot;: &quot;index.html&quot;</div><div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;                }]</div><div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;        }]</div><div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;}</div></div><!-- fragment --><p> To get started quickly, an example config reproducing the old test server on port 7681, non-SSL is provided. To set it up </p><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;# mkdir -p /etc/lwsws/conf.d /var/log/lwsws</div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;# cp ./lwsws/etc-lwsws-conf-EXAMPLE /etc/lwsws/conf</div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;# cp ./lwsws/etc-lwsws-conf.d-localhost-EXAMPLE /etc/lwsws/conf.d/test-server</div><div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;# sudo lwsws</div></div><!-- fragment --> <h2>Vhosts </h2>
@@ -123,11 +124,18 @@ $(document).ready(function(){initNavTree('md_README.lwsws.html','');});
 <li>cgi:// this causes any matching url to be given to the named cgi, eg <div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;{</div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160; &quot;mountpoint&quot;: &quot;/git&quot;,</div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160; &quot;origin&quot;: &quot;cgi:///var/www/cgi-bin/cgit&quot;,</div><div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160; &quot;default&quot;: &quot;/&quot;</div><div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;}, {</div><div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160; &quot;mountpoint&quot;: &quot;/cgit-data&quot;,</div><div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160; &quot;origin&quot;: &quot;file:///usr/share/cgit&quot;,</div><div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160; &quot;default&quot;: &quot;/&quot;</div><div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;},</div></div><!-- fragment --> would cause the url /git/myrepo to pass "myrepo" to the cgi /var/www/cgi-bin/cgit and send the results to the client.</li>
 </ul>
 <h2>Other mount options </h2>
-<p>1) When using a cgi:// protcol origin at a mountpoint, you may also give cgi environment variables specific to the mountpoint like this </p><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;{</div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160; &quot;mountpoint&quot;: &quot;/git&quot;,</div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160; &quot;origin&quot;: &quot;cgi:///var/www/cgi-bin/cgit&quot;,</div><div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160; &quot;default&quot;: &quot;/&quot;,</div><div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160; &quot;cgi-env&quot;: [{</div><div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;         &quot;CGIT_CONFIG&quot;: &quot;/etc/cgitrc/libwebsockets.org&quot;</div><div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160; }]</div><div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;}</div></div><!-- fragment --><p> This allows you to customize one cgi depending on the mountpoint (and / or vhost).</p>
-<p>2) It's also possible to set the cgi timeout (in secs) per cgi:// mount, like this </p><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;&quot;cgi-timeout&quot;: &quot;30&quot;</div></div><!-- fragment --><p> 3) <code>callback://</code> protocol may be used when defining a mount to associate a named protocol callback with the URL namespace area. For example </p><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;{</div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160; &quot;mountpoint&quot;: &quot;/formtest&quot;,</div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160; &quot;origin&quot;: &quot;callback://protocol-post-demo&quot;</div><div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;}</div></div><!-- fragment --><p> All handling of client access to /formtest[anything] will be passed to the callback registered to the protocol "protocol-post-demo".</p>
+<p>1) Some protocols may want "per-mount options" in name:value format. You can provide them using "pmo" </p><pre class="fragment">           {
+            "mountpoint": "/stuff",
+            "origin": "callback://myprotocol",
+            "pmo": [{
+                    "myname": "myvalue"
+            }]
+           }
+</pre><p>2) When using a cgi:// protcol origin at a mountpoint, you may also give cgi environment variables specific to the mountpoint like this </p><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;{</div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160; &quot;mountpoint&quot;: &quot;/git&quot;,</div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160; &quot;origin&quot;: &quot;cgi:///var/www/cgi-bin/cgit&quot;,</div><div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160; &quot;default&quot;: &quot;/&quot;,</div><div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160; &quot;cgi-env&quot;: [{</div><div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;         &quot;CGIT_CONFIG&quot;: &quot;/etc/cgitrc/libwebsockets.org&quot;</div><div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160; }]</div><div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;}</div></div><!-- fragment --><p> This allows you to customize one cgi depending on the mountpoint (and / or vhost).</p>
+<p>3) It's also possible to set the cgi timeout (in secs) per cgi:// mount, like this </p><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;&quot;cgi-timeout&quot;: &quot;30&quot;</div></div><!-- fragment --><p> 4) <code>callback://</code> protocol may be used when defining a mount to associate a named protocol callback with the URL namespace area. For example </p><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;{</div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160; &quot;mountpoint&quot;: &quot;/formtest&quot;,</div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160; &quot;origin&quot;: &quot;callback://protocol-post-demo&quot;</div><div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;}</div></div><!-- fragment --><p> All handling of client access to /formtest[anything] will be passed to the callback registered to the protocol "protocol-post-demo".</p>
 <p>This is useful for handling POST http body content or general non-cgi http payload generation inside a plugin.</p>
 <p>See the related notes in README.coding.md</p>
-<p>4) Cache policy of the files in the mount can also be set. If no options are given, the content is marked uncacheable. </p><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;{</div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160; &quot;mountpoint&quot;: &quot;/&quot;,</div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160; &quot;origin&quot;: &quot;file:///var/www/mysite.com&quot;,</div><div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160; &quot;cache-max-age&quot;: &quot;60&quot;,      # seconds</div><div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160; &quot;cache-reuse&quot;: &quot;1&quot;,         # allow reuse at client at all</div><div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160; &quot;cache-revalidate&quot;: &quot;1&quot;,    # check it with server each time</div><div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160; &quot;cache-intermediaries&quot;: &quot;1&quot; # allow intermediary caches to hold</div><div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;}</div></div><!-- fragment --><p>4) You can also define a list of additional mimetypes per-mount </p><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;&quot;extra-mimetypes&quot;: {</div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;         &quot;.zip&quot;: &quot;application/zip&quot;,</div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;         &quot;.doc&quot;: &quot;text/evil&quot;</div><div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160; }</div></div><!-- fragment --><h2>Plugins </h2>
+<p>5) Cache policy of the files in the mount can also be set. If no options are given, the content is marked uncacheable. </p><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;{</div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160; &quot;mountpoint&quot;: &quot;/&quot;,</div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160; &quot;origin&quot;: &quot;file:///var/www/mysite.com&quot;,</div><div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160; &quot;cache-max-age&quot;: &quot;60&quot;,      # seconds</div><div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160; &quot;cache-reuse&quot;: &quot;1&quot;,         # allow reuse at client at all</div><div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160; &quot;cache-revalidate&quot;: &quot;1&quot;,    # check it with server each time</div><div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160; &quot;cache-intermediaries&quot;: &quot;1&quot; # allow intermediary caches to hold</div><div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;}</div></div><!-- fragment --><p>6) You can also define a list of additional mimetypes per-mount </p><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;&quot;extra-mimetypes&quot;: {</div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;         &quot;.zip&quot;: &quot;application/zip&quot;,</div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;         &quot;.doc&quot;: &quot;text/evil&quot;</div><div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160; }</div></div><!-- fragment --><h2>Plugins </h2>
 <p>Protcols and extensions may also be provided from "plugins", these are lightweight dynamic libraries. They are scanned for at init time, and any protocols and extensions found are added to the list given at context creation time.</p>
 <p>Protocols receive init (LWS_CALLBACK_PROTOCOL_INIT) and destruction (LWS_CALLBACK_PROTOCOL_DESTROY) callbacks per-vhost, and there are arrangements they can make per-vhost allocations and get hold of the correct pointer from the wsi at the callback.</p>
 <p>This allows a protocol to choose to strictly segregate data on a per-vhost basis, and also allows the plugin to handle its own initialization and context storage.</p>
index c3992ff..afe0aed 100644 (file)
@@ -12,6 +12,8 @@ It enables libuv and plugin support automatically.
 
 lwsws uses J\+S\+ON config files, they\textquotesingle{}re pure J\+S\+ON but \# may be used to turn the rest of the line into a comment.
 
+There\textquotesingle{}s also a single substitution, if a string contains \char`\"{}\+\_\+lws\+\_\+ddir\+\_\+\char`\"{}, then that is replaced with the L\+WS install data directory path, eg, \char`\"{}/usr/share\char`\"{} or whatever was set when L\+WS was built + installed. That lets you refer to installed paths without having to change the config if your install path was different.
+
 There is a single file intended for global settings
 
 /etc/lwsws/conf 
@@ -240,7 +242,17 @@ Eg, with this mountpoint
 
 \subsection*{Other mount options }
 
-1) When using a cgi\+:// protcol origin at a mountpoint, you may also give cgi environment variables specific to the mountpoint like this 
+1) Some protocols may want \char`\"{}per-\/mount options\char`\"{} in name\+:value format. You can provide them using \char`\"{}pmo\char`\"{} \begin{DoxyVerb}           {
+            "mountpoint": "/stuff",
+            "origin": "callback://myprotocol",
+            "pmo": [{
+                    "myname": "myvalue"
+            }]
+           }
+\end{DoxyVerb}
+
+
+2) When using a cgi\+:// protcol origin at a mountpoint, you may also give cgi environment variables specific to the mountpoint like this 
 \begin{DoxyCode}
 1 \{
 2  "mountpoint": "/git",
@@ -253,11 +265,11 @@ Eg, with this mountpoint
 \end{DoxyCode}
  This allows you to customize one cgi depending on the mountpoint (and / or vhost).
 
-2) It\textquotesingle{}s also possible to set the cgi timeout (in secs) per cgi\+:// mount, like this 
+3) It\textquotesingle{}s also possible to set the cgi timeout (in secs) per cgi\+:// mount, like this 
 \begin{DoxyCode}
 1 "cgi-timeout": "30"
 \end{DoxyCode}
3) {\ttfamily callback\+://} protocol may be used when defining a mount to associate a named protocol callback with the U\+RL namespace area. For example 
4) {\ttfamily callback\+://} protocol may be used when defining a mount to associate a named protocol callback with the U\+RL namespace area. For example 
 \begin{DoxyCode}
 1 \{
 2  "mountpoint": "/formtest",
@@ -270,7 +282,7 @@ This is useful for handling P\+O\+ST http body content or general non-\/cgi http
 
 See the related notes in R\+E\+A\+D\+M\+E.\+coding.\+md
 
-4) Cache policy of the files in the mount can also be set. If no options are given, the content is marked uncacheable. 
+5) Cache policy of the files in the mount can also be set. If no options are given, the content is marked uncacheable. 
 \begin{DoxyCode}
 1 \{
 2  "mountpoint": "/",
@@ -283,7 +295,7 @@ See the related notes in R\+E\+A\+D\+M\+E.\+coding.\+md
 \end{DoxyCode}
 
 
-4) You can also define a list of additional mimetypes per-\/mount 
+6) You can also define a list of additional mimetypes per-\/mount 
 \begin{DoxyCode}
 1 "extra-mimetypes": \{
 2          ".zip": "application/zip",
index 81c85b1..4637aa9 100644 (file)
@@ -27,6 +27,8 @@
 #include <dirent.h>
 #endif
 
+#define ESC_INSTALL_DATADIR "_lws_ddir_"
+
 static const char * const paths_global[] = {
        "global.uid",
        "global.gid",
@@ -246,6 +248,7 @@ lejp_vhosts_cb(struct lejp_ctx *ctx, char reason)
        struct jpargs *a = (struct jpargs *)ctx->user;
        struct lws_protocol_vhost_options *pvo, *mp_cgienv;
        struct lws_http_mount *m;
+       char *p, *p1;
        int n;
 
 #if 0
@@ -309,8 +312,7 @@ lejp_vhosts_cb(struct lejp_ctx *ctx, char reason)
                a->p += n;
                a->pvo->value = a->p;
                a->pvo->options = NULL;
-               a->p += snprintf(a->p, a->end - a->p, "%s", ctx->buf);
-               *(a->p)++ = '\0';
+               goto dostring;
        }
 
        if (reason == LEJPCB_OBJECT_END &&
@@ -484,13 +486,10 @@ lejp_vhosts_cb(struct lejp_ctx *ctx, char reason)
                a->p += n;
                mp_cgienv->value = a->p;
                mp_cgienv->options = NULL;
-               a->p += snprintf(a->p, a->end - a->p, "%s", ctx->buf);
-               *(a->p)++ = '\0';
-
                lwsl_notice("    adding pmo / cgi-env '%s' = '%s'\n", mp_cgienv->name,
                                mp_cgienv->value);
+               goto dostring;
 
-               break;
        case LEJPVP_PROTOCOL_NAME_OPT:
                /* this catches, eg,
                 * vhosts[].ws-protocols[].xxx-protocol.yyy-option
@@ -570,7 +569,20 @@ lejp_vhosts_cb(struct lejp_ctx *ctx, char reason)
                return 0;
        }
 
-       a->p += snprintf(a->p, a->end - a->p, "%s", ctx->buf);
+dostring:
+       p = ctx->buf;
+       p1 = strstr(p, ESC_INSTALL_DATADIR);
+       if (p1) {
+               n = p1 - p;
+               if (n > a->end - a->p)
+                       n = a->end - a->p;
+               strncpy(a->p, p, n);
+               a->p += n;
+               a->p += snprintf(a->p, a->end - a->p, "%s", LWS_INSTALL_DATADIR);
+               p += n + strlen(ESC_INSTALL_DATADIR);
+       }
+
+       a->p += snprintf(a->p, a->end - a->p, "%s", p);
        *(a->p)++ = '\0';
 
        return 0;
index 0e929b9..42a77c6 100644 (file)
@@ -6,6 +6,8 @@
        #endif
 #endif
 
+#define LWS_INSTALL_DATADIR "${CMAKE_INSTALL_PREFIX}/share"
+
 /* Define to 1 to use wolfSSL/CyaSSL as a replacement for OpenSSL.
  * LWS_OPENSSL_SUPPORT needs to be set also for this to work. */
 #cmakedefine USE_WOLFSSL
index 59bf9aa..42ac275 100644 (file)
@@ -10,7 +10,7 @@
 #     "sts": "on",
      "mounts": [{
        "mountpoint": "/",
-       "origin": "file:///usr/share/libwebsockets-test-server",
+       "origin": "file://_lws_ddir_/libwebsockets-test-server",
        "default": "test.html",
        "cache-max-age": "60",
        "cache-reuse": "1",
        "cache-intermediaries": "0"
        }, {
         "mountpoint": "/server-status",
-        "origin": "file:///usr/share/libwebsockets-test-server/server-status",
+        "origin": "file://_lws_ddir_/libwebsockets-test-server/server-status",
         "default": "server-status.html"
        }, {
        "mountpoint": "/testcgi",
-       "origin": "cgi:///usr/share/libwebsockets-test-server/lws-cgi-test.sh"
+       "origin": "cgi://_lws_ddir_/libwebsockets-test-server/lws-cgi-test.sh"
 
        }, {
         "mountpoint": "/formtest",