2002-07-08 Clinton Ebadi <clinton@unknownlamer.org>
+ * source/BotInterp.C (RunHooks): Changed iterators to
+ reverse_iterators because the hooks list is sorted in ascending
+ order--higher priority and fallthrough hooks appear _after_ the
+ lower priority and non-fallthrough hooks.
+
+ * source/Main.C (print_long_help): Added function
+ (print_short_help): Renamed from printUsage
+ (namespace): Most stuff in here is now defined in an anonymouse
+ namespace so it doesn't have external linkage
+ (real_main): Uses getopt_long instead of getopt. Added several
+ command line arguments (bobotpp --help for a full list).
+
+ * scripts/bobot-utils.scm (bot-load): Function moved from
+ bobot-scheme.scm
+
+ * source/Interp.C (Startup): Autoloads
+ PREFIX/bobotpp/scripts/bobot-utils.scm now
+ (Startup): New Scheme variable: bot-sys-scripts-dir (system
+ scripts dir)
+
+ * source/bobot-scheme.scm.in: Removed
+
+ * source/Makefile.am: Removed bobot-scheme.scm compiliation
+
+ * configure.ac (PREFIX): configure.ac defined prefix now
+
* source/Main.C (real_main): Default configuration is now read
from /etc/bobotpp/default
* source/bobot-scheme.scm.in: Added file. This defines the
DIST_COMMON = README ./stamp-h.in AUTHORS COPYING ChangeLog INSTALL \
Makefile.am Makefile.in NEWS TODO acinclude.m4 aclocal.m4 \
config.h.in configure configure.ac depcomp install-sh missing \
- mkinstalldirs
+ mkinstalldirs texinfo.tex
DIST_SUBDIRS = $(SUBDIRS)
all: config.h
$(MAKE) $(AM_MAKEFLAGS) all-recursive
Also as of version 1.98, you must have Guile 1.5.6+ or 1.6.x in order
to compile scripting support.
+Version 2.1.0: Hook!
+- Hooks can now be fallthrough or non fallthrough. You can set a hooks
+ priority and whether or not it falls through (i.e. continues hook
+ matching after it has been executed) using two optional args to
+ (bot-addhook). The new args are pri (integer priority) and fallthru
+ (#t or #f) and are at the end. Higher priority hooks are executed
+ before lower priority hooks, and fallthrough hooks are executed
+ before non-fallthrough hooks.
+- The default config is read from ~/.bobotpp/config/default/ or
+ /etc/bobotpp/default/ if the user config is not found. Put your
+ default config is either dir. You may also specify a specific config
+ under these dirs using the --config or -c arg to bobotpp (see
+ bobotpp --help for the full list of commands you may use and how to
+ use them).
+- Scripts are now stored in ~/.bobotpp/scripts/ or
+ PREFIX/bobotpp/scripts (where PREFIX is /usr/local unless you
+ changed it with the --prefix arg to configure). The new function
+ bot-load will take a filename and load it from these dirs, returning
+ #t if the file was loaded and #f if it wasn't. You can modify the
+ search list by appending to %bot-loadpath.
+- bobot-utils.scm is now autoloaded, so you don't need to
+ load it if you want to use its functions.
+
+
Version 2.0: Stable release / CVS merges
- Merged stuff from Etienne Bernard's dev tree that he was working on
before I took over (not much)
adds the Bot* first arg as Interp::bot. This would eliminate a lot
of the type checking. OTOH, I'll have to look in to this more when
I get back.
-* Use getopt long
-* User config dir
+* Audit code and see what data in classes should be made private and
+ have getters/setters added (e.g. logFileName in Bot--if this is
+ changed the log file doesn't change after the Bot is started).
Networking:
* Add a networked interface to guile repl
* Menu:
* Introduction::
+* Configuration::
+* Scripting::
+* Concept Index::
+* Function Index::
+* Variable Index::
\1f
-File: bobot++.info, Node: Introduction, Prev: Top, Up: Top
+File: bobot++.info, Node: Introduction, Next: Configuration, Prev: Top, Up: Top
Introduction
************
- This manual contains nothing. Stay tuned.
+ This manual feels abused and neglected because it has almost no
+content.
+\1f
+File: bobot++.info, Node: Configuration, Next: Scripting, Prev: Introduction, Up: Top
+
+Configuration
+*************
+
+ Bobot++ is easy to configure. The configuration file format may be
+changing in the 2.1 series, so it is not documented for now. See the
+`examples' directory for an example configuration.
+
+* Menu:
+
+* Configuration File Syntax::
+* Configure File Placement::
+
+\1f
+File: bobot++.info, Node: Configuration File Syntax, Next: Configure File Placement, Prev: Configuration, Up: Configuration
+
+Configuration File Syntax
+=========================
+
+ Not here yet.
+
+\1f
+File: bobot++.info, Node: Configure File Placement, Prev: Configuration File Syntax, Up: Configuration
+
+Configuration File Placement
+============================
+
+ Bobot++ will look in `/etc/bobotpp/default/' for its default config
+if none is specified on the command line. Put the configuration files
+you want to be loaded by default in this directory. If you are not root
+or you want to have your own personal configration, put it in
+`~/.bobotpp/config/default/'.
+
+\1f
+File: bobot++.info, Node: Scripting, Next: Concept Index, Prev: Configuration, Up: Top
+
+Scripting
+*********
+
+ Bobot++'s most powerful feature is its scripting system. You write
+scripts using Guile Scheme. This manual does not cover how to use Guile
+or how to learn Scheme. *Note Guile Reference Manual: (guile)Top, for
+the Guile reference manual and
+<http://www.ccs.neu.edu/home/dorai/t-y-scheme/t-y-scheme.html> for a
+good tutorial on Scheme.
+
+\1f
+File: bobot++.info, Node: Concept Index, Next: Function Index, Prev: Scripting, Up: Top
+
+Concept Index
+*************
+
+* Menu:
+\1f
+File: bobot++.info, Node: Function Index, Next: Variable Index, Prev: Concept Index, Up: Top
+
+Function Index
+**************
+
+* Menu:
+\1f
+File: bobot++.info, Node: Variable Index, Prev: Function Index, Up: Top
+
+Variable Index
+**************
+
+* Menu:
\1f
Tag Table:
Node: Top\7f517
-Node: Introduction\7f817
+Node: Introduction\7f905
+Node: Configuration\7f1096
+Node: Configuration File Syntax\7f1478
+Node: Configure File Placement\7f1680
+Node: Scripting\7f2154
+Node: Concept Index\7f2607
+Node: Function Index\7f2739
+Node: Variable Index\7f2878
\1f
End Tag Table
Not here yet.
@node Configure File Placement, , Configuration File Syntax, Configuration
-@section Configure File Placement
+@section Configuration File Placement
Bobot++ will look in @file{/etc/bobotpp/default/} for its default
config if none is specified on the command line. Put the configuration
-files you want to be loaded by default in this directory. FIXME: add
-bobot++ config in user home dir.
+files you want to be loaded by default in this directory. If you are
+not root or you want to have your own personal configration, put it in
+@file{~/.bobotpp/config/default/}.
@node Scripting, Concept Index, Configuration, Top
@chapter Scripting
Bobot++'s most powerful feature is its scripting system. You write
scripts using Guile Scheme. This manual does not cover how to use
-Guile or how to learn Scheme. @xref{Top, Guile Reference Manual,
-guile}, for the Guile reference manual and
+Guile or how to learn Scheme. @xref{Top, , Guile Reference Manual,
+guile, The Guile Reference Manual}, for the Guile reference manual and
@url{http://www.ccs.neu.edu/home/dorai/t-y-scheme/t-y-scheme.html} for
a good tutorial on Scheme.
#undef USESCRIPTS
#undef MULTITHREAD
#undef NOCRYPT
+#undef PREFIX
# Define the identity of the package.
PACKAGE=Bobot++
-VERSION=2.1.0
+VERSION=2.1.0CVS
cat >>confdefs.h <<_ACEOF
#define PACKAGE "$PACKAGE"
done
+
+if test "x$prefix" == "xNONE"
+then
+ cat >>confdefs.h <<_ACEOF
+#define PREFIX "$ac_default_prefix"
+_ACEOF
+
+else
+ cat >>confdefs.h <<_ACEOF
+#define PREFIX "$prefix"
+_ACEOF
+
+fi
+
ac_config_files="$ac_config_files source/Makefile"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
dnl Process this file with autoconf to produce a configure script.
AC_PRERQ(2.50)
AC_INIT(source/Makefile.in)
-AM_INIT_AUTOMAKE([Bobot++], [2.1.0])
+AM_INIT_AUTOMAKE([Bobot++], [2.1.0CVS])
AM_CONFIG_HEADER(config.h)
dnl Options
AC_TYPE_SIGNAL
AC_CHECK_FUNCS(select socket strtoul)
+
+dnl PREFIX
+if test "x$prefix" == "xNONE"
+then
+ AC_DEFINE_UNQUOTED(PREFIX, "$ac_default_prefix")
+else
+ AC_DEFINE_UNQUOTED(PREFIX, "$prefix")
+fi
+
dnl Generates the makefiles
dnl AC_OUTPUT(source/bobot-scheme.scm)
AC_OUTPUT(source/Makefile)
;;; this is a library of stuff that bobot++ scripts would probably
-;;; want to use.
+;;; want to use. This file is autoloaded by bobot++
;;; This file is covered by the GPL version 2 or (at your option) any
;;; later version
;;; must be GPLed, so all of your scripts have to be GPLed anyway
;;; because you are really linking with Bobot++, a GPLed program!
+;;; Bot load (loads a file from %bot-loadpath)
+
+(define %bot-loadpath (list
+ (string-append (getenv "HOME")
+ "/.bobotpp/scripts")
+ bot-sys-scripts-dir))
+
+(define (bot-load file)
+ (let loop ((load-path %bot-loadpath))
+ (if (not (null? load-path))
+ (if (catch 'system-error
+ (lambda ()
+ (load
+ (string-append (car load-path)
+ file)))
+ (lambda args
+ #f ))
+ #t
+ (loop (cdr load-path)))
+ #f )))
+
+
;;; REGEX UTILS
;;; match-not-channel adds a prefix regex to your regex so it doesn't
;;;; Misc UTILS
;;; bot-log: Write as many messages as you want to the log. If the
-;;; arg is a procedure it will be executed and it's output will be
+;;; arg is a thunk it will be executed and it's output will be
;;; written to the log
(define (bot-log . messages)
(map
(lambda (x)
- (if (procedure? x)
+ (if (thunk? x)
(display (x) (bot-logport))
(display x (bot-logport))))
messages )
BotInterp::RunHooks(int hooktype, String match, SCM args)
{
SCM result;
- std::list<Hook *>::iterator it = hooksMap[hooktype].begin();
- std::list<Hook *>::iterator it2 = hooksMap[hooktype].end();
+ // We want to execute higher priority hooks first, so we start at
+ // the end of the list instead of the beggining
+ std::list<Hook *>::reverse_iterator it = hooksMap[hooktype].rbegin();
+ std::list<Hook *>::reverse_iterator it2 = hooksMap[hooktype].rend();
wrapper_data wd;
wd.args = args;
for ( ; it != it2; ++it) {
{
// scm_primitive_load_path(scm_makfrom0str("ice-9/boot-9.scm"));
- scm_primitive_load (scm_makfrom0str ("/etc/bobotpp/bobot-scheme.scm"));
+ scm_c_define ("bot-sys-scripts-dir",
+ scm_makfrom0str (String(PREFIX) +
+ "/share/bobotpp/scripts/"));
+ scm_primitive_load
+ (scm_makfrom0str (String(PREFIX) +
+ "/share/bobotpp/scripts/bobot-utils.scm"));
bot_new_procedure ("bot-action", (SCMFunc)ScriptCommands::Action, 2, 0, 0);
scm_c_define_gsubr ("bot-adduser", 5, 2, 0,
#include <cstdio>
#include <csignal>
#include <cstdlib>
+#include <getopt.h>
#ifdef USESCRIPTS
#include "Interp.H"
#include "Bot.H"
+namespace
+{
Bot *b;
+option bot_options[] =
+{
+ { "help", no_argument, 0, 'h' },
+ { "version", no_argument, 0, 'v' },
+ { "no-background", no_argument, 0, 'b'},
+ { "config-file", required_argument, 0, 'f'},
+ { "config-dir", required_argument, 0, 'd'},
+ { "config", required_argument, 0, 'c'},
+ { "sys-config", required_argument, 0, 's'},
+ { "user-config", required_argument, 0, 'u'},
+ { "debug", no_argument, 0, 'D' }
+};
+
void sig_hup(int) {
if (b) {
b->userList->read();
}
}
-void printUsage(char *name)
+void print_version ()
{
- std::cout << "Usage: " << name << " [-h] [-b] [-f file] [-d dir] [-D]\n"
- " -h Shows this help.\n"
- " -b Do not run in background.\n"
+ std::cerr << VERSION_STRING << std::endl
+ << COPYRIGHT_STRING << std::endl
+ << PACKAGE" comes with ABSOLUTELY NO WARRANTY\n"
+ << "This is free software, and you are welcome to redistribute it\n"
+ << "under certain conditions; See the COPYING file for details.\n";
+}
+void print_short_help (const char *name)
+{
+ std::cerr << "Usage: " << name << " [--help] [--version] [--no-background]\n\t"
+ << "[--config-file file] [--config-dir dir] [--debug]\n\t"
+ << "[--config dir-under-configpath]\n\t"
+ << "[--sys-config dir-in-sysconfdir]\n\t"
+ << "[--user-config dir-userdir] [--debug]\n"
+ << "\n--help shows long help.\n";
+ /* " -b Do not run in background.\n"
" -f file Use file as config file.\n"
" -d dir Use dir as current dir.\n"
" -c config Use config as config\n"
" -s config Use config as config (only search sysdir)\n"
" -u config Use config as config (only search userdir)\n"
" -D Debug mode (input/output printing and no background mode.\n";
+ */
+}
+
+void print_long_help (const char *name)
+{
+ std::cerr << "Long Help for " << PACKAGE << std::endl;
+ std::cerr <<
+ "The manual (info bobot++) will contain the best information on general\n"
+ "usage of Bobot++. Here is a detailed summary of the command line\n"
+ "arguments: (in long arg short arg format). All args are optional.\n";
+ print_short_help (name);
+ std::cerr <<
+"[--help][-h] Shows this help and exits\n"
+"[--version][-v] Shows version information and exits\n"
+"[--no-background][-b] Run bobot++ in the foreground\n"
+"[--config-file file][-f] Use file instead of bot.conf\n"
+"[--config-dir dir][-d] Use dir as dir to load config file from\n"
+"[--config dir][-c] Search your config path (defaults to\n"
+" "
+ << getenv ("HOME")
+ << "/.bobotpp/config/ and then\n"
+ <<
+" /etc/bobotpp/) for dir and\n"
+" then loads your config data using dir\n"
+"[--sys-config dir][-s] Looks for config in /etc/bobotpp/dir. Note\n"
+" that the user dir is still searched first\n"
+"[--user-config dir][-u] Looks for config in\n"
+" "
+ << getenv("HOME")
+ << "/.bobotpp/config/dir/.\n"
+ <<
+" Note that\n"
+" the system dir is still searched after this if\n"
+" dir is not found.\n"
+"[--debug][-D] Makes Bobot++ print debugging info and run in\n"
+" the foreground"
+ << std::endl
+ << std::endl
+ << "The default configuration is read from\n"
+ << getenv("HOME")
+ << "/.bobotpp/config/default/ and then\n"
+ "/etc/bobotpp/default/ if the user config is not found.\n";
}
static void real_main(void* DONOTUSE, int argc, char **argv)
{
// FIXME: User directory
int opt;
- extern char *optarg;
bool background = true;
String configFile = "bot.conf";
String cmd_directory = "";
std::signal(SIGHUP, sig_hup);
// We parse the command line options
- while ((opt = getopt(argc,argv,"hbf:d:c:D")) != EOF)
+ while ((opt = getopt_long (argc,argv,"vhbf:d:c:D", bot_options, 0))
+ != -1)
switch (opt) {
case 'h':
- printUsage(argv[0]); exit(0);
+ print_long_help (argv[0]);
+ exit(0);
+ break;
+ case 'v':
+ print_version ();
+ exit (0);
+ break;
case 'b':
background = false;
break;
debug = true;
break;
default:
- printUsage(argv[0]); exit(1);
+ print_short_help (argv[0]);
+ exit(1);
}
if (!cmd_directory.length ())
std::exit (2);
}
- std::cout << COPYRIGHT_STRING <<
- "\n"PACKAGE" comes with ABSOLUTELY NO WARRANTY\n"
- "This is free software, and you are welcome to redistribute it\n"
- "under certain conditions; See the COPYING file for details.\n";
+ // std::cout << COPYRIGHT_STRING <<
+ // "\n"PACKAGE" comes with ABSOLUTELY NO WARRANTY\n"
+ // "This is free software, and you are welcome to redistribute it\n"
+ // "under certain conditions; See the COPYING file for details.\n";
+ print_version ();
if (!debug) {
if (background)
#endif
}
+} // static functions and data
+
int main(int argc, char **argv) {
#ifdef USESCRIPTS
scm_boot_guile (argc, argv, real_main, 0);
bobotpp_LDADD = @GUILE_LDFLAGS@
-bobot-scheme.scm: bobot-scheme.scm.in
- sed -e 's|\!pkgdatadir\!|@datadir@\/bobotpp|g' bobot-scheme.scm.in > bobot-scheme.scm
+#bobot-scheme.scm: bobot-scheme.scm.in
+# sed -e 's|\!pkgdatadir\!|@datadir@\/bobotpp|g' bobot-scheme.scm.in > bobot-scheme.scm
-scmconfigdir = /etc/bobotpp
-scmconfig_DATA = bobot-scheme.scm
\ No newline at end of file
+#scmconfigdir = /etc/bobotpp
+#scmconfig_DATA = bobot-scheme.scm
\ No newline at end of file
# TelnetServer.C \
# TelnetServer.H
bobotpp_LDADD = @GUILE_LDFLAGS@
-
-scmconfigdir = /etc/bobotpp
-scmconfig_DATA = bobot-scheme.scm
subdir = source
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/config.h
CCLD = $(CC)
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
DIST_SOURCES = $(bobotpp_SOURCES)
-DATA = $(scmconfig_DATA)
-
DIST_COMMON = Makefile.am Makefile.in
SOURCES = $(bobotpp_SOURCES)
$(CXXCOMPILE) -c -o $@ `cygpath -w $<`
CXXDEPMODE = @CXXDEPMODE@
uninstall-info-am:
-install-scmconfigDATA: $(scmconfig_DATA)
- @$(NORMAL_INSTALL)
- $(mkinstalldirs) $(DESTDIR)$(scmconfigdir)
- @list='$(scmconfig_DATA)'; for p in $$list; do \
- if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
- f="`echo $$p | sed -e 's|^.*/||'`"; \
- echo " $(INSTALL_DATA) $$d$$p $(DESTDIR)$(scmconfigdir)/$$f"; \
- $(INSTALL_DATA) $$d$$p $(DESTDIR)$(scmconfigdir)/$$f; \
- done
-
-uninstall-scmconfigDATA:
- @$(NORMAL_UNINSTALL)
- @list='$(scmconfig_DATA)'; for p in $$list; do \
- f="`echo $$p | sed -e 's|^.*/||'`"; \
- echo " rm -f $(DESTDIR)$(scmconfigdir)/$$f"; \
- rm -f $(DESTDIR)$(scmconfigdir)/$$f; \
- done
tags: TAGS
done
check-am: all-am
check: check-am
-all-am: Makefile $(PROGRAMS) $(DATA)
+all-am: Makefile $(PROGRAMS)
installdirs:
- $(mkinstalldirs) $(DESTDIR)$(bindir) $(DESTDIR)$(scmconfigdir)
+ $(mkinstalldirs) $(DESTDIR)$(bindir)
install: install-am
install-exec: install-exec-am
info-am:
-install-data-am: install-scmconfigDATA
+install-data-am:
install-exec-am: install-binPROGRAMS
mostlyclean-am: mostlyclean-compile mostlyclean-generic
-uninstall-am: uninstall-binPROGRAMS uninstall-info-am \
- uninstall-scmconfigDATA
+uninstall-am: uninstall-binPROGRAMS uninstall-info-am
.PHONY: GTAGS all all-am check check-am clean clean-binPROGRAMS \
clean-generic distclean distclean-compile distclean-depend \
distclean-generic distclean-tags distdir dvi dvi-am info \
info-am install install-am install-binPROGRAMS install-data \
install-data-am install-exec install-exec-am install-info \
- install-info-am install-man install-scmconfigDATA install-strip \
- installcheck installcheck-am installdirs maintainer-clean \
+ install-info-am install-man install-strip installcheck \
+ installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-compile \
mostlyclean-generic tags uninstall uninstall-am \
- uninstall-binPROGRAMS uninstall-info-am uninstall-scmconfigDATA
+ uninstall-binPROGRAMS uninstall-info-am
+
+#bobot-scheme.scm: bobot-scheme.scm.in
+# sed -e 's|\!pkgdatadir\!|@datadir@\/bobotpp|g' bobot-scheme.scm.in > bobot-scheme.scm
-bobot-scheme.scm: bobot-scheme.scm.in
- sed -e 's|\!pkgdatadir\!|@datadir@\/bobotpp|g' bobot-scheme.scm.in > bobot-scheme.scm
+#scmconfigdir = /etc/bobotpp
+#scmconfig_DATA = bobot-scheme.scm
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
+++ /dev/null
-;;; This is -*- guile-scheme -*-
-;;; This is also bobot-scheme.scm.in
-
-;;; DO NOT MODIFY bobot-scheme.scm! It is automatically generated from
-;;; bobot-scheme.scm.in!
-
-;;; This file provides bot-load
-
-(define bot-sys-scripts-dir "!pkgdatadir!/scripts/")
-
-(define %bot-load-path (list (string-append (getenv "HOME")
- "/.bobotpp/scripts/")
- bot-sys-scripts-dir))
-
-(define (bot-load file)
- (let loop ((load-path %bot-load-path))
- (if (not (null? load-path))
- (if (catch 'system-error
- (lambda ()
- (load
- (string-append (car load-path)
- file)))
- (lambda args
- #f ))
- #t
- (loop (cdr load-path)))
- #f )))