3 * External definitions for Anag
5 * (c) 2001 Mark Wooding
8 /*----- Licensing notice --------------------------------------------------*
10 * This file is part of Anag: a simple wordgame helper.
12 * Anag is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * Anag is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with Anag; if not, write to the Free Software Foundation,
24 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
34 /*----- Header files ------------------------------------------------------*/
47 /*----- Data structures ---------------------------------------------------*/
50 int (*func
)(struct node */
*n*/
, const char */
*p*/
, size_t /*sz*/);
59 #define DSTR_INIT { 0, 0, 0 }
61 /*----- Node types --------------------------------------------------------*/
63 extern node
*anagram(const char *const */
*av*/
);
64 extern node
*subgram(const char *const */
*av*/
);
65 extern node
*wildcard(const char *const */
*av*/
);
66 extern node
*trackword(const char *const */
*av*/
);
67 extern node
*mono(const char *const */
*av*/
);
68 extern node
*regexp(const char *const */
*av*/
);
69 extern node
*pcrenode(const char *const */
*av*/
);
70 extern node
*longest(const char *const */
*av*/
);
71 extern node
*shortest(const char *const */
*av*/
);
73 /*----- Exit codes --------------------------------------------------------*/
79 /*----- Error reporting ---------------------------------------------------*/
83 * Arguments: @const char *p@ = pointer to program name
87 * Use: Stores what the program's name is.
90 extern void ego(const char */
*p*/
);
94 * Arguments: @FILE *fp@ = output stream to write on
95 * @const char *p@ = pointer to string to write
97 * Returns: Zero if everything worked, EOF if not.
99 * Use: Writes the string @p@ to the output stream @fp@. Occurrences
100 * of the character `$' in @p@ are replaced by the program name
101 * as reported by @quis@. A `$$' is replaced by a single `$'
105 extern int pquis(FILE */
*fp*/
, const char */
*p*/
);
109 * Arguments: @const char *f@ = a @printf@-style format string
110 * @...@ = other arguments
114 * Use: Reports an error and exits.
117 extern void die(const char */
*f*/
, ...);
119 /*----- Memory allocation -------------------------------------------------*/
121 /* --- @xmalloc@ --- *
123 * Arguments: @size_t sz@ = size of block to allocate
125 * Returns: Pointer to allocated block.
127 * Use: Allocates memory. If there's not enough memory, the
131 extern void *xmalloc(size_t /*sz*/);
133 /* --- @xrealloc@ --- *
135 * Arguments: @void *p@ = a pointer to allocated memory
136 * @size_t sz@ = new size of block wanted
138 * Returns: Pointer to resized block.
140 * Use: Resizes an allocated block. If there's not enough memory,
144 extern void *xrealloc(void */
*p*/
, size_t /*sz*/);
146 /*----- Dynamic string handling -------------------------------------------*/
148 /* --- @dstr_destroy@ --- *
150 * Arguments: @dstr *d@ = pointer to a dynamic string block
154 * Use: Reclaims the space used by a dynamic string.
157 extern void dstr_destroy(dstr */
*d*/
);
159 /* --- @dstr_reset@ --- *
161 * Arguments: @dstr *d@ = pointer to a dynamic string block
165 * Use: Resets a string so that new data gets put at the beginning.
168 extern void dstr_reset(dstr */
*d*/
);
170 /* --- @dstr_ensure@ --- *
172 * Arguments: @dstr *d@ = pointer to a dynamic string block
173 * @size_t sz@ = amount of free space to ensure
177 * Use: Ensures that at least @sz@ bytes are available in the
181 extern void dstr_ensure(dstr */
*d*/
, size_t /*sz*/);
183 /* --- @dstr_putline@ --- *
185 * Arguments: @dstr *d@ = pointer to a dynamic string block
186 * @FILE *fp@ = a stream to read from
188 * Returns: The number of characters read into the buffer, or @EOF@ if
189 * end-of-file was reached before any characters were read.
191 * Use: Appends the next line from the given input stream to the
192 * string. A trailing newline is not added; a trailing null
193 * byte is appended, as for @dstr_putz@.
196 extern int dstr_putline(dstr */
*d*/
, FILE */
*fp*/
);
198 /*----- Infrastructure ----------------------------------------------------*/
200 /* --- @atend_register@ --- *
202 * Arguments: @int (*func)(void *)@ = function to call
203 * @void *p@ = handle to pass to it
207 * Use: Adds a function to the list of things to do at the end of the
208 * program. The function should return nonzero if it produced
212 extern void atend_register(int (*/
*func*/
)(void */
*p*/
), void */
*p*/
);
214 /*----- That's all, folks -------------------------------------------------*/