1 /*
2  *    generic module.
3  *
4  * Copyright (c) 1998, 1999, 2000 SASAKI Shunsuke.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions, and the following disclaimer,
12  *    without modification, immediately at the beginning of the file.
13  * 2. The name of the author may not be used to endorse or promote products
14  *    derived from this software without specific prior written permission.
15  *
16  * Where this Software is combined with software released under the terms of
17  * the GNU Public License ("GPL") and the terms of the GPL would require the
18  * combined work to also be released under the terms of the GPL, the terms
19  * and conditions of this License will apply in addition to those of the
20  * GPL with the exception of any terms or conditions of this License that
21  * conflict with, or are expressly prohibited by, the GPL.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
27  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33  * SUCH DAMAGE.
34  */
35 
36 #ifndef __ELE_GENERIC_H__
37 #define __ELE_GENERIC_H__
38 
39 typedef	int	bool;
40 
41 #ifndef	FALSE
42 #	define	FALSE	0
43 #	define	TRUE	!FALSE
44 #endif
45 
46 #ifndef max
47 #	define	max(x,y)	(x>y?x:y)
48 #	define	min(x,y)	(x<y?x:y)
49 #endif
50 
51 
52 
53 extern	void	*mem_alloc(size_t n);
54 extern	void	*mem_realloc(void *p, size_t n);
55 
56 extern	void	*mem_alloca(size_t n);
57 extern	void	mem_alloca_gc();
58 
59 extern	char	*mem_strdup(const char *s);
60 extern	char	*mem_strdupa(const char *s);
61 
62 extern	void	reg_pf(const char *cp, char *s,bool f);
63 extern	void	reg_path(const char *cp, char *s,bool f);
64 extern	void	cut_pf(const char *s,char *path,char *file);
65 
66 extern	char	*dir_pext(const char *s);
67 extern	char	**dir_glob(const char *s, bool f_dotfile);
68 extern	bool	dir_isdir(const char *s);
69 
70 
71 
72 extern	void	error(const char *s);
73 
74 extern	void	report_set(FILE *fp);
75 extern	void	report_printf(const char *fmt, ...);
76 extern	void	report_puts(const char *s);
77 
78 #ifdef	NDEBUG
79 #	define	report_assert(exp)
80 #else
81 #	define	report_assert(exp)\
82 	if (!exp)\
83 		report_printf(__FILE__ ":%d: " #exp " falied.\n", __LINE__)
84 #endif
85 
86 
87 
88 #endif
89