1313010Sdes/* 2313010Sdes * Copyright (c) 2015 Tim Rice <tim@multitalents.net> 3313010Sdes * 4313010Sdes * Redistribution and use in source and binary forms, with or without 5313010Sdes * modification, are permitted provided that the following conditions 6313010Sdes * are met: 7313010Sdes * 8313010Sdes * 1. Redistributions of source code must retain the above copyright 9313010Sdes * notice, this list of conditions and the following disclaimer. 10313010Sdes * 2. Redistributions in binary form must reproduce the above copyright 11313010Sdes * notice, this list of conditions and the following disclaimer in the 12313010Sdes * documentation and/or other materials provided with the distribution. 13313010Sdes * 3. The name of the author may not be used to endorse or promote products 14313010Sdes * derived from this software without specific prior written permission. 15313010Sdes * 16313010Sdes * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17313010Sdes * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18313010Sdes * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19313010Sdes * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20313010Sdes * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21313010Sdes * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22313010Sdes * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23313010Sdes * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24313010Sdes * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25313010Sdes * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26313010Sdes */ 27313010Sdes 28313010Sdes#include "includes.h" 29313010Sdes 30313010Sdes#ifndef HAVE_ERR 31313010Sdesvoid 32313010Sdeserr(int r, const char *fmt, ...) 33313010Sdes{ 34313010Sdes va_list args; 35313010Sdes 36313010Sdes va_start(args, fmt); 37313010Sdes fprintf(stderr, "%s: ", strerror(errno)); 38313010Sdes vfprintf(stderr, fmt, args); 39313010Sdes fputc('\n', stderr); 40313010Sdes va_end(args); 41313010Sdes exit(r); 42313010Sdes} 43313010Sdes#endif 44313010Sdes 45313010Sdes#ifndef HAVE_ERRX 46313010Sdesvoid 47313010Sdeserrx(int r, const char *fmt, ...) 48313010Sdes{ 49313010Sdes va_list args; 50313010Sdes 51313010Sdes va_start(args, fmt); 52313010Sdes vfprintf(stderr, fmt, args); 53313010Sdes fputc('\n', stderr); 54313010Sdes va_end(args); 55313010Sdes exit(r); 56313010Sdes} 57313010Sdes#endif 58313010Sdes 59313010Sdes#ifndef HAVE_WARN 60313010Sdesvoid 61313010Sdeswarn(const char *fmt, ...) 62313010Sdes{ 63313010Sdes va_list args; 64313010Sdes 65313010Sdes va_start(args, fmt); 66313010Sdes fprintf(stderr, "%s: ", strerror(errno)); 67313010Sdes vfprintf(stderr, fmt, args); 68313010Sdes fputc('\n', stderr); 69313010Sdes va_end(args); 70313010Sdes} 71313010Sdes#endif 72