/[baselayout]/trunk/src/einfo.h
Gentoo

Contents of /trunk/src/einfo.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2652 - (show annotations) (download) (as text)
Wed Apr 25 12:30:24 2007 UTC (7 years, 2 months ago) by uberlord
File MIME type: text/x-chdr
File size: 2846 byte(s)
    We now have an alternative to buffering stdout and stderr.
    RC_PREFIX="yes" will put the service name as a prefix to all output
    made by the service. Thanks to Ciaran McCreesh for the idea.
1 /*
2 rc.h
3 Header file for external applications to get RC information.
4 Copyright 2007 Gentoo Foundation
5 Released under the GPLv2
6 */
7
8 #ifndef __EINFO_H__
9 #define __EINFO_H__
10
11 #ifdef __GNUC__
12 # define EINFO_PRINTF(_one, _two) __attribute__ ((__format__ (__printf__, _one, _two)))
13 # define EINFO_XPRINTF(_one, _two) __attribute__ ((__noreturn__, __format__ (__printf__, _one, _two)))
14 #endif
15
16 #include <sys/types.h>
17 #include <stdbool.h>
18
19 typedef enum
20 {
21 ecolor_good,
22 ecolor_warn,
23 ecolor_bad,
24 ecolor_hilite,
25 ecolor_bracket,
26 ecolor_normal
27 } einfo_color_t;
28
29 /* We work out if the terminal supports colour or not through the use
30 of the TERM env var. We cache the reslt in a static bool, so
31 subsequent calls are very fast.
32 The n suffix means that a newline is NOT appended to the string
33 The v suffix means that we only print it when RC_VERBOSE=yes
34 NOTE We use the v suffix here so we can add veinfo for va_list
35 in the future, but veinfo is used by shell scripts as they don't
36 have the va_list concept
37 */
38 const char *ecolor (einfo_color_t);
39 int einfon (const char *fmt, ...) EINFO_PRINTF (1, 2);
40 int ewarnn (const char *fmt, ...) EINFO_PRINTF (1, 2);
41 int eerrorn (const char *fmt, ...) EINFO_PRINTF (1, 2);
42 int einfo (const char *fmt, ...) EINFO_PRINTF(1, 2);
43 int ewarn (const char *fmt, ...) EINFO_PRINTF (1, 2);
44 void ewarnx (const char *fmt, ...) EINFO_XPRINTF (1,2);
45 int eerror (const char *fmt, ...) EINFO_PRINTF (1,2);
46 void eerrorx (const char *fmt, ...) EINFO_XPRINTF (1,2);
47 int ebegin (const char *fmt, ...) EINFO_PRINTF (1, 2);
48 int eend (int retval, const char *fmt, ...) EINFO_PRINTF (2, 3);
49 int ewend (int retval, const char *fmt, ...) EINFO_PRINTF (2, 3);
50 void ebracket (int col, einfo_color_t color, const char *msg);
51 void eindent (void);
52 void eoutdent (void);
53
54 int einfovn (const char *fmt, ...) EINFO_PRINTF (1, 2);
55 int ewarnvn (const char *fmt, ...) EINFO_PRINTF (1, 2);
56 int ebeginvn (const char *fmt, ...) EINFO_PRINTF (1, 2);
57 int eendvn (int retval, const char *fmt, ...) EINFO_PRINTF (2, 3);
58 int ewendvn (int retval, const char *fmt, ...) EINFO_PRINTF (2, 3);
59 int einfov (const char *fmt, ...) EINFO_PRINTF (1, 2);
60 int ewarnv (const char *fmt, ...) EINFO_PRINTF (1, 2);
61 int ebeginv (const char *fmt, ...) EINFO_PRINTF (1, 2);
62 int eendv (int retval, const char *fmt, ...) EINFO_PRINTF (2, 3);
63 int ewendv (int retval, const char *fmt, ...) EINFO_PRINTF (2, 3);
64 void eindentv (void);
65 void eoutdentv (void);
66
67 /* Pointer to a string that is always prefixed to einfo/ewarn/error */
68 void eprefix (const char *prefix);
69
70 /* Handy utils to buffer stdout and stderr so our output is always
71 * sane when forking around.
72 * Don't depend on these being here though as we may take a different
73 * approach at a later date. */
74 void ebuffer (const char *file);
75 void eflush (void);
76 void eclose (void);
77
78 #endif

  ViewVC Help
Powered by ViewVC 1.1.20