Initial import of the CDE 2.1.30 sources from the Open Group.

This commit is contained in:
Peter Howkins
2012-03-10 18:21:40 +00:00
commit 83b6996daa
18978 changed files with 3945623 additions and 0 deletions

View File

@@ -0,0 +1,101 @@
/*%% (c) Copyright 1993, 1994 Hewlett-Packard Company */
/*%% (c) Copyright 1993, 1994 International Business Machines Corp. */
/*%% (c) Copyright 1993, 1994 Sun Microsystems, Inc. */
/*%% (c) Copyright 1993, 1994 Novell, Inc. */
/*%% $XConsortium: iskeyvalid.c /main/3 1995/10/23 11:42:06 rswiston $ */
#ifndef lint
static char sccsid[] = "@(#)iskeyvalid.c 1.3 89/07/17 Copyr 1988 Sun Micro";
#endif
/*
* Copyright (c) 1988 by Sun Microsystems, Inc.
*/
/*
* iskeydesc.c
*
* Description:
* Functions dealing with the keydesc structure.
*
*
*/
#include "isam_impl.h"
static int _check_typelen();
/*
* _validate_keydesc(keydesc, minreclen)
*
* Validate key descriptor. minreclen is needed to make suree that all
* the key parts have a meaningful offset.
*
*/
int
_validate_keydesc(keydesc, minreclen)
register struct keydesc *keydesc;
int minreclen;
{
int nparts;
register int i;
int type, start, length;
int keylen = 0;
nparts = keydesc->k_nparts;
if (nparts <= 0 || nparts > NPARTS)
return (ISERROR);
for (i = 0; i < nparts;i++) {
type = keydesc->k_part[i].kp_type & ~ISDESC;
start = keydesc->k_part[i].kp_start;
length = keydesc->k_part[i].kp_leng;
if(_check_typelen(type, length) == ISERROR)
return (ISERROR);
if (type < MINTYPE || type >= MAXTYPE)
return (ISERROR);
if (start < 0 || start + length > minreclen)
return (ISERROR);
keylen += length;
}
if(keylen > MAXKEYSIZE)
return (ISERROR);
return (ISOK);
}
/*
* _check_typelen()
*
* Check length against the length of the corresponding type.
*/
static int
_check_typelen(type, length)
int type;
int length;
{
switch (type) {
case INTTYPE:
return ((length == INTSIZE) ? ISOK : ISERROR);
case LONGTYPE:
return ((length == LONGSIZE) ? ISOK : ISERROR);
case FLOATTYPE:
return ((length == FLOATSIZE) ? ISOK : ISERROR);
case DOUBLETYPE:
return ((length == DOUBLESIZE) ? ISOK : ISERROR);
case CHARTYPE:
case BINTYPE:
return ((length > 0) ? ISOK : ISERROR);
default:
return (ISERROR);
}
}