Skip to content
Snippets Groups Projects
Commit 5fee9e75 authored by Per Cederqvist's avatar Per Cederqvist
Browse files

(do_lookup, lookup_person, lookup_conf): New functions.

(legal_name): Set kom_errno to KOM_LONG_STR or KOM_BAD_NAME if it
fails. Updated all callers of legal_name to not set kom_errno.
parent 6a849f9c
No related branches found
No related tags found
No related merge requests found
/*
* $Id: conference.c,v 0.18 1993/01/16 23:16:09 ceder Exp $
* $Id: conference.c,v 0.19 1993/08/05 00:13:25 ceder Exp $
* Copyright (C) 1991 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -28,7 +28,7 @@
* All atomic calls that deals with conferences.
*/
static char *rcsid = "$Id: conference.c,v 0.18 1993/01/16 23:16:09 ceder Exp $";
static char *rcsid = "$Id: conference.c,v 0.19 1993/08/05 00:13:25 ceder Exp $";
#include "rcs.h"
USE(rcsid);
......@@ -125,7 +125,8 @@ do_delete_conf (Conf_no conf_no,
*/
/*
* Return TRUE if NAME is not already used.
* Return TRUE if NAME is not already used. Set kom_errno to
* KOM_LONG_STR or KOM_BAD_NAME if it fails.
*/
Bool
......@@ -133,6 +134,7 @@ legal_name( String name )
{
if (name.len == 0 || name.len > CONF_NAME_LEN )
{
kom_errno = KOM_LONG_STR;
return FALSE;
}
......@@ -141,6 +143,7 @@ legal_name( String name )
if ( /* !isascii(*name.string) && */
!isprint( *name.string ) )
{
kom_errno = KOM_BAD_NAME;
return FALSE;
}
name.string++;
......@@ -343,7 +346,7 @@ change_name (Conf_no conf_no,
if ( !legal_name( new_name ) )
{
kom_errno = KOM_BAD_NAME;
/* kom_errno will be set by legal_name(). */
return FAILURE;
}
......@@ -393,7 +396,7 @@ create_conf(String name,
if ( !legal_name( name ) )
{
kom_errno = KOM_BAD_NAME;
/* kom_errno will be set by legal_name(). */
return 0;
}
......@@ -521,6 +524,61 @@ lookup_name (const String name,
return OK;
}
static Success
do_lookup (const String name,
Conf_no_list * result,
Bool want_persons)
{
Conf_list_old raw_match;
int i;
int retsize;
if ( cached_lookup_name( name, &raw_match ) != OK )
return FAILURE;
/* Find out how much space we need to allocate */
retsize = 0;
for (i = 0; i < raw_match.no_of_conf_nos; i++)
{
/* Don't call check access permissions here. It doesn't matter
that much if we allocate slightly too much memory. */
if (raw_match.type_of_conf[i].letter_box == want_persons)
retsize++;
}
result->conf_nos = tmp_alloc(sizeof(Conf_no) * retsize);
result->no_of_confs = 0;
for (i = 0; i < raw_match.no_of_conf_nos; i++)
{
if (raw_match.type_of_conf[i].letter_box == want_persons
&& fast_access_perm (raw_match.conf_nos[i],
ACTPERS, ACT_P) > none )
{
result->conf_nos[result->no_of_confs++] = raw_match.conf_nos[i];
if (result->no_of_confs > retsize)
restart_kom("ERROR: conference.c: do_lookup: error.\n");
}
}
return OK;
}
extern Success
lookup_person (const String pattern,
Conf_no_list *result)
{
return do_lookup(pattern, result, TRUE);
}
extern Success
lookup_conf (const String pattern,
Conf_no_list *result)
{
return do_lookup(pattern, result, FALSE);
}
/*
* Get status for a conference.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment