example.html 2.5 KB

12345678910111213141516171819202122232425262728293031
  1. <html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Example application</title><link rel="stylesheet" type="text/css" href="manual.css"><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot"><link rel="home" href="index.html" title="neon HTTP/WebDAV client library"><link rel="up" href="intro.html" title="Chapter 1. Introduction"><link rel="prev" href="using.html" title="How to use neon from your application"><link rel="next" href="compliance.html" title="Standards compliance"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Example application</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="using.html">Prev</a> </td><th width="60%" align="center">Chapter 1. Introduction</th><td width="20%" align="right"> <a accesskey="n" href="compliance.html">Next</a></td></tr></table><hr></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="example"></a>Example application</h2></div></div></div><p>The code below is a simple example which sends a
  2. <code class="literal">PUT</code> request, using the API from
  3. <code class="literal">&lt;ne_basic.h&gt;</code>:
  4. </p><pre class="programlisting">
  5. #include &lt;stdio.h&gt;
  6. #include &lt;stdlib.h&gt;
  7. #include &lt;ne_basic.h&gt;
  8. static const char data[] = "Example data.\n";
  9. int main(int argc, char **argv)
  10. {
  11. ne_session *sess;
  12. int ec = EXIT_SUCCESS;
  13. ne_sock_init(); /* Global library initialization. */
  14. sess = ne_session_create("http", "localhost", 80);
  15. if (ne_putbuf(sess, "/dav/data.txt", data, sizeof data)) {
  16. fprintf(stderr, "PUT Request failed: %s\n", ne_get_error(sess));
  17. ec = EXIT_FAILURE;
  18. }
  19. ne_session_destroy(sess);
  20. return ec;
  21. }
  22. </pre></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="using.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="intro.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="compliance.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">How to use neon from your application </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Standards compliance</td></tr></table></div></body></html>