Skip to content

Commit

Permalink
Deploying to gh-pages from @ 0c90591 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
fraya committed Jan 26, 2025
1 parent affd711 commit 70e3eff
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 45 deletions.
2 changes: 1 addition & 1 deletion _sources/index.rst.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Dylan-curl
==========

Curl library wrapper for the Opendylan language.
Curl library wrapper for the Dylan language.

.. toctree::
:maxdepth: 2
Expand Down
22 changes: 9 additions & 13 deletions _sources/introduction.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Introduction

``dylan-curl`` is a wrapper around the popular libcurl library,
providing a way to interact with network resources from within Open
Dylan programs. This wrapper try to simplify the complexities of
Dylan programs. This wrapper tries to simplify the complexities of
libcurl, offering a Dylan-friendly API while maintaining the core
capabilities of the underlying C library.

Expand All @@ -20,8 +20,8 @@ Dylan Integration:
handling into Dylan's exception mechanism for cleaner and more
reliable error management.

Howto convert a libcurl program
-------------------------------
How to convert a libcurl program
--------------------------------

When converting a libcurl-based C program to the Open Dylan wrapper, a
few conventions streamline the process. Below are the main conventions
Expand All @@ -44,7 +44,7 @@ wrapper, you create an object of the :class:`<curl-easy>` class.
}
.. code-block:: dylan
:caption: Opendylan example
:caption: Dylan example
let curl = make(<curl-easy>);
Expand All @@ -59,7 +59,7 @@ In libcurl, parameters are configured using `curl_easy_setopt
<https://curl.se/libcurl/c/curl_easy_setopt.html>`_, where a constant
representing the option name is paired with its value. In the Open
Dylan wrapper, options are set directly using property syntax, such as
`curl.curl-option-name := value`. If an error occurs while setting a
``curl.curl-option-name := value`. If an error occurs while setting a
parameter, a :class:`<curl-option-error>` exception is raised.
.. code-block:: c
Expand All @@ -74,7 +74,7 @@ parameter, a :class:`<curl-option-error>` exception is raised.
}
In libcurl, each parameter should be validated after calling the
`curl_easy_setopt` function, although this step is often omitted in
``curl_easy_setopt`` function, although this step is often omitted in
examples for simplicity. The libcurl documentation cautions: *"A
real-world application will, of course, properly check every return
value and exit correctly at the first serious error."*
Expand All @@ -85,7 +85,7 @@ handled either immediately at the point of the operation or deferred
to another method for centralized error handling.

.. code-block:: dylan
:caption: In Opendylan errors can be captured in a block somewhere.
:caption: In Dylan errors can be captured in a block somewhere.
let curl = make(<curl-easy>);
curl.curl-url := "https://example.com";
Expand Down Expand Up @@ -121,20 +121,16 @@ In Opendylan :function:`curl-perform` raises a

.. code-block:: dylan
curl-easy-perform(curl);
...
block ()
...
curl-easy-perform(curl);
exception (err :: <curl-perform-error>)
... show error or retry?
end block;
Retrieving Information
^^^^^^^^^^^^^^^^^^^^^^

In libcurl, retrieving information is done with `curl_easy_getinfo`,
In libcurl, retrieving information is done with ``curl_easy_getinfo`,
passing a constant for the type of information. In the Open Dylan
wrapper, you access the information directly using property syntax.
Expand Down
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@
<article role="main" id="furo-main-content">
<section id="dylan-curl">
<h1>Dylan-curl<a class="headerlink" href="#dylan-curl" title="Link to this heading"></a></h1>
<p>Curl library wrapper for the Opendylan language.</p>
<p>Curl library wrapper for the Dylan language.</p>
<div class="toctree-wrapper compound">
<p class="caption" role="heading"><span class="caption-text">Contents:</span></p>
<ul>
Expand All @@ -274,7 +274,7 @@ <h1>Dylan-curl<a class="headerlink" href="#dylan-curl" title="Link to this headi
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="introduction.html">Introduction</a><ul>
<li class="toctree-l2"><a class="reference internal" href="introduction.html#howto-convert-a-libcurl-program">Howto convert a libcurl program</a></li>
<li class="toctree-l2"><a class="reference internal" href="introduction.html#how-to-convert-a-libcurl-program">How to convert a libcurl program</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="curl_global.html">Curl global</a><ul>
Expand Down
52 changes: 24 additions & 28 deletions introduction.html
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@
<h1>Introduction<a class="headerlink" href="#introduction" title="Link to this heading"></a></h1>
<p><code class="docutils literal notranslate"><span class="pre">dylan-curl</span></code> is a wrapper around the popular libcurl library,
providing a way to interact with network resources from within Open
Dylan programs. This wrapper try to simplify the complexities of
Dylan programs. This wrapper tries to simplify the complexities of
libcurl, offering a Dylan-friendly API while maintaining the core
capabilities of the underlying C library.</p>
<p><strong>Key Features</strong></p>
Expand All @@ -281,17 +281,17 @@ <h1>Introduction<a class="headerlink" href="#introduction" title="Link to this h
reliable error management.</p>
</dd>
</dl>
<section id="howto-convert-a-libcurl-program">
<h2>Howto convert a libcurl program<a class="headerlink" href="#howto-convert-a-libcurl-program" title="Link to this heading"></a></h2>
<section id="how-to-convert-a-libcurl-program">
<h2>How to convert a libcurl program<a class="headerlink" href="#how-to-convert-a-libcurl-program" title="Link to this heading"></a></h2>
<p>When converting a libcurl-based C program to the Open Dylan wrapper, a
few conventions streamline the process. Below are the main conventions
and their corresponding Open Dylan equivalents.</p>
<section id="creating-a-curl-handle">
<h3>Creating a CURL Handle<a class="headerlink" href="#creating-a-curl-handle" title="Link to this heading"></a></h3>
<p>In libcurl, you create a handle using <a class="reference external" href="https://curl.se/libcurl/c/curl_easy_init.html">curl_easy_init</a>. In the Open Dylan
wrapper, you create an object of the <code class="xref py py-class docutils literal notranslate"><span class="pre">&lt;curl-easy&gt;</span></code> class.</p>
<div class="literal-block-wrapper docutils container" id="id3">
<div class="code-block-caption"><span class="caption-text">C example</span><a class="headerlink" href="#id3" title="Link to this code"></a></div>
<div class="literal-block-wrapper docutils container" id="id7">
<div class="code-block-caption"><span class="caption-text">C example</span><a class="headerlink" href="#id7" title="Link to this code"></a></div>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">CURL</span><span class="w"> </span><span class="o">*</span><span class="n">curl</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">curl_easy_init</span><span class="p">();</span>
<span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">curl</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="p">...</span>
Expand All @@ -300,8 +300,8 @@ <h3>Creating a CURL Handle<a class="headerlink" href="#creating-a-curl-handle" t
</pre></div>
</div>
</div>
<div class="literal-block-wrapper docutils container" id="id4">
<div class="code-block-caption"><span class="caption-text">Opendylan example</span><a class="headerlink" href="#id4" title="Link to this code"></a></div>
<div class="literal-block-wrapper docutils container" id="id8">
<div class="code-block-caption"><span class="caption-text">Dylan example</span><a class="headerlink" href="#id8" title="Link to this code"></a></div>
<div class="highlight-dylan notranslate"><div class="highlight"><pre><span></span><span class="k">let</span><span class="w"> </span><span class="n">curl</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">make</span><span class="p">(</span><span class="nc">&lt;curl-easy&gt;</span><span class="p">);</span>
</pre></div>
</div>
Expand All @@ -315,10 +315,10 @@ <h3>Setting Parameters<a class="headerlink" href="#setting-parameters" title="Li
<p>In libcurl, parameters are configured using <a class="reference external" href="https://curl.se/libcurl/c/curl_easy_setopt.html">curl_easy_setopt</a>, where a constant
representing the option name is paired with its value. In the Open
Dylan wrapper, options are set directly using property syntax, such as
<cite>curl.curl-option-name := value</cite>. If an error occurs while setting a
<a href="#id1"><span class="problematic" id="id2">``</span></a>curl.curl-option-name := value`. If an error occurs while setting a
parameter, a <code class="xref py py-class docutils literal notranslate"><span class="pre">&lt;curl-option-error&gt;</span></code> exception is raised.</p>
<div class="literal-block-wrapper docutils container" id="id5">
<div class="code-block-caption"><span class="caption-text">Example showing the error checking, usually hidden in examples.</span><a class="headerlink" href="#id5" title="Link to this code"></a></div>
<div class="literal-block-wrapper docutils container" id="id9">
<div class="code-block-caption"><span class="caption-text">Example showing the error checking, usually hidden in examples.</span><a class="headerlink" href="#id9" title="Link to this code"></a></div>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">CURLCODE</span><span class="w"> </span><span class="n">code</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">curl_easy_setopt</span><span class="p">(</span><span class="n">curl</span><span class="p">,</span><span class="w"> </span><span class="n">CURLOPT_URL</span><span class="p">,</span><span class="w"> </span><span class="s">&quot;https://example.com&quot;</span><span class="p">);</span>
<span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">code</span><span class="w"> </span><span class="o">!=</span><span class="w"> </span><span class="n">CURLE_OK</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="n">fprintf</span><span class="p">(</span><span class="n">stderr</span><span class="p">,</span>
Expand All @@ -330,16 +330,16 @@ <h3>Setting Parameters<a class="headerlink" href="#setting-parameters" title="Li
</div>
</div>
<p>In libcurl, each parameter should be validated after calling the
<cite>curl_easy_setopt</cite> function, although this step is often omitted in
<code class="docutils literal notranslate"><span class="pre">curl_easy_setopt</span></code> function, although this step is often omitted in
examples for simplicity. The libcurl documentation cautions: <em>“A
real-world application will, of course, properly check every return
value and exit correctly at the first serious error.”</em></p>
<p>In Open Dylan, whenever an option is set, the result is automatically
checked. If an error occurs, an exception is raised, allowing it to be
handled either immediately at the point of the operation or deferred
to another method for centralized error handling.</p>
<div class="literal-block-wrapper docutils container" id="id6">
<div class="code-block-caption"><span class="caption-text">In Opendylan errors can be captured in a block somewhere.</span><a class="headerlink" href="#id6" title="Link to this code"></a></div>
<div class="literal-block-wrapper docutils container" id="id10">
<div class="code-block-caption"><span class="caption-text">In Dylan errors can be captured in a block somewhere.</span><a class="headerlink" href="#id10" title="Link to this code"></a></div>
<div class="highlight-dylan notranslate"><div class="highlight"><pre><span></span><span class="k">let</span><span class="w"> </span><span class="n">curl</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">make</span><span class="p">(</span><span class="nc">&lt;curl-easy&gt;</span><span class="p">);</span>
<span class="n">curl</span><span class="p">.</span><span class="n">curl-url</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="s">&quot;https://example.com&quot;</span><span class="p">;</span>

Expand All @@ -359,8 +359,8 @@ <h3>Setting Parameters<a class="headerlink" href="#setting-parameters" title="Li
<h3>Performing the Request<a class="headerlink" href="#performing-the-request" title="Link to this heading"></a></h3>
<p>In libcurl, the request is executed using <cite>curl_easy_perform</cite>. The
Open Dylan equivalent is the method <code class="xref py py-meth docutils literal notranslate"><span class="pre">curl-easy-perform()</span></code>.</p>
<div class="literal-block-wrapper docutils container" id="id7">
<div class="code-block-caption"><span class="caption-text">C Example</span><a class="headerlink" href="#id7" title="Link to this code"></a></div>
<div class="literal-block-wrapper docutils container" id="id11">
<div class="code-block-caption"><span class="caption-text">C Example</span><a class="headerlink" href="#id11" title="Link to this code"></a></div>
<div class="highlight-C notranslate"><div class="highlight"><pre><span></span><span class="n">CURLcode</span><span class="w"> </span><span class="n">res</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">curl_easy_perform</span><span class="p">(</span><span class="n">curl</span><span class="p">);</span>

<span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">res</span><span class="w"> </span><span class="o">!=</span><span class="w"> </span><span class="n">CURLE_OK</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
Expand All @@ -371,14 +371,10 @@ <h3>Performing the Request<a class="headerlink" href="#performing-the-request" t
</pre></div>
</div>
</div>
<p>In Opendylan <a href="#id1"><span class="problematic" id="id2">:function:`curl-perform`</span></a> raises a
<p>In Opendylan <a href="#id3"><span class="problematic" id="id4">:function:`curl-perform`</span></a> raises a
<code class="xref py py-class docutils literal notranslate"><span class="pre">&lt;curl-perform-error&gt;</span></code>.</p>
<div class="highlight-dylan notranslate"><div class="highlight"><pre><span></span><span class="n">curl-easy-perform</span><span class="p">(</span><span class="n">curl</span><span class="p">);</span>

<span class="p">...</span>

<span class="nb">block</span><span class="w"> </span><span class="p">()</span>
<span class="w"> </span><span class="p">...</span>
<div class="highlight-dylan notranslate"><div class="highlight"><pre><span></span><span class="nb">block</span><span class="w"> </span><span class="p">()</span>
<span class="w"> </span><span class="n">curl-easy-perform</span><span class="p">(</span><span class="n">curl</span><span class="p">);</span>
<span class="nb">exception</span><span class="w"> </span><span class="p">(</span><span class="n">err</span><span class="w"> </span><span class="p">::</span><span class="w"> </span><span class="nc">&lt;curl-perform-error&gt;</span><span class="p">)</span>
<span class="w"> </span><span class="p">...</span><span class="w"> </span><span class="n">show</span><span class="w"> </span><span class="nb">error</span><span class="w"> </span><span class="n">or</span><span class="w"> </span><span class="n">retry?</span>
<span class="k">end</span><span class="w"> </span><span class="nb">block</span><span class="p">;</span>
Expand All @@ -387,11 +383,11 @@ <h3>Performing the Request<a class="headerlink" href="#performing-the-request" t
</section>
<section id="retrieving-information">
<h3>Retrieving Information<a class="headerlink" href="#retrieving-information" title="Link to this heading"></a></h3>
<p>In libcurl, retrieving information is done with <cite>curl_easy_getinfo</cite>,
<p>In libcurl, retrieving information is done with <a href="#id5"><span class="problematic" id="id6">``</span></a>curl_easy_getinfo`,
passing a constant for the type of information. In the Open Dylan
wrapper, you access the information directly using property syntax.</p>
<div class="literal-block-wrapper docutils container" id="id8">
<div class="code-block-caption"><span class="caption-text">C example getting the total time of previous transfer</span><a class="headerlink" href="#id8" title="Link to this code"></a></div>
<div class="literal-block-wrapper docutils container" id="id12">
<div class="code-block-caption"><span class="caption-text">C example getting the total time of previous transfer</span><a class="headerlink" href="#id12" title="Link to this code"></a></div>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="kt">double</span><span class="w"> </span><span class="n">total_time</span><span class="p">;</span>
<span class="n">CURLCODE</span><span class="w"> </span><span class="n">res</span><span class="p">;</span>

Expand All @@ -414,8 +410,8 @@ <h3>Retrieving Information<a class="headerlink" href="#retrieving-information" t
</pre></div>
</div>
</div>
<div class="literal-block-wrapper docutils container" id="id9">
<div class="code-block-caption"><span class="caption-text">Dylan Example</span><a class="headerlink" href="#id9" title="Link to this code"></a></div>
<div class="literal-block-wrapper docutils container" id="id13">
<div class="code-block-caption"><span class="caption-text">Dylan Example</span><a class="headerlink" href="#id13" title="Link to this code"></a></div>
<div class="highlight-dylan notranslate"><div class="highlight"><pre><span></span><span class="nb">block</span><span class="w"> </span><span class="p">()</span>
<span class="w"> </span><span class="k">let</span><span class="w"> </span><span class="n">curl</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">make</span><span class="p">(</span><span class="nc">&lt;curl-easy&gt;</span><span class="p">);</span>
<span class="w"> </span><span class="n">curl</span><span class="p">.</span><span class="n">curl-url</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="s">&quot;https://example.com/&quot;</span><span class="p">;</span>
Expand Down Expand Up @@ -491,7 +487,7 @@ <h3>Retrieving Information<a class="headerlink" href="#retrieving-information" t
<div class="toc-tree">
<ul>
<li><a class="reference internal" href="#">Introduction</a><ul>
<li><a class="reference internal" href="#howto-convert-a-libcurl-program">Howto convert a libcurl program</a><ul>
<li><a class="reference internal" href="#how-to-convert-a-libcurl-program">How to convert a libcurl program</a><ul>
<li><a class="reference internal" href="#creating-a-curl-handle">Creating a CURL Handle</a></li>
<li><a class="reference internal" href="#setting-parameters">Setting Parameters</a></li>
<li><a class="reference internal" href="#performing-the-request">Performing the Request</a></li>
Expand Down
Loading

0 comments on commit 70e3eff

Please sign in to comment.