mostly style fixes
This commit is contained in:
parent
048c93cc55
commit
9225854144
@ -56,20 +56,20 @@ typedef int (*action_fp)(const char *fileName, struct stat *statbuf, void *);
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
action_fp f;
|
action_fp f;
|
||||||
} action;
|
} action;
|
||||||
#define SACT(name, arg...) typedef struct { action a; arg; } action_##name;
|
#define ACTS(name, arg...) typedef struct { action a; arg; } action_##name;
|
||||||
#define SFUNC(name) static int func_##name(const char *fileName, struct stat *statbuf, action_##name* ap)
|
#define ACTF(name) static int func_##name(const char *fileName, struct stat *statbuf, action_##name* ap)
|
||||||
SACT(print)
|
ACTS(print)
|
||||||
SACT(name, char *pattern;)
|
ACTS(name, char *pattern;)
|
||||||
USE_FEATURE_FIND_PRINT0(SACT(print0))
|
USE_FEATURE_FIND_PRINT0(ACTS(print0))
|
||||||
USE_FEATURE_FIND_TYPE( SACT(type, int type_mask;))
|
USE_FEATURE_FIND_TYPE( ACTS(type, int type_mask;))
|
||||||
USE_FEATURE_FIND_PERM( SACT(perm, char perm_char; int perm_mask;))
|
USE_FEATURE_FIND_PERM( ACTS(perm, char perm_char; int perm_mask;))
|
||||||
USE_FEATURE_FIND_MTIME( SACT(mtime, char mtime_char; int mtime_days;))
|
USE_FEATURE_FIND_MTIME( ACTS(mtime, char mtime_char; int mtime_days;))
|
||||||
USE_FEATURE_FIND_MMIN( SACT(mmin, char mmin_char; int mmin_mins;))
|
USE_FEATURE_FIND_MMIN( ACTS(mmin, char mmin_char; int mmin_mins;))
|
||||||
USE_FEATURE_FIND_NEWER( SACT(newer, time_t newer_mtime;))
|
USE_FEATURE_FIND_NEWER( ACTS(newer, time_t newer_mtime;))
|
||||||
USE_FEATURE_FIND_INUM( SACT(inum, ino_t inode_num;))
|
USE_FEATURE_FIND_INUM( ACTS(inum, ino_t inode_num;))
|
||||||
USE_FEATURE_FIND_EXEC( SACT(exec, char **exec_argv; int *subst_count; int exec_argc;))
|
USE_FEATURE_FIND_EXEC( ACTS(exec, char **exec_argv; int *subst_count; int exec_argc;))
|
||||||
USE_DESKTOP( SACT(paren, action ***subexpr;))
|
USE_DESKTOP( ACTS(paren, action ***subexpr;))
|
||||||
USE_DESKTOP( SACT(prune))
|
USE_DESKTOP( ACTS(prune))
|
||||||
|
|
||||||
static action ***actions;
|
static action ***actions;
|
||||||
static int need_print = 1;
|
static int need_print = 1;
|
||||||
@ -131,7 +131,7 @@ static int exec_actions(action ***appp, const char *fileName, struct stat *statb
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SFUNC(name)
|
ACTF(name)
|
||||||
{
|
{
|
||||||
const char *tmp = strrchr(fileName, '/');
|
const char *tmp = strrchr(fileName, '/');
|
||||||
if (tmp == NULL)
|
if (tmp == NULL)
|
||||||
@ -141,13 +141,13 @@ SFUNC(name)
|
|||||||
return fnmatch(ap->pattern, tmp, FNM_PERIOD) == 0;
|
return fnmatch(ap->pattern, tmp, FNM_PERIOD) == 0;
|
||||||
}
|
}
|
||||||
#if ENABLE_FEATURE_FIND_TYPE
|
#if ENABLE_FEATURE_FIND_TYPE
|
||||||
SFUNC(type)
|
ACTF(type)
|
||||||
{
|
{
|
||||||
return ((statbuf->st_mode & S_IFMT) == ap->type_mask);
|
return ((statbuf->st_mode & S_IFMT) == ap->type_mask);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if ENABLE_FEATURE_FIND_PERM
|
#if ENABLE_FEATURE_FIND_PERM
|
||||||
SFUNC(perm)
|
ACTF(perm)
|
||||||
{
|
{
|
||||||
return !((isdigit(ap->perm_char) && (statbuf->st_mode & 07777) == ap->perm_mask)
|
return !((isdigit(ap->perm_char) && (statbuf->st_mode & 07777) == ap->perm_mask)
|
||||||
|| (ap->perm_char == '-' && (statbuf->st_mode & ap->perm_mask) == ap->perm_mask)
|
|| (ap->perm_char == '-' && (statbuf->st_mode & ap->perm_mask) == ap->perm_mask)
|
||||||
@ -155,7 +155,7 @@ SFUNC(perm)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if ENABLE_FEATURE_FIND_MTIME
|
#if ENABLE_FEATURE_FIND_MTIME
|
||||||
SFUNC(mtime)
|
ACTF(mtime)
|
||||||
{
|
{
|
||||||
time_t file_age = time(NULL) - statbuf->st_mtime;
|
time_t file_age = time(NULL) - statbuf->st_mtime;
|
||||||
time_t mtime_secs = ap->mtime_days * 24 * 60 * 60;
|
time_t mtime_secs = ap->mtime_days * 24 * 60 * 60;
|
||||||
@ -166,7 +166,7 @@ SFUNC(mtime)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if ENABLE_FEATURE_FIND_MMIN
|
#if ENABLE_FEATURE_FIND_MMIN
|
||||||
SFUNC(mmin)
|
ACTF(mmin)
|
||||||
{
|
{
|
||||||
time_t file_age = time(NULL) - statbuf->st_mtime;
|
time_t file_age = time(NULL) - statbuf->st_mtime;
|
||||||
time_t mmin_secs = ap->mmin_mins * 60;
|
time_t mmin_secs = ap->mmin_mins * 60;
|
||||||
@ -177,19 +177,19 @@ SFUNC(mmin)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if ENABLE_FEATURE_FIND_NEWER
|
#if ENABLE_FEATURE_FIND_NEWER
|
||||||
SFUNC(newer)
|
ACTF(newer)
|
||||||
{
|
{
|
||||||
return (ap->newer_mtime >= statbuf->st_mtime);
|
return (ap->newer_mtime >= statbuf->st_mtime);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if ENABLE_FEATURE_FIND_INUM
|
#if ENABLE_FEATURE_FIND_INUM
|
||||||
SFUNC(inum)
|
ACTF(inum)
|
||||||
{
|
{
|
||||||
return (statbuf->st_ino != ap->inode_num);
|
return (statbuf->st_ino != ap->inode_num);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if ENABLE_FEATURE_FIND_EXEC
|
#if ENABLE_FEATURE_FIND_EXEC
|
||||||
SFUNC(exec)
|
ACTF(exec)
|
||||||
{
|
{
|
||||||
int i, rc;
|
int i, rc;
|
||||||
char *argv[ap->exec_argc+1];
|
char *argv[ap->exec_argc+1];
|
||||||
@ -207,21 +207,21 @@ SFUNC(exec)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ENABLE_FEATURE_FIND_PRINT0
|
#if ENABLE_FEATURE_FIND_PRINT0
|
||||||
SFUNC(print0)
|
ACTF(print0)
|
||||||
{
|
{
|
||||||
printf("%s%c", fileName, '\0');
|
printf("%s%c", fileName, '\0');
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SFUNC(print)
|
ACTF(print)
|
||||||
{
|
{
|
||||||
puts(fileName);
|
puts(fileName);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLE_DESKTOP
|
#if ENABLE_DESKTOP
|
||||||
SFUNC(paren)
|
ACTF(paren)
|
||||||
{
|
{
|
||||||
return exec_actions(ap->subexpr, fileName, statbuf);
|
return exec_actions(ap->subexpr, fileName, statbuf);
|
||||||
}
|
}
|
||||||
@ -231,7 +231,7 @@ SFUNC(paren)
|
|||||||
* Example:
|
* Example:
|
||||||
* find dir -name 'asm-*' -prune -o -name '*.[chS]' -print
|
* find dir -name 'asm-*' -prune -o -name '*.[chS]' -print
|
||||||
*/
|
*/
|
||||||
SFUNC(prune)
|
ACTF(prune)
|
||||||
{
|
{
|
||||||
return SKIP;
|
return SKIP;
|
||||||
}
|
}
|
||||||
@ -501,6 +501,7 @@ action*** parse_params(char **argv)
|
|||||||
int find_main(int argc, char **argv)
|
int find_main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int dereference = FALSE;
|
int dereference = FALSE;
|
||||||
|
char *arg;
|
||||||
char **argp;
|
char **argp;
|
||||||
int i, firstopt, status = EXIT_SUCCESS;
|
int i, firstopt, status = EXIT_SUCCESS;
|
||||||
|
|
||||||
@ -524,10 +525,9 @@ int find_main(int argc, char **argv)
|
|||||||
// We implement: -follow, -xdev
|
// We implement: -follow, -xdev
|
||||||
|
|
||||||
/* Process options, and replace then with -a */
|
/* Process options, and replace then with -a */
|
||||||
/* (that will be ignored by recursive parser later) */
|
/* (-a will be ignored by recursive parser later) */
|
||||||
argp = &argv[firstopt];
|
argp = &argv[firstopt];
|
||||||
while (*argp) {
|
while ((arg = argp[0])) {
|
||||||
char *arg = argp[0];
|
|
||||||
if (strcmp(arg, "-follow") == 0) {
|
if (strcmp(arg, "-follow") == 0) {
|
||||||
dereference = TRUE;
|
dereference = TRUE;
|
||||||
argp[0] = "-a";
|
argp[0] = "-a";
|
||||||
|
@ -72,8 +72,7 @@ int ps_main(int argc, char **argv)
|
|||||||
safe_strncpy(sbuf, "unknown", 7);
|
safe_strncpy(sbuf, "unknown", 7);
|
||||||
}
|
}
|
||||||
len = printf("%5u %-32s %s ", (unsigned)p->pid, sbuf, p->state);
|
len = printf("%5u %-32s %s ", (unsigned)p->pid, sbuf, p->state);
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
#endif
|
#endif
|
||||||
if (p->rss == 0)
|
if (p->rss == 0)
|
||||||
len = printf("%5u %-8s %s ", (unsigned)p->pid, p->user, p->state);
|
len = printf("%5u %-8s %s ", (unsigned)p->pid, p->user, p->state);
|
||||||
|
@ -10,14 +10,7 @@
|
|||||||
|
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <sys/utsname.h>
|
#include <sys/utsname.h>
|
||||||
#include <ctype.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <syslog.h>
|
|
||||||
#include <time.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include "busybox.h"
|
#include "busybox.h"
|
||||||
|
|
||||||
/* Copied from linux/rtc.h to eliminate the kernel dependency */
|
/* Copied from linux/rtc.h to eliminate the kernel dependency */
|
||||||
@ -42,17 +35,25 @@ struct linux_rtc_time {
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static time_t read_rtc(int utc)
|
static int xopen_rtc(int flags)
|
||||||
{
|
{
|
||||||
int rtc;
|
int rtc;
|
||||||
|
rtc = open("/dev/rtc", flags);
|
||||||
|
if (rtc < 0) {
|
||||||
|
rtc = open("/dev/misc/rtc", flags);
|
||||||
|
if (rtc < 0)
|
||||||
|
bb_perror_msg_and_die("cannot access RTC");
|
||||||
|
}
|
||||||
|
return rtc;
|
||||||
|
}
|
||||||
|
|
||||||
|
static time_t read_rtc(int utc)
|
||||||
|
{
|
||||||
struct tm tm;
|
struct tm tm;
|
||||||
char *oldtz = 0;
|
char *oldtz = 0;
|
||||||
time_t t = 0;
|
time_t t = 0;
|
||||||
|
int rtc = xopen_rtc(O_RDONLY);
|
||||||
|
|
||||||
if (( rtc = open ( "/dev/rtc", O_RDONLY )) < 0 ) {
|
|
||||||
if (( rtc = open ( "/dev/misc/rtc", O_RDONLY )) < 0 )
|
|
||||||
bb_perror_msg_and_die ( "cannot access RTC" );
|
|
||||||
}
|
|
||||||
memset(&tm, 0, sizeof(struct tm));
|
memset(&tm, 0, sizeof(struct tm));
|
||||||
if (ioctl(rtc, RTC_RD_TIME, &tm) < 0 )
|
if (ioctl(rtc, RTC_RD_TIME, &tm) < 0 )
|
||||||
bb_perror_msg_and_die("cannot read time from RTC");
|
bb_perror_msg_and_die("cannot read time from RTC");
|
||||||
@ -80,13 +81,8 @@ static time_t read_rtc(int utc)
|
|||||||
|
|
||||||
static void write_rtc(time_t t, int utc)
|
static void write_rtc(time_t t, int utc)
|
||||||
{
|
{
|
||||||
int rtc;
|
|
||||||
struct tm tm;
|
struct tm tm;
|
||||||
|
int rtc = xopen_rtc(O_WRONLY);
|
||||||
if (( rtc = open ( "/dev/rtc", O_WRONLY )) < 0 ) {
|
|
||||||
if (( rtc = open ( "/dev/misc/rtc", O_WRONLY )) < 0 )
|
|
||||||
bb_perror_msg_and_die ( "cannot access RTC" );
|
|
||||||
}
|
|
||||||
|
|
||||||
tm = *(utc ? gmtime(&t) : localtime(&t));
|
tm = *(utc ? gmtime(&t) : localtime(&t));
|
||||||
tm.tm_isdst = 0;
|
tm.tm_isdst = 0;
|
||||||
@ -196,7 +192,6 @@ static const struct option hwclock_long_options[] = {
|
|||||||
};
|
};
|
||||||
applet_long_options = hwclock_long_options;
|
applet_long_options = hwclock_long_options;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
opt_complementary = "?:r--ws:w--rs:s--wr:l--u:u--l";
|
opt_complementary = "?:r--ws:w--rs:s--wr:l--u:u--l";
|
||||||
opt = getopt32(argc, argv, "lursw");
|
opt = getopt32(argc, argv, "lursw");
|
||||||
|
|
||||||
|
@ -52,10 +52,11 @@ int readprofile_main(int argc, char **argv)
|
|||||||
unsigned int *buf, total, fn_len;
|
unsigned int *buf, total, fn_len;
|
||||||
unsigned long long fn_add, next_add; /* current and next address */
|
unsigned long long fn_add, next_add; /* current and next address */
|
||||||
char fn_name[S_LEN], next_name[S_LEN]; /* current and next name */
|
char fn_name[S_LEN], next_name[S_LEN]; /* current and next name */
|
||||||
char mode[8];
|
|
||||||
int optAll=0, optInfo=0, optReset=0, optVerbose=0, optNative=0;
|
|
||||||
int optBins=0, optSub=0;
|
|
||||||
char mapline[S_LEN];
|
char mapline[S_LEN];
|
||||||
|
char mode[8];
|
||||||
|
int optAll = 0, optInfo = 0, optReset = 0;
|
||||||
|
int optVerbose = 0, optNative = 0;
|
||||||
|
int optBins = 0, optSub = 0;
|
||||||
int maplineno = 1;
|
int maplineno = 1;
|
||||||
int header_printed;
|
int header_printed;
|
||||||
|
|
||||||
@ -87,7 +88,7 @@ int readprofile_main(int argc, char **argv)
|
|||||||
|
|
||||||
fd = xopen(defaultpro, O_WRONLY);
|
fd = xopen(defaultpro, O_WRONLY);
|
||||||
|
|
||||||
if (write(fd, &multiplier, to_write) != to_write)
|
if (full_write(fd, &multiplier, to_write) != to_write)
|
||||||
bb_perror_msg_and_die("error writing %s", defaultpro);
|
bb_perror_msg_and_die("error writing %s", defaultpro);
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
|
Loading…
Reference in New Issue
Block a user