1332eff95SVincenzo Maffione /*- 2*4d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause 3332eff95SVincenzo Maffione * 4332eff95SVincenzo Maffione * Copyright (c) 2019 Vincenzo Maffione <vmaffione@freebsd.org> 5332eff95SVincenzo Maffione * 6332eff95SVincenzo Maffione * Redistribution and use in source and binary forms, with or without 7332eff95SVincenzo Maffione * modification, are permitted provided that the following conditions 8332eff95SVincenzo Maffione * are met: 9332eff95SVincenzo Maffione * 1. Redistributions of source code must retain the above copyright 10332eff95SVincenzo Maffione * notice, this list of conditions and the following disclaimer. 11332eff95SVincenzo Maffione * 2. Redistributions in binary form must reproduce the above copyright 12332eff95SVincenzo Maffione * notice, this list of conditions and the following disclaimer in the 13332eff95SVincenzo Maffione * documentation and/or other materials provided with the distribution. 14332eff95SVincenzo Maffione * 15332eff95SVincenzo Maffione * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND 16332eff95SVincenzo Maffione * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17332eff95SVincenzo Maffione * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18332eff95SVincenzo Maffione * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19332eff95SVincenzo Maffione * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20332eff95SVincenzo Maffione * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21332eff95SVincenzo Maffione * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22332eff95SVincenzo Maffione * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23332eff95SVincenzo Maffione * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24332eff95SVincenzo Maffione * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25332eff95SVincenzo Maffione * SUCH DAMAGE. 26332eff95SVincenzo Maffione */ 27332eff95SVincenzo Maffione 28332eff95SVincenzo Maffione #ifndef _DEBUG_H_ 29332eff95SVincenzo Maffione #define _DEBUG_H_ 30332eff95SVincenzo Maffione 31332eff95SVincenzo Maffione 32332eff95SVincenzo Maffione extern int raw_stdio; 33332eff95SVincenzo Maffione 34332eff95SVincenzo Maffione #define FPRINTLN(filep, fmt, arg...) \ 35332eff95SVincenzo Maffione do { \ 36332eff95SVincenzo Maffione if (raw_stdio) \ 37332eff95SVincenzo Maffione fprintf(filep, fmt "\r\n", ##arg); \ 38332eff95SVincenzo Maffione else \ 39332eff95SVincenzo Maffione fprintf(filep, fmt "\n", ##arg); \ 40332eff95SVincenzo Maffione } while (0) 41332eff95SVincenzo Maffione 42332eff95SVincenzo Maffione #define PRINTLN(fmt, arg...) FPRINTLN(stdout, fmt, ##arg) 43332eff95SVincenzo Maffione #define EPRINTLN(fmt, arg...) FPRINTLN(stderr, fmt, ##arg) 44332eff95SVincenzo Maffione 45332eff95SVincenzo Maffione #endif 46