3 * $Id: anag.h,v 1.4 2003/11/29 23:38:37 mdw Exp $
5 * External definitions for Anag
7 * (c) 2001 Mark Wooding
10 /*----- Licensing notice --------------------------------------------------*
12 * This file is part of Anag: a simple wordgame helper.
14 * Anag is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
19 * Anag is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with Anag; if not, write to the Free Software Foundation,
26 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29 /*----- Revision history --------------------------------------------------*
32 * Revision 1.4 2003/11/29 23:38:37 mdw
35 * Revision 1.3 2003/09/15 02:48:55 mdw
36 * Monoalphabetic match filter.
38 * Revision 1.2 2002/08/11 12:58:09 mdw
39 * Added support for regular expression matching, if supported by the C
42 * Revision 1.1 2001/02/04 17:14:42 mdw
54 /*----- Header files ------------------------------------------------------*/
67 /*----- Data structures ---------------------------------------------------*/
70 int (*func)(struct node */*n*/, const char */*p*/, size_t /*sz*/);
79 #define DSTR_INIT { 0, 0, 0 }
81 /*----- Node types --------------------------------------------------------*/
83 extern node *anagram(const char *const */*av*/);
84 extern node *subgram(const char *const */*av*/);
85 extern node *wildcard(const char *const */*av*/);
86 extern node *trackword(const char *const */*av*/);
87 extern node *mono(const char *const */*av*/);
88 extern node *regexp(const char *const */*av*/);
89 extern node *pcrenode(const char *const */*av*/);
91 /*----- Error reporting ---------------------------------------------------*/
95 * Arguments: @const char *p@ = pointer to program name
99 * Use: Stores what the program's name is.
102 extern void ego(const char */*p*/);
106 * Arguments: @FILE *fp@ = output stream to write on
107 * @const char *p@ = pointer to string to write
109 * Returns: Zero if everything worked, EOF if not.
111 * Use: Writes the string @p@ to the output stream @fp@. Occurrences
112 * of the character `$' in @p@ are replaced by the program name
113 * as reported by @quis@. A `$$' is replaced by a single `$'
117 extern int pquis(FILE */*fp*/, const char */*p*/);
121 * Arguments: @const char *f@ = a @printf@-style format string
122 * @...@ = other arguments
126 * Use: Reports an error and exits.
129 extern void die(const char */*f*/, ...);
131 /*----- Memory allocation -------------------------------------------------*/
133 /* --- @xmalloc@ --- *
135 * Arguments: @size_t sz@ = size of block to allocate
137 * Returns: Pointer to allocated block.
139 * Use: Allocates memory. If there's not enough memory, the
143 extern void *xmalloc(size_t /*sz*/);
145 /* --- @xrealloc@ --- *
147 * Arguments: @void *p@ = a pointer to allocated memory
148 * @size_t sz@ = new size of block wanted
150 * Returns: Pointer to resized block.
152 * Use: Resizes an allocated block. If there's not enough memory,
156 extern void *xrealloc(void */*p*/, size_t /*sz*/);
158 /*----- Dynamic string handling -------------------------------------------*/
160 /* --- @dstr_destroy@ --- *
162 * Arguments: @dstr *d@ = pointer to a dynamic string block
166 * Use: Reclaims the space used by a dynamic string.
169 extern void dstr_destroy(dstr */*d*/);
171 /* --- @dstr_reset@ --- *
173 * Arguments: @dstr *d@ = pointer to a dynamic string block
177 * Use: Resets a string so that new data gets put at the beginning.
180 extern void dstr_reset(dstr */*d*/);
182 /* --- @dstr_ensure@ --- *
184 * Arguments: @dstr *d@ = pointer to a dynamic string block
185 * @size_t sz@ = amount of free space to ensure
189 * Use: Ensures that at least @sz@ bytes are available in the
193 extern void dstr_ensure(dstr */*d*/, size_t /*sz*/);
195 /* --- @dstr_putline@ --- *
197 * Arguments: @dstr *d@ = pointer to a dynamic string block
198 * @FILE *fp@ = a stream to read from
200 * Returns: The number of characters read into the buffer, or @EOF@ if
201 * end-of-file was reached before any characters were read.
203 * Use: Appends the next line from the given input stream to the
204 * string. A trailing newline is not added; a trailing null
205 * byte is appended, as for @dstr_putz@.
208 extern int dstr_putline(dstr */*d*/, FILE */*fp*/);
210 /*----- That's all, folks -------------------------------------------------*/