Просмотр исходного кода

Merge branch 'build-cleanups' into next

* build-cleanups:
  Re-enable TCL by default now that the warnings are fixed.
  Fix generate_defs.sh to respect sections such as #ifdef USE_SCRIPT_TCL.
  Cleanup stringfix dependencies
  Fix help not being garbled.
  Remove the need for makehelp
  Don't use hard-coded indices which will be bad if doc/responses.txt is reordered.
  r_banned() can be inlined
  Remove responses size craziness
  Remove the need for makeres
  Fix spelling
  Remove the need for makeset

Conflicts:
	configure
	src/Makefile.in
	src/generate_defs.sh
Bryan Drewery 11 лет назад
Родитель
Сommit
e642d40203
18 измененных файлов с 187 добавлено и 270 удалено
  1. 5 50
      Makefile.in
  2. 4 0
      build/autotools/configure.ac
  3. 42 0
      build/makehelp.sh
  4. 36 0
      build/makeres.sh
  5. 18 0
      build/makeset.sh
  6. 4 0
      configure
  7. 1 1
      doc/UPDATES
  8. 1 1
      doc/responses.txt
  9. 1 5
      src/.gitignore
  10. 20 14
      src/Makefile.in
  11. 4 0
      src/dl.h
  12. 3 2
      src/generate_defs.sh
  13. 1 1
      src/main.cc
  14. 0 107
      src/makeres.cc
  15. 0 50
      src/makeset.cc
  16. 8 32
      src/response.cc
  17. 36 0
      src/response.h
  18. 3 7
      src/stringfix.cc

+ 5 - 50
Makefile.in

@@ -26,8 +26,6 @@ VERSION 	:= $(shell git describe)
 DISTRIB = wraith-$(VERSION)
 
 HELPFILE = doc/help.txt
-SETTINGSFILE = doc/settings.txt
-RESPONSESFILE = doc/responses.txt
 
 # defaults
 CXX = @CCACHE@ @DISTCC@ @CXX@
@@ -74,14 +72,14 @@ MAKE_UTILS_NR = $(MAKE) 'CXX=$(CXX)' 'STRIP=touch' 'INCLUDES=$(INCLUDES)' \
 
 MAKE_CONFIG = $(MAKE) 'MAKE=$(MAKE)'
 
-.PHONY: checkclean.static checkclean.dynamic checkclean.debug lib wraith dwraith lib.debug debug test general crypto utils sorthelp makehelp makeset makeres stringfix set res help sort indent tar distrib distclean clean cleanutils test all dynamic static tags
+.PHONY: checkclean.static checkclean.dynamic checkclean.debug lib wraith dwraith lib.debug debug test general crypto utils sorthelp stringfix sort indent tar distrib distclean clean cleanutils test all dynamic static tags
 
 all: dynamic
 
 test:
 
 cleanutils:
-	@rm -f $(STRINGFIX) src/sorthelp@EXEEXT@ src/makehelp@EXEEXT@ src/makeres@EXEEXT@ src/makeset@EXEEXT@
+	@rm -f $(STRINGFIX) src/sorthelp@EXEEXT@
 
 clean:  cleanutils
 	+@cd src && $(MAKE) clean
@@ -90,7 +88,7 @@ clean:  cleanutils
 	+@cd src/mod && $(MAKE) clean
 	-+@cd lib && $(MAKE) clean
 	@rm -f $(BINEXEC) build/stamp.* *~ src/*~ configure.temp .mangled stamp.*
-	@rm -f src/help.h src/response.h src/responses.h utctime@EXEEXT@ ts@EXEEXT@
+	@rm -f utctime@EXEEXT@ ts@EXEEXT@
 
 distclean: clean
 	@rm -rf *-$(VERSION)/ autom4te.cache/ autoscan.log configure.scan
@@ -145,61 +143,18 @@ sort: sorthelp
 	@(src/sorthelp@EXEEXT@ $(HELPFILE) $(HELPFILE) || (cp -f help.txt~ $(HELPFILE); echo "Sort failed, restoring backup."))
 	@rm -f help.txt~
 
-help: makehelp
-	@src/makehelp@EXEEXT@ $(HELPFILE) src/help.h~
-	@(if [ ! -f src/help.h ]; then \
-	touch src/help.h; \
-	fi)
-	@(if test "x`$(DIFF) -qurN src/help.h~ src/help.h`" != "x"; then \
-	cp -f src/help.h~ src/help.h; \
-	fi)
-
-set: makeset
-	@src/makeset@EXEEXT@ $(SETTINGSFILE) src/set_default.h~
-	@(if [ ! -f src/set_default.h ]; then \
-	touch src/set_default.h; \
-	fi)
-	@(if test "x`$(DIFF) -qurN src/set_default.h~ src/set_default.h`" != "x"; then \
-	cp -f src/set_default.h~ src/set_default.h; \
-	fi)
-
-
-res: makeres
-	@src/makeres@EXEEXT@ $(RESPONSESFILE) src/ 1
-	@(if [ ! -f src/response.h ]; then \
-	touch src/response.h; \
-	fi)
-	@(if [ ! -f src/responses.h ]; then \
-	touch src/responses.h; \
-	fi)
-	@(if test "x`$(DIFF) -qurN src/response.h~ src/response.h`" != "x"; then \
-	cp -f src/response.h~ src/response.h; \
-	fi)
-	@(if test "x`$(DIFF) -qurN src/responses.h~ src/responses.h`" != "x"; then \
-	cp -f src/responses.h~ src/responses.h; \
-	fi)
-
 stringfix: src/stringfix.cc src/config.h
 	+@cd src && ${MAKE_UTILS} stringfix
 
-makeres: src/makeres.cc
-	+@cd src && ${MAKE_UTILS} makeres
-
-makeset: src/makeset.cc
-	+@cd src && ${MAKE_UTILS} makeset
-
-makehelp: src/makehelp.cc
-	+@cd src && ${MAKE_UTILS} makehelp
-
 sorthelp: src/sorthelp.cc
 	+@cd src && ${MAKE_UTILS} sorthelp
 
-utils: stringfix makehelp
+utils: stringfix
 
 crypto:
 	+@cd src/crypto && ${MAKE_UTILS} crypto
 
-general: help res set stringfix
+general: stringfix
 
 .NOTPARALLEL: checkclean.static checkclean.dynamic checkclean.debug
 

+ 4 - 0
build/autotools/configure.ac

@@ -259,6 +259,10 @@ if test -d .git; then
   git submodule init
   git submodule update
   git submodule foreach --recursive git clean -fdx
+  # Restore as it may have been removed by an older 'make distclean'
+  if ! test -f src/response.h; then
+    git checkout src/response.h
+  fi
 fi
 ]
 

+ 42 - 0
build/makehelp.sh

@@ -0,0 +1,42 @@
+#! /bin/sh
+
+echo "/* Generated by $0 */"
+echo "#include \"cmds.h\""
+echo "help_t help[] = {"
+needcomma=0
+IFS="
+"
+sed -e 's,["],\\&,g' | while read -r line; do
+	if [ -z "${line%%:*}" ]; then
+		if [ ${needcomma} -eq 1 ]; then
+			printf "\""
+			[ ${garble} -eq 1 ] && printf ")"
+			printf "},\n"
+		fi
+		line="${line#:}"
+		garble=0
+		if [ "${line%:}" != "${line}" ]; then
+			garble=1
+			line="${line%:}"
+		fi
+		type="${line%:*}"
+		cmd="${line#*:}"
+		[ "${cmd}" = "end" ] && break
+		case ${type} in
+			hub)  type_int=1 ;;
+			leaf) type_int=2 ;;
+			*)    type_int=0 ;;
+		esac
+
+		if [ ${garble} -eq 0 ]; then
+			printf "  {%d, \"%s\", %d, \"" ${type_int} "${cmd}" ${garble}
+		else
+			printf "  {%d, \"%s\", %d, STR(\"" ${type_int} "${cmd}" ${garble}
+	fi
+		needcomma=0
+	else
+		printf "%s\\\n" "${line}"
+		needcomma=1
+	fi
+done
+echo "};"

+ 36 - 0
build/makeres.sh

@@ -0,0 +1,36 @@
+#! /bin/sh
+
+echo "/* Generated by $0 */"
+needcomma=0
+types=
+while read -r line; do
+	[ -z "${line%%#*}" ] && continue # skip comments
+	if [ -z "${line%%:*}" ]; then
+		[ ${needcomma} -eq 1 ] && printf ",\n};\n\n"
+		type="${line#:}"
+		[ "${type}" = "end" ] && break
+		printf "static const char* res_%s[] = {\n" "${type}"
+		needcomma=0
+		types="${types}${types:+ }${type}"
+	else
+		[ ${needcomma} -eq 1 ] && printf ",\n"
+		printf "\t\"%s\"" "${line}"
+		needcomma=1
+	fi
+done
+
+echo "typedef struct {"
+echo "  const char*  name;"
+echo "  const char** res;"
+echo "  const size_t size;"
+echo "} res_t;"
+echo
+echo "static const res_t res[] = {"
+needcomma=0
+for type in ${types}; do
+	[ ${needcomma} -eq 1 ] && printf ",\n"
+	printf "\t{\"%s\",\tres_%s,\tsizeof(res_%s)/sizeof(res_%s[0])}" "${type}" "${type}" "${type}" "${type}"
+	needcomma=1
+done
+echo
+echo "};"

+ 18 - 0
build/makeset.sh

@@ -0,0 +1,18 @@
+#! /bin/sh
+
+echo "/* Generated by $0 */"
+needcomma=0
+while read -r line; do
+	[ -z "${line%%#*}" ] && continue # skip comments
+	if [ -z "${line%%:*}" ]; then
+		[ ${needcomma} -eq 1 ] && printf "\"\n\n"
+		type="${line#:}"
+		[ "${type}" = "end" ] && break
+		printf "#define DEFAULT_%s \"%c\n" $(echo "${type}" | tr '[:lower:]' '[:upper:]') '\'
+		needcomma=0
+	else
+		[ ${needcomma} -eq 1 ] && printf ",%c\n" '\'
+		printf "%s" "${line}"
+		needcomma=1
+	fi
+done

+ 4 - 0
configure

@@ -9099,6 +9099,10 @@ if test -d .git; then
   git submodule init
   git submodule update
   git submodule foreach --recursive git clean -fdx
+  # Restore as it may have been removed by an older 'make distclean'
+  if ! test -f src/response.h; then
+    git checkout src/response.h
+  fi
 fi
 
 

+ 1 - 1
doc/UPDATES

@@ -13,7 +13,7 @@ master
   * Require C++11 compiler support (G++ 4.7+, clang32+)
 
 maint
-  * Disable demo TCL support by default to prevent confusion during build.
+  * Fix TCL warnings during build if TCL is not being used.
 
 1.4.5
   * Remove ahbl as it now positively identifies all hosts as abusive

+ 1 - 1
doc/responses.txt

@@ -15,7 +15,7 @@
 :manualop
  Manual opping is not allowed
 :manualopped
- Manuaally opped
+ Manually opped
 :closed
  Channel is closed
 :flood

+ 1 - 5
src/.gitignore

@@ -4,15 +4,11 @@
 /_*.cc
 /*~
 /help.h
-/response.h
-/responses.h
+/responses.cc
 /.deps
 /.defs
 /stringfix
-/makehelp
 /sorthelp
-/makeres
-/makeset
 /set_default.h
 *.o
 *.So

+ 20 - 14
src/Makefile.in

@@ -11,6 +11,9 @@ CXXFLAGS = $(CXXFLAGS)
 CFLAGS = $(CFLGS)
 CPPFLAGS = @CPPFLAGS@ -I. -I$(top_srcdir) -I$(top_srcdir)/lib -I$(top_srcdir)/pack @DEFS@ $(INCLUDES) '-DCOMMIT="$(COMMIT)"' '-DBRANCH="$(BRANCH)"' -DBUILDTS=$(BUILDTS) '-DVERSION="$(VERSION)"'
 LDFLAGS = @LDFLAGS@
+SETTINGSFILE = $(top_srcdir)/doc/settings.txt
+RESPONSESFILE = $(top_srcdir)/doc/responses.txt
+HELPFILE = $(top_srcdir)/doc/help.txt
 
 include $(top_srcdir)/build/build.mk
 
@@ -76,27 +79,30 @@ blah:
 	@echo "Use the build script."
 	@echo ""
 
-makeres: makeres.cc ../lib/bdlib/libbdlib.a
-	@echo -e "Compiling: \033[1mmakeres\033[0m"
-	@$(CXX) $(CPPFLAGS) -I$(top_srcdir)/src -I$(top_srcdir)/pack $(CXXFLAGS) $< ../lib/bdlib/libbdlib.a $(LDFLAGS) -o $@
-	@$(STRIP) $@@EXEEXT@
+set.cc: set_default.h
 
-makeset: makeset.cc ../lib/bdlib/libbdlib.a
-	@echo -e "Compiling: \033[1mmakeset\033[0m"
-	@$(CXX) $(CPPFLAGS) -I$(top_srcdir)/src -I$(top_srcdir)/pack $(CXXFLAGS) $< ../lib/bdlib/libbdlib.a $(LDFLAGS) -o $@
-	@$(STRIP) $@@EXEEXT@
+set_default.h: $(SETTINGSFILE) $(top_srcdir)/build/makeset.sh
+	@echo -e "[H]	\033[1m$*\033[0m"
+	@$(top_srcdir)/build/makeset.sh < $(SETTINGSFILE) > $@
 
-makehelp: makehelp.cc ../lib/bdlib/libbdlib.a
-	@echo -e "Compiling: \033[1mmakehelp\033[0m"
-	@$(CXX) $(CPPFLAGS) -I$(top_srcdir)/src -I$(top_srcdir)/pack $(CXXFLAGS) $< ../lib/bdlib/libbdlib.a $(LDFLAGS) -o $@
-	@$(STRIP) $@@EXEEXT@
+response.cc: responses.cc
+
+responses.cc: $(RESPONSESFILE) $(top_srcdir)/build/makeres.sh
+	@echo -e "[CC]	\033[1m$*\033[0m"
+	@$(top_srcdir)/build/makeres.sh < $(RESPONSESFILE) > $@
+
+cmds.cc: help.h
+
+help.h: $(HELPFILE) $(top_srcdir)/build/makehelp.sh stringfix
+	@echo -e "[H]	\033[1m$*\033[0m"
+	@$(top_srcdir)/build/makehelp.sh < $(HELPFILE) | ./stringfix > $@
 
 sorthelp: sorthelp.cc ../lib/bdlib/libbdlib.a
 	@echo -e "Compiling: \033[1msorthelp\033[0m"
 	@$(CXX) $(CPPFLAGS) -I$(top_srcdir)/src -I$(top_srcdir)/pack $(CXXFLAGS) $< ../lib/bdlib/libbdlib.a $(LDFLAGS) -o $@
 	@$(STRIP) $@@EXEEXT@
 
-stringfix: stringfix.cc common.h config.h eggdrop.h
+stringfix: stringfix.cc
 	@echo -e "Compiling: \033[1mstringfix\033[0m"
 	@$(CXX) $(CPPFLAGS) -I$(top_srcdir) -I$(top_srcdir)/pack $(CXXFLAGS) $< $(LDFLAGS) -o stringfix
 	@$(STRIP) $@@EXEEXT@
@@ -116,7 +122,7 @@ stringfix: stringfix.cc common.h config.h eggdrop.h
 $(EGGEXEC): stringfix ../$(EGGEXEC)
 
 clean:
-	@rm -f .depend *.o *.So *~ _*.c _*.cc *.ii *.i
+	@rm -f .depend *.o *.So *~ _*.c _*.cc *.ii *.i set_default.h responses.cc help.h
 
 build_msg:
 	@echo "[*] Compiling core components"

+ 4 - 0
src/dl.h

@@ -32,4 +32,8 @@
 
 extern bd::HashTable<bd::String, FunctionPtr> dl_symbol_table;
 
+#ifdef GENERATE_DEFS
+#undef DLSYM_GLOBAL
+#endif
+
 #endif /* !_DL_H_ */

+ 3 - 2
src/generate_defs.sh

@@ -13,6 +13,7 @@ INCLUDES="${TCL_INCLUDES} ${SSL_INCLUDES}"
 mkdir -p src/.defs > /dev/null 2>&1
 TMPFILE=$(mktemp "/tmp/pre.XXXXXX")
 files=$(grep -l DLSYM_GLOBAL src/*.cc|grep -v "src/_")
+
 for file in ${files}; do
   suffix=${file##*.}
   basename=${file%%.*}
@@ -44,13 +45,13 @@ for file in ${files}; do
   echo "extern \"C\" {" > $defsFile_post
 
   cd src
-  $CXX $CXXFLAGS -E -I. -I.. -I../lib ${INCLUDES} -DHAVE_CONFIG_H ../${file} > $TMPFILE
+  $CXX $CXXFLAGS -E -I. -I.. -I../lib ${INCLUDES} -DHAVE_CONFIG_H -DGENERATE_DEFS ../${file} > $TMPFILE
   # Fix wrapped prototypes
   $SED -e :a -e N -e '$!ba' -e 's/,\n/,/g' $TMPFILE > $TMPFILE.sed
   mv $TMPFILE.sed $TMPFILE
   cd ..
 
-  for symbol in $($SED -n -e 's/.*DLSYM_GLOBAL(.*, \([^)]*\).*/\1/p' $file|sort -u); do
+  for symbol in $($SED -n -e 's/.*DLSYM_GLOBAL(.*, \([^)]*\).*/\1/p' $TMPFILE|sort -u); do
     # Check if the typedef is already defined ...
     typedef=$(grep "^typedef .*(\*${symbol}_t)" ${dirname}/${basename}.h)
     # ... if not, generate it

+ 1 - 1
src/main.cc

@@ -826,7 +826,7 @@ int main(int argc, char **argv)
   Auth::InitTimer();
   init_vars();			/* needed for cfg */
   init_botcmd();
-  init_responses();		/* zeros out response[] */
+  init_responses();
 
   egg_dns_init();
   channels_init();

+ 0 - 107
src/makeres.cc

@@ -1,107 +0,0 @@
-
-#include <bdlib/src/String.h>
-#include <bdlib/src/Stream.h>
-#include <string.h>
-#include <stdio.h>
-#include <ctype.h>
-#include <stdlib.h>
-#include <algorithm>
-
-int skipline (const char *line, int *skip) {
-  static int multi = 0;
-  if ((!strncmp(line, "//", 2))) {
-    (*skip)++;
-  } else if ( (strstr(line, "/*")) && (strstr(line, "*/")) ) {
-    multi = 0;
-    (*skip)++;
-  } else if ( (strstr(line, "/*")) ) {
-    (*skip)++;
-    multi = 1;
-  } else if ( (strstr(line, "*/")) ) {
-    multi = 0;
-  } else {
-    if (!multi) (*skip) = 0;
-  }
-  return (*skip);
-}
-
-int parse_res(const bd::String& inFile, const bd::String& outFile, const bd::String& outsFile) {
-  bd::Stream in, out, outs;
-  bd::String buffer, cmd, buf, lower_resps;
-
-  int skip = 0, total_responses = 0;
-
-  in.loadFile(inFile);
-  printf("Parsing res file '%s'", inFile.c_str());
-
-  out << bd::String::printf( "/* DO NOT EDIT THIS FILE. */\n\
-#ifndef _RESPONSE_H\n\
-#define _RESPONSE_H\n\
-\n\
-typedef unsigned int response_t;\n\n\
-enum {\n");
-
-  outs << bd::String::printf("/* DO NOT EDIT THIS FILE. */\n\
-#ifndef _RESPONSES_H\n\
-#define _RESPONSES_H\n\
-\n\
-typedef const char * res_t;\n\n");
-
-  while (in.tell() < in.length()) {
-    buffer = in.getline().chomp();
-    if ((skipline(buffer.c_str(), &skip))) continue;
-    if (buffer[0] == ':') { /* New cmd */
-      if (cmd.length()) {		/* CLOSE LAST RES */
-        out << ",\n";	/* for enum */
-        outs << "\tNULL\n};\n\n";
-        cmd.clear();
-      }
-
-      cmd = buffer(1);
-      if (cmd != "end") {		/* NEXT RES */
-        ++total_responses;
-        printf(".");
-
-        bd::String cmdUpper(cmd);
-        std::transform(cmdUpper.begin(), cmdUpper.end(), cmdUpper.mdata(), (int(*)(int)) toupper);
-        out << bd::String::printf("\tRES_%s", cmdUpper.c_str());
-        if (total_responses == 1)
-          out << " = 1";
-        outs << bd::String::printf("static res_t res_%s[] = {\n", cmd.c_str());
-        lower_resps += bd::String::printf(",\n\tres_%s", cmd.c_str());
-      } else {			/* END */
-        out << bd::String::printf("\tRES_END\n};\n\n#define RES_TYPES %d\n", total_responses);
-        out << bd::String::printf("const char *response(response_t);\nvoid init_responses();\nconst char *r_banned(struct chanset_t* chan);\n\n#endif /* !_RESPONSE_H */\n");
-        outs << bd::String::printf("static res_t *res[] = {\n\tNULL%s\n};\n#endif /* !_RESPONSES_H */\n", lower_resps.c_str());
-      }
-    } else {				/* NEXT RES TEXT */
-      ++buffer;
-      outs << bd::String::printf("\t\"%s\",\n", buffer.c_str());
-    }
-  }
-
-  if (out.writeFile(outFile)) {
-    fprintf(stderr, "Failure writing %s\n", outFile.c_str());
-    return 1;
-  }
-
-  if (outs.writeFile(outsFile)) {
-    fprintf(stderr, "Failure writing %s\n", outsFile.c_str());
-    return 1;
-  }
-
-  printf(" Success\n");
-
-  return 0;
-}
-
-int main(int argc, char **argv) {
-  if (argc < 3) return 1;
-
-  bd::String in(argv[1]), out, outs;
-
-  out = bd::String::printf("%s/response.h%s", argv[2], argc == 4 ? "~" : "");
-  outs = bd::String::printf("%s/responses.h%s", argv[2], argc == 4 ? "~" : "");
-  return parse_res(in, out, outs);
-}
-/* vim: set sts=2 sw=2 ts=8 et: */

+ 0 - 50
src/makeset.cc

@@ -1,50 +0,0 @@
-#include <bdlib/src/Stream.h>
-#include <bdlib/src/String.h>
-#include <cctype>
-#include <algorithm>
-#include <cstring>
-using namespace std;
-
-int main(int argc, char *argv[]) {
-  if (argc == 2)
-    return 1;
-
-  bd::Stream file, out;
-  file.loadFile(argv[1]);
-
-  bd::String type, line;
-  char c;
-
-  while (file.tell() < file.length()) {
-    line = file.getline().chomp();
-    if (line[0] == '#') continue;
-    if (line[0] == ':') {
-      type = line(1);
-      if (type == "end")
-        break;
-
-      transform(type.begin(), type.end(), type.mdata(), (int(*)(int)) toupper);
-
-      type = "DEFAULT_" + type;
-      out << "#define " << type << " \"\\" << "\n";
-    } else {
-      if (!type.length()) 
-        continue;
-
-      out << line;
-      c = file.peek()[0];
-      if (strchr("\n:", c)) {
-        out << "\"\n\n";
-        type = "";
-      } else
-        out << ",\\\n";
-    }
-  }
-
-  if (out.writeFile(argv[2])) {
-    fprintf(stderr, "Failure writing %s\n", argv[2]);
-    return 1;
-  }
-  return 0;
-}
-/* vim: set sts=2 sw=2 ts=8 et: */

+ 8 - 32
src/response.cc

@@ -5,49 +5,25 @@
  *
  */
 
-
 #include "common.h"
 #include "response.h"
-#include "main.h"
-#include "responses.h"
+#include "responses.cc"
+#include <bdlib/src/HashTable.h>
+#include <vector>
 
-static response_t response_totals[RES_TYPES + 1];
+static bd::HashTable<const char*, std::vector<const char*> > res_map;
 
 void
 init_responses()
 {
-  for (response_t i = 0; i <= RES_TYPES; i++)
-    response_totals[i] = 0;
-}
-
-static void
-count_responses(response_t type)
-{
-  response_t total = 0;
-
-  for (total = 0; res[type][total]; total++) 
-    ;
-
-  response_totals[type] = total;
-  /* printf("Type: %d has %d total responses!\n", type, response_totals[type]); */
+  for (size_t i = 0; i < sizeof(res)/sizeof(res[0]); ++i)
+    res_map[res[i].name] = std::vector<const char*>(res[i].res,
+        res[i].res + res[i].size);
 }
 
 const char *
 response(response_t type)
 {
-  if (!type)
-    type = randint(RES_TYPES) + 1;
-
-  /* wait to count the totals until it's used for the first time */
-  if (!response_totals[type])
-    count_responses(type);
-
-  return res[type][randint(response_totals[type])];
-}
-
-const char *
-r_banned(struct chanset_t *chan)
-{
-  return response(RES_BANNED);
+  return res_map[type].at(randint(res_map[type].size()));
 }
 /* vim: set sts=2 sw=2 ts=8 et: */

+ 36 - 0
src/response.h

@@ -0,0 +1,36 @@
+#ifndef _RESPONSE_H
+#define _RESPONSE_H
+
+#define RES_BANNED	"banned"
+#define RES_KICKBAN	"kickban"
+#define RES_MASSDEOP	"massdeop"
+#define RES_BADOP	"badop"
+#define RES_BADOPPED	"badopped"
+#define RES_BITCHOP	"bitchop"
+#define RES_BITCHOPPED	"bitchopped"
+#define RES_MANUALOP	"manualop"
+#define RES_MANUALOPPED	"manualopped"
+#define RES_CLOSED	"closed"
+#define RES_FLOOD	"flood"
+#define RES_NICKFLOOD	"nickflood"
+#define RES_KICKFLOOD	"kickflood"
+#define RES_REVENGE	"revenge"
+#define RES_USERNAME	"username"
+#define RES_PASSWORD	"password"
+#define RES_BADUSERPASS	"baduserpass"
+#define RES_MIRCVER	"mIRCver"
+#define RES_MIRCSCRIPT	"mIRCscript"
+#define RES_OTHERSCRIPT	"otherscript"
+
+typedef const char* response_t;
+
+void init_responses();
+const char *response(response_t);
+
+inline const char *
+r_banned(struct chanset_t *chan)
+{
+  return response(RES_BANNED);
+}
+
+#endif /* !_RESPONSE_H */

+ 3 - 7
src/stringfix.cc

@@ -9,16 +9,12 @@
 #include <stdio.h>
 #include <string.h>
 
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#define WTF 1524
+#define MAX_LINE_LEN 16384
 int help = 0;
 
 void garble(char **inptr, char **outptr)
 {
-  char *in = *inptr, *out = NULL, *p = NULL, obuf[WTF] = "";
+  char *in = *inptr, *out = NULL, *p = NULL, obuf[MAX_LINE_LEN] = "";
   size_t chars = 0;
   unsigned char x = 0;
 
@@ -98,7 +94,7 @@ void garble(char **inptr, char **outptr)
 
 void processline(char *line)
 {
-  char tmpin[WTF] = "", tmpout[WTF] = "", *in = NULL, *out = NULL;
+  char tmpin[MAX_LINE_LEN] = "", tmpout[MAX_LINE_LEN] = "", *in = NULL, *out = NULL;
   size_t outlen = 0;
 
   strcpy(tmpin, line);