fix bug 4773, 'remove obsolescent AC_C_CONST'
[claws.git] / src / ldapctrl.h
blob39841b41d28bf6b10e59b50d88238434005c8ed0
1 /*
2 * Claws Mail -- a GTK based, lightweight, and fast e-mail client
3 * Copyright (C) 2003-2022 Match Grun and the Claws Mail team
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 3 of the License, or
8 * (at your option) any later version.
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.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * Functions for LDAP control data.
23 #ifndef __LDAPCTRL_H__
24 #define __LDAPCTRL_H__
26 #ifdef USE_LDAP
28 #include <glib.h>
29 #include <stdio.h>
30 #include <pthread.h>
33 * Constants.
35 #define LDAPCTL_DFL_PORT 389
36 #define LDAPCTL_DFL_SSL_PORT 636
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
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 #define LDAPCTL_ATTR_PHONE "telephoneNumber"
47 #define LDAPCTL_ATTR_DISPLAYNAME "displayName"
49 #define LDAPCTL_DFL_ATTR_LIST "mail, cn, givenName, sn, displayName"
52 * Search matching options.
54 #define LDAPCTL_MATCH_BEGINWITH 0
55 #define LDAPCTL_MATCH_CONTAINS 1
58 * Data structures.
60 typedef struct _LdapControl LdapControl;
61 struct _LdapControl {
62 gchar *hostName;
63 gint port;
64 gchar *baseDN;
65 gchar *bindDN;
66 gint maxEntries;
67 gint timeOut;
68 gint maxQueryAge;
69 gint matchingOption;
70 gint version;
71 gboolean enableTLS;
72 gboolean enableSSL;
73 gchar *attribEMail;
74 gchar *attribCName;
75 gchar *attribFName;
76 gchar *attribLName;
77 gchar *attribDName;
78 GList *listCriteria;
79 pthread_mutex_t *mutexCtl;
82 /* Function prototypes */
83 LdapControl *ldapctl_create ( void );
84 void ldapctl_set_host ( LdapControl* ctl, const gchar *value );
85 void ldapctl_set_port ( LdapControl* ctl, const gint value );
86 void ldapctl_set_base_dn ( LdapControl* ctl, const gchar *value );
87 void ldapctl_set_bind_dn ( LdapControl* ctl, const gchar *value );
88 void ldapctl_set_bind_password
89 ( LdapControl* ctl, const gchar *value, gboolean encrypt, gboolean change );
90 gchar* ldapctl_get_bind_password ( LdapControl* ctl );
91 void ldapctl_set_max_entries ( LdapControl* ctl, const gint value );
92 void ldapctl_set_timeout ( LdapControl* ctl, const gint value );
93 void ldapctl_set_max_query_age ( LdapControl* ctl, const gint value );
94 void ldapctl_set_matching_option( LdapControl* ctl, const gint value );
95 void ldapctl_set_tls ( LdapControl* ctl, const gboolean value );
96 void ldapctl_set_ssl ( LdapControl* ctl, const gboolean value );
97 GList *ldapctl_get_criteria_list( const LdapControl* ctl );
98 void ldapctl_criteria_list_clear( LdapControl *ctl );
99 void ldapctl_criteria_list_add ( LdapControl *ctl, gchar *attr );
100 void ldapctl_free ( LdapControl *ctl );
101 #ifdef DEBUG_LDAP
102 void ldapctl_print ( const LdapControl *ctl, FILE *stream );
103 #endif
104 void ldapctl_copy ( const LdapControl *ctlFrom,
105 LdapControl *ctlTo );
106 gchar *ldapctl_format_criteria ( LdapControl *ctl, const gchar *searchVal );
107 char **ldapctl_attribute_array ( LdapControl *ctl );
108 char **ldapctl_full_attribute_array( LdapControl *ctl );
109 void ldapctl_free_attribute_array( char **ptrArray );
110 void ldapctl_parse_ldap_search ( LdapControl *ctl, gchar *criteria );
111 gchar *ldapctl_get_default_criteria(void);
112 GList *ldapctl_get_default_criteria_list();
113 gboolean ldapctl_compare_list(GList *l1, GList *l2);
115 #endif /* USE_LDAP */
117 #endif /* __LDAPCTRL_H__ */