1/* 2 * This program is free software; you can redistribute it and/or 3 * modify it under the terms of the GNU General Public License as 4 * published by the Free Software Foundation; either version 2 of 5 * the License, or (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, 8 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * GNU General Public License for more details. 11 * 12 * You should have received a copy of the GNU General Public License 13 * along with this program; if not, write to the Free Software 14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 15 * MA 02111-1307 USA 16 */ 17/*************************************************************************** 18 * LPRng - An Extended Print Spooler System 19 * 20 * Copyright 1988-2003, Patrick Powell, San Diego, CA 21 * papowell@lprng.com 22 * See LICENSE for conditions of use. 23 * $Id: debug.h,v 1.1.1.1 2008/10/15 03:28:27 james26_jang Exp $ 24 ***************************************************************************/ 25 26 27 28#ifndef _DEBUG_H_ 29#define _DEBUG_H_ 1 30 31/* to remove all debugging, redefine this as follows 32 * note that a good optimizing compiler should not produce code 33 * for the logDebug call. It may produce lots of warnings, but no code... 34 */ 35 36#if !defined(EXTERN) 37# define EXTERN extern 38#endif 39EXTERN int Debug; /* debug flags */ 40EXTERN int DbgFlag; /* debug flags */ 41EXTERN int DbgTest; /* debug flags */ 42 43#ifdef NODEBUG 44 45#define DEBUGFSET(FLAG) ( 0 ) 46#define DEBUGF(FLAG) if( 0 ) logDebug 47#define DEBUGFC(FLAG) if( 0 ) 48#define DEBUG1 if(0) logDebug 49#define DEBUGL1 (0) 50#define DEBUG2 if(0) logDebug 51#define DEBUGL2 (0) 52#define DEBUG3 if(0) logDebug 53#define DEBUGL3 (0) 54#define DEBUG4 if(0) logDebug 55#define DEBUGL4 (0) 56#define DEBUG5 if(0) logDebug 57#define DEBUGL5 (0) 58#define DEBUG6 if(0) logDebug 59#define DEBUGL6 (0) 60 61#else 62 63/* general purpose debug test */ 64#define DEBUGC(VAL,FLAG) if( (Debug >= (VAL) ) || ((FLAG) & DbgFlag) ) logDebug 65#define DEBUGL(VAL,FLAG) ( (Debug >= (VAL) ) || ((FLAG) & DbgFlag) ) 66#define DEBUGF(FLAG) if( (FLAG & DbgFlag) ) logDebug 67#define DEBUGFC(FLAG) if( (FLAG & DbgFlag) ) 68#define DEBUGFSET(FLAG) ( (FLAG & DbgFlag) ) 69 70 71/* Debug variable level */ 72#define DEBUG1 DEBUGC(1,DRECV1|DCTRL1|DLPQ1|DLPRM1) 73#define DEBUGL1 DEBUGL(1,DRECV1|DCTRL1|DLPQ1|DLPRM1) 74#define DEBUG2 DEBUGC(2,DRECV2|DCTRL2|DLPQ2|DLPRM2) 75#define DEBUGL2 DEBUGL(2,DRECV2|DCTRL2|DLPQ2|DLPRM2) 76#define DEBUG3 DEBUGC(3,DRECV3|DCTRL3|DLPQ3|DLPRM3) 77#define DEBUGL3 DEBUGL(3,DRECV3|DCTRL3|DLPQ3|DLPRM3) 78#define DEBUG4 DEBUGC(4,DRECV4|DCTRL4|DLPQ4|DLPRM4) 79#define DEBUGL4 DEBUGL(4,DRECV4|DCTRL4|DLPQ4|DLPRM4) 80#define DEBUG5 DEBUGC(5,0) 81#define DEBUGL5 DEBUGL(5,0) 82#define DEBUG6 DEBUGC(6,0) 83#define DEBUGL6 DEBUGL(6,0) 84 85/* PROTOTYPES */ 86 87#endif 88 89/* Flags for debugging */ 90 91#define DPRSHIFT 0 92#define DLOGMASK ((0xF<<DPRSHIFT)) 93#define DLOG1 ((0x1<<DPRSHIFT)) 94#define DLOG2 ((0x2<<DPRSHIFT)) 95#define DLOG3 ((0x4<<DPRSHIFT)) 96#define DLOG4 ((0x8<<DPRSHIFT)) 97 98#define DNWSHIFT 4 99#define DNWMASK ((0xF<<DNWSHIFT)) 100#define DNW1 ((0x1<<DNWSHIFT)) 101#define DNW2 ((0x2<<DNWSHIFT)) 102#define DNW3 ((0x4<<DNWSHIFT)) 103#define DNW4 ((0x8<<DNWSHIFT)) 104 105#define DDBSHIFT 8 106#define DDBMASK ((0xF<<DDBSHIFT)) 107#define DDB1 ((0x1<<DDBSHIFT)) 108#define DDB2 ((0x2<<DDBSHIFT)) 109#define DDB3 ((0x4<<DDBSHIFT)) 110#define DDB4 ((0x8<<DDBSHIFT)) 111 112#define DRECVSHIFT 12 113#define DRECVMASK ((0xF<<DRECVSHIFT)) 114#define DRECV1 ((0x1<<DRECVSHIFT)) 115#define DRECV2 ((0x2<<DRECVSHIFT)) 116#define DRECV3 ((0x4<<DRECVSHIFT)) 117#define DRECV4 ((0x8<<DRECVSHIFT)) 118 119#define DCTRLSHIFT 16 120#define DCTRLMASK ((0xF<<DCTRLSHIFT)) 121#define DCTRL1 ((0x1<<DCTRLSHIFT)) 122#define DCTRL2 ((0x2<<DCTRLSHIFT)) 123#define DCTRL3 ((0x4<<DCTRLSHIFT)) 124#define DCTRL4 ((0x8<<DCTRLSHIFT)) 125 126#define DLPRMSHIFT 20 127#define DLPRMMASK ((0xF<<DLPRMSHIFT)) 128#define DLPRM1 ((0x1<<DLPRMSHIFT)) 129#define DLPRM2 ((0x2<<DLPRMSHIFT)) 130#define DLPRM3 ((0x4<<DLPRMSHIFT)) 131#define DLPRM4 ((0x8<<DLPRMSHIFT)) 132 133#define DLPQSHIFT 24 134#define DLPQMASK ((0xF<<DLPQSHIFT)) 135#define DLPQ1 ((0x1<<DLPQSHIFT)) 136#define DLPQ2 ((0x2<<DLPQSHIFT)) 137#define DLPQ3 ((0x4<<DLPQSHIFT)) 138#define DLPQ4 ((0x8<<DLPQSHIFT)) 139 140 141#define IP_TEST 0x0001 /* test IP address */ 142 143void Parse_debug( char *arg, int interactive); 144 145 146/* we define these and then run gcc -Wformat -Wall to find 147 * debug statements with bad formats 148 */ 149#if defined(FORMAT_TEST) 150#undef DEBUG1 151#undef DEBUG2 152#undef DEBUG3 153#undef DEBUG4 154#undef DEBUG5 155#undef DEBUG6 156#undef DEBUG7 157#define DEBUG1 printf 158#define DEBUG2 printf 159#define DEBUG3 printf 160#define DEBUG4 printf 161#define DEBUG5 printf 162#define DEBUG6 printf 163#define DEBUG7 printf 164#endif 165 166/* PROTOTYPES */ 167 168#endif 169