aboutsummaryrefslogtreecommitdiff
path: root/include/smap
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2010-06-07 17:50:12 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2010-06-07 18:02:45 +0300
commitc14f3c4856d75624641ffa1d62d6e0c87217036f (patch)
treef4bab25f862624477314348cedadc96ae4a2bb7e /include/smap
parentc42ac1fa64f94f23cec5dac1d2bdb3d000e62f8f (diff)
downloadsmap-c14f3c4856d75624641ffa1d62d6e0c87217036f.tar.gz
smap-c14f3c4856d75624641ffa1d62d6e0c87217036f.tar.bz2
Improve module loading/unloading sequence. Implement `guile' module.
* include/smap/parseopt.h: New file. * lib/parseopt.c: New file. * lib/Makefile.am (libsmap_la_SOURCES): Add parseopt.c. * src/cfg.c (cfg_cur_line): New variable. (read_line,parse_config): cfg_line keeps number of the line where the current statement started. cfg_cur_line keeps the actual line number. * src/module.c (smap_modules_unload): New function. (link_databases): Merge into init_databases. (init_databases): New function. (close_databases): New function. (free_databases: New function. * src/query.c (route_query): Rewrite initialization sequence. (match_map,match_cond): Minor fixes. * src/smap.c (smap_session_server): Close databases before returning. (smap_daemon): Return to caller, instead of exiting. (main): Rewrite initialization sequence. * src/smap.h: Include time.h (DBG_DATABASE): New constant. (smap_database_instance)<opened>: New member. (link_databases): Remove proto. (init_databases, free_databases, close_databases): New prototypes. * gint: New module. * Makefile.am (SUBDIRS): Add gint (ACLOCAL_AMFLAGS): Likewise. * bootstrap: Initialize submodules. * configure.ac: Initialize GINT * modules/Makefile.am (SUBDIRS): Add guile (conditionally) * modules/guile/Makefile.am: New file. * modules/guile/guile.c: New file. * include/smap/Makefile.am (smap_module) <smap_open> <smap_close>: New methods. * modules/echo/echo.c: Update module interfaces. Add missing includes. * modules/mbq/mbq.c: Likewise. * modules/mu-auth/mu-auth.c: Likewise. * lib/ostr.c: Add missing includes. * lib/wordsplit.c: Likewise. * src/srvman.c: Minor fixes. * src/url.c: Likewise.
Diffstat (limited to 'include/smap')
-rw-r--r--include/smap/Makefile.am2
-rw-r--r--include/smap/module.h2
-rw-r--r--include/smap/parseopt.h54
3 files changed, 57 insertions, 1 deletions
diff --git a/include/smap/Makefile.am b/include/smap/Makefile.am
index 9b7a2bb..f5055db 100644
--- a/include/smap/Makefile.am
+++ b/include/smap/Makefile.am
@@ -14,5 +14,5 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-pkginclude_HEADERS = ostr.h wordsplit.h kwtab.h module.h diag.h
+pkginclude_HEADERS = ostr.h wordsplit.h kwtab.h module.h diag.h parseopt.h
diff --git a/include/smap/module.h b/include/smap/module.h
index c7f43ea..5375cd8 100644
--- a/include/smap/module.h
+++ b/include/smap/module.h
@@ -41,6 +41,8 @@ struct smap_module {
int (*smap_init)(int argc, char **argv);
smap_database_t (*smap_init_db)(int argc, char **argv);
int (*smap_free_db)(smap_database_t dbp);
+ int (*smap_open) (smap_database_t hp);
+ int (*smap_close) (smap_database_t hp);
int (*smap_query)(smap_database_t dbp,
smap_ostream_t ostr,
const char *map, const char *key,
diff --git a/include/smap/parseopt.h b/include/smap/parseopt.h
new file mode 100644
index 0000000..b4b9da1
--- /dev/null
+++ b/include/smap/parseopt.h
@@ -0,0 +1,54 @@
+/* This file is part of Smap.
+ Copyright (C) 2008, 2010 Sergey Poznyakoff
+
+ Smap is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3, or (at your option)
+ any later version.
+
+ Smap is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Smap. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef __SMAP_PARSEOPT_H
+#define __SMAP_PARSEOPT_H
+
+#include <stdlib.h>
+
+enum smap_opt_type {
+ smap_opt_null,
+ smap_opt_bool,
+ smap_opt_bitmask,
+ smap_opt_bitmask_rev,
+ smap_opt_long,
+ smap_opt_string,
+ smap_opt_enum,
+ smap_opt_const,
+ smap_opt_const_string
+};
+
+struct smap_option {
+ const char *name;
+ size_t len;
+ enum smap_opt_type type;
+ void *data;
+ union {
+ long value;
+ const char **enumstr;
+ } v;
+ int (*func) (struct smap_option *, const char *);
+};
+
+#define SMAP_OPTSTR(s) #s, (sizeof(#s) - 1)
+
+#define SMAP_PARSEOPT_PARSE_ARGV0 0x01
+#define SMAP_PARSEOPT_PERMUTE 0x02
+
+int smap_parseopt(struct smap_option *opt, int argc, char **argv,
+ int flags, int *index);
+
+#endif

Return to:

Send suggestions and report system problems to the System administrator.