]> git.sur5r.net Git - openldap/blob - servers/slapd/back-shell/config.c
03c7b7da76516ccd5251ab94a0ba29746eb05c73
[openldap] / servers / slapd / back-shell / config.c
1 /* config.c - shell backend configuration file routine */
2 /* $OpenLDAP$ */
3
4 #include "portable.h"
5
6 #include <stdio.h>
7
8 #include <ac/string.h>
9 #include <ac/socket.h>
10
11 #include "slap.h"
12 #include "shell.h"
13
14 int
15 shell_back_db_config(
16     BackendDB   *be,
17     const char  *fname,
18     int         lineno,
19     int         argc,
20     char        **argv
21 )
22 {
23         struct shellinfo        *si = (struct shellinfo *) be->be_private;
24
25         if ( si == NULL ) {
26                 fprintf( stderr, "%s: line %d: shell backend info is null!\n",
27                     fname, lineno );
28                 return( 1 );
29         }
30
31         /* command + args to exec for binds */
32         if ( strcasecmp( argv[0], "bind" ) == 0 ) {
33                 if ( argc < 2 ) {
34                         fprintf( stderr,
35         "%s: line %d: missing executable in \"bind <executable>\" line\n",
36                             fname, lineno );
37                         return( 1 );
38                 }
39                 si->si_bind = charray_dup( &argv[1] );
40
41         /* command + args to exec for unbinds */
42         } else if ( strcasecmp( argv[0], "unbind" ) == 0 ) {
43                 if ( argc < 2 ) {
44                         fprintf( stderr,
45         "%s: line %d: missing executable in \"unbind <executable>\" line\n",
46                             fname, lineno );
47                         return( 1 );
48                 }
49                 si->si_unbind = charray_dup( &argv[1] );
50
51         /* command + args to exec for searches */
52         } else if ( strcasecmp( argv[0], "search" ) == 0 ) {
53                 if ( argc < 2 ) {
54                         fprintf( stderr,
55         "%s: line %d: missing executable in \"search <executable>\" line\n",
56                             fname, lineno );
57                         return( 1 );
58                 }
59                 si->si_search = charray_dup( &argv[1] );
60
61         /* command + args to exec for compares */
62         } else if ( strcasecmp( argv[0], "compare" ) == 0 ) {
63                 if ( argc < 2 ) {
64                         fprintf( stderr,
65         "%s: line %d: missing executable in \"compare <executable>\" line\n",
66                             fname, lineno );
67                         return( 1 );
68                 }
69                 si->si_compare = charray_dup( &argv[1] );
70
71         /* command + args to exec for modifies */
72         } else if ( strcasecmp( argv[0], "modify" ) == 0 ) {
73                 if ( argc < 2 ) {
74                         fprintf( stderr,
75         "%s: line %d: missing executable in \"modify <executable>\" line\n",
76                             fname, lineno );
77                         return( 1 );
78                 }
79                 si->si_modify = charray_dup( &argv[1] );
80
81         /* command + args to exec for modrdn */
82         } else if ( strcasecmp( argv[0], "modrdn" ) == 0 ) {
83                 if ( argc < 2 ) {
84                         fprintf( stderr,
85         "%s: line %d: missing executable in \"modrdn <executable>\" line\n",
86                             fname, lineno );
87                         return( 1 );
88                 }
89                 si->si_modrdn = charray_dup( &argv[1] );
90
91         /* command + args to exec for add */
92         } else if ( strcasecmp( argv[0], "add" ) == 0 ) {
93                 if ( argc < 2 ) {
94                         fprintf( stderr,
95         "%s: line %d: missing executable in \"add <executable>\" line\n",
96                             fname, lineno );
97                         return( 1 );
98                 }
99                 si->si_add = charray_dup( &argv[1] );
100
101         /* command + args to exec for delete */
102         } else if ( strcasecmp( argv[0], "delete" ) == 0 ) {
103                 if ( argc < 2 ) {
104                         fprintf( stderr,
105         "%s: line %d: missing executable in \"delete <executable>\" line\n",
106                             fname, lineno );
107                         return( 1 );
108                 }
109                 si->si_delete = charray_dup( &argv[1] );
110
111         /* command + args to exec for abandon */
112         } else if ( strcasecmp( argv[0], "abandon" ) == 0 ) {
113                 if ( argc < 2 ) {
114                         fprintf( stderr,
115         "%s: line %d: missing executable in \"abandon <executable>\" line\n",
116                             fname, lineno );
117                         return( 1 );
118                 }
119                 si->si_abandon = charray_dup( &argv[1] );
120
121         /* anything else */
122         } else {
123                 fprintf( stderr,
124 "%s: line %d: unknown directive \"%s\" in shell database definition (ignored)\n",
125                     fname, lineno, argv[0] );
126         }
127
128         return 0;
129 }