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