volname: new applet
[oweals/busybox.git] / miscutils / runlevel.c
index a042a7012165401c5363f61443c5e580ce25c228..6e10d9cbb130c2485e04843818ca7108b0a49cce 100644 (file)
@@ -9,35 +9,35 @@
  *
  * Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
  *
- * initially busyboxified by Bernhard Fischer
+ * initially busyboxified by Bernhard Reutner-Fischer
  */
 
-#include "busybox.h"
-#include <stdio.h>
 #include <utmp.h>
-#include <time.h>
-#include <stdlib.h>
+#include "libbb.h"
 
-int runlevel_main(int argc, char *argv[])
+int runlevel_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
+int runlevel_main(int argc, char **argv)
 {
-  struct utmp *ut;
-  char prev;
+       struct utmp *ut;
+       char prev;
 
-  if (argc > 1) utmpname(argv[1]);
+       if (argc > 1) utmpname(argv[1]);
 
-  setutent();
-  while ((ut = getutent()) != NULL) {
-       if (ut->ut_type == RUN_LVL) {
-               prev = ut->ut_pid / 256;
-               if (prev == 0) prev = 'N';
-               printf("%c %c\n", prev, ut->ut_pid % 256);
-               endutent();
-               return (0);
+       setutent();
+       while ((ut = getutent()) != NULL) {
+               if (ut->ut_type == RUN_LVL) {
+                       prev = ut->ut_pid / 256;
+                       if (prev == 0) prev = 'N';
+                       printf("%c %c\n", prev, ut->ut_pid % 256);
+                       if (ENABLE_FEATURE_CLEAN_UP)
+                               endutent();
+                       return 0;
+               }
        }
-  }
 
-  printf("unknown\n");
-  endutent();
-  return (1);
-}
+       puts("unknown");
 
+       if (ENABLE_FEATURE_CLEAN_UP)
+               endutent();
+       return 1;
+}