[hackers] [ubase] lsusb, ps: style: put main at bottom || Hiltjo Posthuma
commit d594d3aa53bfc6f92ef84383ebbe14fd10806d6c
Author: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
Date: Sun Mar 8 13:08:32 2015 +0100
lsusb, ps: style: put main at bottom
diff --git a/lsusb.c b/lsusb.c
index 1667298..486eae6 100644
--- a/lsusb.c
+++ b/lsusb.c
_AT_@ -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)
{
_AT_@ -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
index eca6196..114983b 100644
--- a/ps.c
+++ b/ps.c
_AT_@ -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;
_AT_@ -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;
+}
Received on Wed Mar 11 2015 - 16:18:17 CET
This archive was generated by hypermail 2.3.0
: Wed Mar 11 2015 - 16:24:09 CET