1 /*****************************************************************
2 **
3 **	@(#) misc.h  (c) 2005 - 2007  Holger Zuleger  hznet.de
4 **
5 **	Copyright (c) 2005 - 2007, Holger Zuleger HZnet. All rights reserved.
6 **
7 **	This software is open source.
8 **
9 **	Redistribution and use in source and binary forms, with or without
10 **	modification, are permitted provided that the following conditions
11 **	are met:
12 **
13 **	Redistributions of source code must retain the above copyright notice,
14 **	this list of conditions and the following disclaimer.
15 **
16 **	Redistributions in binary form must reproduce the above copyright notice,
17 **	this list of conditions and the following disclaimer in the documentation
18 **	and/or other materials provided with the distribution.
19 **
20 **	Neither the name of Holger Zuleger HZnet nor the names of its contributors may
21 **	be used to endorse or promote products derived from this software without
22 **	specific prior written permission.
23 **
24 **	THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 **	"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
26 **	TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
27 **	PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
28 **	LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 **	CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 **	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 **	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 **	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 **	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 **	POSSIBILITY OF SUCH DAMAGE.
35 **
36 *****************************************************************/
37 #ifndef MISC_H
38 # define MISC_H
39 # include <sys/types.h>
40 # include <stdarg.h>
41 # include <stdio.h>
42 
43 #ifndef PATH_MAX
44 # define PATH_MAX	4096
45 #endif
46 
47 # define	MINSEC(x)	((x) * 60)
48 # define	HOURSEC(x)	(MINSEC(x) * 60)
49 # define	DAYSEC(x)	(HOURSEC(x) * 24)
50 # define	WEEKSEC(x)	(DAYSEC(x) * 7)
51 
52 #ifndef ulong
53 typedef	unsigned long	ulong;
54 #endif
55 
56 extern	int	ttltostr (char *s, size_t size, ulong ttl);
57 extern	int	ttlfromstr (const char *s, ulong *pttl);
58 extern	char	*str_delspace (char *s);
59 extern	int	in_strarr (const char *str, char *const arr[], int cnt);
60 extern	int	isdelim (char c, int delim);
61 extern	const char	*skipdelim (const char *line, int delim);
62 extern	int	strcmpto (const char *val, const char *list, const char *listdelim);
63 extern	void    error (char *fmt, ...);
64 extern	void    fatal (char *fmt, ...);
65 extern	void    logmesg (char *fmt, ...);
66 extern	void	verbmesg (int verblvl, char *fmt, ...);
67 extern	void	logflush (void);
68 extern	char	*str_untaint (char *str);
69 extern	char	*str_chop (char *str, char c);
70 #endif
71