]> git.sur5r.net Git - openldap/blob - servers/slapd/back-sql/config.c
Fixup bdb_entry_release now that entry_decode uses two memory blocks
[openldap] / servers / slapd / back-sql / config.c
1 /*
2  *       Copyright 1999, Dmitry Kovalev <mit@openldap.org>, All rights reserved.
3  *
4  *       Redistribution and use in source and binary forms are permitted only
5  *       as authorized by the OpenLDAP Public License.  A copy of this
6  *       license is available at http://www.OpenLDAP.org/license.html or
7  *       in file LICENSE in the top-level directory of the distribution.
8  */
9
10 #include "portable.h"
11
12 #ifdef SLAPD_SQL
13
14 #include <stdio.h>
15 #include <string.h>
16 #include <sys/types.h>
17 #include "slap.h"
18 #include "back-sql.h"
19 #include "sql-wrap.h"
20
21 int backsql_db_config(BackendDB *be,const char *fname,int lineno,int argc,char **argv)
22 {
23  backsql_info *si=(backsql_info*) be->be_private;
24
25  Debug(LDAP_DEBUG_TRACE,"==>backsql_db_config()\n",0,0,0);
26  if (!si)
27   {
28    Debug(LDAP_DEBUG_TRACE,"backsql_db_config: be_private is NULL!!!\n",0,0,0);
29    exit(1);
30   }
31   
32  if (!strcasecmp(argv[0],"dbhost"))
33   {
34    if (argc<2)
35     {
36      Debug(LDAP_DEBUG_TRACE,"<==backsql_db_config (%s line %d): missing hostname in dbhost directive\n",
37                      fname,lineno,0);
38     }
39    else
40     {
41      si->dbhost=ch_strdup(argv[1]);
42      Debug(LDAP_DEBUG_TRACE,"<==backsql_db_config(): hostname=%s\n",si->dbhost,0,0);
43     }
44    return(0);
45   }
46   
47  if (!strcasecmp(argv[0],"dbuser"))
48   {
49    if (argc<2)
50     {
51      Debug(LDAP_DEBUG_TRACE,"<==backsql_db_config (%s line %d): missing username in dbuser directive\n",
52                      fname,lineno,0);
53     }
54    else
55     {
56      si->dbuser=ch_strdup(argv[1]);
57      Debug(LDAP_DEBUG_TRACE,"<==backsql_db_config(): dbuser=%s\n",argv[1],0,0);
58     }
59    return(0);
60   }
61  
62  if (!strcasecmp(argv[0],"dbpasswd"))
63   {
64    if (argc<2)
65     {
66      Debug(LDAP_DEBUG_TRACE,"<==backsql_db_config (%s line %d): missing password in dbpasswd directive\n",
67                      fname,lineno,0);
68     }
69    else
70     {
71      si->dbpasswd=ch_strdup(argv[1]);
72      Debug(LDAP_DEBUG_TRACE,"<==backsql_db_config(): dbpasswd=%s\n",si->dbpasswd,0,0);
73     }
74    return(0);
75   }
76   
77  if (!strcasecmp(argv[0],"dbname"))
78   {
79    if (argc<2)
80     {
81      Debug(LDAP_DEBUG_TRACE,"<==backsql_db_config (%s line %d): missing database name in dbname directive\n",
82                      fname,lineno,0);
83     }
84    else
85     {
86      si->dbname=ch_strdup(argv[1]);
87      Debug(LDAP_DEBUG_TRACE,"<==backsql_db_config(): dbname=%s\n",si->dbname,0,0);
88     }
89    return(0);
90   }
91
92  if (!strcasecmp(argv[0],"subtree_cond"))
93   {
94    if (argc<2)
95     {
96      Debug(LDAP_DEBUG_TRACE,"<==backsql_db_config (%s line %d): missing SQL condition in subtree_cond directive\n",
97                      fname,lineno,0);
98     }
99    else
100     {
101      si->subtree_cond=ch_strdup(argv[1]);
102      Debug(LDAP_DEBUG_TRACE,"<==backsql_db_config(): subtree_cond=%s\n",si->subtree_cond,0,0);
103     }
104    return(0);
105   }
106
107  if (!strcasecmp(argv[0],"oc_query"))
108   {
109    if (argc<2)
110     {
111      Debug(LDAP_DEBUG_TRACE,"<==backsql_db_config (%s line %d): missing SQL statement in oc_query directive\n",
112                      fname,lineno,0);
113     }
114    else
115     {
116      si->oc_query=ch_strdup(argv[1]);
117      Debug(LDAP_DEBUG_TRACE,"<==backsql_db_config(): oc_query=%s\n",si->oc_query,0,0);
118     }
119    return(0);
120   }
121
122  if (!strcasecmp(argv[0],"at_query"))
123   {
124    if (argc<2)
125     {
126      Debug(LDAP_DEBUG_TRACE,"<==backsql_db_config (%s line %d): missing SQL statement in at_query directive\n",
127                      fname,lineno,0);
128     }
129    else
130     {
131      si->at_query=ch_strdup(argv[1]);
132      Debug(LDAP_DEBUG_TRACE,"<==backsql_db_config(): at_query=%s\n",si->at_query,0,0);
133     }
134    return(0);
135   }
136
137  if (!strcasecmp(argv[0],"insentry_query"))
138   {
139    if (argc<2)
140     {
141      Debug(LDAP_DEBUG_TRACE,"<==backsql_db_config (%s line %d): missing SQL statement in insentry_query directive\n",
142                      fname,lineno,0);
143     }
144    else
145     {
146      si->insentry_query=ch_strdup(argv[1]);
147      Debug(LDAP_DEBUG_TRACE,"<==backsql_db_config(): insentry_query=%s\n",si->insentry_query,0,0);
148     }
149    return(0);
150   }
151
152  if (!strcasecmp(argv[0],"upper_func"))
153   {
154    if (argc<2)
155     {
156      Debug(LDAP_DEBUG_TRACE,"<==backsql_db_config (%s line %d): missing function name in upper_func directive\n",
157                      fname,lineno,0);
158     }
159    else
160     {
161      si->upper_func=ch_strdup(argv[1]);
162      Debug(LDAP_DEBUG_TRACE,"<==backsql_db_config(): upper_func=%s\n",si->upper_func,0,0);
163     }
164    return(0);
165   }
166
167  if (!strcasecmp(argv[0],"delentry_query"))
168   {
169    if (argc<2)
170     {
171      Debug(LDAP_DEBUG_TRACE,"<==backsql_db_config (%s line %d): missing SQL statement in delentry_query directive\n",
172                      fname,lineno,0);
173     }
174    else
175     {
176      si->delentry_query=ch_strdup(argv[1]);
177      Debug(LDAP_DEBUG_TRACE,"<==backsql_db_config(): delentry_query=%s\n",si->delentry_query,0,0);
178     }
179    return(0);
180   }
181  
182  Debug(LDAP_DEBUG_TRACE,"<==backsql_db_config (%s line %d): unknown directive '%s' (ignored)\n",
183                      fname,lineno,argv[0]);
184  return 0;
185 }
186
187 #endif /* SLAPD_SQL */