blob: 22a81faa209a7649e9824f395795a22fdddc7b47 [file] [log] [blame]
Vikram Narayanana8111cf2012-04-14 15:25:13 +05301/*****************************************************************************\
2 * layout_common.c
3 *****************************************************************************
4 * Copyright (C) 2012, Vikram Narayanan
5 * Unified build_opt_tbl and nvramtool
6 * build_opt_tbl.c
7 * Copyright (C) 2003 Eric Biederman (ebiederm@xmission.com)
8 * Copyright (C) 2007-2010 coresystems GmbH
9 *
10 * This file is part of nvramtool, a utility for reading/writing coreboot
11 * parameters and displaying information from the coreboot table.
12 * For details, see http://coreboot.org/nvramtool.
13 *
14 * Please also read the file DISCLAIMER which is included in this software
15 * distribution.
16 *
17 * This program is free software; you can redistribute it and/or modify it
18 * under the terms of the GNU General Public License (as published by the
19 * Free Software Foundation) version 2, dated June 1991.
20 *
21 * This program is distributed in the hope that it will be useful, but
22 * WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
24 * conditions of the GNU General Public License for more details.
Vikram Narayanana8111cf2012-04-14 15:25:13 +053025\*****************************************************************************/
26
27#include <ctype.h>
28
29static int is_ident_nondigit(int c)
30{
31 int result;
32 switch(c) {
33 case 'A': case 'B': case 'C': case 'D':
34 case 'E': case 'F': case 'G': case 'H':
35 case 'I': case 'J': case 'K': case 'L':
36 case 'M': case 'N': case 'O': case 'P':
37 case 'Q': case 'R': case 'S': case 'T':
38 case 'U': case 'V': case 'W': case 'X':
39 case 'Y': case 'Z':
40 case 'a': case 'b': case 'c': case 'd':
41 case 'e': case 'f': case 'g': case 'h':
42 case 'i': case 'j': case 'k': case 'l':
43 case 'm': case 'n': case 'o': case 'p':
44 case 'q': case 'r': case 's': case 't':
45 case 'u': case 'v': case 'w': case 'x':
46 case 'y': case 'z':
47 case '_':
48 result = 1;
49 break;
50 default:
51 result = 0;
52 break;
53 }
54 return result;
55}
56
57int is_ident(char *str)
58{
59 int result;
60 int ch;
61 ch = *str;
62 result = 0;
63 if (is_ident_nondigit(ch)) {
64 do {
65 str++;
66 ch = *str;
67 } while(ch && (is_ident_nondigit(ch) || (isdigit(ch))));
68 result = (ch == '\0');
69 }
70 return result;
71}