1*00b67f09SDavid van Moolenbroek /* $NetBSD: misc.h,v 1.1.1.1 2015/07/08 15:37:48 christos Exp $ */ 2*00b67f09SDavid van Moolenbroek 3*00b67f09SDavid van Moolenbroek /***************************************************************** 4*00b67f09SDavid van Moolenbroek ** 5*00b67f09SDavid van Moolenbroek ** @(#) misc.h (c) 2005 - 2007 Holger Zuleger hznet.de 6*00b67f09SDavid van Moolenbroek ** 7*00b67f09SDavid van Moolenbroek ** Copyright (c) 2005 - 2007, Holger Zuleger HZnet. All rights reserved. 8*00b67f09SDavid van Moolenbroek ** 9*00b67f09SDavid van Moolenbroek ** This software is open source. 10*00b67f09SDavid van Moolenbroek ** 11*00b67f09SDavid van Moolenbroek ** Redistribution and use in source and binary forms, with or without 12*00b67f09SDavid van Moolenbroek ** modification, are permitted provided that the following conditions 13*00b67f09SDavid van Moolenbroek ** are met: 14*00b67f09SDavid van Moolenbroek ** 15*00b67f09SDavid van Moolenbroek ** Redistributions of source code must retain the above copyright notice, 16*00b67f09SDavid van Moolenbroek ** this list of conditions and the following disclaimer. 17*00b67f09SDavid van Moolenbroek ** 18*00b67f09SDavid van Moolenbroek ** Redistributions in binary form must reproduce the above copyright notice, 19*00b67f09SDavid van Moolenbroek ** this list of conditions and the following disclaimer in the documentation 20*00b67f09SDavid van Moolenbroek ** and/or other materials provided with the distribution. 21*00b67f09SDavid van Moolenbroek ** 22*00b67f09SDavid van Moolenbroek ** Neither the name of Holger Zuleger HZnet nor the names of its contributors may 23*00b67f09SDavid van Moolenbroek ** be used to endorse or promote products derived from this software without 24*00b67f09SDavid van Moolenbroek ** specific prior written permission. 25*00b67f09SDavid van Moolenbroek ** 26*00b67f09SDavid van Moolenbroek ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 27*00b67f09SDavid van Moolenbroek ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 28*00b67f09SDavid van Moolenbroek ** TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 29*00b67f09SDavid van Moolenbroek ** PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE 30*00b67f09SDavid van Moolenbroek ** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 31*00b67f09SDavid van Moolenbroek ** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 32*00b67f09SDavid van Moolenbroek ** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 33*00b67f09SDavid van Moolenbroek ** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 34*00b67f09SDavid van Moolenbroek ** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 35*00b67f09SDavid van Moolenbroek ** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 36*00b67f09SDavid van Moolenbroek ** POSSIBILITY OF SUCH DAMAGE. 37*00b67f09SDavid van Moolenbroek ** 38*00b67f09SDavid van Moolenbroek *****************************************************************/ 39*00b67f09SDavid van Moolenbroek #ifndef MISC_H 40*00b67f09SDavid van Moolenbroek # define MISC_H 41*00b67f09SDavid van Moolenbroek # include <sys/types.h> 42*00b67f09SDavid van Moolenbroek # include <stdarg.h> 43*00b67f09SDavid van Moolenbroek # include <stdio.h> 44*00b67f09SDavid van Moolenbroek # include "zconf.h" 45*00b67f09SDavid van Moolenbroek 46*00b67f09SDavid van Moolenbroek # define min(a, b) ((a) < (b) ? (a) : (b)) 47*00b67f09SDavid van Moolenbroek # define max(a, b) ((a) > (b) ? (a) : (b)) 48*00b67f09SDavid van Moolenbroek 49*00b67f09SDavid van Moolenbroek extern const char *getnameappendix (const char *progname, const char *basename); 50*00b67f09SDavid van Moolenbroek extern const char *getdefconfname (const char *view); 51*00b67f09SDavid van Moolenbroek extern int fileexist (const char *name); 52*00b67f09SDavid van Moolenbroek extern size_t filesize (const char *name); 53*00b67f09SDavid van Moolenbroek extern int file_age (const char *fname); 54*00b67f09SDavid van Moolenbroek extern int touch (const char *fname, time_t sec); 55*00b67f09SDavid van Moolenbroek extern int linkfile (const char *fromfile, const char *tofile); 56*00b67f09SDavid van Moolenbroek //extern int copyfile (const char *fromfile, const char *tofile); 57*00b67f09SDavid van Moolenbroek extern int copyfile (const char *fromfile, const char *tofile, const char *dnskeyfile); 58*00b67f09SDavid van Moolenbroek extern int copyzonefile (const char *fromfile, const char *tofile, const char *dnskeyfile); 59*00b67f09SDavid van Moolenbroek extern int cmpfile (const char *file1, const char *file2); 60*00b67f09SDavid van Moolenbroek extern char *str_delspace (char *s); 61*00b67f09SDavid van Moolenbroek #if 1 62*00b67f09SDavid van Moolenbroek extern char *domain_canonicdup (const char *s); 63*00b67f09SDavid van Moolenbroek #else 64*00b67f09SDavid van Moolenbroek extern char *str_tolowerdup (const char *s); 65*00b67f09SDavid van Moolenbroek #endif 66*00b67f09SDavid van Moolenbroek extern int in_strarr (const char *str, char *const arr[], int cnt); 67*00b67f09SDavid van Moolenbroek extern const char *splitpath (char *path, size_t size, const char *filename); 68*00b67f09SDavid van Moolenbroek extern char *pathname (char *name, size_t size, const char *path, const char *file, const char *ext); 69*00b67f09SDavid van Moolenbroek extern char *time2str (time_t sec, int precision); 70*00b67f09SDavid van Moolenbroek extern char *time2isostr (time_t sec, int precision); 71*00b67f09SDavid van Moolenbroek extern time_t timestr2time (const char *timestr); 72*00b67f09SDavid van Moolenbroek extern int is_keyfilename (const char *name); 73*00b67f09SDavid van Moolenbroek extern int is_directory (const char *name); 74*00b67f09SDavid van Moolenbroek extern time_t file_mtime (const char *fname); 75*00b67f09SDavid van Moolenbroek extern int is_exec_ok (const char *prog); 76*00b67f09SDavid van Moolenbroek extern char *age2str (time_t sec); 77*00b67f09SDavid van Moolenbroek extern time_t stop_timer (time_t start); 78*00b67f09SDavid van Moolenbroek extern time_t start_timer (void); 79*00b67f09SDavid van Moolenbroek extern void error (char *fmt, ...); 80*00b67f09SDavid van Moolenbroek extern void fatal (char *fmt, ...); 81*00b67f09SDavid van Moolenbroek extern void logmesg (char *fmt, ...); 82*00b67f09SDavid van Moolenbroek extern void verbmesg (int verblvl, const zconf_t *conf, char *fmt, ...); 83*00b67f09SDavid van Moolenbroek extern void logflush (void); 84*00b67f09SDavid van Moolenbroek extern int gensalt (char *salt, size_t saltsize, int saltbits, unsigned int seed); 85*00b67f09SDavid van Moolenbroek extern char *str_untaint (char *str); 86*00b67f09SDavid van Moolenbroek extern char *str_chop (char *str, char c); 87*00b67f09SDavid van Moolenbroek extern int is_dotfilename (const char *name); 88*00b67f09SDavid van Moolenbroek extern void parseurl (char *url, char **proto, char **host, char **port, char **para); 89*00b67f09SDavid van Moolenbroek #endif 90