From c0481e3bc4ef4565e8732a4743b03fb96a9dbb34 Mon Sep 17 00:00:00 2001
From: Per Cederqvist <ceder@lysator.liu.se>
Date: Sat, 19 Dec 1992 00:25:47 +0000
Subject: [PATCH] Regular expression matching of conference and person names.

---
 Config                           |  5 +++--
 src/include/config.h             |  3 ++-
 src/include/kom-errno.h          |  3 ++-
 src/include/services.h           | 11 ++++++++++-
 src/libraries/Makefile           |  5 +++--
 src/libraries/regex/Makefile.in  | 26 +++++++++++++++++++++++++-
 src/libraries/regex/Makefile.src | 26 +++++++++++++++++++++++++-
 src/server/cache.h               | 14 ++++++++++++--
 src/server/fncdef.txt            |  6 ++++--
 src/server/prot-a.c              |  6 ++++--
 src/server/server-config.c       |  5 +++--
 src/server/simple-cache.c        | 19 ++++++++++++++++---
 12 files changed, 109 insertions(+), 20 deletions(-)

diff --git a/Config b/Config
index 0ed2b1b09..5889b012c 100755
--- a/Config
+++ b/Config
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $Id: Config,v 1.10 1992/04/14 19:19:40 ceder Exp $
+# $Id: Config,v 1.11 1992/12/19 00:25:02 ceder Exp $
 # Copyright (C) 1991  Lysator Academic Computer Association.
 #
 # This file is part of the LysKOM server.
@@ -23,7 +23,7 @@
 #
 # Please mail bug reports to bug-lyskom@lysator.liu.se. 
 #
-# $Id: Config,v 1.10 1992/04/14 19:19:40 ceder Exp $
+# $Id: Config,v 1.11 1992/12/19 00:25:02 ceder Exp $
 
 x=
 
@@ -56,4 +56,5 @@ error)	false;;
 	ln -s ../config/${x}-defs.make scripts/import.make
 	( cd config; make SYSTEM=${x} config )
 	( cd src/include/ansi/${x} ; make SYSTEM=${x} config )
+	( cd src/libraries/regex ; ./configure )
 esac
diff --git a/src/include/config.h b/src/include/config.h
index b8a0be590..a3b3dece2 100644
--- a/src/include/config.h
+++ b/src/include/config.h
@@ -1,5 +1,5 @@
 /*
- * $Id: config.h,v 0.6 1992/11/22 15:14:15 ceder Exp $
+ * $Id: config.h,v 0.7 1992/12/19 00:25:08 ceder Exp $
  * Copyright (C) 1991  Lysator Academic Computer Association.
  *
  * This file is part of the LysKOM server.
@@ -119,6 +119,7 @@ extern const int WHAT_DO_LEN;	/* what_am_i_doing */
 extern const int USERNAME_LEN;	/* Max login-id from clients */
 extern const int TEXT_LEN;	/* Max len of a text. */
 extern const int BROADCAST_LEN;	/* Max len of a broadcast message */
+extern const int REGEXP_LEN;	/* Max len of regexp. */
 
 /* Text_stat limits */
 
diff --git a/src/include/kom-errno.h b/src/include/kom-errno.h
index 986344dec..8fdf8965d 100644
--- a/src/include/kom-errno.h
+++ b/src/include/kom-errno.h
@@ -1,5 +1,5 @@
 /*
- * $Id: kom-errno.h,v 0.2 1991/09/15 10:13:03 linus Exp $
+ * $Id: kom-errno.h,v 0.3 1992/12/19 00:25:11 ceder Exp $
  * Copyright (C) 1991  Lysator Academic Computer Association.
  *
  * This file is part of the LysKOM server.
@@ -89,6 +89,7 @@ typedef enum
     KOM_CLIENT_IS_CRAZY = 41,	/* Client thinks that server says it can't
 				 * understand client. */
     KOM_UNDEF_SESSION = 42,	/* No such session exists. */
+    KOM_REGEX_ERROR = 43,	/* Regexp compilation failed. */
     not_used			/* Det {r jobbigt att flytta kommatecknet hela
 				   tiden... :-) /ceder */
 } Kom_err;
diff --git a/src/include/services.h b/src/include/services.h
index 900c39e84..630342d76 100644
--- a/src/include/services.h
+++ b/src/include/services.h
@@ -1,5 +1,5 @@
 /*
- * $Id: services.h,v 0.8 1992/04/01 20:46:05 ceder Exp $
+ * $Id: services.h,v 0.9 1992/12/19 00:25:14 ceder Exp $
  * Copyright (C) 1991  Lysator Academic Computer Association.
  *
  * This file is part of the LysKOM server.
@@ -216,6 +216,15 @@ KOM_( lookup_name (const String	 name,
 		   Conf_list	*result));
 #endif
 
+/* Two functions for matching regexps. */
+extern  Success
+KOM_( re_lookup_person (const String  regexp,
+			Conf_no_list  *result));
+
+extern  Success
+KOM_( re_lookup_conf (const String  regexp,
+		      Conf_no_list  *result));
+
 extern  Success
 KOM_( get_conf_stat_old (Conf_no	conf_no,
 			 int		mask,
diff --git a/src/libraries/Makefile b/src/libraries/Makefile
index ac6246569..3aef192e3 100644
--- a/src/libraries/Makefile
+++ b/src/libraries/Makefile
@@ -1,5 +1,5 @@
 #
-# $Id: Makefile,v 0.10 1992/04/15 23:06:07 ceder Exp $
+# $Id: Makefile,v 0.11 1992/12/19 00:25:19 ceder Exp $
 # Copyright (C) 1991  Lysator Academic Computer Association.
 #
 # This file is part of the LysKOM server.
@@ -30,7 +30,8 @@ include $(SCRIPTDIR)/import.make
 # All directories that make should traverse to when doing clean etc.
 # Note that client-support depends on libmisc.
 
-SUBDIRS = libansi libmisc libisc libcommon client-support laclib libisc-new
+SUBDIRS = libansi libmisc libisc libcommon client-support laclib libisc-new \
+	regex
 
 all: includes libraries binaries
 
diff --git a/src/libraries/regex/Makefile.in b/src/libraries/regex/Makefile.in
index ed945788c..3239d920d 100644
--- a/src/libraries/regex/Makefile.in
+++ b/src/libraries/regex/Makefile.in
@@ -43,19 +43,43 @@ DEFS = @DEFS@
 
 SHELL = /bin/sh
 
+# Special support for LysKOM
+include Topdir.make
+SCRIPTDIR = $(TOPDIR)/scripts
+
+include $(SCRIPTDIR)/import.make
+
 subdirs = doc test
 
 default all:: regex.o
 .PHONY: default all
 
+LIBNAME = libregex$(PROFILE-LIB-SUFFIX).a
+LIBOBJS = regex.o
+INSTALL-HDRS = regex.h
+
+$(LIBNAME): $(LIBOBJS)
+	$(AR) $(ARFLAGS) $(LIBNAME) $?
+	$(RANLIB) $(LIBNAME)
+
+libraries: $(LIBNAME)
+	$(RM) $(LIBDIR)/$(LIBNAME)
+	cp $(LIBNAME) $(LIBDIR)/$(LIBNAME)
+	$(TOUCHLIB) $(LIBDIR)/$(LIBNAME)
+
+include $(SCRIPTDIR)/install-includes.make
+
+binaries:;
+
 regex.o: regex.c regex.h
 	$(CC) $(CFLAGS) $(CPPFLAGS) $(DEFS) -I. -I$(srcdir) -c $<
 
 clean mostlyclean::
-	rm -f *.o
+	$(RM) ${OBJECTS} $(GENERIC-CLEAN)
 
 distclean:: clean
 	rm -f Makefile config.status
+	$(RM) $(GENERIC-DIST-CLEAN)
 
 realclean:: distclean
 	rm -f configure
diff --git a/src/libraries/regex/Makefile.src b/src/libraries/regex/Makefile.src
index ed945788c..3239d920d 100644
--- a/src/libraries/regex/Makefile.src
+++ b/src/libraries/regex/Makefile.src
@@ -43,19 +43,43 @@ DEFS = @DEFS@
 
 SHELL = /bin/sh
 
+# Special support for LysKOM
+include Topdir.make
+SCRIPTDIR = $(TOPDIR)/scripts
+
+include $(SCRIPTDIR)/import.make
+
 subdirs = doc test
 
 default all:: regex.o
 .PHONY: default all
 
+LIBNAME = libregex$(PROFILE-LIB-SUFFIX).a
+LIBOBJS = regex.o
+INSTALL-HDRS = regex.h
+
+$(LIBNAME): $(LIBOBJS)
+	$(AR) $(ARFLAGS) $(LIBNAME) $?
+	$(RANLIB) $(LIBNAME)
+
+libraries: $(LIBNAME)
+	$(RM) $(LIBDIR)/$(LIBNAME)
+	cp $(LIBNAME) $(LIBDIR)/$(LIBNAME)
+	$(TOUCHLIB) $(LIBDIR)/$(LIBNAME)
+
+include $(SCRIPTDIR)/install-includes.make
+
+binaries:;
+
 regex.o: regex.c regex.h
 	$(CC) $(CFLAGS) $(CPPFLAGS) $(DEFS) -I. -I$(srcdir) -c $<
 
 clean mostlyclean::
-	rm -f *.o
+	$(RM) ${OBJECTS} $(GENERIC-CLEAN)
 
 distclean:: clean
 	rm -f Makefile config.status
+	$(RM) $(GENERIC-DIST-CLEAN)
 
 realclean:: distclean
 	rm -f configure
diff --git a/src/server/cache.h b/src/server/cache.h
index 624025315..8c76b7fa9 100644
--- a/src/server/cache.h
+++ b/src/server/cache.h
@@ -1,5 +1,5 @@
 /*
- * $Id: cache.h,v 0.9 1992/11/22 15:14:37 ceder Exp $
+ * $Id: cache.h,v 0.10 1992/12/19 00:25:32 ceder Exp $
  * Copyright (C) 1991  Lysator Academic Computer Association.
  *
  * This file is part of the LysKOM server.
@@ -23,7 +23,7 @@
  * Please mail bug reports to bug-lyskom@lysator.liu.se. 
  */
 /*
- * $Id: cache.h,v 0.9 1992/11/22 15:14:37 ceder Exp $
+ * $Id: cache.h,v 0.10 1992/12/19 00:25:32 ceder Exp $
  *
  * This file contains the cached data that the server stores.
  * .h file created by ceder 1990-04-18
@@ -98,6 +98,13 @@ cached_conf_exists( Conf_no conf_no );
 extern Conf_type
 cached_get_conf_type (Conf_no conf_no);
 
+/*
+ * Return number of conferences present.  (Actually, return a number
+ * at least as large as the number of conferences present).
+ */
+extern Conf_no
+cached_no_of_existing_conferences(void);
+
 /*
  * Get garb_nice for a certain conference.
  * It is set when mark_conference_as_changed is called.
@@ -105,6 +112,9 @@ cached_get_conf_type (Conf_no conf_no);
 extern Garb_nice
 cached_get_garb_nice (Conf_no conf_no);
 
+extern String
+cached_get_name (Conf_no conf_no);
+
 extern Local_text_no
 cached_get_highest_local_no (Conf_no conf_no);
 
diff --git a/src/server/fncdef.txt b/src/server/fncdef.txt
index c1116858d..61c95d7b3 100644
--- a/src/server/fncdef.txt
+++ b/src/server/fncdef.txt
@@ -1,5 +1,5 @@
 #
-# $Id: fncdef.txt,v 0.9 1992/04/01 20:46:37 ceder Exp $
+# $Id: fncdef.txt,v 0.10 1992/12/19 00:25:35 ceder Exp $
 # Copyright (C) 1991  Lysator Academic Computer Association.
 #
 # This file is part of the LysKOM server.
@@ -22,7 +22,7 @@
 #
 # Please mail bug reports to bug-lyskom@lysator.liu.se. 
 #
-# $Id: fncdef.txt,v 0.9 1992/04/01 20:46:37 ceder Exp $
+# $Id: fncdef.txt,v 0.10 1992/12/19 00:25:35 ceder Exp $
 # 
 # This file is used to describe the functions in services.c. All
 # functions that are reachable from the clients are listed here, together
@@ -100,3 +100,5 @@ success find_previous_text_no num : text_no
 success login	 	 num c_string (PWD_LEN) num
 success who_is_on_ident : who_info_ident_list
 success get_session_info_ident   num : session_info_ident
+success re_lookup_person c_string (REGEXP_LEN) : conf_no_list
+success re_lookup_conf   c_string (REGEXP_LEN) : conf_no_list
diff --git a/src/server/prot-a.c b/src/server/prot-a.c
index 0b4010398..acd8cf26a 100644
--- a/src/server/prot-a.c
+++ b/src/server/prot-a.c
@@ -1,5 +1,5 @@
 /*
- * $Id: prot-a.c,v 0.15 1992/05/18 23:09:23 ceder Exp $
+ * $Id: prot-a.c,v 0.16 1992/12/19 00:25:38 ceder Exp $
  * Copyright (C) 1991  Lysator Academic Computer Association.
  *
  * This file is part of the LysKOM server.
@@ -26,7 +26,7 @@
  * Protocol A.
  */
 
-static char *rcsid = "$Id: prot-a.c,v 0.15 1992/05/18 23:09:23 ceder Exp $";
+static char *rcsid = "$Id: prot-a.c,v 0.16 1992/12/19 00:25:38 ceder Exp $";
 
 
 #include <stdio.h>
@@ -318,6 +318,8 @@ prot_a_is_legal_fnc(Call_header fnc)
     case call_fnc_who_is_on_ident:
     case call_fnc_get_session_info_ident:
     case call_fnc_login:
+    case call_fnc_re_lookup_person:
+    case call_fnc_re_lookup_conf:
 	return TRUE;
 
     default:
diff --git a/src/server/server-config.c b/src/server/server-config.c
index dbe7ca3cc..1c7df86a6 100644
--- a/src/server/server-config.c
+++ b/src/server/server-config.c
@@ -1,5 +1,5 @@
 /*
- * $Id: server-config.c,v 0.18 1992/06/11 19:16:16 ceder Exp $
+ * $Id: server-config.c,v 0.19 1992/12/19 00:25:41 ceder Exp $
  * Copyright (C) 1991  Lysator Academic Computer Association.
  *
  * This file is part of the LysKOM server.
@@ -32,7 +32,7 @@
 #include <config.h>
 #include <m-config.h>
 
-static char *rcsid = "$Id: server-config.c,v 0.18 1992/06/11 19:16:16 ceder Exp $";
+static char *rcsid = "$Id: server-config.c,v 0.19 1992/12/19 00:25:41 ceder Exp $";
 
 
 
@@ -90,6 +90,7 @@ const int WHAT_DO_LEN	=  60;	/* what_am_i_doing */
 const int USERNAME_LEN	= 128;	/* Max login-id from clients */
 const int TEXT_LEN      =131072;/* Max len of a text. */
 const int BROADCAST_LEN = 1024;	/* Max len of a broadcast message */
+const int REGEXP_LEN  = 1024;	/* Max len of regexp. */
 
 /* Text_stat limits */
 
diff --git a/src/server/simple-cache.c b/src/server/simple-cache.c
index f53c61131..d0c68fc06 100644
--- a/src/server/simple-cache.c
+++ b/src/server/simple-cache.c
@@ -1,5 +1,5 @@
 /*
- * $Id: simple-cache.c,v 0.29 1992/11/30 23:29:16 linus Exp $
+ * $Id: simple-cache.c,v 0.30 1992/12/19 00:25:47 ceder Exp $
  * Copyright (C) 1991  Lysator Academic Computer Association.
  *
  * This file is part of the LysKOM server.
@@ -33,7 +33,7 @@
  * New save algorithm by ceder.
  */
 
-static char *rcsid = "$Id: simple-cache.c,v 0.29 1992/11/30 23:29:16 linus Exp $";
+static char *rcsid = "$Id: simple-cache.c,v 0.30 1992/12/19 00:25:47 ceder Exp $";
 
 
 /*
@@ -345,7 +345,15 @@ cached_get_conf_type (Conf_no conf_no)
     return small_conf_arr [ conf_no ]->type;
 }
 
-
+/*
+ * Return number of conferences present.  (Actually, return a number
+ * at least as large as the number of conferences present).
+ */
+extern Conf_no
+cached_no_of_existing_conferences(void)
+{
+    return next_free_num;	/* This is too large, but who cares? */
+}
 
 /*
  * Various function calls to tell the cache that something is changed.
@@ -990,6 +998,11 @@ cached_get_garb_nice (Conf_no conf_no)
     return small_conf_arr [ conf_no ]->nice;
 }
 
+extern String
+cached_get_name (Conf_no conf_no)
+{
+    return small_conf_arr [ conf_no ]->name;
+}
 
 extern Local_text_no
 cached_get_highest_local_no (Conf_no conf_no)
-- 
GitLab