1 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
3 * Copyright 1999-2004 The OpenLDAP Foundation.
4 * Portions Copyright 1999 Dmitry Kovalev.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted only as authorized by the OpenLDAP
11 * A copy of this license is available in the file LICENSE in the
12 * top-level directory of the distribution or, alternatively, at
13 * <http://www.OpenLDAP.org/license.html>.
16 * This work was initially developed by Dmitry Kovalev for inclusion
17 * by OpenLDAP Software.
25 #include <sys/types.h>
26 #include "ac/string.h"
29 #include "proto-sql.h"
31 static backsql_api *backsqlapi;
34 backsql_api_config( backsql_info *si, const char *name )
41 for ( ba = backsqlapi; ba; ba = ba->ba_next ) {
42 if ( strcasecmp( name, ba->ba_name ) == 0 ) {
45 ba2 = ch_malloc( sizeof( backsql_api ) );
47 ba2->ba_next = si->si_api;
57 backsql_api_register( backsql_api *ba )
63 if ( ba->ba_name == NULL ) {
64 fprintf( stderr, "API module has no name\n" );
68 for ( ba2 = backsqlapi; ba2; ba2 = ba2->ba_next ) {
69 if ( strcasecmp( ba->ba_name, ba2->ba_name ) == 0 ) {
70 fprintf( stderr, "API module \"%s\" already defined\n", ba->ba_name );
75 ba->ba_next = backsqlapi;
82 backsql_api_dn2odbc( Operation *op, SlapReply *rs, struct berval *dn )
84 backsql_info *si = (backsql_info *)op->o_bd->be_private;
97 for ( ; ba; ba = ba->ba_next ) {
98 if ( ba->ba_dn2odbc ) {
99 rc = ( *ba->ba_dn2odbc )( op, rs, &bv );
113 backsql_api_odbc2dn( Operation *op, SlapReply *rs, struct berval *dn )
115 backsql_info *si = (backsql_info *)op->o_bd->be_private;
126 ber_dupbv( &bv, dn );
128 for ( ; ba; ba = ba->ba_next ) {
129 if ( ba->ba_dn2odbc ) {
130 rc = ( *ba->ba_odbc2dn )( op, rs, &bv );
143 #endif /* SLAPD_SQL */