2006-03-07 23:42:47 +03: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 13:26:38 +04: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 23:42:47 +03: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 >
* * 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
version 2 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 .
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
L i c e n s e a l o n g with t h i s library ; if not , write to 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 , I n c . , 59 T e m p l e P l a c e , S u i t e 330 , B o s t o n , M A 02111 - 1307 U S A
* /
% m o d u l e l d b
% {
2006-04-03 13:26:38 +04:00
/* S o m e t y p e d e f s t o h e l p s w i g a l o n g */
2006-03-07 23:42:47 +03:00
t y p e def u n s i g n e d char u i n t 8 _ t ;
t y p e def u n s i g n e d l o n g l o n g u i n t 64 _ t ;
t y p e def l o n g l o n g i n t 64 _ t ;
2006-04-03 13:26:38 +04:00
/* I n c l u d e h e a d e r s */
2006-03-07 23:42:47 +03:00
# i n c l u d e "lib/ldb/include/ldb.h"
2006-04-03 12:03:44 +04:00
# i n c l u d e "lib/talloc/talloc.h"
2006-03-07 23:42:47 +03:00
% }
2006-04-03 13:26:38 +04:00
% i n c l u d e "carrays.i"
% i n c l u d e "exception.i"
2006-03-07 23:42:47 +03:00
2006-04-16 07:46:05 +04:00
/*
* C o n s t a n t s
* /
2006-04-16 10:05:33 +04:00
# define L D B _ S U C C E S S 0
# define L D B _ E R R _ O P E R A T I O N S _ E R R O R 1
# define L D B _ E R R _ P R O T O C O L _ E R R O R 2
# define L D B _ E R R _ T I M E _ L I M I T _ E X C E E D E D 3
# define L D B _ E R R _ S I Z E _ L I M I T _ E X C E E D E D 4
# define L D B _ E R R _ C O M P A R E _ F A L S E 5
# define L D B _ E R R _ C O M P A R E _ T R U E 6
# define L D B _ E R R _ A U T H _ M E T H O D _ N O T _ S U P P O R T E D 7
# define L D B _ E R R _ S T R O N G _ A U T H _ R E Q U I R E D 8
/* 9 R E S E R V E D */
# define L D B _ E R R _ R E F E R R A L 10
# define L D B _ E R R _ A D M I N _ L I M I T _ E X C E E D E D 11
# define L D B _ E R R _ U N S U P P O R T E D _ C R I T I C A L _ E X T E N S I O N 12
# define L D B _ E R R _ C O N F I D E N T I A L I T Y _ R E Q U I R E D 13
# define L D B _ E R R _ S A S L _ B I N D _ I N _ P R O G R E S S 14
# define L D B _ E R R _ N O _ S U C H _ A T T R I B U T E 16
# define L D B _ E R R _ U N D E F I N E D _ A T T R I B U T E _ T Y P E 17
# define L D B _ E R R _ I N A P P R O P R I A T E _ M A T C H I N G 18
# define L D B _ E R R _ C O N S T R A I N T _ V I O L A T I O N 19
# define L D B _ E R R _ A T T R I B U T E _ O R _ V A L U E _ E X I S T S 20
# define L D B _ E R R _ I N V A L I D _ A T T R I B U T E _ S Y N T A X 21
/* 2 2 - 3 1 u n u s e d */
# define L D B _ E R R _ N O _ S U C H _ O B J E C T 32
# define L D B _ E R R _ A L I A S _ P R O B L E M 33
# define L D B _ E R R _ I N V A L I D _ D N _ S Y N T A X 34
/* 3 5 R E S E R V E D */
# define L D B _ E R R _ A L I A S _ D E R E F E R E N C I N G _ P R O B L E M 36
/* 3 7 - 4 7 u n u s e d */
# define L D B _ E R R _ I N A P P R O P R I A T E _ A U T H E N T I C A T I O N 48
# define L D B _ E R R _ I N V A L I D _ C R E D E N T I A L S 49
# define L D B _ E R R _ I N S U F F I C I E N T _ A C C E S S _ R I G H T S 50
# define L D B _ E R R _ B U S Y 51
# define L D B _ E R R _ U N A V A I L A B L E 52
# define L D B _ E R R _ U N W I L L I N G _ T O _ P E R F O R M 53
# define L D B _ E R R _ L O O P _ D E T E C T 54
/* 5 5 - 6 3 u n u s e d */
# define L D B _ E R R _ N A M I N G _ V I O L A T I O N 64
# define L D B _ E R R _ O B J E C T _ C L A S S _ V I O L A T I O N 65
# define L D B _ E R R _ N O T _ A L L O W E D _ O N _ N O N _ L E A F 66
# define L D B _ E R R _ N O T _ A L L O W E D _ O N _ R D N 67
# define L D B _ E R R _ E N T R Y _ A L R E A D Y _ E X I S T S 68
# define L D B _ E R R _ O B J E C T _ C L A S S _ M O D S _ P R O H I B I T E D 69
/* 7 0 R E S E R V E D F O R C L D A P */
# define L D B _ E R R _ A F F E C T S _ M U L T I P L E _ D S A S 71
/* 7 2 - 7 9 u n u s e d */
# define L D B _ E R R _ O T H E R 80
2006-04-16 07:46:05 +04:00
enum l d b _ s c o p e { L D B _ S C O P E _ D E F A U L T = - 1 ,
L D B _ S C O P E _ B A S E = 0 ,
L D B _ S C O P E _ O N E L E V E L = 1 ,
L D B _ S C O P E _ S U B T R E E = 2 } ;
2006-04-03 13:26:38 +04: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 23:42:47 +03:00
% t y p e m a p ( check ) s t r u c t l d b _ c o n t e x t * {
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" ) ;
}
2006-04-03 13:26:38 +04:00
/*
2006-04-30 05:07:16 +04:00
* W r a p a s m a l l b i t of t a l l o c
2006-04-03 13:26:38 +04:00
* /
2006-04-03 12:03:44 +04:00
/* U s e t a l l o c _ i n i t ( ) t o c r e a t e a p a r a m e t e r t o p a s s t o l d b _ i n i t ( ) . D o n ' t
f o r g e t to f r e e i t using t a l l o c _ f r e e ( ) a f t e r w a r d s . * /
2006-03-07 23:42:47 +03:00
2006-04-03 12:03:44 +04:00
T A L L O C _ C T X * t a l l o c _ i n i t ( char * name ) ;
int t a l l o c _ f r e e ( T A L L O C _ C T X * p t r ) ;
2006-04-03 13:26:38 +04:00
/*
* W r a p s t r u c t l d b _ v a l
* /
2006-04-03 12:03:44 +04:00
2006-04-16 07:46:05 +04:00
% t y p e m a p ( in ) 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 14:13:09 +04:00
$ 1 = &temp;
2006-04-03 12:03:44 +04: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 14:13:09 +04: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 12:03:44 +04:00
}
2006-04-16 07:46:05 +04:00
% t y p e m a p ( o u t ) 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 ( $ 1 . d a t a , $ 1 . length ) ;
2006-03-07 23:42:47 +03:00
}
2006-04-03 13:26:38 +04:00
/*
* W r a p s t r u c t l d b _ r e s u l t
* /
2006-04-03 12:03:44 +04:00
% t y p e m a p ( in , 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 ) {
$ 1 = &temp_ldb_result;
}
% t y p e m a p ( a r g o u t ) s t r u c t l d b _ r e s u l t * * {
2006-04-04 05:22:38 +04:00
r e s u l t o b j = 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 _ r e s u l t , 0 ) ;
2006-04-03 12:03:44 +04:00
}
% t y p e s ( s t r u c t l d b _ r e s u l t * ) ;
2006-04-03 13:26:38 +04:00
/*
* W r a p s t r u c t l d b _ m e s s a g e _ e l e m e n t
* /
% a r r a y _ f u n c t i o n s ( s t r u c t l d b _ v a l , l d b _ v a l _ a r r a y ) ;
2006-04-03 12:25:03 +04:00
s t r u c t l d b _ m e s s a g e _ e l e m e n t {
u n s i g n e d int f l a g s ;
c o n s t char * name ;
u n s i g n e d int n u m _ v a l u e s ;
s t r u c t l d b _ v a l * values ;
} ;
2006-04-03 13:26:38 +04:00
/*
* W r a p s t r u c t l d b _ m e s s a g e
* /
% a r r a y _ f u n c t i o n s ( 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 e s s a g e _ e l e m e n t _ a r r a y ) ;
2006-04-03 12:03:44 +04:00
s t r u c t l d b _ m e s s a g e {
s t r u c t l d b _ d n * d n ;
u n s i g n e d int n u m _ e l e m e n t s ;
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 e m e n t s ;
2006-04-15 14:13:09 +04:00
void * p r i v a t e _ d a t a ;
2006-04-03 12:03:44 +04:00
} ;
2006-04-04 05:22:38 +04:00
/*
* W r a p s t r u c t l d b _ r e s u l t
* /
% a r r a y _ f u n c t i o n s ( s t r u c t l d b _ m e s s a g e * , l d b _ m e s s a g e _ p t r _ a r r a y ) ;
s t r u c t l d b _ r e s u l t {
u n s i g n e d int count ;
s t r u c t l d b _ m e s s a g e * * m s g s ;
char * * r e f s ;
s t r u c t l d b _ c o n t r o l * * c o n t r o l s ;
} ;
2006-04-03 13:26:38 +04:00
/*
* W r a p l d b f u n c t i o n s
* /
2006-03-07 23:42:47 +03:00
2006-05-02 09:14:00 +04:00
/* I n i t i a l i s a t i o n */
2006-04-18 01:59:44 +04:00
2006-05-02 09:14:00 +04:00
int l d b _ g l o b a l _ i n i t ( void ) ;
2006-04-03 12:03:44 +04:00
s t r u c t l d b _ c o n t e x t * l d b _ i n i t ( T A L L O C _ C T X * m e m _ c t x ) ;
2006-03-07 23:42:47 +03:00
2006-05-02 09:14:00 +04:00
/* E r r o r h a n d l i n g */
2006-04-04 05:22:38 +04:00
c o n s t char * l d b _ e r r s t r i n g ( s t r u c t l d b _ c o n t e x t * l d b ) ;
2006-04-23 19:29:25 +04:00
c o n s t char * l d b _ s t r e r r o r ( int l d b _ e r r ) ;
2006-04-04 05:22:38 +04:00
2006-05-02 09:14:00 +04:00
/* T o p - l e v e l l d b o p e r a t i o n s */
2006-03-07 23:42:47 +03:00
int l d b _ c o n n e c t ( s t r u c t l d b _ c o n t e x t * l d b , c o n s t char * url , u n s i g n e d int f l a g s , c o n s t char * o p t i o n s [ ] ) ;
2006-04-03 12:03:44 +04:00
int l d b _ s e a r c h ( s t r u c t l d b _ c o n t e x t * l d b , c o n s t s t r u c t l d b _ d n * b a s e , enum l d b _ s c o p e s c o p e , c o n s t char * e x p r e s s i o n , c o n s t char * c o n s t * a t t r s , s t r u c t l d b _ r e s u l t * * O U T ) ;
2006-04-04 05:22:38 +04:00
int l d b _ d e l e t e ( s t r u c t l d b _ c o n t e x t * l d b , c o n s t s t r u c t l d b _ d n * d n ) ;
int l d b _ r e n a m e ( s t r u c t l d b _ c o n t e x t * l d b , c o n s t s t r u c t l d b _ d n * o l d d n , c o n s t s t r u c t l d b _ d n * n e w d n ) ;
int l d b _ a d d ( s t r u c t l d b _ c o n t e x t * l d b , c o n s t s t r u c t l d b _ m e s s a g e * message ) ;
2006-04-15 14:13:09 +04:00
2006-05-02 09:14:00 +04:00
/* L d b m e s s a g e o p e r a t i o n s */
2006-04-15 14:13:09 +04:00
s t r u c t l d b _ m e s s a g e * l d b _ m s g _ n e w ( void * m e m _ c t x ) ;
2006-05-02 09:14:00 +04:00
2006-04-15 14:13:09 +04:00
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 _ f i n d _ e l e m e n t ( c o n s t s t r u c t l d b _ m e s s a g e * m s g , c o n s t char * a t t r _ n a m e ) ;
2006-05-02 09:14:00 +04:00
2006-04-16 07:46:05 +04:00
int l d b _ m s g _ a d d _ v a l u e ( s t r u c t l d b _ m e s s a g e * m s g , c o n s t char * a t t r _ n a m e , c o n s t s t r u c t l d b _ v a l * INPUT ) ;
2006-04-16 10:05:33 +04:00
2006-05-02 09:14:00 +04:00
void l d b _ m s g _ r e m o v e _ a t t r ( s t r u c t l d b _ m e s s a g e * m s g , c o n s t char * attr ) ;
int l d b _ m s g _ s a n i t y _ c h e c k ( s t r u c t l d b _ m e s s a g e * m s g ) ;
/* D N o p e r a t i o n s */
2006-04-16 10:05:33 +04:00
s t r u c t l d b _ d n * l d b _ d n _ e x p l o d e ( void * m e m _ c t x , c o n s t char * d n ) ;
2006-05-02 09:14:00 +04:00
2006-04-16 10:05:33 +04:00
char * l d b _ d n _ l i n e a r i z e ( void * m e m _ c t x , c o n s t s t r u c t l d b _ d n * d n ) ;