scyther/src/symbol.h

78 lines
2.1 KiB
C
Raw Normal View History

/*
* Scyther : An automatic verifier for security protocols.
* Copyright (C) 2007 Cas Cremers
*
* 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
#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
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;
//! 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.
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);
void free_symb (const Symbol s);
2004-04-23 11:58:43 +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);
void symbol_fix_keylevels (void);
Symbol symbolNextFree (Symbol prefixsymbol);
2004-04-23 11:58:43 +01:00
void eprintf (char *fmt, ...);
void veprintf (const char *fmt, va_list args);
extern int globalError;
extern char *globalStream;
2004-04-23 11:58:43 +01:00
#endif