3 * $Id: anag.h,v 1.3 2003/09/15 02:48:55 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.3 2003/09/15 02:48:55 mdw
33 * Monoalphabetic match filter.
35 * Revision 1.2 2002/08/11 12:58:09 mdw
36 * Added support for regular expression matching, if supported by the C
39 * Revision 1.1 2001/02/04 17:14:42 mdw
51 /*----- Header files ------------------------------------------------------*/
64 /*----- Data structures ---------------------------------------------------*/
67 int (*func)(struct node */*n*/, const char */*p*/, size_t /*sz*/);
76 #define DSTR_INIT { 0, 0, 0 }
78 /*----- Node types --------------------------------------------------------*/
80 extern node *anagram(const char *const */*av*/);
81 extern node *subgram(const char *const */*av*/);
82 extern node *wildcard(const char *const */*av*/);
83 extern node *trackword(const char *const */*av*/);
84 extern node *mono(const char *const */*av*/);
85 extern node *regexp(const char *const */*av*/);
87 /*----- Error reporting ---------------------------------------------------*/
91 * Arguments: @const char *p@ = pointer to program name
95 * Use: Stores what the program's name is.
98 extern void ego(const char */*p*/);
102 * Arguments: @FILE *fp@ = output stream to write on
103 * @const char *p@ = pointer to string to write
105 * Returns: Zero if everything worked, EOF if not.
107 * Use: Writes the string @p@ to the output stream @fp@. Occurrences
108 * of the character `$' in @p@ are replaced by the program name
109 * as reported by @quis@. A `$$' is replaced by a single `$'
113 extern int pquis(FILE */*fp*/, const char */*p*/);
117 * Arguments: @const char *f@ = a @printf@-style format string
118 * @...@ = other arguments
122 * Use: Reports an error and exits.
125 extern void die(const char */*f*/, ...);
127 /*----- Memory allocation -------------------------------------------------*/
129 /* --- @xmalloc@ --- *
131 * Arguments: @size_t sz@ = size of block to allocate
133 * Returns: Pointer to allocated block.
135 * Use: Allocates memory. If there's not enough memory, the
139 extern void *xmalloc(size_t /*sz*/);
141 /* --- @xrealloc@ --- *
143 * Arguments: @void *p@ = a pointer to allocated memory
144 * @size_t sz@ = new size of block wanted
146 * Returns: Pointer to resized block.
148 * Use: Resizes an allocated block. If there's not enough memory,
152 extern void *xrealloc(void */*p*/, size_t /*sz*/);
154 /*----- Dynamic string handling -------------------------------------------*/
156 /* --- @dstr_destroy@ --- *
158 * Arguments: @dstr *d@ = pointer to a dynamic string block
162 * Use: Reclaims the space used by a dynamic string.
165 extern void dstr_destroy(dstr */*d*/);
167 /* --- @dstr_reset@ --- *
169 * Arguments: @dstr *d@ = pointer to a dynamic string block
173 * Use: Resets a string so that new data gets put at the beginning.
176 extern void dstr_reset(dstr */*d*/);
178 /* --- @dstr_ensure@ --- *
180 * Arguments: @dstr *d@ = pointer to a dynamic string block
181 * @size_t sz@ = amount of free space to ensure
185 * Use: Ensures that at least @sz@ bytes are available in the
189 extern void dstr_ensure(dstr */*d*/, size_t /*sz*/);
191 /* --- @dstr_putline@ --- *
193 * Arguments: @dstr *d@ = pointer to a dynamic string block
194 * @FILE *fp@ = a stream to read from
196 * Returns: The number of characters read into the buffer, or @EOF@ if
197 * end-of-file was reached before any characters were read.
199 * Use: Appends the next line from the given input stream to the
200 * string. A trailing newline is not added; a trailing null
201 * byte is appended, as for @dstr_putz@.
204 extern int dstr_putline(dstr */*d*/, FILE */*fp*/);
206 /*----- That's all, folks -------------------------------------------------*/