#define AR_OPT_INSERT 0x40
int ar_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
-int ar_main(int argc, char **argv)
+int ar_main(int argc UNUSED_PARAM, char **argv)
{
static const char msg_unsupported_err[] ALIGN1 =
"archive %s is not supported";
/* Prepend '-' to the first argument if required */
opt_complementary = "--:p:t:x:-1:p--tx:t--px:x--pt";
opt = getopt32(argv, "ptxovcr");
+ argv += optind;
if (opt & AR_CTX_PRINT) {
archive_handle->action_data = data_extract_to_stdout;
archive_handle->src_fd = xopen(argv[optind++], O_RDONLY);
- while (optind < argc) {
+ while (*argv) {
archive_handle->filter = filter_accept_list;
- llist_add_to(&(archive_handle->accept), argv[optind++]);
+ llist_add_to(&archive_handle->accept, *argv++);
}
unpack_ar_archive(archive_handle);
}
argv += optind;
//argc -= optind;
- if (!argv[0]) bb_show_usage();
+ if (!argv[0]) {
+ bb_show_usage();
+ }
while (*argv) {
rpm_fd = xopen(*argv++, O_RDONLY);
#define HEAD_SEP 2 /* spaces between day headings */
int cal_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
-int cal_main(int argc, char **argv)
+int cal_main(int argc UNUSED_PARAM, char **argv)
{
struct tm *local_time;
struct tm zero_tm;
option_mask32 &= 1;
month = 0;
argv += optind;
- argc -= optind;
- if (argc > 2) {
- bb_show_usage();
- }
-
- if (!argc) {
+ if (!argv[0]) {
time(&now);
local_time = localtime(&now);
year = local_time->tm_year + 1900;
month = local_time->tm_mon + 1;
}
} else {
- if (argc == 2) {
+ if (argv[1]) {
+ if (argv[2]) {
+ bb_show_usage();
+ }
month = xatou_range(*argv++, 1, 12);
}
year = xatou_range(*argv, 1, 9999);
/* This is a NOFORK applet. Be very careful! */
int hostid_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
-int hostid_main(int argc, char **argv UNUSED_PARAM)
+int hostid_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
{
- if (argc > 1) {
+ if (argv[1]) {
bb_show_usage();
}
/* This is a NOFORK applet. Be very careful! */
int logname_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
-int logname_main(int argc, char **argv UNUSED_PARAM)
+int logname_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
{
char buf[64];
- if (argc > 1) {
+ if (argv[1]) {
bb_show_usage();
}
xfunc_error_retval = 127;
- if (!argv[1]) bb_show_usage();
+ if (!argv[1]) {
+ bb_show_usage();
+ }
/* If stdin is a tty, detach from it. */
if (isatty(STDIN_FILENO)) {
};
int uuencode_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
-int uuencode_main(int argc, char **argv)
+int uuencode_main(int argc UNUSED_PARAM, char **argv)
{
struct stat stat_buf;
int src_fd = STDIN_FILENO;
tbl = bb_uuenc_tbl_base64;
}
argv += optind;
- if (argc == optind + 2) {
+ if (argv[1]) {
src_fd = xopen(*argv, O_RDONLY);
fstat(src_fd, &stat_buf);
mode = stat_buf.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
/* This is a NOFORK applet. Be very careful! */
int whoami_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
-int whoami_main(int argc, char **argv UNUSED_PARAM)
+int whoami_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
{
- if (argc > 1)
+ if (argv[1])
bb_show_usage();
/* Will complain and die if username not found */
int find_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
-int find_main(int argc, char **argv)
+int find_main(int argc UNUSED_PARAM, char **argv)
{
static const char options[] ALIGN1 =
"-follow\0"
INIT_G();
- for (firstopt = 1; firstopt < argc; firstopt++) {
+ for (firstopt = 1; argv[firstopt]; firstopt++) {
if (argv[firstopt][0] == '-')
break;
if (ENABLE_FEATURE_FIND_NOT && LONE_CHAR(argv[firstopt], '!'))
}
int grep_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
-int grep_main(int argc, char **argv)
+int grep_main(int argc UNUSED_PARAM, char **argv)
{
FILE *file;
int matched;
}
argv += optind;
- argc -= optind;
/* if we didn't get a pattern from -e and no command file was specified,
* first parameter should be the pattern. no pattern, no worky */
bb_show_usage();
pattern = new_grep_list_data(*argv++, 0);
llist_add_to(&pattern_head, pattern);
- argc--;
}
/* argv[0..(argc-1)] should be names of file to grep through. If
* there is more than one file to grep, we will print the filenames. */
- if (argc > 1)
+ if (argv[0] && argv[1])
print_filename = 1;
/* -H / -h of course override */
if (option_mask32 & OPT_H)
* stdin. Otherwise, we grep through all the files specified. */
matched = 0;
do {
- cur_file = *argv++;
+ cur_file = *argv;
file = stdin;
if (!cur_file || LONE_DASH(cur_file)) {
cur_file = "(standard input)";
matched += grep_file(file);
fclose_if_not_stdin(file);
grep_done: ;
- } while (--argc > 0);
+ } while (*argv && *++argv);
/* destroy all the elments in the pattern list */
if (ENABLE_FEATURE_CLEAN_UP) {
#endif
int mesg_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
-int mesg_main(int argc, char **argv)
+int mesg_main(int argc UNUSED_PARAM, char **argv)
{
struct stat sb;
const char *tty;
char c = 0;
- if (--argc == 0
- || (argc == 1 && ((c = **++argv) == 'y' || c == 'n'))
+ argv++;
+
+ if (!argv[0]
+ || (!argv[1] && ((c = argv[0][0]) == 'y' || c == 'n'))
) {
tty = xmalloc_ttyname(STDERR_FILENO);
if (tty == NULL) {
tty = "ttyname";
} else if (stat(tty, &sb) == 0) {
mode_t m;
- if (argc == 0) {
+ if (c == 0) {
puts((sb.st_mode & (S_IWGRP|S_IWOTH)) ? "is y" : "is n");
return EXIT_SUCCESS;
}
#endif
int last_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
-int last_main(int argc, char **argv UNUSED_PARAM)
+int last_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
{
struct utmp ut;
int n, file = STDIN_FILENO;
TYPE_OLD_TIME /* OLD_TIME, 4 */
};
- if (argc > 1) {
+ if (argv[1]) {
bb_show_usage();
}
file = xopen(bb_path_wtmp_file, O_RDONLY);
#include "libbb.h"
int readahead_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
-int readahead_main(int argc, char **argv)
+int readahead_main(int argc UNUSED_PARAM, char **argv)
{
int retval = EXIT_SUCCESS;
- if (argc == 1) bb_show_usage();
+ if (!argv[1]) {
+ bb_show_usage();
+ }
while (*++argv) {
int fd = open_or_warn(*argv, O_RDONLY);
#include "libbb.h"
int ttysize_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
-int ttysize_main(int argc, char **argv)
+int ttysize_main(int argc UNUSED_PARAM, char **argv)
{
unsigned w, h;
struct winsize wsz;
h = wsz.ws_row;
}
- if (argc == 1) {
+ if (!argv[1]) {
printf("%u %u", w, h);
} else {
const char *fmt, *arg;
* Our main function.
*/
int ifconfig_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
-int ifconfig_main(int argc, char **argv)
+int ifconfig_main(int argc UNUSED_PARAM, char **argv)
{
struct ifreq ifr;
struct sockaddr_in sai;
/* skip argv[0] */
++argv;
- --argc;
#if ENABLE_FEATURE_IFCONFIG_STATUS
- if (argc > 0 && (argv[0][0] == '-' && argv[0][1] == 'a' && !argv[0][2])) {
+ if (argv[0] && (argv[0][0] == '-' && argv[0][1] == 'a' && !argv[0][2])) {
interface_opt_a = 1;
- --argc;
++argv;
}
#endif
- if (argc <= 1) {
+ if (!argv[0] || !argv[1]) { /* one or no args */
#if ENABLE_FEATURE_IFCONFIG_STATUS
- return display_interfaces(argc ? *argv : NULL);
+ return display_interfaces(argv[0] /* can be NULL */);
#else
bb_error_msg_and_die("no support for status display");
#endif
int ifupdown_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
-int ifupdown_main(int argc, char **argv)
+int ifupdown_main(int argc UNUSED_PARAM, char **argv)
{
int (*cmds)(struct interface_defn_t *);
struct interfaces_file_t *defn;
}
getopt32(argv, OPTION_STR, &interfaces);
- if (argc - optind > 0) {
+ argv += optind;
+ if (argv[0]) {
if (DO_ALL) bb_show_usage();
} else {
if (!DO_ALL) bb_show_usage();
if (DO_ALL) {
target_list = defn->autointerfaces;
} else {
- llist_add_to_end(&target_list, argv[optind]);
+ llist_add_to_end(&target_list, argv[0]);
}
/* Update the interfaces */
/* main: now we pull it all together... */
int nc_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
-int nc_main(int argc, char **argv)
+int nc_main(int argc UNUSED_PARAM, char **argv)
{
char *str_p, *str_s;
IF_NC_EXTRA(char *str_i, *str_o;)
while (*++proggie) {
if (strcmp(*proggie, "-e") == 0) {
*proggie = NULL;
- argc = proggie - argv;
proggie++;
goto e_found;
}
* main program
*/
int zcip_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
-int zcip_main(int argc, char **argv)
+int zcip_main(int argc UNUSED_PARAM, char **argv)
{
int state;
char *r_opt;
bb_error_msg_and_die("invalid link address");
}
}
- argc -= optind;
argv += optind - 1;
/* Now: argv[0]:junk argv[1]:intf argv[2]:script argv[3]:NULL */
#include "libbb.h"
int free_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
-int free_main(int argc, char **argv)
+int free_main(int argc UNUSED_PARAM, char **argv)
{
struct sysinfo info;
sysinfo(&info);
info.bufferram*=info.mem_unit;
}
- if (argc > 1 && *argv[1] == '-')
+ if (argv[1] && argv[1][0] == '-')
bb_show_usage();
printf("%6s%13s%13s%13s%13s%13s\n", "", "total", "used", "free",
};
int nmeter_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
-int nmeter_main(int argc, char **argv)
+int nmeter_main(int argc UNUSED_PARAM, char **argv)
{
char buf[32];
s_stat *first = NULL;
xchdir("/proc");
- if (argc != 2)
+ if (!argv[1])
bb_show_usage();
if (open_read_close("version", buf, sizeof(buf)-1) > 0) {
#include "libbb.h"
int load_policy_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
-int load_policy_main(int argc, char **argv UNUSED_PARAM)
+int load_policy_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
{
int rc;
- if (argc != 1) {
+ if (argv[1]) {
bb_show_usage();
}
};
int setenforce_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
-int setenforce_main(int argc, char **argv)
+int setenforce_main(int argc UNUSED_PARAM, char **argv)
{
int i, rc;
- if (argc != 2)
+ if (!argv[1] || argv[2])
bb_show_usage();
selinux_or_die();
}
int setfiles_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
-int setfiles_main(int argc, char **argv)
+int setfiles_main(int argc UNUSED_PARAM, char **argv)
{
struct stat sb;
int rc, i = 0;
IF_FEATURE_SETFILES_CHECK_OPTION(&policyfile,)
&verbose);
}
+ argv += optind;
#if ENABLE_FEATURE_SETFILES_CHECK_OPTION
if ((applet_name[0] == 's') && (flags & OPT_c)) {
we can support either checking against the active policy or
checking against a binary policy file. */
set_matchpathcon_canoncon(&canoncon);
- if (argc == 1)
+ if (!argv[0])
bb_show_usage();
- if (stat(argv[optind], &sb) < 0) {
- bb_simple_perror_msg_and_die(argv[optind]);
- }
+ xstat(argv[0], &sb);
if (!S_ISREG(sb.st_mode)) {
- bb_error_msg_and_die("spec file %s is not a regular file", argv[optind]);
+ bb_error_msg_and_die("spec file %s is not a regular file", argv[0]);
}
/* Load the file contexts configuration and check it. */
- rc = matchpathcon_init(argv[optind]);
+ rc = matchpathcon_init(argv[0]);
if (rc < 0) {
- bb_simple_perror_msg_and_die(argv[optind]);
+ bb_simple_perror_msg_and_die(argv[0]);
}
-
- optind++;
-
if (nerr)
exit(EXIT_FAILURE);
+ argv++;
}
if (input_filename) {
if (ENABLE_FEATURE_CLEAN_UP)
fclose_if_not_stdin(f);
} else {
- if (optind >= argc)
+ if (!argv[0])
bb_show_usage();
- for (i = optind; i < argc; i++) {
+ for (i = 0; argv[i]; i++) {
errors |= process_one(argv[i]);
}
}
}
int bbsh_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
-int bbsh_main(int argc, char **argv)
+int bbsh_main(int argc UNUSED_PARAM, char **argv)
{
char *command=NULL;
FILE *f;
#define strbuf bb_common_bufsiz1
int logger_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
-int logger_main(int argc, char **argv)
+int logger_main(int argc UNUSED_PARAM, char **argv)
{
char *str_p, *str_t;
int opt;
if (opt & 0x1) /* -p */
i = pencode(str_p);
- argc -= optind;
argv += optind;
- if (!argc) {
+ if (!argv[0]) {
while (fgets(strbuf, COMMON_BUFSIZE, stdin)) {
if (strbuf[0]
&& NOT_LONE_CHAR(strbuf, '\n')
}
argv += optind;
+ argc -= optind;
// goto configuration directory
xchdir(opt_conf);
// evdev files given, use evdev interface
// open event devices
- pfd = xzalloc(sizeof(*pfd) * (argc - optind));
+ pfd = xzalloc(sizeof(*pfd) * argc);
nfd = 0;
while (*argv) {
pfd[nfd].fd = open_or_warn(*argv++, O_RDONLY | O_NONBLOCK);