2007-11-21 12:31:47 +01:00
/*
2006-03-07 20:42:47 +00:00
Unix S M B / C I F S i m p l e m e n t a t i o n .
S w i g interface to l d b .
2006-04-03 09:26:38 +00:00
C o p y r i g h t ( C ) 2005 , 2006 T i m P o t t e r < t p o t @ s a m b a . o r g >
2006-03-07 20:42:47 +00:00
C o p y r i g h t ( C ) 2006 S i m o S o r c e < i d r a @ s a m b a . o r g >
2008-01-25 03:46:47 +01:00
C o p y r i g h t ( C ) 2007 - 2008 J e l m e r V e r n o o i j < j e l m e r @ s a m b a . o r g >
2006-03-07 20:42:47 +00:00
* * N O T E ! T h e f o l l o w i n g L G P L l i c e n s e a p p l i e s to t h e l d b
* * library . T h i s d o e s NOT i m p l y t h a t all of S a m b a is r e l e a s e d
* * u n d e r t h e L G P L
T h i s library is f r e e s o f t w a r e ; y o u c a n r e d i s t r i b u t e i t and / or
m o d i f y i t u n d e r t h e t e r m s of t h e G N U L e s s e r G e n e r a l Public
L i c e n s e as p u b l i s h e d by t h e F r e e S o f t w a r e F o u n d a t i o n ; e i t h e r
2007-07-10 02:46:15 +00:00
version 3 of t h e L i c e n s e , or ( at y o u r option ) any l a t e r version .
2006-03-07 20:42:47 +00:00
T h i s library is d i s t r i b u t e d in t h e h o p e t h a t i t w i l l b e u s e f u l ,
b u t W I T H O U T ANY W A R R A N T Y ; w i t h o u t e v e n t h e i m p l i e d w a r r a n t y of
M E R C H A N T A B I L I T Y or F I T N E S S FOR A P A R T I C U L A R P U R P O S E . S e e t h e G N U
L e s s e r G e n e r a l Public L i c e n s e for m o r e d e t a i l s .
Y o u s h o u l d h a v e r e c e i v e d a c o p y of t h e G N U L e s s e r G e n e r a l Public
2007-07-10 03:42:26 +00:00
L i c e n s e a l o n g with t h i s library ; if not , s e e < h t t p : //www.gnu.org/licenses/>.
2006-03-07 20:42:47 +00:00
* /
2007-12-16 15:50:02 +01:00
% m o d u l e l d b
2006-03-07 20:42:47 +00:00
% {
2007-11-21 12:31:47 +01:00
# i n c l u d e < s t d i n t . h >
2007-10-05 23:04:46 +00:00
# i n c l u d e < s t d b o o l . h >
# i n c l u d e "talloc.h"
# i n c l u d e "ldb.h"
2007-11-21 12:31:47 +01:00
# i n c l u d e "ldb_errors.h"
2007-12-22 14:28:45 -06:00
# i n c l u d e "ldb_private.h"
2007-11-21 12:31:47 +01:00
t y p e def s t r u c t l d b _ m e s s a g e l d b _ m s g ;
t y p e def s t r u c t l d b _ c o n t e x t l d b ;
t y p e def s t r u c t l d b _ d n l d b _ d n ;
t y p e def s t r u c t l d b _ l d i f l d b _ l d i f ;
t y p e def s t r u c t l d b _ m e s s a g e _ e l e m e n t l d b _ m s g _ e l e m e n t ;
t y p e def int l d b _ e r r o r ;
2008-03-04 13:45:31 +11:00
t y p e def int l d b _ i n t _ e r r o r ;
2006-03-07 20:42:47 +00:00
% }
2007-11-21 12:31:47 +01:00
% import "carrays.i"
% import "typemaps.i"
2006-04-03 09:26:38 +00:00
% i n c l u d e "exception.i"
2007-11-21 12:31:47 +01:00
% import "stdint.i"
2006-03-07 20:42:47 +00:00
2008-01-11 02:36:59 +01:00
/* D o n ' t e x p o s e t a l l o c c o n t e x t s i n P y t h o n c o d e . P y t h o n d o e s r e f e r e n c e
c o u n t i n g for u s , s o j u s t create a new t o p - l e v e l t a l l o c context .
* /
% t y p e m a p ( in , n u m i n p u t s = 0 , n o b l o c k = 1 ) T A L L O C _ C T X * {
$ 1 = NULL ;
}
2007-11-21 12:31:47 +01:00
% c o n s t a n t int S C O P E _ D E F A U L T = L D B _ S C O P E _ D E F A U L T ;
% c o n s t a n t int S C O P E _ B A S E = L D B _ S C O P E _ B A S E ;
% c o n s t a n t int S C O P E _ O N E L E V E L = L D B _ S C O P E _ O N E L E V E L ;
% c o n s t a n t int S C O P E _ S U B T R E E = L D B _ S C O P E _ S U B T R E E ;
2006-04-16 03:46:05 +00:00
2007-11-21 12:31:47 +01:00
% c o n s t a n t int C H A N G E T Y P E _ N O N E = L D B _ C H A N G E T Y P E _ N O N E ;
% c o n s t a n t int C H A N G E T Y P E _ A D D = L D B _ C H A N G E T Y P E _ A D D ;
% c o n s t a n t int C H A N G E T Y P E _ D E L E T E = L D B _ C H A N G E T Y P E _ D E L E T E ;
% c o n s t a n t int C H A N G E T Y P E _ M O D I F Y = L D B _ C H A N G E T Y P E _ M O D I F Y ;
2006-04-16 03:46:05 +00:00
2006-04-03 09:26:38 +00:00
/*
* W r a p s t r u c t l d b _ c o n t e x t
* /
/* T h e l d b f u n c t i o n s w i l l c r a s h i f a N U L L l d b c o n t e x t i s p a s s e d s o
catch t h i s b e f o r e i t h a p p e n s . * /
2006-03-07 20:42:47 +00:00
2007-12-23 19:19:41 -06:00
% t y p e m a p ( check , n o b l o c k = 1 ) s t r u c t l d b _ c o n t e x t * {
2006-03-07 20:42:47 +00:00
if ( $ 1 = = NULL )
S W I G _ e x c e p t i o n ( S W I G _ V a l u e E r r o r ,
"ldb context must be non-NULL" ) ;
}
2007-12-23 19:19:41 -06:00
% t y p e m a p ( check , n o b l o c k = 1 ) l d b _ m s g * {
2007-11-21 12:31:47 +01:00
if ( $ 1 = = NULL )
S W I G _ e x c e p t i o n ( S W I G _ V a l u e E r r o r ,
"Message can not be None" ) ;
}
2006-04-03 09:26:38 +00:00
/*
* W r a p s t r u c t l d b _ v a l
* /
2006-04-03 08:03:44 +00:00
2007-12-23 19:19:41 -06:00
% t y p e m a p ( in , n o b l o c k = 1 ) s t r u c t l d b _ v a l * INPUT ( s t r u c t l d b _ v a l t e m p ) {
2006-04-15 10:13:09 +00:00
$ 1 = &temp;
2006-04-03 08:03:44 +00:00
if ( ! P y S t r i n g _ C h e c k ( $ input ) ) {
P y E r r _ S e t S t r i n g ( P y E x c _ T y p e E r r o r , "string arg expected" ) ;
return NULL ;
}
2006-04-15 10:13:09 +00:00
$ 1 - > length = P y S t r i n g _ S i z e ( $ input ) ;
$ 1 - > d a t a = P y S t r i n g _ A s S t r i n g ( $ input ) ;
2006-04-03 08:03:44 +00:00
}
2008-01-25 03:46:47 +01:00
% i n l i n e % {
P y O b j e c t * l d b _ v a l _ t o _ p y _ o b j e c t ( s t r u c t l d b _ c o n t e x t * l d b _ c t x ,
s t r u c t l d b _ m e s s a g e _ e l e m e n t * e l ,
s t r u c t l d b _ v a l * v a l )
{
c o n s t s t r u c t l d b _ s c h e m a _ a t t r i b u t e * a ;
s t r u c t l d b _ v a l n e w _ v a l ;
T A L L O C _ C T X * m e m _ c t x = t a l l o c _ n e w ( NULL ) ;
P y O b j e c t * r e t ;
n e w _ v a l = * v a l ;
if ( l d b _ c t x ! = NULL ) {
a = l d b _ s c h e m a _ a t t r i b u t e _ b y _ n a m e ( l d b _ c t x , e l - > name ) ;
if ( a ! = NULL ) {
if ( a - > s y n t a x - > l d i f _ w r i t e _ f n ( l d b _ c t x , m e m _ c t x , v a l , &new_val) != 0) {
t a l l o c _ f r e e ( m e m _ c t x ) ;
return NULL ;
}
}
}
r e t = P y S t r i n g _ F r o m S t r i n g A n d S i z e ( ( c o n s t char * ) n e w _ v a l . d a t a , n e w _ v a l . length ) ;
t a l l o c _ f r e e ( m e m _ c t x ) ;
return r e t ;
}
% }
% t y p e m a p ( o u t , n o b l o c k = 1 ) s t r u c t l d b _ v a l * {
$ r e s u l t = P y S t r i n g _ F r o m S t r i n g A n d S i z e ( ( c o n s t char * ) $ 1 - > d a t a , $ 1 - > length )
}
2007-12-23 19:19:41 -06:00
% t y p e m a p ( o u t , n o b l o c k = 1 ) s t r u c t l d b _ v a l {
2008-01-25 03:46:47 +01:00
$ r e s u l t = P y S t r i n g _ F r o m S t r i n g A n d S i z e ( ( c o n s t char * ) $ 1 . d a t a , $ 1 . length )
2006-03-07 20:42:47 +00:00
}
2006-04-03 09:26:38 +00:00
/*
2007-11-21 12:31:47 +01:00
* W r a p s t r u c t l d b _ r e s u l t
2006-04-03 09:26:38 +00:00
* /
2007-12-23 19:19:41 -06:00
% t y p e m a p ( in , n o b l o c k = 1 , n u m i n p u t s = 0 ) s t r u c t l d b _ r e s u l t * * O U T ( s t r u c t l d b _ r e s u l t * t e m p _ l d b _ r e s u l t ) {
2007-11-21 12:31:47 +01:00
$ 1 = &temp_ldb_result;
}
2006-04-03 09:26:38 +00:00
2007-11-21 12:31:47 +01:00
# i f def S W I G P Y T H O N
2008-01-02 01:52:26 -06:00
% t y p e m a p ( a r g o u t , n o b l o c k = 1 ) s t r u c t l d b _ r e s u l t * * ( int i ) {
2007-11-21 12:31:47 +01:00
$ r e s u l t = P y L i s t _ N e w ( ( * $ 1 ) - > count ) ;
for ( i = 0 ; i < ( * $ 1 ) - > count ; i + + ) {
P y L i s t _ S e t I t e m ( $ r e s u l t , i ,
S W I G _ N e w P o i n t e r O b j ( ( * $ 1 ) - > m s g s [ i ] , S W I G T Y P E _ p _ l d b _ m e s s a g e , 0 )
) ;
}
}
2006-04-03 08:03:44 +00:00
2008-01-11 02:36:59 +01:00
% t y p e m a p ( in , n o b l o c k = 1 , n u m i n p u t s = 1 ) c o n s t char * c o n s t * N U L L _ S T R _ L I S T {
2007-11-21 12:31:47 +01:00
if ( $ input = = P y _ N o n e ) {
$ 1 = NULL ;
} else if ( P y S e q u e n c e _ C h e c k ( $ input ) ) {
int i ;
$ 1 = t a l l o c _ a r r a y ( NULL , char * , P y S e q u e n c e _ S i z e ( $ input ) + 1 ) ;
for ( i = 0 ; i < P y S e q u e n c e _ S i z e ( $ input ) ; i + + )
$ 1 [ i ] = P y S t r i n g _ A s S t r i n g ( P y S e q u e n c e _ G e t I t e m ( $ input , i ) ) ;
$ 1 [ i ] = NULL ;
} else {
S W I G _ e x c e p t i o n ( S W I G _ T y p e E r r o r , "expected sequence" ) ;
}
}
2006-04-04 01:22:38 +00:00
2008-01-11 02:36:59 +01:00
% t y p e m a p ( f r e e a r g , n o b l o c k = 1 ) c o n s t char * c o n s t * N U L L _ S T R _ L I S T {
2007-11-21 12:31:47 +01:00
t a l l o c _ f r e e ( $ 1 ) ;
}
2008-01-11 02:36:59 +01:00
% apply c o n s t char * c o n s t * N U L L _ S T R _ L I S T { c o n s t c h a r * c o n s t * a t t r s }
% apply c o n s t char * c o n s t * N U L L _ S T R _ L I S T { c o n s t c h a r * c o n s t * c o n t r o l _ s t r i n g s }
2007-11-21 12:31:47 +01:00
# e n d i f
2006-04-04 01:22:38 +00:00
2007-11-21 12:31:47 +01:00
% t y p e s ( s t r u c t l d b _ r e s u l t * ) ;
2006-04-04 01:22:38 +00:00
2006-04-03 09:26:38 +00:00
/*
2007-11-21 12:31:47 +01:00
* W r a p s t r u c t l d b _ d n
2006-04-03 09:26:38 +00:00
* /
2006-03-07 20:42:47 +00:00
2007-11-21 12:31:47 +01:00
% r e n a m e ( _ _ s t r _ _ ) l d b _ d n : : g e t _ l i n e a r i z e d ;
% r e n a m e ( _ _ c m p _ _ ) l d b _ d n : : c o m p a r e ;
% r e n a m e ( _ _ l e n _ _ ) l d b _ d n : : g e t _ c o m p _ n u m ;
% r e n a m e ( D n ) l d b _ d n ;
t y p e def s t r u c t l d b _ d n {
% e x t e n d {
2007-12-23 20:56:41 -06:00
l d b _ d n ( l d b * l d b _ c t x , c o n s t char * s t r )
2007-11-21 12:31:47 +01:00
{
2007-12-23 20:56:41 -06:00
l d b _ d n * r e t = l d b _ d n _ n e w ( l d b _ c t x , l d b _ c t x , s t r ) ;
2007-11-21 12:31:47 +01:00
/* l d b _ d n _ n e w ( ) d o e s n ' t a c c e p t N U L L a s m e m o r y c o n t e x t , s o
w e do i t t h i s w a y . . . * /
t a l l o c _ s t e a l ( NULL , r e t ) ;
if ( r e t = = NULL )
S W I G _ e x c e p t i o n ( S W I G _ V a l u e E r r o r ,
"unable to parse dn string" ) ;
f a i l :
return r e t ;
}
~ l d b _ d n ( ) { t a l l o c _ f r e e ( $ s e l f ) ; }
b o o l validate ( ) ;
c o n s t char * g e t _ c a s e f o l d ( ) ;
c o n s t char * g e t _ l i n e a r i z e d ( ) ;
l d b _ d n * parent ( ) { r e t u r n l d b _ d n _ g e t _ p a r e n t ( N U L L , $ s e l f ) ; }
int c o m p a r e ( l d b _ d n * o t h e r ) ;
b o o l i s _ v a l i d ( ) ;
b o o l i s _ s p e c i a l ( ) ;
b o o l i s _ n u l l ( ) ;
b o o l c h e c k _ s p e c i a l ( c o n s t char * name ) ;
int g e t _ c o m p _ n u m ( ) ;
b o o l a d d _ c h i l d ( l d b _ d n * c h i l d ) ;
b o o l a d d _ b a s e ( l d b _ d n * b a s e ) ;
c o n s t char * c a n o n i c a l _ s t r ( ) {
return l d b _ d n _ c a n o n i c a l _ s t r i n g ( $ self , $ self ) ;
}
c o n s t char * c a n o n i c a l _ e x _ s t r ( ) {
return l d b _ d n _ c a n o n i c a l _ e x _ s t r i n g ( $ self , $ self ) ;
}
# i f def S W I G P Y T H O N
l d b _ d n * _ _ a d d _ _ ( l d b _ d n * o t h e r )
{
l d b _ d n * r e t = l d b _ d n _ c o p y ( NULL , $ self ) ;
l d b _ d n _ a d d _ c h i l d ( r e t , o t h e r ) ;
return r e t ;
}
/* F I X M E : i m p l e m e n t _ _ g e t s l i c e _ _ */
# e n d i f
2008-01-11 04:05:41 +01:00
% p y t h o n c o d e {
def _ _ e q _ _ ( self , o t h e r ) :
if i s i n s t a n c e ( o t h e r , self . _ _ c l a s s _ _ ) :
return self . _ _ c m p _ _ ( o t h e r ) = = 0
if i s i n s t a n c e ( o t h e r , s t r ) :
return s t r ( self ) = = o t h e r
return False
}
2007-11-21 12:31:47 +01:00
}
} l d b _ d n ;
# i f def S W I G P Y T H O N
2007-12-19 23:27:34 +01:00
% {
int l d b _ d n _ f r o m _ p y o b j e c t ( T A L L O C _ C T X * m e m _ c t x , P y O b j e c t * o b j e c t ,
2007-12-23 20:56:41 -06:00
s t r u c t l d b _ c o n t e x t * l d b _ c t x , l d b _ d n * * d n )
2007-11-21 12:31:47 +01:00
{
2007-12-23 19:19:41 -06:00
int r e t ;
s t r u c t l d b _ d n * o d n ;
2007-12-23 20:56:41 -06:00
if ( l d b _ c t x ! = NULL && PyString_Check(object)) {
2008-03-19 11:11:55 +11:00
o d n = l d b _ d n _ n e w ( m e m _ c t x , l d b _ c t x , P y S t r i n g _ A s S t r i n g ( o b j e c t ) ) ;
if ( ! o d n ) {
2008-03-11 14:20:42 +11:00
return S W I G _ E R R O R ;
}
2008-03-19 11:11:55 +11:00
* d n = o d n ;
2007-12-19 23:27:34 +01:00
return 0 ;
}
2007-12-23 19:19:41 -06:00
r e t = S W I G _ C o n v e r t P t r ( o b j e c t , ( void * * ) &odn, SWIGTYPE_p_ldb_dn,
2007-12-19 23:27:34 +01:00
S W I G _ P O I N T E R _ E X C E P T I O N ) ;
2007-12-23 19:19:41 -06:00
* d n = l d b _ d n _ c o p y ( m e m _ c t x , o d n ) ;
2008-03-19 11:11:55 +11:00
if ( o d n && !*dn) {
return S W I G _ E R R O R ;
}
2007-12-23 19:19:41 -06:00
return r e t ;
2007-11-21 12:31:47 +01:00
}
2006-04-17 21:59:44 +00:00
2007-12-30 16:46:14 -06:00
l d b _ m s g _ e l e m e n t * l d b _ m s g _ e l e m e n t _ f r o m _ p y o b j e c t ( T A L L O C _ C T X * m e m _ c t x ,
P y O b j e c t * s e t _ o b j , int f l a g s ,
2007-11-21 12:31:47 +01:00
c o n s t char * a t t r _ n a m e )
{
2007-12-30 16:46:14 -06:00
s t r u c t l d b _ m e s s a g e _ e l e m e n t * m e = t a l l o c ( m e m _ c t x , s t r u c t l d b _ m e s s a g e _ e l e m e n t ) ;
2007-11-21 12:31:47 +01:00
m e - > name = a t t r _ n a m e ;
m e - > f l a g s = f l a g s ;
if ( P y S t r i n g _ C h e c k ( s e t _ o b j ) ) {
m e - > n u m _ v a l u e s = 1 ;
m e - > values = t a l l o c _ a r r a y ( m e , s t r u c t l d b _ v a l , m e - > n u m _ v a l u e s ) ;
m e - > values [ 0 ] . length = P y S t r i n g _ S i z e ( s e t _ o b j ) ;
m e - > values [ 0 ] . d a t a = ( u i n t 8 _ t * ) t a l l o c _ s t r d u p ( m e - > values ,
P y S t r i n g _ A s S t r i n g ( s e t _ o b j ) ) ;
} else if ( P y S e q u e n c e _ C h e c k ( s e t _ o b j ) ) {
int i ;
m e - > n u m _ v a l u e s = P y S e q u e n c e _ S i z e ( s e t _ o b j ) ;
m e - > values = t a l l o c _ a r r a y ( m e , s t r u c t l d b _ v a l , m e - > n u m _ v a l u e s ) ;
for ( i = 0 ; i < m e - > n u m _ v a l u e s ; i + + ) {
P y O b j e c t * o b j = P y S e q u e n c e _ G e t I t e m ( s e t _ o b j , i ) ;
m e - > values [ i ] . length = P y S t r i n g _ S i z e ( o b j ) ;
m e - > values [ i ] . d a t a = ( u i n t 8 _ t * ) P y S t r i n g _ A s S t r i n g ( o b j ) ;
}
} else {
t a l l o c _ f r e e ( m e ) ;
m e = NULL ;
}
return m e ;
}
2006-03-07 20:42:47 +00:00
2008-01-25 03:46:47 +01:00
P y O b j e c t * l d b _ m s g _ e l e m e n t _ t o _ s e t ( s t r u c t l d b _ c o n t e x t * l d b _ c t x ,
l d b _ m s g _ e l e m e n t * m e )
2007-11-21 12:31:47 +01:00
{
int i ;
P y O b j e c t * r e s u l t ;
2006-05-02 05:14:00 +00:00
2007-11-21 12:31:47 +01:00
/* P y t h o n < < 2 . 5 d o e s n ' t h a v e P y S e t _ N e w a n d P y S e t _ A d d . */
r e s u l t = P y L i s t _ N e w ( m e - > n u m _ v a l u e s ) ;
2006-04-04 01:22:38 +00:00
2007-11-21 12:31:47 +01:00
for ( i = 0 ; i < m e - > n u m _ v a l u e s ; i + + ) {
P y L i s t _ S e t I t e m ( r e s u l t , i ,
2008-01-25 03:46:47 +01:00
l d b _ v a l _ t o _ p y _ o b j e c t ( l d b _ c t x , m e , &me->values[i]));
2007-11-21 12:31:47 +01:00
}
2006-05-02 05:14:00 +00:00
2007-11-21 12:31:47 +01:00
return r e s u l t ;
}
2006-03-07 20:42:47 +00:00
2007-12-19 23:27:34 +01:00
% }
2007-11-21 12:31:47 +01:00
# e n d i f
/* l d b _ m e s s a g e _ e l e m e n t */
% r e n a m e ( _ _ c m p _ _ ) l d b _ m e s s a g e _ e l e m e n t : : c o m p a r e ;
% r e n a m e ( M e s s a g e E l e m e n t ) l d b _ m s g _ e l e m e n t ;
t y p e def s t r u c t l d b _ m e s s a g e _ e l e m e n t {
% e x t e n d {
# i f def S W I G P Y T H O N
P y O b j e c t * _ _ i t e r _ _ ( void )
{
2008-01-25 03:46:47 +01:00
return P y O b j e c t _ G e t I t e r ( l d b _ m s g _ e l e m e n t _ t o _ s e t ( NULL , $ self ) ) ;
2007-11-21 12:31:47 +01:00
}
P y O b j e c t * _ _ s e t _ _ ( void )
{
2008-01-25 03:46:47 +01:00
return l d b _ m s g _ e l e m e n t _ t o _ s e t ( NULL , $ self ) ;
2007-11-21 12:31:47 +01:00
}
l d b _ m s g _ e l e m e n t ( P y O b j e c t * s e t _ o b j , int f l a g s = 0 , c o n s t char * name = NULL )
{
2007-12-30 16:46:14 -06:00
return l d b _ m s g _ e l e m e n t _ f r o m _ p y o b j e c t ( NULL , s e t _ o b j , f l a g s , name ) ;
2007-11-21 12:31:47 +01:00
}
2008-01-11 01:02:58 +01:00
int _ _ l e n _ _ ( )
{
return $ s e l f - > n u m _ v a l u e s ;
}
2007-11-21 12:31:47 +01:00
# e n d i f
2008-01-11 00:23:33 +01:00
P y O b j e c t * get ( int i )
{
if ( i < 0 | | i > = $ s e l f - > n u m _ v a l u e s )
return P y _ N o n e ;
2008-01-25 03:46:47 +01:00
return l d b _ v a l _ t o _ p y _ o b j e c t ( NULL , $ self , &$self->values[i]);
2008-01-11 00:23:33 +01:00
}
2007-11-21 12:31:47 +01:00
~ l d b _ m s g _ e l e m e n t ( ) { t a l l o c _ f r e e ( $ s e l f ) ; }
int c o m p a r e ( l d b _ m s g _ e l e m e n t * ) ;
}
2007-12-23 19:19:41 -06:00
% p y t h o n c o d e {
2008-01-11 00:23:33 +01:00
def _ _ g e t i t e m _ _ ( self , i ) :
r e t = self . get ( i )
if r e t is None :
r a i s e K e y E r r o r ( "no such value" )
return r e t
2007-12-23 19:19:41 -06:00
def _ _ e q _ _ ( self , o t h e r ) :
2008-01-11 01:55:56 +01:00
if ( l e n ( self ) = = 1 and self . get ( 0 ) = = o t h e r ) :
2007-12-23 19:19:41 -06:00
return True
2008-01-11 01:55:56 +01:00
if i s i n s t a n c e ( o t h e r , self . _ _ c l a s s _ _ ) :
return self . _ _ c m p _ _ ( o t h e r ) = = 0
o = i t e r ( o t h e r )
for i in r a n g e ( l e n ( self ) ) :
if self . get ( i ) ! = o . next ( ) :
return False
return True
2007-12-23 19:19:41 -06:00
}
2007-11-21 12:31:47 +01:00
} l d b _ m s g _ e l e m e n t ;
/* l d b _ m e s s a g e */
% r e n a m e ( Message ) l d b _ m e s s a g e ;
# i f def S W I G P Y T H O N
% r e n a m e ( _ _ d e l i t e m _ _ ) l d b _ m e s s a g e : : r e m o v e _ a t t r ;
% t y p e m a p ( o u t ) l d b _ m s g _ e l e m e n t * {
if ( $ 1 = = NULL )
P y E r r _ S e t S t r i n g ( P y E x c _ K e y E r r o r , "no such element" ) ;
else
$ r e s u l t = S W I G _ N e w P o i n t e r O b j ( $ 1 , S W I G T Y P E _ p _ l d b _ m e s s a g e _ e l e m e n t , 0 ) ;
}
% r e n a m e ( _ _ g e t i t e m _ _ ) l d b _ m e s s a g e : : f i n d _ e l e m e n t ;
//%typemap(out) ldb_msg_element *;
% i n l i n e {
P y O b j e c t * l d b _ m s g _ l i s t _ e l e m e n t s ( l d b _ m s g * m s g )
{
int i ;
P y O b j e c t * o b j = P y L i s t _ N e w ( m s g - > n u m _ e l e m e n t s ) ;
for ( i = 0 ; i < m s g - > n u m _ e l e m e n t s ; i + + )
P y L i s t _ S e t I t e m ( o b j , i , P y S t r i n g _ F r o m S t r i n g ( m s g - > e l e m e n t s [ i ] . name ) ) ;
return o b j ;
}
}
2006-04-04 01:22:38 +00:00
2007-11-21 12:31:47 +01:00
# e n d i f
t y p e def s t r u c t l d b _ m e s s a g e {
l d b _ d n * d n ;
% e x t e n d {
l d b _ m s g ( l d b _ d n * d n = NULL ) {
l d b _ m s g * r e t = l d b _ m s g _ n e w ( NULL ) ;
r e t - > d n = t a l l o c _ r e f e r e n c e ( r e t , d n ) ;
return r e t ;
}
~ l d b _ m s g ( ) { t a l l o c _ f r e e ( $ s e l f ) ; }
l d b _ m s g _ e l e m e n t * f i n d _ e l e m e n t ( c o n s t char * name ) ;
# i f def S W I G P Y T H O N
void _ _ s e t i t e m _ _ ( c o n s t char * a t t r _ n a m e , l d b _ m s g _ e l e m e n t * v a l )
{
s t r u c t l d b _ m e s s a g e _ e l e m e n t * e l ;
l d b _ m s g _ r e m o v e _ a t t r ( $ self , a t t r _ n a m e ) ;
e l = t a l l o c ( $ self , s t r u c t l d b _ m e s s a g e _ e l e m e n t ) ;
e l - > name = t a l l o c _ s t r d u p ( e l , a t t r _ n a m e ) ;
e l - > n u m _ v a l u e s = v a l - > n u m _ v a l u e s ;
e l - > values = t a l l o c _ r e f e r e n c e ( e l , v a l - > values ) ;
l d b _ m s g _ a d d ( $ self , e l , v a l - > f l a g s ) ;
}
void _ _ s e t i t e m _ _ ( c o n s t char * a t t r _ n a m e , P y O b j e c t * v a l )
{
2007-12-30 16:46:14 -06:00
s t r u c t l d b _ m e s s a g e _ e l e m e n t * e l = l d b _ m s g _ e l e m e n t _ f r o m _ p y o b j e c t ( NULL ,
2007-11-21 12:31:47 +01:00
v a l , 0 , a t t r _ n a m e ) ;
t a l l o c _ s t e a l ( $ self , e l ) ;
l d b _ m s g _ r e m o v e _ a t t r ( $ self , a t t r _ n a m e ) ;
l d b _ m s g _ a d d ( $ self , e l , e l - > f l a g s ) ;
}
u n s i g n e d int _ _ l e n _ _ ( ) { r e t u r n $ s e l f - > n u m _ e l e m e n t s ; }
P y O b j e c t * keys ( void )
{
return l d b _ m s g _ l i s t _ e l e m e n t s ( $ self ) ;
}
P y O b j e c t * _ _ i t e r _ _ ( void )
{
return P y O b j e c t _ G e t I t e r ( l d b _ m s g _ l i s t _ e l e m e n t s ( $ self ) ) ;
}
# e n d i f
void r e m o v e _ a t t r ( c o n s t char * name ) ;
}
} l d b _ m s g ;
/* F I X M E : C o n v e r t l d b _ r e s u l t t o 3 - t u p l e :
( m s g s , r e f s , c o n t r o l s )
* /
2006-04-04 01:22:38 +00:00
2007-11-21 12:31:47 +01:00
t y p e def s t r u c t l d b _ l d i f l d b _ l d i f ;
2006-04-04 01:22:38 +00:00
2007-11-21 12:31:47 +01:00
# i f def S W I G P Y T H O N
% {
2008-03-26 15:18:17 +11:00
static void p y _ l d b _ d e b u g ( void * context , enum l d b _ d e b u g _ l e v e l l e v e l , c o n s t char * f m t , v a _ l i s t a p ) P R I N T F _ A T T R I B U T E ( 3 , 0 ) ;
2007-11-21 12:31:47 +01:00
static void p y _ l d b _ d e b u g ( void * context , enum l d b _ d e b u g _ l e v e l l e v e l , c o n s t char * f m t , v a _ l i s t a p )
{
char * text ;
P y O b j e c t * f n = context ;
v a s p r i n t f ( &text, fmt, ap);
2007-12-23 20:56:41 -06:00
P y O b j e c t _ C a l l F u n c t i o n ( f n , ( char * ) "(i,s)" , l e v e l , text ) ;
2007-11-21 12:31:47 +01:00
f r e e ( text ) ;
}
% }
2006-04-15 10:13:09 +00:00
2008-01-02 01:52:26 -06:00
% t y p e m a p ( in , n u m i n p u t s = 1 , n o b l o c k = 1 ) ( void ( * debug ) ( void * context , enum l d b _ d e b u g _ l e v e l l e v e l , c o n s t char * f m t , v a _ l i s t a p ) , void * context ) {
2007-11-21 12:31:47 +01:00
$ 1 = p y _ l d b _ d e b u g ;
2007-11-25 14:26:16 +01:00
/* F I X M E : S h o u l d b e d e c r e a s e d s o m e w h e r e a s w e l l . P e r h a p s r e g i s t e r a
destructor and t i e i t to t h e l d b context ? * /
2007-11-21 12:31:47 +01:00
P y _ I N C R E F ( $ input ) ;
$ 2 = $ input ;
}
# e n d i f
% i n l i n e {
static P y O b j e c t * l d b _ l d i f _ t o _ p y o b j e c t ( l d b _ l d i f * l d i f )
{
if ( l d i f = = NULL ) {
return P y _ N o n e ;
} else {
2007-12-23 20:56:41 -06:00
return P y _ B u i l d V a l u e ( ( char * ) "(iO)" , l d i f - > c h a n g e t y p e ,
2007-11-21 12:31:47 +01:00
S W I G _ N e w P o i n t e r O b j ( l d i f - > m s g , S W I G T Y P E _ p _ l d b _ m e s s a g e , 0 ) ) ;
}
}
}
2006-05-02 05:14:00 +00:00
2007-11-21 12:31:47 +01:00
/*
* W r a p l d b e r r o r s
* /
2006-05-02 05:14:00 +00:00
2007-11-21 12:31:47 +01:00
% {
P y O b j e c t * P y E x c _ L d b E r r o r ;
% }
2006-05-02 05:14:00 +00:00
2007-11-21 12:31:47 +01:00
% p y t h o n c o d e % {
L d b E r r o r = _ l d b . L d b E r r o r
% }
2006-04-16 06:05:33 +00:00
2007-11-21 12:31:47 +01:00
% init % {
2007-12-23 20:56:41 -06:00
P y E x c _ L d b E r r o r = P y E r r _ N e w E x c e p t i o n ( ( char * ) "_ldb.LdbError" , NULL , NULL ) ;
2007-11-21 12:31:47 +01:00
P y D i c t _ S e t I t e m S t r i n g ( d , "LdbError" , P y E x c _ L d b E r r o r ) ;
% }
2006-05-02 05:14:00 +00:00
2007-11-21 12:31:47 +01:00
% i g n o r e _ L D B _ E R R O R S _ H _ ;
% i g n o r e L D B _ S U C C E S S ;
% i n c l u d e "include/ldb_errors.h"
2006-05-02 05:14:00 +00:00
2007-11-21 12:31:47 +01:00
/*
* W r a p l d b f u n c t i o n s
* /
2006-05-02 05:14:00 +00:00
2007-12-22 14:28:45 -06:00
2007-12-23 19:19:41 -06:00
% t y p e m a p ( o u t , n o b l o c k = 1 ) l d b _ e r r o r {
2008-03-04 13:45:31 +11:00
if ( $ 1 ! = L D B _ S U C C E S S ) {
P y E r r _ S e t O b j e c t ( P y E x c _ L d b E r r o r , P y _ B u i l d V a l u e ( ( char * ) "(i,s)" , $ 1 , l d b _ e r r s t r i n g ( a r g 1 ) ) ) ;
S W I G _ f a i l ;
}
$ r e s u l t = P y _ N o n e ;
} ;
% t y p e m a p ( o u t , n o b l o c k = 1 ) l d b _ i n t _ e r r o r {
2007-12-22 14:28:45 -06:00
if ( $ 1 ! = L D B _ S U C C E S S ) {
2007-12-23 20:56:41 -06:00
P y E r r _ S e t O b j e c t ( P y E x c _ L d b E r r o r , P y _ B u i l d V a l u e ( ( char * ) "(i,s)" , $ 1 , l d b _ s t r e r r o r ( $ 1 ) ) ) ;
2007-12-22 14:28:45 -06:00
S W I G _ f a i l ;
}
$ r e s u l t = P y _ N o n e ;
} ;
2008-01-11 02:36:59 +01:00
% t y p e m a p ( o u t , n o b l o c k = 1 ) s t r u c t l d b _ c o n t r o l * * {
if ( $ 1 = = NULL ) {
P y E r r _ S e t O b j e c t ( P y E x c _ L d b E r r o r , P y _ B u i l d V a l u e ( ( char * ) "(s)" , l d b _ e r r s t r i n g ( a r g 1 ) ) ) ;
S W I G _ f a i l ;
}
$ r e s u l t = S W I G _ N e w P o i n t e r O b j ( $ 1 , $ 1 _ d e s c r i p t o r , 0 ) ;
}
2007-12-17 08:20:20 +01:00
% r e n a m e ( L d b ) l d b _ c o n t e x t ;
2007-12-23 19:19:41 -06:00
% t y p e m a p ( in , n o b l o c k = 1 ) s t r u c t l d b _ d n * {
if ( l d b _ d n _ f r o m _ p y o b j e c t ( NULL , $ input , a r g 1 , &$1) != 0) {
S W I G _ f a i l ;
}
} ;
% t y p e m a p ( f r e e a r g , n o b l o c k = 1 ) s t r u c t l d b _ d n * {
t a l l o c _ f r e e ( $ 1 ) ;
} ;
2008-03-01 13:01:02 +01:00
% t y p e m a p ( in , n u m i n p u t s = 1 ) l d b _ m s g * a d d _ m s g {
2008-03-26 15:18:17 +11:00
P y _ s s i z e _ t d i c t _ p o s , m s g _ p o s ;
2008-03-01 13:01:02 +01:00
l d b _ m s g _ e l e m e n t * m s g e l ;
2008-03-26 15:18:17 +11:00
P y O b j e c t * key , * value ;
2008-03-01 13:01:02 +01:00
if ( P y D i c t _ C h e c k ( $ input ) ) {
2008-03-26 15:18:17 +11:00
P y O b j e c t * d n _ v a l u e = P y D i c t _ G e t I t e m S t r i n g ( $ input , "dn" ) ;
2008-03-01 13:01:02 +01:00
$ 1 = l d b _ m s g _ n e w ( NULL ) ;
$ 1 - > e l e m e n t s = t a l l o c _ z e r o _ a r r a y ( $ 1 , s t r u c t l d b _ m e s s a g e _ e l e m e n t , P y D i c t _ S i z e ( $ input ) ) ;
m s g _ p o s = d i c t _ p o s = 0 ;
2008-03-26 15:18:17 +11:00
if ( d n _ v a l u e ) {
/* u s i n g a r g p 1 ( m a g i c S W I G v a l u e ) h e r e i s a h a c k */
if ( l d b _ d n _ f r o m _ p y o b j e c t ( $ 1 , d n _ v a l u e , a r g p 1 , &$1->dn) != 0) {
2008-03-01 13:01:02 +01:00
S W I G _ e x c e p t i o n ( S W I G _ T y p e E r r o r , "unable to import dn object" ) ;
}
2008-03-26 15:18:17 +11:00
if ( $ 1 - > d n = = NULL ) {
S W I G _ e x c e p t i o n ( S W I G _ T y p e E r r o r , "dn set but not found" ) ;
}
}
while ( P y D i c t _ N e x t ( $ input , &dict_pos, &key, &value)) {
char * k e y _ s t r = P y S t r i n g _ A s S t r i n g ( key ) ;
if ( s t r c m p ( k e y _ s t r , "dn" ) ! = 0 ) {
m s g e l = l d b _ m s g _ e l e m e n t _ f r o m _ p y o b j e c t ( $ 1 - > e l e m e n t s , value , 0 , k e y _ s t r ) ;
2008-03-01 13:01:02 +01:00
if ( m s g e l = = NULL ) {
S W I G _ e x c e p t i o n ( S W I G _ T y p e E r r o r , "unable to import element" ) ;
}
m e m c p y ( &$1->elements[msg_pos], msgel, sizeof(*msgel));
m s g _ p o s + + ;
}
}
if ( $ 1 - > d n = = NULL ) {
S W I G _ e x c e p t i o n ( S W I G _ T y p e E r r o r , "no dn set" ) ;
}
$ 1 - > n u m _ e l e m e n t s = m s g _ p o s ;
} else {
if ( S W I G _ C o n v e r t P t r ( $ input , ( void * * ) &$1, SWIGTYPE_p_ldb_message, 0) != 0) {
S W I G _ e x c e p t i o n ( S W I G _ T y p e E r r o r , "unable to convert ldb message" ) ;
}
}
}
2007-11-21 12:31:47 +01:00
/* T o p - l e v e l l d b o p e r a t i o n s */
t y p e def s t r u c t l d b _ c o n t e x t {
% e x t e n d {
2007-12-24 11:02:45 -06:00
l d b ( void ) { r e t u r n l d b _ i n i t ( N U L L ) ; }
2007-11-21 12:31:47 +01:00
l d b _ e r r o r connect ( c o n s t char * url , u n s i g n e d int f l a g s = 0 ,
c o n s t char * o p t i o n s [ ] = NULL ) ;
~ l d b ( ) { t a l l o c _ f r e e ( $ s e l f ) ; }
2008-01-11 03:25:22 +01:00
l d b _ e r r o r s e a r c h _ e x ( T A L L O C _ C T X * m e m _ c t x ,
l d b _ d n * b a s e = NULL ,
2007-11-21 12:31:47 +01:00
enum l d b _ s c o p e s c o p e = L D B _ S C O P E _ D E F A U L T ,
c o n s t char * e x p r e s s i o n = NULL ,
2008-01-11 03:25:22 +01:00
c o n s t char * c o n s t * a t t r s = NULL ,
s t r u c t l d b _ c o n t r o l * * c o n t r o l s = NULL ,
s t r u c t l d b _ r e s u l t * * O U T ) {
int r e t ;
s t r u c t l d b _ r e s u l t * r e s ;
s t r u c t l d b _ r e q u e s t * r e q ;
r e s = t a l l o c _ z e r o ( m e m _ c t x , s t r u c t l d b _ r e s u l t ) ;
if ( ! r e s ) {
return L D B _ E R R _ O P E R A T I O N S _ E R R O R ;
}
r e t = l d b _ b u i l d _ s e a r c h _ r e q ( &req, $self, mem_ctx,
b a s e ? b a s e : l d b _ g e t _ d e f a u l t _ b a s e d n ( $ self ) ,
s c o p e ,
e x p r e s s i o n ,
a t t r s ,
c o n t r o l s ,
r e s ,
l d b _ s e a r c h _ d e f a u l t _ c a l l b a c k ) ;
if ( r e t ! = L D B _ S U C C E S S ) {
t a l l o c _ f r e e ( r e s ) ;
return r e t ;
}
l d b _ s e t _ t i m e o u t ( $ self , r e q , 0 ) ; /* u s e d e f a u l t t i m e o u t */
r e t = l d b _ r e q u e s t ( $ self , r e q ) ;
if ( r e t = = L D B _ S U C C E S S ) {
r e t = l d b _ w a i t ( r e q - > handle , L D B _ W A I T _ A L L ) ;
}
t a l l o c _ f r e e ( r e q ) ;
* O U T = r e s ;
return r e t ;
}
2007-11-21 12:31:47 +01:00
l d b _ e r r o r delete ( l d b _ d n * d n ) ;
l d b _ e r r o r r e n a m e ( l d b _ d n * o l d d n , l d b _ d n * n e w d n ) ;
2008-01-11 02:36:59 +01:00
s t r u c t l d b _ c o n t r o l * * p a r s e _ c o n t r o l _ s t r i n g s ( T A L L O C _ C T X * m e m _ c t x ,
c o n s t char * c o n s t * c o n t r o l _ s t r i n g s ) ;
2007-11-21 12:31:47 +01:00
l d b _ e r r o r add ( l d b _ m s g * a d d _ m s g ) ;
l d b _ e r r o r m o d i f y ( l d b _ m s g * message ) ;
l d b _ d n * g e t _ c o n f i g _ b a s e d n ( ) ;
l d b _ d n * g e t _ r o o t _ b a s e d n ( ) ;
l d b _ d n * g e t _ s c h e m a _ b a s e d n ( ) ;
l d b _ d n * g e t _ d e f a u l t _ b a s e d n ( ) ;
2008-01-25 03:46:47 +01:00
P y O b j e c t * s c h e m a _ f o r m a t _ v a l u e ( c o n s t char * e l e m e n t _ n a m e , P y O b j e c t * v a l )
{
c o n s t s t r u c t l d b _ s c h e m a _ a t t r i b u t e * a ;
s t r u c t l d b _ v a l o l d _ v a l ;
s t r u c t l d b _ v a l n e w _ v a l ;
T A L L O C _ C T X * m e m _ c t x = t a l l o c _ n e w ( NULL ) ;
P y O b j e c t * r e t ;
o l d _ v a l . d a t a = P y S t r i n g _ A s S t r i n g ( v a l ) ;
o l d _ v a l . length = P y S t r i n g _ S i z e ( v a l ) ;
a = l d b _ s c h e m a _ a t t r i b u t e _ b y _ n a m e ( $ self , e l e m e n t _ n a m e ) ;
if ( a = = NULL ) {
return P y _ N o n e ;
}
if ( a - > s y n t a x - > l d i f _ w r i t e _ f n ( $ self , m e m _ c t x , &old_val, &new_val) != 0) {
t a l l o c _ f r e e ( m e m _ c t x ) ;
return P y _ N o n e ;
}
r e t = P y S t r i n g _ F r o m S t r i n g A n d S i z e ( ( c o n s t char * ) n e w _ v a l . d a t a , n e w _ v a l . length ) ;
t a l l o c _ f r e e ( m e m _ c t x ) ;
return r e t ;
}
2007-11-21 12:31:47 +01:00
c o n s t char * e r r s t r i n g ( ) ;
void s e t _ c r e a t e _ p e r m s ( u n s i g n e d int p e r m s ) ;
void s e t _ m o d u l e s _ d i r ( c o n s t char * p a t h ) ;
l d b _ e r r o r s e t _ d e b u g ( void ( * debug ) ( void * context , enum l d b _ d e b u g _ l e v e l l e v e l ,
c o n s t char * f m t , v a _ l i s t a p ) ,
void * context ) ;
l d b _ e r r o r s e t _ o p a q u e ( c o n s t char * name , void * value ) ;
void * g e t _ o p a q u e ( c o n s t char * name ) ;
l d b _ e r r o r t r a n s a c t i o n _ s t a r t ( ) ;
l d b _ e r r o r t r a n s a c t i o n _ c o m m i t ( ) ;
l d b _ e r r o r t r a n s a c t i o n _ c a n c e l ( ) ;
2008-01-25 03:46:47 +01:00
void s c h e m a _ a t t r i b u t e _ r e m o v e ( c o n s t char * name ) ;
l d b _ e r r o r s c h e m a _ a t t r i b u t e _ a d d ( c o n s t char * a t t r i b u t e , u n s i g n e d f l a g s , c o n s t char * s y n t a x ) ;
l d b _ e r r o r s e t u p _ w e l l k n o w n _ a t t r i b u t e s ( void ) ;
2007-11-21 12:31:47 +01:00
# i f def S W I G P Y T H O N
2008-01-02 01:52:26 -06:00
% t y p e m a p ( in , n u m i n p u t s = 0 , n o b l o c k = 1 ) s t r u c t l d b _ r e s u l t * * r e s u l t _ a s _ b o o l ( s t r u c t l d b _ r e s u l t * t m p ) { $ 1 = & t m p ; }
% t y p e m a p ( a r g o u t , n o b l o c k = 1 ) s t r u c t l d b _ r e s u l t * * r e s u l t _ a s _ b o o l { $ r e s u l t = ( ( * $ 1 ) - > c o u n t > 0 ) ? P y _ T r u e : P y _ F a l s e ; }
% t y p e m a p ( f r e e a r g , n o b l o c k = 1 ) s t r u c t l d b _ r e s u l t * * r e s u l t _ a s _ b o o l { t a l l o c _ f r e e ( * $ 1 ) ; }
2007-11-25 14:26:16 +01:00
l d b _ e r r o r _ _ c o n t a i n s _ _ ( l d b _ d n * d n , s t r u c t l d b _ r e s u l t * * r e s u l t _ a s _ b o o l )
2007-11-21 12:31:47 +01:00
{
2007-11-25 14:26:16 +01:00
return l d b _ s e a r c h ( $ self , d n , L D B _ S C O P E _ B A S E , NULL , NULL ,
r e s u l t _ a s _ b o o l ) ;
2007-11-21 12:31:47 +01:00
}
P y O b j e c t * p a r s e _ l d i f ( c o n s t char * s )
{
P y O b j e c t * l i s t = P y L i s t _ N e w ( 0 ) ;
s t r u c t l d b _ l d i f * l d i f ;
while ( ( l d i f = l d b _ l d i f _ r e a d _ s t r i n g ( $ self , &s)) != NULL) {
P y L i s t _ A p p e n d ( l i s t , l d b _ l d i f _ t o _ p y o b j e c t ( l d i f ) ) ;
}
return P y O b j e c t _ G e t I t e r ( l i s t ) ;
}
# e n d i f
}
2007-12-24 11:02:45 -06:00
% p y t h o n c o d e {
def _ _ i n i t _ _ ( self , url = None , f l a g s = 0 , o p t i o n s = None ) :
_ l d b . L d b _ s w i g i n i t ( self , _ l d b . n e w _ L d b ( ) )
if url is not None :
self . connect ( url , f l a g s , o p t i o n s )
2008-01-11 03:25:22 +01:00
def search ( self , b a s e = None , s c o p e = S C O P E _ D E F A U L T , e x p r e s s i o n = None ,
a t t r s = None , c o n t r o l s = None ) :
p a r s e d _ c o n t r o l s = None
if c o n t r o l s is not None :
p a r s e d _ c o n t r o l s = self . p a r s e _ c o n t r o l _ s t r i n g s ( c o n t r o l s )
return self . s e a r c h _ e x ( b a s e , s c o p e , e x p r e s s i o n , a t t r s ,
p a r s e d _ c o n t r o l s )
2007-12-24 11:02:45 -06:00
}
2007-11-21 12:31:47 +01:00
} l d b ;
2007-12-23 19:19:41 -06:00
% t y p e m a p ( in , n o b l o c k = 1 ) s t r u c t l d b _ d n * ;
% t y p e m a p ( f r e e a r g , n o b l o c k = 1 ) s t r u c t l d b _ d n * ;
2007-11-21 12:31:47 +01:00
% n o d e f a u l t l d b _ m e s s a g e ;
2007-12-17 08:20:20 +01:00
% n o d e f a u l t l d b _ c o n t e x t ;
2007-11-21 12:31:47 +01:00
% n o d e f a u l t D n ;
% r e n a m e ( v a l i d _ a t t r _ n a m e ) l d b _ v a l i d _ a t t r _ n a m e ;
int l d b _ v a l i d _ a t t r _ n a m e ( c o n s t char * s ) ;
t y p e def u n s i g n e d l o n g t i m e _ t ;
2006-05-02 05:14:00 +00:00
2007-11-21 13:07:16 +01:00
% i n l i n e % {
static char * t i m e s t r i n g ( t i m e _ t t )
2007-11-21 12:31:47 +01:00
{
char * t r e s u l t = l d b _ t i m e s t r i n g ( NULL , t ) ;
char * r e s u l t = s t r d u p ( t r e s u l t ) ;
t a l l o c _ f r e e ( t r e s u l t ) ;
return r e s u l t ;
}
% }
2007-10-05 23:04:46 +00:00
2007-11-21 12:31:47 +01:00
% r e n a m e ( s t r i n g _ t o _ t i m e ) l d b _ s t r i n g _ t o _ t i m e ;
t i m e _ t l d b _ s t r i n g _ t o _ t i m e ( c o n s t char * s ) ;
2007-12-22 14:28:45 -06:00
2008-01-02 01:52:26 -06:00
% t y p e m a p ( in , n o b l o c k = 1 ) c o n s t s t r u c t l d b _ m o d u l e _ o p s * {
2007-12-22 14:28:45 -06:00
$ 1 = t a l l o c _ z e r o ( t a l l o c _ a u t o f r e e _ c o n t e x t ( ) , s t r u c t l d b _ m o d u l e _ o p s ) ;
2007-12-23 20:56:41 -06:00
$ 1 - > name = ( char * ) P y O b j e c t _ G e t A t t r S t r i n g ( $ input , ( char * ) "name" ) ;
2007-12-22 14:28:45 -06:00
}
% r e n a m e ( r e g i s t e r _ m o d u l e ) l d b _ r e g i s t e r _ m o d u l e ;
2008-03-04 13:45:31 +11:00
l d b _ i n t _ e r r o r l d b _ r e g i s t e r _ m o d u l e ( c o n s t s t r u c t l d b _ m o d u l e _ o p s * ) ;