1 /* 2 * Copyright (c) 2010, 2011 Ryan Flannery <ryan.flannery@gmail.com> 3 * 4 * Permission to use, copy, modify, and distribute this software for any 5 * purpose with or without fee is hereby granted, provided that the above 6 * copyright notice and this permission notice appear in all copies. 7 * 8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 */ 16 17 #ifndef DEBUG_H 18 #define DEBUG_H 19 20 #include <stdio.h> 21 22 /* log file for debugging */ 23 extern FILE *debug_log; 24 25 #ifdef DEBUG 26 27 /* debug file logger that goes to the file opened in vitunes.c */ 28 #define DFLOG(format, args...) \ 29 fprintf(debug_log, "%s.%d (%s): ", __FILE__, __LINE__, __FUNCTION__); \ 30 fprintf(debug_log, format, ## args); \ 31 fprintf(debug_log, "\n"); \ 32 fflush(debug_log); 33 34 /* console logger. goes to stdout. doesn't work well in curses */ 35 #define DCLOG(format, args...) \ 36 printf("%d: ", __LINE__); \ 37 printf(format, ## args); \ 38 printf("\n"); \ 39 fflush(stdout); 40 41 42 #else 43 44 #define DFLOG(format, args...) 0; 45 #define DCLOG(format, args...) 0; 46 47 #endif 48 49 50 /* for unused arguments */ 51 #if defined(__GNUC__) || defined(__clang__) 52 # define UNUSED __attribute__((__unused__)) 53 #else 54 # define UNUSED 55 #endif 56 57 #endif 58