09bcc5067316f0cf28f72b6365a73f8fc68dfce4
[alexxy/gromacs.git] / include / symtab.h
1 /*
2  * $Id$
3  * 
4  *       This source code is part of
5  * 
6  *        G   R   O   M   A   C   S
7  * 
8  * GROningen MAchine for Chemical Simulations
9  * 
10  *               VERSION 2.0
11  * 
12  * Copyright (c) 1991-1999
13  * BIOSON Research Institute, Dept. of Biophysical Chemistry
14  * University of Groningen, The Netherlands
15  * 
16  * Please refer to:
17  * GROMACS: A message-passing parallel molecular dynamics implementation
18  * H.J.C. Berendsen, D. van der Spoel and R. van Drunen
19  * Comp. Phys. Comm. 91, 43-56 (1995)
20  * 
21  * Also check out our WWW page:
22  * http://md.chem.rug.nl/~gmx
23  * or e-mail to:
24  * gromacs@chem.rug.nl
25  * 
26  * And Hey:
27  * Green Red Orange Magenta Azure Cyan Skyblue
28  */
29
30 #ifndef _symtab_h
31 #define _symtab_h
32
33 static char *SRCID_symtab_h = "$Id$";
34
35 #ifdef HAVE_CONFIG_H
36 #include <config.h>
37 #endif
38
39 #ifdef HAVE_IDENT
40 #ident  "@(#) symtab.h 1.6 12/16/92"
41 #endif /* HAVE_IDENT */
42
43 #include <stdio.h>
44 #include "typedefs.h"
45
46 /*
47  * This module handles symbol table manipulation. All text strings 
48  * needed by an application are allocated only once. All references
49  * to these text strings use handles returned from the put_symtab()
50  * routine. These handles can easily be converted to address independent
51  * values by invoking lookup_symtab(). So when writing structures to
52  * a file which contains text strings, this value can be written in stead
53  * of the text string or its address. This value can easily be converted
54  * back to a text string handle by get_symtab_handle().
55  */
56
57 extern void open_symtab(t_symtab *symtab);
58      /* Initialises the symbol table symtab.
59       */
60
61 extern void close_symtab(t_symtab *symtab);
62      /* Undoes the effect of open_symtab(), after invoking this function, 
63       * no value can be added to the symbol table, only values can be 
64       * retrieved using get_symtab().
65       */
66
67 extern void free_symtab(t_symtab *symtab);
68      /* Frees the space allocated by the symbol table itself */
69
70 extern void done_symtab(t_symtab *symtab);
71      /* Frees the space allocated by the symbol table, including all
72       * entries in it */
73
74 extern char **put_symtab(t_symtab *symtab,char *name);
75      /* Enters a string into the symbol table symtab, if it was not
76       * available, a reference to a copy is returned else a reference 
77       * to the earlier entered value is returned. Strings are trimmed
78       * of spaces.
79       */
80
81 extern int lookup_symtab(t_symtab *symtab,char **name);
82      /* Returns a unique handle for **name, without a memory reference.
83       * It is a failure when name cannot be found in the symbol table,
84       * it should be entered before with put_symtab().
85       */
86
87 extern char **get_symtab_handle(t_symtab *symtab,int name);
88      /* Returns a text string handle for name. Name should be a value
89       * returned from lookup_symtab(). So get_symtab_handle() and 
90       * lookup_symtab() are inverse functions.
91       */
92
93 extern long wr_symtab(FILE *fp,t_symtab *symtab);
94      /* Writes the symbol table symtab to the file, specified by fp.
95       * The function returns the number of bytes written.
96       */
97
98 extern long rd_symtab(FILE *fp,t_symtab *symtab);
99      /* Reads the symbol table symtab from the file, specified by fp.
100       * This will include allocating the needed space. The function 
101       * returns the number of bytes read. The symtab is in the closed
102       * state afterwards, so no strings can be added to it.
103       */
104
105 extern void pr_symtab(FILE *fp,int indent,char *title,t_symtab *symtab);
106      /* This routine prints out a (human) readable representation of 
107       * the symbol table symtab to the file fp. Ident specifies the
108       * number of spaces the text should be indented. Title is used
109       * to print a header text.
110       */
111
112 #endif  /* _symtab_h */