/[baselayout]/trunk/src/rc-status.c
Gentoo

Diff of /trunk/src/rc-status.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 3037 Revision 3038
16#include "rc.h" 16#include "rc.h"
17#include "rc-misc.h" 17#include "rc-misc.h"
18#include "strlist.h" 18#include "strlist.h"
19 19
20#define APPLET "rc-status" 20#define APPLET "rc-status"
21
22static char const *types[] = { "ineed", "iuse", "iafter", NULL };
21 23
22static void print_level (char *level) 24static void print_level (char *level)
23{ 25{
24 printf ("Runlevel: %s%s%s\n", 26 printf ("Runlevel: %s%s%s\n",
25 ecolor (ECOLOR_HILITE), 27 ecolor (ECOLOR_HILITE),
79}; 81};
80#include "_usage.c" 82#include "_usage.c"
81 83
82int rc_status (int argc, char **argv) 84int rc_status (int argc, char **argv)
83{ 85{
86 rc_depinfo_t *deptree = NULL;
84 char **levels = NULL; 87 char **levels = NULL;
85 char **services = NULL; 88 char **services = NULL;
89 char **ordered = NULL;
86 char *level; 90 char *level;
87 char *service; 91 char *service;
88 int opt; 92 int opt;
89 int i; 93 int i;
90 int j; 94 int j;
133 level = rc_runlevel_get (); 137 level = rc_runlevel_get ();
134 rc_strlist_add (&levels, level); 138 rc_strlist_add (&levels, level);
135 free (level); 139 free (level);
136 } 140 }
137 141
142 /* Output the services in the order in which they would start */
143 deptree = rc_deptree_load ();
138 STRLIST_FOREACH (levels, level, i) { 144 STRLIST_FOREACH (levels, level, i) {
139 print_level (level); 145 print_level (level);
140 services = rc_services_in_runlevel (level); 146 services = rc_services_in_runlevel (level);
147 if (deptree) {
148 ordered = rc_deptree_depends (deptree, (char **) types, services,
149 level, RC_DEP_STRICT | RC_DEP_START);
150 rc_strlist_free (services);
151 services = ordered;
152 ordered = NULL;
153 }
141 STRLIST_FOREACH (services, service, j) 154 STRLIST_FOREACH (services, service, j)
155 if (rc_service_in_runlevel (service, level))
142 print_service (service); 156 print_service (service);
143 rc_strlist_free (services); 157 rc_strlist_free (services);
144 } 158 }
145 159
146 rc_strlist_free (levels); 160 rc_strlist_free (levels);
161 rc_deptree_free (deptree);
147 162
148 return (EXIT_SUCCESS); 163 return (EXIT_SUCCESS);
149} 164}

Legend:
Removed from v.3037  
changed lines
  Added in v.3038

  ViewVC Help
Powered by ViewVC 1.1.20