2005-10-21 [paul] 1.9.15cvs87
[claws.git] / src / ldapctrl.h
1 /*
2  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 2003-2004 Match Grun
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  */
19
20 /*
21  * Functions for LDAP control data.
22  */
23
24 #ifndef __LDAPCTRL_H__
25 #define __LDAPCTRL_H__
26
27 #ifdef USE_LDAP
28
29 #include <glib.h>
30 #include <stdio.h>
31 #include <pthread.h>
32
33 /*
34  * Constants.
35  */
36 #define LDAPCTL_DFL_PORT        389
37 #define LDAPCTL_MAX_ENTRIES     30
38 #define LDAPCTL_DFL_TIMEOUT     30
39 #define LDAPCTL_DFL_QUERY_AGE   600
40 #define LDAPCTL_MAX_QUERY_AGE   86400
41
42 #define LDAPCTL_ATTR_EMAIL      "mail"
43 #define LDAPCTL_ATTR_COMMONNAME "cn"
44 #define LDAPCTL_ATTR_GIVENNAME  "givenName"
45 #define LDAPCTL_ATTR_SURNAME    "sn"
46
47 #define LDAPCTL_DFL_ATTR_LIST   "mail, cn, givenName, sn"
48
49 /*
50  * Search matching options.
51  */
52 #define LDAPCTL_MATCH_BEGINWITH 0
53 #define LDAPCTL_MATCH_CONTAINS  1
54
55 /*
56  * Data structures.
57  */
58 typedef struct _LdapControl LdapControl;
59 struct _LdapControl {
60         gchar     *hostName;
61         gint      port;
62         gchar     *baseDN;
63         gchar     *bindDN;
64         gchar     *bindPass;
65         gint      maxEntries;
66         gint      timeOut;
67         gint      maxQueryAge;
68         gint      matchingOption;
69         gint      version;
70         gboolean  enableTLS;
71         gchar     *attribEMail;
72         gchar     *attribCName;
73         gchar     *attribFName;
74         gchar     *attribLName;
75         GList     *listCriteria;
76         pthread_mutex_t *mutexCtl;
77 };
78
79 /* Function prototypes */
80 LdapControl *ldapctl_create     ( void );
81 void ldapctl_set_host           ( LdapControl* ctl, const gchar *value );
82 void ldapctl_set_port           ( LdapControl* ctl, const gint value );
83 void ldapctl_set_base_dn        ( LdapControl* ctl, const gchar *value );
84 void ldapctl_set_bind_dn        ( LdapControl* ctl, const gchar *value );
85 void ldapctl_set_bind_password  ( LdapControl* ctl, const gchar *value );
86 void ldapctl_set_max_entries    ( LdapControl* ctl, const gint value );
87 void ldapctl_set_timeout        ( LdapControl* ctl, const gint value );
88 void ldapctl_set_max_query_age  ( LdapControl* ctl, const gint value );
89 void ldapctl_set_matching_option( LdapControl* ctl, const gint value );
90 void ldapctl_set_tls            ( LdapControl* ctl, const gboolean value );
91 void ldapctl_set_criteria_list  ( LdapControl* ctl, GList *value );
92 GList *ldapctl_get_criteria_list( const LdapControl* ctl );
93 void ldapctl_criteria_list_clear( LdapControl *ctl );
94 void ldapctl_criteria_list_add  ( LdapControl *ctl, gchar *attr );
95 void ldapctl_default_attributes ( LdapControl *ctl );
96 void ldapctl_clear              ( LdapControl *ctl );
97 void ldapctl_free               ( LdapControl *ctl );
98 void ldapctl_default_values     ( LdapControl *ctl );
99 void ldapctl_print              ( const LdapControl *ctl, FILE *stream );
100 void ldapctl_copy               ( const LdapControl *ctlFrom,
101                                   LdapControl *ctlTo );
102 gchar *ldapctl_format_criteria  ( LdapControl *ctl, const gchar *searchVal );
103 char **ldapctl_attribute_array  ( LdapControl *ctl );
104 void ldapctl_free_attribute_array( char **ptrArray );
105 void ldapctl_parse_ldap_search  ( LdapControl *ctl, gchar *criteria );
106
107 #endif  /* USE_LDAP */
108
109 #endif /* __LDAPCTRL_H__ */
110