LCOV - code coverage report
Current view: top level - dirmngr - ldapserver.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 17 0.0 %
Date: 2016-09-12 12:29:17 Functions: 0 3 0.0 %

          Line data    Source code
       1             : /* ldapserver.h
       2             :    Copyright (C) 2008 g10 Code GmbH
       3             : 
       4             :    This file is part of DirMngr.
       5             : 
       6             :    DirMngr is free software; you can redistribute it and/or modify
       7             :    it under the terms of the GNU General Public License as published by
       8             :    the Free Software Foundation; either version 2 of the License, or
       9             :    (at your option) any later version.
      10             : 
      11             :    DirMngr is distributed in the hope that it will be useful,
      12             :    but WITHOUT ANY WARRANTY; without even the implied warranty of
      13             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      14             :    GNU General Public License for more details.
      15             : 
      16             :    You should have received a copy of the GNU General Public License
      17             :    along with this program; if not, see <http://www.gnu.org/licenses/>.  */
      18             : 
      19             : #ifndef LDAPSERVER_H
      20             : #define LDAPSERVER_H
      21             : 
      22             : #include "dirmngr.h"
      23             : 
      24             : /* Release the list of SERVERS.  As usual it is okay to call this
      25             :    function with SERVERS passed as NULL.  */
      26             : void ldapserver_list_free (ldap_server_t servers);
      27             : 
      28             : 
      29             : /* Parse a single LDAP server configuration line.  Returns the server
      30             :    or NULL in case of errors.  The configuration line is assumed to be
      31             :    colon separated with these fields:
      32             : 
      33             :    1. field: Hostname
      34             :    2. field: Portnumber
      35             :    3. field: Username
      36             :    4. field: Password
      37             :    5. field: Base DN
      38             : 
      39             :    FILENAME and LINENO are used for diagnostic purposes only.
      40             : */
      41             : ldap_server_t ldapserver_parse_one (char *line,
      42             :                                     const char *filename, unsigned int lineno);
      43             : 
      44             : 
      45             : /* Iterate over all servers.  */
      46             : 
      47             : struct ldapserver_iter
      48             : {
      49             :   ctrl_t ctrl;
      50             :   enum { LDAPSERVER_SESSION, LDAPSERVER_OPT } group;
      51             :   ldap_server_t server;
      52             : };
      53             : 
      54             : 
      55             : static inline void
      56           0 : ldapserver_iter_next (struct ldapserver_iter *iter)
      57             : {
      58           0 :   if (iter->server)
      59           0 :     iter->server = iter->server->next;
      60             : 
      61           0 :   if (! iter->server)
      62             :     {
      63           0 :       if (iter->group == LDAPSERVER_SESSION)
      64             :         {
      65           0 :           iter->group = LDAPSERVER_OPT;
      66           0 :           iter->server = opt.ldapservers;
      67             :         }
      68             :     }
      69           0 : }
      70             : 
      71             : 
      72             : static inline int
      73           0 : ldapserver_iter_end_p (struct ldapserver_iter *iter)
      74             : {
      75           0 :   return (iter->group == LDAPSERVER_OPT && iter->server == NULL);
      76             : }
      77             : 
      78             : 
      79             : static inline void
      80           0 : ldapserver_iter_begin (struct ldapserver_iter *iter, ctrl_t ctrl)
      81             : {
      82           0 :   iter->ctrl = ctrl;
      83           0 :   iter->group = LDAPSERVER_SESSION;
      84           0 :   iter->server = get_ldapservers_from_ctrl (ctrl);
      85             : 
      86           0 :   while (iter->server == NULL && ! ldapserver_iter_end_p (iter))
      87           0 :     ldapserver_iter_next (iter);
      88           0 : }
      89             : 
      90             : #endif  /* LDAPSERVER_H */

Generated by: LCOV version 1.11