ubase

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

commit 63ec5ddeafeb90dd36330b8469f1437db1c1ceda
parent f0f0c5f304dfda0e5c369df41088f3b1ef825190
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Sun Mar  8 13:08:32 +0100

lsusb, ps: style: put main at bottom

Diffstat:
lsusb.c | 38++++++++++++++++++--------------------
ps.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; +}