/**********************************************************************
 
	Copyright (C) 2003 Hirohisa MORI <joshua@nichibun.ac.jp>
 
	This program is free software; you can redistribute it 
	and/or modify it under the terms of the GLOBALBASE 
	Library General Public License (G-LGPL) as published by 

	http://www.globalbase.org/
 
	This program is distributed in the hope that it will be 
	useful, but WITHOUT ANY WARRANTY; without even the 
	implied warranty of MERCHANTABILITY or FITNESS FOR A 
	PARTICULAR PURPOSE.

**********************************************************************/



#include "utils.h"


int
get_attr_flags(int * er,L_CHAR * attr,ATTR_TABLE * at)
{
L_CHAR * f;
int ret;
int len;
	ret = 0;
	*er = 0;
retry:
	for ( ; at->flag_name ; at ++ ) {
		f = l_string(std_cm,at->flag_name);
		if ( memcmp(attr,f,(len=l_strlen(f))*sizeof(L_CHAR)) == 0 ) {
			ret |= at->flag;
			attr += len;
			switch ( *attr ) {
			case ':':
				attr ++;
				goto retry;
			case 0:
				return ret;
			default:
				break;
			}
		}
	}
	if ( er )
		*er = -1;
	return ret;
}

