File: imclient.html

package info (click to toggle)
cyrus-imapd 3.12.1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 60,760 kB
  • sloc: ansic: 280,403; perl: 146,834; javascript: 9,624; sh: 5,730; yacc: 2,660; cpp: 2,263; makefile: 2,103; lex: 675; xml: 621; awk: 303; python: 273; asm: 262
file content (396 lines) | stat: -rw-r--r-- 29,121 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8" /><meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />

  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>imclient library &mdash; Cyrus IMAP 3.12.1 documentation</title>
      <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
      <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" />
      <link rel="stylesheet" href="../../../_static/graphviz.css" type="text/css" />
      <link rel="stylesheet" href="../../../_static/cyrus.css" type="text/css" />
  
        <script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
        <script src="../../../_static/jquery.js"></script>
        <script src="../../../_static/underscore.js"></script>
        <script src="../../../_static/_sphinx_javascript_frameworks_compat.js"></script>
        <script src="../../../_static/doctools.js"></script>
        <script src="../../../_static/sphinx_highlight.js"></script>
    <script src="../../../_static/js/theme.js"></script>
    <link rel="index" title="Index" href="../../../genindex.html" />
    <link rel="search" title="Search" href="../../../search.html" />
    <link rel="next" title="Releasing Cyrus IMAP - normal releases" href="../releasing.html" />
    <link rel="prev" title="Developer Libraries" href="../libraries.html" /> 
</head>

<body class="wy-body-for-nav"> 
  <div class="wy-grid-for-nav">
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >

          
          
          <a href="../../../index.html" class="icon icon-home">
            Cyrus IMAP
          </a>
              <div class="version">
                3.12.1
              </div>
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>
        </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
              <p class="caption" role="heading"><span class="caption-text">Cyrus IMAP</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../../download.html">Download</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../quickstart.html">Quickstart Guide</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../overview.html">Overview</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../setup.html">Setup</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../operations.html">Operations</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../../../developers.html">Developers</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../../../contribute.html">We need your help</a></li>
<li class="toctree-l2"><a class="reference internal" href="../documentation.html">Contribute docs</a></li>
<li class="toctree-l2 current"><a class="reference internal" href="../../developer.html">Contribute code and tests</a><ul class="current">
<li class="toctree-l3"><a class="reference internal" href="../../developer.html#getting-started">Getting Started</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../developer.html#system-files-and-databases">System files and Databases</a></li>
<li class="toctree-l3 current"><a class="reference internal" href="../../developer.html#resources">Resources</a><ul class="current">
<li class="toctree-l4 current"><a class="reference internal" href="../libraries.html">Developer Libraries</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="../../developer.html#releasing">Releasing</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../cyrusworks.html">Cyrus.Works</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../developers.html#cyrus-internals">Cyrus Internals</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../developers.html#unit-tests">Unit Tests</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../../support.html">Support/Community</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Cyrus SASL</span></p>
<ul>
<li class="toctree-l1"><a class="reference external" href="http://www.cyrusimap.org/sasl">Cyrus SASL</a></li>
</ul>

        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../../index.html">Cyrus IMAP</a>
      </nav>

      <div class="wy-nav-content">
        <div class="rst-content">
          <div role="navigation" aria-label="Page navigation">
  <ul class="wy-breadcrumbs">
      <li><a href="../../../index.html" class="icon icon-home" aria-label="Home"></a></li>
          <li class="breadcrumb-item"><a href="../../../developers.html">Developers</a></li>
          <li class="breadcrumb-item"><a href="../../developer.html">IMAP Developer Guide</a></li>
          <li class="breadcrumb-item"><a href="../libraries.html">Developer Libraries</a></li>
      <li class="breadcrumb-item active"><strong>imclient</strong> library</li>
      <li class="wy-breadcrumbs-aside">
              <a href="https://github.com/cyrusimap/cyrus-imapd/blob/master/docsrc/imap/developer/libraries/imclient.rst" class="fa fa-github"> Edit on GitHub</a>
      </li>
  </ul>
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
             
  <span class="target" id="std-cyrusman-imclient-3"></span><section id="imclient-library">
<span id="imap-admin-commands-imclient-library"></span><h1><strong>imclient</strong> library<a class="headerlink" href="#imclient-library" title="Permalink to this heading"></a></h1>
<p>Authenticating callback interface to IMAP servers</p>
<section id="synopsis">
<h2>Synopsis<a class="headerlink" href="#synopsis" title="Permalink to this heading"></a></h2>
<pre class="literal-block">#include &lt;cyrus/imclient.h&gt;

<strong>int imclient_connect(struct imclient **</strong><em>imclient</em> <strong>, const char *</strong><em>host</em> <strong>,
    const char *</strong><em>port</em><strong>);</strong>

<strong>void imclient_close (struct imclient *</strong><em>imclient</em><strong>);</strong>
<strong>void imclient_setflags(struct imclient *</strong><em>imclient</em> <strong>, int</strong> <em>flags</em><strong>);</strong>
<strong>void imclient_clearflags (struct imclient *</strong><em>imclient</em> <strong>, int</strong> <em>flags</em><strong>);</strong>
<strong>char* imclient_servername (struct imclient *</strong><em>imclient</em><strong>);</strong>
<strong>void imclient_addcallback (struct imclient *</strong><em>imclient</em>,...<strong>);</strong>
<strong>void imclient_send (struct imclient *</strong><em>imclient</em><strong>, void (*</strong><em>finishproc</em><strong>)(),
    void *</strong><em>finishrock</em><strong>, const char *</strong><em>fmt</em>,...<strong>);</strong>
<strong>void imclient_getselectinfo (struct imclient *</strong><em>imclient</em><strong>, int *</strong> <em>fd</em><strong>,
    int *</strong> <em>wanttowrite</em><strong>);</strong>
<strong>void imclient_processoneevent (struct imclient *</strong><em>imclient</em><strong>);</strong>
<strong>int imclient_authenticate (struct imclient *</strong><em>imclient</em><strong>,
    struct sasl_client **</strong><em>availmech</em><strong>, const char *</strong><em>service</em><strong>,
    const char *</strong><em>user</em><strong>, int</strong> <em>protallowed</em><strong>);</strong>
<strong>int imclient_havetls ();</strong>
<strong>int imclient_starttls (struct imclient *</strong><em>imclient</em><strong>, char *</strong><em>cert_file</em><strong>,
    char *</strong><em>key_file</em><strong>, char *</strong><em>CAfile</em><strong>, char *</strong><em>CApath</em><strong>);</strong></pre>
</section>
<section id="description">
<h2>Description<a class="headerlink" href="#description" title="Permalink to this heading"></a></h2>
<p>The imclient library functions are distributed with Cyrus IMAP.
These functions are used for building IMAP client software. These
functions handle Kerberos authentication and can set callbacks based on the
keyword in untagged replies or based on the command tag at the end of
command replies.</p>
<p>Users must link with the -lcyrus switch, and must supply a function
called <em>fatal</em> to be called in case of any error within <em>libcyrus.la</em>.</p>
<p>All of the <strong>imclient</strong> functions begin with the prefix <em>imclient</em> and
take  an  argument of type <strong>struct imclient *</strong> as the first argument
which is  initialized by <strong>imclient_connect</strong> and freed by
<strong>imclient_close</strong>.</p>
<p>See below for a description of each function.</p>
<dl>
<dt><strong>imclient_connect()</strong></dt><dd><p>Connects the client server to the host. If successful, it returns
0 and sets the imclient argument to a pointer to an <strong>imclient</strong>
struct.  The <strong>imclient</strong> struct represents the current connection,
flags, and callbacks.  On failure, the current <strong>errno</strong> is returned
if a system call failed, -1 is returned if the host name was not
found, and -2 is returned if the service name was not found.</p>
</dd>
<dt><strong>imclient_close()</strong></dt><dd><p>Closes and frees the <strong>imclient</strong> connection.</p>
</dd>
<dt><strong>imclient_setflags()</strong></dt><dd><p>Sets the flags specified by the <em>flags</em> argument on the <strong>imclient</strong>
connection. Currently the only  flag allowed is
<strong>IMCLIENT_CONN_NONSYNCLITERAL</strong> (this flag indicates that the
server supports non-synchronizing literals described by the LITERAL+
extension).</p>
</dd>
<dt><strong>imclient_clearflags()</strong></dt><dd><p>Clears the flags specified by the <em>flags</em> argument on the
<strong>imclient</strong> connection.</p>
</dd>
<dt><strong>imclient_servername()</strong></dt><dd><p>Returns a char * pointer to the name of the server connected to
by <strong>imclient</strong>.</p>
</dd>
<dt><strong>imclient_addcallback()</strong></dt><dd><p>Adds an untagged data callback to the <strong>imclient</strong> connection. The
function <strong>imclient_addcallback</strong> takes callbacks of the type
<strong>imclient_proc_t</strong> which is defined to be:</p>
<blockquote>
<div><div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">typedef</span> <span class="n">void</span> <span class="n">imclient_proc_t</span> <span class="p">(</span><span class="n">struct</span> <span class="n">imclient</span> <span class="o">*</span><span class="n">imclient</span><span class="p">,</span> <span class="n">void</span> <span class="o">*</span><span class="n">rock</span><span class="p">,</span> <span class="n">struct</span> <span class="n">imclient_reply</span> <span class="o">*</span><span class="n">reply</span><span class="p">);</span>
</pre></div>
</div>
</div></blockquote>
<p>and <strong>struct imclient_reply *</strong>
is defined to be:</p>
<blockquote>
<div><div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">struct</span> <span class="n">imclient_reply</span> <span class="p">{</span>
    <span class="n">char</span> <span class="o">*</span><span class="n">keyword</span><span class="p">;</span>
    <span class="n">long</span> <span class="n">msgno</span><span class="p">;</span>
    <span class="n">char</span> <span class="o">*</span><span class="n">text</span><span class="p">;</span>
<span class="p">};</span>
</pre></div>
</div>
</div></blockquote>
<p>After the first argument, <em>imclient</em>, there can be zero or more
instances of the set of <em>keyword</em>, <em>flags</em>, <em>proc</em>, and <em>rock</em>,
each adding or changing a single callback.  Each instance adds or
changes the callback for <em>keyword</em>.  The argument <em>flags</em> specifies
information about the parsing of the untagged data.  <em>proc</em> and
<em>rock</em> specify the callback function and rock to invoke when the
untagged data is received.  <em>proc</em> may be a null pointer, in which
case no function is invoked.  The callback function may not call
the functions <strong>imclient_close(), imclient_send(), imclient_eof(),
imclient_processoneevent()</strong>, or <strong>imclient_authenticate()</strong> on the
connection. The callback function may overwrite  the text of
untagged data.</p>
</dd>
<dt><strong>imclient_send()</strong></dt><dd><p>Sends a new command to the <strong>imclient</strong> connection.  <em>finishproc</em>
and <em>finishrock</em> are the function and rock called when the command
completes.  <em>functionproc</em> may be a null pointer, in which case no
callback is made. The callback function may not call the functions
<strong>imclient_close(), imclient_send(), imclient_eof(),
imclient_processoneevent()</strong>, or <strong>imclient_authenticate()</strong> on the
connection.  The argument <em>fmt</em> is a <em class="manpage">printf(3)</em> like
specification of the command. It must not include the tag as the
tag is automatically added by <strong>imclient_send()</strong>.</p>
<p>The defined %-sequences are:</p>
<blockquote>
<div><div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">%%</span> <span class="k">for</span> <span class="o">%</span>
<span class="o">%</span><span class="n">a</span> <span class="k">for</span> <span class="n">an</span> <span class="n">IMAP</span> <span class="n">atom</span>
<span class="o">%</span><span class="n">s</span> <span class="k">for</span> <span class="n">an</span> <span class="n">astring</span> <span class="p">(</span><span class="n">which</span> <span class="n">will</span> <span class="n">be</span> <span class="n">quoted</span> <span class="ow">or</span> <span class="n">literalized</span> <span class="k">as</span> <span class="n">needed</span><span class="p">)</span>
<span class="o">%</span><span class="n">d</span> <span class="k">for</span> <span class="n">a</span> <span class="n">decimal</span>
<span class="o">%</span><span class="n">u</span> <span class="k">for</span> <span class="n">an</span> <span class="n">unsigned</span> <span class="n">decimal</span>
<span class="o">%</span><span class="n">v</span> <span class="k">for</span> <span class="c1">#astring (argument is a null-terminated array of char *</span>
<span class="n">which</span> <span class="n">are</span> <span class="n">written</span> <span class="k">as</span> <span class="n">space</span> <span class="n">separated</span> <span class="n">astrings</span><span class="p">)</span>
</pre></div>
</div>
</div></blockquote>
</dd>
<dt><strong>imclient_getselectinfo()</strong></dt><dd><p>Gets the information for calling <em class="manpage">select(2)</em>.  <em>fd</em> is
filled in with the file descriptor to <em class="manpage">select(2)</em> for read.
<em>wanttowrite</em> is filled in with a nonzero value if <strong>select</strong> should
be used for write as well.</p>
</dd>
<dt><strong>imclient_processoneevent()</strong></dt><dd><p>Processes one input or output event on the <strong>imclient</strong> connection.</p>
</dd>
<dt><strong>imclient_authenticate()</strong></dt><dd><p>Authenticates the <strong>imclient</strong> connection using one of the mechanisms
in <em>availmech</em>.  The argument <em>user</em>, if not NULL, specifies the user
to authenticate as. If the user is NULL, the current user is used.
The argument <em>protallowed</em> is a bitmask of permissible protection
mechanisms.
On success, 0 is returned.  On failure (i.e., &quot;BAD&quot; keyboard, or
no authentication mechanisms worked), 1 is returned. On extreme
failure (premature &quot;OK&quot;), 2 is returned.</p>
</dd>
<dt><strong>imclient_havetls()</strong></dt><dd><p>Returns a Boolean indicating whether the <strong>imclient</strong> library was
compiled with TLS (SSL) support.  If so, <strong>imclient_starttls()</strong> may
be used to secure the IMAP connection.</p>
</dd>
<dt><strong>imclient_starttls()</strong></dt><dd><p>Issues a STARTTLS command on an existing IMAP connection and
negotiates the secure link.  The <em>cert_file</em> and <em>key_file</em> arguments
specify the client certificate and secret key to use to
authenticate ourselves to the server.  If client authentication is
not needed, set both of these arguments to NULL.</p>
<p>The <em>CAfile</em> and <em>CApath</em> arguments specify a file or directory,
respectively, of CA certificates for validating server
certificates. (See <em class="manpage">SSL_CTX_load_verify_locations(3)</em> for
details.)  If both of these are NULL, the client will be unable to
validate the server's certificate, in which case the connection may
succeed but a warning will be printed to stdout.</p>
</dd>
</dl>
</section>
<section id="examples">
<h2>Examples<a class="headerlink" href="#examples" title="Permalink to this heading"></a></h2>
<p>The following code is a possible skeleton of <strong>imclient</strong> that relies
on Kerberos to do authentication.  This code performs an IMAP
CAPABILITY request and prints out the result.</p>
<blockquote>
<div><div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1">#include &lt;cyrus/xmalloc.h&gt; /* example uses xstrdup */</span>
<span class="c1">#include &lt;cyrus/sasl.h&gt;</span>
<span class="c1">#include &lt;cyrus/imclient.h&gt;</span>
<span class="c1">#include &lt;stdio.h&gt;</span>

<span class="n">extern</span> <span class="n">struct</span> <span class="n">sasl_client</span> <span class="n">krb_sasl_client</span><span class="p">;</span>

<span class="n">struct</span> <span class="n">sasl_client</span> <span class="o">*</span><span class="n">login_sasl_client</span><span class="p">[]</span> <span class="o">=</span> <span class="p">{</span>
    <span class="o">&amp;</span><span class="n">krb_sasl_client</span><span class="p">,</span>
    <span class="n">NULL</span>
<span class="p">};</span>
<span class="n">struct</span> <span class="n">imclient</span> <span class="o">*</span><span class="n">imclient</span><span class="p">;</span>
<span class="n">char</span> <span class="n">server</span><span class="p">[]</span> <span class="o">=</span> <span class="s2">&quot;cyrus.andrew.cmu.edu&quot;</span> <span class="p">;</span>
<span class="n">char</span> <span class="n">port</span><span class="p">[]</span> <span class="o">=</span> <span class="s2">&quot;imap&quot;</span><span class="p">;</span>

<span class="n">void</span> <span class="n">fatal</span><span class="p">(</span><span class="n">char</span><span class="o">*</span> <span class="n">message</span><span class="p">,</span> <span class="nb">int</span> <span class="n">rc</span><span class="p">)</span> <span class="p">{</span>
    <span class="n">fprintf</span><span class="p">(</span><span class="n">stderr</span><span class="p">,</span> <span class="s2">&quot;fatal error: </span><span class="si">%s</span><span class="s2">\en&quot;</span><span class="p">,</span> <span class="n">message</span><span class="p">);</span>
    <span class="n">exit</span><span class="p">(</span><span class="n">rc</span><span class="p">);</span>
<span class="p">}</span>

<span class="n">static</span> <span class="n">void</span> <span class="n">callback_capability</span><span class="p">(</span><span class="n">struct</span> <span class="n">imclient</span> <span class="o">*</span><span class="n">imclient</span><span class="p">,</span>
                                <span class="n">void</span> <span class="o">*</span><span class="n">rock</span><span class="p">,</span>
                                <span class="n">struct</span> <span class="n">imclient_reply</span> <span class="o">*</span><span class="n">reply</span><span class="p">)</span> <span class="p">{</span>
    <span class="k">if</span> <span class="p">(</span><span class="n">reply</span><span class="o">-&gt;</span><span class="n">text</span> <span class="o">!=</span> <span class="n">NULL</span><span class="p">)</span> <span class="p">{</span>
        <span class="o">*</span><span class="p">((</span><span class="n">char</span><span class="o">**</span><span class="p">)</span><span class="n">rock</span><span class="p">)</span> <span class="o">=</span> <span class="n">xstrdup</span><span class="p">(</span> <span class="n">reply</span><span class="o">-&gt;</span><span class="n">text</span> <span class="p">);</span>
    <span class="p">}</span>
<span class="p">}</span>

<span class="n">static</span> <span class="n">void</span> <span class="n">end_command</span><span class="p">(</span><span class="n">struct</span> <span class="n">imclient</span> <span class="o">*</span><span class="n">connection</span><span class="p">,</span> <span class="n">void</span><span class="o">*</span>
                        <span class="n">rock</span><span class="p">,</span>  <span class="n">struct</span> <span class="n">imclient_reply</span> <span class="o">*</span><span class="n">inmsg</span><span class="p">)</span> <span class="p">{</span>
    <span class="p">(</span><span class="o">*</span><span class="p">(</span><span class="nb">int</span><span class="o">*</span><span class="p">)</span><span class="n">rock</span><span class="p">)</span><span class="o">--</span><span class="p">;</span>
<span class="p">}</span>

<span class="n">main</span><span class="p">()</span> <span class="p">{</span>
    <span class="n">char</span><span class="o">*</span> <span class="n">capability_string</span><span class="p">;</span>
    <span class="nb">int</span> <span class="n">nc</span><span class="p">;</span>

    <span class="k">if</span> <span class="p">(</span><span class="n">imclient_connect</span><span class="p">(</span><span class="o">&amp;</span><span class="n">imclient</span><span class="p">,</span> <span class="n">server</span><span class="p">,</span> <span class="n">port</span><span class="p">))</span> <span class="p">{</span>
        <span class="n">fprintf</span><span class="p">(</span><span class="n">stderr</span><span class="p">,</span>
                <span class="s2">&quot;error: Couldn&#39;t connect to </span><span class="si">%s</span><span class="s2"> </span><span class="si">%s</span><span class="s2">\en&quot;</span><span class="p">,</span>
                <span class="n">server</span><span class="p">,</span> <span class="n">port</span><span class="p">);</span>
        <span class="n">exit</span><span class="p">(</span><span class="mi">1</span><span class="p">);</span>
    <span class="p">}</span>

    <span class="k">if</span> <span class="p">(</span><span class="n">imclient_authenticate</span><span class="p">(</span><span class="n">imclient</span><span class="p">,</span> <span class="n">login_sasl_client</span><span class="p">,</span> <span class="s2">&quot;imap&quot;</span>
                              <span class="o">/*</span> <span class="n">service</span> <span class="o">*/</span><span class="p">,</span>
                              <span class="n">NULL</span> <span class="o">/*</span> <span class="n">user</span> <span class="o">*/</span><span class="p">,</span> <span class="n">SASL_PROT_ANY</span><span class="p">))</span> <span class="p">{</span>
        <span class="n">exit</span><span class="p">(</span><span class="mi">1</span><span class="p">);</span>
    <span class="p">}</span>

    <span class="n">imclient_addcallback</span><span class="p">(</span><span class="n">imclient</span><span class="p">,</span> <span class="s2">&quot;CAPABILITY&quot;</span><span class="p">,</span>
                         <span class="n">CALLBACK_NOLITERAL</span><span class="p">,</span>
                         <span class="n">callback_capability</span><span class="p">,</span>
                         <span class="o">&amp;</span><span class="n">capability_string</span><span class="p">,</span>
                         <span class="n">NULL</span><span class="p">);</span>

    <span class="n">nc</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span>

    <span class="n">imclient_send</span><span class="p">(</span><span class="n">imclient</span><span class="p">,</span> <span class="n">end_command</span><span class="p">,</span>
                  <span class="p">(</span><span class="n">void</span><span class="o">*</span><span class="p">)</span> <span class="o">&amp;</span><span class="n">nc</span><span class="p">,</span> <span class="s2">&quot;CAPABILITY&quot;</span><span class="p">);</span>

    <span class="k">while</span><span class="p">(</span><span class="n">nc</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span>
        <span class="n">imclient_processoneevent</span><span class="p">(</span><span class="n">imclient</span><span class="p">);</span>
    <span class="p">}</span>

    <span class="k">if</span> <span class="p">(</span><span class="n">strstr</span><span class="p">(</span><span class="s2">&quot;LITERAL+&quot;</span><span class="p">,</span> <span class="n">capability_string</span><span class="p">))</span> <span class="p">{</span>
        <span class="n">imclient_setflags</span><span class="p">(</span><span class="n">imclient</span><span class="p">,</span> <span class="n">IMCLIENT_CONN_NONSYNCLITERAL</span><span class="p">);</span>
    <span class="p">}</span>

    <span class="n">imclient_send</span><span class="p">(</span><span class="n">imclient</span><span class="p">,</span> <span class="n">NULL</span><span class="p">,</span> <span class="n">NULL</span><span class="p">,</span> <span class="s2">&quot;LOGOUT&quot;</span><span class="p">);</span>
    <span class="n">imclient_close</span><span class="p">(</span><span class="n">imclient</span><span class="p">);</span>

    <span class="n">printf</span><span class="p">(</span><span class="s2">&quot;capability text is: </span><span class="si">%s</span><span class="s2">\en&quot;</span><span class="p">,</span> <span class="n">capability_string</span><span class="p">);</span>

    <span class="n">free</span><span class="p">(</span><span class="n">capability_string</span><span class="p">);</span>
<span class="p">}</span>
</pre></div>
</div>
</div></blockquote>
</section>
<section id="bugs">
<h2>Bugs<a class="headerlink" href="#bugs" title="Permalink to this heading"></a></h2>
<p>No known bugs.</p>
</section>
<section id="see-also">
<h2>See Also<a class="headerlink" href="#see-also" title="Permalink to this heading"></a></h2>
<p><a class="reference internal" href="../../reference/manpages/systemcommands/cyradm.html#std-cyrusman-cyradm-8">cyradm(8)</a>,
<a class="reference internal" href="../../reference/manpages/systemcommands/imapd.html#std-cyrusman-imapd-8">imapd(8)</a>,
<span class="target" id="index-0"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc2033.html"><strong>RFC 2033</strong></a> (IMAP LITERAL+ extension),
<span class="target" id="index-1"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc2060.html"><strong>RFC 2060</strong></a> (IMAP4rev1 specification), and
<em class="manpage">select(2)</em></p>
</section>
<section id="keywords">
<h2>Keywords<a class="headerlink" href="#keywords" title="Permalink to this heading"></a></h2>
<p>IMAP, ACAP, Kerberos, Authentication</p>
</section>
</section>


           </div>
          </div>
          <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
        <a href="../libraries.html" class="btn btn-neutral float-left" title="Developer Libraries" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
        <a href="../releasing.html" class="btn btn-neutral float-right" title="Releasing Cyrus IMAP - normal releases" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
    </div>

  <hr/>

  <div role="contentinfo">
    <p>&#169; Copyright 1993–2025, The Cyrus Team.</p>
  </div>

  Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
    <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
    provided by <a href="https://readthedocs.org">Read the Docs</a>.
   

</footer>
        </div>
      </div>
    </section>
  </div>
  <script>
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>
 



</body>
</html>