getopt_ulflags -> getopt32.
[oweals/busybox.git] / procps / ps.c
index 62571493d513e83f16af3cb56cf7ccded3a6a45a..0452a5046118106e77a8f62f275786c7c8c1e155 100644 (file)
@@ -16,14 +16,14 @@ int ps_main(int argc, char **argv)
 
 #if ENABLE_SELINUX
        int use_selinux = 0;
-       security_context_t sid=NULL;
+       security_context_t sid = NULL;
 #endif
 
 #if ENABLE_FEATURE_PS_WIDE
        int terminal_width;
        int w_count = 0;
 
-       bb_opt_complementally="-:ww";
+       opt_complementary = "-:ww";
 #else
 # define terminal_width 79
 #endif
@@ -31,11 +31,11 @@ int ps_main(int argc, char **argv)
 #if ENABLE_FEATURE_PS_WIDE || ENABLE_SELINUX
        /* handle arguments */
 #if ENABLE_FEATURE_PS_WIDE && ENABLE_SELINUX
-       i = bb_getopt_ulflags(argc, argv, "wc", &w_count);
+       i = getopt32(argc, argv, "wc", &w_count);
 #elif ENABLE_FEATURE_PS_WIDE && !ENABLE_SELINUX
-       bb_getopt_ulflags(argc, argv, "w", &w_count);
+       getopt32(argc, argv, "w", &w_count);
 #else /* !ENABLE_FEATURE_PS_WIDE && ENABLE_SELINUX */
-       i = bb_getopt_ulflags(argc, argv, "c");
+       i = getopt32(argc, argv, "c");
 #endif
 #if ENABLE_FEATURE_PS_WIDE
        /* if w is given once, GNU ps sets the width to 132,
@@ -57,41 +57,40 @@ int ps_main(int argc, char **argv)
 
 #if ENABLE_SELINUX
        if (use_selinux)
-         printf("  PID Context                          Stat Command\n");
+               puts("  PID Context                          Stat Command");
        else
 #endif
-         printf("  PID  Uid     VmSize Stat Command\n");
+               puts("  PID  Uid     VmSize Stat Command");
 
        while ((p = procps_scan(1)) != 0)  {
                char *namecmd = p->cmd;
 #if ENABLE_SELINUX
-               if (use_selinux)
-                 {
+               if (use_selinux) {
                        char sbuf[128];
                        len = sizeof(sbuf);
 
                        if (is_selinux_enabled()) {
-                         if (getpidcon(p->pid,&sid)<0)
-                           sid=NULL;
+                               if (getpidcon(p->pid,&sid) < 0)
+                                       sid = NULL;
                        }
 
                        if (sid) {
-                         /*  I assume sid initilized with NULL  */
-                         len = strlen(sid)+1;
-                         safe_strncpy(sbuf, sid, len);
-                         freecon(sid);
-                         sid=NULL;
-                       }else {
-                         safe_strncpy(sbuf, "unknown",7);
+                               /*  I assume sid initilized with NULL  */
+                               len = strlen(sid)+1;
+                               safe_strncpy(sbuf, sid, len);
+                               freecon(sid);
+                               sid = NULL;
+                       } else {
+                               safe_strncpy(sbuf, "unknown", 7);
                        }
                        len = printf("%5d %-32s %s ", p->pid, sbuf, p->state);
                }
                else
 #endif
-                 if(p->rss == 0)
-                   len = printf("%5d %-8s        %s ", p->pid, p->user, p->state);
-                 else
-                   len = printf("%5d %-8s %6ld %s ", p->pid, p->user, p->rss, p->state);
+                       if(p->rss == 0)
+                               len = printf("%5d %-8s        %s ", p->pid, p->user, p->state);
+                       else
+                               len = printf("%5d %-8s %6ld %s ", p->pid, p->user, p->rss, p->state);
 
                i = terminal_width-len;