Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 444610 | Differences between
and this patch

Collapse All | Expand All

(-)a/src/libeinfo/einfo.h (+3 lines)
Lines 140-144 void eoutdentv(void); Link Here
140
/*! @brief Prefix each einfo line with something */
140
/*! @brief Prefix each einfo line with something */
141
void eprefix(const char * EINFO_RESTRICT);
141
void eprefix(const char * EINFO_RESTRICT);
142
142
143
/*! @brief toggles between left-side and right-sided eend output */
144
void eleft(bool);
145
143
__END_DECLS
146
__END_DECLS
144
#endif
147
#endif
(-)a/src/libeinfo/einfo.map (-1 / +1 lines)
Lines 29-35 global: Link Here
29
	eindentv;
29
	eindentv;
30
	eoutdentv;
30
	eoutdentv;
31
	eprefix;
31
	eprefix;
32
32
	eleft;
33
local:
33
local:
34
	*;
34
	*;
35
};
35
};
(-)a/src/libeinfo/libeinfo.c (-3 / +28 lines)
Lines 73-78 hidden_proto(elog) Link Here
73
hidden_proto(eoutdent)
73
hidden_proto(eoutdent)
74
hidden_proto(eoutdentv)
74
hidden_proto(eoutdentv)
75
hidden_proto(eprefix)
75
hidden_proto(eprefix)
76
hidden_proto(eleft)
76
hidden_proto(ewarn)
77
hidden_proto(ewarn)
77
hidden_proto(ewarnn)
78
hidden_proto(ewarnn)
78
hidden_proto(ewarnv)
79
hidden_proto(ewarnv)
Lines 118-123 hidden_proto(ewendv) Link Here
118
/* A pointer to a string to prefix to einfo/ewarn/eerror messages */
119
/* A pointer to a string to prefix to einfo/ewarn/eerror messages */
119
static const char *_eprefix = NULL;
120
static const char *_eprefix = NULL;
120
121
122
/* A bool for toggling left (true) and right-sided (false)  eend */
123
static bool _eleft = false;
124
121
/* Buffers and structures to hold the final colours */
125
/* Buffers and structures to hold the final colours */
122
static char ebuffer[100];
126
static char ebuffer[100];
123
struct ecolor {
127
struct ecolor {
Lines 525-530 eprefix(const char *EINFO_RESTRICT prefix) Link Here
525
}
529
}
526
hidden_def(eprefix)
530
hidden_def(eprefix)
527
531
532
void
533
eleft(bool eleft)
534
{
535
	_eleft=eleft;
536
}
537
hidden_def(eleft)
538
528
static void EINFO_PRINTF(2, 0)
539
static void EINFO_PRINTF(2, 0)
529
elogv(int level, const char *EINFO_RESTRICT fmt, va_list ap)
540
elogv(int level, const char *EINFO_RESTRICT fmt, va_list ap)
530
{
541
{
Lines 779-791 hidden_def(eerrorx) Link Here
779
int
790
int
780
ebegin(const char *EINFO_RESTRICT fmt, ...)
791
ebegin(const char *EINFO_RESTRICT fmt, ...)
781
{
792
{
782
	int retval;
793
	int retval=0;
783
	va_list ap;
794
	va_list ap;
784
795
785
	if (!fmt || is_quiet())
796
	if (!fmt || is_quiet())
786
		return 0;
797
		return 0;
787
	va_start(ap, fmt);
798
	va_start(ap, fmt);
788
	retval = _einfovn(fmt, ap);
799
	/* hardcoded for now */
800
	if (_eleft) 
801
	{
802
		char *EINFO_RESTRICT fmt2;
803
		sprintf(fmt2,"              %s",fmt);
804
		retval += _einfovn(fmt2, ap);
805
	} else {
806
		retval += _einfovn(fmt, ap);
807
	}
789
	va_end(ap);
808
	va_end(ap);
790
	retval += printf(" ...");
809
	retval += printf(" ...");
791
	if (colour_terminal(stdout))
810
	if (colour_terminal(stdout))
Lines 819-827 _eend(FILE * EINFO_RESTRICT fp, int col, ECOLOR color, const char *msg) Link Here
819
		cols--;
838
		cols--;
820
839
821
	if (cols > 0 && colour_terminal(fp)) {
840
	if (cols > 0 && colour_terminal(fp)) {
822
		fprintf(fp, "%s%s %s[%s %s %s]%s\n", up, tgoto(goto_column, 0, cols),
841
		if (_eleft) {
842
		fprintf(fp, "%s%s %s[%s %s %s]%s\n", up, tgoto(goto_column, 0, 0),
823
		    ecolor(ECOLOR_BRACKET), ecolor(color), msg,
843
		    ecolor(ECOLOR_BRACKET), ecolor(color), msg,
824
		    ecolor(ECOLOR_BRACKET), ecolor(ECOLOR_NORMAL));
844
		    ecolor(ECOLOR_BRACKET), ecolor(ECOLOR_NORMAL));
845
		} else {
846
		fprintf(fp, "%s%s %s[%s %s %s]%s\n", up, tgoto(goto_column, 0, cols),
847
                    ecolor(ECOLOR_BRACKET), ecolor(color), msg,
848
                    ecolor(ECOLOR_BRACKET), ecolor(ECOLOR_NORMAL));
849
		}
825
	} else {
850
	} else {
826
		if (col > 0)
851
		if (col > 0)
827
			for (i = 0; i < cols - col; i++)
852
			for (i = 0; i < cols - col; i++)
(-)a/src/rc/rc-status.c (-2 / +20 lines)
Lines 47-52 static RC_STRINGLIST *types; Link Here
47
static RC_STRINGLIST *levels, *services, *tmp, *alist;
47
static RC_STRINGLIST *levels, *services, *tmp, *alist;
48
static RC_STRINGLIST *sservices, *nservices, *needsme;
48
static RC_STRINGLIST *sservices, *nservices, *needsme;
49
49
50
bool left = false;
51
50
bool
52
bool
51
_rc_can_find_pids(void)
53
_rc_can_find_pids(void)
52
{
54
{
Lines 95-101 static void Link Here
95
print_service(const char *service)
97
print_service(const char *service)
96
{
98
{
97
	char status[10];
99
	char status[10];
98
	int cols =  printf(" %s", service);
100
	int cols;
101
	if (left)
102
	{
103
		/* hardcoded width, should be fixed */
104
		cols =  printf("                 %s", service);
105
	} else {
106
		cols =  printf("%s", service);
107
	}
99
	const char *c = ecolor(ECOLOR_GOOD);
108
	const char *c = ecolor(ECOLOR_GOOD);
100
	RC_SERVICE state = rc_service_state(service);
109
	RC_SERVICE state = rc_service_state(service);
101
	ECOLOR color = ECOLOR_BAD;
110
	ECOLOR color = ECOLOR_BAD;
Lines 195-201 print_stacked_services(const char *runlevel) Link Here
195
#define usagestring ""						\
204
#define usagestring ""						\
196
	"Usage: rc-status [options] <runlevel>...\n"		\
205
	"Usage: rc-status [options] <runlevel>...\n"		\
197
	"   or: rc-status [options] [-a | -c | -l | -r | -s | -u]"
206
	"   or: rc-status [options] [-a | -c | -l | -r | -s | -u]"
198
#define getoptstring "aclrsu" getoptstring_COMMON
207
#define getoptstring "xaclrsu" getoptstring_COMMON
199
static const struct option longopts[] = {
208
static const struct option longopts[] = {
200
	{"all",         0, NULL, 'a'},
209
	{"all",         0, NULL, 'a'},
201
	{"crashed",     0, NULL, 'c'},
210
	{"crashed",     0, NULL, 'c'},
Lines 203-208 static const struct option longopts[] = { Link Here
203
	{"runlevel",    0, NULL, 'r'},
212
	{"runlevel",    0, NULL, 'r'},
204
	{"servicelist", 0, NULL, 's'},
213
	{"servicelist", 0, NULL, 's'},
205
	{"unused",      0, NULL, 'u'},
214
	{"unused",      0, NULL, 'u'},
215
	{"leftaligned", 0, NULL, 'x'},
206
	longopts_COMMON
216
	longopts_COMMON
207
};
217
};
208
static const char * const longopts_help[] = {
218
static const char * const longopts_help[] = {
Lines 212-217 static const char * const longopts_help[] = { Link Here
212
	"Show the name of the current runlevel",
222
	"Show the name of the current runlevel",
213
	"Show service list",
223
	"Show service list",
214
	"Show services not assigned to any runlevel",
224
	"Show services not assigned to any runlevel",
225
	"Show output left-aligned",
215
	longopts_help_COMMON
226
	longopts_help_COMMON
216
};
227
};
217
#include "_usage.c"
228
#include "_usage.c"
Lines 229-234 rc_status(int argc, char **argv) Link Here
229
	while ((opt = getopt_long(argc, argv, getoptstring, longopts,
240
	while ((opt = getopt_long(argc, argv, getoptstring, longopts,
230
				  (int *) 0)) != -1)
241
				  (int *) 0)) != -1)
231
		switch (opt) {
242
		switch (opt) {
243
		case 'x':
244
			left = true;
245
			break;
232
		case 'a':
246
		case 'a':
233
			aflag++;
247
			aflag++;
234
			levels = rc_runlevel_list();
248
			levels = rc_runlevel_list();
Lines 277-282 rc_status(int argc, char **argv) Link Here
277
		case_RC_COMMON_GETOPT
291
		case_RC_COMMON_GETOPT
278
		}
292
		}
279
293
294
	// alignment stuff
295
	if (left)
296
		eleft(true);
297
280
	if (!levels)
298
	if (!levels)
281
		levels = rc_stringlist_new();
299
		levels = rc_stringlist_new();
282
	opt = (optind < argc) ? 0 : 1;
300
	opt = (optind < argc) ? 0 : 1;

Return to bug 444610