19c82a63eSPeter Avalos /*- 29c82a63eSPeter Avalos * Copyright (c) 2009 Joerg Sonnenberger 39c82a63eSPeter Avalos * All rights reserved. 49c82a63eSPeter Avalos * 59c82a63eSPeter Avalos * Redistribution and use in source and binary forms, with or without 69c82a63eSPeter Avalos * modification, are permitted provided that the following conditions 79c82a63eSPeter Avalos * are met: 89c82a63eSPeter Avalos * 1. Redistributions of source code must retain the above copyright 99c82a63eSPeter Avalos * notice, this list of conditions and the following disclaimer. 109c82a63eSPeter Avalos * 2. Redistributions in binary form must reproduce the above copyright 119c82a63eSPeter Avalos * notice, this list of conditions and the following disclaimer in the 129c82a63eSPeter Avalos * documentation and/or other materials provided with the distribution. 139c82a63eSPeter Avalos * 149c82a63eSPeter Avalos * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR 159c82a63eSPeter Avalos * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 169c82a63eSPeter Avalos * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 179c82a63eSPeter Avalos * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, 189c82a63eSPeter Avalos * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 199c82a63eSPeter Avalos * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 209c82a63eSPeter Avalos * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 219c82a63eSPeter Avalos * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 229c82a63eSPeter Avalos * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 239c82a63eSPeter Avalos * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 249c82a63eSPeter Avalos */ 259c82a63eSPeter Avalos 269c82a63eSPeter Avalos #ifndef LAFE_ERR_H 279c82a63eSPeter Avalos #define LAFE_ERR_H 289c82a63eSPeter Avalos 299c82a63eSPeter Avalos #if defined(__GNUC__) && (__GNUC__ > 2 || \ 309c82a63eSPeter Avalos (__GNUC__ == 2 && __GNUC_MINOR__ >= 5)) 319c82a63eSPeter Avalos #define __LA_DEAD __attribute__((__noreturn__)) 329c82a63eSPeter Avalos #else 339c82a63eSPeter Avalos #define __LA_DEAD 349c82a63eSPeter Avalos #endif 359c82a63eSPeter Avalos 3659bf7050SPeter Avalos #if defined(__GNUC__) && (__GNUC__ > 2 || \ 3759bf7050SPeter Avalos (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)) 38*085658deSDaniel Fojt # ifdef __MINGW_PRINTF_FORMAT 39*085658deSDaniel Fojt # define __LA_PRINTF_FORMAT __MINGW_PRINTF_FORMAT 40*085658deSDaniel Fojt # else 41*085658deSDaniel Fojt # define __LA_PRINTF_FORMAT __printf__ 42*085658deSDaniel Fojt # endif 43*085658deSDaniel Fojt # define __LA_PRINTFLIKE(f,a) __attribute__((__format__(__LA_PRINTF_FORMAT, f, a))) 4459bf7050SPeter Avalos #else 4559bf7050SPeter Avalos # define __LA_PRINTFLIKE(f,a) 4659bf7050SPeter Avalos #endif 4759bf7050SPeter Avalos 4859bf7050SPeter Avalos void lafe_warnc(int code, const char *fmt, ...) __LA_PRINTFLIKE(2, 3); 4959bf7050SPeter Avalos void lafe_errc(int eval, int code, const char *fmt, ...) __LA_DEAD 5059bf7050SPeter Avalos __LA_PRINTFLIKE(3, 4); 519c82a63eSPeter Avalos 526b384f39SPeter Avalos const char * lafe_getprogname(void); 536b384f39SPeter Avalos void lafe_setprogname(const char *name, const char *defaultname); 546b384f39SPeter Avalos 559c82a63eSPeter Avalos #endif 56