[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[dev-serveez] Patch for using Guile
From: |
Martin Grabmueller |
Subject: |
[dev-serveez] Patch for using Guile |
Date: |
Sat, 06 Jan 2001 09:56:08 +0100 |
Hi all,
I already mentioned my hack at using Guile for the config file. Now
Raimi told me that he wanted to play with that, so here's a diff for
what I did to get the stuff running (without much functionality yet,
of course!). Have a look for educational purposes.
'mgrabmue
--
Martin Grabmueller address@hidden
http://www.pintus.de/mgrabmue/ address@hidden on EFnet
===File ~/cvs/serveez/diff==================================
Index: src/Makefile.am
===================================================================
RCS file: /home/cvs/cvsroot/serveez/src/Makefile.am,v
retrieving revision 1.23
diff -u -r1.23 Makefile.am
--- src/Makefile.am 2001/01/04 22:11:59 1.23
+++ src/Makefile.am 2001/01/06 08:37:52
@@ -93,7 +93,7 @@
serveez_DEPENDENCIES = $(PROTOLIBS) $(SIZZLEDEP) \
serveez.cfg serveez1.ico
-serveez_LDADD = $(PROTOLIBS) $(SIZZLESTATIC)
+serveez_LDADD = $(PROTOLIBS) $(SIZZLESTATIC) -lguile
mkpassword_SOURCES = mkpassword.c
Index: src/cfgfile.c
===================================================================
RCS file: /home/cvs/cvsroot/serveez/src/cfgfile.c,v
retrieving revision 1.13
diff -u -r1.13 cfgfile.c
--- src/cfgfile.c 2000/12/16 10:57:23 1.13
+++ src/cfgfile.c 2001/01/06 08:37:58
@@ -40,7 +40,12 @@
#include "serveez.h"
#include "server.h"
#include "libsizzle/libsizzle.h"
+#if !USE_SIZZLE
+#include <guile/gh.h>
+#endif /* !USE_SIZZLE */
+#if USE_SIZZLE
+
/* for backward compatibility with older versions of sizzle core */
#ifndef hashtable_p
# define hashtable_p(c) vector_p(c)
@@ -93,6 +98,8 @@
#define REG_HAVEFLAG(name, location) \
zzz_bind_bool_variable (name, location, 1)
+#endif /* USE_SIZZLE */
+
/*
* Loads the configuration from the .cfg file giving all setup variables
* their default/configured values. Returns -1 on error, caller should
@@ -104,6 +111,7 @@
int retval = 0;
int i;
+#if USE_SIZZLE
/* register all configuration items here */
struct config_t configs[] =
{
@@ -278,5 +286,20 @@
retval = -1;
zzz_finalize ();
+#else /* !USE_SIZZLE */
+ gh_define ("serveez-version", gh_str02scm(serveez_config.version_string));
+ gh_define ("guile-version", scm_version ());
+
+ gh_define ("have-debug", gh_bool2scm(have_debug));
+ gh_define ("have-win32", gh_bool2scm(have_win32));
+
+ gh_define ("serveez-verbosity", gh_int2scm(verbosity));
+ gh_define ("serveez-sockets", gh_int2scm(serveez_config.max_sockets));
+ gh_define ("serveez-pass", gh_str02scm(serveez_config.server_password));
+
+ gh_eval_file (cfgfile);
+
+ /* TODO: Remember vcells, copy back values. */
+#endif /* !USE_SIZZLE */
return retval;
}
Index: src/serveez.c
===================================================================
RCS file: /home/cvs/cvsroot/serveez/src/serveez.c,v
retrieving revision 1.20
diff -u -r1.20 serveez.c
--- src/serveez.c 2000/12/22 20:58:04 1.20
+++ src/serveez.c 2001/01/06 08:38:03
@@ -55,6 +55,10 @@
#include "interface.h"
#include "windoze.h"
+#if !USE_SIZZLE
+#include <guile/gh.h>
+#endif /* !USE_SIZZLE */
+
/*
* The configurations structure of the Serveez. Defined
* in the serveez.h.
@@ -73,7 +77,42 @@
serveez_config.build_string = __serveez_timestamp;
}
+#define FUNC_NAME "define-server!"
+SCM
+define_server_x (SCM type, SCM name, SCM alist)
+{
+ char * ctype;
+ char * cname;
+ SCM cpair;
+
+ SCM_VALIDATE_STRING_COPY (1, type, ctype);
+ SCM_VALIDATE_STRING_COPY (2, name, cname);
+ SCM_VALIDATE_LIST (3, alist);
+
+ while (gh_pair_p (alist))
+ {
+ SCM_VALIDATE_ALISTCELL_COPYSCM (3, alist, cpair);
+ alist = gh_cdr (alist);
+ }
+ log_printf (LOG_DEBUG, "defining server `%s' of type `%s'\n",
+ cname, ctype);
+ return SCM_UNSPECIFIED;
+}
+#undef FUNC_NAME
+
/*
+ * Initialize Guile.
+ */
+static void
+init_guile (void)
+{
+ SCM def_serv;
+
+ scm_init_guile ();
+ def_serv = gh_new_procedure3_0("define-server!", define_server_x);
+}
+
+/*
* Print program version.
*/
static void
@@ -301,7 +340,13 @@
return 2;
}
#endif /* __MINGW32__ */
-
+
+ /*
+ * Initialize the Guile library and define support Scheme
+ * procedures.
+ */
+ init_guile ();
+
/*
* Load configuration
*/
============================================================
- [dev-serveez] Patch for using Guile,
Martin Grabmueller <=