1*0d9d0fd8Schristos /* $NetBSD: openpam_debug.h,v 1.5 2023/06/30 21:46:20 christos Exp $ */ 2201780c4Schristos 376e8c542Schristos /*- 476e8c542Schristos * Copyright (c) 2001-2003 Networks Associates Technology, Inc. 576e8c542Schristos * Copyright (c) 2004-2011 Dag-Erling Smørgrav 676e8c542Schristos * All rights reserved. 776e8c542Schristos * 876e8c542Schristos * This software was developed for the FreeBSD Project by ThinkSec AS and 976e8c542Schristos * Network Associates Laboratories, the Security Research Division of 1076e8c542Schristos * Network Associates, Inc. under DARPA/SPAWAR contract N66001-01-C-8035 1176e8c542Schristos * ("CBOSS"), as part of the DARPA CHATS research program. 1276e8c542Schristos * 1376e8c542Schristos * Redistribution and use in source and binary forms, with or without 1476e8c542Schristos * modification, are permitted provided that the following conditions 1576e8c542Schristos * are met: 1676e8c542Schristos * 1. Redistributions of source code must retain the above copyright 1776e8c542Schristos * notice, this list of conditions and the following disclaimer. 1876e8c542Schristos * 2. Redistributions in binary form must reproduce the above copyright 1976e8c542Schristos * notice, this list of conditions and the following disclaimer in the 2076e8c542Schristos * documentation and/or other materials provided with the distribution. 2176e8c542Schristos * 3. The name of the author may not be used to endorse or promote 2276e8c542Schristos * products derived from this software without specific prior written 2376e8c542Schristos * permission. 2476e8c542Schristos * 2576e8c542Schristos * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 2676e8c542Schristos * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2776e8c542Schristos * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2876e8c542Schristos * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 2976e8c542Schristos * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 3076e8c542Schristos * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 3176e8c542Schristos * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3276e8c542Schristos * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3376e8c542Schristos * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3476e8c542Schristos * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3576e8c542Schristos * SUCH DAMAGE. 3676e8c542Schristos */ 3776e8c542Schristos 3876e8c542Schristos #ifndef OPENPAM_DEBUG_H_INCLUDED 3976e8c542Schristos #define OPENPAM_DEBUG_H_INCLUDED 4076e8c542Schristos 4176e8c542Schristos #ifdef OPENPAM_DEBUG 4276e8c542Schristos #define ENTER() openpam_log(PAM_LOG_LIBDEBUG, "entering") 4376e8c542Schristos #define ENTERI(i) do { \ 4476e8c542Schristos int i_ = (i); \ 4576e8c542Schristos if (i_ > 0 && i_ < PAM_NUM_ITEMS) \ 4676e8c542Schristos openpam_log(PAM_LOG_LIBDEBUG, "entering: %s", pam_item_name[i_]); \ 4776e8c542Schristos else \ 4876e8c542Schristos openpam_log(PAM_LOG_LIBDEBUG, "entering: %d", i_); \ 49201780c4Schristos } while (/*CONSTCOND*/0) 5076e8c542Schristos #define ENTERN(n) do { \ 518ddd93c1Schristos intmax_t n_ = (n); \ 528ddd93c1Schristos openpam_log(PAM_LOG_LIBDEBUG, "entering: %jd", n_); \ 53201780c4Schristos } while (/*CONSTCOND*/0) 5476e8c542Schristos #define ENTERS(s) do { \ 5576e8c542Schristos const char *s_ = (s); \ 5676e8c542Schristos if (s_ == NULL) \ 5776e8c542Schristos openpam_log(PAM_LOG_LIBDEBUG, "entering: NULL"); \ 5876e8c542Schristos else \ 5976e8c542Schristos openpam_log(PAM_LOG_LIBDEBUG, "entering: '%s'", s_); \ 60201780c4Schristos } while (/*CONSTCOND*/0) 6176e8c542Schristos #define ENTERF(f) do { \ 6276e8c542Schristos int f_ = (f); \ 6376e8c542Schristos if (f_ >= 0 && f_ <= OPENPAM_NUM_FEATURES) \ 6476e8c542Schristos openpam_log(PAM_LOG_LIBDEBUG, "entering: %s", \ 6576e8c542Schristos openpam_features[f_].name); \ 6676e8c542Schristos else \ 6776e8c542Schristos openpam_log(PAM_LOG_LIBDEBUG, "entering: %d", f_); \ 68201780c4Schristos } while (/*CONSTCOND*/0) 6976e8c542Schristos #define RETURNV() openpam_log(PAM_LOG_LIBDEBUG, "returning") 7076e8c542Schristos #define RETURNC(c) do { \ 7176e8c542Schristos int c_ = (c); \ 7276e8c542Schristos if (c_ >= 0 && c_ < PAM_NUM_ERRORS) \ 7376e8c542Schristos openpam_log(PAM_LOG_LIBDEBUG, "returning %s", pam_err_name[c_]); \ 7476e8c542Schristos else \ 7576e8c542Schristos openpam_log(PAM_LOG_LIBDEBUG, "returning %d!", c_); \ 7676e8c542Schristos return (c_); \ 77201780c4Schristos } while (/*CONSTCOND*/0)/*NOTREACHED*/ 7876e8c542Schristos #define RETURNN(n) do { \ 7976e8c542Schristos int n_ = (n); \ 8076e8c542Schristos openpam_log(PAM_LOG_LIBDEBUG, "returning %d", n_); \ 8176e8c542Schristos return (n_); \ 82201780c4Schristos } while (/*CONSTCOND*/0)/*NOTREACHED*/ 8376e8c542Schristos #define RETURNP(p) do { \ 8476e8c542Schristos void *p_ = (p); \ 8576e8c542Schristos if (p_ == NULL) \ 8676e8c542Schristos openpam_log(PAM_LOG_LIBDEBUG, "returning NULL"); \ 8776e8c542Schristos else \ 8876e8c542Schristos openpam_log(PAM_LOG_LIBDEBUG, "returning %p", p_); \ 8976e8c542Schristos return (p_); \ 90201780c4Schristos } while (/*CONSTCOND*/0)/*NOTREACHED*/ 9176e8c542Schristos #define RETURNS(s) do { \ 9276e8c542Schristos const char *s_ = (s); \ 9376e8c542Schristos if (s_ == NULL) \ 9476e8c542Schristos openpam_log(PAM_LOG_LIBDEBUG, "returning NULL"); \ 9576e8c542Schristos else \ 9676e8c542Schristos openpam_log(PAM_LOG_LIBDEBUG, "returning '%s'", s_); \ 9776e8c542Schristos return (s_); \ 98201780c4Schristos } while (/*CONSTCOND*/0)/*NOTREACHED*/ 9976e8c542Schristos #else 10076e8c542Schristos #define ENTER() 10176e8c542Schristos #define ENTERI(i) 10276e8c542Schristos #define ENTERN(n) 10376e8c542Schristos #define ENTERS(s) 10476e8c542Schristos #define ENTERF(f) 10576e8c542Schristos #define RETURNV() return 10676e8c542Schristos #define RETURNC(c) return (c) 10776e8c542Schristos #define RETURNN(n) return (n) 10876e8c542Schristos #define RETURNP(p) return (p) 10976e8c542Schristos #define RETURNS(s) return (s) 11076e8c542Schristos #endif 11176e8c542Schristos 11276e8c542Schristos #endif 113