ldap/api.h

Go to the documentation of this file.
00001 /*
00002 * $Id: api.h 5003 2008-09-26 11:01:51Z henningw $
00003 *
00004 * Kamailio LDAP Module
00005 *
00006 * Copyright (C) 2007 University of North Carolina
00007 *
00008 * Original author: Christian Schlatter, cs@unc.edu
00009 *
00010 *
00011 * This file is part of Kamailio, a free SIP server.
00012 *
00013 * Kamailio is free software; you can redistribute it and/or modify
00014 * it under the terms of the GNU General Public License as published by
00015 * the Free Software Foundation; either version 2 of the License, or
00016 * (at your option) any later version
00017 *
00018 * Kamailio is distributed in the hope that it will be useful,
00019 * but WITHOUT ANY WARRANTY; without even the implied warranty of
00020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021 * GNU General Public License for more details.
00022 *
00023 * You should have received a copy of the GNU General Public License
00024 * along with this program; if not, write to the Free Software
00025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00026 *
00027 * History:
00028 * --------
00029 * 2007-02-18: Initial version
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 * LDAP API function types
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 * LDAP module API
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 /* LDAP_API_H */

Generated on Wed May 23 08:00:53 2012 for Kamailio - The Open Source SIP Server by  doxygen 1.5.6