X-Git-Url: https://git.distorted.org.uk/~mdw/become/blobdiff_plain/fe59d3d70fc7337b7a50c4fcff72d20967672157..f60a34341fee6aafd5b878dce23b80af7c60064d:/src/sym.h diff --git a/src/sym.h b/src/sym.h deleted file mode 100644 index f8201fd..0000000 --- a/src/sym.h +++ /dev/null @@ -1,196 +0,0 @@ -/* -*-c-*- - * - * $Id: sym.h,v 1.3 1998/01/12 16:46:30 mdw Exp $ - * - * Symbol table management - * - * (c) 1998 Straylight - */ - -/*----- Licensing notice --------------------------------------------------* - * - * This file is part of `become' - * - * `Become' 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. - * - * `Become' 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 `become'; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -/*----- Revision history --------------------------------------------------* - * - * $Log: sym.h,v $ - * Revision 1.3 1998/01/12 16:46:30 mdw - * Fix copyright date. - * - * Revision 1.2 1997/08/04 10:24:25 mdw - * Sources placed under CVS control. - * - * Revision 1.1 1997/07/21 13:47:43 mdw - * Initial revision - * - */ - -#ifndef SYM_H -#define SYM_H - -#ifdef __cplusplus - extern "C" { -#endif - -/*----- Required headers --------------------------------------------------*/ - -#include - -/*----- Type definitions --------------------------------------------------*/ - -/* --- Symbol table --- * - * - * A @sym_table@ contains the information needed to manage a symbol table. - * Users shouldn't fiddle with this information directly, but it needs to be - * here so that objects of the correct type can be created. - */ - -typedef struct sym_table { - unsigned long mask; /* Bit mask for hashing purposes */ - size_t c; /* Down counter for growing table */ - struct sym_base **a; /* Array of hash bins */ -} sym_table; - -/* --- A symbol table entry --- * - * - * I don't care what actually gets stored in symbol entries because I don't - * create them: that's the responsibility of my client. All I care about - * here is that whatever gets passed to me is a structure whose first member - * is a @sym_base@. The ANSI guarantees about structure layout are - * sufficient to allow me to manipulate such objects. - */ - -typedef struct sym_base { - struct sym_base *next; /* Next symbol in hash bin */ - unsigned long hash; /* Hash value for symbol's name */ - char *name; /* Name of this symbol */ - size_t len; /* Length of the symbol's name */ -} sym_base; - -/* --- An iterator block --- */ - -typedef struct sym_iter { - sym_table *t; /* Symbol table being iterated */ - sym_base *n; /* Address of next item to return */ - size_t i; /* Index of next hash bin to use */ -} sym_iter; - -/*----- External functions ------------------------------------------------*/ - -/* --- @sym_createTable@ --- * - * - * Arguments: @sym_table *t@ = symbol table to initialise - * - * Returns: --- - * - * Use: Initialises the given symbol table. - */ - -extern void sym_createTable(sym_table */*t*/); - -/* --- @sym_destroyTable@ --- * - * - * Arguments: @sym_table *t@ = pointer to symbol table in question - * - * Returns: --- - * - * Use: Destroys a symbol table, freeing all the memory it used to - * occupy. - */ - -extern void sym_destroyTable(sym_table */*t*/); - -/* --- @sym_find@ --- * - * - * Arguments: @sym_table *t@ = pointer to symbol table in question - * @const char *n@ = pointer to symbol table to look up - * @long l@ = length of the name string or negative to measure - * @size_t sz@ = size of desired symbol object, or zero - * @unsigned *f@ = pointer to a flag, or null. - * - * Returns: The address of a @sym_base@ structure, or null if not found - * and @sz@ is zero. - * - * Use: Looks up a symbol in a given symbol table. The name is - * passed by the address of its first character. The length - * may be given, in which case the name may contain arbitrary - * binary data, or it may be given as a negative number, in - * which case the length of the name is calculated as - * @strlen(n)@. - * - * The return value is the address of a pointer to a @sym_base@ - * block (which may have other things on the end, as above). If - * the symbol could be found, the return value points to the - * symbol block. If the symbol wasn't there, then if @sz@ is - * nonzero, a new symbol is created and its address is returned; - * otherwise a null pointer is returned. - * - * The value of @*f@ indicates whether a new symbol entry was - * created: a nonzero value indicates that an old value was - * found. - */ - -extern void *sym_find(sym_table */*t*/, const char */*n*/, long /*l*/, - size_t /*sz*/, unsigned */*f*/); - -/* --- @sym_remove@ --- * - * - * Arguments: @sym_table *i@ = pointer to a symbol table object - * @void *b@ = pointer to symbol table entry - * - * Returns: --- - * - * Use: Removes the object from the symbol table. The space occupied - * by the object and its name is freed; anything else attached - * to the entry should already be gone by this point. - */ - -extern void sym_remove(sym_table */*t*/, void */*b*/); - -/* --- @sym_createIter@ --- * - * - * Arguments: @sym_iter *i@ = pointer to an iterator object - * @sym_table *t@ = pointer to a symbol table object - * - * Returns: --- - * - * Use: Creates a new symbol table iterator which may be used to - * iterate through a symbol table. - */ - -extern void sym_createIter(sym_iter */*i*/, sym_table */*t*/); - -/* --- @sym_next@ --- * - * - * Arguments: @sym_iter *i@ = pointer to iterator object - * - * Returns: Pointer to the next symbol found, or null when finished. - * - * Use: Returns the next symbol from the table. Symbols are not - * returned in any particular order. - */ - -extern void *sym_next(sym_iter */*i*/); - -/*----- That's all, folks -------------------------------------------------*/ - -#ifdef __cplusplus - } -#endif - -#endif