3 // Copyright (C) 2004 Enrico Scholz <ensc@delenn.intern.sigma-chemnitz.de>
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; version 2 of the License.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 #include "lib_internal/util-dimof.h"
29 #define DECL(STR, VAL) { STR, sizeof(STR)-1, VAL }
32 char const * const id;
35 } const FLAGVALUES[] = {
36 DECL("fakeinit", S_CTX_INFO_INIT),
40 vc_text2flag(char const *str, size_t len)
43 if (len==0) len=strlen(str);
45 for (i=0; i<sizeof(FLAGVALUES)/sizeof(FLAGVALUES[0]); ++i)
46 if (len==FLAGVALUES[i].len &&
47 strncmp(FLAGVALUES[i].id, str, len)==0)
48 return FLAGVALUES[i].val;
54 vc_hiflag2text(uint_least64_t val)
59 for (i=S_CTX_INFO_INIT, idx=DIM_OF(FLAGVALUES); i>0 && idx>0; i/=2) {
61 if (val & i) return FLAGVALUES[idx].id;