Merge branch 'ff/local'
[collectd.git] / src / dbi.c
1 /**
2  * collectd - src/dbi.c
3  * Copyright (C) 2008,2009  Florian octo Forster
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License as published by the
7  * Free Software Foundation; only version 2 of the License is applicable.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
17  *
18  * Authors:
19  *   Florian octo Forster <octo at verplant.org>
20  **/
21
22 #include "collectd.h"
23 #include "common.h"
24 #include "plugin.h"
25 #include "configfile.h"
26 #include "utils_db_query.h"
27
28 #include <dbi/dbi.h>
29
30 /*
31  * Data types
32  */
33 struct cdbi_driver_option_s /* {{{ */
34 {
35   char *key;
36   char *value;
37 };
38 typedef struct cdbi_driver_option_s cdbi_driver_option_t; /* }}} */
39
40 struct cdbi_database_s /* {{{ */
41 {
42   char *name;
43   char *select_db;
44
45   char *driver;
46   cdbi_driver_option_t *driver_options;
47   size_t driver_options_num;
48
49   udb_query_t **queries;
50   size_t        queries_num;
51
52   dbi_conn connection;
53 };
54 typedef struct cdbi_database_s cdbi_database_t; /* }}} */
55
56 /*
57  * Global variables
58  */
59 static udb_query_t     **queries       = NULL;
60 static size_t            queries_num   = 0;
61 static cdbi_database_t **databases     = NULL;
62 static size_t            databases_num = 0;
63
64 /*
65  * Functions
66  */
67 static const char *cdbi_strerror (dbi_conn conn, /* {{{ */
68     char *buffer, size_t buffer_size)
69 {
70   const char *msg;
71   int status;
72
73   if (conn == NULL)
74   {
75     sstrncpy (buffer, "connection is NULL", buffer_size);
76     return (buffer);
77   }
78
79   msg = NULL;
80   status = dbi_conn_error (conn, &msg);
81   if ((status >= 0) && (msg != NULL))
82     ssnprintf (buffer, buffer_size, "%s (status %i)", msg, status);
83   else
84     ssnprintf (buffer, buffer_size, "dbi_conn_error failed with status %i",
85         status);
86
87   return (buffer);
88 } /* }}} const char *cdbi_conn_error */
89
90 static int cdbi_result_get_field (dbi_result res, /* {{{ */
91     unsigned int index, char *buffer, size_t buffer_size)
92 {
93   unsigned short src_type;
94
95   src_type = dbi_result_get_field_type_idx (res, index);
96   if (src_type == DBI_TYPE_ERROR)
97   {
98     ERROR ("dbi plugin: cdbi_result_get: "
99         "dbi_result_get_field_type_idx failed.");
100     return (-1);
101   }
102
103   if (src_type == DBI_TYPE_INTEGER)
104   {
105     long long value;
106
107     value = dbi_result_get_longlong_idx (res, index);
108     ssnprintf (buffer, buffer_size, "%lli", value);
109   }
110   else if (src_type == DBI_TYPE_DECIMAL)
111   {
112     double value;
113
114     value = dbi_result_get_double_idx (res, index);
115     ssnprintf (buffer, buffer_size, "%63.15g", value);
116   }
117   else if (src_type == DBI_TYPE_STRING)
118   {
119     const char *value;
120     
121     value = dbi_result_get_string_idx (res, index);
122     if (value == NULL)
123       sstrncpy (buffer, "", buffer_size);
124     else if (strcmp ("ERROR", value) == 0)
125       return (-1);
126     else
127       sstrncpy (buffer, value, buffer_size);
128   }
129   else
130   {
131     ERROR ("dbi plugin: cdbi_result_get: Don't know how to handle "
132         "source type %hu.", src_type);
133     return (-1);
134   }
135
136   return (0);
137 } /* }}} int cdbi_result_get_field */
138
139 static void cdbi_database_free (cdbi_database_t *db) /* {{{ */
140 {
141   size_t i;
142
143   if (db == NULL)
144     return;
145
146   sfree (db->name);
147   sfree (db->driver);
148
149   for (i = 0; i < db->driver_options_num; i++)
150   {
151     sfree (db->driver_options[i].key);
152     sfree (db->driver_options[i].value);
153   }
154   sfree (db->driver_options);
155
156   sfree (db);
157 } /* }}} void cdbi_database_free */
158
159 /* Configuration handling functions {{{
160  *
161  * <Plugin dbi>
162  *   <Query "plugin_instance0">
163  *     Statement "SELECT name, value FROM table"
164  *     <Result>
165  *       Type "gauge"
166  *       InstancesFrom "name"
167  *       ValuesFrom "value"
168  *     </Result>
169  *     ...
170  *   </Query>
171  *     
172  *   <Database "plugin_instance1">
173  *     Driver "mysql"
174  *     DriverOption "hostname" "localhost"
175  *     ...
176  *     Query "plugin_instance0"
177  *   </Database>
178  * </Plugin>
179  */
180
181 static int cdbi_config_set_string (char **ret_string, /* {{{ */
182     oconfig_item_t *ci)
183 {
184   char *string;
185
186   if ((ci->values_num != 1)
187       || (ci->values[0].type != OCONFIG_TYPE_STRING))
188   {
189     WARNING ("dbi plugin: The `%s' config option "
190         "needs exactly one string argument.", ci->key);
191     return (-1);
192   }
193
194   string = strdup (ci->values[0].value.string);
195   if (string == NULL)
196   {
197     ERROR ("dbi plugin: strdup failed.");
198     return (-1);
199   }
200
201   if (*ret_string != NULL)
202     free (*ret_string);
203   *ret_string = string;
204
205   return (0);
206 } /* }}} int cdbi_config_set_string */
207
208 static int cdbi_config_add_database_driver_option (cdbi_database_t *db, /* {{{ */
209     oconfig_item_t *ci)
210 {
211   cdbi_driver_option_t *option;
212
213   if ((ci->values_num != 2)
214       || (ci->values[0].type != OCONFIG_TYPE_STRING)
215       || (ci->values[1].type != OCONFIG_TYPE_STRING))
216   {
217     WARNING ("dbi plugin: The `DriverOption' config option "
218         "needs exactly two string arguments.");
219     return (-1);
220   }
221
222   option = (cdbi_driver_option_t *) realloc (db->driver_options,
223       sizeof (*option) * (db->driver_options_num + 1));
224   if (option == NULL)
225   {
226     ERROR ("dbi plugin: realloc failed");
227     return (-1);
228   }
229
230   db->driver_options = option;
231   option = db->driver_options + db->driver_options_num;
232
233   option->key = strdup (ci->values[0].value.string);
234   if (option->key == NULL)
235   {
236     ERROR ("dbi plugin: strdup failed.");
237     return (-1);
238   }
239
240   option->value = strdup (ci->values[1].value.string);
241   if (option->value == NULL)
242   {
243     ERROR ("dbi plugin: strdup failed.");
244     sfree (option->key);
245     return (-1);
246   }
247
248   db->driver_options_num++;
249   return (0);
250 } /* }}} int cdbi_config_add_database_driver_option */
251
252 static int cdbi_config_add_database (oconfig_item_t *ci) /* {{{ */
253 {
254   cdbi_database_t *db;
255   int status;
256   int i;
257
258   if ((ci->values_num != 1)
259       || (ci->values[0].type != OCONFIG_TYPE_STRING))
260   {
261     WARNING ("dbi plugin: The `Database' block "
262         "needs exactly one string argument.");
263     return (-1);
264   }
265
266   db = (cdbi_database_t *) malloc (sizeof (*db));
267   if (db == NULL)
268   {
269     ERROR ("dbi plugin: malloc failed.");
270     return (-1);
271   }
272   memset (db, 0, sizeof (*db));
273
274   status = cdbi_config_set_string (&db->name, ci);
275   if (status != 0)
276   {
277     sfree (db);
278     return (status);
279   }
280
281   /* Fill the `cdbi_database_t' structure.. */
282   for (i = 0; i < ci->children_num; i++)
283   {
284     oconfig_item_t *child = ci->children + i;
285
286     if (strcasecmp ("Driver", child->key) == 0)
287       status = cdbi_config_set_string (&db->driver, child);
288     else if (strcasecmp ("DriverOption", child->key) == 0)
289       status = cdbi_config_add_database_driver_option (db, child);
290     else if (strcasecmp ("SelectDB", child->key) == 0)
291       status = cdbi_config_set_string (&db->select_db, child);
292     else if (strcasecmp ("Query", child->key) == 0)
293       status = udb_query_pick_from_list (child, queries, queries_num,
294           &db->queries, &db->queries_num);
295     else
296     {
297       WARNING ("dbi plugin: Option `%s' not allowed here.", child->key);
298       status = -1;
299     }
300
301     if (status != 0)
302       break;
303   }
304
305   /* Check that all necessary options have been given. */
306   while (status == 0)
307   {
308     if (db->driver == NULL)
309     {
310       WARNING ("dbi plugin: `Driver' not given for database `%s'", db->name);
311       status = -1;
312     }
313     if (db->driver_options_num == 0)
314     {
315       WARNING ("dbi plugin: No `DriverOption' given for database `%s'. "
316           "This will likely not work.", db->name);
317     }
318
319     break;
320   } /* while (status == 0) */
321
322   /* If all went well, add this database to the global list of databases. */
323   if (status == 0)
324   {
325     cdbi_database_t **temp;
326
327     temp = (cdbi_database_t **) realloc (databases,
328         sizeof (*databases) * (databases_num + 1));
329     if (temp == NULL)
330     {
331       ERROR ("dbi plugin: realloc failed");
332       status = -1;
333     }
334     else
335     {
336       databases = temp;
337       databases[databases_num] = db;
338       databases_num++;
339     }
340   }
341
342   if (status != 0)
343   {
344     cdbi_database_free (db);
345     return (-1);
346   }
347
348   return (0);
349 } /* }}} int cdbi_config_add_database */
350
351 static int cdbi_config (oconfig_item_t *ci) /* {{{ */
352 {
353   int i;
354
355   for (i = 0; i < ci->children_num; i++)
356   {
357     oconfig_item_t *child = ci->children + i;
358     if (strcasecmp ("Query", child->key) == 0)
359       udb_query_create (&queries, &queries_num, child,
360           /* callback = */ NULL);
361     else if (strcasecmp ("Database", child->key) == 0)
362       cdbi_config_add_database (child);
363     else
364     {
365       WARNING ("snmp plugin: Ignoring unknown config option `%s'.", child->key);
366     }
367   } /* for (ci->children) */
368
369   return (0);
370 } /* }}} int cdbi_config */
371
372 /* }}} End of configuration handling functions */
373
374 static int cdbi_init (void) /* {{{ */
375 {
376   static int did_init = 0;
377   int status;
378
379   if (did_init != 0)
380     return (0);
381
382   if (queries_num == 0)
383   {
384     ERROR ("dbi plugin: No <Query> blocks have been found. Without them, "
385         "this plugin can't do anything useful, so we will returns an error.");
386     return (-1);
387   }
388
389   if (databases_num == 0)
390   {
391     ERROR ("dbi plugin: No <Database> blocks have been found. Without them, "
392         "this plugin can't do anything useful, so we will returns an error.");
393     return (-1);
394   }
395
396   status = dbi_initialize (NULL);
397   if (status < 0)
398   {
399     ERROR ("dbi plugin: cdbi_init: dbi_initialize failed with status %i.",
400         status);
401     return (-1);
402   }
403   else if (status == 0)
404   {
405     ERROR ("dbi plugin: `dbi_initialize' could not load any drivers. Please "
406         "install at least one `DBD' or check your installation.");
407     return (-1);
408   }
409   DEBUG ("dbi plugin: cdbi_init: dbi_initialize reports %i driver%s.",
410       status, (status == 1) ? "" : "s");
411
412   return (0);
413 } /* }}} int cdbi_init */
414
415 static int cdbi_read_database_query (cdbi_database_t *db, /* {{{ */
416     udb_query_t *q)
417 {
418   const char *statement;
419   dbi_result res;
420   size_t column_num;
421   char **column_names;
422   char **column_values;
423   int status;
424   size_t i;
425
426   /* Macro that cleans up dynamically allocated memory and returns the
427    * specified status. */
428 #define BAIL_OUT(status) \
429   if (column_names != NULL) { sfree (column_names[0]); sfree (column_names); } \
430   if (column_values != NULL) { sfree (column_values[0]); sfree (column_values); } \
431   if (res != NULL) { dbi_result_free (res); res = NULL; } \
432   return (status)
433
434   column_names = NULL;
435   column_values = NULL;
436   res = NULL;
437
438   statement = udb_query_get_statement (q);
439   assert (statement != NULL);
440
441   res = dbi_conn_query (db->connection, statement);
442   if (res == NULL)
443   {
444     char errbuf[1024];
445     ERROR ("dbi plugin: cdbi_read_database_query (%s, %s): "
446         "dbi_conn_query failed: %s",
447         db->name, udb_query_get_name (q),
448         cdbi_strerror (db->connection, errbuf, sizeof (errbuf)));
449     BAIL_OUT (-1);
450   }
451   else /* Get the number of columns */
452   {
453     unsigned int db_status;
454
455     db_status = dbi_result_get_numfields (res);
456     if (db_status == DBI_FIELD_ERROR)
457     {
458       char errbuf[1024];
459       ERROR ("dbi plugin: cdbi_read_database_query (%s, %s): "
460           "dbi_result_get_numfields failed: %s",
461           db->name, udb_query_get_name (q),
462           cdbi_strerror (db->connection, errbuf, sizeof (errbuf)));
463       BAIL_OUT (-1);
464     }
465
466     column_num = (size_t) db_status;
467     DEBUG ("cdbi_read_database_query (%s, %s): There are %zu columns.",
468         db->name, udb_query_get_name (q), column_num);
469   }
470
471   /* Allocate `column_names' and `column_values'. {{{ */
472   column_names = (char **) calloc (column_num, sizeof (char *));
473   if (column_names == NULL)
474   {
475     ERROR ("dbi plugin: malloc failed.");
476     BAIL_OUT (-1);
477   }
478
479   column_names[0] = (char *) calloc (column_num,
480       DATA_MAX_NAME_LEN * sizeof (char));
481   if (column_names[0] == NULL)
482   {
483     ERROR ("dbi plugin: malloc failed.");
484     BAIL_OUT (-1);
485   }
486   for (i = 1; i < column_num; i++)
487     column_names[i] = column_names[i - 1] + DATA_MAX_NAME_LEN;
488
489   column_values = (char **) calloc (column_num, sizeof (char *));
490   if (column_values == NULL)
491   {
492     ERROR ("dbi plugin: malloc failed.");
493     BAIL_OUT (-1);
494   }
495
496   column_values[0] = (char *) calloc (column_num,
497       DATA_MAX_NAME_LEN * sizeof (char));
498   if (column_values[0] == NULL)
499   {
500     ERROR ("dbi plugin: malloc failed.");
501     BAIL_OUT (-1);
502   }
503   for (i = 1; i < column_num; i++)
504     column_values[i] = column_values[i - 1] + DATA_MAX_NAME_LEN;
505   /* }}} */
506
507   /* Copy the field names to `column_names' */
508   for (i = 0; i < column_num; i++) /* {{{ */
509   {
510     const char *column_name;
511
512     column_name = dbi_result_get_field_name (res, (unsigned int) (i + 1));
513     if (column_name == NULL)
514     {
515       ERROR ("dbi plugin: cdbi_read_database_query (%s, %s): "
516           "Cannot retrieve name of field %zu.",
517           db->name, udb_query_get_name (q), i + 1);
518       BAIL_OUT (-1);
519     }
520
521     sstrncpy (column_names[i], column_name, DATA_MAX_NAME_LEN);
522   } /* }}} for (i = 0; i < column_num; i++) */
523
524   udb_query_prepare_result (q, hostname_g, /* plugin = */ "dbi", db->name,
525       column_names, column_num);
526
527   /* 0 = error; 1 = success; */
528   status = dbi_result_first_row (res); /* {{{ */
529   if (status != 1)
530   {
531     char errbuf[1024];
532     ERROR ("dbi plugin: cdbi_read_database_query (%s, %s): "
533         "dbi_result_first_row failed: %s. Maybe the statement didn't "
534         "return any rows?",
535         db->name, udb_query_get_name (q),
536         cdbi_strerror (db->connection, errbuf, sizeof (errbuf)));
537     udb_query_finish_result (q);
538     BAIL_OUT (-1);
539   } /* }}} */
540
541   /* Iterate over all rows and call `udb_query_handle_result' with each list of
542    * values. */
543   while (42) /* {{{ */
544   {
545     status = 0;
546     /* Copy the value of the columns to `column_values' */
547     for (i = 0; i < column_num; i++) /* {{{ */
548     {
549       status = cdbi_result_get_field (res, (unsigned int) (i + 1),
550           column_values[i], DATA_MAX_NAME_LEN);
551
552       if (status != 0)
553       {
554         ERROR ("dbi plugin: cdbi_read_database_query (%s, %s): "
555             "cdbi_result_get_field (%zu) failed.",
556             db->name, udb_query_get_name (q), i + 1);
557         status = -1;
558         break;
559       }
560     } /* }}} for (i = 0; i < column_num; i++) */
561
562     /* If all values were copied successfully, call `udb_query_handle_result'
563      * to dispatch the row to the daemon. */
564     if (status == 0) /* {{{ */
565     {
566       status = udb_query_handle_result (q, column_values);
567       if (status != 0)
568       {
569         ERROR ("dbi plugin: cdbi_read_database_query (%s, %s): "
570             "udb_query_handle_result failed.",
571             db->name, udb_query_get_name (q));
572       }
573     } /* }}} */
574
575     /* Get the next row from the database. */
576     status = dbi_result_next_row (res); /* {{{ */
577     if (status != 1)
578     {
579       if (dbi_conn_error (db->connection, NULL) != 0)
580       {
581         char errbuf[1024];
582         WARNING ("dbi plugin: cdbi_read_database_query (%s, %s): "
583             "dbi_result_next_row failed: %s.",
584             db->name, udb_query_get_name (q),
585             cdbi_strerror (db->connection, errbuf, sizeof (errbuf)));
586       }
587       break;
588     } /* }}} */
589   } /* }}} while (42) */
590
591   /* Tell the db query interface that we're done with this query. */
592   udb_query_finish_result (q);
593
594   /* Clean up and return `status = 0' (success) */
595   BAIL_OUT (0);
596 #undef BAIL_OUT
597 } /* }}} int cdbi_read_database_query */
598
599 static int cdbi_connect_database (cdbi_database_t *db) /* {{{ */
600 {
601   dbi_driver driver;
602   dbi_conn connection;
603   size_t i;
604   int status;
605
606   if (db->connection != NULL)
607   {
608     status = dbi_conn_ping (db->connection);
609     if (status != 0) /* connection is alive */
610       return (0);
611
612     dbi_conn_close (db->connection);
613     db->connection = NULL;
614   }
615
616   driver = dbi_driver_open (db->driver);
617   if (driver == NULL)
618   {
619     ERROR ("dbi plugin: cdbi_connect_database: dbi_driver_open (%s) failed.",
620         db->driver);
621     INFO ("dbi plugin: Maybe the driver isn't installed? "
622         "Known drivers are:");
623     for (driver = dbi_driver_list (NULL);
624         driver != NULL;
625         driver = dbi_driver_list (driver))
626     {
627       INFO ("dbi plugin: * %s", dbi_driver_get_name (driver));
628     }
629     return (-1);
630   }
631
632   connection = dbi_conn_open (driver);
633   if (connection == NULL)
634   {
635     ERROR ("dbi plugin: cdbi_connect_database: dbi_conn_open (%s) failed.",
636         db->driver);
637     return (-1);
638   }
639
640   /* Set all the driver options. Because this is a very very very generic
641    * interface, the error handling is kind of long. If an invalid option is
642    * encountered, it will get a list of options understood by the driver and
643    * report that as `INFO'. This way, users hopefully don't have too much
644    * trouble finding out how to configure the plugin correctly.. */
645   for (i = 0; i < db->driver_options_num; i++)
646   {
647     DEBUG ("dbi plugin: cdbi_connect_database (%s): "
648         "key = %s; value = %s;",
649         db->name,
650         db->driver_options[i].key,
651         db->driver_options[i].value);
652
653     status = dbi_conn_set_option (connection,
654         db->driver_options[i].key, db->driver_options[i].value);
655     if (status != 0)
656     {
657       char errbuf[1024];
658       const char *opt;
659
660       ERROR ("dbi plugin: cdbi_connect_database (%s): "
661           "dbi_conn_set_option (%s, %s) failed: %s.",
662           db->name,
663           db->driver_options[i].key, db->driver_options[i].value,
664           cdbi_strerror (connection, errbuf, sizeof (errbuf)));
665
666       INFO ("dbi plugin: This is a list of all options understood "
667           "by the `%s' driver:", db->driver);
668       for (opt = dbi_conn_get_option_list (connection, NULL);
669           opt != NULL;
670           opt = dbi_conn_get_option_list (connection, opt))
671       {
672         INFO ("dbi plugin: * %s", opt);
673       }
674
675       dbi_conn_close (connection);
676       return (-1);
677     }
678   } /* for (i = 0; i < db->driver_options_num; i++) */
679
680   status = dbi_conn_connect (connection);
681   if (status != 0)
682   {
683     char errbuf[1024];
684     ERROR ("dbi plugin: cdbi_connect_database (%s): "
685         "dbi_conn_connect failed: %s",
686         db->name, cdbi_strerror (connection, errbuf, sizeof (errbuf)));
687     dbi_conn_close (connection);
688     return (-1);
689   }
690
691   if (db->select_db != NULL)
692   {
693     status = dbi_conn_select_db (connection, db->select_db);
694     if (status != 0)
695     {
696       char errbuf[1024];
697       WARNING ("dbi plugin: cdbi_connect_database (%s): "
698           "dbi_conn_select_db (%s) failed: %s. Check the `SelectDB' option.",
699           db->name, db->select_db,
700           cdbi_strerror (connection, errbuf, sizeof (errbuf)));
701       dbi_conn_close (connection);
702       return (-1);
703     }
704   }
705
706   db->connection = connection;
707   return (0);
708 } /* }}} int cdbi_connect_database */
709
710 static int cdbi_read_database (cdbi_database_t *db) /* {{{ */
711 {
712   size_t i;
713   int success;
714   int status;
715
716   unsigned int db_version;
717
718   status = cdbi_connect_database (db);
719   if (status != 0)
720     return (status);
721   assert (db->connection != NULL);
722
723   db_version = dbi_conn_get_engine_version (db->connection);
724   /* TODO: Complain if `db_version == 0' */
725
726   success = 0;
727   for (i = 0; i < db->queries_num; i++)
728   {
729     /* Check if we know the database's version and if so, if this query applies
730      * to that version. */
731     if ((db_version != 0)
732         && (udb_query_check_version (db->queries[i], db_version) == 0))
733       continue;
734
735     status = cdbi_read_database_query (db, db->queries[i]);
736     if (status == 0)
737       success++;
738   }
739
740   if (success == 0)
741   {
742     ERROR ("dbi plugin: All queries failed for database `%s'.", db->name);
743     return (-1);
744   }
745
746   return (0);
747 } /* }}} int cdbi_read_database */
748
749 static int cdbi_read (void) /* {{{ */
750 {
751   size_t i;
752   int success = 0;
753   int status;
754
755   for (i = 0; i < databases_num; i++)
756   {
757     status = cdbi_read_database (databases[i]);
758     if (status == 0)
759       success++;
760   }
761
762   if (success == 0)
763   {
764     ERROR ("dbi plugin: No database could be read. Will return an error so "
765         "the plugin will be delayed.");
766     return (-1);
767   }
768
769   return (0);
770 } /* }}} int cdbi_read */
771
772 static int cdbi_shutdown (void) /* {{{ */
773 {
774   size_t i;
775
776   for (i = 0; i < databases_num; i++)
777   {
778     if (databases[i]->connection != NULL)
779     {
780       dbi_conn_close (databases[i]->connection);
781       databases[i]->connection = NULL;
782     }
783     cdbi_database_free (databases[i]);
784   }
785   sfree (databases);
786   databases_num = 0;
787
788   udb_query_free (queries, queries_num);
789   queries = NULL;
790   queries_num = 0;
791
792   return (0);
793 } /* }}} int cdbi_shutdown */
794
795 void module_register (void) /* {{{ */
796 {
797   plugin_register_complex_config ("dbi", cdbi_config);
798   plugin_register_init ("dbi", cdbi_init);
799   plugin_register_read ("dbi", cdbi_read);
800   plugin_register_shutdown ("dbi", cdbi_shutdown);
801 } /* }}} void module_register */
802
803 /*
804  * vim: shiftwidth=2 softtabstop=2 et fdm=marker
805  */