1228690Sdes/*- 2228690Sdes * Copyright (c) 2001-2003 Networks Associates Technology, Inc. 3228690Sdes * Copyright (c) 2004-2011 Dag-Erling Sm��rgrav 4228690Sdes * All rights reserved. 5228690Sdes * 6228690Sdes * This software was developed for the FreeBSD Project by ThinkSec AS and 7228690Sdes * Network Associates Laboratories, the Security Research Division of 8228690Sdes * Network Associates, Inc. under DARPA/SPAWAR contract N66001-01-C-8035 9228690Sdes * ("CBOSS"), as part of the DARPA CHATS research program. 10228690Sdes * 11228690Sdes * Redistribution and use in source and binary forms, with or without 12228690Sdes * modification, are permitted provided that the following conditions 13228690Sdes * are met: 14228690Sdes * 1. Redistributions of source code must retain the above copyright 15228690Sdes * notice, this list of conditions and the following disclaimer. 16228690Sdes * 2. Redistributions in binary form must reproduce the above copyright 17228690Sdes * notice, this list of conditions and the following disclaimer in the 18228690Sdes * documentation and/or other materials provided with the distribution. 19228690Sdes * 3. The name of the author may not be used to endorse or promote 20228690Sdes * products derived from this software without specific prior written 21228690Sdes * permission. 22228690Sdes * 23228690Sdes * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 24228690Sdes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25228690Sdes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26228690Sdes * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 27228690Sdes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28228690Sdes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29228690Sdes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30228690Sdes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31228690Sdes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32228690Sdes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33228690Sdes * SUCH DAMAGE. 34228690Sdes * 35255376Sdes * $Id: openpam_debug.h 648 2013-03-05 17:54:27Z des $ 36228690Sdes */ 37228690Sdes 38236099Sdes#ifndef OPENPAM_DEBUG_H_INCLUDED 39236099Sdes#define OPENPAM_DEBUG_H_INCLUDED 40228690Sdes 41228690Sdes#ifdef OPENPAM_DEBUG 42236099Sdes#define ENTER() openpam_log(PAM_LOG_LIBDEBUG, "entering") 43228690Sdes#define ENTERI(i) do { \ 44228690Sdes int i_ = (i); \ 45228690Sdes if (i_ > 0 && i_ < PAM_NUM_ITEMS) \ 46236099Sdes openpam_log(PAM_LOG_LIBDEBUG, "entering: %s", pam_item_name[i_]); \ 47228690Sdes else \ 48236099Sdes openpam_log(PAM_LOG_LIBDEBUG, "entering: %d", i_); \ 49228690Sdes} while (0) 50228690Sdes#define ENTERN(n) do { \ 51228690Sdes int n_ = (n); \ 52236099Sdes openpam_log(PAM_LOG_LIBDEBUG, "entering: %d", n_); \ 53228690Sdes} while (0) 54228690Sdes#define ENTERS(s) do { \ 55228690Sdes const char *s_ = (s); \ 56228690Sdes if (s_ == NULL) \ 57236099Sdes openpam_log(PAM_LOG_LIBDEBUG, "entering: NULL"); \ 58228690Sdes else \ 59236099Sdes openpam_log(PAM_LOG_LIBDEBUG, "entering: '%s'", s_); \ 60228690Sdes} while (0) 61236099Sdes#define ENTERF(f) do { \ 62236099Sdes int f_ = (f); \ 63236099Sdes if (f_ >= 0 && f_ <= OPENPAM_NUM_FEATURES) \ 64236099Sdes openpam_log(PAM_LOG_LIBDEBUG, "entering: %s", \ 65236099Sdes openpam_features[f_].name); \ 66236099Sdes else \ 67236099Sdes openpam_log(PAM_LOG_LIBDEBUG, "entering: %d", f_); \ 68236099Sdes} while (0) 69236099Sdes#define RETURNV() openpam_log(PAM_LOG_LIBDEBUG, "returning") 70228690Sdes#define RETURNC(c) do { \ 71228690Sdes int c_ = (c); \ 72228690Sdes if (c_ >= 0 && c_ < PAM_NUM_ERRORS) \ 73236099Sdes openpam_log(PAM_LOG_LIBDEBUG, "returning %s", pam_err_name[c_]); \ 74228690Sdes else \ 75236099Sdes openpam_log(PAM_LOG_LIBDEBUG, "returning %d!", c_); \ 76228690Sdes return (c_); \ 77228690Sdes} while (0) 78228690Sdes#define RETURNN(n) do { \ 79228690Sdes int n_ = (n); \ 80236099Sdes openpam_log(PAM_LOG_LIBDEBUG, "returning %d", n_); \ 81228690Sdes return (n_); \ 82228690Sdes} while (0) 83228690Sdes#define RETURNP(p) do { \ 84236099Sdes void *p_ = (p); \ 85228690Sdes if (p_ == NULL) \ 86236099Sdes openpam_log(PAM_LOG_LIBDEBUG, "returning NULL"); \ 87228690Sdes else \ 88236099Sdes openpam_log(PAM_LOG_LIBDEBUG, "returning %p", p_); \ 89228690Sdes return (p_); \ 90228690Sdes} while (0) 91228690Sdes#define RETURNS(s) do { \ 92228690Sdes const char *s_ = (s); \ 93228690Sdes if (s_ == NULL) \ 94236099Sdes openpam_log(PAM_LOG_LIBDEBUG, "returning NULL"); \ 95228690Sdes else \ 96236099Sdes openpam_log(PAM_LOG_LIBDEBUG, "returning '%s'", s_); \ 97228690Sdes return (s_); \ 98228690Sdes} while (0) 99228690Sdes#else 100228690Sdes#define ENTER() 101228690Sdes#define ENTERI(i) 102228690Sdes#define ENTERN(n) 103228690Sdes#define ENTERS(s) 104236099Sdes#define ENTERF(f) 105228690Sdes#define RETURNV() return 106228690Sdes#define RETURNC(c) return (c) 107228690Sdes#define RETURNN(n) return (n) 108228690Sdes#define RETURNP(p) return (p) 109228690Sdes#define RETURNS(s) return (s) 110228690Sdes#endif 111228690Sdes 112228690Sdes#endif 113