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