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 && isatty(fileno(stdout))) |
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; |