summaryrefslogtreecommitdiff
path: root/miscutils
diff options
context:
space:
mode:
authorErik Andersen2000-02-08 19:58:47 +0000
committerErik Andersen2000-02-08 19:58:47 +0000
commite49d5ecbbe51718fa925b6890a735e5937cc2aa2 (patch)
treec90bda10731ad9333ce3b404f993354c9fc104b8 /miscutils
parentc0bf817bbc5c7867fbe8fb76d5c39f8ee802692f (diff)
downloadbusybox-e49d5ecbbe51718fa925b6890a735e5937cc2aa2.zip
busybox-e49d5ecbbe51718fa925b6890a735e5937cc2aa2.tar.gz
Some formatting updates (ran the code through indent)
-Erik
Diffstat (limited to 'miscutils')
-rw-r--r--miscutils/dutmp.c62
-rw-r--r--miscutils/makedevs.c83
-rw-r--r--miscutils/mt.c122
-rw-r--r--miscutils/update.c18
4 files changed, 146 insertions, 139 deletions
diff --git a/miscutils/dutmp.c b/miscutils/dutmp.c
index a9e879d..45eab8a 100644
--- a/miscutils/dutmp.c
+++ b/miscutils/dutmp.c
@@ -1,3 +1,4 @@
+/* vi: set sw=4 ts=4: */
/*
* public domain -- Dave 'Kill a Cop' Cinege <dcinege@psychosis.com>
*
@@ -15,37 +16,38 @@
#include <utmp.h>
static const char dutmp_usage[] = "dutmp\n"
- "\n"
- "\tDump file or stdin utmp file format to stdout, pipe delimited.\n"
- "\tdutmp /var/run/utmp\n";
+ "\n"
-extern int dutmp_main (int argc, char **argv)
+ "\tDump file or stdin utmp file format to stdout, pipe delimited.\n"
+ "\tdutmp /var/run/utmp\n";
+
+extern int dutmp_main(int argc, char **argv)
{
- FILE *f = stdin;
- struct utmp ut;
-
- if ((argc < 2) || (**(argv + 1) == '-')) {
- usage( dutmp_usage);
- }
-
- if ( **(++argv) == 0 ) {
- f = fopen (*(++argv), "r");
- if (f < 0 ) {
- perror (*argv);
- exit (FALSE);
- }
- }
-
- while (fread (&ut, 1, sizeof (struct utmp), f)) {
- // printf("%d:%d:%s:%s:%s:%s:%d:%d:%ld:%ld:%ld:%x\n",
- printf ("%d|%d|%s|%s|%s|%s|%d|%d|%ld|%ld|%ld|%x\n",
- ut.ut_type, ut.ut_pid, ut.ut_line,
- ut.ut_id, ut.ut_user, ut.ut_host,
- ut.ut_exit.e_termination, ut.ut_exit.e_exit,
- ut.ut_session,
- ut.ut_tv.tv_sec, ut.ut_tv.tv_usec, ut.ut_addr);
- }
-
- exit (TRUE);
+ FILE *f = stdin;
+ struct utmp ut;
+
+ if ((argc < 2) || (**(argv + 1) == '-')) {
+ usage(dutmp_usage);
+ }
+
+ if (**(++argv) == 0) {
+ f = fopen(*(++argv), "r");
+ if (f < 0) {
+ perror(*argv);
+ exit(FALSE);
+ }
+ }
+
+ while (fread(&ut, 1, sizeof(struct utmp), f)) {
+ // printf("%d:%d:%s:%s:%s:%s:%d:%d:%ld:%ld:%ld:%x\n",
+ printf("%d|%d|%s|%s|%s|%s|%d|%d|%ld|%ld|%ld|%x\n",
+ ut.ut_type, ut.ut_pid, ut.ut_line,
+ ut.ut_id, ut.ut_user, ut.ut_host,
+ ut.ut_exit.e_termination, ut.ut_exit.e_exit,
+ ut.ut_session,
+ ut.ut_tv.tv_sec, ut.ut_tv.tv_usec, ut.ut_addr);
+ }
+
+ exit(TRUE);
}
diff --git a/miscutils/makedevs.c b/miscutils/makedevs.c
index f7fbeb2..5948bac 100644
--- a/miscutils/makedevs.c
+++ b/miscutils/makedevs.c
@@ -1,3 +1,4 @@
+/* vi: set sw=4 ts=4: */
/*
* public domain -- Dave 'Kill a Cop' Cinege <dcinege@psychosis.com>
*
@@ -5,7 +6,7 @@
* Make ranges of device files quickly.
* known bugs: can't deal with alpha ranges
*/
-
+
#include "internal.h"
#include <stdio.h>
#include <stdlib.h>
@@ -15,60 +16,64 @@
#include <sys/types.h>
#include <sys/stat.h>
-static const char makedevs_usage[] =
-"makedevs 0.01 -- Create an entire range of device files\n\n"
-"\tmakedevs /dev/ttyS c 4 64 0 63 (ttyS0-ttyS63)\n"
-"\tmakedevs /dev/hda b 3 0 0 8 s (hda,hda1-hda8)\n";
+static const char makedevs_usage[] =
+ "makedevs 0.01 -- Create an entire range of device files\n\n"
+ "\tmakedevs /dev/ttyS c 4 64 0 63 (ttyS0-ttyS63)\n"
+
+ "\tmakedevs /dev/hda b 3 0 0 8 s (hda,hda1-hda8)\n";
-int
-makedevs_main(int argc, char * * argv)
+int makedevs_main(int argc, char **argv)
{
-const char *basedev = argv[1];
-const char *type = argv[2];
-int major = atoi(argv[3]);
-int Sminor = atoi(argv[4]);
-int S = atoi(argv[5]);
-int E = atoi(argv[6]);
-int sbase = argc == 8 ? 1 : 0;
+ const char *basedev = argv[1];
+ const char *type = argv[2];
+ int major = atoi(argv[3]);
+ int Sminor = atoi(argv[4]);
+ int S = atoi(argv[5]);
+ int E = atoi(argv[6]);
+ int sbase = argc == 8 ? 1 : 0;
-mode_t mode = 0;
-dev_t dev = 0;
-char devname[255];
-char buf[255];
+ mode_t mode = 0;
+ dev_t dev = 0;
+ char devname[255];
+ char buf[255];
switch (type[0]) {
- case 'c':
- mode = S_IFCHR; break;
- case 'b':
- mode = S_IFBLK; break;
- case 'f':
- mode = S_IFIFO; break;
- default:
- usage( makedevs_usage);
- }
- mode |= 0660;
-
- while ( S <= E ) {
-
+ case 'c':
+ mode = S_IFCHR;
+ break;
+ case 'b':
+ mode = S_IFBLK;
+ break;
+ case 'f':
+ mode = S_IFIFO;
+ break;
+ default:
+ usage(makedevs_usage);
+ }
+ mode |= 0660;
+
+ while (S <= E) {
+
if (type[0] != 'f')
dev = (major << 8) | Sminor;
strcpy(devname, basedev);
-
+
if (sbase == 0) {
- sprintf(buf, "%d", S);
+ sprintf(buf, "%d", S);
strcat(devname, buf);
} else {
sbase = 0;
}
-
- if (mknod (devname, mode, dev))
- printf("Failed to create: %s\n", devname);
-
- S++; Sminor++;
+
+ if (mknod(devname, mode, dev))
+ printf("Failed to create: %s\n", devname);
+
+ S++;
+ Sminor++;
}
-return 0;
+ return 0;
}
/*
diff --git a/miscutils/mt.c b/miscutils/mt.c
index 7168ef7..9791b64 100644
--- a/miscutils/mt.c
+++ b/miscutils/mt.c
@@ -1,97 +1,97 @@
+/* vi: set sw=4 ts=4: */
#include "internal.h"
#include <stdio.h>
#include <sys/mtio.h>
#include <sys/fcntl.h>
-static const char mt_usage[] = "mt [-f device] opcode value\n";
+static const char mt_usage[] = "mt [-f device] opcode value\n";
struct mt_opcodes {
- char * name;
- short value;
+ char *name;
+ short value;
};
/* missing: eod/seod, stoptions, stwrthreshold, densities */
-static const struct mt_opcodes opcodes[] = {
- { "bsf", MTBSF },
- { "bsfm", MTBSFM },
- { "bsr", MTBSR },
- { "bss", MTBSS },
- { "datacompression", MTCOMPRESSION },
- { "eom", MTEOM },
- { "erase", MTERASE },
- { "fsf", MTFSF },
- { "fsfm", MTFSFM },
- { "fsr", MTFSR },
- { "fss", MTFSS },
- { "load", MTLOAD },
- { "lock", MTLOCK },
- { "mkpart", MTMKPART },
- { "nop", MTNOP },
- { "offline",MTOFFL },
- { "rewoffline",MTOFFL },
- { "ras1", MTRAS1 },
- { "ras2", MTRAS2 },
- { "ras3", MTRAS3 },
- { "reset", MTRESET },
- { "retension", MTRETEN },
- { "rew", MTREW },
- { "seek", MTSEEK },
- { "setblk", MTSETBLK },
- { "setdensity", MTSETDENSITY },
- { "drvbuffer", MTSETDRVBUFFER },
- { "setpart", MTSETPART },
- { "tell", MTTELL },
- { "wset", MTWSM },
- { "unload", MTUNLOAD },
- { "unlock", MTUNLOCK },
- { "eof", MTWEOF },
- { "weof", MTWEOF },
- { 0, 0 }
+static const struct mt_opcodes opcodes[] = {
+ {"bsf", MTBSF},
+ {"bsfm", MTBSFM},
+ {"bsr", MTBSR},
+ {"bss", MTBSS},
+ {"datacompression", MTCOMPRESSION},
+ {"eom", MTEOM},
+ {"erase", MTERASE},
+ {"fsf", MTFSF},
+ {"fsfm", MTFSFM},
+ {"fsr", MTFSR},
+ {"fss", MTFSS},
+ {"load", MTLOAD},
+ {"lock", MTLOCK},
+ {"mkpart", MTMKPART},
+ {"nop", MTNOP},
+ {"offline", MTOFFL},
+ {"rewoffline", MTOFFL},
+ {"ras1", MTRAS1},
+ {"ras2", MTRAS2},
+ {"ras3", MTRAS3},
+ {"reset", MTRESET},
+ {"retension", MTRETEN},
+ {"rew", MTREW},
+ {"seek", MTSEEK},
+ {"setblk", MTSETBLK},
+ {"setdensity", MTSETDENSITY},
+ {"drvbuffer", MTSETDRVBUFFER},
+ {"setpart", MTSETPART},
+ {"tell", MTTELL},
+ {"wset", MTWSM},
+ {"unload", MTUNLOAD},
+ {"unlock", MTUNLOCK},
+ {"eof", MTWEOF},
+ {"weof", MTWEOF},
+ {0, 0}
};
-extern int
-mt_main(int argc, char** argv)
+extern int mt_main(int argc, char **argv)
{
- const char * file = "/dev/tape";
- const struct mt_opcodes * code = opcodes;
- struct mtop op;
- int fd;
-
- if ( strcmp(argv[1], "-f") == 0 ) {
- if ( argc < 4 ) {
- usage (mt_usage);
+ const char *file = "/dev/tape";
+ const struct mt_opcodes *code = opcodes;
+ struct mtop op;
+ int fd;
+
+ if (strcmp(argv[1], "-f") == 0) {
+ if (argc < 4) {
+ usage(mt_usage);
}
file = argv[2];
argv += 2;
argc -= 2;
}
- while ( code->name != 0 ) {
- if ( strcmp(code->name, argv[1]) == 0 )
+ while (code->name != 0) {
+ if (strcmp(code->name, argv[1]) == 0)
break;
code++;
}
- if ( code->name == 0 ) {
+ if (code->name == 0) {
fprintf(stderr, "mt: unrecognized opcode %s.\n", argv[1]);
- return( FALSE);
+ return (FALSE);
}
op.mt_op = code->value;
- if ( argc >= 3 )
- op.mt_count = atoi(argv[2]);
+ if (argc >= 3)
+ op.mt_count = atoi(argv[2]);
else
- op.mt_count = 1; /* One, not zero, right? */
+ op.mt_count = 1; /* One, not zero, right? */
- if ( (fd = open(file, O_RDONLY, 0)) < 0 ) {
+ if ((fd = open(file, O_RDONLY, 0)) < 0) {
perror(file);
- return( FALSE);
+ return (FALSE);
}
- if ( ioctl(fd, MTIOCTOP, &op) != 0 ) {
+ if (ioctl(fd, MTIOCTOP, &op) != 0) {
perror(file);
- return( FALSE);
+ return (FALSE);
}
- return( TRUE);
+ return (TRUE);
}
diff --git a/miscutils/update.c b/miscutils/update.c
index 5a7c755..fef188b 100644
--- a/miscutils/update.c
+++ b/miscutils/update.c
@@ -1,3 +1,4 @@
+/* vi: set sw=4 ts=4: */
/*
* Mini update implementation for busybox
*
@@ -27,20 +28,19 @@
#include <sys/kdaemon.h>
#else
_syscall2(int, bdflush, int, func, int, data);
-#endif /* __GLIBC__ */
+#endif /* __GLIBC__ */
-extern int
-update_main(int argc, char** argv)
+extern int update_main(int argc, char **argv)
{
/*
* Update is actually two daemons, bdflush and update.
*/
- int pid;
+ int pid;
pid = fork();
- if ( pid < 0 )
+ if (pid < 0)
return pid;
- else if ( pid == 0 ) {
+ else if (pid == 0) {
/*
* This is no longer necessary since 1.3.5x, but it will harmlessly
* exit if that is the case.
@@ -52,11 +52,11 @@ update_main(int argc, char** argv)
_exit(0);
}
pid = fork();
- if ( pid < 0 )
+ if (pid < 0)
return pid;
- else if ( pid == 0 ) {
+ else if (pid == 0) {
argv[0] = "update";
- for ( ; ; ) {
+ for (;;) {
sync();
sleep(30);
}