ubase

suckless linux base utils
git clone git://git.suckless.org/ubase
Log | Files | Refs | README | LICENSE

commit d594d3aa53bfc6f92ef84383ebbe14fd10806d6c
parent 54b84ee3bdd47e91e7eecef69e280f737e71f092
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Sun,  8 Mar 2015 13:08:32 +0100

lsusb, ps: style: put main at bottom

Diffstat:
Mlsusb.c | 38++++++++++++++++++--------------------
Mps.c | 74+++++++++++++++++++++++++++++++++++++-------------------------------------
2 files changed, 55 insertions(+), 57 deletions(-)

diff --git a/lsusb.c b/lsusb.c @@ -6,26 +6,6 @@ #include "text.h" #include "util.h" -static void lsusb(const char *file); - -static void -usage(void) -{ - eprintf("usage: %s\n", argv0); -} - -int -main(int argc, char *argv[]) -{ - ARGBEGIN { - default: - usage(); - } ARGEND; - - recurse("/sys/bus/usb/devices", lsusb); - return 0; -} - static void lsusb(const char *file) { @@ -58,3 +38,21 @@ lsusb(const char *file) free(buf); fclose(fp); } + +static void +usage(void) +{ + eprintf("usage: %s\n", argv0); +} + +int +main(int argc, char *argv[]) +{ + ARGBEGIN { + default: + usage(); + } ARGEND; + + recurse("/sys/bus/usb/devices", lsusb); + return 0; +} diff --git a/ps.c b/ps.c @@ -28,43 +28,6 @@ enum { static int flags; static void -usage(void) -{ - eprintf("usage: [-aAdef] %s\n", argv0); -} - -int -main(int argc, char *argv[]) -{ - ARGBEGIN { - case 'a': - flags |= PS_aflag; - break; - case 'A': - flags |= PS_Aflag; - break; - case 'd': - flags |= PS_dflag; - break; - case 'e': - flags |= PS_Aflag; - break; - case 'f': - flags |= PS_fflag; - break; - default: - usage(); - } ARGEND; - - if (!(flags & PS_fflag)) - printf(" PID TTY TIME CMD\n"); - else - printf("UID PID PPID C STIME TTY TIME CMD\n"); - recurse("/proc", psr); - return 0; -} - -static void psout(struct procstat *ps) { struct procstatus pstatus; @@ -178,3 +141,40 @@ psr(const char *file) return; psout(&ps); } + +static void +usage(void) +{ + eprintf("usage: [-aAdef] %s\n", argv0); +} + +int +main(int argc, char *argv[]) +{ + ARGBEGIN { + case 'a': + flags |= PS_aflag; + break; + case 'A': + flags |= PS_Aflag; + break; + case 'd': + flags |= PS_dflag; + break; + case 'e': + flags |= PS_Aflag; + break; + case 'f': + flags |= PS_fflag; + break; + default: + usage(); + } ARGEND; + + if (!(flags & PS_fflag)) + printf(" PID TTY TIME CMD\n"); + else + printf("UID PID PPID C STIME TTY TIME CMD\n"); + recurse("/proc", psr); + return 0; +}