2007-09-26 14:38:07 +05:30
|
|
|
/*
|
|
|
|
* @file einfo.h
|
2007-09-25 21:08:21 +05:30
|
|
|
* @brief Describes how to interface with the einfo library
|
|
|
|
*
|
|
|
|
* Copyright 2007 Gentoo Foundation
|
|
|
|
* Released under the GPLv2
|
|
|
|
*/
|
2007-04-05 16:48:42 +05:30
|
|
|
|
|
|
|
#ifndef __EINFO_H__
|
|
|
|
#define __EINFO_H__
|
|
|
|
|
|
|
|
#ifdef __GNUC__
|
2007-09-26 14:38:07 +05:30
|
|
|
# define __EINFO_PRINTF __attribute__ ((__format__ (__printf__, 1, 2)))
|
|
|
|
# define __EINFO_XPRINTF __attribute__ ((__noreturn__, __format__ (__printf__, 1, 2)))
|
|
|
|
# define __EEND_PRINTF __attribute__ ((__format__ (__printf__, 2, 3)))
|
|
|
|
#else
|
|
|
|
# define __EINFO_PRINTF
|
|
|
|
# define __EINFO_XPRINTF
|
|
|
|
# define __EEND_PRINTF
|
2007-04-05 16:48:42 +05:30
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
2007-09-25 21:08:21 +05:30
|
|
|
/*! @brief Color types to use */
|
2007-04-05 16:48:42 +05:30
|
|
|
typedef enum
|
|
|
|
{
|
2007-04-17 15:02:18 +05:30
|
|
|
ecolor_good,
|
|
|
|
ecolor_warn,
|
|
|
|
ecolor_bad,
|
|
|
|
ecolor_hilite,
|
|
|
|
ecolor_bracket,
|
|
|
|
ecolor_normal
|
2007-04-05 16:48:42 +05:30
|
|
|
} einfo_color_t;
|
|
|
|
|
2007-09-25 21:08:21 +05:30
|
|
|
/*! @brief Returns the ASCII code for the color */
|
2007-04-17 15:02:18 +05:30
|
|
|
const char *ecolor (einfo_color_t);
|
2007-09-25 21:08:21 +05:30
|
|
|
|
|
|
|
/*! @brief Writes to syslog. */
|
2007-09-26 14:38:07 +05:30
|
|
|
void elog (int __level, const char *__fmt, ...) __EEND_PRINTF;
|
2007-09-25 21:08:21 +05:30
|
|
|
|
|
|
|
/*!
|
|
|
|
* @brief Display informational messages.
|
|
|
|
*
|
|
|
|
* The einfo family of functions display messages in a consistent manner
|
|
|
|
* across Gentoo applications. Basically they prefix the message with
|
|
|
|
* " * ". If the terminal can handle color then we color the * based on
|
|
|
|
* the command used. Otherwise we are identical to the printf function.
|
|
|
|
*
|
|
|
|
* - einfo - green
|
|
|
|
* - ewarn - yellow
|
|
|
|
* - eerror - red
|
|
|
|
*
|
|
|
|
* The n suffix denotes that no new line should be printed.
|
|
|
|
* The v suffix means only print if RC_VERBOSE is yes.
|
|
|
|
*/
|
|
|
|
/*@{*/
|
2007-09-26 14:38:07 +05:30
|
|
|
int einfon (const char *__fmt, ...) __EINFO_PRINTF;
|
|
|
|
int ewarnn (const char *__fmt, ...) __EINFO_PRINTF;
|
|
|
|
int eerrorn (const char *__fmt, ...) __EINFO_PRINTF;
|
|
|
|
int einfo (const char *__fmt, ...) __EINFO_PRINTF;
|
|
|
|
int ewarn (const char *__fmt, ...) __EINFO_PRINTF;
|
|
|
|
void ewarnx (const char *__fmt, ...) __EINFO_XPRINTF;
|
|
|
|
int eerror (const char *__fmt, ...) __EINFO_PRINTF;
|
|
|
|
void eerrorx (const char *__fmt, ...) __EINFO_XPRINTF;
|
2007-09-25 21:08:21 +05:30
|
|
|
|
2007-09-26 14:38:07 +05:30
|
|
|
int einfovn (const char *__fmt, ...) __EINFO_PRINTF;
|
|
|
|
int ewarnvn (const char *__fmt, ...) __EINFO_PRINTF;
|
|
|
|
int ebeginvn (const char *__fmt, ...) __EINFO_PRINTF;
|
|
|
|
int eendvn (int __retval, const char *__fmt, ...) __EEND_PRINTF;
|
|
|
|
int ewendvn (int __retval, const char *__fmt, ...) __EEND_PRINTF;
|
|
|
|
int einfov (const char *__fmt, ...) __EINFO_PRINTF;
|
|
|
|
int ewarnv (const char *__fmt, ...) __EINFO_PRINTF;
|
2007-09-25 21:08:21 +05:30
|
|
|
/*@}*/
|
|
|
|
|
|
|
|
/*! @ingroup ebegin
|
|
|
|
* @brief Display informational messages that may take some time.
|
|
|
|
*
|
|
|
|
* Similar to einfo, but we add ... to the end of the message */
|
|
|
|
/*@{*/
|
2007-09-26 14:38:07 +05:30
|
|
|
int ebeginv (const char *__fmt, ...) __EINFO_PRINTF;
|
|
|
|
int ebegin (const char *__fmt, ...) __EINFO_PRINTF;
|
2007-09-25 21:08:21 +05:30
|
|
|
/*@}*/
|
|
|
|
|
|
|
|
/*! @ingroup eend
|
|
|
|
* @brief End an ebegin.
|
|
|
|
*
|
|
|
|
* If you ebegin, you should eend also.
|
|
|
|
* eend places [ ok ] or [ !! ] at the end of the terminal line depending on
|
|
|
|
* retval (0 or ok, anything else for !!)
|
|
|
|
*
|
|
|
|
* ebracket allows you to specifiy the position, color and message */
|
|
|
|
/*@{*/
|
2007-09-26 14:38:07 +05:30
|
|
|
int eend (int __retval, const char *__fmt, ...) __EEND_PRINTF;
|
|
|
|
int ewend (int __retval, const char *__fmt, ...) __EEND_PRINTF;
|
|
|
|
void ebracket (int __col, einfo_color_t __color, const char *__msg);
|
2007-09-25 21:08:21 +05:30
|
|
|
|
2007-09-26 14:38:07 +05:30
|
|
|
int eendv (int __retval, const char *__fmt, ...) __EEND_PRINTF;
|
|
|
|
int ewendv (int __retval, const char *__fmt, ...) __EEND_PRINTF;
|
2007-09-25 21:08:21 +05:30
|
|
|
/*@}*/
|
|
|
|
|
|
|
|
/*! @ingroup eindent
|
|
|
|
* @brief Indents the einfo lines.
|
|
|
|
*
|
|
|
|
* For each indent you should outdent when done */
|
|
|
|
/*@{*/
|
2007-04-05 16:48:42 +05:30
|
|
|
void eindent (void);
|
|
|
|
void eoutdent (void);
|
2007-04-10 21:41:20 +05:30
|
|
|
void eindentv (void);
|
|
|
|
void eoutdentv (void);
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2007-09-25 21:08:21 +05:30
|
|
|
/*! @brief Prefix each einfo line with something */
|
2007-09-26 14:38:07 +05:30
|
|
|
void eprefix (const char *__prefix);
|
2007-04-25 18:00:24 +05:30
|
|
|
|
2007-04-05 16:48:42 +05:30
|
|
|
#endif
|