1999-01-14 14:33:09 +08:00
|
|
|
/*
|
|
|
|
* Copyright 1999, John C. Quillan, All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms are permitted only
|
|
|
|
* as authorized by the OpenLDAP Public License. A copy of this
|
|
|
|
* license is available at http://www.OpenLDAP.org/license.html or
|
|
|
|
* in file LICENSE in the top-level directory of the distribution.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "portable.h"
|
|
|
|
/* init.c - initialize shell backend */
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
/* #include <ac/types.h>
|
|
|
|
#include <ac/socket.h>
|
|
|
|
*/
|
|
|
|
|
1999-04-04 12:16:14 +08:00
|
|
|
|
|
|
|
|
1999-01-14 14:33:09 +08:00
|
|
|
#include <EXTERN.h>
|
|
|
|
#include <perl.h>
|
|
|
|
|
|
|
|
#include "slap.h"
|
|
|
|
#include "perl_back.h"
|
|
|
|
|
|
|
|
|
1999-04-04 12:16:14 +08:00
|
|
|
|
1999-01-14 14:33:09 +08:00
|
|
|
PerlInterpreter *perl_interpreter = NULL;
|
1999-01-28 12:34:55 +08:00
|
|
|
ldap_pvt_thread_mutex_t perl_interpreter_mutex;
|
1999-01-14 14:33:09 +08:00
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************
|
|
|
|
*
|
|
|
|
* Init
|
|
|
|
*
|
|
|
|
**********************************************************/
|
|
|
|
|
1999-02-05 17:03:47 +08:00
|
|
|
int
|
|
|
|
perl_back_initialize(
|
|
|
|
BackendInfo *bi
|
1999-01-14 14:33:09 +08:00
|
|
|
)
|
|
|
|
{
|
|
|
|
char *embedding[] = { "", "-e", "0" };
|
|
|
|
|
1999-02-05 17:03:47 +08:00
|
|
|
Debug( LDAP_DEBUG_TRACE, "perl backend open\n", 0, 0, 0 );
|
|
|
|
|
|
|
|
if( perl_interpreter != NULL ) {
|
|
|
|
Debug( LDAP_DEBUG_ANY, "perl backend open: already opened\n",
|
|
|
|
0, 0, 0 );
|
|
|
|
return 1;
|
1999-01-14 14:33:09 +08:00
|
|
|
}
|
1999-02-05 17:03:47 +08:00
|
|
|
|
|
|
|
perl_interpreter = perl_alloc();
|
|
|
|
perl_construct(perl_interpreter);
|
|
|
|
perl_parse(perl_interpreter, NULL, 3, embedding, (char **)NULL);
|
|
|
|
perl_run(perl_interpreter);
|
|
|
|
|
|
|
|
bi->bi_open = perl_back_open;
|
1999-03-04 01:02:10 +08:00
|
|
|
bi->bi_config = 0;
|
1999-02-05 17:03:47 +08:00
|
|
|
bi->bi_close = perl_back_close;
|
|
|
|
bi->bi_destroy = perl_back_destroy;
|
|
|
|
|
|
|
|
bi->bi_db_init = perl_back_db_init;
|
|
|
|
bi->bi_db_config = perl_back_db_config;
|
1999-03-04 01:02:10 +08:00
|
|
|
bi->bi_db_open = 0;
|
|
|
|
bi->bi_db_close = 0;
|
1999-02-05 17:03:47 +08:00
|
|
|
bi->bi_db_destroy = perl_back_db_destroy;
|
|
|
|
|
|
|
|
bi->bi_op_bind = perl_back_bind;
|
|
|
|
bi->bi_op_unbind = perl_back_unbind;
|
|
|
|
bi->bi_op_search = perl_back_search;
|
|
|
|
bi->bi_op_compare = perl_back_compare;
|
|
|
|
bi->bi_op_modify = perl_back_modify;
|
|
|
|
bi->bi_op_modrdn = perl_back_modrdn;
|
|
|
|
bi->bi_op_add = perl_back_add;
|
|
|
|
bi->bi_op_delete = perl_back_delete;
|
1999-03-04 01:02:10 +08:00
|
|
|
bi->bi_op_abandon = 0;
|
1999-02-05 17:03:47 +08:00
|
|
|
|
1999-02-20 16:53:48 +08:00
|
|
|
#ifdef SLAPD_ACLGROUPS
|
1999-03-04 01:02:10 +08:00
|
|
|
bi->bi_acl_group = 0;
|
1999-02-20 16:53:48 +08:00
|
|
|
#endif
|
1999-02-05 17:03:47 +08:00
|
|
|
|
1999-06-23 20:31:35 +08:00
|
|
|
bi->bi_connection_init = 0;
|
|
|
|
bi->bi_connection_destroy = 0;
|
|
|
|
|
1999-02-05 17:03:47 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
perl_back_open(
|
|
|
|
BackendInfo *bi
|
|
|
|
)
|
|
|
|
{
|
|
|
|
ldap_pvt_thread_mutex_init( &perl_interpreter_mutex );
|
|
|
|
return 0;
|
|
|
|
}
|
1999-01-14 14:33:09 +08:00
|
|
|
|
1999-02-05 17:03:47 +08:00
|
|
|
int
|
|
|
|
perl_back_db_init(
|
|
|
|
Backend *be
|
|
|
|
)
|
|
|
|
{
|
1999-01-14 14:33:09 +08:00
|
|
|
be->be_private = (PerlBackend *) ch_malloc( sizeof(PerlBackend) );
|
1999-04-04 12:16:14 +08:00
|
|
|
memset( be->be_private, 0, sizeof(PerlBackend));
|
1999-01-14 14:33:09 +08:00
|
|
|
|
1999-02-05 17:03:47 +08:00
|
|
|
Debug( LDAP_DEBUG_TRACE, "perl backend db init\n", 0, 0, 0 );
|
|
|
|
|
|
|
|
return 0;
|
1999-01-14 14:33:09 +08:00
|
|
|
}
|
|
|
|
|