ldap/api.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #ifndef LDAP_API_H
00035 #define LDAP_API_H
00036
00037 #include <ldap.h>
00038
00039 #include "../../str.h"
00040 #include "../../sr_module.h"
00041
00042
00043
00044
00045 typedef int (*ldap_params_search_t)(
00046 int* _ld_result_count,
00047 char* _lds_name,
00048 char* _dn,
00049 int _scope,
00050 char** _attrs,
00051 char* _filter,
00052 ...);
00053
00054 typedef int (*ldap_url_search_t)(
00055 char* _ldap_url,
00056 int* _result_count);
00057
00058 typedef int (*ldap_result_attr_vals_t)(
00059 str* _attr_name,
00060 struct berval ***_vals);
00061
00062 typedef void (*ldap_value_free_len_t)(struct berval **_vals);
00063
00064 typedef int (*ldap_result_next_t)(void);
00065
00066 typedef int (*ldap_str2scope_t)(char* scope_str);
00067
00068 typedef int (*get_ldap_handle_t)(char* _lds_name, LDAP** _ldap_handle);
00069
00070 typedef void (*get_last_ldap_result_t)(
00071 LDAP** _last_ldap_handle,
00072 LDAPMessage** _last_ldap_result);
00073
00074 typedef int (*ldap_rfc4515_escape_t)(str *sin, str *sout, int url_encode);
00075
00076
00077
00078
00079
00080 typedef struct ldap_api {
00081 ldap_params_search_t ldap_params_search;
00082 ldap_url_search_t ldap_url_search;
00083 ldap_result_attr_vals_t ldap_result_attr_vals;
00084 ldap_value_free_len_t ldap_value_free_len;
00085 ldap_result_next_t ldap_result_next;
00086 ldap_str2scope_t ldap_str2scope;
00087 ldap_rfc4515_escape_t ldap_rfc4515_escape;
00088 get_ldap_handle_t get_ldap_handle;
00089 get_last_ldap_result_t get_last_ldap_result;
00090 } ldap_api_t;
00091
00092
00093 typedef int (*load_ldap_t)(ldap_api_t *api);
00094
00095 int load_ldap(ldap_api_t *api);
00096
00097 static inline int load_ldap_api(ldap_api_t *api)
00098 {
00099 load_ldap_t load_ldap;
00100
00101 if (!(load_ldap = (load_ldap_t) find_export("load_ldap", 0, 0)))
00102 {
00103 LM_ERR("can't import load_ldap\n");
00104 return -1;
00105 }
00106
00107 if (load_ldap(api) == -1)
00108 {
00109 return -1;
00110 }
00111
00112 return 0;
00113 }
00114
00115 #endif