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.
23 #include <sys/types.h>
24 #include "ac/string.h"
27 #include "proto-sql.h"
29 static backsql_api *backsqlapi;
32 backsql_api_config( backsql_info *bi, const char *name )
39 for ( ba = backsqlapi; ba; ba = ba->ba_next ) {
40 if ( strcasecmp( name, ba->ba_name ) == 0 ) {
43 ba2 = ch_malloc( sizeof( backsql_api ) );
45 ba2->ba_next = bi->sql_api;
55 backsql_api_register( backsql_api *ba )
61 if ( ba->ba_name == NULL ) {
62 fprintf( stderr, "API module has no name\n" );
66 for ( ba2 = backsqlapi; ba2; ba2 = ba2->ba_next ) {
67 if ( strcasecmp( ba->ba_name, ba2->ba_name ) == 0 ) {
68 fprintf( stderr, "API module \"%s\" already defined\n", ba->ba_name );
73 ba->ba_next = backsqlapi;
80 backsql_api_dn2odbc( Operation *op, SlapReply *rs, struct berval *dn )
82 backsql_info *bi = (backsql_info *)op->o_bd->be_private;
95 for ( ; ba; ba = ba->ba_next ) {
96 if ( ba->ba_dn2odbc ) {
97 rc = ( *ba->ba_dn2odbc )( op, rs, &bv );
111 backsql_api_odbc2dn( Operation *op, SlapReply *rs, struct berval *dn )
113 backsql_info *bi = (backsql_info *)op->o_bd->be_private;
124 ber_dupbv( &bv, dn );
126 for ( ; ba; ba = ba->ba_next ) {
127 if ( ba->ba_dn2odbc ) {
128 rc = ( *ba->ba_odbc2dn )( op, rs, &bv );