2007-06-11 13:01:04 +01:00
|
|
|
/*
|
|
|
|
* Scyther : An automatic verifier for security protocols.
|
2012-04-24 12:56:51 +01:00
|
|
|
* Copyright (C) 2007-2012 Cas Cremers
|
2007-06-11 13:01:04 +01:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* 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. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
2004-04-23 11:58:43 +01:00
|
|
|
#ifndef SYMBOLS
|
|
|
|
#define SYMBOLS
|
|
|
|
|
2005-12-30 12:03:19 +00:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
2004-05-15 16:45:08 +01:00
|
|
|
//! Size of symbol hashtable.
|
|
|
|
/** Optimistically large. Should be a prime, says theory.
|
|
|
|
*/
|
2004-04-23 11:58:43 +01:00
|
|
|
#define HASHSIZE 997
|
|
|
|
|
2004-08-09 11:05:58 +01:00
|
|
|
enum symboltypes
|
|
|
|
{ T_UNDEF = -1, T_PROTOCOL, T_CONST, T_VAR, T_SYSCONST };
|
2004-04-23 11:58:43 +01:00
|
|
|
|
|
|
|
#define EOS 0
|
|
|
|
|
2006-01-02 21:06:08 +00:00
|
|
|
//! Symbol structure
|
2004-04-23 11:58:43 +01:00
|
|
|
struct symbol
|
|
|
|
{
|
2004-05-15 16:45:08 +01:00
|
|
|
//! Type of symbol.
|
|
|
|
/**
|
|
|
|
*\sa T_UNDEF, T_PROTOCOL, T_CONST, T_VAR, T_SYSCONST
|
|
|
|
*/
|
2004-04-23 11:58:43 +01:00
|
|
|
int type;
|
2004-05-15 16:45:08 +01:00
|
|
|
//! Line number at which it occurred.
|
2004-04-23 11:58:43 +01:00
|
|
|
int lineno;
|
2004-08-20 20:16:56 +01:00
|
|
|
//! Level of occurrence in role nodes. 0 for as non-key, 1 for key only, 2 for key of key only, etc..
|
|
|
|
int keylevel;
|
2004-05-15 16:45:08 +01:00
|
|
|
//! Ascii string with name of the symbol.
|
2004-08-09 10:42:58 +01:00
|
|
|
const char *text;
|
2004-05-15 16:45:08 +01:00
|
|
|
//! Possible next pointer.
|
2004-04-23 11:58:43 +01:00
|
|
|
struct symbol *next;
|
2004-05-15 16:45:08 +01:00
|
|
|
//! Used for linking all symbol blocks, freed or in use.
|
2004-04-23 11:58:43 +01:00
|
|
|
struct symbol *allocnext;
|
|
|
|
};
|
|
|
|
|
2006-01-02 21:06:08 +00:00
|
|
|
typedef struct symbol *Symbol; //!< pointer to symbol structure
|
2004-04-23 11:58:43 +01:00
|
|
|
|
|
|
|
void symbolsInit (void);
|
|
|
|
void symbolsDone (void);
|
|
|
|
|
|
|
|
Symbol get_symb (void);
|
2004-08-09 10:42:58 +01:00
|
|
|
void free_symb (const Symbol s);
|
2004-04-23 11:58:43 +01:00
|
|
|
|
2004-08-09 10:42:58 +01:00
|
|
|
void insert (const Symbol s);
|
|
|
|
Symbol lookup (const char *s);
|
|
|
|
void symbolPrint (const Symbol s);
|
|
|
|
void symbolPrintAll (void);
|
|
|
|
Symbol symbolSysConst (const char *str);
|
2004-08-20 20:16:56 +01:00
|
|
|
void symbol_fix_keylevels (void);
|
2005-12-28 11:50:17 +00:00
|
|
|
Symbol symbolNextFree (Symbol prefixsymbol);
|
2011-01-27 13:12:51 +00:00
|
|
|
Symbol symbolFromInt (int n, Symbol prefixsymbol);
|
2004-04-23 11:58:43 +01:00
|
|
|
|
2004-08-09 11:05:58 +01:00
|
|
|
void eprintf (char *fmt, ...);
|
2005-12-30 12:03:19 +00:00
|
|
|
void veprintf (const char *fmt, va_list args);
|
2004-07-29 13:36:24 +01:00
|
|
|
|
|
|
|
extern int globalError;
|
2005-12-27 10:49:22 +00:00
|
|
|
extern char *globalStream;
|
2004-07-29 13:36:24 +01:00
|
|
|
|
2004-04-23 11:58:43 +01:00
|
|
|
#endif
|