Blame include/error.h

Packit 4a16fb
/**
Packit 4a16fb
 * \file include/error.h
Packit 4a16fb
 * \brief Application interface library for the ALSA driver
Packit 4a16fb
 * \author Jaroslav Kysela <perex@perex.cz>
Packit 4a16fb
 * \author Abramo Bagnara <abramo@alsa-project.org>
Packit 4a16fb
 * \author Takashi Iwai <tiwai@suse.de>
Packit 4a16fb
 * \date 1998-2001
Packit 4a16fb
 *
Packit 4a16fb
 * Application interface library for the ALSA driver
Packit 4a16fb
 */
Packit 4a16fb
/*
Packit 4a16fb
 *   This library is free software; you can redistribute it and/or modify
Packit 4a16fb
 *   it under the terms of the GNU Lesser General Public License as
Packit 4a16fb
 *   published by the Free Software Foundation; either version 2.1 of
Packit 4a16fb
 *   the License, or (at your option) any later version.
Packit 4a16fb
 *
Packit 4a16fb
 *   This program is distributed in the hope that it will be useful,
Packit 4a16fb
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 4a16fb
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 4a16fb
 *   GNU Lesser General Public License for more details.
Packit 4a16fb
 *
Packit 4a16fb
 *   You should have received a copy of the GNU Lesser General Public
Packit 4a16fb
 *   License along with this library; if not, write to the Free Software
Packit 4a16fb
 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
Packit 4a16fb
 *
Packit 4a16fb
 */
Packit 4a16fb
Packit 4a16fb
#ifndef __ALSA_ERROR_H
Packit 4a16fb
#define __ALSA_ERROR_H
Packit 4a16fb
Packit 4a16fb
#ifdef __cplusplus
Packit 4a16fb
extern "C" {
Packit 4a16fb
#endif
Packit 4a16fb
Packit 4a16fb
/**
Packit 4a16fb
 *  \defgroup Error Error handling
Packit 4a16fb
 *  Error handling macros and functions.
Packit 4a16fb
 *  \{
Packit 4a16fb
 */
Packit 4a16fb
Packit 4a16fb
#define SND_ERROR_BEGIN				500000			/**< Lower boundary of sound error codes. */
Packit 4a16fb
#define SND_ERROR_INCOMPATIBLE_VERSION		(SND_ERROR_BEGIN+0)	/**< Kernel/library protocols are not compatible. */
Packit 4a16fb
#define SND_ERROR_ALISP_NIL			(SND_ERROR_BEGIN+1)	/**< Lisp encountered an error during acall. */
Packit 4a16fb
Packit 4a16fb
const char *snd_strerror(int errnum);
Packit 4a16fb
Packit 4a16fb
/**
Packit 4a16fb
 * \brief Error handler callback.
Packit 4a16fb
 * \param file Source file name.
Packit 4a16fb
 * \param line Line number.
Packit 4a16fb
 * \param function Function name.
Packit 4a16fb
 * \param err Value of \c errno, or 0 if not relevant.
Packit 4a16fb
 * \param fmt \c printf(3) format.
Packit 4a16fb
 * \param ... \c printf(3) arguments.
Packit 4a16fb
 *
Packit 4a16fb
 * A function of this type is called by the ALSA library when an error occurs.
Packit 4a16fb
 * This function usually shows the message on the screen, and/or logs it.
Packit 4a16fb
 */
Packit 4a16fb
typedef void (*snd_lib_error_handler_t)(const char *file, int line, const char *function, int err, const char *fmt, ...) /* __attribute__ ((format (printf, 5, 6))) */;
Packit 4a16fb
extern snd_lib_error_handler_t snd_lib_error;
Packit 4a16fb
extern int snd_lib_error_set_handler(snd_lib_error_handler_t handler);
Packit 4a16fb
Packit 4a16fb
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 95)
Packit 4a16fb
#define SNDERR(...) snd_lib_error(__FILE__, __LINE__, __func__, 0, __VA_ARGS__) /**< Shows a sound error message. */
Packit 4a16fb
#define SYSERR(...) snd_lib_error(__FILE__, __LINE__, __func__, errno, __VA_ARGS__) /**< Shows a system error message (related to \c errno). */
Packit 4a16fb
#else
Packit 4a16fb
#define SNDERR(args...) snd_lib_error(__FILE__, __LINE__, __func__, 0, ##args) /**< Shows a sound error message. */
Packit 4a16fb
#define SYSERR(args...) snd_lib_error(__FILE__, __LINE__, __func__, errno, ##args) /**< Shows a system error message (related to \c errno). */
Packit 4a16fb
#endif
Packit 4a16fb
Packit 4a16fb
/** \} */
Packit 4a16fb
Packit 4a16fb
#ifdef __cplusplus
Packit 4a16fb
}
Packit 4a16fb
#endif
Packit 4a16fb
Packit 4a16fb
/** Local error handler function type */
Packit 4a16fb
typedef void (*snd_local_error_handler_t)(const char *file, int line,
Packit 4a16fb
					  const char *func, int err,
Packit 4a16fb
					  const char *fmt, va_list arg);
Packit 4a16fb
Packit 4a16fb
snd_local_error_handler_t snd_lib_error_set_local(snd_local_error_handler_t func);
Packit 4a16fb
Packit 4a16fb
#endif /* __ALSA_ERROR_H */
Packit 4a16fb