openrc/src/libeinfo.c

839 lines
14 KiB
C
Raw Normal View History

/*
einfo.c
Gentoo informational functions
Copyright 2007 Gentoo Foundation
*/
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <syslog.h>
#include <unistd.h>
#include "einfo.h"
#include "rc.h"
#include "rc-misc.h"
#include "hidden-visibility.h"
2007-04-17 15:02:18 +05:30
hidden_proto(ecolor)
hidden_proto(ebegin)
hidden_proto(ebeginv)
hidden_proto(ebracket)
hidden_proto(eend)
hidden_proto(eendv)
hidden_proto(eerror)
hidden_proto(eerrorn)
hidden_proto(eerrorx)
hidden_proto(eflush)
hidden_proto(eclose)
hidden_proto(eindent)
hidden_proto(eindentv)
hidden_proto(einfo)
hidden_proto(einfon)
hidden_proto(einfov)
hidden_proto(einfovn)
hidden_proto(eoutdent)
hidden_proto(eoutdentv)
hidden_proto(ewarn)
hidden_proto(ewarnn)
hidden_proto(ewarnv)
hidden_proto(ewarnvn)
hidden_proto(ewarnx)
hidden_proto(ewend)
hidden_proto(ewendv)
2007-04-17 15:02:18 +05:30
/* Incase we cannot work out how many columns from ioctl, supply a default */
#define DEFAULT_COLS 80
2007-04-17 15:02:18 +05:30
#define OK "ok"
#define NOT_OK "!!"
#define CHECK_VERBOSE if (! is_env ("RC_VERBOSE", "yes")) return 0
2007-04-17 15:02:18 +05:30
/* Number of spaces for an indent */
#define INDENT_WIDTH 2
2007-04-17 15:02:18 +05:30
/* How wide can the indent go? */
#define INDENT_MAX 40
#define EBUFFER_LOCK RC_SVCDIR "ebuffer/.lock"
2007-04-17 15:02:18 +05:30
/* Default colours */
#define ECOLOR_GOOD "\033[32;01m"
#define ECOLOR_WARN "\033[33;01m"
#define ECOLOR_BAD "\033[31;01m"
#define ECOLOR_HILITE "\033[36;01m"
#define ECOLOR_BRACKET "\033[34;01m"
#define ECOLOR_NORMAL "\033[0m"
#define ECOLOR_FLUSH "\033[K"
/* A cheat sheet of colour capable terminals
This is taken from DIR_COLORS from GNU coreutils
We embed it here as we shouldn't depend on coreutils */
2007-04-17 15:02:18 +05:30
static const char *color_terms[] = {
2007-04-11 18:14:47 +05:30
"Eterm",
"ansi",
"color-xterm",
"con132x25",
"con132x30",
"con132x43",
"con132x60",
"con80x25",
"con80x28",
"con80x30",
"con80x43",
"con80x50",
"con80x60",
"cons25",
"console",
"cygwin",
"dtterm",
"gnome",
"konsole",
"kterm",
"linux",
"linux-c",
"mach-color",
"mlterm",
"putty",
"rxvt",
"rxvt-cygwin",
"rxvt-cygwin-native",
"rxvt-unicode",
"screen",
"screen-bce",
"screen-w",
"screen.linux",
"vt100",
"xterm",
"xterm-256color",
"xterm-color",
"xterm-debian",
NULL
};
/* We use this array to save the stdout/stderr fd's for buffering */
static int stdfd[2] = {-1, -1};
static FILE *ebfp = NULL;
static char ebfile[PATH_MAX] = { '\0' };
static bool is_env (const char *var, const char *val)
{
2007-04-11 18:14:47 +05:30
char *v;
2007-04-11 18:14:47 +05:30
if (! var)
return (false);
2007-04-11 18:14:47 +05:30
v = getenv (var);
if (! v)
return (val ? false : true);
2007-04-11 18:14:47 +05:30
return (strcasecmp (v, val) ? false : true);
}
2007-04-17 15:02:18 +05:30
static bool colour_terminal (void)
{
2007-04-11 18:14:47 +05:30
static int in_colour = -1;
int i = 0;
char *term;
2007-04-11 18:14:47 +05:30
if (in_colour == 0)
return (false);
if (in_colour == 1)
return (true);
2007-04-11 18:14:47 +05:30
term = getenv ("TERM");
/* If $TERM isn't set then the chances are we're in single user mode */
if (! term)
return (true);
2007-04-17 15:02:18 +05:30
while (color_terms[i]) {
if (strcmp (color_terms[i], term) == 0) {
2007-04-11 18:14:47 +05:30
in_colour = 1;
return (true);
}
i++;
}
2007-04-11 18:14:47 +05:30
in_colour = 0;
return (false);
}
static int get_term_columns (void)
{
2007-04-17 17:51:15 +05:30
#if defined(TIOCGSIZE) /* BSD */
2007-04-11 18:14:47 +05:30
struct ttysize ts;
2007-04-11 18:14:47 +05:30
if (ioctl(0, TIOCGSIZE, &ts) == 0)
return (ts.ts_cols);
2007-04-17 17:51:15 +05:30
#elif defined(TIOCGWINSZ) /* Linux */
struct winsize ws;
2007-04-11 18:14:47 +05:30
if (ioctl(0, TIOCGWINSZ, &ws) == 0)
return (ws.ws_col);
#endif
2007-04-11 18:14:47 +05:30
return (DEFAULT_COLS);
}
void ebuffer (const char *file)
{
/* Don't ebuffer if we don't have a file or we already are */
if (! file || stdfd[0] >= 0 || ! isatty (fileno (stdout)))
return;
/* Save the current fd's */
stdfd[0] = dup (fileno (stdout));
stdfd[1] = dup (fileno (stderr));
if (! (ebfp = fopen (file, "w+"))) {
2007-04-11 18:14:47 +05:30
fprintf (stderr, "fopen `%s': %s\n", file, strerror (errno));
return;
2007-04-11 18:14:47 +05:30
}
snprintf (ebfile, sizeof (ebfile), "%s", file);
fflush (stdout);
fflush (stderr);
/* Now redirect stdout and stderr */
if ((dup2 (fileno (ebfp), fileno (stdout))) < 0)
fprintf (stderr, "dup2: %s", strerror (errno));
if ((dup2 (fileno (ebfp), fileno (stderr))) < 0)
fprintf (stderr, "dup2: %s", strerror (errno));
/* Store the filename in our environment so scripts can tell if we're
* buffering or not */
unsetenv ("RC_EBUFFER");
setenv ("RC_EBUFFER", file, 1);
return;
}
static void _eflush (bool reopen)
{
2007-04-11 18:14:47 +05:30
char buffer[RC_LINEBUFFER];
int serrno = errno;
/* eflush called from an init script? */
if (! ebfp) {
char *file = getenv ("RC_EBUFFER");
if (file)
ebfp = fopen (file, "a+");
2007-04-11 18:14:47 +05:30
}
if (! ebfp)
2007-04-11 18:14:47 +05:30
return;
fflush (stdout);
fflush (stderr);
/* Restore stdout and stderr now */
if (stdfd[0] >= 0) {
dup2 (stdfd[0], fileno (stdout));
dup2 (stdfd[1], fileno (stderr));
} else {
char *tty = getenv ("RC_TTY");
if (tty) {
freopen (tty, "w+", stdout);
dup2 (fileno (stdout), fileno (stderr));
}
}
2007-04-11 18:14:47 +05:30
/* Spin until we can lock the ebuffer */
while (true) {
struct timeval tv;
errno = 0;
if (mkfifo (EBUFFER_LOCK, 0700) == 0)
2007-04-11 18:14:47 +05:30
break;
if (errno != EEXIST)
eerror ("mkfifo `%s': %s\n", EBUFFER_LOCK, strerror (errno));
tv.tv_sec = 0;
tv.tv_usec = 20000;
select (0, NULL, NULL, NULL, &tv);
2007-04-11 18:14:47 +05:30
}
errno = serrno;
2007-04-11 18:14:47 +05:30
/* Dump the file to stdout */
2007-04-11 18:14:47 +05:30
memset (buffer, 0, RC_LINEBUFFER);
if (fseek (ebfp, (off_t) 0, SEEK_SET) < 0)
eerror ("fseek: %s", strerror (errno));
else {
while (fgets (buffer, RC_LINEBUFFER, ebfp))
printf ("%s", buffer);
2007-04-11 18:14:47 +05:30
}
fflush (stdout);
fflush (stderr);
2007-04-11 18:14:47 +05:30
if (unlink (EBUFFER_LOCK))
eerror ("unlink `%s': %s", EBUFFER_LOCK, strerror (errno));
if (reopen) {
ftruncate (fileno (ebfp), (off_t) 0);
fseek (ebfp, (off_t) 0, SEEK_SET);
dup2 (fileno (ebfp), fileno (stdout));
dup2 (fileno (ebfp), fileno (stderr));
} else {
stdfd[0] = -1;
stdfd[1] = -1;
fclose (ebfp);
ebfp = NULL;
unlink (ebfile);
ebfile[0] = '\0';
unsetenv ("RC_EBUFFER");
}
2007-04-11 18:14:47 +05:30
return;
}
2007-04-11 18:14:47 +05:30
void eflush () {
_eflush (true);
2007-04-11 18:14:47 +05:30
}
hidden_def(eflush)
2007-04-11 18:14:47 +05:30
void eclose () {
_eflush (false);
}
hidden_def(eclose)
static void elog (int level, const char *fmt, va_list ap)
{
2007-04-11 18:14:47 +05:30
char *e = getenv ("RC_ELOG");
va_list apc;
2007-04-11 18:14:47 +05:30
if (fmt && e) {
closelog ();
openlog (e, LOG_PID, LOG_DAEMON);
va_copy (apc, ap);
vsyslog (level, fmt, apc);
va_end (apc);
closelog ();
}
}
2007-04-11 18:14:47 +05:30
static int _eindent (FILE *stream)
{
2007-04-11 18:14:47 +05:30
char *env = getenv ("RC_EINDENT");
int amount = 0;
char indent[INDENT_MAX];
2007-04-11 18:14:47 +05:30
if (env) {
errno = 0;
amount = strtol (env, NULL, 0);
if (errno != 0 || amount < 0)
amount = 0;
else if (amount > INDENT_MAX)
amount = INDENT_MAX;
2007-04-11 18:14:47 +05:30
if (amount > 0)
memset (indent, ' ', amount);
}
2007-04-11 18:14:47 +05:30
/* Terminate it */
memset (indent + amount, 0, 1);
return (fprintf (stream, "%s", indent));
}
2007-04-17 15:02:18 +05:30
const char *ecolor (einfo_color_t color) {
const char *col = NULL;
2007-04-17 15:02:18 +05:30
if (! colour_terminal ())
return ("");
switch (color) {
2007-04-17 15:02:18 +05:30
case ecolor_good:
if (! (col = getenv ("ECOLOR_GOOD")))
col = ECOLOR_GOOD;
break;
2007-04-17 15:02:18 +05:30
case ecolor_warn:
if (! (col = getenv ("ECOLOR_WARN")))
col = ECOLOR_WARN;
break;
2007-04-17 15:02:18 +05:30
case ecolor_bad:
if (! (col = getenv ("ECOLOR_BAD")))
col = ECOLOR_BAD;
break;
2007-04-17 15:02:18 +05:30
case ecolor_hilite:
if (! (col = getenv ("ECOLOR_HILITE")))
col = ECOLOR_HILITE;
break;
2007-04-17 15:02:18 +05:30
case ecolor_bracket:
if (! (col = getenv ("ECOLOR_BRACKET")))
col = ECOLOR_BRACKET;
break;
2007-04-17 15:02:18 +05:30
case ecolor_normal:
col = ECOLOR_NORMAL;
break;
}
return (col);
}
2007-04-17 15:02:18 +05:30
hidden_def(ecolor)
#define EINFOVN(_file, _color) \
2007-04-17 15:02:18 +05:30
fprintf (_file, " %s*%s ", ecolor (_color), ecolor (ecolor_normal)); \
2007-04-10 16:54:58 +05:30
retval += _eindent (_file); \
{ \
2007-04-11 18:14:47 +05:30
va_list _ap; \
va_copy (_ap, ap); \
retval += vfprintf (_file, fmt, _ap) + 3; \
va_end (_ap); \
2007-04-10 16:54:58 +05:30
} \
if (colour_terminal ()) \
2007-04-17 15:02:18 +05:30
fprintf (_file, ECOLOR_FLUSH);
static int _einfovn (const char *fmt, va_list ap)
{
2007-04-11 18:14:47 +05:30
int retval = 0;
2007-04-17 15:02:18 +05:30
EINFOVN (stdout, ecolor_good);
2007-04-11 18:14:47 +05:30
return (retval);
}
static int _ewarnvn (const char *fmt, va_list ap)
{
2007-04-11 18:14:47 +05:30
int retval = 0;
2007-04-17 15:02:18 +05:30
EINFOVN (stdout, ecolor_warn);
2007-04-11 18:14:47 +05:30
return (retval);
}
static int _eerrorvn (const char *fmt, va_list ap)
{
2007-04-11 18:14:47 +05:30
int retval = 0;
2007-04-17 15:02:18 +05:30
EINFOVN (stderr, ecolor_bad);
2007-04-11 18:14:47 +05:30
return (retval);
}
int einfon (const char *fmt, ...)
{
2007-04-11 18:14:47 +05:30
int retval;
va_list ap;
2007-04-11 18:14:47 +05:30
if (! fmt || is_env ("RC_QUIET", "yes"))
return (0);
2007-04-11 18:14:47 +05:30
va_start (ap, fmt);
retval = _einfovn (fmt, ap);
2007-04-11 18:14:47 +05:30
va_end (ap);
2007-04-11 18:14:47 +05:30
return (retval);
}
hidden_def(einfon)
int ewarnn (const char *fmt, ...)
{
2007-04-11 18:14:47 +05:30
int retval;
va_list ap;
2007-04-11 18:14:47 +05:30
if (! fmt || is_env ("RC_QUIET", "yes"))
return (0);
2007-04-10 16:54:58 +05:30
2007-04-11 18:14:47 +05:30
va_start (ap, fmt);
retval = _ewarnvn (fmt, ap);
2007-04-11 18:14:47 +05:30
va_end (ap);
2007-04-11 18:14:47 +05:30
return (retval);
}
hidden_def(ewarnn)
int eerrorn (const char *fmt, ...)
{
2007-04-11 18:14:47 +05:30
int retval;
va_list ap;
2007-04-11 18:14:47 +05:30
va_start (ap, fmt);
retval = _eerrorvn (fmt, ap);
2007-04-11 18:14:47 +05:30
va_end (ap);
2007-04-11 18:14:47 +05:30
return (retval);
}
hidden_def(eerrorn)
int einfo (const char *fmt, ...)
{
2007-04-11 18:14:47 +05:30
int retval;
va_list ap;
2007-04-11 18:14:47 +05:30
if (! fmt || is_env ("RC_QUIET", "yes"))
return (0);
2007-04-11 18:14:47 +05:30
va_start (ap, fmt);
retval = _einfovn (fmt, ap);
retval += printf ("\n");
2007-04-11 18:14:47 +05:30
va_end (ap);
2007-04-11 18:14:47 +05:30
return (retval);
}
hidden_def(einfo)
int ewarn (const char *fmt, ...)
{
2007-04-11 18:14:47 +05:30
int retval;
va_list ap;
2007-04-11 18:14:47 +05:30
if (! fmt || is_env ("RC_QUIET", "yes"))
return (0);
2007-04-11 18:14:47 +05:30
va_start (ap, fmt);
elog (LOG_WARNING, fmt, ap);
retval = _ewarnvn (fmt, ap);
retval += printf ("\n");
2007-04-11 18:14:47 +05:30
va_end (ap);
2007-04-11 18:14:47 +05:30
return (retval);
}
hidden_def(ewarn)
void ewarnx (const char *fmt, ...)
{
2007-04-11 18:14:47 +05:30
int retval;
va_list ap;
eclose ();
2007-04-11 18:14:47 +05:30
if (fmt && ! is_env ("RC_QUIET", "yes")) {
va_start (ap, fmt);
elog (LOG_WARNING, fmt, ap);
retval = _ewarnvn (fmt, ap);
va_end (ap);
retval += printf ("\n");
}
exit (EXIT_FAILURE);
}
hidden_def(ewarnx)
int eerror (const char *fmt, ...)
{
2007-04-11 18:14:47 +05:30
int retval;
va_list ap;
2007-04-11 18:14:47 +05:30
if (! fmt)
return (0);
2007-04-11 18:14:47 +05:30
va_start (ap, fmt);
elog (LOG_ERR, fmt, ap);
retval = _eerrorvn (fmt, ap);
va_end (ap);
retval += fprintf (stderr, "\n");
eflush ();
2007-04-11 18:14:47 +05:30
return (retval);
}
hidden_def(eerror)
void eerrorx (const char *fmt, ...)
{
2007-04-11 18:14:47 +05:30
va_list ap;
eclose ();
2007-04-11 18:14:47 +05:30
if (fmt) {
va_start (ap, fmt);
elog (LOG_ERR, fmt, ap);
_eerrorvn (fmt, ap);
va_end (ap);
printf ("\n");
}
2007-04-11 18:14:47 +05:30
exit (EXIT_FAILURE);
}
hidden_def(eerrorx)
int ebegin (const char *fmt, ...)
{
2007-04-11 18:14:47 +05:30
int retval;
va_list ap;
2007-04-11 18:14:47 +05:30
if (! fmt || is_env ("RC_QUIET", "yes"))
return (0);
2007-04-11 18:14:47 +05:30
va_start (ap, fmt);
retval = _einfovn (fmt, ap);
va_end (ap);
retval += printf (" ...");
if (colour_terminal ())
retval += printf ("\n");
2007-04-11 18:14:47 +05:30
return (retval);
}
hidden_def(ebegin)
static void _eend (int col, einfo_color_t color, const char *msg)
{
2007-04-11 18:14:47 +05:30
FILE *fp = stdout;
int i;
int cols;
if (! msg)
return;
2007-04-17 15:02:18 +05:30
if (color == ecolor_bad)
2007-04-11 18:14:47 +05:30
fp = stderr;
cols = get_term_columns () - (strlen (msg) + 6);
if (cols > 0 && colour_terminal ()) {
fprintf (fp, "\033[A\033[%dC %s[ %s%s %s]%s\n", cols,
2007-04-17 15:02:18 +05:30
ecolor (ecolor_bracket), ecolor (color), msg,
ecolor (ecolor_bracket), ecolor (ecolor_normal));
2007-04-11 18:14:47 +05:30
} else {
for (i = -1; i < cols - col; i++)
fprintf (fp, " ");
fprintf (fp, "[ %s ]\n", msg);
}
}
static int _do_eend (const char *cmd, int retval, const char *fmt, va_list ap)
{
2007-04-11 18:14:47 +05:30
int col = 0;
FILE *fp;
va_list apc;
if (fmt && retval != 0) {
va_copy (apc, ap);
if (strcmp (cmd, "ewend") == 0) {
col = _ewarnvn (fmt, apc);
fp = stdout;
} else {
col = _eerrorvn (fmt, apc);
fp = stderr;
}
va_end (apc);
if (colour_terminal ())
fprintf (fp, "\n");
}
2007-04-17 15:02:18 +05:30
_eend (col,
retval == 0 ? ecolor_good : ecolor_bad,
retval == 0 ? OK : NOT_OK);
2007-04-11 18:14:47 +05:30
return (retval);
}
int eend (int retval, const char *fmt, ...)
{
2007-04-11 18:14:47 +05:30
va_list ap;
2007-04-11 18:14:47 +05:30
if (is_env ("RC_QUIET", "yes"))
return (retval);
2007-04-11 18:14:47 +05:30
va_start (ap, fmt);
_do_eend ("eend", retval, fmt, ap);
va_end (ap);
2007-04-11 18:14:47 +05:30
return (retval);
}
hidden_def(eend)
2007-04-10 16:54:58 +05:30
int ewend (int retval, const char *fmt, ...)
{
2007-04-11 18:14:47 +05:30
va_list ap;
2007-04-11 18:14:47 +05:30
if (is_env ("RC_QUIET", "yes"))
return (retval);
2007-04-11 18:14:47 +05:30
va_start (ap, fmt);
_do_eend ("ewend", retval, fmt, ap);
va_end (ap);
2007-04-11 18:14:47 +05:30
return (retval);
}
hidden_def(ewend)
void ebracket (int col, einfo_color_t color, const char *msg)
{
2007-04-11 18:14:47 +05:30
_eend (col, color, msg);
}
hidden_def(ebracket)
void eindent (void)
{
2007-04-11 18:14:47 +05:30
char *env = getenv ("RC_EINDENT");
int amount = 0;
char num[10];
2007-04-11 18:14:47 +05:30
if (env) {
errno = 0;
amount = strtol (env, NULL, 0);
if (errno != 0)
amount = 0;
}
2007-04-11 18:14:47 +05:30
amount += INDENT_WIDTH;
if (amount > INDENT_MAX)
amount = INDENT_MAX;
2007-04-11 18:14:47 +05:30
snprintf (num, 10, "%08d", amount);
setenv ("RC_EINDENT", num, 1);
}
hidden_def(eindent)
void eoutdent (void)
{
2007-04-11 18:14:47 +05:30
char *env = getenv ("RC_EINDENT");
int amount = 0;
char num[10];
2007-04-11 18:14:47 +05:30
if (! env)
return;
2007-04-10 16:54:58 +05:30
2007-04-11 18:14:47 +05:30
errno = 0;
amount = strtol (env, NULL, 0);
if (errno != 0)
amount = 0;
else
amount -= INDENT_WIDTH;
2007-04-11 18:14:47 +05:30
if (amount <= 0)
unsetenv ("RC_EINDENT");
else {
snprintf (num, 10, "%08d", amount);
setenv ("RC_EINDENT", num, 1);
}
}
hidden_def(eoutdent)
int einfovn (const char *fmt, ...)
{
2007-04-11 18:14:47 +05:30
int retval;
va_list ap;
2007-04-11 18:14:47 +05:30
CHECK_VERBOSE;
2007-04-11 18:14:47 +05:30
if (! fmt)
return (0);
2007-04-11 18:14:47 +05:30
va_start (ap, fmt);
retval = _einfovn (fmt, ap);
2007-04-11 18:14:47 +05:30
va_end (ap);
2007-04-11 18:14:47 +05:30
return (retval);
}
hidden_def(einfovn)
int ewarnvn (const char *fmt, ...)
{
2007-04-11 18:14:47 +05:30
int retval;
va_list ap;
2007-04-11 18:14:47 +05:30
CHECK_VERBOSE;
2007-04-11 18:14:47 +05:30
if (! fmt)
return (0);
2007-04-10 16:54:58 +05:30
2007-04-11 18:14:47 +05:30
va_start (ap, fmt);
retval = _ewarnvn (fmt, ap);
2007-04-11 18:14:47 +05:30
va_end (ap);
2007-04-11 18:14:47 +05:30
return (retval);
}
hidden_def(ewarnvn)
int einfov (const char *fmt, ...)
{
2007-04-11 18:14:47 +05:30
int retval;
va_list ap;
2007-04-11 18:14:47 +05:30
CHECK_VERBOSE;
2007-04-11 18:14:47 +05:30
if (! fmt)
return (0);
2007-04-11 18:14:47 +05:30
va_start (ap, fmt);
retval = _einfovn (fmt, ap);
retval += printf ("\n");
2007-04-11 18:14:47 +05:30
va_end (ap);
2007-04-11 18:14:47 +05:30
return (retval);
}
hidden_def(einfov)
int ewarnv (const char *fmt, ...)
{
2007-04-11 18:14:47 +05:30
int retval;
va_list ap;
2007-04-11 18:14:47 +05:30
CHECK_VERBOSE;
2007-04-11 18:14:47 +05:30
if (! fmt)
return (0);
2007-04-11 18:14:47 +05:30
va_start (ap, fmt);
retval = _ewarnvn (fmt, ap);
retval += printf ("\n");
2007-04-11 18:14:47 +05:30
va_end (ap);
2007-04-11 18:14:47 +05:30
return (retval);
}
hidden_def(ewarnv)
int ebeginv (const char *fmt, ...)
{
2007-04-11 18:14:47 +05:30
int retval;
va_list ap;
2007-04-11 18:14:47 +05:30
CHECK_VERBOSE;
2007-04-11 18:14:47 +05:30
if (! fmt)
return (0);
2007-04-11 18:14:47 +05:30
va_start (ap, fmt);
retval = _einfovn (fmt, ap);
retval += printf (" ...");
if (colour_terminal ())
retval += printf ("\n");
2007-04-11 18:14:47 +05:30
va_end (ap);
2007-04-11 18:14:47 +05:30
return (retval);
}
hidden_def(ebeginv)
int eendv (int retval, const char *fmt, ...)
{
2007-04-11 18:14:47 +05:30
va_list ap;
2007-04-11 18:14:47 +05:30
CHECK_VERBOSE;
2007-04-11 18:14:47 +05:30
va_start (ap, fmt);
_do_eend ("eendv", retval, fmt, ap);
va_end (ap);
2007-04-11 18:14:47 +05:30
return (retval);
}
hidden_def(eendv)
int ewendv (int retval, const char *fmt, ...)
{
2007-04-11 18:14:47 +05:30
va_list ap;
2007-04-11 18:14:47 +05:30
CHECK_VERBOSE;
2007-04-11 18:14:47 +05:30
va_start (ap, fmt);
_do_eend ("ewendv", retval, fmt, ap);
va_end (ap);
2007-04-11 18:14:47 +05:30
return (retval);
}
hidden_def(ewendv)
void eindentv (void)
{
2007-04-11 18:14:47 +05:30
if (is_env ("RC_VERBOSE", "yes"))
eindent ();
}
hidden_def(eindentv)
void eoutdentv (void)
{
2007-04-11 18:14:47 +05:30
if (is_env ("RC_VERBOSE", "yes"))
eoutdent ();
}
hidden_def(eoutdentv)