lsusb, ps: style: put main at bottom

This commit is contained in:
Hiltjo Posthuma 2015-03-08 13:08:32 +01:00 committed by sin
parent 54b84ee3bd
commit d594d3aa53
2 changed files with 55 additions and 57 deletions

38
lsusb.c
View File

@ -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;
}

74
ps.c
View File

@ -27,43 +27,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)
{
@ -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;
}