2
* Reads lexical config files and updates database.
4
* MUSCLE SmartCard Development ( http://www.linuxnet.com )
6
* Copyright (C) 2001-2003
7
* David Corcoran <corcoran@linuxnet.com>
8
* Ludovic Rousseau <ludovic.rousseau@free.fr>
10
* $Id: tokenparser.l,v 1.9 2003/10/18 18:24:00 aet-guest Exp $
22
void tpevalToken(char *pcToken, int tokType);
24
static char *pcDesiredKey = 0;
25
static char pcKey[TOKEN_MAX_KEY_SIZE];
26
static char pcValue[TOKEN_MAX_VALUE_SIZE];
27
static char pcFinValue[TOKEN_MAX_VALUE_SIZE];
28
static int valueIndex = 0;
29
static int desiredIndex = 0;
31
void tperrorCheck (char *pcToken_error);
39
\<key\>([A-Z]|[a-z]|[0-9]|[ \t])+\<\/key\> { valueIndex = 0; tpevalToken(yytext, TOKEN_TYPE_KEY); }
41
\<string\>([A-Z]|[a-z]|[0-9]|[ \t]|[!@#$%^&*()\-+/_\:?.,=~'"])+\<\/string\> {tpevalToken(yytext, TOKEN_TYPE_STRING); valueIndex += 1;}
42
. { tperrorCheck( yytext ); }
52
void tpevalToken(char *pcToken, int tokType)
57
if (tokType == TOKEN_TYPE_KEY)
59
for (len=5; pcToken[len] != '<'; len++)
61
if (len - 5 > TOKEN_MAX_KEY_SIZE)
63
strncpy(pcKey, &pcToken[5], TOKEN_MAX_KEY_SIZE);
64
pcKey[TOKEN_MAX_KEY_SIZE - 1] = '\0';
68
strncpy(pcKey, &pcToken[5], len - 5);
73
if (tokType == TOKEN_TYPE_STRING)
75
for (len=8; pcToken[len] != '<'; len++)
77
if (len - 8 > TOKEN_MAX_VALUE_SIZE)
79
strncpy(pcValue, &pcToken[8], TOKEN_MAX_VALUE_SIZE);
80
pcValue[TOKEN_MAX_VALUE_SIZE - 1] = '\0';
84
strncpy(pcValue, &pcToken[8], len - 8);
87
if (strcmp(pcKey, pcDesiredKey) == 0)
88
if (desiredIndex == valueIndex)
90
strncpy(pcFinValue, pcValue, TOKEN_MAX_VALUE_SIZE);
91
pcFinValue[TOKEN_MAX_VALUE_SIZE - 1] = '\0';
96
void tperrorCheck (char *token_error)
100
int LTPBundleFindValueWithKey(char *fileName, char *tokenKey,
101
char *tokenValue, int tokenIndice)
106
desiredIndex = tokenIndice;
107
pcDesiredKey = tokenKey;
108
pcFinValue[0] = '\0';
110
file = fopen(fileName, "r");
114
DebugLogB("Could not open bundle file : %s", fileName);
123
} while (!feof(file));
125
if (pcFinValue[0] == 0)
127
if (tokenIndice == 0)
129
/* Not defined at all */
130
DebugLogC("Value/Key not defined for: %s, indice: %d",
131
tokenKey, tokenIndice);
137
strncpy(tokenValue, pcFinValue, TOKEN_MAX_VALUE_SIZE);
138
tokenValue[TOKEN_MAX_VALUE_SIZE - 1] = '\0';