Commit 8cd5a079 authored by Per Cederqvist's avatar Per Cederqvist
Browse files

(lookup_regexp): Return a Conf_z_info_list instead

	of a Conf_no_list.  New parameter: want_confs.
(downgrade): New static function.
(re_lookup_person, re_lookup_conf): Use downgrade to adapt to the
	new API of lookup_regexp.
(re_z_lookup): New function.
parent 20fb7a0b
/*
* $Id: regex-match.c,v 1.9 1994/04/05 08:04:23 ceder Exp $
* $Id: regex-match.c,v 1.10 1994/12/31 11:57:28 ceder Exp $
* Copyright (C) 1992, 1993 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -27,7 +27,7 @@
* Regexp matching
*/
static char *rcsid = "$Id: regex-match.c,v 1.9 1994/04/05 08:04:23 ceder Exp $";
static char *rcsid = "$Id: regex-match.c,v 1.10 1994/12/31 11:57:28 ceder Exp $";
#include "rcs.h"
USE(rcsid);
......@@ -53,18 +53,20 @@ USE(rcsid);
#include "log.h"
static Success
lookup_regexp (const String regexp,
Conf_no_list *result,
Bool want_persons)
lookup_regexp (const String regexp,
Conf_z_info_list *result,
Bool want_persons,
Bool want_confs)
{
struct re_pattern_buffer pat_buf;
Conf_no conf_no;
String name = EMPTY_STRING;
const char *errmsg;
Conf_type type;
/* +++ Unnecessary to allocate this much if only one conference matches. */
result->conf_nos = tmp_alloc (cached_no_of_existing_conferences()
* sizeof(Conf_no));
result->confs = tmp_alloc (cached_no_of_existing_conferences()
* sizeof(Conf_z_info));
result->no_of_confs = 0;
re_syntax_options = RE_SYNTAX_GREP;
......@@ -86,7 +88,8 @@ lookup_regexp (const String regexp,
for (conf_no = 0; (conf_no = traverse_conference(conf_no)) != 0;)
{
if (cached_get_conf_type(conf_no).letter_box == want_persons
type = cached_get_conf_type(conf_no);
if ((type.letter_box ? want_persons : want_confs)
&& fast_access_perm (conf_no, ACTPERS, ACT_P) > none )
{
name = cached_get_name(conf_no);
......@@ -100,7 +103,9 @@ lookup_regexp (const String regexp,
break;
default:
/* It matched. (Ignore where it matched). */
result->conf_nos[result->no_of_confs++] = conf_no;
result->confs[result->no_of_confs].conf_no = conf_no;
result->confs[result->no_of_confs].name = name;
result->confs[result->no_of_confs++].type = type;
break;
}
}
......@@ -111,11 +116,31 @@ lookup_regexp (const String regexp,
return OK;
}
static void
downgrade(Conf_z_info_list *in,
Conf_no_list *out)
{
int ix;
out->conf_nos = tmp_alloc(sizeof(Conf_no) * in->no_of_confs);
out->no_of_confs = in->no_of_confs;
for (ix = 0; ix < in->no_of_confs; ix++)
{
out->conf_nos[ix] = in->confs[ix].conf_no;
}
}
Success
re_lookup_person (const String regexp,
Conf_no_list *result)
{
return lookup_regexp(regexp, result, TRUE);
Conf_z_info_list tmp;
Success retval;
retval = lookup_regexp(regexp, &tmp, TRUE, FALSE);
if (retval == OK)
downgrade(&tmp, result);
return retval;
}
......@@ -123,5 +148,20 @@ Success
re_lookup_conf (const String regexp,
Conf_no_list *result)
{
return lookup_regexp(regexp, result, FALSE);
Conf_z_info_list tmp;
Success retval;
retval = lookup_regexp(regexp, &tmp, FALSE, TRUE);
if (retval == OK)
downgrade(&tmp, result);
return retval;
}
Success
re_z_lookup (const String regexp,
int want_persons,
int want_confs,
Conf_z_info_list *result)
{
return lookup_regexp(regexp, result, want_persons, want_confs);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment